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.

576 lines
11 KiB

  1. #ifndef _GDIPBRUSH_HPP
  2. #define _GDIPBRUSH_HPP
  3. class TestBrush;
  4. class TestSolidBrush;
  5. class TestTextureBrush;
  6. class TestRectangleGradientBrush;
  7. class TestRadialGradientBrush;
  8. class TestTriangleGradientBrush;
  9. class TestPathGradientBrush;
  10. class TestHatchBrush;
  11. //
  12. // Interface class to inherit from GDI+ Brush objects
  13. //
  14. class TestBrushInterface : public TestConfigureInterface,
  15. public TestDialogInterface
  16. {
  17. public:
  18. TestBrushInterface() : brush(NULL) {};
  19. ~TestBrushInterface()
  20. {
  21. delete brush;
  22. }
  23. // acquire brush object
  24. virtual Brush* GetBrush() { return brush; }
  25. virtual INT GetType() = 0;
  26. protected:
  27. // pointer to underlying GDI+ brush object
  28. Brush *brush;
  29. };
  30. class TestBrush : public TestBrushInterface
  31. {
  32. public:
  33. static TestBrush* CreateNewBrush(INT type);
  34. virtual VOID AddToFile(OutputFile* outfile, INT id = 0) = 0;
  35. virtual TestBrush* Clone() = 0;
  36. };
  37. class TestSolidBrush : public TestBrush
  38. {
  39. public:
  40. TestSolidBrush()
  41. {
  42. argb = 0x80000000;
  43. }
  44. // Configuration Interface
  45. virtual BOOL ChangeSettings(HWND hwnd);
  46. virtual VOID Initialize();
  47. // Dialog Management Interface
  48. virtual VOID InitDialog(HWND hwnd);
  49. virtual BOOL SaveValues(HWND hwnd);
  50. virtual BOOL ProcessDialog(HWND hwnd,
  51. UINT msg,
  52. WPARAM wParam,
  53. LPARAM lParam);
  54. // output brush setup to File
  55. virtual VOID AddToFile(OutputFile* outfile, INT id = 0);
  56. // return type of brush
  57. virtual INT GetType()
  58. {
  59. return SolidColorBrush;
  60. };
  61. // Clone interface
  62. virtual TestBrush* Clone()
  63. {
  64. TestSolidBrush *newBrush = new TestSolidBrush();
  65. *newBrush = *this; // bitwise copy
  66. if (brush)
  67. newBrush->brush = brush->Clone(); // clone GDI+ brush
  68. return newBrush;
  69. };
  70. private:
  71. ARGB argb;
  72. };
  73. class TestTextureBrush : public TestBrush
  74. {
  75. public:
  76. TestTextureBrush()
  77. {
  78. filename = NULL;
  79. bitmap = NULL;
  80. wrapMode = 0;
  81. matrix = NULL;
  82. }
  83. ~TestTextureBrush()
  84. {
  85. if (filename)
  86. free(filename);
  87. delete bitmap;
  88. delete matrix;
  89. }
  90. // Configuration Interface
  91. virtual BOOL ChangeSettings(HWND hwnd);
  92. virtual VOID Initialize();
  93. // Dialog Management Interface
  94. virtual VOID InitDialog(HWND hwnd);
  95. virtual BOOL SaveValues(HWND hwnd);
  96. virtual BOOL ProcessDialog(HWND hwnd,
  97. UINT msg,
  98. WPARAM wParam,
  99. LPARAM lParam);
  100. // output brush setup to File
  101. virtual VOID AddToFile(OutputFile* outfile, INT id = 0);
  102. // return type of brush
  103. virtual INT GetType()
  104. {
  105. return TextureFillBrush;
  106. };
  107. // Clone interface
  108. virtual TestBrush* Clone()
  109. {
  110. TestTextureBrush *newBrush = new TestTextureBrush();
  111. *newBrush = *this; // bitwise copy
  112. if (brush)
  113. newBrush->brush = brush->Clone(); // clone GDI+ brush
  114. if (bitmap)
  115. newBrush->bitmap = (Bitmap*)bitmap->Clone();
  116. if (matrix)
  117. newBrush->matrix = matrix->Clone();
  118. if (filename)
  119. {
  120. #ifdef UNICODE
  121. newBrush->filename = _wcsdup(filename);
  122. #else
  123. newBrush->filename = _strdup(filename);
  124. #endif
  125. }
  126. return newBrush;
  127. };
  128. private:
  129. Bitmap *bitmap;
  130. LPTSTR filename;
  131. INT wrapMode;
  132. Matrix *matrix;
  133. };
  134. class TestRectGradBrush : public TestBrush
  135. {
  136. public:
  137. friend class TestRectGradShape;
  138. TestRectGradBrush()
  139. {
  140. horzBlend = vertBlend = NULL;
  141. wrapMode = 0;
  142. matrix = NULL;
  143. }
  144. ~TestRectGradBrush()
  145. {
  146. if (horzBlend)
  147. free(horzBlend);
  148. if (vertBlend)
  149. free(vertBlend);
  150. delete matrix;
  151. }
  152. // Configuration Interface
  153. virtual BOOL ChangeSettings(HWND hwnd);
  154. virtual VOID Initialize();
  155. // Dialog Management Interface
  156. virtual VOID InitDialog(HWND hwnd);
  157. virtual BOOL SaveValues(HWND hwnd);
  158. virtual BOOL ProcessDialog(HWND hwnd,
  159. UINT msg,
  160. WPARAM wParam,
  161. LPARAM lParam);
  162. // output brush setup to File
  163. virtual VOID AddToFile(OutputFile* outfile, INT id = 0);
  164. // return type of brush
  165. virtual INT GetType()
  166. {
  167. return RectGradBrush;
  168. };
  169. // Clone interface
  170. virtual TestBrush* Clone()
  171. {
  172. TestRectGradBrush *newBrush = new TestRectGradBrush();
  173. *newBrush = *this; // bitwise copy
  174. if (brush)
  175. newBrush->brush = brush->Clone(); // clone GDI+ brush
  176. if (matrix)
  177. newBrush->matrix = matrix->Clone();
  178. if (horzCount && horzBlend)
  179. {
  180. INT pos;
  181. newBrush->horzBlend = (REAL*)malloc(sizeof(REAL)*horzCount);
  182. for (pos = 0; pos < horzCount; pos++)
  183. newBrush->horzBlend[pos] = horzBlend[pos];
  184. }
  185. if (vertCount && vertBlend)
  186. {
  187. INT pos;
  188. newBrush->vertBlend = (REAL*)malloc(sizeof(REAL)*vertCount);
  189. for (pos = 0; pos < vertCount; pos++)
  190. newBrush->vertBlend[pos] = vertBlend[pos];
  191. }
  192. return newBrush;
  193. };
  194. private:
  195. ERectangle rect;
  196. ARGB argb[4];
  197. INT horzCount, vertCount;
  198. REAL *horzBlend, *vertBlend;
  199. INT wrapMode;
  200. Matrix *matrix;
  201. };
  202. class TestRadialGradBrush : public TestBrush
  203. {
  204. public:
  205. friend class TestRadialGradShape;
  206. TestRadialGradBrush()
  207. {
  208. blend = NULL;
  209. matrix = NULL;
  210. wrapMode = 0;
  211. }
  212. ~TestRadialGradBrush()
  213. {
  214. if (blend)
  215. free(blend);
  216. delete matrix;
  217. }
  218. // Configuration Interface
  219. virtual BOOL ChangeSettings(HWND hwnd);
  220. virtual VOID Initialize();
  221. // Dialog Management Interface
  222. virtual VOID InitDialog(HWND hwnd);
  223. virtual BOOL SaveValues(HWND hwnd);
  224. virtual BOOL ProcessDialog(HWND hwnd,
  225. UINT msg,
  226. WPARAM wParam,
  227. LPARAM lParam);
  228. // output brush setup to File
  229. virtual VOID AddToFile(OutputFile* outfile, INT id = 0);
  230. // return type of brush
  231. virtual INT GetType()
  232. {
  233. return RadialGradBrush;
  234. };
  235. // Clone interface
  236. virtual TestBrush* Clone()
  237. {
  238. TestRadialGradBrush *newBrush = new TestRadialGradBrush();
  239. *newBrush = *this; // bitwise copy
  240. if (brush)
  241. newBrush->brush = brush->Clone(); // clone GDI+ brush
  242. if (matrix)
  243. newBrush->matrix = matrix->Clone();
  244. if (blendCount && blend)
  245. {
  246. INT pos;
  247. blend = (REAL*)malloc(sizeof(REAL)*blendCount);
  248. for (pos = 0; pos < blendCount; pos++)
  249. newBrush->blend[pos] = blend[pos];
  250. }
  251. return newBrush;
  252. };
  253. private:
  254. ERectangle rect;
  255. ARGB centerARGB, boundaryARGB;
  256. INT blendCount;
  257. REAL *blend;
  258. INT wrapMode;
  259. Matrix *matrix;
  260. };
  261. class TestTriangleGradBrush : public TestBrush
  262. {
  263. public:
  264. friend class TestTriangleGradShape;
  265. TestTriangleGradBrush()
  266. {
  267. pts[0].X = 10; pts[0].Y = 10;
  268. pts[1].X = 90; pts[1].Y = 10;
  269. pts[2].X = 50; pts[2].Y = 100;
  270. blend[0] = blend[1] = blend[2] = NULL;
  271. argb[0] = 0x80FF0000;
  272. argb[1] = 0x8000FF00;
  273. argb[2] = 0x800000FF;
  274. wrapMode = 0;
  275. matrix = NULL;
  276. }
  277. ~TestTriangleGradBrush()
  278. {
  279. for (INT pos = 0; pos < 3; pos++)
  280. if (blend[pos])
  281. free(blend[pos]);
  282. delete matrix;
  283. }
  284. // Configuration Interface
  285. virtual BOOL ChangeSettings(HWND hwnd);
  286. virtual VOID Initialize();
  287. // Dialog Management Interface
  288. virtual VOID InitDialog(HWND hwnd);
  289. virtual BOOL SaveValues(HWND hwnd);
  290. virtual BOOL ProcessDialog(HWND hwnd,
  291. UINT msg,
  292. WPARAM wParam,
  293. LPARAM lParam);
  294. // output brush setup to File
  295. virtual VOID AddToFile(OutputFile* outfile, INT id = 0);
  296. // return type of brush
  297. virtual INT GetType()
  298. {
  299. return TriangleGradBrush;
  300. };
  301. // Clone interface
  302. virtual TestBrush* Clone()
  303. {
  304. TestTriangleGradBrush *newBrush = new TestTriangleGradBrush();
  305. *newBrush = *this; // bitwise copy
  306. if (brush)
  307. newBrush->brush = brush->Clone(); // clone GDI+ brush
  308. if (matrix)
  309. newBrush->matrix = matrix->Clone();
  310. for (INT pos = 0; pos < 3; pos++)
  311. {
  312. if (count[pos] && blend[pos])
  313. {
  314. newBrush->blend[pos] = (REAL*)malloc(sizeof(REAL)*count[pos]);
  315. for (INT pos2 = 0; pos2 < 3; pos2++)
  316. newBrush->blend[pos][pos2] = blend[pos][pos2];
  317. }
  318. else
  319. {
  320. newBrush->blend[pos] = NULL;
  321. newBrush->count[pos] = 0;
  322. }
  323. }
  324. return newBrush;
  325. };
  326. private:
  327. ARGB argb[3];
  328. Point pts[3];
  329. INT count[3]; // blend factor counts
  330. REAL* blend[3];
  331. INT wrapMode;
  332. Matrix *matrix;
  333. };
  334. class TestPathGradBrush : public TestBrush
  335. {
  336. public:
  337. friend class TestTriangleGradShape;
  338. TestPathGradBrush()
  339. {
  340. pts.Add(Point(100,100));
  341. pts.Add(Point(100,50));
  342. pts.Add(Point(150,150));
  343. pts.Add(Point(50,150));
  344. surroundBlend = centerBlend = NULL;
  345. surroundCount = centerCount = 0;
  346. argb.Add((ARGB)0x80000000);
  347. argb.Add((ARGB)0x80FF0000);
  348. argb.Add((ARGB)0x8000FF00);
  349. argb.Add((ARGB)0x800000FF);
  350. wrapMode = 0;
  351. matrix = NULL;
  352. }
  353. ~TestPathGradBrush()
  354. {
  355. if (surroundBlend)
  356. free(surroundBlend);
  357. if (centerBlend)
  358. free(centerBlend);
  359. delete matrix;
  360. }
  361. // Configuration Interface
  362. virtual BOOL ChangeSettings(HWND hwnd);
  363. virtual VOID Initialize();
  364. // Dialog Management Interface
  365. virtual VOID InitDialog(HWND hwnd);
  366. virtual BOOL SaveValues(HWND hwnd);
  367. virtual BOOL ProcessDialog(HWND hwnd,
  368. UINT msg,
  369. WPARAM wParam,
  370. LPARAM lParam);
  371. // output brush setup to File
  372. virtual VOID AddToFile(OutputFile* outfile, INT id = 0);
  373. // return type of brush
  374. virtual INT GetType()
  375. {
  376. return PathGradBrush;
  377. };
  378. // Clone interface
  379. virtual TestBrush* Clone()
  380. {
  381. TestPathGradBrush *newBrush = new TestPathGradBrush();
  382. *newBrush = *this; // bitwise copy
  383. if (brush)
  384. newBrush->brush = brush->Clone(); // clone GDI+ brush
  385. if (matrix)
  386. newBrush->matrix = matrix->Clone();
  387. // !! HACK POLICE !! HACK ALERT !!
  388. // internally clone the DataBuffer pointer
  389. pts.RenewDataBuffer();
  390. argb.RenewDataBuffer();
  391. if (surroundCount && surroundBlend)
  392. {
  393. newBrush->surroundBlend = (REAL*) malloc(sizeof(REAL)*surroundCount);
  394. memcpy(newBrush->surroundBlend, surroundBlend, sizeof(REAL)*surroundCount);
  395. }
  396. else
  397. newBrush->surroundBlend = NULL;
  398. if (centerCount && centerBlend)
  399. {
  400. newBrush->centerBlend = (REAL*) malloc(sizeof(REAL)*centerCount);
  401. memcpy(newBrush->centerBlend, centerBlend, sizeof(REAL)*centerCount);
  402. }
  403. else
  404. newBrush->centerBlend = NULL;
  405. return newBrush;
  406. };
  407. private:
  408. ARGBArray argb;
  409. PointArray pts;
  410. REAL* surroundBlend;
  411. REAL* centerBlend;
  412. INT surroundCount; // blend factor counts
  413. INT centerCount;
  414. INT wrapMode;
  415. Matrix *matrix;
  416. };
  417. class TestHatchBrush : public TestBrush
  418. {
  419. public:
  420. TestHatchBrush()
  421. {
  422. foreArgb = 0xFF000000;
  423. backArgb = 0xFFFFFFFF;
  424. hatch = 0;
  425. }
  426. // Configuration Interface
  427. virtual BOOL ChangeSettings(HWND hwnd);
  428. virtual VOID Initialize();
  429. // Dialog Management Interface
  430. virtual VOID InitDialog(HWND hwnd);
  431. virtual BOOL SaveValues(HWND hwnd);
  432. virtual BOOL ProcessDialog(HWND hwnd,
  433. UINT msg,
  434. WPARAM wParam,
  435. LPARAM lParam);
  436. // output brush setup to File
  437. virtual VOID AddToFile(OutputFile* outfile, INT id = 0);
  438. // return type of brush
  439. virtual INT GetType()
  440. {
  441. return HatchFillBrush;
  442. };
  443. // Clone interface
  444. virtual TestBrush* Clone()
  445. {
  446. TestHatchBrush *newBrush = new TestHatchBrush();
  447. *newBrush = *this; // bitwise copy
  448. if (brush)
  449. newBrush->brush = brush->Clone(); // clone GDI+ brush
  450. return newBrush;
  451. };
  452. private:
  453. ARGB foreArgb, backArgb;
  454. INT hatch;
  455. };
  456. #endif // _GDIPBRUSH_HPP