/programs/develop/libGUI/examples/C example/interface.c |
---|
0,0 → 1,1270 |
#include "./include/kolibrisys.h" |
#include "./include/stdlib.h" |
#define Cannot_load_libGUI 100 |
#define ParendSize 44 |
#define MessageSize 16 |
#define TOTAL_NUMBERS_OF_CONTROLS 150 |
#define WINDOW_POSX 50 |
#define WINDOW_POSY 50 |
#define WINDOW_SIZEX 512 |
#define WINDOW_SIZEY 384 |
#define FONT_SIZEX 6 |
#define BOOKMARK1_POSX 0 |
#define BOOKMARK1_POSY 55 |
#define BOOKMARK1_SIZEX 210 |
#define BOOKMARK2_POSX 215 |
#define BOOKMARK2_POSY 55 |
#define SCREEN_SIZEX 1024 |
#define SCREEN_SIZEY 768 |
#define CONTROLS_NUMBER_POS 4 |
#define DISTANCE1 130 |
struct WINDOW |
{ |
int posx; |
int posy; |
int sizex; |
int sizey; |
}; |
struct HEADER |
{ |
dword ctrl_proc; |
dword *ctrl_fd; |
dword *ctrl_bk; |
dword *child_fd; |
dword *child_bk; |
dword *parend; |
dword ctrl_x; |
dword ctrl_y; |
dword ctrl_sizex; |
dword ctrl_sizey; |
dword ctrl_ID; |
}__attribute__((packed));; |
struct MESSAGE |
{ |
dword type; |
dword arg1; |
dword arg2; |
dword arg3; |
}__attribute__((packed)); |
struct ControlButton |
{ |
dword ctrl_proc; |
dword *ctrl_fd; |
dword *ctrl_bk; |
dword *child_fd; |
dword *child_bk; |
dword *parend; |
dword ctrl_x; |
dword ctrl_y; |
dword ctrl_sizex; |
dword ctrl_sizey; |
dword ctrl_ID; |
byte type; |
byte flag; |
word x; |
word y; |
word width; |
word height; |
dword image; |
word imageX; |
word imageY; |
word imageSizeX; |
word imageSizeY; |
dword transparentColor; |
dword text; |
word textX; |
word textY; |
dword textcolor; |
dword color1; |
dword color2; |
word mouseX; |
word mouseY; |
}__attribute__((packed));; |
struct ControlScroller |
{ |
dword ctrl_proc; |
dword *ctrl_fd; |
dword *ctrl_bk; |
dword *child_fd; |
dword *child_bk; |
dword *parend; |
dword ctrl_x; |
dword ctrl_y; |
dword ctrl_sizex; |
dword ctrl_sizey; |
dword ctrl_ID; |
byte type; |
word x; |
word y; |
word length; |
dword color1; |
float size; |
float pos; |
word buttons_flags; |
dword ChildButton1; |
dword ChildButton2; |
word MouseX; |
word MouseY; |
}__attribute__((packed));; |
struct ControlProgressbar |
{ |
dword ctrl_proc; |
dword *ctrl_fd; |
dword *ctrl_bk; |
dword *child_fd; |
dword *child_bk; |
dword *parend; |
dword ctrl_x; |
dword ctrl_y; |
dword ctrl_sizex; |
dword ctrl_sizey; |
dword ctrl_ID; |
byte type; |
byte flag; |
dword color1; |
dword color2; |
dword x; |
dword y; |
dword sizex; |
dword sizey; |
float progress; |
dword color3; |
}__attribute__((packed));; |
typedef struct InfoForButton |
{ |
byte type; //0 |
byte flag; //1 |
word x; //2 |
word y; //4 |
word width; //6 |
word height; //8 |
dword image; //10 |
word imageX; //14 |
word imageY; //16 |
word imageSizeX; //18 |
word imageSizeY; //20 |
dword transparentColor;//24 |
dword text; //28 |
word textX; //32 |
word textY; //34 |
dword textcolor; //36 |
dword color1; //40 |
dword color2; |
word mouseX; |
word mouseY; |
}__attribute__((packed)); |
struct InfoForScroller |
{ |
byte type; |
word x; |
word y; |
word length; |
dword color1; |
float size; |
float pos; |
word buttons_flags; |
dword ChildButton1; |
dword ChildButton2; |
word MouseX; |
word MouseY; |
}__attribute__((packed)); |
struct InfoForProgressbar |
{ |
byte type; |
byte flag; |
dword color1; |
dword color2; |
dword x; |
dword y; |
dword sizex; |
dword sizey; |
float progress; |
dword color3; |
}__attribute__((packed)); |
struct InfoForImage |
{ |
byte type; |
byte flag; |
dword color1; |
dword x; |
dword y; |
dword sizex; |
dword sizey; |
dword pointer; |
}__attribute__((packed)); |
struct InfoForText |
{ |
byte type; |
byte flag; |
dword color1; |
dword x; |
dword y; |
dword length; |
dword text; |
}__attribute__((packed)); |
struct InfoForNumber |
{ |
byte type; |
byte flag; |
dword color1; |
dword x; |
dword y; |
float number; |
dword format; |
}__attribute__((packed)); |
struct ControlImage |
{ |
dword ctrl_proc; |
dword *ctrl_fd; |
dword *ctrl_bk; |
dword *child_fd; |
dword *child_bk; |
dword *parend; |
dword ctrl_x; |
dword ctrl_y; |
dword ctrl_sizex; |
dword ctrl_sizey; |
dword ctrl_ID; |
byte type; |
byte flag; |
dword color1; |
dword x; |
dword y; |
dword sizex; |
dword sizey; |
dword pointer; |
}__attribute__((packed)); |
struct ControlText |
{ |
dword ctrl_proc; |
dword *ctrl_fd; |
dword *ctrl_bk; |
dword *child_fd; |
dword *child_bk; |
dword *parend; |
dword ctrl_x; |
dword ctrl_y; |
dword ctrl_sizex; |
dword ctrl_sizey; |
dword ctrl_ID; |
byte type; |
byte flag; |
dword color1; |
dword x; |
dword y; |
dword length; |
dword text; |
}__attribute__((packed)); |
struct ControlNumber |
{ |
dword ctrl_proc; |
dword *ctrl_fd; |
dword *ctrl_bk; |
dword *child_fd; |
dword *child_bk; |
dword *parend; |
dword ctrl_x; |
dword ctrl_y; |
dword ctrl_sizex; |
dword ctrl_sizey; |
dword ctrl_ID; |
byte type; |
byte flag; |
dword color1; |
dword x; |
dword y; |
float number; |
dword format; |
}__attribute__((packed)); |
//////////////////////////////Info for Bookmark 1/////////////////////////////// |
struct InfoForBookmark1 |
{ |
byte type; |
byte flag; |
dword x; |
dword y; |
dword sizex; |
dword sizey; |
dword color1; |
dword reserved; |
dword color2; |
dword number_lines_bookmarks; |
dword number_lines_bookmarks_in_1; |
dword number_lines_bookmarks_in_2; |
dword text_for_1; |
dword number_controls_1; |
dword type_control_10; |
dword info_for_10_control; |
dword a1,b1; |
dword a2,b2; |
dword a3,b3; |
dword a4,b4; |
dword a5,b5; |
dword a6,b6; |
dword a7,b7; |
dword a8,b8; |
dword text_for_2; |
dword number_controls_2; |
dword type_control_20; |
dword info_for_20_control; |
dword a9,b9; |
dword a10,b10; |
dword a11,b11; |
dword a12,b12; |
dword a13,b13; |
dword a14,b14; |
dword a15,b15; |
dword a16,b16; |
dword a17,b17; |
dword a18,b18; |
dword a19,b19; |
dword a20,b20; |
dword a21,b21; |
dword a22,b22; |
dword text_for_3; |
dword number_controls_3; |
dword type_control_30; |
dword info_for_30_control; |
//filler 256 |
dword a23,b23; |
dword a24,b24; |
dword a25,b25; |
dword a26,b26; |
dword a27,b27; |
dword a28,b28; |
dword a29,b29; |
dword a30,b30; |
dword a31,b31; |
dword a32,b32; |
dword a33,b33; |
dword a34,b34; |
dword a35,b35; |
dword a36,b36; |
dword a37,b37; |
dword a38,b38; |
dword a39,b39; |
dword a40,b40; |
dword a41,b41; |
dword a42,b42; |
dword a43,b43; |
dword a44,b44; |
dword a45,b45; |
dword a46,b46; |
dword a47,b47; |
dword a48,b48; |
dword a49,b49; |
dword a50,b50; |
dword a51,b51; |
dword a52,b52; |
dword a53,b53; |
dword a54,b54; |
dword text_for_4; |
dword number_controls_4; |
dword type_control_40; |
dword info_for_40_control; |
//filler 64 |
dword a55,b55; |
dword a56,b56; |
dword a57,b57; |
dword a58,b58; |
dword a59,b59; |
dword a60,b60; |
dword a61,b61; |
dword a62,b62; |
dword text_for_5; |
dword number_controls_5; |
dword type_control_50; |
dword info_for_50_control; |
}__attribute__((packed)); |
struct ControlBookmark1 |
{ |
dword ctrl_proc; |
dword *ctrl_fd; |
dword *ctrl_bk; |
dword *child_fd; |
dword *child_bk; |
dword *parend; |
dword ctrl_x; |
dword ctrl_y; |
dword ctrl_sizex; |
dword ctrl_sizey; |
dword ctrl_ID; |
byte type; |
byte flag; |
dword x; |
dword y; |
dword sizex; |
dword sizey; |
dword color1; |
dword reserved; |
dword color2; |
dword number_lines_bookmarks; |
dword number_lines_bookmarks_in_1; |
dword number_lines_bookmarks_in_2; |
dword text_for_1; |
dword number_controls_1; |
dword type_control_10; |
dword info_for_10_control; |
//filler 64 |
dword a1,b1; |
dword a2,b2; |
dword a3,b3; |
dword a4,b4; |
dword a5,b5; |
dword a6,b6; |
dword a7,b7; |
dword a8,b8; |
dword text_for_2; |
dword number_controls_2; |
dword type_control_20; |
dword info_for_20_control; |
//filller 112 bytes |
dword a9,b9; |
dword a10,b10; |
dword a11,b11; |
dword a12,b12; |
dword a13,b13; |
dword a14,b14; |
dword a15,b15; |
dword a16,b16; |
dword a17,b17; |
dword a18,b18; |
dword a19,b19; |
dword a20,b20; |
dword a21,b21; |
dword a22,b22; |
dword text_for_3; |
dword number_controls_3; |
dword type_control_30; |
dword info_for_30_control; |
//filler 256 |
dword a23,b23; |
dword a24,b24; |
dword a25,b25; |
dword a26,b26; |
dword a27,b27; |
dword a28,b28; |
dword a29,b29; |
dword a30,b30; |
dword a31,b31; |
dword a32,b32; |
dword a33,b33; |
dword a34,b34; |
dword a35,b35; |
dword a36,b36; |
dword a37,b37; |
dword a38,b38; |
dword a39,b39; |
dword a40,b40; |
dword a41,b41; |
dword a42,b42; |
dword a43,b43; |
dword a44,b44; |
dword a45,b45; |
dword a46,b46; |
dword a47,b47; |
dword a48,b48; |
dword a49,b49; |
dword a50,b50; |
dword a51,b51; |
dword a52,b52; |
dword a53,b53; |
dword a54,b54; |
dword text_for_4; |
dword number_controls_4; |
dword type_control_40; |
dword info_for_40_control; |
//filler 64 |
dword a55,b55; |
dword a56,b56; |
dword a57,b57; |
dword a58,b58; |
dword a59,b59; |
dword a60,b60; |
dword a61,b61; |
dword a62,b62; |
dword text_for_5; |
dword number_controls_5; |
dword type_control_50; |
dword info_for_50_control; |
}__attribute__((packed)); |
//////////////////////////////////////////////////////////////////////////////// |
//////////////////////////////Info for Bookmark 2/////////////////////////////// |
struct InfoForBookmark2 |
{ |
byte type; |
byte flag; |
dword x; |
dword y; |
dword sizex; |
dword sizey; |
dword color1; |
dword reserved; |
dword color2; |
dword number_lines_bookmarks; |
dword number_lines_bookmarks_in_1; |
dword text_for_1; |
dword number_controls_1; |
dword type_control_10; |
dword info_for_10_control; |
dword type_control_11; |
dword info_for_11_control; |
dword text_for_2; |
dword number_controls_2; |
dword type_control_20; |
dword info_for_20_control; |
//filler 64 |
dword a1,b1; |
dword a2,b2; |
dword a3,b3; |
dword a4,b4; |
dword a5,b5; |
dword a6,b6; |
dword a7,b7; |
dword a8,b8; |
}__attribute__((packed)); |
struct ControlBookmark2 |
{ |
dword ctrl_proc; |
dword *ctrl_fd; |
dword *ctrl_bk; |
dword *child_fd; |
dword *child_bk; |
dword *parend; |
dword ctrl_x; |
dword ctrl_y; |
dword ctrl_sizex; |
dword ctrl_sizey; |
dword ctrl_ID; |
byte type; |
byte flag; |
dword x; |
dword y; |
dword sizex; |
dword sizey; |
dword color1; |
dword reserved; |
dword color2; |
dword number_lines_bookmarks; |
dword number_lines_bookmarks_in_1; |
dword text_for_1; |
dword number_controls_1; |
dword type_control_10; |
dword info_for_10_control; |
dword type_control_11; |
dword info_for_11_control; |
dword text_for_2; |
dword number_controls_2; |
dword type_control_20; |
dword info_for_20_control; |
//filler 64 |
dword a1,b1; |
dword a2,b2; |
dword a3,b3; |
dword a4,b4; |
dword a5,b5; |
dword a6,b6; |
dword a7,b7; |
dword a8,b8; |
}__attribute__((packed)); |
//////////////////////////////////////////////////////////////////////////////// |
// |
// libGUI functions |
// |
void stdcall (*DestroyControl)(void *control); |
void stdcall (*SendMessage)(struct HEADER *Parend,struct MESSAGE *Message); |
int stdcall (*Version)(void); |
void stdcall (*ResizeComponent)(void *Control,int new_sizex,int new_sizey); |
void stdcall (*RemoveComponent)(void *Control,int new_x,int new_y); |
void* stdcall (*CraeteButton)(struct HEADER *Parend,void *Control); |
void* stdcall (*CraeteScroller)(struct HEADER *Parend,void *Control); |
void* stdcall (*CraeteBookmark)(struct HEADER *Parend,void *Control); |
void* stdcall (*CraeteImage)(struct HEADER *Parend,void *Control); |
void* stdcall (*CraeteText)(struct HEADER *Parend,void *Control); |
void* stdcall (*CraeteNumber)(struct HEADER *Parend,void *Control); |
void* stdcall (*CraeteCheckbox)(struct HEADER *Parend,void *Control); |
void* stdcall (*CraeteEditbox)(struct HEADER *Parend,void *Control); |
void* stdcall (*CraeteProgressbar)(struct HEADER *Parend,void *Control); |
char* sys_libGUI_path="/sys/lib/libGUI.obj"; |
void link(char *exp){ |
char name_DestroyControl[]={"DestroyControl"}; |
char name_SendMessage[]={"SendMessage"}; |
char name_Version[]={"Version"}; |
char name_ResizeComponent[]={"ResizeComponent"}; |
char name_RemoveComponent[]={"RemoveComponent"}; |
char name_CraeteButton[]={"CraeteButton"}; |
char name_CraeteScroller[]={"CraeteScroller"}; |
char name_CraeteBookmark[]={"CraeteBookmark"}; |
char name_CraeteImage[]={"CraeteImage"}; |
char name_CraeteText[]={"CraeteText"}; |
char name_CraeteNumber[]={"CraeteNumber"}; |
char name_CraeteCheckbox[]={"CraeteCheckbox"}; |
char name_CraeteEditbox[]={"CraeteEditbox"}; |
char name_CraeteProgressbar[]={"CraeteProgressbar"}; |
DestroyControl=(void stdcall (*)(void *control)) |
_ksys_cofflib_getproc(exp,name_DestroyControl); |
SendMessage=(void stdcall (*)(struct HEADER *Parend,struct MESSAGE *Message)) |
_ksys_cofflib_getproc(exp,name_SendMessage); |
Version=(int stdcall (*)(void)) |
_ksys_cofflib_getproc(exp,name_Version); |
ResizeComponent=(void stdcall(*)(void *Control,int new_sizex,int new_sizey)) |
_ksys_cofflib_getproc(exp,name_ResizeComponent); |
RemoveComponent=(void stdcall(*)(void *Control,int new_x,int new_y)) |
_ksys_cofflib_getproc(exp,name_RemoveComponent); |
CraeteButton=(void* stdcall (*)(struct HEADER *Parend,void *Control)) |
_ksys_cofflib_getproc(exp,name_CraeteButton); |
CraeteScroller=(void* stdcall (*)(struct HEADER *Parend,void *Control)) |
_ksys_cofflib_getproc(exp,name_CraeteScroller); |
CraeteBookmark=(void* stdcall (*)(struct HEADER *Parend,void *Control)) |
_ksys_cofflib_getproc(exp,name_CraeteBookmark); |
CraeteImage=(void* stdcall (*)(struct HEADER *Parend,void *Control)) |
_ksys_cofflib_getproc(exp,name_CraeteImage); |
CraeteText=(void* stdcall (*)(struct HEADER *Parend,void *Control)) |
_ksys_cofflib_getproc(exp,name_CraeteText); |
CraeteNumber=(void* stdcall (*)(struct HEADER *Parend,void *Control)) |
_ksys_cofflib_getproc(exp,name_CraeteNumber); |
CraeteCheckbox=(void* stdcall (*)(struct HEADER *Parend,void *Control)) |
_ksys_cofflib_getproc(exp,name_CraeteCheckbox); |
CraeteEditbox=(void* stdcall (*)(struct HEADER *Parend,void *Control)) |
_ksys_cofflib_getproc(exp,name_CraeteEditbox); |
CraeteProgressbar=(void* stdcall (*)(struct HEADER *Parend,void *Control)) |
_ksys_cofflib_getproc(exp,name_CraeteProgressbar); |
} |
int Init_libGUI(void) |
{ |
char *Export; |
Export=(char *)_ksys_cofflib_load(sys_libGUI_path); |
if (Export==0) return Cannot_load_libGUI; |
link(Export); |
return(0); |
} |
void draw_window(struct WINDOW *win) |
{ |
_ksys_window_redraw(1); |
_ksys_draw_window(win->posx,win->posy,win->sizex,win->sizey,0xaabbcc,3,0x5090d0,0,0x5080d0); |
_ksys_window_redraw(2); |
} |
void CraeteInterface(dword *controls,struct HEADER *Parend,struct WINDOW *win) |
{ |
char *names_of_bookmarks1[]={"SINGLET","DOUBLET","SIXTET","P(H)","OTHER"}; |
char *names_of_bookmarks2[]={"SPECTRA","INFORMATION"}; |
char *bookmark_singlet_text[]={"Isomer shift","Amplitude","Width","Xi^2"}; |
char *bookmark_doublet_text[]={"Isomer shift","Quadrupol shift","Amplitude 1", |
"Amplitude 2","Width 1","Width 2","Xi^2"}; |
char *bookmark_sixtet_text[]={"Isomer shift","Quadrupol shift","Feld","Amplitude 1", |
"Amplitude 2","Amplitude 3","Amplitude 4","Amplitude 5", |
"Amplitude 6","Width 1","Width 2","Width 3","Width 4","Width 5", |
"Width 6","Xi^2"}; |
char *bookmark_P_text[]={"K","Maximum feld H","Amplitude","Xi^2"}; |
char *bookmark_information_text[]={"Channels","Null channel","mm/s","Basis(impulses)"}; |
char button_crate_text[]={"Craete"}; |
char button_autocolibrovka_text[]={"Auto colibrovka"}; |
char button_combine_spectras_text[]={"To combine spectras"}; |
struct ControlButton *ButtonCraete; |
struct InfoForButton *InfoButtonCraete; |
struct ControlButton *ButtonAutoColibrovka; |
struct InfoForButton *InfoButtonAutoColibrovka; |
struct ControlButton *ButtonCombineSpectras; |
struct InfoForButton *InfoButtonCombineSpectras; |
struct InfoForImage *InfoImage; |
struct ControlImage *Image; |
struct InfoForText *InfoText; |
struct ControlText *Text; |
struct InfoForNumber *InfoNumber; |
struct ControlNumber *Number; |
struct ControlProgressbar *Progressbar1; |
struct InfoForProgressbar *InfoProgressbar1; |
struct ControlBookmark1 *Bookmark1; |
struct InfoForBookmark1 *InfoBookmark1; |
struct ControlBookmark2 *Bookmark2; |
struct InfoForBookmark2 *InfoBookmark2; |
dword *ptr,*ptr2; |
int skin_height; |
int i; |
int x,y; |
dword textcolor; |
InfoButtonCraete=malloc(sizeof(InfoButtonCraete)); |
InfoButtonAutoColibrovka=malloc(sizeof(InfoButtonAutoColibrovka)); |
InfoButtonCombineSpectras=malloc(sizeof(InfoButtonCombineSpectras)); |
InfoImage=malloc(sizeof(InfoImage)); |
InfoText=malloc(sizeof(InfoText)); |
InfoNumber=malloc(sizeof(InfoNumber)); |
InfoProgressbar1=malloc(sizeof(InfoProgressbar1)); |
InfoBookmark1=malloc(sizeof(InfoBookmark1)); |
InfoBookmark2=malloc(sizeof(InfoBookmark2)); |
skin_height=_ksys_get_skin_height(); |
InfoButtonCraete->type=0x91;//10010001b |
InfoButtonCraete->flag=0; |
InfoButtonCraete->x=10; |
InfoButtonCraete->y=10; |
InfoButtonCraete->width=FONT_SIZEX*sizeof(button_crate_text)+10; |
InfoButtonCraete->height=20; |
InfoButtonCraete->text=(dword)button_crate_text; |
InfoButtonCraete->textcolor=0; |
InfoButtonCraete->color1=0xaabbcc; |
InfoButtonAutoColibrovka->type=0x91;//10010001b |
InfoButtonAutoColibrovka->flag=0; |
InfoButtonAutoColibrovka->x=10; |
InfoButtonAutoColibrovka->y=30; |
InfoButtonAutoColibrovka->width=FONT_SIZEX*sizeof(button_autocolibrovka_text)+10; |
InfoButtonAutoColibrovka->height=20; |
InfoButtonAutoColibrovka->text=(dword)button_autocolibrovka_text; |
InfoButtonAutoColibrovka->textcolor=0; |
InfoButtonAutoColibrovka->color1=0xaabbcc; |
InfoButtonCombineSpectras->type=0x91;//10010001b |
InfoButtonCombineSpectras->flag=0; |
InfoButtonCombineSpectras->x=10; |
InfoButtonCombineSpectras->y=10; |
InfoButtonCombineSpectras->width=FONT_SIZEX*sizeof(button_combine_spectras_text)+10; |
InfoButtonCombineSpectras->height=20; |
InfoButtonCombineSpectras->text=(dword)button_combine_spectras_text; |
InfoButtonCombineSpectras->textcolor=0; |
InfoButtonCombineSpectras->color1=0xaabbcc; |
//prepea text for bookmark SINGLET |
textcolor=0xffffff; |
x=10; |
y=40; |
ptr=58+(dword)InfoBookmark1; |
ptr2=58+32+(dword)InfoBookmark1; |
for(i=0;i<4;i++) |
{ |
InfoText[i].type=0x80; |
InfoText[i].flag=0; |
InfoText[i].x=x; |
InfoText[i].y=y; |
InfoText[i].color1=textcolor; |
InfoText[i].text=bookmark_singlet_text[i]; |
InfoText[i].length=strlen(bookmark_singlet_text[i]); |
InfoNumber[i].type=0x82; |
InfoNumber[i].flag=0; |
InfoNumber[i].x=x+DISTANCE1; |
InfoNumber[i].y=y; |
InfoNumber[i].color1=textcolor; |
InfoNumber[i].number=-0.1234567; |
InfoNumber[i].format=10*65536+7; |
*ptr=(dword)5; |
ptr++; |
*ptr=(dword)&InfoText[i]; |
ptr++; |
*ptr2=(dword)6; |
ptr2++; |
*ptr2=(dword)&InfoNumber[i]; |
ptr2++; |
y=y+12; |
} |
//prepea text for bookmark DOUBLET |
y=40; |
ptr=58+64+16+(dword)InfoBookmark1; |
ptr2=58+64+16+56+(dword)InfoBookmark1; |
for(i=4;i<4+7;i++) |
{ |
InfoText[i].type=0x80; |
InfoText[i].flag=0; |
InfoText[i].x=x; |
InfoText[i].y=y; |
InfoText[i].color1=textcolor; |
InfoText[i].text=bookmark_doublet_text[i-4]; |
InfoText[i].length=strlen(bookmark_doublet_text[i-4]); |
InfoNumber[i].type=0x82; |
InfoNumber[i].flag=0; |
InfoNumber[i].x=x+DISTANCE1; |
InfoNumber[i].y=y; |
InfoNumber[i].color1=textcolor; |
InfoNumber[i].number=-0.1234567; |
InfoNumber[i].format=10*65536+7; |
*ptr=(dword)5; |
ptr++; |
*ptr=(dword)&InfoText[i]; |
ptr++; |
*ptr2=(dword)6; |
ptr2++; |
*ptr2=(dword)&InfoNumber[i]; |
ptr2++; |
y=y+12; |
} |
//prepea text for bookmark SIXTET |
y=40; |
ptr=58+64+16+112+16+(dword)InfoBookmark1; |
ptr2=58+64+16+112+16+128+(dword)InfoBookmark1; |
for(i=4+7;i<4+7+16;i++) |
{ |
InfoText[i].type=0x80; |
InfoText[i].flag=0; |
InfoText[i].x=x; |
InfoText[i].y=y; |
InfoText[i].color1=textcolor; |
InfoText[i].text=bookmark_sixtet_text[i-(4+7)]; |
InfoText[i].length=strlen(bookmark_sixtet_text[i-(4+7)]); |
InfoNumber[i].type=0x82; |
InfoNumber[i].flag=0; |
InfoNumber[i].x=x+DISTANCE1; |
InfoNumber[i].y=y; |
InfoNumber[i].color1=textcolor; |
InfoNumber[i].number=-0.1234567; |
InfoNumber[i].format=10*65536+7; |
*ptr=(dword)5; |
ptr++; |
*ptr=(dword)&InfoText[i]; |
ptr++; |
*ptr2=(dword)6; |
ptr2++; |
*ptr2=(dword)&InfoNumber[i]; |
ptr2++; |
y=y+12; |
} |
//prepea text for bookmark P(H) |
y=40; |
ptr=58+64+16+112+16+256+16+(dword)InfoBookmark1; |
ptr2=58+64+16+112+16+256+16+32+(dword)InfoBookmark1; |
for(i=4+7+16;i<4+7+16+4;i++) |
{ |
InfoText[i].type=0x80; |
InfoText[i].flag=0; |
InfoText[i].x=x; |
InfoText[i].y=y; |
InfoText[i].color1=textcolor; |
InfoText[i].text=bookmark_P_text[i-(4+7+16)]; |
InfoText[i].length=strlen(bookmark_P_text[i-(4+7+16)]); |
InfoNumber[i].type=0x82; |
InfoNumber[i].flag=0; |
InfoNumber[i].x=x+DISTANCE1; |
InfoNumber[i].y=y; |
InfoNumber[i].color1=textcolor; |
InfoNumber[i].number=-0.1234567; |
InfoNumber[i].format=10*65536+7; |
*ptr=(dword)5; |
ptr++; |
*ptr=(dword)&InfoText[i]; |
ptr++; |
*ptr2=(dword)6; |
ptr2++; |
*ptr2=(dword)&InfoNumber[i]; |
ptr2++; |
y=y+12; |
} |
//prepea text for bookmark INFORMATION |
textcolor=0xffffff; |
x=10; |
y=40; |
ptr=78+(dword)InfoBookmark2; |
ptr2=78+32+(dword)InfoBookmark2; |
for(i=4+7+16+4;i<4+7+16+4+4;i++) |
{ |
InfoText[i].type=0x80; |
InfoText[i].flag=0; |
InfoText[i].x=x; |
InfoText[i].y=y; |
InfoText[i].color1=textcolor; |
InfoText[i].text=bookmark_information_text[i-(4+7+16+4)]; |
InfoText[i].length=strlen(bookmark_information_text[i-(4+7+16+4)]); |
InfoNumber[i].type=0x82; |
InfoNumber[i].flag=0; |
InfoNumber[i].x=x+DISTANCE1; |
InfoNumber[i].y=y; |
InfoNumber[i].color1=textcolor; |
InfoNumber[i].number=-0.1234567; |
InfoNumber[i].format=10*65536+7; |
*ptr=(dword)5; |
ptr++; |
*ptr=(dword)&InfoText[i]; |
ptr++; |
*ptr2=(dword)6; |
ptr2++; |
*ptr2=(dword)&InfoNumber[i]; |
ptr2++; |
y=y+12; |
} |
//-------------------Init bookmark 1-------------------------------- |
InfoBookmark1->type=0x81; //10000001b |
InfoBookmark1->x=BOOKMARK1_POSX; |
InfoBookmark1->y=BOOKMARK1_POSY; |
InfoBookmark1->sizex=BOOKMARK1_SIZEX; |
InfoBookmark1->sizey=win->sizey-InfoBookmark1->y-skin_height-5; |
InfoBookmark1->color1=0xaabbcc; |
InfoBookmark1->color2=0xffffff; |
InfoBookmark1->number_lines_bookmarks=2; |
InfoBookmark1->number_lines_bookmarks_in_1=3; |
InfoBookmark1->number_lines_bookmarks_in_2=2; |
//bookmark singlet |
InfoBookmark1->text_for_1=(dword)names_of_bookmarks1[0]; |
InfoBookmark1->number_controls_1=1+4+4; |
InfoBookmark1->type_control_10=1; |
InfoBookmark1->info_for_10_control=(dword)InfoButtonCraete; |
//bookmark doublet |
InfoBookmark1->text_for_2=(dword)names_of_bookmarks1[1]; |
InfoBookmark1->number_controls_2=1+7+7; |
InfoBookmark1->type_control_20=1; |
InfoBookmark1->info_for_20_control=(dword)InfoButtonCraete; |
//bookmark sixtet |
InfoBookmark1->text_for_3=(dword)names_of_bookmarks1[2]; |
InfoBookmark1->number_controls_3=1+16+16; |
InfoBookmark1->type_control_30=1; |
InfoBookmark1->info_for_30_control=(dword)InfoButtonCraete; |
//bookmark P(H) |
InfoBookmark1->text_for_4=(dword)names_of_bookmarks1[3]; |
InfoBookmark1->number_controls_4=1+4+4; |
InfoBookmark1->type_control_40=1; |
InfoBookmark1->info_for_40_control=(dword)InfoButtonCraete; |
//bookmark OTHER |
InfoBookmark1->text_for_5=(dword)names_of_bookmarks1[4]; |
InfoBookmark1->number_controls_5=1; |
InfoBookmark1->type_control_50=1; |
InfoBookmark1->info_for_50_control=(dword)InfoButtonCombineSpectras; |
//-----------------------Init bookmark 2-------------------------------- |
InfoBookmark2->type=0x81; //10000001b |
InfoBookmark2->x=BOOKMARK2_POSX; |
InfoBookmark2->y=BOOKMARK2_POSY; |
InfoBookmark2->sizex=win->sizex-InfoBookmark2->x-10; |
InfoBookmark2->sizey=win->sizey-InfoBookmark2->y-skin_height-5; |
InfoBookmark2->color1=0xaabbcc; |
InfoBookmark2->color2=0xffffff; |
InfoBookmark2->number_lines_bookmarks=1; |
InfoBookmark2->number_lines_bookmarks_in_1=2; |
//bookmark SPECTRA |
InfoBookmark2->text_for_1=(dword)names_of_bookmarks2[0]; |
InfoBookmark2->number_controls_1=2; |
InfoBookmark2->type_control_10=4; |
InfoBookmark2->info_for_10_control=(dword)InfoImage; |
InfoBookmark2->type_control_11=9; |
InfoBookmark2->info_for_11_control=(dword)InfoProgressbar1; |
//bookmark INFORMATION |
InfoBookmark2->text_for_2=(dword)names_of_bookmarks2[1]; |
InfoBookmark2->number_controls_2=1+4+4; |
InfoBookmark2->type_control_20=1; |
InfoBookmark2->info_for_20_control=(dword)InfoButtonCraete; |
InfoImage->type=0x80;//10000000b |
InfoImage->flag=0; |
InfoImage->x=10; |
InfoImage->y=10; |
InfoImage->sizex=InfoBookmark2->sizex-20; |
InfoImage->sizey=InfoBookmark2->sizey-44-16; |
InfoImage->pointer=(dword)malloc(SCREEN_SIZEX*SCREEN_SIZEY*3); |
InfoProgressbar1->type=0x81;//10000001b; |
InfoProgressbar1->flag=0; |
InfoProgressbar1->color1=0xffffff; |
InfoProgressbar1->color2=0xff0000; |
InfoProgressbar1->x=10; |
InfoProgressbar1->y=InfoBookmark2->sizey-16-26; |
InfoProgressbar1->sizex=InfoBookmark2->sizex-20; |
InfoProgressbar1->sizey=16; |
InfoProgressbar1->progress=0.1; |
InfoProgressbar1->color3=0xaabbcc; |
Bookmark1=CraeteBookmark(Parend,InfoBookmark1); |
Bookmark2=CraeteBookmark(Parend,InfoBookmark2); |
ButtonAutoColibrovka=CraeteButton(Parend,InfoButtonAutoColibrovka); |
controls[0]=(dword)Bookmark1; |
controls[1]=(dword)Bookmark2; |
controls[2]=(dword)ButtonAutoColibrovka; |
controls[3]=(dword)InfoImage->pointer; |
//copy child controls of bookmark1 to the array |
//It's proved simple way for acces to the child controls of bookmark1. |
ptr2=44+58+32+4+(dword)Bookmark1; |
for(i=CONTROLS_NUMBER_POS;i<CONTROLS_NUMBER_POS+4;i++) |
{ |
controls[i]=*ptr2; |
ptr2=ptr2+2; |
} |
ptr2=44+58+64+16+56+4+(dword)Bookmark1; |
for(i=CONTROLS_NUMBER_POS+4;i<CONTROLS_NUMBER_POS+4+7;i++) |
{ |
controls[i]=*ptr2; |
ptr2=ptr2+2; |
} |
ptr2=44+58+64+16+112+16+128+4+(dword)Bookmark1; |
for(i=CONTROLS_NUMBER_POS+4+7;i<CONTROLS_NUMBER_POS+4+7+16;i++) |
{ |
controls[i]=*ptr2; |
ptr2=ptr2+2; |
} |
ptr2=44+58+64+16+112+16+256+16+32+4+(dword)Bookmark1; |
for(i=CONTROLS_NUMBER_POS+4+7+16;i<CONTROLS_NUMBER_POS+4+7+16+4;i++) |
{ |
controls[i]=*ptr2; |
ptr2=ptr2+2; |
} |
ptr2=44+78+32+4+(dword)Bookmark2; |
for(i=CONTROLS_NUMBER_POS+4+7+16+4;i<CONTROLS_NUMBER_POS+4+7+16+4+4;i++) |
{ |
controls[i]=*ptr2; |
ptr2=ptr2+2; |
} |
free(InfoButtonCraete); |
free(InfoButtonAutoColibrovka); |
free(InfoButtonCombineSpectras); |
free(InfoBookmark1); |
free(InfoBookmark2); |
free(InfoImage); |
free(InfoText); |
free(InfoProgressbar1); |
} |
int main(int argc, char **argv) |
{ |
char exit_status; |
struct WINDOW *win; |
struct HEADER *Parend; |
struct MESSAGE *Message; |
struct ControlProgressbar *Progressbar1; |
struct InfoForProgressbar *InfoProgressbar1; |
struct ControlBookmark1 *Bookmark1; |
struct ControlBookmark2 *Bookmark2; |
struct ControlImage *Image; |
struct process_table_entry *ProcessInformation; |
dword *controls; |
int new_sizex1; |
int new_sizey1; |
int new_sizex2; |
int new_sizey2; |
int new_sizex3; |
int new_sizey3; |
int new_sizex4; |
int new_sizey4; |
int new_x; |
int new_y; |
int skin_height; |
dword x,y,mouse_buttons; |
float p; |
_ksys_set_wanted_events(0x67); |
Init_libGUI(); |
win=malloc(16); |
win->posx=WINDOW_POSX; |
win->posy=WINDOW_POSY; |
win->sizex=WINDOW_SIZEX; |
win->sizey=WINDOW_SIZEY; |
draw_window(win); |
controls=malloc(TOTAL_NUMBERS_OF_CONTROLS*100); |
Parend=(struct HEADER *)malloc(ParendSize); |
Message=(struct MESSAGE *)malloc(MessageSize); |
ProcessInformation=malloc(sizeof(ProcessInformation)); |
CraeteInterface(controls,Parend,win); |
Message->type=1; |
Message->arg1=0; |
Message->arg2=0; |
Message->arg3=0; |
SendMessage(Parend,Message); |
exit_status=0; |
while(exit_status!=1) |
{ |
switch(_ksys_wait_for_event(2)) |
{ |
case 1: |
{ |
_ksys_get_process_table(ProcessInformation,-1); |
win->sizex=ProcessInformation->winx_size; |
win->sizey=ProcessInformation->winy_size; |
draw_window(win); |
skin_height=_ksys_get_skin_height(); |
Bookmark1=controls[0]; |
Bookmark2=controls[1]; |
new_sizex1=Bookmark1->sizex; |
new_sizey1=win->sizey-Bookmark1->y-skin_height-5; |
new_sizex2=win->sizex-Bookmark2->x-10; |
new_sizey2=win->sizey-Bookmark2->y-skin_height-5; |
Image=Bookmark2->info_for_10_control; |
new_sizex3=new_sizex2-20; |
new_sizey3=new_sizey2-44-16; |
Progressbar1=Bookmark2->info_for_11_control; |
new_sizex4=new_sizex2-20; |
new_sizey4=16; |
new_x=Bookmark2->x+10; |
new_y=Bookmark2->y+new_sizey2; |
RemoveComponent(Progressbar1,new_x,new_y); |
ResizeComponent(Bookmark1,new_sizex1,new_sizey1); |
ResizeComponent(Image,new_sizex3,new_sizey3); |
ResizeComponent(Progressbar1,new_sizex4,new_sizey4); |
ResizeComponent(Bookmark2,new_sizex2,new_sizey2); |
Message->type=1; |
SendMessage(Parend,Message); |
break; |
} |
case 2: |
{ |
exit_status=1; |
break; |
} |
case 3: { |
if (_ksys_get_button_id()==1) {exit_status=1;} |
break; |
} |
case 6: |
{ |
mouse_buttons=_ksys_GetMouseButtonsState(); |
x=_ksys_GetMouseXY(); |
y=x & 0xffff; |
x=x >> 16; |
Message->type=6; |
Message->arg1=x; |
Message->arg2=y; |
Message->arg3=mouse_buttons; |
SendMessage(Parend,Message); |
break; |
} |
default: break; |
} |
} |
} |
/programs/develop/libGUI/examples/C example/kolibri.ld |
---|
0,0 → 1,18 |
/*OUTPUT_FORMAT("binary")*/ |
ENTRY("start_") |
SECTIONS |
{ |
.text 0x000000: |
{ |
*(.text) |
} |
.data : { |
*(.data) |
} |
.bss : |
{ |
*(.bss) |
} |
} |
/programs/develop/libGUI/examples/C example/makefile2 |
---|
0,0 → 1,22 |
OUTFILE = interface.kex |
INPUT = interface.c |
OUTPUT = interface.o |
OBJS = start.o interface.o |
.SUFFIXES: .asm .o |
$(OUTFILE) : $(OBJS) |
fasm start.asm start.o |
gcc -c $(INPUT) -nostdinc -I/home/andrew/kolibri/develop/include/ |
ld -nostdlib -T kolibri.ld -n -L/home/andrew/kolibri/develop/lib/ -o $(OUTFILE) $(OBJS) -lck -lm |
objcopy $(OUTFILE) -O binary |
.asm.o: |
fasm $*.asm |
.c.o: |
gcc -c $*.c |
clean : |
del *.o |
/programs/develop/libGUI/examples/C example/start.asm |
---|
0,0 → 1,136 |
format MS COFF |
section '.text' executable |
public start_ |
;extrn mf_init |
extrn main |
;include 'debug2.inc' |
__DEBUG__=0 |
start_: |
;virtual at 0 |
db 'MENUET01' ; 1. Magic number (8 bytes) |
dd 0x01 ; 2. Version of executable file |
dd start ; 3. Start address |
dd 0x0 ; 4. Size of image |
dd 0x100000 ; 5. Size of needed memory |
dd 0x100000 ; 6. Pointer to stack |
hparams dd 0x0 ; 7. Pointer to program arguments |
hpath dd 0x0 ; 8. Pointer to program path |
;end virtual |
start: |
;DEBUGF 'Start programm\n' |
;init heap of memory |
mov eax,68 |
mov ebx,11 |
int 0x40 |
;DEBUGF ' path "%s"\n params "%s"\n', .path, .params |
; check for overflow |
mov al, [path+buf_len-1] |
or al, [params+buf_len-1] |
jnz .crash |
; check if path written by OS |
mov eax, [hparams] |
test eax, eax |
jz .without_path |
mov eax, path |
.without_path: |
mov esi, eax |
call push_param |
; retrieving parameters |
mov esi, params |
xor edx, edx ; dl - èä¸ò ïà ðà ìåòð(1) èëè ðà çäåëèòåëè(0) |
; dh - ñèìâîë ñ êîòîðîãî Ãà ÷à ëñÿ ïà ðà ìåòð (1 êà âû÷êè, 0 îñòà ëüÃîå) |
mov ecx, 1 ; cl = 1 |
; ch = 0 ïðîñòî Ãîëü |
.parse: |
lodsb |
test al, al |
jz .run |
test dl, dl |
jnz .findendparam |
;{åñëè áûë ðà çäåëèòåëü |
cmp al, ' ' |
jz .parse ;çà ãðóæåà ïðîáåë, ãðóçèì ñëåäóþùèé ñèìâîë |
mov dl, cl ;Ãà ÷èÃà åòñÿ ïà ðà ìåòð |
cmp al, '"' |
jz @f ;çà ãðóæåÃû êà âû÷êè |
mov dh, ch ;ïà ðà ìåòð áåç êà âû÷åê |
dec esi |
call push_param |
inc esi |
jmp .parse |
@@: |
mov dh, cl ;ïà ðà ìåòð â êà âû÷åêà õ |
call push_param ;åñëè ÃÃ¥ ïðîáåë çÃà ÷èò Ãà ÷èÃà åòñÿ êà êîé òî ïà ðà ìåòð |
jmp .parse ;åñëè áûë ðà çäåëèòåëü} |
.findendparam: |
test dh, dh |
jz @f ; áåç êà âû÷åê |
cmp al, '"' |
jz .clear |
jmp .parse |
@@: |
cmp al, ' ' |
jnz .parse |
.clear: |
lea ebx, [esi - 1] |
mov [ebx], ch |
mov dl, ch |
jmp .parse |
.run: |
;DEBUGF 'call main(%x, %x) with params:\n', [argc], argv |
if __DEBUG__ = 1 |
mov ecx, [argc] |
@@: |
lea esi, [ecx * 4 + argv-4] |
DEBUGF '0x%x) "%s"\n', cx, [esi] |
loop @b |
end if |
push [argc] |
push argv |
call main |
.exit: |
;DEBUGF 'Exit from prog\n'; |
xor eax,eax |
dec eax |
int 0x40 |
dd -1 |
.crash: |
;DEBUGF 'E:buffer overflowed\n' |
jmp .exit |
;============================ |
push_param: |
;============================ |
;parameters |
; esi - pointer |
;description |
; procedure increase argc |
; and add pointer to array argv |
; procedure changes ebx |
mov ebx, [argc] |
cmp ebx, max_parameters |
jae .dont_add |
mov [argv+4*ebx], esi |
inc [argc] |
.dont_add: |
ret |
;============================== |
public params as '__argv' |
public path as '__path' |
section '.bss' |
buf_len = 0x400 |
max_parameters=0x20 |
argc rd 1 |
argv rd max_parameters |
path rb buf_len |
params rb buf_len |
;section '.data' |
;include_debug_strings ; ALWAYS present in data section |
/programs/develop/libGUI/examples/bookmarks/GETPROC.ASM |
---|
0,0 → 1,47 |
_ksys_cofflib_getproc: |
mov ebx,[esp+4] |
next_name_check: |
mov ecx,[ebx] |
test ecx,ecx |
jz end_export |
;cmp export string with name |
mov esi,[esp+8] |
xor edi,edi |
next_simbol_check: |
xor eax,eax |
mov al,[ecx] |
test al,al |
jz exit_check_simbol |
xor edx,edx |
mov dl,[esi] |
cmp al,dl |
je simbols_equvalent |
add edi,1 |
jmp exit_check_simbol |
simbols_equvalent: |
add ecx,1 |
add esi,1 |
jmp next_simbol_check |
exit_check_simbol: |
test edi,edi |
jnz function_not_finded |
mov eax,[ebx+4] |
jmp end_export |
function_not_finded: |
add ebx,8 |
jmp next_name_check |
end_export: |
ret 8 |
/programs/develop/libGUI/examples/bookmarks/bookmark.asm |
---|
0,0 → 1,800 |
; |
; |
; This is example using GUI component Bookmark from libGUI. |
; |
; |
include 'macros.inc' |
use32 |
db 'MENUET01' |
dd 1 |
dd start |
dd i_end |
dd 126*1024 |
dd 126*1024 |
dd 0 |
dd path |
start: |
;init hepe of memory |
mcall 68,11 |
;set current dir as ./ |
call GetPath |
;load dll |
mcall 68,19,path |
test eax,eax |
jnz libGUI_loaded |
mcall 68,19,sys_libGUI_path |
test eax,eax |
jnz libGUI_loaded |
mcall -1 |
libGUI_loaded: |
mov [myexport],eax |
;load dll functions |
push fnDestroyControl |
push [myexport] |
call _ksys_cofflib_getproc |
mov [destroy_control],eax |
push fnSendMessage |
push [myexport] |
call _ksys_cofflib_getproc |
mov [send_message],eax |
push fnResizeComponent |
push [myexport] |
call _ksys_cofflib_getproc |
mov [resize_component],eax |
push fnRemoveComponent |
push [myexport] |
call _ksys_cofflib_getproc |
mov [remove_component],eax |
push fnCraeteButton |
push [myexport] |
call _ksys_cofflib_getproc |
mov [craete_button],eax |
push fnCraeteScroller |
push [myexport] |
call _ksys_cofflib_getproc |
mov [craete_scroller],eax |
push fnCraeteBookmark |
push [myexport] |
call _ksys_cofflib_getproc |
mov [craete_bookmark],eax |
push fnCraeteImage |
push [myexport] |
call _ksys_cofflib_getproc |
mov [craete_image],eax |
push fnCraeteText |
push [myexport] |
call _ksys_cofflib_getproc |
mov [craete_text],eax |
push fnCraeteNumber |
push [myexport] |
call _ksys_cofflib_getproc |
mov [craete_number],eax |
push fnCraeteCheckbox |
push [myexport] |
call _ksys_cofflib_getproc |
mov [craete_check_box],eax |
push fnCraeteEditbox |
push [myexport] |
call _ksys_cofflib_getproc |
mov [craete_edit_box],eax |
;set events mask |
mcall 40,1100111b |
;get standart colors table |
mcall 48,3,ColorsTable,40 |
;********************************************* |
;****************Init Butttons**************** |
;********************************************* |
mov ecx,[ColorsTable+8] |
and ecx,0xffffff |
mov [Button1.type],byte 10010001b |
mov [Button1.x],120 |
mov [Button1.y],120 |
mov [Button1.width],word 70 |
mov [Button1.height],word 20 |
mov [Button1.color1],dword ecx |
mov [Button1.color2],dword 0xffffff |
mov [Button1.text],text1 |
mov [Button3.type],byte 10010001b |
mov [Button3.x],165 |
mov [Button3.y],320 |
mov [Button3.width],word 70 |
mov [Button3.height],word 20 |
mov [Button3.color1],dword ecx |
mov [Button3.color2],dword 0xffffff |
mov [Button3.text],text3 |
push Button3 |
push Parend |
call [craete_button] |
mov [PointerToControlForButtonExit],eax |
mov ecx,[ColorsTable+8] |
and ecx,0xffffff |
;******************************************** |
;***************Init scrollers**************** |
;******************************************** |
;init vertical scroller |
mov ecx,[ColorsTable+8] |
mov [VerticalScroller.type],byte 11110001b |
mov [VerticalScroller.x],150 |
mov [VerticalScroller.y],10 |
mov [VerticalScroller.pos],0.2 |
mov [VerticalScroller.length],200 |
mov [VerticalScroller.size],0.3 |
mov [VerticalScroller.color1],ecx |
;******************************************** |
;******************Init Image**************** |
;******************************************** |
mov [Image.type],byte 10000000b |
mov [Image.x],30 |
mov [Image.y],10 |
mov [Image.sizex],200 |
mov [Image.sizey],200 |
mov [Image.pointer],Picture |
;******************************************** |
;******************Init Text***************** |
;******************************************** |
mov [Text.type],byte 10000000b |
mov [Text.color],0xffffff |
mov [Text.x],100 |
mov [Text.y],100 |
mov [Text.length],25 |
mov [Text.pointer],text_for_text |
;******************************************** |
;*****************Init Number**************** |
;******************************************** |
mov [Number.type],byte 10000010b |
mov [Number.color],0xffffff |
mov [Number.x],150 |
mov [Number.y],100 |
mov [Number.parameters],5*65536+4 |
mov [Number.number],-1234.5678 |
;******************************************** |
;***************Init CheckBox**************** |
;******************************************** |
mov ecx,[ColorsTable+8] |
and ecx,0xffffff |
;mov [CheckBox.ch_flags],word 10b |
mov [CheckBox.ch_left],150 |
mov [CheckBox.ch_top],330 |
mov [CheckBox.ch_text_margin],4 |
mov [CheckBox.ch_size],11 |
mov [CheckBox.ch_color],0xffffff |
mov [CheckBox.ch_border_color],ecx |
mov [CheckBox.ch_text_color],0 |
mov [CheckBox.ch_text_ptr],check_box_text |
mov [CheckBox.ch_text_length],9 |
;******************************************** |
;***************Init EditBox***************** |
;******************************************** |
mov ecx,[ColorsTable+8] |
mov [EditBox.ed_flags],0b;1000000000000000b |
mov [EditBox.ed_left],100 ;x |
mov [EditBox.ed_top],100 ;y |
mov [EditBox.ed_width],150 |
mov [EditBox.ed_height],14 |
mov [EditBox.ed_max],100 |
mov [EditBox.ed_text],buffer_for_text |
mov [EditBox.ed_color],dword 0xffffff |
mov [EditBox.shift_color],dword 0xaabbcc |
mov [EditBox.ed_focus_border_color],0 |
mov [EditBox.ed_blur_border_color],ecx |
mov [EditBox.ed_text_color],0 |
;******************************************** |
;***************Init bookmark**************** |
;******************************************** |
;init bookmark |
mov ecx,[ColorsTable+8] |
mov [Bookmark.type],byte 10000001b |
mov [Bookmark.x],10 |
mov [Bookmark.y],10 |
mov [Bookmark.sizex],350 |
mov [Bookmark.sizey],270 |
mov [Bookmark.color_1],dword ecx |
mov [Bookmark.color2],dword 0xffffff |
mov [Bookmark.number_bookmarks],3 |
mov [Bookmark.number_zak_in_1],2 |
mov [Bookmark.number_zak_in_2],3 |
mov [Bookmark.number_zak_in_3],1 |
mov [Bookmark.text_for_1],text4 |
mov [Bookmark.number_contrl_1],1 |
mov [Bookmark.type_control_1],1 |
mov [Bookmark.info_1_control],dword Button1 |
mov [Bookmark.text_for_2],text5 |
mov [Bookmark.number_contrl_2],1 |
mov [Bookmark.type_control_2],6 |
mov [Bookmark.info_2_control],dword Number |
mov [Bookmark.text_for_3],text6 |
mov [Bookmark.number_contrl_3],1 |
mov [Bookmark.type_control_3],8 |
mov [Bookmark.info_3_control],dword EditBox |
mov [Bookmark.text_for_4],text7 |
mov [Bookmark.number_contrl_4],1 |
mov [Bookmark.type_control_4],4 |
mov [Bookmark.info_4_control],dword Image |
mov [Bookmark.text_for_5],text8 |
mov [Bookmark.number_contrl_5],1 |
mov [Bookmark.type_control_5],2 |
mov [Bookmark.info_5_control],dword VerticalScroller |
mov [Bookmark.text_for_6],text9 |
mov [Bookmark.number_contrl_6],1 |
mov [Bookmark.type_control_6],5 |
mov [Bookmark.info_6_control],dword Text |
push Bookmark |
push Parend |
call [craete_bookmark] |
mov [PointerToControlForBookmark],eax |
call draw_window |
;***************************************************** |
;**********Example of resize component**************** |
;***************************************************** |
mov ebx,[PointerToControlForButtonExit] |
push 30;270 |
push 150;250 |
push ebx |
call [resize_component] |
;***************************************************** |
;**********Example of remove component**************** |
;***************************************************** |
mov ebx,[PointerToControlForButtonExit] |
push 340;270 |
push 120;250 |
push ebx |
call [remove_component] |
;send message 1 for redrawing ALL controls |
mov [Message],dword 1 |
push Message |
push Parend |
call [send_message] |
still: |
mcall 10 |
;check for redraw window |
cmp eax,1 |
jne no_window |
call draw_window |
mov eax,[PointerToControlForBookmark] |
mov ebx,[Window_SizeX] |
mov ecx,[Window_SizeY] |
sub ebx,50 |
sub ecx,130 |
;or [eax+44],byte 1000000b |
mov [eax+32],ebx |
mov [eax+36],ecx |
mov [Message],dword 1 |
push Message |
push Parend |
call [send_message] |
jmp still |
no_window: |
;check for keys events |
cmp eax,2 |
jne no_keys |
mcall 2 |
shr eax,8 |
mov [Message],dword 2 |
mov [Message+4],eax |
push Message |
push Parend |
call [send_message] |
mov eax,[Message+4] |
cmp al,27 |
je exit |
jmp still |
no_keys: |
;check for pressed butons |
cmp eax,3 |
jne no_buttons |
mcall 17 |
shr eax,8 |
jmp still |
no_buttons: |
;check for mouse events |
cmp eax,6 |
jne no_mouse |
mov [Message],dword 6 |
mcall 37,1 |
mov ebx,eax |
shr eax,16 ;x |
and ebx,0xffff ;y |
mov [Message+4],eax |
mov [Message+8],ebx |
mcall 37,2 |
mov [Message+12],eax |
;send system events to control |
push Message |
push Parend |
call [send_message] |
mov eax,[PointerToControlForButtonExit] |
xor ebx,ebx |
mov bl,byte[eax+45] |
cmp bl,11b |
jne no_crossing_pressing_button |
mov [button_pressed],1 |
no_crossing_pressing_button: |
xor ebx,ebx |
mov bl,byte[eax+45] |
cmp bl,1b |
jne no_crossing_button |
cmp [button_pressed],1 |
jne no_crossing_button |
jmp exit |
no_crossing_button: |
jmp still |
no_mouse: |
jmp still |
exit: |
push [PointerToControlForButtonExit] |
call [destroy_control] |
push [PointerToControlForBookmark] |
call [destroy_control] |
mcall -1 |
;********************************************** |
;*******************Draw window**************** |
;********************************************** |
draw_window: |
mcall 9,IPC_table,-1 |
mcall 12,1 |
mov eax,[IPC_table+34] |
mov ebx,[IPC_table+38] |
mov ecx,[IPC_table+42] |
mov edx,[IPC_table+46] |
mov [Window_CordinatX],eax |
mov [Window_CordinatY],ebx |
mov [Window_SizeX],ecx |
mov [Window_SizeY],edx |
cmp [Window_SizeX],400 |
jae no_minimum_size_x |
mov [Window_SizeX],400 |
mov ecx,[Window_SizeX] |
no_minimum_size_x: |
cmp [Window_SizeY],400 |
jae no_minimum_size_y |
mov [Window_SizeY],400 |
mov edx,[Window_SizeY] |
no_minimum_size_y: |
xor eax,eax |
mov ebx,[Window_CordinatX] |
mov ecx,[Window_CordinatY] |
shl ebx,16 |
shl ecx,16 |
add ebx,[Window_SizeX] |
add ecx,[Window_SizeY] |
mov edx,0x03aabbcc |
mov esi,0x805080d0 |
mov edi,0x005080d0 |
mcall |
;call print_controls_information |
mcall 12,2 |
ret |
GetPath: |
mov ebx,255 |
mov ecx,path |
next_symvol: |
mov edx,ecx |
add edx,ebx |
xor eax,eax |
mov al,[edx] |
cmp eax,'/' |
je exit_path |
dec ebx |
jnz next_symvol |
exit_path: |
inc edx |
mov esi,dll_name |
mov edi,edx |
mov ecx,10 |
rep movsb |
ret |
include 'getproc.asm' |
;************************************************************ |
;***************************DATA***************************** |
;************************************************************ |
align 4 |
dll_name db 'libGUI.obj',0 |
sys_libGUI_path db '/sys/lib/libGUI.obj',0 |
check_box_text db 'Check box',0 |
text1 db 'text',0 |
text3 db 'Exit',0 |
text4 db 'Bookmark_1',0 |
text5 db 'Bookmark_2',0 |
text6 db 'Bookmark_3',0 |
text7 db 'Bookmark_4',0 |
text8 db 'Bookmark_5',0 |
text9 db 'Bookmark_6',0 |
text_for_text db 'Hello world from bookmark',0 |
fnDestroyControl db 'DestroyControl',0 |
fnSendMessage db 'SendMessage',0 |
fnResizeComponent db 'ResizeComponent',0 |
fnRemoveComponent db 'RemoveComponent',0 |
fnCraeteButton db 'CraeteButton',0 |
fnCraeteScroller db 'CraeteScroller',0 |
fnCraeteBookmark db 'CraeteBookmark',0 |
fnCraeteImage db 'CraeteImage',0 |
fnCraeteText db 'CraeteText',0 |
fnCraeteNumber db 'CraeteNumber',0 |
fnCraeteCheckbox db 'CraeteCheckbox',0 |
fnCraeteEditbox db 'CraeteEditbox',0 |
fnCraeteProgressbar db 'CraeteProgressbar',0 |
myexport dd 0 |
destroy_control dd 0 |
send_message dd 0 |
resize_component dd 0 |
remove_component dd 0 |
craete_button dd 0 |
craete_scroller dd 0 |
craete_bookmark dd 0 |
craete_image dd 0 |
craete_text dd 0 |
craete_number dd 0 |
craete_check_box dd 0 |
craete_edit_box dd 0 |
craete_progres_bar dd 0 |
PointerToControlForButton1 dd 0 |
PointerToControlForButtonExit dd 0 |
PointerToControlForHorizontalScroller dd 0 |
PointerToControlForVerticalScroller dd 0 |
PointerToControlForBookmark dd 0 |
PointerToControlForImage dd 0 |
PointerToControlForText dd 0 |
PointerToControlForCheckBox dd 0 |
PointerToControlForEditBox dd 0 |
Window_CordinatX dd 0 |
Window_CordinatY dd 0 |
Window_SizeX dd 0 |
Window_SizeY dd 0 |
button_pressed dd 0 |
IPC_table rd 256 |
path rb 256 |
Parend: dd 0,0,0,0,0,0,0,0,0,0,0,0 ;44 bytes |
Message rd 4 |
ColorsTable rd 10 |
buffer_for_text rb 100+2 |
struc BUTTON |
{ |
.type db 1 |
.flag db 1 |
.x dw 1 |
.y dw 1 |
.width dw 1 |
.height dw 1 |
.image dd 1 |
.imageX dw 1 |
.imageY dw 1 |
.imageSizeX dw 1 |
.imageSizeY dw 1 |
.transparentColor dd 1 |
.text dd 1 |
.textX dw 1 |
.textY dw 1 |
.textcolor dd 1 |
.color1 dd 1 |
.color2 dd 1 |
.mouseX dw 1 |
.mouseY dw 1 |
} |
struc SCROLLER |
{ |
.type rb 1 |
.x rw 1 |
.y rw 1 |
.length rw 1 |
.color1 rd 1 |
.size rd 1 |
.pos rd 1 |
.buttons_flags rw 1 |
.ChildButton1 rd 1 |
.ChildButton2 rd 1 |
.mouseX rw 1 |
.mouseY rw 1 |
} |
struc BOOKMARK |
{ |
.type rb 1 |
.flag rb 1 |
.x rd 1 |
.y rd 1 |
.sizex rd 1 |
.sizey rd 1 |
.color_1 rd 1 |
.reserved rd 1 |
.color2 rd 1 |
.number_bookmarks rd 1 |
.number_zak_in_1 rd 1 |
.number_zak_in_2 rd 1 |
.number_zak_in_3 rd 1 |
.text_for_1 rd 1 |
.number_contrl_1 rd 1 |
.type_control_1 rd 1 |
.info_1_control rd 1 |
.text_for_2 rd 1 |
.number_contrl_2 rd 1 |
.type_control_2 rd 1 |
.info_2_control rd 1 |
.text_for_3 rd 1 |
.number_contrl_3 rd 1 |
.type_control_3 rd 1 |
.info_3_control rd 1 |
.text_for_4 rd 1 |
.number_contrl_4 rd 1 |
.type_control_4 rd 1 |
.info_4_control rd 1 |
.text_for_5 rd 1 |
.number_contrl_5 rd 1 |
.type_control_5 rd 1 |
.info_5_control rd 1 |
.text_for_6 rd 1 |
.number_contrl_6 rd 1 |
.type_control_6 rd 1 |
.info_6_control rd 1 |
} |
struc IMAGE |
{ |
.type rb 1 |
.flag rb 1 |
.color rd 1 |
.x rd 1 |
.y rd 1 |
.sizex rd 1 |
.sizey rd 1 |
.pointer rd 1 |
} |
struc TEXT |
{ |
.type rb 1 |
.flag rb 1 |
.color rd 1 |
.x rd 1 |
.y rd 1 |
.length rd 1 |
.pointer rd 1 |
} |
struc NUMBER |
{ |
.type rb 1 |
.flag rb 1 |
.color rd 1 |
.x rd 1 |
.y rd 1 |
.number rd 1 |
.parameters rd 1 |
} |
struc CHECKBOX |
{ |
.ch_flags rw 1 |
.ch_left rw 1 |
.ch_top rw 1 |
.ch_text_margin rd 1 |
.ch_size rd 1 |
.ch_size_2 rw 1 |
.ch_size_3 rw 1 |
.ch_color rd 1 |
.ch_border_color rd 1 |
.ch_text_color rd 1 |
.ch_text_ptr rd 1 |
.ch_text_length rw 1 |
.mouseX rd 1 |
.mouseY rd 1 |
} |
struc EDITBOX |
{ |
.ed_width rd 1 ;? ? |
.ed_left rd 1 ; ?? |
.ed_top rd 1 ; ?? |
.ed_color rd 1 ;??? ? |
.shift_color rd 1 ;?????. ?? |
.ed_focus_border_color rd 1 ;??? ? |
.ed_blur_border_color rd 1 ;?? ? ? |
.ed_text_color rd 1 ;???? |
.ed_max rd 1 ;- ? ?? ?? ? |
.ed_text rd 1 ;??? ?? |
.ed_flags rw 1 ;? |
.ed_size rd 1 ;- ? |
.ed_pos rd 1 ;? ?? |
.ed_offset rd 1 ;?? |
.cl_curs_x rd 1 ;??? ???? ? |
.cl_curs_y rd 1 ;??? ???? ? |
.ed_shift_pos rd 1 ; ?? |
.ed_shift_pos_old rd 1 ;?? ?? |
.ed_height rd 1 |
.mouseX rd 1 |
.mouseY rd 1 |
} |
struc PROGRESSBAR |
{ |
.type rb 1 |
.flag rb 1 |
.color1 rd 1 |
.color2 rd 1 |
.x rd 1 |
.y rd 1 |
.sizex rd 1 |
.sizey rd 1 |
.progres rd 1 |
.color3 rd 1 |
} |
Button1 BUTTON |
Button3 BUTTON |
VerticalScroller SCROLLER |
Bookmark BOOKMARK |
Image IMAGE |
Text TEXT |
Number NUMBER |
CheckBox CHECKBOX |
EditBox EDITBOX |
EditBox2 EDITBOX |
ProgressBar PROGRESSBAR |
antibug: rb 2000 |
Picture: |
file 'image.raw' |
i_end: |
/programs/develop/libGUI/examples/bookmarks/image.raw |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/programs/develop/libGUI/examples/button/GETPROC.ASM |
---|
0,0 → 1,47 |
_ksys_cofflib_getproc: |
mov ebx,[esp+4] |
next_name_check: |
mov ecx,[ebx] |
test ecx,ecx |
jz end_export |
;cmp export string with name |
mov esi,[esp+8] |
xor edi,edi |
next_simbol_check: |
xor eax,eax |
mov al,[ecx] |
test al,al |
jz exit_check_simbol |
xor edx,edx |
mov dl,[esi] |
cmp al,dl |
je simbols_equvalent |
add edi,1 |
jmp exit_check_simbol |
simbols_equvalent: |
add ecx,1 |
add esi,1 |
jmp next_simbol_check |
exit_check_simbol: |
test edi,edi |
jnz function_not_finded |
mov eax,[ebx+4] |
jmp end_export |
function_not_finded: |
add ebx,8 |
jmp next_name_check |
end_export: |
ret 8 |
/programs/develop/libGUI/examples/button/button.asm |
---|
0,0 → 1,444 |
; |
; |
; This is a example of using GUI component Button from libGUI |
; |
; |
control_hader_size = 44 |
control_button_data_size = 50 |
include 'macros.inc' |
use32 |
db 'MENUET01' |
dd 1 |
dd start |
dd i_end |
dd 4*1024 |
dd 4*1024 |
dd 0 |
dd path |
start: |
;init hepe of memory |
mcall 68,11 |
;set current dir as ./ |
call GetPath |
;load dll |
mcall 68,19,path |
test eax,eax |
jnz libGUI_loaded |
;load dll from system directory |
mcall 68,19,sys_dll_path |
test eax,eax |
jnz libGUI_loaded |
mcall -1 |
libGUI_loaded: |
mov [myexport],eax |
;load dll functions |
push fnDestroyControl |
push [myexport] |
call _ksys_cofflib_getproc |
mov [destroy_control],eax |
push fnSendMessage |
push [myexport] |
call _ksys_cofflib_getproc |
mov [send_message],eax |
push fnCraeteButton |
push [myexport] |
call _ksys_cofflib_getproc |
mov [crate_button],eax |
;set events mask |
mcall 40,1100111b |
;get standart colors table |
mcall 48,3,ColorsTable,40 |
;********************************************* |
;****************Init Butttons**************** |
;********************************************* |
mov ecx,[ColorsTable+8] |
and ecx,0xffffff |
mov [Button1.type],byte 10010001b |
mov [Button1.x],20 |
mov [Button1.y],10 |
mov [Button1.width],word 70 |
mov [Button1.height],word 20 |
mov [Button1.color1],0xaabbccff;dword ecx |
;mov [Button1.color2],dword 0xffffff |
mov [Button1.text],text1 |
push Button1 |
push Parend |
call [crate_button] |
mov [PointerToControlForButton1],eax |
mov ecx,[ColorsTable+8] |
and ecx,0xffffff |
mov [Button2.type],byte 10010010b |
mov [Button2.x],20 |
mov [Button2.y],40 |
mov [Button2.width],word 70 |
mov [Button2.height],word 20 |
mov [Button2.color1],dword ecx |
mov [Button2.color2],dword 0xffffff |
mov [Button2.image],ButtonPicture |
mov [Button2.imageSizeX],16 |
mov [Button2.imageSizeY],16 |
mov [Button2.transparentColor],0xffffff |
push Button2 |
push Parend |
call [crate_button] |
mov [PointerToControlForButton2],eax |
mov ecx,[ColorsTable+8] |
and ecx,0xffffff |
mov [Button3.type],byte 10000100b |
mov [Button3.x],20 |
mov [Button3.y],70 |
mov [Button3.width],word 70 |
mov [Button3.height],word 20 |
mov [Button3.color1],dword ecx |
mov [Button3.color2],dword 0xffffff |
mov [Button3.text],text1 |
mov [Button3.textX],40 |
mov [Button3.textY],8 |
mov [Button3.textcolor],0 |
mov [Button3.image],ButtonPicture |
mov [Button3.imageX],3 |
mov [Button3.imageY],3 |
mov [Button3.imageSizeX],16 |
mov [Button3.imageSizeY],16 |
mov [Button3.transparentColor],0xffffff |
push Button3 |
push Parend |
call [crate_button] |
mov [PointerToControlForButton3],eax |
mov ecx,[ColorsTable+8] |
and ecx,0xffffff |
mov [Button4.type],byte 10010001b |
mov [Button4.x],20 |
mov [Button4.y],100 |
mov [Button4.width],word 70 |
mov [Button4.height],word 20 |
mov [Button4.color1],dword ecx |
mov [Button4.color2],dword 0xffffff |
mov [Button4.text],text4 |
mov [Button4.textX],10 |
mov [Button4.textY],10 |
mov [Button4.textcolor],0 |
mov [Button4.image],ButtonPicture |
mov [Button4.imageX],5 |
mov [Button4.imageY],5 |
mov [Button4.imageSizeX],16 |
mov [Button4.imageSizeY],16 |
mov [Button4.transparentColor],0xffffff |
push Button4 |
push Parend |
call [crate_button] |
mov [PointerToControlForButton4],eax |
call draw_window |
;send message 1 for redrawing ALL controls |
mov [Message],dword 1 |
push Message |
push Parend |
call [send_message] |
still: |
mcall 10 |
mov [SystemEvent],eax |
;check for redraw window |
cmp eax,1 |
jne no_window |
call draw_window |
mov [Message],dword 1 |
push Message |
push Parend |
call [send_message] |
jmp still |
no_window: |
;check for keys events |
cmp eax,2 |
jne no_keys |
mcall 2 |
shr eax,8 |
mov [Message],dword 2 |
mov [Message+4],eax |
push Message |
push Parend |
call [send_message] |
mov eax,[Message+4] |
cmp al,27 |
je exit |
jmp still |
no_keys: |
;check for pressed butons |
cmp eax,3 |
jne no_buttons |
mcall 17 |
shr eax,8 |
jmp still |
no_buttons: |
;check for mouse events |
cmp eax,6 |
jne no_mouse |
mov [Message],dword 6 |
mcall 37,1 |
mov ebx,eax |
shr eax,16 ;x |
and ebx,0xffff ;y |
mov [Message+4],eax |
mov [Message+8],ebx |
mcall 37,2 |
mov [Message+12],eax |
;send system events to control |
push Message |
push Parend |
call [send_message] |
;button 1 |
mov esi,[PointerToControlForButton1] |
add esi,control_hader_size ;size control's structure |
mov edi,Button1 |
mov ecx,control_button_data_size |
rep movsb |
;button 2 |
mov esi,[PointerToControlForButton2] |
add esi,control_hader_size ;size control's structure |
mov edi,Button2 |
mov ecx,control_button_data_size |
rep movsb |
;button 3 |
mov esi,[PointerToControlForButton3] |
add esi,control_hader_size ;size control's structure |
mov edi,Button3 |
mov ecx,control_button_data_size |
rep movsb |
;button 4 |
mov esi,[PointerToControlForButton4] |
add esi,control_hader_size ;size control's structure |
mov edi,Button4 |
mov ecx,control_button_data_size |
rep movsb |
xor eax,eax |
mov al,[Button4.flag] |
cmp al,11b |
jne no_exit_demo |
mov [button_pressed],1 |
no_exit_demo: |
cmp al,1b |
jne no_only_crossing_button |
cmp [button_pressed],1 |
jne no_only_crossing_button |
jmp exit |
no_only_crossing_button: |
jmp still |
no_mouse: |
jmp still |
exit: |
;free resourses |
push [PointerToControlForButton1] |
call [destroy_control] |
push [PointerToControlForButton2] |
call [destroy_control] |
push [PointerToControlForButton3] |
call [destroy_control] |
push [PointerToControlForButton4] |
call [destroy_control] |
mcall -1 |
;********************************************** |
;*******************Draw window**************** |
;********************************************** |
draw_window: |
mcall 12,1 |
xor eax,eax |
mov ebx,50 |
mov ecx,50 |
shl ebx,16 |
shl ecx,16 |
add ebx,200 |
add ecx,200 |
mov edx,0x03aabbcc |
mov esi,0x805080d0 |
mov edi,0x005080d0 |
mcall |
mcall 12,2 |
ret |
GetPath: |
mov ebx,255 |
mov ecx,path |
next_symvol: |
mov edx,ecx |
add edx,ebx |
xor eax,eax |
mov al,[edx] |
cmp eax,'/' |
je exit_path |
dec ebx |
jnz next_symvol |
exit_path: |
inc edx |
mov esi,dll_name |
mov edi,edx |
mov ecx,10 |
rep movsb |
ret |
include 'getproc.asm' |
;************************************************************ |
;***************************DATA***************************** |
;************************************************************ |
align 4 |
dll_name db 'libGUI.obj',0 |
sys_dll_path db '/sys/lib/libGUi.obj',0 |
text1 db 'text',0 |
text4 db 'Exit',0 |
fnDestroyControl db 'DestroyControl',0 |
fnSendMessage db 'SendMessage',0 |
fnCraeteButton db 'CraeteButton',0 |
myexport dd 0 |
destroy_control dd 0 |
send_message dd 0 |
crate_button dd 0 |
PointerToControlForButton1 dd 0 |
PointerToControlForButton2 dd 0 |
PointerToControlForButton3 dd 0 |
PointerToControlForButton4 dd 0 |
SystemEvent dd 0 |
button_pressed rb 1 |
path rb 256 |
Parend: dd 0,0,0,0,0,0,0,0,0,0,0,0 ;44 bytes |
Message dd 0,0,0,0 |
ColorsTable dd 0,0,0,0,0,0,0,0,0,0,0,0 |
struc BUTTON |
{ |
.type db 1 |
.flag db 1 |
.x dw 1 |
.y dw 1 |
.width dw 1 |
.height dw 1 |
.image dd 1 |
.imageX dw 1 |
.imageY dw 1 |
.imageSizeX dw 1 |
.imageSizeY dw 1 |
.transparentColor dd 1 |
.text dd 1 |
.textX dw 1 |
.textY dw 1 |
.textcolor dd 1 |
.color1 dd 1 |
.color2 dd 1 |
.mouseX dw 1 |
.mouseY dw 1 |
} |
Button1 BUTTON |
Button2 BUTTON |
Button3 BUTTON |
Button4 BUTTON |
antibug rb 460 |
ButtonPicture: |
file 'test.raw' |
i_end: |
/programs/develop/libGUI/examples/button/test.raw |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/programs/develop/libGUI/examples/check_box/GETPROC.ASM |
---|
0,0 → 1,47 |
_ksys_cofflib_getproc: |
mov ebx,[esp+4] |
next_name_check: |
mov ecx,[ebx] |
test ecx,ecx |
jz end_export |
;cmp export string with name |
mov esi,[esp+8] |
xor edi,edi |
next_simbol_check: |
xor eax,eax |
mov al,[ecx] |
test al,al |
jz exit_check_simbol |
xor edx,edx |
mov dl,[esi] |
cmp al,dl |
je simbols_equvalent |
add edi,1 |
jmp exit_check_simbol |
simbols_equvalent: |
add ecx,1 |
add esi,1 |
jmp next_simbol_check |
exit_check_simbol: |
test edi,edi |
jnz function_not_finded |
mov eax,[ebx+4] |
jmp end_export |
function_not_finded: |
add ebx,8 |
jmp next_name_check |
end_export: |
ret 8 |
/programs/develop/libGUI/examples/check_box/check_box.asm |
---|
0,0 → 1,373 |
; |
; |
; Example of using gui component CheckBox from libGUI. |
; |
; |
include 'macros.inc' |
use32 |
db 'MENUET01' |
dd 1 |
dd start |
dd i_end |
dd 1600 |
dd 1600 |
dd 0 |
dd path |
start: |
;init hepe of memory |
mcall 68,11 |
;set current dir as ./ |
call GetPath |
;load dll |
mcall 68,19,path |
test eax,eax |
jnz libGUI_loaded |
mcall 68,19,sys_libGUI_path |
test eax,eax |
jnz libGUI_loaded |
mcall -1 |
libGUI_loaded: |
mov [myexport],eax |
;load dll functions |
push fnDestroyControl |
push [myexport] |
call _ksys_cofflib_getproc |
mov [destroy_control],eax |
push fnSendMessage |
push [myexport] |
call _ksys_cofflib_getproc |
mov [send_message],eax |
push fnCraeteButton |
push [myexport] |
call _ksys_cofflib_getproc |
mov [craete_button],eax |
push fnCraeteCheckbox |
push [myexport] |
call _ksys_cofflib_getproc |
mov [craete_check_box],eax |
;set events mask |
mcall 40,1100111b |
;get standart colors table |
mcall 48,3,ColorsTable,40 |
;********************************************* |
;****************Init Buttton**************** |
;********************************************* |
mov ecx,[ColorsTable+8] |
and ecx,0xffffff |
mov [Button1.type],byte 10010001b |
mov [Button1.x],10 |
mov [Button1.y],40 |
mov [Button1.width],word 70 |
mov [Button1.height],word 20 |
mov [Button1.color1],dword ecx |
mov [Button1.color2],dword 0xffffff |
mov [Button1.text],text1 |
push Button1 |
push Parend |
call [craete_button] |
mov [PointerToControlForButtonExit],eax |
;******************************************** |
;***************Init CheckBox**************** |
;******************************************** |
mov ecx,[ColorsTable+8] |
and ecx,0xffffff |
;mov [CheckBox.ch_flags],word 10b |
mov [CheckBox.ch_left],20 |
mov [CheckBox.ch_top],15 |
mov [CheckBox.ch_text_margin],4 |
mov [CheckBox.ch_size],11 |
mov [CheckBox.ch_color],0xffffff |
mov [CheckBox.ch_border_color],ecx |
mov [CheckBox.ch_text_color],0 |
mov [CheckBox.ch_text_ptr],check_box_text |
mov [CheckBox.ch_text_length],9 |
push CheckBox |
push Parend |
call [craete_check_box] |
mov [PointerToControlForCheckBox],eax |
call draw_window |
;send message 1 for redrawing ALL controls |
mov [Message],dword 1 |
push Message |
push Parend |
call [send_message] |
still: |
mcall 10 |
;check for redraw window |
cmp eax,1 |
jne no_window |
call draw_window |
mov [Message],dword 1 |
push Message |
push Parend |
call [send_message] |
jmp still |
no_window: |
;check for keys events |
cmp eax,2 |
jne no_keys |
mcall 2 |
shr eax,8 |
mov [Message],dword 2 |
mov [Message+4],eax |
push Message |
push Parend |
call [send_message] |
mov eax,[Message+4] |
cmp al,27 |
je exit |
jmp still |
no_keys: |
;check for pressed butons |
cmp eax,3 |
jne no_buttons |
mcall 17 |
shr eax,8 |
jmp still |
no_buttons: |
;check for mouse events |
cmp eax,6 |
jne no_mouse |
mov [Message],dword 6 |
mcall 37,1 |
mov ebx,eax |
shr eax,16 ;x |
and ebx,0xffff ;y |
mov [Message+4],eax |
mov [Message+8],ebx |
mcall 37,2 |
mov [Message+12],eax |
;send system events to control |
push Message |
push Parend |
call [send_message] |
mov eax,[PointerToControlForButtonExit] |
xor ebx,ebx |
mov bl,byte[eax+45] |
cmp bl,11b |
jne no_crossing_pressing_button |
mov [button_pressed],1 |
no_crossing_pressing_button: |
xor ebx,ebx |
mov bl,byte[eax+45] |
cmp bl,1b |
jne no_crossing_button |
cmp [button_pressed],1 |
jne no_crossing_button |
jmp exit |
no_crossing_button: |
jmp still |
no_mouse: |
jmp still |
exit: |
push [PointerToControlForButtonExit] |
call [destroy_control] |
push [PointerToControlForCheckBox] |
call [destroy_control] |
mcall -1 |
;********************************************** |
;*******************Draw window**************** |
;********************************************** |
draw_window: |
mcall 12,1 |
xor eax,eax |
mov ebx,50 |
mov ecx,50 |
shl ebx,16 |
shl ecx,16 |
add ebx,100 |
add ecx,100 |
mov edx,0x03aabbcc |
mov esi,0x805080d0 |
mov edi,0x005080d0 |
mcall |
mcall 12,2 |
ret |
GetPath: |
mov ebx,255 |
mov ecx,path |
next_symvol: |
mov edx,ecx |
add edx,ebx |
xor eax,eax |
mov al,[edx] |
cmp eax,'/' |
je exit_path |
dec ebx |
jnz next_symvol |
exit_path: |
inc edx |
mov esi,dll_name |
mov edi,edx |
mov ecx,10 |
rep movsb |
ret |
include 'getproc.asm' |
;************************************************************ |
;***************************DATA***************************** |
;************************************************************ |
align 4 |
dll_name db 'libGUI.obj',0 |
sys_libGUI_path db '/sys/lib/libGUI.obj',0 |
check_box_text db 'Check box',0 |
text1 db 'Exit',0 |
fnDestroyControl db 'DestroyControl',0 |
fnSendMessage db 'SendMessage',0 |
fnCraeteButton db 'CraeteButton',0 |
fnCraeteCheckbox db 'CraeteCheckbox',0 |
myexport dd 0 |
destroy_control dd 0 |
send_message dd 0 |
craete_button dd 0 |
craete_check_box dd 0 |
PointerToControlForButtonExit dd 0 |
PointerToControlForCheckBox dd 0 |
button_pressed dd 0 |
path rb 256 |
Parend: dd 0,0,0,0,0,0,0,0,0,0,0,0 ;44 bytes |
Message rd 4 |
ColorsTable rd 10 |
struc BUTTON |
{ |
.type db 1 |
.flag db 1 |
.x dw 1 |
.y dw 1 |
.width dw 1 |
.height dw 1 |
.image dd 1 |
.imageX dw 1 |
.imageY dw 1 |
.imageSizeX dw 1 |
.imageSizeY dw 1 |
.transparentColor dd 1 |
.text dd 1 |
.textX dw 1 |
.textY dw 1 |
.textcolor dd 1 |
.color1 dd 1 |
.color2 dd 1 |
.mouseX dw 1 |
.mouseY dw 1 |
} |
struc CHECKBOX |
{ |
.ch_flags rw 1 |
.ch_left rw 1 |
.ch_top rw 1 |
.ch_text_margin rd 1 |
.ch_size rd 1 |
.ch_size_2 rw 1 |
.ch_size_3 rw 1 |
.ch_color rd 1 |
.ch_border_color rd 1 |
.ch_text_color rd 1 |
.ch_text_ptr rd 1 |
.ch_text_length rw 1 |
.mouseX rd 1 |
.mouseY rd 1 |
} |
Button1 BUTTON |
CheckBox CHECKBOX |
i_end: |
/programs/develop/libGUI/examples/edit_box/GETPROC.ASM |
---|
0,0 → 1,47 |
_ksys_cofflib_getproc: |
mov ebx,[esp+4] |
next_name_check: |
mov ecx,[ebx] |
test ecx,ecx |
jz end_export |
;cmp export string with name |
mov esi,[esp+8] |
xor edi,edi |
next_simbol_check: |
xor eax,eax |
mov al,[ecx] |
test al,al |
jz exit_check_simbol |
xor edx,edx |
mov dl,[esi] |
cmp al,dl |
je simbols_equvalent |
add edi,1 |
jmp exit_check_simbol |
simbols_equvalent: |
add ecx,1 |
add esi,1 |
jmp next_simbol_check |
exit_check_simbol: |
test edi,edi |
jnz function_not_finded |
mov eax,[ebx+4] |
jmp end_export |
function_not_finded: |
add ebx,8 |
jmp next_name_check |
end_export: |
ret 8 |
/programs/develop/libGUI/examples/edit_box/edit_box.asm |
---|
0,0 → 1,383 |
; |
; |
; This is example of using GUI component EditBox from libGUI. |
; |
; |
include 'macros.inc' |
use32 |
db 'MENUET01' |
dd 1 |
dd start |
dd i_end |
dd 1800 |
dd 1800 |
dd 0 |
dd path |
start: |
;init hepe of memory |
mcall 68,11 |
;set current dir as ./ |
call GetPath |
;load dll |
mcall 68,19,path |
test eax,eax |
jnz libGUI_loaded |
mcall 68,19,sys_libGUI_path |
test eax,eax |
jnz libGUI_loaded |
mcall -1 |
libGUI_loaded: |
mov [myexport],eax |
;load dll functions |
push fnDestroyControl |
push [myexport] |
call _ksys_cofflib_getproc |
mov [destroy_control],eax |
push fnSendMessage |
push [myexport] |
call _ksys_cofflib_getproc |
mov [send_message],eax |
push fnCraeteButton |
push [myexport] |
call _ksys_cofflib_getproc |
mov [craete_button],eax |
push fnCraeteEditbox |
push [myexport] |
call _ksys_cofflib_getproc |
mov [craete_edit_box],eax |
;set events mask |
mcall 40,1100111b |
;get standart colors table |
mcall 48,3,ColorsTable,40 |
;********************************************* |
;****************Init Butttons**************** |
;********************************************* |
mov ecx,[ColorsTable+8] |
and ecx,0xffffff |
mov [Button1.type],byte 10010001b |
mov [Button1.x],20 |
mov [Button1.y],50 |
mov [Button1.width],word 70 |
mov [Button1.height],word 20 |
mov [Button1.color1],dword ecx |
mov [Button1.color2],dword 0xffffff |
mov [Button1.text],text1 |
push Button1 |
push Parend |
call [craete_button] |
mov [PointerToControlForButtonExit],eax |
mov ecx,[ColorsTable+8] |
and ecx,0xffffff |
;******************************************** |
;***************Init EditBox***************** |
;******************************************** |
mov ecx,[ColorsTable+8] |
mov [EditBox.ed_flags],0b;1000000000000000b |
mov [EditBox.ed_left],5 ;x |
mov [EditBox.ed_top],10 ;y |
mov [EditBox.ed_width],100 |
mov [EditBox.ed_height],14 |
mov [EditBox.ed_max],100 |
mov [EditBox.ed_text],buffer_for_text |
mov [EditBox.ed_color],dword 0xffffff |
mov [EditBox.shift_color],dword 0xaabbcc |
mov [EditBox.ed_focus_border_color],0 |
mov [EditBox.ed_blur_border_color],ecx |
mov [EditBox.ed_text_color],0 |
push EditBox |
push Parend |
call [craete_edit_box] |
mov [PointerToControlForEditBox],eax |
call draw_window |
;send message 1 for redrawing ALL controls |
mov [Message],dword 1 |
push Message |
push Parend |
call [send_message] |
still: |
mcall 10 |
;check for redraw window |
cmp eax,1 |
jne no_window |
call draw_window |
mov [Message],dword 1 |
push Message |
push Parend |
call [send_message] |
jmp still |
no_window: |
;check for keys events |
cmp eax,2 |
jne no_keys |
mcall 2 |
shr eax,8 |
mov [Message],dword 2 |
mov [Message+4],eax |
push Message |
push Parend |
call [send_message] |
mov eax,[Message+4] |
cmp al,27 |
je exit |
jmp still |
no_keys: |
;check for pressed butons |
cmp eax,3 |
jne no_buttons |
mcall 17 |
shr eax,8 |
jmp still |
no_buttons: |
;check for mouse events |
cmp eax,6 |
jne no_mouse |
mov [Message],dword 6 |
mcall 37,1 |
mov ebx,eax |
shr eax,16 ;x |
and ebx,0xffff ;y |
mov [Message+4],eax |
mov [Message+8],ebx |
mcall 37,2 |
mov [Message+12],eax |
;send system events to control |
push Message |
push Parend |
call [send_message] |
mov eax,[PointerToControlForButtonExit] |
xor ebx,ebx |
mov bl,byte[eax+45] |
cmp bl,11b |
jne no_crossing_pressing_button |
mov [button_pressed],1 |
no_crossing_pressing_button: |
xor ebx,ebx |
mov bl,byte[eax+45] |
cmp bl,1b |
jne no_crossing_button |
cmp [button_pressed],1 |
jne no_crossing_button |
jmp exit |
no_crossing_button: |
jmp still |
no_mouse: |
jmp still |
exit: |
push [PointerToControlForButtonExit] |
call [destroy_control] |
push [PointerToControlForEditBox] |
call [destroy_control] |
mcall -1 |
;********************************************** |
;*******************Draw window**************** |
;********************************************** |
draw_window: |
mcall 12,1 |
xor eax,eax |
mov ebx,50 |
mov ecx,50 |
shl ebx,16 |
shl ecx,16 |
add ebx,120 |
add ecx,120 |
mov edx,0x03aabbcc |
mov esi,0x805080d0 |
mov edi,0x005080d0 |
mcall |
mcall 12,2 |
ret |
GetPath: |
mov ebx,255 |
mov ecx,path |
next_symvol: |
mov edx,ecx |
add edx,ebx |
xor eax,eax |
mov al,[edx] |
cmp eax,'/' |
je exit_path |
dec ebx |
jnz next_symvol |
exit_path: |
inc edx |
mov esi,dll_name |
mov edi,edx |
mov ecx,10 |
rep movsb |
ret |
include 'getproc.asm' |
;************************************************************ |
;***************************DATA***************************** |
;************************************************************ |
align 4 |
dll_name db 'libGUI.obj',0 |
sys_libGUI_path db '/sys/lib/libGUI.obj',0 |
text1 db 'Exit',0 |
text_for_text db 'Hello world from zakladka',0 |
fnDestroyControl db 'DestroyControl',0 |
fnSendMessage db 'SendMessage',0 |
fnCraeteButton db 'CraeteButton',0 |
fnCraeteEditbox db 'CraeteEditbox',0 |
myexport dd 0 |
destroy_control dd 0 |
send_message dd 0 |
craete_button dd 0 |
craete_edit_box dd 0 |
PointerToControlForButtonExit dd 0 |
PointerToControlForEditBox dd 0 |
button_pressed dd 0 |
path rb 256 |
Parend: dd 0,0,0,0,0,0,0,0,0,0,0,0 ;44 bytes |
Message rd 4 |
ColorsTable rd 10 |
buffer_for_text rb 100+2 |
struc BUTTON |
{ |
.type db 1 |
.flag db 1 |
.x dw 1 |
.y dw 1 |
.width dw 1 |
.height dw 1 |
.image dd 1 |
.imageX dw 1 |
.imageY dw 1 |
.imageSizeX dw 1 |
.imageSizeY dw 1 |
.transparentColor dd 1 |
.text dd 1 |
.textX dw 1 |
.textY dw 1 |
.textcolor dd 1 |
.color1 dd 1 |
.color2 dd 1 |
.mouseX dw 1 |
.mouseY dw 1 |
} |
struc EDITBOX |
{ |
.ed_width rd 1 |
.ed_left rd 1 |
.ed_top rd 1 |
.ed_color rd 1 |
.shift_color rd 1 |
.ed_focus_border_color rd 1 |
.ed_blur_border_color rd 1 |
.ed_text_color rd 1 |
.ed_max rd 1 |
.ed_text rd 1 |
.ed_flags rw 1 |
.ed_size rd 1 |
.ed_pos rd 1 |
.ed_offset rd 1 |
.cl_curs_x rd 1 |
.cl_curs_y rd 1 |
.ed_shift_pos rd 1 |
.ed_shift_pos_old rd 1 |
.ed_height rd 1 |
.mouseX rd 1 |
.mouseY rd 1 |
} |
Button1 BUTTON |
EditBox EDITBOX |
i_end: |
/programs/develop/libGUI/examples/image/GETPROC.ASM |
---|
0,0 → 1,47 |
_ksys_cofflib_getproc: |
mov ebx,[esp+4] |
next_name_check: |
mov ecx,[ebx] |
test ecx,ecx |
jz end_export |
;cmp export string with name |
mov esi,[esp+8] |
xor edi,edi |
next_simbol_check: |
xor eax,eax |
mov al,[ecx] |
test al,al |
jz exit_check_simbol |
xor edx,edx |
mov dl,[esi] |
cmp al,dl |
je simbols_equvalent |
add edi,1 |
jmp exit_check_simbol |
simbols_equvalent: |
add ecx,1 |
add esi,1 |
jmp next_simbol_check |
exit_check_simbol: |
test edi,edi |
jnz function_not_finded |
mov eax,[ebx+4] |
jmp end_export |
function_not_finded: |
add ebx,8 |
jmp next_name_check |
end_export: |
ret 8 |
/programs/develop/libGUI/examples/image/KOSLOGO.RAW |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/programs/develop/libGUI/examples/image/image.asm |
---|
0,0 → 1,362 |
; |
; |
; This is example of using GUI component Image from libGUI. |
; |
; |
include 'macros.inc' |
use32 |
db 'MENUET01' |
dd 1 |
dd start |
dd i_end |
dd 7*1024+100 |
dd 7*1024+100 |
dd 0 |
dd path |
start: |
;init hepe of memory |
mcall 68,11 |
;set current dir as ./ |
call GetPath |
;load dll |
mcall 68,19,path |
test eax,eax |
jnz libGUI_loaded |
mcall 68,19,sys_libGUI_path |
test eax,eax |
jnz libGUI_loaded |
mcall -1 |
libGUI_loaded: |
mov [myexport],eax |
;load dll functions |
push fnDestroyControl |
push [myexport] |
call _ksys_cofflib_getproc |
mov [destroy_control],eax |
push fnSendMessage |
push [myexport] |
call _ksys_cofflib_getproc |
mov [send_message],eax |
push fnCraeteButton |
push [myexport] |
call _ksys_cofflib_getproc |
mov [crate_button],eax |
push fnCraeteImage |
push [myexport] |
call _ksys_cofflib_getproc |
mov [crate_image],eax |
;set events mask |
mcall 40,1100111b |
;get standart colors table |
mcall 48,3,ColorsTable,40 |
;********************************************* |
;****************Init Butttons**************** |
;********************************************* |
mov ecx,[ColorsTable+8] |
and ecx,0xffffff |
mov [Button1.type],byte 10010001b |
mov [Button1.x],10 |
mov [Button1.y],50 |
mov [Button1.width],word 70 |
mov [Button1.height],word 20 |
mov [Button1.color1],dword ecx |
mov [Button1.color2],dword 0xffffff |
mov [Button1.text],text1 |
push Button1 |
push Parend |
call [crate_button] |
mov [PointerToControlForButtonExit],eax |
;******************************************** |
;******************Init Image**************** |
;******************************************** |
mov [Image.type],byte 10000000b |
mov [Image.x],25 |
mov [Image.y],5 |
mov [Image.sizex],40 |
mov [Image.sizey],40 |
mov [Image.pointer],Picture |
push Image |
push Parend |
call [crate_image] |
mov [PointerToControlForImage],eax |
call draw_window |
;send message 1 for redrawing ALL controls |
mov [Message],dword 1 |
push Message |
push Parend |
call [send_message] |
still: |
mcall 10 |
;check for redraw window |
cmp eax,1 |
jne no_window |
call draw_window |
mov [Message],1 |
push Message |
push Parend |
call [send_message] |
jmp still |
no_window: |
;check for keys events |
cmp eax,2 |
jne no_keys |
mcall 2 |
shr eax,8 |
mov [Message],dword 2 |
mov [Message+4],eax |
push Message |
push Parend |
call [send_message] |
mov eax,[Message+4] |
cmp al,27 |
je exit |
jmp still |
no_keys: |
;check for pressed butons |
cmp eax,3 |
jne no_buttons |
mcall 17 |
shr eax,8 |
jmp still |
no_buttons: |
;check for mouse events |
cmp eax,6 |
jne no_mouse |
mov [Message],dword 6 |
mcall 37,1 |
mov ebx,eax |
shr eax,16 ;x |
and ebx,0xffff ;y |
mov [Message+4],eax |
mov [Message+8],ebx |
mcall 37,2 |
mov [Message+12],eax |
;send system events to control |
push Message |
push Parend |
call [send_message] |
mov eax,[PointerToControlForButtonExit] |
xor ebx,ebx |
mov bl,byte[eax+45] |
cmp bl,11b |
jne no_crossing_pressing_button |
mov [button_pressed],1 |
no_crossing_pressing_button: |
xor ebx,ebx |
mov bl,byte[eax+45] |
cmp bl,1b |
jne no_crossing_button |
cmp [button_pressed],1 |
jne no_crossing_button |
jmp exit |
no_crossing_button: |
jmp still |
no_mouse: |
jmp still |
exit: |
push [PointerToControlForButtonExit] |
call [destroy_control] |
push [PointerToControlForImage] |
call [destroy_control] |
mcall -1 |
;********************************************** |
;*******************Draw window**************** |
;********************************************** |
draw_window: |
mcall 12,1 |
xor eax,eax |
mov ebx,50 |
mov ecx,50 |
shl ebx,16 |
shl ecx,16 |
add ebx,100 |
add ecx,100 |
mov edx,0x03aabbcc |
mov esi,0x805080d0 |
mov edi,0x005080d0 |
mcall |
mcall 12,2 |
ret |
GetPath: |
mov ebx,255 |
mov ecx,path |
next_symvol: |
mov edx,ecx |
add edx,ebx |
xor eax,eax |
mov al,[edx] |
cmp eax,'/' |
je exit_path |
dec ebx |
jnz next_symvol |
exit_path: |
inc edx |
mov esi,dll_name |
mov edi,edx |
mov ecx,10 |
rep movsb |
ret |
include 'getproc.asm' |
;************************************************************ |
;***************************DATA***************************** |
;************************************************************ |
align 4 |
dll_name db 'libGUI.obj',0 |
sys_libGUI_path db '/sys/lib/libGUI.obj',0 |
text1 db 'Exit',0 |
fnDestroyControl db 'DestroyControl',0 |
fnSendMessage db 'SendMessage',0 |
fnCraeteButton db 'CraeteButton',0 |
fnCraeteImage db 'CraeteImage',0 |
myexport dd 0 |
destroy_control dd 0 |
send_message dd 0 |
crate_button dd 0 |
crate_image dd 0 |
PointerToControlForButtonExit dd 0 |
PointerToControlForImage dd 0 |
button_pressed dd 0 |
path rb 256 |
Parend: dd 0,0,0,0,0,0,0,0,0,0,0,0 ;44 bytes |
Message rd 4 |
ColorsTable rd 10 |
struc BUTTON |
{ |
.type db 1 |
.flag db 1 |
.x dw 1 |
.y dw 1 |
.width dw 1 |
.height dw 1 |
.image dd 1 |
.imageX dw 1 |
.imageY dw 1 |
.imageSizeX dw 1 |
.imageSizeY dw 1 |
.transparentColor dd 1 |
.text dd 1 |
.textX dw 1 |
.textY dw 1 |
.textcolor dd 1 |
.color1 dd 1 |
.color2 dd 1 |
.mouseX dw 1 |
.mouseY dw 1 |
} |
struc IMAGE |
{ |
.type rb 1 |
.flag rb 1 |
.color rd 1 |
.x rd 1 |
.y rd 1 |
.sizex rd 1 |
.sizey rd 1 |
.pointer rd 1 |
} |
Button1 BUTTON |
Image IMAGE |
untibug: rb 1000 |
Picture: |
file 'koslogo.raw' |
i_end: |
/programs/develop/libGUI/examples/number/GETPROC.ASM |
---|
0,0 → 1,47 |
_ksys_cofflib_getproc: |
mov ebx,[esp+4] |
next_name_check: |
mov ecx,[ebx] |
test ecx,ecx |
jz end_export |
;cmp export string with name |
mov esi,[esp+8] |
xor edi,edi |
next_simbol_check: |
xor eax,eax |
mov al,[ecx] |
test al,al |
jz exit_check_simbol |
xor edx,edx |
mov dl,[esi] |
cmp al,dl |
je simbols_equvalent |
add edi,1 |
jmp exit_check_simbol |
simbols_equvalent: |
add ecx,1 |
add esi,1 |
jmp next_simbol_check |
exit_check_simbol: |
test edi,edi |
jnz function_not_finded |
mov eax,[ebx+4] |
jmp end_export |
function_not_finded: |
add ebx,8 |
jmp next_name_check |
end_export: |
ret 8 |
/programs/develop/libGUI/examples/number/number.asm |
---|
0,0 → 1,377 |
; |
; |
; This is example using GUI component Number from libGUI. |
; |
; |
include 'macros.inc' |
use32 |
db 'MENUET01' |
dd 1 |
dd start |
dd i_end |
dd 1700 |
dd 1700 |
dd 0 |
dd path |
start: |
;init hepe of memory |
mcall 68,11 |
;set current dir as ./ |
call GetPath |
;load dll |
mcall 68,19,path |
test eax,eax |
jnz libGUI_loaded |
mcall 68,19,sys_libGUI_path |
test eax,eax |
jnz libGUI_loaded |
mcall -1 |
libGUI_loaded: |
mov [myexport],eax |
;load dll functions |
push fnDestroyControl |
push [myexport] |
call _ksys_cofflib_getproc |
mov [destroy_control],eax |
push fnSendMessage |
push [myexport] |
call _ksys_cofflib_getproc |
mov [send_message],eax |
push fnCraeteButton |
push [myexport] |
call _ksys_cofflib_getproc |
mov [craete_button],eax |
push fnCraeteNumber |
push [myexport] |
call _ksys_cofflib_getproc |
mov [craete_number],eax |
;set events mask |
mcall 40,1100111b |
;get standart colors table |
mcall 48,3,ColorsTable,40 |
;********************************************* |
;****************Init Butttons**************** |
;********************************************* |
mov ecx,[ColorsTable+8] |
and ecx,0xffffff |
mov [Button1.type],byte 10010001b |
mov [Button1.x],10 |
mov [Button1.y],50 |
mov [Button1.width],word 70 |
mov [Button1.height],word 20 |
mov [Button1.color1],dword ecx |
mov [Button1.color2],dword 0xffffff |
mov [Button1.text],text1 |
push Button1 |
push Parend |
call [craete_button] |
mov [PointerToControlForButtonExit],eax |
mov ecx,[ColorsTable+8] |
and ecx,0xffffff |
;******************************************** |
;****************Init Numbers**************** |
;******************************************** |
mov [NumberFloat.type],byte 10000010b |
mov [NumberFloat.color],0xffffff |
mov [NumberFloat.x],20 |
mov [NumberFloat.y],10 |
mov [NumberFloat.parameters],4*65536+5 |
mov [NumberFloat.number],-1234.56789 |
mov [NumberInteger.type],byte 10000000b |
mov [NumberInteger.color],0xffffff |
mov [NumberInteger.x],26 |
mov [NumberInteger.y],30 |
mov [NumberInteger.parameters],8*65536 |
mov [NumberInteger.number],12345678 |
push NumberFloat |
push Parend |
call [craete_number] |
mov [PointerToControlForNumberFloat],eax |
push NumberInteger |
push Parend |
call [craete_number] |
mov [PointerToControlForNumberInteger],eax |
call draw_window |
;send message 1 for redrawing ALL controls |
mov [Message],dword 1 |
push Message |
push Parend |
call [send_message] |
still: |
mcall 10 |
;check for redraw window |
cmp eax,1 |
jne no_window |
call draw_window |
mov [Message],dword 1 |
push Message |
push Parend |
call [send_message] |
jmp still |
no_window: |
;check for keys events |
cmp eax,2 |
jne no_keys |
mcall 2 |
shr eax,8 |
mov [Message],dword 2 |
mov [Message+4],eax |
push Message |
push Parend |
call [send_message] |
mov eax,[Message+4] |
cmp al,27 |
je exit |
jmp still |
no_keys: |
;check for pressed butons |
cmp eax,3 |
jne no_buttons |
mcall 17 |
shr eax,8 |
jmp still |
no_buttons: |
;check for mouse events |
cmp eax,6 |
jne no_mouse |
mov [Message],dword 6 |
mcall 37,1 |
mov ebx,eax |
shr eax,16 ;x |
and ebx,0xffff ;y |
mov [Message+4],eax |
mov [Message+8],ebx |
mcall 37,2 |
mov [Message+12],eax |
;send system events to control |
push Message |
push Parend |
call [send_message] |
mov eax,[PointerToControlForButtonExit] |
xor ebx,ebx |
mov bl,byte[eax+45] |
cmp bl,11b |
jne no_crossing_pressing_button |
mov [button_pressed],1 |
no_crossing_pressing_button: |
xor ebx,ebx |
mov bl,byte[eax+45] |
cmp bl,1b |
jne no_crossing_button |
cmp [button_pressed],1 |
jne no_crossing_button |
jmp exit |
no_crossing_button: |
jmp still |
no_mouse: |
jmp still |
exit: |
push [PointerToControlForButtonExit] |
call [destroy_control] |
push [PointerToControlForNumberFloat] |
call [destroy_control] |
push [PointerToControlForNumberInteger] |
call [destroy_control] |
mcall -1 |
;********************************************** |
;*******************Draw window**************** |
;********************************************** |
draw_window: |
mcall 12,1 |
xor eax,eax |
mov ebx,50 |
mov ecx,50 |
shl ebx,16 |
shl ecx,16 |
add ebx,100 |
add ecx,100 |
mov edx,0x03aabbcc |
mov esi,0x805080d0 |
mov edi,0x005080d0 |
mcall |
mcall 12,2 |
ret |
GetPath: |
mov ebx,255 |
mov ecx,path |
next_symvol: |
mov edx,ecx |
add edx,ebx |
xor eax,eax |
mov al,[edx] |
cmp eax,'/' |
je exit_path |
dec ebx |
jnz next_symvol |
exit_path: |
inc edx |
mov esi,dll_name |
mov edi,edx |
mov ecx,10 |
rep movsb |
ret |
include 'getproc.asm' |
;************************************************************ |
;***************************DATA***************************** |
;************************************************************ |
align 4 |
dll_name db 'libGUI.obj',0 |
sys_libGUI_path db '/sys/lib/libGUI.obj',0 |
text1 db 'Exit',0 |
fnDestroyControl db 'DestroyControl',0 |
fnSendMessage db 'SendMessage',0 |
fnCraeteButton db 'CraeteButton',0 |
fnCraeteNumber db 'CraeteNumber',0 |
myexport dd 0 |
destroy_control dd 0 |
send_message dd 0 |
craete_button dd 0 |
craete_number dd 0 |
PointerToControlForButtonExit dd 0 |
PointerToControlForNumberFloat dd 0 |
PointerToControlForNumberInteger dd 0 |
button_pressed dd 0 |
path rb 256 |
Parend: dd 0,0,0,0,0,0,0,0,0,0,0,0 ;44 bytes |
Message rd 4 |
ColorsTable rd 10 |
struc BUTTON |
{ |
.type db 1 |
.flag db 1 |
.x dw 1 |
.y dw 1 |
.width dw 1 |
.height dw 1 |
.image dd 1 |
.imageX dw 1 |
.imageY dw 1 |
.imageSizeX dw 1 |
.imageSizeY dw 1 |
.transparentColor dd 1 |
.text dd 1 |
.textX dw 1 |
.textY dw 1 |
.textcolor dd 1 |
.color1 dd 1 |
.color2 dd 1 |
.mouseX dw 1 |
.mouseY dw 1 |
} |
struc NUMBER |
{ |
.type rb 1 |
.flag rb 1 |
.color rd 1 |
.x rd 1 |
.y rd 1 |
.number rd 1 |
.parameters rd 1 |
} |
Button1 BUTTON |
NumberFloat NUMBER |
NumberInteger NUMBER |
i_end: |
/programs/develop/libGUI/examples/progress_bar/GETPROC.ASM |
---|
0,0 → 1,47 |
_ksys_cofflib_getproc: |
mov ebx,[esp+4] |
next_name_check: |
mov ecx,[ebx] |
test ecx,ecx |
jz end_export |
;cmp export string with name |
mov esi,[esp+8] |
xor edi,edi |
next_simbol_check: |
xor eax,eax |
mov al,[ecx] |
test al,al |
jz exit_check_simbol |
xor edx,edx |
mov dl,[esi] |
cmp al,dl |
je simbols_equvalent |
add edi,1 |
jmp exit_check_simbol |
simbols_equvalent: |
add ecx,1 |
add esi,1 |
jmp next_simbol_check |
exit_check_simbol: |
test edi,edi |
jnz function_not_finded |
mov eax,[ebx+4] |
jmp end_export |
function_not_finded: |
add ebx,8 |
jmp next_name_check |
end_export: |
ret 8 |
/programs/develop/libGUI/examples/progress_bar/progress_bar.asm |
---|
0,0 → 1,412 |
; |
; |
; Example of using GUI componet ProgressBar from libGUI |
; |
; |
include 'macros.inc' |
use32 |
db 'MENUET01' |
dd 1 |
dd start |
dd i_end |
dd 124*1024 |
dd 124*1024 |
dd 0 |
dd path |
start: |
;init hepe of memory |
mcall 68,11 |
;set current dir as ./ |
call GetPath |
;load dll |
mcall 68,19,path |
test eax,eax |
jnz libGUI_loaded |
mcall 68,19,sys_libGUI_path |
test eax,eax |
jnz libGUI_loaded |
mcall -1 |
libGUI_loaded: |
mov [myexport],eax |
;load dll functions |
push fnDestroyControl |
push [myexport] |
call _ksys_cofflib_getproc |
mov [destroy_control],eax |
push fnSendMessage |
push [myexport] |
call _ksys_cofflib_getproc |
mov [send_message],eax |
push fnCraeteButton |
push [myexport] |
call _ksys_cofflib_getproc |
mov [craete_button],eax |
push fnCraeteProgressbar |
push [myexport] |
call _ksys_cofflib_getproc |
mov [craete_progress_bar],eax |
;set events mask |
mcall 40,1100111b |
;get standart colors table |
mcall 48,3,ColorsTable,40 |
;********************************************* |
;****************Init Butttons**************** |
;********************************************* |
mov ecx,[ColorsTable+8] |
and ecx,0xffffff |
mov [Button1.type],byte 10010001b |
mov [Button1.x],60 |
mov [Button1.y],50 |
mov [Button1.width],word 70 |
mov [Button1.height],word 20 |
mov [Button1.color1],dword ecx |
mov [Button1.color2],dword 0xffffff |
mov [Button1.text],text1 |
mov [ProgressBar.type],byte 10000001b |
mov [ProgressBar.color1],dword 0xffffff |
mov [ProgressBar.color2],0xff0000 |
mov [ProgressBar.color3],ecx |
mov [ProgressBar.x],5 |
mov [ProgressBar.y],5 |
mov [ProgressBar.sizex],175 |
mov [ProgressBar.sizey],16 |
mov [ProgressBar.progres],0 |
push Button1 |
push Parend |
call [craete_button] |
mov [PointerToControlForButtonExit],eax |
mov ecx,[ColorsTable+8] |
and ecx,0xffffff |
push ProgressBar |
push Parend |
call [craete_progress_bar] |
mov [PointerToControlForProgressBar],eax |
call draw_window |
;send message 1 for redrawing ALL controls |
mov [Message],dword 1 |
push Message |
push Parend |
call [send_message] |
mov [progress],0.02 |
mov [progress_step],0.01 |
still: |
;---------------------------------------- |
;--send special message for ProgressBar-- |
;---------------------------------------- |
mov ebx,[progress] |
mov eax,[PointerToControlForProgressBar] |
mov [eax+44],byte 1b |
mov [eax+44+26],ebx |
fld [progress_step] |
fld [progress] |
fadd st0,st1 |
fstp [progress] |
fstp st0 |
cmp [progress],dword 1.0 |
jl no_1_ |
mov [progress],0.02 |
mov eax,[PointerToControlForProgressBar] |
mov [eax+44],byte 10000001b |
mov [eax+44+26],dword 0.02 |
mov [Message],dword 1 |
push Message |
push Parend |
call [send_message] |
no_1_: |
;fld [progress] |
;fcmovbe |
;fstsw ax |
;sahf |
;jle no_1_ |
;no_1_: |
mov [Message],dword 3 |
push Message |
push Parend |
call [send_message] |
mcall 5,1 |
mcall 11 |
;check for redraw window |
cmp eax,1 |
jne no_window |
call draw_window |
mov [Message],dword 1 |
push Message |
push Parend |
call [send_message] |
jmp still |
no_window: |
;check for keys events |
cmp eax,2 |
jne no_keys |
mcall 2 |
shr eax,8 |
mov [Message],dword 2 |
mov [Message+4],eax |
push Message |
push Parend |
call [send_message] |
mov eax,[Message+4] |
cmp al,27 |
je exit |
jmp still |
no_keys: |
;check for pressed butons |
cmp eax,3 |
jne no_buttons |
mcall 17 |
shr eax,8 |
jmp still |
no_buttons: |
;check for mouse events |
cmp eax,6 |
jne no_mouse |
mov [Message],dword 6 |
mcall 37,1 |
mov ebx,eax |
shr eax,16 ;x |
and ebx,0xffff ;y |
mov [Message+4],eax |
mov [Message+8],ebx |
mcall 37,2 |
mov [Message+12],eax |
;send system events to control |
push Message |
push Parend |
call [send_message] |
mov eax,[PointerToControlForButtonExit] |
xor ebx,ebx |
mov bl,byte[eax+45] |
cmp bl,11b |
jne no_crossing_pressing_button |
mov [button_pressed],1 |
no_crossing_pressing_button: |
xor ebx,ebx |
mov bl,byte[eax+45] |
cmp bl,1b |
jne no_crossing_button |
cmp [button_pressed],1 |
jne no_crossing_button |
jmp exit |
no_crossing_button: |
jmp still |
no_mouse: |
jmp still |
exit: |
push [PointerToControlForButtonExit] |
call [destroy_control] |
push [PointerToControlForProgressBar] |
call [destroy_control] |
mcall -1 |
;********************************************** |
;*******************Draw window**************** |
;********************************************** |
draw_window: |
mcall 12,1 |
xor eax,eax |
mov ebx,50 |
mov ecx,50 |
shl ebx,16 |
shl ecx,16 |
add ebx,200 |
add ecx,100 |
mov edx,0x03aabbcc |
mov esi,0x805080d0 |
mov edi,0x005080d0 |
mcall |
;call print_controls_information |
mcall 12,2 |
ret |
GetPath: |
mov ebx,255 |
mov ecx,path |
next_symvol: |
mov edx,ecx |
add edx,ebx |
xor eax,eax |
mov al,[edx] |
cmp eax,'/' |
je exit_path |
dec ebx |
jnz next_symvol |
exit_path: |
inc edx |
mov esi,dll_name |
mov edi,edx |
mov ecx,10 |
rep movsb |
ret |
include 'getproc.asm' |
;************************************************************ |
;***************************DATA***************************** |
;************************************************************ |
align 4 |
dll_name db 'libGUI.obj',0 |
sys_libGUI_path db '/sys/lib/libGUI.obj',0 |
text1 db 'Exit',0 |
fnDestroyControl db 'DestroyControl',0 |
fnSendMessage db 'SendMessage',0 |
fnCraeteButton db 'CraeteButton',0 |
fnCraeteProgressbar db 'CraeteProgressbar',0 |
myexport dd 0 |
destroy_control dd 0 |
send_message dd 0 |
craete_button dd 0 |
craete_progress_bar dd 0 |
PointerToControlForButtonExit dd 0 |
PointerToControlForProgressBar dd 0 |
button_pressed dd 0 |
progress dd 0 |
progress_step dd 0 |
path rb 256 |
Parend: dd 0,0,0,0,0,0,0,0,0,0,0,0 ;44 bytes |
Message rd 4 |
ColorsTable rd 10 |
struc BUTTON |
{ |
.type db 1 |
.flag db 1 |
.x dw 1 |
.y dw 1 |
.width dw 1 |
.height dw 1 |
.image dd 1 |
.imageX dw 1 |
.imageY dw 1 |
.imageSizeX dw 1 |
.imageSizeY dw 1 |
.transparentColor dd 1 |
.text dd 1 |
.textX dw 1 |
.textY dw 1 |
.textcolor dd 1 |
.color1 dd 1 |
.color2 dd 1 |
.mouseX dw 1 |
.mouseY dw 1 |
} |
struc PROGRESSBAR |
{ |
.type rb 1 |
.flag rb 1 |
.color1 rd 1 |
.color2 rd 1 |
.x rd 1 |
.y rd 1 |
.sizex rd 1 |
.sizey rd 1 |
.progres rd 1 |
.color3 rd 1 |
} |
Button1 BUTTON |
ProgressBar PROGRESSBAR |
i_end: |
/programs/develop/libGUI/examples/scroll_bar/GETPROC.ASM |
---|
0,0 → 1,47 |
_ksys_cofflib_getproc: |
mov ebx,[esp+4] |
next_name_check: |
mov ecx,[ebx] |
test ecx,ecx |
jz end_export |
;cmp export string with name |
mov esi,[esp+8] |
xor edi,edi |
next_simbol_check: |
xor eax,eax |
mov al,[ecx] |
test al,al |
jz exit_check_simbol |
xor edx,edx |
mov dl,[esi] |
cmp al,dl |
je simbols_equvalent |
add edi,1 |
jmp exit_check_simbol |
simbols_equvalent: |
add ecx,1 |
add esi,1 |
jmp next_simbol_check |
exit_check_simbol: |
test edi,edi |
jnz function_not_finded |
mov eax,[ebx+4] |
jmp end_export |
function_not_finded: |
add ebx,8 |
jmp next_name_check |
end_export: |
ret 8 |
/programs/develop/libGUI/examples/scroll_bar/scroller.asm |
---|
0,0 → 1,506 |
; |
; |
; This is example of using GUI component Scroller from libGUI |
; |
; |
control_hader_size = 44 |
control_scroller_data_size = 29 |
control_button_data_size = 50 |
first_child_button_pressed = 1b |
second_child_button_pressed = 10000b |
include 'macros.inc' |
use32 |
db 'MENUET01' |
dd 1 |
dd start |
dd i_end |
dd 4000 |
dd 4000 |
dd 0 |
dd path |
start: |
;init hepe of memory |
mcall 68,11 |
;set current dir as ./ |
call GetPath |
;load dll |
mcall 68,19,path |
test eax,eax |
jnz libGUI_loaded |
;load dll from system directory |
mcall 68,19,sys_dll_path |
test eax,eax |
jnz libGUI_loaded |
mcall -1 |
libGUI_loaded: |
mov [myexport],eax |
;load dll functions |
push fnDestroyControl |
push [myexport] |
call _ksys_cofflib_getproc |
mov [destroy_control],eax |
push fnSendMessage |
push [myexport] |
call _ksys_cofflib_getproc |
mov [send_message],eax |
push fnCraeteButton |
push [myexport] |
call _ksys_cofflib_getproc |
mov [craete_button],eax |
push fnCraeteScroller |
push [myexport] |
call _ksys_cofflib_getproc |
mov [craete_scroller],eax |
;set events mask |
mcall 40,1100111b |
;get standart colors table |
mcall 48,3,ColorsTable,40 |
;********************************************* |
;****************Init Butttons**************** |
;********************************************* |
mov ecx,[ColorsTable+8] |
and ecx,0xffffff |
mov [ButtonExit.type],byte 10010001b |
mov [ButtonExit.x],90 |
mov [ButtonExit.y],160 |
mov [ButtonExit.width],word 70 |
mov [ButtonExit.height],word 20 |
mov [ButtonExit.color1],dword ecx |
mov [ButtonExit.color2],dword 0xffffff |
mov [ButtonExit.text],text |
push ButtonExit |
push Parend |
call [craete_button] |
mov [PointerToControlForButtonExit],eax |
mov ecx,[ColorsTable+8] |
and ecx,0xffffff |
;******************************************** |
;***************Init scrollers**************** |
;******************************************** |
;init vertical scroller |
mov ecx,[ColorsTable+8] |
mov [VerticalScroller.type],byte 11100001b |
mov [VerticalScroller.x],10 |
mov [VerticalScroller.y],30 |
mov [VerticalScroller.pos],0.2 |
mov [VerticalScroller.length],200 |
mov [VerticalScroller.size],0.9 |
mov [VerticalScroller.color1],ecx |
push VerticalScroller |
push Parend |
call [craete_scroller] |
mov [PointerToControlForVerticalScroller],eax |
;init horizontal scroller |
mov ecx,[ColorsTable+8] |
mov [HorizontalScroller.type],byte 11110010b |
mov [HorizontalScroller.x],30 |
mov [HorizontalScroller.y],30 |
mov [HorizontalScroller.pos],0.7 |
mov [HorizontalScroller.length],200 |
mov [HorizontalScroller.size],0.3 |
mov [HorizontalScroller.color1],0xaabbccff;ecx |
push HorizontalScroller |
push Parend |
call [craete_scroller] |
mov [PointerToControlForHorizontalScroller],eax |
call draw_window |
;send message 1 for redrawing ALL controls |
mov [Message],dword 1 |
push Message |
push Parend |
call [send_message] |
still: |
mcall 10 |
mov [SystemEvent],eax |
;----------------------- |
;check for redraw window |
;----------------------- |
cmp eax,1 |
jne no_window |
call draw_window |
mov [Message],dword 1 |
push Message |
push Parend |
call [send_message] |
jmp still |
no_window: |
;--------------------- |
;check for keys events |
;--------------------- |
cmp eax,2 |
jne no_keys |
mcall 2 |
shr eax,8 |
mov [Message],dword 2 |
mov [Message+4],eax |
push Message |
push Parend |
call [send_message] |
mov eax,[Message+4] |
cmp al,27 |
je exit |
jmp still |
no_keys: |
;------------------------- |
;check for events of mouse |
;------------------------- |
cmp eax,3 |
jne no_button_close_window |
mcall 17 |
shr eax,8 |
jmp still |
no_button_close_window: |
;check for mouse events |
cmp eax,6 |
jne no_mouse |
;craete message of mouse for controls |
mov [Message],dword 6 |
mcall 37,1 |
mov ebx,eax |
shr eax,16 ;x |
and ebx,0xffff ;y |
mov [Message+4],eax |
mov [Message+8],ebx |
mcall 37,2 |
mov [Message+12],eax |
;send message to controls |
push Message |
push Parend |
call [send_message] |
;interraction with button exit |
;copy data of scroller of button from control to structure |
mov esi,[PointerToControlForButtonExit] |
add esi,control_hader_size |
mov edi,ButtonExit |
mov ecx,control_button_data_size |
rep movsb |
xor eax,eax |
mov al,[ButtonExit.flag] |
;check button for pressing |
and al,10b |
test al,al |
jz button_3_not_pressed |
mov [button_pressed],1 |
jmp no_pressed_button |
button_3_not_pressed: |
cmp [button_pressed],1 |
jne no_pressed_button |
jmp exit |
no_pressed_button: |
;interraction with vertical scroller |
;copy data of vertical scroller from control to structure |
mov esi,[PointerToControlForVerticalScroller] |
add esi,control_hader_size |
mov edi,VerticalScroller |
mov ecx,control_scroller_data_size |
rep movsb |
mov eax,[VerticalScroller.pos] |
mov [PosY_float],eax ;position of scroll bar from 0...1 |
xor edx,edx |
call DrawRectangle |
xor eax,eax |
mov ax,[VerticalScroller.buttons_flags] |
and ax,first_child_button_pressed |
test ax,ax |
jz vertical_first_child_button_not_pressed |
mov edx,0xff00 |
call DrawRectangle |
vertical_first_child_button_not_pressed: |
xor eax,eax |
mov ax,[VerticalScroller.buttons_flags] |
and ax,second_child_button_pressed |
test ax,ax |
jz vertical_second_child_button_not_pressed |
mov edx,0xff |
call DrawRectangle |
vertical_second_child_button_not_pressed: |
;interraction with horizontal scroller |
;copy data of horizontal scroller from control to structure |
mov esi,[PointerToControlForHorizontalScroller] |
add esi,control_hader_size |
mov edi,HorizontalScroller |
mov ecx,control_scroller_data_size |
rep movsb |
xor eax,eax |
mov ax,[HorizontalScroller.buttons_flags] |
and ax,first_child_button_pressed |
test ax,ax |
jz horizontal_first_child_button_not_pressed |
mov edx,0xffffff |
call DrawRectangle |
horizontal_first_child_button_not_pressed: |
xor eax,eax |
mov ax,[HorizontalScroller.buttons_flags] |
and ax,second_child_button_pressed |
test ax,ax |
jz horizontal_second_child_button_not_pressed |
mov edx,0xff0000 |
call DrawRectangle |
horizontal_second_child_button_not_pressed: |
jmp still |
no_mouse: |
jmp still |
exit: |
;free resourses |
push [PointerToControlForVerticalScroller] |
call [destroy_control] |
push [PointerToControlForHorizontalScroller] |
call [destroy_control] |
push [PointerToControlForButtonExit] |
call [destroy_control] |
mcall -1 |
;********************************************** |
;*******************Draw window**************** |
;********************************************** |
draw_window: |
mcall 12,1 |
xor eax,eax |
mov ebx,50 |
mov ecx,50 |
shl ebx,16 |
shl ecx,16 |
add ebx,280 |
add ecx,280 |
mov edx,0x03aabbcc |
mov esi,0x805080d0 |
mov edi,0x005080d0 |
mcall |
mcall 12,2 |
ret |
GetPath: |
mov ebx,255 |
mov ecx,path |
next_symvol: |
mov edx,ecx |
add edx,ebx |
xor eax,eax |
mov al,[edx] |
cmp eax,'/' |
je exit_path |
dec ebx |
jnz next_symvol |
exit_path: |
inc edx |
mov esi,dll_name |
mov edi,edx |
mov ecx,10 |
rep movsb |
ret |
DrawRectangle: |
mov eax,13 |
mov ebx,100*65536+50 |
mov ecx,100*65536+50 |
int 0x40 |
ret |
include 'getproc.asm' |
;************************************************************ |
;***************************DATA***************************** |
;************************************************************ |
align 4 |
dll_name db 'libGUI.obj',0 |
sys_dll_path db '/sys/lib/libGUI.obj',0 |
text db 'Exit',0 |
fnDestroyControl db 'DestroyControl',0 |
fnSendMessage db 'SendMessage',0 |
fnCraeteButton db 'CraeteButton',0 |
fnCraeteScroller db 'CraeteScroller',0 |
myexport dd 0 |
destroy_control dd 0 |
send_message dd 0 |
craete_button dd 0 |
craete_scroller dd 0 |
PointerToControlForButtonExit dd 0 |
PointerToControlForHorizontalScroller dd 0 |
PointerToControlForVerticalScroller dd 0 |
SystemEvent dd 0 |
PosX_float dd 0 |
PosY_float dd 0 |
button_pressed dd 0 |
IPC_table rd 256 |
path rb 256 |
ColorsTable rd 10 |
Parend: dd 0,0,0,0,0,0,0,0,0,0,0,0 ;44 bytes |
Message rd 4 |
x dd 0 |
y dd 0 |
number dd 0 |
struc BUTTON |
{ |
.type db 1 |
.flag db 1 |
.x dw 1 |
.y dw 1 |
.width dw 1 |
.height dw 1 |
.image dd 1 |
.imageX dw 1 |
.imageY dw 1 |
.imageSizeX dw 1 |
.imageSizeY dw 1 |
.transparentColor dd 1 |
.text dd 1 |
.textX dw 1 |
.textY dw 1 |
.textcolor dd 1 |
.color1 dd 1 |
.color2 dd 1 |
.mouseX dw 1 |
.mouseY dw 1 |
} |
struc SCROLLER |
{ |
.type rb 1 |
.x rw 1 |
.y rw 1 |
.length rw 1 |
.color1 rd 1 |
.size rd 1 |
.pos rd 1 |
.buttons_flags rw 1 |
.ChildButton1 rd 1 |
.ChildButton2 rd 1 |
.mouseX rw 1 |
.mouseY rw 1 |
} |
ButtonExit BUTTON |
VerticalScroller SCROLLER |
HorizontalScroller SCROLLER |
i_end: |
/programs/develop/libGUI/examples/text/GETPROC.ASM |
---|
0,0 → 1,47 |
_ksys_cofflib_getproc: |
mov ebx,[esp+4] |
next_name_check: |
mov ecx,[ebx] |
test ecx,ecx |
jz end_export |
;cmp export string with name |
mov esi,[esp+8] |
xor edi,edi |
next_simbol_check: |
xor eax,eax |
mov al,[ecx] |
test al,al |
jz exit_check_simbol |
xor edx,edx |
mov dl,[esi] |
cmp al,dl |
je simbols_equvalent |
add edi,1 |
jmp exit_check_simbol |
simbols_equvalent: |
add ecx,1 |
add esi,1 |
jmp next_simbol_check |
exit_check_simbol: |
test edi,edi |
jnz function_not_finded |
mov eax,[ebx+4] |
jmp end_export |
function_not_finded: |
add ebx,8 |
jmp next_name_check |
end_export: |
ret 8 |
/programs/develop/libGUI/examples/text/text.asm |
---|
0,0 → 1,364 |
; |
; |
; This is example using GUI component Text from libGUI. |
; |
; |
include 'macros.inc' |
use32 |
db 'MENUET01' |
dd 1 |
dd start |
dd i_end |
dd 1600 |
dd 1600 |
dd 0 |
dd path |
start: |
;init hepe of memory |
mcall 68,11 |
;set current dir as ./ |
call GetPath |
;load dll |
mcall 68,19,path |
test eax,eax |
jnz libGUI_loaded |
mcall 68,19,sys_libGUI_path |
test eax,eax |
jnz libGUI_loaded |
mcall -1 |
libGUI_loaded: |
mov [myexport],eax |
;load dll functions |
push fnDestroyControl |
push [myexport] |
call _ksys_cofflib_getproc |
mov [destroy_control],eax |
push fnSendMessage |
push [myexport] |
call _ksys_cofflib_getproc |
mov [send_message],eax |
push fnCraeteButton |
push [myexport] |
call _ksys_cofflib_getproc |
mov [craete_button],eax |
push fnCraeteText |
push [myexport] |
call _ksys_cofflib_getproc |
mov [craete_text],eax |
;set events mask |
mcall 40,1100111b |
;get standart colors table |
mcall 48,3,ColorsTable,40 |
;********************************************* |
;****************Init Butttons**************** |
;********************************************* |
mov ecx,[ColorsTable+8] |
and ecx,0xffffff |
mov [Button1.type],byte 10010001b |
mov [Button1.x],80 |
mov [Button1.y],50 |
mov [Button1.width],word 70 |
mov [Button1.height],word 20 |
mov [Button1.color1],dword ecx |
mov [Button1.color2],dword 0xffffff |
mov [Button1.text],text1 |
push Button1 |
push Parend |
call [craete_button] |
mov [PointerToControlForButtonExit],eax |
mov ecx,[ColorsTable+8] |
and ecx,0xffffff |
;******************************************** |
;******************Init Text***************** |
;******************************************** |
mov [Text.type],byte 10000000b |
mov [Text.color],0xffffff |
mov [Text.x],5 |
mov [Text.y],10 |
mov [Text.length],36 |
mov [Text.pointer],text_for_text |
push Text |
push Parend |
call [craete_text] |
mov [PointerToControlForText],eax |
call draw_window |
;send message 1 for redrawing ALL controls |
mov [Message],dword 1 |
push Message |
push Parend |
call [send_message] |
still: |
mcall 10 |
;check for redraw window |
cmp eax,1 |
jne no_window |
call draw_window |
mov [Message],dword 1 |
push Message |
push Parend |
call [send_message] |
jmp still |
no_window: |
;check for keys events |
cmp eax,2 |
jne no_keys |
mcall 2 |
shr eax,8 |
mov [Message],dword 2 |
mov [Message+4],eax |
push Message |
push Parend |
call [send_message] |
mov eax,[Message+4] |
cmp al,27 |
je exit |
jmp still |
no_keys: |
;check for pressed butons |
cmp eax,3 |
jne no_buttons |
mcall 17 |
shr eax,8 |
jmp still |
no_buttons: |
;check for mouse events |
cmp eax,6 |
jne no_mouse |
mov [Message],dword 6 |
mcall 37,1 |
mov ebx,eax |
shr eax,16 ;x |
and ebx,0xffff ;y |
mov [Message+4],eax |
mov [Message+8],ebx |
mcall 37,2 |
mov [Message+12],eax |
;send system events to control |
push Message |
push Parend |
call [send_message] |
mov eax,[PointerToControlForButtonExit] |
xor ebx,ebx |
mov bl,byte[eax+45] |
cmp bl,11b |
jne no_crossing_pressing_button |
mov [button_pressed],1 |
no_crossing_pressing_button: |
xor ebx,ebx |
mov bl,byte[eax+45] |
cmp bl,1b |
jne no_crossing_button |
cmp [button_pressed],1 |
jne no_crossing_button |
jmp exit |
no_crossing_button: |
jmp still |
no_mouse: |
jmp still |
exit: |
push [PointerToControlForButtonExit] |
call [destroy_control] |
push [PointerToControlForText] |
call [destroy_control] |
mcall -1 |
;********************************************** |
;*******************Draw window**************** |
;********************************************** |
draw_window: |
mcall 12,1 |
xor eax,eax |
mov ebx,50 |
mov ecx,50 |
shl ebx,16 |
shl ecx,16 |
add ebx,250 |
add ecx,100 |
mov edx,0x03aabbcc |
mov esi,0x805080d0 |
mov edi,0x005080d0 |
mcall |
;call print_controls_information |
mcall 12,2 |
ret |
GetPath: |
mov ebx,255 |
mov ecx,path |
next_symvol: |
mov edx,ecx |
add edx,ebx |
xor eax,eax |
mov al,[edx] |
cmp eax,'/' |
je exit_path |
dec ebx |
jnz next_symvol |
exit_path: |
inc edx |
mov esi,dll_name |
mov edi,edx |
mov ecx,10 |
rep movsb |
ret |
include 'getproc.asm' |
;************************************************************ |
;***************************DATA***************************** |
;************************************************************ |
align 4 |
dll_name db 'libGUI.obj',0 |
sys_libGUI_path db '/sys/lib/libGUI.obj',0 |
text1 db 'Exit',0 |
text_for_text db 'Example of using GUI component text.',0 |
fnDestroyControl db 'DestroyControl',0 |
fnSendMessage db 'SendMessage',0 |
fnCraeteButton db 'CraeteButton',0 |
fnCraeteText db 'CraeteText',0 |
myexport dd 0 |
destroy_control dd 0 |
send_message dd 0 |
craete_button dd 0 |
craete_text dd 0 |
PointerToControlForButtonExit dd 0 |
PointerToControlForText dd 0 |
button_pressed dd 0 |
path rb 256 |
Parend: dd 0,0,0,0,0,0,0,0,0,0,0,0 ;44 bytes |
Message rd 4 |
ColorsTable rd 10 |
struc BUTTON |
{ |
.type db 1 |
.flag db 1 |
.x dw 1 |
.y dw 1 |
.width dw 1 |
.height dw 1 |
.image dd 1 |
.imageX dw 1 |
.imageY dw 1 |
.imageSizeX dw 1 |
.imageSizeY dw 1 |
.transparentColor dd 1 |
.text dd 1 |
.textX dw 1 |
.textY dw 1 |
.textcolor dd 1 |
.color1 dd 1 |
.color2 dd 1 |
.mouseX dw 1 |
.mouseY dw 1 |
} |
struc TEXT |
{ |
.type rb 1 |
.flag rb 1 |
.color rd 1 |
.x rd 1 |
.y rd 1 |
.length rd 1 |
.pointer rd 1 |
} |
Button1 BUTTON |
Text TEXT |
i_end: |