home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 October: Mac OS SDK / Dev.CD Oct 96 SDK / Dev.CD Oct 96 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / Framewrk / FWViews / Include / FWContrl.h < prev    next >
Encoding:
Text File  |  1996-08-16  |  6.7 KB  |  254 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWControl.h
  4. //    Release Version:    $ ODF 1 $
  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.              ODID viewId,
  94.              const FW_CRect& bounds,
  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_Boolean     AdjustCursor(Environment *ev, ODFacet* odFacet, const FW_CPoint& where);
  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.              ODID viewId,
  147.              const FW_CRect& bounds,
  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, const FW_CString& label, 
  158.                                                         FW_Boolean refresh = TRUE);
  159.  
  160.     void                 RedrawControl(Environment* ev);
  161.  
  162.     virtual void        ControlClicked(Environment *ev, FW_ControlValue value, ODFacet* facet) = 0;
  163.  
  164.     FW_PlatformHandle    GetPlatformControlHandle(Environment*ev) const;
  165.     
  166.     // ----- FW_CControl API -------
  167.     virtual void        SetValue(Environment* ev, FW_ControlValue value);
  168.     
  169.     // ----- FW_MEventHandler API
  170.     virtual FW_Boolean     DoMouseDown(Environment *ev, const FW_CMouseEvent& theMouseEvent);
  171.     virtual void          Disable(Environment* ev);
  172.     virtual void          Enable(Environment* ev);
  173.  
  174.     // ----- FW_CView API
  175.     virtual void         Draw(Environment* ev, ODFacet* facet, ODShape* invalidShape);
  176.     virtual void        LocationChanged(Environment* ev, const FW_CPoint& oldLocation);
  177.     virtual void        SizeChanged(Environment* ev, const FW_CPoint& oldSize);
  178.     virtual void        SetVisible(Environment* ev, FW_Boolean visible, 
  179.                                         FW_Boolean propagate = TRUE);
  180.  
  181.     // ----- Archiving -----
  182.     virtual void        Flatten(Environment*ev, FW_CWritableStream& stream) const;
  183.     virtual void        InitializeFromStream(Environment*ev, FW_CReadableStream& stream);
  184.  
  185. protected:
  186.     // ----- Internal use only
  187.     virtual FW_Boolean     PrivSetValue(Environment* ev, FW_ControlValue value, ODFacet* facet);
  188.  
  189. // ----- Private data -----
  190. protected:
  191. #ifdef FW_BUILD_MAC
  192.     FW_CPrivMacControlHelper*    fControlHelper;
  193. #endif
  194. #ifdef FW_BUILD_WIN
  195.     FW_CPrivWinControlHelper*    fControlHelper;
  196. #endif
  197.  
  198.     friend FW_CPrivMacControlHelper;
  199.     friend FW_CPrivWinControlHelper;
  200. };
  201.  
  202. //========================================================================================
  203. //    CLASS FW_CControlNotification
  204. //========================================================================================
  205.  
  206. class FW_CControlNotification : public FW_CNotification
  207. {
  208. public:
  209.     FW_DECLARE_CLASS
  210.  
  211.     FW_CControlNotification(FW_CControl* control, FW_Message inMsg = 0);
  212.     FW_CControlNotification(const FW_CControlNotification& other);
  213.     virtual            ~FW_CControlNotification();
  214.  
  215.     FW_CControlNotification&    operator=(const FW_CControlNotification& other);
  216.     
  217.     FW_CControl*        GetControl(Environment* ev) const;
  218.     ODID                GetViewId(Environment* ev) const;
  219.     
  220. private:
  221.     FW_CControl*        fControl;
  222. };
  223.  
  224.  
  225. //========================================================================================
  226. // Inlines for FW_CControl
  227. //========================================================================================
  228.  
  229. inline FW_ControlValue    FW_CControl::GetValue(Environment*) const
  230. {
  231.     return fValue;
  232. }
  233.  
  234. inline     FW_Message    FW_CControl::GetMessage(Environment*) const
  235. {
  236.     return fMessage;
  237. }
  238.  
  239. //========================================================================================
  240. // Inlines for FW_CControlNotification
  241. //========================================================================================
  242.  
  243. inline FW_CControl* FW_CControlNotification::GetControl(Environment*) const
  244. {
  245.     return fControl;
  246. }
  247.  
  248. inline     ODID    FW_CControlNotification::GetViewId(Environment* ev) const
  249. {
  250.     return fControl->GetViewId(ev);
  251. }
  252.  
  253. #endif
  254.