00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
#ifndef TView_H_
00045
#define TView_H_
00046
00047
#include <Carbon/Carbon.h>
00048
00049
#include "TObject.h"
00050
#include "TCarbonEvent.h"
00051
#include "TRect.h"
00052
00053 #define PURE_VIRTUAL 0
00054
00055 class TView
00056 :
public TObject
00057 {
00058
public:
00059
00060
void SetFrame(
00061
const HIRect& inBounds );
00062 HIRect
Frame();
00063 HIRect
Bounds();
00064
00065
void GetOptimalSize(
00066 HISize* outSize,
00067
float* outBaseLine );
00068
00069
00070
void Show();
00071
void Hide();
00072
00073 OSStatus
AddSubView(
00074
TView* inSubView );
00075 OSStatus
RemoveFromSuperView();
00076
00077
00078 HIViewRef
GetViewRef()
00079 {
return (HIViewRef)
GetObjectRef(); }
00080
void Hilite(
00081 ControlPartCode inPart );
00082 ControlPartCode
GetHilite();
00083 WindowRef
GetOwner();
00084 SInt32
GetValue();
00085
void SetValue(
00086 SInt32 inValue );
00087 SInt32
GetMinimum();
00088
void SetMinimum(
00089 SInt32 inMinimum );
00090 SInt32
GetMaximum();
00091
void SetMaximum(
00092 SInt32 inMaximum );
00093
00094
00095 Boolean
IsVisible();
00096 Boolean
IsEnabled();
00097 Boolean
IsActive();
00098
00099 OSStatus
Invalidate();
00100
00101
protected:
00102
00103
enum {
00104 kAutoInvalidateOnActivate = (1 << 0),
00105 kAutoInvalidateOnHilite = (1 << 1),
00106 kAutoInvalidateOnEnable = (1 << 2),
00107 kAutoInvalidateOnValueChange = (1 << 3),
00108 kAutoInvalidateOnTitleChange = (1 << 4)
00109 };
00110
void ChangeAutoInvalidateFlags(
00111 OptionBits inSetFlags,
00112 OptionBits inClearFlags );
00113 OptionBits
GetAutoInvalidateFlags()
00114 {
return fAutoInvalidateFlags; }
00115
00116
00117
TView(
00118 HIViewRef inView );
00119
virtual ~TView();
00120
00121
virtual ControlKind
GetKind() =
PURE_VIRTUAL;
00122
virtual UInt32
GetBehaviors();
00123
00124
00125
virtual void ActiveStateChanged();
00126
virtual void BoundsChanged(
00127 UInt32 inOptions,
00128
const HIRect& inOriginalBounds,
00129
const HIRect& inCurrentBounds );
00130
virtual void EnabledStateChanged();
00131
virtual void HiliteChanged(
00132 ControlPartCode inOriginalPart,
00133 ControlPartCode inCurrentPart );
00134
virtual void OwninmWindowChanged(
00135 WindowRef oldWindow,
00136 WindowRef newWindow );
00137
virtual void VisibilityChanged();
00138
virtual void TitleChanged();
00139
virtual void ValueChanged();
00140
00141
00142
00143
virtual OSStatus ControlHit(
00144 ControlPartCode inPart,
00145 UInt32 inModifiers );
00146
virtual void Draw(
00147 RgnHandle inLimitRgn,
00148 CGContextRef inContext );
00149
virtual OSStatus GetData(
00150 OSType inTag,
00151 ControlPartCode inPart,
00152 Size inSize,
00153 Size* outSize,
00154
void* inPtr );
00155
virtual OSStatus GetRegion(
00156 ControlPartCode inPart,
00157 RgnHandle outRgn );
00158
virtual ControlPartCode HitTest(
00159
const HIPoint& inWhere );
00160
virtual OSStatus SetData(
00161 OSType inTag,
00162 ControlPartCode inPart,
00163 Size inSize,
00164
const void* inPtr );
00165
virtual OSStatus SetFocusPart(
00166 ControlPartCode inDesiredFocus,
00167 Boolean inFocusEverything,
00168 ControlPartCode* outActualFocus );
00169
virtual OSStatus TextInput(
00170
TCarbonEvent& inEvent );
00171
virtual OSStatus Track(
00172
TCarbonEvent& inEvent,
00173 ControlPartCode* outPartHit );
00174
00175
00176
virtual OSStatus GetSizeConstraints(
00177 HISize* outMin,
00178 HISize* outMax );
00179
virtual OSStatus GetOptimalSizeSelf(
00180 HISize* outSize,
00181
float* outBaseLine );
00182
00183
00184 WindowRef
GetWindowRef()
00185 {
return GetControlOwner(
GetViewRef() ); }
00186
00187
00188
00189
virtual bool DragEnter(
00190 DragRef inDrag );
00191
virtual bool DragWithin(
00192 DragRef inDrag );
00193
virtual bool DragLeave(
00194 DragRef inDrag );
00195
virtual OSStatus DragReceive(
00196 DragRef inDrag );
00197
00198
00199
virtual OSStatus ProcessCommand(
00200
const HICommand& inCommand );
00201
virtual OSStatus UpdateCommandStatus(
00202
const HICommand& inCommand );
00203
00204
00205 static OSStatus
RegisterSubclass(
00206 CFStringRef inID,
00207 ConstructProc inProc )
00208 {
return TObject::RegisterSubclass( inID, kHIViewClassID, inProc ); }
00209
00210 enum Interface {
00211
kDragAndDrop = 1,
00212
kKeyboardFocus
00213 };
00214
virtual OSStatus ActivateInterface(
00215 Interface inInterface );
00216
00217
00218
virtual void PrintDebugInfoSelf();
00219
00220
private:
00221
static pascal OSStatus ViewEventHandler(
00222 EventHandlerCallRef inCallRef,
00223 EventRef inEvent,
00224
void* inUserData );
00225 OSStatus HandleEvent(
00226 EventHandlerCallRef inCallRef,
00227
TCarbonEvent& inEvent );
00228
00229 HIViewRef fViewRef;
00230 EventHandlerRef fHandler;
00231
00232 OptionBits fAutoInvalidateFlags;
00233 };
00234
00235 typedef TView*
TViewPtr;
00236
00237
#endif // TView_H_