Beispiel #1
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;
}
Beispiel #2
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);
}
Beispiel #3
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;
}
Beispiel #4
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);
    }
  }
}
Beispiel #5
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;
}
Beispiel #6
0
/*
 * main
 */
int main (int argc, char * argv [])
{
  /* Constants to facilitate passing commands through pgBind() */
  struct keyboard_command cmd_show           = {htons (PG_KEYBOARD_SHOW)};
  struct keyboard_command cmd_hide           = {htons (PG_KEYBOARD_HIDE)};
  struct keyboard_command cmd_toggle         = {htons (PG_KEYBOARD_TOGGLE)};
  struct keyboard_command cmd_enable         = {htons (PG_KEYBOARD_ENABLE)};
  struct keyboard_command cmd_disable        = {htons (PG_KEYBOARD_DISABLE)};
  struct keyboard_command cmd_toggle_display = {htons (PG_KEYBOARD_TOGGLE_DISPLAY)};
  struct keyboard_command cmd_select_pattern = {htons (PG_KEYBOARD_SELECT_PATTERN), htons (PG_KBPATTERN_NUMERIC)};
  struct keyboard_command cmd_push_context   = {htons (PG_KEYBOARD_PUSH_CONTEXT)};
  struct keyboard_command cmd_pop_context    = {htons (PG_KEYBOARD_POP_CONTEXT)};
  struct keyboard_command cmd_block          = {htons (PG_KEYBOARD_BLOCK)};
  struct keyboard_command cmd_release        = {htons (PG_KEYBOARD_RELEASE)};

  /* Handle for GUI placement */
  pghandle lastBox;

  /* Handle for font object */
  pghandle font;

  /* Init and register the app */
  pgInit (argc, argv);
  pgRegisterApp (PG_APP_NORMAL, "Virtual Keyboard Commands", 0);

  font = pgNewFont ("Helvetica", 8, 0);

  /* Create all the widgets */
  lastBox = pgNewWidget (PG_WIDGET_BOX, 0, 0);

  pgNewWidget (PG_WIDGET_BUTTON, PG_DERIVE_INSIDE, PGDEFAULT);	
  pgSetWidget (PGDEFAULT,
	       PG_WP_TEXT, pgNewString ("SHOW"),
	       PG_WP_SIDE, PG_S_LEFT,
	       PG_WP_FONT, font,
	       0);
  pgBind (PGDEFAULT, PG_WE_ACTIVATE, &handleButton, &cmd_show);

  pgNewWidget (PG_WIDGET_BUTTON, PG_DERIVE_AFTER, PGDEFAULT);
  pgSetWidget (PGDEFAULT,
	       PG_WP_TEXT, pgNewString ("HIDE"),
	       PG_WP_SIDE, PG_S_LEFT,
	       PG_WP_FONT, font,
	       0);
  pgBind (PGDEFAULT, PG_WE_ACTIVATE, &handleButton, &cmd_hide);

  pgNewWidget (PG_WIDGET_BUTTON, PG_DERIVE_AFTER, PGDEFAULT);
  pgSetWidget (PGDEFAULT,
	       PG_WP_TEXT, pgNewString ("TOGGLE"),
	       PG_WP_SIDE, PG_S_LEFT,
	       PG_WP_FONT, font,
	       0);
  pgBind (PGDEFAULT, PG_WE_ACTIVATE, &handleButton, &cmd_toggle);

  lastBox = pgNewWidget (PG_WIDGET_BOX, PG_DERIVE_AFTER, lastBox);

  pgNewWidget (PG_WIDGET_BUTTON, PG_DERIVE_INSIDE, PGDEFAULT);	
  pgSetWidget (PGDEFAULT,
	       PG_WP_TEXT, pgNewString ("ENABLE"),
	       PG_WP_SIDE, PG_S_LEFT,
	       PG_WP_FONT, font,
	       0);
  pgBind (PGDEFAULT, PG_WE_ACTIVATE, &handleButton, &cmd_enable);

  pgNewWidget (PG_WIDGET_BUTTON, PG_DERIVE_AFTER, PGDEFAULT);	
  pgSetWidget (PGDEFAULT,
	       PG_WP_TEXT, pgNewString ("DISABLE"),
	       PG_WP_SIDE, PG_S_LEFT,
	       PG_WP_FONT, font,
	       0);
  pgBind (PGDEFAULT, PG_WE_ACTIVATE, &handleButton, &cmd_disable);

  pgNewWidget (PG_WIDGET_BUTTON, PG_DERIVE_AFTER, PGDEFAULT);	
  pgSetWidget (PGDEFAULT,
	       PG_WP_TEXT, pgNewString ("TOGGLE_ENABLE"),
	       PG_WP_SIDE, PG_S_LEFT,
	       PG_WP_FONT, font,
	       0);
  pgBind (PGDEFAULT, PG_WE_ACTIVATE, &handleButton, &cmd_toggle_display);

  lastBox = pgNewWidget (PG_WIDGET_BOX, PG_DERIVE_AFTER, lastBox);

  pgNewWidget (PG_WIDGET_BUTTON, PG_DERIVE_INSIDE, PGDEFAULT);	
  pgSetWidget (PGDEFAULT,
	       PG_WP_TEXT, pgNewString ("SELECT_PATTERN NUMERIC"),
	       PG_WP_SIDE, PG_S_LEFT,
	       PG_WP_FONT, font,
	       0);
  pgBind (PGDEFAULT, PG_WE_ACTIVATE, &handleButton, &cmd_select_pattern);

  pgNewWidget (PG_WIDGET_BUTTON, PG_DERIVE_AFTER, PGDEFAULT);	
  pgSetWidget (PGDEFAULT,
	       PG_WP_TEXT, pgNewString ("PUSH_CONTEXT"),
	       PG_WP_SIDE, PG_S_LEFT,
	       PG_WP_FONT, font,
	       0);
  pgBind (PGDEFAULT, PG_WE_ACTIVATE, &handleButton, &cmd_push_context);

  pgNewWidget (PG_WIDGET_BUTTON, PG_DERIVE_AFTER, PGDEFAULT);	
  pgSetWidget (PGDEFAULT,
	       PG_WP_TEXT, pgNewString ("POP_CONTEXT"),
	       PG_WP_SIDE, PG_S_LEFT,
	       PG_WP_FONT, font,
	       0);
  pgBind (PGDEFAULT, PG_WE_ACTIVATE, &handleButton, &cmd_pop_context);

  lastBox = pgNewWidget (PG_WIDGET_BOX, PG_DERIVE_AFTER, lastBox);

  pgNewWidget (PG_WIDGET_BUTTON, PG_DERIVE_INSIDE, PGDEFAULT);	
  pgSetWidget (PGDEFAULT,
	       PG_WP_TEXT, pgNewString ("BLOCK"),
	       PG_WP_SIDE, PG_S_LEFT,
	       PG_WP_FONT, font,
	       0);
  pgBind (PGDEFAULT, PG_WE_ACTIVATE, &handleButton, &cmd_block);

  pgNewWidget (PG_WIDGET_BUTTON, PG_DERIVE_AFTER, PGDEFAULT);	
  pgSetWidget (PGDEFAULT,
	       PG_WP_TEXT, pgNewString ("RELEASE"),
	       PG_WP_SIDE, PG_S_LEFT,
	       PG_WP_FONT, font,
	       0);
  pgBind (PGDEFAULT, PG_WE_ACTIVATE, &handleButton, &cmd_release);

  font = pgNewFont ("Helvetica", 12, 0);

  pgNewWidget (PG_WIDGET_FIELD, PG_DERIVE_AFTER, lastBox);
  pgSetWidget (PGDEFAULT,
	       PG_WP_SIZE, 16,
	       PG_WP_FONT, font,
	       0);

  /* Wait for events */
  pgEventLoop ();

  return 0;
}
Beispiel #7
0
/* Create our toolbar */
void init_call_info(void) {
  pghandle bArrowMask,bArrow;
    
  /* Set up a bitmap/bitmask for the keypad button up arrow.
   * We have the mask stored in PNM format, and we paint
   * the arrow bitmap itself solid black. If we wanted another
   * color for the arrow, we could paint it that other color,
   * then apply the bitmask to it with the PG_LGOP_INVERT_AND
   * logical operation to mask out only the arrow part.
   */
  bArrowMask = pgNewBitmap(pgFromMemory(arrow_bits,arrow_len));
  bArrow = pgCreateBitmap(11,6);
  pgRender(bArrow,PG_GROP_SETCOLOR,0x000000);
  pgRender(bArrow,PG_GROP_RECT,0,0,15,8);

  /* Create a toolbar that starts out hidden */
  wInfoBar = pgRegisterApp(PG_APP_TOOLBAR,"pgtuxphone/call_info",
			   PG_APPSPEC_SIDE, PG_S_BOTTOM,
			   0);
  pgSetWidget(PGDEFAULT,
	      PG_WP_SIZE,0,
	      0);
  
  /* Create widgets within the toolbar */
  
  wKeypadBtn = pgNewWidget(PG_WIDGET_BUTTON,0,0);
  pgSetWidget(PGDEFAULT,
	      PG_WP_SIDE,PG_S_LEFT,
	      PG_WP_BITMAP, bArrow,
	      PG_WP_BITMASK, bArrowMask,
	      PG_WP_EXTDEVENTS, PG_EXEV_TOGGLE,
	      PG_WP_TEXT,pgNewString("Keypad"),
	      0);
  pgBind(PGDEFAULT,PG_WE_ACTIVATE,&btnKeypad,NULL);
  
  pgNewWidget(PG_WIDGET_BUTTON,0,0);
  pgSetWidget(PGDEFAULT,
	      PG_WP_SIDE,PG_S_LEFT,
	      PG_WP_TEXT,pgNewString("Redial"),
	      0);
  pgBind(PGDEFAULT,PG_WE_ACTIVATE,&btnRedial,NULL);

  /* Make the connect time opaque and fixed-width to minimize the
   * amount of redrawing necessary to update it */
  wConnectTime = pgNewWidget(PG_WIDGET_LABEL,0,0);
  pgSetWidget(PGDEFAULT,
	      PG_WP_TRANSPARENT,0,
	      PG_WP_SIDE,PG_S_RIGHT,
	      PG_WP_FONT,pgNewFont(NULL,0,PG_FSTYLE_FIXED),
	      0);
  wCallStatus = pgNewWidget(PG_WIDGET_LABEL,0,0);
  pgSetWidget(PGDEFAULT,
	      PG_WP_SIDE,PG_S_RIGHT,
	      0);

  wName = pgNewWidget(PG_WIDGET_LABEL,0,0);
  pgSetWidget(PGDEFAULT,
	      PG_WP_SIDE,PG_S_LEFT,
	      PG_WP_FONT,pgNewFont(NULL,12,0),
	      0);

  wPhoneNumber = pgNewWidget(PG_WIDGET_CANVAS,0,0);
  pgSetWidget(PGDEFAULT,
	      PG_WP_SIDE,PG_S_ALL,
	      0);
  new_vfd_label(wPhoneNumber);

}
Beispiel #8
0
int main(int argc, char **argv) {
  pghandle wAllBox, wTXbox, wRXbox;

  /* initialise and register the application */
  pgInit(argc,argv);
  pgRegisterApp(PG_APP_NORMAL,"Network Monitor",0);
  
  /* create a box for putting all the ting inside it */
  wAllBox = pgNewWidget(PG_WIDGET_BOX,0,0);

  /* create a widget which have the name of the interface to monitor */
  wDeviceName = pgNewWidget(PG_WIDGET_BUTTON, PG_DERIVE_INSIDE, wAllBox);
  pgSetWidget (PGDEFAULT,
	       //PG_WP_DIRECTION,PG_DIR_VERTICAL,
	       PG_WP_SIDE, PG_S_RIGHT,
	       PG_WP_EXTDEVENTS, PG_EXEV_PNTR_DOWN,
	       0);
  pgReplaceTextFmt (wDeviceName, "%s", DEFAULT_NETWORK_INTERFACE);
  pgBind (PGDEFAULT, PG_WE_PNTR_DOWN, &selectInterface, NULL);

  /* create the widgets for monitor the RX traffic */
  wRXlabel = pgNewWidget(PG_WIDGET_BUTTON, 0, 0);
  pgSetWidget (PGDEFAULT,
	       PG_WP_SIDE, PG_S_TOP,
	       PG_WP_EXTDEVENTS, PG_EXEV_PNTR_DOWN,
	       0);
  pgBind (PGDEFAULT, PG_WE_PNTR_DOWN, &changeDisplay, NULL);
  wRXbox = pgNewWidget(PG_WIDGET_BOX, 0,0);

  /* create the widgets for monitor the TX traffic */
  wTXlabel = pgNewWidget(PG_WIDGET_BUTTON,0,0);
  pgSetWidget (PGDEFAULT,
	       PG_WP_SIDE, PG_S_TOP,
	       PG_WP_EXTDEVENTS, PG_EXEV_PNTR_DOWN,
	       0);
  pgBind (PGDEFAULT, PG_WE_PNTR_DOWN, &changeDisplay, NULL);
  wTXbox = pgNewWidget(PG_WIDGET_BOX,0,0);

  /* add the RX gauge */
  pgNewWidget(PG_WIDGET_LABEL, PG_DERIVE_INSIDE, wRXbox);
  pgSetWidget(PGDEFAULT,
	      PG_WP_TEXT, pgNewString("RX"),
	      PG_WP_SIDE, PG_S_RIGHT,
	      0);
  wRX = pgNewWidget(PG_WIDGET_INDICATOR, 0,0);
  pgSetWidget(PGDEFAULT,
	      PG_WP_SIDE, PG_S_ALL,
	      0);

  /* add the TX gauge */
  pgNewWidget(PG_WIDGET_LABEL, PG_DERIVE_INSIDE, wTXbox);
  pgSetWidget(PGDEFAULT,
	      PG_WP_TEXT, pgNewString("TX"),
	      PG_WP_SIDE, PG_S_RIGHT,
	      0);
  wTX = pgNewWidget(PG_WIDGET_INDICATOR, 0,0);
  pgSetWidget(PGDEFAULT,
	      PG_WP_SIDE, PG_S_ALL,
	      0);

  /* put the monitoring in the idle time */
  pgSetIdle(IDLE_TIME,&sysIdle);

  /* the main loop */
  pgEventLoop();

  /* bye */
  return 0;

}
Beispiel #9
0
int main(int argc, char **argv) {
    pghandle vbox, vbox2, wToolbar;

    pgInit(argc,argv);
    pgRegisterApp(PG_APP_NORMAL,"Textedit Demo",0);
    
    /* A toolbar for the buttons */
    wToolbar = pgNewWidget (PG_WIDGET_TOOLBAR, 0, 0);

    /* share the screen for two textedit widgets */
    vbox = pgNewWidget (PG_WIDGET_BOX, 0, 0);
    pgSetWidget (PGDEFAULT,
		 PG_WP_SIDE, PG_S_LEFT,
		 PG_WP_SIZE, pgFraction (1, 2),
		 PG_WP_SIZEMODE, PG_SZMODE_CNTFRACT,
		 0);

    vbox2 = pgNewWidget (PG_WIDGET_BOX, 0, 0);
    pgSetWidget (PGDEFAULT,
		 PG_WP_SIDE, PG_S_ALL,
		 0);

    /* first edit box */
    edit = pgNewWidget (PG_WIDGET_TEXTEDIT, PG_DERIVE_INSIDE, vbox); 
    pgSetWidget (edit,
		 PG_WP_FONT, pgNewFont (NULL, 12, PG_FSTYLE_BOLD),
		 PG_WP_TEXT, pgNewString ("Howdy!"),
		 PG_WP_SELECTION, pgNewString ("Hey!"),
		 0);

    /* second edit box */
    edit = pgNewWidget(PG_WIDGET_TEXTEDIT, PG_DERIVE_INSIDE, vbox2); 
    pgSetWidget (edit,
		 PG_WP_FONT, pgNewFont (NULL, 24, PG_FSTYLE_BOLD),
		 PG_WP_TEXT, pgNewString ("Howdy!"),
		 PG_WP_SELECTION, pgNewString ("Hey!"),
		 0);

    /* buttons in the toolbar */    
    wPaste = pgNewWidget(PG_WIDGET_BUTTON,PG_DERIVE_INSIDE,wToolbar);
    pgSetWidget(PGDEFAULT,
                PG_WP_SIZE,pgFraction(1,3),
                PG_WP_SIZEMODE,PG_SZMODE_CNTFRACT,
                PG_WP_TEXT,pgNewString("Paste"),
                0);
    pgBind(PGDEFAULT,PG_WE_ACTIVATE,&evtBtn,NULL);

    wCopy = pgNewWidget(PG_WIDGET_BUTTON,PG_DERIVE_INSIDE,wToolbar);
    pgSetWidget(PGDEFAULT,
                PG_WP_SIZE,pgFraction(1,3),
                PG_WP_SIZEMODE,PG_SZMODE_CNTFRACT,
                PG_WP_TEXT,pgNewString("Copy"),
                0);
    pgBind(PGDEFAULT,PG_WE_ACTIVATE,&evtBtn,NULL);

    wCut = pgNewWidget(PG_WIDGET_BUTTON,PG_DERIVE_INSIDE,wToolbar);
    pgSetWidget(PGDEFAULT,
                PG_WP_SIZE,pgFraction(1,3),
                PG_WP_SIZEMODE,PG_SZMODE_CNTFRACT,
                PG_WP_TEXT,pgNewString("Cut"),
                0);
    pgBind(PGDEFAULT,PG_WE_ACTIVATE,&evtBtn,NULL);
    
    pgSetWidget(edit,
		PG_WP_SELECTION, pgNewString("Two!"),
		0);

    pgEventLoop();

    return 0;
}
Beispiel #10
0
int main(int argc, char **argv) {
  pghandle wBox, wItem, sFoo;
  int i;

  /* Application
   */
  pgInit(argc,argv);
  pgRegisterApp(PG_APP_NORMAL,"List Test App",0);

  /* Scrolling box
   */
  wBox = pgNewWidget(PG_WIDGET_BOX,0,0);
  pgNewWidget(PG_WIDGET_SCROLL, PG_DERIVE_BEFORE, wBox);
  pgSetWidget(PGDEFAULT,
	      PG_WP_BIND, wBox,
	      0);

  /* Add some normal listitems (just text)
   * The listitem widget is hilighted when the cursor is over them,
   * and turned on when clicked. They are mutually exclusive.
   */
  for (i=0;i<5;i++) {
    wItem = pgNewWidget(PG_WIDGET_LISTITEM,
			i ? PGDEFAULT : PG_DERIVE_INSIDE,
			i ? PGDEFAULT : wBox);
    pgReplaceTextFmt(PGDEFAULT,"Normal listitem #%d",i);
  }

  /* Normally you'd want to use listitems, but just to show the
   * difference we'll throw in some menuitems...
   */
  for (i=0;i<5;i++) {
    wItem = pgNewWidget(PG_WIDGET_MENUITEM,0,0);
    pgReplaceTextFmt(PGDEFAULT,"Normal menuitem #%d",i);
  }

  /* Instead of using the PG_WP_TEXT property, create some
   * other widgets inside the listitem. They will be hilighted
   * with their PG_WP_HILIGHTED property when the mouse is over them.
   */
  sFoo = pgNewString("Foo");
  for (i=0;i<5;i++) {
    wItem = pgNewWidget(PG_WIDGET_LISTITEM,PG_DERIVE_AFTER,wItem);

    pgNewWidget(PG_WIDGET_CHECKBOX, PG_DERIVE_INSIDE, wItem);
    pgSetWidget(PGDEFAULT,
		PG_WP_TEXT, sFoo,
		PG_WP_SIDE, PG_S_LEFT,
		PG_WP_SIZEMODE, PG_SZMODE_PERCENT,
		PG_WP_SIZE, 20,
		0);

    pgNewWidget(PG_WIDGET_LABEL, 0,0);
    pgSetWidget(PGDEFAULT,
		PG_WP_SIDE, PG_S_LEFT,
		0);
    pgReplaceTextFmt(PGDEFAULT,"Container listitem #%d",i);
  }

  /* For contrast, repeat the same example with menuitems
   */
  for (i=0;i<5;i++) {
    wItem = pgNewWidget(PG_WIDGET_MENUITEM,PG_DERIVE_AFTER,wItem);

    pgNewWidget(PG_WIDGET_CHECKBOX, PG_DERIVE_INSIDE, wItem);
    pgSetWidget(PGDEFAULT,
		PG_WP_TEXT, sFoo,
		PG_WP_SIDE, PG_S_LEFT,
		PG_WP_SIZEMODE, PG_SZMODE_PERCENT,
		PG_WP_SIZE, 20,
		0);

    pgNewWidget(PG_WIDGET_LABEL, 0,0);
    pgSetWidget(PGDEFAULT,
		PG_WP_SIDE, PG_S_LEFT,
		0);
    pgReplaceTextFmt(PGDEFAULT,"Container menuitem #%d",i);
  }
  
  /* Just for testing the pgTraverseWidget method of finding
   * an item by its index:
   * (Normally if you wanted to print out all the items in a container
   * you should iterate with PG_TRAVERSE_FORWARD)
   */
  for (i=0;;i++) {
    pghandle w,t;
    char *text = "(no text)";

    w = pgTraverseWidget(wBox, PG_TRAVERSE_CHILDREN, i);
    if (!w)
      break;

    /* Get the widget's text if it has any */
    t = pgGetWidget(w, PG_WP_TEXT);
    if (t)
      text = pgGetString(t);

    printf("Child #%d : %s\n",i, text);
  }
  
  /* Add an event handler to catch all hilighting events
   */
  pgBind(PGBIND_ANY, PGBIND_ANY, evtHilight, NULL);  
  pgEventLoop();
  return 0;
}
Beispiel #11
0
int
main (int argc, char *argv[])
{
    char *home, *conffile;

    pghandle msgscroll, msgbox;
    pghandle wToolbar, wScroll, wItem;

    row = 0;

    pgInit (argc, argv);
    picomailapp = pgRegisterApp (PG_APP_NORMAL, "PicoMail", 0);

    home = getenv ("HOME");
    conffile = malloc (strlen (home) + strlen (CONFIG_FILE) + 1);
    if (home && conffile)
    {
        strcpy (conffile, home);
        strcat (conffile, CONFIG_FILE);

        if (!configfile_parse (conffile))
        {
            pgMessageDialog ("PicoMail",
                             "Configuration file could not be parsed.\n"
                             "Please make sure you have a good '~/.picomail.conf'!",
                             PG_MSGBTN_OK || PG_MSGICON_ERROR);
            exit (1);
        }
        free (conffile);
    }

    wToolbar = pgNewWidget (PG_WIDGET_TOOLBAR, 0, 0);



    wScroll = pgNewWidget (PG_WIDGET_SCROLL, 0, 0);
    wBox = pgNewWidget (PG_WIDGET_BOX, 0, 0);
    pgSetWidget (PGDEFAULT, PG_WP_SIDE, PG_S_ALL, 0);
    pgSetWidget (wScroll, PG_WP_BIND, wBox, 0);




    pgNewWidget (PG_WIDGET_BUTTON, PG_DERIVE_INSIDE, wToolbar);
    pgSetWidget (PGDEFAULT,
                 PG_WP_TEXT, pgNewString ("Read Message"),
                 PG_WP_SIDE, PG_S_LEFT, PG_WP_EXTDEVENTS, PG_EXEV_PNTR_DOWN, 0);
    pgBind (PGDEFAULT, PG_WE_PNTR_DOWN, &readMessage, NULL);


    pgNewWidget (PG_WIDGET_BUTTON, PG_DERIVE_INSIDE, wToolbar);
    pgSetWidget (PGDEFAULT,
                 PG_WP_TEXT, pgNewString ("Delete Message"),
                 PG_WP_SIDE, PG_S_LEFT, PG_WP_EXTDEVENTS, PG_EXEV_PNTR_DOWN, 0);
    pgBind (PGDEFAULT, PG_WE_PNTR_DOWN, &deleteMessage, NULL);


    pgNewWidget (PG_WIDGET_BUTTON, PG_DERIVE_INSIDE, wToolbar);
    pgSetWidget (PGDEFAULT,
                 PG_WP_TEXT, pgNewString ("Get list of messages!"),
                 PG_WP_SIDE, PG_S_LEFT, PG_WP_EXTDEVENTS, PG_EXEV_PNTR_DOWN, 0);
    pgBind (PGDEFAULT, PG_WE_PNTR_DOWN, &getList, NULL);

    pgBind (PGBIND_ANY, PG_WE_CLOSE, &closeboxHandler, NULL);

    /* message viewer */

    mesgviewer = pgRegisterApp (PG_APP_NORMAL, "PicoMail Message", 0);
    pgBind (mesgviewer, PG_WE_CLOSE, &viewerCloseboxHandler, NULL);
    pgSetWidget (mesgviewer, PG_WP_SIZE, 0, 0);
    msgscroll = pgNewWidget (PG_WIDGET_SCROLL, 0, 0);
    msgbox = pgNewWidget (PG_WIDGET_BOX, 0, 0);
    pgSetWidget (msgbox, PG_WP_SIDE, PG_S_ALL, 0);
    pgSetWidget (msgscroll, PG_WP_BIND, msgbox, 0);
    messagebox = pgNewWidget (PG_WIDGET_TEXTBOX, PG_DERIVE_INSIDE, PGDEFAULT);
//        pgSetWidget(msgscroll, PG_WP_BIND,messagebox, 0);
    pgSetWidget (messagebox,
                 PG_WP_TEXT, pgNewString ("Hier is uw bericht!"), 0);



    pgEventLoop ();

    configfile_free ();
    return 0;
}
Beispiel #12
0
int
main(int argc, char** argv)
{
  pgcolor color;
  struct pgmodeinfo mi;
  int i;
  pghandle ttl_box;

  /* init PicoGUI client */
  pgInit(argc,argv);
  pgRegisterApp(PG_APP_NORMAL, argv[0], 0);

  /* create the title */
  ttl_box = pgNewWidget(PG_WIDGET_BOX,0,0);

  ttl_text = pgNewWidget(PG_WIDGET_LABEL, PG_DERIVE_INSIDE, ttl_box);
  pgSetWidget (PGDEFAULT,
	       PG_WP_TEXT, pgNewString("wclock"),
	       0);

  pgNewWidget(PG_WIDGET_BUTTON, PG_DERIVE_INSIDE, ttl_box);
  pgSetWidget (PGDEFAULT,
               PG_WP_SIDE, PG_S_RIGHT,
 	       PG_WP_TEXT, pgNewString("?"),
               PG_WP_EXTDEVENTS, PG_EXEV_PNTR_DOWN,
               0);
  pgBind (PGDEFAULT, PG_WE_PNTR_DOWN, &btn_handler, (void*)btnid_set);

  pgNewWidget(PG_WIDGET_BUTTON, PG_DERIVE_INSIDE, ttl_box);
  pgSetWidget (PGDEFAULT,
               PG_WP_SIDE, PG_S_LEFT,
 	       PG_WP_TEXT, pgNewString(">"),
               PG_WP_EXTDEVENTS, PG_EXEV_PNTR_DOWN,
               0);
  pgBind (PGDEFAULT, PG_WE_PNTR_DOWN, &btn_handler, (void*)btnid_right);

  pgNewWidget(PG_WIDGET_BUTTON, PG_DERIVE_INSIDE, ttl_box);
  pgSetWidget (PGDEFAULT,
               PG_WP_SIDE, PG_S_LEFT,
 	       PG_WP_TEXT, pgNewString("<"),
               PG_WP_EXTDEVENTS, PG_EXEV_PNTR_DOWN,
               0);
  pgBind (PGDEFAULT, PG_WE_PNTR_DOWN, &btn_handler, (void*)btnid_left);

  /* create the main context */
  main_window = pgNewWidget(PG_WIDGET_CANVAS, PG_DERIVE_AFTER, ttl_box);
  pgBind(PGDEFAULT, PGBIND_ANY, &canvas_handler, NULL);

  /* init time zones */
  init_zones();

  /* activate mouse move, keyboard and focus events */
  pgSetWidget(main_window,
	      PG_WP_TRIGGERMASK, pgGetWidget(main_window, PG_WP_TRIGGERMASK) |
	      PG_TRIGGER_MOVE |
	      PG_TRIGGER_CHAR |
	      PG_TRIGGER_KEYDOWN |
	      PG_TRIGGER_KEYUP /* |
	      PG_TRIGGER_ACTIVATE |
	      PG_TRIGGER_DEACTIVATE */,
	      0);

  mi = *pgGetVideoMode();
  width = mi.lxres;
  height = mi.lyres;

  /* Make a backbuffer bitmap */
  world_bitmap = create_world_bitmap();
  width = get_world_width();
  height = get_world_height();

  /* Set the clipping rectangle */
  pgWriteCmd(main_window,
	     PGCANVAS_GROP, 5,
	     PG_GROP_SETCLIP, 0, 0, width, height + TIMEBAR_HEIGHT);
  
  /* Set to be always rendered */
  pgWriteCmd(main_window,
	     PGCANVAS_GROPFLAGS, 1,
	     PG_GROPF_UNIVERSAL);
  
  /* Create contexts for the canvas itself and the back-buffer */
  gfx_context = pgNewCanvasContext(main_window, PGFX_IMMEDIATE );

  /* run all */
  DPRINTF(">>> entering loop\n");
  pgEventLoop();

  return 0;
}
Beispiel #13
0
int main(int argc,char **argv) {
  /* File data */
  unsigned char * file_data;

#ifdef POCKETBEE

  /* Register the handler for SIGTERM */
  signal (SIGTERM, sig_handler);
  /* Register exit function */
  atexit (proper_exit);

#endif /* POCKETBEE */

  /* Make a 'toolbar' app */
  pgInit(argc,argv);
  wApp = pgRegisterApp(PG_APP_TOOLBAR,"Keyboard",0);

  wCanvas = pgNewWidget(PG_WIDGET_CANVAS, PG_DERIVE_INSIDE, wApp);
  pgSetWidget (PGDEFAULT,
	       PG_WP_SIDE, PG_S_ALL,
	       0);
  wDisabled = pgNewWidget (PG_WIDGET_CANVAS, PG_DERIVE_AFTER, wCanvas);
  pgSetWidget (PGDEFAULT,
	       PG_WP_SIDE, PG_S_ALL,
	       0);
  drawDisabledKeyboard ();

  if (!argv[1] || argv[2]) {
    printf("usage:\n  %s <keyboard file>\n",argv[0]);
    return 1;
  }

  /* Load patterns */
  fpat = fopen(argv[1],"r");
  if (!fpat) {
    pgMessageDialog(*argv,"Error loading keyboard file",0);
    return 1;
  }
  file_data = kb_validate (fpat, &mpat);
  fclose (fpat);
  if (file_data == NULL) {
    pgMessageDialog(*argv,"Invalid keyboard file [kb_validate()]",0);
    return 1;
  }
  if (kb_loadpatterns(file_data)) {
    free (file_data);
    pgMessageDialog(*argv,"Invalid keyboard file [kb_loadpatterns()]",0);
    return 1;
  }
  free (file_data);

  /* Resize app widget */
  pgSetWidget(wApp,
              PG_WP_NAME,pgNewString(PG_KEYBOARD_APPNAME),
	      PG_WP_SIDE,mpat->app_side,
#ifdef POCKETBEE
	      /* Start the keyboard hidden */
	      PG_WP_SIZE,0,
#else /* POCKETBEE */
	      PG_WP_SIZE,mpat->app_size,
#endif /* POCKETBEE */
	      PG_WP_SIZEMODE,mpat->app_sizemode,
	      PG_WP_TRANSPARENT,1,
	      0);

#ifdef POCKETBEE

#  ifdef USE_PM

  DPRINTF ("about to tell PM we are ready\n");
  
  /* Signal the PM of a proper start */
  if (pm_ready () == -1) {
    DPRINTF ("cannot signal PM (error during pm_ready)\n");
  }

#  endif /* USE_PM */

  /* Find the public box in the finder */
  {
    pghandle box;
    int i = 0;

    while ( !(box = pgFindWidget ("FinderKbdBox")) && i < 5 )
      {
	DPRINTF ("Finder public box not found, waiting ...\n");
	sleep (1);
	i++;
      }

    if (box)
      {
	/* Create a button in this box */
	pgNewWidget (PG_WIDGET_BUTTON, PG_DERIVE_INSIDE, box);
	pgSetWidget (PGDEFAULT,
		     PG_WP_TEXT, pgNewString ("Kbd"),
		     0);

	/* Attach a handler to it */
	pgBind (PGDEFAULT, PG_WE_ACTIVATE, &kbd_btn_handler, NULL);
      }
  }

#endif /* POCKETBEE */

  initKbdCanvas ();

  /* Set up an event handler for the received messages */
  pgBind (wApp, PG_WE_APPMSG, &evtMessage, NULL);

  pgEventLoop();
  return 0;
}