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