Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1482 lines
37 KiB

  1. /**************************************************/
  2. /* */
  3. /* */
  4. /* Character List( Referrence Dialog) */
  5. /* */
  6. /* */
  7. /* */
  8. /* Copyright (c) 1997-1999 Microsoft Corporation. */
  9. /**************************************************/
  10. #include "stdafx.h"
  11. #include "eudcedit.h"
  12. #include "refrlist.h"
  13. #include "util.h"
  14. #define STRSAFE_LIB
  15. #include <strsafe.h>
  16. // 6 * 16 Matrics
  17. #define NUM_CHAR 16
  18. #define NUM_LINE 6
  19. // Type of Character Code
  20. #define CHAR_INIT 0 // Initial value
  21. #define CHAR_SBCS 1 // SBCS
  22. #define CHAR_DBCS1 2 // DBCS1
  23. #define CHAR_DBCS2 3 // DBCS2
  24. #define CHAR_EUDC 4 // EUDC
  25. #define CHAR_ETC 5 // Other
  26. #ifdef _DEBUG
  27. #undef THIS_FILE
  28. static char BASED_CODE THIS_FILE[] = __FILE__;
  29. #endif
  30. IMPLEMENT_DYNCREATE( CRefrList, CEdit)
  31. BEGIN_MESSAGE_MAP( CRefrList, CEdit)
  32. //{{AFX_MSG_MAP( CRefrList)
  33. ON_WM_PAINT()
  34. ON_WM_VSCROLL()
  35. ON_WM_LBUTTONDOWN()
  36. ON_WM_LBUTTONDBLCLK()
  37. ON_WM_SETCURSOR()
  38. ON_WM_KEYDOWN()
  39. ON_WM_SETFOCUS()
  40. ON_WM_KILLFOCUS()
  41. ON_WM_RBUTTONUP()
  42. //}}AFX_MSG_MAP
  43. END_MESSAGE_MAP()
  44. // Range of character code( high byte)
  45. static WORD HiByteRange[][10] =
  46. {
  47. // JPN CHT KRW CHS OTHER
  48. { 0x00a0, 0xfca0, 0x00a0, 0xfea0, 0x00a0, 0xfea0, 0x00a0, 0xfea0, 0x00a0, 0x00a0}, // CHAR_INIT
  49. { 0x0020, 0x00ff, 0x0020, 0x00ff, 0x0020, 0x00ff, 0x0020, 0x00ff, 0x0020, 0x00ff}, // CHAR_SBCS
  50. { 0x8140, 0x9fff, 0x8140, 0xa0ff, 0x8140, 0x8fff, 0x8140, 0xafff, 0x0020, 0x00ff}, // CHAR_DBCS1
  51. { 0xe040, 0xeaff, 0xa140, 0xf9ff, 0x9040, 0x9fff, 0xb040, 0xf7ff, 0x0020, 0x00ff}, // CHAR_DBCS2
  52. { 0xf040, 0xfcff, 0xfa40, 0xfeff, 0xa040, 0xfeff, 0xf840, 0xfeff, 0x0020, 0x00ff}, // CHAR_EUDC
  53. };
  54. // Range of character code( low byte)
  55. static WORD LoByteRange[][10] =
  56. {
  57. { 0x0020, 0x00ff, 0x0020, 0x00ff, 0x0020, 0x00ff, 0x0020, 0x00ff, 0x0020, 0x00ff },
  58. { 0x0040, 0x007e, 0x0040, 0x007e, 0x0041, 0x005a, 0x0040, 0x007e, 0x0040, 0x007e },
  59. { 0x0080, 0x00fc, 0x0080, 0x00fe, 0x0061, 0x007a, 0x0080, 0x00fe, 0x0040, 0x007e },
  60. { 0x0080, 0x00fc, 0x0080, 0x00fe, 0x0081, 0x00fe, 0x0080, 0x00fe, 0x0040, 0x007e },
  61. { 0x0000, 0x003f, 0x0000, 0x003f, 0x0000, 0x003f, 0x0000, 0x003f, 0x0040, 0x007e },
  62. };
  63. extern LOGFONT ReffLogFont;
  64. extern LOGFONT EditLogFont;
  65. extern BOOL TitleFlag;
  66. extern BOOL CodeFocus;
  67. extern BOOL CharFocus;
  68. static CRect rcReferChar[NUM_LINE][NUM_CHAR];
  69. static CRect rcReferCode[NUM_LINE];
  70. /****************************************/
  71. /* */
  72. /* Default Constructor */
  73. /* */
  74. /****************************************/
  75. CRefrList::CRefrList()
  76. {
  77. /*
  78. // Initialize static parameter
  79. if( CountryInfo.LangID == EUDC_CHT)
  80. CHN = 2;
  81. else if( CountryInfo.LangID == EUDC_JPN)
  82. CHN = 0;
  83. else if( CountryInfo.LangID == EUDC_KRW)
  84. CHN = 4;
  85. else if( CountryInfo.LangID == EUDC_CHS)
  86. CHN = 6;
  87. else CHN = 8;
  88. */
  89. FocusFlag = FALSE;
  90. }
  91. /****************************************/
  92. /* */
  93. /* Destructor( Virtual) */
  94. /* */
  95. /****************************************/
  96. CRefrList::~CRefrList()
  97. {
  98. SysFFont.DeleteObject();
  99. CharFont.DeleteObject();
  100. ViewFont.DeleteObject();
  101. }
  102. /****************************************/
  103. /* */
  104. /* Set intitial code range */
  105. /* */
  106. /****************************************/
  107. void
  108. CRefrList::SetCodeRange()
  109. {
  110. CHARSETINFO CharsetInfo;
  111. BYTE CharSet;
  112. SelectCode = 0x0020;
  113. ScrlBarPos = 0;
  114. StartCode = 0x0020;
  115. EndCode = 0xffff;
  116. ViewStart = 0x0020;
  117. ViewEnd = 0xffa0;
  118. /*
  119. SelectCode = HiByteRange[CHAR_SBCS][CHN];
  120. ScrlBarPos = 0;
  121. StartCode = HiByteRange[CHAR_SBCS][CHN];
  122. ViewStart = HiByteRange[CHAR_SBCS][CHN];
  123. if( !TitleFlag){
  124. if( rLogFont.lfCharSet == CountryInfo.CharacterSet){
  125. // Correspond to DBCS
  126. ViewEnd = HiByteRange[CHAR_INIT][CHN+1];
  127. EndCode = HiByteRange[CHAR_EUDC][CHN+1];
  128. }else{
  129. // Correspond to SBCS
  130. ViewEnd = HiByteRange[CHAR_INIT][CHN];
  131. EndCode = HiByteRange[CHAR_SBCS][CHN+1];
  132. }
  133. CharSet = rLogFont.lfCharSet;
  134. }else{
  135. if( cLogFont.lfCharSet == CountryInfo.CharacterSet){
  136. ViewEnd = HiByteRange[CHAR_INIT][CHN+1];
  137. EndCode = HiByteRange[CHAR_EUDC][CHN+1];
  138. }else{
  139. ViewEnd = HiByteRange[CHAR_INIT][CHN];
  140. EndCode = HiByteRange[CHAR_SBCS][CHN+1];
  141. }
  142. CharSet = cLogFont.lfCharSet;
  143. }
  144. if(CharSet == SYMBOL_CHARSET)
  145. {
  146. dwCodePage = 1252;
  147. }
  148. else if(TranslateCharsetInfo((DWORD *)CharSet,&CharsetInfo,TCI_SRCCHARSET))
  149. {
  150. dwCodePage = CharsetInfo.ciACP;
  151. }
  152. else
  153. {
  154. dwCodePage = CP_ACP;
  155. }
  156. */
  157. }
  158. /****************************************/
  159. /* */
  160. /* Check type of character code */
  161. /* */
  162. /****************************************/
  163. int
  164. CRefrList::CheckCharType(
  165. WORD Code)
  166. {
  167. /*
  168. if( !( Code & 0xff00))
  169. return CHAR_SBCS;
  170. else if(( Code >= HiByteRange[CHAR_DBCS1][CHN]) &&
  171. ( Code <= HiByteRange[CHAR_DBCS1][CHN+1]))
  172. return CHAR_DBCS1;
  173. else if(( Code >= HiByteRange[CHAR_DBCS2][CHN]) &&
  174. ( Code <= HiByteRange[CHAR_DBCS2][CHN+1]))
  175. return CHAR_DBCS2;
  176. else if(( Code >= HiByteRange[CHAR_EUDC][CHN]) &&
  177. ( Code <= HiByteRange[CHAR_EUDC][CHN+1]))
  178. return CHAR_EUDC;
  179. else return CHAR_ETC;
  180. */
  181. return 0;
  182. }
  183. /****************************************/
  184. /* */
  185. /* Increase character code */
  186. /* */
  187. /****************************************/
  188. WORD
  189. CRefrList::GetPlusCode(
  190. WORD Code,
  191. int ScrollNum)
  192. {
  193. WORD PrevCode;
  194. WORD LowByte, HighByte;
  195. int CharType;
  196. int CharType1, CharType2;
  197. int Offset;
  198. Code += (WORD)ScrollNum;
  199. /*
  200. PrevCode = (WORD)(Code - (WORD)ScrollNum);
  201. CharType1 = CheckCharType( PrevCode);
  202. CharType2 = CheckCharType( Code);
  203. if( CharType1 != CharType2){
  204. if( CharType1 == CHAR_EUDC)
  205. Code = PrevCode;
  206. else{
  207. Offset = Code - HiByteRange[CharType1][CHN+1];
  208. Code = (WORD)( HiByteRange[CharType1+1][CHN] +Offset-1);
  209. }
  210. }
  211. CharType = CheckCharType( Code);
  212. if( CharType != CHAR_SBCS){
  213. LowByte = Code & 0x00ff;
  214. HighByte = Code & 0xff00;
  215. if( LowByte <= LoByteRange[4][CHN+1] &&
  216. LowByte >= LoByteRange[4][CHN] ){
  217. #if 0
  218. if( CountryInfo.LangID == EUDC_CHS)
  219. LowByte = 0x00a0;
  220. else LowByte = 0x0040;
  221. #endif
  222. LowByte = 0x0040;
  223. }
  224. Code = ( HighByte | LowByte);
  225. }
  226. */
  227. return Code;
  228. }
  229. /****************************************/
  230. /* */
  231. /* Decrease Character Code */
  232. /* */
  233. /****************************************/
  234. WORD
  235. CRefrList::GetMinusCode(
  236. WORD Code,
  237. int ScrollNum)
  238. {
  239. WORD PrevCode;
  240. int CharType;
  241. int CharType1, CharType2;
  242. int Offset;
  243. Code -= (WORD)ScrollNum;
  244. /*
  245. PrevCode = (WORD)( Code + (WORD)ScrollNum);
  246. CharType1 = CheckCharType( Code);
  247. CharType2 = CheckCharType( PrevCode);
  248. if( CharType1 != CharType2){
  249. if( CharType2 == CHAR_SBCS)
  250. return (WORD)HiByteRange[CHAR_SBCS][CHN];
  251. else{
  252. Offset = HiByteRange[CharType2][CHN] - Code;
  253. return (WORD)(HiByteRange[CharType2-1][CHN+1]-Offset+1);
  254. }
  255. }
  256. CharType = CheckCharType( Code);
  257. if( CharType != CHAR_SBCS){
  258. WORD LowByte;
  259. WORD HighByte;
  260. WORD Tmp;
  261. LowByte = Code & 0x00ff;
  262. HighByte = Code & 0xff00;
  263. if( LowByte <= LoByteRange[4][CHN+1] &&
  264. LowByte >= LoByteRange[4][CHN] ){
  265. LowByte = 0xf0;
  266. Tmp = ( HighByte >> 8);
  267. Tmp -= 0x1;
  268. HighByte = Tmp << 8;
  269. }
  270. Code = ( HighByte | LowByte);
  271. }
  272. */
  273. return Code;
  274. }
  275. /****************************************/
  276. /* */
  277. /* Calculate scroll position */
  278. /* */
  279. /****************************************/
  280. int
  281. CRefrList::GetBarPosition(
  282. WORD Code)
  283. {
  284. short i, StartType, EndType;
  285. int Pos = 0;
  286. Pos = (Code - StartCode) /NUM_CHAR;
  287. return Pos;
  288. /*
  289. StartType = CheckCharType( StartCode);
  290. EndType = CheckCharType( Code);
  291. if( EndType == CHAR_SBCS){
  292. Pos = ( Code - HiByteRange[CHAR_SBCS][CHN]) /NUM_CHAR;
  293. return Pos;
  294. }
  295. for (i = StartType; i < EndType; i++){
  296. if( i == CHAR_SBCS){
  297. Pos += (HiByteRange[CHAR_SBCS][CHN+1]
  298. - HiByteRange[CHAR_SBCS][CHN] + 1) / NUM_CHAR;
  299. }else{
  300. Pos += CalculateCode( HiByteRange[i][CHN],
  301. HiByteRange[i][CHN+1]) / NUM_CHAR;
  302. }
  303. }
  304. Pos += CalculateCode( HiByteRange[i][CHN], Code) / NUM_CHAR;
  305. return Pos;
  306. */
  307. }
  308. /****************************************/
  309. /* */
  310. /* Calculate character code */
  311. /* */
  312. /****************************************/
  313. WORD
  314. CRefrList::CalculateCode(
  315. WORD Start,
  316. WORD End)
  317. {
  318. WORD PageNum = 0;
  319. WORD CodeNum = 0;
  320. if ( Start >= End )
  321. return 0;
  322. PageNum = HIBYTE(End) - HIBYTE(Start);
  323. #if 0
  324. if( CountryInfo.LangID == EUDC_CHS){
  325. if( HIBYTE(End)){
  326. WORD LoCode;
  327. WORD HiCode;
  328. HiCode = End & 0xff00;
  329. LoCode = End & 0x00ff;
  330. if( LoCode < 0xa0)
  331. LoCode = 0xa0;
  332. End = HiCode | LoCode;
  333. }
  334. CodeNum = End - Start - PageNum * 0x00a0;
  335. }else CodeNum = End - Start - PageNum * 0x0040;
  336. #endif
  337. CodeNum = End - Start - PageNum * 0x0040;
  338. return CodeNum;
  339. }
  340. /****************************************/
  341. /* */
  342. /* Calculate code from scroll pos */
  343. /* */
  344. /****************************************/
  345. WORD
  346. CRefrList::GetCodeScrPos(
  347. int Pos)
  348. {
  349. short i, StartType, EndType;
  350. WORD Code = 0;
  351. WORD NumLine = 0, PNumLine = 0;
  352. if (Pos == 0)
  353. return StartCode;
  354. if (Pos >= BottomCode)
  355. return ViewEnd;
  356. Code = StartCode + Pos * NUM_CHAR;
  357. Code &= 0xfff0;
  358. return Code;
  359. /*
  360. if( !Pos)
  361. return HiByteRange[1][CHN];
  362. if( Pos >= BottomCode)
  363. return ViewEnd;
  364. StartType = CheckCharType( HiByteRange[1][CHN]);
  365. EndType = CheckCharType( HiByteRange[4][CHN+1]);
  366. for( i = StartType; i <= EndType; ++i){
  367. if( i == CHAR_SBCS )
  368. NumLine += (HiByteRange[i][CHN+1] - HiByteRange[i][CHN] + 1) /NUM_CHAR;
  369. else
  370. NumLine += CalculateCode( HiByteRange[i][CHN],HiByteRange[i][CHN+1])/NUM_CHAR;
  371. if( NumLine > Pos){
  372. NumLine = PNumLine;
  373. break;
  374. }
  375. PNumLine = NumLine;
  376. }
  377. Code = HiByteRange[i][CHN];
  378. Pos -= NumLine;
  379. while( Code < HiByteRange[i][CHN+1]){
  380. NumLine = CalculateCode( HiByteRange[i][CHN], Code) /NUM_CHAR;
  381. if( Pos <= NumLine){
  382. break;
  383. }
  384. Code += NUM_CHAR;
  385. }
  386. Code &= 0xfff0;
  387. return Code;
  388. */
  389. }
  390. /****************************************/
  391. /* */
  392. /* Jump view if editbox get focus */
  393. /* */
  394. /****************************************/
  395. BOOL
  396. CRefrList::CodeButtonClicked()
  397. {
  398. WCHAR CodeValue[15] = {0};
  399. WCHAR CharValue[15] = {0};
  400. WORD Code1, Code2;
  401. Code1 = (WORD)0;
  402. Code2 = (WORD)0;
  403. #ifdef UNICODE
  404. ::GetDlgItemTextW(GetParent()->GetSafeHwnd(), IDC_EDITCODE, CodeValue, 15);
  405. ::GetDlgItemTextW(GetParent()->GetSafeHwnd(), IDC_EDITCHAR, CharValue, 15);
  406. #else
  407. CHAR CodeValueA[15];
  408. CHAR CharValueA[15];
  409. ::GetDlgItemText(GetParent()->GetSafeHwnd(), IDC_EDITCODE, CodeValueA, 15);
  410. int nchar = ::GetDlgItemText(GetParent()->GetSafeHwnd(), IDC_EDITCHAR, CharValueA, 15);
  411. MultiByteToWideChar(CP_ACP, 0, CodeValueA, 4, CodeValue, sizeof(CodeValue)/sizeof(CodeValue[0]));
  412. MultiByteToWideChar(CP_ACP, 0, CharValueA, nchar, CharValue, sizeof(CharValue)/sizeof(CharValue[0]));
  413. #endif
  414. /* ::GetDlgItemTextA( GetParent()->GetSafeHwnd(),IDC_EDITCHAR, CharValue, 15); */
  415. if( CodeValue[0] == '\0' && CharValue[0] == '\0')
  416. return TRUE;
  417. if( CodeValue[0] == '\0')
  418. Code2 = 0xffff;
  419. else Code2 = (WORD)wcstol((LPWSTR)CodeValue, (WCHAR **)0, 16);
  420. if( CharValue[0] == '\0')
  421. Code1 = 0xffff;
  422. else
  423. Code1 = CharValue[0];
  424. if( CodeFocus){
  425. if( !IsCheckedCode( Code2))
  426. goto Error;
  427. SelectCode = Code2;
  428. }
  429. if( CharFocus){
  430. if( !IsCheckedCode( Code1))
  431. goto Error;
  432. SelectCode = Code1;
  433. }
  434. if( SelectCode >= ViewEnd)
  435. ViewStart = ViewEnd;
  436. else ViewStart = SelectCode & 0xfff0;
  437. BottomCode = (WORD)GetBarPosition((WORD)ViewEnd);
  438. this->SetScrollRange( SB_VERT, 0, BottomCode, FALSE);
  439. ScrlBarPos = (short)GetBarPosition( ViewStart);
  440. this->SetScrollPos( SB_VERT, ScrlBarPos, TRUE);
  441. this->InvalidateRect( &CodeListRect, TRUE);
  442. this->UpdateWindow();
  443. return TRUE;
  444. Error:
  445. return FALSE;
  446. }
  447. /****************************************/
  448. /* */
  449. /* Check Character Code Range */
  450. /* */
  451. /****************************************/
  452. BOOL
  453. CRefrList::IsCheckedCode(
  454. WORD CodeStock)
  455. {
  456. WORD Offset;
  457. int CharType;
  458. int CharType1;
  459. /*
  460. if(( CharType = CheckCharType( CodeStock)) == CHAR_ETC)
  461. return FALSE;
  462. CharType1 = CheckCharType( ViewEnd);
  463. Offset = CodeStock & 0x00ff;
  464. if( CharType == CHAR_SBCS){
  465. if( Offset < LoByteRange[0][CHN])
  466. return FALSE;
  467. }else{
  468. if( CharType1 == CHAR_SBCS)
  469. return FALSE;
  470. if( Offset >= LoByteRange[4][CHN] &&
  471. Offset <= LoByteRange[4][CHN+1] )
  472. return FALSE;
  473. if(( Offset >= LoByteRange[1][CHN] &&
  474. Offset <= LoByteRange[1][CHN+1]) ||
  475. ( Offset >= LoByteRange[2][CHN] &&
  476. Offset <= LoByteRange[2][CHN+1]) ||
  477. ( Offset >= LoByteRange[3][CHN] &&
  478. Offset <= LoByteRange[3][CHN+1])){
  479. ;
  480. }else return FALSE;
  481. }
  482. */
  483. return TRUE;
  484. }
  485. #define FIX_SPACE 6
  486. #define LINEWIDTH 4
  487. /****************************************/
  488. /* *
  489. /* Calcurate character size */
  490. /* */
  491. /****************************************/
  492. void
  493. CRefrList::CalcCharSize()
  494. {
  495. char Dummy[] = "FA40";
  496. int Sx;
  497. CClientDC dc( this);
  498. this->GetClientRect( &CodeListRect);
  499. CFont *OldFont = dc.SelectObject( &SysFFont);
  500. GetTextExtentPoint32A( dc.GetSafeHdc(), Dummy, 4, &FixSize);
  501. FixSize.cx += FIX_SPACE;
  502. dc.SelectObject( OldFont);
  503. CharSize.cy = ( CodeListRect.Height()
  504. - ((NUM_LINE-1)*LINEWIDTH) - 2) /NUM_LINE;
  505. CharSize.cx = ( CodeListRect.Width()
  506. - FixSize.cx - 2 - (NUM_CHAR*LINEWIDTH)) / NUM_CHAR;
  507. for( int i = 0; i < NUM_LINE; i++){
  508. rcReferCode[i].left = 1;
  509. rcReferCode[i].top = 1 + i*(CharSize.cy + LINEWIDTH);
  510. rcReferCode[i].right = rcReferCode[i].left + FixSize.cx;
  511. rcReferCode[i].bottom = rcReferCode[i].top + CharSize.cy;
  512. Sx = rcReferCode[i].right + LINEWIDTH;
  513. for( int j = 0; j < NUM_CHAR; j++){
  514. rcReferChar[i][j].left = Sx + j*( CharSize.cx
  515. + LINEWIDTH);
  516. rcReferChar[i][j].top = rcReferCode[i].top;
  517. rcReferChar[i][j].right = rcReferChar[i][j].left
  518. + CharSize.cx;
  519. rcReferChar[i][j].bottom = rcReferChar[i][j].top
  520. + CharSize.cy;
  521. }
  522. }
  523. }
  524. /****************************************/
  525. /* */
  526. /* MESSAGE "WM_PAINT" */
  527. /* */
  528. /****************************************/
  529. void
  530. CRefrList::OnPaint()
  531. {
  532. register int i, j;
  533. WORD Code;
  534. HRESULT hresult;
  535. CPaintDC dc( this);
  536. int BottomCode = GetBarPosition((WORD)ViewEnd);
  537. this->SetScrollRange( SB_VERT, 0, BottomCode, FALSE);
  538. this->SetScrollPos( SB_VERT, ScrlBarPos, TRUE);
  539. // Initialize character code
  540. Code = ViewStart;
  541. // Change Mapping mode
  542. int OldMode = dc.SetMapMode(MM_TEXT);
  543. dc.SetViewportOrg( 0, 0);
  544. CFont *OldFont = dc.SelectObject( &SysFFont);
  545. for( i = 0; i < NUM_LINE; i++){
  546. int xOffset, yOffset;
  547. TCHAR Work[5];
  548. int wLength, CharType;
  549. // Draw character code on character list to display
  550. dc.SelectObject( &SysFFont);
  551. //*STRSAFE* wsprintf(Work, _T("%04X"), Code);
  552. hresult = StringCchPrintf(Work , ARRAYLEN(Work), _T("%04X"), Code);
  553. if (!SUCCEEDED(hresult))
  554. {
  555. return ;
  556. }
  557. dc.SetBkColor( COLOR_FACE);
  558. dc.SetTextColor(GetSysColor(COLOR_WINDOWTEXT)); //COLOR_BLACK);
  559. if( rcReferCode[i].Height() > FixSize.cy){
  560. yOffset = (rcReferCode[i].Height() - FixSize.cy) /2;
  561. }else yOffset = 0;
  562. ::ExtTextOut(dc, rcReferCode[i].left + FIX_SPACE/2,
  563. rcReferCode[i].top + yOffset,
  564. ETO_OPAQUE, &rcReferCode[i],
  565. (TCHAR *)Work, 4, NULL);
  566. dc.SelectObject( &CharFont);
  567. for( j = 0; j < NUM_CHAR; j++ , Code = GetPlusCode( Code, 1)){
  568. WORD Offset;
  569. CSize cSize;
  570. WCHAR Work1[5];
  571. Work1[0] = Code;
  572. Work1[1] = 0;
  573. wLength = 1;
  574. /*
  575. if(( CharType = CheckCharType( Code)) == CHAR_SBCS){
  576. Work[0] = LOBYTE(Code);
  577. wLength = 1;
  578. }else if( CharType == CHAR_DBCS1 ||
  579. CharType == CHAR_DBCS2 ||
  580. CharType == CHAR_EUDC ){
  581. Offset = Code & 0x00ff;
  582. if(( Offset <= LoByteRange[1][CHN+1] &&
  583. Offset >= LoByteRange[1][CHN]) ||
  584. ( Offset <= LoByteRange[2][CHN+1] &&
  585. Offset >= LoByteRange[2][CHN]) ||
  586. ( Offset <= LoByteRange[3][CHN+1] &&
  587. Offset >= LoByteRange[3][CHN]) ){
  588. Work[0] = (BYTE)((Code>>8) & 0x00ff);
  589. Work[1] = (BYTE) (Code & 0x00ff);
  590. wLength = 2;
  591. }else{
  592. continue;
  593. }
  594. }else wLength = 0;
  595. Work[wLength] = (BYTE)'\0';
  596. #ifdef UNICODE
  597. WCHAR wszCodeTemp[2];
  598. wLength = MultiByteToWideChar(dwCodePage,
  599. 0,
  600. (LPSTR) Work,
  601. wLength,
  602. wszCodeTemp,
  603. 1);
  604. Work[0] = LOBYTE(wszCodeTemp[0]);
  605. Work[1] = HIBYTE(wszCodeTemp[0]);
  606. Work[2] = '\0';
  607. #endif
  608. */
  609. BOOL PtIn;
  610. if( rcReferChar[i][j].PtInRect( LButtonPt) ||
  611. SelectCode == Code){
  612. TCHAR CodeNum[10];
  613. // If character is selected by clickking
  614. // left button, draw it on dialog
  615. PtIn = TRUE;
  616. SelectCode = Code;
  617. dc.SetBkColor( COLOR_FACE);
  618. dc.SetTextColor(GetSysColor(COLOR_WINDOWTEXT)); // COLOR_BLACK);
  619. //*STRSAFE* wsprintf((TCHAR *)CodeNum, _T("%04X"), Code);
  620. hresult = StringCchPrintf((TCHAR *)CodeNum , ARRAYLEN(CodeNum), _T("%04X"), Code);
  621. if (!SUCCEEDED(hresult))
  622. {
  623. return ;
  624. }
  625. if (!CodeFocus)
  626. {
  627. ::SetDlgItemText(GetParent()->GetSafeHwnd(), IDC_EDITCODE, (LPCTSTR)CodeNum);
  628. }
  629. if (!CharFocus)
  630. {
  631. #ifdef UNICODE
  632. ::SetDlgItemTextW(GetParent()->GetSafeHwnd(), IDC_EDITCHAR, (LPCWSTR)Work1);
  633. #else
  634. CHAR Work2[5];
  635. int nchar=WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)Work1, 1, (LPSTR)Work2, sizeof(Work2), 0,0);
  636. Work2[nchar]=0;
  637. ::SetDlgItemText(GetParent()->GetSafeHwnd(), IDC_EDITCHAR, (LPCSTR)Work2);
  638. #endif
  639. }
  640. }else{
  641. PtIn = FALSE;
  642. dc.SetBkColor( COLOR_FACE);
  643. dc.SetTextColor(GetSysColor(COLOR_WINDOWTEXT)); // COLOR_BLACK);
  644. }
  645. BOOL sts = GetTextExtentPoint32W( dc.GetSafeHdc(),
  646. (LPCWSTR)Work1, wLength, &cSize);
  647. if( rcReferChar[i][j].Width() > cSize.cx){
  648. xOffset = rcReferChar[i][j].Width() - cSize.cx;
  649. xOffset /= 2;
  650. }else xOffset = 0;
  651. if( rcReferChar[i][j].Height() > cSize.cy){
  652. yOffset = rcReferChar[i][j].Height() - cSize.cy;
  653. yOffset /= 2;
  654. }else yOffset = 0;
  655. // Draw character code on character list
  656. ExtTextOutW(dc.GetSafeHdc(), rcReferChar[i][j].left + xOffset,
  657. rcReferChar[i][j].top + yOffset,
  658. ETO_OPAQUE, &rcReferChar[i][j],
  659. (LPCWSTR)Work1, wLength, NULL);
  660. DrawConcave( &dc, rcReferChar[i][j], PtIn);
  661. }
  662. }
  663. dc.SelectObject( OldFont);
  664. dc.SetMapMode(OldMode);
  665. LButtonPt.x = 0;
  666. LButtonPt.y = 0;
  667. }
  668. /****************************************/
  669. /* */
  670. /* MESSAGE "WM_VSCROLL" */
  671. /* */
  672. /****************************************/
  673. void
  674. CRefrList::OnVScroll(
  675. UINT nSBCode,
  676. UINT nPos,
  677. CScrollBar *pScrollBar)
  678. {
  679. int MoveScr;
  680. BOOL ThumbTrkFlag, ThumbPosFlag;
  681. BottomCode = (WORD)GetBarPosition((WORD)ViewEnd);
  682. this->SetScrollRange( SB_VERT, 0, BottomCode, FALSE);
  683. MoveScr = 0;
  684. ThumbTrkFlag = ThumbPosFlag = FALSE;
  685. switch( nSBCode){
  686. case SB_LINEDOWN:
  687. if(( ViewStart + NUM_CHAR) <= ViewEnd){
  688. MoveScr = 0 - (CharSize.cy + LINEWIDTH);
  689. ViewStart = GetPlusCode( ViewStart,NUM_CHAR);
  690. ScrlBarPos = (short)GetBarPosition( ViewStart);
  691. }
  692. break;
  693. case SB_LINEUP:
  694. if(( ViewStart - NUM_CHAR) >= StartCode){
  695. MoveScr = CharSize.cy + LINEWIDTH;
  696. ViewStart = GetMinusCode(ViewStart,NUM_CHAR);
  697. ScrlBarPos = (short)GetBarPosition( ViewStart);
  698. }
  699. break;
  700. case SB_PAGEDOWN:
  701. if(( ViewStart + NUM_CHAR*NUM_LINE) <= ViewEnd){
  702. MoveScr = ( 0 -(CharSize.cy+LINEWIDTH)) *NUM_LINE;
  703. ScrlBarPos = (short)GetBarPosition( ViewStart);
  704. ScrlBarPos += NUM_LINE;
  705. ViewStart = GetCodeScrPos( ScrlBarPos);
  706. }else{
  707. MoveScr = ( 0 -(CharSize.cy+LINEWIDTH)) *NUM_LINE;
  708. ViewStart = ViewEnd;
  709. ScrlBarPos = (short)GetBarPosition( ViewStart);
  710. }
  711. break;
  712. case SB_PAGEUP:
  713. if(( ViewStart - NUM_CHAR*NUM_LINE) >= StartCode &&
  714. ViewStart >= NUM_CHAR*NUM_LINE){
  715. MoveScr = (CharSize.cy + LINEWIDTH) *NUM_LINE;
  716. ScrlBarPos = (short)GetBarPosition( ViewStart);
  717. ScrlBarPos -= NUM_LINE;
  718. ViewStart = GetCodeScrPos( ScrlBarPos);
  719. }else{
  720. MoveScr = (CharSize.cy + LINEWIDTH) *NUM_LINE;
  721. ViewStart = StartCode;
  722. ScrlBarPos = (short)GetBarPosition( ViewStart);
  723. }
  724. break;
  725. case SB_THUMBPOSITION:
  726. ThumbPosFlag = TRUE;
  727. ScrlBarPos = (short)nPos;
  728. ViewStart = GetCodeScrPos( nPos);
  729. break;
  730. case SB_THUMBTRACK:
  731. ThumbTrkFlag = TRUE;
  732. break;
  733. case SB_TOP:
  734. ViewStart = StartCode;
  735. ScrlBarPos = 0;
  736. break;
  737. case SB_BOTTOM:
  738. ViewStart = ViewEnd;
  739. ScrlBarPos = BottomCode;
  740. break;
  741. default:
  742. break;
  743. }
  744. if( abs( MoveScr) <= (CharSize.cy + LINEWIDTH) &&
  745. abs( MoveScr) > 0 && !ThumbTrkFlag){
  746. CRect ScrllRect;
  747. CRect ClintRect;
  748. GetClientRect( &ClintRect);
  749. ScrllRect.CopyRect( &ClintRect);
  750. if( MoveScr < 0){
  751. ClintRect.top = 0 - MoveScr;
  752. this->ScrollWindow( 0, MoveScr, &ClintRect, NULL);
  753. ScrllRect.top = ( 0-MoveScr)*(NUM_LINE -1);
  754. }else{
  755. ClintRect.top = 0;
  756. ClintRect.bottom = MoveScr*(NUM_LINE -1);
  757. this->ScrollWindow( 0, MoveScr, &ClintRect, NULL);
  758. ScrllRect.top = 0;
  759. ScrllRect.bottom = ScrllRect.top + MoveScr;
  760. }
  761. this->InvalidateRect( &ScrllRect, FALSE);
  762. }else if( !ThumbTrkFlag && ( MoveScr || ThumbPosFlag)){
  763. this->InvalidateRect( &CodeListRect, TRUE);
  764. }
  765. this->SetScrollPos( SB_VERT, ScrlBarPos, TRUE);
  766. }
  767. /****************************************/
  768. /* */
  769. /* MESSAGE "WM_LBUTTONDOWN" */
  770. /* */
  771. /****************************************/
  772. void
  773. CRefrList::OnLButtonDown(
  774. UINT ,
  775. CPoint point)
  776. {
  777. CRect test;
  778. BOOL PtIn;
  779. unsigned int i, j;
  780. PtIn = FALSE;
  781. this->SetFocus();
  782. for( i = 0; i < NUM_LINE; i++){
  783. for( j = 0; j < NUM_CHAR; j++){
  784. if( rcReferChar[i][j].PtInRect( point)){
  785. if( IsCorrectChar( i, j))
  786. PtIn = TRUE;
  787. break;
  788. }
  789. }
  790. }
  791. if( !PtIn){
  792. MessageBeep((UINT)-1);
  793. return;
  794. }
  795. LButtonPt = point;
  796. SearchKeyPosition( TRUE);
  797. SelectCode = 0;
  798. for( i = 0; i < NUM_LINE; i++){
  799. for( j = 0; j < NUM_CHAR; j++){
  800. if( rcReferChar[i][j].PtInRect( LButtonPt)){
  801. test.SetRect( rcReferChar[i][j].left - 2,
  802. rcReferChar[i][j].top - 2,
  803. rcReferChar[i][j].right + 2,
  804. rcReferChar[i][j].bottom + 2);
  805. this->InvalidateRect( &test, FALSE);
  806. break;
  807. }
  808. }
  809. }
  810. this->UpdateWindow();
  811. }
  812. /****************************************/
  813. /* */
  814. /* MESSAGE "WM_LBUTTONDBLCLK" */
  815. /* */
  816. /****************************************/
  817. void
  818. CRefrList::OnLButtonDblClk(
  819. UINT nFlags,
  820. CPoint point)
  821. {
  822. BOOL PtIn;
  823. unsigned int i, j;
  824. LButtonPt = point;
  825. this->InvalidateRect( &CodeListRect, FALSE);
  826. this->UpdateWindow();
  827. PtIn = FALSE;
  828. this->SetFocus();
  829. for( i = 0; i < NUM_LINE; i++){
  830. for( j = 0; j < NUM_CHAR; j++){
  831. if( rcReferChar[i][j].PtInRect( point)){
  832. if( IsCorrectChar( i, j))
  833. PtIn = TRUE;
  834. break;
  835. }
  836. }
  837. }
  838. if( !PtIn){
  839. MessageBeep((UINT)-1);
  840. return;
  841. }else{
  842. GetParent()->PostMessage( WM_COMMAND, IDOK, 0L);
  843. }
  844. }
  845. /****************************************/
  846. /* */
  847. /* MESSAGE "WM_SETCURSOR" */
  848. /* */
  849. /****************************************/
  850. BOOL
  851. CRefrList::OnSetCursor(
  852. CWnd* pWnd,
  853. UINT nHitTest,
  854. UINT message)
  855. {
  856. ::SetCursor( AfxGetApp()->LoadStandardCursor(IDC_ARROW));
  857. return TRUE;
  858. }
  859. /****************************************/
  860. /* */
  861. /* Reset parameter */
  862. /* */
  863. /****************************************/
  864. void
  865. CRefrList::ResetParam()
  866. {
  867. LButtonPt.x = LButtonPt.y = 0;
  868. /*
  869. SelectCode = HiByteRange[CHAR_SBCS][CHN];
  870. */
  871. SelectCode = 0x0020;
  872. ScrlBarPos = 0;
  873. this->SetScrollPos( SB_VERT, ScrlBarPos, TRUE);
  874. }
  875. /****************************************/
  876. /* */
  877. /* Draw Concave ractangle */
  878. /* */
  879. /****************************************/
  880. void
  881. CRefrList::DrawConcave(
  882. CDC *dc,
  883. CRect rect,
  884. BOOL PtIn)
  885. {
  886. CBrush ConBrush, *OldBrush;
  887. CRect Rt;
  888. if (!dc)
  889. {
  890. return;
  891. }
  892. Rt.SetRect( rect.left-1, rect.top-1, rect.right+1, rect.bottom+1);
  893. if( !PtIn){
  894. ConBrush.CreateSolidBrush( COLOR_HLIGHT);
  895. OldBrush = dc->SelectObject( &ConBrush);
  896. dc->PatBlt( Rt.left, Rt.top, Rt.Width(), 1, PATCOPY);
  897. dc->PatBlt( Rt.left, Rt.top, 1, Rt.Height(), PATCOPY);
  898. dc->SelectObject( OldBrush);
  899. ConBrush.DeleteObject();
  900. ConBrush.CreateSolidBrush( COLOR_SHADOW);
  901. OldBrush = dc->SelectObject( &ConBrush);
  902. dc->PatBlt( Rt.left, Rt.bottom, Rt.Width(), 1, PATCOPY);
  903. dc->PatBlt( Rt.right, Rt.top, 1, Rt.Height()+1, PATCOPY);
  904. dc->SelectObject( OldBrush);
  905. ConBrush.DeleteObject();
  906. if( FocusFlag){
  907. CBrush fBrush;
  908. CPen fPen, *OldPen;
  909. fBrush.CreateStockObject( NULL_BRUSH);
  910. fPen.CreatePen( PS_SOLID, 1, COLOR_FACE);
  911. OldBrush = dc->SelectObject( &fBrush);
  912. OldPen = dc->SelectObject( &fPen);
  913. dc->Rectangle( &rect);
  914. dc->SelectObject( OldBrush);
  915. dc->SelectObject( OldPen);
  916. fBrush.DeleteObject();
  917. fPen.DeleteObject();
  918. }
  919. }else{
  920. ConBrush.CreateSolidBrush( COLOR_SHADOW);
  921. OldBrush = dc->SelectObject( &ConBrush);
  922. dc->PatBlt( Rt.left, Rt.top, Rt.Width(), 1, PATCOPY);
  923. dc->PatBlt( Rt.left, Rt.top, 1, Rt.Height(), PATCOPY);
  924. dc->SelectObject( OldBrush);
  925. ConBrush.DeleteObject();
  926. ConBrush.CreateSolidBrush( COLOR_HLIGHT);
  927. OldBrush = dc->SelectObject( &ConBrush);
  928. dc->PatBlt( Rt.left, Rt.bottom, Rt.Width(), 1, PATCOPY);
  929. dc->PatBlt( Rt.right, Rt.top, 1, Rt.Height()+1, PATCOPY);
  930. dc->SelectObject( OldBrush);
  931. ConBrush.DeleteObject();
  932. if( FocusFlag){
  933. CBrush fBrush;
  934. CPen fPen, *OldPen;
  935. fBrush.CreateStockObject( NULL_BRUSH);
  936. fPen.CreatePen( PS_SOLID, 1, COLOR_SHADOW);
  937. OldBrush = dc->SelectObject( &fBrush);
  938. OldPen = dc->SelectObject( &fPen);
  939. dc->Rectangle( &rect);
  940. dc->SelectObject( OldBrush);
  941. dc->SelectObject( OldPen);
  942. fBrush.DeleteObject();
  943. fPen.DeleteObject();
  944. }
  945. }
  946. }
  947. /****************************************/
  948. /* */
  949. /* MESSAGE "WM_KEYDOWN" */
  950. /* */
  951. /****************************************/
  952. void
  953. CRefrList::OnKeyDown(
  954. UINT nChar,
  955. UINT nRepCnt,
  956. UINT nFlags)
  957. {
  958. int sPos;
  959. int ePos;
  960. if( nChar == VK_UP || nChar == VK_DOWN ||
  961. nChar == VK_LEFT || nChar == VK_RIGHT){
  962. sPos = GetBarPosition( ViewStart);
  963. ePos = GetBarPosition( SelectCode);
  964. if( ePos - sPos >= NUM_LINE || ePos < sPos){
  965. ViewStart = SelectCode & 0xfff0;
  966. ScrlBarPos = (short)GetBarPosition( ViewStart);
  967. this->Invalidate(FALSE);
  968. this->UpdateWindow();
  969. }
  970. switch( nChar){
  971. case VK_UP:
  972. if( SelectCode - NUM_CHAR < StartCode)
  973. break;
  974. if( SelectCode - NUM_CHAR < ViewStart){
  975. this->SendMessage(WM_VSCROLL, SB_LINEUP, 0);
  976. }
  977. SearchKeyPosition(FALSE);
  978. SelectCode = GetMinusCodeKey( SelectCode, NUM_CHAR);
  979. SearchKeyPosition(FALSE);
  980. break;
  981. case VK_DOWN:
  982. if( SelectCode + NUM_CHAR > EndCode)
  983. break;
  984. if( ePos - sPos >= NUM_LINE - 1){
  985. this->SendMessage(WM_VSCROLL, SB_LINEDOWN, 0);
  986. }
  987. SearchKeyPosition(FALSE);
  988. SelectCode = GetPlusCodeKey( SelectCode, NUM_CHAR);
  989. SearchKeyPosition(FALSE);
  990. break;
  991. case VK_LEFT:
  992. if( SelectCode - 1 < StartCode)
  993. break;
  994. if( SelectCode - 1 < ViewStart){
  995. this->SendMessage(WM_VSCROLL, SB_LINEUP, 0);
  996. }
  997. SearchKeyPosition(FALSE);
  998. SelectCode = GetMinusCodeKey( SelectCode, 1);
  999. SearchKeyPosition(FALSE);
  1000. break;
  1001. case VK_RIGHT:
  1002. WORD TmpCode;
  1003. int TmpPos;
  1004. if( SelectCode + 1 > EndCode)
  1005. break;
  1006. TmpCode = GetPlusCodeKey( SelectCode, 1);
  1007. sPos = GetBarPosition( ViewStart);
  1008. ePos = GetBarPosition( SelectCode);
  1009. TmpPos = GetBarPosition( TmpCode);
  1010. if( TmpPos - sPos >= NUM_LINE){
  1011. this->SendMessage(WM_VSCROLL, SB_LINEDOWN, 0);
  1012. }
  1013. SearchKeyPosition(FALSE);
  1014. SelectCode = GetPlusCodeKey( SelectCode, 1);
  1015. SearchKeyPosition(FALSE);
  1016. break;
  1017. }
  1018. }else CEdit::OnKeyDown(nChar, nRepCnt, nFlags);
  1019. }
  1020. /****************************************/
  1021. /* */
  1022. /* Search focus position */
  1023. /* */
  1024. /****************************************/
  1025. void
  1026. CRefrList::SearchKeyPosition(
  1027. BOOL Flg)
  1028. {
  1029. CRect test;
  1030. int sViewPt, sCodePt;
  1031. int sType, eType;
  1032. unsigned int i, j;
  1033. sViewPt = GetBarPosition( ViewStart);
  1034. sCodePt = GetBarPosition( SelectCode);
  1035. if(( sViewPt > sCodePt || abs( sCodePt - sViewPt) >= NUM_LINE) && Flg){
  1036. this->Invalidate( FALSE);
  1037. return;
  1038. }
  1039. i = (unsigned int)(sCodePt - sViewPt);
  1040. j = (unsigned int)(SelectCode & 0x000f);
  1041. /*
  1042. sType = CheckCharType( ViewStart);
  1043. eType = CheckCharType( SelectCode);
  1044. if( sType != eType && sType != CHAR_SBCS)
  1045. i++;
  1046. */
  1047. test.SetRect( rcReferChar[i][j].left - 2,
  1048. rcReferChar[i][j].top - 2,
  1049. rcReferChar[i][j].right + 2,
  1050. rcReferChar[i][j].bottom + 2);
  1051. this->InvalidateRect( &test, FALSE);
  1052. }
  1053. /****************************************/
  1054. /* */
  1055. /* MESSAGE "WM_SETFOCUS" */
  1056. /* */
  1057. /****************************************/
  1058. void
  1059. CRefrList::OnSetFocus(
  1060. CWnd* pOldWnd)
  1061. {
  1062. CEdit::OnSetFocus(pOldWnd);
  1063. this->HideCaret();
  1064. FocusFlag = TRUE;
  1065. SearchKeyPosition(TRUE);
  1066. this->UpdateWindow();
  1067. }
  1068. /****************************************/
  1069. /* */
  1070. /* SearchCode */
  1071. /* */
  1072. /****************************************/
  1073. BOOL
  1074. CRefrList::IsCorrectChar(
  1075. UINT i,
  1076. UINT j)
  1077. {
  1078. int sViewPt, CharType;
  1079. WORD wCode;
  1080. WORD sOffset;
  1081. BOOL flg;
  1082. flg = FALSE;
  1083. BottomCode = (WORD)GetBarPosition((WORD)ViewEnd);
  1084. sViewPt = GetBarPosition( ViewStart);
  1085. wCode = GetCodeScrPos( sViewPt + i);
  1086. wCode |= j;
  1087. /*
  1088. CharType = CheckCharType( wCode);
  1089. sOffset = wCode & 0x00ff;
  1090. if( CharType == CHAR_SBCS){
  1091. if( sOffset >= LoByteRange[0][CHN] &&
  1092. sOffset <= LoByteRange[0][CHN+1])
  1093. flg = TRUE;
  1094. }else{
  1095. if(( sOffset >= LoByteRange[1][CHN] &&
  1096. sOffset <= LoByteRange[1][CHN+1]) ||
  1097. ( sOffset >= LoByteRange[2][CHN] &&
  1098. sOffset <= LoByteRange[2][CHN+1]) ||
  1099. ( sOffset >= LoByteRange[3][CHN] &&
  1100. sOffset <= LoByteRange[3][CHN+1]))
  1101. flg = TRUE;
  1102. }
  1103. return flg;
  1104. */
  1105. return TRUE;
  1106. }
  1107. /****************************************/
  1108. /* */
  1109. /* Increase key focus */
  1110. /* */
  1111. /****************************************/
  1112. WORD
  1113. CRefrList::GetPlusCodeKey(
  1114. WORD Code,
  1115. int ScrollNum)
  1116. {
  1117. /*
  1118. WORD PrevCode;
  1119. WORD LowByte, HighByte;
  1120. WORD LLByte;
  1121. int CharType;
  1122. int CharType1, CharType2;
  1123. int Offset;
  1124. */
  1125. Code += (WORD)ScrollNum;
  1126. /*
  1127. PrevCode = (WORD)(Code - (WORD)ScrollNum);
  1128. CharType1 = CheckCharType( PrevCode);
  1129. CharType2 = CheckCharType( Code);
  1130. if( CharType1 != CharType2){
  1131. if( CharType1 == CHAR_EUDC)
  1132. Code = PrevCode;
  1133. else{
  1134. Offset = Code - HiByteRange[CharType1][CHN+1];
  1135. Code = (WORD)( HiByteRange[CharType1+1][CHN] +Offset-1);
  1136. }
  1137. }
  1138. CharType = CheckCharType( Code);
  1139. if( CharType != CHAR_SBCS){
  1140. LowByte = Code & 0x00ff;
  1141. HighByte = Code & 0xff00;
  1142. LLByte = Code & 0x000f;
  1143. if( LowByte <= LoByteRange[4][CHN+1] &&
  1144. LowByte >= LoByteRange[4][CHN] ){
  1145. LowByte = 0x0040 + LLByte;
  1146. }
  1147. Code = ( HighByte | LowByte);
  1148. }*/
  1149. return Code;
  1150. }
  1151. /****************************************/
  1152. /* */
  1153. /* Decrease focus key */
  1154. /* */
  1155. /****************************************/
  1156. WORD
  1157. CRefrList::GetMinusCodeKey(
  1158. WORD Code,
  1159. int ScrollNum)
  1160. {
  1161. /*
  1162. WORD PrevCode;
  1163. WORD LLByte;
  1164. int CharType;
  1165. int CharType1, CharType2;
  1166. int Offset;
  1167. */
  1168. Code -= (WORD)ScrollNum;
  1169. /*
  1170. PrevCode = (WORD)( Code + (WORD)ScrollNum);
  1171. CharType1 = CheckCharType( Code);
  1172. CharType2 = CheckCharType( PrevCode);
  1173. if( CharType1 != CharType2){
  1174. if( CharType2 == CHAR_SBCS)
  1175. return (WORD)HiByteRange[CHAR_SBCS][CHN];
  1176. else{
  1177. Offset = HiByteRange[CharType2][CHN] - Code;
  1178. return (WORD)(HiByteRange[CharType2-1][CHN+1]-Offset+1);
  1179. }
  1180. }
  1181. CharType = CheckCharType( Code);
  1182. if( CharType != CHAR_SBCS){
  1183. WORD LowByte;
  1184. WORD HighByte;
  1185. WORD Tmp;
  1186. LowByte = Code & 0x00ff;
  1187. HighByte = Code & 0xff00;
  1188. LLByte = Code & 0x000f;
  1189. if( LowByte <= LoByteRange[4][CHN+1] &&
  1190. LowByte >= LoByteRange[4][CHN] ){
  1191. LowByte = 0xf0 + LLByte;
  1192. Tmp = ( HighByte >> 8);
  1193. Tmp -= 0x1;
  1194. HighByte = Tmp << 8;
  1195. }
  1196. Code = ( HighByte | LowByte);
  1197. }*/
  1198. return Code;
  1199. }
  1200. /****************************************/
  1201. /* */
  1202. /* MESSAGE "WM_KILLFOCUS" */
  1203. /* */
  1204. /****************************************/
  1205. void
  1206. CRefrList::OnKillFocus(
  1207. CWnd* pNewWnd)
  1208. {
  1209. CEdit::OnKillFocus(pNewWnd);
  1210. FocusFlag = FALSE;
  1211. SearchKeyPosition(TRUE);
  1212. this->UpdateWindow();
  1213. }
  1214. /****************************************/
  1215. /* */
  1216. /* MESSAGE "WM_RBUTTONUP" */
  1217. /* */
  1218. /****************************************/
  1219. void
  1220. CRefrList::OnRButtonUp(
  1221. UINT nFlags,
  1222. CPoint point)
  1223. {
  1224. GetParent()->SendMessage( WM_CONTEXTMENU, (WPARAM)this->GetSafeHwnd(), 0);
  1225. }
  1226. BEGIN_MESSAGE_MAP( CRefListFrame, CStatic)
  1227. //{{AFX_MSG_MAP( CRefListFrame)
  1228. ON_WM_PAINT()
  1229. //}}AFX_MSG_MAP
  1230. END_MESSAGE_MAP()
  1231. /****************************************/
  1232. /* */
  1233. /* Default Constructor */
  1234. /* */
  1235. /****************************************/
  1236. CRefListFrame::CRefListFrame()
  1237. {
  1238. }
  1239. /****************************************/
  1240. /* */
  1241. /* Destructor */
  1242. /* */
  1243. /****************************************/
  1244. CRefListFrame::~CRefListFrame()
  1245. {
  1246. }
  1247. /****************************************/
  1248. /* */
  1249. /* MESSAGE "WM_PAINT" */
  1250. /* */
  1251. /****************************************/
  1252. void
  1253. CRefListFrame::OnPaint()
  1254. {
  1255. CRect FrameRect;
  1256. CPaintDC dc( this);
  1257. this->GetClientRect( &FrameRect);
  1258. this->DrawConcave( &dc, FrameRect);
  1259. }
  1260. /****************************************/
  1261. /* */
  1262. /* Draw Concave Rect */
  1263. /* */
  1264. /****************************************/
  1265. void
  1266. CRefListFrame::DrawConcave(
  1267. CDC *dc,
  1268. CRect rect)
  1269. {
  1270. CBrush ConBrush, *OldBrush;
  1271. CRect Rt;
  1272. Rt.SetRect( rect.left-1, rect.top-1, rect.right, rect.bottom);
  1273. ConBrush.CreateSolidBrush( COLOR_HLIGHT);
  1274. OldBrush = dc->SelectObject( &ConBrush);
  1275. dc->PatBlt( Rt.left, Rt.top, Rt.Width(), 1, PATCOPY);
  1276. dc->PatBlt( Rt.left, Rt.top, 1, Rt.Height(), PATCOPY);
  1277. dc->SelectObject( OldBrush);
  1278. ConBrush.DeleteObject();
  1279. ConBrush.CreateSolidBrush( COLOR_SHADOW);
  1280. OldBrush = dc->SelectObject( &ConBrush);
  1281. dc->PatBlt( Rt.left, Rt.bottom, Rt.Width(), 1, PATCOPY);
  1282. dc->PatBlt( Rt.right, Rt.top, 1, Rt.Height()+1, PATCOPY);
  1283. dc->SelectObject( OldBrush);
  1284. ConBrush.DeleteObject();
  1285. }
  1286. BEGIN_MESSAGE_MAP( CRefInfoFrame, CStatic)
  1287. //{{AFX_MSG_MAP( CRefInfoFrame)
  1288. ON_WM_PAINT()
  1289. //}}AFX_MSG_MAP
  1290. END_MESSAGE_MAP()
  1291. /****************************************/
  1292. /* */
  1293. /* Default Constructor */
  1294. /* */
  1295. /****************************************/
  1296. CRefInfoFrame::CRefInfoFrame()
  1297. {
  1298. }
  1299. /****************************************/
  1300. /* */
  1301. /* Destructor */
  1302. /* */
  1303. /****************************************/
  1304. CRefInfoFrame::~CRefInfoFrame()
  1305. {
  1306. }
  1307. /****************************************/
  1308. /* */
  1309. /* MESSAGE "WM_PAINT" */
  1310. /* */
  1311. /****************************************/
  1312. void
  1313. CRefInfoFrame::OnPaint()
  1314. {
  1315. CRect FrameRect;
  1316. CPaintDC dc( this);
  1317. this->GetClientRect( &FrameRect);
  1318. this->DrawConcave( &dc, FrameRect);
  1319. }
  1320. /****************************************/
  1321. /* */
  1322. /* Draw Concave Rect */
  1323. /* */
  1324. /****************************************/
  1325. void
  1326. CRefInfoFrame::DrawConcave(
  1327. CDC *dc,
  1328. CRect rect)
  1329. {
  1330. CBrush ConBrush, *OldBrush;
  1331. CRect Rt;
  1332. Rt.SetRect( rect.left-1, rect.top-1, rect.right, rect.bottom);
  1333. ConBrush.CreateSolidBrush( COLOR_SHADOW);
  1334. OldBrush = dc->SelectObject( &ConBrush);
  1335. dc->PatBlt( Rt.left, Rt.top, Rt.Width(), 1, PATCOPY);
  1336. dc->PatBlt( Rt.left, Rt.top, 1, Rt.Height(), PATCOPY);
  1337. dc->SelectObject( OldBrush);
  1338. ConBrush.DeleteObject();
  1339. ConBrush.CreateSolidBrush( COLOR_HLIGHT);
  1340. OldBrush = dc->SelectObject( &ConBrush);
  1341. dc->PatBlt( Rt.left, Rt.bottom, Rt.Width(), 1, PATCOPY);
  1342. dc->PatBlt( Rt.right, Rt.top, 1, Rt.Height()+1, PATCOPY);
  1343. dc->SelectObject( OldBrush);
  1344. ConBrush.DeleteObject();
  1345. }