00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef OMGUI_TYPES_H
00024 #define OMGUI_TYPES_H
00025
00026
00027 #ifdef OMGUI_WIN32
00028 #ifndef UNICODE
00029 #define UNICODE
00030 #endif
00031 #endif
00032
00033 #include <stddef.h>
00034 #include <omgui/dllimpexp.h>
00035 #include <omgui/refcount.h>
00036 #include <omgui/api-prototypes.h>
00037 #include <string>
00038 #include <sstream>
00039 #include <list>
00040
00041 namespace omgui {
00042
00051 #ifdef OMGUI_WIDECHARS
00052 #define OMGUI_STR(s) L##s
00053 typedef std::wstring string;
00054 typedef std::wstringstream stringstream;
00055 #else // !defined(OMGUI_WIDECHARS)
00056 #define OMGUI_STR(s) s
00057 typedef std::string string;
00058 typedef std::stringstream stringstream;
00059 #endif
00060
00080 enum LAYOUT_FLAGS {
00081 ALIGN_LEFT = 0x01,
00082 ALIGN_RIGHT = 0x02,
00083 ALIGN_CENTER_HORIZONTAL = 0x04,
00084 ALIGN_TOP = 0x08,
00085 ALIGN_BOTTOM = 0x10,
00086 ALIGN_CENTER_VERTICAL = 0x20,
00087 ALIGN_CENTER = ALIGN_CENTER_HORIZONTAL | ALIGN_CENTER_VERTICAL,
00088 EXPAND_HORIZONTAL = 0x40,
00089 EXPAND_VERTICAL = 0x80,
00090 EXPAND_BOTH = EXPAND_HORIZONTAL | EXPAND_VERTICAL,
00091 };
00092
00093 typedef std::list< Pointer<omgui::Widget> > ChildList;
00094
00100 typedef unsigned short menu_id;
00101
00102 typedef int object_id;
00103 const object_id OBJECT_ID_ANY = 0;
00104
00106 typedef int event_id;
00107
00108 class Panel;
00109 typedef Pointer<Panel> NotebookPage;
00110
00114 struct OMGUI_API Size
00115 {
00116 int width, height;
00117
00121 Size()
00122 : width(0),
00123 height(0)
00124 { }
00125
00131 Size(int w, int h)
00132 : width(w),
00133 height(h)
00134 { }
00135
00139 Size &operator+=(const Size &s)
00140 {
00141 width += s.width;
00142 height += s.height;
00143 return *this;
00144 }
00145
00149 Size &operator-=(const Size &s)
00150 {
00151 width -= s.width;
00152 height -= s.height;
00153 return *this;
00154 }
00155
00159 Size &operator*=(float f)
00160 {
00161
00162 width = static_cast<int>(width * f);
00163 height = static_cast<int>(height * f);
00164 return *this;
00165 }
00166
00170 Size &operator/=(float f)
00171 {
00172
00173 width = static_cast<int>(width * f);
00174 height = static_cast<int>(height *f);
00175 return *this;
00176 }
00177
00181 bool operator==(const Size &s)
00182 {
00183 return width == s.width && height == s.height;
00184 }
00185
00189 bool operator!=(const Size &s)
00190 {
00191 return width != s.width || height != s.height;
00192 }
00193 };
00194
00198 struct OMGUI_API Point
00199 {
00200 int x, y;
00201
00205 Point()
00206 : x(0),
00207 y(0)
00208 { }
00209
00215 Point(int xx, int yy)
00216 : x(xx),
00217 y(yy)
00218 { }
00219
00223 Point &operator+=(const Point &p)
00224 {
00225 x += p.x;
00226 y += p.y;
00227 return *this;
00228 }
00229
00233 Point &operator-=(const Point &p)
00234 {
00235 x -= p.x;
00236 y -= p.y;
00237 return *this;
00238 }
00239
00243 bool operator==(const Point &p)
00244 {
00245 return x == p.x && y == p.y;
00246 }
00247
00251 bool operator!=(const Point &p)
00252 {
00253 return x != p.x || y != p.y;
00254 }
00255 };
00256
00260 struct OMGUI_API Rect
00261 {
00262 Size size;
00263 Point position;
00264
00268 Rect()
00269 : size(0,0),
00270 position(0,0)
00271 { }
00272
00278 Rect(const Size &s)
00279 : size(s)
00280 { }
00281
00287 Rect(const Point &p, const Size &s)
00288 : size(s),
00289 position(p)
00290 { }
00291
00299 Rect(int x, int y, int w, int h)
00300 : size(w,h),
00301 position(x,y)
00302 { }
00303
00307 bool operator==(const Rect &r)
00308 {
00309 return size == r.size && position == r.position;
00310 }
00311
00315 bool operator!=(const Rect &r)
00316 {
00317 return size != r.size || position != r.position;
00318 }
00319 };
00320
00321 typedef int text_range_t;
00322
00352 struct OMGUI_API TextRange
00353 {
00354 static const text_range_t END;
00355 text_range_t first, second;
00356
00357 TextRange()
00358 : first(0),
00359 second(0)
00360 { }
00361
00362 TextRange(text_range_t begin, text_range_t end = END)
00363 : first(begin),
00364 second(end)
00365 { }
00366
00367 TextRange(const TextRange &other)
00368 : first(other.first),
00369 second(other.second)
00370 { }
00371
00372 TextRange &operator=(const TextRange &other)
00373 {
00374 first = other.first;
00375 second = other.second;
00376 return *this;
00377 }
00378
00382 void normalize()
00383 {
00384 if( first > second )
00385 {
00386 int temp = first;
00387 first = second;
00388 second = temp;
00389 }
00390 }
00391
00397 TextRange(const TextRange &other, text_range_t length)
00398 : first(other.first),
00399 second(other.second)
00400 {
00401 if( first < 0 )
00402 first += length;
00403 else if( first == END )
00404 first = length;
00405 if( second < 0 )
00406 second += length;
00407 else if( second == END )
00408 second = length;
00409 }
00410 };
00411
00412
00413
00414
00415
00416
00417
00418
00419 }
00420
00421 inline omgui::Size operator+(const omgui::Size &l, const omgui::Size &r)
00422 {
00423 return omgui::Size(l.width + r.width, l.height + r.height);
00424 }
00425
00426 inline omgui::Size operator-(const omgui::Size &l, const omgui::Size &r)
00427 {
00428 return omgui::Size(l.width - r.width, l.height - r.height);
00429 }
00430
00431 inline omgui::Size operator*(const omgui::Size &l, float f)
00432 {
00433
00434 return omgui::Size(static_cast<int>(l.width * f), static_cast<int>(l.height * f));
00435 }
00436
00437 inline omgui::Size operator/(const omgui::Size &l, float f)
00438 {
00439
00440 return omgui::Size(static_cast<int>(l.width / f), static_cast<int>(l.height / f));
00441 }
00442
00443 inline omgui::Point operator+(const omgui::Point &l, const omgui::Point &r)
00444 {
00445 return omgui::Point(l.x + r.x, l.y + r.y);
00446 }
00447
00448 inline omgui::Point operator-(const omgui::Point &l, const omgui::Point &r)
00449 {
00450 return omgui::Point(l.x - r.x, l.y - r.y);
00451 }
00452
00453 #endif // OMGUI_TYPES_H