Rev 8104 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8104 | Rev 8106 | ||
---|---|---|---|
Line 1... | Line -... | ||
1 | // WRITED BY MAXCODEHACK |
- | |
2 | // Need to other sample, this sample is very shitcode) |
1 | // sample writed by maxcodehack |
3 | - | ||
4 | #include |
2 | #include |
5 | #include |
3 | #include |
6 | #include |
- | |
7 | #include |
- | |
8 | #include "kos32sys1.h" |
- | |
9 | #include |
4 | #include |
Line -... | Line 5... | ||
- | 5 | ||
- | 6 | #define evReDraw 1 |
|
- | 7 | #define evKey 2 |
|
- | 8 | #define evButton 3 |
|
- | 9 | #define evExit 4 |
|
- | 10 | #define evDesktop 5 |
|
- | 11 | #define evMouse 6 |
|
10 | 12 | #define evIPC 7 |
|
- | 13 | #define evNetwork 8 |
|
11 | struct kolibri_system_colors sys_color_table; |
14 | #define evDebug 9 |
- | 15 | ||
12 | 16 | #define WIN_W 640 |
|
- | 17 | #define WIN_H 563 |
|
13 | char statusbar[255]; |
18 | |
14 | char proc_info[1024]; |
19 | char* title = "Boxlib example"; |
- | 20 | int win_bg_color = 0x858585; |
|
Line 15... | Line -... | ||
15 | char text_line[255]; |
- | |
16 | - | ||
17 | enum BUTTONS |
- | |
18 | { |
- | |
19 | BTN_QUIT = 1, |
- | |
20 | BTN_POP = 10, |
- | |
21 | BTN_UNLOCK = 11 |
- | |
22 | }; |
- | |
23 | - | ||
24 | #define FONT_W 8 |
- | |
25 | #define FONT_H 14 |
- | |
26 | #define LINES 10 |
21 | scrollbar scroll = {15, WIN_W - 26, WIN_H - 29, 0, 0, 2, 115, 15, 0,0x707070,0xD2CED0,0x555555,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; |
27 | - | ||
28 | void draw_window() |
- | |
29 | { |
- | |
30 | int win_hight, win_width, i, pos_y = get_skin_height() + 36; // 60 == 24+36 |
- | |
31 | 22 | ||
32 | // start redraw |
- | |
33 | begin_draw(); |
23 | void draw_window(){ |
34 | // define&draw window |
- | |
35 | sys_create_window(10, 40, 600, 400, "My window", /*sys_color_table.work_area*/0xFFFFFF, 0x13); |
24 | begin_draw(); |
36 | 25 | sys_create_window(215,100,WIN_W,WIN_H,title,win_bg_color,0x34); |
|
37 | // end redraw |
26 | scrollbar_v_draw(&scroll); |
- | 27 | end_draw(); |
|
- | 28 | } |
|
- | 29 | ||
- | 30 | //// EVENTMASK |
|
- | 31 | #define EVM_REDRAW 1 |
|
- | 32 | #define EVM_KEY 2 |
|
- | 33 | #define EVM_BUTTON 4 |
|
- | 34 | #define EVM_EXIT 8 |
|
- | 35 | #define EVM_BACKGROUND 16 |
|
- | 36 | #define EVM_MOUSE 32 |
|
- | 37 | #define EVM_IPC 64 |
|
- | 38 | #define EVM_STACK 128 |
|
38 | end_draw(); |
39 | #define EVM_DEBUG 256 |
- | 40 | #define EVM_STACK2 512 |
|
- | 41 | #define EVM_MOUSE_FILTER 0x80000000 |
|
- | 42 | #define EVM_CURSOR_FILTER 0x40000000 |
|
- | 43 | //// EVENTMASK |
|
39 | } |
44 | |
40 | scrollbar scroll_ver = {15, 100 - 26, 100 - 29, 0, 0, 2 /* type */, 115, 15, 0,0x353B47,0xD2CED0,0x555555,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; |
45 | |
41 | int main() |
46 | int main() |
42 | { |
- | |
43 | kolibri_boxlib_init(); |
- | |
44 | int gui_event; |
- | |
45 | uint32_t pressed_button = 0, mouse_button; |
- | |
46 | pos_t mouse_pos; |
- | |
47 | - | ||
Line -... | Line 47... | ||
- | 47 | { |
|
48 | get_system_colors(&sys_color_table); |
48 | kolibri_boxlib_init(); |
49 | set_event_mask(0xC0000027); // mouse events only when focused window and mouse inside |
49 | |
50 | - | ||
51 | do |
50 | set_event_mask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER); |
52 | { |
51 | while(1) |
53 | gui_event = get_os_event(); |
- | |
54 | switch(gui_event) |
- | |
55 | { |
52 | { |
56 | case KOLIBRI_EVENT_NONE: |
- | |
57 | // background work |
- | |
58 | break; |
53 | switch(get_os_event()) |
59 | case KOLIBRI_EVENT_REDRAW: |
54 | { |
- | 55 | case evButton: |
|
60 | draw_window(); |
56 | if (get_os_button() == 1) exit(0); |
61 | scrollbar_v_draw(&scroll_ver); |
57 | break; |
62 | break; |
58 | |
63 | case KOLIBRI_EVENT_KEY: |
- | |
Line -... | Line 59... | ||
- | 59 | case evKey: |
|
- | 60 | get_key(); |
|
64 | // scroll |
61 | break; |
65 | break; |
62 | |
66 | case KOLIBRI_EVENT_BUTTON: |
63 | case evReDraw: |
67 | 64 | draw_window(); |
|
68 | break; |
65 | break; |
69 | case KOLIBRI_EVENT_MOUSE: |
- | |
70 | scrollbar_v_mouse(&scroll_ver); |
66 | case evMouse: |
71 | break; |
- | |
72 | } |
67 | scrollbar_v_mouse(&scroll); |