home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 10 / ioProg_10.iso / soft / optima / samples.z / SystemMenu.wxf < prev    next >
Encoding:
Text File  |  1996-09-16  |  15.9 KB  |  614 lines

  1. Save Format v1.3
  2. @begin Form "MainForm"
  3.  Exported 0;
  4.  
  5.  @begin Object "WModelessDialog"
  6.   WSCaption 1;
  7.   WSSizeable 1;
  8.   WSDlgBorder 1;
  9.   WSSysMenu 1;
  10.   WSSystemMenu 1;
  11.   WSMinimizeBox 1;
  12.   WSMaximizeBox 1;
  13.   WSGroup 1;
  14.   WSTabStop 1;
  15.   WSResizeBorder 1;
  16.   WSVisible 1;
  17.   Font "8.MS Sans Serif";
  18.   Icon "WIcon( WResourceID( ICON_01 ) )";
  19.   FormPositionType "Centered";
  20.   FormAbsTop "110";
  21.   FormAbsLeft "19";
  22.   FDXStructName "SystemMenusFDXStruct";
  23.   Text "System Menu";
  24.   @begin Event "Create"
  25.    GencodeSrcLine 205;
  26.    FunctionName "MainForm::MainForm_Create";
  27.   @end;
  28.   @begin Event "InitMenu"
  29.    GencodeSrcLine 222;
  30.    FunctionName "MainForm::MainForm_InitMenu";
  31.   @end;
  32.   @begin UserFunction "MainForm()"
  33.    Compiler 1;
  34.    GencodeSrcLine 234;
  35.    FunctionName "MainForm::MainForm()";
  36.   @end;
  37.   @begin UserFunction "~MainForm()"
  38.    Compiler 1;
  39.    GencodeSrcLine 240;
  40.    FunctionName "MainForm::~MainForm()";
  41.   @end;
  42.   @begin UserFunction "createSystemMenu()"
  43.    Private 1;
  44.    GencodeSrcLine 246;
  45.    FunctionName "MainForm::createSystemMenu()";
  46.   @end;
  47.   @begin UserFunction "Prototype for createSystemMenu()"
  48.    Private 1;
  49.    GencodeSrcLine 75;
  50.    FunctionName "MainForm::Prototype for createSystemMenu()";
  51.   @end;
  52.   @begin UserFunction "menu_system_item_1_Click( WObject * source, WEventData * event )"
  53.    Private 1;
  54.    GencodeSrcLine 312;
  55.    FunctionName "MainForm::menu_system_item_1_Click( WObject * source, WEventData * event )";
  56.   @end;
  57.   @begin UserFunction "Prototype for menu_system_item_1_Click( WObject * source, WEventData * event )"
  58.    Private 1;
  59.    GencodeSrcLine 77;
  60.    FunctionName "MainForm::Prototype for menu_system_item_1_Click( WObject * source, WEventData * event )";
  61.   @end;
  62.   @begin UserFunction "addEventToListview( const WString & event )"
  63.    Private 1;
  64.    GencodeSrcLine 321;
  65.    FunctionName "MainForm::addEventToListview( const WString & event )";
  66.   @end;
  67.   @begin UserFunction "Prototype for addEventToListview( const WString & event )"
  68.    Private 1;
  69.    GencodeSrcLine 79;
  70.    FunctionName "MainForm::Prototype for addEventToListview( const WString & event )";
  71.   @end;
  72.   @begin UserFunction "menu_system_item_1_Select( WObject * source, WEventData * event )"
  73.    Private 1;
  74.    GencodeSrcLine 331;
  75.    FunctionName "MainForm::menu_system_item_1_Select( WObject * source, WEventData * event )";
  76.   @end;
  77.   @begin UserFunction "Prototype for menu_system_item_1_Select( WObject * source, WEventData * event )"
  78.    Private 1;
  79.    GencodeSrcLine 81;
  80.    FunctionName "MainForm::Prototype for menu_system_item_1_Select( WObject * source, WEventData * event )";
  81.   @end;
  82.   @begin UserFunction "menu_system_item_2_Click( WObject * source, WEventData * event )"
  83.    Private 1;
  84.    GencodeSrcLine 338;
  85.    FunctionName "MainForm::menu_system_item_2_Click( WObject * source, WEventData * event )";
  86.   @end;
  87.   @begin UserFunction "Prototype for menu_system_item_2_Click( WObject * source, WEventData * event )"
  88.    Private 1;
  89.    GencodeSrcLine 83;
  90.    FunctionName "MainForm::Prototype for menu_system_item_2_Click( WObject * source, WEventData * event )";
  91.   @end;
  92.   @begin UserFunction "menu_system_item_2_Select( WObject * source, WEventData * event )"
  93.    Private 1;
  94.    GencodeSrcLine 346;
  95.    FunctionName "MainForm::menu_system_item_2_Select( WObject * source, WEventData * event )";
  96.   @end;
  97.   @begin UserFunction "Prototype for menu_system_item_2_Select( WObject * source, WEventData * event )"
  98.    Private 1;
  99.    GencodeSrcLine 85;
  100.    FunctionName "MainForm::Prototype for menu_system_item_2_Select( WObject * source, WEventData * event )";
  101.   @end;
  102.   ResID 102;
  103.   DesignName MainForm;
  104.   TabIndex 0;
  105.   DesignRect 19,110,280,227;
  106.  @end;
  107.  
  108.  @begin Object "WLabel"
  109.   WSSLeftNoWordWrap 1;
  110.   WSSNotify 1;
  111.   WCCSNoResize 1;
  112.   WCCSNoParentAlign 1;
  113.   WSChild 1;
  114.   WSMinimizeBox 1;
  115.   WSGroup 1;
  116.   WSVisible 1;
  117.   Text "1.  Click on the system menu and navigate to see the generated events";
  118.   AutoSize "1";
  119.   ResID 101;
  120.   DesignName label_Hint1;
  121.   TabIndex 0;
  122.   DesignRect 7,5,224,8;
  123.  @end;
  124.  
  125.  @begin Object "WLabel"
  126.   WSSLeftNoWordWrap 1;
  127.   WSSNotify 1;
  128.   WCCSNoResize 1;
  129.   WCCSNoParentAlign 1;
  130.   WSChild 1;
  131.   WSVisible 1;
  132.   Text "2.  Right click on this label to see the system menu used in SetPopup";
  133.   AutoSize "1";
  134.   @begin Event "InitPopupMenu"
  135.    GencodeSrcLine 353;
  136.    FunctionName "MainForm::label_Hint2_InitPopupMenu";
  137.   @end;
  138.   ResID 102;
  139.   DesignName label_Hint2;
  140.   TabIndex 1;
  141.   DesignRect 7,25,217,8;
  142.  @end;
  143.  
  144.  @begin Object "WLabel"
  145.   WSSLeftNoWordWrap 1;
  146.   WSSNotify 1;
  147.   WCCSNoResize 1;
  148.   WCCSNoParentAlign 1;
  149.   WSChild 1;
  150.   WSVisible 1;
  151.   Text "3.  Click this checkbox to check Item 1";
  152.   AutoSize "1";
  153.   ResID 103;
  154.   DesignName label_Hint3;
  155.   TabIndex 2;
  156.   DesignRect 7,45,123,8;
  157.  @end;
  158.  
  159.  @begin Object "WCheckBox"
  160.   WBSAutoCheckBox 1;
  161.   WCCSTop 1;
  162.   WCCSNoMoveY 1;
  163.   WCCSBottom 1;
  164.   WSChild 1;
  165.   WSMaximizeBox 1;
  166.   WSTabStop 1;
  167.   WSVisible 1;
  168.   FDXFieldName "checkbox_1_data";
  169.   FDXFieldType "WULong";
  170.   AutoSize "1";
  171.   Text "Check \"Item 1\"";
  172.   Checked "0";
  173.   @begin Event "Click"
  174.    GencodeSrcLine 361;
  175.    FunctionName "MainForm::checkbox_Checked_Click";
  176.   @end;
  177.   ResID 104;
  178.   DesignName checkbox_Checked;
  179.   TabIndex 3;
  180.   DesignRect 20,55,62,11;
  181.  @end;
  182.  
  183.  @begin Object "WLabel"
  184.   WSSLeftNoWordWrap 1;
  185.   WSSNotify 1;
  186.   WCCSNoResize 1;
  187.   WCCSNoParentAlign 1;
  188.   WSChild 1;
  189.   WSVisible 1;
  190.   Text "4.  Click this checkbox to disable Item 2 in the Form and label Init... events";
  191.   AutoSize "1";
  192.   ResID 105;
  193.   DesignName label_Hint4;
  194.   TabIndex 4;
  195.   DesignRect 5,80,233,8;
  196.  @end;
  197.  
  198.  @begin Object "WCheckBox"
  199.   WBSAutoCheckBox 1;
  200.   WCCSTop 1;
  201.   WCCSNoMoveY 1;
  202.   WCCSBottom 1;
  203.   WSChild 1;
  204.   WSMaximizeBox 1;
  205.   WSTabStop 1;
  206.   WSVisible 1;
  207.   FDXFieldName "checkbox_1_data";
  208.   FDXFieldType "WULong";
  209.   AutoSize "1";
  210.   Text "Disable \"Item 2\"";
  211.   Checked "0";
  212.   @begin Event "Click"
  213.    GencodeSrcLine 369;
  214.    FunctionName "MainForm::checkbox_Disable_Click";
  215.   @end;
  216.   ResID 106;
  217.   DesignName checkbox_Disable;
  218.   TabIndex 5;
  219.   DesignRect 20,90,65,12;
  220.  @end;
  221.  
  222.  @begin Object "WLabel"
  223.   WSSLeftNoWordWrap 1;
  224.   WSSNotify 1;
  225.   WCCSNoResize 1;
  226.   WCCSNoParentAlign 1;
  227.   WSChild 1;
  228.   WSVisible 1;
  229.   Text "System Menu Events:";
  230.   ResID 107;
  231.   DesignName label_Events_Description;
  232.   TabIndex 6;
  233.   DesignRect 7,118,215,8;
  234.  @end;
  235.  
  236.  @begin Object "WListView"
  237.   WLVSReport 1;
  238.   WLVSSingleSelection 1;
  239.   WLVSShareImageLists 1;
  240.   WLVSAutoArrange 1;
  241.   WCCSTop 1;
  242.   WCCSNoResize 1;
  243.   WCCSNoDivider 1;
  244.   WSChild 1;
  245.   WSMaximizeBox 1;
  246.   WSTabStop 1;
  247.   WSExClientEdge 1;
  248.   WSVisible 1;
  249.   ResizePercentages "[ 0 0 100 100 ]";
  250.   ResID 108;
  251.   DesignName lv_Events;
  252.   TabIndex 7;
  253.   DesignRect 7,130,215,74;
  254.  @end;
  255.  
  256.  @begin Object "WCommandButton"
  257.   WSChild 1;
  258.   WSMaximizeBox 1;
  259.   WSTabStop 1;
  260.   WSVisible 1;
  261.   Default "1";
  262.   Pressed "0";
  263.   ResizePercentages "[ 100 0 0 0 ]";
  264.   Text "Clear";
  265.   @begin Event "Click"
  266.    GencodeSrcLine 377;
  267.    FunctionName "MainForm::cb_Clear_Click";
  268.   @end;
  269.   ResID 109;
  270.   DesignName cb_Clear;
  271.   TabIndex 8;
  272.   DesignRect 225,130,40,14;
  273.  @end;
  274.  
  275.  @begin HPPPrefixBlock
  276. @begin-code HPPPrefix
  277.  
  278. // Declarations added here will be included at the top of the .HPP file
  279.  
  280. @end-code;
  281.   GencodeSrcLine 10;
  282.  @end;
  283.  
  284.  @begin CPPPrefixBlock
  285. @begin-code CPPPrefix
  286.  
  287. //  Include definitions for resources.
  288. #include "WRes.h"
  289.  
  290. @end-code;
  291.   GencodeSrcLine 10;
  292.  @end;
  293.  
  294.  @begin ClassContentsBlock
  295. @begin-code ClassContents
  296.  
  297.     /*  Declare a member variable for each menu item you want
  298.         in the system menu.  This makes it easier to dynamically
  299.         modify menu properties.
  300.         
  301.         This sample names the items following the convention for
  302.         popup or pull down menus: <menu_name>_item_<item name>;
  303.         you should replace the number at the end of the variable
  304.         with a meaningful suffix.
  305.     */
  306.     private:
  307.         WSystemMenu *   menu_system;
  308.         WMenuItem *     menu_system_item_1;
  309.         WMenuItem *     menu_system_item_2;
  310.  
  311. @end-code;
  312.   GencodeSrcLine 62;
  313.  @end;
  314.  
  315. @begin-code GeneratedClassContents
  316.  
  317.         MainForm();
  318.         ~MainForm();
  319.  
  320. @end-code;
  321.  
  322. @begin-code Code "MainForm::MainForm()"
  323.  
  324. @@CLASSNAME@::@CLASSNAME@()
  325.     : menu_system_item_1( NULL )
  326.     , menu_system_item_2( NULL )
  327. {
  328.     
  329. }
  330.  
  331. @end-code;
  332.  
  333. @begin-code Code "MainForm::~MainForm()"
  334.  
  335. /*  the menu items were added with the autoDelete flag
  336.     set so the system will be responsible for deleting them.
  337. */
  338. @@CLASSNAME@::~@CLASSNAME@()
  339. {
  340. }
  341.  
  342. @end-code;
  343.  
  344. @begin-code Code "MainForm::createSystemMenu()"
  345.  
  346. /*  This function, "createSystemMenu", modifies the form's system
  347.     menu by adding a new item at the top and a new item at the
  348.     bottom.  
  349.     
  350.     To interface correctly with the system, you must create
  351.     menu items that are to be placed in a system menu with 
  352.     menu IDs of the following form:
  353.         a) all user id's must be less than 0xf000.  
  354.            the system reserves ids from 0xf000 to 0xffff.
  355.         b) all user id's must satisfy (id & 0xfff0) == id.
  356.     
  357.     After constructing each menu item, you can set event handlers which
  358.     will be called when the user tracks over the menu item (Select event),
  359.     or chooses the menu item (Click event).
  360. */
  361. WBool @CLASSNAME@::createSystemMenu()
  362. {
  363.     WUShort         menuID = 0x0010;
  364.     
  365.     menu_system = GetSystemMenu();
  366.     WASSERTEX( menu_system != NULL, "Could not retrieve form's system menu" );
  367.     if( menu_system == NULL ) {
  368.         return( FALSE );
  369.     }
  370.     
  371.     /*  Set menu_system as a popup menu on the second hint label
  372.     */
  373.     label_Hint2->SetPopup( menu_system );
  374.     
  375.     
  376.     /*  Add a new item at the top
  377.     */
  378.     menu_system_item_1 = new WMenuItem( menuID,
  379.         WTEXT("Item 1"),
  380.         WTEXT("Execute command 1") );
  381.         
  382.     menu_system_item_1->SetEventHandler( WClickEvent,
  383.         this, (WEventHandler)&@CLASSNAME@::menu_system_item_1_Click );
  384.     menu_system_item_1->SetEventHandler( WSelectEvent,
  385.         this, (WEventHandler)&@CLASSNAME@::menu_system_item_1_Select );
  386.         
  387.     menu_system->AddItem( menu_system_item_1, 0, TRUE );
  388.     menu_system->AddSeparator( 1 );
  389.     
  390.     
  391.     /*  Increment the menu ID, preserving the properties described above
  392.     */
  393.     menuID += 0x10;
  394.     
  395.     
  396.     /*  Add a new item at the bottom
  397.     */
  398.     menu_system_item_2 = new WMenuItem( menuID,
  399.         WTEXT("Item 2"),
  400.         WTEXT("Execute command 2") );
  401.         
  402.     menu_system_item_2->SetEventHandler( WClickEvent,
  403.         this, (WEventHandler)&@CLASSNAME@::menu_system_item_2_Click );
  404.     menu_system_item_2->SetEventHandler( WSelectEvent,
  405.         this, (WEventHandler)&@CLASSNAME@::menu_system_item_2_Select );
  406.  
  407.     menu_system->AddSeparator();
  408.     menu_system->AddItem( menu_system_item_2, -1, TRUE );
  409.     
  410.     return( TRUE );
  411. }
  412.  
  413. @end-code;
  414.  
  415. @begin-code Code "MainForm::Prototype for createSystemMenu()"
  416.  
  417.     private:
  418.         WBool createSystemMenu();
  419.  
  420. @end-code;
  421.  
  422. @begin-code Code "MainForm::menu_system_item_1_Click( WObject * source, WEventData * event )"
  423.  
  424. WBool @CLASSNAME@::menu_system_item_1_Click( 
  425.     WObject *       source, 
  426.     WEventData *    event )
  427. {
  428.     addEventToListview( "Click item_1" );
  429.     WMessageBox::Info( this, WTEXT("System Menu"), WTEXT("Item 1 clicked (%schecked)"),
  430.         menu_system_item_1->GetChecked() ? "" : "not " );
  431.     return FALSE;
  432. }
  433.  
  434. @end-code;
  435.  
  436. @begin-code Code "MainForm::Prototype for menu_system_item_1_Click( WObject * source, WEventData * event )"
  437.  
  438.     private:
  439.         WBool menu_system_item_1_Click( WObject * source, WEventData * event );
  440.  
  441. @end-code;
  442.  
  443. @begin-code Code "MainForm::addEventToListview( const WString & event )"
  444.  
  445. void @CLASSNAME@::addEventToListview( const WString & event )
  446. {
  447.     static WInt EventNum = 0;
  448.     WInt        item;
  449.     
  450.     WString     eventNumText;
  451.     eventNumText.Sprintf("%d", EventNum++ );
  452.     item = lv_Events->Add( eventNumText, -1, 0, -1, NULL, 1, event.GetText() );
  453.     lv_Events->EnsureIsVisible( item );
  454. }
  455.  
  456. @end-code;
  457.  
  458. @begin-code Code "MainForm::Prototype for addEventToListview( const WString & event )"
  459.  
  460.     private:
  461.         void addEventToListview( const WString & event );
  462.  
  463. @end-code;
  464.  
  465. @begin-code Code "MainForm::menu_system_item_1_Select( WObject * source, WEventData * event )"
  466.  
  467. WBool @CLASSNAME@::menu_system_item_1_Select( 
  468.     WObject *       source, 
  469.     WEventData *    event )
  470. {
  471.     addEventToListview( WTEXT("Select item_1") );
  472.     return FALSE;
  473. }
  474.  
  475. @end-code;
  476.  
  477. @begin-code Code "MainForm::Prototype for menu_system_item_1_Select( WObject * source, WEventData * event )"
  478.  
  479.     private:
  480.         WBool menu_system_item_1_Select( WObject * source, WEventData * event );
  481.  
  482. @end-code;
  483.  
  484. @begin-code Code "MainForm::menu_system_item_2_Click( WObject * source, WEventData * event )"
  485.  
  486. WBool @CLASSNAME@::menu_system_item_2_Click( 
  487.     WObject *       source, 
  488.     WEventData *    event )
  489. {
  490.     addEventToListview( WTEXT("Click item_2") );
  491.     WMessageBox::Info( this, WTEXT("System Menu"), WTEXT("Item 2 clicked") );
  492.     return FALSE;
  493. }
  494.  
  495. @end-code;
  496.  
  497. @begin-code Code "MainForm::Prototype for menu_system_item_2_Click( WObject * source, WEventData * event )"
  498.  
  499.     private:
  500.         WBool menu_system_item_2_Click( WObject * source, WEventData * event );
  501.  
  502. @end-code;
  503.  
  504. @begin-code Code "MainForm::menu_system_item_2_Select( WObject * source, WEventData * event )"
  505.  
  506. WBool @CLASSNAME@::menu_system_item_2_Select( 
  507.     WObject *       source, 
  508.     WEventData *    event )
  509. {
  510.     addEventToListview( "Select item_2" );
  511.     return FALSE;
  512. }
  513.  
  514. @end-code;
  515.  
  516. @begin-code Code "MainForm::Prototype for menu_system_item_2_Select( WObject * source, WEventData * event )"
  517.  
  518.     private:
  519.         WBool menu_system_item_2_Select( WObject * source, WEventData * event );
  520.  
  521. @end-code;
  522.  
  523. @begin-code Code "MainForm::MainForm_Create"
  524.  
  525. WBool @CLASSNAME@::MainForm_Create(
  526.     WObject *               source,
  527.     WCreateEventData *      event )
  528. {
  529.     WRect   cr;
  530.     
  531.     createSystemMenu();
  532.     
  533.     cr = lv_Events->GetClientRectangle();
  534.     lv_Events->AddColumn( WTEXT("Number") );
  535.     lv_Events->AddColumn( WTEXT("Event") );
  536.     lv_Events->SetColumnWidth( 1, cr.w - lv_Events->GetColumnWidth( 0 ) );
  537.     
  538.     cr = GetRectangle();
  539.     SetMinimumTrackingSize( WSize( cr.w, cr.h ) );
  540.     return FALSE;
  541. }
  542.  
  543. @end-code;
  544.  
  545. @begin-code Code "MainForm::MainForm_InitMenu"
  546.  
  547. /*  The InitMenu event is triggered on the form before any of
  548.     the form's menus are displayed.  You can use this event to
  549.     enable or disable any menu items.
  550. */
  551. WBool @CLASSNAME@::MainForm_InitMenu(
  552.     WObject *               source,
  553.     WMessageEventData *     event )
  554. {
  555.     menu_system_item_2->SetEnabled( !checkbox_Disable->GetChecked() );
  556.     addEventToListview( "InitMenu SystemMenus" );
  557.     return FALSE;
  558. }
  559.  
  560. @end-code;
  561.  
  562. @begin-code Code "MainForm::label_Hint2_InitPopupMenu"
  563.  
  564. WBool @CLASSNAME@::label_Hint2_InitPopupMenu(
  565.     WObject *               source,
  566.     WMessageEventData *     event )
  567. {
  568.     menu_system_item_2->SetEnabled( !checkbox_Disable->GetChecked() );
  569.     addEventToListview( "InitPopupMenu label_Hint2" );
  570.     return FALSE;
  571. }
  572.  
  573. @end-code;
  574.  
  575. @begin-code Code "MainForm::checkbox_Checked_Click"
  576.  
  577. WBool @CLASSNAME@::checkbox_Checked_Click(
  578.     WObject *           source,
  579.     WEventData *        event )
  580. {
  581.     menu_system_item_1->SetChecked( checkbox_Checked->GetChecked() );
  582.     
  583.     return FALSE;
  584. }
  585.  
  586. @end-code;
  587.  
  588. @begin-code Code "MainForm::checkbox_Disable_Click"
  589.  
  590. WBool @CLASSNAME@::checkbox_Disable_Click(
  591.     WObject *           source,
  592.     WEventData *        event )
  593. {
  594.     menu_system_item_1->SetChecked( checkbox_Checked->GetChecked() );
  595.     
  596.     return FALSE;
  597. }
  598.  
  599. @end-code;
  600.  
  601. @begin-code Code "MainForm::cb_Clear_Click"
  602.  
  603. WBool @CLASSNAME@::cb_Clear_Click(
  604.     WObject *           source,
  605.     WEventData *        event )
  606. {
  607.     lv_Events->DeleteAll();
  608.     
  609.     return FALSE;
  610. }
  611.  
  612. @end-code;
  613. @end;
  614.