home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Add-Ons / XCMDs / XCMDTools++ / xcmdWind.h < prev   
Encoding:
C/C++ Source or Header  |  1995-10-05  |  3.9 KB  |  90 lines  |  [TEXT/CWIE]

  1. #pragma    once
  2. #include    "xcmdBase.h"
  3. #include    "xcmdStrings.h"
  4.  
  5. //    © Paul B. Beeken, Work In Progress, 1994-5
  6. //    Knowledge Software Consulting.
  7. //
  8. //    These files are a mindlessly simple wrapper class for the
  9. //    basic XCMD operations.  Only one instance of the xcmdBase class is
  10. //    generated per XCMD call but there may be many instances of the XCMDString
  11. //    class.  I have used these classes to whip out XCMD/XFCNs within hours of
  12. //    receiving the specs.  They work great for me but I will always consider 
  13. //    suggestions.
  14. //
  15. //    Please, please, please, in the unlikely event you should use this stuff
  16. //    for some commercial application I would appreciate you contacting me.  If
  17. //    its for your own use, use away. Send email: knowsoft@ios.com
  18. //
  19. //    As always: this file is presented as is with no warrantees expressed or implied.
  20. //    Swim at your own risk, etc. etc.
  21.  
  22. //
  23. //    This is the base class for all Xwindow objects.
  24. //        It is a decendant of the xcmdBase because, while there doesn't seem
  25. //        to be any specific prohibition to multiple windows per xcmd, it is a
  26. //        practical limitation.  HC only maintains one windowPtr per xcmd call.
  27. //        Thus when I handle operations I can only deal with one window at a time.
  28. //        N.B. there can be multiple windows through multiple calls for the xcmd
  29. //        to open windows.  The result of this is that the xcmd event called is for
  30. //        the front most window.  The xcmd must either limit the windows or not assume
  31. //        anything about the state of the window when the event call is made.
  32. //
  33. //    The idea is to override most of the default actions listed below.
  34.  
  35. class    xcmdWindow : public xcmdBase    {
  36.  
  37.     public:
  38.     
  39.         xcmdWindow( XCmdPtr xP, Boolean lockParams=false );
  40.         ~xcmdWindow( void );
  41.         
  42.             // Test for establishing if we are a toolbox "event."
  43.         Boolean        isWindowEvent( void )            { return xEventInfo != nil; }
  44.             // This is the entry point for handling events.
  45.         void        doWindowEvent( void );
  46.             // This is a tool to help open windows
  47.         CWindowPtr    createWindow( short rID, ResType rType='WIND', Boolean floating=false );
  48.  
  49.     protected:
  50.         // These functions must be used with great care.
  51.         // I don't check to see if the xEvent pointer is valid.
  52.         CWindowPtr        getXWindow( void );
  53.         void*            getXEventParam( int i );
  54.         void            setXEventResult( xcmdString* rv );
  55.         EventRecord*    getXEvent( void );
  56.         
  57.         Handle            getPrivateStorage( void )        { return xPrivStore; }
  58.         void            setPrivateStorage( Handle h )    { xPrivStore = h; }
  59.         
  60.         // These are the default actions for the window. most do nothing.
  61.         //    client should override these with special features.
  62.         virtual    void        doOpenWindow( void );            // Window is openning, initialize
  63.         virtual    void        doCloseWindow( void );            // Window is closing, clean up
  64.         virtual    void        doEditEvent( short what );        // Handle events relating to editing.
  65.  
  66.         virtual    void        doMenuUpdate( void );            // A menuBar click, set up menus
  67.         virtual    void        doMenuClick( long m, long i );    // A menu click
  68.         
  69.         virtual    void        doMessage( const xcmdString& msg );    // a send message to window...
  70.         
  71.         virtual    void        doSetProperty( const xcmdString& prop, const xcmdString& val );    // set a window property
  72.         virtual    xcmdString*    doGetProperty( const xcmdString& prop );    // get a window property (nil returned if invalid request)
  73.         virtual    void        doSetCursor( void );                        // cursor is within the window */
  74.  
  75.         // These are the default actions for the standard event switches
  76.         //    notice that this list is not exhaustive.  If you wish to respond to other
  77.         //    events you need to supercede the doWindowEvent member above and handle the other
  78.         //    events.
  79.         virtual void        doAcitveWindow( Boolean activating );    
  80.         virtual void        doUpdateWindow( void );    
  81.         virtual void        doDrawWindow( void );
  82.  
  83.     private:
  84.         GrafPtr            oldXPort;        // copy of current port
  85.         XWEventInfoPtr    xEventInfo;        // the original XEvent ptr or nil if none.
  86.         Handle            xPrivStore;        // handle to "permanent" storage
  87.         CWindowPtr        xWindow;        // we are always a color window
  88.         EventRecord        xEvent;            // the event record
  89.  
  90.     };