First of all, great job for the optimisation, the last bug I send is corrected.
However, I note two bad behaviour (sorry, I have only bad news those last times...)
* Popup seems not to dimm the background anymore
* Update of deleted widget seems not to work
The first appear today (with the last modifications) but the second was already
present yesterday.
The following program hightlight the second problem. (it's almost the same proggy as
yesterday...)
A little 'coucou!' button have to appear/disappear in the same way as the launcher.
But it doesn't and is always displayed but not binded...
If I replace the create/delete process by a size=size/size=0 one, it works, then maybe
the problem is about it's grop node that isn't deleted...
Maybe this is of some help...
-philippe
---8<--------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <picogui.h>
/*
* define the grid of the button for the Launcher
* a 'NULL' define a new line and a double 'NULL' for the end of the grid
* (this is due to the algo for grid construction)
*/
static char *buttongrid[] = {
NULL,"ToDo","Web","Games",
NULL,"Calculator","Mail","Expenses",
NULL,"Addresses","Calendar","Notes",
NULL,NULL
};
static pghandle wLauncherApp;
static pghandle wBtnToggle;
static pghandle wBtnLauncher;
/* Load the Launcher app in memory */
int launcher_load(void) {
char* s;
int i;
pghandle wRow=0,wButton=0,wGridbox=0;
wLauncherApp = pgRegisterApp(PG_APP_NORMAL,"Launcher Panel",0);
/* Box widget that occupies ... */
wGridbox = pgNewWidget(PG_WIDGET_BOX,0,0);
pgSetWidget(PGDEFAULT,PG_WP_SIDE,PG_S_ALL,0); /* ... all the free space */
/* The Launcher panel */
for (i=0;;i++) {
s = buttongrid[i];
if (s) { /* Add a button to the row */
wButton = pgNewWidget(PG_WIDGET_FLATBUTTON,
wButton ? PG_DERIVE_AFTER : PG_DERIVE_INSIDE,
wButton ? wButton : wRow);
pgSetWidget(PGDEFAULT,
PG_WP_TEXT,pgNewString(s),
PG_WP_SIZEMODE,PG_SZMODE_CNTFRACT,
PG_WP_SIZE,pgFraction(1,3),
0);
pgSetPayload(PGDEFAULT,(unsigned long) s);
}
else { /* Add a row */
if (!buttongrid[i+1]) /* Two consecutive NULLs, exit */
break;
wRow = pgNewWidget(PG_WIDGET_BOX,
wRow ? PG_DERIVE_AFTER : PG_DERIVE_INSIDE,
wRow ? wRow : wGridbox);
pgSetWidget(PGDEFAULT,
PG_WP_TRANSPARENT,1,
PG_WP_SIDE,PG_S_BOTTOM,
PG_WP_SIZEMODE,PG_SZMODE_CNTFRACT,
PG_WP_SIZE,pgFraction(1,3),
0);
wButton = 0;
}
}
}
/* toggle the size of the launcher */
int toggle_btn_handler(struct pgEvent *evt) {
static int size = 0;
static int last_size = 1;
last_size = (last_size ? 0 : 1);
size = PG_S_ALL * last_size;
if(wLauncherApp)
/* the handle is not 0 then the Launcher app is already loaded */
pgSetWidget(wLauncherApp,PG_WP_SIZE,size,0);
if(!wBtnLauncher) {
wBtnLauncher = pgNewWidget(PG_WIDGET_BUTTON,PG_DERIVE_AFTER,wBtnToggle);
pgSetWidget(PGDEFAULT,
PG_WP_TEXT,pgNewString("Coucou!"),
0);
pgBind(PGDEFAULT,PG_WE_ACTIVATE,&toggle_btn_handler,NULL);
}
else {
pgDelete(wBtnLauncher);
wBtnLauncher = 0;
}
return 0;
}
/* Main program */
int main(int argc, char **argv) {
pgInit(argc,argv);
wBtnLauncher = 0;
pgRegisterApp( PG_APP_TOOLBAR,"Toolbar",
PG_APPSPEC_SIDE,PG_S_BOTTOM,
0 );
wBtnToggle = pgNewWidget(PG_WIDGET_BUTTON, 0, 0);
pgSetWidget(PGDEFAULT,
PG_WP_SIDE,PG_S_LEFT,
PG_WP_TEXT,pgNewString("Toggle"),
0);
pgBind(PGDEFAULT,PG_WE_ACTIVATE,&toggle_btn_handler,NULL);
/* Call the launcher panel */
launcher_load();
pgEventLoop();
return 0;
}
/* The End */
_______________________________________________
Pgui-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/pgui-devel