home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 October / Chip_1997-10_cd.bin / tema / sybase / powerj / hpp.z / WFORM.HPP < prev    next >
C/C++ Source or Header  |  1997-01-24  |  15KB  |  470 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,8);
  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.         // FDXInitializeControls
  270.         //
  271.         //      Called by the default Initialize event handler
  272.  
  273.         virtual WBool FDXInitializeControls();
  274.  
  275.         // FDXUpdateControls
  276.         //
  277.         //      Called by the default OK event handler
  278.  
  279.         virtual WBool FDXUpdateControls();
  280.  
  281.         // Initialize
  282.  
  283.         virtual WBool Initialize();
  284.  
  285.         // RedrawFrame
  286.  
  287.         WBool RedrawFrame();
  288.  
  289.         // RemoveDockedWindow
  290.  
  291.         virtual void RemoveDockedWindow( WWindow * docked );
  292.  
  293.         // RemoveDrawPrimitive
  294.         //
  295.         // Note: The added drawPrimitives will automatically be
  296.         //       deleted by the window in its destructor, so the
  297.         //       user should NOT delete this primitives him/herself
  298.  
  299.         virtual void RemoveDrawPrimitive( WDrawPrimitive * drawPrimitive );
  300.  
  301.         // RemovePinnedWindow
  302.  
  303.         virtual WBool RemovePinnedWindow( WWindow *pinned );
  304.  
  305.         // ResetSystemMenu
  306.  
  307.         WBool ResetSystemMenu();
  308.  
  309.         // ShiftDockedWindows
  310.  
  311.         virtual void ShiftDockedWindows( WDockPosition pos,
  312.                                          WInt startIndex, WInt endIndex,
  313.                                          WBool moveUp );
  314.  
  315.         // Show
  316.  
  317.         virtual WBool Show( WShowStyle style=WWinStateShowNormal );
  318.     
  319.         // UpdateMenu
  320.  
  321.         WBool UpdateMenu();
  322.  
  323.         /**************************************************************
  324.          * Item properties
  325.          **************************************************************/
  326.  
  327.         // Control
  328.  
  329.         virtual WControl * GetControl( WInt itemNumber );
  330.  
  331.         // DockedWindow
  332.  
  333.         virtual WWindow * GetDockedWindow( WInt index, WDockPosition pos );
  334.  
  335.         // DockedWindowCount
  336.  
  337.         virtual WInt GetDockedWindowCount( WDockPosition pos );
  338.  
  339.         /**************************************************************
  340.          * Event handlers
  341.          **************************************************************/
  342.  
  343.         WBool InitMenuEventHandler( WForm * form,
  344.                                     WMessageEventData * event );
  345.  
  346.         WBool SystemCommandEventHandler( WForm * form,
  347.                                          WMessageEventData * event );
  348.  
  349.         WBool CommandEventHandler( WForm * form,
  350.                                    WMessageEventData * event );
  351.  
  352.         WBool InitPopupMenuEventHandler( WForm * form,
  353.                                          WMessageEventData * event );
  354.  
  355.         WBool MenuSelectEventHandler( WForm * form,
  356.                                       WMessageEventData * event );
  357.  
  358.         WBool FormCloseEventHandler( WForm * form,
  359.                                              WEventData * event );
  360.                                              
  361.         WBool EraseBackgroundHandler( WWindow * window,
  362.                                       WPaintEventData * event );
  363.  
  364.         WBool ResizeEventHandler( WWindow * window,
  365.                                   WResizeEventData * event );
  366.  
  367.         WBool DestroyEventHandler( WWindow * window, WEventData * event );
  368.  
  369.         WBool HelpEventHandler( WWindow * window, WHelpEventData * event );
  370.  
  371.         WBool PositionChangedEventHandler( WForm *window,
  372.                                            WResizeEventData * event );
  373.  
  374.         WBool ScrollEventHandler( WWindow * window,
  375.                                   WScrollBarEventData * event );
  376.  
  377.         /**************************************************************
  378.          * Overrides
  379.          **************************************************************/
  380.         
  381.         virtual WBool SetPopup( WPopupMenu * popup );
  382.  
  383.         virtual WBool AdjustFloatingFormStyle( WStyle & style,
  384.                                                WStyle & exStyle );
  385.  
  386.         virtual WRect CalculateSize( const WRect &, WBool adjust );
  387.  
  388.         virtual void SetDockedPosition( WDockPosition pos, WInt index=0,
  389.                                         WBool insert=FALSE,
  390.                                         WWindow * sibling=NULL,
  391.                                         WBool insertBeforeSibling=TRUE,
  392.                                         WBool callEventHandler=TRUE );
  393.  
  394.         virtual void AddControl( WControl * ctrl );
  395.  
  396.         virtual void RemoveControl( WControl * ctrl );
  397.  
  398.         virtual WBool ProcessMessage( const WMessage & msg, WLong & returns );
  399.  
  400.         virtual WBool SetFont( const WFont & font, WBool preserveSize=TRUE );
  401.  
  402.         virtual WFont GetFont( WBool getResultingFont=TRUE );
  403.  
  404.         virtual WUInt AssignWindowID();
  405.  
  406.         virtual WStyle GetDefaultStyle() const;
  407.  
  408.         virtual WStyle GetDefaultExtendedStyle() const;
  409.     
  410.         virtual WBool LoadWindow( WWindow * parent,
  411.                                   const WResourceID & id,
  412.                                   WModuleHandle module=_ApplicationModule );
  413.     
  414.         virtual WBool MakeWindow( WWindow * parent, WUInt id,
  415.                                   const WChar *className,
  416.                                   const WChar *title, const WRect & r,
  417.                                   WStyle wstyle, WStyle exStyle,
  418.                                   void * data=NULL );
  419.  
  420.         virtual WBool CloneWindow( WStyle newStyle, WStyle newExStyle,
  421.                                    void * data=NULL );
  422.  
  423.         /**************************************************************
  424.          * Others
  425.          **************************************************************/
  426.         
  427.         virtual WBool FilterMessage( WMessage & msg, WBool & eatMessage );
  428.  
  429.         /**************************************************************
  430.          * Data members
  431.          **************************************************************/
  432.  
  433.     protected:
  434.  
  435.         WRect                           _lastResizeRect;
  436.  
  437.     private:
  438.  
  439.         WString                         _hintText;
  440.         WFilePath                       _helpFile;
  441.         WStatusBar *                    _statusBar;
  442.         WMenu *                         _menu;
  443.         WSystemMenu *                   _systemMenu;
  444.         WInt                            _nextChildID;
  445.         WAcceleratorTable *             _accelTable;
  446.         WSize                           _maxSize;
  447.         WPoint                          _maxPosition;
  448.         WSize                           _minTrackSize;
  449.         WSize                           _maxTrackSize;
  450.         WWindow *                       _clientWindow;
  451.         WStyle *                        _dockStyle;
  452.         WStyle *                        _dockExStyle;
  453.         WDrawPrimitiveGroup *           _drawPrimitives;
  454.         WVector< WWindow > *            _dockedWindows;
  455.         WVector< WWindow > *            _dockWindowFrames;
  456.         WVector< WWindow > *            _pinnedWindows;
  457.         WVector< WObject > *            _objects;
  458.         WVector< WString > *            _objectNames;
  459.         WRect                           _virtClientRect;
  460.         WBool                           _automaticScrolling;
  461.         WBool                           _inResize;
  462. };
  463.  
  464. #ifndef _WNO_PRAGMA_PUSH
  465. #pragma enum pop;
  466. #pragma pack(pop);
  467. #endif
  468.  
  469. #endif // _WFORM_HPP_INCLUDED
  470.