Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 6478 → Rev 6479

/contrib/C_Layer/INCLUDE/kolibri_colors.h
1,16 → 1,31
#ifndef KOLIBRI_COLORS_H
#define KOLIBRI_COLORS_H
/*
* +0: dword: frames - öâåò ðàìêè
* +4: dword: grab - öâåò çàãîëîâêà
* +8: dword: grab_button - öâåò êíîïêè íà ïîëîñå çàãîëîâêà
* +12 = +0xC: dword: grab_button_text - öâåò òåêñòà íà êíîïêå
íà ïîëîñå çàãîëîâêà
* +16 = +0x10: dword: grab_text - öâåò òåêñòà íà çàãîëîâêå
* +20 = +0x14: dword: work - öâåò ðàáî÷åé îáëàñòè
* +24 = +0x18: dword: work_button - öâåò êíîïêè â ðàáî÷åé îáëàñòè
* +28 = +0x1C: dword: work_button_text - öâåò òåêñòà íà êíîïêå
â ðàáî÷åé îáëàñòè
* +32 = +0x20: dword: work_text - öâåò òåêñòà â ðàáî÷åé îáëàñòè
* +36 = +0x24: dword: work_graph - öâåò ãðàôèêè â ðàáî÷åé îáëàñòè
*/
 
typedef struct {
unsigned int color_frame_area;
unsigned int color_grab_bar;
unsigned int color_grab_bar_button;
unsigned int color_grab_button_text;
unsigned int color_grab_text;
unsigned int color_work_area;
unsigned int color_work_button;
unsigned int color_work_button_text;
unsigned int color_work_text;
unsigned int color_work_graph;
unsigned int color_frame_area; // 0 öâåò ðàìêè
unsigned int color_grab_bar; // 4
unsigned int color_grab_bar_button; // 8
unsigned int color_grab_button_text; // 12
unsigned int color_grab_text; // 16
unsigned int color_work_area; // 20
unsigned int color_work_button; // 24
unsigned int color_work_button_text; // 28
unsigned int color_work_text; // 32
unsigned int color_work_graph; // 36
}kolibri_system_colors;
 
kolibri_system_colors kolibri_color_table;
/contrib/C_Layer/INCLUDE/kolibri_editbox.h
6,7 → 6,7
/* flags meaning
ed_figure_only= 1000000000000000b ;îäíè ñèìâîëû
ed_always_focus= 100000000000000b
ed_focus= 10b ;ôîêóñ ïðèëîæåíèÿ
ed_focus= 10b ;ôîêóñ ââîäà ïðèëîæåíèÿ
ed_pass= 1b ;ïîëå ñ ïàðîëåì
ed_shift_on= 1000b ;åñëè íå óñòàíîâëåí -çíà÷èò âïåðâûå íàæàò shift,åñëè áûë óñòàíîâëåí, çíà÷èò ìû óæå ÷òî - òî äåëàëè óäåðæèâàÿ shift
ed_shift_on_off=1111111111110111b
25,9 → 25,15
ed_mouse_on = 100000000b
ed_mous_adn_b= 100011000b
ed_mouse_on_off=1111111011111111b
ed_mouse_on_off= not (ed_mouse_on)
ed_ctrl_on = 1000000000b
ed_ctrl_off = not (ed_ctrl_on)
ed_alt_on = 10000000000b
ed_alt_off = not (ed_alt_on)
ed_disabled= 100000000000b
*/
 
typedef struct {
typedef struct edit_box_t {
unsigned int width;
unsigned int left;
unsigned int top;
38,7 → 44,7
unsigned int text_color;
unsigned int max;
char *text;
unsigned int mouse_variable; // mus be int* pointer to saved mouse pos ??
struct edit_box_t** mouse_variable; // must be pointer edit_box** to save focused editbox
unsigned int flags;
 
unsigned int size; // used symbols in buffer without trailing zero
66,11 → 72,11
max_chars = Limit of number of characters user can enter into edit box.
*/
 
edit_box* kolibri_new_edit_box(unsigned int tlx, unsigned int tly, unsigned int max_chars)
edit_box* kolibri_new_edit_box(unsigned int tlx, unsigned int tly, unsigned int max_chars, edit_box **editbox_interlock)
{
unsigned int PIXELS_PER_CHAR = 7;
edit_box *new_textbox = (edit_box *)malloc(sizeof(edit_box));
char *text_buffer = (char *)calloc(max_chars + 1, sizeof(char));
edit_box *new_textbox = (edit_box *)calloc(1, sizeof(edit_box));
char *text_buffer = (char *)calloc(max_chars + 2, sizeof(char)); // +2 as asked in box_lib src
 
/* Update blur_border_color and shift_color from box_lib.mac macro */
/* edit_boxes_set_sys_color */
85,19 → 91,9
new_textbox -> text_color = kolibri_color_table.color_work_text; /* Always black text when typing */
new_textbox -> max = max_chars;
new_textbox -> text = text_buffer;
new_textbox -> mouse_variable = 1; /* let the mouse take control? */
new_textbox -> mouse_variable = editbox_interlock;
new_textbox -> flags = 0x00000000;
/* If these lines are uncommented, the executable will crash for no reason at start */
/* Even though these lines are not ever read it ALWAYS causes a crash, even crashes MTDBG. What gives? */
 
new_textbox -> size = 0;
new_textbox -> pos = 0;
new_textbox -> offset = 0;
new_textbox -> cl_curs_x = 0;
new_textbox -> cl_curs_y = 0;
new_textbox -> shift = 0;
new_textbox -> shift_old = 0;
 
return new_textbox;
}
 
/contrib/C_Layer/INCLUDE/kolibri_frame.h
7,42 → 7,60
};
 
typedef struct {
unsigned int type;
uint16_t size_x;
uint16_t start_x;
uint16_t size_y;
uint16_t start_y;
unsigned int ext_col;
unsigned int int_col;
unsigned int draw_text_flag;
uint32_t type;
uint32_t x_w;
uint32_t y_h;
color_t ext_col;
color_t int_col;
uint32_t draw_text_flag;
char *text_pointer;
unsigned int text_position;
unsigned int font_number;
unsigned int font_size_y;
unsigned int font_color;
unsigned int font_backgr_color;
uint32_t text_position;
uint32_t font_number;
uint32_t font_size_y;
color_t font_color;
color_t font_bg_color;
}frame;
 
frame* kolibri_new_frame(uint16_t tlx, uint16_t tly, uint16_t sizex, uint16_t sizey, unsigned int ext_col, unsigned int int_col, unsigned int draw_text_flag, char *text_pointer, unsigned int text_position, unsigned int font_color, unsigned int font_bgcolor)
inline frame* kolibri_frame(frame* f, uint32_t x_w, uint32_t y_h, color_t ext_col, color_t int_col, char *text, uint32_t text_position, color_t font_color, color_t font_bgcolor)
{
f->type = 0;
f->x_w = x_w;
f->y_h = y_h;
f->ext_col = ext_col;
f->int_col = int_col;
f->draw_text_flag = text != NULL;
f->text_pointer = text;
f->text_position = text_position;
f->font_number = 0; // 0 == font 6x9, 1==8x16
f->font_size_y = 9;
f->font_color = font_color | 0x80000000;
f->font_bg_color = font_bgcolor;
 
return f;
}
 
inline frame* kolibri_new_frame(uint32_t x_w, uint32_t y_h, color_t ext_col, color_t int_col, char *text, uint32_t text_position, color_t font_color, color_t font_bgcolor)
{
frame *new_frame = (frame *)malloc(sizeof(frame));
new_frame -> type = 0;
new_frame -> size_x = sizex;
new_frame -> start_x = tlx;
new_frame -> size_y = sizey;
new_frame -> start_y = tly;
new_frame -> ext_col = ext_col;
new_frame -> int_col = int_col;
new_frame -> draw_text_flag = draw_text_flag;
new_frame -> text_pointer = text_pointer;
new_frame -> text_position = text_position;
new_frame -> font_number = 0; // 0 == font 6x9, 1==8x16
new_frame -> font_size_y = 9;
new_frame -> font_color = font_color;
new_frame -> font_backgr_color = font_bgcolor;
return new_frame;
return kolibri_frame(new_frame, x_w, y_h, ext_col, int_col, text, text_position, font_color, font_bgcolor);
}
 
inline frame* kolibri_frame_def(frame* f, uint32_t x_w, uint32_t y_h, char *text)
{
return kolibri_frame(f, x_w, y_h, 0x00FCFCFC, 0x00DCDCDC, text, TOP, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area);
}
 
inline frame* kolibri_new_frame_def(uint32_t x_w, uint32_t y_h, char *text)
{
return kolibri_new_frame(x_w, y_h, 0x00FCFCFC, 0x00DCDCDC, text, TOP, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area);
}
 
inline void gui_add_frame(kolibri_window *wnd, frame* f)
{
kolibri_window_add_element(wnd, KOLIBRI_FRAME, f);
}
 
 
extern void (*frame_draw)(frame *) __attribute__((__stdcall__));
 
#endif /* KOLIBRI_FRAME_H */
/contrib/C_Layer/INCLUDE/kolibri_gui.h
1,9 → 1,6
#ifndef KOLIBRI_GUI_H
#define KOLIBRI_GUI_H
 
#include <stdlib.h> /* for malloc() */
#include <kos32sys.h>
 
#include "kolibri_debug.h" /* work with debug board */
 
/* boxlib loader */
/contrib/C_Layer/INCLUDE/kolibri_gui_elements.h
1,23 → 1,14
#ifndef KOLIBRI_GUI_ELEMENTS_H
#define KOLIBRI_GUI_ELEMENTS_H
 
/* GUI Elements being used */
#include "kolibri_editbox.h"
#include "kolibri_checkbox.h"
#include "kolibri_button.h"
#include "kolibri_progressbar.h"
#include "kolibri_frame.h"
#include "kolibri_scrollbar.h"
#include "kolibri_statictext.h"
#include "kolibri_colors.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 */
enum KOLIBRI_GUI_ELEMENT_TYPE {
KOLIBRI_EDIT_BOX,
KOLIBRI_CHECK_BOX,
KOLIBRI_RADIO_BUTTON,
KOLIBRI_OPTIONGROUP,
KOLIBRI_SCROLL_BAR_H,
KOLIBRI_SCROLL_BAR_V,
KOLIBRI_DYNAMIC_BUTTON,
68,6 → 59,23
}kolibri_window;
 
/*---------------------End of Structure and enum definitions---------------*/
 
void kolibri_window_add_element(kolibri_window *some_window, enum KOLIBRI_GUI_ELEMENT_TYPE element_type, void *some_gui_element); // forward declaration
 
/* GUI Elements being used */
#include "kolibri_editbox.h"
#include "kolibri_checkbox.h"
#include "kolibri_button.h"
#include "kolibri_progressbar.h"
#include "kolibri_frame.h"
#include "kolibri_scrollbar.h"
#include "kolibri_statictext.h"
#include "kolibri_optionbox.h"
 
#define X_Y(x,y) (((x)<<16)|(y))
 
 
 
/*---------------------Define various functions for initializing GUI-------*/
 
/* Master table containing operations for various GUI elements in one place */
94,7 → 102,6
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;
101,19 → 108,14
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;
122,7 → 124,12
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);
 
kolibri_gui_op_table[KOLIBRI_OPTIONGROUP].redraw_fn = (cb_elem_boxlib)option_box_draw;
kolibri_gui_op_table[KOLIBRI_OPTIONGROUP].mouse_fn = (cb_elem_boxlib)option_box_mouse;
kolibri_gui_op_table[KOLIBRI_OPTIONGROUP].key_fn = NULL;
 
debug_board_printf("KOLIBRI_OPTIONGROUP (%x,%x,%x)\n", option_box_draw,option_box_mouse,0);
}
 
/* Create a new main GUI window for KolibriOS */
/contrib/C_Layer/INCLUDE/kolibri_optionbox.h
0,0 → 1,55
#ifndef KOLIBRI_OPTIONBOX_H
#define KOLIBRI_OPTIONBOX_H
 
typedef struct option_box_t{
struct option_box_t **selected;
uint16_t posx;
uint16_t posy;
uint32_t text_margin; // = 4 ðàññòîÿíèå îò ïðÿìîóãîëüíèêà ÷åê áîêñà äî íàäïèñè
uint32_t size; // 12 ðàçìåð êâàäðàòà ÷åê áîêñà
color_t color;
color_t border_color; // individual border
color_t text_color;
char *text;
uint32_t text_len;
uint32_t flags;
}option_box;
 
extern void (*option_box_draw)(option_box **) __attribute__((__stdcall__));
extern void (*option_box_mouse)(option_box **)__attribute__((__stdcall__));
 
inline option_box* gui_optionbox(option_box* ob, uint32_t x_y, char* text, option_box**select)
{
ob->selected = select;
ob->posx = x_y >> 16;
ob->posy = x_y & 0xFFFF;
ob->text_margin = 4;
ob->size = 12;
ob->color = kolibri_color_table.color_work_button_text;
ob->border_color = kolibri_color_table.color_work_button;
ob->text_color = kolibri_color_table.color_work_text | 0x80000000;
ob->text = text;
ob->text_len = strlen(text);
ob->flags = 0; // not used
 
return ob;
}
 
inline option_box* gui_new_optionbox(uint32_t x_y, char* text, option_box**select)
{
option_box* ob = malloc(sizeof(option_box));
 
return gui_optionbox(ob, x_y, text, select);
}
 
#define gui_optionbox_def(a,b,c,d) gui_optionbox(a,b,c,d)
 
#define gui_new_optionbox_def(a,b,c) gui_new_optionbox(a,b,c)
 
inline void gui_add_optiongroup(kolibri_window *wnd, option_box** option_group)
{
kolibri_window_add_element(wnd, KOLIBRI_OPTIONGROUP, option_group);
}
 
 
#endif /* KOLIBRI_OPTIONBOX_H */