summaryrefslogtreecommitdiff
path: root/win/Colorlst.cpp
diff options
context:
space:
mode:
authordocwhat1999-11-14 06:43:18 +0000
committerdocwhat1999-11-14 06:43:18 +0000
commitd71eec8062e852e56f03102ba4b4e87dc485821d (patch)
tree452368ad0e7e24627e517a0c88c2508d02cea6dc /win/Colorlst.cpp
parent2046090b7ce8dd901ce43e650be5acf44016d714 (diff)
Initial revision
git-svn-id: http://svn.leocad.org/trunk@2 c7d43263-9d01-0410-8a33-9dba5d9f93d6
Diffstat (limited to 'win/Colorlst.cpp')
-rw-r--r--win/Colorlst.cpp135
1 files changed, 135 insertions, 0 deletions
diff --git a/win/Colorlst.cpp b/win/Colorlst.cpp
new file mode 100644
index 0000000..afb7918
--- /dev/null
+++ b/win/Colorlst.cpp
@@ -0,0 +1,135 @@
+// ColorLst.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "leocad.h"
+#include "ColorLst.h"
+#include "globals.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CColorsList
+
+CColorsList::CColorsList()
+{
+ m_bLowRes = FALSE;
+}
+
+CColorsList::~CColorsList()
+{
+}
+
+
+BEGIN_MESSAGE_MAP(CColorsList, CListBox)
+ //{{AFX_MSG_MAP(CColorsList)
+ ON_WM_CREATE()
+ ON_WM_KEYDOWN()
+ //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CColorsList message handlers
+
+void CColorsList::DrawItem(LPDRAWITEMSTRUCT lpDIS)
+{
+ int x = lpDIS->itemID;
+ if (x%2 == 0)
+ x/=2;
+ else
+ x = ((x-1)/2)+14;
+
+ if ((!(lpDIS->itemState & ODS_SELECTED) &&
+ (lpDIS->itemAction & ODA_SELECT)) ||
+ (lpDIS->itemAction & ODA_DRAWENTIRE))
+ {
+ if (m_bLowRes)
+ {
+ HBRUSH hbr = CreateSolidBrush(RGB(255*FlatColorArray[x][0], 255*FlatColorArray[x][1], 255*FlatColorArray[x][2]));
+ FillRect(lpDIS->hDC, &lpDIS->rcItem, hbr);
+ DeleteObject (hbr);
+ }
+ else
+ {
+ SetBkColor(lpDIS->hDC, RGB(255*FlatColorArray[x][0], 255*FlatColorArray[x][1], 255*FlatColorArray[x][2]));
+ ExtTextOut(lpDIS->hDC, 0, 0, ETO_OPAQUE, &lpDIS->rcItem, NULL, 0, NULL);
+ }
+
+ if (x > 13 && x < 22)
+ for (x = lpDIS->rcItem.left; x < lpDIS->rcItem.right; x++)
+ {
+ for (int y = lpDIS->rcItem.top; y < lpDIS->rcItem.bottom; y+=4)
+ {
+ if (y == lpDIS->rcItem.top) y += x%4;
+ SetPixelV (lpDIS->hDC, x,y,RGB(255,255,255));
+ }
+ for (y = lpDIS->rcItem.bottom; y > lpDIS->rcItem.top; y-=4)
+ {
+ if (y == lpDIS->rcItem.bottom) y-= x%4;
+ SetPixelV (lpDIS->hDC, x,y,RGB(255,255,255));
+ }
+ }
+ }
+
+ // item has been selected - hilite frame
+ if ((lpDIS->itemState & ODS_SELECTED) &&
+ (lpDIS->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)))
+ {
+ HBRUSH hbr = CreateSolidBrush(RGB(255*(1-FlatColorArray[x][0]), 255*(1-FlatColorArray[x][1]), 255*(1-FlatColorArray[x][2])));
+ FrameRect(lpDIS->hDC, &lpDIS->rcItem, hbr);
+ DeleteObject (hbr);
+ }
+}
+
+void CColorsList::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
+{
+ lpMeasureItemStruct->itemHeight = 12;
+ lpMeasureItemStruct->itemWidth = 15;
+}
+
+BOOL CColorsList::PreTranslateMessage(MSG* pMsg)
+{
+ if (m_ToolTip.m_hWnd)
+ m_ToolTip.RelayEvent(pMsg);
+
+ return CListBox::PreTranslateMessage(pMsg);
+}
+
+int CColorsList::OnCreate(LPCREATESTRUCT lpCreateStruct)
+{
+ if (CListBox::OnCreate(lpCreateStruct) == -1)
+ return -1;
+
+ m_ToolTip.Create(this);
+// m_ToolTip.Activate(TRUE);
+
+ for (int i = 0; i < 14; i++)
+ {
+ CRect rect (i*15,0,(i+1)*15,12);
+ m_ToolTip.AddTool(this, IDS_COLOR01+i, rect, 1);
+ rect.OffsetRect (0,12);
+ m_ToolTip.AddTool(this, IDS_COLOR15+i, rect, 1);
+ }
+
+ return 0;
+}
+
+void CColorsList::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
+{
+ if (nChar == VK_INSERT)
+ {
+// project->HandleCommand(LC_PIECE_INSERT, 0);
+
+ CFrameWnd* pFrame = (CFrameWnd*)AfxGetMainWnd();
+ pFrame->PostMessage(WM_COMMAND, ID_PIECE_INSERT, 0);
+
+ CView* pView = pFrame->GetActiveView();
+ pView->SetFocus();
+ }
+ else
+ CListBox::OnKeyDown(nChar, nRepCnt, nFlags);
+}