Example #1
0
int main(int argc, char **argv) {
  pghandle wPGLbar,wBattbox;
  pgInit(argc,argv);

  /* Find the applet container */
  wPGLbar = pgFindWidget("PGL-AppletBar");
  if (!wPGLbar) {
    pgMessageDialog(argv[0],"This applet requires PGL",PG_MSGICON_ERROR);
    return 1;
  }
 
  wBattbox = pgNewWidget(PG_WIDGET_BOX,PG_DERIVE_INSIDE,wPGLbar);
  pgSetWidget(PGDEFAULT,
	      PG_WP_SIDE,PG_S_RIGHT,
	      0);

  pgNewWidget(PG_WIDGET_LABEL,PG_DERIVE_INSIDE,wBattbox);
  pgSetWidget(PGDEFAULT,
	      PG_WP_TEXT,pgNewString("Batt"),
	      PG_WP_SIDE,PG_S_RIGHT,
	      0);

  wBatt = pgNewWidget(PG_WIDGET_INDICATOR,0,0);
  pgSetWidget(PGDEFAULT,
	      PG_WP_SIDE,PG_S_RIGHT,
	      0);  

  /* Run it. */
  pgSetIdle(4000,&sysIdle);
  pgEventLoop();
   
  return 0;
}
Example #2
0
void hide_call_info(void) {
  /* Turn off the idle handler, hide everything */
  pgSetIdle(0,NULL);
  pgSetWidget(wInfoBar,PG_WP_SIZE,0,0);
  pgSetWidget(wKeypad,PG_WP_SIZE,0,0);
  pgUpdate();
}
Example #3
0
int
viewerCloseboxHandler (struct pgEvent *evt)
{
    pgSetWidget (picomailapp, PG_WP_SIZE, 0x7FFF, 0);
    pgSetWidget (mesgviewer, PG_WP_SIZE, 0, 0);
    return 1;
}
Example #4
0
int main(int argc, char **argv) {
  pghandle w[40];
  pghandle app;
  int i;
  float t;
  
  pgInit(argc,argv);
  app = pgRegisterApp(PG_APP_NORMAL,"Scrollbar Fun - C",0);
  
  for (i=0;i<40;i++) {
    w[i] = pgNewWidget(PG_WIDGET_SCROLL,PG_DERIVE_INSIDE,app);
    pgSetWidget(PGDEFAULT,
		PG_WP_SIDE, PG_S_LEFT,
		0);
  }
  
  t = 0;
  while (1) {
    t += 0.04;
    for (i=0;i<40;i++)
      pgSetWidget(w[i],
		  PG_WP_VALUE, (int)(50 + 50 * sin(i*0.2+t)),
		  0);
    pgUpdate();
  }

  return 0;
}
Example #5
0
int evtClear(struct pgEvent *evt){
  picosmUI *interface = (picosmUI *)evt->extra;

  pgEnterContext();
  pgSetWidget(interface->wPasswd,
	      PG_WP_TEXT, pgNewString(""),
	      0);
  pgSetWidget(interface->wLogin,
	      PG_WP_TEXT, pgNewString(""),
	      0);
  pgFocus(interface->wLogin);
  pgLeaveContext();

  return 1;
}
Example #6
0
int main(int argc, char **argv) {
  pghandle wLoadbox,fntLabel;

  pgInit(argc,argv);
  pgRegisterApp(PG_APP_TOOLBAR,"OmniBar-Helio",0);

  /* A font for our labels */
  fntLabel = pgNewFont(NULL,10,PG_FSTYLE_FIXED);

  /* Top-level widgets */

  pgNewWidget(PG_WIDGET_BUTTON,0,0);
  pgSetWidget(PGDEFAULT,
	      PG_WP_TEXT,pgNewString("App"),
	      PG_WP_EXTDEVENTS,PG_EXEV_PNTR_DOWN,
	      0);
  pgBind(PGDEFAULT,PG_WE_PNTR_DOWN,&btnAppMenu,NULL);

  pgNewWidget(PG_WIDGET_BUTTON,0,0);
  pgSetWidget(PGDEFAULT,
	      PG_WP_TEXT,pgNewString("Sys"),
	      PG_WP_EXTDEVENTS,PG_EXEV_PNTR_DOWN,
	      0);
  pgBind(PGDEFAULT,PG_WE_PNTR_DOWN,&btnSysMenu,NULL);

  wClock = pgNewWidget(PG_WIDGET_LABEL,0,0);
  pgSetWidget(PGDEFAULT,
	      PG_WP_SIDE,PG_S_RIGHT,
	      PG_WP_FONT,fntLabel,
	      PG_WP_TRANSPARENT,0,
	      0);

  pgNewWidget(PG_WIDGET_BOX,0,0);
  pgNewWidget(PG_WIDGET_LABEL,PG_DERIVE_INSIDE,PGDEFAULT);
  pgSetWidget(PGDEFAULT,
	      PG_WP_TEXT,pgNewString("Batt:"),
	      PG_WP_SIDE,PG_S_LEFT,
	      PG_WP_TRANSPARENT,1,
	      0);
  wBatt = pgNewWidget(PG_WIDGET_INDICATOR,0,0);
  pgSetWidget(PGDEFAULT,PG_WP_SIDE,PG_S_ALL,0);

  /* Run it. */
  pgSetIdle(5000,&sysIdle);
  pgEventLoop();
   
  return 0;
}
Example #7
0
void sysIdle(void) {
  FILE *f;
  char buf[50];
  int bat_raw, bat_percent;
  
  /* Get battery status */
  f = fopen("/proc/r39xxpm","r");
  if (f) {
    /* I don't think the format of /proc/r39xxpm is set in stone, so
     * this might break? Oh well, works for now. */
    fgets(buf,50,f);  /* CPU speed */
    fgets(buf,50,f);  /* Battery voltage */
    fclose(f);
    bat_raw = atoi(buf+9); /* Skip past "Battery: " */
    
    /* Translate to percent, assuming 259 (2.0 volts) is empty
     * and 402 (3.0 volts) is full. */
    bat_percent = ((bat_raw - 259) * 100) / 143;
    if (bat_percent < 0) bat_percent = 0;
    if (bat_percent > 100) bat_percent = 100;
    
    pgSetWidget(wBatt,PG_WP_VALUE,bat_percent,0);
    pgFlushRequests();
    pgSubUpdate(wBatt);  
  }
}
Example #8
0
int main(int argc,char **argv) {
  pghandle wPGLbar;
  pgInit(argc,argv);

  /* Find the applet container */
  pglToolbar = pgFindWidget("PGL-AppletBar");
  if (!pglToolbar) {
    pgMessageDialog(argv[0],"This applet requires PGL",PG_MSGICON_ERROR);
    return 1;
  }
 
  /* Clock widget. Make it a flatbutton so it normally looks fairly
   * unobtrusive, but it can be clicked. Clicking the clock launches
   * an options dialog box.
   */
  currentClock.wClock = pgNewWidget(PG_WIDGET_FLATBUTTON,
				    PG_DERIVE_INSIDE,pglToolbar);
  pgSetWidget(PGDEFAULT,
	      PG_WP_SIDE,PG_S_RIGHT,
	      PG_WP_NAME,pgNewString("PGL-Clock"),
	      0);
  pgBind(PGDEFAULT,PG_WE_ACTIVATE,&btnDialog,NULL);
  pgBind(PGDEFAULT, PG_WE_APPMSG, &recieveMessage, NULL);

  /* Let the toolbar know we exist */
  
  pgAppMessage(pglToolbar, pglBuildMessage(PGL_APPLETINSTALLED, "PGL-Clock", "", ""));

  /* Set up default clock */
  currentClock.fClockFont = pgNewFont(NULL,0,PG_FSTYLE_FIXED);
  mungeSettings();

  pgEventLoop();
  return 0;
}
Example #9
0
void loadSettings(void){
  char *dataPath, *bitmapName, *finalPath;
  pghandle bitmapHandle;

  pgAppMessage(pglToolbar, pglBuildMessage(PGL_GETPREF, 
					   "PGL-Keyboard", 
					   "dataPath", 
					   ""));
  recieveMessage(pgGetEvent());
  dataPath = strdup(pglToolbarResponse);
  pgAppMessage(pglToolbar, pglBuildMessage(PGL_GETPREF, "PGL-Keyboard", "kbIcon", ""));
  recieveMessage(pgGetEvent());
  bitmapName = strdup(pglToolbarResponse);
  
  finalPath = malloc(strlen(dataPath)+strlen(bitmapName)+1);
  strcpy(finalPath, dataPath);
  strcat(finalPath, bitmapName);

  printf("%s\n", finalPath);

  bitmapHandle = pgNewBitmap(pgFromFile(finalPath));

  printf("%d\n", pglButton);

  pgSetWidget(pglButton,
	      PG_WP_BITMAP, bitmapHandle,
	      0);
}
Example #10
0
int main(int argc, char **argv){
  struct keyboard_command cmd_toggle         = {htons (PG_KEYBOARD_TOGGLE)};

  pgInit(argc, argv);
  
  /* Find the applet container */
  pglToolbar = pgFindWidget("PGL-AppletBar");
  if (!pglToolbar) {
    pgMessageDialog(argv[0],"This applet requires PGL",PG_MSGICON_ERROR);
    return 1;
  }

  pglButton = pgNewWidget(PG_WIDGET_FLATBUTTON, PG_DERIVE_INSIDE, pglToolbar);
  pgSetWidget (pglButton,
	       PG_WP_NAME, pgNewString("PGL-Keyboard"),
	       PG_WP_SIDE, PG_S_RIGHT,
	       0);
  pgBind(pglButton, PG_WE_APPMSG, &recieveMessage, NULL);
  pgBind(pglButton, PG_WE_ACTIVATE, &handleButton, &cmd_toggle);

  pgAppMessage(pglToolbar, pglBuildMessage(PGL_APPLETINSTALLED, "PGL-Keyboard", "", ""));

  pgEventLoop();
  return 0;
}
Example #11
0
int hIndicatorBar(struct edemoUI* interface, pghandle widget)
{
    wIndicatorBar = widget;
    iIndicatorValue = 30;
    pgSetWidget(widget, PG_WP_VALUE, iIndicatorValue, 0);
    return 0;
}
Example #12
0
void sysIdle(void) {
  char *ct;
  char buf[50];
  FILE *f;
  unsigned long cpu_user,cpu_nice,cpu_sys,cpu_idle;
  unsigned long crun,ctotal,wval;
  static unsigned long ocrun = 0,octotal = 1,owval = 0;

  /* Get CPU load */
  f = fopen("/proc/stat","r");
  fgets(buf,50,f);
  fclose(f);
  sscanf(buf,"cpu %lu %lu %lu %lu",&cpu_user,&cpu_nice,&cpu_sys,&cpu_idle);  
  crun = cpu_user + cpu_sys;
  ctotal = crun + cpu_nice + cpu_idle;
  if (crun==ocrun || ctotal==octotal)
    wval = 0;
  else
    wval = (crun-ocrun) * 100 / (ctotal-octotal);

  if (wval!=owval) {
    pgSetWidget(wLoad,PG_WP_VALUE,wval,0);
    pgSubUpdate(wLoad);
  }

  owval = wval;
  ocrun = crun;
  octotal = ctotal;
}
Example #13
0
/*
 * Pop the last pushed keyboard context
 */
void popKeyboardContext ()
{
  struct keyboard_context * kbc = context_top;

  if (context_top == NULL)
    {
      /* No context to pop -> ignore */
      DPRINTF ("popKeyboardContext() on empty context stack --> ignored\n");
      return;
    }

  /* Retrieve context data */
  pgSetWidget(wApp,
	      PG_WP_SIZE, kbc->appSize,
	      0);
  enable_status = kbc->enable_status;
  enable_status ? enableKbdCanvas () : disableKbdCanvas ();
  selectPattern (kbc->current_patnum);

  /* Update top of context stack */
  context_top = kbc->next;

  /* Free context space */
  free (kbc);
}
Example #14
0
int PG_VideoInit(_THIS, SDL_PixelFormat *vformat)
{
        /* Connect to the PicoGUI server. No way to process command line args yet,
	 * but since this is based on SHM it's not important to be able to specify
	 * a remote PicoGUI server.
	 *
	 * FIXME: Another nitpick about the current client lib is there's no
	 *        clean way to indicate that command line args are not available.
	 */
        pgInit(0,(char**)"");
	this->hidden->mi = *pgGetVideoMode();

	/* Create a picogui application and canvas. We'll populate the canvas later. */
	this->hidden->wApp = pgRegisterApp(PG_APP_NORMAL,"SDL",0);
	this->hidden->wCanvas = pgNewWidget(PG_WIDGET_CANVAS,0,0);
	pgSetWidget(PGDEFAULT,
		    PG_WP_SIDE, PG_S_ALL,
		    0);

	PG_InitEvents(this);

	/* Determine the screen depth.
	 * We change this during the SDL_SetVideoMode implementation... 
	 * Round up to the nearest Bytes per pixel
	 */
	vformat->BitsPerPixel = this->hidden->mi.bpp;
	vformat->BytesPerPixel = this->hidden->mi.bpp >> 3;
	if (this->hidden->mi.bpp & 7)
	  vformat->BytesPerPixel++;

	/* We're done! */
	return(0);
}
Example #15
0
/*
 * Disable the keyboard canvas
 */
void disableKbdCanvas ()
{
  pgSetWidget (wCanvas,
	       PG_WP_SIZE, 0,
	       PG_WP_SIDE, PG_S_TOP,
	       0);
}
Example #16
0
int
readMessage (struct pgEvent *evt)
{
    char *message;

    if (selectedMessage > 0)
    {
        pgSetWidget (mesgviewer, PG_WP_SIZE, 0x7FFF, 0);
        pgSetWidget (picomailapp, PG_WP_SIZE, 0, 0);
        message = imap_getmesg (selectedMessage);
        pgSetWidget (messagebox, PG_WP_TEXT, pgNewString (message), 0);
    }
    else
        pgMessageDialog ("PicoMail",
                         "Please select a message first!", PG_MSGBTN_OK);

    return 0;
}
Example #17
0
int evtIndicatorUp(struct pgEvent *evt)
{
    iIndicatorValue += INDSTEP;
    if (iIndicatorValue > 100)
	iIndicatorValue = 100;

    pgSetWidget((pghandle)evt->extra, PG_WP_VALUE, iIndicatorValue, 0);
    return 1;
}
Example #18
0
int evtIndicatorDown(struct pgEvent *evt)
{
    iIndicatorValue -= INDSTEP;
    if (iIndicatorValue < 0)
	iIndicatorValue = 0;

    pgSetWidget((pghandle)evt->extra, PG_WP_VALUE, iIndicatorValue, 0);
    return 1;
}
Example #19
0
/* Create the phone keypad so we can easily turn it on and off later */
void init_keypad(void) {
  pghandle column,button;
  int i,j;
  struct pgEvent e;
  pghandle font;

  /* Create the keypad toolbar, invisible for now */
  wKeypad = pgRegisterApp(PG_APP_TOOLBAR,"pgtuxphone/keypad",
			  PG_APPSPEC_SIDE, PG_S_BOTTOM,
			  0);
  pgSetWidget(PGDEFAULT,
	      PG_WP_SIZE,0,
	      0);

  font = pgNewFont(NULL,20,0);

  /* Make our button grid */
  for (i=0, column=0;i<3;i++) {
    column = pgNewWidget(PG_WIDGET_BOX,column ? PG_DERIVE_AFTER : PG_DERIVE_INSIDE,
			 column);
    pgSetWidget(PGDEFAULT,
		PG_WP_TRANSPARENT,1,
		PG_WP_SIDE,PG_S_LEFT,
		0);
    for (j=0, button=0; j<4;j++) {
      button = pgNewWidget(PG_WIDGET_BUTTON, button ? PG_DERIVE_AFTER :
			   PG_DERIVE_INSIDE, button ? button : column);
      pgSetWidget(PGDEFAULT,
		  //		  PG_WP_SIZE,pgFraction(1,4),
		  //		  PG_WP_SIZEMODE,PG_SZMODE_CNTFRACT,
		  PG_WP_TEXT,pgNewString(keypad[j][i]),
		  PG_WP_FONT,font,
		  PG_WP_SIDE,PG_S_TOP,
		  0);

      /* Extra is a pointer to the digit to dial. Since there's some padding
       * in the button strings, the +1 gives the character itself
       */
      pgBind(PGDEFAULT,PG_WE_ACTIVATE,btnDial,keypad[j][i]+1);
    }
  }
}
Example #20
0
int main(int argc, char **argv) {
   pgInit(argc,argv);
   pgRegisterApp(PG_APP_NORMAL,"Blackout",0);

   /*** Top-level widgets: toolbar and canvas */
   wToolbar = pgNewWidget(PG_WIDGET_TOOLBAR,0,0);
   wCanvas = pgNewWidget(PG_WIDGET_CANVAS,0,0);
   pgBind(PGDEFAULT,PG_WE_BUILD,&evtDrawBoard,NULL);
   pgBind(PGDEFAULT,PG_WE_PNTR_DOWN,&evtMouseDown,NULL);

   /* Toolbar thingies */
   
   pgNewWidget(PG_WIDGET_BUTTON,PG_DERIVE_INSIDE,wToolbar);
   pgSetWidget(PGDEFAULT,
	       PG_WP_TEXT,pgNewString("Menu"),
	       PG_WP_EXTDEVENTS,PG_EXEV_PNTR_DOWN,
	       0);
   pgBind(PGDEFAULT,PG_WE_PNTR_DOWN,&btnMenu,NULL);

   wStatusLabel = pgNewWidget(PG_WIDGET_LABEL,0,0);
   pgSetWidget(PGDEFAULT,
	       PG_WP_SIDE,PG_S_ALL,
	       PG_WP_TRANSPARENT,0,
	       PG_WP_ALIGN,PG_A_CENTER,
//	       PG_WP_FONT,pgNewFont(NULL,10,PG_FSTYLE_BOLD),
	       0);


   /*** Allocate default game board */
   srand(time(NULL));
   boardwidth = 5;
   boardheight = 5;
   boardsize = sizeof(light) * boardwidth * boardheight;
   board = (light *) malloc(boardsize);
   solution = (light *) malloc(boardsize);
   startLevel(1);
   
   /*** Event loop */
   pgEventLoop();
   return 0;
}
Example #21
0
/* Prepare settings for use in updateTime */
void mungeSettings(void) {
  unsigned long t;

  /* Set clock font */
  pgSetWidget(currentClock.wClock,
	      PG_WP_FONT,currentClock.fClockFont,
	      0);
  
  /* Figure out the necessary update time */
  if (currentClock.flashColon)
    t = 500;
  else if (currentClock.enableSeconds)
    t = 1000;
  else
    t = 60000;
  pgSetIdle(t,&updateTime);

  /* Build a format string */
  currentClock.fmt1[0] = 0;              /* Start out blank */
  if (currentClock.enableWeekDay)
    strcat(currentClock.fmt1,"%a ");
  if (currentClock.enableMonth)
    strcat(currentClock.fmt1,"%b ");
  if (currentClock.enableDay)
    strcat(currentClock.fmt1,"%e ");
  if (currentClock.enable24hour)
    strcat(currentClock.fmt1,"%k");
  else
    strcat(currentClock.fmt1,"%l");
  strcat(currentClock.fmt1,":%M");
  if (currentClock.enableSeconds)        /* Careful with the colons... */
    strcat(currentClock.fmt1,":%S ");
  else
    strcat(currentClock.fmt1," ");
  if (!currentClock.enable24hour)
    strcat(currentClock.fmt1,"%p ");
  if (currentClock.enableYear)
    strcat(currentClock.fmt1,"%Y ");
  currentClock.fmt1[strlen(currentClock.fmt1)-1] = 0;  /* Chop extra space */

  /* Make secondary format string with optional colon flashing */
  strcpy(currentClock.fmt2,currentClock.fmt1);
  if (currentClock.flashColon) {
    /* Convert all colons to blanks */
    char *p = currentClock.fmt2;
    while (p = strchr(p,':'))
      *p = ' ';
  }

  /* Resize the applet if necessary */
  updateTime();
  pgUpdate();
}
Example #22
0
/* This is now pretty much obsolete, since there's the dialogbox widget to do all the work */
pghandle pgDialogBox(const char *title) {
  pghandle popupHandle;

  popupHandle = pgCreateWidget(PG_WIDGET_DIALOGBOX);
  pgSetWidget(PGDEFAULT,
	      PG_WP_TEXT,pgNewString(title),
	      0);
  _pgdefault_rship = PG_DERIVE_INSIDE;

  /* return the newly created handle */
  return popupHandle;
}
Example #23
0
int btnTarget(struct pgEvent *evt) {
  pgcontext gc;
  pghandle wClose,wTB;
  int i,x,w;

  pgEnterContext();
  pgDialogBox("Target");
  wTB = pgNewWidget(PG_WIDGET_TOOLBAR,0,0);
  pgSetWidget(PGDEFAULT,
	      PG_WP_SIDE,PG_S_BOTTOM,
	      0);

  /* Just draw something fun here */
  pgNewWidget(PG_WIDGET_CANVAS,0,0);
  gc = pgNewCanvasContext(PGDEFAULT,PGFX_PERSISTENT);
  pgSetMapping(gc,0,0,100,100,PG_MAP_SCALE);
  for (i=0;i<=4;i++) {
    x = i*10;
    w = 100-(x<<1);
    pgSetColor(gc,i&1 ? 0xFFFFFF : 0xFF0000);
    pgFEllipse(gc,x,x,w,w);
    pgSetColor(gc,0x000000);
    pgEllipse(gc,x,x,w,w);
  }
  pgContextUpdate(gc);
  pgDeleteContext(gc);

  /* A close button */
  wClose = pgNewWidget(PG_WIDGET_BUTTON,PG_DERIVE_INSIDE,wTB);
  pgSetWidget(PGDEFAULT,
	      PG_WP_TEXT,pgNewString("Close"),
	      PG_WP_HOTKEY,PGKEY_RETURN,
	      PG_WP_SIDE,PG_S_RIGHT,
	      0);

  /* Wait for a click on the canvas, then clean up */
  while (pgGetEvent()->from != wClose);
  pgLeaveContext();
  return 0;
}
Example #24
0
int btnFont(struct pgEvent *evt) {
  pghandle fnt;

  fnt = pgFontPicker("Pick a new font");

  if (fnt) {
    /* Delete the old font, and set the new font */
    
    pgDelete(pgGetWidget(wFontBtn,PG_WP_FONT));
    pgSetWidget(wFontBtn,PG_WP_FONT,fnt,0);
  }

  return 0;
}
Example #25
0
/* Show and hide the call info bar */
void show_call_info(struct phonecall *call) {
  current_call = call;
  old_connect_time = -1;

  /* Display info on this call 
   *
   * FIXME: pretty-print the phone number, so the user sees "(303) 555-1234"
   *        instead of "3035551234". Make sure to look up the appropriate specs
   *        so it does local calls, long distance, 10-digit dialing,
   *        and international correctly.
   */
  set_call_status(call,call->status);
  update_call_timer();
  pgSetIdle(500,update_call_timer);
  pgSetWidget(wKeypadBtn,
	      PG_WP_ON,0,
	      0);
  set_vfd_text(wPhoneNumber,"");
  pgSetWidget(wInfoBar,
	      PG_WP_SIZE,-1,    /* Automatic sizing */
	      0);
  pgUpdate();
}
Example #26
0
void dlgicon(pghandle at,int prop) {
  pghandle bit;

  bit = pgThemeLookup(PGTH_O_POPUP_MESSAGEDLG,prop);
  if (bit) {

  pgNewWidget(PG_WIDGET_LABEL,PG_DERIVE_AFTER,at);
  pgSetWidget(PGDEFAULT,
	      PG_WP_SIDE,PG_S_LEFT,
	      PG_WP_IMAGE,bit,
	      PG_WP_BITMASK,pgThemeLookup(PGTH_O_POPUP_MESSAGEDLG,prop+1),
	      0);
  }
}
Example #27
0
/* Little internal helper function for the message dialog */
void dlgbtn(pghandle tb,u32 payload,int textproperty,
	    int iconproperty,int key) {

  pgNewWidget(PG_WIDGET_BUTTON,PG_DERIVE_INSIDE,tb);
  pgSetWidget(PGDEFAULT,
	      PG_WP_TEXT,pgGetServerRes(textproperty),
	      PG_WP_SIDE,PG_S_RIGHT,
	      PG_WP_HOTKEY,pgThemeLookup(PGTH_O_POPUP_MESSAGEDLG,key),
	      PG_WP_IMAGE,pgThemeLookup(PGTH_O_POPUP_MESSAGEDLG,
					 iconproperty),
	      PG_WP_BITMASK,pgThemeLookup(PGTH_O_POPUP_MESSAGEDLG,
					  iconproperty+1),
	      0);
  pgSetPayload(PGDEFAULT,payload);
}
Example #28
0
/* This creates a menu from an array of string handles. 
 * Same return values as pgMenuFromString above.
 *
 * Important note: pgMenuFromArray expects that a new
 *                 context will be entered before the
 *                 string handles are created
 */
int pgMenuFromArray(pghandle *items,int numitems) {
  int i;
  pghandle returnHandle;
  returnHandle = pgNewPopupAt(PG_POPUP_ATEVENT,PG_POPUP_ATEVENT,0,0);

  for (i=0;i<numitems;i++) {
    printf("Menu Item => %d\n", pgNewWidget(PG_WIDGET_MENUITEM,0,0));
    pgSetWidget(PGDEFAULT,
		PG_WP_TEXT,items[i],
		0);
    pgSetPayload(PGDEFAULT,i+1);
  }

  /* Return event */
  return pgGetPayload(pgGetEvent()->from);
}
Example #29
0
int btnInput(struct pgEvent *evt) {
  pghandle str;

  str = pgInputDialog("Input Test",
		      "What... is the air-speed velocity of\n"
                      "an unladen swallow?",
                      pgGetWidget(wInputBtn,PG_WP_TEXT));

  if (str) {
    /* Normally we would use pgReplaceText, but we already have a
     * handle so we can save a step. */
    
    pgDelete(pgGetWidget(wInputBtn,PG_WP_TEXT));
    pgSetWidget(wInputBtn,PG_WP_TEXT,str,0);
  }
  return 0;
}
Example #30
0
/*
 * Handler for click event on the Keyboard button
 */
int kbd_btn_handler (struct pgEvent * evt)
{
  if (evt->type == PG_WE_ACTIVATE)
    {
      if (!blocked)
	{
	  pgSetWidget(wApp,
		      PG_WP_SIZE, mpat->app_size - pgGetWidget (wApp, PG_WP_SIZE),
		      0);
	}
    }
  else
    {
      /* Ignore */
    }

  return 1;
}