home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / hpp.z / WPROPSHT.HPP < prev    next >
C/C++ Source or Header  |  1996-10-30  |  11KB  |  372 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. #ifndef _WPROPSHT_HPP_INCLUDED
  12. #define _WPROPSHT_HPP_INCLUDED
  13.  
  14. #ifndef _WNO_PRAGMA_PUSH
  15. #pragma pack(push,8);
  16. #pragma enum int;
  17. #endif
  18.  
  19. #ifndef _WCONTROL_HPP_INCLUDED
  20. #  include "wcontrol.hpp"
  21. #endif
  22. #ifndef _WVECTOR_HPP_INCLUDED
  23. #  include "wvector.hpp"
  24. #endif
  25.  
  26. /*************************************************************************
  27.  *
  28.  * WPropertySheetItem --
  29.  *
  30.  *************************************************************************/
  31.  
  32. class WIcon;
  33. class WPropertySheet;
  34.  
  35. struct WPropertySheetEventData : public WEventData {
  36.     WInt        index;
  37. };
  38.  
  39. struct WPSDialogEventData : public WEventData {
  40.     WLong       p1;
  41.     WLong       p2;
  42. };
  43.  
  44. //
  45. // PropertySheet styles
  46. //
  47.  
  48. #define WPSSDefault             ((WStyle)0x50000000L) // WS_VISIBLE|WS_CHILD
  49.  
  50. class WCMCLASS WPropertySheetItem : public WModelessDialog {
  51.     WDeclareSubclass( WPropertySheetItem, WModelessDialog );
  52.  
  53.     friend class WModelessPropertySheet;
  54.     friend class WPropertySheet;
  55.  
  56.     public:
  57.  
  58.         /**********************************************************
  59.          * Constructors and Destructors
  60.          *********************************************************/
  61.          
  62.         WPropertySheetItem( WWindow * prt=NULL,
  63.                             WPropertySheet * propsht=NULL );
  64.     
  65.         ~WPropertySheetItem();
  66.     
  67.         /**********************************************************
  68.          * Properties
  69.          *********************************************************/
  70.  
  71.         WInt GetIndex() const;
  72.          
  73.         /**********************************************************
  74.          * Methods
  75.          *********************************************************/
  76.          
  77.         /**********************************************************
  78.          * Overrides
  79.          *********************************************************/
  80.  
  81.         virtual WBool ProcessMessage( const WMessage & msg,
  82.                                       WLong & returns );
  83.     
  84.         virtual void * GetTargetWindowProc() const;
  85.  
  86.         /**********************************************************
  87.          * Others
  88.          *********************************************************/
  89.  
  90.         virtual int operator ==( const WPropertySheetItem & obj ) const;
  91.  
  92.         /**********************************************************
  93.          * Data members
  94.          *********************************************************/
  95.          
  96.     private:
  97.  
  98.         WModelessPropertySheet *        _parent;
  99.         char const *                    _id;
  100.         void *                          _data;
  101.         WInt                            _index;
  102. };
  103.  
  104. class WCMCLASS WPropertySheetInfo {
  105.  
  106.     public:
  107.  
  108.         /**********************************************************
  109.          * Constructors and Destructors
  110.          *********************************************************/
  111.  
  112.         WPropertySheetInfo();
  113.         WPropertySheetInfo( const WPropertySheetInfo & info );
  114.         ~WPropertySheetInfo();
  115.  
  116.         /**********************************************************
  117.          * Methods
  118.          *********************************************************/
  119.  
  120.         void Init();
  121.  
  122.         /**********************************************************
  123.          * Others
  124.          *********************************************************/
  125.  
  126.         WPropertySheetInfo& operator=( const WPropertySheetInfo & info );
  127.  
  128.  
  129.     public:
  130.  
  131.         /**********************************************************
  132.          * Data members
  133.          *********************************************************/
  134.  
  135.         WString                 text;
  136.         void *                  data;
  137.         WIcon *                 image;
  138.         WBool                   selfDeleteImage;
  139.         WPropertySheetItem *    dialog;
  140.         WBool                   selfDeleteDialog;
  141.         WResourceID *           dlgID;
  142.         WBool                   selfDeleteDialogID;
  143.         WModuleHandle *         module;
  144.         WBool                   selfDeleteModule;
  145.         WBool                   hasHelp;
  146.         WWindowHandle           handle;         // ignored by Add(),
  147.                                                 // will be set later
  148.                                                 // automatically
  149. };
  150.  
  151. enum WPropertySheetButton {
  152.     WPSBOK,
  153.     WPSBCancel,
  154.     WPSBApplyNow,
  155.     WPSBHelp
  156. };
  157.  
  158. /*************************************************************************
  159.  *
  160.  * WModelessPropertySheet -- Wrapper for the Windows 95 Property Sheet
  161.  *
  162.  *   Events:
  163.  *
  164.  *       ApplyNowOrOK --
  165.  *
  166.  *       Back --
  167.  *
  168.  *       Cancel --
  169.  *
  170.  *       Finish --
  171.  *
  172.  *       Help --
  173.  *
  174.  *       Next --
  175.  *
  176.  *       PageSelect --
  177.  *
  178.  *       PageUnselect --
  179.  *
  180.  *       QueryCancel --
  181.  *
  182.  *       QuerySibling --
  183.  *
  184.  *************************************************************************/
  185.  
  186. class WCMCLASS WModelessPropertySheet : public WControl {
  187.     WDeclareSubclass( WModelessPropertySheet, WControl );
  188.  
  189.     friend class WPropertySheetItem;
  190.  
  191.     public:
  192.  
  193.         /**********************************************************
  194.          * Constructors and destructors
  195.          *********************************************************/
  196.          
  197.         WModelessPropertySheet( WBool hasHelp=FALSE, WIcon * image=NULL,
  198.                                 const WChar * text=NULL,
  199.                                 WBool isPropertyTitle=FALSE,
  200.                                 WInt startItemIndex=0,
  201.                                 WPropertySheetInfo * infoArray=NULL,
  202.                                 WInt numItems=0 );
  203.     
  204.         ~WModelessPropertySheet();
  205.  
  206.         /**********************************************************
  207.          * Properties
  208.          *********************************************************/
  209.  
  210.         // Changed
  211.  
  212.         WBool SetChanged( WBool changed );
  213.  
  214.         // Count
  215.  
  216.         WInt GetCount() const;
  217.  
  218.         // Selected
  219.  
  220.         WBool SetSelected( WInt index );
  221.  
  222.         /**********************************************************
  223.          * Methods
  224.          *********************************************************/
  225.  
  226.         // Add
  227.  
  228.         WPropertySheetItem * Add( const WPropertySheetInfo & info );
  229.  
  230.         // Center
  231.  
  232.         WBool Center();
  233.         WBool Center( WWindow *window );
  234.  
  235.         // ChangeCancelToClose
  236.  
  237.         virtual WBool ChangeCancelToClose();
  238.  
  239.         // Delete
  240.  
  241.         WBool Delete( WInt index );
  242.  
  243.         // DeleteAll
  244.  
  245.         WBool DeleteAll();
  246.  
  247.         // QuerySiblings
  248.  
  249.         WInt QuerySiblings( WLong p1, WLong p2 );
  250.  
  251.         // PressButton
  252.  
  253.         WBool PressButton( WPropertySheetButton buttonToSimulate );
  254.  
  255.         // RebootSystem
  256.  
  257.         WBool RebootSystem();
  258.  
  259.         // RestartWindows
  260.  
  261.         WBool RestartWindows();
  262.  
  263.         /**********************************************************
  264.          * Overrides
  265.          *********************************************************/
  266.  
  267.         virtual WBool SetText( const WString & text );
  268.  
  269.         virtual const WChar * InitializeClass();
  270.  
  271.         virtual WStyle GetDefaultStyle() const;
  272.  
  273.         virtual WBool CloneWindow( WStyle newStyle, WStyle newExStyle,
  274.                                    void * data=NULL );
  275.  
  276.     protected:
  277.  
  278.         virtual WBool ProcessNotify( WUInt id, WNotify code, WNotifyInfo info,
  279.                                      WLong & returns );
  280.  
  281.         virtual WBool MakeWindow( WWindow * parent, WUInt id,
  282.                                   const WChar * className,
  283.                                   const WChar * title,
  284.                                   const WRect & r, WStyle wstyle,
  285.                                   WStyle exStyle, void * data=NULL );
  286.  
  287.         /**********************************************************
  288.          * Data members
  289.          *********************************************************/
  290.  
  291.     protected:
  292.  
  293.         WBool                           _isWizard;
  294.     
  295.     public:
  296.  
  297.         static char *                   _WPropertySheetClassName;
  298.  
  299.     protected:
  300.  
  301.         WULong                          _return;
  302.         WBool                           _canRebootOrRestart;
  303.         WInt                            _currItemIndex;
  304.         WPropertySheetInfo *            _infoArray;
  305.  
  306.     private:
  307.  
  308.         WInt                            _numItems;
  309.         WBool                           _hasHelp;
  310.         WBool                           _isPropertyTitle;
  311.         WString                         _text;
  312.         WIcon *                         _image;
  313.         WInt                            _startItemIndex;
  314. };
  315.  
  316. /*************************************************************************
  317.  *
  318.  * WPropertySheet -- Wrapper for the Windows 95 Property Sheet
  319.  *
  320.  *   Events:
  321.  *
  322.  *************************************************************************/
  323.  
  324. class WCMCLASS WPropertySheet : public WModelessPropertySheet {
  325.     WDeclareSubclass( WPropertySheet, WModelessPropertySheet );
  326.  
  327.     friend class WPropertySheetItem;
  328.  
  329.     public:
  330.  
  331.         /**********************************************************
  332.          * Constructors and Destructors
  333.          *********************************************************/
  334.  
  335.         WPropertySheet( WBool hasHelp=FALSE, WIcon * image=NULL,
  336.                         const WChar * text=NULL, WBool isPropertyTitle=FALSE,
  337.                         WInt startItemIndex=0,
  338.                         WPropertySheetInfo * infoArray=NULL,
  339.                         WInt numItems=0 );
  340.     
  341.         ~WPropertySheet();
  342.  
  343.         /**********************************************************
  344.          * Properties
  345.          *********************************************************/
  346.  
  347.         // ReturnValue
  348.  
  349.         WULong GetReturnValue() const;
  350.  
  351.         /**********************************************************
  352.          * Methods
  353.          *********************************************************/
  354.  
  355.         /**********************************************************
  356.          * Other
  357.          *********************************************************/
  358.  
  359.     protected:
  360.  
  361.         virtual WBool ProcessNotify( WUInt id, WNotify code, WNotifyInfo info,
  362.                                      WLong & returns );
  363.  
  364. };
  365.  
  366. #ifndef _WNO_PRAGMA_PUSH
  367. #pragma enum pop;
  368. #pragma pack(pop);
  369. #endif
  370.  
  371. #endif // _WPROPSHT_HPP_INCLUDED
  372.