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
00045 #ifndef ColorSwatch_TVIEW
00046 #define ColorSwatch_TVIEW
00047
00048 #include <Carbon/Carbon.h>
00049
00050 #include "TViewNoCompositingCompatible.h"
00051
00052 #define kFlavorTypeColor 'colr'
00053
00054 #define kControlSwatchColorTag 'colr'
00055
00056 OSStatus
00057 HIColorSwatchGetColor(
00058 ControlRef inControl,
00059 RGBColor* outColor );
00060
00061 OSStatus
00062 HIColorSwatchSetColor(
00063 ControlRef inControl,
00064 RGBColor inColor );
00065
00066
00067
00068 class ColorSwatch
00069 : public TViewNoCompositingCompatible
00070 {
00071 AUGUIDefineControl(ColorSwatch, TViewNoCompositingCompatible, "color");
00072 protected:
00073
00074 ColorSwatch(
00075 HIViewRef inControl );
00076 ~ColorSwatch();
00077
00078 ControlKind GetKind();
00079
00080
00081
00082 UInt32 GetBehaviors();
00083
00084 OSStatus GetData(
00085 OSType inTag,
00086 ControlPartCode inPart,
00087 Size inSize,
00088 Size* outSize,
00089 void* inPtr );
00090
00091 OSStatus SetData(
00092 OSType inTag,
00093 ControlPartCode inPart,
00094 Size inSize,
00095 const void* inPtr );
00096
00097 OSStatus ControlHit(
00098 ControlPartCode inPart,
00099 UInt32 inModifiers );
00100
00101 OSStatus Track(
00102 TCarbonEvent& inEvent,
00103 ControlPartCode* outPartHit );
00104
00105 void CompatibleDraw(RgnHandle inLimitRgn, CGContextRef inContext, bool inCompositing );
00106
00107 ControlPartCode HitTest(
00108 const HIPoint& inWhere );
00109
00110 OSStatus GetRegion(
00111 ControlPartCode inPart,
00112 RgnHandle outRgn );
00113
00114 OSStatus TextInput( TCarbonEvent& inEvent );
00115
00116 OSStatus GetSizeConstraints(
00117 HISize* outMin,
00118 HISize* outMax );
00119
00120 OSStatus GetOptimalSize(
00121 HISize* outSize,
00122 float* outBaseLine );
00123
00124
00125 bool DragEnter(
00126 DragRef inDrag );
00127
00128 bool DragLeave(
00129 DragRef inDrag );
00130
00131 OSStatus DragReceive(
00132 DragRef inDrag );
00133
00134 private:
00135 RGBColor fSwatchColor;
00136 float fAlpha;
00137 RgnHandle fSwatchRgn;
00138 bool fCanAcceptDrag;
00139
00140 void PerformColorDrag(
00141 EventRef inEvent );
00142
00143 bool GetColorFromDrag(
00144 DragRef inDragRef,
00145 RGBColor* inColor );
00146
00147 OSStatus SendColorChangedCommandEvent();
00148 };
00149
00150 typedef ColorSwatch* ColorSwatchPtr;
00151
00152 #endif // ColorSwatch_TVIEW