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