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.

350 lines
8.4 KiB

  1. // pbrush.h : main header file for the PBRUSH application
  2. //
  3. #ifndef __AFXWIN_H__
  4. #error include TEXT('stdafx.h') before including this file for PCH
  5. #endif
  6. #include "resource.h" // main symbols
  7. #include "loadimag.h"
  8. #ifdef PNG_SUPPORT
  9. #undef PNG_SUPPORT
  10. #endif
  11. // Bits for CTheApp::m_wEmergencyFlags
  12. //
  13. #define memoryEmergency 0x0001 // in a low free memory state
  14. #define gdiEmergency 0x0002 // some GDI create failed
  15. #define userEmergency 0x0004 // a CreateWindow failed
  16. #define warnEmergency 0x0008 // still need to warn the user
  17. #define failedEmergency 0x0010 // last operation actually failed
  18. // This is the minimum delay between warning messages so the user doesn't
  19. // get bombed by repetitious message boxes. The value is in milli-seconds.
  20. #define ticksBetweenWarnings (1000L * 60)
  21. #define nSysBrushes 25
  22. #define nOurBrushes 4
  23. #if 0
  24. // Pulling self-registration out. This is to be done once during setup only
  25. class CPBTemplateServer : public COleTemplateServer
  26. {
  27. public:
  28. void UpdateRegistry(OLE_APPTYPE nAppType,
  29. LPCTSTR* rglpszRegister = NULL, LPCTSTR* rglpszOverwrite = NULL);
  30. } ;
  31. #endif
  32. /***************************************************************************/
  33. // CPBApp:
  34. // See pbrush.cpp for the implementation of this class
  35. //
  36. class CPBApp : public CWinApp
  37. {
  38. public:
  39. CPBApp();
  40. ~CPBApp();
  41. //
  42. // OnFileNew made public for scanning support
  43. //
  44. afx_msg void OnFileNew();
  45. // Overrides
  46. virtual BOOL InitInstance();
  47. virtual int ExitInstance();
  48. virtual void WinHelp( DWORD dwData, UINT nCmd = HELP_CONTEXT ); // general
  49. virtual BOOL OnIdle(LONG);
  50. // error handling routines
  51. inline BOOL InEmergencyState() const { return m_wEmergencyFlags != 0; }
  52. void SetMemoryEmergency(BOOL bFailed = TRUE);
  53. void SetGdiEmergency (BOOL bFailed = TRUE);
  54. void SetUserEmergency (BOOL bFailed = TRUE);
  55. BOOL CheckForEmergency() { return (m_wEmergencyFlags? TRUE: FALSE); }
  56. void WarnUserOfEmergency();
  57. void SetFileError( UINT uOperationint, int nCause, LPCTSTR lpszFile = NULL );
  58. void FileErrorMessageBox( void );
  59. CString GetLastFile() {return m_sLastFile;}
  60. void TryToFreeMemory();
  61. void ParseCommandLine();
  62. // Patch to set the devmode and devname after pagesetup
  63. void SetDeviceHandles(HANDLE hDevNames, HANDLE hDevMode);
  64. // setup routines
  65. void LoadProfileSettings();
  66. void SaveProfileSettings();
  67. void GetSystemSettings( CDC* pdc );
  68. // Methods
  69. CPoint CheckWindowPosition( CPoint ptPosition, CSize& sizeWindow );
  70. CDocument* OpenDocumentFile( LPCTSTR lpszFileName );
  71. BOOL DoPromptFileName( CString& fileName, UINT nIDSTitle, DWORD lFlags,
  72. BOOL bOpenFileDialog, int& iColors, BOOL bOnlyBmp );
  73. #if 0
  74. // Pulling self-registration out. This is to be done once during setup only
  75. void RegisterShell(CSingleDocTemplate *pDocTemplate);
  76. #endif
  77. // Implementation
  78. COleTemplateServer m_server; // Server object for document creation
  79. // This is the minimum amount of free memory we like to have
  80. DWORD m_dwLowMemoryBytes;
  81. UINT m_nLowGdiPercent;
  82. UINT m_nLowUserPercent;
  83. WORD m_wEmergencyFlags;
  84. // General user settings
  85. BOOL m_bShowStatusbar;
  86. #ifdef CUSTOMFLOAT
  87. BOOL m_bShowToolbar;
  88. BOOL m_bShowColorbar;
  89. #endif
  90. BOOL m_bShowThumbnail;
  91. BOOL m_bShowTextToolbar;
  92. BOOL m_bShowIconToolbar;
  93. BOOL m_bShowGrid;
  94. #ifdef CUSTOMFLOAT
  95. BOOL m_bToolsDocked;
  96. BOOL m_bColorsDocked;
  97. #endif //CUSTOMFLOAT
  98. BOOL m_bEmbedded;
  99. BOOL m_bLinked;
  100. BOOL m_bHidden;
  101. BOOL m_bActiveApp;
  102. BOOL m_bPenSystem;
  103. BOOL m_bMonoDevice;
  104. BOOL m_bPaletted;
  105. BOOL m_bPrintOnly;
  106. CString m_strDocName;
  107. CString m_strPrinterName;
  108. CString m_strDriverName;
  109. CString m_strPortName;
  110. BOOL m_bWiaCallback;
  111. CString m_strWiaDeviceId;
  112. CString m_strWiaEventId;
  113. #ifdef PCX_SUPPORT
  114. BOOL m_bPCXfile;
  115. #endif
  116. int m_iCurrentUnits;
  117. // custom colors defined by the user
  118. COLORREF* m_pColors;
  119. int m_iColors;
  120. // copy of the system wide palette
  121. CPalette* m_pPalette;
  122. CFont m_fntStatus;
  123. int m_nEmbeddedType;
  124. HWND m_hwndInPlaceApp;
  125. class CInPlaceFrame* m_pwndInPlaceFrame;
  126. #ifdef CUSTOMFLOAT
  127. CRect m_rectFloatTools;
  128. CRect m_rectFloatColors;
  129. #endif
  130. CRect m_rectFloatThumbnail;
  131. CRect m_rectMargins;
  132. BOOL m_bCenterHorizontally;
  133. BOOL m_bCenterVertically;
  134. BOOL m_bScaleFitTo;
  135. int m_nAdjustToPercent;
  136. int m_nFitToPagesWide;
  137. int m_nFitToPagesTall;
  138. WINDOWPLACEMENT m_wpPlacement;
  139. CSize m_sizeBitmap;
  140. int m_iPointSize;
  141. int m_iPosTextX;
  142. int m_iPosTextY;
  143. int m_iBoldText;
  144. int m_iUnderlineText;
  145. int m_iItalicText;
  146. int m_iVertEditText;
  147. int m_iPenText;
  148. CString m_strTypeFaceName;
  149. int m_iCharSet;
  150. int m_iSnapToGrid;
  151. int m_iGridExtent;
  152. // general system metrics. updated on system notification
  153. struct
  154. {
  155. int iWidthinPels;
  156. int iHeightinPels;
  157. int iWidthinMM;
  158. int iHeightinMM;
  159. int iWidthinINCH;
  160. int iHeightinINCH;
  161. int ixPelsPerDM;
  162. int iyPelsPerDM;
  163. int ixPelsPerMM;
  164. int iyPelsPerMM;
  165. int ixPelsPerINCH;
  166. int iyPelsPerINCH;
  167. int iBitsPixel;
  168. int iPlanes;
  169. } ScreenDeviceInfo;
  170. int m_cxFrame;
  171. int m_cyFrame;
  172. int m_cxBorder;
  173. int m_cyBorder;
  174. int m_cyCaption;
  175. CBrush* m_pbrSysColors[nSysBrushes + nOurBrushes];
  176. CString m_sCurFile;
  177. int m_nFilters;
  178. GUID *m_guidFltType; // export filter types available
  179. GUID m_guidFltTypeUsed;
  180. int m_nFilterInIdx;
  181. int m_nFilterOutIdx;
  182. DWORD GetFilterIndex (REFGUID guidFltType);
  183. void FixExtension (CString& fileName, int iflFltType);
  184. CGdiplusInit GdiplusInit;
  185. #ifdef _DEBUG
  186. BOOL m_bLogUndo;
  187. #endif
  188. private:
  189. int m_nFileErrorCause; // from CFileException::m_cause
  190. WORD m_wEmergencyFlagss;
  191. DWORD m_tickLastWarning;
  192. CString m_strEmergencyNoMem;
  193. CString m_strEmergencyLowMem;
  194. CString m_sLastFile;
  195. UINT m_uOperation;
  196. afx_msg void OnFileOpen();
  197. //{{AFX_MSG(CPBApp)
  198. afx_msg void OnAppAbout();
  199. // NOTE - the ClassWizard will add and remove member functions here.
  200. // DO NOT EDIT what you see in these blocks of generated code !
  201. //}}AFX_MSG
  202. DECLARE_MESSAGE_MAP()
  203. };
  204. extern CPBApp theApp;
  205. #define IsInPlace() (theApp.m_pwndInPlaceFrame != NULL)
  206. //#define SZ_MAPISENDDOC TEXT("MAPISendDocuments")
  207. //#define MAPIDLL TEXT("MAPI32.DLL")
  208. typedef ULONG (FAR PASCAL *LPFNMAPISENDDOCUMENTS)(ULONG, LPTSTR, LPTSTR, LPTSTR, ULONG);
  209. void CancelToolMode(BOOL bSelectionCommand);
  210. #if 0
  211. // removing CRegKey - clashes with ATL class
  212. class CRegKey
  213. {
  214. public:
  215. CRegKey(HKEY hkParent, LPCTSTR pszSubKey) { if (RegCreateKey(hkParent, pszSubKey, &m_hk)!=ERROR_SUCCESS) m_hk=NULL; }
  216. ~CRegKey() { if (m_hk) RegCloseKey(m_hk); }
  217. operator HKEY() const { return(m_hk); }
  218. private:
  219. HKEY m_hk;
  220. };
  221. #endif
  222. extern const CLSID BASED_CODE CLSID_Paint;
  223. extern const CLSID BASED_CODE CLSID_PaintBrush;
  224. #define ARRAYSIZE(_x) sizeof(_x)/sizeof(_x[0])
  225. // make atoi work if building unicode
  226. //
  227. #ifdef UNICODE
  228. #define Atoi _wtoi
  229. #define _Itoa _itow
  230. #define Itoa _itow
  231. #else
  232. #define Atoi atoi
  233. #define _Itoa _itoa
  234. #define Itoa itoa
  235. #endif
  236. // macro-ize ansi/unicode conversions
  237. #define AtoW(x, y) MultiByteToWideChar (CP_ACP, 0, (x), -1, (y), (lstrlenA ((x))+1))
  238. #define WtoA(x,y) WideCharToMultiByte(CP_ACP, 0, (x), -1, (y), (lstrlenW((x))+1), NULL,NULL)
  239. #ifdef USE_MIRRORING
  240. //// REGetLayout - Get layout of DC
  241. //
  242. // Returns layout flags from an NT5/W98 or later DC, or zero
  243. // on legacy platforms.
  244. #ifndef WS_EX_LAYOUTRTL
  245. #define WS_EX_LAYOUTRTL 0x00400000L
  246. #endif
  247. #ifndef WS_EX_NOINHERITLAYOUT
  248. #define WS_EX_NOINHERITLAYOUT 0x00100000L
  249. #endif
  250. #ifndef LAYOUT_RTL
  251. #define LAYOUT_RTL 0x01
  252. #endif
  253. DWORD WINAPI PBGetLayoutInit(HDC hdc);
  254. DWORD WINAPI PBSetLayoutInit(HDC hdc, DWORD dwLayout);
  255. extern DWORD (WINAPI *PBSetLayout) (HDC hdc, DWORD dwLayout);
  256. extern DWORD (WINAPI *PBGetLayout) (HDC hdc);
  257. #endif
  258. /***************************************************************************/