home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 10 / ioProg_10.iso / soft / optima / hpp.z / WFORM.HPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-13  |  14.4 KB  |  462 lines

  1. /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2.    %     Copyright (C) 1994, by WATCOM International Inc.  All rights    %
  3.    %     reserved.  No part of this software may be reproduced or        %
  4.    %     used in any form or by any means - graphic, electronic or       %
  5.    %     mechanical, including photocopying, recording, taping or        %
  6.    %     information storage and retrieval systems - except with the     %
  7.    %     written permission of WATCOM International Inc.                 %
  8.    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  9. */
  10.  
  11. /*************************************************************************
  12.  *
  13.  * WForm -- Base Form class
  14.  *
  15.  *
  16.  *   Events:
  17.  *
  18.  *       Close --
  19.  *
  20.  *       InitMenu --
  21.  *
  22.  *************************************************************************/
  23.  
  24. #ifndef _WFORM_HPP_INCLUDED
  25. #define _WFORM_HPP_INCLUDED
  26.  
  27. #ifndef _WNO_PRAGMA_PUSH
  28. #pragma pack(push,4);
  29. #pragma enum int;
  30. #endif
  31.  
  32. #ifndef _WVECTOR_HPP_INCLUDED
  33. #  include "wvector.hpp"
  34. #endif
  35. #ifndef _WWINDOW_HPP_INCLUDED
  36. #  include "wwindow.hpp"
  37. #endif
  38. #ifndef _WCONTROL_HPP_INCLUDED
  39. #  include "wcontrol.hpp"
  40. #endif
  41. #ifndef _WPOPMENU_HPP_INCLUDED
  42. #  include "wpopmenu.hpp"
  43. #endif
  44. #ifndef _WFILPATH_HPP_INCLUDED
  45. #  include "wfilpath.hpp"
  46. #endif
  47.  
  48.  
  49. extern template WVector<WWindow>;
  50. extern template WVector<WObject>;
  51. extern template WVector<WString>;
  52.  
  53. class WAcceleratorTable;
  54. class WStatusBar;
  55.  
  56. enum WWindowState {
  57.     WWindowStateNormal,
  58.     WWindowStateMinimized,
  59.     WWindowStateMaximized
  60. };
  61.  
  62. //
  63. // Styles
  64. //
  65.  
  66. #define WFormDefault ((WStyle)0x12CF0000L) // WS_OVERLAPPEDWINDOW|WS_VISIBLE|WS_CLIPCHILDREN
  67.  
  68. class WCMCLASS WForm : public WWindow {
  69.     WDeclareSubclass( WForm, WWindow );
  70.  
  71.     public:
  72.  
  73.         /**************************************************************
  74.          * Constructors
  75.          **************************************************************/
  76.  
  77.         WForm();
  78.     
  79.         WForm( WWindow * parent, WWindowHandle hdl );
  80.     
  81.         virtual ~WForm();
  82.  
  83.         /**************************************************************
  84.          * Properties
  85.          **************************************************************/
  86.  
  87.         // AcceleratorTable
  88.  
  89.         WAcceleratorTable GetAcceleratorTable() const;
  90.         WBool SetAcceleratorTable( const WAcceleratorTable & table,
  91.                                    WBool append=FALSE );
  92.  
  93.         // Active
  94.         //
  95.         //     If TRUE, window is the active window for this thread.
  96.         //     Use the Activate method to force a window to become
  97.         //     the active window.
  98.  
  99.         virtual WBool GetActive() const;
  100.  
  101.         // AutomaticScrolling
  102.  
  103.         WBool GetAutomaticScrolling() const;
  104.         WBool SetAutomaticScrolling( WBool automaticScrolling );
  105.  
  106.         // ClientWindow
  107.         //
  108.         //      The client window will automatically be positioned directly
  109.         //      over the client area of the form, excluding any space taken
  110.         //      up by docked windows such as toolbars and status bars.
  111.  
  112.         virtual WWindow * GetClientWindow();
  113.         virtual WBool SetClientWindow( WWindow * clientWindow );
  114.  
  115.         // ControlCount
  116.  
  117.         virtual WInt GetControlCount();
  118.  
  119.         // MaximizedPosition
  120.         //
  121.         //    Defines the left & top position of the form when
  122.         //    maximized.
  123.  
  124.         WPoint GetMaximizedPosition() const;
  125.         WBool  SetMaximizedPosition( const WPoint & maxPos );
  126.  
  127.         // MaximizedSize
  128.         //
  129.         //    Defines the height & width of the form when
  130.         //    maximized.
  131.  
  132.         WSize  GetMaximizedSize() const;
  133.         WBool  SetMaximizedSize( const WSize & maxSize );
  134.  
  135.         // MaximumTrackingSize
  136.         //
  137.         //    Defines the maximum height & width when the window
  138.         //    is being resized.
  139.  
  140.         WSize GetMaximumTrackingSize() const;
  141.         WBool SetMaximumTrackingSize( const WSize & maxTrackSize );
  142.  
  143.         // Menu
  144.  
  145.         virtual WMenu *GetMenu() const;
  146.         virtual WBool  SetMenu( WMenu *menu );
  147.  
  148.         // MinimumTrackingSize
  149.         //
  150.         //    Defines the minimum height & width when the window
  151.         //    is being resized.
  152.  
  153.         WSize GetMinimumTrackingSize() const;
  154.         WBool SetMinimumTrackingSize( const WSize & minTrackSize );
  155.  
  156.         // SystemMenu
  157.         //
  158.         //
  159.  
  160.         WSystemMenu *GetSystemMenu();
  161.  
  162.         // Icon in the window's title bar
  163.         //
  164.         //
  165.  
  166.         WIcon GetIcon(WBool size = FALSE);
  167.         WIcon SetIcon(const WIcon & icon, WBool size = FALSE); // default small size
  168.  
  169.         // HelpFile
  170.  
  171.         WFilePath GetHelpFile() const;
  172.         WBool     SetHelpFile( const WFilePath & helpFile );
  173.  
  174.         // HintText
  175.  
  176.         WString       GetHintText() const;
  177.         virtual WBool SetHintText( const WString & str );
  178.  
  179.         // StatusBar
  180.  
  181.         virtual WStatusBar *GetStatusBar() const;
  182.         virtual WBool       SetStatusBar( WStatusBar * statusBar );
  183.  
  184.         // VirtualClientRectangle
  185.  
  186.         virtual WBool SetVirtualClientRectangle( const WRect & rect );
  187.         virtual WRect GetVirtualClientRectangle() const;
  188.  
  189.         // WindowID
  190.  
  191.         virtual WUInt GetWindowID() const;
  192.         virtual WBool SetWindowID( WUInt newID );
  193.  
  194.         // WindowState
  195.         
  196.         WWindowState GetWindowState();
  197.         WBool        SetWindowState( WWindowState state );
  198.  
  199.         /**************************************************************
  200.          * Methods
  201.          **************************************************************/
  202.  
  203.         // Activate
  204.         //
  205.         //     Force this form to become the active window for the
  206.         //     thread.
  207.  
  208.         virtual WBool Activate() const;
  209.  
  210.         // AddDockedWindow
  211.  
  212.         virtual void AddDockedWindow( WWindow * docked,
  213.                                       WWindow * sibling=NULL,
  214.                                       WBool insertBeforeSibling=TRUE );
  215.  
  216.         // AddObject
  217.  
  218.         WBool AddObject( WObject * object, const WString & objectName );
  219.  
  220.         // Close
  221.  
  222.         virtual WBool Close();
  223.  
  224.         // GetObject
  225.  
  226.         WObject * FindObject( const WString & objectName,
  227.                              WBool recurseUp=TRUE );
  228.  
  229.         // RemoveObject
  230.  
  231.         WBool RemoveObject( WObject * object, WBool recurseUp=TRUE );
  232.         WBool RemoveObject( const WString & objectName,
  233.                             WBool recurseUp=TRUE );
  234.  
  235.         // AddDrawPrimitive
  236.         //
  237.         // Note: The added drawPrimitives will automatically be
  238.         //       deleted by the window in its destructor, so the
  239.         //       user should NOT delete this primitives him/herself
  240.  
  241.         virtual void AddDrawPrimitive( WDrawPrimitive * drawPrimitive );
  242.  
  243.         // AddPinnedWindow
  244.  
  245.         virtual WBool AddPinnedWindow( WWindow * pinned );
  246.  
  247.         // AdjustClientRectangle
  248.  
  249.         virtual void AdjustClientRectangle( WRect & rect,
  250.                                             WBool moveChildren=FALSE );
  251.  
  252.         // Center
  253.         //
  254.         //    Center the form, either over its parent (owner) or
  255.         //    over an arbitrary window.  Pass NULL to center over
  256.         //    the desktop.
  257.  
  258.         WBool Center();
  259.         WBool Center( WWindow *window );
  260.  
  261.         // ClearMenu
  262.  
  263.         WMenu * ClearMenu();
  264.  
  265.         // CreateStatusBar
  266.  
  267.         WBool CreateStatusBar();
  268.  
  269.         // Initialize
  270.  
  271.         virtual WBool Initialize();
  272.  
  273.         // RedrawFrame
  274.  
  275.         WBool RedrawFrame();
  276.  
  277.         // RemoveDockedWindow
  278.  
  279.         virtual void RemoveDockedWindow( WWindow * docked );
  280.  
  281.         // RemoveDrawPrimitive
  282.         //
  283.         // Note: The added drawPrimitives will automatically be
  284.         //       deleted by the window in its destructor, so the
  285.         //       user should NOT delete this primitives him/herself
  286.  
  287.         virtual void RemoveDrawPrimitive( WDrawPrimitive * drawPrimitive );
  288.  
  289.         // RemovePinnedWindow
  290.  
  291.         virtual WBool RemovePinnedWindow( WWindow *pinned );
  292.  
  293.         // ResetSystemMenu
  294.  
  295.         WBool ResetSystemMenu();
  296.  
  297.         // Scroll
  298.  
  299.         virtual WBool Scroll( const WPoint & amount, WRect * toScroll=NULL,
  300.                               WRect * clipRegion=NULL );
  301.  
  302.         // ShiftDockedWindows
  303.  
  304.         virtual void ShiftDockedWindows( WDockPosition pos,
  305.                                          WInt startIndex, WInt endIndex,
  306.                                          WBool moveUp );
  307.  
  308.         // Show
  309.  
  310.         virtual WBool Show( WShowStyle style=WWinStateShowNormal );
  311.     
  312.         // UpdateMenu
  313.  
  314.         WBool UpdateMenu();
  315.  
  316.         /**************************************************************
  317.          * Item properties
  318.          **************************************************************/
  319.  
  320.         // Control
  321.  
  322.         virtual WControl * GetControl( WInt itemNumber );
  323.  
  324.         // DockedWindow
  325.  
  326.         virtual WWindow * GetDockedWindow( WInt index, WDockPosition pos );
  327.  
  328.         // DockedWindowCount
  329.  
  330.         virtual WInt GetDockedWindowCount( WDockPosition pos );
  331.  
  332.         /**************************************************************
  333.          * Event handlers
  334.          **************************************************************/
  335.  
  336.         WBool InitMenuEventHandler( WForm * form,
  337.                                     WMessageEventData * event );
  338.  
  339.         WBool SystemCommandEventHandler( WForm * form,
  340.                                          WMessageEventData * event );
  341.  
  342.         WBool CommandEventHandler( WForm * form,
  343.                                    WMessageEventData * event );
  344.  
  345.         WBool InitPopupMenuEventHandler( WForm * form,
  346.                                          WMessageEventData * event );
  347.  
  348.         WBool MenuSelectEventHandler( WForm * form,
  349.                                       WMessageEventData * event );
  350.  
  351.         WBool FormCloseEventHandler( WForm * form,
  352.                                              WEventData * event );
  353.                                              
  354.         WBool EraseBackgroundHandler( WWindow * window,
  355.                                       WPaintEventData * event );
  356.  
  357.         WBool ResizeEventHandler( WWindow * window,
  358.                                   WResizeEventData * event );
  359.  
  360.         WBool DestroyEventHandler( WWindow * window, WEventData * event );
  361.  
  362.         WBool HelpEventHandler( WWindow * window, WHelpEventData * event );
  363.  
  364.         WBool PositionChangedEventHandler( WForm *window,
  365.                                            WResizeEventData * event );
  366.  
  367.         WBool ScrollEventHandler( WWindow * window,
  368.                                   WScrollBarEventData * event );
  369.  
  370.         /**************************************************************
  371.          * Overrides
  372.          **************************************************************/
  373.         
  374.         virtual WBool SetPopup( WPopupMenu * popup );
  375.  
  376.         virtual WBool AdjustFloatingFormStyle( WStyle & style,
  377.                                                WStyle & exStyle );
  378.  
  379.         virtual WRect CalculateSize( const WRect &, WBool adjust );
  380.  
  381.         virtual void SetDockedPosition( WDockPosition pos, WInt index=0,
  382.                                         WBool insert=FALSE,
  383.                                         WWindow * sibling=NULL,
  384.                                         WBool insertBeforeSibling=TRUE,
  385.                                         WBool callEventHandler=TRUE );
  386.  
  387.         virtual void AddControl( WControl * ctrl );
  388.  
  389.         virtual void RemoveControl( WControl * ctrl );
  390.  
  391.         virtual WBool ProcessMessage( const WMessage & msg, WLong & returns );
  392.  
  393.         virtual WBool SetFont( const WFont & font, WBool preserveSize=TRUE );
  394.  
  395.         virtual WFont GetFont( WBool getResultingFont=TRUE );
  396.  
  397.         virtual WUInt AssignWindowID();
  398.  
  399.         virtual WStyle GetDefaultStyle() const;
  400.  
  401.         virtual WStyle GetDefaultExtendedStyle() const;
  402.     
  403.         virtual WBool LoadWindow( WWindow * parent,
  404.                                   const WResourceID & id,
  405.                                   WModuleHandle module=_ApplicationModule );
  406.     
  407.         virtual WBool MakeWindow( WWindow * parent, WUInt id,
  408.                                   const WChar *className,
  409.                                   const WChar *title, const WRect & r,
  410.                                   WStyle wstyle, WStyle exStyle,
  411.                                   void * data=NULL );
  412.  
  413.         virtual WBool CloneWindow( WStyle newStyle, WStyle newExStyle,
  414.                                    void * data=NULL );
  415.  
  416.         /**************************************************************
  417.          * Others
  418.          **************************************************************/
  419.         
  420.         virtual WBool FilterMessage( WMessage & msg, WBool & eatMessage );
  421.  
  422.         /**************************************************************
  423.          * Data members
  424.          **************************************************************/
  425.  
  426.     protected:
  427.  
  428.         WRect                           _lastResizeRect;
  429.  
  430.     private:
  431.  
  432.         WString                         _hintText;
  433.         WFilePath                       _helpFile;
  434.         WStatusBar *                    _statusBar;
  435.         WMenu *                         _menu;
  436.         WSystemMenu *                   _systemMenu;
  437.         WInt                            _nextChildID;
  438.         WAcceleratorTable *             _accelTable;
  439.         WSize                           _maxSize;
  440.         WPoint                          _maxPosition;
  441.         WSize                           _minTrackSize;
  442.         WSize                           _maxTrackSize;
  443.         WWindow *                       _clientWindow;
  444.         WStyle *                        _dockStyle;
  445.         WStyle *                        _dockExStyle;
  446.         WDrawPrimitiveGroup *           _drawPrimitives;
  447.         WVector< WWindow > *            _dockedWindows;
  448.         WVector< WWindow > *            _dockWindowFrames;
  449.         WVector< WWindow > *            _pinnedWindows;
  450.         WVector< WObject > *            _objects;
  451.         WVector< WString > *            _objectNames;
  452.         WRect                           _virtClientRect;
  453.         WBool                           _automaticScrolling;
  454. };
  455.  
  456. #ifndef _WNO_PRAGMA_PUSH
  457. #pragma enum pop;
  458. #pragma pack(pop);
  459. #endif
  460.  
  461. #endif // _WFORM_HPP_INCLUDED
  462.