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

XCmyk - CMYK to RGB Calculator with source code

, 5 Jul 2003
XCmyk implements an RGB to CMYK calculator
//
//	Class:		CKnobControlST
//
//	Compiler:	Visual C++
//	Tested on:	Visual C++ 6.0
//
//	Version:	See GetVersionC() or GetVersionI()
//
//	Created:	15/June/2003
//	Updated:	15/June/2003
//
//	Author:		Davide Calabro'		davide_calabro@yahoo.com
//									http://www.softechsoftware.it
//
//	Disclaimer
//	----------
//	THIS SOFTWARE AND THE ACCOMPANYING FILES ARE DISTRIBUTED "AS IS" AND WITHOUT
//	ANY WARRANTIES WHETHER EXPRESSED OR IMPLIED. NO REPONSIBILITIES FOR POSSIBLE
//	DAMAGES OR EVEN FUNCTIONALITY CAN BE TAKEN. THE USER MUST ASSUME THE ENTIRE
//	RISK OF USING THIS SOFTWARE.
//
//	Terms of use
//	------------
//	THIS SOFTWARE IS FREE FOR PERSONAL USE OR FREEWARE APPLICATIONS.
//	IF YOU USE THIS SOFTWARE IN COMMERCIAL OR SHAREWARE APPLICATIONS YOU
//	ARE GENTLY ASKED TO DONATE 5$ (FIVE U.S. DOLLARS) TO THE AUTHOR:
//
//		Davide Calabro'
//		P.O. Box 65
//		21019 Somma Lombardo (VA)
//		Italy
//
#ifndef KNOBCONTROLST_H
#define KNOBCONTROLST_H

#include <gdiplus.h>
#include <math.h>

// Return values
#ifndef	KNOBCONTROLST_OK
#define	KNOBCONTROLST_OK					0
#endif
#ifndef	KNOBCONTROLST_BADPARAM
#define	KNOBCONTROLST_BADPARAM				1
#endif
#ifndef	KNOBCONTROLST_INVALIDRESOURCE
#define	KNOBCONTROLST_INVALIDRESOURCE		2
#endif

class CKnobControlST : public CSliderCtrl
{
public:
	CKnobControlST();
	virtual ~CKnobControlST();

	DWORD SetIcon(int nIcon, BOOL bRepaint = TRUE, HINSTANCE hInstance = NULL);
	DWORD SetIcon(HICON hIcon, BOOL bRepaint = TRUE);

	void SetColors(Color cFgColor, Color cBkColor, BOOL bRepaint = TRUE);
	void SetFgColor(Color cFgColor, BOOL bRepaint = TRUE);
	void SetBkColor(Color cBkColor, BOOL bRepaint = TRUE);
	void SetScaleColor(Color cColor, BOOL bRepaint = TRUE);

	void SetAlpha(BYTE byAlpha, BOOL bRepaint = TRUE);
	BYTE GetAlpha();

	void ShowLargeScale(BOOL bShow, BOOL bRepaint = TRUE);
	void ShowSmallScale(BOOL bShow, BOOL bRepaint = TRUE);
	void SetLargeChangeValue(int nLargeChange, BOOL bRepaint = TRUE);
	void SetSmallChangeValue(int nSmallChange, BOOL bRepaint = TRUE);

	void SetTooltipText(int nId, BOOL bActivate = TRUE);
	void SetTooltipText(LPCTSTR lpszText, BOOL bActivate = TRUE);
	void ActivateTooltip(BOOL bActivate = TRUE);

	DWORD SetChangeCallback(HWND hWnd, UINT nMessage, WPARAM wParam = 0, LPARAM lParam = 0);

	DWORD DrawTransparent(BOOL bRepaint = FALSE);
	DWORD SetBk(CDC* pDC);

	static short GetVersionI()		{return 10;}
	static LPCTSTR GetVersionC()	{return (LPCTSTR)_T("1.0");}

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CKnobControlST)
	public:
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	//}}AFX_VIRTUAL

protected:
	//{{AFX_MSG(CKnobControlST)
	afx_msg void OnPaint();
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
	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 BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
	//}}AFX_MSG

	virtual DWORD OnDrawBackground(Graphics* pGfx, LPCRECT pRect);
	virtual DWORD OnDrawIcon(Graphics* pGfx, Rect* rpKnob);

	CToolTipCtrl	m_ToolTip;

	BOOL			m_bDrawTransparent;	// Draw transparent?
	BOOL			m_bShowSmallScale;
	BOOL			m_bShowLargeScale;
	int				m_nLargeChange;
	int				m_nSmallChange;
	Color			m_cFgColor;
	Color			m_cBkColor;
	Color			m_cScaleColor;
	Rect			m_rKnob;
	Point			m_pntKnob;
	BOOL			m_bIsKnobRotating;

	HICON			m_hIcon;
	BYTE			m_cyIcon;
	BYTE			m_cxIcon;

#pragma pack(1)
	typedef struct _STRUCT_CALLBACK
	{
		HWND		hWnd;			// Handle to window
		UINT		nMessage;		// Message identifier
		WPARAM		wParam;
		LPARAM		lParam;
	} STRUCT_CALLBACK;
#pragma pack()

	STRUCT_CALLBACK	m_csCallbacks;

private:
	void FreeResources(BOOL bCheckForNULL = TRUE);
	void DrawItem(Graphics* pGfx);
	void DrawInsetCircle(Graphics* g, Rect r, Pen* p);
	void PaintBk(Graphics* pGfx);
	Point GetKnobPosition(Rect* rKnob);
	Point GetMarkerPoint(int length, int Value, Rect* rKnob);
	int GetValueFromPosition(Point p);
	Color OffsetColor(Color cColor, short shOffset);
	void InitToolTip();
	void SendChangeCallback();

	CDC				m_dcBk;
	CBitmap			m_bmpBk;
	CBitmap*		m_pbmpOldBk;

	DECLARE_MESSAGE_MAP()
};

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

#endif

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Hans Dietrich
Software Developer (Senior) Hans Dietrich Software
United States United States
I attended St. Michael's College of the University of Toronto, with the intention of becoming a priest. A friend in the University's Computer Science Department got me interested in programming, and I have been hooked ever since.
 
Recently, I have moved to Los Angeles where I am doing consulting and development work.
 
For consulting and custom software development, please see www.hdsoft.org.






| Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 6 Jul 2003
Article Copyright 2003 by Hans Dietrich
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid