home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / g / gina15.zip / demos / perf.C < prev    next >
C/C++ Source or Header  |  1992-02-27  |  4KB  |  133 lines

  1. #include <Gina/GnObject.h>
  2. #include <Gina/GnToolkit.h>
  3.  
  4. #include <Gina/GnApplicationShell.h>
  5. #include <Gina/GnCascadeButtonG.h>
  6. #include <Gina/GnFileSelectD.h>
  7. #include <Gina/GnMainWindow.h>
  8. #include <Gina/GnMenuBar.h>
  9. #include <Gina/GnPulldownMenuPane.h>
  10. #include <Gina/GnPushButton.h>
  11. #include <Gina/GnPushButtonG.h>
  12. #include <Gina/GnRowColumn.h>
  13. #include <Gina/GnTimer.h>
  14.  
  15. void update_counter(void *client_data_1, void *client_data_2,
  16.             caddr_t /* call_data */)
  17. {
  18.     GnPushButton *button = (GnPushButton *)client_data_1;
  19.     int *timer_counter = (int *)client_data_2;
  20.     
  21.     char counter_string [10];
  22.     
  23.     (*timer_counter)++;
  24.     sprintf(counter_string, "%d", *timer_counter);
  25.     button->setR_labelString(counter_string);
  26.     button->SetValues();
  27. }
  28.  
  29. void quit_app(caddr_t /* call_data */)
  30. {
  31.     exit(1);
  32. }
  33.  
  34. /* Callback handler for testing GpathSelectionDialogs */
  35.  
  36. void test_file_select(void *client_data, caddr_t /* call_data */)
  37. {
  38.     GnPathname *out_path;
  39.     GnWidget *widget = (GnWidget *)client_data;
  40.     
  41.     if( select_new_file(*widget, &out_path) == OK )
  42.     Gina_Debug_NL(out_path->abs_namestring()); 
  43.     if( select_old_file(*widget, &out_path,
  44.             "dummy", "?*.C", "/home/baecker/gina-c++/src") == OK )
  45.     Gina_Debug_NL(out_path->abs_namestring());
  46.     if( select_old_or_new_file(*widget, &out_path,
  47.                    "dummy", "?*.C",
  48.                    "/home/baecker/gina-c++/src") == OK )
  49.     Gina_Debug_NL(out_path->abs_namestring());
  50. }
  51.  
  52. //int ext_res_def = 2;
  53. int ext_res = 2;
  54.  
  55. XtResource ExtRes[] = {
  56.     { "extres", "Extres", XtRInt, sizeof(int), (Cardinal)&ext_res,
  57.       XtRInt, (XtPointer)&ext_res},
  58. };
  59.  
  60. int main(Cardinal argc, char **argv)
  61. {
  62.     GnToolkit toolkit("Perf");
  63.     GnRowColumn *row;
  64.     GnMainWindow *main_window;
  65.     GnMenuBar *menu_bar;
  66.     GnCascadeButton *file_cascade;
  67.     GnPulldownMenuPane *file_pane;
  68.     GnPushButton *file_button, *button;
  69.     int i;
  70.     char w_name[10];
  71.     GnTimer *timer;
  72.  
  73.     if( ! toolkit.AppInitialize(&argc, argv) )
  74.     abort();
  75.  
  76.     ////XtGetApplicationResources(toolkit.AppShell().get_widget_id(),
  77.                   //(XtPointer)0,
  78.                   //ExtRes,
  79.                   //1,
  80.                   //(ArgList)0,
  81.                   //0);
  82.  
  83.     cout << "\n\n" << ext_res << "\n\n" ; cout.flush();
  84.     
  85.     toolkit.set_xt_error_handler((XtErrorHandler)abort);
  86.     toolkit.set_xt_warning_handler((XtErrorHandler)abort);
  87.     toolkit.AppShell().setR_allowShellResize(True);
  88.     toolkit.AppShell().setR_deleteResponse(XmDO_NOTHING);
  89.     toolkit.AppShell().SetValues();
  90.     toolkit.AppShell().add_wm_closed_callback(SIMPLE_CALLBACK(quit_app));
  91.  
  92.     main_window = new GnMainWindow;
  93.     main_window->create(toolkit.AppShell(), "main_window");
  94.  
  95.     menu_bar = new GnMenuBar;
  96.     menu_bar->create(main_window, "menu_bar");
  97.  
  98.     file_pane = new GnPulldownMenuPane;
  99.     file_pane->create(menu_bar, "filePane");
  100.  
  101.     file_cascade = new GnCascadeButton("File", file_pane);
  102.     file_cascade->create(menu_bar, "fileCascade");
  103.  
  104.     file_button = new GnPushButton("New");
  105.     file_button->create(file_pane, "fileButton");
  106.     file_button->add_activateCallback(SIMPLE_CALLBACK1(test_file_select,
  107.                                GnWidget *,
  108.                                main_window));
  109.  
  110.     row = new GnRowColumn;
  111.     row->setR_packing(XmPACK_COLUMN);
  112.     row->setR_numColumns(3);
  113.     row->setR_traversalOn(False);
  114.     row->create(main_window, "row");
  115.  
  116.     main_window->set_areas(menu_bar, 0, 0, 0, row);
  117.  
  118.     for( i = 0; i < 6; i++ ) {
  119.     button = new GnPushButtonGadget;
  120.     sprintf(w_name, "%3d", i);
  121.     button->create(row, w_name);
  122.     }
  123.  
  124.     toolkit.AppShell().realize();
  125.     int timer_counter = 0;
  126.     timer = new GnTimer(1000, SIMPLE_CALLBACK2(update_counter,
  127.                           GnPushButton *, button,
  128.                           int *, &timer_counter));
  129.     timer->start();
  130.  
  131.     toolkit.AppMainLoop();
  132. }
  133.