SECColorWell Class
class SECColorWell: public CWnd
The SECColorWell class implements a color selection window. This window displays a grid of the 20 system colors, and optionally a button labeled 'Other'. If the 'Other' button is clicked, a common color selection dialog is displayed allowing selection of additional colors.Defined in: SECWELL.h
Example
You can create a color well window with the following method call:m_well.Create(WS_VISIBLE|WS_TABSTOP|CWS_RAISED_BORDER,
0, 0, this, IDC_WELL1);
Comments
The currently selected color can optionally track the mouse (enabled with SetMouseTracking). This means that if the mouse passes over a color cell, then that cell becomes the selected cell.All displayed colors can optionally be realized in a palette before drawing. This is enabled with SetPaletteRealization.
Any change to the selected color causes a CWN_COLOR_CHANGE message to be sent to the parent of the color well window.
DDX_Color can be used for DDX support with the color well classes.
See the COLOR sample in the \\OT\\SAMPLES\\STANDARD\\CONTROLS\\COLRWELL directory for a demonstration of this class.
Class Members
Creation/Initialization
enum SelTypes
Selection types
Constructs a color well object.
virtual BOOL Create(DWORD dwStyle, int x, int y, CWnd* pParentWnd, UINT nID, BOOL bDialogBaseUnits = FALSE, BOOL bOtherButton = TRUE, CCreateContext* pContext = NULL)
Creates a color well window.
Attributes
COLORREF GetColor() const
Returns the currently selected color.
void SetColor(COLORREF color)
Gets the currently selected color.
BOOL GetMouseTracking() const
Returns the mouse tracking mode.
void SetMouseTracking(BOOL bTracking)
Sets the mouse tracking mode.
BOOL GetPaletteRealization() const
Returns the palette realization mode.
void SetPaletteRealization(BOOL bRealize)
Sets the palette realization mode.
virtual void SetColorDialogFlags(DWORD v)
Sets the flags for customizing the CColorDialog that is display in response to a click on the "Other" button. Default = CC_RGBINIT|CC_FULLOPEN.
DWORD GetColorDialogFlags() const
Returns the flags for the CColorDialog. Default = CC_RGBINIT|CC_FULLOPEN.
virtual void SetCustomColors(COLORREF* pColors)
Sets the array of 16 colors for the custom color boxes in CColorDialog
COLORREF* GetCustomColors() const
Retrieves the array of 16 colors for the custom color boxes in CColorDialog. Default=NULL
virtual void Reset()
Resets the color well object.
Overridable
virtual void DrawCell(CDC& memDC, CDC& paintDC, const CRect& internalRect, int nCol, int nRow)
Draws an unselected color cell.
virtual void DrawSelectedCell(CDC& memDC, CDC& paintDC, const CRect& internalRect, int nCol, int nRow)
Draws a selected color cell.
virtual void NotifyChange()
Notifies the parent window of a change in color.
virtual void HandleSelection(int nCol, int nRow, SelTypes selType)
Called when the user selects a new color.
virtual void CreatePalette()
Creates a color palette.
virtual void SetGridSize()
Sets the number of columns and number of rows in the grid.
virtual void InitAdditionalColors(LPPALETTEENTRY pPalEntry, int nCols, int nSystemCols)
Called to initialise colors other than the 20 system colors.
virtual UINT GetClassStyle() const
Returns the class style used to register the color well window class.
virtual BOOL HasFocusRectangle() const
Returns whether the color well has a focus rectangle.
Overrides
afx_msg void OnPaint()
Called when Windows or an application makes a request to repaint.
afx_msg void OnSetFocus(CWnd* pOldWnd)
Called after gaining the input focus.
afx_msg void OnKillFocus(CWnd* pNewWnd)
Called immediately before losing the input focus.
afx_msg UINT OnGetDlgCode()
Override to control the particular types of input to process.
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
Called when a nonsystem key is pressed.
afx_msg void OnLButtonDown(UINT nFlags, CPoint point)
Called when the user presses the left mouse button.
afx_msg void OnMouseMove(UINT nFlags, CPoint point)
Called when the mouse cursor moves.
afx_msg void OnClickedOther()
Called when the "other" button is clicked (to create CColorDialog).
afx_msg void OnSysColorChange()
Called when a change is made in the system color setting.
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
Called when a child control is about to be drawn.
Implementation
void GetCellRect(const CRect& internalRect, CRect& rect, int nCol, int nRow)
Returns the client rectangle of an individual cell.
void GetCellRect(CRect& rect, int nCol, int nRow)
Returns the client rectangle of an individual cell.
void Paint(CDC& memDC, CDC& paintDC)
Draws the well.
void DrawFocusRect()
Draws the focus rectangle.
void InvalidateCell(int nCol, int nRow)
Invalidates an individual cell.
BOOL HitTest(CPoint point, int& nCol, int& nRow)
Hit tests which cell a specified point is in.
int GetPaletteIndex( int nCol, int nRow ) const
Obtains the palette index associated with an individual cell.
COLORREF GetPaletteColor( int nCol, int nRow ) const
Obtains the color associated with an individual cell.
void ChangeSelection(int nCol, int nRow)
Changes the selection to a given cell.
void GetInternalRect(CRect& rect)
Calculates the internal client rectangle (less 3d borders).
virtual CRect CalculateSize(CWnd* pParentWnd, int nCol, int nRow, BOOL bDialogBaseUnits)
Calculates the required size of the client rectangle.
Protected data members
CPalette m_palette
The palette. Holds the colors for cells.
int m_nRows
Number of cell rows.
int m_nCols
Number of cell columns.
int m_nIndexOtherCol
Column number of "other" cell.
int m_nIndexOtherRow
Row number of "other" cell.
int m_nCellHeight
Height of cell.
int m_nCellWidth
Width of cell.
int m_nIndentWidth
Width of border.
int m_nIndentHeight
Height of border.
int m_nButtonHeight
Height of other button.
int m_nCurRow
The row of the currently selected cell.
int m_nCurCol
The column of the currently selected cell.
Index of other cell in color palette.
BOOL m_bHasFocus
True if this currently have focus.
BOOL m_bMouseTracking
Indicates whether mouse tracking is enabled.
BOOL m_bHasOther
Indicates whether we have an "other" button.
BOOL m_bOtherSet
Indicates whether the color for "other" been set.
BOOL m_bRealizePalette
Indicates whether we realize our palette.
DWORD m_dwColorDialogFlags
Flags for customizing the CColorDialog displayed in response to clicking the Other button
COLORREF* m_pCustomColors
Pointer to an array of 16 colors for the custom color boxes in CColorDialog
CBrush m_brushBtnFace
Brush for painting button face
SECOtherButton* m_pOtherButton
Object for other button