Advertisement
Guest User

QNX Photon grid/table widget

a guest
Jan 17th, 2013
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.33 KB | None | 0 0
  1. #include <Pt.h>
  2.  
  3. int main( int argc, char *argv[] )
  4. {
  5.   PtWidget_t *window, *container, *grid, *divider, *column00, *column01;
  6.   PtArg_t args[20];
  7.   int i = 0;
  8.  
  9.   /* Create a window */
  10.   i = 0;
  11.   PtSetArg( &args[i++], Pt_ARG_WINDOW_TITLE, "demo window", 0 );
  12.   if ( NULL == ( window = PtAppInit( NULL, &argc, argv, i, args ) ) ) {
  13.     perror( "PtAppInit()" );
  14.     return 1;
  15.   }
  16.  
  17.   i = 0;
  18.   PtSetArg( &args[i++], Pt_ARG_ANCHOR_FLAGS,
  19.       Pt_BOTTOM_ANCHORED_BOTTOM | Pt_TOP_ANCHORED_TOP |
  20.       Pt_LEFT_ANCHORED_LEFT     | Pt_RIGHT_ANCHORED_RIGHT,
  21.       Pt_IS_ANCHORED);
  22.   container = PtCreateWidget( PtContainer, window, i, args );
  23.  
  24.   i = 0;
  25.   PtSetArg( &args[i++], Pt_ARG_ANCHOR_FLAGS,
  26.       Pt_BOTTOM_ANCHORED_BOTTOM | Pt_TOP_ANCHORED_TOP |
  27.       Pt_LEFT_ANCHORED_LEFT     | Pt_RIGHT_ANCHORED_RIGHT,
  28.       Pt_IS_ANCHORED);
  29.   grid = PtCreateWidget( PtScrollContainer, container, i, args );
  30.  
  31.   i = 0;
  32.   PtSetArg( &args[i++], Pt_ARG_RESIZE_FLAGS, Pt_RESIZE_XY_ALWAYS, 0 );
  33.   PtSetArg( &args[i++], Pt_ARG_DIVIDER_FLAGS, Pt_FALSE, Pt_DIVIDER_RESIZE_BOTH );
  34.   //PtSetArg( &args[i++], Pt_ARG_CONTAINER_FLAGS,
  35.   //    Pt_ENABLE_CUA | Pt_ENABLE_CUA_ARROWS | Pt_AUTO_EXTENT, 0 );
  36.   divider = PtCreateWidget( PtDivider, grid, i, args );
  37.  
  38.   /* Set layout type and layout info */
  39.   PtRowLayoutInfo_t info;
  40.   info.type = Pt_LAYOUT_VERTICAL;
  41.   info.flags = 0;  // all widgets will have the same size
  42.   info.margin.ul.x = 0;  // upper left
  43.   info.margin.ul.y = 0;
  44.   info.margin.lr.x = 0;  // lower right
  45.   info.margin.lr.y = 0;
  46.   info.h_spacing = 0;
  47.   info.v_spacing = 0;
  48.  
  49.   i = 0;
  50.   PtSetArg( &args[i++], Pt_ARG_CONTAINER_FLAGS,
  51.       Pt_AUTO_EXTENT | Pt_ENABLE_CUA | Pt_ENABLE_CUA_ARROWS, 0 );
  52.   PtSetArg( &args[i++], Pt_ARG_LAYOUT, PtRowLayout, &info );
  53.   column00 = PtCreateWidget( PtContainer, divider, i, args );
  54.  
  55.   i = 0;
  56.   PtSetArg( &args[i++], Pt_ARG_CONTAINER_FLAGS,
  57.       Pt_AUTO_EXTENT | Pt_ENABLE_CUA | Pt_ENABLE_CUA_ARROWS, 0 );
  58.   PtSetArg( &args[i++], Pt_ARG_LAYOUT, PtRowLayout, &info );
  59.   column01 = PtCreateWidget( PtContainer, divider, i, args );
  60.  
  61.   /* column00 buttons */
  62.  
  63.   i = 0;
  64.   PtSetArg( &args[i++], Pt_ARG_TEXT_STRING, "T1", 0 );
  65.   //PtSetArg( &args[i++], Pt_ARG_RESIZE_FLAGS, Pt_RESIZE_XY_ALWAYS, 0 );
  66.   PtCreateWidget( PtText, column00, i, args );
  67.  
  68.   i = 0;
  69.   PtSetArg( &args[i++], Pt_ARG_TEXT_STRING, "Button 2 (two)", 0);
  70.   //PtSetArg( &args[i++], Pt_ARG_RESIZE_FLAGS, Pt_RESIZE_XY_ALWAYS, 0 );
  71.   PtCreateWidget( PtButton, column00, i, args );
  72.  
  73.   i = 0;
  74.   PtSetArg( &args[i++], Pt_ARG_TEXT_STRING, "Butt 3", 0 );
  75.   //PtSetArg( &args[i++], Pt_ARG_RESIZE_FLAGS, Pt_RESIZE_XY_ALWAYS, 0 );
  76.   PtCreateWidget( PtButton, column00, i, args );
  77.  
  78.   /* column01 buttons */
  79.  
  80.   i = 0;
  81.   PtSetArg( &args[i++], Pt_ARG_TEXT_STRING, "B4", 0 );
  82.   //PtSetArg( &args[i++], Pt_ARG_RESIZE_FLAGS, Pt_RESIZE_XY_ALWAYS, 0 );
  83.   PtCreateWidget( PtButton, column01, i, args );
  84.  
  85.   i = 0;
  86.   PtSetArg( &args[i++], Pt_ARG_TEXT_STRING, "Butt 5", 0 );
  87.   //PtSetArg( &args[i++], Pt_ARG_RESIZE_FLAGS, Pt_RESIZE_XY_ALWAYS, 0 );
  88.   PtCreateWidget( PtButton, column01, i, args );
  89.  
  90.   i = 0;
  91.   PtSetArg( &args[i++], Pt_ARG_TEXT_STRING, "Buttonchen 6", 0 );
  92.   //PtSetArg( &args[i++], Pt_ARG_RESIZE_FLAGS, Pt_RESIZE_XY_ALWAYS, 0 );
  93.   PtCreateWidget( PtButton, column01, i, args );
  94.  
  95.   PtRealizeWidget( window );
  96.   PtMainLoop();
  97.  
  98.   return 0;
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement