PageRenderTime 64ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/zmatrix/Config/ConfigForm.cpp

https://github.com/kovrov/scrap
C++ | 2553 lines | 2065 code | 323 blank | 165 comment | 447 complexity | 0dc1ed942dae39baa3abc83abb6fbf9c MD5 | raw file
  1. /*!=========================================================================
  2. //
  3. // Program: ZMatrix
  4. // Module: $RCSfile: ConfigForm.cpp,v $
  5. // Language: C/C++
  6. // Date: $Date: 2003/05/12 07:43:56 $
  7. // Version: $Revision: 1.21 $
  8. //
  9. // Copyright (c) 2001-2002 Z. Shaker
  10. // All rights reserved.
  11. // See License.txt for details.
  12. //
  13. // This file is part of ZMatrix.
  14. //
  15. // ZMatrix is free software; you can redistribute it and/or modify
  16. // it under the terms of the GNU General Public License as published by
  17. // the Free Software Foundation; either version 2 of the License, or
  18. // (at your option) any later version.
  19. //
  20. // ZMatrix is distributed in the hope that it will be useful,
  21. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. // GNU General Public License for more details.
  24. //
  25. // You should have received a copy of the GNU General Public License
  26. // along with ZMatrix; if not, write to the Free Software
  27. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  28. //
  29. //=========================================================================*/
  30. //---------------------------------------------------------------------------
  31. #define NO_WIN32_LEAN_AND_MEAN
  32. #include <vcl.h>
  33. #pragma hdrstop
  34. #include <tchar.h>
  35. #include <SysUtils.hpp>
  36. #include <stdio.h>
  37. #include <htmlhelp.h>
  38. #include "ConfigForm.h"
  39. #include "AboutUnit.h"
  40. #include "HireUnit.h"
  41. //---------------------------------------------------------------------------
  42. #pragma package(smart_init)
  43. #pragma resource "*.dfm"
  44. TConfigurationForm *ConfigurationForm = NULL;
  45. #ifndef min
  46. #define min(a,b) (a)<(b)? (a):(b)
  47. #endif
  48. #ifndef CLAMP
  49. #define CLAMP(var,min,max)\
  50. if((var) > (max)) (var) = (max);\
  51. if((var) < (min)) (var) = (min);
  52. #endif
  53. #define LONG_MAX_PATH 2048
  54. //---------------------------------------------------------------------------
  55. extern "C" void __stdcall LaunchAboutForm(void *Parent)
  56. {
  57. static bool AlreadyLaunched = false;
  58. if(!AlreadyLaunched)
  59. {
  60. AlreadyLaunched = true;
  61. if(AboutForm == NULL)
  62. {
  63. AboutForm = new TAboutForm((TComponent *)Parent);
  64. }
  65. AboutForm->ShowModal();
  66. if(AboutForm != NULL)
  67. {
  68. delete AboutForm;
  69. AboutForm = NULL;
  70. }
  71. AlreadyLaunched = false;
  72. }
  73. }
  74. //---------------------------------------------------------------------------
  75. extern "C" void __stdcall LaunchHireForm(void *Parent)
  76. {
  77. static bool AlreadyLaunched = false;
  78. if(!AlreadyLaunched)
  79. {
  80. AlreadyLaunched = true;
  81. if(HireForm == NULL)
  82. {
  83. HireForm = new THireForm((TComponent *)Parent);
  84. }
  85. HireForm->ShowModal();
  86. if(HireForm != NULL)
  87. {
  88. delete HireForm;
  89. HireForm = NULL;
  90. }
  91. AlreadyLaunched = false;
  92. }
  93. }
  94. //---------------------------------------------------------------------------
  95. extern "C" int __stdcall LaunchConfigForm(IzsMatrix *Matrix,unsigned int &RefreshTime,DWORD &Priority)
  96. {
  97. //zsMatrix Matrix(NULL,NULL);
  98. int returnValue;
  99. ConfigurationForm = new TConfigurationForm(NULL,Matrix,&RefreshTime,&Priority);
  100. returnValue = ConfigurationForm->ShowModal();
  101. delete ConfigurationForm;
  102. ConfigurationForm = NULL;
  103. if(returnValue == mrOk)
  104. return true;
  105. return false;
  106. }
  107. //---------------------------------------------------------------------------
  108. int __stdcall SaveConfigToFile(IzsMatrix *Matrix,unsigned int RefreshTime,DWORD Priority,_TCHAR *FileName)
  109. {
  110. if((Matrix == NULL) || (FileName == NULL))
  111. {
  112. return 0;
  113. }
  114. AnsiString SectionName;
  115. AnsiString ValueName;
  116. TIniFile *OutFile = new TIniFile(ExpandFileName(AnsiString(FileName)));
  117. //TIniFile *OutFile = new TIniFile(AnsiString(FileName));
  118. SectionName = "General";
  119. ValueName = "ConfigFileFormatVersion";
  120. OutFile->WriteString(SectionName,ValueName,"1.0");
  121. ValueName = "MaxStream";
  122. OutFile->WriteInteger(SectionName,ValueName,Matrix->GetMaxStream());
  123. ValueName = "SpeedVariance";
  124. OutFile->WriteInteger(SectionName,ValueName,Matrix->GetSpeedVariance());
  125. ValueName = "MonotonousCleanupEnabled";
  126. OutFile->WriteBool(SectionName,ValueName,Matrix->GetMonotonousCleanupEnabled());
  127. ValueName = "BackTrace";
  128. OutFile->WriteInteger(SectionName,ValueName,Matrix->GetBackTrace());
  129. ValueName = "RandomizedCleanupEnabled";
  130. OutFile->WriteBool(SectionName,ValueName,Matrix->GetRandomizedCleanupEnabled());
  131. ValueName = "Leading";
  132. OutFile->WriteInteger(SectionName,ValueName,Matrix->GetLeading());
  133. ValueName = "SpacePad";
  134. OutFile->WriteInteger(SectionName,ValueName,Matrix->GetSpacePad());
  135. ValueName = "RefreshTime";
  136. OutFile->WriteInteger(SectionName,ValueName,RefreshTime);
  137. ValueName = "PriorityClass";
  138. AnsiString PriorityName;
  139. switch(Priority)
  140. {
  141. case(ABOVE_NORMAL_PRIORITY_CLASS): PriorityName = "ABOVE_NORMAL_PRIORITY_CLASS"; break;
  142. case(BELOW_NORMAL_PRIORITY_CLASS): PriorityName = "BELOW_NORMAL_PRIORITY_CLASS"; break;
  143. case(HIGH_PRIORITY_CLASS): PriorityName = "HIGH_PRIORITY_CLASS"; break;
  144. case(IDLE_PRIORITY_CLASS): PriorityName = "IDLE_PRIORITY_CLASS"; break;
  145. case(NORMAL_PRIORITY_CLASS): PriorityName = "NORMAL_PRIORITY_CLASS"; break;
  146. default: PriorityName = "IDLE_PRIORITY_CLASS"; break;
  147. }
  148. OutFile->WriteString(SectionName,ValueName,PriorityName);
  149. ValueName = "SpecialStringStreamProbability";
  150. OutFile->WriteFloat(SectionName,ValueName,Matrix->GetSpecialStringStreamProbability());
  151. SectionName = "Text";
  152. LOGFONT LogFont;
  153. GetObject(Matrix->GetFont(),sizeof(LOGFONT),&LogFont);
  154. WriteLogFontToConfigFile(OutFile,SectionName,LogFont);
  155. ValueName = "CharSet";
  156. AnsiString CharSet;
  157. ConvertCharSetToAnsiString(Matrix->GetValidCharSet(),Matrix->GetNumCharsInSet(),CharSet);
  158. OutFile->WriteString(SectionName,ValueName,CharSet);
  159. SectionName = "SpecialText";
  160. GetObject(Matrix->GetSpecialStringFont(),sizeof(LOGFONT),&LogFont);
  161. WriteLogFontToConfigFile(OutFile,SectionName,LogFont);
  162. ValueName = "Strings";
  163. AnsiString SpecialStrings;
  164. vector<tstring> SpecialStringVec;
  165. SpecialStringVec.resize(Matrix->GetNumSpecialStringsInSet());
  166. unsigned int i = 0;
  167. for(vector<tstring>::iterator iter = SpecialStringVec.begin();
  168. iter != SpecialStringVec.end();
  169. ++iter, ++i)
  170. {
  171. iter->assign(Matrix->GetValidSpecialString(i));
  172. }
  173. ConvertSpecialStringsToAnsiString(SpecialStringVec,SpecialStrings,CONFIG_FILE_SPECIAL_STRING_DELIMITER);
  174. OutFile->WriteString(SectionName,ValueName,SpecialStrings);
  175. SectionName = "Colors";
  176. ValueName = "FGColor";
  177. BYTE R,G,B,A;
  178. Matrix->GetColor(R,G,B,A);
  179. AnsiString ForegroundColor = "{" + AnsiString(R) + "," + AnsiString(G) + "," + AnsiString(B) + "," + AnsiString(A) + "}";
  180. OutFile->WriteString(SectionName,ValueName,ForegroundColor);
  181. ValueName = "FadeColor";
  182. Matrix->GetFadeColor(R,G,B,A);
  183. AnsiString FadeColor = "{" + AnsiString(R) + "," + AnsiString(G) + "," + AnsiString(B) + "," + AnsiString(A) + "}";
  184. OutFile->WriteString(SectionName,ValueName,FadeColor);
  185. ValueName = "BGColor";
  186. Matrix->GetBGColor(R,G,B,A);
  187. AnsiString BackgroundColor = "{" + AnsiString(R) + "," + AnsiString(G) + "," + AnsiString(B) + "," + AnsiString(A) + "}";
  188. OutFile->WriteString(SectionName,ValueName,BackgroundColor);
  189. ValueName = "SpecialStringFGColor";
  190. Matrix->GetSpecialStringColor(R,G,B,A);
  191. AnsiString SpecialStringForegroundColor = "{" + AnsiString(R) + "," + AnsiString(G) + "," + AnsiString(B) + "," + AnsiString(A) + "}";
  192. OutFile->WriteString(SectionName,ValueName,SpecialStringForegroundColor);
  193. ValueName = "SpecialStringFadeColor";
  194. Matrix->GetSpecialStringFadeColor(R,G,B,A);
  195. AnsiString SpecialStringFadeColor = "{" + AnsiString(R) + "," + AnsiString(G) + "," + AnsiString(B) + "," + AnsiString(A) + "}";
  196. OutFile->WriteString(SectionName,ValueName,SpecialStringFadeColor);
  197. ValueName = "SpecialStringBGColor";
  198. Matrix->GetSpecialStringBGColor(R,G,B,A);
  199. AnsiString SpecialStringBackgroundColor = "{" + AnsiString(R) + "," + AnsiString(G) + "," + AnsiString(B) + "," + AnsiString(A) + "}";
  200. OutFile->WriteString(SectionName,ValueName,SpecialStringBackgroundColor);
  201. ValueName = "BGMode";
  202. TBGMode BGMode = Matrix->GetBGMode();
  203. AnsiString BGModeString;
  204. switch(BGMode)
  205. {
  206. case(bgmodeColor):
  207. {
  208. BGModeString = "bgmodeColor";
  209. }
  210. break;
  211. default:
  212. case(bgmodeBitmap):
  213. {
  214. BGModeString = "bgmodeBitmap";
  215. }
  216. break;
  217. }
  218. OutFile->WriteString(SectionName,ValueName,BGModeString);
  219. ValueName = "BlendMode";
  220. TBlendMode BlendMode = Matrix->GetBlendMode();
  221. AnsiString BlendModeString;
  222. switch(BlendMode)
  223. {
  224. case(blendmodeOR):
  225. {
  226. BlendModeString = "blendmodeOR";
  227. }
  228. break;
  229. case(blendmodeAND):
  230. {
  231. BlendModeString = "blendmodeAND";
  232. }
  233. break;
  234. default:
  235. case(blendmodeXOR):
  236. {
  237. BlendModeString = "blendmodeXOR";
  238. }
  239. break;
  240. }
  241. OutFile->WriteString(SectionName,ValueName,BlendModeString);
  242. delete OutFile;
  243. return 1;
  244. }
  245. //---------------------------------------------------------------------------
  246. int __stdcall LoadConfigFromFile(IzsMatrix *Matrix,unsigned int &RefreshTime,DWORD &Priority,_TCHAR *FileName)
  247. {
  248. if((Matrix == NULL) || (FileName == NULL))
  249. {
  250. return 0;
  251. }
  252. AnsiString SectionName;
  253. AnsiString ValueName;
  254. TMemIniFile *InFile = new TMemIniFile(ExpandFileName(AnsiString(FileName)));
  255. //TMemIniFile *InFile = new TMemIniFile(AnsiString(FileName));
  256. SectionName = "General";
  257. ValueName = "MaxStream";
  258. Matrix->SetMaxStream(InFile->ReadInteger(SectionName,ValueName,Matrix->GetMaxStream()));
  259. ValueName = "SpeedVariance";
  260. Matrix->SetSpeedVariance(InFile->ReadInteger(SectionName,ValueName,Matrix->GetSpeedVariance()));
  261. ValueName = "MonotonousCleanupEnabled";
  262. Matrix->SetMonotonousCleanupEnabled(InFile->ReadBool(SectionName,ValueName,Matrix->GetMonotonousCleanupEnabled()));
  263. ValueName = "BackTrace";
  264. Matrix->SetBackTrace(InFile->ReadInteger(SectionName,ValueName,Matrix->GetBackTrace()));
  265. ValueName = "RandomizedCleanupEnabled";
  266. Matrix->SetRandomizedCleanupEnabled(InFile->ReadBool(SectionName,ValueName,Matrix->GetRandomizedCleanupEnabled()));
  267. ValueName = "Leading";
  268. Matrix->SetLeading(InFile->ReadInteger(SectionName,ValueName,Matrix->GetLeading()));
  269. ValueName = "SpacePad";
  270. Matrix->SetSpacePad(InFile->ReadInteger(SectionName,ValueName,Matrix->GetSpacePad()));
  271. ValueName = "RefreshTime";
  272. RefreshTime = InFile->ReadInteger(SectionName,ValueName,RefreshTime);
  273. ValueName = "PriorityClass";
  274. AnsiString PriorityName = InFile->ReadString(SectionName,ValueName,"IDLE_PRIORITY_CLASS");
  275. if(PriorityName == "ABOVE_NORMAL_PRIORITY_CLASS")
  276. {
  277. Priority = ABOVE_NORMAL_PRIORITY_CLASS;
  278. }
  279. else if(PriorityName == "BELOW_NORMAL_PRIORITY_CLASS")
  280. {
  281. Priority = BELOW_NORMAL_PRIORITY_CLASS;
  282. }
  283. else if(PriorityName == "HIGH_PRIORITY_CLASS")
  284. {
  285. Priority = HIGH_PRIORITY_CLASS;
  286. }
  287. else if(PriorityName == "IDLE_PRIORITY_CLASS")
  288. {
  289. Priority = IDLE_PRIORITY_CLASS;
  290. }
  291. else if(PriorityName == "NORMAL_PRIORITY_CLASS")
  292. {
  293. Priority = NORMAL_PRIORITY_CLASS;
  294. }
  295. else
  296. {
  297. Priority = IDLE_PRIORITY_CLASS;
  298. }
  299. ValueName = "SpecialStringStreamProbability";
  300. Matrix->SetSpecialStringStreamProbability(InFile->ReadFloat(SectionName,ValueName,Matrix->GetSpecialStringStreamProbability()));
  301. SectionName = "Text";
  302. LOGFONT LogFont;
  303. ReadLogFontFromConfigFile(InFile,SectionName,LogFont);
  304. Matrix->SetLogFont(LogFont);
  305. ValueName = "CharSet";
  306. AnsiString CharSetInString = InFile->ReadString(SectionName,ValueName,"*");
  307. std::vector<_TCHAR> CharSet;
  308. ConvertAnsiStringToCharSet(CharSet,CharSetInString);
  309. if(CharSet.empty())
  310. {
  311. Matrix->ClearValidCharSet();
  312. }
  313. else
  314. {
  315. const _TCHAR *CharSetPointer = &(CharSet.front());
  316. unsigned int CharSetSize = CharSet.size();
  317. Matrix->SetValidCharSet(CharSetPointer,CharSetSize);
  318. }
  319. SectionName = "SpecialText";
  320. ReadLogFontFromConfigFile(InFile,SectionName,LogFont);
  321. Matrix->SetSpecialStringLogFont(LogFont);
  322. ValueName = "Strings";
  323. AnsiString SpecialStringsInString = InFile->ReadString(SectionName,ValueName,"The matrix has you");
  324. std::vector<tstring> SpecialStringVec;
  325. ConvertAnsiStringToSpecialStrings(SpecialStringVec,SpecialStringsInString,CONFIG_FILE_SPECIAL_STRING_DELIMITER);
  326. if(SpecialStringVec.empty())
  327. {
  328. Matrix->ClearValidSpecialStringSet();
  329. }
  330. else
  331. {
  332. unsigned int SpecialStringArraySize = SpecialStringVec.size();
  333. const _TCHAR * /*const*/ *SpecialStringArray = new const _TCHAR *[SpecialStringArraySize];
  334. for(unsigned int i = 0; i < SpecialStringArraySize; i++)
  335. {
  336. SpecialStringArray[i] = SpecialStringVec[i].c_str();
  337. }
  338. Matrix->SetValidSpecialStringSet(SpecialStringArray,SpecialStringArraySize);
  339. delete[] SpecialStringArray;
  340. }
  341. SectionName = "Colors";
  342. ValueName = "FGColor";
  343. int IntR = 150,IntG = 255,IntB = 100,IntA = 255;
  344. AnsiString ForegroundColorString = InFile->ReadString(SectionName,ValueName,"{150,255,100,255}");
  345. sscanf(ForegroundColorString.c_str(),"{%d,%d,%d,%d}",&IntR,&IntG,&IntB,&IntA);
  346. CLAMP(IntR,0,255);CLAMP(IntG,0,255);CLAMP(IntB,0,255);CLAMP(IntA,0,255);
  347. Matrix->SetColor((BYTE)IntR,(BYTE)IntG,(BYTE)IntB,(BYTE)IntA);
  348. ValueName = "FadeColor";
  349. IntR = 0,IntG = 0,IntB = 0,IntA = 0;
  350. AnsiString FadeColorString = InFile->ReadString(SectionName,ValueName,"{50,85,33,128}");
  351. sscanf(FadeColorString.c_str(),"{%d,%d,%d,%d}",&IntR,&IntG,&IntB,&IntA);
  352. CLAMP(IntR,0,255);CLAMP(IntG,0,255);CLAMP(IntB,0,255);CLAMP(IntA,0,255);
  353. Matrix->SetFadeColor((BYTE)IntR,(BYTE)IntG,(BYTE)IntB,(BYTE)IntA);
  354. ValueName = "BGColor";
  355. IntR = 0,IntG = 0,IntB = 0,IntA = 0;
  356. AnsiString BackgroundColorString = InFile->ReadString(SectionName,ValueName,"{0,0,0,0}");
  357. sscanf(BackgroundColorString.c_str(),"{%d,%d,%d,%d}",&IntR,&IntG,&IntB,&IntA);
  358. CLAMP(IntR,0,255);CLAMP(IntG,0,255);CLAMP(IntB,0,255);CLAMP(IntA,0,255);
  359. Matrix->SetBGColor((BYTE)IntR,(BYTE)IntG,(BYTE)IntB,(BYTE)IntA);
  360. ValueName = "SpecialStringFGColor";
  361. IntR = 150,IntG = 255,IntB = 100,IntA = 255;
  362. AnsiString SpecialStringForegroundColorString = InFile->ReadString(SectionName,ValueName,"{150,255,100,255}");
  363. sscanf(SpecialStringForegroundColorString.c_str(),"{%d,%d,%d,%d}",&IntR,&IntG,&IntB,&IntA);
  364. CLAMP(IntR,0,255);CLAMP(IntG,0,255);CLAMP(IntB,0,255);CLAMP(IntA,0,255);
  365. Matrix->SetSpecialStringColor((BYTE)IntR,(BYTE)IntG,(BYTE)IntB,(BYTE)IntA);
  366. ValueName = "SpecialStringFadeColor";
  367. IntR = 0,IntG = 0,IntB = 0,IntA = 0;
  368. AnsiString SpecialStringFadeColorString = InFile->ReadString(SectionName,ValueName,"{50,85,33,128}");
  369. sscanf(SpecialStringFadeColorString.c_str(),"{%d,%d,%d,%d}",&IntR,&IntG,&IntB,&IntA);
  370. CLAMP(IntR,0,255);CLAMP(IntG,0,255);CLAMP(IntB,0,255);CLAMP(IntA,0,255);
  371. Matrix->SetSpecialStringFadeColor((BYTE)IntR,(BYTE)IntG,(BYTE)IntB,(BYTE)IntA);
  372. ValueName = "SpecialStringBGColor";
  373. IntR = 0,IntG = 0,IntB = 0,IntA = 0;
  374. AnsiString SpecialStringBackgroundColorString = InFile->ReadString(SectionName,ValueName,"{0,0,0,0}");
  375. sscanf(SpecialStringBackgroundColorString.c_str(),"{%d,%d,%d,%d}",&IntR,&IntG,&IntB,&IntA);
  376. CLAMP(IntR,0,255);CLAMP(IntG,0,255);CLAMP(IntB,0,255);CLAMP(IntA,0,255);
  377. Matrix->SetSpecialStringBGColor((BYTE)IntR,(BYTE)IntG,(BYTE)IntB,(BYTE)IntA);
  378. ValueName = "BGMode";
  379. TBGMode BGMode;
  380. AnsiString BGModeString = InFile->ReadString(SectionName,ValueName,"bgmodeBitmap");
  381. if(BGModeString == "bgmodeColor")
  382. {
  383. BGMode = bgmodeColor;
  384. }
  385. else
  386. {
  387. BGMode = bgmodeBitmap;
  388. }
  389. Matrix->SetBGMode(BGMode);
  390. ValueName = "BlendMode";
  391. TBlendMode BlendMode;
  392. AnsiString BlendModeString = InFile->ReadString(SectionName,ValueName,"blendmodeXOR");
  393. if(BlendModeString == "blendmodeOR")
  394. {
  395. BlendMode = blendmodeOR;
  396. }
  397. else if(BlendModeString == "blendmodeAND")
  398. {
  399. BlendMode = blendmodeAND;
  400. }
  401. else
  402. {
  403. BlendMode = blendmodeXOR;
  404. }
  405. Matrix->SetBlendMode(BlendMode);
  406. delete InFile;
  407. return 1;
  408. }
  409. //---------------------------------------------------------------------------
  410. int WriteLogFontToConfigFile(TCustomIniFile *OutFile,const AnsiString SectionName,const LOGFONT &LogFont)
  411. {
  412. if(OutFile == NULL)
  413. {
  414. return 0;
  415. }
  416. AnsiString ValueName;
  417. ValueName = "FontHeight";
  418. OutFile->WriteInteger(SectionName,ValueName,LogFont.lfHeight);
  419. ValueName = "FontWidth";
  420. OutFile->WriteInteger(SectionName,ValueName,LogFont.lfWidth);
  421. ValueName = "FontEscapement";
  422. OutFile->WriteInteger(SectionName,ValueName,LogFont.lfEscapement);
  423. ValueName = "FontOrientation";
  424. OutFile->WriteInteger(SectionName,ValueName,LogFont.lfOrientation);
  425. ValueName = "FontWeight";
  426. OutFile->WriteInteger(SectionName,ValueName,LogFont.lfWeight);
  427. ValueName = "FontItalic";
  428. OutFile->WriteBool(SectionName,ValueName,(LogFont.lfItalic == TRUE));
  429. ValueName = "FontUnderline";
  430. OutFile->WriteBool(SectionName,ValueName,(LogFont.lfUnderline == TRUE));
  431. ValueName = "FontStrikeOut";
  432. OutFile->WriteBool(SectionName,ValueName,(LogFont.lfStrikeOut == TRUE));
  433. ValueName = "FontCharSet";
  434. AnsiString CharSetName;
  435. switch(LogFont.lfCharSet)
  436. {
  437. case(ANSI_CHARSET): CharSetName = "ANSI_CHARSET"; break;
  438. case(BALTIC_CHARSET): CharSetName = "BALTIC_CHARSET"; break;
  439. case(CHINESEBIG5_CHARSET): CharSetName = "CHINESEBIG5_CHARSET"; break;
  440. case(EASTEUROPE_CHARSET): CharSetName = "EASTEUROPE_CHARSET"; break;
  441. case(GB2312_CHARSET): CharSetName = "GB2312_CHARSET"; break;
  442. case(GREEK_CHARSET): CharSetName = "GREEK_CHARSET"; break;
  443. case(HANGUL_CHARSET): CharSetName = "HANGUL_CHARSET"; break;
  444. case(MAC_CHARSET): CharSetName = "MAC_CHARSET"; break;
  445. case(OEM_CHARSET): CharSetName = "OEM_CHARSET"; break;
  446. case(RUSSIAN_CHARSET): CharSetName = "RUSSIAN_CHARSET"; break;
  447. case(SHIFTJIS_CHARSET): CharSetName = "SHIFTJIS_CHARSET"; break;
  448. case(SYMBOL_CHARSET): CharSetName = "SYMBOL_CHARSET"; break;
  449. case(TURKISH_CHARSET): CharSetName = "TURKISH_CHARSET"; break;
  450. case(JOHAB_CHARSET): CharSetName = "JOHAB_CHARSET"; break;
  451. case(HEBREW_CHARSET): CharSetName = "HEBREW_CHARSET"; break;
  452. case(ARABIC_CHARSET): CharSetName = "ARABIC_CHARSET"; break;
  453. case(THAI_CHARSET): CharSetName = "THAI_CHARSET"; break;
  454. default: CharSetName = "DEFAULT_CHARSET"; break;
  455. }
  456. OutFile->WriteString(SectionName,ValueName,CharSetName);
  457. ValueName = "FontOutPrecision";
  458. AnsiString OutPrecisionName;
  459. switch(LogFont.lfOutPrecision)
  460. {
  461. case(OUT_DEVICE_PRECIS): OutPrecisionName = "OUT_DEVICE_PRECIS"; break;
  462. case(OUT_OUTLINE_PRECIS): OutPrecisionName = "OUT_OUTLINE_PRECIS"; break;
  463. case(OUT_RASTER_PRECIS): OutPrecisionName = "OUT_RASTER_PRECIS"; break;
  464. case(OUT_STRING_PRECIS): OutPrecisionName = "OUT_STRING_PRECIS"; break;
  465. case(OUT_STROKE_PRECIS): OutPrecisionName = "OUT_STROKE_PRECIS"; break;
  466. case(OUT_TT_ONLY_PRECIS): OutPrecisionName = "OUT_TT_ONLY_PRECIS"; break;
  467. case(OUT_TT_PRECIS): OutPrecisionName = "OUT_TT_PRECIS"; break;
  468. default: OutPrecisionName = "OUT_DEFAULT_PRECIS"; break;
  469. }
  470. OutFile->WriteString(SectionName,ValueName,OutPrecisionName);
  471. ValueName = "FontClipPrecision";
  472. AnsiString ClipPrecisionName;
  473. switch(LogFont.lfClipPrecision)
  474. {
  475. case(CLIP_STROKE_PRECIS): ClipPrecisionName = "CLIP_STROKE_PRECIS"; break;
  476. case(CLIP_EMBEDDED): ClipPrecisionName = "CLIP_EMBEDDED"; break;
  477. case(CLIP_LH_ANGLES): ClipPrecisionName = "CLIP_LH_ANGLES"; break;
  478. default: ClipPrecisionName = "CLIP_DEFAULT_PRECIS"; break;
  479. }
  480. OutFile->WriteString(SectionName,ValueName,ClipPrecisionName);
  481. ValueName = "FontQuality";
  482. AnsiString QualityName;
  483. switch(LogFont.lfQuality)
  484. {
  485. case(DRAFT_QUALITY): QualityName = "DRAFT_QUALITY"; break;
  486. case(PROOF_QUALITY): QualityName = "PROOF_QUALITY"; break;
  487. default: QualityName = "DEFAULT_QUALITY"; break;
  488. }
  489. OutFile->WriteString(SectionName,ValueName,QualityName);
  490. ValueName = "FontPitch";
  491. AnsiString PitchName;
  492. if(LogFont.lfPitchAndFamily & FIXED_PITCH)
  493. {
  494. PitchName = "FIXED_PITCH";
  495. }
  496. else if(LogFont.lfPitchAndFamily & VARIABLE_PITCH)
  497. {
  498. PitchName = "VARIABLE_PITCH";
  499. }
  500. else
  501. {
  502. PitchName = "DEFAULT_PITCH";
  503. }
  504. OutFile->WriteString(SectionName,ValueName,PitchName);
  505. ValueName = "FontFamily";
  506. AnsiString FamilyName;
  507. if(LogFont.lfPitchAndFamily & FF_DECORATIVE)
  508. {
  509. FamilyName = "FF_DECORATIVE";
  510. }
  511. else if(LogFont.lfPitchAndFamily & FF_MODERN)
  512. {
  513. FamilyName = "FF_MODERN";
  514. }
  515. else if(LogFont.lfPitchAndFamily & FF_ROMAN)
  516. {
  517. FamilyName = "FF_ROMAN";
  518. }
  519. else if(LogFont.lfPitchAndFamily & FF_SCRIPT)
  520. {
  521. FamilyName = "FF_SCRIPT";
  522. }
  523. else if(LogFont.lfPitchAndFamily & FF_SWISS)
  524. {
  525. FamilyName = "FF_SWISS";
  526. }
  527. else
  528. {
  529. FamilyName = "FF_DONTCARE";
  530. }
  531. OutFile->WriteString(SectionName,ValueName,FamilyName);
  532. ValueName = "FontName";
  533. OutFile->WriteString(SectionName,ValueName,AnsiString(LogFont.lfFaceName));
  534. return 1;
  535. }
  536. //---------------------------------------------------------------------------
  537. int ReadLogFontFromConfigFile(TCustomIniFile *InFile,const AnsiString SectionName,LOGFONT &LogFont)
  538. {
  539. if(InFile == NULL)
  540. {
  541. return 0;
  542. }
  543. AnsiString ValueName;
  544. LogFont.lfHeight = 12;
  545. LogFont.lfWidth = 0;
  546. LogFont.lfEscapement = 0;
  547. LogFont.lfOrientation = 0;
  548. LogFont.lfWeight = 400;
  549. LogFont.lfItalic = FALSE;
  550. LogFont.lfUnderline = FALSE;
  551. LogFont.lfStrikeOut = FALSE;
  552. ValueName = "FontHeight";
  553. LogFont.lfHeight = InFile->ReadInteger(SectionName,ValueName,LogFont.lfHeight);
  554. ValueName = "FontWidth";
  555. LogFont.lfWidth = InFile->ReadInteger(SectionName,ValueName,LogFont.lfWidth);
  556. ValueName = "FontEscapement";
  557. LogFont.lfEscapement = InFile->ReadInteger(SectionName,ValueName,LogFont.lfEscapement);
  558. ValueName = "FontOrientation";
  559. LogFont.lfOrientation = InFile->ReadInteger(SectionName,ValueName,LogFont.lfOrientation);
  560. ValueName = "FontWeight";
  561. LogFont.lfWeight = InFile->ReadInteger(SectionName,ValueName,LogFont.lfWeight);
  562. ValueName = "FontItalic";
  563. LogFont.lfItalic = InFile->ReadBool(SectionName,ValueName,(LogFont.lfItalic == TRUE));
  564. ValueName = "FontUnderline";
  565. LogFont.lfUnderline = InFile->ReadBool(SectionName,ValueName,(LogFont.lfUnderline == TRUE));
  566. ValueName = "FontStrikeOut";
  567. LogFont.lfStrikeOut = InFile->ReadBool(SectionName,ValueName,(LogFont.lfStrikeOut == TRUE));
  568. ValueName = "FontCharSet";
  569. AnsiString CharSetName = InFile->ReadString(SectionName,ValueName,"DEFAULT_CHARSET");
  570. if(CharSetName == "ANSI_CHARSET")
  571. {
  572. LogFont.lfCharSet = ANSI_CHARSET;
  573. }
  574. else if(CharSetName == "BALTIC_CHARSET")
  575. {
  576. LogFont.lfCharSet = BALTIC_CHARSET;
  577. }
  578. else if(CharSetName == "CHINESEBIG5_CHARSET")
  579. {
  580. LogFont.lfCharSet = CHINESEBIG5_CHARSET;
  581. }
  582. else if(CharSetName == "EASTEUROPE_CHARSET")
  583. {
  584. LogFont.lfCharSet = EASTEUROPE_CHARSET;
  585. }
  586. else if(CharSetName == "GB2312_CHARSET")
  587. {
  588. LogFont.lfCharSet = GB2312_CHARSET;
  589. }
  590. else if(CharSetName == "GREEK_CHARSET")
  591. {
  592. LogFont.lfCharSet = GREEK_CHARSET;
  593. }
  594. else if(CharSetName == "HANGUL_CHARSET")
  595. {
  596. LogFont.lfCharSet = HANGUL_CHARSET;
  597. }
  598. else if(CharSetName == "MAC_CHARSET")
  599. {
  600. LogFont.lfCharSet = MAC_CHARSET;
  601. }
  602. else if(CharSetName == "OEM_CHARSET")
  603. {
  604. LogFont.lfCharSet = OEM_CHARSET;
  605. }
  606. else if(CharSetName == "RUSSIAN_CHARSET")
  607. {
  608. LogFont.lfCharSet = RUSSIAN_CHARSET;
  609. }
  610. else if(CharSetName == "SHIFTJIS_CHARSET")
  611. {
  612. LogFont.lfCharSet = SHIFTJIS_CHARSET;
  613. }
  614. else if(CharSetName == "SYMBOL_CHARSET")
  615. {
  616. LogFont.lfCharSet = SYMBOL_CHARSET;
  617. }
  618. else if(CharSetName == "TURKISH_CHARSET")
  619. {
  620. LogFont.lfCharSet = TURKISH_CHARSET;
  621. }
  622. else if(CharSetName == "JOHAB_CHARSET")
  623. {
  624. LogFont.lfCharSet = JOHAB_CHARSET;
  625. }
  626. else if(CharSetName == "HEBREW_CHARSET")
  627. {
  628. LogFont.lfCharSet = HEBREW_CHARSET;
  629. }
  630. else if(CharSetName == "ARABIC_CHARSET")
  631. {
  632. LogFont.lfCharSet = ARABIC_CHARSET;
  633. }
  634. else if(CharSetName == "THAI_CHARSET")
  635. {
  636. LogFont.lfCharSet = THAI_CHARSET;
  637. }
  638. else
  639. {
  640. LogFont.lfCharSet = DEFAULT_CHARSET;
  641. }
  642. ValueName = "FontOutPrecision";
  643. AnsiString OutPrecisionName = InFile->ReadString(SectionName,ValueName,"OUT_DEFAULT_PRECIS");
  644. if(OutPrecisionName == "OUT_DEVICE_PRECIS")
  645. {
  646. LogFont.lfOutPrecision = OUT_DEVICE_PRECIS;
  647. }
  648. else if(OutPrecisionName == "OUT_OUTLINE_PRECIS")
  649. {
  650. LogFont.lfOutPrecision = OUT_OUTLINE_PRECIS;
  651. }
  652. else if(OutPrecisionName == "OUT_RASTER_PRECIS")
  653. {
  654. LogFont.lfOutPrecision = OUT_RASTER_PRECIS;
  655. }
  656. else if(OutPrecisionName == "OUT_STRING_PRECIS")
  657. {
  658. LogFont.lfOutPrecision = OUT_STRING_PRECIS;
  659. }
  660. else if(OutPrecisionName == "OUT_STROKE_PRECIS")
  661. {
  662. LogFont.lfOutPrecision = OUT_STROKE_PRECIS;
  663. }
  664. else if(OutPrecisionName == "OUT_TT_ONLY_PRECIS")
  665. {
  666. LogFont.lfOutPrecision = OUT_TT_ONLY_PRECIS;
  667. }
  668. else if(OutPrecisionName == "OUT_TT_PRECIS")
  669. {
  670. LogFont.lfOutPrecision = OUT_TT_PRECIS;
  671. }
  672. else
  673. {
  674. LogFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
  675. }
  676. ValueName = "FontClipPrecision";
  677. AnsiString ClipPrecisionName = InFile->ReadString(SectionName,ValueName,"CLIP_DEFAULT_PRECIS");
  678. if(ClipPrecisionName == "CLIP_STROKE_PRECIS")
  679. {
  680. LogFont.lfClipPrecision = CLIP_STROKE_PRECIS;
  681. }
  682. else if(ClipPrecisionName == "CLIP_EMBEDDED")
  683. {
  684. LogFont.lfClipPrecision = CLIP_EMBEDDED;
  685. }
  686. else if(ClipPrecisionName == "CLIP_LH_ANGLES")
  687. {
  688. LogFont.lfClipPrecision = CLIP_LH_ANGLES;
  689. }
  690. else
  691. {
  692. LogFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
  693. }
  694. ValueName = "FontQuality";
  695. AnsiString QualityName = InFile->ReadString(SectionName,ValueName,"DEFAULT_QUALITY");
  696. if(QualityName == "DRAFT_QUALITY")
  697. {
  698. LogFont.lfQuality = DRAFT_QUALITY;
  699. }
  700. else if(QualityName == "PROOF_QUALITY")
  701. {
  702. LogFont.lfQuality = PROOF_QUALITY;
  703. }
  704. else
  705. {
  706. LogFont.lfQuality = DEFAULT_QUALITY;
  707. }
  708. ValueName = "FontPitch";
  709. AnsiString PitchName = InFile->ReadString(SectionName,ValueName,"DEFAULT_PITCH");
  710. if(PitchName == "FIXED_PITCH")
  711. {
  712. LogFont.lfPitchAndFamily = FIXED_PITCH;
  713. }
  714. else if (PitchName == "VARIABLE_PITCH")
  715. {
  716. LogFont.lfPitchAndFamily = VARIABLE_PITCH;
  717. }
  718. else
  719. {
  720. LogFont.lfPitchAndFamily = DEFAULT_PITCH;
  721. }
  722. ValueName = "FontFamily";
  723. AnsiString FamilyName = InFile->ReadString(SectionName,ValueName,"FF_DONTCARE");
  724. if(FamilyName == "FF_DECORATIVE")
  725. {
  726. LogFont.lfPitchAndFamily |= FF_DECORATIVE;
  727. }
  728. else if(FamilyName == "FF_MODERN")
  729. {
  730. LogFont.lfPitchAndFamily |= FF_MODERN;
  731. }
  732. else if(FamilyName == "FF_ROMAN")
  733. {
  734. LogFont.lfPitchAndFamily |= FF_ROMAN;
  735. }
  736. else if(FamilyName == "FF_SCRIPT")
  737. {
  738. LogFont.lfPitchAndFamily |= FF_SCRIPT;
  739. }
  740. else if(FamilyName == "FF_SWISS")
  741. {
  742. LogFont.lfPitchAndFamily |= FF_SWISS;
  743. }
  744. else
  745. {
  746. LogFont.lfPitchAndFamily |= FF_DONTCARE;
  747. }
  748. ValueName = "FontName";
  749. AnsiString FontNameString = InFile->ReadString(SectionName,ValueName,"Terminal");
  750. #ifdef _UNICODE
  751. snwprintf(LogFont.lfFaceName,LF_FACESIZE - 1,_TEXT("%S"),FontNameString.c_str());
  752. #else
  753. snprintf(LogFont.lfFaceName,LF_FACESIZE - 1,"%s",FontNameString.c_str());
  754. #endif
  755. LogFont.lfFaceName[LF_FACESIZE - 1] = (_TCHAR)'\0';
  756. return 1;
  757. }
  758. //---------------------------------------------------------------------------
  759. int ConvertCharSetToAnsiString(const _TCHAR *CharSet,const unsigned int &CharSetSize,AnsiString &OutString)
  760. {
  761. OutString.SetLength(0);
  762. static char HexBuff[16];
  763. unsigned int i;
  764. bool NeedsTrailingCleanup = false;
  765. for(i = 0; i < CharSetSize; i++)
  766. {
  767. if((CharSet[i] == '\t') || (CharSet[i] == ' ') || (CharSet[i] == '\r') ||
  768. (CharSet[i] == '\f') || (CharSet[i] == '\n') || (CharSet[i] == '\0')
  769. )
  770. {
  771. }
  772. else if(CharSet[i] == ',')
  773. {
  774. OutString+= AnsiString("\\,, ");
  775. NeedsTrailingCleanup = true;
  776. }
  777. else if(CharSet[i] == '\\')
  778. {
  779. OutString+= AnsiString("\\\\, ");
  780. NeedsTrailingCleanup = true;
  781. }
  782. else if(CharSet[i] < 256)
  783. {
  784. if(_istprint(CharSet[i]))
  785. {
  786. OutString+= AnsiString((char)CharSet[i]) + AnsiString(", ");
  787. NeedsTrailingCleanup = true;
  788. }
  789. }
  790. else
  791. {
  792. if(_istprint(CharSet[i]))
  793. {
  794. sprintf(HexBuff,"\\0x%X, ",(unsigned int)CharSet[i]);
  795. OutString+= AnsiString(HexBuff);
  796. NeedsTrailingCleanup = true;
  797. }
  798. }
  799. }
  800. if(NeedsTrailingCleanup)
  801. {
  802. int DeleteStartIndex = OutString.Length() + 1;
  803. while((DeleteStartIndex > 1) &&
  804. ((OutString[DeleteStartIndex - 1] == ' ') || (OutString[DeleteStartIndex - 1] == ',')))
  805. {
  806. DeleteStartIndex--;
  807. }
  808. OutString.Delete(DeleteStartIndex,OutString.Length());
  809. }
  810. return 1;
  811. }
  812. //---------------------------------------------------------------------------
  813. int ConvertCharSetToWideString(const _TCHAR *CharSet,const unsigned int &CharSetSize,WideString &OutString)
  814. {
  815. OutString.SetLength(0);
  816. unsigned int i;
  817. bool NeedsTrailingCleanup = false;
  818. for(i = 0; i < CharSetSize; i++)
  819. {
  820. if((CharSet[i] == '\t') || (CharSet[i] == ' ') || (CharSet[i] == '\r') ||
  821. (CharSet[i] == '\f') || (CharSet[i] == '\n') || (CharSet[i] == '\0')
  822. )
  823. {
  824. }
  825. else if(CharSet[i] == ',')
  826. {
  827. OutString+= WideString("\\,, ");
  828. NeedsTrailingCleanup = true;
  829. }
  830. else if(CharSet[i] == '\\')
  831. {
  832. OutString+= WideString("\\\\, ");
  833. NeedsTrailingCleanup = true;
  834. }
  835. else
  836. {
  837. if(_istprint(CharSet[i]))
  838. {
  839. OutString+= WideString((wchar_t)CharSet[i]) + WideString(", ");
  840. NeedsTrailingCleanup = true;
  841. }
  842. }
  843. }
  844. if(NeedsTrailingCleanup)
  845. {
  846. int DeleteStartIndex = OutString.Length() + 1;
  847. while((DeleteStartIndex > 1) &&
  848. ((OutString[DeleteStartIndex - 1] == ' ') || (OutString[DeleteStartIndex - 1] == ',')))
  849. {
  850. DeleteStartIndex--;
  851. }
  852. OutString.Delete(DeleteStartIndex,OutString.Length());
  853. }
  854. return 1;
  855. }
  856. //---------------------------------------------------------------------------
  857. int ConvertAnsiStringToCharSet(std::vector<_TCHAR> &CharSet,const AnsiString &InString)
  858. {
  859. int i = 0;
  860. int j;
  861. char TempBuff[16];
  862. char TempChar;
  863. int TextLength = InString.Length();
  864. int TempInt;
  865. CharSet.clear();
  866. char *MemoCString = InString.c_str();
  867. if(MemoCString == NULL)
  868. {
  869. return 1;
  870. }
  871. while(MemoCString[i] != '\0')
  872. {
  873. TempChar = MemoCString[i];
  874. if((TempChar == ' ') || (TempChar == '\t') || (TempChar == '\n') ||
  875. (TempChar == ',') || (TempChar == '\r') || (TempChar == '\f') )
  876. {
  877. i++;
  878. }
  879. else if(TempChar == '\\')
  880. {
  881. //if at least 3 more chars after the backslash, and the two immediately following are 0 and x (any case)
  882. if((TextLength > (i + 3)) && (MemoCString[i+1] == '0') &&
  883. ((MemoCString[i+2] == 'x') || (MemoCString[i+2] == 'X'))
  884. )
  885. {
  886. //officially over \0x , so we can update i
  887. i+=3;
  888. j = 0;
  889. while((j < 4) && (MemoCString[i+j] != ' ') &&
  890. (MemoCString[i+j] != '\t') &&
  891. (MemoCString[i+j] != '\r') &&
  892. (MemoCString[i+j] != '\f') &&
  893. (MemoCString[i+j] != '\n') &&
  894. (MemoCString[i+j] != ',') &&
  895. ( ((MemoCString[i+j] >= '0') && (MemoCString[i+j] <= '9')) ||
  896. ((MemoCString[i+j] >= 'A') && (MemoCString[i+j] <= 'F')) ||
  897. ((MemoCString[i+j] >= 'a') && (MemoCString[i+j] <= 'f'))
  898. )
  899. )
  900. {
  901. TempBuff[j] = MemoCString[i+j];
  902. j++;
  903. }
  904. TempBuff[j] = '\0';
  905. i+= j;
  906. if(sscanf(TempBuff,"%x",&TempInt))
  907. {
  908. if(_istprint((_TCHAR)TempInt))
  909. {
  910. CharSet.push_back((_TCHAR)TempInt);
  911. }
  912. }
  913. }
  914. //if at least 1 more char after the backslash, and the immediately following is backslash
  915. else if((TextLength > (i + 1)) && (MemoCString[i+1] == '\\'))
  916. {
  917. CharSet.push_back(_TEXT('\\'));
  918. i+=2;
  919. }
  920. //if at least 1 more char after the backslash, and the immediately following is comma
  921. else if((TextLength > (i + 1)) && (MemoCString[i+1] == ','))
  922. {
  923. CharSet.push_back(_TEXT(','));
  924. i+=2;
  925. }
  926. else
  927. {
  928. i++;
  929. }
  930. }
  931. else
  932. {
  933. if(_istprint((_TCHAR)TempChar))
  934. {
  935. CharSet.push_back((_TCHAR)TempChar);
  936. }
  937. i++;
  938. }
  939. }
  940. return CharSet.size();
  941. }
  942. //---------------------------------------------------------------------------
  943. int ConvertWideStringToCharSet(std::vector<_TCHAR> &CharSet,const WideString &InString)
  944. {
  945. int i = 0;
  946. int j;
  947. wchar_t TempBuff[16];
  948. wchar_t TempChar;
  949. int TextLength = InString.Length();
  950. int TempInt;
  951. CharSet.clear();
  952. BSTR MemoCString = InString.c_bstr();
  953. if(MemoCString == NULL)
  954. {
  955. return 1;
  956. }
  957. while(MemoCString[i] != '\0')
  958. {
  959. TempChar = MemoCString[i];
  960. if((TempChar == ' ') || (TempChar == '\t') || (TempChar == '\n') ||
  961. (TempChar == ',') || (TempChar == '\r') || (TempChar == '\f') )
  962. {
  963. i++;
  964. }
  965. else if(TempChar == '\\')
  966. {
  967. //if at least 3 more chars after the backslash, and the two immediately following are 0 and x (any case)
  968. if((TextLength > (i + 3)) && (MemoCString[i+1] == '0') &&
  969. ((MemoCString[i+2] == 'x') || (MemoCString[i+2] == 'X'))
  970. )
  971. {
  972. //officially over \0x , so we can update i
  973. i+=3;
  974. j = 0;
  975. while((j < 4) && (MemoCString[i+j] != ' ') &&
  976. (MemoCString[i+j] != '\t') &&
  977. (MemoCString[i+j] != '\r') &&
  978. (MemoCString[i+j] != '\f') &&
  979. (MemoCString[i+j] != '\n') &&
  980. (MemoCString[i+j] != ',') &&
  981. ( ((MemoCString[i+j] >= '0') && (MemoCString[i+j] <= '9')) ||
  982. ((MemoCString[i+j] >= 'A') && (MemoCString[i+j] <= 'F')) ||
  983. ((MemoCString[i+j] >= 'a') && (MemoCString[i+j] <= 'f'))
  984. )
  985. )
  986. {
  987. TempBuff[j] = MemoCString[i+j];
  988. j++;
  989. }
  990. TempBuff[j] = '\0';
  991. i+= j;
  992. if(swscanf(TempBuff,L"%x",&TempInt))
  993. {
  994. if(_istprint((_TCHAR)TempInt))
  995. {
  996. CharSet.push_back((_TCHAR)TempInt);
  997. }
  998. }
  999. }
  1000. //if at least 1 more char after the backslash, and the immediately following is backslash
  1001. else if((TextLength > (i + 1)) && (MemoCString[i+1] == '\\'))
  1002. {
  1003. CharSet.push_back(_TEXT('\\'));
  1004. i+=2;
  1005. }
  1006. //if at least 1 more char after the backslash, and the immediately following is comma
  1007. else if((TextLength > (i + 1)) && (MemoCString[i+1] == ','))
  1008. {
  1009. CharSet.push_back(_TEXT(','));
  1010. i+=2;
  1011. }
  1012. else
  1013. {
  1014. i++;
  1015. }
  1016. }
  1017. else
  1018. {
  1019. if(_istprint((_TCHAR)TempChar))
  1020. {
  1021. CharSet.push_back((_TCHAR)TempChar);
  1022. }
  1023. i++;
  1024. }
  1025. }
  1026. return CharSet.size();
  1027. }
  1028. //---------------------------------------------------------------------------
  1029. int ConvertSpecialStringsToAnsiString(const std::vector<tstring> &SpecialStrings,AnsiString &OutString, _TCHAR Delimiter)
  1030. {
  1031. OutString.SetLength(0);
  1032. static char HexBuff[16];
  1033. unsigned int i, j;
  1034. AnsiString DelimiterReplacement;
  1035. if(Delimiter == '\n')
  1036. {
  1037. DelimiterReplacement = "\\n";
  1038. }
  1039. else
  1040. {
  1041. DelimiterReplacement = "\\";
  1042. DelimiterReplacement += (char)Delimiter;
  1043. }
  1044. for(i = 0; i < SpecialStrings.size(); i++)
  1045. {
  1046. for(j = 0; j < SpecialStrings[i].length(); j++)
  1047. {
  1048. _TCHAR CurrentChar = SpecialStrings[i][j];
  1049. if((CurrentChar == '\0')
  1050. )
  1051. {
  1052. }
  1053. else if(CurrentChar == Delimiter)
  1054. {
  1055. OutString+= DelimiterReplacement;
  1056. }
  1057. else if(CurrentChar == '\\')
  1058. {
  1059. OutString+= AnsiString("\\\\");
  1060. }
  1061. else if(CurrentChar < 256)
  1062. {
  1063. if(_istprint(CurrentChar))
  1064. {
  1065. OutString+= AnsiString((char)CurrentChar);
  1066. }
  1067. }
  1068. else
  1069. {
  1070. if(_istprint(CurrentChar))
  1071. {
  1072. sprintf(HexBuff,"\\0x%X",(unsigned int)CurrentChar);
  1073. OutString+= AnsiString(HexBuff);
  1074. }
  1075. }
  1076. }
  1077. if(i < (SpecialStrings.size() - 1))
  1078. {
  1079. OutString+= (char)Delimiter;
  1080. }
  1081. }
  1082. return 1;
  1083. }
  1084. //---------------------------------------------------------------------------
  1085. int ConvertSpecialStringsToWideString(const std::vector<tstring> &SpecialStrings,WideString &OutString, _TCHAR Delimiter)
  1086. {
  1087. OutString.SetLength(0);
  1088. unsigned int i, j;
  1089. AnsiString DelimiterReplacement;
  1090. if(Delimiter == '\n')
  1091. {
  1092. DelimiterReplacement = "\\n";
  1093. }
  1094. else
  1095. {
  1096. DelimiterReplacement = "\\";
  1097. DelimiterReplacement += Delimiter;
  1098. }
  1099. for(i = 0; i < SpecialStrings.size(); i++)
  1100. {
  1101. for(j = 0; j < SpecialStrings[i].length(); j++)
  1102. {
  1103. _TCHAR CurrentChar = SpecialStrings[i][j];
  1104. if((CurrentChar == '\0')
  1105. )
  1106. {
  1107. }
  1108. else if(CurrentChar == Delimiter)
  1109. {
  1110. OutString+= DelimiterReplacement;
  1111. }
  1112. else if(CurrentChar == '\\')
  1113. {
  1114. OutString+= AnsiString("\\\\");
  1115. }
  1116. else
  1117. {
  1118. if(_istprint(CurrentChar))
  1119. {
  1120. OutString+= AnsiString((char)CurrentChar);
  1121. }
  1122. }
  1123. }
  1124. if(i < (SpecialStrings.size() - 1))
  1125. {
  1126. OutString+= WideString(Delimiter);
  1127. }
  1128. }
  1129. return 1;
  1130. }
  1131. //---------------------------------------------------------------------------
  1132. int ConvertAnsiStringToSpecialStrings(std::vector<tstring> &SpecialStrings,const AnsiString &InString, _TCHAR Delimiter)
  1133. {
  1134. int i = 0;
  1135. int j;
  1136. char TempBuff[16];
  1137. char TempChar;
  1138. int TextLength = InString.Length();
  1139. int TempInt;
  1140. SpecialStrings.clear();
  1141. tstring CurrentString;
  1142. char *MemoCString = InString.c_str();
  1143. if(MemoCString == NULL)
  1144. {
  1145. return 1;
  1146. }
  1147. while(MemoCString[i] != '\0')
  1148. {
  1149. TempChar = MemoCString[i];
  1150. if(TempChar == Delimiter)
  1151. {
  1152. if(CurrentString.length() > 0)
  1153. {
  1154. SpecialStrings.push_back(CurrentString);
  1155. CurrentString.resize(0);
  1156. }
  1157. i++;
  1158. }
  1159. else if(TempChar == '\\')
  1160. {
  1161. if((TextLength > (i + 1)) && (MemoCString[i+1] == Delimiter))
  1162. {
  1163. CurrentString.append(1,(_TCHAR)MemoCString[i+1]);
  1164. i+=2;
  1165. }
  1166. //if at least 3 more chars after the backslash, and the two immediately following are 0 and x (any case)
  1167. else
  1168. if((TextLength > (i + 3)) && (MemoCString[i+1] == '0') &&
  1169. ((MemoCString[i+2] == 'x') || (MemoCString[i+2] == 'X'))
  1170. )
  1171. {
  1172. //officially over \0x , so we can update i
  1173. i+=3;
  1174. j = 0;
  1175. while((j < 4) && (MemoCString[i+j] != Delimiter) &&
  1176. ( ((MemoCString[i+j] >= '0') && (MemoCString[i+j] <= '9')) ||
  1177. ((MemoCString[i+j] >= 'A') && (MemoCString[i+j] <= 'F')) ||
  1178. ((MemoCString[i+j] >= 'a') && (MemoCString[i+j] <= 'f'))
  1179. )
  1180. )
  1181. {
  1182. TempBuff[j] = MemoCString[i+j];
  1183. j++;
  1184. }
  1185. TempBuff[j] = '\0';
  1186. i+= j;
  1187. if(sscanf(TempBuff,"%x",&TempInt))
  1188. {
  1189. if(((_TCHAR)TempInt) == Delimiter)
  1190. {
  1191. if(CurrentString.length() > 0)
  1192. {
  1193. SpecialStrings.push_back(CurrentString);
  1194. CurrentString.resize(0);
  1195. }
  1196. }
  1197. else if(_istprint((_TCHAR)TempInt))
  1198. {
  1199. CurrentString.append(1,(_TCHAR)TempInt);
  1200. }
  1201. }
  1202. }
  1203. else
  1204. {
  1205. i++;
  1206. }
  1207. }
  1208. else
  1209. {
  1210. if(_istprint((_TCHAR)TempChar))
  1211. {
  1212. CurrentString.append(1,(_TCHAR)TempChar);
  1213. }
  1214. i++;
  1215. }
  1216. }
  1217. if(CurrentString.length() > 0)
  1218. {
  1219. SpecialStrings.push_back(CurrentString);
  1220. CurrentString.resize(0);
  1221. }
  1222. return 1;
  1223. }
  1224. //---------------------------------------------------------------------------
  1225. int ConvertWideStringToSpecialStrings(std::vector<tstring> &SpecialStrings,const WideString &InString, _TCHAR Delimiter)
  1226. {
  1227. int i = 0;
  1228. int j;
  1229. wchar_t TempBuff[16];
  1230. wchar_t TempChar;
  1231. int TextLength = InString.Length();
  1232. int TempInt;
  1233. SpecialStrings.clear();
  1234. tstring CurrentString;
  1235. BSTR MemoCString = InString.c_bstr();
  1236. if(MemoCString == NULL)
  1237. {
  1238. return 1;
  1239. }
  1240. while(MemoCString[i] != '\0')
  1241. {
  1242. TempChar = MemoCString[i];
  1243. if(TempChar == Delimiter)
  1244. {
  1245. if(CurrentString.length() > 0)
  1246. {
  1247. SpecialStrings.push_back(CurrentString);
  1248. CurrentString.resize(0);
  1249. }
  1250. i++;
  1251. }
  1252. else if(TempChar == '\\')
  1253. {
  1254. if((TextLength > (i + 1)) && (MemoCString[i+1] == Delimiter))
  1255. {
  1256. CurrentString.append(1,(_TCHAR)MemoCString[i+1]);
  1257. i+=2;
  1258. }
  1259. //if at least 3 more chars after the backslash, and the two immediately following are 0 and x (any case)
  1260. else
  1261. if((TextLength > (i + 3)) && (MemoCString[i+1] == '0') &&
  1262. ((MemoCString[i+2] == 'x') || (MemoCString[i+2] == 'X'))
  1263. )
  1264. {
  1265. //officially over \0x , so we can update i
  1266. i+=3;
  1267. j = 0;
  1268. while((j < 4) && (MemoCString[i+j] != Delimiter) &&
  1269. ( ((MemoCString[i+j] >= '0') && (MemoCString[i+j] <= '9')) ||
  1270. ((MemoCString[i+j] >= 'A') && (MemoCString[i+j] <= 'F')) ||
  1271. ((MemoCString[i+j] >= 'a') && (MemoCString[i+j] <= 'f'))
  1272. )
  1273. )
  1274. {
  1275. TempBuff[j] = MemoCString[i+j];
  1276. j++;
  1277. }
  1278. TempBuff[j] = '\0';
  1279. i+= j;
  1280. if(swscanf(TempBuff,L"%x",&TempInt))
  1281. {
  1282. if(((_TCHAR)TempInt) == Delimiter)
  1283. {
  1284. if(CurrentString.length() > 0)
  1285. {
  1286. SpecialStrings.push_back(CurrentString);
  1287. CurrentString.resize(0);
  1288. }
  1289. }
  1290. else if(_istprint((_TCHAR)TempInt))
  1291. {
  1292. CurrentString.append(1,(_TCHAR)TempInt);
  1293. }
  1294. }
  1295. }
  1296. else
  1297. {
  1298. i++;
  1299. }
  1300. }
  1301. else
  1302. {
  1303. if(_istprint((_TCHAR)TempChar))
  1304. {
  1305. CurrentString.append(1,(_TCHAR)TempChar);
  1306. }
  1307. i++;
  1308. }
  1309. }
  1310. if(CurrentString.length() > 0)
  1311. {
  1312. SpecialStrings.push_back(CurrentString);
  1313. CurrentString.resize(0);
  1314. }
  1315. return 1;
  1316. }
  1317. //---------------------------------------------------------------------------
  1318. void TConfigurationForm::SetFormMaxStream(int NewFormMaxStream)
  1319. {
  1320. CLAMP(NewFormMaxStream,this->MaxStreamTrackBar->Min,this->MaxStreamTrackBar->Max);
  1321. this->MaxStreamTrackBar->Position = NewFormMaxStream;
  1322. this->MaxStreamWidgetUpDown->Position = NewFormMaxStream;
  1323. }
  1324. //---------------------------------------------------------------------------
  1325. void TConfigurationForm::SetFormSpeedVariance(int NewFormSpeedVariance)
  1326. {
  1327. CLAMP(NewFormSpeedVariance,this->SpeedVarianceTrackBar->Min,this->SpeedVarianceTrackBar->Max);
  1328. this->SpeedVarianceTrackBar->Position = NewFormSpeedVariance;
  1329. this->SpeedVarianceWidgetUpDown->Position = NewFormSpeedVariance;
  1330. }
  1331. //---------------------------------------------------------------------------
  1332. void TConfigurationForm::SetFormMonotonousCleanupEnabled(bool Enabled)
  1333. {
  1334. this->MonotonousCleanupEnabledCheckBox->Checked = Enabled;
  1335. if(Enabled)
  1336. {
  1337. this->EnableBackTraceConfig();
  1338. }
  1339. else
  1340. {
  1341. this->DisableBackTraceConfig();
  1342. }
  1343. }
  1344. //---------------------------------------------------------------------------
  1345. void TConfigurationForm::SetFormBackTrace(int NewFormBackTrace)
  1346. {
  1347. CLAMP(NewFormBackTrace,this->BackTraceTrackBar->Min,this->BackTraceTrackBar->Max);
  1348. this->BackTraceTrackBar->Position = NewFormBackTrace;
  1349. this->BackTraceWidgetUpDown->Position = NewFormBackTrace;
  1350. }
  1351. //---------------------------------------------------------------------------
  1352. void TConfigurationForm::SetFormRandomizedCleanupEnabled(bool Enabled)
  1353. {
  1354. this->RandomizedCleanupEnabledCheckBox->Checked = Enabled;
  1355. if(Enabled)
  1356. {
  1357. this->EnableLeadingConfig();
  1358. this->EnableSpacePadConfig();
  1359. }
  1360. else
  1361. {
  1362. this->DisableLeadingConfig();
  1363. this->DisableSpacePadConfig();
  1364. }
  1365. }
  1366. //---------------------------------------------------------------------------
  1367. void TConfigurationForm::SetFormLeading(int NewFormLeading)
  1368. {
  1369. CLAMP(NewFormLeading,this->LeadingTrackBar->Min,this->LeadingTrackBar->Max);
  1370. this->LeadingTrackBar->Position = NewFormLeading;
  1371. this->LeadingWidgetUpDown->Position = NewFormLeading;
  1372. }
  1373. //---------------------------------------------------------------------------
  1374. void TConfigurationForm::SetFormSpacePad(int NewFormSpacePad)
  1375. {
  1376. CLAMP(NewFormSpacePad,this->SpacePadTrackBar->Min,this->SpacePadTrackBar->Max);
  1377. this->SpacePadTrackBar->Position = NewFormSpacePad;
  1378. this->SpacePadWidgetUpDown->Position = NewFormSpacePad;
  1379. }
  1380. //---------------------------------------------------------------------------
  1381. void TConfigurationForm::SetFormFont(HFONT hFont)
  1382. {
  1383. if(hFont != NULL)
  1384. {
  1385. int TempSize;
  1386. TFont *TargetFont = this->FontDialog->Font;
  1387. LOGFONT NewLogFont;
  1388. GetObject(hFont,sizeof(LOGFONT),&NewLogFont);
  1389. TargetFont->Name = NewLogFont.lfFaceName;
  1390. TargetFont->Charset = NewLogFont.lfCharSet;
  1391. TempSize = -NewLogFont.lfHeight * 72 / TargetFont->PixelsPerInch;
  1392. if(TempSize)
  1393. TargetFont->Size = TempSize;
  1394. else
  1395. TargetFont->Size = 1;
  1396. if(NewLogFont.lfPitchAndFamily & FIXED_PITCH)
  1397. {
  1398. TargetFont->Pitch = fpFixed;
  1399. }
  1400. else if(NewLogFont.lfPitchAndFamily & VARIABLE_PITCH)
  1401. {
  1402. TargetFont->Pitch = fpVariable;
  1403. }
  1404. else
  1405. {
  1406. TargetFont->Pitch = fpDefault;
  1407. }
  1408. if(NewLogFont.lfWeight >= FW_BOLD) TargetFont->Style = TargetFont->Style << fsBold;
  1409. else TargetFont->Style = TargetFont->Style >> fsBold;
  1410. if(NewLogFont.lfItalic) TargetFont->Style = TargetFont->Style << fsItalic;
  1411. else TargetFont->Style = TargetFont->Style >> fsItalic;
  1412. if(NewLogFont.lfUnderline) TargetFont->Style = TargetFont->Style << fsUnderline;
  1413. else TargetFont->Style = TargetFont->Style >> fsUnderline;
  1414. if(NewLogFont.lfStrikeOut) TargetFont->Style = TargetFont->Style << fsStrikeOut;
  1415. else TargetFont->Style = TargetFont->Style >> fsStrikeOut;
  1416. this->FontNameWidget->Text = NewLogFont.lfFaceName;
  1417. }
  1418. }
  1419. //---------------------------------------------------------------------------
  1420. void TConfigurationForm::SetFormSpecialFont(HFONT hFont)
  1421. {
  1422. if(hFont != NULL)
  1423. {
  1424. int TempSize;
  1425. TFont *TargetFont = this->SpecialFontDialog->Font;
  1426. LOGFONT NewLogFont;
  1427. GetObject(hFont,sizeof(LOGFONT),&NewLogFont);
  1428. TargetFont->Name = NewLogFont.lfFaceName;
  1429. TargetFont->Charset = NewLogFont.lfCharSet;
  1430. TempSize = -NewLogFont.lfHeight * 72 / TargetFont->PixelsPerInch;
  1431. if(TempSize)
  1432. TargetFont->Size = TempSize;
  1433. else
  1434. TargetFont->Size = 1;
  1435. if(NewLogFont.lfPitchAndFamily & FIXED_PITCH)
  1436. {
  1437. TargetFont->Pitch = fpFixed;
  1438. }
  1439. else if(NewLogFont.lfPitchAndFamily & VARIABLE_PITCH)
  1440. {
  1441. TargetFont->Pitch = fpVariable;
  1442. }
  1443. else
  1444. {
  1445. TargetFont->Pitch = fpDefault;
  1446. }
  1447. if(NewLogFont.lfWeight >= FW_BOLD) TargetFont->Style = TargetFont->Style << fsBold;
  1448. else TargetFont->Style = TargetFont->Style >> fsBold;
  1449. if(NewLogFont.lfItalic) TargetFont->Style = TargetFont->Style << fsItalic;
  1450. else TargetFont->Style = TargetFont->Style >> fsItalic;
  1451. if(NewLogFont.lfUnderline) TargetFont->Style = TargetFont->Style << fsUnderline;
  1452. else TargetFont->Style = TargetFont->Style >> fsUnderline;
  1453. if(NewLogFont.lfStrikeOut) TargetFont->Style = TargetFont->Style << fsStrikeOut;
  1454. else TargetFont->Style = TargetFont->Style >> fsStrikeOut;
  1455. this->SpecialFontNameWidget->Text = NewLogFont.lfFaceName;
  1456. }
  1457. }
  1458. //---------------------------------------------------------------------------
  1459. void TConfigurationForm::SetFormForegroundColor(BYTE R,BYTE G,BYTE B,BYTE A)
  1460. {
  1461. TColor NewCol = (TColor)RGB(R,G,B);
  1462. this->LeadColorPanel->Font->Color = (TColor)NewCol;
  1463. this->ForegroundColorDialog->Color = (TColor)NewCol;
  1464. }
  1465. //---------------------------------------------------------------------------
  1466. void TConfigurationForm::SetFormFadeColor(BYTE R,BYTE G,BYTE B,BYTE A)
  1467. {
  1468. TColor NewFadeCol = (TColor)RGB(R,G,B);
  1469. this->TrailColorPanel->Font->Color = (TColor)NewFadeCol;
  1470. this->FadeColorDialog->Color = (TColor)NewFadeCol;
  1471. }
  1472. //---------------------------------------------------------------------------
  1473. void TConfigurationForm::SetFormBackgroundColor(BYTE R,BYTE G,BYTE B,BYTE A)
  1474. {
  1475. TColor NewBGCol = (TColor)RGB(R,G,B);
  1476. this->LeadColorPanel->Color = (TColor)NewBGCol;
  1477. this->TrailColorPanel->Color = (TColor)NewBGCol;
  1478. this->SpecialLeadColorPanel->Color = (TColor)NewBGCol;
  1479. this->SpecialTrailColorPanel->Color = (TColor)NewBGCol;
  1480. this->BackgroundColorDialog->Color = (TColor)NewBGCol;
  1481. if(A < 128)
  1482. {
  1483. this->TransparentBGRadioButton->Checked = true;
  1484. }
  1485. else
  1486. {
  1487. this->OpaqueBGRadioButton->Checked = true;
  1488. }
  1489. }
  1490. //---------------------------------------------------------------------------
  1491. void TConfigurationForm::SetFormSpecialForegroundColor(BYTE R,BYTE G,BYTE B,BYTE A)
  1492. {
  1493. TColor NewCol = (TColor)RGB(R,G,B);
  1494. this->SpecialLeadColorPanel->Font->Color = (TColor)NewCol;
  1495. this->SpecialForegroundColorDialog->Color = (TColor)NewCol;
  1496. }
  1497. //---------------------------------------------------------------------------
  1498. void TConfigurationForm::SetFormSpecialFadeColor(BYTE R,BYTE G,BYTE B,BYTE A)
  1499. {
  1500. TColor NewFadeCol = (TColor)RGB(R,G,B);
  1501. this->SpecialTrailColorPanel->Font->Color = (TColor)NewFadeCol;
  1502. this->SpecialFadeColorDialog->Color = (TColor)NewFadeCol;
  1503. }
  1504. //---------------------------------------------------------------------------
  1505. void TConfigurationForm::SetFormBGMode(TBGMode NewBGMode)
  1506. {
  1507. switch(NewBGMode)
  1508. {
  1509. case(bgmodeBitmap):
  1510. {
  1511. this->BitmapBGModeRadioButton->Checked = true;
  1512. this->EnableBlendingConfig();
  1513. }
  1514. break;
  1515. case(bgmodeColor):
  1516. {
  1517. this->ColorBGModeRadioButton->Checked = true;
  1518. this->DisableBlendingConfig();
  1519. }
  1520. break;
  1521. }
  1522. }
  1523. //---------------------------------------------------------------------------
  1524. void TConfigurationForm::SetFormBlendingMode(TBlendMode NewBlendMode)
  1525. {
  1526. switch(NewBlendMode)
  1527. {
  1528. case(blendmodeXOR):
  1529. {
  1530. this->XORBGBlendModeRadioButton->Checked = true;
  1531. }
  1532. break;
  1533. case(blendmodeOR):
  1534. {
  1535. this->ORBGBlendModeRadioButton->Checked = true;
  1536. }
  1537. break;
  1538. case(blendmodeAND):
  1539. {
  1540. this->ANDBGBlendModeRadioButton->Checked = true;
  1541. }
  1542. break;
  1543. }
  1544. }
  1545. //---------------------------------------------------------------------------
  1546. void TConfigurationForm::DisableLeadingConfig(void)
  1547. {
  1548. this->LeadingGroupBox->Enabled = false;
  1549. this->LeadingTrackBar->Enabled = false;
  1550. this->LeadingWidget->Enabled = false;
  1551. this->LeadingWidgetUpDown->Enabled = false;
  1552. }
  1553. //---------------------------------------------------------------------------
  1554. void TConfigurationForm::EnableLeadingConfig(void)
  1555. {
  1556. this->LeadingGroupBox->Enabled = true;
  1557. this->LeadingTrackBar->Enabled = true;
  1558. this->LeadingWidget->Enabled = true;
  1559. this->LeadingWidgetUpDown->Enabled = true;
  1560. }
  1561. //---------------------------------------------------------------------------
  1562. void TConfigurationForm::DisableBackTraceConfig(void)
  1563. {
  1564. this->BackTraceGroupBox->Enabled = false;
  1565. this->BackTraceTrackBar->Enabled = false;
  1566. this->BackTraceWidget->Enabled = false;
  1567. this->BackTraceWidgetUpDown->Enabled = false;
  1568. }
  1569. //---------------------------------------------------------------------------
  1570. void TConfigurationForm::EnableBackTraceConfig(void)
  1571. {
  1572. this->BackTraceGroupBox->Enabled = true;
  1573. this->BackTraceTrackBar->Enabled = true;
  1574. this->BackTraceWidget->Enabled = true;
  1575. this->BackTraceWidgetUpDown->Enabled = true;
  1576. }
  1577. //---------------------------------------------------------------------------
  1578. void TConfigurationForm::DisableSpacePadConfig(void)
  1579. {
  1580. this->SpacePadGroupBox->Enabled = false;
  1581. this->SpacePadTrackBar->Enabled = false;
  1582. this->SpacePadWidget->Enabled = false;
  1583. this->SpacePadWidgetUpDown->Enabled = false;
  1584. }
  1585. //---------------------------------------------------------------------------
  1586. void TConfigurationForm::EnableSpacePadConfig(void)
  1587. {
  1588. this->SpacePadGroupBox->Enabled = true;
  1589. this->SpacePadTrackBar->Enabled = true;
  1590. this->SpacePadWidget->Enabled = true;
  1591. this->SpacePadWidgetUpDown->Enabled = true;
  1592. }
  1593. //---------------------------------------------------------------------------
  1594. void TConfigurationForm::SetFormRefreshTime(unsigned int NewFormRefreshTime)
  1595. {
  1596. CLAMP(NewFormRefreshTime,((unsigned int)this->RefreshTimeTrackBar->Min),((unsigned int)this->RefreshTimeTrackBar->Max));
  1597. this->RefreshTimeTrackBar->Position = NewFormRefreshTime;
  1598. this->RefreshTimeWidgetUpDown->Position = NewFormRefreshTime;
  1599. }
  1600. //---------------------------------------------------------------------------
  1601. void TConfigurationForm::SetFormSpecialStreamProbability(float NewSpecialStreamProbability)
  1602. {
  1603. unsigned int NewProbabilityAsInteger = (unsigned int)(NewSpecialStreamProbability*100);
  1604. CLAMP(NewProbabilityAsInteger,((unsigned int)this->SpecialStreamProbabilityTrackBar->Min),((unsigned int)this->SpecialStreamProbabilityTrackBar->Max));
  1605. this->SpecialStreamProbabilityTrackBar->Position = NewProbabilityAsInteger;
  1606. this->SpecialStreamProbabilityWidgetUpDown->Position = NewProbabilityAsInteger;
  1607. }
  1608. //---------------------------------------------------------------------------
  1609. void TConfigurationForm::SetFormPriority(DWORD NewFormPriority)
  1610. {
  1611. switch(NewFormPriority)
  1612. {
  1613. case(HIGH_PRIORITY_CLASS):
  1614. {
  1615. this->HighPriorityRadioButton->Checked = true;
  1616. }
  1617. break;
  1618. case(ABOVE_NORMAL_PRIORITY_CLASS):
  1619. {
  1620. this->AboveNormalPriorityRadioButton->Checked = true;
  1621. }
  1622. break;
  1623. case(NORMAL_PRIORITY_CLASS):
  1624. {
  1625. this->NormalPriorityRadioButton->Checked = true;
  1626. }
  1627. break;
  1628. case(BELOW_NORMAL_PRIORITY_CLASS):
  1629. {
  1630. this->BelowNormalPriorityRadioButton->Checked = true;
  1631. }
  1632. break;
  1633. default:
  1634. case(IDLE_PRIORITY_CLASS):
  1635. {
  1636. this->IdlePriorityRadioButton->Checked = true;
  1637. }
  1638. break;
  1639. }
  1640. }
  1641. //---------------------------------------------------------------------------
  1642. void TConfigurationForm::DisableBlendingConfig(void)
  1643. {
  1644. this->BGBlendModePanel->Enabled = false;
  1645. this->BGBlendModeLabel->Enabled = false;
  1646. this->XORBGBlendModeRadioButton->Enabled = false;
  1647. this->ORBGBlendModeRadioButton->Enabled = false;
  1648. this->ANDBGBlendModeRadioButton->Enabled = false;
  1649. }
  1650. //---------------------------------------------------------------------------
  1651. void TConfigurationForm::EnableBlendingConfig(void)
  1652. {
  1653. this->BGBlendModePanel->Enabled = true;
  1654. this->BGBlendModeLabel->Enabled = true;
  1655. this->XORBGBlendModeRadioButton->Enabled = true;
  1656. this->ORBGBlendModeRadioButton->Enabled = true;
  1657. this->ANDBGBlendModeRadioButton->Enabled = true;
  1658. }
  1659. //---------------------------------------------------------------------------
  1660. void TConfigurationForm::UpdateFormBasedOnTarget(void)
  1661. {
  1662. this->SetFormMaxStream(this->TargetMatrix->GetMaxStream());
  1663. this->SetFormSpeedVariance(this->TargetMatrix->GetSpeedVariance());
  1664. this->SetFormBackTrace(this->TargetMatrix->GetBackTrace());
  1665. this->SetFormMonotonousCleanupEnabled(this->TargetMatrix->GetMonotonousCleanupEnabled());
  1666. this->SetFormLeading(this->TargetMatrix->GetLeading());
  1667. this->SetFormSpacePad(this->TargetMatrix->GetSpacePad());
  1668. this->SetFormRandomizedCleanupEnabled(this->TargetMatrix->GetRandomizedCleanupEnabled());
  1669. this->SetFormFont(this->TargetMatrix->GetFont());
  1670. this->SetFormSpecialFont(this->TargetMatrix->GetSpecialStringFont());
  1671. BYTE R,G,B,A;
  1672. this->TargetMatrix->GetColor(R,G,B,A);
  1673. this->SetFormForegroundColor(R,G,B,A);
  1674. this->TargetMatrix->GetFadeColor(R,G,B,A);
  1675. this->SetFormFadeColor(R,G,B,A);
  1676. this->TargetMatrix->GetBGColor(R,G,B,A);
  1677. this->SetFormBackgroundColor(R,G,B,A);
  1678. this->TargetMatrix->GetSpecialStringColor(R,G,B,A);
  1679. this->SetFormSpecialForegroundColor(R,G,B,A);
  1680. this->TargetMatrix->GetSpecialStringFadeColor(R,G,B,A);
  1681. this->SetFormSpecialFadeColor(R,G,B,A);
  1682. this->SetFormBGMode((TBGMode)this->TargetMatrix->GetBGMode());
  1683. this->SetFormBlendingMode((TBlendMode)this->TargetMatrix->GetBlendMode());
  1684. this->SetFormRefreshTime(*(this->TargetRefreshTime));
  1685. this->SetFormSpecialStreamProbability(this->TargetMatrix->GetSpecialStringStreamProbability());
  1686. this->SetFormPriority(*(this->TargetPriority));
  1687. }
  1688. //---------------------------------------------------------------------------
  1689. void TConfigurationForm::LaunchURL(const _TCHAR *URL)
  1690. {
  1691. ShellExecute(this->Handle,_TEXT("open"),URL, NULL, NULL, SW_SHOWNORMAL );
  1692. }
  1693. //---------------------------------------------------------------------------
  1694. //---------------------------------------------------------------------------
  1695. //--------------------------CONSTRUCTOR--------------------------------------
  1696. //---------------------------------------------------------------------------
  1697. //---------------------------------------------------------------------------
  1698. __fastcall TConfigurationForm::TConfigurationForm(TComponent* Owner,IzsMatrix *NewTargetMatrix,unsigned int *NewTargetRefreshTime,DWORD *NewTargetPriority)
  1699. :TForm(Owner)
  1700. {
  1701. if(CharacterSetForm == NULL)
  1702. {
  1703. CharacterSetForm = new TCharacterSetForm(this);
  1704. }
  1705. this->TargetMatrix = NewTargetMatrix;
  1706. this->TargetRefreshTime = NewTargetRefreshTime;
  1707. this->TargetPriority = NewTargetPriority;
  1708. this->UpdateFormBasedOnTarget();
  1709. }
  1710. //---------------------------------------------------------------------------
  1711. __fastcall TConfigurationForm::~TConfigurationForm(void)
  1712. {
  1713. if(CharacterSetForm != NULL)
  1714. {
  1715. delete CharacterSetForm;
  1716. CharacterSetForm = NULL;
  1717. }
  1718. }
  1719. //---------------------------------------------------------------------------
  1720. void __fastcall TConfigurationForm::MaxStreamTrackBarChange(
  1721. TObject *Sender)
  1722. {
  1723. TargetMatrix->SetMaxStream(this->MaxStreamTrackBar->Position);
  1724. this->MaxStreamWidgetUpDown->Position = this->MaxStreamTrackBar->Position;
  1725. }
  1726. //---------------------------------------------------------------------------
  1727. void __fastcall TConfigurationForm::MaxStreamWidgetChange(
  1728. TObject *Sender)
  1729. {
  1730. if(this->MaxStreamWidgetUpDown->Position < this->MaxStreamTrackBar->Min)
  1731. this->MaxStreamWidgetUpDown->Position = this->MaxStreamTrackBar->Min;
  1732. if(this->MaxStreamWidgetUpDown->Position > this->MaxStreamTrackBar->Max)
  1733. this->MaxStreamWidgetUpDown->Position = this->MaxStreamTrackBar->Max;
  1734. //CLAMP(this->MaxStreamWidgetUpDown->Position,this->MaxStreamTrackBar->Min,this->MaxStreamTrackBar->Max);
  1735. TargetMatrix->SetMaxStream(this->MaxStreamWidgetUpDown->Position);
  1736. this->MaxStreamTrackBar->Position = this->MaxStreamWidgetUpDown->Position;
  1737. }
  1738. //---------------------------------------------------------------------------
  1739. void __fastcall TConfigurationForm::FontSelectionButtonClick(
  1740. TObject *Sender)
  1741. {
  1742. if(this->FontDialog->Execute())
  1743. {
  1744. this->FontNameWidget->Text = this->FontDialog->Font->Name;
  1745. this->TargetMatrix->SetFont(this->FontDialog->Font->Handle);
  1746. }
  1747. }
  1748. //---------------------------------------------------------------------------
  1749. void __fastcall TConfigurationForm::SpecialFontSelectionButtonClick(
  1750. TObject *Sender)
  1751. {
  1752. if(this->SpecialFontDialog->Execute())
  1753. {
  1754. this->SpecialFontNameWidget->Text = this->SpecialFontDialog->Font->Name;
  1755. this->TargetMatrix->SetSpecialStringFont(this->SpecialFontDialog->Font->Handle);
  1756. }
  1757. }
  1758. //---------------------------------------------------------------------------
  1759. void __fastcall TConfigurationForm::ForegroundColorSelectionButtonClick(
  1760. TObject *Sender)
  1761. {
  1762. if(this->ForegroundColorDialog->Execute())
  1763. {
  1764. this->LeadColorPanel->Font->Color = this->ForegroundColorDialog->Color;
  1765. BYTE DummyR,DummyG,DummyB,A;
  1766. this->TargetMatrix->GetColor(DummyR,DummyG,DummyB,A);
  1767. BYTE B = (BYTE)((this->ForegroundColorDialog->Color>>16) & 0xFF);
  1768. BYTE G = (BYTE)((this->ForegroundColorDialog->Color>>8) & 0xFF);
  1769. BYTE R = (BYTE)((this->ForegroundColorDialog->Color) & 0xFF);
  1770. this->TargetMatrix->SetColor(R,G,B,A);
  1771. }
  1772. }
  1773. //---------------------------------------------------------------------------
  1774. void __fastcall TConfigurationForm::FadeColorSelectionButtonClick(
  1775. TObject *Sender)
  1776. {
  1777. if(this->FadeColorDialog->Execute())
  1778. {
  1779. this->TrailColorPanel->Font->Color = this->FadeColorDialog->Color;
  1780. BYTE DummyR,DummyG,DummyB,A;
  1781. this->TargetMatrix->GetFadeColor(DummyR,DummyG,DummyB,A);
  1782. BYTE B = (BYTE)((this->FadeColorDialog->Color>>16) & 0xFF);
  1783. BYTE G = (BYTE)((this->FadeColorDialog->Color>>8) & 0xFF);
  1784. BYTE R = (BYTE)((this->FadeColorDialog->Color) & 0xFF);
  1785. this->TargetMatrix->SetFadeColor(R,G,B,A);
  1786. }
  1787. }
  1788. //---------------------------------------------------------------------------
  1789. void __fastcall TConfigurationForm::BackgroundColorSelectionButtonClick(
  1790. TObject *Sender)
  1791. {
  1792. if(this->BackgroundColorDialog->Execute())
  1793. {
  1794. this->LeadColorPanel->Color = this->BackgroundColorDialog->Color;
  1795. this->TrailColorPanel->Color = this->BackgroundColorDialog->Color;
  1796. this->SpecialLeadColorPanel->Color = this->BackgroundColorDialog->Color;
  1797. this->SpecialTrailColorPanel->Color = this->BackgroundColorDialog->Color;
  1798. BYTE DummyR,DummyG,DummyB,A;
  1799. this->TargetMatrix->GetBGColor(DummyR,DummyG,DummyB,A);
  1800. BYTE B = (BYTE)((this->BackgroundColorDialog->Color>>16) & 0xFF);
  1801. BYTE G = (BYTE)((this->BackgroundColorDialog->Color>>8) & 0xFF);
  1802. BYTE R = (BYTE)((this->BackgroundColorDialog->Color) & 0xFF);
  1803. this->TargetMatrix->SetBGColor(R,G,B,A);
  1804. this->TargetMatrix->SetSpecialStringBGColor(R,G,B,A);
  1805. }
  1806. }
  1807. //---------------------------------------------------------------------------
  1808. void __fastcall TConfigurationForm::SpecialForegroundColorSelectionButtonClick(
  1809. TObject *Sender)
  1810. {
  1811. if(this->SpecialForegroundColorDialog->Execute())
  1812. {
  1813. this->SpecialLeadColorPanel->Font->Color = this->SpecialForegroundColorDialog->Color;
  1814. BYTE DummyR,DummyG,DummyB,A;
  1815. this->TargetMatrix->GetSpecialStringColor(DummyR,DummyG,DummyB,A);
  1816. BYTE B = (BYTE)((this->SpecialForegroundColorDialog->Color>>16) & 0xFF);
  1817. BYTE G = (BYTE)((this->SpecialForegroundColorDialog->Color>>8) & 0xFF);
  1818. BYTE R = (BYTE)((this->SpecialForegroundColorDialog->Color) & 0xFF);
  1819. this->TargetMatrix->SetSpecialStringColor(R,G,B,A);
  1820. }
  1821. }
  1822. //---------------------------------------------------------------------------
  1823. void __fastcall TConfigurationForm::SpecialFadeColorSelectionButtonClick(
  1824. TObject *Sender)
  1825. {
  1826. if(this->SpecialFadeColorDialog->Execute())
  1827. {
  1828. this->SpecialTrailColorPanel->Font->Color = this->SpecialFadeColorDialog->Color;
  1829. BYTE DummyR,DummyG,DummyB,A;
  1830. this->TargetMatrix->GetSpecialStringFadeColor(DummyR,DummyG,DummyB,A);
  1831. BYTE B = (BYTE)((this->SpecialFadeColorDialog->Color>>16) & 0xFF);
  1832. BYTE G = (BYTE)((this->SpecialFadeColorDialog->Color>>8) & 0xFF);
  1833. BYTE R = (BYTE)((this->SpecialFadeColorDialog->Color) & 0xFF);
  1834. this->TargetMatrix->SetSpecialStringFadeColor(R,G,B,A);
  1835. }
  1836. }
  1837. //---------------------------------------------------------------------------
  1838. void __fastcall TConfigurationForm::ColorBGModeRadioButtonClick(
  1839. TObject *Sender)
  1840. {
  1841. this->TargetMatrix->SetBGMode(bgmodeColor);
  1842. this->DisableBlendingConfig();
  1843. }
  1844. //---------------------------------------------------------------------------
  1845. void __fastcall TConfigurationForm::BitmapBGModeRadioButtonClick(
  1846. TObject *Sender)
  1847. {
  1848. this->TargetMatrix->SetBGMode(bgmodeBitmap);
  1849. this->EnableBlendingConfig();
  1850. }
  1851. //---------------------------------------------------------------------------
  1852. void __fastcall TConfigurationForm::XORBGBlendModeRadioButtonClick(
  1853. TObject *Sender)
  1854. {
  1855. this->TargetMatrix->SetBlendMode(blendmodeXOR);
  1856. }
  1857. //---------------------------------------------------------------------------
  1858. void __fastcall TConfigurationForm::ORBGBlendModeRadioButtonClick(
  1859. TObject *Sender)
  1860. {
  1861. this->TargetMatrix->SetBlendMode(blendmodeOR);
  1862. }
  1863. //---------------------------------------------------------------------------
  1864. void __fastcall TConfigurationForm::ANDBGBlendModeRadioButtonClick(
  1865. TObject *Sender)
  1866. {
  1867. this->TargetMatrix->SetBlendMode(blendmodeAND);
  1868. }
  1869. //---------------------------------------------------------------------------
  1870. void __fastcall TConfigurationForm::TransparentBGRadioButtonClick(
  1871. TObject *Sender)
  1872. {
  1873. BYTE R,G,B,A;
  1874. this->TargetMatrix->GetBGColor(R,G,B,A);
  1875. this->TargetMatrix->SetBGColor(R,G,B,0);
  1876. }
  1877. //---------------------------------------------------------------------------
  1878. void __fastcall TConfigurationForm::OpaqueBGRadioButtonClick(
  1879. TObject *Sender)
  1880. {
  1881. BYTE R,G,B,A;
  1882. this->TargetMatrix->GetBGColor(R,G,B,A);
  1883. this->TargetMatrix->SetBGColor(R,G,B,255);
  1884. }
  1885. //---------------------------------------------------------------------------
  1886. void __fastcall TConfigurationForm::SpeedVarianceTrackBarChange(
  1887. TObject *Sender)
  1888. {
  1889. TargetMatrix->SetSpeedVariance(this->SpeedVarianceTrackBar->Position);
  1890. this->SpeedVarianceWidgetUpDown->Position = this->SpeedVarianceTrackBar->Position;
  1891. }
  1892. //---------------------------------------------------------------------------
  1893. void __fastcall TConfigurationForm::SpeedVarianceWidgetChange(
  1894. TObject *Sender)
  1895. {
  1896. if(this->SpeedVarianceWidgetUpDown->Position < this->SpeedVarianceTrackBar->Min)
  1897. this->SpeedVarianceWidgetUpDown->Position = this->SpeedVarianceTrackBar->Min;
  1898. if(this->SpeedVarianceWidgetUpDown->Position > this->SpeedVarianceTrackBar->Max)
  1899. this->SpeedVarianceWidgetUpDown->Position = this->SpeedVarianceTrackBar->Max;
  1900. //CLAMP(this->SpeedVarianceWidgetUpDown->Position,this->SpeedVarianceTrackBar->Min,this->SpeedVarianceTrackBar->Max);
  1901. TargetMatrix->SetSpeedVariance(this->SpeedVarianceWidgetUpDown->Position);
  1902. this->SpeedVarianceTrackBar->Position = this->SpeedVarianceWidgetUpDown->Position;
  1903. }
  1904. //---------------------------------------------------------------------------
  1905. void __fastcall TConfigurationForm::LeadingTrackBarChange(TObject *Sender)
  1906. {
  1907. TargetMatrix->SetLeading(this->LeadingTrackBar->Position);
  1908. this->LeadingWidgetUpDown->Position = this->LeadingTrackBar->Position;
  1909. }
  1910. //---------------------------------------------------------------------------
  1911. void __fastcall TConfigurationForm::LeadingWidgetChange(TObject *Sender)
  1912. {
  1913. if(this->LeadingWidgetUpDown->Position < this->LeadingTrackBar->Min)
  1914. this->LeadingWidgetUpDown->Position = this->LeadingTrackBar->Min;
  1915. if(this->LeadingWidgetUpDown->Position > this->LeadingTrackBar->Max)
  1916. this->LeadingWidgetUpDown->Position = this->LeadingTrackBar->Max;
  1917. //CLAMP(this->LeadingWidgetUpDown->Position,this->LeadingTrackBar->Min,this->LeadingTrackBar->Max);
  1918. TargetMatrix->SetLeading(this->LeadingWidgetUpDown->Position);
  1919. this->LeadingTrackBar->Position = this->LeadingWidgetUpDown->Position;
  1920. }
  1921. //---------------------------------------------------------------------------
  1922. void __fastcall TConfigurationForm::BackTraceTrackBarChange(
  1923. TObject *Sender)
  1924. {
  1925. TargetMatrix->SetBackTrace(this->BackTraceTrackBar->Position);
  1926. this->BackTraceWidgetUpDown->Position = this->BackTraceTrackBar->Position;
  1927. }
  1928. //---------------------------------------------------------------------------
  1929. void __fastcall TConfigurationForm::BackTraceWidgetChange(
  1930. TObject *Sender)
  1931. {
  1932. if(this->BackTraceWidgetUpDown->Position < this->BackTraceTrackBar->Min)
  1933. this->BackTraceWidgetUpDown->Position = this->BackTraceTrackBar->Min;
  1934. if(this->BackTraceWidgetUpDown->Position > this->BackTraceTrackBar->Max)
  1935. this->BackTraceWidgetUpDown->Position = this->BackTraceTrackBar->Max;
  1936. //CLAMP(this->BackTraceWidgetUpDown->Position,this->BackTraceTrackBar->Min,this->BackTraceTrackBar->Max);
  1937. TargetMatrix->SetBackTrace(this->BackTraceWidgetUpDown->Position);
  1938. this->BackTraceTrackBar->Position = this->BackTraceWidgetUpDown->Position;
  1939. }
  1940. //---------------------------------------------------------------------------
  1941. void __fastcall TConfigurationForm::SpacePadTrackBarChange(TObject *Sender)
  1942. {
  1943. TargetMatrix->SetSpacePad(this->SpacePadTrackBar->Position);
  1944. this->SpacePadWidgetUpDown->Position = this->SpacePadTrackBar->Position;
  1945. }
  1946. //---------------------------------------------------------------------------
  1947. void __fastcall TConfigurationForm::SpacePadWidgetChange(TObject *Sender)
  1948. {
  1949. if(this->SpacePadWidgetUpDown->Position < this->SpacePadTrackBar->Min)
  1950. this->SpacePadWidgetUpDown->Position = this->SpacePadTrackBar->Min;
  1951. if(this->SpacePadWidgetUpDown->Position > this->SpacePadTrackBar->Max)
  1952. this->SpacePadWidgetUpDown->Position = this->SpacePadTrackBar->Max;
  1953. //CLAMP(this->SpacePadWidgetUpDown->Position,this->SpacePadTrackBar->Min,this->SpacePadTrackBar->Max);
  1954. TargetMatrix->SetSpacePad(this->SpacePadWidgetUpDown->Position);
  1955. this->SpacePadTrackBar->Position = this->SpacePadWidgetUpDown->Position;
  1956. }
  1957. //---------------------------------------------------------------------------
  1958. void __fastcall TConfigurationForm::EditCharSetButtonClick(TObject *Sender)
  1959. {
  1960. CharacterSetForm->SetFormCharSet(this->TargetMatrix->GetValidCharSet(),
  1961. this->TargetMatrix->GetNumCharsInSet());
  1962. vector<tstring> SpecialStringVec;
  1963. SpecialStringVec.resize(this->TargetMatrix->GetNumSpecialStringsInSet());
  1964. unsigned int i = 0;
  1965. for(vector<tstring>::iterator iter = SpecialStringVec.begin();
  1966. iter != SpecialStringVec.end();
  1967. ++iter, ++i)
  1968. {
  1969. iter->assign(this->TargetMatrix->GetValidSpecialString(i));
  1970. }
  1971. CharacterSetForm->SetFormSpecialStrings(SpecialStringVec);
  1972. if(mrOk == CharacterSetForm->ShowModal())
  1973. {
  1974. const vector<_TCHAR> *CharSet = CharacterSetForm->GetFormCharSet();
  1975. if(CharSet->empty())
  1976. {
  1977. this->TargetMatrix->ClearValidCharSet();
  1978. }
  1979. else
  1980. {
  1981. const _TCHAR *CharSetPointer = &(CharSet->front());
  1982. this->TargetMatrix->SetValidCharSet(CharSetPointer,CharSet->size());
  1983. }
  1984. CharacterSetForm->GetFormSpecialStrings(SpecialStringVec);
  1985. if(SpecialStringVec.empty())
  1986. {
  1987. this->TargetMatrix->ClearValidSpecialStringSet();
  1988. }
  1989. else
  1990. {
  1991. unsigned int SpecialStringArraySize = SpecialStringVec.size();
  1992. const _TCHAR * /*const*/ *SpecialStringArray = new const _TCHAR *[SpecialStringArraySize];
  1993. for(i = 0; i < SpecialStringArraySize; i++)
  1994. {
  1995. SpecialStringArray[i] = SpecialStringVec[i].c_str();
  1996. }
  1997. this->TargetMatrix->SetValidSpecialStringSet(SpecialStringArray,SpecialStringArraySize);
  1998. delete[] SpecialStringArray;
  1999. }
  2000. }
  2001. }
  2002. //---------------------------------------------------------------------------
  2003. void __fastcall TConfigurationForm::ExitClick(TObject *Sender)
  2004. {
  2005. this->ModalResult = mrCancel;
  2006. }
  2007. //---------------------------------------------------------------------------
  2008. void __fastcall TConfigurationForm::SaveClick(TObject *Sender)
  2009. {
  2010. if(this->ConfigSaveDialog->Execute())
  2011. {
  2012. _TCHAR TargetFile[LONG_MAX_PATH];
  2013. #ifdef _UNICODE
  2014. snwprintf(TargetFile,LONG_MAX_PATH - 1,_TEXT("%S"),this->ConfigSaveDialog->FileName.c_str());
  2015. #else
  2016. snprintf(TargetFile,LONG_MAX_PATH - 1,"%s",this->ConfigSaveDialog->FileName.c_str());
  2017. #endif
  2018. SaveConfigToFile(this->TargetMatrix,*(this->TargetRefreshTime),GetPriorityClass(GetCurrentProcess()),TargetFile);
  2019. }
  2020. }
  2021. //---------------------------------------------------------------------------
  2022. void __fastcall TConfigurationForm::LoadClick(TObject *Sender)
  2023. {
  2024. if(this->ConfigOpenDialog->Execute())
  2025. {
  2026. _TCHAR TargetFile[LONG_MAX_PATH];
  2027. #ifdef _UNICODE
  2028. snwprintf(TargetFile,LONG_MAX_PATH - 1,_TEXT("%S"),this->ConfigOpenDialog->FileName.c_str());
  2029. #else
  2030. snprintf(TargetFile,LONG_MAX_PATH - 1,"%s",this->ConfigOpenDialog->FileName.c_str());
  2031. #endif
  2032. DWORD PriorityClass = IDLE_PRIORITY_CLASS;
  2033. LoadConfigFromFile(this->TargetMatrix,*(this->TargetRefreshTime),PriorityClass,TargetFile);
  2034. SetPriorityClass(GetCurrentProcess(),PriorityClass);
  2035. SetTimer(this->TargetMatrix->GethWnd(),REFRESH_TIMER_ID,*(this->TargetRefreshTime),NULL);
  2036. this->UpdateFormBasedOnTarget();
  2037. }
  2038. }
  2039. //---------------------------------------------------------------------------
  2040. void __fastcall TConfigurationForm::LoadDefaultsClick(TObject *Sender)
  2041. {
  2042. _TCHAR TargetFile[] = _T("./default.cfg");
  2043. DWORD PriorityClass = IDLE_PRIORITY_CLASS;
  2044. LoadConfigFromFile(this->TargetMatrix,*(this->TargetRefreshTime),PriorityClass,TargetFile);
  2045. SetPriorityClass(GetCurrentProcess(),PriorityClass);
  2046. SetTimer(this->TargetMatrix->GethWnd(),REFRESH_TIMER_ID,*(this->TargetRefreshTime),NULL);
  2047. this->UpdateFormBasedOnTarget();
  2048. }
  2049. //---------------------------------------------------------------------------
  2050. void __fastcall TConfigurationForm::AboutClick(TObject *Sender)
  2051. {
  2052. LaunchAboutForm(this);
  2053. }
  2054. //---------------------------------------------------------------------------
  2055. void __fastcall TConfigurationForm::ReadMeClick(TObject *Sender)
  2056. {
  2057. ShellExecute(this->Handle,_TEXT("open"),_TEXT("readme.txt"), NULL, NULL, SW_SHOWNORMAL );
  2058. //WinExec("notepad.exe readme.txt",SW_SHOW);
  2059. /* STARTUPINFO StartupInfo;
  2060. memset(&StartupInfo,0,sizeof(StartupInfo));
  2061. StartupInfo.cb = sizeof(StartupInfo);
  2062. PROCESS_INFORMATION ProcessInfo;
  2063. CreateProcess(NULL,_TEXT("start readme.txt"),NULL,NULL,FALSE,0,NULL,NULL,&StartupInfo,&ProcessInfo);
  2064. */
  2065. }
  2066. //---------------------------------------------------------------------------
  2067. void __fastcall TConfigurationForm::MonotonousCleanupEnabledCheckBoxClick(
  2068. TObject *Sender)
  2069. {
  2070. this->SetFormMonotonousCleanupEnabled(this->MonotonousCleanupEnabledCheckBox->Checked);
  2071. this->TargetMatrix->SetMonotonousCleanupEnabled(this->MonotonousCleanupEnabledCheckBox->Checked);
  2072. }
  2073. //---------------------------------------------------------------------------
  2074. void __fastcall TConfigurationForm::RandomizedCleanupEnabledCheckBoxClick(
  2075. TObject *Sender)
  2076. {
  2077. this->SetFormRandomizedCleanupEnabled(this->RandomizedCleanupEnabledCheckBox->Checked);
  2078. this->TargetMatrix->SetRandomizedCleanupEnabled(this->RandomizedCleanupEnabledCheckBox->Checked);
  2079. }
  2080. //---------------------------------------------------------------------------
  2081. void __fastcall TConfigurationForm::RefreshTimeTrackBarChange(
  2082. TObject *Sender)
  2083. {
  2084. *TargetRefreshTime = this->RefreshTimeTrackBar->Position;
  2085. SetTimer(this->TargetMatrix->GethWnd(),REFRESH_TIMER_ID,*TargetRefreshTime,0);
  2086. this->RefreshTimeWidgetUpDown->Position = this->RefreshTimeTrackBar->Position;
  2087. }
  2088. //---------------------------------------------------------------------------
  2089. void __fastcall TConfigurationForm::RefreshTimeWidgetChange(
  2090. TObject *Sender)
  2091. {
  2092. if(this->RefreshTimeWidgetUpDown->Position < this->RefreshTimeTrackBar->Min)
  2093. this->RefreshTimeWidgetUpDown->Position = this->RefreshTimeTrackBar->Min;
  2094. if(this->RefreshTimeWidgetUpDown->Position > this->RefreshTimeTrackBar->Max)
  2095. this->RefreshTimeWidgetUpDown->Position = this->RefreshTimeTrackBar->Max;
  2096. //CLAMP(this->RefreshTimeWidgetUpDown->Position,this->RefreshTimeTrackBar->Min,this->RefreshTimeTrackBar->Max);
  2097. *TargetRefreshTime = this->RefreshTimeWidgetUpDown->Position;
  2098. SetTimer(this->TargetMatrix->GethWnd(),REFRESH_TIMER_ID,*TargetRefreshTime,0);
  2099. this->RefreshTimeTrackBar->Position = this->RefreshTimeWidgetUpDown->Position;
  2100. }
  2101. //---------------------------------------------------------------------------
  2102. void __fastcall TConfigurationForm::SpecialStreamProbabilityTrackBarChange(
  2103. TObject *Sender)
  2104. {
  2105. TargetMatrix->SetSpecialStringStreamProbability(this->SpecialStreamProbabilityTrackBar->Position/100.0);
  2106. this->SpecialStreamProbabilityWidgetUpDown->Position = this->SpecialStreamProbabilityTrackBar->Position;
  2107. }
  2108. //---------------------------------------------------------------------------
  2109. void __fastcall TConfigurationForm::SpecialStreamProbabilityWidgetChange(
  2110. TObject *Sender)
  2111. {
  2112. if(this->SpecialStreamProbabilityWidgetUpDown->Position < this->SpecialStreamProbabilityTrackBar->Min)
  2113. this->SpecialStreamProbabilityWidgetUpDown->Position = this->SpecialStreamProbabilityTrackBar->Min;
  2114. if(this->SpecialStreamProbabilityWidgetUpDown->Position > this->SpecialStreamProbabilityTrackBar->Max)
  2115. this->SpecialStreamProbabilityWidgetUpDown->Position = this->SpecialStreamProbabilityTrackBar->Max;
  2116. //CLAMP(this->SpeedVarianceWidgetUpDown->Position,this->SpeedVarianceTrackBar->Min,this->SpeedVarianceTrackBar->Max);
  2117. TargetMatrix->SetSpecialStringStreamProbability(this->SpecialStreamProbabilityWidgetUpDown->Position/100.0);
  2118. this->SpecialStreamProbabilityTrackBar->Position = this->SpecialStreamProbabilityWidgetUpDown->Position;
  2119. }
  2120. //---------------------------------------------------------------------------
  2121. void __fastcall TConfigurationForm::HighPriorityRadioButtonClick(
  2122. TObject *Sender)
  2123. {
  2124. *(this->TargetPriority) = HIGH_PRIORITY_CLASS;
  2125. SetPriorityClass(GetCurrentProcess(),*(this->TargetPriority));
  2126. }
  2127. //---------------------------------------------------------------------------
  2128. void __fastcall TConfigurationForm::AboveNormalPriorityRadioButtonClick(
  2129. TObject *Sender)
  2130. {
  2131. *(this->TargetPriority) = ABOVE_NORMAL_PRIORITY_CLASS;
  2132. SetPriorityClass(GetCurrentProcess(),*(this->TargetPriority));
  2133. }
  2134. //---------------------------------------------------------------------------
  2135. void __fastcall TConfigurationForm::NormalPriorityRadioButtonClick(
  2136. TObject *Sender)
  2137. {
  2138. *(this->TargetPriority) = NORMAL_PRIORITY_CLASS;
  2139. SetPriorityClass(GetCurrentProcess(),*(this->TargetPriority));
  2140. }
  2141. //---------------------------------------------------------------------------
  2142. void __fastcall TConfigurationForm::BelowNormalPriorityRadioButtonClick(
  2143. TObject *Sender)
  2144. {
  2145. *(this->TargetPriority) = BELOW_NORMAL_PRIORITY_CLASS;
  2146. SetPriorityClass(GetCurrentProcess(),*(this->TargetPriority));
  2147. }
  2148. //---------------------------------------------------------------------------
  2149. void __fastcall TConfigurationForm::IdlePriorityRadioButtonClick(
  2150. TObject *Sender)
  2151. {
  2152. *(this->TargetPriority) = IDLE_PRIORITY_CLASS;
  2153. SetPriorityClass(GetCurrentProcess(),*(this->TargetPriority));
  2154. }
  2155. //---------------------------------------------------------------------------
  2156. void __fastcall TConfigurationForm::HomepageClick(TObject *Sender)
  2157. {
  2158. this->LaunchURL(HOMEPAGE_URL);
  2159. }
  2160. //---------------------------------------------------------------------------
  2161. void __fastcall TConfigurationForm::ProjectSummaryPageClick(
  2162. TObject *Sender)
  2163. {
  2164. this->LaunchURL(PROJECTSUMMARYPAGE_URL);
  2165. }
  2166. //---------------------------------------------------------------------------
  2167. void __fastcall TConfigurationForm::SupportRequestsClick(TObject *Sender)
  2168. {
  2169. this->LaunchURL(SUPPORTREQUESTS_URL);
  2170. }
  2171. //---------------------------------------------------------------------------
  2172. void __fastcall TConfigurationForm::BugReportsClick(TObject *Sender)
  2173. {
  2174. this->LaunchURL(BUGREPORTS_URL);
  2175. }
  2176. //---------------------------------------------------------------------------
  2177. void __fastcall TConfigurationForm::FeatureRequestsClick(TObject *Sender)
  2178. {
  2179. this->LaunchURL(FEATUREREQUESTS_URL);
  2180. }
  2181. //---------------------------------------------------------------------------
  2182. void __fastcall TConfigurationForm::DiscussionForumsClick(TObject *Sender)
  2183. {
  2184. this->LaunchURL(DISCUSSIONFORUMS_URL);
  2185. }
  2186. //---------------------------------------------------------------------------
  2187. void __fastcall TConfigurationForm::DonateClick(TObject *Sender)
  2188. {
  2189. this->LaunchURL(DONATE_URL);
  2190. }
  2191. //---------------------------------------------------------------------------
  2192. void __fastcall TConfigurationForm::LaunchHelpClick(TObject *Sender)
  2193. {
  2194. ShellExecute(this->Handle,_TEXT("open"),_TEXT("ZMatrixHelp.chm"), NULL, NULL, SW_SHOWNORMAL );
  2195. }
  2196. //---------------------------------------------------------------------------
  2197. void __fastcall TConfigurationForm::HireTheDeveloperClick(TObject *Sender)
  2198. {
  2199. LaunchHireForm(this);
  2200. }
  2201. //---------------------------------------------------------------------------
  2202. void __fastcall TConfigurationForm::SpecialColorsCopyButtonClick(
  2203. TObject *Sender)
  2204. {
  2205. BYTE DummyR,DummyG,DummyB,A;
  2206. BYTE R,G,B;
  2207. this->TargetMatrix->GetColor(R,G,B,A);
  2208. this->SpecialForegroundColorDialog->Color = (TColor)RGB(R,G,B);
  2209. this->TargetMatrix->GetFadeColor(R,G,B,A);
  2210. this->SpecialFadeColorDialog->Color = (TColor)RGB(R,G,B);
  2211. this->SpecialLeadColorPanel->Font->Color = this->SpecialForegroundColorDialog->Color;
  2212. this->TargetMatrix->GetSpecialStringColor(DummyR,DummyG,DummyB,A);
  2213. B = (BYTE)((this->SpecialForegroundColorDialog->Color>>16) & 0xFF);
  2214. G = (BYTE)((this->SpecialForegroundColorDialog->Color>>8) & 0xFF);
  2215. R = (BYTE)((this->SpecialForegroundColorDialog->Color) & 0xFF);
  2216. this->TargetMatrix->SetSpecialStringColor(R,G,B,A);
  2217. this->SpecialTrailColorPanel->Font->Color = this->SpecialFadeColorDialog->Color;
  2218. this->TargetMatrix->GetSpecialStringFadeColor(DummyR,DummyG,DummyB,A);
  2219. B = (BYTE)((this->SpecialFadeColorDialog->Color>>16) & 0xFF);
  2220. G = (BYTE)((this->SpecialFadeColorDialog->Color>>8) & 0xFF);
  2221. R = (BYTE)((this->SpecialFadeColorDialog->Color) & 0xFF);
  2222. this->TargetMatrix->SetSpecialStringFadeColor(R,G,B,A);
  2223. }
  2224. //---------------------------------------------------------------------------