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

  1. Save Format v1.3
  2. @begin Form "FormParent"
  3.  Exported 0;
  4.  
  5.  @begin Object "WMDIParent"
  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.   StatusBar "StatusBarAtBottom";
  19.   Icon "WIcon( WResourceID( ICON_01 ) )";
  20.   FormPositionType "Centered";
  21.   FormAbsTop "99";
  22.   FormAbsLeft "12";
  23.   Text "MDI";
  24.   @begin Event "Close"
  25.    GencodeSrcLine 168;
  26.    FunctionName "FormParent::FormParent_Close";
  27.   @end;
  28.   @begin Event "Create"
  29.    GencodeSrcLine 182;
  30.    FunctionName "FormParent::FormParent_Create";
  31.   @end;
  32.   @begin Event "User"
  33.    GencodeSrcLine 199;
  34.    FunctionName "FormParent::FormParent_User";
  35.   @end;
  36.   @begin UserFunction "FormParent()"
  37.    Compiler 1;
  38.    GencodeSrcLine 218;
  39.    FunctionName "FormParent::FormParent()";
  40.   @end;
  41.   @begin UserFunction "~FormParent()"
  42.    Compiler 1;
  43.    GencodeSrcLine 222;
  44.    FunctionName "FormParent::~FormParent()";
  45.   @end;
  46.   @begin UserFunction "addChild( void )"
  47.    Private 1;
  48.    GencodeSrcLine 226;
  49.    FunctionName "FormParent::addChild( void )";
  50.   @end;
  51.   @begin UserFunction "Prototype for addChild( void )"
  52.    Private 1;
  53.    GencodeSrcLine 96;
  54.    FunctionName "FormParent::Prototype for addChild( void )";
  55.   @end;
  56.   @begin UserFunction "minimalMenu( void )"
  57.    Private 1;
  58.    GencodeSrcLine 260;
  59.    FunctionName "FormParent::minimalMenu( void )";
  60.   @end;
  61.   @begin UserFunction "Prototype for minimalMenu( void )"
  62.    Private 1;
  63.    GencodeSrcLine 98;
  64.    FunctionName "FormParent::Prototype for minimalMenu( void )";
  65.   @end;
  66.   @begin UserFunction "fullMenu( void )"
  67.    Private 1;
  68.    GencodeSrcLine 280;
  69.    FunctionName "FormParent::fullMenu( void )";
  70.   @end;
  71.   @begin UserFunction "Prototype for fullMenu( void )"
  72.    Private 1;
  73.    GencodeSrcLine 100;
  74.    FunctionName "FormParent::Prototype for fullMenu( void )";
  75.   @end;
  76.   ResID 102;
  77.   DesignName FormParent;
  78.   TabIndex 0;
  79.   DesignRect 4,115,200,160;
  80.  @end;
  81.  
  82.  @begin Menu
  83.   ItemCount 1;
  84.   DesignName "menu_1";
  85.   IsDefault 1;
  86.   ResID 101;
  87.   DesignRect 175,0,19,17;
  88.   @begin Event "InitMenu"
  89.    GencodeSrcLine 299;
  90.    FunctionName "FormParent::menu_1_InitMenu";
  91.   @end;
  92.   @begin Popup
  93.    Name "item_File";
  94.    Caption "&File";
  95.    NegotiatePosition None;
  96.    @begin Item
  97.     Name "item_New";
  98.     Caption "&New";
  99.     ResID 1015;
  100.     NegotiatePosition None;
  101.     @begin Event "Click"
  102.      GencodeSrcLine 360;
  103.      FunctionName "FormParent::menu_1_item_New_Click";
  104.     @end;
  105.    @end;
  106.    @begin Item
  107.     Name "item_Close";
  108.     Caption "&Close";
  109.     ResID 1016;
  110.     NegotiatePosition None;
  111.     @begin Event "Click"
  112.      GencodeSrcLine 340;
  113.      FunctionName "FormParent::menu_1_item_Close_Click";
  114.     @end;
  115.    @end;
  116.    Separator ;
  117.    @begin Item
  118.     Name "item_Exit";
  119.     Caption "E&xit";
  120.     ResID 1018;
  121.     NegotiatePosition None;
  122.     @begin Event "Click"
  123.      GencodeSrcLine 352;
  124.      FunctionName "FormParent::menu_1_item_Exit_Click";
  125.     @end;
  126.    @end;
  127.   @end;
  128.   @begin Popup
  129.    Name "item_Edit";
  130.    Caption "&Edit";
  131.    NegotiatePosition None;
  132.    @begin Item
  133.     Name "item_Cut";
  134.     Caption "Cu&t";
  135.     ResID 1012;
  136.     NegotiatePosition None;
  137.    @end;
  138.    @begin Item
  139.     Name "item_Copy";
  140.     Caption "&Copy";
  141.     ResID 1013;
  142.     NegotiatePosition None;
  143.    @end;
  144.    @begin Item
  145.     Name "item_Paste";
  146.     Caption "&Paste";
  147.     ResID 1014;
  148.     NegotiatePosition None;
  149.    @end;
  150.   @end;
  151.   @begin Popup
  152.    Name "item_Window";
  153.    Caption "&Window";
  154.    NegotiatePosition None;
  155.    @begin Item
  156.     Name "item_Cascade";
  157.     Caption "&Cascade";
  158.     ResID 1005;
  159.     NegotiatePosition None;
  160.     @begin Event "Click"
  161.      GencodeSrcLine 331;
  162.      FunctionName "FormParent::menu_1_item_Cascade_Click";
  163.     @end;
  164.    @end;
  165.    @begin Item
  166.     Name "item_TileHorizontal";
  167.     Caption "Tile &Horizontal";
  168.     ResID 1006;
  169.     NegotiatePosition None;
  170.     @begin Event "Click"
  171.      GencodeSrcLine 386;
  172.      FunctionName "FormParent::menu_1_item_TileHorizontal_Click";
  173.     @end;
  174.    @end;
  175.    @begin Item
  176.     Name "item_TileVertical";
  177.     Caption "Tile &Vertical";
  178.     ResID 1007;
  179.     NegotiatePosition None;
  180.     @begin Event "Click"
  181.      GencodeSrcLine 395;
  182.      FunctionName "FormParent::menu_1_item_TileVertical_Click";
  183.     @end;
  184.    @end;
  185.    @begin Item
  186.     Name "item_ArrangeIcons";
  187.     Caption "&Arrange Icons";
  188.     ResID 1008;
  189.     NegotiatePosition None;
  190.     @begin Event "Click"
  191.      GencodeSrcLine 322;
  192.      FunctionName "FormParent::menu_1_item_ArrangeIcons_Click";
  193.     @end;
  194.    @end;
  195.    Separator ;
  196.    @begin Item
  197.     Name "item_Next";
  198.     Caption "&Next";
  199.     ResID 1010;
  200.     NegotiatePosition None;
  201.     @begin Event "Click"
  202.      GencodeSrcLine 368;
  203.      FunctionName "FormParent::menu_1_item_Next_Click";
  204.     @end;
  205.    @end;
  206.    @begin Item
  207.     Name "item_Previous";
  208.     Caption "&Previous";
  209.     ResID 1011;
  210.     NegotiatePosition None;
  211.     @begin Event "Click"
  212.      GencodeSrcLine 377;
  213.      FunctionName "FormParent::menu_1_item_Previous_Click";
  214.     @end;
  215.    @end;
  216.   @end;
  217.   @begin Popup
  218.    Name "item_Help";
  219.    Caption "&Help";
  220.    NegotiatePosition None;
  221.    @begin Item
  222.     Name "item_About";
  223.     Caption "&About";
  224.     ResID 1004;
  225.     NegotiatePosition None;
  226.     @begin Event "Click"
  227.      GencodeSrcLine 313;
  228.      FunctionName "FormParent::menu_1_item_About_Click";
  229.     @end;
  230.    @end;
  231.   @end;
  232.  @end;
  233.  
  234.  @begin Object "WFormProxy"
  235.   FormClass "AboutBox";
  236.   ResID 102;
  237.   DesignName AboutBox1;
  238.   TabIndex 1;
  239.   DesignRect 175,15,19,17;
  240.  @end;
  241.  
  242.  @begin HPPPrefixBlock
  243. @begin-code HPPPrefix
  244.  
  245. // Declarations added here will be included at the top of the .HPP file
  246. #include <formChild1.hpp>
  247.  
  248. @end-code;
  249.   GencodeSrcLine 11;
  250.  @end;
  251.  
  252.  @begin CPPPrefixBlock
  253. @begin-code CPPPrefix
  254.  
  255. // Code added here will be included at the top of the .CPP file
  256.  
  257. //  Include definitions for resources.
  258. #include "WRes.h"
  259.  
  260. @end-code;
  261.   GencodeSrcLine 10;
  262.  @end;
  263.  
  264.  @begin ClassContentsBlock
  265. @begin-code ClassContents
  266.  
  267.     private:
  268.         // add your private instance data here
  269.         WVector<WMDIChild>  _childWindowVector;
  270.         WPopupMenu          *_editMenu;
  271.         WPopupMenu          *_windowMenu;
  272.         WMenuItem           *_closeItem;
  273.  
  274. @end-code;
  275.   GencodeSrcLine 90;
  276.  @end;
  277.  
  278. @begin-code GeneratedClassContents
  279.  
  280.         FormParent();
  281.         ~FormParent();
  282.  
  283. @end-code;
  284.  
  285. @begin-code Code "FormParent::FormParent()"
  286.  
  287. @@CLASSNAME@::@CLASSNAME@()
  288. {
  289.     
  290. }
  291.  
  292. @end-code;
  293.  
  294. @begin-code Code "FormParent::~FormParent()"
  295.  
  296. @@CLASSNAME@::~@CLASSNAME@()
  297. {
  298.     
  299. }
  300.  
  301. @end-code;
  302.  
  303. @begin-code Code "FormParent::addChild( void )"
  304.  
  305. void @CLASSNAME@::addChild( void )
  306. {
  307.     FormChild       *formChild;
  308.     WString         caption;
  309.     WMDIChild       *currentMDIChild;
  310.     WWindowState    currentState;
  311.     static          childNumber = 1;
  312.     
  313.     //  Choose a window state for the new child
  314.     currentMDIChild = GetActiveChild();    
  315.     if( currentMDIChild ) {
  316.         currentState = currentMDIChild->GetWindowState();
  317.     }
  318.     
  319.     //  Instantiate a new MDI child form
  320.     formChild = new FormChild;
  321.     formChild->Create( this );
  322.     
  323.     if( currentState == WWindowStateMaximized ) {
  324.         formChild->SetWindowState( WWindowStateMaximized );
  325.     }
  326.     
  327.     // append the child window vector
  328.     _childWindowVector.Append( formChild );
  329.     
  330.     //  Set the child window caption
  331.     caption.Sprintf( "MDI Child %d", childNumber++ );
  332.     formChild->SetText( caption );
  333.     
  334.     //  If this is the first child window, switch to full menus
  335.     if( _childWindowVector.GetCount() == 1 ) {
  336.         fullMenu();
  337.     }    
  338. }
  339.  
  340. @end-code;
  341.  
  342. @begin-code Code "FormParent::Prototype for addChild( void )"
  343.  
  344.     private:
  345.         void addChild( void );
  346.  
  347. @end-code;
  348.  
  349. @begin-code Code "FormParent::minimalMenu( void )"
  350.  
  351. void @CLASSNAME@::minimalMenu( void )
  352. {
  353.     WPopupMenu  *fileMenu;
  354.     
  355.     // remove the edit menu
  356.     _editMenu = menu_1->RemovePopup( menu_1_item_Edit );
  357.     
  358.     // remove the window menu
  359.     _windowMenu = menu_1->RemovePopup( menu_1_item_Window );
  360.     
  361.     // get the file popup menu
  362.     fileMenu = menu_1_item_File;
  363.     
  364.     // remove the Close menu item
  365.     _closeItem = fileMenu->RemoveItem( menu_1_item_Close );
  366.             
  367.     // update the menu
  368.     UpdateMenu();
  369.     
  370. }
  371.  
  372. @end-code;
  373.  
  374. @begin-code Code "FormParent::Prototype for minimalMenu( void )"
  375.  
  376.     private:
  377.         void minimalMenu( void );
  378.  
  379. @end-code;
  380.  
  381. @begin-code Code "FormParent::fullMenu( void )"
  382.  
  383. void @CLASSNAME@::fullMenu( void )
  384. {
  385.     WPopupMenu      *fileMenu;
  386.     
  387.     // add the edit menu
  388.     menu_1->AddPopup( _editMenu, 1 );
  389.     
  390.     // remove the window menu
  391.     menu_1->AddPopup( _windowMenu, 2);
  392.     
  393.     // get the file popup menu
  394.     fileMenu = menu_1_item_File;
  395.     
  396.     // add the Close menu item
  397.     fileMenu->AddItem( _closeItem, 1 );
  398.     
  399.     // update the menu
  400.     UpdateMenu();
  401. }
  402.  
  403. @end-code;
  404.  
  405. @begin-code Code "FormParent::Prototype for fullMenu( void )"
  406.  
  407.     private:
  408.         void fullMenu( void );
  409.  
  410. @end-code;
  411.  
  412. @begin-code Code "FormParent::FormParent_Close"
  413.  
  414. WBool @CLASSNAME@::FormParent_Close(
  415.     WObject *           source,
  416.     WEventData *        event )
  417. {
  418.     // cleanup
  419.     if( _editMenu )     delete _editMenu;
  420.     if( _windowMenu )   delete _windowMenu;    
  421.     if( _closeItem )    delete _closeItem;
  422.     
  423.     //  Delete any remaining child windows
  424.     _childWindowVector.Clear( TRUE );
  425.     
  426.     return FALSE;
  427. }
  428.  
  429. @end-code;
  430.  
  431. @begin-code Code "FormParent::FormParent_Create"
  432.  
  433. WBool @CLASSNAME@::FormParent_Create(
  434.     WObject *                 source,
  435.     WCreateEventData *        event )
  436. {
  437.     WMenuObject *                   windowMenu;
  438.     WRect                           clientRectangle;
  439.     
  440.     //  Set the window menu property. This tells the component library
  441.     //  where to put the list of MDI child windows.
  442.     windowMenu = menu_1->Find( "&Window", 0, true );    
  443.     SetWindowMenu( (WMenu*)windowMenu );
  444.     
  445.     //  Use the minimal menu
  446.     minimalMenu();
  447.     
  448.     return FALSE;
  449. }
  450.  
  451. @end-code;
  452.  
  453. @begin-code Code "FormParent::FormParent_User"
  454.  
  455. WBool @CLASSNAME@::FormParent_User(
  456.     WObject *               source,
  457.     WUserEventData *        event )
  458. {
  459.     FormChild   *child;
  460.     
  461.     //  Child windows post a message back to us (the parent window) asking
  462.     //  to be closed. 
  463.     child = (FormChild *)event->data;    
  464.     _childWindowVector.Remove( child );
  465.     delete child;
  466.     
  467.     //  If we just closed the last child window, switch back to the minimial menu
  468.     if( _childWindowVector.GetCount() == 0 ) {
  469.         minimalMenu();
  470.     }
  471.    
  472.     return FALSE;
  473. }
  474.  
  475. @end-code;
  476.  
  477. @begin-code Code "FormParent::menu_1_InitMenu"
  478.  
  479. WBool @CLASSNAME@::menu_1_InitMenu(
  480.     WObject *                  source,
  481.     WMessageEventData *        event )
  482. {
  483.     WBool       enabled;
  484.     
  485.     //  If there are more than 2 windows, enable the Next and
  486.     //  Previous menu items.
  487.     enabled = ( _childWindowVector.GetCount() >= 2 );
  488.     menu_1_item_Next->SetEnabled( enabled );
  489.     menu_1_item_Previous->SetEnabled( enabled );    
  490.     
  491.     return FALSE;
  492. }
  493.  
  494. @end-code;
  495.  
  496. @begin-code Code "FormParent::menu_1_item_About_Click"
  497.  
  498. WBool @CLASSNAME@::menu_1_item_About_Click(
  499.     WObject *           source,
  500.     WEventData *        event )
  501. {
  502.     // display the about box
  503.     AboutBox1->Create( this );
  504.     
  505.     return FALSE;
  506. }
  507.  
  508. @end-code;
  509.  
  510. @begin-code Code "FormParent::menu_1_item_ArrangeIcons_Click"
  511.  
  512. WBool @CLASSNAME@::menu_1_item_ArrangeIcons_Click(
  513.     WObject *           source,
  514.     WEventData *        event )
  515. {
  516.     // arrange all minimized MDI child window icons
  517.     ArrangeMinimized();
  518.     
  519.     return FALSE;
  520. }
  521.  
  522. @end-code;
  523.  
  524. @begin-code Code "FormParent::menu_1_item_Cascade_Click"
  525.  
  526. WBool @CLASSNAME@::menu_1_item_Cascade_Click(
  527.     WObject *           source,
  528.     WEventData *        event )
  529. {
  530.     // cascade all MDI child windows
  531.     Cascade( );
  532.     
  533.     return FALSE;
  534. }
  535.  
  536. @end-code;
  537.  
  538. @begin-code Code "FormParent::menu_1_item_Close_Click"
  539.  
  540. WBool @CLASSNAME@::menu_1_item_Close_Click(
  541.     WObject *           source,
  542.     WEventData *        event )
  543. {
  544.     WMDIChild   *child;
  545.     
  546.     //  Close the active MDI child
  547.     child = GetActiveChild();
  548.     child->Close();
  549.     
  550.     return FALSE;
  551. }
  552.  
  553. @end-code;
  554.  
  555. @begin-code Code "FormParent::menu_1_item_Exit_Click"
  556.  
  557. WBool @CLASSNAME@::menu_1_item_Exit_Click(
  558.     WObject *           source,
  559.     WEventData *        event )
  560. {
  561.     Close();
  562.     
  563.     return FALSE;
  564. }
  565.  
  566. @end-code;
  567.  
  568. @begin-code Code "FormParent::menu_1_item_New_Click"
  569.  
  570. WBool @CLASSNAME@::menu_1_item_New_Click(
  571.     WObject *           source,
  572.     WEventData *        event )
  573. {
  574.     addChild();
  575.     
  576.     return FALSE;
  577. }
  578.  
  579. @end-code;
  580.  
  581. @begin-code Code "FormParent::menu_1_item_Next_Click"
  582.  
  583. WBool @CLASSNAME@::menu_1_item_Next_Click(
  584.     WObject *           source,
  585.     WEventData *        event )
  586. {
  587.     //  Activate he next MDI child form
  588.     ActivateNext();
  589.     
  590.     return FALSE;
  591. }
  592.  
  593. @end-code;
  594.  
  595. @begin-code Code "FormParent::menu_1_item_Previous_Click"
  596.  
  597. WBool @CLASSNAME@::menu_1_item_Previous_Click(
  598.     WObject *           source,
  599.     WEventData *        event )
  600. {
  601.     //  Activate the previous MDI child form
  602.     ActivatePrevious();
  603.     
  604.     return FALSE;
  605. }
  606.  
  607. @end-code;
  608.  
  609. @begin-code Code "FormParent::menu_1_item_TileHorizontal_Click"
  610.  
  611. WBool @CLASSNAME@::menu_1_item_TileHorizontal_Click(
  612.     WObject *           source,
  613.     WEventData *        event )
  614. {
  615.     // tile horizontally all MDI child windows
  616.     Tile( true );
  617.     
  618.     return FALSE;
  619. }
  620.  
  621. @end-code;
  622.  
  623. @begin-code Code "FormParent::menu_1_item_TileVertical_Click"
  624.  
  625. WBool @CLASSNAME@::menu_1_item_TileVertical_Click(
  626.     WObject *           source,
  627.     WEventData *        event )
  628. {
  629.     // tile vertically all MDI child windows
  630.     Tile( false );
  631.     
  632.     return FALSE;
  633. }
  634.  
  635. @end-code;
  636. @end;
  637.