bugfix of last SVN revision
git-svn-id: svn://kolibrios.org@1176 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
70
programs/develop/libraries/libGUI/examples/src/button.c
Normal file
70
programs/develop/libraries/libGUI/examples/src/button.c
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
test libGUI library
|
||||
*/
|
||||
#include "stdarg.h"
|
||||
#include "libGUI.h"
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
|
||||
void callback_func_delete_window(header_t *control,void *data)
|
||||
{
|
||||
QuitLibGUI((parent_t*)control);
|
||||
}
|
||||
|
||||
void callback_func1(header_t *control,void *data)
|
||||
{
|
||||
printf("\nentry in button");
|
||||
}
|
||||
|
||||
void callback_func2(header_t *control,void *data)
|
||||
{
|
||||
printf("\nbutton pressed");
|
||||
}
|
||||
|
||||
void callback_func3(header_t *control,void *data)
|
||||
{
|
||||
printf("\nbutton released");
|
||||
}
|
||||
|
||||
void callback_func4(header_t *control,void *data)
|
||||
{
|
||||
printf("\nleave button");
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
parent_t *window;
|
||||
gui_callback_t *id1,*id2,*id3,*id4;
|
||||
gui_button_data_t button_data;
|
||||
gui_button_t *button;
|
||||
|
||||
//load libGUI library
|
||||
LoadLibGUI(NULL);
|
||||
|
||||
//create main window
|
||||
window=CreateWindow();
|
||||
SetWindowSizeRequest(window,90,60);
|
||||
//create button
|
||||
button_data.x=5;
|
||||
button_data.y=5;
|
||||
button_data.width=70;
|
||||
button_data.height=20;
|
||||
//create button with text
|
||||
button=CreateButtonWithText(&button_data,"Click my!");
|
||||
//set callback functions for button close window
|
||||
SetCallbackFunction(window,DELETE_EVENT,&callback_func_delete_window,NULL);
|
||||
|
||||
//set callback functions for button
|
||||
id1=SetCallbackFunction(button,BUTTON_ENTER_EVENT,&callback_func1,NULL);
|
||||
id2=SetCallbackFunction(button,BUTTON_PRESSED_EVENT,&callback_func2,NULL);
|
||||
id3=SetCallbackFunction(button,BUTTON_RELEASED_EVENT,&callback_func3,NULL);
|
||||
id4=SetCallbackFunction(button,BUTTON_LEAVE_EVENT,&callback_func4,NULL);
|
||||
//pack button in window
|
||||
PackControls(window,button);
|
||||
//start main libGUI loop
|
||||
LibGUImain(window);
|
||||
}
|
52
programs/develop/libraries/libGUI/examples/src/image.c
Normal file
52
programs/develop/libraries/libGUI/examples/src/image.c
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
test libGUI library
|
||||
*/
|
||||
#include "stdarg.h"
|
||||
#include "libGUI.h"
|
||||
#include "stdlib.h"
|
||||
#include "stdio.h"
|
||||
|
||||
void callback_func_delete_window(header_t *control,void *data)
|
||||
{
|
||||
QuitLibGUI((parent_t*)control);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
parent_t *window;
|
||||
gui_image_data_t imdata;
|
||||
gui_image_t *image;
|
||||
int i,j;
|
||||
unsigned int *img;
|
||||
|
||||
//load libGUI library
|
||||
LoadLibGUI(NULL);//use default system path to library
|
||||
//create main window
|
||||
window=CreateWindow();
|
||||
//change window size
|
||||
SetWindowSizeRequest(window,220,142);
|
||||
//set callback function for close window button
|
||||
SetCallbackFunction(window,DELETE_EVENT,&callback_func_delete_window,NULL);
|
||||
//create image
|
||||
imdata.x=5;
|
||||
imdata.y=5;
|
||||
imdata.width=200;
|
||||
imdata.height=100;
|
||||
imdata.bits_per_pixel=32;//bits per pixel
|
||||
|
||||
image=CreateImage(&imdata);
|
||||
img=(unsigned int*)image->img;
|
||||
//generate 32 bits image
|
||||
for(i=0;i<GetControlSizeY(image);i++)
|
||||
{
|
||||
for(j=0;j<GetControlSizeX(image);j++)
|
||||
{
|
||||
*img=100*(i*i+j*j-i*3+2*j);
|
||||
img++;
|
||||
}
|
||||
}
|
||||
//pack image in window
|
||||
PackControls(window,image);
|
||||
//start main libGUI loop
|
||||
LibGUImain(window);
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
test libGUI library
|
||||
*/
|
||||
#include "stdarg.h"
|
||||
#include "libGUI.h"
|
||||
#include "string.h"
|
||||
|
||||
|
||||
void callback_func_delete_window(header_t *control,void *data)
|
||||
{
|
||||
QuitLibGUI((parent_t*)control);
|
||||
}
|
||||
|
||||
void ProgressBarCallback(void *data)
|
||||
{
|
||||
gui_progress_bar_t *progress_bar;
|
||||
int progress;
|
||||
static char txt[16];
|
||||
|
||||
progress_bar=(gui_progress_bar_t*)data;
|
||||
progress_bar->progress+=0.01;//incrase progress
|
||||
|
||||
if (progress_bar->progress>1.0) progress_bar->progress=0.0;
|
||||
|
||||
//calculate progress level in %
|
||||
progress=progress_bar->progress*100;
|
||||
snprintf(txt,16,"progress %d%%",progress);
|
||||
//set text for progress bar
|
||||
ProgressBarSetText(progress_bar,txt);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
parent_t *window;
|
||||
gui_progress_bar_data_t progress_bar_data;
|
||||
gui_progress_bar_t *progress_bar;
|
||||
gui_timer_t *timer;
|
||||
|
||||
//load libGUI library
|
||||
LoadLibGUI(NULL);//use default system path to library
|
||||
//create main window
|
||||
window=CreateWindow();
|
||||
//change size of main window
|
||||
SetWindowSizeRequest(window,320,57);
|
||||
//set callback function for button close window
|
||||
SetCallbackFunction(window,DELETE_EVENT,&callback_func_delete_window,NULL);
|
||||
//create progress bar
|
||||
progress_bar_data.x=5;
|
||||
progress_bar_data.y=5;
|
||||
progress_bar_data.width=300;
|
||||
progress_bar_data.height=25;
|
||||
progress_bar_data.progress=0.0;
|
||||
progress_bar=CreateProgressBar(&progress_bar_data);
|
||||
|
||||
//create timer for update progress level each 50 millisecunds
|
||||
timer=SetTimerCallbackForFunction(window,5,&ProgressBarCallback,progress_bar);
|
||||
|
||||
//pack progress bar in window
|
||||
PackControls(window,progress_bar);
|
||||
|
||||
//update progress bar automatically each 50 millisecund
|
||||
SetProgressBarPulse(progress_bar,5);
|
||||
|
||||
//call main libGUI loop
|
||||
LibGUImain(window);
|
||||
}
|
76
programs/develop/libraries/libGUI/examples/src/scroll_bar.c
Normal file
76
programs/develop/libraries/libGUI/examples/src/scroll_bar.c
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
test libGUI library
|
||||
*/
|
||||
#include "stdarg.h"
|
||||
#include "libGUI.h"
|
||||
#include "stdio.h"
|
||||
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
|
||||
void callback_func_delete_window(header_t *control,void *data)
|
||||
{
|
||||
printf("\nlibGUI quit...");
|
||||
QuitLibGUI((parent_t*)control);
|
||||
}
|
||||
|
||||
void ScrollStateH(header_t *control,void *data)
|
||||
{
|
||||
gui_scroll_bar_t *hsc;
|
||||
|
||||
hsc=(gui_scroll_bar_t*)control;
|
||||
printf("\nhorizontal ruler position %d%%",(int)(hsc->ruller_pos*100));
|
||||
}
|
||||
|
||||
void ScrollStateV(header_t *control,void *data)
|
||||
{
|
||||
gui_scroll_bar_t *vsc;
|
||||
|
||||
vsc=(gui_scroll_bar_t*)control;
|
||||
printf("\nvertical ruler position %d%%",(int)(vsc->ruller_pos*100));
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
parent_t *window;
|
||||
gui_callback_t *id1,*id2;
|
||||
gui_scroll_bar_data_t horizontal_sbar_data;
|
||||
gui_scroll_bar_data_t vertical_sbar_data;
|
||||
gui_scroll_bar_t *ScrollBarH;
|
||||
gui_scroll_bar_t *ScrollBarV;
|
||||
|
||||
//load libGUI library
|
||||
LoadLibGUI(NULL);//use default system path to library
|
||||
//create main window
|
||||
window=CreateWindow();
|
||||
//change size of window
|
||||
SetWindowSizeRequest(window,270,207);
|
||||
//create horizontal scroll bar
|
||||
horizontal_sbar_data.x=5;
|
||||
horizontal_sbar_data.y=5;
|
||||
horizontal_sbar_data.width=250;
|
||||
horizontal_sbar_data.height=16;
|
||||
horizontal_sbar_data.ruller_size=0.2;//size of ruler E [0,1]
|
||||
horizontal_sbar_data.ruller_pos=0.5;//ruler position E [0,1]
|
||||
horizontal_sbar_data.ruller_step=0.1;//step of change ruler pos after press of button E [0,1]
|
||||
//create vertical scroll bar
|
||||
vertical_sbar_data.x=5;
|
||||
vertical_sbar_data.y=26;
|
||||
vertical_sbar_data.width=16;
|
||||
vertical_sbar_data.height=150;
|
||||
vertical_sbar_data.ruller_size=0.5;//size of ruler E [0,1]
|
||||
vertical_sbar_data.ruller_pos=0.05;//ruler position E [0,1]
|
||||
vertical_sbar_data.ruller_step=0.1;//step of change ruler pos after press of button E [0,1]
|
||||
|
||||
//create horizontal and vertical scroll bars
|
||||
ScrollBarH=CreateHorizontalScrollBar(&horizontal_sbar_data);
|
||||
ScrollBarV=CreateVerticalScrollBar(&vertical_sbar_data);
|
||||
//set callback functions for scroll bars
|
||||
id1=SetCallbackFunction(ScrollBarH,SCROLLBAR_CHANGED_EVENT,&ScrollStateH,NULL);
|
||||
id2=SetCallbackFunction(ScrollBarV,SCROLLBAR_CHANGED_EVENT,&ScrollStateV,NULL);
|
||||
//pack scroll bars in window
|
||||
PackControls(window,ScrollBarH);
|
||||
PackControls(window,ScrollBarV);
|
||||
//start minl libGUI loop
|
||||
LibGUImain(window);
|
||||
}
|
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
test libGUI library
|
||||
*/
|
||||
#include "stdarg.h"
|
||||
#include "libGUI.h"
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
|
||||
void callback_func_delete_window(header_t *control,void *data)
|
||||
{
|
||||
QuitLibGUI((parent_t*)control);
|
||||
}
|
||||
|
||||
void callback_func(header_t *control,void *data)
|
||||
{
|
||||
printf("\npressed button with ID=%d control=%d",(int)control->ctrl_ID,(int)control);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
parent_t *window;
|
||||
gui_button_data_t button_data;
|
||||
gui_button_t *button;
|
||||
gui_scrolled_window_data_t scroll_win_data;
|
||||
gui_scrolled_window_t *ScrollWin;
|
||||
int i,j;
|
||||
static char txt[20];
|
||||
|
||||
//load libGUI library
|
||||
LoadLibGUI(NULL);
|
||||
//create main window
|
||||
window=CreateWindow();
|
||||
//change size of window
|
||||
SetWindowSizeRequest(window,270,282);
|
||||
|
||||
//create scrolled window
|
||||
scroll_win_data.x=5;
|
||||
scroll_win_data.y=5;
|
||||
scroll_win_data.width=250;
|
||||
scroll_win_data.height=250;
|
||||
ScrollWin=CreateScrolledWindow(&scroll_win_data);
|
||||
|
||||
//create buttons
|
||||
for(j=1;j<=10;j++)
|
||||
{
|
||||
for(i=1;i<=10;i++)
|
||||
{
|
||||
button_data.x=10+(i-1)*75;
|
||||
button_data.y=10+(j-1)*25;
|
||||
button_data.width=70;
|
||||
button_data.height=20;
|
||||
|
||||
snprintf(txt,20,"(%d,%d)",j,i);
|
||||
button=CreateButtonWithText(&button_data,txt);
|
||||
|
||||
SetCallbackFunction(button,BUTTON_PRESSED_EVENT,&callback_func,NULL);
|
||||
ScrolledWindowPackControls(ScrollWin,button);
|
||||
}
|
||||
}
|
||||
//set callback function for button close window
|
||||
SetCallbackFunction(window,DELETE_EVENT,&callback_func_delete_window,NULL);
|
||||
//pack scrolled window in window
|
||||
PackControls(window,ScrollWin);
|
||||
//start main libGUI loop
|
||||
LibGUImain(window);
|
||||
}
|
45
programs/develop/libraries/libGUI/examples/src/text.c
Normal file
45
programs/develop/libraries/libGUI/examples/src/text.c
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
hello world example
|
||||
*/
|
||||
|
||||
#include "libGUI.h"
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
void callback_func_delete_window(header_t *control,void *data)
|
||||
{
|
||||
QuitLibGUI((parent_t*)control);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
parent_t *window;
|
||||
gui_text_data_t txtdata;
|
||||
gui_text_t *text;
|
||||
|
||||
//load libGUI library
|
||||
LoadLibGUI(NULL);//load from default system path to library
|
||||
//create main window
|
||||
window=CreateWindow();
|
||||
//change size of window
|
||||
SetWindowSizeRequest(window,92,46);
|
||||
//set callback function for button close window
|
||||
SetCallbackFunction(window,DELETE_EVENT,&callback_func_delete_window,NULL);
|
||||
//create control text
|
||||
txtdata.x=5;
|
||||
txtdata.y=5;
|
||||
txtdata.font=NULL;//use default system libGUI font
|
||||
txtdata.background=TRUE;//use background for text
|
||||
txtdata.color=0xffffff;//text color
|
||||
txtdata.background_color=0xff8000;//background color
|
||||
txtdata.text="Hello world!";
|
||||
text=CreateText(&txtdata);
|
||||
|
||||
//pack control text in window
|
||||
PackControls(window,text);
|
||||
|
||||
//start libGUI main loop
|
||||
LibGUImain(window);
|
||||
}
|
||||
|
Reference in New Issue
Block a user