Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 6488 → Rev 6489

/contrib/C_Layer/EXAMPLE/kmenu/kmenu_example.c
1,3 → 1,6
#include <stdlib.h>
#include <string.h>
#include <kos32sys.h>
#include <kolibri_gui.h>
#include <kolibri_kmenu.h>
 
41,7 → 44,8
 
do /* Start of main activity loop */
{
if(gui_event == KOLIBRI_EVENT_REDRAW)
if(gui_event == KOLIBRI_EVENT_REDRAW)#include <string.h>
 
{
kolibri_handle_event_redraw(main_window);
kmainmenu_draw(main_menu);
/contrib/C_Layer/EXAMPLE/libguic_kolibri/boardmsg.c
36,7 → 36,7
 
edit_box *editbox_interlock = NULL;
edit_box *textbox = kolibri_new_edit_box(20, 60, 40, &editbox_interlock);
edit_box *textbox2 = kolibri_new_edit_box(20, 80, 40, &editbox_interlock);
edit_box *textbox2 = kolibri_new_edit_box(20, 80, 30, &editbox_interlock);
kolibri_button *button = kolibri_new_button(310, 60, 24, 14, 0x21, kolibri_color_table.color_work_button);
frame *fr = kolibri_new_frame(X_Y(12, 350), X_Y(35, 70), 0x00FCFCFC, 0x00DCDCDC, "Frame Title", 0, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area);
 
46,6 → 46,8
kolibri_window_add_element(main_window, KOLIBRI_BUTTON, button);
kolibri_window_add_element(main_window, KOLIBRI_FRAME, fr);
 
(*edit_box_set_text)(textbox2, "Sample text very long to get shorted");
 
extern volatile unsigned press_key;
 
do /* Start of main activity loop */
/contrib/C_Layer/EXAMPLE/libguic_kolibri/option_menu.c
18,7 → 18,40
#include "kos32sys.h"
#include "kolibri_gui.h"
 
#define SCAN_CODE_ALTM 50
#define SCAN_CODE_ALTE 18
inline
uint32_t get_os_keyb_modifiers()
{
register uint32_t val;
__asm__ __volatile__(
"int $0x40"
:"=a"(val)
:"a"(66), "b"(3));
return val;
};
 
#define KEY_LSHIFT 0x1
#define KEY_RSHIFT 0x2
#define KEY_LCTRL 0x4
#define KEY_RCTRL 0x8
#define KEY_LALT 0x10
#define KEY_RALT 0x20
#define KEY_CAPSLOCK 0x40
#define KEY_NUMLOCK 0x80
#define KEY_SCROLLLOCK 0x100
#define KEY_LWIN 0x200
#define KEY_RWIN 0x400
 
inline
void set_os_keyb_mode(int mode)
// 0 - ASCII, 1 - SCAN
{
__asm__ __volatile__(
"int $0x40"
::"a"(66), "b"(1), "c"(mode));
};
 
int main()
{
/* Load all libraries, initialize global tables like system color table and
64,25 → 97,24
int option_index1 = 0; // index of selected option
int option_index2 = 0;
 
static char *menu1t = "Menu1";
static char *menu11t = "Set RED";
static char *menu12t = "Set GREEN";
static char *menu13t = "Set BLUE";
static char *menu14t = "";
menubar* menu1 = kolibri_new_menubar_def(X_Y(20, 40), X_Y(25, 15), 80, 100, menu1t, menu11t);
char *menu1stru[] = {"Menu1", "Set RED", "Set GREEN", "Set BLUE", NULL};
menubar* menu1 = kolibri_new_menubar_def(X_Y(10, 40), X_Y(25, 15), 80, 100, menu1stru);
gui_add_menubar(main_window, menu1);
 
static char *menu2t = "Menu2";
static char *menu21t = "Set Option 1";
static char *menu22t = "Set Option 2";
static char *menu23t = "Set Option 3";
static char *menu24t = "";
menubar* menu2 = kolibri_new_menubar_def(X_Y(60, 40), X_Y(25, 15), 80, 100, menu2t, menu21t);
char *menu2stru[] = {"mEnu2", "Set Option 1", "Set Option 2", "Set Option 3", NULL};
menubar* menu2 = kolibri_new_menubar_def(X_Y(50, 40), X_Y(25, 15), 80, 100, menu2stru);
gui_add_menubar(main_window, menu2);
 
char *menu3stru[] = {"Quit", NULL};
menubar* menu3 = kolibri_new_menubar_def(X_Y(90, 40), X_Y(25, 15), 0, 0, menu3stru);
menu3->type = 1; // no subitems
gui_add_menubar(main_window, menu3);
 
 
 
set_os_keyb_mode(1); // needed for keyboard use in menu
 
 
do /* Start of main activity loop */
{
if(option_index1 != option1sel - opts1)
100,7 → 132,13
case KOLIBRI_EVENT_NONE:
break;
case KOLIBRI_EVENT_KEY:
keypress = get_key();
debug_board_printf("Key pressed state(%d) code(%d) ctrl_key(%d) modifiers(%#x)\n", keypress.state, keypress.code, keypress.ctrl_key, get_os_keyb_modifiers());
kolibri_handle_event_key(main_window); // ???????
 
if(keypress.code == SCAN_CODE_ALTM && get_os_keyb_modifiers() & (KEY_LALT | KEY_RALT))
(*menu_bar_activate)(menu1); // wont work, immediately redraw command closes menu (
 
break;
case KOLIBRI_EVENT_BUTTON:
pressed_button = get_os_button();
115,6 → 153,21
// mouse_pos = get_mouse_pos(POS_WINDOW); // window relative
// mouse_button = get_mouse_eventstate();
kolibri_handle_event_mouse(main_window);
if(menu1->click && menu1->cursor_out)
{
option1sel = opts1 + menu1->cursor_out - 1; // check bounds ?
(*option_box_draw)(option_group1);
}
if(menu2->click && menu2->cursor_out)
{
option2sel = opts2 + menu2->cursor_out - 1; // check bounds ?
(*option_box_draw)(option_group2);
}
if(menu3->click && menu3->cursor_out)
{
return 0; // quit
}
 
break;
}