home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 7.0 KB | 263 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWControl.h
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWCONTRL_H
- #define FWCONTRL_H
-
- // ----- Framewrk Layer -----
-
- #ifndef FWVIEW_H
- #include "FWView.h"
- #endif
-
- #if defined(FW_BUILD_WIN) && !defined(FWCNTRHW_H)
- #include "FWCntrHW.h"
- #endif
-
- #if defined(FW_BUILD_MAC) && !defined(FWCONTRH_H)
- #include "FWContrH.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- #ifndef FWRECT_H
- #include "FWRect.h"
- #endif
-
- // ----- Foundation Layer -----
-
- #ifndef FWNOTIFI_H
- #include "FWNotifi.h"
- #endif
-
- #ifndef FWNOTIFR_H
- #include "FWNotifr.h"
- #endif
-
- #ifndef FWEXCLIB_H
- #include "FWExcLib.h"
- #endif
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWRUNTYP_H
- #include "FWRunTyp.h"
- #endif
-
- //========================================================================================
- // Forward declarations
- //========================================================================================
-
- class FW_CPrivMacControlHelper;
- class FW_CPrivWinControlHelper;
- class FW_CMouseEvent;
- class FW_CViewContext;
- class FW_MReceiver;
-
- //========================================================================================
- // Type definitions
- //========================================================================================
-
- typedef long FW_ControlValue;
-
- //========================================================================================
- // class FW_CControl
- //========================================================================================
-
- class FW_CControl : public FW_CView, public FW_MNotifier
- {
- public:
- FW_DECLARE_CLASS
-
- // ----- Initialization/destruction
-
- public:
- virtual ~ FW_CControl();
-
- protected:
- // one-step initialization constructor
- FW_CControl(Environment* ev,
- FW_CSuperView* container,
- const FW_CRect& bounds,
- ODID viewID,
- FW_Message msg = 0,
- FW_ControlValue value = 0);
-
- // two-step initialization constructor
- FW_CControl(Environment* ev);
-
- public:
- // ----- New API -----
- FW_ControlValue GetValue(Environment* ev) const;
- virtual void SetValue(Environment* ev, FW_ControlValue value);
-
- FW_Message GetMessage(Environment* ev) const;
- void SetMessage(Environment* ev, FW_Message msg);
-
- virtual void LinkControlTo(Environment *ev, FW_MReceiver* receiver);
-
- // ----- View -----
- virtual FW_Handled AdjustCursor(Environment *ev, ODFacet* odFacet, const FW_CPoint& where, ODEventInfo* eventInfo);
-
- // ----- Archiving -----
- virtual void Flatten(Environment*ev, FW_CWritableStream& stream) const;
- virtual void InitializeFromStream(Environment*ev, FW_CReadableStream& stream);
-
- protected:
- // ----- Internal use only
- virtual FW_Boolean PrivSetValue(Environment* ev, FW_ControlValue value, ODFacet* facet);
-
- // ----- Private data -----
- protected:
- FW_Message fMessage;
- FW_ControlValue fValue;
- };
-
- //========================================================================================
- // class FW_CNativeControl
- //========================================================================================
-
- class FW_CNativeControl : public FW_CControl
- {
- public:
- FW_DECLARE_CLASS
-
- // ----- Initialization/destruction
-
- public:
- virtual ~FW_CNativeControl();
-
- protected:
- // one-step initialization constructor
- FW_CNativeControl(Environment* ev,
- FW_CSuperView* container,
- const FW_CRect& bounds,
- ODID viewID,
- FW_Message msg = 0,
- FW_ControlValue value = 0);
-
- // two-step initialization constructor
- FW_CNativeControl(Environment* ev);
-
- public:
- // ----- New API -----
- void GetLabel(Environment* ev, FW_CString& label);
- void SetLabel(Environment* ev,
- const FW_CString& label,
- FW_ERedrawVerb redraw = FW_kInvalidate);
-
- void RedrawControl(Environment* ev);
-
- virtual void ControlClicked(Environment *ev, FW_ControlValue value, ODFacet* facet) = 0;
-
- FW_PlatformHandle GetPlatformControlHandle(Environment*ev) const;
-
- // ----- FW_CControl API -------
- virtual void SetValue(Environment* ev, FW_ControlValue value);
-
- // ----- FW_MEventHandler API
- virtual FW_Handled DoMouseDown(Environment *ev, const FW_CMouseEvent& theMouseEvent);
- virtual void Disable(Environment* ev);
- virtual void Enable(Environment* ev);
-
- // ----- FW_CView API
- virtual void Draw(Environment* ev, ODFacet* facet, ODShape* invalidShape);
- virtual void LocationChanged(Environment* ev, const FW_CPoint& oldLocation);
- virtual void SizeChanged(Environment* ev, const FW_CPoint& oldSize);
- virtual void SetVisible(Environment* ev, FW_Boolean visible,
- FW_Boolean propagate = TRUE);
-
- // ----- Archiving -----
- virtual void Flatten(Environment*ev, FW_CWritableStream& stream) const;
- virtual void InitializeFromStream(Environment*ev, FW_CReadableStream& stream);
-
- protected:
- // ----- Internal use only
- virtual FW_Boolean PrivSetValue(Environment* ev, FW_ControlValue value, ODFacet* facet);
-
- // ----- Private data -----
- protected:
- #ifdef FW_BUILD_MAC
- FW_CPrivMacControlHelper* fControlHelper;
- #endif
- #ifdef FW_BUILD_WIN
- FW_CPrivWinControlHelper* fControlHelper;
- #endif
-
- friend FW_CPrivMacControlHelper;
- friend FW_CPrivWinControlHelper;
- };
-
- //========================================================================================
- // CLASS FW_CControlNotification
- //========================================================================================
-
- class FW_CControlNotification : public FW_CNotification
- {
- public:
- FW_DECLARE_CLASS
-
- FW_CControlNotification(FW_CControl* control, FW_Message inMsg = 0);
- FW_CControlNotification(const FW_CControlNotification& other);
- virtual ~FW_CControlNotification();
-
- FW_CControlNotification& operator=(const FW_CControlNotification& other);
-
- FW_Boolean operator==(const FW_CControlNotification& other) const;
- FW_Boolean operator!=(const FW_CControlNotification& other) const;
-
- FW_CControl* GetControl(Environment* ev) const;
- ODID GetViewID(Environment* ev) const;
-
- private:
- FW_CControl* fControl;
- };
-
-
- //========================================================================================
- // Inlines for FW_CControl
- //========================================================================================
-
- inline FW_ControlValue FW_CControl::GetValue(Environment*) const
- {
- return fValue;
- }
-
- inline FW_Message FW_CControl::GetMessage(Environment*) const
- {
- return fMessage;
- }
-
- //========================================================================================
- // Inlines for FW_CControlNotification
- //========================================================================================
-
- inline FW_CControl* FW_CControlNotification::GetControl(Environment*) const
- {
- return fControl;
- }
-
- inline ODID FW_CControlNotification::GetViewID(Environment* ev) const
- {
- return fControl->GetViewID(ev);
- }
-
- inline FW_Boolean FW_CControlNotification::operator!=(const FW_CControlNotification& other) const
- {
- return !(*this == other);
- }
-
- #endif
-