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