Hi Micah,

Since the last changes of the server, I note a problem that seems to be due to 
resizing of widgets.
The following code highlight the problem.
The 'toggle' button juste toggle the size of the ~laucher~ between 0 and PG_S_ALL.
And when the ~laucher~ is graphically corrupted, you can retrieve it as good by 
changing the size of the window.

I hope this is of some help for you,
-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;


/* 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);
  printf("%i\n",last_size);
  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);

  return 0;
}


/* Main program */
int main(int argc, char **argv) {
  pgInit(argc,argv);

  pgRegisterApp( PG_APP_TOOLBAR,"Toolbar",
                 PG_APPSPEC_SIDE,PG_S_BOTTOM,
                 0 );

  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

Reply via email to