Subversion Repositories Kolibri OS

Rev

Rev 8171 | 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";
23
int win_bg_color = 0x858585;
8110 maxcodehac 24
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};
25
progressbar pg = {0, 10, 10, 270, 35, 1, 0, 200, 0xB4B4B4, 0x2728FF, 0xA9A9A9};
8104 maxcodehac 26
 
8106 maxcodehac 27
void draw_window(){
8171 maxcodehac 28
        BeginDraw();
29
        DrawWindow(215,100,WIN_W,WIN_H,title,win_bg_color,0x34);
8106 maxcodehac 30
        scrollbar_v_draw(&scroll);
8110 maxcodehac 31
        progressbar_draw(&pg);
8171 maxcodehac 32
        EndDraw();
8106 maxcodehac 33
}
8104 maxcodehac 34
 
8106 maxcodehac 35
//// EVENTMASK
36
#define EVM_REDRAW        1
37
#define EVM_KEY           2
38
#define EVM_BUTTON        4
39
#define EVM_EXIT          8
40
#define EVM_BACKGROUND    16
41
#define EVM_MOUSE         32
42
#define EVM_IPC           64
43
#define EVM_STACK         128
44
#define EVM_DEBUG         256
45
#define EVM_STACK2        512
46
#define EVM_MOUSE_FILTER  0x80000000
47
#define EVM_CURSOR_FILTER 0x40000000
48
//// EVENTMASK
8104 maxcodehac 49
 
50
 
8106 maxcodehac 51
int main()
52
{
53
	kolibri_boxlib_init();
54
 
55
	set_event_mask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
56
	while(1)
57
	{
8171 maxcodehac 58
		switch(GetOsEvent())
8106 maxcodehac 59
		{
60
			case evButton:
61
				if (get_os_button() == 1) exit(0);
62
				break;
63
 
64
			case evKey:
65
				get_key();
66
				break;
67
 
68
			case evReDraw:
69
				draw_window();
70
				break;
71
			case evMouse:
72
				scrollbar_v_mouse(&scroll);
8171 maxcodehac 73
 
74
				// Wheel scrolling
75
				// Quite unstable
76
				/*
77
				int scroll_strong = 40;
78
				wheels = GetMouseWheels();
79
				if(wheels & 0xFFFF)
80
				{
81
					if((short)wheels > 0 && scroll.position < scroll.max_area - scroll_strong)
82
						scroll.position += scroll_strong;
83
					else if((short)wheels < 0 && scroll.position > 0)
84
						scroll.position -= scroll_strong;
85
 
86
					scrollbar_v_draw(&scroll);
87
				}
88
				*/
8110 maxcodehac 89
				pg.value = scroll.position;
90
				progressbar_draw(&pg);
8106 maxcodehac 91
				break;
92
		}
93
	}
8104 maxcodehac 94
}