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

  1. /* @(#)ibtestappl.C    1.1 11/15/91 */
  2.  
  3. #include <Gina/Gina.h>
  4.  
  5. // Include IB files (specification + implementation)
  6.  
  7. #include "ib-test.h"
  8. #include "ib-test.C"
  9.  
  10. // Define an alias for the new dialog class
  11.  
  12. #define DIALOG_CLASS GnDemoDocumentShell
  13. #define IS_DOC_SHELL
  14.  
  15. // NO CHANGES AFTER HERE !!
  16. // ============================================================================
  17.  
  18. class IbTestApplication : public GnApplication {
  19.   public:
  20.     virtual GnDocument *create_document ();
  21.  
  22.     char * app_class () { return "IbTest" ; }
  23.     char * app_signature() { return "ibtest" ; }
  24.     char * app_file_type() { return ".ibtest" ; }
  25. };
  26.  
  27.  
  28. class IbTestDocument : public GnDocument {
  29.   public:
  30.     virtual void create_windows(int new_width = 0, int new_height = 0);
  31. #ifndef IS_DOC_SHELL
  32.   protected:
  33.     DIALOG_CLASS *dialog;
  34. #endif
  35.   protected:
  36.     void CallManage(GnWidget *w, caddr_t);
  37.     void CallPopup(GnTopLevelToolDialogBox *w, caddr_t);
  38. };
  39.  
  40. GnDocument *IbTestApplication ::
  41. create_document()
  42.     return new IbTestDocument;
  43. }
  44.  
  45. void IbTestDocument ::
  46. create_windows(int new_width, int new_height)
  47. {
  48. #ifdef IS_DOC_SHELL
  49.     main_shell = new DIALOG_CLASS(this, new_width, new_height);
  50.     main_shell->create(APPLICATION->get_application_shell(), "main_shell");
  51. #else
  52.     GnDocument::create_windows(new_width, new_height);
  53.  
  54.     dialog = new DIALOG_CLASS(this);
  55.     dialog->create(main_shell, "dialog");
  56.  
  57.     main_shell->add_menu_command("Dialog", "Manage Dialog",
  58.                  CALLBACK1(IbTestDocument, CallManage, this,
  59.                        GnWidget *, dialog));
  60. #endif
  61.  
  62.     GnToolDialogBox *tool = new GnToolDialogBox;
  63.     tool->create(main_shell, "bla");
  64.  
  65.     GnLabel *lbllbl = new GnLabel("I'm a GnToolDialogBox");
  66.     lbllbl->setR_topAttachment(XmATTACH_WIDGET);
  67.     lbllbl->setR_topWidget(tool->GetMainMenu());
  68.     lbllbl->create(tool, "lbllbl");
  69.  
  70.     main_shell->add_menu_command("Dialog", "Manage Tool-Dialog",
  71.                  CALLBACK1(IbTestDocument, CallManage, this,
  72.                        GnWidget *, tool));
  73.  
  74.     GnTopLevelToolDialogBox *top_tool = new GnTopLevelToolDialogBox;
  75.     top_tool->setR_title("Class => GnTopLevelToolDialogBox");
  76.     top_tool->create(main_shell, "bla");
  77.  
  78.     GnLabel *lbllbllbl = new GnLabel("I'm a GnTopLevelToolDialogBox");
  79.     lbllbllbl->setR_topAttachment(XmATTACH_WIDGET);
  80.     lbllbllbl->setR_topWidget(top_tool->GetMainMenu());
  81.     lbllbllbl->create(top_tool->GetForm(), "lbllbllbl");
  82.  
  83.     main_shell->add_menu_command("Dialog", "GnTopLevelToolDialogBox ...",
  84.                  CALLBACK1(IbTestDocument, CallPopup, this,
  85.                        GnTopLevelToolDialogBox*, top_tool));
  86. }
  87.  
  88. void IbTestDocument::
  89. CallManage(GnWidget *w, caddr_t)
  90. {
  91.     w->manage();
  92. }
  93.  
  94. void IbTestDocument::
  95. CallPopup(GnTopLevelToolDialogBox *w, caddr_t)
  96. {
  97.     w->pop_up();
  98. }
  99.  
  100. int main (unsigned int argc, char ** argv)
  101. {
  102.     IbTestApplication app;
  103.  
  104.     app.run ( argc, argv );
  105. }
  106.