1 /*M///////////////////////////////////////////////////////////////////////////////////////
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
5 // By downloading, copying, installing or using the software you agree to this license.
6 // If you do not agree to this license, do not download, install,
7 // copy or use the software.
10 // Intel License Agreement
11 // For Open Source Computer Vision Library
13 // Copyright (C) 2000, Intel Corporation, all rights reserved.
14 // Third party copyrights are property of their respective owners.
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
19 // * Redistribution's of source code must retain the above copyright notice,
20 // this list of conditions and the following disclaimer.
22 // * Redistribution's in binary form must reproduce the above copyright notice,
23 // this list of conditions and the following disclaimer in the documentation
24 // and/or other materials provided with the distribution.
26 // * The name of Intel Corporation may not be used to endorse or promote products
27 // derived from this software without specific prior written permission.
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the Intel Corporation or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
40 //M*/// WordColors.cpp : implementation file
52 #include "WordColors.h"
57 static char THIS_FILE[] = __FILE__;
60 /////////////////////////////////////////////////////////////////////////////
64 CWordColors::CWordColors(CWnd* pParent /*=NULL*/)
65 : CDialog(CWordColors::IDD, pParent)
67 //{{AFX_DATA_INIT(CWordColors)
68 // NOTE: the ClassWizard will add member initialization here
73 void CWordColors::DoDataExchange(CDataExchange* pDX)
75 CDialog::DoDataExchange(pDX);
76 //{{AFX_DATA_MAP(CWordColors)
77 DDX_Control(pDX, IDC_SAMPLE, m_Sample);
78 DDX_Control(pDX, IDC_KEYWORDS, m_KeyWords);
83 BEGIN_MESSAGE_MAP(CWordColors, CDialog)
84 //{{AFX_MSG_MAP(CWordColors)
85 ON_LBN_SELCHANGE(IDC_KEYWORDS, OnSelchangeKeywords)
86 ON_BN_CLICKED(IDC_FOREGROUND, OnForeground)
91 /////////////////////////////////////////////////////////////////////////////
92 // CWordColors message handlers
94 BOOL CWordColors::OnInitDialog()
96 CDialog::OnInitDialog();
98 // TODO: Add extra initialization here
99 m_KeyWords.AddString("Selection Background");
100 m_KeyWords.AddString("Selection Foreground");
101 m_KeyWords.AddString("Background");
102 m_KeyWords.AddString("Normal");
103 m_KeyWords.AddString("Comment");
104 m_KeyWords.AddString("String");
105 m_KeyWords.AddString("KeyWord");
106 m_KeyWords.AddString("Number");
108 m_KeyWords.SetCurSel(0);
109 OnSelchangeKeywords();
110 m_Sample.SetWindowText("Sample Sample Sample Sample Sample Sample Sample Sample "
111 "Sample Sample Sample Sample Sample Sample Sample Sample "
112 "Sample Sample Sample Sample Sample Sample Sample Sample "
113 "Sample Sample Sample Sample Sample Sample Sample Sample "
114 "Sample Sample Sample Sample Sample Sample Sample Sample "
115 "Sample Sample Sample Sample Sample Sample Sample Sample "
116 "Sample Sample Sample Sample Sample Sample Sample Sample "
117 "Sample Sample Sample Sample Sample Sample Sample Sample "
118 "Sample Sample Sample Sample Sample Sample Sample Sample "
119 "Sample Sample Sample Sample Sample Sample Sample Sample "
120 "Sample Sample Sample Sample Sample Sample Sample Sample "
121 "Sample Sample Sample Sample Sample Sample Sample Sample "
122 "Sample Sample Sample Sample Sample Sample Sample Sample "
123 "Sample Sample Sample Sample Sample Sample Sample Sample "
124 "Sample Sample Sample Sample Sample Sample Sample Sample "
125 "Sample Sample Sample Sample Sample Sample Sample Sample "
126 "Sample Sample Sample Sample Sample Sample Sample Sample ");
128 return TRUE; // return TRUE unless you set the focus to a control
129 // EXCEPTION: OCX Property Pages should return FALSE
132 ColorScheme CWordColors::DoModal(ColorScheme scheme)
135 if(CDialog::DoModal() == IDOK)
137 m_Colors.bkBrush = (HBRUSH)CreateSolidBrush( m_Colors.background );
139 CHawkApp* app = (CHawkApp*)AfxGetApp();
140 app->WriteProfileInt("Configuration", "background", m_Colors.background);
141 app->WriteProfileInt("Configuration", "TOKEN_NORMAL", m_Colors.clr[TOKEN_NORMAL]);
142 app->WriteProfileInt("Configuration", "TOKEN_KEYWORD", m_Colors.clr[TOKEN_KEYWORD]);
143 app->WriteProfileInt("Configuration", "TOKEN_COMMENT", m_Colors.clr[TOKEN_COMMENT]);
144 app->WriteProfileInt("Configuration", "TOKEN_NUMBER", m_Colors.clr[TOKEN_NUMBER]);
145 app->WriteProfileInt("Configuration", "TOKEN_STRING", m_Colors.clr[TOKEN_STRING]);
146 app->WriteProfileInt("Configuration", "selbk", m_Colors.selbk);
147 app->WriteProfileInt("Configuration", "selfk", m_Colors.selfk);
153 void CWordColors::OnSelchangeKeywords()
155 // TODO: Add your control notification handler code here
156 switch(m_KeyWords.GetCurSel())
159 m_Color = (COLORREF*)&m_Colors.selbk;
160 m_Background = m_Colors.selbk;
161 m_Foreground = m_Colors.selfk;
165 m_Color = (COLORREF*)&m_Colors.selfk;
166 m_Background = m_Colors.selbk;
167 m_Foreground = m_Colors.selfk;
171 m_Color = (COLORREF*)&m_Colors.background;
172 m_Background = m_Foreground = m_Colors.background;
173 m_Entry = "background";
176 m_Color = (COLORREF*)&m_Colors.clr[TOKEN_NORMAL];
177 m_Background = m_Colors.background;
178 m_Foreground = m_Colors.clr[0];
179 m_Entry = "TOKEN_NORMAL";
182 m_Color = (COLORREF*)&m_Colors.clr[TOKEN_COMMENT];
183 m_Background = m_Colors.background;
184 m_Foreground = m_Colors.clr[1];
185 m_Entry = "TOKEN_COMMENT";
188 m_Color = (COLORREF*)&m_Colors.clr[TOKEN_STRING];
189 m_Background = m_Colors.background;
190 m_Foreground = m_Colors.clr[2];
191 m_Entry = "TOKEN_STRING";
194 m_Color = (COLORREF*)&m_Colors.clr[TOKEN_KEYWORD];
195 m_Background = m_Colors.background;
196 m_Foreground = m_Colors.clr[3];
197 m_Entry = "TOKEN_KEYWORD";
200 m_Color = (COLORREF*)&m_Colors.clr[TOKEN_NUMBER];
201 m_Background = m_Colors.background;
202 m_Foreground = m_Colors.clr[4];
203 m_Entry = "TOKEN_NUMBER";
206 m_Sample.RedrawWindow();
209 void CWordColors::OnForeground()
211 // TODO: Add your control notification handler code here
212 static COLORREF colors[16];
213 CHOOSECOLOR cl = {sizeof(cl), AfxGetMainWnd()->m_hWnd, 0, *m_Color, colors,
214 CC_RGBINIT, 0, 0, 0};
215 BOOL res = ChooseColor(&cl);
216 if(res) *m_Color = cl.rgbResult;
217 OnSelchangeKeywords();
220 HBRUSH CWordColors::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
222 HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
224 // TODO: Change any attributes of the DC here
225 if(pWnd->m_hWnd == m_Sample.m_hWnd)
227 pDC->SetTextColor(m_Foreground);
228 pDC->SetBkColor(m_Background);
230 // TODO: Return a different brush if the default is not desired