Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Professional User Interface Suite

, 13 Jan 2004
MFC extension library enabling software to be provided with a professional UI
prof-uis-223-freeware_src.zip
Prof-UIS
Bin_600
Bin_700
Bin_710
Include
profuisdll
idd_ext_color_dlg.ico
profuisdll.def
profuisdll_600.dsp
profuisdll_600.dsw
res
black_arrow_bottom.cur
black_arrow_left.cur
black_arrow_right.cur
black_arrow_top.cur
cmd00001.cur
cmd00002.cur
cmd00003.cur
cur_arrow_invert.cur
cur_black_finger.cur
cur_black_hand.cur
cur_hand_like.cur
cur_pan_all.cur
cur_pan_bottom.cur
cur_pan_bottom_left.cur
cur_pan_bottom_right.cur
cur_pan_horz.cur
cur_pan_left.cur
cur_pan_right.cur
cur_pan_top.cur
cur_pan_top_left.cur
cur_pan_top_right.cur
cur_pan_vert.cur
cur_resize_h1.cur
cur_resize_h2.cur
cur_resize_v1.cur
cur_resize_v2.cur
cur00001.cur
cur00002.cur
cur00003.cur
cur00004.cur
hollow_cross_normal.cur
hollow_cross_small.cur
ico00001.ico
id_view_.bmp
idd_ext_.ico
idd_icon.ico
ied_cp.cur
ied_el.cur
ied_fill.cur
ied_line.cur
ied_pen.cur
ied_rect.cur
ied_tool.cur
suppress.cur
suppress_arrow.cur
toolbar_.bmp
zoom_hollow.cur
zoom_minus.cur
zoom_plus.cur
profuislib
profuislib_600.dsp
profuislib_600.dsw
Samples
AviFrames
AviFrames_600.dsp
res
AviFrames.ico
CINEAPK.AVI
IDR_TOOLBAR_PLAYER.bmp
IDR_TOOLBAR_UISTYLE.bmp
Toolbar.bmp
toolbar2.bmp
xptheme.bin
DRAWCLI
DRAWCLI_600.dsp
L.JPN
RES
res
DRAWCLI.ICO
DRAWDOC.ICO
ico00001.ico
ico00002.ico
ico00003.ico
ico00004.ico
ico00005.ico
ico00006.ico
ico00007.ico
ico00008.ico
icon1.ico
id_objec.ico
id_scppv.ico
idr_abou.ico
PENCIL.CUR
TOOLBAR_1_16bit.bmp
TOOLBAR_1_4bit.bmp
TOOLBAR_2_16bit.bmp
TOOLBAR_2_4bit.bmp
FixedSizePanels
FixedSizePanels_600.dsp
res
bitmap_t.bmp
FixedSizePanels.ico
Toolbar.bmp
toolbar2.bmp
FullScreenState
FullScreenState_600.dsp
res
FullScreenState.ico
idr_mdit.ico
Toolbar.bmp
toolbar1.bmp
toolbar2.bmp
toolbar4.bmp
FunnyBars
FunnyBars_600.dsp
res
FunnyBars.ico
Toolbar.bmp
toolbar_16_16_8.bmp
toolbar_44_40_32.bmp
winXP.manifest
GLViews
GLViews_600.dsp
res
bitmap_i.bmp
bitmap_s.bmp
bitmap_t.bmp
bmp00001.bmp
btpnlane.bmp
CINEAPK.AVI
cur00001.cur
cur00002.cur
cursor_g.cur
earth.bmp
GLViews.ico
moon.bmp
ProfUisCubeSideOrange.bmp
ProfUisCubeSideWhite.bmp
ring.bmp
Toolbar.bmp
toolbar_.bmp
toolbar2.bmp
wndavipl.bmp
wndmirror.bmp
res_html
bodytop.gif
book_close.gif
book_open.gif
MDI
MDI_600.dsp
res
idr_mdit.ico
MDI.ico
Toolbar.bmp
toolbar2.bmp
MDI_InnerOuterBars
MDI_InnerOuterBars_600.dsp
res
bmp00001.bmp
idr_mdit.ico
MDI_InnerOuterBars.ico
Toolbar.bmp
toolbar_.bmp
toolbar2.bmp
MDIDOCVIEW
MDIDOCVIEW_600.dsp
res
MDIDOCVIEW.ico
MDIDOCVIEWDoc.ico
Toolbar.bmp
MthOutput
MthOutput_600.dsp
res
idr_mdit.ico
MthOutput.ico
Toolbar.bmp
toolbar1.bmp
toolbar2.bmp
ProfUIS_Controls
ProfUIS_Controls_600.dsp
res
bitmap1.bmp
bitmap2.bmp
icon1.ico
ProfUIS_Controls.ico
tab_imag.bmp
toolbar1.bmp
ResizableChildSheet
res
idr_chil.ico
ResizableChildSheet.ico
Toolbar.bmp
ResizableChildSheet_600.dsp
ResizablePropertySheet
res
bitmap1.bmp
bitmap2.bmp
ResizablePropertySheet.ico
ResizablePropertySheet_600.dsp
SDI
res
SDI.ico
Toolbar.bmp
toolbar2.bmp
SDI_600.dsp
SDIDOCVIEW
res
SDIDOCVIEW.ico
SDIDOCVIEWDoc.ico
Toolbar.bmp
SDIDOCVIEW_600.dsp
StateInFile
res
StateInFile.ico
Toolbar.bmp
StateInFile_600.dsp
StatusPanes
res
download.avi
StatusPanes.ico
Toolbar.bmp
toolbar2.bmp
StatusPanes_600.dsp
Src
Workspace
ProfUIS_600.dsw
profuis-v2.20_freeware.zip
Include
profuisdll
idd_ext_color_dlg.ico
profuisdll.def
profuisdll.dsp
res
profuislib
profuislib.dsp
Samples
DRAWCLI
MDI
MDIDOCVIEW
MDI_InnerOuterBars
ProfUIS_Controls
ResizablePropertySheet
SDI
SDIDOCVIEW
StateInFile
DRAWCLI.dsp
L.JPN
res
RES
DRAWCLI.ICO
DRAWDOC.ICO
ico00001.ico
ico00002.ico
icon1.ico
id_objec.ico
PENCIL.CUR
TOOLBAR.BMP
MDI.dsp
res
idr_mdit.ico
MDI.ico
Toolbar.bmp
toolbar2.bmp
MDIDOCVIEW.dsp
res
MDIDOCVIEW.ico
MDIDOCVIEWDoc.ico
Toolbar.bmp
MDI_InnerOuterBars.dsp
res
bmp00001.bmp
idr_mdit.ico
MDI_InnerOuterBars.ico
Toolbar.bmp
toolbar2.bmp
toolbar_.bmp
ProfUIS_Controls.dsp
res
bitmap1.bmp
bitmap2.bmp
icon1.ico
ProfUIS_Controls.ico
tab_imag.bmp
toolbar1.bmp
res
ResizablePropertySheet.dsp
ResizablePropertySheet.ico
res
SDI.dsp
SDI.ico
Toolbar.bmp
toolbar2.bmp
res
SDIDOCVIEW.dsp
SDIDOCVIEW.ico
SDIDOCVIEWDoc.ico
Toolbar.bmp
res
StateInFile.dsp
StateInFile.ico
Toolbar.bmp
Src
Workspace
ProfUIS.dsw
ProfUIS.suo
profuis21_bin.zip
Bin
MDI.exe
ProfUIS21.dll
ProfUIS_Controls.exe
SDI.exe
StateInFile.exe
profuis21_src.zip
idd_ext_color_dlg.ico
profuisdll.aps
profuisdll.clw
profuisdll.def
profuisdll.dep
profuisdll.dsp
profuisdll.mak
profuisdll.plg
MDI.APS
MDI.clw
MDI.dep
MDI.dsp
MDI.mak
MDI.plg
idr_mdit.ico
MDI.ico
Toolbar.bmp
toolbar2.bmp
ProfUIS_Controls.aps
ProfUIS_Controls.clw
ProfUIS_Controls.dep
ProfUIS_Controls.dsp
ProfUIS_Controls.mak
ProfUIS_Controls.ico
toolbar1.bmp
SDI.APS
SDI.clw
SDI.dep
SDI.dsp
SDI.mak
SDI.plg
SDI.ico
Toolbar.bmp
toolbar2.bmp
StateInFile.aps
StateInFile.clw
StateInFile.dep
StateInFile.dsp
StateInFile.mak
StateInFile.plg
StateInFile.ico
Toolbar.bmp
ProfUIS.dsw
ProfUIS.ncb
ProfUIS.opt
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
///                                                                    ///
/// Professional User Interface Suite (TM)                             ///
/// Copyright (C) 2001-2002 by Foss Software Inc.                      ///
///                                                                    ///
/// http://www.fossware.com                                            ///
/// mailto:foss@fossware.com                                           ///
///                                                                    ///
///                                                                    ///
/// This software and accompanying documentation is the copyrighted    ///
/// work of Foss Software Inc.                                         ///
///                                                                    ///
/// Use of this software is governed by the following conditions:      ///
///                                                                    ///
///   a) this software is free for any kind of personal and            ///
///      commercial usage;                                             ///
///                                                                    ///
///   a) you may not reproduce, record, publish, publicly exhibit      ///
///      or distribute this source code without author's express       ///
///      prior written consent (foss@fossware.com);                    ///
///                                                                    ///
///   b) this notice should be remained intact in distributed source   ///
///      files;                                                        ///
///                                                                    ///
///   c) this software is subject to all Warranties and Disclaimers    ///
///      as set forth below;                                           ///
///                                                                    ///
/// Warranties and Disclaimers:                                        ///
///                                                                    ///
/// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND     ///
/// INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY,      ///
/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.             ///
/// IN NO EVENT WILL FOSS SOFTWARE INC. BE LIABLE FOR ANY DIRECT,      ///
/// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES, ///
/// INCLUDING DAMAGES FOR LOSS OF PROFITS, LOSS OR INACCURACY OF DATA, ///
/// INCURRED BY ANY PERSON FROM SUCH PERSON'S USAGE OF THIS SOFTWARE   ///
/// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.                ///
///                                                                    ///
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////

#if (!defined __EXTCOLORCTRL_H)
#define __EXTCOLORCTRL_H

// 
// The idea of the HSL colorspace algorithm  belongs to Patrick Prache
// The idea of the hexagon pallette algorithm belongs to Jack Mesic
//

#if (!defined __EXT_MFC_DEF_H)
	#include <ExtMfcDef.h>
#endif // __EXT_MFC_DEF_H

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <math.h>

#if (!defined __AFXPLEX_H__)
	#include <AfxTempl.h>
#endif

/////////////////////////////////////////////////////////////////////////////
// CExtColorCtrl window

class __PROF_UIS_API CExtColorCtrl : public CWnd
{
// Construction
public:
	enum e_mode_t
	{
		MODE_HEXAGON = 0,
		MODE_HSL_PANEL = 1,
		MODE_HSL_BASIC_HUE = 2,
		MODE_HSL_ROLLER = 3,
		MODE_RGB_CUBE = 4,
		MODE_RGB_MIX = 5,
		MODE_GRAY_SCALE_MIX = 6,
		MODE_CMY_CUBE = 7,
		MODE_CMY_MIX = 8,
		MODE_XYZ_R = 9,
		MODE_XYZ_G = 10,
		MODE_XYZ_B = 11,
		MODE_XYZ_C = 12,
		MODE_XYZ_M = 13,
		MODE_XYZ_Y = 14,
		MODE_DIFF = 15,
		MODE_VAL_MIN = 0,
		MODE_VAL_MAX = 15
	};

	CExtColorCtrl(
		e_mode_t eMode = MODE_HEXAGON
		);

	struct __PROF_UIS_API selection_colors_t
	{
		COLORREF m_clrCurrent;
		COLORREF m_clrNew;
		COLORREF m_clrPrev;
		selection_colors_t(
			COLORREF clrCurrent = RGB(255,255,255),
			COLORREF clrNew = RGB(255,255,255),
			COLORREF clrPrev = RGB(255,255,255)
			)
			: m_clrCurrent( clrCurrent )
			, m_clrNew( clrNew )
			, m_clrPrev( clrPrev )
		{
		};
		selection_colors_t(
			const selection_colors_t & other
			)
			: m_clrCurrent( RGB(255,255,255) )
			, m_clrNew( RGB(255,255,255) )
			, m_clrPrev( RGB(255,255,255) )
		{
			AssignFromOther( other );
		};
		~selection_colors_t()
		{
		};
		selection_colors_t & operator=(
			const selection_colors_t & other
			)
		{
			AssignFromOther( other );
			return *this;
		};
	private:
		void AssignFromOther(
			const selection_colors_t & other
			)
		{
			m_clrCurrent = other.m_clrCurrent;
			m_clrNew = other.m_clrNew;
			m_clrPrev = other.m_clrPrev;
		};
	}; // struct selection_colors_t

// Attributes
public:

private:
	e_mode_t m_eMode;
	bool m_bMouseTracking;

	struct __PROF_UIS_API any_picker_data_t
	{
		enum eMoveMode_t
		{
			_MM_NONE = 0,
			_MM_RED = 1,
			_MM_GREEN = 2,
			_MM_BLUE = 3,
			_MM_SLIDER = 4,
			_MM_PICKER = 5,
			_MM_CELL_SCAN = 6,
		};
		eMoveMode_t m_eMoveMode;

		CSize m_sizeTotal;
		COLORREF m_clr;
		COLORREF m_clrOld;
		double
			m_fCurrLuminance,
			m_fCurrSaturation,
			m_fCurrHue;

		any_picker_data_t();
		~any_picker_data_t();

		virtual void OnInit(
			CDC & dc,
			CPalette * pPalette,
			CSize sizeTotal,
			bool bOnlySizeChanged
			);
		virtual void OnDone() = 0;
		virtual void OnDraw(
			CDC & dc,
			CPalette * pPalette
			) = 0;
		virtual void OnLButtonDown(
			UINT nFlags,
			CPoint point
			) = 0; 
		virtual void OnLButtonUp(
			UINT nFlags,
			CPoint point
			) = 0; 
		virtual void OnMouseMove(
			UINT nFlags,
			CPoint point
			) = 0; 
		virtual void OnSetOldRGB(
			COLORREF clr
			);
		virtual void OnSetRGB(
			COLORREF clr
			);
		virtual void OnSetHLS(
			double hue,
			double luminance,
			double saturation
			);

	}; // struct any_picker_data_t

	struct __PROF_UIS_API cell_t
	{
		COLORREF	m_clr;
		CRect		m_rcPosition;
		int			m_nBorderSize;
		CPoint		m_vPoints[6];
		bool		m_bAtFirstType;

		cell_t( COLORREF clr = RGB(255,255,255) )
			: m_clr( clr )
			, m_nBorderSize( 1 )
			, m_bAtFirstType( true )
		{
			for( int i = 0; i < 6; i++ )
				m_vPoints[i] = CPoint(0,0);
		};
		cell_t( const cell_t & other )
			: m_clr( RGB(255,255,255) )
			, m_nBorderSize( 1 )
			, m_bAtFirstType( true )
		{
			for( int i = 0; i < 6; i++ )
				m_vPoints[i] = CPoint(0,0);
			AssignFromOther( other );
		};
		~cell_t()
		{
		};
		cell_t& operator=( const cell_t & other )
		{
			AssignFromOther( other );
			return *this;
		};
		cell_t& operator=( COLORREF clr )
		{
			m_clr = clr;
			return *this;
		};
		void AdjustCellPosition(
			int x,
			int y,
			int nWidth
			)
		{
			float nSideLength =
				(float)((float)nWidth * 0.57735026918962F);
			m_vPoints[0] = CPoint(MoreNear(x - (float)(nWidth / 2)),MoreNear(y - (float)(nSideLength/2)));
			m_vPoints[1] = CPoint(MoreNear((float)x),MoreNear(y - (float)(nWidth / 2)));
			m_vPoints[2] = CPoint(MoreNear(x + (float)(nWidth / 2)),MoreNear(y - (float)(nSideLength/2)));
			m_vPoints[3] = CPoint(MoreNear(x + (float)(nWidth / 2)),MoreNear(y + (float)(nSideLength/2))+1);
			m_vPoints[4] = CPoint(MoreNear((float)x),MoreNear(y + (float)(nWidth / 2))+1);
			m_vPoints[5] = CPoint(MoreNear(x - (float)(nWidth / 2)),MoreNear(y + (float)(nSideLength/2))+1);
		};
		static int MoreNear(float fNear)
		{
			int nRound = (int)fabs(fNear);
			nRound = (fabs(fNear) - (float)nRound >= 0.5) ? nRound+1 : nRound;
			return (fNear < 0) ? -nRound : nRound;
		};
		void SetRect( const CRect & rcPos )
		{
			m_rcPosition = rcPos;
		};
		CRect GetRect() const
		{
			if( !m_bAtFirstType )
			{
				return m_rcPosition;
			}
			CRect rcBounds;
			
			rcBounds.left = rcBounds.right  = m_vPoints[0].x;
			rcBounds.top  = rcBounds.bottom = m_vPoints[0].y;
			
			for (int i=1; i<6; i++)
			{
				rcBounds.left   = min(rcBounds.left,   m_vPoints[i].x);
				rcBounds.top    = min(rcBounds.top,    m_vPoints[i].y);
				rcBounds.right  = max(rcBounds.right,  m_vPoints[i].x);
				rcBounds.bottom = max(rcBounds.bottom, m_vPoints[i].y);
			}
			return rcBounds;
		};
		void SetCellColor(const COLORREF &cr) 
		{ 
			m_clr = cr; 
		};
		void OnDraw(
			CDC & dc,
			CPalette * pPalette,
			bool bFocused
			)
		{
			// prepare DC
			ASSERT( dc.GetSafeHdc() != NULL );
			dc.SaveDC();
			dc.SetBkMode( TRANSPARENT );
			CBrush _brush( m_clr );
			dc.SelectObject( &_brush );
			CPen _pen( PS_SOLID, 0, m_clr );
			dc.SelectObject( &_pen );

			CBrush * pBrWhite = NULL;
			CBrush * pBrBlack = NULL;
			if( bFocused )
			{
				pBrWhite = CBrush::FromHandle ((HBRUSH) ::GetStockObject (WHITE_BRUSH));
				ASSERT_VALID (pBrWhite);
				pBrBlack = CBrush::FromHandle ((HBRUSH) ::GetStockObject (BLACK_BRUSH));
				ASSERT_VALID (pBrBlack);
			} // if( bFocused )

			if( !m_bAtFirstType )
			{ // draw rectangular
				if( bFocused )
				{
//					CRgn rgnOne, rgnTwo, rgnThree;
//					CRect rcPos;
//					rcPos = m_rcPosition;
//					rcPos.DeflateRect(1,1,1,1);
//					rgnTwo.CreateRectRgnIndirect(&rcPos);
//					dc.FrameRgn(&rgnTwo, pBrWhite, 2, 2);
//					rcPos.InflateRect(2,2,2,2);
//					rgnThree.CreateRectRgnIndirect(&rcPos);
//					dc.FrameRgn(&rgnThree, pBrBlack, 1, 1);
					CRect rcPos(m_rcPosition);
					rcPos.InflateRect(3,3);
					dc.FillSolidRect(rcPos,RGB(0,0,0));
					rcPos.DeflateRect(1,1);
					dc.FillSolidRect(rcPos,RGB(255,255,255));
					rcPos.DeflateRect(1,1);
					dc.FillSolidRect(rcPos,RGB(0,0,0));
					dc.FillSolidRect(m_rcPosition,m_clr);
				} // if( bFocused )
				else
				{
					//dc.Rectangle( rcPos );
					if( pPalette != NULL )
					{
						CBrush brush( m_clr );
						dc.FillRect(
							m_rcPosition,
							& brush
							);
					}
					else
						dc.FillSolidRect(m_rcPosition,m_clr);
				} // else from if( bFocused )
			} // draw rectangular
			else
			{ // draw hexagonal
				if( bFocused )
				{
//					if(m_clr == RGB(255,255,255))
//					{
//						CRgn rgnOne;
//						rgnOne.CreatePolygonRgn(m_vPoints, 6, ALTERNATE);
//						dc.FrameRgn(&rgnOne, pBrWhite, 3, 3);
//						dc.FrameRgn(&rgnOne, pBrBlack, 2, 2);
//					}
//					else
//					{
//						CRgn rgnOne;
//						rgnOne.CreatePolygonRgn(m_vPoints, 6, ALTERNATE);
//						dc.FrameRgn(&rgnOne, pBrWhite, 3, 3);
//						dc.FrameRgn(&rgnOne, pBrBlack, 1, 1);
//					}

					CRgn rgnOne,rgnTwo;
					CPoint vPoints[6];
					for( int i = 0; i < 6; i++ )
						vPoints[i] = m_vPoints[i];
					vPoints[0].x -= 2;
					vPoints[0].y -= 1;
					
					vPoints[5].x -= 2;
					vPoints[5].y += 1;
					
					vPoints[2].x += 2;
					vPoints[2].y -= 1;
					vPoints[3].x += 2;
					vPoints[3].y += 1;
					
					vPoints[1].y -= 2;
					vPoints[4].y += 2;
					rgnOne.CreatePolygonRgn(
						vPoints, 6, ALTERNATE );
					rgnTwo.CreatePolygonRgn(
						m_vPoints, 6, ALTERNATE );

					dc.SelectObject( pBrWhite );
					dc.Polygon( vPoints, 6 );
					dc.SelectObject( &_brush );
					dc.Polygon( m_vPoints, 6 );

					dc.FrameRgn(
						&rgnOne, pBrWhite, 3, 3 );
					dc.FrameRgn(
						&rgnOne, pBrBlack, 1, 1 );
					dc.FrameRgn(
						&rgnTwo, pBrBlack, 1, 1 );
				} // if( bFocused )
				else
					dc.Polygon( m_vPoints, 6 );
			} // draw hexagonal

			// resrore DC
			dc.RestoreDC(-1);
		};
		BOOL HitTest(CPoint point)
		{
			if( m_bAtFirstType )
			{
				CRgn rgn;
				rgn.CreatePolygonRgn(m_vPoints, 6, ALTERNATE);
				return rgn.PtInRegion (point);
			}
			else
			{
				CRgn rgn;
				rgn.CreateRectRgn(m_rcPosition.left,m_rcPosition.top,m_rcPosition.right,m_rcPosition.bottom);
				return rgn.PtInRegion (point);
			}
		};
		
	private:
		void AssignFromOther( const cell_t & other )
		{
			m_clr = other.m_clr;
			m_rcPosition = other.m_rcPosition;
			m_nBorderSize = other.m_nBorderSize;
			for( int i = 0; i < 6; i++ )
				m_vPoints[i] = other.m_vPoints[i];
			m_bAtFirstType = other.m_bAtFirstType;
		};
	}; // struct cell_t

	typedef
		CArray < cell_t, cell_t & >
		vCells_t;

	struct __PROF_UIS_API cell_based_data_t : public any_picker_data_t
	{
		vCells_t m_vCells;

		cell_based_data_t()
		{
		};
		~cell_based_data_t()
		{
			ReleaseAll();
		};

		virtual void OnInit(
			CDC & dc,
			CPalette * pPalette,
			CSize sizeTotal,
			bool bOnlySizeChanged
			);
		virtual void OnDone();
		virtual void OnDraw(
			CDC & dc,
			CPalette * pPalette
			);
		virtual void OnLButtonDown(
			UINT nFlags,
			CPoint point
			); 
		virtual void OnLButtonUp(
			UINT nFlags,
			CPoint point
			); 
		virtual void OnMouseMove(
			UINT nFlags,
			CPoint point
			); 

	private:
		void Generate(
			bool bOnlySizeChanged
			);
		void ReleaseAll();
	}; // struct cell_based_data_t

	struct __PROF_UIS_API grayscale_mixer_data_t : public cell_based_data_t
	{
		grayscale_mixer_data_t()
		{
		};
		~grayscale_mixer_data_t()
		{
		};
		virtual void OnInit(
			CDC & dc,
			CPalette * pPalette,
			CSize sizeTotal,
			bool bOnlySizeChanged
			);
		virtual void OnDraw(
			CDC & dc,
			CPalette * pPalette
			);
	}; // struct grayscale_mixer_data_t

	struct __PROF_UIS_API rgb_mixer_data_t : public cell_based_data_t
	{
		rgb_mixer_data_t()
		{
		};
		~rgb_mixer_data_t()
		{
		};
		virtual void OnInit(
			CDC & dc,
			CPalette * pPalette,
			CSize sizeTotal,
			bool bOnlySizeChanged
			);
		virtual void OnDraw(
			CDC & dc,
			CPalette * pPalette
			);
		virtual void OnMouseMove(
			UINT nFlags,
			CPoint point
			); 
	}; // struct rgb_mixer_data_t

	struct __PROF_UIS_API rgb_cube_data_t : public any_picker_data_t
	{
		CDC m_dcCube;
		CSize m_sizeHalfSelBox;
		CRect m_rcCube;
		int m_nSideGap;
		CPoint
			m_ptCubeR,m_ptCubeG,m_ptCubeB,m_ptCubeC,
			m_ptClrR,m_ptClrG,m_ptClrB,m_ptClrCurr,
			m_ptPlainRG,m_ptPlainRB,m_ptPlainGB;

		rgb_cube_data_t();
		~rgb_cube_data_t();

		virtual void OnInit(
			CDC & dc,
			CPalette * pPalette,
			CSize sizeTotal,
			bool bOnlySizeChanged
			);
		virtual void OnDone();
		virtual void OnDraw(
			CDC & dc,
			CPalette * pPalette
			);
		virtual void OnLButtonDown(
			UINT nFlags,
			CPoint point
			); 
		virtual void OnLButtonUp(
			UINT nFlags,
			CPoint point
			); 
		virtual void OnMouseMove(
			UINT nFlags,
			CPoint point
			); 
		virtual void OnSetRGB(
			COLORREF clr
			);
		virtual void OnSetHLS(
			double hue,
			double luminance,
			double saturation
			);

	private:
		void ReleaseAll();
		void Generate(
			CDC & dc,
			CPalette * pPalette
			);
		void RecalcLayout();

	}; // struct rgb_cube_data_t

	struct __PROF_UIS_API cmy_mixer_data_t : public cell_based_data_t
	{
		cmy_mixer_data_t()
		{
		};
		~cmy_mixer_data_t()
		{
		};
		virtual void OnInit(
			CDC & dc,
			CPalette * pPalette,
			CSize sizeTotal,
			bool bOnlySizeChanged
			);
		virtual void OnDraw(
			CDC & dc,
			CPalette * pPalette
			);
		virtual void OnMouseMove(
			UINT nFlags,
			CPoint point
			); 
	}; // struct cmy_mixer_data_t

	struct __PROF_UIS_API cmy_cube_data_t : public any_picker_data_t
	{
		CDC m_dcCube;
		CSize m_sizeHalfSelBox;
		CRect m_rcCube;
		int m_nSideGap;
		CPoint
			m_ptCubeR,m_ptCubeG,m_ptCubeB,m_ptCubeC,
			m_ptClrR,m_ptClrG,m_ptClrB,m_ptClrCurr,
			m_ptPlainRG,m_ptPlainRB,m_ptPlainGB;

		cmy_cube_data_t();
		~cmy_cube_data_t();

		virtual void OnInit(
			CDC & dc,
			CPalette * pPalette,
			CSize sizeTotal,
			bool bOnlySizeChanged
			);
		virtual void OnDone();
		virtual void OnDraw(
			CDC & dc,
			CPalette * pPalette
			);
		virtual void OnLButtonDown(
			UINT nFlags,
			CPoint point
			); 
		virtual void OnLButtonUp(
			UINT nFlags,
			CPoint point
			); 
		virtual void OnMouseMove(
			UINT nFlags,
			CPoint point
			); 
		virtual void OnSetRGB(
			COLORREF clr
			);
		virtual void OnSetHLS(
			double hue,
			double luminance,
			double saturation
			);

	private:
		void ReleaseAll();
		void Generate(
			CDC & dc,
			CPalette * pPalette
			);
		void RecalcLayout();

	}; // struct cmy_cube_data_t

	struct __PROF_UIS_API hsl_panel_data_t : public any_picker_data_t
	{
		CDC m_dcPicker;
		CDC m_dcSlider;
		bool m_bBmpValidPicker;
		bool m_bBmpValidSlider;

		CPoint m_ptMousePos; // position of the picker

		SIZE m_sizeColorPicker;
		SIZE m_sizeColorSlider;
	
		int m_nLumBarDy;
		int m_nAreaGap;

		hsl_panel_data_t();
		~hsl_panel_data_t();

		virtual void OnInit(
			CDC & dc,
			CPalette * pPalette,
			CSize sizeTotal,
			bool bOnlySizeChanged
			);
		virtual void OnDone();
		virtual void OnDraw(
			CDC & dc,
			CPalette * pPalette
			);
		virtual void OnLButtonDown(
			UINT nFlags,
			CPoint point
			); 
		virtual void OnLButtonUp(
			UINT nFlags,
			CPoint point
			); 
		virtual void OnMouseMove(
			UINT nFlags,
			CPoint point
			); 
		virtual void OnSetRGB(
			COLORREF clr
			);
		virtual void OnSetHLS(
			double hue,
			double luminance,
			double saturation
			);
	private:
		void ReleaseAll();
	protected:
		virtual void GenerateSlider(
			CDC &dc,
			CPalette * pPalette
			);
		virtual void GeneratePicker(
			CDC &dc,
			CPalette * pPalette
			);
		void DrawCrossAt(
			CPoint & point,
			CDC & dc,
			SIZE & sz
			);
	}; // struct hsl_panel_data_t

	struct __PROF_UIS_API hsl_basic_hue_data_t : public hsl_panel_data_t
	{
		hsl_basic_hue_data_t()
		{
		};
		~hsl_basic_hue_data_t()
		{
		};

		virtual void OnDraw(
			CDC & dc,
			CPalette * pPalette
			);
		virtual void OnMouseMove(
			UINT nFlags,
			CPoint point
			); 
		virtual void OnSetRGB(
			COLORREF clr
			);
		virtual void OnSetHLS(
			double hue,
			double luminance,
			double saturation
			);
	protected:
		virtual void GenerateSlider(
			CDC &dc,
			CPalette * pPalette
			);
		virtual void GeneratePicker(
			CDC &dc,
			CPalette * pPalette
			);
	}; // struct hsl_basic_hue_data_t

	struct __PROF_UIS_API hsl_roller_data_t : public hsl_panel_data_t
	{
		hsl_roller_data_t()
		{
		};
		~hsl_roller_data_t()
		{
		};

		virtual void OnDraw(
			CDC & dc,
			CPalette * pPalette
			);
		virtual void OnLButtonDown(
			UINT nFlags,
			CPoint point
			); 
		virtual void OnLButtonUp(
			UINT nFlags,
			CPoint point
			); 
		virtual void OnMouseMove(
			UINT nFlags,
			CPoint point
			); 
	protected:
		virtual void GeneratePicker(
			CDC &dc,
			CPalette * pPalette
			);
	}; // struct hsl_roller_data_t

	struct __PROF_UIS_API xyz_plain_data_t : public hsl_panel_data_t
	{
		enum eXYZmode_t
		{
			MXYZ_R = 0,
			MXYZ_G = 1,
			MXYZ_B = 2,
			MXYZ_C = 3,
			MXYZ_M = 4,
			MXYZ_Y = 5,
			MXYZ_MIN = 0,
			MXYZ_MAX = 5
		};
		eXYZmode_t m_eXYZmode;

		xyz_plain_data_t(
			eXYZmode_t eXYZmode
			)
			: m_eXYZmode( eXYZmode )
		{
			ASSERT(
				MXYZ_MIN <= m_eXYZmode
				&& m_eXYZmode <= MXYZ_MAX
				);
		};
		~xyz_plain_data_t()
		{
		};

		virtual void OnDraw(
			CDC & dc,
			CPalette * pPalette
			);
		virtual void OnMouseMove(
			UINT nFlags,
			CPoint point
			); 
		virtual void OnSetRGB(
			COLORREF clr
			);
		virtual void OnSetHLS(
			double hue,
			double luminance,
			double saturation
			);
	protected:
		virtual void GenerateSlider(
			CDC &dc,
			CPalette * pPalette
			);
		virtual void GeneratePicker(
			CDC &dc,
			CPalette * pPalette
			);
		COLORREF CalcColorPicker( int nX, int nY );
		COLORREF CalcColorSlider( int nZ );
		void CalcPoints(
			int &nX,
			int &nY,
			int &nZ,
			bool bDcScale
			);
		void RecalcByZ(
			int nZ
			);
	}; // struct xyz_plain_data_t

	struct __PROF_UIS_API diff_data_t : public grayscale_mixer_data_t
	{
		diff_data_t()
		{
		};
		~diff_data_t()
		{
		};
		virtual void OnInit(
			CDC & dc,
			CPalette * pPalette,
			CSize sizeTotal,
			bool bOnlySizeChanged
			);
		virtual void OnDraw(
			CDC & dc,
			CPalette * pPalette
			);
		virtual void OnSetRGB(
			COLORREF clr
			);
		virtual void OnSetHLS(
			double hue,
			double luminance,
			double saturation
			);
	private:
		void Generate( bool bOnlySizeChanged );
	}; // struct diff_data_t
	
public:
	selection_colors_t m_selClrs;

private:
	cell_based_data_t m_hexagon_data;
	grayscale_mixer_data_t m_grayscale_mixer_data;
	rgb_mixer_data_t m_rgb_mixer_data;
	rgb_cube_data_t m_rgb_cube_data;
	cmy_mixer_data_t m_cmy_mixer_data;
	cmy_cube_data_t m_cmy_cube_data;
	hsl_panel_data_t m_hsl_panel_data;
	hsl_basic_hue_data_t m_hsl_basic_hue_data;
	hsl_roller_data_t m_hsl_roller_data;
	xyz_plain_data_t m_xyz_r;
	xyz_plain_data_t m_xyz_g;
	xyz_plain_data_t m_xyz_b;
	xyz_plain_data_t m_xyz_c;
	xyz_plain_data_t m_xyz_m;
	xyz_plain_data_t m_xyz_y;
	diff_data_t m_diff_data;
	any_picker_data_t * m_algorithms[MODE_VAL_MAX+1];

// Operations
public:
	void SetupColor(
		COLORREF clr,
		bool bNotifyChanged
		);

	// get / set mode
	operator e_mode_t() const
	{
		return m_eMode;
	};
	CExtColorCtrl & operator=( e_mode_t eMode )
	{
		ASSERT(
			MODE_VAL_MIN <= eMode
			&& eMode <= MODE_VAL_MAX
			);
		_Cleanup();
		m_eMode = eMode;
		_Init( false );
		Invalidate();
		UpdateWindow();
		return *this;
	};
private:
	void _Cleanup();
	void _Init( bool bOnlySizeChanged );
	void _MouseTracking( bool bStart = true );

public:
	static UINT g_nMsgColorChanged;
protected:
	virtual void NotifyColorChanged();

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CExtColorCtrl)
	protected:
	virtual void PreSubclassWindow();
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CExtColorCtrl();

	// Generated message map functions
protected:
	//{{AFX_MSG(CExtColorCtrl)
	afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnCancelMode();
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnPaint();
	afx_msg BOOL OnQueryNewPalette();
	afx_msg void OnPaletteChanged(CWnd* pFocusWnd);
	afx_msg void OnKillFocus(CWnd* pNewWnd);
	afx_msg void OnCaptureChanged(CWnd *pWnd);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
	afx_msg void OnMButtonDblClk(UINT nFlags, CPoint point);
	afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point);
	afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // __EXTCOLORCTRL_H

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Sergiy Lavrynenko of Foss Software, Inc.
Architect Foss Software Inc
Ukraine Ukraine
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141223.1 | Last Updated 14 Jan 2004
Article Copyright 2002 by Sergiy Lavrynenko of Foss Software, Inc.
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid