]> git.saurik.com Git - wxWidgets.git/blob - interface/gdicmn.h
[ 1936700 ] wxCAL_SHOW_WEEK_NUMBERS, slightly modified
[wxWidgets.git] / interface / gdicmn.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: gdicmn.h
3 // Purpose: interface of wxRealPoint
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9
10 /**
11 Bitmap type flags.
12
13 See wxBitmap and wxImage classes.
14 */
15 enum wxBitmapType
16 {
17 wxBITMAP_TYPE_INVALID,
18 wxBITMAP_TYPE_BMP,
19 wxBITMAP_TYPE_BMP_RESOURCE,
20 wxBITMAP_TYPE_RESOURCE = wxBITMAP_TYPE_BMP_RESOURCE,
21 wxBITMAP_TYPE_ICO,
22 wxBITMAP_TYPE_ICO_RESOURCE,
23 wxBITMAP_TYPE_CUR,
24 wxBITMAP_TYPE_CUR_RESOURCE,
25 wxBITMAP_TYPE_XBM,
26 wxBITMAP_TYPE_XBM_DATA,
27 wxBITMAP_TYPE_XPM,
28 wxBITMAP_TYPE_XPM_DATA,
29 wxBITMAP_TYPE_TIF,
30 wxBITMAP_TYPE_TIF_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 Standard cursors.
55
56 See wxCursor.
57 */
58 enum wxStockCursor
59 {
60 wxCURSOR_NONE,
61 wxCURSOR_ARROW,
62 wxCURSOR_RIGHT_ARROW,
63 wxCURSOR_BULLSEYE,
64 wxCURSOR_CHAR,
65 wxCURSOR_CROSS,
66 wxCURSOR_HAND,
67 wxCURSOR_IBEAM,
68 wxCURSOR_LEFT_BUTTON,
69 wxCURSOR_MAGNIFIER,
70 wxCURSOR_MIDDLE_BUTTON,
71 wxCURSOR_NO_ENTRY,
72 wxCURSOR_PAINT_BRUSH,
73 wxCURSOR_PENCIL,
74 wxCURSOR_POINT_LEFT,
75 wxCURSOR_POINT_RIGHT,
76 wxCURSOR_QUESTION_ARROW,
77 wxCURSOR_RIGHT_BUTTON,
78 wxCURSOR_SIZENESW,
79 wxCURSOR_SIZENS,
80 wxCURSOR_SIZENWSE,
81 wxCURSOR_SIZEWE,
82 wxCURSOR_SIZING,
83 wxCURSOR_SPRAYCAN,
84 wxCURSOR_WAIT,
85 wxCURSOR_WATCH,
86 wxCURSOR_BLANK,
87 wxCURSOR_DEFAULT, //!< standard X11 cursor
88 wxCURSOR_COPY_ARROW , //!< MacOS Theme Plus arrow
89 // Not yet implemented for Windows
90 wxCURSOR_CROSS_REVERSE,
91 wxCURSOR_DOUBLE_ARROW,
92 wxCURSOR_BASED_ARROW_UP,
93 wxCURSOR_BASED_ARROW_DOWN,
94 wxCURSOR_ARROWWAIT,
95 wxCURSOR_MAX
96 };
97
98
99
100 /**
101 @class wxRealPoint
102 @wxheader{gdicmn.h}
103
104 A @b wxRealPoint is a useful data structure for graphics operations.
105
106 It contains floating point @e x and @e y members.
107 See also wxPoint for an integer version.
108
109 @library{wxcore}
110 @category{data}
111
112 @see wxPoint
113 */
114 class wxRealPoint
115 {
116 public:
117 wxRealPoint();
118
119 /**
120 Initializes the point with the given coordinates.
121 */
122 wxRealPoint(double x, double y);
123
124 /**
125 X coordinate of this point.
126 */
127 double x;
128
129 /**
130 Y coordinate of this point.
131 */
132 double y;
133 };
134
135
136
137 /**
138 @class wxRect
139 @wxheader{gdicmn.h}
140
141 A class for manipulating rectangles.
142
143 @library{wxcore}
144 @category{data}
145
146 @see wxPoint, wxSize
147 */
148 class wxRect
149 {
150 public:
151 //@{
152 /**
153 Creates a wxRect object from size values at the origin.
154 */
155 wxRect();
156 wxRect(int x, int y, int width, int height);
157 wxRect(const wxPoint& topLeft, const wxPoint& bottomRight);
158 wxRect(const wxPoint& pos, const wxSize& size);
159 wxRect(const wxSize& size);
160 //@}
161
162 //@{
163 /**
164 Returns the rectangle having the same size as this one but centered relatively
165 to the given rectangle @e r. By default, rectangle is centred in both
166 directions but if @a dir includes only @c wxVERTICAL or only
167 @c wxHORIZONTAL flag, then it is only centered in this direction while
168 the other component of its position remains unchanged.
169 */
170 wxRect CentreIn(const wxRect& r, int dir = wxBOTH) const;
171 const wxRect CenterIn(const wxRect& r, int dir = wxBOTH) const;
172 //@}
173
174 //@{
175 /**
176 Returns @true if the given rectangle is completely inside this rectangle
177 (or touches its boundary) and @false otherwise.
178 */
179 bool Contains(int x, int y) const;
180 const bool Contains(const wxPoint& pt) const;
181 const bool Contains(const wxRect& rect) const;
182 //@}
183
184 //@{
185 /**
186 Decrease the rectangle size.
187 This method is the opposite from Inflate():
188 Deflate(a, b) is equivalent to Inflate(-a, -b).
189 Please refer to Inflate() for full description.
190
191 @see Inflate()
192 */
193 void Deflate(wxCoord dx, wxCoord dy) const;
194 void Deflate(const wxSize& diff) const;
195 void Deflate(wxCoord diff) const;
196 wxRect Deflate(wxCoord dx, wxCoord dy) const;
197 //@}
198
199 /**
200 Gets the bottom point of the rectangle.
201 */
202 int GetBottom() const;
203
204 /**
205 Gets the position of the bottom left corner.
206 */
207 wxPoint GetBottomLeft() const;
208
209 /**
210 Gets the position of the bottom right corner.
211 */
212 wxPoint GetBottomRight() const;
213
214 /**
215 Gets the height member.
216 */
217 int GetHeight() const;
218
219 /**
220 Gets the left point of the rectangle (the same as wxRect::GetX).
221 */
222 int GetLeft() const;
223
224 /**
225 Gets the position.
226 */
227 wxPoint GetPosition() const;
228
229 /**
230 Gets the right point of the rectangle.
231 */
232 int GetRight() const;
233
234 /**
235 Gets the size.
236
237 @see SetSize()
238 */
239 wxSize GetSize() const;
240
241 /**
242 Gets the top point of the rectangle (the same as wxRect::GetY).
243 */
244 int GetTop() const;
245
246 /**
247 Gets the position of the top left corner of the rectangle, same as
248 GetPosition().
249 */
250 wxPoint GetTopLeft() const;
251
252 /**
253 Gets the position of the top right corner.
254 */
255 wxPoint GetTopRight() const;
256
257 /**
258 Gets the width member.
259 */
260 int GetWidth() const;
261
262 /**
263 Gets the x member.
264 */
265 int GetX() const;
266
267 /**
268 Gets the y member.
269 */
270 int GetY() const;
271
272 //@{
273 /**
274 Increases the size of the rectangle.
275 The second form uses the same @a diff for both @a dx and @e dy.
276 The first two versions modify the rectangle in place, the last one returns a
277 new rectangle leaving this one unchanged.
278 The left border is moved farther left and the right border is moved farther
279 right by @e dx. The upper border is moved farther up and the bottom border
280 is moved farther down by @e dy. (Note the the width and height of the
281 rectangle thus change by 2*@a dx and 2*@e dy, respectively.) If one or
282 both of @a dx and @a dy are negative, the opposite happens: the rectangle
283 size decreases in the respective direction.
284 Inflating and deflating behaves "naturally". Defined more precisely, that
285 means:
286 "Real" inflates (that is, @a dx and/or @a dy = 0) are not
287 constrained. Thus inflating a rectangle can cause its upper left corner
288 to move into the negative numbers. (the versions prior to 2.5.4 forced
289 the top left coordinate to not fall below (0, 0), which implied a
290 forced move of the rectangle.)
291 Deflates are clamped to not reduce the width or height of the
292 rectangle below zero. In such cases, the top-left corner is nonetheless
293 handled properly. For example, a rectangle at (10, 10) with size (20,
294 40) that is inflated by (-15, -15) will become located at (20, 25) at
295 size (0, 10). Finally, observe that the width and height are treated
296 independently. In the above example, the width is reduced by 20,
297 whereas the height is reduced by the full 30 (rather than also stopping
298 at 20, when the width reached zero).
299
300 @see Deflate()
301 */
302 void Inflate(wxCoord dx, wxCoord dy) const;
303 void Inflate(const wxSize& diff) const;
304 void Inflate(wxCoord diff) const;
305 wxRect Inflate(wxCoord dx, wxCoord dy) const;
306 //@}
307
308 //@{
309 /**
310 Modifies the rectangle to contain the overlapping box of this rectangle and the
311 one passed in as parameter. The const version returns the new rectangle, the
312 other one modifies this rectangle in place.
313 */
314 wxRect Intersect(const wxRect& rect);
315 const wxRect& Intersect(const wxRect& rect);
316 //@}
317
318 /**
319 Returns @true if this rectangle has a non-empty intersection with the
320 rectangle @a rect and @false otherwise.
321 */
322 bool Intersects(const wxRect& rect) const;
323
324 /**
325 Returns @true if this rectangle has a width or height less than or equal to
326 0 and @false otherwise.
327 */
328 bool IsEmpty() const;
329
330 //@{
331 /**
332 Moves the rectangle by the specified offset. If @a dx is positive, the
333 rectangle is moved to the right, if @a dy is positive, it is moved to the
334 bottom, otherwise it is moved to the left or top respectively.
335 */
336 void Offset(wxCoord dx, wxCoord dy);
337 void Offset(const wxPoint& pt);
338 //@}
339
340 /**
341 Sets the height.
342 */
343 void SetHeight(int height);
344
345 /**
346 Sets the size.
347
348 @see GetSize()
349 */
350 void SetSize(const wxSize& s);
351
352 /**
353 Sets the width.
354 */
355 void SetWidth(int width);
356
357 /**
358 Sets the x position.
359 */
360 void SetX(int x);
361
362 /**
363 Sets the y position.
364 */
365 void SetY(int y);
366
367 //@{
368 /**
369 Modifies the rectangle to contain the bounding box of this rectangle and the
370 one passed in as parameter. The const version returns the new rectangle, the
371 other one modifies this rectangle in place.
372 */
373 wxRect Union(const wxRect& rect);
374 const wxRect& Union(const wxRect& rect);
375 //@}
376
377 /**
378 int height
379 Height member.
380 */
381
382
383 //@{
384 /**
385 Returns the intersection of two rectangles (which may be empty).
386 */
387 bool operator !=(const wxRect& r1, const wxRect& r2);
388 wxRect operator +(const wxRect& r1, const wxRect& r2);
389 wxRect operator +=(const wxRect& r);
390 See also wxRect operator *(const wxRect& r1,
391 const wxRect& r2);
392 wxRect operator *=(const wxRect& r);
393 //@}
394
395 /**
396 Assignment operator.
397 */
398 void operator =(const wxRect& rect);
399
400 /**
401 Equality operator.
402 */
403 bool operator ==(const wxRect& r1, const wxRect& r2);
404
405 /**
406 int width
407 Width member.
408 */
409
410
411 /**
412 int x
413 x coordinate of the top-level corner of the rectangle.
414 */
415
416
417 /**
418 int y
419 y coordinate of the top-level corner of the rectangle.
420 */
421 };
422
423
424
425 /**
426 @class wxPoint
427 @wxheader{gdicmn.h}
428
429 A @b wxPoint is a useful data structure for graphics operations.
430 It simply contains integer @e x and @e y members.
431
432 See also wxRealPoint for a floating point version.
433
434 @library{wxcore}
435 @category{data}
436
437 @stdobjects
438 ::wxDefaultPosition
439
440 @see wxRealPoint
441 */
442 class wxPoint
443 {
444 public:
445 //@{
446 /**
447 Create a point.
448 */
449 wxPoint();
450 wxPoint(int x, int y);
451 //@}
452
453 //@{
454 /**
455 Operators for sum and subtraction between a wxPoint object and a
456 wxSize object.
457 */
458 void operator =(const wxPoint& pt);
459 bool operator ==(const wxPoint& p1, const wxPoint& p2);
460 bool operator !=(const wxPoint& p1, const wxPoint& p2);
461 wxPoint operator +(const wxPoint& p1, const wxPoint& p2);
462 wxPoint operator -(const wxPoint& p1, const wxPoint& p2);
463 wxPoint operator +=(const wxPoint& pt);
464 wxPoint operator -=(const wxPoint& pt);
465 wxPoint operator +(const wxPoint& pt, const wxSize& sz);
466 wxPoint operator -(const wxPoint& pt, const wxSize& sz);
467 wxPoint operator +(const wxSize& sz, const wxPoint& pt);
468 wxPoint operator -(const wxSize& sz, const wxPoint& pt);
469 wxPoint operator +=(const wxSize& sz);
470 wxPoint operator -=(const wxSize& sz);
471 //@}
472
473 /**
474 int x
475 x member.
476 */
477
478
479 /**
480 int y
481 y member.
482 */
483 };
484
485 /**
486 Global istance of a wxPoint initialized with values -1;-1.
487 */
488 wxPoint wxDefaultPosition;
489
490
491 /**
492 @class wxColourDatabase
493 @wxheader{gdicmn.h}
494
495 wxWidgets maintains a database of standard RGB colours for a predefined
496 set of named colours (such as "BLACK", "LIGHT GREY"). The
497 application may add to this set if desired by using
498 wxColourDatabase::AddColour and may use it to look up
499 colours by names using wxColourDatabase::Find or find the names
500 for the standard colour suing wxColourDatabase::FindName.
501
502 There is one predefined instance of this class called
503 @b wxTheColourDatabase.
504
505 @library{wxcore}
506 @category{FIXME}
507
508 @see wxColour
509 */
510 class wxColourDatabase
511 {
512 public:
513 /**
514 Constructs the colour database. It will be initialized at the first use.
515 */
516 wxColourDatabase();
517
518 //@{
519 /**
520 Adds a colour to the database. If a colour with the same name already exists,
521 it is replaced.
522 Please note that the overload taking a pointer is deprecated and will be
523 removed in the next wxWidgets version, please don't use it.
524 */
525 void AddColour(const wxString& colourName,
526 const wxColour& colour);
527 void AddColour(const wxString& colourName, wxColour* colour);
528 //@}
529
530 /**
531 Finds a colour given the name. Returns an invalid colour object (that is, such
532 that its @ref wxColour::isok Ok method returns @false) if the colour wasn't
533 found in the database.
534 */
535 wxColour Find(const wxString& colourName);
536
537 /**
538 Finds a colour name given the colour. Returns an empty string if the colour is
539 not found in the database.
540 */
541 wxString FindName(const wxColour& colour) const;
542 };
543
544
545 /**
546 @class wxSize
547 @wxheader{gdicmn.h}
548
549 A @b wxSize is a useful data structure for graphics operations.
550 It simply contains integer @e width and @e height members.
551
552 wxSize is used throughout wxWidgets as well as wxPoint which, although almost
553 equivalent to wxSize, has a different meaning: wxPoint represents a position
554 while wxSize - the size.
555
556 @b wxPython note: wxPython defines aliases for the @c x and @c y members
557 named @c width and @c height since it makes much more sense for
558 sizes.
559
560 @library{wxcore}
561 @category{data}
562
563 @stdobjects
564 ::wxDefaultSize
565
566 @see wxPoint, wxRealPoint
567 */
568 class wxSize
569 {
570 public:
571 //@{
572 /**
573 Creates a size object.
574 */
575 wxSize();
576 wxSize(int width, int height);
577 //@}
578
579 //@{
580 /**
581 Decreases the size in x- and y- directions
582 By @e size.x and @e size.y for the first overload
583 By @a dx and @a dy for the second one
584 By @a d and @a d for the third one
585
586 @see IncBy()
587 */
588 void DecBy(const wxSize& size);
589 void DecBy(int dx, int dy);
590 void DecBy(int d);
591 //@}
592
593 /**
594 Decrements this object so that both of its dimensions are not greater than the
595 corresponding dimensions of the @e size.
596
597 @see IncTo()
598 */
599 void DecTo(const wxSize& size);
600
601 /**
602 Gets the height member.
603 */
604 int GetHeight() const;
605
606 /**
607 Gets the width member.
608 */
609 int GetWidth() const;
610
611 //@{
612 /**
613 Increases the size in x- and y- directions
614 By @e size.x and @e size.y for the first overload
615 By @a dx and @a dy for the second one
616 By @a d and @a d for the third one
617
618 @see DecBy()
619 */
620 void IncBy(const wxSize& size);
621 void IncBy(int dx, int dy);
622 void IncBy(int d);
623 //@}
624
625 /**
626 Increments this object so that both of its dimensions are not less than the
627 corresponding dimensions of the @e size.
628
629 @see DecTo()
630 */
631 void IncTo(const wxSize& size);
632
633 /**
634 Returns @true if neither of the size object components is equal to -1, which
635 is used as default for the size values in wxWidgets (hence the predefined
636 @c wxDefaultSize has both of its components equal to -1).
637 This method is typically used before calling
638 SetDefaults().
639 */
640 bool IsFullySpecified() const;
641
642 //@{
643 /**
644 Operators for division and multiplication between a wxSize object and an
645 integer.
646 */
647 void operator =(const wxSize& sz);
648 bool operator ==(const wxSize& s1, const wxSize& s2);
649 bool operator !=(const wxSize& s1, const wxSize& s2);
650 wxSize operator +(const wxSize& s1, const wxSize& s2);
651 wxSize operator -(const wxSize& s1, const wxSize& s2);
652 wxSize operator +=(const wxSize& sz);
653 wxSize operator -=(const wxSize& sz);
654 wxSize operator /(const wxSize& sz, int factor);
655 wxSize operator *(const wxSize& sz, int factor);
656 wxSize operator *(int factor, const wxSize& sz);
657 wxSize operator /=(int factor);
658 wxSize operator *=(int factor);
659 //@}
660
661 /**
662 Scales the dimensions of this object by the given factors.
663 If you want to scale both dimensions by the same factor you can also use
664 the @ref operators() "operator *="
665 Returns a reference to this object (so that you can concatenate other
666 operations in the same line).
667 */
668 wxSize Scale(float xscale, float yscale);
669
670 /**
671 Sets the width and height members.
672 */
673 void Set(int width, int height);
674
675 /**
676 Combine this size object with another one replacing the default (i.e. equal
677 to -1) components of this object with those of the other. It is typically
678 used like this:
679
680 @see IsFullySpecified()
681 */
682 void SetDefaults(const wxSize& sizeDefault);
683
684 /**
685 Sets the height.
686 */
687 void SetHeight(int height);
688
689 /**
690 Sets the width.
691 */
692 void SetWidth(int width);
693 };
694
695 /**
696 Global instance of a wxSize object initialized with values -1;-1.
697 */
698 wxSize wxDefaultSize;
699
700
701
702
703 // ============================================================================
704 // Global functions/macros
705 // ============================================================================
706
707 /** @ingroup group_funcmacro_gdi */
708 //@{
709
710 /**
711 This macro loads a bitmap from either application resources (on the
712 platforms for which they exist, i.e. Windows and OS2) or from an XPM file.
713 This can help to avoid using @ifdef_ when creating bitmaps.
714
715 @see @ref overview_bitmap, wxICON()
716
717 @header{wx/gdicmn.h}
718 */
719 #define wxBITMAP(bitmapName)
720
721 /**
722 This macro loads an icon from either application resources (on the
723 platforms for which they exist, i.e. Windows and OS2) or from an XPM file.
724 This can help to avoid using @ifdef_ when creating icons.
725
726 @see @ref overview_bitmap, wxBITMAP()
727
728 @header{wx/gdicmn.h}
729 */
730 wxICON();
731
732 /**
733 Returns @true if the display is colour, @false otherwise.
734
735 @header{wx/gdicmn.h}
736 */
737 bool wxColourDisplay();
738
739 /**
740 Returns the depth of the display (a value of 1 denotes a monochrome
741 display).
742
743 @header{wx/gdicmn.h}
744 */
745 int wxDisplayDepth();
746
747 /**
748 Globally sets the cursor; only has an effect on Windows, Mac and GTK+. You
749 should call this function with wxNullCursor to restore the system cursor.
750
751 @see wxCursor, wxWindow::SetCursor()
752
753 @header{wx/gdicmn.h}
754 */
755 void wxSetCursor(const wxCursor& cursor);
756
757 //@}
758
759 /** @ingroup group_funcmacro_gdi */
760 //@{
761 /**
762 Returns the dimensions of the work area on the display. On Windows this
763 means the area not covered by the taskbar, etc. Other platforms are
764 currently defaulting to the whole display until a way is found to provide
765 this info for all window managers, etc.
766
767 @header{wx/gdicmn.h}
768 */
769 void wxClientDisplayRect(int* x, int* y, int* width, int* height);
770 wxRect wxGetClientDisplayRect();
771 //@}
772
773 /** @ingroup group_funcmacro_gdi */
774 //@{
775 /**
776 Returns the display size in pixels.
777
778 @header{wx/gdicmn.h}
779 */
780 void wxDisplaySize(int* width, int* height);
781 wxSize wxGetDisplaySize();
782 //@}
783
784 /** @ingroup group_funcmacro_gdi */
785 //@{
786 /**
787 Returns the display size in millimeters.
788
789 @header{wx/gdicmn.h}
790 */
791 void wxDisplaySizeMM(int* width, int* height);
792 wxSize wxGetDisplaySizeMM();
793 //@}
794