Subversion Repositories Kolibri OS

Rev

Rev 9094 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9094 Rev 9766
Line -... Line 1...
-
 
1
#include 
1
#include 
2
#include 
2
#include 
3
#include 
3
#include 
4
#include 
4
#include 
-
 
5
#include 
5
#include 
Line 6... Line 6...
6
 
6
 
Line 7... Line 7...
7
ksys_colors_table_t sys_color_table;
7
ksys_colors_table_t sys_color_table;
8
 
8
 
9
char statusbar[255];
9
char statusbar[255];
Line 10... Line 10...
10
ksys_thread_t proc_info;
10
ksys_thread_t proc_info;
11
char text_line[255];
-
 
12
 
11
char text_line[255];
13
enum BUTTONS
12
 
14
{
13
enum BUTTONS {
15
    BTN_QUIT = 1,
14
    BTN_QUIT = 1,
Line 28... Line 27...
28
    // start redraw
27
    // start redraw
29
    _ksys_start_draw();
28
    _ksys_start_draw();
30
	// define&draw window
29
    // define&draw window
31
    _ksys_create_window(10, 40, 600, 400, "My window", sys_color_table.work_area, 0x13);
30
    _ksys_create_window(10, 40, 600, 400, "My window", sys_color_table.work_area, 0x13);
32
    _ksys_thread_info(&proc_info, -1);
31
    _ksys_thread_info(&proc_info, -1);
-
 
32
    F
Line -... Line 33...
-
 
33
 
33
 
34
        win_width
34
    win_width = proc_info.winx_size;
35
        = proc_info.winx_size;
Line 35... Line 36...
35
    win_hight = proc_info.winy_size;
36
    win_hight = proc_info.winy_size;
36
    
37
 
37
    _ksys_define_button(10, 30, 70, 20, BTN_POP, sys_color_table.work_button);
38
    _ksys_define_button(10, 30, 70, 20, BTN_POP, sys_color_table.work_button);
Line 49... Line 50...
49
 
50
 
50
        text_line[(win_width - 10 - 5) / FONT_W + 1] = '\0'; // clip text size, seems to big lines crashing OS, and form len by window size
51
        text_line[(win_width - 10 - 5) / FONT_W + 1] = '\0'; // clip text size, seems to big lines crashing OS, and form len by window size
51
        _ksys_draw_text(text_line, 5, pos_y, 0, 0x90000000 | sys_color_table.work_text);
52
        _ksys_draw_text(text_line, 5, pos_y, 0, 0x90000000 | sys_color_table.work_text);
Line -... Line 53...
-
 
53
        pos_y += FONT_H;
52
        pos_y += FONT_H;
54
 
53
 
55
        if (pos_y + 29 > win_hight)
54
        if(pos_y + 29 > win_hight) break; // 12 font + 12 statusbar + 5 border
56
            break; // 12 font + 12 statusbar + 5 border
55
    }
57
    }
56
    // end redraw
58
    // end redraw
Line 67... Line 69...
67
    _ksys_get_system_colors(&sys_color_table);
69
    _ksys_get_system_colors(&sys_color_table);
68
    _ksys_set_event_mask(0xC0000027); // mouse events only when focused window and mouse inside
70
    _ksys_set_event_mask(0xC0000027); // mouse events only when focused window and mouse inside
Line 69... Line 71...
69
 
71
 
70
    do{
72
    do {
71
        gui_event = _ksys_get_event(); 
73
        gui_event = _ksys_get_event();
72
        switch(gui_event)
-
 
73
        {
74
        switch (gui_event) {
74
        case KSYS_EVENT_NONE:
75
        case KSYS_EVENT_NONE:
75
			break;
76
            break;
76
        case KSYS_EVENT_REDRAW:
77
        case KSYS_EVENT_REDRAW:
77
            draw_window();
78
            draw_window();
78
			break;
79
            break;
79
        case KSYS_EVENT_KEY:
80
        case KSYS_EVENT_KEY:
80
			break;
81
            break;
81
        case KSYS_EVENT_BUTTON:
82
        case KSYS_EVENT_BUTTON:
82
            pressed_button = _ksys_get_button();
83
            pressed_button = _ksys_get_button();
83
            switch (pressed_button)
-
 
84
            {
84
            switch (pressed_button) {
85
              case BTN_POP:
85
            case BTN_POP:
86
                strcpy(statusbar, "POP pressed....");
86
                strcpy(statusbar, "POP pressed....");
87
                draw_window();
87
                draw_window();
88
                break;
88
                break;
Line 100... Line 100...
100
            mouse_button = _ksys_get_mouse_eventstate();
100
            mouse_button = _ksys_get_mouse_eventstate();
101
            debug_printf("mouse ev (%d,%d)%x\n", mouse_pos.x, mouse_pos.y, mouse_button);
101
            debug_printf("mouse ev (%d,%d)%x\n", mouse_pos.x, mouse_pos.y, mouse_button);
102
            if (mouse_button & (1<<24)) // double click
102
            if (mouse_button & (1 << 24)) // double click
103
            {
103
            {
104
                int n = (mouse_pos.y - 60) / FONT_H;
104
                int n = (mouse_pos.y - 60) / FONT_H;
105
                if (n < 0 || n >= LINES) break;
105
                if (n < 0 || n >= LINES)
-
 
106
                    break;
106
                debug_printf("click on str(%d), clip slot(%d)\n", n, LINES - n - 1);
107
                debug_printf("click on str(%d), clip slot(%d)\n", n, LINES - n - 1);
107
                sprintf(statusbar, "click on str(%d), clip slot(%d)\n", n, LINES - n - 1);
108
                sprintf(statusbar, "click on str(%d), clip slot(%d)\n", n, LINES - n - 1);
108
                draw_window();
109
                draw_window();
109
            }
110
            }
110
            break;
111
            break;