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.

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