home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / Framewrk / FWViews / FWContrl.h < prev    next >
Encoding:
Text File  |  1996-09-17  |  7.0 KB  |  263 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWControl.h
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:            (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWCONTRL_H
  11. #define FWCONTRL_H
  12.  
  13. // ----- Framewrk Layer -----
  14.  
  15. #ifndef FWVIEW_H
  16. #include "FWView.h"
  17. #endif
  18.  
  19. #if defined(FW_BUILD_WIN) && !defined(FWCNTRHW_H)
  20. #include "FWCntrHW.h"
  21. #endif
  22.  
  23. #if defined(FW_BUILD_MAC) && !defined(FWCONTRH_H)
  24. #include "FWContrH.h"
  25. #endif
  26.  
  27. // ----- OS Layer -----
  28.  
  29. #ifndef FWPOINT_H
  30. #include "FWPoint.h"
  31. #endif
  32.  
  33. #ifndef FWRECT_H
  34. #include "FWRect.h"
  35. #endif
  36.  
  37. // ----- Foundation Layer -----
  38.  
  39. #ifndef FWNOTIFI_H
  40. #include "FWNotifi.h"
  41. #endif
  42.  
  43. #ifndef FWNOTIFR_H
  44. #include "FWNotifr.h"
  45. #endif
  46.  
  47. #ifndef FWEXCLIB_H
  48. #include "FWExcLib.h"
  49. #endif
  50.  
  51. #ifndef FWUTIL_H
  52. #include "FWUtil.h"
  53. #endif
  54.  
  55. #ifndef FWRUNTYP_H
  56. #include "FWRunTyp.h"
  57. #endif
  58.  
  59. //========================================================================================
  60. // Forward declarations
  61. //========================================================================================
  62.  
  63. class FW_CPrivMacControlHelper;
  64. class FW_CPrivWinControlHelper;
  65. class FW_CMouseEvent;
  66. class FW_CViewContext;
  67. class FW_MReceiver;
  68.  
  69. //========================================================================================
  70. //  Type definitions
  71. //========================================================================================
  72.  
  73. typedef long    FW_ControlValue;
  74.  
  75. //========================================================================================
  76. // class FW_CControl
  77. //========================================================================================
  78.  
  79. class FW_CControl :  public FW_CView, public FW_MNotifier
  80. {
  81. public:
  82.     FW_DECLARE_CLASS
  83.  
  84. // ----- Initialization/destruction
  85.  
  86. public:
  87.     virtual ~ FW_CControl();
  88.  
  89. protected:
  90.     // one-step initialization constructor
  91.     FW_CControl(Environment* ev, 
  92.              FW_CSuperView* container, 
  93.              const FW_CRect& bounds,
  94.              ODID viewID,
  95.              FW_Message msg = 0,
  96.              FW_ControlValue value = 0);
  97.  
  98.     // two-step initialization constructor
  99.     FW_CControl(Environment* ev);
  100.  
  101. public:
  102.     // ----- New API -----
  103.     FW_ControlValue            GetValue(Environment* ev) const;
  104.     virtual void            SetValue(Environment* ev, FW_ControlValue value);
  105.  
  106.     FW_Message                GetMessage(Environment* ev) const;
  107.     void                    SetMessage(Environment* ev, FW_Message msg);
  108.  
  109.     virtual void            LinkControlTo(Environment *ev, FW_MReceiver* receiver);
  110.     
  111.     // ----- View -----
  112.     virtual FW_Handled        AdjustCursor(Environment *ev, ODFacet* odFacet, const FW_CPoint& where, ODEventInfo* eventInfo);
  113.  
  114.     // ----- Archiving -----
  115.     virtual void            Flatten(Environment*ev, FW_CWritableStream& stream) const;
  116.     virtual void            InitializeFromStream(Environment*ev, FW_CReadableStream& stream);
  117.     
  118. protected:
  119.     // ----- Internal use only
  120.     virtual FW_Boolean         PrivSetValue(Environment* ev, FW_ControlValue value, ODFacet* facet);
  121.     
  122. // ----- Private data -----
  123. protected:
  124.     FW_Message                fMessage;
  125.     FW_ControlValue            fValue;
  126. };
  127.  
  128. //========================================================================================
  129. // class FW_CNativeControl
  130. //========================================================================================
  131.  
  132. class FW_CNativeControl :  public FW_CControl
  133. {
  134. public:
  135.     FW_DECLARE_CLASS
  136.  
  137. // ----- Initialization/destruction
  138.  
  139. public:
  140.     virtual ~FW_CNativeControl();
  141.  
  142. protected:
  143.     // one-step initialization constructor
  144.     FW_CNativeControl(Environment* ev, 
  145.              FW_CSuperView* container, 
  146.              const FW_CRect& bounds,
  147.              ODID viewID,
  148.              FW_Message msg = 0,
  149.              FW_ControlValue value = 0);
  150.  
  151.     // two-step initialization constructor
  152.     FW_CNativeControl(Environment* ev);
  153.  
  154. public:
  155.     // ----- New API -----
  156.     void                GetLabel(Environment* ev, FW_CString& label);
  157.     void                SetLabel(Environment* ev, 
  158.                                 const FW_CString& label, 
  159.                                 FW_ERedrawVerb redraw = FW_kInvalidate);
  160.  
  161.     void                 RedrawControl(Environment* ev);
  162.  
  163.     virtual void        ControlClicked(Environment *ev, FW_ControlValue value, ODFacet* facet) = 0;
  164.  
  165.     FW_PlatformHandle    GetPlatformControlHandle(Environment*ev) const;
  166.     
  167.     // ----- FW_CControl API -------
  168.     virtual void        SetValue(Environment* ev, FW_ControlValue value);
  169.     
  170.     // ----- FW_MEventHandler API
  171.     virtual FW_Handled DoMouseDown(Environment *ev, const FW_CMouseEvent& theMouseEvent);
  172.     virtual void          Disable(Environment* ev);
  173.     virtual void          Enable(Environment* ev);
  174.  
  175.     // ----- FW_CView API
  176.     virtual void         Draw(Environment* ev, ODFacet* facet, ODShape* invalidShape);
  177.     virtual void        LocationChanged(Environment* ev, const FW_CPoint& oldLocation);
  178.     virtual void        SizeChanged(Environment* ev, const FW_CPoint& oldSize);
  179.     virtual void        SetVisible(Environment* ev, FW_Boolean visible, 
  180.                                         FW_Boolean propagate = TRUE);
  181.  
  182.     // ----- Archiving -----
  183.     virtual void        Flatten(Environment*ev, FW_CWritableStream& stream) const;
  184.     virtual void        InitializeFromStream(Environment*ev, FW_CReadableStream& stream);
  185.  
  186. protected:
  187.     // ----- Internal use only
  188.     virtual FW_Boolean     PrivSetValue(Environment* ev, FW_ControlValue value, ODFacet* facet);
  189.  
  190. // ----- Private data -----
  191. protected:
  192. #ifdef FW_BUILD_MAC
  193.     FW_CPrivMacControlHelper*    fControlHelper;
  194. #endif
  195. #ifdef FW_BUILD_WIN
  196.     FW_CPrivWinControlHelper*    fControlHelper;
  197. #endif
  198.  
  199.     friend FW_CPrivMacControlHelper;
  200.     friend FW_CPrivWinControlHelper;
  201. };
  202.  
  203. //========================================================================================
  204. //    CLASS FW_CControlNotification
  205. //========================================================================================
  206.  
  207. class FW_CControlNotification : public FW_CNotification
  208. {
  209. public:
  210.     FW_DECLARE_CLASS
  211.  
  212.     FW_CControlNotification(FW_CControl* control, FW_Message inMsg = 0);
  213.     FW_CControlNotification(const FW_CControlNotification& other);
  214.     virtual    ~FW_CControlNotification();
  215.  
  216.     FW_CControlNotification& operator=(const FW_CControlNotification& other);
  217.     
  218.     FW_Boolean    operator==(const FW_CControlNotification& other) const;
  219.     FW_Boolean    operator!=(const FW_CControlNotification& other) const;
  220.     
  221.     FW_CControl*        GetControl(Environment* ev) const;
  222.     ODID                GetViewID(Environment* ev) const;
  223.  
  224. private:
  225.     FW_CControl*        fControl;
  226. };
  227.  
  228.  
  229. //========================================================================================
  230. // Inlines for FW_CControl
  231. //========================================================================================
  232.  
  233. inline FW_ControlValue FW_CControl::GetValue(Environment*) const
  234. {
  235.     return fValue;
  236. }
  237.  
  238. inline     FW_Message FW_CControl::GetMessage(Environment*) const
  239. {
  240.     return fMessage;
  241. }
  242.  
  243. //========================================================================================
  244. // Inlines for FW_CControlNotification
  245. //========================================================================================
  246.  
  247. inline FW_CControl* FW_CControlNotification::GetControl(Environment*) const
  248. {
  249.     return fControl;
  250. }
  251.  
  252. inline     ODID FW_CControlNotification::GetViewID(Environment* ev) const
  253. {
  254.     return fControl->GetViewID(ev);
  255. }
  256.  
  257. inline FW_Boolean FW_CControlNotification::operator!=(const FW_CControlNotification& other) const
  258. {
  259.     return !(*this == other);
  260. }
  261.  
  262. #endif
  263.