/contrib/C_Layer/INCLUDE/kolibri_checkbox.h |
---|
3,6 → 3,13 |
#include "kolibri_colors.h" |
/* |
ch_flag_en - ôëàã óñòàíîâëåííîãî ÷åê áîêñà |
ch_flag_top - ôëàã ðàñïîëîæåíèÿ òåêñòà ââåðõó |
ch_flag_middle - ôëàã ðàñïîëîæåíèÿ òåêñòà â öåíòðå |
ch_flag_bottom - ôëàã ðàñïîëîæåíèÿ òåêñòà â íèçó ò.å. ïî óìîë÷àíèþ ïðèíèìàåòñÿ çíà÷åíèå âíèçó |
*/ |
enum CHECKBOX_FLAGS { |
CHECKBOX_IS_SET = 0x00000002 |
/* Add more flags later */ |
32,7 → 39,7 |
new_checkbox -> left_s = (tlx << 16) + sizex; |
new_checkbox -> top_s = (tly << 16) + sizey; |
new_checkbox -> ch_text_margin = 10; |
new_checkbox -> color = 0xFFFFFFFF; |
new_checkbox -> color = 0xFFFFFFFF; // 0x80AABBCC, 31-bit mus be set asciiz |
new_checkbox -> border_color = kolibri_color_table.color_work_graph; |
new_checkbox -> text_color = kolibri_color_table.color_work_text; |
new_checkbox -> text = label_text; |
/contrib/C_Layer/INCLUDE/kolibri_editbox.h |
---|
2,24 → 2,48 |
#define KOLIBRI_EDITBOX_H |
#include "kolibri_colors.h" |
/* flags meaning |
ed_figure_only= 1000000000000000b ;îäíè ñèìâîëû |
ed_always_focus= 100000000000000b |
ed_focus= 10b ;ôîêóñ ïðèëîæåíèÿ |
ed_pass= 1b ;ïîëå ñ ïàðîëåì |
ed_shift_on= 1000b ;åñëè íå óñòàíîâëåí -çíà÷èò âïåðâûå íàæàò shift,åñëè áûë óñòàíîâëåí, çíà÷èò ìû óæå ÷òî - òî äåëàëè óäåðæèâàÿ shift |
ed_shift_on_off=1111111111110111b |
ed_shift= 100b ;âêëþ÷àåòñÿ ïðè íàæàòèè íà shift ò.å. åñëè íàæèìàþ |
ed_shift_off= 1111111111111011b |
ed_shift_bac= 10000b ;áèò äëÿ î÷èñòêè âûäåëåíîãî shift ò.å. ïðè óñòàíîâêå ãîâîðèò ÷òî åñòü âûäåëåíèå |
ed_shift_bac_cl=1111111111101111b ;î÷èñòêà ïðè óäàëåíèè âûäåëåíèÿ |
ed_shift_cl= 1111111111100011b |
ed_shift_mcl= 1111111111111011b |
ed_left_fl= 100000b |
ed_right_fl= 1111111111011111b |
ed_offset_fl= 1000000b |
ed_offset_cl= 1111111110111111b |
ed_insert= 10000000b |
ed_insert_cl= 1111111101111111b |
ed_mouse_on = 100000000b |
ed_mous_adn_b= 100011000b |
ed_mouse_on_off=1111111011111111b |
*/ |
typedef struct { |
unsigned int width; |
unsigned int width; |
unsigned int left; |
unsigned int top; |
unsigned int color; |
unsigned int shift_color; |
unsigned int focus_border_color; |
unsigned int top; |
unsigned int color; |
unsigned int shift_color; // selected text color |
unsigned int focus_border_color; |
unsigned int blur_border_color; |
unsigned int text_color; |
unsigned int max; |
char *text; |
unsigned int mouse_variable; |
unsigned int mouse_variable; // mus be int* pointer to saved mouse pos ?? |
unsigned int flags; |
unsigned int size; // used symbols in buffer without trailing zero |
unsigned int pos; // cursor position |
/* The following struct members are not used by the users of API */ |
unsigned int size; |
unsigned int pos; |
unsigned int offset; |
unsigned int cl_curs_x; |
unsigned int cl_curs_y; |
27,18 → 51,18 |
unsigned int shift_old; |
}edit_box; |
/* Initializes an Editbox with sane settings, sufficient for most use. |
This will let you create a box and position it somewhere on the screen. |
The text_buffer is a pointer to a character array and needs to be as long as |
AT LEAST MAX_CHARS + 1.If the text_buffer is smaller, it will crash if user |
/* Initializes an Editbox with sane settings, sufficient for most use. |
This will let you create a box and position it somewhere on the screen. |
The text_buffer is a pointer to a character array and needs to be as long as |
AT LEAST MAX_CHARS + 1.If the text_buffer is smaller, it will crash if user |
types more characters than what will fit into the text buffer. |
Allocating buffer space automatically so that programmer can be carefree now. |
This also automatically adjusts the size of edit box so that it can hold enough characters. |
All you need is : |
All you need is : |
tlx,tly = Coordinates of the beginning of the edit box. |
tlx,tly = Coordinates of the beginning of the edit box. |
max_chars = Limit of number of characters user can enter into edit box. |
*/ |
53,10 → 77,10 |
new_textbox -> width = max_chars * PIXELS_PER_CHAR; |
new_textbox -> left = tlx; |
new_textbox -> top = tly; |
new_textbox -> top = tly; |
new_textbox -> color = 0xFFFFFF; /* Always make white edit boxes */ |
new_textbox -> shift_color = 0x6a9480; |
new_textbox -> focus_border_color = kolibri_color_table.color_work_graph; |
new_textbox -> shift_color = 0x6a9480; |
new_textbox -> focus_border_color = kolibri_color_table.color_work_graph; |
new_textbox -> blur_border_color = 0x6a9480; |
new_textbox -> text_color = kolibri_color_table.color_work_text; /* Always black text when typing */ |
new_textbox -> max = max_chars; |
85,5 → 109,6 |
extern void editbox_key(edit_box *) __attribute__((__stdcall__)); |
extern void (*edit_box_mouse)(edit_box *) __attribute__((__stdcall__)); |
extern void (*edit_box_set_text)(edit_box *, char *) __attribute__((__stdcall__)); |
extern volatile unsigned press_key; |
#endif /* KOLIBRI_EDITBOX_H */ |
/contrib/C_Layer/INCLUDE/kolibri_gui.h |
---|
13,13 → 13,20 |
#include "kolibri_gui_elements.h" |
enum KOLIBRI_GUI_EVENTS { |
KOLIBRI_EVENT_REDRAW = 1, /* Window and window elements should be redrawn */ |
KOLIBRI_EVENT_KEY = 2, /* A key on the keyboard was pressed */ |
KOLIBRI_EVENT_BUTTON = 3, /* A button was clicked with the mouse */ |
KOLIBRI_EVENT_MOUSE = 6 /* Mouse activity (movement, button press) was detected */ |
KOLIBRI_EVENT_NONE = 0, /* Event queue is empty */ |
KOLIBRI_EVENT_REDRAW = 1, /* Window and window elements should be redrawn */ |
KOLIBRI_EVENT_KEY = 2, /* A key on the keyboard was pressed */ |
KOLIBRI_EVENT_BUTTON = 3, /* A button was clicked with the mouse */ |
KOLIBRI_EVENT_DESKTOP = 5, /* Desktop redraw finished */ |
KOLIBRI_EVENT_MOUSE = 6, /* Mouse activity (movement, button press) was detected */ |
KOLIBRI_EVENT_IPC = 7, /* Interprocess communication notify */ |
KOLIBRI_EVENT_NETWORK = 8, /* Network event */ |
KOLIBRI_EVENT_DEBUG = 9, /* Debug subsystem event */ |
KOLIBRI_EVENT_IRQBEGIN = 16 /* 16..31 IRQ0..IRQ15 interrupt =IRQBEGIN+IRQn */ |
}; |
#define BUTTON_CLOSE 0x1 |
#define BUTTON_CLOSE 0x1 |
#define BTN_QUIT 1 |
void kolibri_handle_event_redraw(kolibri_window* some_window) |
{ |
40,7 → 47,7 |
do |
{ |
/* The redraw_fn serves as draw_fn on initial draw */ |
if(kolibri_gui_op_table[current_element -> type].redraw_fn) |
if((int)kolibri_gui_op_table[current_element -> type].redraw_fn > 0) // -1 if DLL link fail |
kolibri_gui_op_table[current_element -> type].redraw_fn(current_element -> element); |
//sie after fixing calling conventions no more needed |
72,7 → 79,7 |
do |
{ |
/* Only execute if the function pointer isn't NULL */ |
if(kolibri_gui_op_table[current_element -> type].key_fn) |
if((int)kolibri_gui_op_table[current_element -> type].key_fn > 0) |
kolibri_gui_op_table[current_element -> type].key_fn(current_element -> element); |
current_element = current_element -> next; |
89,7 → 96,7 |
do |
{ |
if(kolibri_gui_op_table[current_element -> type].mouse_fn) |
if((int)kolibri_gui_op_table[current_element -> type].mouse_fn > 0) |
kolibri_gui_op_table[current_element -> type].mouse_fn(current_element -> element); |
current_element = current_element -> next; |
/contrib/C_Layer/INCLUDE/kolibri_gui_elements.h |
---|
7,6 → 7,10 |
#include "kolibri_button.h" |
#include "kolibri_progressbar.h" |
#include "kolibri_frame.h" |
#include "kolibri_scrollbar.h" |
#include "kolibri_statictext.h" |
#define X_Y(x,y) (((x)<<16)|(y)) |
/* enum KOLIBRI_GUI_ELEMENT_TYPE contains all available GUI items from box_lib */ |
/* More elements can be added from other libraries as required */ |
14,7 → 18,8 |
KOLIBRI_EDIT_BOX, |
KOLIBRI_CHECK_BOX, |
KOLIBRI_RADIO_BUTTON, |
KOLIBRI_SCROLL_BAR, |
KOLIBRI_SCROLL_BAR_H, |
KOLIBRI_SCROLL_BAR_V, |
KOLIBRI_DYNAMIC_BUTTON, |
KOLIBRI_MENU_BAR, |
KOLIBRI_FILE_BROWSER, |
23,7 → 28,9 |
KOLIBRI_TEXT_EDITOR, |
KOLIBRI_FRAME, |
KOLIBRI_PROGRESS_BAR, |
KOLIBRI_STATICTEXT, |
KOLIBRI_STATICNUM, |
KOLIBRI_BUTTON, |
/* Add elements above this element in order to let KOLIBRI_NUM_GUI_ELEMENTS */ |
87,12 → 94,35 |
kolibri_gui_op_table[KOLIBRI_PROGRESS_BAR].redraw_fn = (cb_elem_boxlib)progressbar_draw; |
kolibri_gui_op_table[KOLIBRI_PROGRESS_BAR].mouse_fn = NULL; |
kolibri_gui_op_table[KOLIBRI_PROGRESS_BAR].key_fn = NULL; |
debug_board_printf("PROGRESS (%x,%x,%x)\n", progressbar_draw,0,0); |
/* Setting up functions for frame GUI elements*/ |
kolibri_gui_op_table[KOLIBRI_FRAME].redraw_fn = (cb_elem_boxlib)frame_draw; |
kolibri_gui_op_table[KOLIBRI_FRAME].mouse_fn = NULL; |
kolibri_gui_op_table[KOLIBRI_FRAME].key_fn = NULL; |
debug_board_printf("FRAME (%x,%x,%x)\n", frame_draw,0,0); |
/* scrollbars */ |
kolibri_gui_op_table[KOLIBRI_SCROLL_BAR_H].redraw_fn = (cb_elem_boxlib)scrollbar_h_draw; |
kolibri_gui_op_table[KOLIBRI_SCROLL_BAR_H].mouse_fn = (cb_elem_boxlib)scrollbar_h_mouse; |
kolibri_gui_op_table[KOLIBRI_SCROLL_BAR_H].key_fn = NULL; |
debug_board_printf("SCROLL_H (%x,%x,%x)\n", scrollbar_h_draw,scrollbar_h_mouse,0); |
kolibri_gui_op_table[KOLIBRI_SCROLL_BAR_V].redraw_fn = (cb_elem_boxlib)scrollbar_v_draw; |
kolibri_gui_op_table[KOLIBRI_SCROLL_BAR_V].mouse_fn = (cb_elem_boxlib)scrollbar_v_mouse; |
kolibri_gui_op_table[KOLIBRI_SCROLL_BAR_V].key_fn = NULL; |
debug_board_printf("SCROLL_V (%x,%x,%x)\n", scrollbar_v_draw,scrollbar_v_mouse,0); |
kolibri_gui_op_table[KOLIBRI_STATICTEXT].redraw_fn = (cb_elem_boxlib)statictext_draw; |
kolibri_gui_op_table[KOLIBRI_STATICTEXT].mouse_fn = NULL; |
kolibri_gui_op_table[KOLIBRI_STATICTEXT].key_fn = NULL; |
kolibri_gui_op_table[KOLIBRI_STATICNUM].redraw_fn = (cb_elem_boxlib)staticnum_draw; |
kolibri_gui_op_table[KOLIBRI_STATICNUM].mouse_fn = NULL; |
kolibri_gui_op_table[KOLIBRI_STATICNUM].key_fn = NULL; |
debug_board_printf("STATICNUM (%x,%x,%x)\n", staticnum_draw,0,0); |
} |
/* Create a new main GUI window for KolibriOS */ |
/contrib/C_Layer/INCLUDE/kolibri_progressbar.h |
---|
1,39 → 1,39 |
#ifndef KOLIBRI_PROGRESSBAR_H |
#define KOLIBRI_PROGRESSBAR_H |
struct progress_bar { |
unsigned int value; |
typedef struct { |
unsigned int value; |
unsigned int left; |
unsigned int top; |
unsigned int width; |
unsigned int height; |
unsigned int style; |
unsigned int top; |
unsigned int width; |
unsigned int height; |
unsigned int style; |
unsigned int min; |
unsigned int max; |
unsigned int back_color; |
unsigned int progress_color; |
unsigned int frame_color; |
}; |
} progressbar; |
struct progress_bar* kolibri_new_progress_bar(unsigned int min_value, unsigned int max_value, unsigned int cur_value, unsigned int tlx, unsigned int tly, unsigned int sizex, unsigned int sizey) |
progressbar* kolibri_new_progressbar(unsigned int min_value, unsigned int max_value, unsigned int cur_value, unsigned int tlx, unsigned int tly, unsigned int sizex, unsigned int sizey) |
{ |
struct progress_bar *new_progressbar = (struct progress_bar *)malloc(sizeof(struct progress_bar)); |
new_progressbar -> value = cur_value; |
progressbar *new_progressbar = (progressbar*)malloc(sizeof(progressbar)); |
new_progressbar -> value = cur_value; |
new_progressbar -> left = tlx; |
new_progressbar -> top = tly; |
new_progressbar -> width = sizex; |
new_progressbar -> height = sizey; |
new_progressbar -> style = 1; |
new_progressbar -> top = tly; |
new_progressbar -> width = sizex; |
new_progressbar -> height = sizey; |
new_progressbar -> style = 1; |
new_progressbar -> min = min_value; |
new_progressbar -> max = max_value; |
new_progressbar -> back_color = 0xffffff; |
new_progressbar -> progress_color = 0x00ff00; |
new_progressbar -> frame_color = 0x000000; |
new_progressbar -> back_color = 0xffffff; // white |
new_progressbar -> progress_color = 0x00ff00; // green |
new_progressbar -> frame_color = 0x000000; // black |
return new_progressbar; |
} |
extern void (*progressbar_draw)(struct progress_bar *) __attribute__((__stdcall__)); |
extern void (*progressbar_progress)(struct progress_bar *) __attribute__((__stdcall__)); |
extern void (*progressbar_draw)(progressbar *) __attribute__((__stdcall__)); |
extern void (*progressbar_progress)(progressbar *) __attribute__((__stdcall__)); |
#endif /* KOLIBRI_PROGRESSBAR_H */ |
/contrib/C_Layer/INCLUDE/kolibri_scrollbar.h |
---|
0,0 → 1,63 |
#ifndef KOLIBRI_SCROLLBAR_H |
#define KOLIBRI_SCROLLBAR_H |
typedef struct { |
// uint16_t xsize; |
// uint16_t xpos; |
// uint16_t ysize; |
// uint16_t ypos; |
uint32_t x_w; |
uint32_t y_h; |
uint32_t btn_height; |
uint32_t type; |
uint32_t max_area; |
uint32_t cur_area; |
uint32_t position; |
uint32_t back_color; |
uint32_t front_color; |
uint32_t line_color; |
uint32_t redraw; |
uint16_t delta; |
uint16_t delta2; |
uint16_t r_size_x; |
uint16_t r_start_x; |
uint16_t r_size_y; |
uint16_t r_start_y; |
uint32_t m_pos; |
uint32_t m_pos2; |
uint32_t m_keys; |
uint32_t run_size; |
uint32_t position2; |
uint32_t work_size; |
uint32_t all_redraw; |
uint32_t ar_offset; |
} scrollbar; |
scrollbar* kolibri_new_scrollbar(uint32_t x_w, uint32_t y_h, uint32_t btn_height, uint32_t max_area, |
uint32_t cur_area, uint32_t position, uint32_t back_color, uint32_t front_color, uint32_t line_color) |
{ |
scrollbar *sb = (scrollbar *)calloc(1, sizeof(scrollbar)); |
sb->x_w = x_w; |
sb->y_h = y_h; |
sb->btn_height = btn_height; |
sb->type = 1; |
sb->max_area = max_area; |
sb->cur_area = cur_area; |
sb->position = position; |
sb->line_color = 0; //line_color; // 0 |
sb->back_color = 0xeeeeee; // back_color; // 0xeeeeee |
sb->front_color = 0xbbddff; //front_color; // 0xbbddff |
sb->ar_offset = max_area / 30; // temporary step 3% |
sb->all_redraw = 1; |
return sb; |
}; |
//use_optionbox_driver |
extern void (*scrollbar_h_draw)(scrollbar*) __attribute__((__stdcall__)); |
extern void (*scrollbar_h_mouse)(scrollbar*) __attribute__((__stdcall__)); |
extern void (*scrollbar_v_draw)(scrollbar*) __attribute__((__stdcall__)); |
extern void (*scrollbar_v_mouse)(scrollbar*) __attribute__((__stdcall__)); |
#endif /* KOLIBRI_SCROLLBAR_H */ |
/contrib/C_Layer/INCLUDE/kolibri_statictext.h |
---|
0,0 → 1,121 |
#ifndef KOLIBRI_STATICTEXT_H |
#define KOLIBRI_STATICTEXT_H |
typedef enum { |
cp866, // 6x9 |
CP866, // 8x16 |
UTF16, |
UTF8 |
} encoding_t; |
typedef struct { |
uint32_t start_xy; |
char *text; |
uint32_t color_flags; |
uint32_t bg_color; |
}statictext; |
typedef struct { |
uint32_t start_xy; |
int32_t number; |
uint32_t color_flags; |
uint32_t bg_color; |
uint16_t width; |
}staticnum; |
statictext* kolibri_statictext(statictext* st, uint32_t xy, char *text, encoding_t enc, int size, color_t font, color_t bg) |
{ |
st->start_xy = xy; |
st->text = text; |
st->color_flags = 0x80000000; // asciiz |
st->bg_color = bg; |
if(bg & 0xFFFFFF) st->color_flags |= 0x40000000;// use background |
st->color_flags |= ((enc & 1) << 4) | (size & 7) << 24; |
st->color_flags |= font & 0xFFFFFF; |
return st; |
} |
statictext* kolibri_statictext_def(statictext* st, uint32_t xy, char *text) |
{ |
return kolibri_statictext(st, xy, text, 0, 0, kolibri_color_table.color_work_text, 0); |
} |
statictext* kolibri_new_statictext(uint32_t xy, char *text, encoding_t enc, int size, color_t font, color_t bg) |
{ |
statictext *st = (statictext*)malloc(sizeof(statictext)); |
return kolibri_statictext(st, xy, text, enc, size, font, bg); |
} |
statictext* kolibri_new_statictext_def(uint32_t xy, char *text) |
{ |
return kolibri_new_statictext(xy, text, 0, 0, kolibri_color_table.color_work_text, 0); |
} |
__attribute__((__stdcall__)) |
void statictext_draw(statictext *st) |
{ |
__asm__ __volatile__( |
"int $0x40" |
::"a"(4), |
"b"(st->start_xy), |
"c"(st->color_flags), |
"d"(st->text), |
"D"(st->bg_color) |
:); |
} |
staticnum* kolibri_staticnum(staticnum* st, uint32_t xy, int32_t width, int16_t number, encoding_t enc, int size, color_t font, color_t bg) |
{ |
st->start_xy = xy; |
st->number = number; |
st->color_flags = 0; |
st->bg_color = bg; |
if(bg & 0xFFFFFF) st->color_flags |= 0x40000000;// use background |
st->color_flags |= ((enc & 1) << 4) | (size & 7) << 24; |
st->color_flags |= font & 0xFFFFFF; |
st->width = width; |
return st; |
} |
staticnum* kolibri_staticnum_def(staticnum* st, uint32_t xy, int16_t width, int32_t number) |
{ |
return kolibri_staticnum(st, xy, width, number, 0, 0, kolibri_color_table.color_work_text, 0); |
} |
staticnum* kolibri_new_staticnum(uint32_t xy, int32_t width, int32_t number, encoding_t enc, int size, color_t font, color_t bg) |
{ |
staticnum *st = (staticnum*)malloc(sizeof(staticnum)); |
return kolibri_staticnum(st, xy, width, number, enc, size, font, bg); |
} |
staticnum* kolibri_new_staticnum_def(uint32_t xy, int32_t width, int32_t number) |
{ |
return kolibri_new_staticnum(xy, width, number, cp866, 0, kolibri_color_table.color_work_text, 0); |
} |
__attribute__((__stdcall__)) |
void staticnum_draw(staticnum *st) |
{ |
register uint32_t fmt; |
if (st->width < 0) |
fmt = (-st->width << 16); // leading zeros, decimal |
else |
fmt = (st->width << 16) | 0x80000000; // no leading zeros, decimal |
__asm__ __volatile__( |
"int $0x40" |
::"a"(47), |
"b"(fmt), |
"c"(st->number), |
"d"(st->start_xy), |
"S"(st->color_flags), |
"D"(st->bg_color) |
:); |
} |
#endif /* KOLIBRI_STATICTEXT_H */ |