Subversion Repositories Kolibri OS

Compare Revisions

Ignore whitespace Rev 6466 → Rev 6470

/contrib/C_Layer/ASM/Makefile
2,6 → 2,6
FASM = fasm
 
all: $(patsubst %.asm,%.obj,$(wildcard *.asm))
mv $^ ../OBJ/
mv $^ ../OBJ
%.obj: %.asm
$(FASM) $< $%
/contrib/C_Layer/ASM/loadboxlib.asm
12,7 → 12,7
include '../../../programs/dll.inc'
public init_boxlib as '_init_boxlib_asm'
public editbox_key as '_editbox_key@4'
public editbox_key_thunk as '_editbox_key@4' ; renamed due to ambiguity
public press_key as '_press_key'
;;; Returns 0 on success. -1 on failure.
 
34,7 → 34,7
;; Wrapper to handle edit_box_key function for editboxes.
;; Call this baby from C (refer kolibri_editbox.h for details)
editbox_key:
editbox_key_thunk:
mov [oldebp], ebp ;Save ebp because GCC is crazy for it otherwise.
pop ebp ;Save return address in ebp. Stack top is param now.
mov eax, dword [press_key]
59,12 → 59,12
check_box_mouse2, 'check_box_mouse2' , \
option_box_draw, 'option_box_draw' , \
option_box_mouse, 'option_box_mouse' , \
scroll_bar_vertical_draw, 'scrollbar_ver_draw' , \
scroll_bar_vertical_mouse, 'scrollbar_ver_mouse' , \
scroll_bar_horizontal_draw, 'scrollbar_hor_draw' , \
scroll_bar_horizontal_mouse, 'scrollbar_hor_mouse' , \
dinamic_button_draw, 'dbutton_draw' , \
dinamic_button_mouse, 'dbutton_mouse' , \
scrollbar_v_draw, 'scrollbar_v_draw' , \
scrollbar_v_mouse, 'scrollbar_v_mouse' , \
scrollbar_h_draw, 'scrollbar_h_draw' , \
scrollbar_h_mouse, 'scrollbar_h_mouse' , \
dynamic_button_draw, 'dbutton_draw' , \
dynamic_button_mouse, 'dbutton_mouse' , \
menu_bar_draw, 'menu_bar_draw' , \
menu_bar_mouse, 'menu_bar_mouse' , \
menu_bar_activate, 'menu_bar_activate' , \
127,10 → 127,12
frame_draw, 'frame_draw' , \
progressbar_draw,'progressbar_draw' , \
progressbar_progress, 'progressbar_progress'
 
public edit_box_draw as '_edit_box_draw'
public edit_box_key as '_edit_box_key'
public edit_box_mouse as '_edit_box_mouse'
public edit_box_set_text as '_edit_box_set_text'
 
public check_box_draw2 as '_check_box_draw2'
public check_box_mouse2 as '_check_box_mouse2'
140,3 → 142,8
public progressbar_progress as '_progressbar_progress'
 
public frame_draw as '_frame_draw'
 
public scrollbar_v_draw as '_scrollbar_v_draw'
public scrollbar_v_mouse as '_scrollbar_v_mouse'
public scrollbar_h_draw as '_scrollbar_h_draw'
public scrollbar_h_mouse as '_scrollbar_h_mouse'
/contrib/C_Layer/EXAMPLE/libguic_kolibri/scroll_progress.c
0,0 → 1,213
/*
Scrollbar and Progressbar usage example KolibriOS GUI lib
 
Free for all
 
Initially written by Siemargl, 2016
 
 
ToDo
*/
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "kolibri_gui.h"
#include "kos32sys.h"
 
// codes copied from \programs\cmm\lib\keyboard.h, but they're decimal
//ASCII KEYS
#define ASCII_KEY_BS 8
#define ASCII_KEY_TAB 9
#define ASCII_KEY_ENTER 13
#define ASCII_KEY_ESC 27
#define ASCII_KEY_DEL 182
#define ASCII_KEY_INS 185
#define ASCII_KEY_SPACE 32
 
#define ASCII_KEY_LEFT 176
#define ASCII_KEY_RIGHT 179
#define ASCII_KEY_DOWN 177
#define ASCII_KEY_UP 178
#define ASCII_KEY_HOME 180
#define ASCII_KEY_END 181
#define ASCII_KEY_PGDN 183
#define ASCII_KEY_PGUP 184
 
//SCAN CODE KEYS
#define SCAN_CODE_BS 14
#define SCAN_CODE_TAB 15
#define SCAN_CODE_ENTER 28
#define SCAN_CODE_ESC 1
#define SCAN_CODE_DEL 83
#define SCAN_CODE_INS 82
#define SCAN_CODE_SPACE 57
 
#define SCAN_CODE_LEFT 75
#define SCAN_CODE_RIGHT 77
#define SCAN_CODE_DOWN 80
#define SCAN_CODE_UP 72
#define SCAN_CODE_HOME 71
#define SCAN_CODE_END 79
#define SCAN_CODE_PGDN 81
#define SCAN_CODE_PGUP 73
 
#define KEY_LSHIFT 00000000001b
#define KEY_RSHIFT 00000000010b
#define KEY_LCTRL 00000000100b
#define KEY_RCTRL 00000001000b
#define KEY_LALT 00000010000b
#define KEY_RALT 00000100000b
#define KEY_CAPSLOCK 00001000000b
#define KEY_NUMLOCK 00010000000b
#define KEY_SCROLLLOCK 00100000000b
#define KEY_LWIN 01000000000b
#define KEY_RWIN 10000000000b
 
 
int main()
{
/* Load all libraries, initialize global tables like system color table and
operations table. kolibri_gui_init() will EXIT with mcall -1 if it fails
to do it's job. This is all you need to call and all libraries and GUI
elements can be used after a successful call to this function
*/
kolibri_gui_init();
int gui_event = KOLIBRI_EVENT_REDRAW;
uint32_t pressed_button = 0;
// uint32_t mouse_button;
// pos_t mouse_pos;
oskey_t keypress;
 
int value = 40; // showed value
int valuechange = 0;
 
// creating GUI using library functions
kolibri_window *main_window = kolibri_new_window(50, 50, 400, 400, "Scrollbar and progressbar showcase");
statictext *txt = kolibri_new_statictext_def(X_Y(10,30), "StaticText default 6x9. Use Arrows or PgUp/PgDn");
statictext *txt2 = kolibri_new_statictext(X_Y(10,40), "StaticText 8x16 x2:", CP866, 1, kolibri_color_table.color_work_text, 0);
staticnum *num = kolibri_new_staticnum_def(X_Y(10 + (strlen("StaticText 8x16 x2:") + 2) * 8 * 2, 40), 3, value);
scrollbar *sbh = kolibri_new_scrollbar(X_Y(30, 300), X_Y(370, 15), 15, 100, 10, value, kolibri_color_table.color_work_area, kolibri_color_table.color_work_button, 0);
scrollbar *sbv = kolibri_new_scrollbar(X_Y(370, 15), X_Y(50, 300), 15, 100, 10, value, kolibri_color_table.color_work_area, kolibri_color_table.color_work_button, 0);
progressbar *pg = kolibri_new_progressbar(0, 100, value, 10, 80, 200, 20);
 
kolibri_window_add_element(main_window, KOLIBRI_STATICTEXT, txt);
kolibri_window_add_element(main_window, KOLIBRI_STATICTEXT, txt2);
kolibri_window_add_element(main_window, KOLIBRI_STATICNUM, num);
kolibri_window_add_element(main_window, KOLIBRI_SCROLL_BAR_H, sbh);
kolibri_window_add_element(main_window, KOLIBRI_SCROLL_BAR_V, sbv);
kolibri_window_add_element(main_window, KOLIBRI_PROGRESS_BAR, pg);
 
do /* Start of main activity loop */
{
switch(gui_event)
{
case KOLIBRI_EVENT_REDRAW:
sbh->all_redraw = sbv->all_redraw = 1; // resetted
kolibri_handle_event_redraw(main_window);
valuechange = 0;
break;
case KOLIBRI_EVENT_NONE:
break;
case KOLIBRI_EVENT_KEY:
keypress = get_key();
// add logic to find focused active widget
// we have only one reaction
switch (keypress.ctrl_key)
{
case SCAN_CODE_UP: case SCAN_CODE_RIGHT:
if(value < 100)
{
value++; valuechange = 1;
progressbar_progress(pg); // +1 and redraw self
}
break;
case SCAN_CODE_PGUP:
if(value < 100)
{
value += 10; valuechange = 1;
if (value > 100) value = 100;
}
break;
case SCAN_CODE_DOWN: case SCAN_CODE_LEFT:
if(value > 0)
{
value--; valuechange = 1;
}
break;
case SCAN_CODE_PGDN:
if(value > 0)
{
value -= 10; valuechange = 1;
if (value < 0) value = 0;
}
break;
}
kolibri_handle_event_key(main_window); // ???????
break;
case KOLIBRI_EVENT_BUTTON:
pressed_button = get_os_button();
switch (pressed_button)
{
case BTN_QUIT:
return 0;
break;
}
break;
case KOLIBRI_EVENT_MOUSE:
// mouse_pos = get_mouse_pos(POS_WINDOW); // window relative
// mouse_button = get_mouse_eventstate();
// add logic to find widget under mouse
kolibri_handle_event_mouse(main_window);
if (sbh->position != value) // scrollbars was changed
{
value = sbh->position;
valuechange = 1;
}else
if (sbv->position != value) // scrollbars was changed
{
value = sbv->position;
valuechange = 1;
}
/* debug_board_printf("mouse ev (%d,%d)%x\n", mouse_pos.x, mouse_pos.y, mouse_button);
if (mouse_button & (1<<24)) // double click
{
}
// ignore
*/
break;
}
if(valuechange)
{
debug_board_printf("value change (%d)\n", value);
num->number = value;
sbh->position = value;
sbv->position = value;
pg->value = value;
gui_event = KOLIBRI_EVENT_REDRAW;
continue;
}
 
gui_event = wait_for_event(10); // 100 = 1 sec
} while(1) ; /* End of main activity loop */
 
return 0;
}
/*
void __attribute__ ((noinline)) debug_board_write_str(const char* str){
while(*str)
debug_board_write_byte(*str++);
}
 
void __attribute__ ((noinline)) debug_board_printf(const char *format,...)
{
va_list ap;
char log_board[300];
 
va_start (ap, format);
tiny_vsnprintf(log_board, sizeof log_board, format, ap);
va_end(ap);
debug_board_write_str(log_board);
 
}
*/
/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 */