forked from KolibriOS/kolibrios
scc 0.5.3 b + new examples
git-svn-id: svn://kolibrios.org@721 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
c31385a3f3
commit
15f607fd64
@ -1,10 +1,9 @@
|
|||||||
##############################
|
##############################
|
||||||
# SCC (simple c compiler)
|
# SCC (simple c compiler) #
|
||||||
# port of CCOMP to KolibriOS
|
# port of CCOMP to KolibriOS #
|
||||||
#
|
##############################
|
||||||
######
|
# contact: jacekm.pl@gmail.com #
|
||||||
# contact: jacekm.pl@gmail.com
|
##############################
|
||||||
##############################
|
|
||||||
|
|
||||||
KNOWN BUGS:
|
KNOWN BUGS:
|
||||||
* only directiory /rd/1/ works
|
* only directiory /rd/1/ works
|
||||||
|
@ -14,24 +14,35 @@ include 'INTRINS.ASM'
|
|||||||
#endasm
|
#endasm
|
||||||
|
|
||||||
#include "klib.h"
|
#include "klib.h"
|
||||||
|
|
||||||
|
// CONTROLS:
|
||||||
|
#define CONTROLS 2
|
||||||
|
int control[CONTROLS];
|
||||||
|
int cont1[7] = { CheckBox,4,10,40,0x111111,0xFFFFFF,0};
|
||||||
|
int cont2[7] = { CheckBox,5,25,55,0xBBBBBB,0,0};
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{int event;
|
{
|
||||||
int button_id;
|
int event;
|
||||||
|
int button_id;
|
||||||
draw_window();
|
|
||||||
while(1)
|
control[0]=&cont1[0];
|
||||||
{
|
control[1]=&cont2[0];
|
||||||
event=get_event();
|
|
||||||
switch(event)
|
draw_window();
|
||||||
|
while(1)
|
||||||
{
|
{
|
||||||
case 1: draw_window(); break;
|
event=get_event();
|
||||||
case 2: get_button(); break;
|
switch(event)
|
||||||
case 3: button_id=get_button();
|
{
|
||||||
if(button_id==1) s_quit();
|
case 1: draw_window(); break;
|
||||||
break;
|
case 2: get_button(); break;
|
||||||
|
case 3: button_id=get_button();
|
||||||
|
eventControls(control,CONTROLS,button_id);
|
||||||
|
if(button_id==1) s_quit();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char text1[50]="THIS IS AN EXAMPLE OF C";
|
char text1[50]="THIS IS AN EXAMPLE OF C";
|
||||||
@ -39,26 +50,32 @@ char text2[50]="PROGRAM IN KOLIBRIOS";
|
|||||||
char text3[50]="";
|
char text3[50]="";
|
||||||
char text4[50]="SUCCESS";
|
char text4[50]="SUCCESS";
|
||||||
int p_text[4];
|
int p_text[4];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
draw_window()
|
draw_window()
|
||||||
{int i; /* for index */
|
{
|
||||||
int y;y=25;
|
int i; /* for index */
|
||||||
|
int y;y=25;
|
||||||
p_text[0]=&text1[0];
|
|
||||||
p_text[1]=&text2[0];
|
p_text[0]=&text1[0];
|
||||||
p_text[2]=&text3[0];
|
p_text[1]=&text2[0];
|
||||||
p_text[3]=&text4[0];
|
p_text[2]=&text3[0];
|
||||||
|
p_text[3]=&text4[0];
|
||||||
begin_draw();
|
|
||||||
|
begin_draw();
|
||||||
window(100,100,320,150,0x03ffffff,0x805080d0,0x005080d0);
|
|
||||||
label(8,8,0x10ddeeff,"Example application");
|
window(100,100,320,150,0x03ffffff,0x805080d0,0x005080d0);
|
||||||
buttonT(50,35,60,12,0x111111,1, "Click Me!", 0xFFFFFF);
|
label(8,8,0x10ddeeff,"Example application");
|
||||||
|
buttonT(50,35,60,12,0x111111,1, "Click Me!", 0xFFFFFF);
|
||||||
for(i=0;i<4;i++)
|
//checkbox(cbTest);
|
||||||
label(20,40+(y+=10),0x000000,p_text[i]);
|
|
||||||
|
renderControls(control, CONTROLS);
|
||||||
end_draw();
|
|
||||||
|
for(i=0;i<4;i++)
|
||||||
|
label(20,40+(y+=10),0x000000,p_text[i]);
|
||||||
|
|
||||||
|
end_draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
#asm
|
#asm
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
#ifndef __KLIB_H__
|
||||||
|
#define __KLIB_H__
|
||||||
|
|
||||||
/********* C library *********/
|
/********* C library *********/
|
||||||
|
|
||||||
get_event()
|
get_event()
|
||||||
@ -99,6 +102,8 @@ char *p_string; /* esp +8 */
|
|||||||
#endasm
|
#endasm
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Button + Text
|
// Button + Text
|
||||||
buttonT(x1,y1,w,h,color,id,p_string, str_color)
|
buttonT(x1,y1,w,h,color,id,p_string, str_color)
|
||||||
int x1,y1,w,h; /* esp +28 +24 +20 +16 */
|
int x1,y1,w,h; /* esp +28 +24 +20 +16 */
|
||||||
@ -111,6 +116,7 @@ int str_color;
|
|||||||
label(x1+4,y1+2,str_color,p_string);
|
label(x1+4,y1+2,str_color,p_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Button
|
||||||
button(x1,y1,w,h,color,id)
|
button(x1,y1,w,h,color,id)
|
||||||
int x1,y1,w,h; /* esp +28 +24 +20 +16 */
|
int x1,y1,w,h; /* esp +28 +24 +20 +16 */
|
||||||
int color,id; /* esp +12 +8 */
|
int color,id; /* esp +12 +8 */
|
||||||
@ -132,6 +138,75 @@ int color,id; /* esp +12 +8 */
|
|||||||
int 0x40
|
int 0x40
|
||||||
#endasm
|
#endasm
|
||||||
}
|
}
|
||||||
|
// CONTROLS:
|
||||||
|
#define CheckBox 1
|
||||||
|
|
||||||
|
/* CheckBox
|
||||||
|
array[ ]:
|
||||||
|
0 int type
|
||||||
|
1 int id
|
||||||
|
2 int x,
|
||||||
|
3 int y,
|
||||||
|
4 int color,
|
||||||
|
5 int colorText
|
||||||
|
6 int checked
|
||||||
|
*/
|
||||||
|
char cbt[2] = " ";
|
||||||
|
checkbox(cb)
|
||||||
|
int *cb;
|
||||||
|
{
|
||||||
|
if (cb[6] == 1) // cheked is set
|
||||||
|
cbt[0] = 'X';
|
||||||
|
else
|
||||||
|
cbt[0] = ' ';
|
||||||
|
|
||||||
|
buttonT(cb[2], cb[3], 12,10,cb[4],cb[1],cbt,cb[5]);
|
||||||
|
}
|
||||||
|
|
||||||
|
eventControls(control,count,id)
|
||||||
|
int* control;
|
||||||
|
int count;
|
||||||
|
int id;
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int *cont;
|
||||||
|
for (i=0; i<count; i++)
|
||||||
|
{
|
||||||
|
cont = control[i];
|
||||||
|
switch (cont[0])
|
||||||
|
{
|
||||||
|
case CheckBox:
|
||||||
|
if (cont[1]==id)
|
||||||
|
{
|
||||||
|
cont[6] = 1 - cont[6];
|
||||||
|
renderControls(control,count);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
renderControls(control, count)
|
||||||
|
int* control;
|
||||||
|
int count;
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int *cont;
|
||||||
|
|
||||||
|
for (i=0; i<count; i++)
|
||||||
|
{
|
||||||
|
cont = control[i];
|
||||||
|
switch (cont[0])
|
||||||
|
{
|
||||||
|
case CheckBox:
|
||||||
|
checkbox(cont)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
s_quit()
|
s_quit()
|
||||||
{
|
{
|
||||||
@ -139,20 +214,8 @@ s_quit()
|
|||||||
mov eax,-1
|
mov eax,-1
|
||||||
int 0x40
|
int 0x40
|
||||||
#endasm
|
#endasm
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
#endif
|
||||||
s_get_event()
|
|
||||||
s_get_key()
|
|
||||||
s_get_button()
|
|
||||||
s_begin_draw()
|
|
||||||
s_end_draw()
|
|
||||||
s_draw_window(x1,y1,w,h,c_area,c_grab,c_fram)
|
|
||||||
s_print_text(x,y,color,p_string)
|
|
||||||
s_draw_button(x1,y1,w,h,color,id)
|
|
||||||
s_quit()
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*****************************/
|
|
Loading…
Reference in New Issue
Block a user