home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / samples / ioc / acdf2 / acdfvw2.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  3.7 KB  |  96 lines

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //                        SAMPLE CODE
  3. //
  4. // FileName: ACDFVw2.hpp
  5. //
  6. // ClassName: ACompDocFwkView
  7. //
  8. // Description: Compound Document Framework (SimpleServer) View
  9. //              This sample is to illustrates the use of notification and the use of
  10. //              keyboard, mouse and command handlers in the server application. When 
  11. //              a notification is recieved from the model, if the handleNotification method
  12. //              was NOT overridden the drawContents would have been called and the notification ID
  13. //              not checked. 
  14. //              In this case the handleNotification method was overridden as a result different data
  15. //              is set depending on the NotificationId
  16. //              The view contains 2 entry fields to allow the user to change the model data
  17. //              by entering the new data and hitting either newline or enter. Using the keyboard
  18. //              handler to trap these events.
  19. //              Doubleclick on either of the entry fields to change the string in MyObject 
  20. //              in the model, using the mouse handler trap this event.
  21. //              The pushbutton and the menu option perform the same function which is
  22. //              to update both the strings in the model.
  23. ///////////////////////////////////////////////////////////////////////////////
  24. #ifndef _COMPDOCFWK_VIEW_
  25. #define _COMPDOCFWK_VIEW_
  26.  
  27. #ifdef IC_TRACE_DEVELOP
  28.     #include <itrace.hpp>
  29. #else
  30.     #define IFUNCTRACE_DEVELOP()
  31.     #define ITRACE_DEVELOP(x)
  32. #endif
  33.  
  34. #include <iview.hpp>
  35.  
  36. #include <ipushbut.hpp>
  37. #include <ientryfd.hpp>
  38. #include <istattxt.hpp>
  39.  
  40. #include <icmdhdr.hpp>
  41. #include <ikeyhdr.hpp>
  42. #include <imoushdr.hpp>
  43.  
  44. class ACompDocFwkModel;
  45.  
  46. class ACompDocFwkView : public IView    //Inherits from the IView class
  47. {
  48. public:
  49.                                 ACompDocFwkView(IGUIBundle& );
  50.     virtual                     ~ACompDocFwkView();
  51.  
  52.     virtual void                initialize();
  53.  
  54.     // This is convenience function that downcast the model
  55.     virtual ACompDocFwkModel*    getModelPointer() const;
  56.  
  57.     // Two size methods overidde the view class to resize the screen 
  58.     virtual ACompDocFwkView&    sizeTo(const ISize& newSize);
  59.     virtual ACompDocFwkView&    moveSizeTo(const IRectangle& newRect);
  60.  
  61.     void                        drawContents( IPresSpaceHandle& hdl,
  62.                                             const IRectangle& invalidArea,
  63.                                             Boolean metaFile );
  64.     // handle functions
  65.             void                handleFileNew();
  66.  
  67.     virtual Boolean             handleMouseClicked(IMouseClickEvent&);
  68.     virtual Boolean             handleVirtualKeyPress(IKeyboardEvent&);
  69.  
  70.     virtual Boolean             handleButtonPressed(ICommandEvent&);
  71.  
  72.     virtual void                handleNotification( const INotificationEvent& );
  73.  
  74. protected:
  75.             void                SizeFieldsToScreen(const ISize&);
  76.  
  77.                                 ACompDocFwkView(const ACompDocFwkView&);
  78.  
  79. private:
  80.     ACompDocFwkView&            operator=( const ACompDocFwkView& );
  81.  
  82.     IPushButton                 fButton;
  83.     IStaticText                 fDataStaticField1;
  84.     IEntryField                 fDataEntryField1;
  85.     IStaticText                 fDataStaticField2;
  86.     IEntryField                 fDataEntryField2;
  87.     IStaticText                 fMyObjectField;
  88.  
  89.     // All the handlers                     
  90.     ICommandConnectionTo<ACompDocFwkView>   fButtonHandler;
  91.     IKeyboardConnectionTo<ACompDocFwkView>  fKeyboardHandler;
  92.     IMouseConnectionTo<ACompDocFwkView>     fMouseHandler;
  93. };
  94. #endif
  95.     
  96.