Subversion Repositories Kolibri OS

Rev

Rev 8185 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
8110 maxcodehac 1
// BOXLIB EXAMPLE (scrollbar, progressbar)
8108 maxcodehac 2
// Writed by maxcodehack
8185 maxcodehac 3
// GCC version is in /contrib/C_Layer/EXAMPLE/boxlib
8106 maxcodehac 4
#include 
8104 maxcodehac 5
#include 
6
#include 
7
 
8106 maxcodehac 8
#define evReDraw  1
9
#define evKey     2
10
#define evButton  3
11
#define evExit    4
12
#define evDesktop 5
13
#define evMouse   6
14
#define evIPC     7
15
#define evNetwork 8
16
#define evDebug   9
8104 maxcodehac 17
 
8106 maxcodehac 18
#define WIN_W 640
19
#define WIN_H 563
8104 maxcodehac 20
 
8171 maxcodehac 21
uint32_t wheels;
8106 maxcodehac 22
char* title = "Boxlib example";
8110 maxcodehac 23
scrollbar scroll = {15, WIN_W - 26, WIN_H - 29, 0, 0, 2, 215, 15, 0,0x707070,0xD2CED0,0x555555,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
24
progressbar pg = {0, 10, 10, 270, 35, 1, 0, 200, 0xB4B4B4, 0x2728FF, 0xA9A9A9};
8104 maxcodehac 25
 
8188 maxcodehac 26
/*
27
// System colors
28
struct kolibri_system_colors sys_color;
29
*/
30
 
8106 maxcodehac 31
void draw_window(){
8171 maxcodehac 32
        BeginDraw();
8188 maxcodehac 33
        DrawWindow(215,100,WIN_W,WIN_H,title, /* sys_color.work_area */ 0x858585, 0x34);
8106 maxcodehac 34
        scrollbar_v_draw(&scroll);
8110 maxcodehac 35
        progressbar_draw(&pg);
8171 maxcodehac 36
        EndDraw();
8106 maxcodehac 37
}
8104 maxcodehac 38
 
8106 maxcodehac 39
//// EVENTMASK
40
#define EVM_REDRAW        1
41
#define EVM_KEY           2
42
#define EVM_BUTTON        4
43
#define EVM_EXIT          8
44
#define EVM_BACKGROUND    16
45
#define EVM_MOUSE         32
46
#define EVM_IPC           64
47
#define EVM_STACK         128
48
#define EVM_DEBUG         256
49
#define EVM_STACK2        512
50
#define EVM_MOUSE_FILTER  0x80000000
51
#define EVM_CURSOR_FILTER 0x40000000
52
//// EVENTMASK
8104 maxcodehac 53
 
54
 
8106 maxcodehac 55
int main()
56
{
57
	kolibri_boxlib_init();
8188 maxcodehac 58
	/*
59
	get_system_colors(&sys_color);
60
	*/
8106 maxcodehac 61
	set_event_mask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
62
	while(1)
63
	{
8171 maxcodehac 64
		switch(GetOsEvent())
8106 maxcodehac 65
		{
66
			case evButton:
67
				if (get_os_button() == 1) exit(0);
68
				break;
69
 
70
			case evKey:
71
				get_key();
72
				break;
73
 
74
			case evReDraw:
75
				draw_window();
76
				break;
77
			case evMouse:
78
				scrollbar_v_mouse(&scroll);
8171 maxcodehac 79
 
80
				// Wheel scrolling
81
				// Quite unstable
82
				/*
83
				int scroll_strong = 40;
84
				wheels = GetMouseWheels();
85
				if(wheels & 0xFFFF)
86
				{
87
					if((short)wheels > 0 && scroll.position < scroll.max_area - scroll_strong)
88
						scroll.position += scroll_strong;
89
					else if((short)wheels < 0 && scroll.position > 0)
90
						scroll.position -= scroll_strong;
91
 
92
					scrollbar_v_draw(&scroll);
93
				}
94
				*/
8110 maxcodehac 95
				pg.value = scroll.position;
96
				progressbar_draw(&pg);
8106 maxcodehac 97
				break;
98
		}
99
	}
8104 maxcodehac 100
}