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

FOUNDATION_API SECColorWell()

Constructs a color well object.

FOUNDATION_API 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

FOUNDATION_API COLORREF GetColor() const

Returns the currently selected color.

FOUNDATION_API void SetColor(COLORREF color)

Gets the currently selected color.

FOUNDATION_API BOOL GetMouseTracking() const

Returns the mouse tracking mode.

FOUNDATION_API void SetMouseTracking(BOOL bTracking)

Sets the mouse tracking mode.

FOUNDATION_API BOOL GetPaletteRealization() const

Returns the palette realization mode.

FOUNDATION_API void SetPaletteRealization(BOOL bRealize)

Sets the palette realization mode.

FOUNDATION_API 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.

FOUNDATION_API DWORD GetColorDialogFlags() const

Returns the flags for the CColorDialog. Default = CC_RGBINIT|CC_FULLOPEN.

FOUNDATION_API virtual void SetCustomColors(COLORREF* pColors)

Sets the array of 16 colors for the custom color boxes in CColorDialog

FOUNDATION_API COLORREF* GetCustomColors() const

Retrieves the array of 16 colors for the custom color boxes in CColorDialog. Default=NULL

FOUNDATION_API virtual void Reset()

Resets the color well object.

Overridable

FOUNDATION_API virtual void DrawCell(CDC& memDC, CDC& paintDC, const CRect& internalRect, int nCol, int nRow)

Draws an unselected color cell.

FOUNDATION_API virtual void DrawSelectedCell(CDC& memDC, CDC& paintDC, const CRect& internalRect, int nCol, int nRow)

Draws a selected color cell.

FOUNDATION_API virtual void NotifyChange()

Notifies the parent window of a change in color.

FOUNDATION_API virtual void HandleSelection(int nCol, int nRow, SelTypes selType)

Called when the user selects a new color.

FOUNDATION_API virtual void CreatePalette()

Creates a color palette.

FOUNDATION_API virtual void SetGridSize()

Sets the number of columns and number of rows in the grid.

FOUNDATION_API virtual void InitAdditionalColors(LPPALETTEENTRY pPalEntry, int nCols, int nSystemCols)

Called to initialise colors other than the 20 system colors.

FOUNDATION_API virtual UINT GetClassStyle() const

Returns the class style used to register the color well window class.

FOUNDATION_API virtual BOOL HasFocusRectangle() const

Returns whether the color well has a focus rectangle.

Overrides

FOUNDATION_API afx_msg void OnPaint()

Called when Windows or an application makes a request to repaint.

FOUNDATION_API afx_msg void OnSetFocus(CWnd* pOldWnd)

Called after gaining the input focus.

FOUNDATION_API afx_msg void OnKillFocus(CWnd* pNewWnd)

Called immediately before losing the input focus.

FOUNDATION_API afx_msg UINT OnGetDlgCode()

Override to control the particular types of input to process.

FOUNDATION_API afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)

Called when a nonsystem key is pressed.

FOUNDATION_API afx_msg void OnLButtonDown(UINT nFlags, CPoint point)

Called when the user presses the left mouse button.

FOUNDATION_API afx_msg void OnMouseMove(UINT nFlags, CPoint point)

Called when the mouse cursor moves.

FOUNDATION_API afx_msg void OnClickedOther()

Called when the "other" button is clicked (to create CColorDialog).

FOUNDATION_API afx_msg void OnSysColorChange()

Called when a change is made in the system color setting.

FOUNDATION_API afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)

Called when a child control is about to be drawn.

Implementation

FOUNDATION_API void GetCellRect(const CRect& internalRect, CRect& rect, int nCol, int nRow)

Returns the client rectangle of an individual cell.

FOUNDATION_API void GetCellRect(CRect& rect, int nCol, int nRow)

Returns the client rectangle of an individual cell.

FOUNDATION_API void Paint(CDC& memDC, CDC& paintDC)

Draws the well.

FOUNDATION_API void DrawFocusRect()

Draws the focus rectangle.

FOUNDATION_API void InvalidateCell(int nCol, int nRow)

Invalidates an individual cell.

FOUNDATION_API BOOL HitTest(CPoint point, int& nCol, int& nRow)

Hit tests which cell a specified point is in.

FOUNDATION_API int GetPaletteIndex( int nCol, int nRow ) const

Obtains the palette index associated with an individual cell.

FOUNDATION_API COLORREF GetPaletteColor( int nCol, int nRow ) const

Obtains the color associated with an individual cell.

FOUNDATION_API void ChangeSelection(int nCol, int nRow)

Changes the selection to a given cell.

FOUNDATION_API void GetInternalRect(CRect& rect)

Calculates the internal client rectangle (less 3d borders).

FOUNDATION_API 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.

int m_nPaletteIndexOther

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