gdicmn.h 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: gdicmn.h
  3. // Purpose: interface of wxRealPoint
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. Bitmap type flags. See wxBitmap and wxImage classes.
  9. */
  10. enum wxBitmapType
  11. {
  12. wxBITMAP_TYPE_INVALID,
  13. wxBITMAP_TYPE_BMP,
  14. wxBITMAP_TYPE_BMP_RESOURCE,
  15. wxBITMAP_TYPE_RESOURCE = wxBITMAP_TYPE_BMP_RESOURCE,
  16. wxBITMAP_TYPE_ICO,
  17. wxBITMAP_TYPE_ICO_RESOURCE,
  18. wxBITMAP_TYPE_CUR,
  19. wxBITMAP_TYPE_CUR_RESOURCE,
  20. wxBITMAP_TYPE_XBM,
  21. wxBITMAP_TYPE_XBM_DATA,
  22. wxBITMAP_TYPE_XPM,
  23. wxBITMAP_TYPE_XPM_DATA,
  24. wxBITMAP_TYPE_TIFF,
  25. wxBITMAP_TYPE_TIF = wxBITMAP_TYPE_TIFF,
  26. wxBITMAP_TYPE_TIFF_RESOURCE,
  27. wxBITMAP_TYPE_TIF_RESOURCE = wxBITMAP_TYPE_TIFF_RESOURCE,
  28. wxBITMAP_TYPE_GIF,
  29. wxBITMAP_TYPE_GIF_RESOURCE,
  30. wxBITMAP_TYPE_PNG,
  31. wxBITMAP_TYPE_PNG_RESOURCE,
  32. wxBITMAP_TYPE_JPEG,
  33. wxBITMAP_TYPE_JPEG_RESOURCE,
  34. wxBITMAP_TYPE_PNM,
  35. wxBITMAP_TYPE_PNM_RESOURCE,
  36. wxBITMAP_TYPE_PCX,
  37. wxBITMAP_TYPE_PCX_RESOURCE,
  38. wxBITMAP_TYPE_PICT,
  39. wxBITMAP_TYPE_PICT_RESOURCE,
  40. wxBITMAP_TYPE_ICON,
  41. wxBITMAP_TYPE_ICON_RESOURCE,
  42. wxBITMAP_TYPE_ANI,
  43. wxBITMAP_TYPE_IFF,
  44. wxBITMAP_TYPE_TGA,
  45. wxBITMAP_TYPE_MACCURSOR,
  46. wxBITMAP_TYPE_MACCURSOR_RESOURCE,
  47. wxBITMAP_TYPE_ANY = 50
  48. };
  49. /**
  50. Polygon filling mode. See wxDC::DrawPolygon.
  51. */
  52. enum wxPolygonFillMode
  53. {
  54. wxODDEVEN_RULE = 1,
  55. wxWINDING_RULE
  56. };
  57. /**
  58. Standard cursors.
  59. Notice that under wxMSW some of these cursors are defined in @c wx.rc file
  60. and not by the system itself so you should include this file from your own
  61. resource file (possibly creating a trivial resource file just containing a
  62. single include line if you don't need it otherwise) to be able to use them.
  63. See wxCursor.
  64. */
  65. enum wxStockCursor
  66. {
  67. wxCURSOR_NONE,
  68. wxCURSOR_ARROW, ///< A standard arrow cursor.
  69. wxCURSOR_RIGHT_ARROW, ///< A standard arrow cursor pointing to the right.
  70. wxCURSOR_BULLSEYE, ///< Bullseye cursor.
  71. wxCURSOR_CHAR, ///< Rectangular character cursor.
  72. wxCURSOR_CROSS, ///< A cross cursor.
  73. wxCURSOR_HAND, ///< A hand cursor.
  74. wxCURSOR_IBEAM, ///< An I-beam cursor (vertical line).
  75. wxCURSOR_LEFT_BUTTON, ///< Represents a mouse with the left button depressed.
  76. wxCURSOR_MAGNIFIER, ///< A magnifier icon.
  77. wxCURSOR_MIDDLE_BUTTON, ///< Represents a mouse with the middle button depressed.
  78. wxCURSOR_NO_ENTRY, ///< A no-entry sign cursor.
  79. wxCURSOR_PAINT_BRUSH, ///< A paintbrush cursor.
  80. wxCURSOR_PENCIL, ///< A pencil cursor.
  81. wxCURSOR_POINT_LEFT, ///< A cursor that points left.
  82. wxCURSOR_POINT_RIGHT, ///< A cursor that points right.
  83. wxCURSOR_QUESTION_ARROW, ///< An arrow and question mark.
  84. wxCURSOR_RIGHT_BUTTON, ///< Represents a mouse with the right button depressed.
  85. wxCURSOR_SIZENESW, ///< A sizing cursor pointing NE-SW.
  86. wxCURSOR_SIZENS, ///< A sizing cursor pointing N-S.
  87. wxCURSOR_SIZENWSE, ///< A sizing cursor pointing NW-SE.
  88. wxCURSOR_SIZEWE, ///< A sizing cursor pointing W-E.
  89. wxCURSOR_SIZING, ///< A general sizing cursor.
  90. wxCURSOR_SPRAYCAN, ///< A spraycan cursor.
  91. wxCURSOR_WAIT, ///< A wait cursor.
  92. wxCURSOR_WATCH, ///< A watch cursor.
  93. wxCURSOR_BLANK, ///< Transparent cursor.
  94. wxCURSOR_DEFAULT, ///< Standard X11 cursor (only in wxGTK).
  95. wxCURSOR_COPY_ARROW , ///< MacOS Theme Plus arrow (only in wxMac).
  96. wxCURSOR_CROSS_REVERSE, ///< Only available on wxX11.
  97. wxCURSOR_DOUBLE_ARROW, ///< Only available on wxX11.
  98. wxCURSOR_BASED_ARROW_UP, ///< Only available on wxX11.
  99. wxCURSOR_BASED_ARROW_DOWN, ///< Only available on wxX11.
  100. wxCURSOR_ARROWWAIT, ///< A wait cursor with a standard arrow.
  101. wxCURSOR_MAX
  102. };
  103. /**
  104. @class wxRealPoint
  105. A wxRealPoint is a useful data structure for graphics operations.
  106. It contains floating point @e x and @e y members.
  107. See wxPoint for an integer version.
  108. Note that the coordinates stored inside a wxRealPoint object may be negative
  109. and that wxRealPoint functions do not perform any check against negative values.
  110. @library{wxcore}
  111. @category{data}
  112. @see wxPoint
  113. */
  114. class wxRealPoint
  115. {
  116. public:
  117. /**
  118. Initializes to zero the x and y members.
  119. */
  120. wxRealPoint();
  121. /**
  122. Initializes the point with the given coordinates.
  123. */
  124. wxRealPoint(double x, double y);
  125. /**
  126. Converts the given wxPoint (with integer coordinates) to a wxRealPoint.
  127. */
  128. wxRealPoint(const wxPoint& pt);
  129. /**
  130. @name Miscellaneous operators
  131. Note that these operators are documented as class members
  132. (to make them easier to find) but, as their prototype shows,
  133. they are implemented as global operators; note that this is
  134. transparent to the user but it helps to understand why the
  135. following functions are documented to take the wxPoint they
  136. operate on as an explicit argument.
  137. */
  138. //@{
  139. wxRealPoint& operator=(const wxRealPoint& pt);
  140. bool operator ==(const wxRealPoint& p1, const wxRealPoint& p2);
  141. bool operator !=(const wxRealPoint& p1, const wxRealPoint& p2);
  142. wxRealPoint operator +(const wxRealPoint& p1, const wxRealPoint& p2);
  143. wxRealPoint operator -(const wxRealPoint& p1, const wxRealPoint& p2);
  144. wxRealPoint& operator +=(const wxRealPoint& pt);
  145. wxRealPoint& operator -=(const wxRealPoint& pt);
  146. wxRealPoint operator +(const wxRealPoint& pt, const wxSize& sz);
  147. wxRealPoint operator -(const wxRealPoint& pt, const wxSize& sz);
  148. wxRealPoint operator +(const wxSize& sz, const wxRealPoint& pt);
  149. wxRealPoint operator -(const wxSize& sz, const wxRealPoint& pt);
  150. wxRealPoint& operator +=(const wxSize& sz);
  151. wxRealPoint& operator -=(const wxSize& sz);
  152. wxSize operator /(const wxRealPoint& sz, int factor);
  153. wxSize operator *(const wxRealPoint& sz, int factor);
  154. wxSize operator *(int factor, const wxSize& sz);
  155. wxSize& operator /=(int factor);
  156. wxSize& operator *=(int factor);
  157. //@}
  158. /**
  159. X coordinate of this point.
  160. */
  161. double x;
  162. /**
  163. Y coordinate of this point.
  164. */
  165. double y;
  166. };
  167. /**
  168. @class wxRect
  169. A class for manipulating rectangles.
  170. Note that the x, y coordinates and the width and height stored inside a wxRect
  171. object may be negative and that wxRect functions do not perform any check against
  172. negative values.
  173. @library{wxcore}
  174. @category{data}
  175. @see wxPoint, wxSize
  176. */
  177. class wxRect
  178. {
  179. public:
  180. /**
  181. Default constructor.
  182. Initializes to zero the internal @a x, @a y, @a width and @a height members.
  183. */
  184. wxRect();
  185. /**
  186. Creates a wxRect object from @a x, @a y, @a width and @a height values.
  187. */
  188. wxRect(int x, int y, int width, int height);
  189. /**
  190. Creates a wxRect object from top-left and bottom-right points.
  191. */
  192. wxRect(const wxPoint& topLeft, const wxPoint& bottomRight);
  193. /**
  194. Creates a wxRect object from position @a pos and @a size values.
  195. */
  196. wxRect(const wxPoint& pos, const wxSize& size);
  197. /**
  198. Creates a wxRect object from @a size values at the origin.
  199. */
  200. wxRect(const wxSize& size);
  201. //@{
  202. /**
  203. Returns the rectangle having the same size as this one but centered
  204. relatively to the given rectangle @a r. By default, rectangle is
  205. centred in both directions but if @a dir includes only @c wxVERTICAL or
  206. only @c wxHORIZONTAL, then it is only centered in this direction while
  207. the other component of its position remains unchanged.
  208. */
  209. wxRect CentreIn(const wxRect& r, int dir = wxBOTH) const;
  210. wxRect CenterIn(const wxRect& r, int dir = wxBOTH) const;
  211. //@}
  212. /**
  213. Returns @true if the given point is inside the rectangle (or on its
  214. boundary) and @false otherwise.
  215. */
  216. bool Contains(int x, int y) const;
  217. /**
  218. Returns @true if the given point is inside the rectangle (or on its
  219. boundary) and @false otherwise.
  220. */
  221. bool Contains(const wxPoint& pt) const;
  222. /**
  223. Returns @true if the given rectangle is completely inside this
  224. rectangle (or touches its boundary) and @false otherwise.
  225. */
  226. bool Contains(const wxRect& rect) const;
  227. //@{
  228. /**
  229. Decrease the rectangle size.
  230. This method is the opposite from Inflate(): Deflate(a, b) is equivalent
  231. to Inflate(-a, -b). Please refer to Inflate() for full description.
  232. */
  233. wxRect& Deflate(wxCoord dx, wxCoord dy);
  234. wxRect& Deflate(const wxSize& diff);
  235. wxRect& Deflate(wxCoord diff);
  236. wxRect Deflate(wxCoord dx, wxCoord dy) const;
  237. //@}
  238. /**
  239. Gets the bottom point of the rectangle.
  240. */
  241. int GetBottom() const;
  242. /**
  243. Gets the position of the bottom left corner.
  244. */
  245. wxPoint GetBottomLeft() const;
  246. /**
  247. Gets the position of the bottom right corner.
  248. */
  249. wxPoint GetBottomRight() const;
  250. /**
  251. Gets the height member.
  252. */
  253. int GetHeight() const;
  254. /**
  255. Gets the left point of the rectangle (the same as GetX()).
  256. */
  257. int GetLeft() const;
  258. /**
  259. Gets the position.
  260. */
  261. wxPoint GetPosition() const;
  262. /**
  263. Gets the right point of the rectangle.
  264. */
  265. int GetRight() const;
  266. /**
  267. Gets the size.
  268. @see SetSize()
  269. */
  270. wxSize GetSize() const;
  271. /**
  272. Gets the top point of the rectangle (the same as GetY()).
  273. */
  274. int GetTop() const;
  275. /**
  276. Gets the position of the top left corner of the rectangle, same as
  277. GetPosition().
  278. */
  279. wxPoint GetTopLeft() const;
  280. /**
  281. Gets the position of the top right corner.
  282. */
  283. wxPoint GetTopRight() const;
  284. /**
  285. Gets the width member.
  286. */
  287. int GetWidth() const;
  288. /**
  289. Gets the x member.
  290. */
  291. int GetX() const;
  292. /**
  293. Gets the y member.
  294. */
  295. int GetY() const;
  296. //@{
  297. /**
  298. Increases the size of the rectangle.
  299. The left border is moved farther left and the right border is moved
  300. farther right by @a dx. The upper border is moved farther up and the
  301. bottom border is moved farther down by @a dy. (Note that the width and
  302. height of the rectangle thus change by 2*dx and 2*dy, respectively.) If
  303. one or both of @a dx and @a dy are negative, the opposite happens: the
  304. rectangle size decreases in the respective direction.
  305. Inflating and deflating behaves "naturally". Defined more precisely,
  306. that means:
  307. -# "Real" inflates (that is, @a dx and/or @a dy = 0) are not
  308. constrained. Thus inflating a rectangle can cause its upper left
  309. corner to move into the negative numbers. (2.5.4 and older forced
  310. the top left coordinate to not fall below (0, 0), which implied a
  311. forced move of the rectangle.)
  312. -# Deflates are clamped to not reduce the width or height of the
  313. rectangle below zero. In such cases, the top-left corner is
  314. nonetheless handled properly. For example, a rectangle at (10, 10)
  315. with size (20, 40) that is inflated by (-15, -15) will become
  316. located at (20, 25) at size (0, 10). Finally, observe that the width
  317. and height are treated independently. In the above example, the
  318. width is reduced by 20, whereas the height is reduced by the full 30
  319. (rather than also stopping at 20, when the width reached zero).
  320. @see Deflate()
  321. */
  322. wxRect& Inflate(wxCoord dx, wxCoord dy);
  323. wxRect& Inflate(const wxSize& diff);
  324. wxRect& Inflate(wxCoord diff);
  325. wxRect Inflate(wxCoord dx, wxCoord dy) const;
  326. //@}
  327. /**
  328. Modifies this rectangle to contain the overlapping portion of this rectangle
  329. and the one passed in as parameter.
  330. @return This rectangle, modified.
  331. */
  332. wxRect& Intersect(const wxRect& rect);
  333. /**
  334. Returns the overlapping portion of this rectangle and the one passed in as
  335. parameter.
  336. */
  337. wxRect Intersect(const wxRect& rect) const;
  338. /**
  339. Returns @true if this rectangle has a non-empty intersection with the
  340. rectangle @a rect and @false otherwise.
  341. */
  342. bool Intersects(const wxRect& rect) const;
  343. /**
  344. Returns @true if this rectangle has a width or height less than or
  345. equal to 0 and @false otherwise.
  346. */
  347. bool IsEmpty() const;
  348. //@{
  349. /**
  350. Moves the rectangle by the specified offset. If @a dx is positive, the
  351. rectangle is moved to the right, if @a dy is positive, it is moved to the
  352. bottom, otherwise it is moved to the left or top respectively.
  353. */
  354. void Offset(wxCoord dx, wxCoord dy);
  355. void Offset(const wxPoint& pt);
  356. //@}
  357. /**
  358. Sets the height.
  359. */
  360. void SetHeight(int height);
  361. /**
  362. Sets the position.
  363. */
  364. void SetPosition(const wxPoint& pos);
  365. /**
  366. Sets the size.
  367. @see GetSize()
  368. */
  369. void SetSize(const wxSize& s);
  370. /**
  371. Sets the width.
  372. */
  373. void SetWidth(int width);
  374. /**
  375. Sets the x position.
  376. */
  377. void SetX(int x);
  378. /**
  379. Sets the y position.
  380. */
  381. void SetY(int y);
  382. /**
  383. Set the left side of the rectangle.
  384. Notice that because the rectangle stores its left side and width,
  385. calling SetLeft() changes the right side position too -- but does
  386. preserve the width.
  387. */
  388. void SetLeft(int left);
  389. /**
  390. Set the right side of the rectangle.
  391. Notice that this doesn't affect GetLeft() return value but changes the
  392. rectangle width to set its right side to the given position.
  393. */
  394. void SetRight(int right);
  395. /**
  396. Set the top edge of the rectangle.
  397. Notice that because the rectangle stores its top side and height,
  398. calling SetTop() changes the bottom side position too -- but does
  399. preserve the height.
  400. */
  401. void SetTop(int top);
  402. /**
  403. Set the bottom edge of the rectangle.
  404. Notice that this doesn't affect GetTop() return value but changes the
  405. rectangle height to set its bottom side to the given position.
  406. */
  407. void SetBottom(int bottom);
  408. /**
  409. Set the top-left point of the rectangle.
  410. */
  411. void SetTopLeft(const wxPoint &p);
  412. /**
  413. Set the bottom-right point of the rectangle.
  414. */
  415. void SetBottomRight(const wxPoint &p);
  416. /**
  417. Set the top-right point of the rectangle.
  418. */
  419. void SetTopRight(const wxPoint &p);
  420. /**
  421. Set the bottom-left point of the rectangle.
  422. */
  423. void SetBottomLeft(const wxPoint &p);
  424. //@{
  425. /**
  426. Modifies the rectangle to contain the bounding box of this rectangle
  427. and the one passed in as parameter.
  428. */
  429. wxRect Union(const wxRect& rect) const;
  430. wxRect& Union(const wxRect& rect);
  431. //@}
  432. /**
  433. Inequality operator.
  434. */
  435. bool operator !=(const wxRect& r1, const wxRect& r2);
  436. //@{
  437. /**
  438. Like Union(), but doesn't treat empty rectangles specially.
  439. */
  440. wxRect operator +(const wxRect& r1, const wxRect& r2);
  441. wxRect& operator +=(const wxRect& r);
  442. //@}
  443. //@{
  444. /**
  445. Returns the intersection of two rectangles (which may be empty).
  446. */
  447. wxRect operator *(const wxRect& r1, const wxRect& r2);
  448. wxRect& operator *=(const wxRect& r);
  449. //@}
  450. /**
  451. Assignment operator.
  452. */
  453. wxRect& operator=(const wxRect& rect);
  454. /**
  455. Equality operator.
  456. */
  457. bool operator ==(const wxRect& r1, const wxRect& r2);
  458. /**
  459. Height member.
  460. */
  461. int height;
  462. /**
  463. Width member.
  464. */
  465. int width;
  466. /**
  467. x coordinate of the top-level corner of the rectangle.
  468. */
  469. int x;
  470. /**
  471. y coordinate of the top-level corner of the rectangle.
  472. */
  473. int y;
  474. };
  475. /**
  476. @class wxPoint
  477. A wxPoint is a useful data structure for graphics operations.
  478. It contains integer @e x and @e y members.
  479. See wxRealPoint for a floating point version.
  480. Note that the width and height stored inside a wxPoint object may be negative
  481. and that wxPoint functions do not perform any check against negative values
  482. (this is used to e.g. store the special -1 value in ::wxDefaultPosition instance).
  483. @library{wxcore}
  484. @category{data}
  485. @stdobjects
  486. ::wxDefaultPosition
  487. @see wxRealPoint
  488. */
  489. class wxPoint
  490. {
  491. public:
  492. /**
  493. Constructs a point.
  494. Initializes the internal x and y coordinates to zero.
  495. */
  496. wxPoint();
  497. /**
  498. Initializes the point object with the given @a x and @a y coordinates.
  499. */
  500. wxPoint(int x, int y);
  501. /**
  502. Converts the given wxRealPoint (with floating point coordinates) to a
  503. wxPoint instance.
  504. Notice that this truncates the floating point values of @a pt
  505. components, if you want to round them instead you need to do it
  506. manually, e.g.
  507. @code
  508. #include <wx/math.h> // for wxRound()
  509. wxRealPoint rp = ...;
  510. wxPoint p(wxRound(rp.x), wxRound(rp.y));
  511. @endcode
  512. */
  513. wxPoint(const wxRealPoint& pt);
  514. /**
  515. @name Miscellaneous operators
  516. Note that these operators are documented as class members
  517. (to make them easier to find) but, as their prototype shows,
  518. they are implemented as global operators; note that this is
  519. transparent to the user but it helps to understand why the
  520. following functions are documented to take the wxPoint they
  521. operate on as an explicit argument.
  522. */
  523. //@{
  524. wxPoint& operator=(const wxPoint& pt);
  525. bool operator ==(const wxPoint& p1, const wxPoint& p2);
  526. bool operator !=(const wxPoint& p1, const wxPoint& p2);
  527. wxPoint operator +(const wxPoint& p1, const wxPoint& p2);
  528. wxPoint operator -(const wxPoint& p1, const wxPoint& p2);
  529. wxPoint& operator +=(const wxPoint& pt);
  530. wxPoint& operator -=(const wxPoint& pt);
  531. wxPoint operator +(const wxPoint& pt, const wxSize& sz);
  532. wxPoint operator -(const wxPoint& pt, const wxSize& sz);
  533. wxPoint operator +(const wxSize& sz, const wxPoint& pt);
  534. wxPoint operator -(const wxSize& sz, const wxPoint& pt);
  535. wxPoint& operator +=(const wxSize& sz);
  536. wxPoint& operator -=(const wxSize& sz);
  537. wxSize operator /(const wxPoint& sz, int factor);
  538. wxSize operator *(const wxPoint& sz, int factor);
  539. wxSize operator *(int factor, const wxSize& sz);
  540. wxSize& operator /=(int factor);
  541. wxSize& operator *=(int factor);
  542. //@}
  543. /**
  544. @name Defaults handling.
  545. Test for and set non-specified wxPoint components.
  546. Although a wxPoint is always initialized to (0, 0), wxWidgets commonly
  547. uses wxDefaultCoord (defined as @c -1) to indicate that a point hasn't
  548. been initialized or specified. In particular, ::wxDefaultPosition is
  549. used in many places with this meaning.
  550. */
  551. //@{
  552. /**
  553. Returns @true if neither of the point components is equal to
  554. wxDefaultCoord.
  555. This method is typically used before calling SetDefaults().
  556. @since 2.9.2
  557. */
  558. bool IsFullySpecified() const;
  559. /**
  560. Combine this object with another one replacing the uninitialized
  561. values.
  562. It is typically used like this:
  563. @code
  564. if ( !pos.IsFullySpecified() )
  565. {
  566. pos.SetDefaults(GetDefaultPosition());
  567. }
  568. @endcode
  569. @see IsFullySpecified()
  570. @since 2.9.2
  571. */
  572. void SetDefaults(const wxPoint& pt);
  573. //@}
  574. /**
  575. x member.
  576. */
  577. int x;
  578. /**
  579. y member.
  580. */
  581. int y;
  582. };
  583. /**
  584. Global instance of a wxPoint initialized with values (-1,-1).
  585. */
  586. const wxPoint wxDefaultPosition;
  587. /**
  588. @class wxColourDatabase
  589. wxWidgets maintains a database of standard RGB colours for a predefined
  590. set of named colours. The application may add to this set if desired by
  591. using AddColour() and may use it to look up colours by names using Find()
  592. or find the names for the standard colour using FindName().
  593. There is one predefined, global instance of this class called
  594. ::wxTheColourDatabase.
  595. The standard database contains at least the following colours:
  596. @beginTable
  597. <tr><td>
  598. AQUAMARINE
  599. @n BLACK
  600. @n BLUE
  601. @n BLUE VIOLET
  602. @n BROWN
  603. @n CADET BLUE
  604. @n CORAL
  605. @n CORNFLOWER BLUE
  606. @n CYAN
  607. @n DARK GREY
  608. @n DARK GREEN
  609. @n DARK OLIVE GREEN
  610. @n DARK ORCHID
  611. @n DARK SLATE BLUE
  612. @n DARK SLATE GREY
  613. @n DARK TURQUOISE
  614. @n DIM GREY
  615. </td><td>
  616. FIREBRICK
  617. @n FOREST GREEN
  618. @n GOLD
  619. @n GOLDENROD
  620. @n GREY
  621. @n GREEN
  622. @n GREEN YELLOW
  623. @n INDIAN RED
  624. @n KHAKI
  625. @n LIGHT BLUE
  626. @n LIGHT GREY
  627. @n LIGHT STEEL BLUE
  628. @n LIME GREEN
  629. @n MAGENTA
  630. @n MAROON
  631. @n MEDIUM AQUAMARINE
  632. @n MEDIUM BLUE
  633. </td><td>
  634. MEDIUM FOREST GREEN
  635. @n MEDIUM GOLDENROD
  636. @n MEDIUM ORCHID
  637. @n MEDIUM SEA GREEN
  638. @n MEDIUM SLATE BLUE
  639. @n MEDIUM SPRING GREEN
  640. @n MEDIUM TURQUOISE
  641. @n MEDIUM VIOLET RED
  642. @n MIDNIGHT BLUE
  643. @n NAVY
  644. @n ORANGE
  645. @n ORANGE RED
  646. @n ORCHID
  647. @n PALE GREEN
  648. @n PINK
  649. @n PLUM
  650. @n PURPLE
  651. </td><td>
  652. RED
  653. @n SALMON
  654. @n SEA GREEN
  655. @n SIENNA
  656. @n SKY BLUE
  657. @n SLATE BLUE
  658. @n SPRING GREEN
  659. @n STEEL BLUE
  660. @n TAN
  661. @n THISTLE
  662. @n TURQUOISE
  663. @n VIOLET
  664. @n VIOLET RED
  665. @n WHEAT
  666. @n WHITE
  667. @n YELLOW
  668. @n YELLOW GREEN
  669. </td></tr>
  670. @endTable
  671. @library{wxcore}
  672. @category{gdi}
  673. @see wxColour
  674. */
  675. class wxColourDatabase
  676. {
  677. public:
  678. /**
  679. Constructs the colour database. It will be initialized at the first
  680. use.
  681. */
  682. wxColourDatabase();
  683. /**
  684. Adds a colour to the database. If a colour with the same name already
  685. exists, it is replaced.
  686. */
  687. void AddColour(const wxString& colourName, const wxColour& colour);
  688. /**
  689. Finds a colour given the name. Returns an invalid colour object (that
  690. is, wxColour::IsOk() will return @false) if the colour wasn't found in
  691. the database.
  692. */
  693. wxColour Find(const wxString& colourName) const;
  694. /**
  695. Finds a colour name given the colour. Returns an empty string if the
  696. colour is not found in the database.
  697. */
  698. wxString FindName(const wxColour& colour) const;
  699. };
  700. /**
  701. Global instance of a wxColourDatabase.
  702. */
  703. wxColourDatabase* wxTheColourDatabase;
  704. /**
  705. @class wxSize
  706. A wxSize is a useful data structure for graphics operations.
  707. It simply contains integer @e width and @e height members.
  708. Note that the width and height stored inside a wxSize object may be negative
  709. and that wxSize functions do not perform any check against negative values
  710. (this is used to e.g. store the special -1 value in ::wxDefaultSize instance).
  711. See also IsFullySpecified() and SetDefaults() for utility functions regarding
  712. the special -1 value.
  713. wxSize is used throughout wxWidgets as well as wxPoint which, although
  714. almost equivalent to wxSize, has a different meaning: wxPoint represents a
  715. position while wxSize represents the size.
  716. @library{wxcore}
  717. @category{data}
  718. @stdobjects
  719. ::wxDefaultSize
  720. @see wxPoint, wxRealPoint
  721. */
  722. class wxSize
  723. {
  724. public:
  725. /**
  726. Initializes this size object with zero width and height.
  727. */
  728. wxSize();
  729. /**
  730. Initializes this size object with the given @a width and @a height.
  731. */
  732. wxSize(int width, int height);
  733. //@{
  734. /**
  735. Decreases the size in both x and y directions.
  736. @see IncBy()
  737. */
  738. void DecBy(const wxPoint& pt);
  739. void DecBy(const wxSize& size);
  740. void DecBy(int dx, int dy);
  741. void DecBy(int d);
  742. //@}
  743. /**
  744. Decrements this object so that both of its dimensions are not greater
  745. than the corresponding dimensions of the @a size.
  746. @see IncTo()
  747. */
  748. void DecTo(const wxSize& size);
  749. /**
  750. Decrements this object to be not bigger than the given size ignoring
  751. non-specified components.
  752. This is similar to DecTo() but doesn't do anything for x or y
  753. component if the same component of @a size is not specified, i.e. set
  754. to ::wxDefaultCoord.
  755. @since 2.9.5
  756. */
  757. void DecToIfSpecified(const wxSize& size);
  758. /**
  759. Gets the height member.
  760. */
  761. int GetHeight() const;
  762. /**
  763. Gets the width member.
  764. */
  765. int GetWidth() const;
  766. //@{
  767. /**
  768. Increases the size in both x and y directions.
  769. @see DecBy()
  770. */
  771. void IncBy(const wxPoint& pt);
  772. void IncBy(const wxSize& size);
  773. void IncBy(int dx, int dy);
  774. void IncBy(int d);
  775. //@}
  776. /**
  777. Increments this object so that both of its dimensions are not less than
  778. the corresponding dimensions of the @a size.
  779. @see DecTo()
  780. */
  781. void IncTo(const wxSize& size);
  782. /**
  783. Returns @true if neither of the size object components is equal to -1,
  784. which is used as default for the size values in wxWidgets (hence the
  785. predefined ::wxDefaultSize has both of its components equal to -1).
  786. This method is typically used before calling SetDefaults().
  787. */
  788. bool IsFullySpecified() const;
  789. /**
  790. Scales the dimensions of this object by the given factors. If you want
  791. to scale both dimensions by the same factor you can also use
  792. operator*=().
  793. @return A reference to this object (so that you can concatenate other
  794. operations in the same line).
  795. */
  796. wxSize& Scale(float xscale, float yscale);
  797. /**
  798. Sets the width and height members.
  799. */
  800. void Set(int width, int height);
  801. /**
  802. Combine this size object with another one replacing the default (i.e.\ equal to -1)
  803. components of this object with those of the other. It is typically used like this:
  804. @code
  805. if ( !size.IsFullySpecified() )
  806. {
  807. size.SetDefaults(GetDefaultSize());
  808. }
  809. @endcode
  810. @see IsFullySpecified()
  811. */
  812. void SetDefaults(const wxSize& sizeDefault);
  813. /**
  814. Sets the height.
  815. */
  816. void SetHeight(int height);
  817. /**
  818. Sets the width.
  819. */
  820. void SetWidth(int width);
  821. /**
  822. @name Miscellaneous operators
  823. Note that these operators are documented as class members
  824. (to make them easier to find) but, as their prototype shows,
  825. they are implemented as global operators; note that this is
  826. transparent to the user but it helps to understand why the
  827. following functions are documented to take the wxSize they
  828. operate on as an explicit argument.
  829. */
  830. //@{
  831. wxSize& operator=(const wxSize& sz);
  832. bool operator ==(const wxSize& s1, const wxSize& s2);
  833. bool operator !=(const wxSize& s1, const wxSize& s2);
  834. wxSize operator +(const wxSize& s1, const wxSize& s2);
  835. wxSize operator -(const wxSize& s1, const wxSize& s2);
  836. wxSize& operator +=(const wxSize& sz);
  837. wxSize& operator -=(const wxSize& sz);
  838. wxSize operator /(const wxSize& sz, int factor);
  839. wxSize operator *(const wxSize& sz, int factor);
  840. wxSize operator *(int factor, const wxSize& sz);
  841. wxSize& operator /=(int factor);
  842. wxSize& operator *=(int factor);
  843. //@}
  844. };
  845. /**
  846. Global instance of a wxSize object initialized to (-1,-1).
  847. */
  848. const wxSize wxDefaultSize;
  849. // ============================================================================
  850. // Global functions/macros
  851. // ============================================================================
  852. /** @addtogroup group_funcmacro_gdi */
  853. //@{
  854. /**
  855. This macro loads a bitmap from either application resources (on the
  856. platforms for which they exist, i.e. Windows and OS2) or from an XPM file.
  857. This can help to avoid using @ifdef_ when creating bitmaps.
  858. @see @ref overview_bitmap, wxICON()
  859. @header{wx/gdicmn.h}
  860. */
  861. #define wxBITMAP(bitmapName)
  862. /**
  863. Creates a bitmap from either application resources or embedded image data
  864. in PNG format.
  865. This macro is similar to wxBITMAP() but works with bitmap data in PNG
  866. format and not BMP or XPM.
  867. Under Windows the given @a bitmapName must be present in the application
  868. resource file with the type @c RCDATA and refer to a PNG image. I.e. you
  869. should have a definition similar to the following in your @c .rc file:
  870. @code
  871. mybitmap RCDATA "mybitmap.png"
  872. @endcode
  873. to be able to use @c wxBITMAP_PNG(mybitmap) in the code.
  874. Under OS X the file with the specified name and "png" extension must be
  875. present in the "Resources" subdirectory of the application bundle.
  876. Under the other platforms, this is equivalent to wxBITMAP_PNG_FROM_DATA()
  877. and so loads the image data from the array called @c bitmapName_png that
  878. must exist. Notice that it @e must be an array and not a pointer as the
  879. macro needs to be able to determine its size. Such an array can be produced
  880. by a number of conversion programs. A very simple one is included in
  881. wxWidgets distribution as @c misc/scripts/png2c.py.
  882. Finally notice that you must register PNG image handler to be able to
  883. load bitmaps from PNG data. This can be done either by calling
  884. wxInitAllImageHandlers() which also registers all the other image formats
  885. or including the necessary header:
  886. @code
  887. #include <wx/imagpng.h>
  888. @endcode
  889. and calling
  890. @code
  891. wxImage::AddHandler(new wxPNGHandler);
  892. @endcode
  893. in your application startup code.
  894. @see wxBITMAP_PNG_FROM_DATA()
  895. @header{wx/gdicmn.h}
  896. @since 2.9.5
  897. */
  898. #define wxBITMAP_PNG(bitmapName)
  899. /**
  900. Creates a bitmap from embedded image data in PNG format.
  901. This macro is a thin wrapper around wxBitmap::NewFromPNGData() and takes
  902. just the base name of the array containing the image data and computes its
  903. size internally. In other words, the array called @c bitmapName_png must
  904. exist. Notice that it @e must be an array and not a pointer as the macro
  905. needs to be able to determine its size. Such an array can be produced by a
  906. number of conversion programs. A very simple one is included in wxWidgets
  907. distribution as @c misc/scripts/png2c.py.
  908. You can use wxBITMAP_PNG() to load the PNG bitmaps from resources on the
  909. platforms that support this and only fall back to loading them from data
  910. under the other ones (i.e. not Windows and not OS X).
  911. @header{wx/gdicmn.h}
  912. @since 2.9.5
  913. */
  914. #define wxBITMAP_PNG_FROM_DATA(bitmapName)
  915. /**
  916. This macro loads an icon from either application resources (on the
  917. platforms for which they exist, i.e. Windows and OS2) or from an XPM file.
  918. This can help to avoid using @ifdef_ when creating icons.
  919. @see @ref overview_bitmap, wxBITMAP()
  920. @header{wx/gdicmn.h}
  921. */
  922. #define wxICON(iconName)
  923. /**
  924. Returns @true if the display is colour, @false otherwise.
  925. @header{wx/gdicmn.h}
  926. */
  927. bool wxColourDisplay();
  928. /**
  929. Returns the depth of the display (a value of 1 denotes a monochrome
  930. display).
  931. @header{wx/gdicmn.h}
  932. */
  933. int wxDisplayDepth();
  934. /**
  935. Globally sets the cursor; only has an effect on Windows, Mac and GTK+. You
  936. should call this function with wxNullCursor to restore the system cursor.
  937. @see wxCursor, wxWindow::SetCursor()
  938. @header{wx/gdicmn.h}
  939. */
  940. void wxSetCursor(const wxCursor& cursor);
  941. //@}
  942. /** @addtogroup group_funcmacro_gdi */
  943. //@{
  944. /**
  945. Returns the dimensions of the work area on the display.
  946. This is the same as wxGetClientDisplayRect() but allows to retrieve the
  947. individual components instead of the entire rectangle.
  948. Any of the output pointers can be @NULL if the corresponding value is not
  949. needed by the caller.
  950. @see wxDisplay
  951. @header{wx/gdicmn.h}
  952. */
  953. void wxClientDisplayRect(int* x, int* y, int* width, int* height);
  954. //@}
  955. /** @addtogroup group_funcmacro_gdi */
  956. //@{
  957. /**
  958. Returns the dimensions of the work area on the display. On Windows this
  959. means the area not covered by the taskbar, etc. Other platforms are
  960. currently defaulting to the whole display until a way is found to provide
  961. this info for all window managers, etc.
  962. @see wxDisplay
  963. @header{wx/gdicmn.h}
  964. */
  965. wxRect wxGetClientDisplayRect();
  966. //@}
  967. /** @addtogroup group_funcmacro_gdi */
  968. //@{
  969. /**
  970. Returns the display resolution in pixels per inch.
  971. The @c x component of the returned wxSize object contains the horizontal
  972. resolution and the @c y one -- the vertical resolution.
  973. @header{wx/gdicmn.h}
  974. @see wxDisplay
  975. @since 2.9.0
  976. */
  977. wxSize wxGetDisplayPPI();
  978. //@}
  979. /** @addtogroup group_funcmacro_gdi */
  980. //@{
  981. /**
  982. Returns the display size in pixels.
  983. Either of output pointers can be @NULL if the caller is not interested in
  984. the corresponding value.
  985. @see wxGetDisplaySize(), wxDisplay
  986. @header{wx/gdicmn.h}
  987. */
  988. void wxDisplaySize(int* width, int* height);
  989. //@}
  990. /** @addtogroup group_funcmacro_gdi */
  991. //@{
  992. /**
  993. Returns the display size in pixels.
  994. @see wxDisplay
  995. @header{wx/gdicmn.h}
  996. */
  997. wxSize wxGetDisplaySize();
  998. //@}
  999. /** @addtogroup group_funcmacro_gdi */
  1000. //@{
  1001. /**
  1002. Returns the display size in millimeters.
  1003. Either of output pointers can be @NULL if the caller is not interested in
  1004. the corresponding value.
  1005. @see wxGetDisplaySizeMM(), wxDisplay
  1006. @header{wx/gdicmn.h}
  1007. */
  1008. void wxDisplaySizeMM(int* width, int* height);
  1009. //@}
  1010. /** @addtogroup group_funcmacro_gdi */
  1011. //@{
  1012. /**
  1013. Returns the display size in millimeters.
  1014. @see wxDisplay
  1015. @header{wx/gdicmn.h}
  1016. */
  1017. wxSize wxGetDisplaySizeMM();
  1018. //@}