Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1176 andrew_pro 1
/*
2
	test libGUI library
3
*/
4
#include "stdarg.h"
5
#include "libGUI.h"
6
#include "string.h"
7
 
8
 
9
void	callback_func_delete_window(header_t *control,void *data)
10
{
11
	QuitLibGUI((parent_t*)control);
12
}
13
 
14
void ProgressBarCallback(void *data)
15
{
16
	gui_progress_bar_t	*progress_bar;
17
	int			progress;
18
	static char		txt[16];
19
 
20
	progress_bar=(gui_progress_bar_t*)data;
21
	progress_bar->progress+=0.01;//incrase progress
22
 
23
	if (progress_bar->progress>1.0) progress_bar->progress=0.0;
24
 
25
	//calculate progress level in %
26
	progress=progress_bar->progress*100;
27
	snprintf(txt,16,"progress %d%%",progress);
28
	//set text for progress bar
29
	ProgressBarSetText(progress_bar,txt);
30
}
31
 
32
int main(int argc, char *argv[])
33
{
34
	parent_t			*window;
35
	gui_progress_bar_data_t	progress_bar_data;
36
	gui_progress_bar_t		*progress_bar;
37
	gui_timer_t			*timer;
38
 
39
	//load libGUI library
40
	LoadLibGUI(NULL);//use default system path to library
41
	//create main window
42
	window=CreateWindow();
43
	//change size of main window
44
	SetWindowSizeRequest(window,320,57);
45
	//set callback function for button close window
46
	SetCallbackFunction(window,DELETE_EVENT,&callback_func_delete_window,NULL);
47
	//create progress bar
48
	progress_bar_data.x=5;
49
	progress_bar_data.y=5;
50
	progress_bar_data.width=300;
51
	progress_bar_data.height=25;
52
	progress_bar_data.progress=0.0;
53
	progress_bar=CreateProgressBar(&progress_bar_data);
54
 
55
	//create timer for update progress level each 50 millisecunds
56
	timer=SetTimerCallbackForFunction(window,5,&ProgressBarCallback,progress_bar);
57
 
58
	//pack progress bar in window
59
	PackControls(window,progress_bar);
60
 
61
	//update progress bar automatically each 50 millisecund
62
	SetProgressBarPulse(progress_bar,5);
63
 
64
	//call main libGUI loop
65
	LibGUImain(window);
66
}