home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-16 | 7.1 KB | 220 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWContrH.h
- // Release Version: $ ODF 1 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #if defined(FW_BUILD_MAC) && !defined(FWCONTRH_H)
- #define FWCONTRH_H
-
- // ----- OS Layer -----
-
- #ifndef FWRECT_H
- #include "FWRect.h"
- #endif
-
- // ----- Macintosh Includes -----
-
- #if defined(FW_BUILD_MAC) && !defined(__CONTROLS__)
- #include <Controls.h>
- #endif
-
- //========================================================================================
- // Forward declarations
- //========================================================================================
-
- class FW_CNativeControl;
- class FW_CFont;
- class FW_CScrollBar;
- class FW_CPopupMenu;
- class FW_CString;
- class FW_SPrivControlOwner;
- class ODFacet;
- class FW_CAcquireCFMResourceAccess;
- class FW_CViewContext;
-
- //========================================================================================
- // CLASS FW_CPrivMacControlHelper
- //========================================================================================
-
- class FW_CPrivMacControlHelper
- {
- public:
- // FW_DECLARE_CLASS
-
- // ----- Initialization/destruction
- public:
- FW_CPrivMacControlHelper(Environment* ev, FW_CNativeControl* control,
- short value, short min,
- short max, short procID,
- const Str255 label,
- const FW_CFont& font,
- long refCon = 0);
- virtual ~FW_CPrivMacControlHelper();
-
- public:
- ControlHandle GetControlHandle() const;
-
- void SetControlMargin(short margin);
-
- void SetBounds(const FW_CPlatformRect& controlBounds);
- void GetBounds(FW_CPlatformRect& controlBounds) const;
-
- void SetValue(short value,
- const FW_CPlatformPoint& location,
- const FW_CPlatformPoint& size);
- void SetValue(short value, FW_Boolean drawNow);
- short GetValue() const;
- void SetMin(short min);
- short GetMin() const;
- void SetMax(short max);
- short GetMax() const;
- void SetText(const FW_CString& text);
- void GetText(FW_CString& text) const;
-
- FW_CNativeControl* GetControl() const;
-
- void Draw(Environment* ev,
- ODFacet* facet,
- const FW_CPlatformPoint& location,
- const FW_CPlatformPoint& size);
- void Print(Environment* ev, ODFacet* facet,
- const FW_CPlatformPoint& location,
- const FW_CPlatformPoint& size);
- void Enable(FW_Boolean enabled, const FW_CPlatformPoint& location,
- const FW_CPlatformPoint& size);
- void Enable(FW_Boolean enabled);
- void Show(const FW_CPlatformPoint& location,
- const FW_CPlatformPoint& size);
- void Show();
- void Hide();
- Boolean MouseDown(Environment* ev, const FW_CViewContext& vc,
- const FW_CPlatformPoint& whereMouse);
- void SimulateButtonPressed(const FW_CPlatformPoint& location,
- const FW_CPlatformPoint& size);
-
- virtual FW_Boolean PartCodeSwitch(Environment* ev,
- const FW_CViewContext& vc,
- const FW_CPlatformPoint& whereMouse,
- short partCode);
-
- private:
- void Initialize(Environment* ev, short value, short min, short max,
- const Str255 label, const FW_CFont& font, long refCon);
-
- void DrawControl(Environment* ev, ODFacet* facet);
- void SetupControl(const FW_CPlatformPoint& location,
- const FW_CPlatformPoint& size);
-
- FW_CAcquireCFMResourceAccess* OpenResFileForPopup(Environment* ev);
-
- protected:
- FW_CNativeControl* fControl;
- ControlHandle fControlHandle; // Mac control
- short fControlMargin; // Used for drawing default button
- short fMacProcId;
- short fMacFontId; // = 0 if controls uses default font
- short fMacFontStyle;
- short fMacFontSize;
- };
-
- //========================================================================================
- // CLASS FW_CPrivMacScrollBarControlHelper
- //========================================================================================
-
- class FW_CPrivMacScrollBarControlHelper : public FW_CPrivMacControlHelper
- {
- public:
- FW_CPrivMacScrollBarControlHelper(Environment* ev,
- FW_CNativeControl* control,
- short value,
- short min,
- short max,
- long refCon = 0);
- virtual ~FW_CPrivMacScrollBarControlHelper();
-
- virtual FW_Boolean PartCodeSwitch(Environment* ev,
- const FW_CViewContext& vc,
- const FW_CPlatformPoint& whereMouse,
- short partCode);
-
- private:
- static pascal void CallActionProc(ControlHandle controlHandle, short partCode);
- void ActionProc(short partCode);
-
- private:
- ODFacet* fFacet;
- };
-
- //========================================================================================
- // Inlines
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivMacControlHelper::GetControlHandle
- //----------------------------------------------------------------------------------------
-
- inline ControlHandle FW_CPrivMacControlHelper::GetControlHandle() const
- {
- return fControlHandle;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivMacControlHelper::GetBounds
- //----------------------------------------------------------------------------------------
-
- inline void FW_CPrivMacControlHelper::GetBounds(FW_CPlatformRect& controlBounds) const
- {
- controlBounds = (*fControlHandle)->contrlRect;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivMacControlHelper::GetValue
- //----------------------------------------------------------------------------------------
-
- inline short FW_CPrivMacControlHelper::GetValue() const
- {
- return ::GetControlValue(fControlHandle);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivMacControlHelper::GetMin
- //----------------------------------------------------------------------------------------
-
- inline short FW_CPrivMacControlHelper::GetMin() const
- {
- return ::GetControlMinimum(fControlHandle);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivMacControlHelper::GetMax
- //----------------------------------------------------------------------------------------
-
- inline short FW_CPrivMacControlHelper::GetMax() const
- {
- return ::GetControlMaximum(fControlHandle);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivMacControlHelper::GetControl
- //----------------------------------------------------------------------------------------
-
- inline FW_CNativeControl* FW_CPrivMacControlHelper::GetControl() const
- {
- return fControl;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivMacControlHelper::SetControlMargin
- //----------------------------------------------------------------------------------------
-
- inline void FW_CPrivMacControlHelper::SetControlMargin(short controlMargin)
- {
- fControlMargin = controlMargin;
- }
-
- #endif
-