Source code of Windows XP (NT5)
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.

216 lines
5.0 KiB

  1. /**************************************************/
  2. /* */
  3. /* */
  4. /* Guide Bar */
  5. /* */
  6. /* */
  7. /* Copyright (c) 1997-1999 Microsoft Corporation. */
  8. /**************************************************/
  9. #include "stdafx.h"
  10. #include "eudcedit.h"
  11. #include "guidebar.h"
  12. #include "registry.h"
  13. #include "util.h"
  14. #define GUIDEHIGH 50
  15. #define COMBOWIDTH 55
  16. #define COMBOHEIGHT 200
  17. #ifdef _DEBUG
  18. #undef THIS_FILE
  19. static char BASED_CODE THIS_FILE[] = __FILE__;
  20. #endif
  21. IMPLEMENT_DYNAMIC( CGuideBar, CStatusBar)
  22. BEGIN_MESSAGE_MAP( CGuideBar, CStatusBar)
  23. //{{AFX_MSG_MAP(CGuideBar)
  24. ON_WM_CREATE()
  25. //}}AFX_MSG_MAP
  26. END_MESSAGE_MAP()
  27. /****************************************/
  28. /* */
  29. /* Constructor */
  30. /* */
  31. /****************************************/
  32. CGuideBar::CGuideBar()
  33. {
  34. m_comboBoxAdded = FALSE;
  35. }
  36. /****************************************/
  37. /* */
  38. /* Destructor */
  39. /* */
  40. /****************************************/
  41. CGuideBar::~CGuideBar()
  42. {
  43. }
  44. /****************************************/
  45. /* */
  46. /* Create GuideBar */
  47. /* */
  48. /****************************************/
  49. BOOL
  50. CGuideBar::Create(
  51. CWnd* pOwnerWnd,
  52. UINT pID)
  53. {
  54. LONG lStyle;
  55. //
  56. // We don't want the sizegrip for this status bar because it is at
  57. // the top of the frame. However MFC creates a sizegrip if the
  58. // parent window has a thickframe. We temporarily turn off the bit
  59. // to fool MFC so that SBARS_GRIPSIZE is not set.
  60. //
  61. lStyle = ::SetWindowLong(pOwnerWnd->GetSafeHwnd(),
  62. GWL_STYLE,
  63. (pOwnerWnd->GetStyle() & ~WS_THICKFRAME));
  64. m_pOwnerWnd = pOwnerWnd;
  65. if (!CStatusBar::Create( pOwnerWnd, WS_CHILD | WS_VISIBLE
  66. | CBRS_TOP | CBRS_NOALIGN, AFX_IDW_STATUS_BAR))
  67. {
  68. return FALSE;
  69. }
  70. ::SetWindowLong(pOwnerWnd->GetSafeHwnd(), GWL_STYLE, lStyle);
  71. return TRUE;
  72. }
  73. int
  74. CGuideBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
  75. {
  76. CRect rect;
  77. TCHAR CharBuf[MAX_PATH];
  78. UINT nID = 0;
  79. if (CStatusBar::OnCreate(lpCreateStruct) == -1)
  80. return -1;
  81. if (!m_comboCharset.Create(WS_CHILD | WS_VISIBLE | WS_TABSTOP |
  82. CBS_DROPDOWNLIST | CBS_HASSTRINGS, rect, this, IDC_SELECTCHARSET)){
  83. return -1;
  84. }
  85. m_comboCharset.SendMessage(WM_SETFONT, (WPARAM) CStatusBar::GetFont()->GetSafeHandle());
  86. switch (CountryInfo.LangID){
  87. case EUDC_JPN:
  88. nID=IDS_SHIFTJIS;
  89. break;
  90. case EUDC_CHS:
  91. nID=IDS_GB2312;
  92. break;
  93. case EUDC_KRW:
  94. nID=IDS_HANGUL;
  95. break;
  96. case EUDC_CHT:
  97. nID=IDS_CHINESEBIG5;
  98. break;
  99. }
  100. if (nID){
  101. GetStringRes(CharBuf, nID);
  102. m_comboCharset.AddString(CharBuf);
  103. }
  104. GetStringRes(CharBuf, IDS_UNICODE);
  105. m_comboCharset.AddString(CharBuf);
  106. m_comboCharset.SetCurSel(0);
  107. return TRUE;
  108. }
  109. /****************************************/
  110. /* */
  111. /* MESSAGE "WM_PAINT" */
  112. /* */
  113. /****************************************/
  114. void
  115. CGuideBar::PositionStatusPane()
  116. {
  117. TCHAR CharBuf[MAX_PATH], BufTmp[MAX_PATH], *FilePtr;
  118. int nWidth;
  119. UINT nStyle, nID;
  120. CRect rect;
  121. CSize StringSize;
  122. GetPaneInfo(0,nID,nStyle,nWidth);
  123. CDC* dc = this->GetDC();
  124. int nComboWidth;
  125. int nDlgBaseUnitX = LOWORD(GetDialogBaseUnits());
  126. nComboWidth = (nDlgBaseUnitX * COMBOWIDTH + 2) /4;
  127. if (!m_comboBoxAdded)
  128. {
  129. SetPaneInfo(0,nID, nStyle | SBPS_NOBORDERS,nWidth+nComboWidth);
  130. m_comboCharset.SetWindowPos( NULL, nWidth+nDlgBaseUnitX, 0,
  131. nComboWidth, COMBOHEIGHT, SWP_NOZORDER);
  132. m_comboBoxAdded = TRUE;
  133. }
  134. // Draw "Code:"
  135. if( SelectEUDC.m_Code[0] != '\0'){
  136. GetStringRes(CharBuf, IDS_CODE_STR);
  137. lstrcat( CharBuf, TEXT(" "));
  138. lstrcat( CharBuf, SelectEUDC.m_Code);
  139. SetPaneText (1, CharBuf, TRUE);
  140. StringSize = dc->GetTextExtent(CharBuf,lstrlen(CharBuf));
  141. GetPaneInfo(1,nID,nStyle,nWidth);
  142. SetPaneInfo(1,nID,nStyle,StringSize.cx + 3*nDlgBaseUnitX);
  143. }
  144. if( SelectEUDC.m_Font[0] != '\0'){
  145. GetStringRes(CharBuf, IDS_FONT_STR);
  146. lstrcat( CharBuf, TEXT(" "));
  147. lstrcat( CharBuf, SelectEUDC.m_Font);
  148. SetPaneText (2, CharBuf, TRUE);
  149. StringSize = dc->GetTextExtent(CharBuf,lstrlen(CharBuf));
  150. GetPaneInfo(2,nID,nStyle,nWidth);
  151. SetPaneInfo(2,nID,nStyle,StringSize.cx + 3*nDlgBaseUnitX);
  152. }
  153. if( SelectEUDC.m_Font[0] != TEXT('\0') && InqTypeFace(SelectEUDC.m_Font,
  154. SelectEUDC.m_File, sizeof( SelectEUDC.m_File)/sizeof(TCHAR))){
  155. GetStringRes(CharBuf, IDS_FILE_STR);
  156. lstrcat( CharBuf, TEXT(" "));
  157. lstrcpy( BufTmp, SelectEUDC.m_FileTitle);
  158. if(( FilePtr = Mytcsrchr( BufTmp, '.')) != NULL)
  159. *FilePtr = '\0';
  160. if( lstrlen((const TCHAR *)BufTmp) > 20){
  161. BufTmp[20] = '\0';
  162. lstrcat(BufTmp, TEXT(".."));
  163. }
  164. lstrcat( CharBuf, BufTmp);
  165. SetPaneText (3, CharBuf, TRUE);
  166. StringSize = dc->GetTextExtent(CharBuf,lstrlen(CharBuf));
  167. GetPaneInfo(3,nID,nStyle,nWidth);
  168. SetPaneInfo(3,nID,nStyle,StringSize.cx + 3*nDlgBaseUnitX);
  169. }
  170. UpdateWindow();
  171. this->ReleaseDC(dc);
  172. }
  173. #ifdef _DEBUG
  174. void CGuideBar::AssertValid() const
  175. {
  176. CStatusBar::AssertValid();
  177. }
  178. void CGuideBar::Dump(CDumpContext& dc) const
  179. {
  180. CStatusBar::Dump(dc);
  181. }
  182. #endif //_DEBUG