CColourBar Class Reference

The CColourBar window - a window like the status bar, which contains a strip of colours that can be used in the selected Document. More...

#include <ccolbar.h>

List of all members.

Public Member Functions

 CColourBar ()
 CColourBar constructor Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care.
virtual ~CColourBar ()
 Destroys the object, as one might expect. Notes: IMPORTANT - After calling the destructor (delete ColourBar) it is VITAL that you then call RecalcLayout() for the main frame window in which the Colour Bar is appearing (the one you passed in to PB::Create(). If you don't do this, the bar won't disappear until the next time the main window is resized or a tool is chosen.
BOOL Create (wxWindow *parent, UINT32 id)
 Creates a window and associates it with this CColourBar object. The window appears at the bottom of the main frame window, just like the status bar.
virtual wxSize DoGetBestSize () const
void SetSizes (INT32 NewCellSize, INT32 NewScrollbarSize)
 Sets the base sizes of the colour strip and colour scroll bar in the colour bar window. Other features of the bar are automatically resized to fit the new sizing. The bar will be redrawn. If the combined height of the bar elements has now changed, the bar will be resized (by calling the parent's RecalcLayout method).
INT32 GetNumberOfColours ()
 Determines the number of colours that we wish to display on the ColourBar.
BOOL IsColourPickerOverStripRect (wxWindow *colourPicker, wxPoint mousePt)
 This function helps to determin how colour picker controls should behave when they are over the colour bar.
BOOL DoColourPickerColour (wxWindow *colourPicker, wxPoint mousePt, IndexedColour **pTheCol=NULL)
 Instruct the colour edit dialog to use that colour on the colour bar (of which the colour picker is over).

Static Public Member Functions

static void RedrawGBrushAreas (void)
 Force-redraws all areas of the colourbar that depend upon GBrush for their rendering. Used by winoil.cpp when GBrush rendering is enabled or disabled in order to redraw the colourbar.
static void Show (BOOL HideOrShow=FALSE)
 Tells the colour bar to show or hide itself. The bar will remain visible/hidden until the next call to this method. If no colour bar currently exists, the desired state will be remembered and used on creation of any new bar.
static void SetDisplayMode (INT32 NewDisplayMode=-1)
 Sets the Colour Bar display mode to the new value. Current legal mode values are 0..3 (small, med, med+scroll, large) Illegal values will cause it to resort to the default mode, medium+scroll (2) The default value of -1 is used to mean 'use the preference setting'. This allows the prefs dialogue to cause the ColourBar to sit up and take notice of changed preference settings. The preference setting ColourBarMode will be set to the new value.
static BOOL GetStatusLineText (String_256 *Result)
 To retrieve help text for use by the status line system.
static CColourBarGetColourBar ()
static BOOL EnsureLibraryColoursPresent ()
 Ensures that any colour library sections we require are present.

Protected Member Functions

void DoPaint (wxDC *pDC)
 Redraws the ColourBar window contents.
void OnPaint (wxPaintEvent &event)
 Redraws the colour bar.
void OnSize (wxSizeEvent &event)
 Handle resizing of our window. This ensures that the scroll offset is within the new bounds of the colour strip, and forces a redraw.
void OnLButtonDown (wxMouseEvent &event)
 Handle left-button clicks in the colour bar Note that a shift-click is converted into the equivalent of a right-click by this function.
void OnRButtonDown (wxMouseEvent &event)
 Handle right-button clicks in the Colour Bar.
void OnLButtonDblClk (wxMouseEvent &event)
 Handle left-button double clicks in the colour bar.
void OnRButtonDblClk (wxMouseEvent &event)
 Handle right-button double clicks in the Colour Bar.
void OnLButtonUp (wxMouseEvent &event)
 Processes a left-button-released message.
void OnRButtonUp (wxMouseEvent &event)
 Processes a right-button-released message.
void OnMouseMove (wxMouseEvent &event)
 Processes all mouse moves over the colour bar. This currently involves providing bubble help and updating during drags of the scroll sausage. Other 'drag' updates (button autorepeats) are handled by OnTimer().
void OnTimer (wxTimerEvent &event)
 Responds to the triggering of the timer which we set when a click or drag first occurred, in order to check for auto-repeat of buttons. This currently processes the scroll left/right and page left/right areas Dragging the scroll sausage is handled in OnMouseMove.
BOOL HasNoScrollBar (INT32 DisplayedColours, INT32 MaxColours, wxRect *pStripRect=NULL)
 Determines if the ColourBar actually need bother with a scrollbar (It does not need one if it can display all the available colours).
void CalculateRects (void)
 Calculates various useful rectangular regions to be found within the Colour Bar window. Returns the screen rectangles ready for redraw.
void CalculateRectsInternal (wxRect *pWindowRect, wxRect *pStripRect, wxRect *pIndicatorRect, wxRect *pScrollBarRect, wxRect *pEditButtonRect, wxRect *pNewButtonRect)
 Calculates various useful rectangular regions to be found within the Colour Bar window. Returns the screen rectangles ready for redraw.
BOOL CalculateSausageRect (wxRect *Result)
 Calculates the scroll sausage area within the scroll bar rectangle Notes: You must call CalculateRects and cache the value of TotalNumColours prior to calling this function - see DoPaint for everything that needs to be done. The ColourBar works exclusively on the SELECTED Doc. Change with care.
void CalculateNoColourCellRect (wxRect *Rect)
 Calculates the 'NoColour' colour cell position, just to the left of the ColourStrip Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care.
INT32 CalculateNewBarHeight (wxRect *AvailableRect)
 Determine how high the colour bar should be - this is difficult, because the height depends upon whether we want a scrollbar, and this in turn depends upon how wide the colourstrip is.
INT32 CalculateColourCellIndex (IndexedColour *TheColour)
 Searches the colour list to find the given colour, returning its index in the list if it is found, or a negative value if it is not.
INT32 CalculateColourCellIndex (DocColour *TheColour)
 Given a DocColour, will determine which *visible* colour cell, if any, is displaying that colour, anmd return its Cell Index.
void OnAnyButtonUp (const wxPoint &point)
 Processes any button-released event. This stops auto-repeat and drags, and releases any claims (timers, drags) we might have.
void OnAnyButtonDown (const wxPoint &point, INT32 Modifier)
 Handle button clicks in the colour bar. Called by the LButton and RButton handlers to share the code somewhat.
void OnAnyButtonDblClk (wxPoint point, INT32 Modifier)
 Handle double clicks in the colour bar. This brings up the colour picker on the given colour. This works on any colour cell, including the current colour indicators. Double clicks on scroll arrows are passed on to the normal single-click handler (otherwise every second click, when repeating fast, is lost).
void EditAColour (ColourList *DisplayList, IndexedColour *TheColour, BOOL LineColour=FALSE)
 Edits the given colour.
INT32 WhereIsMouse (wxPoint MousePos, wxRect *TheRectItIsIn=NULL, BOOL *ToLeft=NULL)
 Checks which part of the ColourBar the given point lies over (if any) and returns a value indicating where it is.
void ApplyColour (IndexedColour *TheColour, BOOL SetLineColour)
 Applies the given IndexedColour as a stroke/fill colour attribute to the selected objects. This also makes the colour the 'current' attribute, etc, if desired by the user.
void CellClicked (INT32 CellIndex, BOOL SetLineColour)
 Processes a click on a given colour cell by setting the line/fill colour of the selected objects, or if nothing is selected, setting the default line/fill colour.
IndexedColourFindColourByIndex (UINT32 Index)
 Given the current Display List, finds the 'Index'th item, and dereferences it to find the actual IndexedColour that lies at that list position in the current colour bar display order.
DocColourFindLibColourByIndex (UINT32 Index, SGDisplayLibColour **ppLibColour=NULL)
 Given the current Display List, finds the 'Index'th item, and dereferences it to find the actual DocColour that lies at that list position in the current colour bar display order. This will only look through the Library colours and hence returns DocColours rather than indexed colours.
IndexedColourFindLibIndexedColourByIndex (UINT32 Index)
 Given the current Display List, finds the 'Index'th item, and dereferences it to find the actual DocColour that lies at that list position in the current colour bar display order. This will only look through the Library colours and hence finds DocColours rather than indexed colours. This versions is the same as above but then goes and creates an IndexedColour in the current document and returns this.
void PaintColourCell (wxDC *pDC, wxRect *Rect, DocColour *RectCol)
 Draws the given rectangle as a 'Colour cell' for the given DocColour. The top half of the rect is solid-filled with the colour, while the bottom 2 quarters are filled with the colour as it would appear on top of a white background and black bgnd respectively (if the col isn't fractionally transparent, rect is just solid filled).
void PaintNoColourCell (wxDC *pDC)
 Draws the 'NoColour' colour cell just to the left of the ColourStrip Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care.
void PaintIndicatorDiamond (wxDC *pDC, const wxRect &CellRect, CBColourType ColourType, INT32 CellIndex, BOOL DiamondType)
 Draws a small diamond in the top left/right corner of a colour cell to indicate that the given cell is the current line/fill colour.
void PaintColourStrip (wxDC *pDC, const wxRect &ClipRect)
 Redraws the ColourBar colour strip Notes: You must call CalculateRects and cache the value of TotalNumColours prior to calling this function - see DoPaint for everything that needs to be done. If GBrush has been initialised before calling this function, it will be used to plot the colour cells.
void PaintIndicators (wxDC *pDC)
 Redraws the ColourBar colour indicators (current fg/bg colours) Notes: You must call CalculateRects and cache the value of TotalNumColours prior to calling this function - see DoPaint for everything that needs to be done. If GBrush has been initialised before calling this function, it will be used to plot the colour cells. The ColourBar works exclusively on the SELECTED Doc. Change with care.
void PaintEditOrNewButton (wxDC *pDC, BOOL Normal, BOOL IsEditButton)
 Draws the colour bar "edit colour" or "new colour" button Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care.
void PaintScrollButton (wxDC *pDC, INT32 ButtonID, BOOL Normal)
 Draws a scroll button at the appropriate end of the scroll bar The button is scaled to fit into (ButtonWidth x ScrollHeight) Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care.
void PaintScrollBar (wxDC *pDC)
 Redraws the ColourBar window's mini proportional scroll bar Notes: You must call CalculateRects and cache the value of TotalNumColours prior to calling this function - see DoPaint for everything that needs to be done.
void PaintLibColourCell (wxDC *pDC, wxRect *Rect, DocColour *RectCol, BOOL SpotColour=FALSE)
 Draws the given rectangle as a 'Colour cell' for the given DocColour.
void ForceRedrawOfCell (INT32 CellIndex)
 Forces a redraw of the given Cell in the colour strip. The index is from the first colour in the list - if this is outside the displayed portion of the colour strip, no action will be taken Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care.
void ForceRedrawOfCell (DocColour *TheColour)
void ForceRedrawOfRect (const wxRect &RectToDraw)
 Causes the given portion of the colour bar to be redrawn Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care.
void ScrollTheStrip (INT32 ScrollBy, BOOL RedrawAlways=FALSE)
 Scrolls the colour strip to the left or right. Does not allow scrolling past the ends of the available list. Causes the window to be redrawn.
void CaptureTheMouse (void)
 Captures the mouse for drags/autorepeat. Nothing will be done if we already have mouse capture.
void SetATimer (BOOL Delay)
 Sets a timer to cause a timer message to be sent to us after the keyboard auto-repeat delay. If we are already waiting for a timer event, the current timer will be replaced by the new one.
void ReleaseAllClaims (void)
 Ensures that all our temporary claims (timers, mouse capture) are released.
BOOL InitPrefs (void)
 Initialisation of ColourBar preference option(s) Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care.
wxBrush * GetColourBrush (COLORREF rgb)
 Calculates a logical brush for use in painting. If GDraw is available via CColourBar::GDrawBrush, GDraw will be used. If not, GDI will be used. Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care.
void SelectionHasChangedInternal (void)
 This will cause the colourbar to redraw any necessary portions of the colour strip and indicators to indicate the colour of the selection (or the default line/fill colours if there is no selection).

Static Protected Member Functions

static INT32 GetCurrentBarHeight (void)
 Determine how high the colour bar currently is.
static TCHARHelpCallbackHandler (wxWindow *Window, INT32 Item, void *This)
 Callback handler for providing Bubble help over the Colour Bar window.
static void PaletteHasChanged (ColourList *ChangedList=NULL)
 This will cause the colourbar to redraw itself with the new list if necessary, and cache new values for the new current list.
static void SelectionHasChanged (void)
 This will cause the colourbar to redraw any necessary portions of the colour strip and indicators to indicate the colour of the selection (or the default line/fill colours if there is no selection).

Protected Attributes

INT32 m_cxLeftBorder
INT32 m_cyTopBorder
INT32 m_cxRightBorder
INT32 m_cyBottomBorder
UINT32 LeftmostColour
UINT32 TotalNumColours
INT32 LastLineCell
INT32 LastFillCell
INT32 LastEndCell
BOOL LastDiamondShape
INT32 IndentedButton
ColourListm_pCurrentColourList
ColourBarMsgHandlerMsgHandler
wxRect WindowRect
wxRect StripRect
wxRect IndicatorRect
wxRect ScrollBarRect
wxRect EditButtonRect
wxRect NewButtonRect
INT32 OldBarHeight
wxTimer m_DragTimer
ColourSGallerym_pColourGallery
CBDragInfo DragInfo
CursorPushCursor
GBrush GDrawBrush

Static Protected Attributes

static CColourBarTheColourBar = NULL
static BOOL BarIsVisible = TRUE

Friends

class ColourBarMsgHandler
class ColourDragInformation
class EditButtonDragTarget
class ColourLineDragTarget


Detailed Description

The CColourBar window - a window like the status bar, which contains a strip of colours that can be used in the selected Document.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/6/94

Definition at line 282 of file ccolbar.h.


Constructor & Destructor Documentation

CColourBar::CColourBar  ) 
 

CColourBar constructor Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care.

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

Definition at line 827 of file ccolbar.cpp.

00828 {
00829     m_pCurrentColourList = NULL;
00830 
00831     LeftmostColour = 0;         // Initially, are at left end of the colourstrip
00832 
00833     LastLineCell = CELLINDEX_NOCELL;    // We have not drawn any indicator diamonds anywhere
00834     LastFillCell = CELLINDEX_NOCELL;
00835     LastEndCell  = CELLINDEX_NOCELL;
00836     LastDiamondShape = TRUE;
00837 
00838     IndentedButton = CLICKED_NOTHING;
00839 
00840     m_cxLeftBorder = 1;         // Automatic 1 pixel gap at left end of bar
00841     m_cyTopBorder = 0;
00842     m_cxRightBorder = 0;
00843     m_cyBottomBorder = 0;
00844 
00845     TheColourBar = this;
00846 
00847     MsgHandler = NULL;
00848 
00849     m_DragTimer.SetOwner(this, 2);
00850 
00851     DragInfo.TimerOn = 0;
00852     DragInfo.MouseCaptured = FALSE;
00853 
00854     PushCursor = NULL;
00855 
00856     OldBarHeight = 0;
00857 
00858     // We have no current colour gallery to access the fixed gallery section colours
00859     m_pColourGallery = NULL;
00860 }

CColourBar::~CColourBar  )  [virtual]
 

Destroys the object, as one might expect. Notes: IMPORTANT - After calling the destructor (delete ColourBar) it is VITAL that you then call RecalcLayout() for the main frame window in which the Colour Bar is appearing (the one you passed in to PB::Create(). If you don't do this, the bar won't disappear until the next time the main window is resized or a tool is chosen.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/6/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-
The ColourBar works exclusively on the SELECTED Doc. Change with care

Definition at line 884 of file ccolbar.cpp.

00885 {
00886     TheColourBar = NULL;    // There is no longer a colour bar around   
00887 
00888     if (MsgHandler != NULL)
00889         delete MsgHandler;  // Kill our message handler
00890 
00891     ReleaseAllClaims();     // Ensure all temp. window claims (mouse/timer) released
00892 
00893     if (PushCursor)
00894         delete PushCursor;
00895 }


Member Function Documentation

void CColourBar::ApplyColour IndexedColour TheColour,
BOOL  SetLineColour
[protected]
 

Applies the given IndexedColour as a stroke/fill colour attribute to the selected objects. This also makes the colour the 'current' attribute, etc, if desired by the user.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/10/94 (separated from CellClicked() - originally written 23/6/94)
Parameters:
TheColour - The IndexedColour to apply, or NULL to apply 'no colour' (complete [INPUTS] transparency) SetLineColour - TRUE to set this as a line colour, FALSE to set as a fill colour
Scope: private

Notes: Works on CurrentDoc, so ensure Current == Selected before calling this function

Definition at line 3103 of file ccolbar.cpp.

03104 {
03105     NodeAttribute *Attrib = NULL;
03106     DocColour ColourToApply(COLOUR_TRANS);
03107 
03108     if (TheColour != NULL)
03109         ColourToApply.MakeRefToIndexedColour(TheColour);
03110 
03111     if (SetLineColour)
03112     {
03113         // Line colour selected so create a line colour attribute
03114         Attrib = new AttrStrokeColourChange;
03115         if (Attrib == NULL)
03116             return;
03117 
03118         ((AttrStrokeColourChange *)Attrib)->SetStartColour(&ColourToApply);
03119 
03120         // AttributeSelected knows what to do with a selected attribute
03121         AttributeManager::AttributeSelected(NULL, Attrib); 
03122 
03123 /*
03124         // Bodge Alert !!
03125         // To make blends work properly, we need to set the line transparecy.
03126         // We set it to Max if the colour is 'Tranaparent' or zero otherwise
03127         Attrib = new AttrStrokeTranspChange;
03128         if (Attrib == NULL)
03129             return;
03130 
03131         UINT32 Transp;
03132 
03133         if (ColourToApply.IsTransparent())
03134             Transp = 255;
03135         else
03136             Transp = 0;
03137 
03138         ((AttrStrokeTranspChange *)Attrib)->SetStartTransp(&Transp);
03139 
03140         // AttributeSelected knows what to do with a selected attribute
03141         AttributeManager::AttributeSelected(NULL, Attrib); 
03142 */
03143     }
03144     else
03145     {   
03146         // Rather than setting the flat fill colour, we do an AttrColourChange, which
03147         // (I assume) will handle things like selected grad fill points, etc.
03148         Attrib = new AttrColourChange;
03149         if (Attrib == NULL)
03150             return;
03151 
03152         ((AttrColourChange *)Attrib)->SetStartColour(&ColourToApply);
03153 
03154         // AttributeSelected knows what to do with a selected attribute
03155         AttributeManager::AttributeSelected(NULL, Attrib); 
03156     }
03157 
03158     // Note: Redraw of affected parts of the colour bar (indicator diamonds, etc) will
03159     // automatically occur as a result of the message which the AttributeManager will
03160     // broadcast in the above call. Thus we need do no more.
03161 }

INT32 CColourBar::CalculateColourCellIndex DocColour TheColour  )  [protected]
 

Given a DocColour, will determine which *visible* colour cell, if any, is displaying that colour, anmd return its Cell Index.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/7/94
Parameters:
TheColour - the colour whose Cell index you wish to calculate [INPUTS]
Returns:
CELLINDEX_NOCOLOURCELL, CELLINDEX_NOCELL, or the index of the given colour
Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care

Definition at line 3446 of file ccolbar.cpp.

03447 {
03448     if (TheColour == NULL)
03449         return(CELLINDEX_NOCELL);
03450 
03451     if (TheColour->IsTransparent())
03452         return(CELLINDEX_NOCOLOURCELL);
03453 
03454     return (CalculateColourCellIndex(TheColour->FindParentIndexedColour()));
03455 }

INT32 CColourBar::CalculateColourCellIndex IndexedColour TheColour  )  [protected]
 

Searches the colour list to find the given colour, returning its index in the list if it is found, or a negative value if it is not.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/7/94
Parameters:
TheColour - The colour to find the index of [INPUTS]
Returns:
The index (0..NumColours-1) of the colour cell containing the colour, or CELLINDEX_NOCELL (-2) if the colour wasn't found
Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care

Definition at line 3399 of file ccolbar.cpp.

03400 {
03401     m_pCurrentColourList = ColourManager::GetColourList();
03402 
03403     if (TheColour == NULL || m_pCurrentColourList == NULL)
03404         return(CELLINDEX_NOCELL);
03405 
03406     INT32 Index = 0;
03407 
03408     // If the user has asked for document colours in the colour line then check these first
03409     // Indexed Colours are document colours and so can never exist in the library groups.
03410     if (ColourSGallery::ShowDocumentColours)
03411     {
03412         IndexedColour *TestColour = m_pCurrentColourList->GetUndeletedHead();
03413 
03414         while (TestColour != NULL)
03415         { 
03416             if (TheColour == TestColour)
03417                 return((INT32) Index);
03418 
03419             TestColour = m_pCurrentColourList->GetUndeletedNext(TestColour);
03420             Index++;
03421         }
03422     }
03423 
03424     // Didn't find a match for this colour in the list
03425     return(CELLINDEX_NOCELL);
03426 }

INT32 CColourBar::CalculateNewBarHeight wxRect *  AvailableRect  )  [protected]
 

Determine how high the colour bar should be - this is difficult, because the height depends upon whether we want a scrollbar, and this in turn depends upon how wide the colourstrip is.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/9/94
Parameters:
AvailableRect - The space available for the colourbar to fit into. [INPUTS] Only the available x space is significant.
- [OUTPUTS]
Returns:
The height, in pixels, the bar will need to be at this width in order to contain all its 'controls'.
Notes: AvailableRect is now preserved by this call

See also:
CColourBar::GetCurrentBarHeight; CColourBar::OnSize

Definition at line 4306 of file ccolbar.cpp.

04307 {
04308     TRACEUSER("Gerry", _T("CColourBar::CalculateNewBarHeight"));
04309 
04310     if (ScrollHeight == 0)                      // Has no scroll bar, so always the same height
04311     {
04312         TRACEUSER("Gerry", _T("   returning %d"), BarHeight);
04313         return(BarHeight);
04314     }
04315 
04316     // Work out how many colours we want to display in the window.
04317     // Removed this line so that FullScreen mode (which destroys and recreates the colour 
04318     // gallery) does not leave us with a cached pointer to garbage memory.
04319     // if (m_pCurrentColourList == NULL)
04320         m_pCurrentColourList = ColourManager::GetColourList();
04321 
04322     if (m_pCurrentColourList == NULL)               // No colours; we won't display anything anyway
04323     {
04324 //      TRACEUSER("Gerry", _T("   returning %d"), BarHeight - ScrollHeight);
04325 //      return(BarHeight - ScrollHeight);
04326         return(CellSize + 4);
04327     }
04328 
04329     // Calculate where all the rectangles are going to be placed if the window is resized
04330     // to the 'AvailableRect'. From this, we get the projected StripRect size, which allows
04331     // us to project the number of colours we will be able to display.
04332     
04333     wxRect tStripRect;      // Temporary lookalikes to the global cached rects
04334     wxRect tIndicatorRect;
04335     wxRect tScrollBarRect;
04336     wxRect tEditButtonRect;
04337     wxRect tNewButtonRect;      // Warning - this button is now defunct
04338 
04339     CalculateRectsInternal(AvailableRect,
04340                             &tStripRect, &tIndicatorRect, &tScrollBarRect,
04341                             &tEditButtonRect, &tNewButtonRect);
04342 
04343     INT32 DisplayedColours = tStripRect.width / CellSize;
04344 
04345     // We can display all the colours, we don't need a scrollbar, so only need CellSize+4 pixels
04346     //if ((INT32) m_pCurrentColourList->GetUndeletedCount() <= DisplayedColours) // FIXEDCOLOURS
04347     if ((INT32)GetNumberOfColours() <= DisplayedColours)
04348     {
04349 //      TRACEUSER("Gerry", _T("   returning %d"), BarHeight - ScrollHeight);
04350 //      return(BarHeight - ScrollHeight);
04351         return(CellSize + 4);
04352     }
04353 
04354     // We can't display all colours, so we need the desired BarHeight, which includes the
04355     // size of the colourstrip and the scrollbar (if enabled)
04356     TRACEUSER("Gerry", _T("   returning %d"), BarHeight);
04357     return(BarHeight);
04358 }

void CColourBar::CalculateNoColourCellRect wxRect *  Rect  )  [protected]
 

Calculates the 'NoColour' colour cell position, just to the left of the ColourStrip Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/7/94
Parameters:
- [INPUTS]
Rect - will be filled in with the caclculated rect [OUTPUTS]
Returns:
-

Definition at line 1693 of file ccolbar.cpp.

01694 {
01695     *Rect = StripRect;
01696     if (ScrollHeight == 0)              // If in 'small' mode, correct for scroll arrow
01697         Rect->x -= ButtonWidth;
01698 //  else if (!HasNoScrollBar(-1, -1))   // otherwise if there IS a scroll bar
01699 //      Rect->Offset(0,1);              // then move the rectangle down a pixel
01700 
01701     Rect->x -= NoColourSize + InterControlGap;
01702     Rect->width = NoColourSize;
01703     Rect->height = NoColourSize;
01704 }

void CColourBar::CalculateRects void   )  [protected]
 

Calculates various useful rectangular regions to be found within the Colour Bar window. Returns the screen rectangles ready for redraw.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/6/94
Parameters:
- [INPUTS]
The following data members are calculated on exit: [OUTPUTS] WindowRect - The usable client-are of the ColourBar window StripRect - The area in which the colour cells are drawn IndicatorRect - The area the current colour indicator is drawn in ScrollBarRect - The area in which the scrollbar is drawn EditButtonRect - The area in which the Edit Button is drawn NewButtonRect - The area in which the New Button is drawn [DEFUNCT]
Returns:
-
Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care

IMPORTANT: If you change the rect calculations, be sure to change the 2 occurences of a related calculation in CColBar::CalculateNewBarHeight, below

See also:
CColourBar::CalculateScrollButtonRects; CColourBar::CalculateRectsInternal

Definition at line 1449 of file ccolbar.cpp.

01450 {
01451     // Calculate inside of window area
01452     WindowRect = GetClientRect();
01453 
01454     CalculateRectsInternal(&WindowRect,
01455                             &StripRect, &IndicatorRect, &ScrollBarRect,
01456                             &EditButtonRect, &NewButtonRect);
01457 
01458     // Now, calculate the inside rect (the area of the window which lies inside the borders
01459     // which have been drawn by the base class DoPaint() function). The only things that
01460     // should be using this rectangle (rather than the rects calculated above) should be
01461     // the 2 bits in the DoPaint method which fill undrawn areas of the bar with grey.
01462 //  CalcInsideRect(&WindowRect);
01463 }

void CColourBar::CalculateRectsInternal wxRect *  pWindowRect,
wxRect *  pStripRect,
wxRect *  pIndicatorRect,
wxRect *  pScrollBarRect,
wxRect *  pEditButtonRect,
wxRect *  pNewButtonRect
[protected]
 

Calculates various useful rectangular regions to be found within the Colour Bar window. Returns the screen rectangles ready for redraw.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/6/94
Parameters:
pWindowRect - The usable client-area of the ColourBar window [INPUTS]
pStripRect - The area in which the colour cells are drawn [OUTPUTS] pIndicatorRect - The area the current colour indicator is drawn in pScrollBarRect - The area in which the scrollbar is drawn pEditButtonRect - The area in which the Edit Button is drawn pNewButtonRect - The area in which the New Button is drawn [DEFUNCT]
NONE of these inputs/outputs may be NULL!

Returns:
-
Identical to the CalculateRects function, but you pass in the rects for it to plonk the results into. WindowRect is untouched. All other rects are updated from WindowRect. The contents on entry of all but WindowRect are unimportant.

Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care

USE CalculateRects UNLESS ABSOLUTELY NECESSARY

See also:
CColourBar::CalculateRects

Definition at line 1502 of file ccolbar.cpp.

01505 {
01506     ERROR3IF(pWindowRect == NULL || pStripRect == NULL || pIndicatorRect == NULL ||
01507              pScrollBarRect == NULL || pEditButtonRect == NULL || pNewButtonRect == NULL,
01508                 _T("NULL parameter passed to CColourBar::CalculateRectsInternal"));
01509     
01510     wxRect TempRect(*pWindowRect);
01511 
01512 //  CalcInsideRect(&TempRect);
01513     TempRect.Inflate(-CX_BORDER, -CY_BORDER);
01514 
01515     // Calculate the current-colour indicator rectangle, and ensure it's a square
01516     *pIndicatorRect = TempRect;
01517     pIndicatorRect->width = pIndicatorRect->height;
01518 
01519     // Subtract the indicator width from the available space. We now always make the indicator
01520     // 'BarHeight' pixels wide: This means that there is a gap to its right when there is
01521     // no scrollbar (because the square indicator shrinks), but this means the colourstrip
01522     // width is not dependant on whether or not it has a scrollbar (which in turn is dependant
01523     // upon the colourstrip width - a nasty circular reference!)
01524     TempRect.x += BarHeight + InterControlGap;
01525     TempRect.width -= BarHeight + InterControlGap;
01526 
01527     // Calculate the new and edit button positions
01528     *pNewButtonRect = TempRect;
01529     pNewButtonRect->width = EditButtonSizeX;
01530     pNewButtonRect->height = EditButtonSizeY;
01531 
01532     *pEditButtonRect = *pNewButtonRect;
01533     // The new button isn't current present so make the edit button the same
01534 //  pEditButtonRect->x += EditButtonSizeX + InterControlGap;
01535 
01536     // Subtract new, edit, and no-colour buttons from the TempRect
01537     TempRect.x += NoColourSize + EditButtonSizeX + (InterControlGap * 2);
01538     TempRect.width -= NoColourSize + EditButtonSizeX + (InterControlGap * 2);
01539 
01540     // Calculate scrollbar and colour strip rectangles in the remaining space
01541     *pStripRect = TempRect;
01542 
01543     // This may be called fairly early on so if no colour list then get out immediately
01544     if (m_pCurrentColourList == NULL)       // No colours, so give safe default and exit
01545     {
01546         *pScrollBarRect = TempRect;
01547         return;
01548     }
01549 
01550     // INT32 MaxColours = (INT32) m_pCurrentColourList->GetUndeletedCount(); FIXED COLOURS
01551     INT32 MaxColours = GetNumberOfColours();
01552     // Removed 4/8/97 Neville as causes a redraw problem when switching from document with two colours
01553     // in to one with none in.
01554 /*  if (MaxColours <= 0)
01555     {
01556         pScrollBarRect->CopyRect(&TempRect);
01557         return;
01558     } */
01559 
01560     INT32 Width = pStripRect->width;
01561 
01562     // Normally, the buttons are flush with the ends of the colourstrip, but in
01563     // this mode, they sit outside the ends of the colourstrip instead
01564     if (ScrollHeight == 0)
01565         Width -= 2 * (ButtonWidth + 1);
01566 
01567     if (MaxColours * CellSize < Width)
01568         pStripRect->width = MaxColours * CellSize;
01569     else
01570         pStripRect->width = Width - (Width % CellSize);
01571 
01572     if (ScrollHeight == 0)
01573     {
01574         // We want no scroll bar, just arrows on either end of the colourstrip
01575         // As the arrows are drawn on either end (outside) of the scroll rect,
01576         // we must now move both rects one scroll button width to the right
01577 
01578         pStripRect->Offset(ButtonWidth + 1, 0);
01579         *pScrollBarRect = *pStripRect;
01580 
01581         // And then make the scroll bar rect slightly bigger so there is a small
01582         // gap between the buttons and the strip
01583         pScrollBarRect->Inflate(2, 0);
01584     }
01585     else
01586     {
01587         // If there is no need for a scrollbar, StripRect expands to fill the space
01588         if (HasNoScrollBar(-1, MaxColours))
01589         {
01590             // For now we will force the strip rect to only be CellSize high
01591             // because the window resizing code isn't working properly
01592             pStripRect->height = CellSize;
01593             return;
01594         }
01595 
01596         *pScrollBarRect = *pStripRect;
01597         // ScrollBarRect is only ScrollHeight pixels high.
01598         // We also subtract off the space for the scroll arrows
01599         pScrollBarRect->y = pScrollBarRect->y + pScrollBarRect->height - ScrollHeight;
01600         pScrollBarRect->height = ScrollHeight;
01601         pScrollBarRect->Inflate(-(ButtonWidth-1), 0);
01602 
01603         // Colour strip is immediately above scroll rect: same width, CellSize height
01604         pStripRect->height = CellSize;
01605         pStripRect->y = pScrollBarRect->y - CellSize;
01606     }
01607 }

BOOL CColourBar::CalculateSausageRect wxRect *  Result  )  [protected]
 

Calculates the scroll sausage area within the scroll bar rectangle Notes: You must call CalculateRects and cache the value of TotalNumColours prior to calling this function - see DoPaint for everything that needs to be done. The ColourBar works exclusively on the SELECTED Doc. Change with care.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/6/94
Parameters:
- [INPUTS]
If successful, Result contains the sausage rect [OUTPUTS]
Returns:
TRUE if it succeeds, FALSE if the scrollbar/sausage is non existent

Definition at line 1628 of file ccolbar.cpp.

01629 {
01630     // If the scroll bar hasn't got enough room to exist, it does not appear
01631     if (ScrollBarRect.width < 5)
01632         return(FALSE);
01633 
01634     // If we are in Med/Large mode and have no scrollbar, it doesn't appear
01635     if (HasNoScrollBar(-1, -1))
01636         return(FALSE);
01637 
01638     *Result = ScrollBarRect;
01639 
01640     UINT32 NumDisplayedColours = StripRect.width / CellSize;
01641     Result->Inflate(-1, -1);
01642 
01643     if (NumDisplayedColours < TotalNumColours)
01644     {
01645         UINT32 BarWidth = Result->width;
01646         // Calculate the midpoint and width of the scroll 'sausage'
01647         //   MidPointColour = LeftmostColour + NumDisplayedColours/2;
01648         //   Mid = (MidPointColour / TotalColours) * BarWidth;
01649         // We calculate everything at *2 magnification to avoid rounding errors
01650         UINT32 Mid = (((LeftmostColour * 2) + NumDisplayedColours) * BarWidth) /
01651                                 (TotalNumColours * 2);
01652 
01653         BarWidth = (BarWidth * NumDisplayedColours) / TotalNumColours;
01654 
01655         if (BarWidth < (UINT32)4)
01656             BarWidth = 4;           // Try to keep some sausage visible!
01657 
01658         Result->x += Mid - (BarWidth / 2);
01659         Result->width = BarWidth;
01660 
01661         // Clip the values in case of rounding errors causing a pixel or 2 error
01662         if (Result->x <= ScrollBarRect.x)
01663             Result->x = ScrollBarRect.x + 1;
01664 
01665         // Clip rounding error, also make sure that errors don't make bar 1 pixel
01666         // short when at the very rightmost scroll position (this douubles up the
01667         // black lines around scroll sausage/arrow and looks bad)
01668         if (Result->GetRight() >= ScrollBarRect.GetRight() ||
01669             TotalNumColours-NumDisplayedColours <= LeftmostColour)
01670             Result->SetRight(ScrollBarRect.GetRight() - 1);
01671     }
01672 
01673     return(TRUE);
01674 }

void CColourBar::CaptureTheMouse void   )  [protected]
 

Captures the mouse for drags/autorepeat. Nothing will be done if we already have mouse capture.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/6/94
Parameters:
- [INPUTS]
Notes: When capturing the mouse, you should also set the value of DragInfo.CaptureRect to the area within which the mouse was captured. This allows the other handlers to determine if the mouse strays out of the relevant area (in which case scrolling/autorepeat will cease). If not set, this will cause odd effects.

The ColourBar works exclusively on the SELECTED Doc. Change with care

Definition at line 3883 of file ccolbar.cpp.

03884 {
03885     TRACEUSER("Gerry", _T("CColourBar::CaptureTheMouse"));
03886 
03887     if (DragInfo.MouseCaptured)
03888     {
03889         TRACEUSER("Gerry", _T("Already got capture"));
03890         return;
03891     }
03892 
03893     CaptureMouse();
03894     DragInfo.MouseCaptured = TRUE;
03895 }

void CColourBar::CellClicked INT32  CellIndex,
BOOL  SetLineColour
[protected]
 

Processes a click on a given colour cell by setting the line/fill colour of the selected objects, or if nothing is selected, setting the default line/fill colour.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/6/94
Parameters:
CellIndex - The index of the clicked colour cell (0..MaxColours) [INPUTS] SetLineColour - TRUE to set the line colour to the given colour FALSE to set the fill color to the given colour
- [OUTPUTS]
Returns:
-
Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care

If you add code to this routine, note the way in which we return - the selected order must always be deselected before exit

Definition at line 3186 of file ccolbar.cpp.

03187 {
03188     if ((CellIndex >= CLICKED_NOTHING && CellIndex != CLICKED_NOCOLOURCELL) ||
03189             m_pCurrentColourList == NULL)
03190         return;
03191 
03192     // Ensure that CurrentDoc == SelectedDoc
03193     Document *OldCurrentDoc = SetCurrentDoc();
03194 
03195     // Create an attribute of the correct type
03196     IndexedColour *TheColour  = NULL;
03197     if (CellIndex != CLICKED_NOCOLOURCELL)
03198     {
03199         // If the user has asked for document colours in the colour line then check these first
03200         if (ColourSGallery::ShowDocumentColours)
03201             TheColour = FindColourByIndex(CellIndex);
03202 
03203         // If we didn't find it there check the library colours
03204         if (TheColour == NULL)
03205         {
03206             // FIXED COLOURS
03207             // It is not one of the standard document colours so check the fixed library colours
03208             // If it finds the correct one then this will create an indexed colour and add it to
03209             // the currently selected document
03210             TheColour = FindLibIndexedColourByIndex(CellIndex);
03211             if (TheColour == NULL)
03212             {
03213                 // It is an unknown colour so just exit
03214                 // Before exiting the function, we must always restore CurrentDoc
03215                 RestoreCurrentDoc(OldCurrentDoc);
03216                 return;
03217             }
03218         }
03219     }
03220 
03221     ApplyColour(TheColour, SetLineColour);      // Apply this colour to the selection
03222 
03223     RestoreCurrentDoc(OldCurrentDoc);           // Restore previous CurrentDoc value
03224 }

BOOL CColourBar::Create wxWindow *  pParent,
UINT32  id
 

Creates a window and associates it with this CColourBar object. The window appears at the bottom of the main frame window, just like the status bar.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/6/94
Parameters:
ParentWnd - The parent frame window (in Camelot, there can be only one) [INPUTS] dwstyle, nID - you shouldn't have to mess with these (cf CStatusBar)
- [OUTPUTS]
Returns:
TRUE if the initialisation of the Colour bar was successful.
Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care

Definition at line 949 of file ccolbar.cpp.

00950 {
00951     if (!wxWindow::Create(pParent, id, wxDefaultPosition, wxSize(BarHeight, BarHeight), wxNO_BORDER))
00952         return(FALSE);
00953 
00954 #if FALSE
00955     ASSERT_VALID(pParentWnd);   // must have a parent
00956 
00957     // Create a new WndClass- this should be identical to CControlBar's WndClass but
00958     // we also would kindof like double clicks if it isn't too much trouble, Mr MFC
00959     CString WndClassName = AfxRegisterWndClass(CS_DBLCLKS, NULL, //Cursor::Arrow->Handle(),
00960                                     (HBRUSH)(COLOR_BTNFACE + 1));
00961 
00962     // Do we want to show this bar after it's created?
00963     BOOL Show = dwStyle & WS_VISIBLE;
00964 
00965     // Make sure the style flags only has legal flags set (VC6 change)
00966     dwStyle &= CBRS_ALL;
00967 
00968 #if WIN32
00969     // this element of CControlBar does not exist in MFC 2.5 16-bit
00970     m_dwStyle = dwStyle;
00971 #endif
00972 
00973     // create the wxWindow*
00974     wxRect rect;
00975     rect.SetRectEmpty();
00976     if (!CWnd::Create(WndClassName, NULL, dwStyle, rect, pParentWnd, nID))
00977         return(FALSE);
00978         // NOTE: Parent must resize itself for control bar to be resized
00979 
00980     if (Show)
00981         ShowWindow(SW_SHOW);
00982 #endif
00983 
00984     InitPrefs();
00985     SetDisplayMode();
00986 
00987     InvalidateBestSize();
00988 
00989     IndentedButton = CLICKED_NOTHING;
00990 
00991     return(TRUE);
00992 }

BOOL CColourBar::DoColourPickerColour wxWindow *  colourPicker,
wxPoint  mousePt,
IndexedColour **  pTheCol = NULL
 

Instruct the colour edit dialog to use that colour on the colour bar (of which the colour picker is over).

Author:
Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/10/99
Parameters:
colourPicker - The wxWindow* of the claimed colour picker control [INPUTS]
Returns:
True if success False otherwise Throws ENSURE error if colourPicker is NOT a colour picker control

Definition at line 1293 of file ccolbar.cpp.

01294 {
01295     if (colourPicker == this)
01296     {
01297         UINT32 ColourCell = WhereIsMouse (mousePt);
01298         static UINT32 lastColourCell = (UINT32)-1;
01299 
01300         if ((((INT32)ColourCell) >= 0)/* && (lastColourCell != ColourCell)*/)       // we are over a valid colour
01301         {
01302             BOOL validColour = FALSE;
01303             
01304             if (m_pCurrentColourList == NULL)       // Ensure the current ColourList pointer is valid
01305             {
01306                 m_pCurrentColourList = ColourManager::GetColourList();
01307             }
01308 
01309             IndexedColour *TheColour = NULL;
01310 
01311             // If the user has the preference set then include and hence show the document
01312             // colours
01313             if (ColourSGallery::ShowDocumentColours)
01314             {
01315                 TheColour = FindColourByIndex(ColourCell);
01316             }
01317 
01318             if (TheColour != NULL)
01319             {
01320                 validColour = TRUE;
01321             }
01322             else
01323             {
01324                 // We didn't find the colour in the document colours section
01325                 // so check any library sections that may be present
01326                 SGDisplayLibColour *pLibColour = NULL;
01327                 DocColour * pTheDocColour = FindLibColourByIndex(ColourCell, &pLibColour);
01328                 TheColour = ColourManager::GenerateNewUnnamedColour (m_pCurrentColourList, pTheDocColour);
01329 
01330                 if (pTheDocColour && pLibColour)
01331                 {
01332                     validColour = TRUE;
01333                 }
01334             }
01335 
01336             if (validColour && pTheCol)
01337                 *pTheCol = TheColour;
01338             
01339             if ((lastColourCell != ColourCell) && validColour)
01340             {
01341                 ColourEditDlg* pColourEditDlg = ColourEditDlg::GetColourEditDlg ();
01342                 ASSERT (pColourEditDlg);
01343 
01344                 pColourEditDlg->SetEditingColour (TheColour);
01345                 lastColourCell = ColourCell;
01346             }
01347             
01348             return (TRUE);
01349         }
01350         else
01351         {
01352             return (TRUE);
01353         }
01354     }
01355 
01356     ENSURE(FALSE, "DoColourPickerColour called for invalid colour picker control");
01357 
01358     return (FALSE);
01359 }

wxSize CColourBar::DoGetBestSize  )  const [virtual]
 

Author:
Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/03/06
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
Best size of this window

Definition at line 1008 of file ccolbar.cpp.

01009 {
01010     TRACEUSER("Gerry", _T("CColourBar::DoGetBestSize"));
01011     wxRect AvailableRect = GetParent()->GetClientRect();
01012     AvailableRect.height = BarHeight;
01013     INT32 Height = ((CColourBar*)this)->CalculateNewBarHeight(&AvailableRect);
01014     INT32 Width = GetParent()->GetClientSize().x;
01015 
01016     return(wxSize(Width, Height));
01017 }

void CColourBar::DoPaint wxDC *  pDC  )  [protected]
 

Redraws the ColourBar window contents.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/6/94
Parameters:
pDC - The DC to paint into [INPUTS]
- [OUTPUTS]
Returns:
-
Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care

Definition at line 2707 of file ccolbar.cpp.

02708 {
02709     // If we're in the middle of doing something important (having a bit of an error)
02710     // then we just pretend that we redraw, and abort, to save going re-entrant.
02711     if (CCamApp::IsDisabled())
02712     {
02713         TRACE( _T("Colour bar repaint has been aborted: the system is disabled (due to an error/ensure?)\n"));
02714         // The paint condition will have been cleared by the creation of the wxPaintDC
02715 //      ::ValidateRect(m_hWnd, NULL);                               // Clear paint condition
02716         return;
02717     }
02718 
02719 //  ASSERT_VALID(this);
02720 //  ASSERT_VALID(pDC);
02721 
02722     Error::RenderThreadIn();        // Handle errors/exceptions during rendering properly
02723 
02724 //  CControlBar::DoPaint(pDC);      // draw border
02725 
02726     Document *OldCurrentDoc = SetCurrentDoc();
02727 
02728     // Get the current colour list, and calculate the rects to be redrawn
02729     m_pCurrentColourList = ColourManager::GetColourList();
02730     CalculateRects();
02731 
02732     wxPen TransPen(wxColour(0,0,0), 1, wxTRANSPARENT);
02733     pDC->SetPen(TransPen);
02734 
02735     wxBrush GreyBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
02736 
02737     if (m_pCurrentColourList == NULL)// || m_pCurrentColourList->GetUndeletedCount() == 0)
02738     {
02739         // No colours, so just fill the entire bar with grey
02740         pDC->SetBrush(GreyBrush);
02741         pDC->DrawRectangle(WindowRect);
02742         pDC->SetBrush(wxNullBrush);
02743         pDC->SetPen(wxNullPen);
02744         RestoreCurrentDoc(OldCurrentDoc);
02745 
02746         Error::RenderThreadOut();
02747         return;
02748     }
02749 
02750     wxRect ClipRect;
02751     pDC->GetClippingBox(&ClipRect.x, &ClipRect.y, &ClipRect.width, &ClipRect.height);
02752 
02753     if (ClipRect.IsEmpty())
02754         ClipRect = GetClientRect();
02755 
02756     // Fill everything to the right of the colourstrip with BTNFACE grey, to ensure we 
02757     // overwrite any stuff that might have been drawn there and not erased (on some updates
02758     // we purposely do not bother with erasing the background, to reduce flicker)
02759     wxRect TheRect(WindowRect);
02760     INT32 OffsetLeft = StripRect.x + StripRect.width - TheRect.x;
02761     TheRect.x += OffsetLeft;
02762     TheRect.width -= OffsetLeft;
02763     pDC->SetBrush(GreyBrush);
02764     pDC->DrawRectangle(TheRect);
02765     pDC->SetBrush(wxNullBrush);
02766     pDC->SetPen(wxNullPen);
02767 
02768 //  TotalNumColours = m_pCurrentColourList->GetUndeletedCount(); // FIXEDCOLOURS
02769     TotalNumColours = GetNumberOfColours();
02770     if ((ScrollHeight == 0 || !HasNoScrollBar(-1, (INT32) TotalNumColours)))
02771     {
02772         wxRect AllScrollBarRect(ScrollBarRect);             // ScrollBarRect does not include the
02773         AllScrollBarRect.x -= ButtonWidth + 1;              // scroll arrows, which extend outside
02774         AllScrollBarRect.width += (ButtonWidth + 1) * 2;    // this rect by ButtonWidth + 1 pixels
02775 
02776         if (ClipRect.Intersects(AllScrollBarRect))
02777             PaintScrollBar(pDC);
02778     }
02779 
02780     PaintNoColourCell(pDC);
02781     if (ClipRect.Intersects(EditButtonRect))
02782         PaintEditOrNewButton(pDC, (IndentedButton != CLICKED_EDITBUTTON), TRUE);
02783 
02784 #if FALSE
02785     if (ClipRect.Intersects(NewButtonRect))
02786         PaintEditOrNewButton(pDC, (IndentedButton != CLICKED_NEWBUTTON), FALSE);
02787 #endif
02788 
02789     // Set up palette and GBrush for Spiffy redraw
02790 //  CPalette * OldPal = NULL;
02791 //  if (PaletteManager::UsePalette())
02792 //  {
02793 //      OldPal = PaletteManager::StartPaintPalette(pDC);
02794 //  }
02795 
02796     GDrawBrush.Init(pDC);
02797     GDrawBrush.Start();
02798 
02799     // Draw Indicators and colour strip, using GBrush if possible
02800     if (ClipRect.Intersects(IndicatorRect))
02801         PaintIndicators(pDC);
02802 
02803     if (ClipRect.Intersects(StripRect))
02804         PaintColourStrip(pDC, ClipRect);
02805 
02806     // Finish with GBrush
02807     GDrawBrush.Stop();
02808 //  if (OldPal)
02809 //      PaletteManager::StopPaintPalette(pDC, OldPal);
02810 
02811     Error::RenderThreadOut();
02812 
02813     RestoreCurrentDoc(OldCurrentDoc);
02814 }

void CColourBar::EditAColour ColourList DisplayList,
IndexedColour TheColour,
BOOL  LineColour = FALSE
[protected]
 

Edits the given colour.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/6/94
Parameters:
DisplayList - The ColourList in which the colour resides. [INPUTS] TheColour - The Colour to be edited LineColour - TRUE if this should be the line colour (ignored unless TheColour and DisplayList are both non-NULL)
- [OUTPUTS]
Returns:
-
Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care

Scope: private

Returns:
Errors: -
See also:
ColourPicker::EditColour

Definition at line 3922 of file ccolbar.cpp.

03924 {
03925     ColourPicker ColPicker;
03926 
03927     if (DisplayList == NULL || TheColour == NULL)
03928         ColPicker.EditColour(NULL, NULL, LineColour);   // Open, but don't edit anything
03929     else
03930         ColPicker.EditColour(DisplayList, TheColour);
03931 }

BOOL CColourBar::EnsureLibraryColoursPresent  )  [static]
 

Ensures that any colour library sections we require are present.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/3/97
Parameters:
- [INPUTS]
Returns:
True if worked correctly

Definition at line 1196 of file ccolbar.cpp.

01197 {
01198 PORTNOTE("other","Removed ColourSGallery usage")
01199 #if !defined(EXCLUDE_FROM_XARALX)
01200     // try and ensure all our required colour gallery sections are present and de-virtilised
01201     ColourSGallery * pColourGallery = ColourSGallery::GetInstance();
01202     if (pColourGallery != NULL)
01203     {
01204         // This will create the groups if they're not there yet
01205         pColourGallery->MakeSureGroupsHaveBeenCreated();
01206 
01207         // Find the Netscape palette library
01208         SGDisplayLibColGroup * pLibGroup = pColourGallery->GetFirstLibGroup();
01209         while (pLibGroup)
01210         {
01211             // Add in any items that are flagged as being required
01212             if (pLibGroup->DisplayInColourLine())
01213             {
01214                 pLibGroup->DeVirtualise();
01215             }
01216 
01217             pLibGroup = pColourGallery->GetNextLibGroup(pLibGroup);
01218         }
01219 
01220         if (TheColourBar != NULL)           // If there's a bar, set it to the new size
01221         {
01222             // Force a redraw of the bar to ensure it's up to date
01223             // This checks that the size is correct
01224             PaletteHasChanged(NULL);
01225             //TheColourBar->Invalidate();       
01226         }
01227     }
01228 #endif
01229     return TRUE;
01230 }

IndexedColour * CColourBar::FindColourByIndex UINT32  Index  )  [protected]
 

Given the current Display List, finds the 'Index'th item, and dereferences it to find the actual IndexedColour that lies at that list position in the current colour bar display order.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/8/94
Returns:
NULL, or a pointer to the IndexedColour we are interested in.
Notes: Ensures that m_pCurrentColourList is up to date. If no list can be found, it returns NULL.

Ignores 'deleted' colours held in the colour list

Scope: private (to ccolourbar)

Definition at line 3983 of file ccolbar.cpp.

03984 {
03985     if (m_pCurrentColourList == NULL)
03986         m_pCurrentColourList = ColourManager::GetColourList();
03987 
03988     if (m_pCurrentColourList == NULL)
03989     {
03990         ERROR3(_T("CColourBar::FindColourByIndex can't handle NULL Colour Lists"));
03991         return(NULL);
03992     }
03993 
03994     // First, check if the index is in the main colour list
03995     UINT32 DocColours = (UINT32) m_pCurrentColourList->GetUndeletedCount();
03996     if (Index < DocColours)
03997         return(m_pCurrentColourList->FindUndeletedItem(Index));
03998     
03999     // not in this list so return NULL
04000     return NULL;
04001 }

DocColour * CColourBar::FindLibColourByIndex UINT32  Index,
SGDisplayLibColour **  ppLibColour = NULL
[protected]
 

Given the current Display List, finds the 'Index'th item, and dereferences it to find the actual DocColour that lies at that list position in the current colour bar display order. This will only look through the Library colours and hence returns DocColours rather than indexed colours.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/3/97
Parameters:
The index of the item required [INPUTS] An optional SGDisplayLibColour pointer, defaults to null.
Returns:
NULL, or a pointer to the DocColour we are interested in.

Definition at line 4020 of file ccolbar.cpp.

04021 {
04022     // First, check if the index is in the main colour list
04023     UINT32 DocColours = 0;
04024     // If the user has the preference set then include and hence show the document
04025     // colours
04026     if (ColourSGallery::ShowDocumentColours)
04027     {
04028         DocColours = (UINT32) m_pCurrentColourList->GetUndeletedCount();
04029         if (Index < DocColours)
04030             return NULL;
04031     }
04032 
04033 PORTNOTE("other","Removed ColourSGallery usage")
04034 #if !defined(EXCLUDE_FROM_XARALX)
04035     // The new index count has to have these doc colours removed from the original index
04036     UINT32 NewIndex = Index - DocColours;
04037 
04038     // Index is beyond the colours in the current document and so try the colour libraries
04039     m_pColourGallery = ColourSGallery::GetInstance();
04040     UINT32 items = 0;
04041     if (m_pColourGallery != NULL)
04042     {
04043         // This will create the groups if they're not there yet
04044         m_pColourGallery->MakeSureGroupsHaveBeenCreated();
04045 
04046         // Find the Netscape palette library
04047         SGDisplayLibColGroup * pLibGroup = m_pColourGallery->GetFirstLibGroup();
04048         BOOL Found = FALSE;
04049         while (!Found && pLibGroup)
04050         {
04051             // Add in any items that are flagged as being required
04052             if (pLibGroup->DisplayInColourLine())
04053             {
04054                 // pLibGroup->DeVirtualise();   // This is dangerous as it may change current doc!
04055                                                 // Disabled as it causes problems during start up
04056                 items = pLibGroup->CountChildren();
04057                 if (NewIndex < items)
04058                 {
04059                     return pLibGroup->GetItemColour(NewIndex, ppLibColour);
04060                 }
04061                 else
04062                 {
04063                     // remove these items from the count
04064                     NewIndex -= items;
04065                 }
04066             }
04067 
04068             pLibGroup = m_pColourGallery->GetNextLibGroup(pLibGroup);
04069         }
04070     }
04071 #endif
04072     // Nothing found
04073     return NULL;
04074 } 

IndexedColour * CColourBar::FindLibIndexedColourByIndex UINT32  Index  )  [protected]
 

Given the current Display List, finds the 'Index'th item, and dereferences it to find the actual DocColour that lies at that list position in the current colour bar display order. This will only look through the Library colours and hence finds DocColours rather than indexed colours. This versions is the same as above but then goes and creates an IndexedColour in the current document and returns this.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/3/97
Parameters:
The index of the item required [INPUTS]
Returns:
NULL, or a pointer to the IndexedColour we are interested in.

Definition at line 4093 of file ccolbar.cpp.

04094 {
04095     // If we have no current colour list then nothing doing
04096     if (m_pCurrentColourList == NULL)
04097         return NULL;
04098 
04099     IndexedColour *pNewCol = NULL;
04100 
04101     SGDisplayLibColour *pLibColour = NULL;
04102     DocColour * pTheColour = FindLibColourByIndex(Index, &pLibColour);
04103 
04104     if (pTheColour == NULL || pLibColour == NULL)
04105         return NULL;
04106 
04107     // We have discovered a library DocColour - we must copy it into the document before trying to apply it
04108     // Make a temporary IndexedColour from the library colour
04109     pNewCol = new IndexedColour(*pTheColour);
04110 
04111     if (pNewCol != NULL)
04112     {
04113         // Set the colour's name to the same as the library item (but make sure it's unique)
04114         String_256 Buffer;
04115         pLibColour->GetNameText(&Buffer);
04116         pNewCol->SetName(Buffer);
04117 // If we do this then the EnsureColourIsInDocument wont do all its work.
04118 // It will handle duplicate names for us
04119 //      if (m_pCurrentColourList->GenerateUniqueColourName(pNewCol->GetName(), (String_64 *) &Buffer))
04120 //          pNewCol->SetName(Buffer);
04121 
04122         // If it's a spot colour, make it so
04123         if (pLibColour->IsASpotColour())
04124             pNewCol->SetLinkedParent(NULL, COLOURTYPE_SPOT);
04125 
04126         // Copy the colour into the destination document (merging it with existing
04127         // colours so we won't keep creating new copies of the same colour as it's applied)
04128         DocColour ColourToApply;
04129         ColourToApply.MakeRefToIndexedColour(pNewCol);
04130         ColourManager::EnsureColourIsInDocument(NULL, Document::GetSelected(), &ColourToApply);
04131 
04132         // Delete the temporary IndexedColour we used
04133         delete pNewCol;
04134 
04135         // And remember the new colour we've just made
04136         pNewCol = ColourToApply.FindParentIndexedColour();
04137     }
04138 
04139     // return the result to the caller
04140     return pNewCol;
04141 }

void CColourBar::ForceRedrawOfCell DocColour TheColour  )  [protected]
 

void CColourBar::ForceRedrawOfCell INT32  CellIndex  )  [protected]
 

Forces a redraw of the given Cell in the colour strip. The index is from the first colour in the list - if this is outside the displayed portion of the colour strip, no action will be taken Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/7/94
Parameters:
CellIndex - Index of the colour cell to redraw [INPUTS]

Definition at line 3473 of file ccolbar.cpp.

03474 {
03475     if (CellIndex == CELLINDEX_NOCOLOURCELL)        // Redraw No-colour cell
03476     {
03477         wxRect Rect;
03478         CalculateNoColourCellRect(&Rect);
03479 
03480         ForceRedrawOfRect(Rect);
03481         return;
03482     }
03483 
03484     if (CellIndex < (INT32)LeftmostColour)          // Cell is not visible (off left of strip)
03485         return;
03486 
03487     // Calculate position of the colour cell in the strip...
03488     wxRect RedrawRect(StripRect);                   // Copy the striprect
03489 
03490                                                     // Calculate left edge of the cell
03491     RedrawRect.x += CellSize * (CellIndex - LeftmostColour);
03492     if (RedrawRect.x > (StripRect.x + StripRect.width)) // Cell is not visible (off right of strip)
03493         return;
03494 
03495     RedrawRect.width = CellSize;                    // Set width of the cell
03496     ForceRedrawOfRect(RedrawRect);                  // redraw the sucker
03497 }

void CColourBar::ForceRedrawOfRect const wxRect &  RectToDraw  )  [protected]
 

Causes the given portion of the colour bar to be redrawn Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/6/94
Parameters:
RectToDraw - The rectangle to force-redraw. This should be [INPUTS] one of the member rectangles (ScrollBarRect, StripRect, IndicatorRect)
- [OUTPUTS]
Returns:
-

Definition at line 2833 of file ccolbar.cpp.

02834 {
02835     wxRect OffsetRectToDraw(RectToDraw);
02836     wxRect RealWindowRect;
02837     
02838     // Convert the screen rectangle coords into window *offsets*
02839     RealWindowRect = GetClientRect();
02840     OffsetRectToDraw.Offset(-RealWindowRect.x, -RealWindowRect.y);
02841 
02842     RefreshRect(OffsetRectToDraw, false);
02843 }

static CColourBar* CColourBar::GetColourBar  )  [inline, static]
 

Definition at line 311 of file ccolbar.h.

00311 { return(TheColourBar); }

wxBrush * CColourBar::GetColourBrush COLORREF  rgb  )  [protected]
 

Calculates a logical brush for use in painting. If GDraw is available via CColourBar::GDrawBrush, GDraw will be used. If not, GDI will be used. Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/6/94
Parameters:
rgb - An RGB ScreenWord for passing to GDI or GBrush in order to create [INPUTS] a brush of the desired colour.
- [OUTPUTS]
Returns:
A pointer to a wxBrush for the given colour. NOTE that it is up to the caller to dispose of this brush using delete. This pointer will be NULL if the brush could not be created

Definition at line 2015 of file ccolbar.cpp.

02016 {
02017     wxBrush* pBrush = NULL;
02018 
02019     if (GDrawBrush.Available())
02020     {
02021         pBrush = new wxBrush;
02022 
02023         if (pBrush != NULL)
02024         {
02025             GDrawBrush.GetLogBrush(rgb, pBrush);
02026         }
02027     }
02028     else
02029         pBrush = new wxBrush(rgb);
02030 
02031     return pBrush;
02032 }

INT32 CColourBar::GetCurrentBarHeight void   )  [static, protected]
 

Determine how high the colour bar currently is.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/3/96
Returns:
The height, in pixels, the bar is currently taking on screen If there is no colour bar currently displayed, the return value is 0
See also:
CColourBar::CalculateNewBarHeight; CColourBar::OnSize

Definition at line 4272 of file ccolbar.cpp.

04273 {
04274     if (TheColourBar == NULL || !TheColourBar->BarIsVisible)
04275         return(0);
04276 
04277     wxRect ClientRect = TheColourBar->GetClientRect();
04278     return(ClientRect.height);
04279 }

INT32 CColourBar::GetNumberOfColours  ) 
 

Determines the number of colours that we wish to display on the ColourBar.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/3/97
Parameters:
- [INPUTS]
Returns:
The number of colours we wish to display on the bar.

Definition at line 1135 of file ccolbar.cpp.

01136 {
01137     INT32 total = 0;
01138     
01139     // Get the actually colours in the selected document
01140     INT32 DocColours = 0;
01141 
01142     // If the user has the preference set then include and hence show the document
01143     // colours
01144     if (ColourSGallery::ShowDocumentColours)
01145     {
01146         if (m_pCurrentColourList == NULL)
01147             m_pCurrentColourList = ColourManager::GetColourList();
01148 
01149         if (m_pCurrentColourList != NULL)
01150             DocColours = (INT32) m_pCurrentColourList->GetUndeletedCount();
01151 
01152         total += DocColours;
01153     }
01154 
01155 PORTNOTE("other","Removed ColourSGallery usage")
01156 #if !defined(EXCLUDE_FROM_XARALX)
01157     // try and add in any fixed sections required
01158     m_pColourGallery = ColourSGallery::GetInstance();
01159     if (m_pColourGallery != NULL)
01160     {
01161         // This will create the groups if they're not there yet
01162         m_pColourGallery->MakeSureGroupsHaveBeenCreated();
01163 
01164         // Find the Netscape palette library
01165         SGDisplayLibColGroup * pLibGroup = m_pColourGallery->GetFirstLibGroup();
01166         BOOL Found = FALSE;
01167         while (!Found && pLibGroup)
01168         {
01169             // Add in any items that are flagged as being required
01170             if (pLibGroup->DisplayInColourLine())
01171             {
01172                 // pLibGroup->DeVirtualise();   // This is dangerous as it may change things like current doc!
01173                                                 // Disabled as it causes problems during start up
01174                 total += pLibGroup->CountChildren();
01175             }
01176 
01177             pLibGroup = m_pColourGallery->GetNextLibGroup(pLibGroup);
01178         }
01179     }
01180 #endif
01181     return total;
01182 }

BOOL CColourBar::GetStatusLineText String_256 Result  )  [static]
 

To retrieve help text for use by the status line system.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/1/95
Parameters:
- [INPUTS]
Result - If the mouse pointer is currently over the colour line, this is [OUTPUTS] returned containing appropriate help text, otherwise this is left untouched.
Returns:
TRUE if the Result string was updated with valid help text

Definition at line 5317 of file ccolbar.cpp.

05318 {
05319     if (TheColourBar == NULL)       // There is no colour bar!
05320         return(FALSE);
05321 
05322     if (TheColourBar->m_pCurrentColourList == NULL) // No Colours! Exit immediately!
05323         return(FALSE);
05324 
05325 //  ASSERT_VALID(TheColourBar);
05326     ERROR3IF(Result == NULL, _T("CColourBar::GetStatusLineText - NULL Result parameter is bad"));
05327 
05328     wxPoint ScreenPos = ::wxGetMousePosition();
05329 
05330     if (::wxChildWindowFromPoint(ScreenPos, false, -1) != TheColourBar)
05331         return(FALSE);
05332 
05333     wxPoint ClientPos = TheColourBar->ScreenToClient(ScreenPos);    // make relative to window
05334 
05335     static String_64 HelpStringStore;
05336 //  StringBase *HelpString = NULL;
05337 
05338     INT32 Item = TheColourBar->WhereIsMouse(ClientPos);
05339     if (Item >= CLICKED_NOTHING)
05340     {
05341         switch(Item)
05342         {
05343             case CLICKED_SCROLLBAR:
05344             case CLICKED_SCROLLBARLEFT:
05345             case CLICKED_SCROLLBARRIGHT:
05346             case CLICKED_LEFTSCROLL:
05347             case CLICKED_RIGHTSCROLL:
05348                 Result->MakeMsg(_R(IDS_COLBAR_SSCROLL));
05349                 break;
05350 
05351             case CLICKED_INDICATORS:
05352                 Result->MakeMsg(_R(IDS_COLBAR_HINDICATOR));
05353                 break;
05354 
05355             case CLICKED_NOCOLOURCELL:
05356                 Result->MakeMsg(_R(IDS_COLBAR_SNOCOLOUR));
05357                 break;
05358 
05359             case CLICKED_EDITBUTTON:
05360                 {
05361                     // "Click to edit the current colour"
05362                     Result->MakeMsg(_R(IDS_COLBAR_SEDITBUTTON));
05363 
05364                     // If there is a selection, then chnage to using:
05365                     // "Click to edit colour of ellipse"
05366                     SelRange *Selection = GetApplication()->FindSelection();
05367                     if (Selection != NULL)
05368                     {
05369                         if (Selection->Count() > 0)
05370                         {
05371                             String_256 Desc = Selection->Describe(MENU);
05372                             Result->MakeMsg(_R(IDS_COLBAR_SEDITBUTTON2), (TCHAR *)Desc);
05373                         }
05374                     }                   
05375                 }
05376                 break;
05377             
05378 #if FALSE
05379             case CLICKED_NEWBUTTON:
05380                 Result->MakeMsg(_R(IDS_COLBAR_SNEWBUTTON));
05381                 break;
05382 #endif
05383 
05384             case CLICKED_NOTHING:       // No useful help - return nothing
05385                 return(FALSE);
05386         }
05387     }
05388     else
05389     {
05390         if (AttrFillGeometry::SelectionCount > 0)
05391             Result->Load(_R(IDS_COLBAR_SSTRIPGRAD));    // Set grad fill handle colours
05392         else
05393             Result->Load(_R(IDS_COLBAR_SSTRIPFLAT));    // Set normal flat fill colours
05394     }
05395 
05396     return(TRUE);
05397 }

BOOL CColourBar::HasNoScrollBar INT32  DisplayedColours,
INT32  MaxColours,
wxRect *  pStripRect = NULL
[protected]
 

Determines if the ColourBar actually need bother with a scrollbar (It does not need one if it can display all the available colours).

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/7/94
Parameters:
DisplayedColours - -1 or the number of colours that can be displayed in [INPUTS] the bar MaxColours - -1 or the number of colours available for display (these values will be calculated for you if you pass in -1, but if you've already calculated them it's silly to reinvent the wheel)
pStripRect - NULL to use the precalculated CColourBar StripRect, or a pointer to a wxRect that holds a StripRect. (Used when calculating things based on a projected window size rather than the current cached window size)

Returns:
TRUE if there is no need for a scroll bar
Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care

Definition at line 1389 of file ccolbar.cpp.

01390 {
01391     if (BarHeight == 0)             // In small mode, always has arrows
01392         return(FALSE);
01393 
01394     if (pStripRect == NULL)         // By default, use our 'global' strip rectangle
01395         pStripRect = &StripRect;
01396 
01397     if (DisplayedColours < 0)
01398         DisplayedColours = pStripRect->width / CellSize;
01399 
01400     if (MaxColours < 0)
01401     {
01402         MaxColours = GetNumberOfColours();
01403 
01404         /* FIXEDCOLOURS
01405         if (m_pCurrentColourList == NULL)
01406             m_pCurrentColourList = ColourManager::GetColourList();
01407 
01408         if (m_pCurrentColourList == NULL)
01409             return(FALSE);
01410 
01411         MaxColours = (INT32) m_pCurrentColourList->GetUndeletedCount();
01412         */
01413     }
01414 
01415     return(MaxColours <= DisplayedColours);
01416 }

TCHAR * CColourBar::HelpCallbackHandler wxWindow *  Window,
INT32  Item,
void *  UserData
[static, protected]
 

Callback handler for providing Bubble help over the Colour Bar window.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/5/94 (moved to new CColourBar from ColourBar 23/6/94)
Parameters:
Window - The window handle for which bubble help is required (ignored) [INPUTS] Item - The item (in our case the colour index) on which we want help UserData - user data passed on to us by the help system - ignored
Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care

Definition at line 3244 of file ccolbar.cpp.

03245 {
03246     static String_64 HelpStringStore;
03247     StringBase *HelpString = NULL;
03248 
03249     if (TheColourBar == NULL || Item == CLICKED_NOTHING)
03250         return(NULL);
03251 
03252 //  ASSERT_VALID(TheColourBar);
03253 
03254     if (Item >= CLICKED_NOTHING)
03255     {
03256         switch(Item)
03257         {
03258             case CLICKED_SCROLLBAR:         // 'Drag to scroll'
03259                 HelpStringStore.MakeMsg(_R(IDS_COLBAR_HSCROLL));
03260                 HelpString = &HelpStringStore;
03261                 break;
03262 
03263             case CLICKED_SCROLLBARLEFT:     // 'Click to scroll'
03264             case CLICKED_SCROLLBARRIGHT:
03265             case CLICKED_LEFTSCROLL:
03266             case CLICKED_RIGHTSCROLL:
03267                 HelpStringStore.MakeMsg(_R(IDS_COLBAR_HBUTTONS));
03268                 HelpString = &HelpStringStore;
03269                 break;
03270 
03271             case CLICKED_INDICATORS:        // 'Current line/fill colours'
03272                 HelpStringStore.MakeMsg(_R(IDS_COLBAR_HINDICATOR));
03273                 HelpString = &HelpStringStore;
03274                 break;
03275 
03276             case CLICKED_NOCOLOURCELL:
03277                 HelpStringStore.MakeMsg(_R(IDS_COLBAR_HNOCOLOUR));
03278                 HelpString = &HelpStringStore;
03279                 break;
03280 
03281             case CLICKED_EDITBUTTON:
03282                 HelpStringStore.MakeMsg(_R(IDS_COLBAR_HEDITBUTTON));
03283                 HelpString = &HelpStringStore;
03284                 break;
03285 
03286 #if FALSE
03287             case CLICKED_NEWBUTTON:
03288                 HelpStringStore.MakeMsg(_R(IDS_COLBAR_HNEWBUTTON));
03289                 HelpString = &HelpStringStore;
03290                 break;
03291 #endif
03292         }
03293     }
03294     else
03295     {
03296         // We are over a colour cell - bubble-help its name
03297         IndexedColour *TheColour = NULL;
03298         // If the user has the preference set then include and hence show the document
03299         // colours
03300         if (ColourSGallery::ShowDocumentColours)
03301             TheColour = TheColourBar->FindColourByIndex(Item);
03302 
03303         if (TheColour != NULL)
03304         {
03305             HelpStringStore = *(TheColour->GetName());
03306             HelpString = &HelpStringStore;
03307         }
03308         else
03309         {
03310 PORTNOTE("other","Removed ColourSGallery usage")
03311 #if !defined(EXCLUDE_FROM_XARALX)
03312             // Check to see if its a colour library item
03313             SGDisplayLibColour *pLibColour = NULL;
03314             DocColour * pTheColour = TheColourBar->FindLibColourByIndex(Item, &pLibColour);
03315             if (pTheColour && pLibColour)
03316             {
03317                 // Get the name of the item from the LibColour gallery item
03318                 // which is keeping it safe for us
03319                 String_256 Buffer;
03320                 pLibColour->GetNameText(&Buffer);
03321                 HelpStringStore = Buffer;
03322                 HelpString = &HelpStringStore;
03323             }
03324 #endif
03325         }
03326     }
03327 
03328     if (HelpString != NULL)
03329         return((TCHAR *) *HelpString);
03330 
03331     return(NULL);
03332 }

BOOL CColourBar::InitPrefs void   )  [protected]
 

Initialisation of ColourBar preference option(s) Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/6/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if the initialisation of the Colour bar prefs was successful.

Definition at line 913 of file ccolbar.cpp.

00914 {
00915     if (MsgHandler == NULL)
00916         MsgHandler = new ColourBarMsgHandler;
00917 
00918     if (MsgHandler == NULL)
00919         return(FALSE);
00920 
00921     Camelot.DeclareSection(TEXT("Displays"), 8);
00922     Camelot.DeclarePref(TEXT("Displays"), TEXT("ColourBarMode"), &DefaultSizeIndex);
00923     Camelot.DeclarePref(TEXT("Displays"), TEXT("ColourCellsDivided"), &ColourCellsDivided);
00924 
00925     return(TRUE);
00926 }

BOOL CColourBar::IsColourPickerOverStripRect wxWindow *  colourPicker,
wxPoint  mousePt
 

This function helps to determin how colour picker controls should behave when they are over the colour bar.

Author:
Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/10/99
Parameters:
colourPicker - The wxWindow* of the claimed colour picker control [INPUTS] mousePt - the current mouse location that the colour picker is supplying
Returns:
True if mousePt is in StripRect False otherwise Throws ENSURE error if colourPicker is NOT a colour picker control

Definition at line 1248 of file ccolbar.cpp.

01249 {
01250     return((colourPicker == this) && StripRect.Inside(mousePt));
01251 
01252 #if FALSE
01253     // firstly, lets check for obvious insanity
01254     String_256 ClassNameStr;  // The control type
01255 
01256     // Find out the class type of the gadget
01257     GetClassName (colourPicker, (TCHAR*) ClassNameStr, 255);
01258 
01259     //BOOL returnVal = FALSE;
01260 
01261     if (ClassNameStr == String_8(TEXT("cc_colPicker")))
01262     {
01263         if (StripRect.PtInRect(mousePt))
01264         {
01265             return (TRUE);
01266         }
01267         else
01268         {
01269             return (FALSE);
01270         }
01271     }
01272 
01273     ENSURE(FALSE, _T("IsColourPickerOverStripRect called for invalid colour picker control"));
01274     return (FALSE);
01275 #endif
01276 }

void CColourBar::OnAnyButtonDblClk wxPoint  point,
INT32  Modifier
[protected]
 

Handle double clicks in the colour bar. This brings up the colour picker on the given colour. This works on any colour cell, including the current colour indicators. Double clicks on scroll arrows are passed on to the normal single-click handler (otherwise every second click, when repeating fast, is lost).

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/6/94
Parameters:
point - co-ordinate of the click point [INPUTS] Modifier - should be +1 (Select) or -1 (Adjust)

Definition at line 4854 of file ccolbar.cpp.

04855 {
04856     if (m_pCurrentColourList == NULL)
04857         return;
04858 
04859     INT32 ColourCell = WhereIsMouse(point);
04860 
04861     if (ColourCell == CLICKED_INDICATORS)
04862     {
04863         // Have double-clicked the line/fill colour indicator, so edit them if possible
04864         wxRect InnerRect(IndicatorRect);
04865         INT32 DeflateBy = (abs(IndicatorRect.height) * 2) / 5;
04866         if (DeflateBy < 4)
04867             DeflateBy = 4;  // Line indicator is min. of 2 pixels wide
04868         InnerRect.Inflate(-DeflateBy / 2, -DeflateBy / 2);
04869 
04870 //      IndexedColour *IndexedColToEdit = NULL;
04871 
04872         DocColour *LineColour;
04873         DocColour *FillColour;
04874         DocColour *EndColour;
04875         ColourManager::GetCurrentLineAndFillColours(&LineColour, &FillColour, &EndColour);
04876 
04877         if (InnerRect.Inside(point))
04878         {
04879             if (EndColour != NULL && point.y <= (InnerRect.y + (InnerRect.height / 2)))
04880                 FillColour = EndColour;
04881 
04882             if (FillColour!= NULL)
04883             {
04884                 // Find the fill colour. If it's unnamed, then we'll use NULL so that we
04885                 // edit the local colour properly instead of doing the wrong thing
04886                 IndexedColour *IxColour = FillColour->FindParentIndexedColour();
04887                 if (IxColour != NULL && !IxColour->IsNamed())
04888                     IxColour = NULL;
04889 
04890                 EditAColour(m_pCurrentColourList, IxColour, FALSE);
04891             }
04892             else
04893                 EditAColour(NULL, NULL, FALSE);
04894         }
04895         else
04896         {
04897             if (LineColour != NULL)
04898             {
04899                 // Find the line colour. If it's unnamed, then we'll use NULL so that we
04900                 // edit the local colour properly instead of doing the wrong thing
04901                 IndexedColour *IxColour = LineColour->FindParentIndexedColour();
04902                 if (IxColour != NULL && !IxColour->IsNamed())
04903                     IxColour = NULL;
04904 
04905                 EditAColour(m_pCurrentColourList, IxColour, TRUE);
04906             }
04907             else
04908                 EditAColour(NULL, NULL, TRUE);
04909         }
04910     }
04911     else if (ColourCell == CLICKED_LEFTSCROLL || ColourCell == CLICKED_RIGHTSCROLL)
04912     {
04913         // As double-clicks are enabled, Windows weeds out every second click if the
04914         // user clicks repeatedly at high speed. Thus, we respond to a double-click
04915         // on the scroll arrows as if it were just a second ordinary click.
04916         OnAnyButtonDown(point, Modifier);
04917     }
04918 }

void CColourBar::OnAnyButtonDown const wxPoint &  point,
INT32  Modifier
[protected]
 

Handle button clicks in the colour bar. Called by the LButton and RButton handlers to share the code somewhat.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/6/94
Parameters:
point - co-ordinate of the click point [INPUTS] Modifier - +1 if select click, -1 if adjust click

Definition at line 4516 of file ccolbar.cpp.

04517 {
04518     if (DragInfo.MouseCaptured)                 // Ignore clicks during drags
04519         return;
04520 
04521     // Remove bubble help whenever the user clicks
04522 //  ControlHelper::BubbleHelpDisable();
04523 
04524     if (m_pCurrentColourList == NULL)       // Ensure the current ColourList pointer is valid
04525         m_pCurrentColourList = ColourManager::GetColourList();
04526 
04527     if (m_pCurrentColourList == NULL)       // No DOCUMENT! No Colours! Exit immediately!
04528         return;
04529 
04530     wxRect RectMouseIsIn;
04531     INT32 MousePos = WhereIsMouse(point, &RectMouseIsIn);
04532 
04533     DragInfo.Adjust = (Modifier < 0);
04534     DragInfo.LastMousePos = point;              // Remember last point mouse was at
04535     DragInfo.DragItem = MousePos;               // and last item it was over
04536 
04537 
04538     if (MousePos < CLICKED_NOTHING)
04539     {
04540         BOOL ModifierKeyDown = GetModifierKeyState();
04541 
04542         if (ModifierKeyDown)
04543         {
04544             // If Right ALT down, allow 'push tool' dragging mode on colourstrip
04545             CaptureTheMouse();
04546             DragInfo.DragItem = CLICKED_SCROLLSTRIP;
04547 
04548             // AnchorOffset is now the colour cell being dragged
04549             DragInfo.AnchorOffset = (INT32) (LeftmostColour +
04550                                     ((point.x - StripRect.x) / CellSize));
04551             return;
04552         }
04553         else
04554         {
04555 #ifdef DISABLE_COLOUR_DRAGS
04556             CellClicked(MousePos, (Modifier < 0));
04557 #else
04558             // Find the clicked colour, and start a drag of it
04559             IndexedColour *TheColour = NULL;
04560             ColourDragInformation *DragCol = NULL;
04561             // If the user has the preference set then include and hence show the document
04562             // colours
04563             if (ColourSGallery::ShowDocumentColours)
04564                 TheColour = FindColourByIndex(MousePos);
04565 
04566             if (TheColour != NULL)
04567             {
04568                 DragCol = new ColourDragInformation(TheColour, (Modifier < 0),
04569                                                         Document::GetSelected());
04570             }
04571             else
04572             {
04573 PORTNOTE("other","Removed ColourSGallery usage")
04574 #if !defined(EXCLUDE_FROM_XARALX)
04575                 // FIXED COLOURS
04576                 // We didn't find the colour in the document colours section
04577                 // so check any library sections that may be present
04578                 SGDisplayLibColour *pLibColour = NULL;
04579                 DocColour * pTheDocColour = FindLibColourByIndex(MousePos, &pLibColour);
04580                 if (pTheDocColour && pLibColour)
04581                 {
04582                     // Start up a DocColour drag which should give us what we want
04583                     String_256 Buffer;
04584                     pLibColour->GetNameText(&Buffer);
04585                     DragCol = new ColourDragInformation(pTheDocColour, (Modifier < 0),
04586                                                         &Buffer, pLibColour->IsASpotColour());
04587                 }
04588 #endif
04589             }
04590 
04591             DragManagerOp::StartDrag(DragCol, this);
04592 #endif
04593             return;
04594         }
04595     }
04596 
04597     switch(MousePos)
04598     {
04599         case CLICKED_NOCOLOURCELL:              // Set 'no colour'
04600 #ifdef DISABLE_COLOUR_DRAGS
04601             CellClicked(MousePos, (Modifier < 0));
04602 #else
04603             // Create an attribute of the correct type
04604 
04605             ColourDragInformation * DragCol;
04606             DragCol = new ColourDragInformation(NULL, (Modifier < 0),
04607                                                 Document::GetSelected());
04608             DragManagerOp::StartDrag(DragCol, this);
04609 #endif
04610             break;
04611 
04612         case CLICKED_INDICATORS:
04613 #ifndef DISABLE_COLOUR_DRAGS
04614             {
04615                 // Have clicked the line/fill colour indicator, so drag them if possible
04616                 wxRect InnerRect(IndicatorRect);
04617                 INT32 DeflateBy = (abs(IndicatorRect.height) * 2) / 5;
04618                 if (DeflateBy < 4)
04619                     DeflateBy = 4;  // Line indicator is min. of 2 pixels wide
04620                 InnerRect.Inflate(-DeflateBy / 2, -DeflateBy / 2);
04621 
04622                 // Resort to dragging 'no colour' if a better colour can't be found
04623                 IndexedColour *IndexedColToDrag = NULL;
04624 
04625                 DocColour *LineColour;
04626                 DocColour *FillColour;
04627                 DocColour *EndColour;
04628                 ColourManager::GetCurrentLineAndFillColours(&LineColour, &FillColour, &EndColour);
04629 
04630                 DocColour *DocColourToUse = NULL;
04631 
04632                 if (InnerRect.Inside(point))
04633                 {
04634                     if (EndColour != NULL && point.y <= (InnerRect.y + (InnerRect.height / 2)))
04635                         DocColourToUse = EndColour;
04636                     else
04637                         DocColourToUse = FillColour;
04638                 }
04639                 else
04640                     DocColourToUse = LineColour;
04641 
04642                 // If we found a doc colour to be dragged, find its IndexedColour parent (or if necessary,
04643                 // create a new local colour to be dragged from the immediate-doccolour definition)
04644                 if (DocColourToUse != NULL)
04645                 {
04646                     IndexedColToDrag = DocColourToUse->FindParentIndexedColour();
04647 
04648                     // If the DocColour was an immediate colour (non-transparent, but
04649                     // with no parent IndexedColour) then we'll need to create a local IndexedColour
04650                     // to represent the colour to be dragged, or else it'll drag 'no colour'!
04651                     // This may return NULL, but we're quite happy with that.
04652                     if (IndexedColToDrag == NULL && !DocColourToUse->IsTransparent())
04653                     {
04654                         IndexedColToDrag = ColourManager::GenerateNewUnnamedColour(
04655                                                             m_pCurrentColourList, DocColourToUse);
04656                     }
04657                 }
04658 
04659                 ColourDragInformation *DragCol;
04660                 DragCol = new ColourDragInformation(IndexedColToDrag, (Modifier < 0),
04661                                                     Document::GetSelected());
04662                 DragManagerOp::StartDrag(DragCol, this);
04663             }
04664 #endif
04665             break;
04666 
04667         case CLICKED_LEFTSCROLL:
04668             ScrollTheStrip(-Modifier);          // Scroll once
04669             CaptureTheMouse();                  // And start an autorepeat 'drag'
04670             SetATimer(TRUE);
04671             break;
04672 
04673         case CLICKED_RIGHTSCROLL:
04674             ScrollTheStrip(Modifier);           // Scroll once
04675             CaptureTheMouse();                  // And start an autorepeat 'drag'
04676             SetATimer(TRUE);
04677             break;
04678 
04679         case CLICKED_SCROLLBARLEFT:             // PageRight once
04680             {
04681                 UINT32 NumDisplayedColours = StripRect.width / CellSize;
04682                 ScrollTheStrip((INT32) ((-Modifier) * NumDisplayedColours));
04683                 CaptureTheMouse();              // And start an autorepeat 'drag'
04684                 SetATimer(TRUE);
04685             }
04686             break;
04687 
04688         case CLICKED_SCROLLBARRIGHT:            // PageLeft once
04689             {
04690                 UINT32 NumDisplayedColours = StripRect.width / CellSize;
04691                 ScrollTheStrip((INT32) (Modifier * NumDisplayedColours));
04692                 CaptureTheMouse();              // And start an autorepeat 'drag'
04693                 SetATimer(TRUE);
04694             }
04695             break;
04696 
04697         case CLICKED_SCROLLBAR:
04698             CaptureTheMouse();                  // Start drag (on MouseMoves, not Timers)
04699 
04700             // AnchorOffset is now the distance (pixels) of the drag anchor from
04701             // the center of the scroll sausage
04702             DragInfo.AnchorOffset = point.x -
04703                                     (RectMouseIsIn.x + (RectMouseIsIn.width / 2));
04704             break;
04705 
04706         case CLICKED_EDITBUTTON:
04707             {
04708                 if (IndentedButton == CLICKED_NOTHING)      // Indent button while mouse down
04709                 {
04710                     TRACEUSER("Gerry", _T("Edit Clicked"));
04711                     IndentedButton = CLICKED_EDITBUTTON;
04712                     ForceRedrawOfRect(EditButtonRect);
04713                     Update();                           // Force immediate redraw
04714                     CaptureMouse();                         // And grab all mouse events
04715                 }                                           // until the button is released
04716 
04717 #if FALSE
04718 /*
04719     // No longer needed - we want the editor to pop up in "local" mode.
04720                 DocColour *LineColour;
04721                 DocColour *FillColour;
04722 
04723                 ERROR3IF(m_pCurrentColourList == NULL,
04724                         _T("Unexpected NULL ColourList pointer in CColourBar::OnAnyButtonDown"));
04725 
04726                 ColourManager::GetCurrentLineAndFillColours(&LineColour, &FillColour);
04727 
04728                 // Edit the appropriate colour. If there is none, EditAColour just beeps
04729                 // and returns without getting upset
04730 
04731                 IndexedColour *ColToEdit = NULL;
04732                 if (Modifier < 0)
04733                 {
04734                     if (LineColour != NULL)
04735                         ColToEdit = LineColour->FindParentIndexedColour();
04736                 }
04737                 else
04738                 {
04739                     if (FillColour != NULL)
04740                         ColToEdit = FillColour->FindParentIndexedColour();
04741                 }
04742 
04743                 EditAColour(m_pCurrentColourList, ColToEdit);
04744 */
04745 #else
04746                 EditAColour(NULL, NULL, (Modifier < 0));
04747 #endif
04748             }
04749             break;
04750 
04751 
04752 #if FALSE
04753 /*
04754         case CLICKED_NEWBUTTON:
04755             {
04756                 if (IndentedButton == CLICKED_NOTHING)      // Indent button while mouse down
04757                 {
04758                     IndentedButton = CLICKED_NEWBUTTON;
04759                     ForceRedrawOfRect(NewButtonRect);
04760                     UpdateWindow();                         // Force immediate redraw
04761                     SetCapture();                           // And grab all mouse events
04762                 }                                           // until the button is released
04763 
04764                 ERROR3IF(m_pCurrentColourList == NULL,
04765                         _T("Unexpected NULL ColourList pointer in CColourBar::OnAnyButtonDown"));
04766 
04767                 IndexedColour *NewCol = NULL;
04768 
04769                 // Create a new colour, in the current colour list, copied from the
04770                 // current attribute/selection if possible.
04771                 ColourList *CurrentDocColours = ColourManager::GetColourList();
04772                 ERROR3IF(CurrentDocColours == NULL, _T("No colour list present?!"));
04773 
04774                 if (CurrentDocColours != NULL)
04775                 {
04776                     NewCol = ColourManager::GenerateNewNamedColour(CurrentDocColours, NULL);
04777 
04778                     if (NewCol != NULL)
04779                     {
04780                         ApplyColour(NewCol, (Modifier < 0));    // Apply col to selection
04781                         EditAColour(m_pCurrentColourList, NewCol);  // And open editor
04782                     }
04783                 }
04784             }
04785             break;  
04786 */
04787 #endif
04788     }
04789 }

void CColourBar::OnAnyButtonUp const wxPoint &  point  )  [protected]
 

Processes any button-released event. This stops auto-repeat and drags, and releases any claims (timers, drags) we might have.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/6/94
Parameters:
point - the point where the mouse was released [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

Definition at line 5107 of file ccolbar.cpp.

05108 {
05109     DragInfo.LastMousePos = point;
05110     ReleaseAllClaims();
05111 
05112     if (IndentedButton == CLICKED_EDITBUTTON)
05113         ForceRedrawOfRect(EditButtonRect);
05114 #if FALSE
05115     else if (IndentedButton == CLICKED_NEWBUTTON)
05116         ForceRedrawOfRect(NewButtonRect);
05117 #endif
05118 
05119     if (IndentedButton != CLICKED_NOTHING)
05120     {
05121         IndentedButton = CLICKED_NOTHING;       // Remember that nothing is indented
05122     }
05123 }

void CColourBar::OnLButtonDblClk wxMouseEvent &  event  )  [protected]
 

Handle left-button double clicks in the colour bar.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/6/94
Parameters:
nFlags - unused [INPUTS] point - co-ordinate of the click point

Definition at line 4934 of file ccolbar.cpp.

04935 {
04936     OnAnyButtonDblClk(event.GetPosition(), (ShiftIsDown() ? -1 : +1));
04937 }

void CColourBar::OnLButtonDown wxMouseEvent &  event  )  [protected]
 

Handle left-button clicks in the colour bar Note that a shift-click is converted into the equivalent of a right-click by this function.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/6/94
Parameters:
nFlags - unused [INPUTS] point - co-ordinate of the click point
See also:
CColourBar::OnAnyButtonDown

Definition at line 4808 of file ccolbar.cpp.

04809 {
04810     TRACEUSER("Gerry", _T("CColourBar::OnLButtonDown"));
04811     OnAnyButtonDown(event.GetPosition(), (ShiftIsDown() ? -1 : +1));
04812 }

void CColourBar::OnLButtonUp wxMouseEvent &  event  )  [protected]
 

Processes a left-button-released message.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/6/94
Parameters:
nFlags - A bit-field describing which buttons and keys were down [INPUTS] when the message was generated point - the position of the mouse cursor.
- [OUTPUTS]
Returns:
-

Errors: -

Definition at line 5142 of file ccolbar.cpp.

05143 {
05144     TRACEUSER("Gerry", _T("CColourBar::OnLButtonUp"));
05145     OnAnyButtonUp(event.GetPosition());
05146 }

void CColourBar::OnMouseMove wxMouseEvent &  event  )  [protected]
 

Processes all mouse moves over the colour bar. This currently involves providing bubble help and updating during drags of the scroll sausage. Other 'drag' updates (button autorepeats) are handled by OnTimer().

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/6/94
Parameters:
nflags - Ignored [INPUTS] point - The mouse position
See also:
CControlBar::OnTimer

Definition at line 4977 of file ccolbar.cpp.

04978 {
04979 //  TRACEUSER("Gerry", _T("CColourBar::OnMouseMove"));
04980 
04981     if (m_pCurrentColourList == NULL)       // Ensure the current ColourList pointer is valid
04982         m_pCurrentColourList = ColourManager::GetColourList();
04983 
04984     if (m_pCurrentColourList == NULL)       // No DOCUMENT! No Colours! Exit immediately!
04985         return;
04986 
04987     wxPoint point = event.GetPosition();
04988     DragInfo.LastMousePos = point;  // Remember new mouse position for OnTimer code
04989 
04990     // Check if the push-mode modifier key is down, and if so, swap to the push cursor
04991     BOOL ModifierKeyDown = GetModifierKeyState();
04992 
04993     if (StripRect.Inside(point) && ModifierKeyDown)
04994     {
04995         // Set the cursor to the push hand shape
04996         if (!PushCursor)
04997             PushCursor = new Cursor(_R(IDC_PUSHTOOLCURSOR));
04998 
04999         if (PushCursor)
05000             PushCursor->SetActive();
05001     }
05002     else
05003     {
05004         Cursor::Arrow->SetActive();
05005         if (PushCursor)
05006         {
05007             delete PushCursor;
05008             PushCursor = NULL;
05009         }
05010     }
05011 
05012 
05013     if (DragInfo.MouseCaptured)
05014     {
05015         // We are dragging something
05016         if (DragInfo.DragItem == CLICKED_SCROLLBAR && ScrollHeight != 0)
05017         {
05018             // We are dragging the scrollbar sausage
05019             wxRect SausageRect;
05020             if (CalculateSausageRect(&SausageRect))
05021             {
05022                 // We want to scroll the AnchorOffset point under the mouse posn.
05023                 INT32 DistToScroll = point.x -
05024                                     ((SausageRect.x + (SausageRect.width / 2)) +
05025                                     DragInfo.AnchorOffset);
05026 
05027                 ENSURE(ScrollBarRect.width > 0,
05028                         "Serious problem with the ColourBar's ScrollBarRect");
05029 
05030                 INT32 ColoursToScroll = ((INT32)TotalNumColours * DistToScroll) / ScrollBarRect.width;
05031 
05032                 ScrollTheStrip(ColoursToScroll);
05033             }
05034         }
05035         else if (DragInfo.DragItem == CLICKED_SCROLLSTRIP)
05036         {
05037             ENSURE(StripRect.width > 0,
05038                     "Serious problem with the ColourBar's StripRect");
05039 
05040             INT32 NewAnchorCellIndex = (INT32) ((INT32)LeftmostColour +
05041                                     ((INT32)(point.x - StripRect.x) / (INT32)CellSize));
05042             ScrollTheStrip((INT32) (DragInfo.AnchorOffset - NewAnchorCellIndex));
05043         }
05044     }
05045     else
05046 
05047     {
05048         // Not dragging, so do Bubble & StatusBar Help on the thing under the mouse,
05049         // but only if the colour bar is active (we have a colour display list)
05050         if (ColourManager::GetColourList() != NULL)
05051         {
05052             String_256 HelpText(_T(""));
05053 
05054             if (GetStatusLineText(&HelpText))
05055             {
05056                 StatusLine *pStatusLine = GetApplication()->GetpStatusLine();
05057                 if (pStatusLine)
05058                     pStatusLine->UpdateText(&HelpText, STATUSLINE_SELDESC_COLBAR);
05059 
05060 //              TRACEUSER("Gerry", _T("CColourBar updating status to '%s'"), (LPCTSTR)HelpText);
05061             }
05062 
05063             INT32 MousePos = WhereIsMouse(point);
05064 
05065             // Do bubble help for the colour cells and assorted icons
05066             if (MousePos == CLICKED_NOTHING)
05067             {
05068                 // Remove bubble help, as they're over no man's land
05069                 // This should no longer completely disable bubble help over our window,
05070                 // but merely turn off the bubble while the pointer is not over anything
05071                 // of any interest.
05072 //              ControlHelper::BubbleHelpDisable();
05073             }
05074             else
05075             {
05076 PORTNOTE("other","Removed ControlHelper bubblehelp usage")
05077 #if !defined(EXCLUDE_FROM_XARALX)
05078                 ControlHelper::DoBubbleHelpOn(m_hWnd, MousePos,
05079                                                 HelpCallbackHandler, this);
05080 #endif
05081             }
05082         }
05083 //      else
05084 //          ControlHelper::BubbleHelpDisable(); // No colourstrip, so no help
05085     }
05086 
05087     event.Skip();
05088 }

void CColourBar::OnPaint wxPaintEvent &  evnt  )  [protected]
 

Redraws the colour bar.

Author:
Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com>
Date:
ages ago
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

Definition at line 2679 of file ccolbar.cpp.

02680 {
02681     // Always create this so that the area is validated
02682     wxPaintDC dc(this);
02683 
02684     if (!CCamApp::IsDisabled())
02685     {
02686         DoPaint(&dc);
02687     }
02688 }

void CColourBar::OnRButtonDblClk wxMouseEvent &  event  )  [protected]
 

Handle right-button double clicks in the Colour Bar.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/6/94
Parameters:
nFlags - unused [INPUTS] point - co-ordinate of the click point

Definition at line 4953 of file ccolbar.cpp.

04954 {
04955     OnAnyButtonDblClk(event.GetPosition(), -1);
04956 }

void CColourBar::OnRButtonDown wxMouseEvent &  event  )  [protected]
 

Handle right-button clicks in the Colour Bar.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/6/94
Parameters:
nFlags - unused [INPUTS] point - co-ordinate of the click point
See also:
CColourBar::OnAnyButtonDown

Definition at line 4829 of file ccolbar.cpp.

04830 {
04831     TRACEUSER("Gerry", _T("CColourBar::OnRButtonDown"));
04832     OnAnyButtonDown(event.GetPosition(), -1);
04833 }

void CColourBar::OnRButtonUp wxMouseEvent &  event  )  [protected]
 

Processes a right-button-released message.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/6/94
Parameters:
nFlags - A bit-field describing which buttons and keys were down [INPUTS] when the message was generated point - the position of the mouse cursor.
- [OUTPUTS]
Returns:
-

Errors: -

Definition at line 5166 of file ccolbar.cpp.

05167 {
05168     TRACEUSER("Gerry", _T("CColourBar::OnLButtonUp"));
05169     OnAnyButtonUp(event.GetPosition());
05170 }

void CColourBar::OnSize wxSizeEvent &  event  )  [protected]
 

Handle resizing of our window. This ensures that the scroll offset is within the new bounds of the colour strip, and forces a redraw.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/6/94
Parameters:
all ignored [INPUTS]

Definition at line 4191 of file ccolbar.cpp.

04192 {
04193 //  TRACEUSER("Gerry", _T("CColourBar::OnSize(%d, %d)\n"), event.m_size.x, event.m_size.y);
04194     if (m_pCurrentColourList == NULL)
04195     {
04196         Refresh();      // No colour list - just ensure we're redrawn OK, and exit
04197         return;
04198     }
04199 
04200     INT32 NewWidth = event.GetSize().x;
04201     INT32 NewHeight = event.GetSize().y;
04202 
04203     // Calculate what the new window rect is going to be (width is all the it really needs
04204     // to know) and from it, calculate where ther striprect is going to be placed. From
04205     // this, we can calculate how many colours will be displayed at the new window size.
04206     wxRect AvailableRect(0, 0, NewWidth, NewHeight);
04207 
04208     wxRect tStripRect;      // Temporary lookalikes to the global cached rects
04209     wxRect tIndicatorRect;
04210     wxRect tScrollBarRect;
04211     wxRect tEditButtonRect;
04212     wxRect tNewButtonRect;  // Warning - this button is now defunct
04213 
04214     CalculateRectsInternal(&AvailableRect,
04215                             &tStripRect, &tIndicatorRect, &tScrollBarRect,
04216                             &tEditButtonRect, &tNewButtonRect);
04217 
04218     INT32 NewDisplayedColours = tStripRect.width / CellSize;
04219     
04220     //INT32 MaxColours = (INT32) m_pCurrentColourList->GetUndeletedCount(); // FIXEDCOLOURS
04221     INT32 MaxColours = (INT32)GetNumberOfColours();
04222 
04223     // If height of bar unchanged, we may not need to redraw (stop solid-drag flicker)...
04224     if (NewHeight == OldBarHeight)
04225     {
04226         INT32 OldDisplayedColours = StripRect.width / CellSize;
04227 
04228         // If we can display exactly the same number of colours, no need to redraw
04229         if (NewDisplayedColours == OldDisplayedColours)
04230             return;
04231 
04232         // if all colours were & still-are displayed, then we need not redraw
04233         if (NewDisplayedColours >= MaxColours && OldDisplayedColours >= MaxColours)
04234             return;
04235     }
04236 
04237     // Ensure the scroll position is valid (similar to ScrollTheStrip(0))
04238     INT32 NewLeftmost = (INT32)LeftmostColour;
04239 
04240     if (NewLeftmost > MaxColours - NewDisplayedColours)
04241         NewLeftmost = MaxColours - NewDisplayedColours;
04242     if (NewLeftmost < 0)
04243         NewLeftmost = 0;
04244 
04245     LeftmostColour = (UINT32) NewLeftmost;
04246 
04247     Refresh(false);         // Force-redraw the entire window
04248 
04249     // Finally, remember the new size of the bar so we don't unnecessarily redraw
04250     // if we are resized again soon (i.e. solid drag)
04251     OldBarHeight = NewHeight;
04252 }

void CColourBar::OnTimer wxTimerEvent &  event  )  [protected]
 

Responds to the triggering of the timer which we set when a click or drag first occurred, in order to check for auto-repeat of buttons. This currently processes the scroll left/right and page left/right areas Dragging the scroll sausage is handled in OnMouseMove.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/6/94
Parameters:
nIDEvent - The ID number of the elapsed timer (not used) [INPUTS]
- [OUTPUTS]
Returns:
-
See also:
CColourbar::OnMouseMove

Definition at line 5192 of file ccolbar.cpp.

05193 {
05194     // We aren't dragging, or this is not the timer we set
05195     if (!DragInfo.MouseCaptured)
05196         return;
05197 
05198     SetATimer(FALSE);   // Replace the repeat-delay timer with a repeat-speed timer
05199 
05200     INT32 NewMouseItem = WhereIsMouse(DragInfo.LastMousePos);
05201 
05202     if (NewMouseItem == DragInfo.DragItem)
05203     {
05204         switch(DragInfo.DragItem)
05205         {
05206             case CLICKED_LEFTSCROLL:
05207                 ScrollTheStrip((DragInfo.Adjust) ? +1 : -1);
05208                 break;
05209 
05210             case CLICKED_RIGHTSCROLL:
05211                 ScrollTheStrip((DragInfo.Adjust) ? -1 : +1);
05212                 break;
05213 
05214             case CLICKED_SCROLLBARLEFT:
05215                 {
05216                     UINT32 NumDisplayedColours = StripRect.width / CellSize;
05217                     ScrollTheStrip((INT32) (((DragInfo.Adjust) ? 1 : -1) * NumDisplayedColours));
05218                 }
05219                 break;
05220 
05221             case CLICKED_SCROLLBARRIGHT:
05222                 {
05223                     UINT32 NumDisplayedColours = StripRect.width / CellSize;
05224                     ScrollTheStrip((INT32) (((DragInfo.Adjust) ? -1 : 1) * NumDisplayedColours));
05225                 }
05226                 break;
05227         }
05228     }
05229 }

void CColourBar::PaintColourCell wxDC *  pDC,
wxRect *  Rect,
DocColour RectCol
[protected]
 

Draws the given rectangle as a 'Colour cell' for the given DocColour. The top half of the rect is solid-filled with the colour, while the bottom 2 quarters are filled with the colour as it would appear on top of a white background and black bgnd respectively (if the col isn't fractionally transparent, rect is just solid filled).

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/6/94
Parameters:
pDC - The DC to draw into [INPUTS] rect - The rectangle to plot the colour cell into RectCol - The colour with which to fill the rectangle, or NULL if the cell is to be filled to represent 'no' colour or 'many' colours in a selection.
- [OUTPUTS]
Returns:
-
Notes: If GBrush has been initialised before calling this function, it will be used to plot the colour cells. The ColourBar works exclusively on the SELECTED Doc. Change with care

See also:
CColourBar::PaintColourStrip; CColourBar::DoPaint

Definition at line 2063 of file ccolbar.cpp.

02064 {          
02065     Document *ScopeDoc = Document::GetSelected();
02066     if (ScopeDoc == NULL) return;
02067 
02068     wxPen TransPen(wxColour(0,0,0), 1, wxTRANSPARENT);
02069     pDC->SetPen(TransPen);
02070 
02071     if (RectCol == NULL)        // No colour (eg 'many' colours in selection)
02072     {
02073 //      pDC->SetBkColor(RGB(255,255,255));              // ensure white background
02074         wxBrush HatchBrush(wxColour(0,0,0), wxBDIAGONAL_HATCH); // Fill with black/white hatch
02075         pDC->SetBrush(HatchBrush);
02076         pDC->DrawRectangle(*Rect);
02077         pDC->SetPen(wxNullPen);
02078         pDC->SetBrush(wxNullBrush);
02079         return;
02080     }
02081 
02082     if (RectCol->IsTransparent())
02083     {
02084 //      pDC->SetBkColor(RGB(255,255,255));              // ensure white background
02085         wxBrush HatchBrush(wxColour(0,0,0), wxCROSSDIAG_HATCH); // Fill with black/white hatch
02086         pDC->SetBrush(HatchBrush);
02087         pDC->DrawRectangle(*Rect);
02088         pDC->SetPen(wxNullPen);
02089         pDC->SetBrush(wxNullBrush);
02090         return;
02091     }
02092 
02093     // Find a context to render with. We'll use the Selected View's context if possible,
02094     // so that we render using the same colour correction/separation mode. If there
02095     // is no selected view, then we will look for a global context.
02096     ColourContextRGBT *CCrgbt = (ColourContextRGBT *)
02097                 ColourManager::GetColourContext(COLOURMODEL_RGBT, DocView::GetSelected());
02098 
02099     ERROR3IF(CCrgbt == NULL, _T("Can't find an RGB colour context to render with!"));
02100 
02101     DWORD ScreenWord = ConvertColourToTransScreenWord(CCrgbt, RectCol);
02102     
02103     wxBrush *Brush = GetColourBrush((COLORREF) (ScreenWord & 0x00ffffff));
02104 
02105     IndexedColour *Parent = RectCol->FindParentIndexedColour();
02106 // Webster shows spots as normal library colours
02107 #ifndef WEBSTER
02108     if (Parent != NULL && Parent->IsSpotOrTintOfSpot())
02109     {
02110         // Spot colours are shown as circular swatches in order to make them more obvious
02111         // (First we must fill the background with BTNFACE to clear the corners)
02112         wxBrush BackBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
02113         pDC->SetBrush(BackBrush);
02114         pDC->DrawRectangle(*Rect);
02115 
02116         // Try to make the rectangle more square, so we always render a circle
02117         wxRect Square(*Rect);
02118         if (Square.width > Square.height)
02119             Square.Inflate(-(Square.width - Square.height) / 2, 0);
02120         else if (Square.width < Square.height)
02121             Square.Inflate(0, -(Square.height - Square.width) / 2);
02122 
02123         pDC->SetBrush(*Brush);
02124         pDC->DrawEllipse(Square);
02125     }
02126     else
02127 #endif // WEBSTER
02128     {
02129         // Process colours are shown as rectangles
02130         pDC->SetBrush(*Brush);
02131         pDC->DrawRectangle(*Rect);
02132 
02133         if (ColourCellsDivided)
02134         {
02135             // If the user wants a grey line between the colour cells to make them easier
02136             // to distinguish, draw a line.
02137             wxBrush GreyBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
02138             wxRect LineRect(*Rect);
02139             LineRect.x = LineRect.GetRight();
02140             LineRect.width = 1;
02141             pDC->SetBrush(GreyBrush);
02142             pDC->DrawRectangle(LineRect);
02143         }
02144     }
02145 
02146     pDC->SetPen(wxNullPen);
02147     pDC->SetBrush(wxNullBrush);
02148     delete Brush;
02149 }

void CColourBar::PaintColourStrip wxDC *  pDC,
const wxRect &  ClipRect
[protected]
 

Redraws the ColourBar colour strip Notes: You must call CalculateRects and cache the value of TotalNumColours prior to calling this function - see DoPaint for everything that needs to be done. If GBrush has been initialised before calling this function, it will be used to plot the colour cells.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/6/94
Parameters:
pDC - The DC to paint into [INPUTS] ClipRect - The rectangle into which we're drawing. Cells outside this rectangle will not be rendered, to improve renderintg speed.
- [OUTPUTS]
Returns:
-
The ColourBar works exclusively on the SELECTED Doc. Change with care

See also:
CColourBar::DoPaint

Definition at line 2536 of file ccolbar.cpp.

02537 {
02538     // Find pointers to the fill/line IndexedColours so we will know when we hit
02539     // them as we draw, and can then draw indicator diamonds on the colour cells.
02540     IndexedColour *CurrentLineColour = NULL;
02541     IndexedColour *CurrentFillColour = NULL;    // FlatFill colour or GradFill Start colour
02542     IndexedColour *CurrentEndColour = NULL;     // GradFill End colour
02543     BOOL DiamondType;
02544 
02545     BOOL IsAGradFill = FALSE;                   // True if FillColour is the Gradfill Start colour
02546 
02547     {
02548         DocColour *LineColour = NULL;
02549         DocColour *FillColour = NULL;
02550         DocColour *EndColour  = NULL;
02551         DiamondType = ColourManager::GetCurrentLineAndFillColours(&LineColour,
02552                                                             &FillColour, &EndColour);
02553         if (LineColour)
02554             CurrentLineColour = LineColour->FindParentIndexedColour();
02555 
02556         if (FillColour)
02557             CurrentFillColour = FillColour->FindParentIndexedColour();  
02558 
02559         if (EndColour)
02560         {
02561             IsAGradFill = TRUE;
02562             CurrentEndColour  = EndColour->FindParentIndexedColour();
02563         }
02564     }
02565 
02566     // Calculate the screen rectangle of the leftmost visible cell
02567     wxRect CellRect(StripRect);
02568     CellRect.width = CellSize;
02569 
02570     INT32 CellIndex = (INT32) LeftmostColour;   // keep track of each cell's index as we draw
02571 
02572     // Draw the colours in the strip
02573     BOOL RedrawFinished = FALSE;
02574     // If the user has the preference set then include and hence show the document
02575     // colours
02576     if (ColourSGallery::ShowDocumentColours)
02577     {
02578         // Find the leftmost displayed colour in the DisplayList sequence
02579         DocColour Temp;
02580         IndexedColour *TheColour = FindColourByIndex((UINT32) LeftmostColour);
02581         while (TheColour != NULL)
02582         { 
02583             // Paint the colour cell, but only bother if it's in the invalid region
02584             // This speeds up redraw, especially when ScrollTheStrip only wishes to redraw
02585             // a few colour cells at one end of the strip.
02586             if ((CellRect.x + CellRect.width) >= ClipRect.x)
02587             {
02588                 Temp.MakeRefToIndexedColour(TheColour);
02589 
02590                 PaintColourCell(pDC, &CellRect, &Temp); // Paint this Cell
02591 
02592                 if (TheColour == CurrentLineColour)     // Paint current LineCol indicator
02593                     PaintIndicatorDiamond(pDC, CellRect, CBCOLOUR_LINE, CellIndex, DiamondType);
02594 
02595                 if (TheColour == CurrentFillColour)     // Paint Current Fill/Start indicator
02596                     PaintIndicatorDiamond(pDC, CellRect,
02597                                           (IsAGradFill) ? CBCOLOUR_START : CBCOLOUR_FILL,
02598                                           CellIndex, DiamondType);
02599 
02600                 if (TheColour == CurrentEndColour)      // Paint Current End indicator
02601                     PaintIndicatorDiamond(pDC, CellRect, CBCOLOUR_END,  CellIndex, DiamondType);
02602             }
02603 
02604             CellRect.x += CellSize;                 // Move on to next Cell
02605 
02606             // if no more room in the strip for painting, or have updated the clip
02607             // rectangle fully, we can stop redrawing
02608             if ((CellRect.x + CellRect.width) > (StripRect.x + StripRect.width) || 
02609                 CellRect.x > (ClipRect.x + ClipRect.width))
02610             {
02611                 RedrawFinished = TRUE;
02612                 break;
02613             }
02614 
02615             CellIndex++;        // Increment the current cell index
02616 
02617             // And find the next colour
02618             TheColour = m_pCurrentColourList->GetUndeletedNext(TheColour);
02619         }
02620 
02621         // If the redraw is finished then return now rather than doing extra work
02622         if (RedrawFinished)
02623             return;
02624     }
02625 
02626     // Now go through the library colours that we have been asked to display
02627     // A bit of similar code to the above may be recognised here!!!!
02628     SGDisplayLibColour *pLibColour = NULL;
02629     DocColour * pRedrawCol = FindLibColourByIndex(CellIndex, &pLibColour);
02630     while (pRedrawCol != NULL && pLibColour != NULL)
02631     {
02632         // Paint the colour cell, but only bother if it's in the invalid region
02633         // This speeds up redraw, especially when ScrollTheStrip only wishes to redraw
02634         // a few colour cells at one end of the strip.
02635         if ((CellRect.x + CellRect.width) >= ClipRect.x)
02636         {
02637             // Paint this Cell
02638 #ifndef WEBSTER
02639             // In Camelot use a special colour library item drawing routine
02640             PaintLibColourCell(pDC, &CellRect, pRedrawCol, pLibColour->IsASpotColour());
02641 #else
02642             // In Webster draw spots as standard library colours
02643             PaintLibColourCell(pDC, &CellRect, pRedrawCol, FALSE);
02644 #endif
02645         }
02646 
02647         CellRect.x += CellSize;                 // Move on to next Cell
02648 
02649         // if no more room in the strip for painting, or have updated the clip
02650         // rectangle fully, we can stop redrawing
02651         if ((CellRect.x + CellRect.width) > (StripRect.x + StripRect.width) || 
02652             CellRect.x > (ClipRect.x + ClipRect.width))
02653         {
02654             RedrawFinished = TRUE;
02655             break;
02656         }
02657 
02658         CellIndex++;        // Increment the current cell index
02659 
02660         // And find the next colour
02661         // This could be speeded up but is ok for now
02662         pRedrawCol = FindLibColourByIndex(CellIndex, &pLibColour);
02663     }
02664 }

void CColourBar::PaintEditOrNewButton wxDC *  pDC,
BOOL  Normal,
BOOL  IsEditButton
[protected]
 

Draws the colour bar "edit colour" or "new colour" button Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/9/94
Parameters:
- [INPUTS]
pDC - The DC into which to draw [OUTPUTS] Normal - FALSE for an indented button, TRUE for normal (raised) IsEditButton - TRUE to draw the Edit button, FALSE to draw the New button
Returns:
-

Definition at line 1762 of file ccolbar.cpp.

01763 {
01764     wxRect TheRect;                                 // Determine the rect to draw
01765     if (IsEditButton)
01766         TheRect = EditButtonRect;
01767     else
01768 #if FALSE
01769         TheRect = NewButtonRect;
01770 #else
01771     {
01772         ERROR3(_T("Attempt to paint 'new colour' button, which no longer exists!"));
01773         return;
01774     }
01775 #endif
01776 
01777     wxPen FramePen(wxColour(0,0,0));
01778     pDC->SetPen(FramePen);
01779     wxBrush TransBrush(wxColour(0,0,0), wxTRANSPARENT);
01780     pDC->SetBrush(TransBrush);
01781     pDC->DrawRectangle(TheRect);
01782     pDC->SetPen(wxNullPen);
01783     pDC->SetBrush(wxNullBrush);
01784 
01785     TheRect.Inflate(-1, -1);                    // ...with a plinth inside it
01786     Paint3dPlinth(pDC, &TheRect, Normal);
01787 
01788     wxPen TransPen(wxColour(0,0,0), 1, wxTRANSPARENT);
01789     pDC->SetPen(TransPen);
01790     wxBrush GreyBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));   // Fill with default colour
01791     TheRect.Inflate(-1, -1);
01792     pDC->SetBrush(GreyBrush);
01793     pDC->DrawRectangle(TheRect);
01794     pDC->SetBrush(wxNullBrush);
01795     pDC->SetPen(wxNullPen);
01796 
01797     ResourceID bitmap = 0;
01798 
01799     INT32 BmpSize = (CellSize > 15) ? 12 : 8;           // size of glyph bitmaps (8x8 and 12x12)
01800         
01801     if (IsEditButton)                               // Load appropriate glyph bitmap
01802     {
01803         if (CellSize > 15)
01804             bitmap=_R(IDB_LEDITCOL);        // 12x12 Edit glyph
01805         else
01806             bitmap=_R(IDB_EDITCOL);         // 8x8 Edit glyph
01807     }
01808     else
01809     {
01810         if (CellSize > 15)
01811             bitmap=_R(IDB_LNEWCOL);         // 12x12 New glyph
01812         else
01813             bitmap=_R(IDB_NEWCOL);          // 8x8 New glyph
01814     }
01815 
01816     wxBitmap * pBitmap = CamArtProvider::Get()->FindBitmap(bitmap);
01817 
01818     TheRect.Inflate((BmpSize - TheRect.GetWidth())/2, (BmpSize - TheRect.GetHeight())/2);
01819 
01820     // Blit the glyph to screen, including its grey mask areas
01821     if (pBitmap)
01822         pDC->DrawBitmap(*pBitmap, TheRect.GetLeft(), TheRect.GetTop(), TRUE);
01823 }

void CColourBar::PaintIndicatorDiamond wxDC *  pDC,
const wxRect &  CellRect,
CBColourType  ColourType,
INT32  CellIndex,
BOOL  DiamondType
[protected]
 

Draws a small diamond in the top left/right corner of a colour cell to indicate that the given cell is the current line/fill colour.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/6/94
Parameters:
pDC - The DC to paint into [INPUTS]
CellRect - The Colour Cell to paint the indicator into

ColourType - Indicates where and how to plot the diamond (different places and shapes are used for lines, files, and gradfills)

CellIndex - The index of the cell (or CELLINDEX_NOCOLOURCELL) which is being redrawn (this is cached to remember where the diamond is for future updates of the diamond position)

DiamondType - FALSE for 'diamond', TRUE for 'plus' shape (pluses are used to indicate colours when there is no selection, and we are thus displaying the current default attrs, not the selected colours)

Parameters:
- [OUTPUTS]
Returns:
-
Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care

See also:
CColourBar::DoPaint

Definition at line 2431 of file ccolbar.cpp.

02433 {
02434     // Calculate the position to plot the diamond (top left or top right corner)
02435     INT32 MidY = CellRect.y + (CellRect.height / 4);
02436     INT32 MidX;
02437     if (ColourType == CBCOLOUR_LINE)
02438         MidX = CellRect.x + (CellRect.width * 3 / 4);
02439     else
02440         MidX = CellRect.x + (CellRect.width / 4);
02441 
02442     if (DiamondType)
02443     {
02444         // Plot the plus shape
02445         wxBrush TransBrush(wxColour(0,0,0), wxTRANSPARENT);
02446         pDC->SetBrush(TransBrush);
02447         wxPen WhitePen(wxColour(255, 255, 255));
02448         wxRect VertRect(MidX - 3, MidY - 1, 7, 3);
02449         wxRect HorzRect(MidX - 1, MidY - 3, 3, 7);
02450         pDC->SetPen(WhitePen);
02451         pDC->DrawRectangle(VertRect);
02452         pDC->DrawRectangle(HorzRect);
02453 
02454         wxPen BlackPen(wxColour(0, 0, 0));
02455         pDC->SetPen(BlackPen);
02456         pDC->DrawLine(MidX - 2, MidY, MidX + 3, MidY);
02457         pDC->DrawLine(MidX, MidY - 2, MidX, MidY + 3);
02458         pDC->SetPen(wxNullPen);
02459         pDC->SetBrush(wxNullBrush);
02460     }
02461     else
02462     {
02463         // Generate a polygon definition of the diamond shape
02464         // When plotting gradfill start/end colour, the top/bottom point is flattened
02465         // to make an up or down arrow shape
02466         wxPoint Diamond[4];
02467         Diamond[0].x = MidX - 3;
02468         Diamond[0].y = MidY;
02469         Diamond[1].x = MidX;
02470         Diamond[1].y = MidY - ((ColourType == CBCOLOUR_START) ? 0 : 3);
02471         Diamond[2].x = MidX + 3;
02472         Diamond[2].y = MidY;
02473         Diamond[3].x = MidX;
02474         Diamond[3].y = MidY + ((ColourType == CBCOLOUR_END) ? 0 : 3);
02475 
02476         // plot it
02477         wxPen WhitePen(wxColour(255, 255, 255));
02478         wxBrush BlackBrush(wxColour(0, 0, 0));
02479         pDC->SetPen(WhitePen);
02480         pDC->SetBrush(BlackBrush);
02481         pDC->DrawPolygon(4, Diamond);
02482         pDC->SetPen(wxNullPen);
02483         pDC->SetBrush(wxNullBrush);
02484     }
02485 
02486     // Remember where we plotted this diamond
02487     switch (ColourType)
02488     {
02489         case CBCOLOUR_LINE:
02490             LastLineCell = CellIndex;
02491             break;
02492         
02493         case CBCOLOUR_END:
02494             LastEndCell  = CellIndex;
02495             break;
02496 
02497         case CBCOLOUR_FILL:
02498         case CBCOLOUR_START:
02499             LastFillCell = CellIndex;
02500             break;
02501 
02502         default:
02503             ERROR3(_T("Unknown colour type"));
02504             break;
02505     }
02506 
02507     LastDiamondShape = DiamondType;
02508 }

void CColourBar::PaintIndicators wxDC *  pDC  )  [protected]
 

Redraws the ColourBar colour indicators (current fg/bg colours) Notes: You must call CalculateRects and cache the value of TotalNumColours prior to calling this function - see DoPaint for everything that needs to be done. If GBrush has been initialised before calling this function, it will be used to plot the colour cells. The ColourBar works exclusively on the SELECTED Doc. Change with care.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/6/94
Parameters:
pDC - The DC to paint into [INPUTS] ColPalette - The list of colours displayed in the colour strip
- [OUTPUTS]
Returns:
-
See also:
CColourBar::DoPaint

Definition at line 2351 of file ccolbar.cpp.

02352 {
02353     // Save the current ColourCellsDivided preference state and set it to OFF
02354     INT32 OldCellState = ColourCellsDivided;
02355     ColourCellsDivided = FALSE;
02356 
02357 
02358     // Find the current line/fill colours to plot...
02359     DocColour *LineColour;
02360     DocColour *FillColour;
02361     DocColour *EndGradColour;
02362     ColourManager::GetCurrentLineAndFillColours(&LineColour, &FillColour, &EndGradColour);
02363 
02364     // Plot the line colour as a large colour cell filling IndicatorRect
02365     // pass NULL for many colours
02366     PaintColourCell(pDC, &IndicatorRect, LineColour);
02367 
02368     // Work out where the inside rectangle is, and plot it as a colour cell
02369     // (If you change this calculation, fix the other calc. of 'DeflateBy' below)
02370     wxRect InnerRect(IndicatorRect);
02371     INT32 DeflateBy = (INT32) (abs(IndicatorRect.height) * 2) / 5;
02372     if (DeflateBy < 4)
02373         DeflateBy = 4;  // Line indicator is min. of 2 pixels wide
02374     InnerRect.Inflate(-DeflateBy / 2, -DeflateBy / 2);
02375 
02376     if (EndGradColour != NULL)
02377     {
02378         // We want to display the start and end colours for a grad fill, so split the
02379         // fill indicator square into 2 rectangles, one above the other
02380         wxRect TopRect(InnerRect);
02381         TopRect.height = TopRect.height / 2;
02382         InnerRect.y += TopRect.height;
02383         InnerRect.height -= TopRect.height;
02384 
02385         // And paint the end colour at the bottom
02386         PaintColourCell(pDC, &TopRect, EndGradColour);
02387     }
02388 
02389     // And fill the remaining part of inner rect with the fill (or grad-fill start) colour
02390     PaintColourCell(pDC, &InnerRect, FillColour);
02391 
02392     // And restore the saved preference state
02393     ColourCellsDivided = OldCellState;
02394 }

void CColourBar::PaintLibColourCell wxDC *  pDC,
wxRect *  Rect,
DocColour RectCol,
BOOL  SpotColour = FALSE
[protected]
 

Draws the given rectangle as a 'Colour cell' for the given DocColour.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> Humprhys
Date:
20/3/97
Parameters:
pDC - The DC to draw into [INPUTS] rect - The rectangle to plot the colour cell into RectCol - The colour with which to fill the rectangle. SpotColour - falg to say if the colour should be rendered as a spot colour or not
- [OUTPUTS]
Returns:
-
See also:
CColourBar::PaintColourCell; CColourBar::DoPaint

Definition at line 2236 of file ccolbar.cpp.

02237 {          
02238     Document *ScopeDoc = Document::GetSelected();
02239     if (ScopeDoc == NULL) return;
02240 
02241     if (RectCol == NULL)        // No colour (eg 'many' colours in selection)
02242     {
02243 //      pDC->SetBkColor(RGB(255,255,255));              // ensure white background
02244         wxBrush HatchBrush(wxColour(0,0,0), wxBDIAGONAL_HATCH); // Fill with black/white hatch
02245         pDC->SetBrush(HatchBrush);
02246         pDC->DrawRectangle(*Rect);
02247         pDC->SetBrush(wxNullBrush);
02248         return;
02249     }
02250 
02251     // Find a context to render with. We'll use the Selected View's context if possible,
02252     // so that we render using the same colour correction/separation mode. If there
02253     // is no selected view, then we will look for a global context.
02254     ColourContextRGBT *CCrgbt = (ColourContextRGBT *)
02255                 ColourManager::GetColourContext(COLOURMODEL_RGBT, DocView::GetSelected());
02256 
02257     ERROR3IF(CCrgbt == NULL, _T("Can't find an RGB colour context to render with!"));
02258 
02259     DWORD ScreenWord = ConvertColourToTransScreenWord(CCrgbt, RectCol);
02260     
02261     wxBrush *Brush = GetColourBrush((COLORREF) (ScreenWord & 0x00ffffff));
02262 
02263     // Library colours are shown as diamond swatches in order to make them more obvious
02264     // (First we must fill the background with BTNFACE to clear the corners)
02265     wxBrush BackBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
02266     pDC->SetBrush(BackBrush);
02267     pDC->DrawRectangle(*Rect);
02268 
02269     // Try to make the rectangle more square, so we always render a circle
02270     wxRect Square(*Rect);
02271     if (Square.width > Square.height)
02272         Square.Inflate(-(Square.width - Square.height) / 2, 0);
02273     else if (Square.width < Square.height)
02274         Square.Inflate(0, -(Square.height - Square.width) / 2);
02275 
02276     // Generate a polygon definition of the diamond shape
02277     // When plotting gradfill start/end colour, the top/bottom point is flattened
02278     // to make an up or down arrow shape
02279     INT32 MidY = Square.y + (Square.height / 2);
02280     INT32 MidX = Square.x + (Square.width / 2);
02281     wxPoint Diamond[4];
02282     Diamond[0].x = MidX;
02283     Diamond[0].y = Square.y;
02284     Diamond[1].x = Square.x + Square.width;
02285     Diamond[1].y = MidY;
02286     Diamond[2].x = MidX;
02287     Diamond[2].y = Square.y + Square.height;
02288     Diamond[3].x = Square.x;
02289     Diamond[3].y = MidY;
02290 
02291     // plot it
02292     if (!SpotColour)
02293     {
02294         // Non spot colour so render the colour into the diamond
02295         pDC->SetBrush(*Brush);
02296         pDC->DrawPolygon(4, Diamond);
02297         pDC->SetBrush(wxNullBrush);
02298     }
02299     else
02300     {
02301         // Spot colour so render a black diamond and then the usual spot colour
02302         // render a black diamond
02303         wxBrush BlackBrush(wxColour(0,0,0));
02304         pDC->SetBrush(BlackBrush);
02305         pDC->DrawPolygon(4, Diamond);
02306         pDC->SetBrush(wxNullBrush);
02307 
02308         // Try to make the rectangle more square, so we always render a circle
02309         // 1 - 0.707 = 0.293  where 0.707 is cos and sin 45
02310         //INT32 QuarterX = (INT32)(0.2 * (double)((Rect->right - Rect->left)/2));
02311         //INT32 QuarterY = (INT32)(0.2 * (double)((Rect->top - Rect->bottom)/2));
02312         // But we could do this a lot quicker with this rough approximation
02313         //INT32 QuarterX = (INT32)((Square.right - Square.left)/10.0 + 0.5);
02314         //INT32 QuarterY = (INT32)((Square.top - Square.bottom)/10.0 + 0.5);
02315         INT32 QuarterX = Square.width / 10;
02316         INT32 QuarterY = Square.height / 10;
02317         wxRect EllipseSquare(Square.x + QuarterX, Square.y + QuarterY,
02318                             Square.width - (QuarterX * 2), Square.height - (QuarterY * 2));
02319 
02320         // render a spot colour ellipse
02321         pDC->SetBrush(*Brush);
02322         pDC->DrawEllipse(EllipseSquare);
02323         pDC->SetBrush(wxNullBrush);
02324     }
02325 
02326     // clear out the brush we created
02327     delete Brush;
02328 }

void CColourBar::PaintNoColourCell wxDC *  pDC  )  [protected]
 

Draws the 'NoColour' colour cell just to the left of the ColourStrip Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/7/94
Parameters:
pDC - The DC to draw into [INPUTS]
- [OUTPUTS]
Returns:
-
See also:
CColourBar::DoPaint

Definition at line 2168 of file ccolbar.cpp.

02169 {          
02170     wxRect Rect;
02171     CalculateNoColourCellRect(&Rect);
02172 
02173     wxPen FramePen(wxColour(0,0,0));
02174     pDC->SetPen(FramePen);
02175     wxBrush TransBrush(wxColour(0,0,0), wxTRANSPARENT);
02176     pDC->SetBrush(TransBrush);
02177     pDC->DrawRectangle(Rect);
02178 
02179     Rect.Inflate(-1, -1);
02180 
02181     wxPen TransPen(wxColour(0,0,0), 1, wxTRANSPARENT);
02182     pDC->SetPen(TransPen);
02183 
02184 //  pDC->SetBkColor(RGB(255,255,255));              // ensure white background
02185     wxBrush HatchBrush(wxColour(0,0,0), wxCROSSDIAG_HATCH); // Fill with black/white hatch
02186     pDC->SetBrush(HatchBrush);
02187     pDC->DrawRectangle(Rect);
02188 
02189     pDC->SetBrush(wxNullBrush);
02190     pDC->SetPen(wxNullPen);
02191 
02192     // Check if the current line/fill colours are 'no colour', and if so, draw diamonds
02193     // as appropriate on the 'no colour' cell.
02194     DocColour *LineColour;
02195     DocColour *FillColour;
02196     DocColour *EndColour;
02197     BOOL DiamondType = ColourManager::GetCurrentLineAndFillColours(&LineColour,
02198                                                                 &FillColour, &EndColour);
02199 
02200     // If the linecolour is transparent, plot a line diamond
02201     if (LineColour != NULL && LineColour->IsTransparent())
02202         PaintIndicatorDiamond(pDC, Rect, CBCOLOUR_LINE, CELLINDEX_NOCOLOURCELL, DiamondType);
02203 
02204     // Plot a fill diamond (flat fill) or 1 or 2 grad fill 'arrows'
02205     if (FillColour != NULL && FillColour->IsTransparent())
02206     {
02207         CBColourType TheType = CBCOLOUR_FILL;                   // It is a flat fill
02208         if (EndColour != NULL && EndColour->IsTransparent())
02209             TheType = CBCOLOUR_START;                           // Er..no it's a start gradfill
02210 
02211         PaintIndicatorDiamond(pDC, Rect, TheType, CELLINDEX_NOCOLOURCELL, DiamondType);
02212     }
02213 
02214     if (EndColour != NULL && EndColour->IsTransparent())
02215         PaintIndicatorDiamond(pDC, Rect, CBCOLOUR_END, CELLINDEX_NOCOLOURCELL, DiamondType);
02216 }

void CColourBar::PaintScrollBar wxDC *  pDC  )  [protected]
 

Redraws the ColourBar window's mini proportional scroll bar Notes: You must call CalculateRects and cache the value of TotalNumColours prior to calling this function - see DoPaint for everything that needs to be done.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/6/94
Parameters:
pDC - The DC to paint into [INPUTS] ScrollBarRect - The rectangle into which the s.b. should be painted
- [OUTPUTS]
Returns:
-
The scrollbar rect is painted *totally* i.e. all contained pixels are overwritten with colour, so it can be used in updates to redraw without any flicker (When invalidating the rect, pass FALSE to stop it filling with grey first)

The ColourBar works exclusively on the SELECTED Doc. Change with care

See also:
CColourBar::DoPaint

Definition at line 1928 of file ccolbar.cpp.

01929 {
01930     ERROR3IF(m_pCurrentColourList == NULL,
01931             _T("CColourBar::PaintScrollBar entered with NULL Current Colour List"));
01932 
01933     wxRect SausageRect;
01934     BOOL HasSausage = CalculateSausageRect(&SausageRect);
01935 
01936     wxPen TransPen(wxColour(0,0,0), 1, wxTRANSPARENT);
01937 
01938     if (HasSausage && ScrollHeight != 0)
01939     {
01940         // Paint the scrollbar outline rectangle
01941         wxPen FramePen(wxColour(0,0,0));
01942         wxBrush TransBrush(wxColour(0,0,0), wxTRANSPARENT);
01943         pDC->SetBrush(TransBrush);
01944         pDC->SetPen(FramePen);
01945         pDC->DrawRectangle(ScrollBarRect);
01946 
01947         // Paint the grey fill on either side of the sausage
01948         wxBrush GreyBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
01949         pDC->SetBrush(GreyBrush);
01950         pDC->SetPen(TransPen);
01951 
01952         wxRect TheRect(SausageRect);
01953         TheRect.x = ScrollBarRect.x + 1;
01954         TheRect.width = SausageRect.x - TheRect.x;          // Area left of sausage
01955         if (TheRect.width > 0)
01956             pDC->DrawRectangle(TheRect);
01957 
01958         TheRect.x = SausageRect.x + SausageRect.width;      // Area right of sausage
01959         TheRect.width = ScrollBarRect.GetRight() - TheRect.x;
01960         if (TheRect.width > 0)
01961             pDC->DrawRectangle(TheRect);
01962 
01963         // Fill the center of the sausage plinth with btnface grey as well
01964         if (SausageRect.width > 1)
01965         {
01966             TheRect = SausageRect;
01967             TheRect.x++;
01968             TheRect.width--;
01969             TheRect.y++;
01970             TheRect.height--;
01971             pDC->DrawRectangle(TheRect);
01972         }
01973 
01974         // Ensure it has a black line at each end to make it visible
01975         SausageRect.Inflate(1, 1);
01976         pDC->SetPen(FramePen);
01977         pDC->DrawRectangle(SausageRect);
01978 
01979         pDC->SetPen(wxNullPen);
01980         pDC->SetBrush(wxNullBrush);
01981 
01982         // Paint the Sausage plinth
01983         SausageRect.Inflate(-1, -1);
01984         Paint3dPlinth(pDC, &SausageRect, TRUE);
01985     }
01986 
01987     if (HasSausage || ScrollHeight == 0)
01988     {
01989         // Now paint on the scroll buttons
01990         PaintScrollButton(pDC, SCROLLBUTTON_LEFT, TRUE);
01991         PaintScrollButton(pDC, SCROLLBUTTON_RIGHT, TRUE);
01992     }
01993 }

void CColourBar::PaintScrollButton wxDC *  pDC,
INT32  ButtonID,
BOOL  Normal
[protected]
 

Draws a scroll button at the appropriate end of the scroll bar The button is scaled to fit into (ButtonWidth x ScrollHeight) Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/6/94
Parameters:
- [INPUTS]
pDC - The DC into which to draw [OUTPUTS] ButtonID - SCROLLBUTTON_LEFT or _RIGHT: specifies which one to draw Normal - FALSE for an indented button, TRUE for normal (raised)
Returns:
-

Definition at line 1844 of file ccolbar.cpp.

01845 {
01846     wxRect ButtonRect(ScrollBarRect);
01847 
01848     if (ButtonID == SCROLLBUTTON_LEFT)
01849         ButtonRect.x -= ButtonWidth - 1;
01850     else
01851         ButtonRect.x += ButtonRect.width - 1;
01852 
01853     ButtonRect.width = ButtonWidth;
01854 
01855     wxPen FramePen(wxColour(0,0,0));
01856     pDC->SetPen(FramePen);
01857     wxBrush TransBrush(wxColour(0,0,0), wxTRANSPARENT);
01858     pDC->SetBrush(TransBrush);
01859     pDC->DrawRectangle(ButtonRect);
01860 
01861     pDC->SetPen(wxNullPen);
01862     pDC->SetBrush(wxNullBrush);
01863 
01864     // Paint the button border plinth just inside the black outline
01865     ButtonRect.Inflate(-1, -1);
01866     Paint3dPlinth(pDC, &ButtonRect, Normal);
01867 
01868     // Calculate the left/right scroll arrow position
01869     INT32 CenterX = ButtonRect.x + (ButtonRect.width / 2);
01870     INT32 CenterY = ButtonRect.y + (ButtonRect.height / 2);
01871     INT32 offset  = (ButtonID == SCROLLBUTTON_LEFT) ? -1 : 1;
01872 
01873     wxPen TransPen(wxColour(0,0,0), 1, wxTRANSPARENT);
01874     pDC->SetPen(TransPen);
01875 
01876     // Fill the button face area with the user preference colour
01877     wxBrush GreyBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
01878     ButtonRect.Inflate(-1, -1);
01879     pDC->SetBrush(GreyBrush);
01880     pDC->DrawRectangle(ButtonRect);
01881 
01882     // Paint the left/right scroll arrow (will overwrite the border if small bar)
01883     wxPoint Triangle[3];
01884     Triangle[0].x = CenterX - offset;
01885     Triangle[0].y = CenterY + 2;
01886     Triangle[1].x = CenterX + offset;
01887     Triangle[1].y = CenterY;
01888     Triangle[2].x = CenterX - offset;
01889     Triangle[2].y = CenterY - 2;
01890 
01891     wxBrush FrameBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWFRAME));
01892     pDC->SetBrush(FrameBrush);
01893     pDC->SetPen(FramePen);
01894     pDC->DrawPolygon(3, Triangle);
01895 
01896     pDC->SetBrush(wxNullBrush);
01897     pDC->SetPen(wxNullPen);
01898 }

void CColourBar::PaletteHasChanged ColourList ChangedList = NULL  )  [static, protected]
 

This will cause the colourbar to redraw itself with the new list if necessary, and cache new values for the new current list.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/6/94
Parameters:
ChangedList - NULL if the list has been paged to a different one, [INPUTS] or a pointer to the list in which a change has been made.
Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care

Definition at line 3352 of file ccolbar.cpp.

03353 {
03354     if (TheColourBar == NULL)       // There is no colour bar!
03355         return;
03356 
03357     // Scroll (if necessary) to show the current colour indicators properly
03358     TheColourBar->SelectionHasChangedInternal();
03359 
03360     //   a) Scroll the strip by 0 cells to ensure it is scrolled to a legal position
03361     TheColourBar->ScrollTheStrip(0);
03362 
03363     //   b) Force redraw the window. We pass FALSE so the window does not flicker as
03364     //      it is updated (as the Paint() function completely fills the window anyway)
03365     //   c) If the bar needs to add/remove a scrollbar, force a layout recalculation
03366     wxRect TheRect = TheColourBar->GetClientRect();
03367     INT32 NewBarHeight = TheColourBar->CalculateNewBarHeight(&TheRect);
03368 
03369     TheColourBar->OldBarHeight = TheColourBar->GetCurrentBarHeight();
03370 
03371     if (NewBarHeight == TheColourBar->OldBarHeight)
03372         TheColourBar->Refresh(false);       // Redraw, but don't erase bground (stops flicker)
03373     else
03374     {
03375         TheColourBar->Refresh(true);        // Redraw (clear to grey for tidier resize)
03376         GetMainFrame()->UpdateFrameManager();   // Resize to add/remove the scrollbar
03377     }
03378 }

void CColourBar::RedrawGBrushAreas void   )  [static]
 

Force-redraws all areas of the colourbar that depend upon GBrush for their rendering. Used by winoil.cpp when GBrush rendering is enabled or disabled in order to redraw the colourbar.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/6/94
Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care

Definition at line 3949 of file ccolbar.cpp.

03950 {
03951     if (TheColourBar == NULL)
03952         return;
03953 
03954     TheColourBar->CalculateRects();
03955     TheColourBar->ForceRedrawOfRect(TheColourBar->StripRect);   
03956     TheColourBar->ForceRedrawOfRect(TheColourBar->IndicatorRect);   
03957     TheColourBar->Update();
03958 }

void CColourBar::ReleaseAllClaims void   )  [protected]
 

Ensures that all our temporary claims (timers, mouse capture) are released.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/6/94
Parameters:
- [INPUTS]
Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care

Definition at line 3793 of file ccolbar.cpp.

03794 {
03795     if (DragInfo.TimerOn)
03796     {
03797         m_DragTimer.Stop();
03798         DragInfo.TimerOn = FALSE;
03799     }
03800 
03801     if (HasCapture())
03802     {
03803         ReleaseMouse();
03804     }
03805     DragInfo.MouseCaptured = FALSE;
03806 }

void CColourBar::ScrollTheStrip INT32  ScrollBy,
BOOL  RedrawAlways = FALSE
[protected]
 

Scrolls the colour strip to the left or right. Does not allow scrolling past the ends of the available list. Causes the window to be redrawn.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/6/94
Parameters:
ScrollBy - The number of cells (eg +1, -1) by which to scroll the strip [INPUTS] RedrawAlways - TRUE to always redraw the strip & scrollbar, even if the scroll position does not change.
- [OUTPUTS]
Returns:
-
Notes: Passing in ScrollBy=0 has the effect of ensuring that the current scroll position is legal for the current colour list - if not, it will be corrected and the bar will be redrawn. This can thus be used to ensure the bar is updated correctly when paging to a different colour list

This recalculates the layout rects and recaches the current colour list for itself, so may be called at any time.

The ColourBar works exclusively on the SELECTED Doc. Change with care

Definition at line 3021 of file ccolbar.cpp.

03022 {
03023     Document *OldCurrentDoc = SetCurrentDoc();
03024 
03025     m_pCurrentColourList = ColourManager::GetColourList();
03026     if (m_pCurrentColourList == NULL)
03027     {
03028         RestoreCurrentDoc(OldCurrentDoc);
03029         return;
03030     }
03031 
03032     INT32 NewLeftmost = (INT32) (LeftmostColour + ScrollBy);
03033 
03034     CalculateRects();
03035 
03036     // INT32 MaxColours = (INT32) m_pCurrentColourList->GetUndeletedCount(); // FIXEDCOLOURS
03037     INT32 MaxColours = GetNumberOfColours();
03038 
03039     INT32 DisplayedColours = StripRect.width / CellSize;
03040 
03041     if (NewLeftmost > MaxColours - DisplayedColours)
03042         NewLeftmost = MaxColours - DisplayedColours;
03043 
03044     if (NewLeftmost < 0)
03045         NewLeftmost = 0;
03046 
03047     if ((UINT32) NewLeftmost != LeftmostColour || RedrawAlways)
03048     {
03049         ScrollBy = (INT32) (NewLeftmost - LeftmostColour); // Calculate REAL ScrollBy
03050 
03051         LeftmostColour = NewLeftmost;               // Update the scroll position
03052         if (ScrollHeight != 0)                      // If there is a scroll bar...
03053             ForceRedrawOfRect(ScrollBarRect);       // ...force redraw it
03054 
03055 PORTNOTE("other","Removed ScrollWindowEx usage")
03056 #if !defined(EXCLUDE_FROM_XARALX)
03057         if (abs(ScrollBy) < DisplayedColours)
03058         {
03059             // Scroll the StripRect using ScrollWindowEx (this blits the existing
03060             // window contents across, then invalidates the bit that needs redrawing)
03061             wxRect RectToScroll(StripRect);
03062             if (ScrollBy < 0)
03063                 RectToScroll.width += -ScrollBy * CellSize;
03064             else
03065             {
03066                 RectToScroll.x -= ScrollBy * CellSize;
03067                 RectToScroll.width += ScrollBy * CellSize;
03068             }
03069 
03070             ScrollWindow(-ScrollBy * CellSize, 0);
03071             Update();
03072         }
03073         else
03074 #endif
03075             ForceRedrawOfRect(StripRect);   // Force redraw the entire colour strip
03076     }
03077 
03078     RestoreCurrentDoc(OldCurrentDoc);
03079 }

void CColourBar::SelectionHasChanged void   )  [static, protected]
 

This will cause the colourbar to redraw any necessary portions of the colour strip and indicators to indicate the colour of the selection (or the default line/fill colours if there is no selection).

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/7/94
Notes: This is just a veneer. It is a static function which finds the current ColourBar (if any) and passes the call onto its SelectionHasChangedInternal function The ColourBar works exclusively on the SELECTED Doc. Change with care

Definition at line 3771 of file ccolbar.cpp.

03772 {
03773     if (TheColourBar != NULL)
03774         TheColourBar->SelectionHasChangedInternal();
03775 }

void CColourBar::SelectionHasChangedInternal void   )  [protected]
 

This will cause the colourbar to redraw any necessary portions of the colour strip and indicators to indicate the colour of the selection (or the default line/fill colours if there is no selection).

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/7/94
Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care

Definition at line 3515 of file ccolbar.cpp.

03516 {
03517     static Document *LastDocument = NULL;
03518     static INT32 LastClickedLineCell = CELLINDEX_NOCELL;
03519     static INT32 LastClickedFillCell = CELLINDEX_NOCELL;
03520     static INT32 LastClickedEndCell  = CELLINDEX_NOCELL;
03521 
03522     // If the user has not asked for document colours in the colour line then 
03523     // no need to do any of the checks below
03524     if (!ColourSGallery::ShowDocumentColours)
03525     {
03526         ForceRedrawOfRect(TheColourBar->IndicatorRect);         // And redraw the colour indicators
03527         return;
03528     }
03529 
03530     // If swapped documents then forget the last clicked cells
03531     if (LastDocument != Document::GetSelected())
03532     {
03533         LastClickedFillCell = LastClickedEndCell = LastClickedLineCell = CELLINDEX_NOCELL;
03534         LastDocument = Document::GetSelected();
03535     }
03536 
03537     DocColour *LineColour;
03538     DocColour *FillColour;
03539     DocColour *EndColour;
03540 
03541     BOOL DiamondShape = ColourManager::GetCurrentLineAndFillColours(&LineColour,
03542                                                                 &FillColour, &EndColour);
03543     INT32 MinorScrollTo = CELLINDEX_NOCELL;
03544     INT32 MajorScrollTo = CELLINDEX_NOCELL;
03545 
03546     // Determine if we're changing from flatfill display to gradfill or vice-versa. In this case,
03547     // the Fill diamond will change between arow and diamond - if the fill happens to be the same
03548     // colour, this will leave the screen state incorrect, so we must forceredraw it.
03549     BOOL MustRedrawFill = FALSE;
03550     if (EndColour != NULL)
03551     {
03552         if (LastEndCell == CELLINDEX_NOCELL)                    // Change from flat to grad
03553             MustRedrawFill = TRUE;
03554     }
03555     else
03556     {
03557         if (LastEndCell != CELLINDEX_NOCELL)                    // Change from grad to flat
03558             MustRedrawFill = TRUE;
03559     }
03560 
03561     // Now redraw (only as necessary) the line, fill and end-fill cells, and determine
03562     // the major and minor cell positions to autoscroll to.
03563     if (LineColour == NULL)                                     // Is there a line colour?
03564     {
03565         ForceRedrawOfCell((INT32) LastLineCell);                    // No - Remove the old indicator diamond
03566         LastLineCell = CELLINDEX_NOCELL;                        // ... and remember it is not displayed
03567     }
03568     else
03569     {
03570         INT32 CellIndex = CalculateColourCellIndex(LineColour);
03571 
03572         if (CellIndex != LastClickedLineCell)                   // Set Minor scroll position, and
03573             MinorScrollTo = LastClickedLineCell = CellIndex;    // remember where we last put diamond
03574 
03575         if (MinorScrollTo == CELLINDEX_NOCOLOURCELL)            // NoColour doesn't cause scrolling
03576             MinorScrollTo = CELLINDEX_NOCELL;
03577 
03578         // If selected cell changed (or diamond shape has changed)...
03579         if (CellIndex != LastLineCell || LastDiamondShape != DiamondShape)
03580         {
03581             ForceRedrawOfCell((INT32)LastLineCell);             // Redraw old colour cell
03582             ForceRedrawOfCell(CellIndex);                       // Redraw new colour cell
03583             LastLineCell = CELLINDEX_NOCELL;
03584             // (LastLineCell will be automagically updated by the PaintDiamond code)
03585         }
03586     }
03587 
03588     if (FillColour == NULL)                                     // is there a Fill colour?
03589     {
03590         ForceRedrawOfCell((INT32)LastFillCell);                 // No- Remove the old indicator diamond
03591         LastFillCell = CELLINDEX_NOCELL;                        // ... and remember it is not displayed
03592     }
03593     else
03594     {
03595         INT32 CellIndex = CalculateColourCellIndex(FillColour);
03596 
03597         if (CellIndex != LastClickedFillCell)                   // Set Major scroll position, and
03598             MajorScrollTo = LastClickedFillCell = CellIndex;    // remember where we last put diamond
03599 
03600         if (MajorScrollTo == CELLINDEX_NOCOLOURCELL)            // NoColour doesn't cause scrolling
03601             MajorScrollTo = CELLINDEX_NOCELL;
03602 
03603         // If selected cell changed (or diamond shape has changed)...
03604         if (CellIndex != LastFillCell || LastDiamondShape != DiamondShape || MustRedrawFill)
03605         {
03606             ForceRedrawOfCell((INT32)LastFillCell);             // Redraw old colour cell
03607             ForceRedrawOfCell(CellIndex);                       // Redraw new colour cell
03608             LastFillCell = CELLINDEX_NOCELL;
03609             // (LastFillCell will be automagically updated by the PaintDiamond code)
03610         }
03611     }
03612 
03613     if (EndColour == NULL)
03614     {
03615         ForceRedrawOfCell((INT32)LastEndCell);                  // No- Remove the old indicator diamond
03616         LastEndCell = CELLINDEX_NOCELL;                         // ... and remember it is not displayed
03617     }
03618     else
03619     {
03620         INT32 OtherMajor = CELLINDEX_NOCELL;
03621         INT32 CellIndex = CalculateColourCellIndex(EndColour);
03622 
03623         if (CellIndex != LastClickedEndCell)                    // Set alternat major scroll position, and
03624             OtherMajor = LastClickedEndCell = CellIndex;        // remember where we last put diamond
03625 
03626         if (OtherMajor == CELLINDEX_NOCOLOURCELL)               // NoColour doesn't cause scrolling
03627             OtherMajor = CELLINDEX_NOCELL;
03628 
03629         // If selected cell changed (or diamond shape has changed)...
03630         if (CellIndex != LastEndCell || LastDiamondShape != DiamondShape)
03631         {
03632             ForceRedrawOfCell((INT32)LastEndCell);              // Redraw old colour cell
03633             ForceRedrawOfCell(CellIndex);                       // Redraw new colour cell
03634             LastEndCell = CELLINDEX_NOCELL;
03635             // (LastEndCell will be automagically updated by the PaintDiamond code)
03636         }
03637 
03638         // And now decide which of the 3 colours are most important, and decide on major and minor
03639         // scroll-to positions. By default this is already set up to be Fill,Line, but if the end-grad
03640         // colour is not no-colour, it may override the line colour
03641         if (OtherMajor != CELLINDEX_NOCELL)
03642         {
03643             if (MajorScrollTo == CELLINDEX_NOCELL)
03644                 MajorScrollTo = OtherMajor;         // There's only one non-transparent fill, so use it
03645             else
03646             {
03647                 if (MinorScrollTo == CELLINDEX_NOCELL)
03648                     MinorScrollTo = OtherMajor;     // There's no line colour, so just make it the minor
03649                 else
03650                 {
03651                     // We have 3 colours - we will remove the middle one, to maximise the chance of
03652                     // them all being shown (if left/right are visible, the middle must also be visible)
03653 
03654                     if (MinorScrollTo < MajorScrollTo)
03655                     {
03656                         if (OtherMajor < MinorScrollTo)
03657                             MinorScrollTo = OtherMajor;
03658                         else if (OtherMajor > MajorScrollTo)
03659                             MajorScrollTo = OtherMajor;
03660                     }
03661                     else
03662                     {
03663                         if (OtherMajor > MinorScrollTo)
03664                             MinorScrollTo = OtherMajor;
03665                         else if (OtherMajor < MajorScrollTo)
03666                             MajorScrollTo = OtherMajor;
03667                     }
03668                 }
03669             }
03670         }
03671     }
03672 
03673     
03674     // OK, let's autoscroll - Preferably both Major and Minor can be shown, but if not, it is better
03675     // to show Major (fill) than Minor (line).
03676 
03677     if (MajorScrollTo == CELLINDEX_NOCELL)  // Only one diamond, so make it the major one
03678     {
03679         MajorScrollTo = MinorScrollTo;
03680         MinorScrollTo = CELLINDEX_NOCELL;
03681     }
03682 
03683     if (MajorScrollTo != CELLINDEX_NOCELL)
03684     {
03685         // We have 1 or 2 cells that we'd really like visible in the bar if possible.
03686         // The MajorScrollTo is the most important one, so we ensure it is visible, and
03687         // then shift slightly from that scroll pos, if possible, to get the minor in too
03688         // It's also important to minimise scrolling (i.e if the targets can all be seen
03689         // already then we will not move them)
03690 
03691         // Calculate how many colour cells are visible
03692         INT32 NumDisplayedColours = StripRect.width / CellSize;
03693 
03694         BOOL TwoDiamonds = TRUE;            // There are either 1 or 2 diamonds to try to show
03695 
03696         // Convert the cell index into a desired scroll offset from current pos (scroll-by)
03697         MajorScrollTo -= LeftmostColour;
03698         if (MinorScrollTo == CELLINDEX_NOCELL)
03699         {
03700             MinorScrollTo = MajorScrollTo;  // Ensure we scroll to Major one only
03701             TwoDiamonds = FALSE;            // There is only one diamond to try to show
03702         }
03703         else
03704             MinorScrollTo -= LeftmostColour;
03705 
03706         // If one of the 2 diamonds is not already visible, we need to scroll
03707         if (MajorScrollTo < 0 || MajorScrollTo >= NumDisplayedColours ||
03708             MinorScrollTo < 0 || MinorScrollTo >= NumDisplayedColours)
03709         {
03710             INT32 ScrollBy = 0;
03711 
03712             // One or both diamonds are not visible, so we'll have to try scrolling...
03713             if (TwoDiamonds && abs(MajorScrollTo - MinorScrollTo) <= NumDisplayedColours)
03714             {
03715                 if (abs(MajorScrollTo - MinorScrollTo) >= NumDisplayedColours - 1)
03716                 {
03717                     // The diamonds fit exactly at the left/right ends of the bar. We must
03718                     // special case this (rounding errors in the average may get the posn
03719                     // one cell out in this case) - scroll the leftmost diamond to the
03720                     // left end of the bar.
03721 
03722                     ScrollBy = min(MinorScrollTo, MajorScrollTo);
03723                 }
03724                 else
03725                 {
03726                     // Both diamonds should fit on if we just scroll to the average position
03727                     ScrollBy = (MajorScrollTo + MinorScrollTo) / 2;
03728                     ScrollBy -= NumDisplayedColours / 2;        // Turn into center-relative scroll
03729                 }
03730             }
03731             else
03732             {
03733                 // There is only one diamond, or we can only fit one of the diamonds
03734                 // on, so scroll to the major one
03735                 ScrollBy = MajorScrollTo - NumDisplayedColours / 2; // Turn into center-relative scroll
03736             }
03737 
03738 #ifndef EXCLUDE_GALS
03739             if (
03740                 ColourSGallery::AutoScrollSelection && 
03741                 ScrollBy != 0)
03742             {
03743                 ScrollTheStrip(ScrollBy);
03744             }
03745 #endif
03746         }
03747     }
03748 
03749     ForceRedrawOfRect(TheColourBar->IndicatorRect);         // And redraw the colour indicators
03750 }

void CColourBar::SetATimer BOOL  Delay  )  [protected]
 

Sets a timer to cause a timer message to be sent to us after the keyboard auto-repeat delay. If we are already waiting for a timer event, the current timer will be replaced by the new one.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/6/94
Parameters:
Delay - TRUE if this is initial keyboard-delay-before-autorepeat, [INPUTS] FALSE for auto-repeat
Notes: Delay is currently ignored, because Charles didn't like it (and I agree with him).

Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care

Definition at line 3831 of file ccolbar.cpp.

03832 {
03833     if (DragInfo.TimerOn)
03834         m_DragTimer.Stop();
03835 
03836     UINT32 CallbackTime = 1000;
03837     UINT32 RepsPerSec = 5;
03838 
03839 #if FALSE
03840     if (Delay)
03841     {
03842         ::SystemParametersInfo(SPI_GETKEYBOARDDELAY, 0, &RepsPerSec, 0);
03843 
03844         RepsPerSec = 4 - RepsPerSec;
03845     }
03846     else
03847     {
03848         ::SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &RepsPerSec, 0);
03849 
03850         RepsPerSec++;
03851     }
03852 #endif
03853 
03854     if (RepsPerSec > 1)
03855         CallbackTime = (UINT32) 1000 / RepsPerSec;
03856 
03857     m_DragTimer.Start(CallbackTime);
03858     DragInfo.TimerOn = TRUE;
03859 }

void CColourBar::SetDisplayMode INT32  NewDisplayMode = -1  )  [static]
 

Sets the Colour Bar display mode to the new value. Current legal mode values are 0..3 (small, med, med+scroll, large) Illegal values will cause it to resort to the default mode, medium+scroll (2) The default value of -1 is used to mean 'use the preference setting'. This allows the prefs dialogue to cause the ColourBar to sit up and take notice of changed preference settings. The preference setting ColourBarMode will be set to the new value.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/10/94
Parameters:
NewDisplayMode - The mode (0..3) or -1 to re-read the preference value [INPUTS]
Notes: This static function may be called at any time. If a colour bar is not open when the call is made, the new setting will be used for the next colour bar created.

Definition at line 1102 of file ccolbar.cpp.

01103 {
01104     if (NewDisplayMode == -1)
01105         NewDisplayMode = DefaultSizeIndex;
01106 
01107     if (NewDisplayMode < 0 || NewDisplayMode >= MAXDEFAULTSIZES)  
01108         NewDisplayMode = 2;
01109 
01110     DefaultSizeIndex = NewDisplayMode;      // Remember this as a preference setting
01111 
01112     if (TheColourBar != NULL)               // If there's a bar, set it to the new size
01113     {
01114         TheColourBar->SetSizes(ColBarDefaultSize[NewDisplayMode].Cell,
01115                                 ColBarDefaultSize[NewDisplayMode].Scrollbar);
01116         TheColourBar->Refresh();            // Force a redraw of the bar to ensure it's up to date
01117     }
01118 }

void CColourBar::SetSizes INT32  NewCellSize,
INT32  NewScrollbarSize
 

Sets the base sizes of the colour strip and colour scroll bar in the colour bar window. Other features of the bar are automatically resized to fit the new sizing. The bar will be redrawn. If the combined height of the bar elements has now changed, the bar will be resized (by calling the parent's RecalcLayout method).

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/6/94
Parameters:
NewCellSize - The new size in pixels of the square colour cells [INPUTS] This should be an even number (it is truncated if necessary)
NewScrollbarSize - The new height of the scroll bar in pixels

Parameters:
- [OUTPUTS]
Returns:
-
Notes: Setting NewScrollBarSize == 0 enters a special mode where the scroll sausage is not drawn, and the scroll arrows sit at either end of the colour strip. In this size, it is recommended that CellSize == ButtonWidth (i.e. about 10 pixels), to make the buttons square and therefore not entirely disgusting looking

The ColourBar works exclusively on the SELECTED Doc. Change with care

Definition at line 1049 of file ccolbar.cpp.

01050 {
01051     ENSURE (NewCellSize >= 4 && NewCellSize <= 64,
01052         "Silly CellSize passed to CColourBar::SetSizes()");
01053 
01054     ENSURE (NewScrollbarSize == 0 ||
01055             (NewScrollbarSize >= 3 && NewScrollbarSize <= 24),
01056         "Silly ScrollbarSize passed to CColourBar::SetSizes()");
01057 
01058     NewCellSize &= ~1;      // Force Cellsize to be an even value
01059 
01060 //  BOOL ResizeFrame = (NewCellSize + NewScrollbarSize != CellSize + ScrollHeight);
01061 
01062     CellSize = NewCellSize;
01063     ScrollHeight = NewScrollbarSize;
01064 
01065     BarHeight = CellSize + ScrollHeight + (2 * CY_BORDER) +
01066                     m_cyTopBorder + m_cyBottomBorder + 1;
01067 
01068 //  if (ResizeFrame)
01069     {
01070         SetMinSize(wxSize(8, BarHeight));
01071 
01072         InvalidateBestSize();
01073         GetMainFrame()->UpdateFrameManager();
01074     }
01075 }

void CColourBar::Show BOOL  ShowOrHide = FALSE  )  [static]
 

Tells the colour bar to show or hide itself. The bar will remain visible/hidden until the next call to this method. If no colour bar currently exists, the desired state will be remembered and used on creation of any new bar.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/10/94
Parameters:
HideOrShow - TRUE to Show the window (the default) [INPUTS] FALSE to hide the window
Scope: public

Definition at line 4163 of file ccolbar.cpp.

04164 {
04165     BarIsVisible = ShowOrHide;                  // Remember our current state
04166 
04167     if (TheColourBar != NULL)                   // If a colour bar exists...
04168     {
04169         if (BarIsVisible)
04170             TheColourBar->Show(true);           // Show or hide the window
04171         else
04172             TheColourBar->Show(false);
04173 
04174         GetMainFrame()->UpdateFrameManager();   // And ensure it places itself usefully!
04175     }
04176 }

INT32 CColourBar::WhereIsMouse wxPoint  MousePos,
wxRect *  TheRectItIsIn = NULL,
BOOL *  ToLeft = NULL
[protected]
 

Checks which part of the ColourBar the given point lies over (if any) and returns a value indicating where it is.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/6/94
Parameters:
MousePos - The point you wish to check [INPUTS]
TheRectItIsIn - if non-NULL, this rect is filled in with a copy of [OUTPUTS] the rectangle in which the mouse pointer lies. This is indeterminate in the case of a CLICKED_NOTHING return value.
ToLeft - if non-NULL, and if the mouse was over a colour cell, this boolean is filled in TRUE if the pointer is over the left side of the cell, or FALSE if over the right. Used for drag'n'drop to determine which side of a colour to insert a dropped colour into.

Returns:
A positive (0..MaxColours) value indicates the given position lies over a colour cell of that index. A negative value indicates one of the special 'controls' in the window (scroll bar, colour indicators etc) - see the constants CLICKED_XXXX defined at the top of ccolbar.cpp
Notes: The ColourBar works exclusively on the SELECTED Doc. Change with care

Definition at line 2879 of file ccolbar.cpp.

02880 {
02881     if (ToLeft != NULL)     // Sensible default output
02882         *ToLeft = TRUE;
02883 
02884     if (StripRect.Inside(MousePos))     // Check ColourStrip - MUST be checked first!
02885     {
02886         if (TheRectItIsIn != NULL)
02887             *TheRectItIsIn = StripRect;
02888 
02889         // If necessary, determine if the pointer is in the left or right half of the colour cell
02890         if (ToLeft != NULL)
02891         {
02892             if ( (MousePos.x - StripRect.x) % CellSize >= CellSize / 2)
02893             {
02894                 // The pointer is in the right hand side of the cell, so return ToLeft=FALSE
02895                 *ToLeft = FALSE;
02896             }
02897         }
02898 
02899         return((INT32) (((MousePos.x - StripRect.x) / CellSize) + LeftmostColour));
02900     }
02901 
02902     if (IndicatorRect.Inside(MousePos)) // Check Indicator patch
02903     {
02904         if (TheRectItIsIn != NULL)
02905             *TheRectItIsIn = IndicatorRect;
02906         return(CLICKED_INDICATORS);
02907     }
02908 
02909     if (EditButtonRect.Inside(MousePos))
02910     {
02911         if (TheRectItIsIn != NULL)
02912             *TheRectItIsIn = EditButtonRect;
02913         return(CLICKED_EDITBUTTON);
02914     }
02915 
02916 #if FALSE
02917 /*
02918     if (NewButtonRect.Inside(MousePos))
02919     {
02920         if (TheRectItIsIn != NULL)
02921             *TheRectItIsIn = NewButtonRect;
02922         return(CLICKED_NEWBUTTON);
02923     }
02924 */
02925 #endif
02926 
02927     wxRect TheRect;
02928 
02929     if (!HasNoScrollBar(-1, -1))            // Check Scrollbar rectangle (if any)
02930     {
02931         if (ScrollHeight != 0 && ScrollBarRect.Inside(MousePos) &&
02932             CalculateSausageRect(&TheRect))
02933         {
02934             if (TheRectItIsIn != NULL)
02935                 *TheRectItIsIn = TheRect;
02936 
02937             if (MousePos.x < TheRect.x) // Left of the sausage
02938             {
02939                 if (TheRectItIsIn != NULL)
02940                 {
02941                     TheRectItIsIn->x = ScrollBarRect.x;
02942                     TheRectItIsIn->width = (TheRect.x - 1 - TheRectItIsIn->x);
02943                 }
02944 
02945                 return(CLICKED_SCROLLBARLEFT);
02946             }
02947 
02948             if (MousePos.x > (TheRect.x + TheRect.width))   // Right of the sausage
02949             {
02950                 if (TheRectItIsIn != NULL)
02951                 {
02952                     TheRectItIsIn->x = TheRect.x + TheRect.width + 1;
02953                     TheRectItIsIn->width = ScrollBarRect.x + ScrollBarRect.x - TheRectItIsIn->x;
02954                 }
02955                 return(CLICKED_SCROLLBARRIGHT);
02956             }
02957 
02958             return(CLICKED_SCROLLBAR);      // Middle of the sausage
02959         }
02960 
02961         TheRect = ScrollBarRect;            // Check left scroll button
02962         TheRect.x -= ButtonWidth;
02963         TheRect.width = ButtonWidth;
02964         if (TheRect.Inside(MousePos))
02965         {
02966             if (TheRectItIsIn != NULL)
02967                 *TheRectItIsIn = TheRect;
02968             return(CLICKED_LEFTSCROLL);
02969         }
02970 
02971         TheRect = ScrollBarRect;            // Check right scroll button
02972         TheRect.x += TheRect.width;
02973         TheRect.width = ButtonWidth;
02974         if (TheRect.Inside(MousePos))
02975         {
02976             if (TheRectItIsIn != NULL)
02977                 *TheRectItIsIn = TheRect;
02978             return(CLICKED_RIGHTSCROLL);
02979         }
02980     }
02981 
02982     CalculateNoColourCellRect(&TheRect);    // Check NoColour cell
02983     if (TheRect.Inside(MousePos))
02984     {
02985         if (TheRectItIsIn != NULL)
02986             *TheRectItIsIn = TheRect;
02987         return(CLICKED_NOCOLOURCELL);
02988     }
02989 
02990     return(CLICKED_NOTHING);                // Not over anything important
02991 }


Friends And Related Function Documentation

friend class ColourBarMsgHandler [friend]
 

Definition at line 286 of file ccolbar.h.

friend class ColourDragInformation [friend]
 

Definition at line 287 of file ccolbar.h.

friend class ColourLineDragTarget [friend]
 

Definition at line 289 of file ccolbar.h.

friend class EditButtonDragTarget [friend]
 

Definition at line 288 of file ccolbar.h.


Member Data Documentation

BOOL CColourBar::BarIsVisible = TRUE [static, protected]
 

Definition at line 333 of file ccolbar.h.

CBDragInfo CColourBar::DragInfo [protected]
 

Definition at line 431 of file ccolbar.h.

wxRect CColourBar::EditButtonRect [protected]
 

Definition at line 358 of file ccolbar.h.

GBrush CColourBar::GDrawBrush [protected]
 

Definition at line 445 of file ccolbar.h.

INT32 CColourBar::IndentedButton [protected]
 

Definition at line 348 of file ccolbar.h.

wxRect CColourBar::IndicatorRect [protected]
 

Definition at line 356 of file ccolbar.h.

BOOL CColourBar::LastDiamondShape [protected]
 

Definition at line 346 of file ccolbar.h.

INT32 CColourBar::LastEndCell [protected]
 

Definition at line 345 of file ccolbar.h.

INT32 CColourBar::LastFillCell [protected]
 

Definition at line 344 of file ccolbar.h.

INT32 CColourBar::LastLineCell [protected]
 

Definition at line 343 of file ccolbar.h.

UINT32 CColourBar::LeftmostColour [protected]
 

Definition at line 340 of file ccolbar.h.

INT32 CColourBar::m_cxLeftBorder [protected]
 

Definition at line 335 of file ccolbar.h.

INT32 CColourBar::m_cxRightBorder [protected]
 

Definition at line 337 of file ccolbar.h.

INT32 CColourBar::m_cyBottomBorder [protected]
 

Definition at line 338 of file ccolbar.h.

INT32 CColourBar::m_cyTopBorder [protected]
 

Definition at line 336 of file ccolbar.h.

wxTimer CColourBar::m_DragTimer [protected]
 

Definition at line 363 of file ccolbar.h.

ColourSGallery* CColourBar::m_pColourGallery [protected]
 

Definition at line 365 of file ccolbar.h.

ColourList* CColourBar::m_pCurrentColourList [protected]
 

Definition at line 350 of file ccolbar.h.

ColourBarMsgHandler* CColourBar::MsgHandler [protected]
 

Definition at line 352 of file ccolbar.h.

wxRect CColourBar::NewButtonRect [protected]
 

Definition at line 359 of file ccolbar.h.

INT32 CColourBar::OldBarHeight [protected]
 

Definition at line 361 of file ccolbar.h.

Cursor* CColourBar::PushCursor [protected]
 

Definition at line 441 of file ccolbar.h.

wxRect CColourBar::ScrollBarRect [protected]
 

Definition at line 357 of file ccolbar.h.

wxRect CColourBar::StripRect [protected]
 

Definition at line 355 of file ccolbar.h.

CColourBar * CColourBar::TheColourBar = NULL [static, protected]
 

Definition at line 332 of file ccolbar.h.

UINT32 CColourBar::TotalNumColours [protected]
 

Definition at line 341 of file ccolbar.h.

wxRect CColourBar::WindowRect [protected]
 

Definition at line 354 of file ccolbar.h.


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