選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 
 

794 行
22 KiB

  1. /**************************************************************************\
  2. *
  3. * Copyright (c) 1998-2000, Microsoft Corp. All Rights Reserved.
  4. *
  5. * Module Name:
  6. *
  7. * GdiplusHeaders.h
  8. *
  9. * Abstract:
  10. *
  11. * GDI+ Native C++ public header file
  12. *
  13. \**************************************************************************/
  14. #ifndef _GDIPLUSHEADERS_H
  15. #define _GDIPLUSHEADERS_H
  16. //--------------------------------------------------------------------------
  17. // Abstract base class for regions
  18. //--------------------------------------------------------------------------
  19. // Include the class declarations here and have inline class implementation
  20. // in separate file to avoid circular references.
  21. class Region : public GdiplusBase
  22. {
  23. public:
  24. friend class Graphics;
  25. Region();
  26. Region(IN const RectF& rect);
  27. Region(IN const Rect& rect);
  28. Region(IN const GraphicsPath* path);
  29. Region(IN const BYTE* regionData, IN INT size);
  30. Region(IN HRGN hRgn);
  31. static Region* FromHRGN(IN HRGN hRgn);
  32. ~Region();
  33. Region* Clone() const;
  34. Status MakeInfinite();
  35. Status MakeEmpty();
  36. // Get the size of the buffer needed for the GetData method
  37. UINT GetDataSize() const;
  38. // buffer - where to put the data
  39. // bufferSize - how big the buffer is (should be at least as big as GetDataSize())
  40. // sizeFilled - if not NULL, this is an OUT param that says how many bytes
  41. // of data were written to the buffer.
  42. Status GetData(OUT BYTE* buffer,
  43. IN UINT bufferSize,
  44. OUT UINT* sizeFilled = NULL) const;
  45. Status Intersect(IN const Rect& rect);
  46. Status Intersect(IN const RectF& rect);
  47. Status Intersect(IN const GraphicsPath* path);
  48. Status Intersect(IN const Region* region);
  49. Status Union(IN const Rect& rect);
  50. Status Union(IN const RectF& rect);
  51. Status Union(IN const GraphicsPath* path);
  52. Status Union(IN const Region* region);
  53. Status Xor(IN const Rect& rect);
  54. Status Xor(IN const RectF& rect);
  55. Status Xor(IN const GraphicsPath* path);
  56. Status Xor(IN const Region* region);
  57. Status Exclude(IN const Rect& rect);
  58. Status Exclude(IN const RectF& rect);
  59. Status Exclude(IN const GraphicsPath* path);
  60. Status Exclude(IN const Region* region);
  61. Status Complement(IN const Rect& rect);
  62. Status Complement(IN const RectF& rect);
  63. Status Complement(IN const GraphicsPath* path);
  64. Status Complement(IN const Region* region);
  65. Status Translate(IN REAL dx,
  66. IN REAL dy);
  67. Status Translate(IN INT dx,
  68. IN INT dy);
  69. Status Transform(IN const Matrix* matrix);
  70. Status GetBounds(OUT Rect* rect,
  71. IN const Graphics* g) const;
  72. Status GetBounds(OUT RectF* rect,
  73. IN const Graphics* g) const;
  74. HRGN GetHRGN (IN const Graphics * g) const;
  75. BOOL IsEmpty(IN const Graphics *g) const;
  76. BOOL IsInfinite(IN const Graphics *g) const;
  77. BOOL IsVisible(IN INT x,
  78. IN INT y,
  79. IN const Graphics* g = NULL) const
  80. {
  81. return IsVisible(Point(x, y), g);
  82. }
  83. BOOL IsVisible(IN const Point& point,
  84. IN const Graphics* g = NULL) const;
  85. BOOL IsVisible(IN REAL x,
  86. IN REAL y,
  87. IN const Graphics* g = NULL) const
  88. {
  89. return IsVisible(PointF(x, y), g);
  90. }
  91. BOOL IsVisible(IN const PointF& point,
  92. IN const Graphics* g = NULL) const;
  93. BOOL IsVisible(IN INT x,
  94. IN INT y,
  95. IN INT width,
  96. IN INT height,
  97. IN const Graphics* g) const
  98. {
  99. return IsVisible(Rect(x, y, width, height), g);
  100. }
  101. BOOL IsVisible(IN const Rect& rect,
  102. IN const Graphics* g = NULL) const;
  103. BOOL IsVisible(IN REAL x,
  104. IN REAL y,
  105. IN REAL width,
  106. IN REAL height,
  107. IN const Graphics* g = NULL) const
  108. {
  109. return IsVisible(RectF(x, y, width, height), g);
  110. }
  111. BOOL IsVisible(IN const RectF& rect,
  112. IN const Graphics* g = NULL) const;
  113. BOOL Equals(IN const Region* region,
  114. IN const Graphics* g) const;
  115. UINT GetRegionScansCount(IN const Matrix* matrix) const;
  116. Status GetRegionScans(IN const Matrix* matrix,
  117. OUT RectF* rects,
  118. OUT INT* count) const;
  119. Status GetRegionScans(IN const Matrix* matrix,
  120. OUT Rect* rects,
  121. OUT INT* count) const;
  122. Status GetLastStatus() const;
  123. protected:
  124. #ifdef DCR_USE_NEW_250932
  125. private:
  126. Region(const Region &region);
  127. Region& operator=(const Region &region);
  128. protected:
  129. #else
  130. Region(const Region &region)
  131. {
  132. region; // reference parameter
  133. SetStatus(NotImplemented);
  134. }
  135. Region& operator=(const Region &region)
  136. {
  137. region; // reference parameter
  138. SetStatus(NotImplemented);
  139. return *this;
  140. }
  141. #endif
  142. Status SetStatus(Status status) const
  143. {
  144. if (status != Ok)
  145. return (lastResult = status);
  146. else
  147. return status;
  148. }
  149. Region(GpRegion* nativeRegion);
  150. VOID SetNativeRegion(GpRegion* nativeRegion);
  151. protected:
  152. GpRegion* nativeRegion;
  153. mutable Status lastResult;
  154. };
  155. //--------------------------------------------------------------------------
  156. // Abstract base class for FontFamily
  157. //--------------------------------------------------------------------------
  158. class FontFamily : public GdiplusBase
  159. {
  160. public:
  161. friend class Font;
  162. friend class Graphics;
  163. friend class GraphicsPath;
  164. friend class FontCollection;
  165. FontFamily();
  166. FontFamily(
  167. IN const WCHAR *name,
  168. IN const FontCollection *fontCollection = NULL
  169. );
  170. ~FontFamily();
  171. static const FontFamily *GenericSansSerif();
  172. static const FontFamily *GenericSerif();
  173. static const FontFamily *GenericMonospace();
  174. Status GetFamilyName(
  175. OUT WCHAR name[LF_FACESIZE],
  176. IN LANGID language = 0
  177. ) const;
  178. // Copy operator
  179. FontFamily * Clone() const;
  180. BOOL IsAvailable() const
  181. {
  182. return (nativeFamily != NULL);
  183. };
  184. BOOL IsStyleAvailable(IN INT style) const;
  185. UINT16 GetEmHeight (IN INT style) const;
  186. UINT16 GetCellAscent (IN INT style) const;
  187. UINT16 GetCellDescent (IN INT style) const;
  188. UINT16 GetLineSpacing (IN INT style) const;
  189. ///////////////////////////////////////////////////////////
  190. Status GetLastStatus() const;
  191. #ifdef DCR_USE_NEW_250932
  192. private:
  193. FontFamily(const FontFamily &);
  194. FontFamily& operator=(const FontFamily &);
  195. #endif
  196. protected:
  197. Status SetStatus(Status status) const;
  198. // private constructor for copy
  199. FontFamily(GpFontFamily * nativeFamily, Status status);
  200. ///////////////////////////////////////
  201. // Data members
  202. protected:
  203. GpFontFamily *nativeFamily;
  204. mutable Status lastResult;
  205. };
  206. static FontFamily *GenericSansSerifFontFamily = NULL;
  207. static FontFamily *GenericSerifFontFamily = NULL;
  208. static FontFamily *GenericMonospaceFontFamily = NULL;
  209. static BYTE GenericSansSerifFontFamilyBuffer[sizeof(FontFamily)] = {0};
  210. static BYTE GenericSerifFontFamilyBuffer [sizeof(FontFamily)] = {0};
  211. static BYTE GenericMonospaceFontFamilyBuffer[sizeof(FontFamily)] = {0};
  212. //--------------------------------------------------------------------------
  213. // Abstract base class for fonts
  214. //--------------------------------------------------------------------------
  215. class Font : public GdiplusBase
  216. {
  217. public:
  218. friend class Graphics;
  219. Font(IN HDC hdc);
  220. Font(IN HDC hdc,
  221. IN const LOGFONTA* logfont);
  222. Font(IN HDC hdc,
  223. IN const LOGFONTW* logfont);
  224. #ifdef DCR_USE_NEW_127084
  225. Font(IN HDC hdc,
  226. IN const HFONT hfont);
  227. #endif
  228. Font(
  229. IN const FontFamily * family,
  230. IN REAL emSize,
  231. IN INT style = FontStyleRegular,
  232. IN Unit unit = UnitPoint
  233. );
  234. Font(
  235. IN const WCHAR * familyName,
  236. IN REAL emSize,
  237. IN INT style = FontStyleRegular,
  238. IN Unit unit = UnitPoint,
  239. IN const FontCollection * fontCollection = NULL
  240. );
  241. Status GetLogFontA(IN const Graphics* g,
  242. OUT LOGFONTA * logfontA) const;
  243. Status GetLogFontW(IN const Graphics* g,
  244. OUT LOGFONTW * logfontW) const;
  245. Font* Clone() const;
  246. ~Font();
  247. BOOL IsAvailable() const;
  248. INT GetStyle() const;
  249. REAL GetSize() const;
  250. Unit GetUnit() const;
  251. Status GetLastStatus() const;
  252. REAL GetHeight(IN const Graphics *graphics = NULL) const;
  253. #ifdef DCR_USE_NEW_125467
  254. REAL GetHeight(IN REAL dpi) const;
  255. #endif
  256. Status GetFamily(OUT FontFamily *family) const;
  257. #ifdef DCR_USE_NEW_250932
  258. private:
  259. Font(const Font &);
  260. Font& operator=(const Font &);
  261. #endif
  262. protected:
  263. Font(GpFont* font, Status status);
  264. VOID SetNativeFont(GpFont *Font);
  265. Status SetStatus(Status status) const;
  266. protected:
  267. /*
  268. * handle to native line texture object
  269. */
  270. GpFont* nativeFont;
  271. mutable Status lastResult;
  272. };
  273. //--------------------------------------------------------------------------
  274. // Abstract base classes for font collections
  275. //--------------------------------------------------------------------------
  276. class FontCollection : public GdiplusBase
  277. {
  278. public:
  279. friend class FontFamily;
  280. FontCollection();
  281. virtual ~FontCollection();
  282. INT GetFamilyCount() const; // number of enumerable families in the collection
  283. Status GetFamilies( // enumerate the fonts in a collection
  284. IN INT numSought,
  285. OUT FontFamily * gpfamilies,
  286. OUT INT * numFound
  287. ) const;
  288. Status GetLastStatus() const;
  289. #ifdef DCR_USE_NEW_250932
  290. private:
  291. FontCollection(const FontCollection &);
  292. FontCollection& operator=(const FontCollection &);
  293. #endif
  294. protected:
  295. Status SetStatus(Status status) const ;
  296. GpFontCollection *nativeFontCollection;
  297. mutable Status lastResult;
  298. };
  299. class InstalledFontCollection : public FontCollection
  300. {
  301. public:
  302. InstalledFontCollection();
  303. ~InstalledFontCollection();
  304. #ifdef DCR_USE_NEW_250932
  305. private:
  306. InstalledFontCollection(const InstalledFontCollection &);
  307. InstalledFontCollection& operator=(const InstalledFontCollection &);
  308. #endif
  309. protected:
  310. #ifndef DCR_USE_NEW_235072
  311. Status InstallFontFile(IN const WCHAR* filename);
  312. Status UninstallFontFile(IN const WCHAR* filename);
  313. #endif
  314. Status SetStatus(Status status) const ;
  315. };
  316. class PrivateFontCollection : public FontCollection
  317. {
  318. public:
  319. PrivateFontCollection();
  320. ~PrivateFontCollection();
  321. Status AddFontFile(IN const WCHAR* filename);
  322. Status AddMemoryFont(IN const VOID* memory,
  323. IN INT length);
  324. #ifdef DCR_USE_NEW_250932
  325. private:
  326. PrivateFontCollection(const PrivateFontCollection &);
  327. PrivateFontCollection& operator=(const PrivateFontCollection &);
  328. #endif
  329. };
  330. //--------------------------------------------------------------------------
  331. // Abstract base class for bitmap image and metafile
  332. //--------------------------------------------------------------------------
  333. // !!! Note:
  334. // Include the class declarations here and have the inline class
  335. // implementation in a separate file. This is done to resolve a
  336. // circular dependency since one of the Bitmap methods needs to
  337. // access the private member nativeGraphics of the Graphics object.
  338. class Image : public GdiplusBase
  339. {
  340. public:
  341. friend class Brush;
  342. friend class TextureBrush;
  343. friend class Graphics;
  344. #ifndef DCR_USE_NEW_140782
  345. Image(
  346. IN const WCHAR* filename
  347. );
  348. Image(
  349. IN IStream* stream
  350. );
  351. static Image* FromFile(
  352. IN const WCHAR* filename
  353. );
  354. static Image* FromStream(
  355. IN IStream* stream
  356. );
  357. #else
  358. Image(
  359. IN const WCHAR* filename,
  360. IN BOOL useEmbeddedColorManagement = FALSE
  361. );
  362. Image(
  363. IN IStream* stream,
  364. IN BOOL useEmbeddedColorManagement = FALSE
  365. );
  366. static Image* FromFile(
  367. IN const WCHAR* filename,
  368. IN BOOL useEmbeddedColorManagement = FALSE
  369. );
  370. static Image* FromStream(
  371. IN IStream* stream,
  372. IN BOOL useEmbeddedColorManagement = FALSE
  373. );
  374. #endif
  375. virtual ~Image();
  376. virtual Image* Clone();
  377. Status Save(IN const WCHAR* filename,
  378. IN const CLSID* clsidEncoder,
  379. IN const EncoderParameters *encoderParams = NULL);
  380. Status Save(IN IStream* stream,
  381. IN const CLSID* clsidEncoder,
  382. IN const EncoderParameters *encoderParams = NULL);
  383. Status SaveAdd(IN const EncoderParameters* encoderParams);
  384. Status SaveAdd(IN Image* newImage,
  385. IN const EncoderParameters* encoderParams);
  386. ImageType GetType() const;
  387. Status GetPhysicalDimension(OUT SizeF* size);
  388. Status GetBounds(OUT RectF* srcRect,
  389. OUT Unit* srcUnit);
  390. UINT GetWidth();
  391. UINT GetHeight();
  392. REAL GetHorizontalResolution();
  393. REAL GetVerticalResolution();
  394. UINT GetFlags();
  395. Status GetRawFormat(OUT GUID *format);
  396. PixelFormat GetPixelFormat();
  397. INT GetPaletteSize();
  398. Status GetPalette(OUT ColorPalette* palette,
  399. IN INT size);
  400. Status SetPalette(IN const ColorPalette* palette);
  401. Image* GetThumbnailImage(IN UINT thumbWidth,
  402. IN UINT thumbHeight,
  403. IN GetThumbnailImageAbort callback = NULL,
  404. IN VOID* callbackData = NULL);
  405. UINT GetFrameDimensionsCount();
  406. Status GetFrameDimensionsList(OUT GUID* dimensionIDs,
  407. IN UINT count);
  408. UINT GetFrameCount(IN const GUID* dimensionID);
  409. Status SelectActiveFrame(IN const GUID* dimensionID,
  410. IN UINT frameIndex);
  411. Status RotateFlip(IN RotateFlipType rotateFlipType);
  412. UINT GetPropertyCount();
  413. Status GetPropertyIdList(IN UINT numOfProperty,
  414. OUT PROPID* list);
  415. UINT GetPropertyItemSize(IN PROPID propId);
  416. Status GetPropertyItem(IN PROPID propId,
  417. IN UINT propSize,
  418. OUT PropertyItem* buffer);
  419. Status GetPropertySize(OUT UINT* totalBufferSize,
  420. OUT UINT* numProperties);
  421. Status GetAllPropertyItems(IN UINT totalBufferSize,
  422. IN UINT numProperties,
  423. OUT PropertyItem* allItems);
  424. Status RemovePropertyItem(IN PROPID propId);
  425. Status SetPropertyItem(IN const PropertyItem* item);
  426. UINT GetEncoderParameterListSize(IN const CLSID* clsidEncoder);
  427. Status GetEncoderParameterList(IN const CLSID* clsidEncoder,
  428. IN UINT size,
  429. OUT EncoderParameters* buffer);
  430. // Support for Middle East localization (right-to-left mirroring)
  431. ImageLayout GetLayout() const;
  432. Status SetLayout(IN const ImageLayout layout);
  433. Status GetLastStatus() const;
  434. protected:
  435. Image() {}
  436. Image(GpImage *nativeImage, Status status);
  437. VOID SetNativeImage(GpImage* nativeImage);
  438. Status SetStatus(Status status) const
  439. {
  440. if (status != Ok)
  441. return (lastResult = status);
  442. else
  443. return status;
  444. }
  445. GpImage* nativeImage;
  446. mutable Status lastResult;
  447. mutable Status loadStatus;
  448. #ifdef DCR_USE_NEW_250932
  449. private:
  450. #else
  451. protected:
  452. #endif
  453. // Disable copy constructor and assignment operator
  454. Image(IN const Image& C);
  455. Image& operator=(IN const Image& C);
  456. };
  457. class Bitmap : public Image
  458. {
  459. public:
  460. friend class Image;
  461. friend class CachedBitmap;
  462. Bitmap(
  463. IN const WCHAR *filename,
  464. IN BOOL useEmbeddedColorManagement = FALSE
  465. );
  466. Bitmap(
  467. IN IStream *stream,
  468. IN BOOL useEmbeddedColorManagement = FALSE
  469. );
  470. static Bitmap* FromFile(
  471. IN const WCHAR *filename,
  472. IN BOOL useEmbeddedColorManagement = FALSE
  473. );
  474. static Bitmap* FromStream(
  475. IN IStream *stream,
  476. IN BOOL useEmbeddedColorManagement = FALSE
  477. );
  478. Bitmap(IN INT width,
  479. IN INT height,
  480. IN INT stride, PixelFormat format,
  481. IN BYTE* scan0);
  482. Bitmap(IN INT width,
  483. IN INT height,
  484. IN PixelFormat format = PixelFormat32bppARGB);
  485. Bitmap(IN INT width,
  486. IN INT height,
  487. IN Graphics* target);
  488. Bitmap* Clone(IN const Rect& rect,
  489. IN PixelFormat format);
  490. Bitmap* Clone(IN INT x,
  491. IN INT y,
  492. IN INT width,
  493. IN INT height,
  494. IN PixelFormat format);
  495. Bitmap* Clone(IN const RectF& rect,
  496. IN PixelFormat format);
  497. Bitmap* Clone(IN REAL x,
  498. IN REAL y,
  499. IN REAL width,
  500. IN REAL height,
  501. IN PixelFormat format);
  502. Status LockBits(IN const Rect* rect,
  503. IN UINT flags,
  504. IN PixelFormat format,
  505. OUT BitmapData* lockedBitmapData);
  506. Status UnlockBits(IN BitmapData* lockedBitmapData);
  507. Status GetPixel(IN INT x,
  508. IN INT y,
  509. OUT Color *color);
  510. Status SetPixel(IN INT x,
  511. IN INT y,
  512. IN const Color &color);
  513. Status SetResolution(IN REAL xdpi,
  514. IN REAL ydpi);
  515. // GDI interop:
  516. Bitmap(IN IDirectDrawSurface7* surface);
  517. Bitmap(IN const BITMAPINFO* gdiBitmapInfo,
  518. IN VOID* gdiBitmapData);
  519. Bitmap(IN HBITMAP hbm,
  520. IN HPALETTE hpal);
  521. Bitmap(IN HICON hicon);
  522. Bitmap(IN HINSTANCE hInstance,
  523. IN const WCHAR * bitmapName);
  524. static Bitmap* FromDirectDrawSurface7(IN IDirectDrawSurface7* surface);
  525. static Bitmap* FromBITMAPINFO(IN const BITMAPINFO* gdiBitmapInfo,
  526. IN VOID* gdiBitmapData);
  527. static Bitmap* FromHBITMAP(IN HBITMAP hbm,
  528. IN HPALETTE hpal);
  529. static Bitmap* FromHICON(IN HICON hicon);
  530. static Bitmap* FromResource(IN HINSTANCE hInstance,
  531. IN const WCHAR * bitmapName);
  532. Status GetHBITMAP(IN const Color& colorBackground,
  533. OUT HBITMAP *hbmReturn);
  534. Status GetHICON(HICON *hicon);
  535. #ifdef DCR_USE_NEW_250932
  536. private:
  537. Bitmap(const Bitmap &);
  538. Bitmap& operator=(const Bitmap &);
  539. #endif
  540. protected:
  541. Bitmap(GpBitmap *nativeBitmap);
  542. };
  543. class CustomLineCap : public GdiplusBase
  544. {
  545. public:
  546. friend class Pen;
  547. CustomLineCap(
  548. IN const GraphicsPath* fillPath,
  549. IN const GraphicsPath* strokePath,
  550. IN LineCap baseCap = LineCapFlat,
  551. IN REAL baseInset = 0
  552. );
  553. virtual ~CustomLineCap();
  554. CustomLineCap* Clone() const;
  555. Status SetStrokeCap(IN LineCap strokeCap)
  556. {
  557. // This changes both start and and caps.
  558. return SetStrokeCaps(strokeCap, strokeCap);
  559. }
  560. Status SetStrokeCaps(IN LineCap startCap,
  561. IN LineCap endCap);
  562. Status GetStrokeCaps(OUT LineCap* startCap,
  563. OUT LineCap* endCap) const;
  564. Status SetStrokeJoin(IN LineJoin lineJoin);
  565. LineJoin GetStrokeJoin() const;
  566. Status SetBaseCap(IN LineCap baseCap);
  567. LineCap GetBaseCap() const;
  568. Status SetBaseInset(IN REAL inset);
  569. REAL GetBaseInset() const;
  570. Status SetWidthScale(IN REAL widthScale);
  571. REAL GetWidthScale() const;
  572. protected:
  573. CustomLineCap();
  574. #ifdef DCR_USE_NEW_250932
  575. private:
  576. CustomLineCap(const CustomLineCap &);
  577. CustomLineCap& operator=(const CustomLineCap &);
  578. protected:
  579. #else
  580. CustomLineCap(const CustomLineCap& customLineCap)
  581. {
  582. customLineCap;
  583. SetStatus(NotImplemented);
  584. }
  585. CustomLineCap& operator=(const CustomLineCap& customLineCap)
  586. {
  587. customLineCap;
  588. SetStatus(NotImplemented);
  589. return *this;
  590. }
  591. #endif
  592. CustomLineCap(GpCustomLineCap* nativeCap, Status status)
  593. {
  594. lastResult = status;
  595. SetNativeCap(nativeCap);
  596. }
  597. VOID SetNativeCap(GpCustomLineCap* nativeCap)
  598. {
  599. this->nativeCap = nativeCap;
  600. }
  601. Status SetStatus(Status status) const
  602. {
  603. if (status != Ok)
  604. return (lastResult = status);
  605. else
  606. return status;
  607. }
  608. protected:
  609. GpCustomLineCap* nativeCap;
  610. mutable Status lastResult;
  611. };
  612. class CachedBitmap : public GdiplusBase
  613. {
  614. friend class Graphics;
  615. public:
  616. CachedBitmap(IN Bitmap *bitmap,
  617. IN Graphics *graphics);
  618. virtual ~CachedBitmap();
  619. Status GetLastStatus() const;
  620. #ifdef DCR_USE_NEW_250932
  621. private:
  622. CachedBitmap(const CachedBitmap &);
  623. CachedBitmap& operator=(const CachedBitmap &);
  624. #endif
  625. protected:
  626. GpCachedBitmap *nativeCachedBitmap;
  627. mutable Status lastResult;
  628. };
  629. #endif // !_GDIPLUSHEADERS.HPP