ColourPicker Class Reference

Encapsulates OS-specific colour picker dialogue system, giving a kernel interface for using whatever colour picker(s) are available. More...

#include <colpick.h>

Inheritance diagram for ColourPicker:

CCObject SimpleCCObject List of all members.

Public Member Functions

 ColourPicker ()
 Creates a colourpicker object Scope: private.
 ~ColourPicker ()
 Destructor for a Colour Picker Scope: private.
void EditColour (ColourList *ParentList, IndexedColour *SourceAndResult, BOOL PreferLineColour=FALSE)
 Converts a ColourValue (0.0 to 1.0) into a byte (0..255) with clipping to handle out-of-gamut values.The main colour picker function. Given an IndexedColour, sets up a colour picker showing that colour, allows the user to edit it, and returns the new colour in said IndexedColour. If the colour is changed, an appropriate ColourChangingMsg will be broadcast.

Static Public Member Functions

static BOOL GetStatusLineText (String_256 *Result)
static void UpdateBubbleHelpAndPointer (void)
 Called on Idle (or MouseMove) events to provide bubble help and update the mouse pointer while it is over the colour editor dialogue.
static void SetBubbleHelp (CGadgetID *GadgetList)
 Set all the bubble help up for the colour picker.

Static Protected Member Functions

static BOOL GetStatusLineText (ColourEditDlg *Editor, UINT32 GadgetID, String_256 *Result)
 Bodge to get around the fact that DialogOps don't plug into the status line help system. Returns help for the colour editor. Must go via the winoil, as we have to read the mouse position and find the window it's in.
static TCHARHelpCallbackHandler (CWindowID Window, UINT32 Item, void *UserData)
 Help callback handler to provide bubble help for the colour editor.
static BOOL GetComponentHelp (ColourContext *const pSourceContext, const UINT32 ComponentIndex, StringBase &HelpString)
 Subprocedure for HelpCallbackHandler providing help for each of the colour components.
static BOOL GetComponentAsString (IndexedColour *Source, ColourContext *DestContext, INT32 ComponentIndex, String_8 *Result)
 Retrieves the colour definition of the given colour, converts it to the given colour model, and returns the desired component of the definition in that model as a decimal string appropriate for placing into a colour editor dialogue gadget.
static BOOL GetComponentsAsHexString (IndexedColour *Source, ColourContext *DestContext, INT32 ComponentIndex, String_16 *Result)
 Retrieves the colour definition of the given colour, converts it to the given colour model, and returns the combined value of all components of the definition in that model as a hexadecimal string appropriate for placing into a colour editor dialogue gadget.
static BOOL SetComponentFromString (IndexedColour *Dest, ColourContext *SourceContext, INT32 ComponentIndex, String_8 *NewValue)
 Converts AND COERCES the colour into the destination context. Assumes that the string will be 0..100 (or 0..360 for HSV) Clips the string value into a 0.0 to 1.0 in-gamut range, and then sets the given component of the converted colour to that value. This thus changes the colour model in which the colour is defined as well as the component value.
static BOOL SetComponentsFromHexString (IndexedColour *Dest, ColourContext *SourceContext, String_16 *NewValue)
 Converts AND COERCES the colour into the destination context. Assumes that the string will in hex format (i.e rrggbb or 0xrrggbb) Clips the string value into 0.0 to 1.0 in-gamut ranges, and then sets the components of the converted colour to those values. This thus changes the colour model in which the colour is defined as well as the component value.
static BOOL IsValidHexString (String_16 Hex)
 Internal helper function for ColourPicker::SetComponentsFromHexString () UNLESS YOU KNOW WHAT YOUR DOING - DON'T CALL THIS AS IT ONLY EXISTS TO HELP THE FORE-MENTIONED FUNCTION - AND I CANNOT SEE WHY YOUR CALLING THIS FROM ELSEWHERE ANYWAY !!!!
static BOOL SetComponentFromDouble (IndexedColour *Dest, ColourContext *SourceContext, INT32 ComponentIndex, double NewValue)
 Converts AND COERCES the colour into the destination context. Clips the new value into a 0.0 to 1.0 in-gamut range, and then sets the given component of the converted colour to that value.
static void ForceColourModel (IndexedColour *Dest, ColourContext *SourceContext)
 COERCES the colour into the destination context. This ensures that the colour is defined in the given context's colour model, converting its definition if necessary.
static BOOL GetTintAsString (IndexedColour *Source, StringBase *Result)
 Retrieves the tint of the given colour as a decimal string appropriate for placing into a colour editor dialogue gadget.
static BOOL SetTintFromString (IndexedColour *Dest, StringBase *NewValue)
 Assumes that the string will be 0..100 Clips the string value into a 0.0 to 1.0 in-gamut range, and then sets the tint component of the converted colour to that value.
static BOOL GetShadeValueAsString (IndexedColour *Source, INT32 ValueIndex, StringBase *Result)
 Retrieves the shade of the given colour as a decimal string appropriate for placing into a colour editor dialogue gadget.
static BOOL SetShadeFromStrings (IndexedColour *Dest, StringBase *NewValueX, StringBase *NewValueY)
 Assumes that the string will be -100..100 Clips the string value into a -1.0 to 1.0 in-gamut range, and then sets the shade components of the converted colour to those values.
static void SetWindowExtent (CWindowID WindowID, CGadgetID XGadgetID, CGadgetID YGadgetID)
 Private function used by the kernel ColourEditDlg editor. Given a WindowID and GadgetID (cf DialogOp->DialogMgr interface), this sets the window extent of the window to a short distance outside the right/ bottom edges of the X/Y named gadgets respectively.
static void SetGadgetPositions (CWindowID WindowID, CGadgetID *Gadgets, CGadgetID MoveUnder)
 Private function used by the kernel ColourEditDlg editor. Given a WindowID and GadgetIDs (cf DialogOp->DialogMgr interface), this moves all the gadgets such that (a) All the gadgets in the group remain in the same relative positions, and (b) the Gadgets[0] gadget is moved to lie just underneath the MoveUnder gadget.
static void SetComponentGadgets (CWindowID WindowID, CGadgetID *Gadgets, CGadgetID PickerGadget, ColourModel ModelToDisplay)
 Private function used by the kernel ColourEditDlg editor.
static void SetFixedComponentGadgets (CWindowID WindowID, CGadgetID *Gadgets, CGadgetID PickerGadget, ColourModel ModelToDisplay, INT32 TextWidth[], INT32 EditWidth[])
 Private function used by the kernel ColourEditDlg editor.
static void RelayoutDialog (CWindowID WindowID)
 Ensure the dialog is a sensible size Scope: Protected.
static void OnSize (CWindowID WindowID)
 Respond to size events Scope: Protected.
static void RecursiveBestSize (wxWindow *pwxWindow)
 Initialize platform dependent resources.
static BOOL OnIdleEvent (CWindowID WindowID)
 Respond idle events Scope: Protected.
static void OnCreate (CWindowID WindowID)
 Respond to size events Scope: Protected.
static void ArtificialSizeEvents (CWindowID WindowID)
 Produce artificial size events recursively Scope: Protected.

Static Private Attributes

static wxSize s_LastSize = wxDefaultSize
static wxSize s_UserSize = wxSize(245,245)
static wxSize s_MinSize = wxSize(180,100)
static BOOL s_InColourDialogLayout = FALSE
static BOOL s_JustCreated = FALSE
static INT32 s_IdleCounter = 0

Friends

class ColourEditDlg
class ColourLinkDlg
class NewColourDlg

Detailed Description

Encapsulates OS-specific colour picker dialogue system, giving a kernel interface for using whatever colour picker(s) are available.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/5/95
Given a (named or unnamed) IndexedColour, a Colour Picker somehow provides a user interface to change it, and returns the colour, cleaner and brighter than you ever thought possible, and for only about the same price as you'd expect to pay for an inferior colour picker. 1 out of 10 home economists prefer our colour picker to all others.

This class also provides secrel-squirrel interfaces for doing rather horrendous direct-pokey Coloue Editor things to IndexedColours. These are only available to our friend editor dialogue classes.

Friends: ColourEditDlg; ColourLinkDlg

See also:
IndexedColour; ColourEditDlg; ColourLinkDlg

Definition at line 138 of file colpick.h.


Constructor & Destructor Documentation

ColourPicker::ColourPicker  ) 
 

Creates a colourpicker object Scope: private.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/5/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 166 of file colpick.cpp.

00167 {
00168 }

ColourPicker::~ColourPicker  ) 
 

Destructor for a Colour Picker Scope: private.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/5/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 188 of file colpick.cpp.

00189 {
00190 }


Member Function Documentation

void ColourPicker::ArtificialSizeEvents CWindowID  WindowID  )  [static, protected]
 

Produce artificial size events recursively Scope: Protected.

Author:
Alex Bligh
Date:
30/5/2005
Parameters:
- [INPUTS]
On GTK at least, sizing does not occur synchronously. Some of it happens on size events from a gtk_window_size_callback. For various reasons (like the necessity for a wxyield) this is not great). So we produce them ourselves.

Definition at line 3006 of file colpick.cpp.

03007 {
03008     if (!WindowID->IsShown())
03009         return;
03010 
03011     // size children first
03012     wxWindowList::Node * pNode = WindowID->GetChildren().GetFirst();
03013     while (pNode)
03014     {
03015         ArtificialSizeEvents(pNode->GetData());
03016         pNode = pNode->GetNext();
03017     }
03018 
03019     wxSizeEvent event( WindowID->GetSize(), WindowID->GetId() );
03020     event.SetEventObject( WindowID );
03021     WindowID->GetEventHandler()->ProcessEvent( event );
03022 }

void ColourPicker::EditColour ColourList ParentList,
IndexedColour SourceAndResult,
BOOL  PreferLineColour = FALSE
 

Converts a ColourValue (0.0 to 1.0) into a byte (0..255) with clipping to handle out-of-gamut values.The main colour picker function. Given an IndexedColour, sets up a colour picker showing that colour, allows the user to edit it, and returns the new colour in said IndexedColour. If the colour is changed, an appropriate ColourChangingMsg will be broadcast.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/5/94
Parameters:
ParentList - The list in which the colour resides [INPUTS] May be NULL if you want to just show the picker for whatever local colour is appropriate. SourceAndResult must also be NULL in this case
SourceAndResult - The colour to be edited. If the user changes the colour, this will be set to the new definition. May be NULL if you want to just show the picker for whatever local colour is appropriate. ParentList must also be NULL in this case

PreferLineColour - TRUE if you'd like to edit line colours rather than fill colours in local mode, FALSE to edit fill colours. This flag is ignored unless ParentList == SourceAndResult == NULL. (Implementation note: This calls ColourEditDlg::ForceLineOrFillMode)

Parameters:
- [OUTPUTS]
Returns:
-
Notes: The IndexedColour is actually copied into another for editing. The change, if OK'd is then applied using the ColourManager::ChangeColour function, which provides an undo record of the event.

Scope: private

Returns:
Errors: -
See also:
ColourEditDlg::InvokeDialog

Definition at line 275 of file colpick.cpp.

00277 {
00278 #if FALSE
00279 /*
00280 // **** DEBUG - use Windows Picker if SHIFT NOT held down on entry,
00281 //              else use the Camelot Picker
00282     if (ForceNativePicker)
00283         UseOSPicker = TRUE;
00284     else
00285         UseOSPicker = (::GetAsyncKeyState(CAMKEY(SHIFT)) & 0x8000) ? TRUE : FALSE;
00286 // ****
00287     if (UseOSPicker)
00288     {
00289         IndexedColour *UndoBuffer = new IndexedColour(*SourceAndResult);
00290         if (UndoBuffer == NULL)     // Fail gracefully. Well... Don't crash, anyway
00291             return;
00292 
00293         ColourGeneric *TheColour = UndoBuffer->SourceColourPtr();
00294 
00295         Document *ScopeDoc = Document::GetSelected();
00296         if (ScopeDoc == NULL)
00297             return;
00298 
00299         ColourContext *ccRGB = ScopeDoc->GetDefaultColourContexts()->Context[COLOURMODEL_RGBT];
00300         ENSURE(ccRGB != NULL, "Default RGBT context can't be found!");
00301 
00302         ColourContext *ccSource = ScopeDoc->GetDefaultColourContexts()->Context[UndoBuffer->GetColourModel()];
00303         if (ccSource == NULL)
00304         {
00305             ENSURE(FALSE, "Unsupported source colour context - I can't edit that colour");
00306             return;
00307         }
00308 
00309         // Convert the given colour into RGB, using 'pure' contexts (logical rather than physica
00310         // conversion, i.e. no colour correction en-route)
00311         ColourRGBT TheColourRGB;
00312         ccRGB->ConvertColour(ccSource, TheColour, (ColourGeneric *) &TheColourRGB);
00313 
00314 
00315         // Now set up, and call the Windows colour picker to edit the colour...
00316         CHOOSECOLOR cc;
00317 
00318         // Set initial colour for the colour picker to use
00319         cc.rgbResult = RGB( ColourValueToByte(TheColourRGB.Red),
00320                             ColourValueToByte(TheColourRGB.Green),
00321                             ColourValueToByte(TheColourRGB.Blue) );
00322 
00323 
00324         // Set the default set of available colours (a greyscale for the time being)
00325         // (it is static so that if the user changes any of the colours they will get
00326         // the changed palette back next time around)
00327         static COLORREF acrCustClr[16] =
00328             {
00329                 RGB(255, 255, 255), RGB(239, 239, 239),
00330                 RGB(223, 223, 223), RGB(207, 207, 207),
00331                 RGB(191, 191, 191), RGB(175, 175, 175),
00332                 RGB(159, 159, 159), RGB(143, 143, 143),
00333                 RGB(127, 127, 127), RGB(111, 111, 111),
00334                 RGB(95, 95, 95),    RGB(79, 79, 79),
00335                 RGB(63, 63, 63),    RGB(47, 47, 47),
00336                 RGB(31, 31, 31),    RGB(15, 15, 15)
00337             };
00338 
00339         cc.lStructSize = sizeof(CHOOSECOLOR);
00340         cc.hwndOwner = AfxGetApp()->m_pMainWnd->m_hWnd; // 'owner' window
00341         cc.lpCustColors = (LPDWORD) acrCustClr;         // List of default colours
00342         cc.Flags = CC_RGBINIT | CC_FULLOPEN;            // Use cc.rgbResult to init picker...
00343                                                         // and picker appears fully opened - Geez that
00344                                                         // 'define wossnames' button is a pain in the butt!!!
00345 
00346         if (ChooseColor(&cc))       // Invoke Windows colour picker (if it qualifies as a colour picker!)
00347         {
00348             // User chose a colour and hit OK - read out the return value (always RGB)
00349             UndoBuffer->SetSourceColourModel(COLOURMODEL_RGBT);
00350             ((ColourRGBT *)TheColour)->Red   = ((double) GetRValue(cc.rgbResult)) / 256.0;
00351             ((ColourRGBT *)TheColour)->Green = ((double) GetGValue(cc.rgbResult)) / 256.0;
00352             ((ColourRGBT *)TheColour)->Blue  = ((double) GetBValue(cc.rgbResult)) / 256.0;
00353             ((ColourRGBT *)TheColour)->Transparent = 0;
00354 
00355             Document::GetSelected()->SetCurrent();      // Make this document the current one
00356 
00357             // This swallows UndoBuffer into the undo system - we must NOT delete it
00358             ColourManager::ChangeColour(ParentList, UndoBuffer, SourceAndResult);
00359         }
00360         else
00361             delete UndoBuffer;  // UndoBuffer not used - delete it
00362     }
00363     else
00364 */
00365 #endif
00366     {
00367 #ifndef STANDALONE
00368         // If we are asking to edit an appropriate local colour, state our preference
00369         // for either fill or line colour.
00370         if (SourceAndResult == NULL)
00371             ColourEditDlg::ForceLineOrFillMode(PreferLineColour);
00372 
00373         ColourEditDlg::InvokeDialog(ParentList, SourceAndResult);
00374 #endif
00375     }
00376 }

void ColourPicker::ForceColourModel IndexedColour Dest,
ColourContext SourceContext
[static, protected]
 

COERCES the colour into the destination context. This ensures that the colour is defined in the given context's colour model, converting its definition if necessary.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/11/94
Parameters:
Dest - the colour to be set [INPUTS] SourceContext - the context in which the new colour value should be defined
Dest is updated appropriately [OUTPUTS]
Returns:
-
Notes: This method always flushes the colour's output cache.

Scope: private

Definition at line 1926 of file colpick.cpp.

01927 {
01928     ERROR3IF(Dest == NULL || SourceContext == NULL,
01929                 "ColourPicker::ForceColourModel - NULL Parameters are illegal");
01930 
01931     // Invalidate the colour's output cache (even if it hasn't really changed - in this
01932     // case we're only causing one weeny little colour conversion, so it's no big deal)
01933     // This is also needed because the above functions expect this call to flush the cache.
01934     Dest->InvalidateCache();
01935 
01936     if (Dest->GetColourModel() != SourceContext->GetColourModel())
01937     {
01938         ColourContext *OldContext = ColourContext::GetGlobalDefault(Dest->GetColourModel());
01939         if (OldContext == NULL)
01940         {
01941             ERROR2RAW("Unable to get colour context for ForceColourModel");
01942             return;
01943         }
01944 
01945         // The colour must be coerced into the new model using secret squirrel private
01946         // methods which we can access only because we are a friend of IndexedColour
01947         ColourGeneric NewDefn;
01948 
01949         Dest->GetSourceColour(&NewDefn);    // Copy into temp space & convert back into the colour
01950         SourceContext->ConvertColour(OldContext, &NewDefn, Dest->SourceColourPtr());
01951 
01952         Dest->SetSourceColourModel(SourceContext->GetColourModel());
01953 
01954         // and once again, flush the cache to make sure the change in model has been noticed
01955         Dest->InvalidateCache();
01956     }
01957 }

BOOL ColourPicker::GetComponentAsString IndexedColour Source,
ColourContext DestContext,
INT32  ComponentIndex,
String_8 Result
[static, protected]
 

Retrieves the colour definition of the given colour, converts it to the given colour model, and returns the desired component of the definition in that model as a decimal string appropriate for placing into a colour editor dialogue gadget.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/11/94
Parameters:
Source - The colour from which you wish to extract the component [INPUTS] DestContext - The colour context in which you want the resulting component ComponentIndex - The component you wish to extract (1..4)
Result - returns containing a decimal (0.0 .. 100.0) string representing [OUTPUTS] the value of the given component of the colour as it is defined in the given colour model (Note: HSV Hue is done as 0..360).
Returns:
TRUE if the value converted was out of gamut.
Notes: At present, this function clips the value to lie within the legal 0.0 to 1.0 gamut range.

Scope: private

See also:
ColourPicker::SetComponentFromDouble; ColourPicker::SetComponentFromString

Definition at line 1238 of file colpick.cpp.

01241 {
01242     ERROR2IF(Source == NULL || DestContext == NULL || Result == NULL, FALSE,
01243                 "NULL parameters are illegal");
01244 
01245     ERROR2IF(ComponentIndex < 1 || (UINT32)ComponentIndex > DestContext->GetComponentCount(), FALSE,
01246                 "ComponentIndex not in range");
01247 
01248     BOOL OutOfGamut = FALSE;
01249     ColourGeneric Defn;
01250 
01251     DestContext->ConvertColour(Source, &Defn);
01252     
01253     // Sneakily get the component from the ColourGeneric by treating it as an array
01254     // of 4 ColourValue components.
01255     ColourValue *CompPtr = (ColourValue *) &Defn;       
01256     double CompValue = CompPtr[ComponentIndex-1].MakeDouble();
01257 
01258     if (CompValue < 0.0)
01259     {
01260         CompValue = 0.0;        // **** Clip out-of-gamut values.
01261         OutOfGamut = TRUE;      // Remember that this was out of gamut
01262     }
01263 
01264     if (CompValue > 1.0)
01265     {
01266         CompValue = 1.0;        // **** Clip out-of-gamut values.
01267         OutOfGamut = TRUE;      // Remember that this was out of gamut
01268     }
01269 
01270     // Generate a 0..100 value, except for Hue, in which case it's 0..360
01271     UnitGroup* pPossibleUnits = DestContext->GetComponentUnitGroup(ComponentIndex);
01272     if (pPossibleUnits == NULL)
01273     {
01274         ERROR3("ColourPicker::GetComponentAsString - pPossibleUnits NULL");
01275         return FALSE;
01276     }
01277     ERROR3IF(!pPossibleUnits->IS_KIND_OF(UnitGroup), "pPossibleUnits aren't");
01278     ScaleUnit* pUnit = pPossibleUnits->GetDefaultUnit();
01279     if (pUnit == NULL)
01280     {
01281         ERROR3("ColourPicker::GetComponentAsString - Default units NULL");
01282         return FALSE;
01283     }
01284     ERROR3IF(!pUnit->IS_KIND_OF(ScaleUnit), "pUnits isn't");
01285     pUnit->StringFromScale(CompValue, Result, 6);
01286 
01287     // Convert to a 1 d.p. string using the global conversion function
01288 /*  String_32 TempString;
01289     Convert::DoubleToString(CompValue, (StringBase *) &TempString, pUnit->GetDPtoShow());
01290     TempString.Left(Result, 6);
01291 
01292     const Qualifier* pQualifier = pUnit->GetQualifier();
01293     if (pQualifier == NULL || !pQualifier->IS_KIND_OF(Qualifier))
01294     {
01295         ERROR3("ColourPicker::GetComponentAsString - not a Qualifier!");
01296         return FALSE;
01297     }
01298     if (pQualifier->IsShown())
01299         *Result += pQualifier->GetToken();
01300 */
01301     return(OutOfGamut);
01302 }

BOOL ColourPicker::GetComponentHelp ColourContext *const   pSourceContext,
const UINT32  ComponentIndex,
StringBase HelpString
[static, protected]
 

Subprocedure for HelpCallbackHandler providing help for each of the colour components.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/05/96
Parameters:
pSourceContext - the ColourContext in which the component is [INPUTS] ComponentIndex - the index of the component in the colour context (1..GetComponentCount())
HelpString - a string to be displayed as help for the given component [OUTPUTS]
Returns:
TRUE : If help string constructed correctly FALSE : otherwise

Errors: ERROR2IF's if invalid paramters given ERROR3IF's for corrupt data structures

See also:
ColourPicker::HelpCallbackHandler

Definition at line 979 of file colpick.cpp.

00980 {
00981     ERROR2IF(pSourceContext == NULL, FALSE, "NULL parameters not allowed");
00982     ERROR3IF(!pSourceContext->IS_KIND_OF(ColourContext), "ColourPicker::GetComponentHelp() - pSourceContext isn't");
00983     ERROR2IF((ComponentIndex < 1) || (ComponentIndex > pSourceContext->GetComponentCount()), FALSE,
00984                 "Component index out of bounds");
00985 
00986     // Create a string of the form "Red (0..100%)" using the colour component's name and the limits defined for
00987     // the component's unit
00988     UnitGroup* pUnitGroup = pSourceContext->GetComponentUnitGroup(ComponentIndex);
00989     if (pUnitGroup == NULL)
00990     {
00991         ERROR3("ColourPicker::GetComponentHelp - Model has no units");
00992         return FALSE;
00993     }
00994     ERROR3IF(!pUnitGroup->IS_KIND_OF(UnitGroup), "ColourPicker::GetComponentHelp() - pUnitGroup isn't");
00995     ScaleUnit* pUnit = pUnitGroup->GetDefaultUnit();
00996     if (pUnit == NULL)
00997     {
00998         ERROR3("ColourPicker::GetComponentHelp - No default units");
00999         return FALSE;
01000     }
01001     ERROR3IF(!pUnit->IS_KIND_OF(ScaleUnit), "ColourPicker::GetComponentHelp() - pUnit isn't");
01002 
01003     String_64 CompName;
01004     pSourceContext->GetComponentName(ComponentIndex, &CompName, TRUE);
01005 
01006     String_32 LowerLimit;
01007     Convert::DoubleToString(pUnit->GetMin(), (StringBase*)&LowerLimit, pUnit->GetDPtoShow());
01008 
01009     String_32 UpperLimit;
01010     Convert::DoubleToString(pUnit->GetMax(), (StringBase*)&UpperLimit, pUnit->GetDPtoShow());
01011 
01012     String_32 QualifierToken;
01013     const Qualifier* pQualifier = pUnit->GetQualifier();
01014     if (pQualifier == NULL)
01015     {
01016         ERROR3("ColourPicker::GetComponentHelp - No qualifier");
01017         return FALSE;
01018     }
01019     ERROR3IF(!pQualifier->IS_KIND_OF(Qualifier), "ColourPicker::GetComponentHelp - Qualifier isn't");
01020 
01021     if (pQualifier->IsShown())
01022     {
01023         QualifierToken = pQualifier->GetToken();
01024     }
01025 
01026     HelpString.MakeMsg(_R(IDS_EDITBH_COMP234), (TCHAR *)CompName, (TCHAR *)LowerLimit, (TCHAR *)UpperLimit, 
01027                         (TCHAR *)QualifierToken);
01028 
01029     return TRUE;
01030 }

BOOL ColourPicker::GetComponentsAsHexString IndexedColour Source,
ColourContext DestContext,
INT32  ComponentIndex,
String_16 Result
[static, protected]
 

Retrieves the colour definition of the given colour, converts it to the given colour model, and returns the combined value of all components of the definition in that model as a hexadecimal string appropriate for placing into a colour editor dialogue gadget.

Author:
Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/11/99
Parameters:
Source - The colour from which you wish to extract the component [INPUTS] DestContext - The colour context in which you want the resulting component ComponentIndex - This should be set to -1 at present (cause we are getting all components; and not one in the range 1-4)
Result - returns containing a hexadecimal string representation (rrggbb) [OUTPUTS]
Returns:
TRUE if the value converted was out of gamut.
Notes: At present, this function clips the value to lie within the legal 0.0 to 1.0 gamut range.

Scope: private

See also:
ColourPicker::GetComponentsAsString; ColourPicker::SetComponentsFromHexString

Definition at line 1338 of file colpick.cpp.

01341 {
01342     ERROR2IF(Source == NULL || DestContext == NULL || Result == NULL, FALSE,
01343                 "NULL parameters are illegal");
01344 //  ERROR2IF(!DestContext->IS_KIND_OF(ColourContextWebRGBT), FALSE,
01345 //              "SourceContext parameter is not of type ColourContextWebRGBT");
01346 
01347     if (ComponentIndex == -1)
01348     {
01349         BOOL OutOfGamut = FALSE;
01350         ColourGeneric Defn;
01351 
01352         DestContext->ConvertColour(Source, &Defn);
01353 
01354         // Sneakily get the component from the ColourGeneric by treating it as an array
01355         // of 4 ColourValue components ....
01356 
01357         ColourValue *CompPtr = (ColourValue *) &Defn;       
01358         
01359         String_8 ResultR, ResultG, ResultB;
01360 
01361         for (INT32 i = 1; i < 4; i++)
01362         {
01363             double CompValue = CompPtr[i-1].MakeDouble();
01364 
01365             if (CompValue < 0.0)
01366             {
01367                 CompValue = 0.0;        // **** Clip out-of-gamut values.
01368                 OutOfGamut = TRUE;      // Remember that this was out of gamut
01369             }
01370 
01371             if (CompValue > 1.0)
01372             {
01373                 CompValue = 1.0;        // **** Clip out-of-gamut values.
01374                 OutOfGamut = TRUE;      // Remember that this was out of gamut
01375             }
01376 
01377             // Generate a 0..100 value, except for Hue, in which case it's 0..360
01378             UnitGroup* pPossibleUnits = DestContext->GetComponentUnitGroup(i);
01379             if (pPossibleUnits == NULL)
01380             {
01381                 ERROR3("ColourPicker::GetComponentAsString - pPossibleUnits NULL");
01382                 return FALSE;
01383             }
01384             ERROR3IF(!pPossibleUnits->IS_KIND_OF(UnitGroup), "pPossibleUnits aren't");
01385             ScaleUnit* pUnit = pPossibleUnits->FindUnitFromIndex (1);//GetDefaultUnit();
01386             if (pUnit == NULL)
01387             {
01388                 ERROR3("ColourPicker::GetComponentAsString - Default units NULL");
01389                 return FALSE;
01390             }
01391             ERROR3IF(!pUnit->IS_KIND_OF(ScaleUnit), "pUnits isn't");
01392             
01393             switch (i)
01394             {
01395                 case 1:
01396                     pUnit->StringFromScale(CompValue, &ResultR, 6);
01397                 break;
01398                 case 2:
01399                     pUnit->StringFromScale(CompValue, &ResultG, 6);
01400                 break;
01401                 case 3:
01402                     pUnit->StringFromScale(CompValue, &ResultB, 6);
01403                 break;
01404             }
01405         }
01406 
01407         // convert strings into integers ....
01408         
01409         INT32 rVal = camAtoi ((const TCHAR*) ResultR);
01410         INT32 gVal = camAtoi ((const TCHAR*) ResultG);
01411         INT32 bVal = camAtoi ((const TCHAR*) ResultB);
01412 
01413         // convert integers to base 16 ....
01414         
01415         camSprintf((TCHAR*)ResultR, _T("%X"), rVal);
01416         camSprintf((TCHAR*)ResultG, _T("%X"), gVal);
01417         camSprintf((TCHAR*)ResultB, _T("%X"), bVal);
01418 
01419         String_8 Builder;//FinalResultR, FinalResultG, FinalResultB;
01420 
01421         // I don't want an _itoa one length rr's, gg's or bb's thankyou very much!
01422         // AND glue the results together (== rrggbb) at the same time
01423 
01424         if (ResultR.Length () == 1)
01425         {
01426             Builder += (String_8 (TEXT ("0"))) += ResultR;
01427         }
01428         else
01429         {
01430             Builder += ResultR;
01431         }
01432 
01433         if (ResultG.Length () == 1)
01434         {
01435             Builder += (String_8 (TEXT ("0"))) += ResultG;
01436         }
01437         else
01438         {
01439             Builder += ResultG;
01440         }
01441 
01442         if (ResultB.Length () == 1)
01443         {
01444             Builder += (String_8 (TEXT ("0"))) += ResultB;
01445         }
01446         else
01447         {
01448             Builder += ResultB;
01449         }
01450 
01451         *Result = Builder;      // take that edit box - a correctly built hex string!
01452         
01453         //if ((ResultR.Length () == 1) || (ResultG.Length () == 1) || (ResultB.Length () == 1))
01454         //{
01455         //  *Result += /*(String_8 (TEXT ("0x"))) +=*/ FinalResultR += FinalResultG += FinalResultB;
01456         //}
01457         //else
01458         //{
01459         //  *Result += /*(String_8 (TEXT ("0x"))) +=*/ ResultR += ResultG += ResultB;
01460         //}
01461 
01462         return(OutOfGamut);
01463     }
01464 
01465     return (FALSE);     // stop that annoying warning about not all paths return a value!
01466 }

BOOL ColourPicker::GetShadeValueAsString IndexedColour Source,
INT32  ValueIndex,
StringBase Result
[static, protected]
 

Retrieves the shade of the given colour as a decimal string appropriate for placing into a colour editor dialogue gadget.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/10/95
Parameters:
Source - The colour from which you wish to extract the shade value [INPUTS] ValueIndex - 1 to extract the X component 2 to extract the Y component
Result - returns containing a decimal (-100.0 .. 100.0) string representing [OUTPUTS] the value of the given shade component of the colour
Returns:
TRUE if the value converted was out of gamut.
Notes: At present, this function clips the value to lie within the legal -1.0 to 1.0 gamut range.

If the colour is not a shade, will ENSURE and return "0%"

Scope: private

See also:
ColourPicker::SetShadeFromStrings

Definition at line 2144 of file colpick.cpp.

02145 {
02146     ERROR3IF(Source == NULL || Result == NULL,
02147                 "ColourPicker::GetShadeValueAsString - NULL parameters are illegal");
02148 
02149     ERROR3IF(ValueIndex != 1 && ValueIndex != 2, "ColourPicker::GetShadeValueAsString - Illegal ValueIndex parameter");
02150 
02151     if (Source->GetType() != COLOURTYPE_TINT)
02152     {
02153         ERROR3("ColourPicker::GetShadeValueAsString - Source colour isn't a tint");
02154         *Result = String_8(_R(IDS_CONVERT_ZERO_CHAR)); // TEXT("0");
02155         return(FALSE);
02156     }
02157 
02158     BOOL OutOfGamut = FALSE;
02159     
02160     double CompValue;
02161     if (ValueIndex == 1)
02162         CompValue = -Source->GetShadeValueX().MakeDouble();
02163     else
02164         CompValue = Source->GetShadeValueY().MakeDouble();
02165 
02166     if (CompValue < -1.0)
02167     {
02168         CompValue = -1.0;       // **** Clip out-of-gamut values.
02169         OutOfGamut = TRUE;      // Remember that this was out of gamut
02170     }
02171 
02172     if (CompValue > 1.0)
02173     {
02174         CompValue = 1.0;        // **** Clip out-of-gamut values.
02175         OutOfGamut = TRUE;      // Remember that this was out of gamut
02176     }
02177 
02178     CompValue *= 100.0;
02179 
02180     String_32 TempString;
02181     Convert::DoubleToString(CompValue, (StringBase *) &TempString, 1);
02182 
02183     TempString.Left(Result, 7);
02184 
02185     return(OutOfGamut);
02186 }

BOOL ColourPicker::GetStatusLineText ColourEditDlg Editor,
UINT32  GadgetID,
String_256 Result
[static, protected]
 

Bodge to get around the fact that DialogOps don't plug into the status line help system. Returns help for the colour editor. Must go via the winoil, as we have to read the mouse position and find the window it's in.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/5/95
Parameters:
Editor - points to the current editor [INPUTS] GadgetID - indicates the gadget for which you desire help
If return value is TRUE, Result is updated with an appropriate help string [OUTPUTS]
Returns:
TRUE if it changed Result, FALSE if it can offer no help
See also:
ColourEditDlg::GetStatusLineText

Definition at line 403 of file colpick.cpp.

00404 {
00405 #ifndef STANDALONE
00406 
00407     IndexedColour *Bob = Editor->EditingColour;
00408     if (Bob == NULL)
00409     {
00410         *Result = String_256(_R(IDS_EDITST_NOCOLOUR));
00411         return(TRUE);
00412     }
00413 
00414     ColourContext *cc = ColourContext::GetGlobalDefault(ColourEditDlg::DisplayModel);
00415 
00416     // Set the default help
00417     *Result = String_256(_R(IDS_EDITST_DEFAULT));
00418 
00419     if (FALSE) {}
00420 //  else if (GadgetID == _R(IDCANCEL))
00421 //  {
00422 //      *Result = String_256(_R(IDS_EDITST_CANCEL));
00423 //  }
00424     else if (GadgetID == _R(IDC_EDIT_DROPMENU))
00425     {
00426         *Result = String_256(_R(IDS_EDITST_MENU));
00427     }
00428     else if (GadgetID == _R(IDC_EDIT_COMPONENT1))
00429     {
00430         if (ColourEditDlg::DisplayModel == COLOURMODEL_HSVT)
00431         {
00432             *Result = String_256(_R(IDS_EDITST_COMP1));
00433         }
00434         else
00435         {
00436             if (cc != NULL)
00437             {
00438                 String_64 CompName;
00439                 cc->GetComponentName(1, &CompName, TRUE);
00440                 Result->MakeMsg(_R(IDS_EDITST_COMP234), (TCHAR *)CompName);
00441             }
00442         }
00443     }
00444     else if (GadgetID == _R(IDC_EDIT_COMPONENT2))
00445     {
00446         if (cc != NULL)
00447         {
00448             String_64 CompName;
00449             cc->GetComponentName(2, &CompName, TRUE);
00450             Result->MakeMsg(_R(IDS_EDITST_COMP234), (TCHAR *)CompName);
00451         }
00452     }
00453     else if (GadgetID == _R(IDC_EDIT_COMPONENT3))
00454     {
00455         if (cc != NULL)
00456         {
00457             String_64 CompName;
00458             cc->GetComponentName(3, &CompName, TRUE);
00459             Result->MakeMsg(_R(IDS_EDITST_COMP234), (TCHAR *)CompName);
00460         }
00461     }
00462 // WEBSTER - markn 14/12/96
00463 #ifndef WEBSTER
00464     else if (GadgetID == _R(IDC_EDIT_COMPONENT4))
00465     {
00466         if (cc != NULL)
00467         {
00468             String_64 CompName;
00469             cc->GetComponentName(4, &CompName, TRUE);
00470             Result->MakeMsg(_R(IDS_EDITST_COMP234), (TCHAR *)CompName);
00471         }
00472     }
00473     else if (GadgetID == _R(IDC_EDIT_COLMODEL))
00474     {
00475         *Result = String_256(_R(IDS_EDITST_COLMODEL));
00476     }
00477     else if (GadgetID == _R(IDC_EDIT_NAMEMENU))
00478     {
00479         *Result = String_256(_R(IDS_EDITST_NAME));
00480     }
00481     else if (GadgetID == _R(IDC_EDIT_COLTYPE))
00482     {
00483         *Result = String_256(_R(IDS_EDITST_COLTYPE));
00484     }
00485     else if ((GadgetID == _R(IDC_EDIT_INHERIT1)) ||
00486              (GadgetID == _R(IDC_EDIT_INHERIT2)) ||
00487              (GadgetID == _R(IDC_EDIT_INHERIT3)) ||
00488              (GadgetID == _R(IDC_EDIT_INHERIT4)))
00489     {
00490         *Result = String_256(_R(IDS_EDITST_INHERIT));
00491     }
00492 //  else if ((GadgetID == _R(IDC_EDIT_PATCH)) ||
00493 //           (GadgetID == _R(IDC_EDIT_PARENTPATCH)))
00494 //  {
00495 //      *Result = String_256(_R(IDS_EDITST_PARENTPATCH));
00496 //  }
00497     else if ((GadgetID == _R(IDC_EDIT_PARENTCOL)) ||
00498              (GadgetID == _R(IDC_EDIT_PARENTNAME)))
00499     {
00500         *Result = String_256(_R(IDS_EDITST_PARENTCOL));
00501     }
00502     else if ((GadgetID == _R(IDC_EDIT_TINT)) ||
00503              (GadgetID == _R(IDC_EDIT_TINTSLIDER)))
00504     {
00505         if (Bob->GetType() == COLOURTYPE_TINT && !Bob->TintIsShade())
00506             *Result = String_256(_R(IDS_EDITST_TINT1));     // It's a tint
00507         else
00508             *Result = String_256(_R(IDS_EDITST_TINT2));     // It's a shade
00509     }
00510     else if (GadgetID == _R(IDC_EDIT_SHADE))
00511     {
00512         *Result = String_256(_R(IDS_EDITST_TINT2));         // It's a shade
00513     }
00514     else if (GadgetID == _R(IDC_EDIT_ADVANCED))
00515     {
00516         if (Editor->Folded)
00517             *Result = String_256(_R(IDS_EDITST_ADVANCED1));
00518         else
00519             *Result = String_256(_R(IDS_EDITST_ADVANCED2));
00520     }
00521     else if (GadgetID == _R(IDC_EDIT_3D))
00522     {
00523         *Result = String_256(_R(IDS_EDITST_3D));
00524     }
00525     else if (GadgetID == _R(IDC_EDIT_MAKESTYLE))
00526     {
00527         *Result = String_256(_R(IDS_EDITST_MAKESTYLE));
00528     }
00529 #endif // WEBSTER
00530     else if (GadgetID == _R(IDC_EDIT_PICKER))
00531     {
00532         if (!StatusHelpBuffer.IsEmpty())
00533             *Result = StatusHelpBuffer;
00534         else
00535         {
00536             switch(Bob->GetType())
00537             {
00538             // WEBSTER - markn 14/12/96
00539             #ifndef WEBSTER
00540                 case COLOURTYPE_TINT:
00541                     if (Editor->Folded)
00542                         *Result = String_256(_R(IDS_EDITST_PICKER1));
00543                     else
00544                         *Result = String_256(_R(IDS_EDITST_PICKER2));
00545                     break;
00546 
00547                 case COLOURTYPE_LINKED:
00548                     *Result = String_256(_R(IDS_EDITST_PICKER3));
00549                     break;
00550             #endif // WEBSTER
00551 
00552                 case COLOURTYPE_NORMAL:
00553                 case COLOURTYPE_SPOT:
00554                 default:
00555                     *Result = String_256(_R(IDS_EDITST_PICKER4));
00556                     break;
00557             }
00558         }
00559     }   
00560     else if (GadgetID == _R(IDC_EDIT_216ONLY))
00561     {
00562         *Result = String_256(_R(IDS_EDITST_216ONLY));
00563     }   
00564     else if (GadgetID == _R(IDC_COLOURPICKER))
00565     {
00566         *Result = String_256(_R(IDS_STATICCOLOURPICKERTOOLHELP));
00567     }
00568     else if (GadgetID == _R(IDC_MAKE_LOCAL))
00569     {
00570         *Result = String_256(_R(IDS_EDITST_MAKE_LOCAL));
00571     }
00572     else if (GadgetID == _R(IDC_EDIT_NOCOLOUR))
00573     {
00574         *Result = String_256(_R(IDS_EDITST_SETNOCOLOUR));
00575     }
00576     else if (GadgetID == _R(IDC_EDIT_RENAME))
00577     {
00578         *Result = String_256(_R(IDS_EDITST_RENAME));
00579     }
00580     else if (GadgetID == _R(IDC_EDIT_LINEFILL))
00581     {
00582         *Result = String_256(_R(IDS_EDITST_LINEFILL));
00583     }
00584 #endif
00585     return(TRUE);
00586 }

BOOL ColourPicker::GetStatusLineText String_256 Result  )  [static]
 

Definition at line 655 of file colpick.cpp.

00656 {
00657 #ifndef STANDALONE
00658 
00659     ERROR3IF(Result == NULL, "Illegal NULL param");
00660     
00661     ColourEditDlg *Editor = ColourEditDlg::TheEditor;
00662     if (Editor == NULL)
00663         return(FALSE);
00664 
00665     // Find the main editor window
00666     CWindowID TheWindow = (CWindowID)Editor->WindowID;
00667     if (TheWindow == NULL)
00668         return(FALSE);
00669 
00670     wxPoint mousepos = ::wxGetMousePosition();
00671     wxWindow * window=::wxChildWindowFromPoint(TheWindow, mousepos, FALSE, -1);
00672     if ((!window) || (window!=::wxChildWindowFromPoint(mousepos, FALSE, -1))) // second check to ensure it is not obscured
00673         return FALSE;
00674 
00675     return GetStatusLineText(Editor, window->GetId(), Result);
00676 #else
00677     return(TRUE);
00678 #endif
00679 }

BOOL ColourPicker::GetTintAsString IndexedColour Source,
StringBase Result
[static, protected]
 

Retrieves the tint of the given colour as a decimal string appropriate for placing into a colour editor dialogue gadget.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/8/95
Parameters:
Source - The colour from which you wish to extract the tint [INPUTS]
Result - returns containing a decimal (0.0 .. 100.0) string representing [OUTPUTS] the value of the tint component of the colour
Returns:
TRUE if the value converted was out of gamut.
Notes: At present, this function clips the value to lie within the legal 0.0 to 1.0 gamut range.

If the colour is not a tint, will ENSURE and return "0%"

Scope: private

See also:
ColourPicker::SetTintFromString

Definition at line 1989 of file colpick.cpp.

01990 {
01991     ERROR3IF(Source == NULL || Result == NULL,
01992                 "ColourPicker::GetComponentAsString - NULL parameters are illegal");
01993 
01994     if (Source->GetType() != COLOURTYPE_TINT)
01995     {
01996         ERROR3("ColourPicker::GetTintAsString: Source colour isn't a tint");
01997         *Result = String_8(_R(IDS_CONVERT_ZERO_CHAR)); //TEXT("0");
01998         return(FALSE);
01999     }
02000 
02001     BOOL OutOfGamut = FALSE;
02002     
02003     double CompValue;
02004     if (Source->TintIsShade())
02005         CompValue = Source->GetShadeValueY().MakeDouble();
02006     else
02007         CompValue = Source->GetTintValue().MakeDouble();
02008 
02009     if (CompValue < 0.0)
02010     {
02011         CompValue = 0.0;        // **** Clip out-of-gamut values.
02012         OutOfGamut = TRUE;      // Remember that this was out of gamut
02013     }
02014 
02015     if (CompValue > 1.0)
02016     {
02017         CompValue = 1.0;        // **** Clip out-of-gamut values.
02018         OutOfGamut = TRUE;      // Remember that this was out of gamut
02019     }
02020 
02021     CompValue *= 100.0;
02022 
02023     String_32 TempString;
02024     Convert::DoubleToString(CompValue, (StringBase *) &TempString, 1);
02025 
02026     TempString.Left(Result, 7);
02027 
02028     return(OutOfGamut);
02029 }

TCHAR * ColourPicker::HelpCallbackHandler CWindowID  Window,
UINT32  Item,
void *  UserData
[static, protected]
 

Help callback handler to provide bubble help for the colour editor.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/9/95
Parameters:
Window - identifies the window to get help for [INPUTS] Item - identifies the control to get help for UserData - User-supplied data (not used)
Returns:
The bubble help string to use, or NULL if no help is available
See also:
ColourPicker::UpdateBubbleHelpAndPointer

Definition at line 702 of file colpick.cpp.

00703 {
00704 #ifndef STANDALONE
00705     static String_256 HelpStringStore;
00706     BOOL ReturnVal = FALSE;
00707 
00708     ColourEditDlg *Editor = ColourEditDlg::TheEditor;
00709     if (Editor == NULL)
00710         return(NULL);
00711 
00712     IndexedColour *Bob = Editor->EditingColour;
00713 
00714     ColourContext *cc = NULL;
00715     if (Bob != NULL)
00716         cc = ColourContext::GetGlobalDefault(ColourEditDlg::DisplayModel);
00717 
00718     if (FALSE) {}
00719     else if (Item == _R(IDC_EDIT_DROPMENU))
00720     {
00721         HelpStringStore = String_256(_R(IDS_EDITBH_MENU));
00722         ReturnVal = TRUE;
00723     }
00724     else if ((Item == _R(IDC_EDIT_PATCH1))  ||  // Fake ID for current colour patch to give it a unique ID
00725              (Item == _R(IDC_EDIT_PATCH2)) ||   // Fake ID for current colour patch to give it a unique ID
00726              (Item == _R(IDC_EDIT_PATCH)) ||
00727              (Item == _R(IDC_EDIT_PICKER)))
00728     {
00729         // NOTE: This gives help for "Original/Current colour" patch
00730         // We will only get called for this if it is necessary (pointer in correct region of control)
00731         HelpStringStore = PickerBubbleBuffer; //String_256(_R(IDS_EDITBH_PARENTPATCH));
00732         ReturnVal = TRUE;
00733     }   
00734 
00735     else if (Item == _R(IDC_EDIT_COMPONENT1))
00736     {
00737         if (cc)
00738             ReturnVal = GetComponentHelp(cc, 1, HelpStringStore);
00739     }
00740     else if (Item == _R(IDC_EDIT_COMPONENT2))
00741     {
00742         if (cc)
00743             ReturnVal = GetComponentHelp(cc, 2, HelpStringStore);
00744     }
00745     else if (Item == _R(IDC_EDIT_COMPONENT3))
00746     {
00747         if (cc)
00748             ReturnVal = GetComponentHelp(cc, 3, HelpStringStore);
00749     }
00750     else if (Item == _R(IDC_EDIT_COMPONENT4))
00751     {
00752         if (cc)
00753             ReturnVal = GetComponentHelp(cc, 4, HelpStringStore);
00754     }
00755 #if 0
00756     {
00757         if (ColourEditDlg::DisplayModel == COLOURMODEL_HSVT)
00758         {
00759             HelpStringStore = String_256(_R(IDS_EDITBH_COMP1));
00760             ReturnVal = TRUE;
00761         }
00762         else
00763         {
00764             if (cc != NULL)
00765             {
00766                 String_64 CompName;
00767                 cc->GetComponentName(1, &CompName, TRUE);
00768                 HelpStringStore.MakeMsg(_R(IDS_EDITBH_COMP234), (TCHAR *)CompName);
00769                 ReturnVal = TRUE;
00770             }
00771         }
00772     }
00773 
00774     else if (Item == _R(IDC_EDIT_COMPONENT2))
00775     {
00776         if (cc != NULL)
00777         {
00778             String_64 CompName;
00779             cc->GetComponentName(2, &CompName, TRUE);
00780             HelpStringStore.MakeMsg(_R(IDS_EDITBH_COMP234), (TCHAR *)CompName);
00781             ReturnVal = TRUE;
00782         }
00783     }   
00784 
00785     else if (Item == _R(IDC_EDIT_COMPONENT3))
00786     {
00787         if (cc != NULL)
00788         {
00789             String_64 CompName;
00790             cc->GetComponentName(3, &CompName, TRUE);
00791             HelpStringStore.MakeMsg(_R(IDS_EDITBH_COMP234), (TCHAR *)CompName);
00792             ReturnVal = TRUE;
00793         }
00794     }   
00795 
00796     else if (Item == _R(IDC_EDIT_COMPONENT4))
00797     {
00798         if (cc != NULL)
00799         {
00800             String_64 CompName;
00801             cc->GetComponentName(4, &CompName, TRUE);
00802             HelpStringStore.MakeMsg(_R(IDS_EDITBH_COMP234), (TCHAR *)CompName);
00803             ReturnVal = TRUE;
00804         }
00805     }   
00806 
00807 #endif
00808     else if (Item == _R(IDC_EDIT_COLMODEL))
00809     {
00810         HelpStringStore = String_256(_R(IDS_EDITBH_COLMODEL));
00811         ReturnVal = TRUE;
00812     }   
00813     else if (Item == _R(IDC_EDIT_NAMEMENU))
00814     {
00815         HelpStringStore = String_256(_R(IDS_EDITBH_NAME));
00816         ReturnVal = TRUE;
00817     }
00818     else if (Item == _R(IDC_EDIT_WEBHEX))
00819     {
00820         HelpStringStore = String_256(_R(IDS_EDITBH_WEBHEX));
00821         ReturnVal = TRUE;
00822     }
00823     else if (Item == _R(IDC_EDIT_COLTYPE))
00824     {
00825         HelpStringStore = String_256(_R(IDS_EDITBH_COLTYPE));
00826         ReturnVal = TRUE;
00827     }
00828     else if ((Item == _R(IDC_EDIT_INHERIT1)) ||
00829              (Item == _R(IDC_EDIT_INHERIT2)) ||
00830              (Item == _R(IDC_EDIT_INHERIT3)) ||
00831              (Item == _R(IDC_EDIT_INHERIT4)) )
00832     {
00833         HelpStringStore = String_256(_R(IDS_EDITBH_INHERIT));
00834         ReturnVal = TRUE;
00835     }
00836     else if ((Item == _R(IDC_EDIT_PARENTCOL)) ||
00837              (Item == _R(IDC_EDIT_PARENTNAME)))
00838     {
00839         HelpStringStore = String_256(_R(IDS_EDITBH_PARENTCOL));
00840         ReturnVal = TRUE;
00841     }
00842     else if ((Item == _R(IDC_EDIT_TINT)) ||
00843              (Item == _R(IDC_EDIT_TINTSLIDER)))
00844     {
00845         if (Bob != NULL && Bob->GetType() == COLOURTYPE_TINT && !Bob->TintIsShade())
00846             HelpStringStore = String_256(_R(IDS_EDITBH_TINT1));     // It's a tint
00847         else
00848             HelpStringStore = String_256(_R(IDS_EDITBH_TINT2));     // It's a shade
00849         ReturnVal = TRUE;
00850     }   
00851     else if (Item == _R(IDC_EDIT_SHADE))
00852     {
00853         HelpStringStore = String_256(_R(IDS_EDITBH_TINT2));         // It's a shade
00854         ReturnVal = TRUE;
00855     }   
00856     else if (Item == _R(IDC_EDIT_ADVANCED))
00857     {
00858         if (Editor->Folded)
00859             HelpStringStore = String_256(_R(IDS_EDITBH_ADVANCED1));
00860         else
00861             HelpStringStore = String_256(_R(IDS_EDITBH_ADVANCED2));
00862         ReturnVal = TRUE;
00863     }
00864     else if (Item == _R(IDC_EDIT_3D))
00865     {
00866         HelpStringStore = String_256(_R(IDS_EDITBH_3D));
00867         ReturnVal = TRUE;
00868     }
00869     else if (Item == _R(IDC_EDIT_MAKESTYLE))
00870     {
00871         HelpStringStore = String_256(_R(IDS_EDITBH_MAKESTYLE));
00872         ReturnVal = TRUE;
00873     }
00874     else if (Item == _R(IDC_EDIT_NOCOLOUR))
00875     {
00876         HelpStringStore = String_256(_R(IDS_COLBAR_HNOCOLOUR));
00877         ReturnVal = TRUE;
00878     }
00879     else if (Item == _R(IDC_MAKE_LOCAL))
00880     {
00881         HelpStringStore = String_256(_R(IDS_EDITBH_MAKE_LOCAL));
00882         ReturnVal = TRUE;
00883     }
00884     else if (Item == _R(IDC_EDIT_RENAME))   
00885     {
00886         HelpStringStore = String_256(_R(IDS_EDITBH_RENAME));
00887         ReturnVal = TRUE;
00888     }
00889     else if (Item == _R(IDC_EDIT_LINEFILL))
00890     {
00891         HelpStringStore = String_256(_R(IDS_EDITBH_LINEFILL));
00892         ReturnVal = TRUE;
00893     }
00894     else if (Item == _R(IDC_EDIT_216ONLY))
00895     {
00896         HelpStringStore = String_256(_R(IDS_EDITBH_216ONLY));
00897         ReturnVal = TRUE;
00898     }   
00899     else if (Item == _R(IDC_COLOURPICKER))
00900     {
00901         HelpStringStore = String_256(_R(IDS_STATICCOLOURPICKERTOOLHELP));
00902         ReturnVal = TRUE;
00903     }
00904 
00905     if (ReturnVal)
00906         return((TCHAR *) HelpStringStore);
00907 
00908 #endif
00909 
00910     return(NULL);
00911 }

BOOL ColourPicker::IsValidHexString String_16  Hex  )  [static, protected]
 

Internal helper function for ColourPicker::SetComponentsFromHexString () UNLESS YOU KNOW WHAT YOUR DOING - DON'T CALL THIS AS IT ONLY EXISTS TO HELP THE FORE-MENTIONED FUNCTION - AND I CANNOT SEE WHY YOUR CALLING THIS FROM ELSEWHERE ANYWAY !!!!

Author:
Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/11/99
Parameters:
Hex - the string to interrogate to see if all characters are trully [INPUTS] hexadecimal.
Returns:
TRUE if success (i.e. all characters in string were hexadecimal)
Scope: private

See also:
ColourPicker::GetComponentAsHexString

Definition at line 1551 of file colpick.cpp.

01552 {
01553     for (INT32 i = 0; i < Hex.Length(); i++)
01554     {
01555         char x = Hex[i];
01556         
01557         if (x >= '0' && x <= '9') {}
01558         else if (x >= 'A' && x <= 'F') {}
01559         else if (x >= 'a' && x <= 'f') {}
01560         else
01561         {
01562             return (FALSE);
01563         }
01564     }
01565     return (TRUE);
01566 }

void ColourPicker::OnCreate CWindowID  WindowID  )  [static, protected]
 

Respond to size events Scope: Protected.

Author:
Alex Bligh
Date:
30/5/2005
Parameters:
- [INPUTS]

Definition at line 3100 of file colpick.cpp.

03101 {
03102     s_IdleCounter=0;
03103     s_JustCreated=TRUE;
03104 
03105     // Fix the window size so Open doesn't overwrite it (grrrr)
03106     wxWindow * pPicker=DialogManager::GetGadget(WindowID, _R(IDC_EDIT_PICKER));
03107     if (pPicker && (s_UserSize != wxDefaultSize))
03108     {
03109         // Ensure no amount of sizing uses a different size for the picker to the one we want
03110         pPicker->SetSize(pPicker->GetSize().GetWidth()+1, pPicker->GetSize().GetHeight()+1); // cause a resize
03111         WindowID->Layout();
03112         WindowID->Fit();
03113         wxSizer *pSizer = WindowID->GetSizer();
03114         if (pSizer)
03115             pSizer->SetSizeHints(WindowID);
03116         pPicker->SetMinSize(s_UserSize);
03117         pPicker->SetMaxSize(s_UserSize);
03118         pPicker->SetSize(s_UserSize);
03119     }
03120 }

BOOL ColourPicker::OnIdleEvent CWindowID  WindowID  )  [static, protected]
 

Respond idle events Scope: Protected.

Author:
Alex Bligh
Date:
30/5/2005
Parameters:
- [INPUTS]

Definition at line 3068 of file colpick.cpp.

03069 {
03070     if (s_InColourDialogLayout)
03071         return FALSE; // That's not a real idle
03072 
03073     if (s_IdleCounter>0)
03074     {
03075         s_IdleCounter--;
03076     }
03077 
03078     if (s_JustCreated && !s_IdleCounter)
03079     {
03080         // We've just been created so we need to do a post open resize
03081         s_JustCreated=FALSE;
03082         RelayoutDialog(WindowID);
03083     }
03084 
03085     return (s_IdleCounter!=0); // we want more events
03086 }

void ColourPicker::OnSize CWindowID  WindowID  )  [static, protected]
 

Respond to size events Scope: Protected.

Author:
Alex Bligh
Date:
30/5/2005
Parameters:
- [INPUTS]

Definition at line 3036 of file colpick.cpp.

03037 {
03038     wxWindow * pGadget = DialogManager::GetGadget(WindowID, _R(IDC_EDIT_PICKER));
03039     if (pGadget)
03040     {
03041         wxSize NewSize = pGadget->GetSize();
03042         
03043         if (s_LastSize != NewSize)
03044         {
03045             // Record the new size
03046             s_LastSize = NewSize;
03047             if (!s_InColourDialogLayout && !s_IdleCounter && WindowID->IsShown())
03048             {
03049                 // It must have been user initiated
03050                 s_UserSize = NewSize;
03051             }
03052         }
03053     }
03054 }

void ColourPicker::RecursiveBestSize wxWindow *  pwxWindow  )  [static, protected]
 

Initialize platform dependent resources.

Author:
Alex_Bligh <alex@alex.org.uk>
Date:
02/12/2005
Parameters:
pWindow - pointer to window to process [INPUTS]
None [OUTPUTS]
Returns:
None

Errors: -

See also:
-

Definition at line 2867 of file colpick.cpp.

02868 {
02869     if (pwxWindow->IsShown())
02870     {
02871         // Now process children if any
02872         wxWindowList::Node * pNode = pwxWindow->GetChildren().GetFirst();
02873         while (pNode)
02874         {
02875             RecursiveBestSize(pNode->GetData());
02876             pNode = pNode->GetNext();
02877         }
02878     }
02879 
02880     pwxWindow->InvalidateBestSize();
02881 
02882     wxSizer * s=pwxWindow->GetSizer();
02883 
02884     // Shrink this window around any sizer it contains
02885     pwxWindow->Layout();
02886     pwxWindow->Fit();
02887     if (s)
02888         s->SetSizeHints(pwxWindow);
02889 
02890     if (pwxWindow->IsShown())
02891         if ((s_UserSize != wxDefaultSize) && ((ResourceID)(pwxWindow->GetId()) == _R(IDC_EDIT_PICKER)))
02892             pwxWindow->SetSize(s_UserSize);
02893         else
02894             pwxWindow->SetSize(pwxWindow->GetMinSize());
02895     else
02896         pwxWindow->SetSize(wxSize(1,1));
02897 
02898     return;
02899 }

void ColourPicker::RelayoutDialog CWindowID  WindowID  )  [static, protected]
 

Ensure the dialog is a sensible size Scope: Protected.

Author:
Alex Bligh
Date:
30/5/2005
Parameters:
- [INPUTS]

Definition at line 2913 of file colpick.cpp.

02914 {
02915     static INT32 flag=0;
02916 
02917     if (s_InColourDialogLayout)
02918     {
02919         TRACEUSER("amb", _T("Recursive colour dialog layout"));
02920         return; // this should not happen
02921     }
02922 
02923     s_InColourDialogLayout = TRUE;
02924 
02925     wxWindow * pPicker=DialogManager::GetGadget(WindowID, _R(IDC_EDIT_PICKER));
02926     if (pPicker)
02927         pPicker->Freeze();
02928     WindowID->Freeze();
02929 
02930     if (pPicker && (s_UserSize != wxDefaultSize))
02931     {
02932         // Ensure no amount of sizing uses a different size for the picker to the one we want
02933         pPicker->SetSize(pPicker->GetSize().GetWidth()+1, pPicker->GetSize().GetHeight()+1); // cause a resize
02934         WindowID->Layout();
02935         WindowID->Fit();
02936         wxSizer * pSizer = WindowID->GetSizer();
02937         if (pSizer)
02938             pSizer->SetSizeHints(WindowID);
02939         pPicker->SetMinSize(s_UserSize);
02940         pPicker->SetMaxSize(s_UserSize);
02941         pPicker->SetSize(s_UserSize);
02942     }
02943 
02944     RecursiveBestSize(WindowID);
02945 
02946     ArtificialSizeEvents(WindowID);
02947     if (!flag)
02948     {
02949         flag++;
02950         wxPlatformDependent::Get()->RealYield();
02951         flag--;
02952     }
02953 
02954     // And now do it again with the minimum size for the colour picker restored so the dialog
02955     // can shrink
02956 
02957     if (pPicker && (s_UserSize != wxDefaultSize))
02958     {
02959         // If s_JustCreated is set, use s_UserSize
02960         pPicker->SetMinSize((s_JustCreated && (s_UserSize != wxDefaultSize))?s_UserSize:s_MinSize);
02961         pPicker->SetMaxSize(wxDefaultSize);
02962     }
02963 
02964     RecursiveBestSize(WindowID);
02965 
02966     ArtificialSizeEvents(WindowID);
02967     if (!flag)
02968     {
02969         flag++;
02970         wxPlatformDependent::Get()->RealYield();
02971         flag--;
02972     }
02973 
02974     WindowID->Thaw();
02975     if (pPicker)
02976     {
02977         pPicker->Thaw();
02978         pPicker->Refresh();
02979     }
02980 
02981     // Now, even having done the above, believe it or not some of the GTK sizing code seems
02982     // to run off idles. So we have to ignore some OnSize events because the idle events
02983     // may not be out the system yet. Sigh... Why can't GTK resize sychronously?
02984 
02985     s_IdleCounter = 3; // 3 more idle counts before we use an OnSize (somewhat arbitrary)
02986     GetApplication()->NeedMoreIdles(); // wake up idle system
02987     s_InColourDialogLayout = FALSE;
02988 }

void ColourPicker::SetBubbleHelp CGadgetID GadgetList  )  [static]
 

Set all the bubble help up for the colour picker.

Author:
Alex Bligh <alex@alex.org.uk>
Date:
31/5/2006
Parameters:
GadgetList - NULL terminated list of gadgets [INPUTS]
Returns:
-
See also:
-

Definition at line 930 of file colpick.cpp.

00931 {
00932     ColourEditDlg *Editor = ColourEditDlg::TheEditor;
00933     if (Editor == NULL)
00934         return;
00935 
00936     CGadgetID i;
00937     while ((i=*(GadgetList++))) // assignment
00938     {
00939         wxWindow * pGadget = DialogManager::GetGadget(Editor->WindowID, i);
00940         wxString s;
00941         if (pGadget)
00942         {
00943             if (pGadget->IsEnabled() && pGadget->IsShown())
00944             {
00945                 // This is OK because HelpCallbackHandler uses a disgusting static. Not my doing
00946                 TCHAR * pHelp = HelpCallbackHandler(Editor->WindowID, i, NULL);
00947                 if (pHelp)
00948                     s=wxString(pHelp);
00949             }
00950             if (!s.IsEmpty())
00951                 pGadget->SetToolTip(s);
00952             else
00953                 pGadget->SetToolTip(NULL);
00954         }
00955     }
00956 }

BOOL ColourPicker::SetComponentFromDouble IndexedColour Dest,
ColourContext SourceContext,
INT32  ComponentIndex,
double  NewValue
[static, protected]
 

Converts AND COERCES the colour into the destination context. Clips the new value into a 0.0 to 1.0 in-gamut range, and then sets the given component of the converted colour to that value.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/11/94
Parameters:
Dest - the colour to be set [INPUTS] SourceContext - the context in which the new component value is defined ComponentIndex - the index [1..4] of the component being set, in that context NewValue - the new value (0.0 - 1.0) of the component
Dest is updated appropriately [OUTPUTS]
Returns:
TRUE if the value was out of gamut and had to be clipped
This thus changes the colour model in which the colour is defined as well as the component value.

The value is rounded as it is squeezed into the Fixed24 format used in colour definitions.

Scope: private

See also:
ColourPicker::SetComponentFromString; ColourPicker::GetComponentAsString

Definition at line 1862 of file colpick.cpp.

01865 {
01866     BOOL OutOfGamut = FALSE;
01867 
01868     ERROR3IF(Dest == NULL || SourceContext == NULL,
01869                 "ColourPicker::SetComponentFromDouble - NULL Parameters are illegal");
01870 
01871     ERROR3IF(ComponentIndex < 1 || ComponentIndex > 4,
01872                 "ColourPicker::SetComponentFromDouble- Index should be in range 1..4!");
01873     
01874     // Ensure it is in the correct colour model, and flush its output cache
01875     ForceColourModel(Dest, SourceContext);
01876 
01877     // Add half of the least-significant-bit-value to round the new value
01878     NewValue += 1.0 / ((double) (1<<25));
01879 
01880     // Clip to lie within gamut
01881     if (NewValue < 0.0)
01882     {
01883         NewValue = 0.0;
01884         OutOfGamut = TRUE;
01885     }
01886 
01887     if (NewValue > 1.0)
01888     {
01889         NewValue = 1.0;
01890         OutOfGamut = TRUE;
01891     }
01892 
01893     // Sneakily place the component back into the ColourGeneric by treating it as an array
01894     // of 4 ColourValue components.
01895     ColourValue *CompPtr = (ColourValue *) Dest->SourceColourPtr();
01896     CompPtr[ComponentIndex-1] = FIXED24(NewValue);
01897 
01898     return(OutOfGamut);
01899 }

BOOL ColourPicker::SetComponentFromString IndexedColour Dest,
ColourContext SourceContext,
INT32  ComponentIndex,
String_8 NewValue
[static, protected]
 

Converts AND COERCES the colour into the destination context. Assumes that the string will be 0..100 (or 0..360 for HSV) Clips the string value into a 0.0 to 1.0 in-gamut range, and then sets the given component of the converted colour to that value. This thus changes the colour model in which the colour is defined as well as the component value.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/11/94
Parameters:
Dest - the colour to be set [INPUTS] SourceContext - the context in which the new component value is defined ComponentIndex - the index [1..4] of the component being set, in that context NewValue - new value (decimal, as 0..100 or 0..360 for Hue) of the component
Dest is updated appropriately [OUTPUTS]
Returns:
TRUE if the value was out of gamut and had to be clipped
Scope: private

See also:
ColourPicker::SetComponentFromDouble; ColourPicker::GetComponentAsString

Definition at line 1500 of file colpick.cpp.

01503 {
01504     ERROR2IF(Dest == NULL ||  SourceContext == NULL || NewValue == NULL, FALSE, 
01505                 "NULL Parameters are illegal");
01506     ERROR3IF(!Dest->IS_KIND_OF(IndexedColour) || !SourceContext->IS_KIND_OF(ColourContext),
01507                 "Parameters incorrect classes");
01508     ERROR2IF(ComponentIndex < 1 || (UINT32)ComponentIndex > SourceContext->GetComponentCount(), 
01509                 FALSE, "ComponentIndex not in range");
01510 
01511     UnitGroup* pPossibleUnits = SourceContext->GetComponentUnitGroup(ComponentIndex);
01512     if (pPossibleUnits == NULL)
01513     {
01514         ERROR3("ColourPicker::SetComponentFromString - SourceContext has NULL units");
01515         return FALSE;
01516     }
01517     ERROR3IF(!pPossibleUnits->IS_KIND_OF(UnitGroup), "ColourPicker::SetComponentFromString - pPossibleUnits aren't");
01518 
01519     double dNewVal;
01520     if (pPossibleUnits->ScaleFromString(*NewValue, dNewVal) == FALSE)
01521         return FALSE;
01522 
01523     // And set the new value
01524     return(SetComponentFromDouble(Dest, SourceContext, ComponentIndex, dNewVal));
01525 }

void ColourPicker::SetComponentGadgets CWindowID  WindowID,
CGadgetID Gadgets,
CGadgetID  PickerGadget,
ColourModel  ModelToDisplay
[static, protected]
 

Private function used by the kernel ColourEditDlg editor.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/4/95
Parameters:
WindowID - The DialogOp->WindowID member variable of the Dialogue [INPUTS]
Gadgets - A NULL-terminated list of Gadget IDs of the gadgets to be moved/resized. There MUST be 8 gadget IDs, paired up into (name,writable) sets.

PickerGadget - specifies the gadget under which the controls are spaced. If they can be fitted, they will maybe be centered under this control in order to look neater.

ModelToDisplay - Indicates the model you're going to put into the controls This is used to determine how many components should be shown and stuff.

This takes the 4 component names and component writable fields and spreads them out within the window to allow the names to go next to the writables. The name fileds are resized to fill the available spaces, so you should make them right-aligned to keep the text a set disatnce from the writable for all colour models.

It's still up to you to set the contents of the controls, and hide any extra ones (so as much of this crap goes into the kernel as possible). This only changes the positions of the first NumComponents control-pairs.

It also hides ALL of the windows. This means that while swapping models they go off and on, but it looks a lot better than the user seeing all the faffing arounf as they are moved, resized, and have their contents changed.

Scope: private

Definition at line 2533 of file colpick.cpp.

02536 {
02537 PORTNOTE("other", "Disabled ColourPicker::SetComponentGadgets")
02538 #ifndef EXCLUDE_FROM_XARALX
02539     // Find out how many visible components we're dealing with...
02540     ColourContext *cc = ColourContext::GetGlobalDefault(ModelToDisplay);
02541     INT32 NumComponents = 0;
02542     INT32 i;
02543     if (cc != NULL)
02544     {
02545         for (i = 1; i <= 4; i++)
02546         {
02547             if (cc->GetComponentName(i, NULL))
02548                 NumComponents++;
02549         }
02550     }
02551 
02552     if (NumComponents < 1)
02553         return;
02554 
02555 
02556     RECT TheRect;
02557 
02558     CWindowID hGadget;
02559     INT32 Left = 8;
02560     INT32 MaxWidth = 0;
02561 //  if (NumComponents < 3)
02562     {
02563         // Use width of colour picker control
02564         hGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)PickerGadget);
02565         if (hGadget && GetWindowRect(hGadget, &TheRect))
02566         {
02567             // convert screen rect to client position within the parent wnd
02568             ::MapWindowPoints(NULL, (CWindowID)WindowID, (LPPOINT) &TheRect, 2);
02569 
02570             MaxWidth = TheRect.right - TheRect.left;
02571             Left = TheRect.left;
02572         }
02573     }
02574 /*
02575     else
02576     {
02577         // Use width of the window
02578         if (GetClientRect((CWindowID)WindowID, &TheRect))
02579         {
02580             MaxWidth = TheRect.right - TheRect.left;
02581             MaxWidth -= 2 * Left;
02582         }
02583     }
02584 */
02585     if (MaxWidth < 1)
02586         return;
02587 
02588 
02589     // We must now fit NumComponents items into MaxWidth pixels
02590     INT32 PairWidth = MaxWidth / NumComponents;
02591 
02592     // Read the writable control size and y position
02593     static INT32 BaseWritableWidth = 0;
02594     hGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)Gadgets[1]);
02595     
02596     if (GetWindowRect(hGadget, &TheRect))
02597     {
02598         // Only read the static writable width the first time we do this,
02599         // so that we remember the original size before we started resizing these controls
02600         if (BaseWritableWidth == 0)
02601             BaseWritableWidth = TheRect.right - TheRect.left;
02602     }
02603 
02604     INT32 WritableWidth = BaseWritableWidth;
02605     if (WritableWidth < 1)
02606         return; 
02607 
02608     // If doing 4 components, we use the width of the original writable controls
02609     // If doing fewer components, we make the writables a bit bigger, as there
02610     // is some spare room around to absorb.
02611     if (NumComponents < 4)
02612         WritableWidth += 4;
02613 
02614 // WEBSTER - markn 9/1/97
02615 // We make the room available to the ed fields for HSV be the same as RGB
02616 // The WritableWidth used to only be adjusted for RGB 
02617 //
02618     // The RGBT model has even more room availble ...
02619     if (ModelToDisplay == COLOURMODEL_RGBT || ModelToDisplay == COLOURMODEL_HSVT)
02620         WritableWidth += 8;
02621 
02622 
02623     const INT32 Gap = 3;            // Min. gap between adjacent fields
02624     if (PairWidth - (2*Gap + WritableWidth) > 64)
02625     {
02626         // There is heaps of space. Limit to the max size, and shift the left
02627         // and maxwidth to keep the controls centered.
02628         PairWidth = 64 + 2*Gap + WritableWidth;
02629 
02630         Left += (MaxWidth - (NumComponents * PairWidth)) / 2;
02631         MaxWidth  = NumComponents * PairWidth;
02632     }
02633 
02634 
02635     // Convert the rect from screen to client coords within the parent wnd.
02636     ::MapWindowPoints(NULL, (CWindowID)WindowID, (LPPOINT) &TheRect, 2);
02637 
02638 
02639     // Find the top/bottom position for the text gadgets, in client coords
02640     RECT TextRect;
02641     hGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)Gadgets[0]);
02642     if (hGadget == NULL || !GetWindowRect(hGadget, &TextRect))
02643         return;
02644     ::MapWindowPoints(NULL, (CWindowID)WindowID, (LPPOINT) &TextRect, 2);
02645 
02646 
02647     // For each component, place the controls
02648     const INT32 NewWidth  = PairWidth - (2*Gap + WritableWidth);
02649     const INT32 NewHeight = ABS(TheRect.bottom - TheRect.top);  // Don't change the height
02650     INT32 LeftEnd;
02651 
02652     for (i = 0; i < NumComponents; i++)
02653     {
02654         LeftEnd = Left + (i * PairWidth);
02655 
02656         // Move and resize (in x axis only) the text gadget
02657         hGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)Gadgets[i*2]);
02658         if (hGadget)
02659         {
02660             if (i < NumComponents)
02661             {
02662                 SetWindowPos(hGadget, NULL,
02663                                 LeftEnd, TextRect.top, NewWidth, NewHeight,
02664                                 SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOZORDER |
02665                                 SWP_NOCOPYBITS | SWP_NOREDRAW);
02666             }
02667             else
02668                 ShowWindow(hGadget, SW_HIDE);
02669         }
02670 
02671         LeftEnd += NewWidth + Gap;
02672 
02673         // Move (in x axis only) the writable gadget
02674         hGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)Gadgets[(i*2)+1]);
02675         if (hGadget)
02676         {
02677             if (i < NumComponents)
02678             {
02679                 SetWindowPos(hGadget, NULL,
02680                                 LeftEnd, TheRect.top, WritableWidth, NewHeight,
02681                                 SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOZORDER |
02682                                 SWP_NOCOPYBITS | SWP_NOREDRAW);
02683             }
02684             else
02685                 ShowWindow(hGadget, SW_HIDE);
02686         }
02687     }
02688 
02689     // Finally, redraw the affected strip of the window, because the controls won't
02690     TheRect.left = 0;       // Left edge of window
02691     TheRect.right = 0x1000; // Infinity as far as the window is concerned
02692     ::InvalidateRect((CWindowID)WindowID, &TheRect, TRUE);
02693 #endif
02694 }

BOOL ColourPicker::SetComponentsFromHexString IndexedColour Dest,
ColourContext SourceContext,
String_16 NewValue
[static, protected]
 

Converts AND COERCES the colour into the destination context. Assumes that the string will in hex format (i.e rrggbb or 0xrrggbb) Clips the string value into 0.0 to 1.0 in-gamut ranges, and then sets the components of the converted colour to those values. This thus changes the colour model in which the colour is defined as well as the component value.

Author:
Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/11/99
Parameters:
Dest - the colour to be set [INPUTS] SourceContext - the context in which the new component value is defined NewValue - new value (hexadecimal) of the components (i.e. rrggbb or 0xrrggbb)
Dest is updated appropriately [OUTPUTS]
Returns:
TRUE if success (i.e. valid input and we could do things)
Scope: private

See also:
ColourPicker::SetComponentFromDouble; ColourPicker::GetComponentAsHexString

Definition at line 1600 of file colpick.cpp.

01603 {
01604     ERROR2IF(Dest == NULL ||  SourceContext == NULL || NewValue == NULL, FALSE, 
01605                 "NULL Parameters are illegal");
01606     ERROR3IF(!Dest->IS_KIND_OF(IndexedColour) || !SourceContext->IS_KIND_OF(ColourContext),
01607                 "Parameters incorrect classes");
01608 //  ERROR2IF(!SourceContext->IS_KIND_OF(ColourContextWebRGBT), FALSE,
01609 //              "SourceContext parameter is not of type ColourContextWebRGBT");
01610 
01611     // take a copy of the string - since were going to have to interrogate/parse it ....
01612     String_16 CopyNewValue (*NewValue);
01613     // convert to lower case (avoid trouble with caps etc.)
01614     CopyNewValue.toLower ();
01615 
01616     INT32 StringLength = CopyNewValue.Length ();//camStrlen ((TCHAR*) CopyNewValue);
01617 
01618     BOOL ValidStringParseSoFar = TRUE;
01619     BOOL Single0xPrefix = FALSE;
01620     BOOL SingleHashPrefix = FALSE;
01621     BOOL More0xPrefixs = FALSE;
01622     BOOL MoreHashPrefixs = FALSE;
01623 
01624     // decide if we have a 0x prefix, or a # prefix ....
01625 
01626     const TCHAR* PtrPrefix = cc_lstrstr (CopyNewValue, _T("0x"));
01627     Single0xPrefix = (PtrPrefix != NULL) ? TRUE : FALSE;
01628     const TCHAR* PtrPrefix2 = cc_lstrstr (CopyNewValue, _T("#"));
01629     SingleHashPrefix = (PtrPrefix2 != NULL) ? TRUE : FALSE;
01630 
01631     if (Single0xPrefix == TRUE)
01632     {
01633         CopyNewValue = PtrPrefix += 2;
01634 
01635         // not quite and simple as this - since we now need to see if theres (at least) one
01636         // other 0x - and if there is, ABORT (since that cannot be a valid hex number)
01637 
01638         PtrPrefix = cc_lstrstr (CopyNewValue, _T("0x"));
01639         More0xPrefixs = (PtrPrefix != NULL) ? TRUE : FALSE;
01640 
01641         ValidStringParseSoFar = More0xPrefixs ? FALSE : TRUE;
01642 
01643         if (ValidStringParseSoFar)
01644         {
01645             // scan for # ....
01646 
01647             PtrPrefix2 = cc_lstrstr ((const TCHAR*) CopyNewValue, _T("#"));
01648             SingleHashPrefix = (PtrPrefix2 != NULL) ? TRUE : FALSE;
01649             ValidStringParseSoFar = SingleHashPrefix ? FALSE : TRUE;
01650         }
01651 
01652         if (!ValidStringParseSoFar)
01653         {
01654             return (FALSE);
01655         }
01656     }
01657     else if (SingleHashPrefix == TRUE)
01658     {
01659         CopyNewValue = PtrPrefix2 += 1;
01660 
01661         // not quite and simple as this - since we now need to see if theres (at least) one
01662         // other # - and if there is, ABORT (since that cannot be a valid hex number)
01663 
01664         PtrPrefix2 = cc_lstrstr ((const TCHAR*) CopyNewValue, _T("#"));
01665         MoreHashPrefixs = (PtrPrefix2 != NULL) ? TRUE : FALSE;
01666 
01667         ValidStringParseSoFar = MoreHashPrefixs ? FALSE : TRUE;
01668 
01669         if (ValidStringParseSoFar)
01670         {
01671             // scan for 0x ....
01672 
01673             PtrPrefix = cc_lstrstr ((const TCHAR*) CopyNewValue, _T("0x"));
01674             Single0xPrefix = (PtrPrefix != NULL) ? TRUE : FALSE;
01675             ValidStringParseSoFar = Single0xPrefix ? FALSE : TRUE;
01676         }
01677 
01678         if (!ValidStringParseSoFar)
01679         {
01680             return (FALSE);
01681         }
01682     }
01683 
01684     if (ValidStringParseSoFar == FALSE) return (FALSE);
01685 
01686     // weve made it this far - and have removed the trailing 0x
01687     // so now take a copy of the this new (copied) string and lets try to break
01688     // the string into components ....
01689 
01690     String_16 No0xPrefixNewValue (CopyNewValue);
01691     StringLength = No0xPrefixNewValue.Length ();
01692 
01693     BOOL rComponent = FALSE;
01694     BOOL bComponent = FALSE;
01695     BOOL gComponent = FALSE;
01696 
01697     String_8 rValStr;
01698     String_8 gValStr;
01699     String_8 bValStr;
01700 
01701     if ((StringLength <= 0) || (StringLength > 6)) return (FALSE);
01702 
01703     switch (StringLength)
01704     {
01705         case 2: rComponent = TRUE; break;
01706         case 4: rComponent = TRUE; gComponent = TRUE; break;
01707         case 6: rComponent = TRUE; gComponent = TRUE; bComponent = TRUE; break;
01708     }
01709 
01710     BOOL returnVal = FALSE;
01711 
01712     // now break the string and do conversions ....
01713 
01714     // NOTE - I could have made use of a for/while loop to reduce code size here; BUT
01715     // when I tried the BLOODY thing kept falling over - and it didn't seem worth it
01716     // for all the hastle ....
01717 
01718     if (IsValidHexString (No0xPrefixNewValue))
01719     {
01720         if (rComponent == TRUE)     // deal with the red component
01721         {   
01722             No0xPrefixNewValue.Split (&rValStr, &No0xPrefixNewValue, 2, FALSE);
01723            INT32 convertedVal;
01724            camSscanf(rValStr, _T("%X"), &convertedVal);
01725            camSprintf(rValStr, _T("%d"), convertedVal);
01726            //INT32 convertedVal = (INT32) strtol ((TCHAR*) rValStr, (TCHAR**) "\0", 16);//ToDec (rValStr);//atoi ((TCHAR*) rValStr);
01727            //_itoa (convertedVal, (TCHAR*) rValStr, 10);
01728 
01729             UnitGroup* pPossibleUnits = SourceContext->GetComponentUnitGroup(1);
01730             if (pPossibleUnits == NULL)
01731             {
01732                 ERROR3("ColourPicker::SetComponentFromString - SourceContext has NULL units");
01733                 return FALSE;
01734             }
01735             ERROR3IF(!pPossibleUnits->IS_KIND_OF(UnitGroup), "ColourPicker::SetComponentFromString - pPossibleUnits aren't");
01736 
01737             ScaleUnit* pUnit = pPossibleUnits->FindUnitFromIndex (1);//GetDefaultUnit();
01738             if (pUnit == NULL)
01739             {
01740                 ERROR3("ColourPicker::GetComponentAsString - Default units NULL");
01741                 return FALSE;
01742             }
01743             ERROR3IF(!pUnit->IS_KIND_OF(ScaleUnit), "pUnits isn't");
01744 
01745             double dNewVal;
01746            Convert::StringToDouble(rValStr, &dNewVal);
01747             pUnit->ConvertTo0to1 (dNewVal);
01748 
01749             // And set the new value
01750             returnVal = SetComponentFromDouble(Dest, SourceContext, 1, dNewVal);
01751         }
01752 
01753         if (gComponent == TRUE)     // deal with the green component
01754         {
01755             No0xPrefixNewValue.Split (&gValStr, &No0xPrefixNewValue, 2, FALSE);
01756            INT32 convertedVal;
01757            camSscanf(gValStr, _T("%X"), &convertedVal);
01758            camSprintf(gValStr, _T("%d"), convertedVal);
01759            //INT32 convertedVal = (INT32) strtol ((TCHAR*) gValStr, (TCHAR**) "\0", 16);//ToDec (rValStr);//atoi ((TCHAR*) rValStr);
01760            //_itoa (convertedVal, (TCHAR*) gValStr, 10);
01761 
01762             UnitGroup* pPossibleUnits = SourceContext->GetComponentUnitGroup(2);
01763             if (pPossibleUnits == NULL)
01764             {
01765                 ERROR3("ColourPicker::SetComponentFromString - SourceContext has NULL units");
01766                 return FALSE;
01767             }
01768             ERROR3IF(!pPossibleUnits->IS_KIND_OF(UnitGroup), "ColourPicker::SetComponentFromString - pPossibleUnits aren't");
01769 
01770             ScaleUnit* pUnit = pPossibleUnits->FindUnitFromIndex (1);//GetDefaultUnit();
01771             if (pUnit == NULL)
01772             {
01773                 ERROR3("ColourPicker::GetComponentAsString - Default units NULL");
01774                 return FALSE;
01775             }
01776             ERROR3IF(!pUnit->IS_KIND_OF(ScaleUnit), "pUnits isn't");
01777 
01778             double dNewVal;
01779            Convert::StringToDouble(gValStr, &dNewVal);
01780             pUnit->ConvertTo0to1 (dNewVal);
01781 
01782             // And set the new value
01783             returnVal = SetComponentFromDouble(Dest, SourceContext, 2, dNewVal);
01784         }
01785 
01786         if (bComponent == TRUE)     // deal with the blue component
01787         {
01788             No0xPrefixNewValue.Split (&bValStr, &No0xPrefixNewValue, 2, FALSE);
01789            INT32 convertedVal;
01790            camSscanf(bValStr, _T("%X"), &convertedVal);
01791            camSprintf(bValStr, _T("%d"), convertedVal);
01792            //INT32 convertedVal = (INT32) strtol ((TCHAR*) bValStr, (TCHAR**) "\0", 16);//ToDec (rValStr);//atoi ((TCHAR*) rValStr);
01793            //_itoa (convertedVal, (TCHAR*) bValStr, 10);
01794 
01795             UnitGroup* pPossibleUnits = SourceContext->GetComponentUnitGroup(3);
01796             if (pPossibleUnits == NULL)
01797             {
01798                 ERROR3("ColourPicker::SetComponentFromString - SourceContext has NULL units");
01799                 return FALSE;
01800             }
01801             ERROR3IF(!pPossibleUnits->IS_KIND_OF(UnitGroup), "ColourPicker::SetComponentFromString - pPossibleUnits aren't");
01802 
01803             ScaleUnit* pUnit = pPossibleUnits->FindUnitFromIndex (1);//GetDefaultUnit();
01804             if (pUnit == NULL)
01805             {
01806                 ERROR3("ColourPicker::GetComponentAsString - Default units NULL");
01807                 return FALSE;
01808             }
01809             ERROR3IF(!pUnit->IS_KIND_OF(ScaleUnit), "pUnits isn't");
01810 
01811             double dNewVal;
01812             Convert::StringToDouble(bValStr, &dNewVal);
01813             pUnit->ConvertTo0to1 (dNewVal);
01814 
01815             // And set the new value
01816             returnVal = SetComponentFromDouble(Dest, SourceContext, 3, dNewVal);
01817         }
01818 
01819         return (returnVal);
01820     }
01821     else
01822     {
01823         return (FALSE);     // that don't look like hex to me!
01824     }
01825 }

void ColourPicker::SetFixedComponentGadgets CWindowID  WindowID,
CGadgetID Gadgets,
CGadgetID  PickerGadget,
ColourModel  ModelToDisplay,
INT32  TextWidth[],
INT32  EditWidth[]
[static, protected]
 

Private function used by the kernel ColourEditDlg editor.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/02/2004
Parameters:
WindowID - The DialogOp->WindowID member variable of the Dialogue [INPUTS]
Gadgets - A NULL-terminated list of Gadget IDs of the gadgets to be moved/resized. There MUST be 8 gadget IDs, paired up into (name,writable) sets.

PickerGadget - specifies the gadget under which the controls are spaced. If they can be fitted, they will maybe be centered under this control in order to look neater.

ModelToDisplay - Indicates the model you're going to put into the controls This is used to determine how many components should be shown and stuff.

This takes the 5 component names and component writable fields and spreads them out within the window to allow the names to go next to the writables. The name fileds are resized to fill the available spaces, so you should make them right-aligned to keep the text a set disatnce from the writable for all colour models.

It's still up to you to set the contents of the controls, and hide any extra ones (so as much of this crap goes into the kernel as possible). This only changes the positions of the first NumComponents control-pairs.

It also hides ALL of the windows. This means that while swapping models they go off and on, but it looks a lot better than the user seeing all the faffing arounf as they are moved, resized, and have their contents changed.

Scope: private

Definition at line 2742 of file colpick.cpp.

02748 {
02749 PORTNOTE("other", "Disabled ColourPicker::SetFixedComponentGadgets")
02750 #ifndef EXCLUDE_FROM_XARALX
02751     RECT TheRect;
02752 
02753     CWindowID hGadget;
02754     INT32 Left = 0;
02755     INT32 MaxWidth = 0;
02756 //  if (NumComponents < 3)
02757     {
02758         // Use width of colour picker control
02759         hGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)PickerGadget);
02760         if (hGadget && GetWindowRect(hGadget, &TheRect))
02761         {
02762             // convert screen rect to client position within the parent wnd
02763             ::MapWindowPoints(NULL, (CWindowID)WindowID, (LPPOINT) &TheRect, 2);
02764 
02765             MaxWidth = TheRect.right - TheRect.left;
02766             Left = TheRect.left;
02767         }
02768     }
02769 
02770     // Use width of the window
02771 //  if (GetClientRect((CWindowID)WindowID, &TheRect))
02772 //  {
02773 //      MaxWidth = TheRect.right - TheRect.left;
02774 //      MaxWidth -= 2 * Left;
02775 //      Left = 0;
02776 //  }
02777 
02778 //  if (MaxWidth < 1)
02779 //      return;
02780 //
02781 
02782     // Find the top/bottom position for the text gadgets, in client coords
02783     RECT TextRect;
02784     hGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)Gadgets[0]);
02785     if (hGadget == NULL || !GetWindowRect(hGadget, &TextRect))
02786         return;
02787     ::MapWindowPoints(NULL, (CWindowID)WindowID, (LPPOINT) &TextRect, 2);
02788     INT32 TextHeight = TextRect.bottom-TextRect.top;
02789 
02790     // Get the current position of the first Editable control
02791     RECT EditRect;
02792     hGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)Gadgets[1]);
02793     GetWindowRect(hGadget, &EditRect);
02794     ::MapWindowPoints(NULL, (CWindowID)WindowID, (LPPOINT) &EditRect, 2);
02795     INT32 EditHeight = EditRect.bottom-EditRect.top;
02796 
02797     // For each component, place the controls
02798     INT32 LeftEnd = Left;
02799     INT32 i=0;
02800     const INT32 Gap = 4;            // Min. gap between adjacent fields
02801     const INT32 LabelGap = 1;
02802 
02803     for (i = 0; i < 5; i++)
02804     {
02805         // Move and resize (in x axis only) the text gadget
02806         hGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)Gadgets[i*2]);
02807         if (hGadget)
02808         {
02809             if (TextWidth[i]!=0)
02810             {
02811                 SetWindowPos(hGadget, NULL,
02812                                 LeftEnd, TextRect.top, TextWidth[i], TextHeight,
02813                                 SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOZORDER |
02814                                 SWP_NOCOPYBITS | SWP_NOREDRAW);
02815 
02816                 LeftEnd += TextWidth[i] + LabelGap;
02817             }
02818             else
02819                 ShowWindow(hGadget, SW_HIDE);
02820 
02821         }
02822 
02823         // Move (in x axis only) the writable gadget
02824         hGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)Gadgets[(i*2)+1]);
02825         if (hGadget)
02826         {
02827             if (EditWidth[i]!=0)
02828             {
02829                 SetWindowPos(hGadget, NULL,
02830                                 LeftEnd, EditRect.top, EditWidth[i], EditHeight,
02831                                 SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOZORDER |
02832                                 SWP_NOCOPYBITS | SWP_NOREDRAW);
02833 
02834                 LeftEnd += EditWidth[i] + Gap;
02835             }
02836             else
02837                 ShowWindow(hGadget, SW_HIDE);
02838 
02839         }
02840 
02841     }
02842 
02843     // Finally, redraw the affected strip of the window, because the controls won't
02844     EditRect.left = 0;      // Left edge of window
02845     EditRect.right = 0x1000;    // Infinity as far as the window is concerned
02846     ::InvalidateRect((CWindowID)WindowID, &EditRect, TRUE);
02847 #endif
02848 }

void ColourPicker::SetGadgetPositions CWindowID  WindowID,
CGadgetID Gadgets,
CGadgetID  MoveUnder
[static, protected]
 

Private function used by the kernel ColourEditDlg editor. Given a WindowID and GadgetIDs (cf DialogOp->DialogMgr interface), this moves all the gadgets such that (a) All the gadgets in the group remain in the same relative positions, and (b) the Gadgets[0] gadget is moved to lie just underneath the MoveUnder gadget.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/11/94
Parameters:
WindowID - The DialogOp->WindowID member variable of the Dialogue [INPUTS]
Gadgets - A NULL-terminated list of Gadget IDs of the gadgets to be moved. The first entry in this list is the anchor gadget - it will be moved just under 'MoveUnder', and the others will stay in the same position relative to the first gadget in the list.

MoveUnder - The gadget ID of the gadget under which all these gadgets should be positioned, or NULL to 'hide' the gadgets well off the window

The X positions of the gadgets are unaffected by this call.

If MoveUnder == NULL, then the gadgets are moved a large distance away so that they will not appear in the visible portion of the window.

This is used to move tint/link options to the bottom of the editor window, while hiding the link/tint options gadgtes respectively.

Scope: private

Definition at line 2409 of file colpick.cpp.

02411 {
02412 PORTNOTE("other", "Disabled ColourPicker::SetGadgetPositions");
02413 #ifndef EXCLUDE_FROM_XARALX
02414     if (Gadgets == NULL || !Gadgets[0])
02415         return;
02416 
02417     CWindowID hGadget;
02418     RECT MoveRect;
02419     POINT TopLeft;
02420     INT32 YShift = 10000;       // If MoveUnder == NULL, move out of the way
02421 
02422     if (MoveUnder)
02423     {
02424         // Get the positions of the MoveUnder and Gadgets[0] gadgets, and work out
02425         // the Y Shift to move Gadgets[0] just under the MoveUnder gadget.
02426         // All calculations are done in Client coords (not screen coords)
02427         hGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)MoveUnder);
02428         if (!GetWindowRect(hGadget, &MoveRect))
02429             return;
02430 
02431         TopLeft.x = MoveRect.left;
02432         TopLeft.y = MoveRect.bottom;
02433         ScreenToClient((CWindowID)WindowID, &TopLeft);
02434         YShift = -(TopLeft.y + 8);      // Remember first part of the shift
02435 
02436         hGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)Gadgets[0]);
02437         if (!GetWindowRect(hGadget, &MoveRect))
02438             return;
02439 
02440         TopLeft.x = MoveRect.left;
02441         TopLeft.y = MoveRect.top;
02442         ScreenToClient((CWindowID)WindowID, &TopLeft);
02443 
02444         YShift += TopLeft.y;            // Complete the shift calculation
02445     }
02446     else
02447     {
02448         // Move the gadgets out of view: Check if we need to bother to do this
02449         // (are they aready out of view?)
02450 
02451         hGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)Gadgets[0]);
02452         if (!GetWindowRect(hGadget, &MoveRect))
02453             return;
02454 
02455         TopLeft.x = MoveRect.left;
02456         TopLeft.y = MoveRect.top;
02457         ScreenToClient((CWindowID)WindowID, &TopLeft);
02458 
02459         if (abs(TopLeft.y) > 8000)      // Is it already out of the way?
02460             YShift = 0;                 // Yes - so don't shift it
02461     }
02462 
02463     if (YShift == 0)                    // No shift needed!
02464         return;
02465 
02466     INT32 Index = 0;
02467     while (Gadgets[Index] != 0)
02468     {
02469         hGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)Gadgets[Index]);
02470 
02471         if (GetWindowRect(hGadget, &MoveRect))
02472         {
02473             TopLeft.x = MoveRect.left;      // Convert TopLeft coord into client coords
02474             TopLeft.y = MoveRect.top;
02475             ScreenToClient((CWindowID)WindowID, &TopLeft);
02476             TopLeft.y -= YShift;
02477 
02478             SetWindowPos(hGadget, NULL,
02479                             TopLeft.x, TopLeft.y, 0, 0,
02480                             SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER);
02481         }
02482 
02483         Index++;
02484     }
02485 #endif
02486 }

BOOL ColourPicker::SetShadeFromStrings IndexedColour Dest,
StringBase NewValueX,
StringBase NewValueY
[static, protected]
 

Assumes that the string will be -100..100 Clips the string value into a -1.0 to 1.0 in-gamut range, and then sets the shade components of the converted colour to those values.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/10/95
Parameters:
Dest - the colour to be set [INPUTS] NewValueX - new value (decimal, as -100..100) of the shade X component NewValueY - new value (decimal, as -100..100) of the shade Y component
Dest is updated appropriately [OUTPUTS]
Returns:
TRUE if the value was out of gamut and had to be clipped
Notes: ENSUREs and does nothing if the colour is not already a Shade

Scope: private

See also:
ColourPicker::GetShadeValueAsString

Definition at line 2216 of file colpick.cpp.

02217 {
02218     ERROR3IF(Dest == NULL || NewValueX == NULL || NewValueY == NULL,
02219                 "ColourPicker::SetShadeFromStrings - NULL Parameters are illegal");
02220     
02221     if (Dest->GetType() != COLOURTYPE_TINT)
02222     {
02223         ERROR3("ColourPicker::SetShadeFromStrings - colour isn't a tint/shade");
02224         return(FALSE);
02225     }
02226 
02227 
02228     // Turn all percent signs in the number to spaces so the StringToDouble doesn't yell and scream
02229     String_8 TempString;
02230     NewValueX->Left(&TempString, 7);
02231     TempString.SwapChar(_T('%'),_T(' '));
02232 
02233     // Convert the string to a double using the global conversion routine
02234     // Note that we ignore failure, because the number is validated below, and it
02235     // only seems to retun false if crap was typed on the end of the number anyway
02236     double NewValX;
02237     Convert::StringToDouble(TempString, &NewValX);
02238 
02239     // Convert from percentage to -1.0-1.0 range
02240     NewValX = (-NewValX) / 100.0;
02241 
02242     BOOL OutOfGamut = FALSE;
02243 
02244     // Add half of the least-significant-bit-value to round the new value
02245     NewValX += 1.0 / ((double) (1<<25));
02246 
02247     // Clip to lie within gamut
02248     if (NewValX < -1.0)
02249     {
02250         NewValX = -1.0;
02251         OutOfGamut = TRUE;
02252     }
02253 
02254     if (NewValX > 1.0)
02255     {
02256         NewValX = 1.0;
02257         OutOfGamut = TRUE;
02258     }
02259 
02260 
02261     // Turn all percent signs in the number to spaces so the StringToDouble doesn't yell and scream
02262     NewValueY->Left(&TempString, 7);
02263     TempString.SwapChar(_T('%'),_T(' '));
02264 
02265     // Convert the string to a double using the global conversion routine
02266     // Note that we ignore failure, because the number is validated below, and it
02267     // only seems to retun false if crap was typed on the end of the number anyway
02268     double NewValY;
02269     Convert::StringToDouble(TempString, &NewValY);
02270 
02271     // Convert from percentage to -1.0-1.0 range
02272     NewValY /= 100.0;
02273 
02274     // Add half of the least-significant-bit-value to round the new value
02275     NewValY += 1.0 / ((double) (1<<25));
02276 
02277     // Clip to lie within gamut
02278     if (NewValY < -1.0)
02279     {
02280         NewValY = -1.0;
02281         OutOfGamut = TRUE;
02282     }
02283 
02284     if (NewValY > 1.0)
02285     {
02286         NewValY = 1.0;
02287         OutOfGamut = TRUE;
02288     }
02289 
02290     Dest->SetShadeValues(FIXED24(NewValX), FIXED24(NewValY));
02291 
02292     return(OutOfGamut);
02293 }

BOOL ColourPicker::SetTintFromString IndexedColour Dest,
StringBase NewValue
[static, protected]
 

Assumes that the string will be 0..100 Clips the string value into a 0.0 to 1.0 in-gamut range, and then sets the tint component of the converted colour to that value.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/8/95
Parameters:
Dest - the colour to be set [INPUTS] NewValue - new value (decimal, as 0..100) of the tint
Dest is updated appropriately [OUTPUTS]
Returns:
TRUE if the value was out of gamut and had to be clipped
Notes: ENSUREs and does nothing if the colour is not already a Tint

Scope: private

See also:
ColourPicker::GetTintAsString

Definition at line 2058 of file colpick.cpp.

02059 {
02060     ERROR3IF(Dest == NULL || NewValue == NULL,
02061                 "ColourPicker::SetTintFromString - NULL Parameters are illegal");
02062     
02063     if (Dest->GetType() != COLOURTYPE_TINT)
02064     {
02065         ERROR3("ColourPicker::SetTintFromString - colour isn't a tint");
02066         return(FALSE);
02067     }
02068 
02069     // Turn all percent signs in the number to spaces so the StringToDouble doesn't yell and scream
02070     String_8 TempString;
02071     NewValue->Left(&TempString, 7);
02072     TempString.SwapChar(_T('%'), _T(' '));
02073 
02074     // Convert the string to a double using the global conversion routine
02075     // Note that we ignore failure, because the number is validated below, and it
02076     // only seems to retun false if crap was typed on the end of the number anyway
02077     double NewVal;
02078     Convert::StringToDouble(TempString, &NewVal);
02079 
02080     // Convert from percentage to 0.0-1.0 range
02081     NewVal /= 100.0;
02082 
02083     BOOL OutOfGamut = FALSE;
02084 
02085     // Add half of the least-significant-bit-value to round the new value
02086     NewVal += 1.0 / ((double) (1<<25));
02087 
02088     // Clip to lie within gamut
02089     if (NewVal < 0.0)
02090     {
02091         NewVal = 0.0;
02092         OutOfGamut = TRUE;
02093     }
02094 
02095     if (NewVal > 1.0)
02096     {
02097         NewVal = 1.0;
02098         OutOfGamut = TRUE;
02099     }
02100 
02101     // And set the new value
02102     if (Dest->TintIsShade())
02103     {
02104 //      Dest->SetShadeValue(NewVal);
02105     }
02106     else
02107         Dest->SetTintValue(NewVal);
02108 
02109     return(OutOfGamut);
02110 }

void ColourPicker::SetWindowExtent CWindowID  WindowID,
CGadgetID  XGadgetID,
CGadgetID  YGadgetID
[static, protected]
 

Private function used by the kernel ColourEditDlg editor. Given a WindowID and GadgetID (cf DialogOp->DialogMgr interface), this sets the window extent of the window to a short distance outside the right/ bottom edges of the X/Y named gadgets respectively.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/11/94
Parameters:
WindowID - The DialogOp->WindowID member variable of the Dialogue [INPUTS] XGadgetID - The Gadget ID of the gadget to be at the right side of the dlg YGadgetID - The Gadget ID of the gadget to be at the bottom of the dlg
The colour editor uses this to 'fold' and 'unfold' its window to hide/show the advanced editing options.

Scope: private

Definition at line 2321 of file colpick.cpp.

02323 {
02324 PORTNOTE("other", "Disable Colourpicker::SetWindowExtent")
02325 #ifndef EXCLUDE_FROM_XARALX
02326     CWindowID hXGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)XGadgetID);
02327     CWindowID hYGadget = DialogManager::GetGadget((CWindowID)WindowID, (INT32)YGadgetID);
02328 
02329     RECT MainWinPos;
02330     RECT XGadgetPos;
02331     RECT YGadgetPos;
02332     BOOL ok = TRUE;
02333 
02334     // We can't use GetWindowRect() for the gadgets then use these values when adjusting
02335     // the values you get from GetWindowPlacement() for the main window, because they use two
02336     // different origins.
02337     //
02338     // Basically, using the above calls will result in errors if the task bar is at the top of the
02339     // screen, because one call uses the actual screen top-left coord, the other uses the top-ledt coord
02340     // of the desk top excluding the task bar.
02341     //
02342     // The method used here uses GetWindowRect() for all three gadgets to work out a relative difference
02343     // between the gadgets.  It then uses GetWindowPosition() & SetWindowPosition() which work consistantly
02344     // because they use the same coord space.
02345 
02346     // Collect the screen positions of the three items
02347     if (ok) ok = GetWindowRect((CWindowID)WindowID,&MainWinPos);
02348     if (ok) ok = GetWindowRect(hXGadget,&XGadgetPos);
02349     if (ok) ok = GetWindowRect(hYGadget,&YGadgetPos);
02350 
02351     if (ok)
02352     {
02353         // dx & dy are calculated to be the amount we need to adjust the right & bottom of the
02354         // dlg to come in line with the two gadgets given
02355         INT32 dx = MainWinPos.right  - XGadgetPos.right;
02356         INT32 dy = MainWinPos.bottom - YGadgetPos.bottom;
02357 
02358         // Get the window's screen position
02359         if (DialogManager::GetWindowPosition(WindowID, &MainWinPos))
02360         {
02361             // Adjust it (with added help from a bodge value)
02362             MainWinPos.right  -= dx - 6;
02363             MainWinPos.bottom -= dy - 6;
02364 
02365             // Set it back again
02366             DialogManager::SetWindowPosition(WindowID, MainWinPos);
02367         }
02368     }
02369 #endif
02370 }

void ColourPicker::UpdateBubbleHelpAndPointer void   )  [static]
 

Called on Idle (or MouseMove) events to provide bubble help and update the mouse pointer while it is over the colour editor dialogue.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/9/95
Notes: This is basically a bodge until a proper dialogue bubblehelp system is available to do everything I need to do in the colour editor.

See also:
ColourEditDlg::GetStatusLineText

Definition at line 1050 of file colpick.cpp.

01051 {
01052 PORTNOTE("other", "Disabled ColourPicker::UpdateBubbleHelpAndPointer()")
01053 #ifndef EXCLUDE_FROM_XARALX
01054 #ifndef STANDALONE
01055     ColourEditDlg *Editor = ColourEditDlg::TheEditor;
01056     if (Editor == NULL)
01057         return;
01058 
01059     static CWindowID TheWindow = NULL;
01060     
01061     if (TheWindow == NULL)
01062         TheWindow = (CWindowID)Editor->WindowID;
01063 
01064     if (TheWindow == NULL)
01065         return;
01066 
01067     // We will update the bubble help every time we are called. However, we will only
01068     // bother checking through all the gadgets in the window a maximum of 10 times
01069     // per second. This stops the colour editor making a CPU interference buzzing noise
01070     // in my headphones while the pointer is idling over it!!
01071     static MonotonicTime LastUpdate;
01072     static UINT32 MousePos = 0;
01073 
01074     if (LastUpdate.Elapsed(100))
01075     {
01076         // Remember when we last checked
01077         LastUpdate.Sample();
01078 
01079         // Default to the mouse being "nowhere special" again
01080         TheWindow = (CWindowID)Editor->WindowID;
01081         MousePos = 0;
01082 
01083         POINT MouseScreenPos;
01084         if (::GetCursorPos(&MouseScreenPos))
01085         {
01086             // Only continue processing if the window under the pointer is the colour editor
01087             // or a child thereof. My machine makes a funny CPU buzz in my earphones when the
01088             // pointer is in the editor window, and it was doing this even when I had another
01089             // application maximised in front of camelot! ChildWindowFromPoint does not
01090             // determine if the child window is actually *visible*!
01091 
01092             CWindowID WindowUnder = ::WindowFromPoint(MouseScreenPos);
01093 
01094             if (WindowUnder != NULL &&
01095                 (WindowUnder == TheWindow || ::GetParent(WindowUnder) == TheWindow))
01096             {
01097                 POINT TempPos;
01098                 TempPos.x = MouseScreenPos.x;
01099                 TempPos.y = MouseScreenPos.y;
01100 
01101                 // Convert to client coords in the main window
01102                 ::ScreenToClient(TheWindow, &TempPos);
01103 
01104                 CPoint Pos(TempPos);
01105                 CWindowID WindowUnderPointer = ::ChildWindowFromPoint(TheWindow, Pos);
01106                 if (WindowUnderPointer != NULL && IsWindowVisible(WindowUnderPointer))
01107                 {
01108                     // Make sure that hidden windows do not provide status help!
01109                     INT32 WindowStyle = ::GetWindowLong(WindowUnderPointer, GWL_STYLE);
01110                     if ((WindowStyle & WS_VISIBLE) != 0)
01111                     {
01112                         CWindowID hGadget;
01113                         INT32 i = 0;
01114                         while (GadgetList[i] && MousePos)
01115                         {
01116                             hGadget = DialogManager::GetGadget(TheWindow, GadgetList[i]);
01117                             if (WindowUnderPointer == hGadget)
01118                             {
01119                                 MousePos = (UINT32)GadgetList[i];
01120                                 TheWindow = hGadget;
01121                             }
01122                             i++;
01123                         }
01124                     }
01125                 }
01126 
01127                 // Special check for Picker control (BODGE is a more accurate term!)
01128                 // We look to see if the pointer is vaguely over the area of the picker used
01129                 // to display the current/original colour patch, and only give help for that
01130                 // region!
01131 
01132                 if (MousePos == _R(IDC_EDIT_PICKER))
01133                 {
01134                     MousePos =0;    // Default to no help if anything goes wrong
01135 
01136                     // Set up a ReDrawInfoType containing the click position info, and information
01137                     // that will come in handy (size of the gadget, and screen DPI)
01138                     ReDrawInfoType ExtraInfo;
01139 
01140                     ExtraInfo.pDC = NULL;       // No redraw info for mouse events
01141                     ExtraInfo.pClipRect = NULL;
01142 
01143                     // Get the screen DPI
01144                     HDC ScreenDC = CreateCompatibleDC(NULL);
01145                     if (ScreenDC == NULL)
01146                     {
01147                         ERROR3("ColourPicker: Unable to create screen DC");
01148                         return;
01149                     }
01150                     ExtraInfo.Dpi = GetDeviceCaps(ScreenDC, LOGPIXELSY);
01151                     DeleteDC(ScreenDC);
01152 
01153                     // Calculate how big the window is, in MILLIPOINTS
01154                     RECT WindowSize;
01155                     if (!GetClientRect(TheWindow, &WindowSize))
01156                     {
01157                         ERROR3("GetClientRect failed in ColourPicker");
01158                         return;
01159                     }
01160 
01161                     ExtraInfo.dx = (((INT32)WindowSize.right)*72000) / ExtraInfo.Dpi;
01162                     ExtraInfo.dy = (((INT32)WindowSize.bottom)*72000) / ExtraInfo.Dpi;
01163 
01164                     // Work out the MILLIPOINT coordinates of the mouse position
01165                     // Note that the Y value is flipped, as the kernel-origin is at the bottom left
01166                     // and we have to first convert the screen mouse position into client coords
01167                     ScreenToClient(TheWindow, &MouseScreenPos);
01168 
01169                     INT32 XPos = (INT32) MouseScreenPos.x;
01170                     INT32 YPos = (INT32) MouseScreenPos.y;
01171 
01172                     DocCoord MouseInfo;
01173                     MouseInfo.x = (XPos * 72000) / ExtraInfo.Dpi;
01174                     MouseInfo.y = ExtraInfo.dy - ((YPos * 72000) / ExtraInfo.Dpi);
01175                     ExtraInfo.pMousePos = &MouseInfo;
01176 
01177                     // Now call the colour editor to handle the mouse position - it will
01178                     // set the pointer shape as appropriate and also return us some bubble help.
01179                     PickerBubbleBuffer = String_128("");
01180                     StatusHelpBuffer = String_256("");
01181                     Editor->HandleIdlePointer(&ExtraInfo, &PickerBubbleBuffer, &StatusHelpBuffer, &MousePos);
01182 
01183                     if (MousePos)
01184                         ControlHelper::BubbleHelpDisable();     // On non-helpful bit of picker - cancel bubble help
01185                 }
01186             }
01187         }
01188     }
01189 
01190     // Finally, tell the bubble help system what help we want, if any
01191     if (MousePos)
01192     {
01193         // Set up our callback handler to show the help if/when necessary
01194         ControlHelper::DoBubbleHelpOn(TheWindow, MousePos, ColourPicker::HelpCallbackHandler, NULL);
01195     }
01196 #endif
01197 #endif
01198 }


Friends And Related Function Documentation

friend class ColourEditDlg [friend]
 

Definition at line 142 of file colpick.h.

friend class ColourLinkDlg [friend]
 

Definition at line 143 of file colpick.h.

friend class NewColourDlg [friend]
 

Definition at line 144 of file colpick.h.


Member Data Documentation

INT32 ColourPicker::s_IdleCounter = 0 [static, private]
 

Definition at line 266 of file colpick.h.

BOOL ColourPicker::s_InColourDialogLayout = FALSE [static, private]
 

Definition at line 264 of file colpick.h.

BOOL ColourPicker::s_JustCreated = FALSE [static, private]
 

Definition at line 265 of file colpick.h.

wxSize ColourPicker::s_LastSize = wxDefaultSize [static, private]
 

Definition at line 261 of file colpick.h.

wxSize ColourPicker::s_MinSize = wxSize(180,100) [static, private]
 

Definition at line 263 of file colpick.h.

wxSize ColourPicker::s_UserSize = wxSize(245,245) [static, private]
 

Definition at line 262 of file colpick.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:52:59 2007 for Camelot by  doxygen 1.4.4