00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "CEGUIWindowProperties.h"
00027 #include "CEGUIWindow.h"
00028 #include "CEGUIFont.h"
00029 #include "CEGUIPropertyHelper.h"
00030 #include "CEGUIExceptions.h"
00031 #include <cstdlib>
00032 #include <cstdio>
00033
00034
00035 namespace CEGUI
00036 {
00037
00038 namespace WindowProperties
00039 {
00040
00041 String RelativeMinSize::get(const PropertyReceiver* receiver) const
00042 {
00043 CEGUI::Size msz(static_cast<const Window*>(receiver)->getMinimumSize());
00044
00045 if (static_cast<const Window*>(receiver)->getMetricsMode() == Absolute)
00046 {
00047 CEGUI::Size dsz(System::getSingleton().getRenderer()->getSize());
00048
00049 msz.d_width /= dsz.d_width;
00050 msz.d_height /= dsz.d_height;
00051 }
00052
00053 return PropertyHelper::sizeToString(msz);
00054 }
00055
00056
00057 void RelativeMinSize::set(PropertyReceiver* receiver, const String& value)
00058 {
00059 CEGUI::Size msz(PropertyHelper::stringToSize(value));
00060
00061 if (static_cast<Window*>(receiver)->getMetricsMode() == Absolute)
00062 {
00063 CEGUI::Size dsz(System::getSingleton().getRenderer()->getSize());
00064
00065 msz.d_width *= dsz.d_width;
00066 msz.d_height *= dsz.d_height;
00067 }
00068
00069 static_cast<Window*>(receiver)->setMinimumSize(msz);
00070 }
00071
00072
00073 String RelativeMaxSize::get(const PropertyReceiver* receiver) const
00074 {
00075 CEGUI::Size msz(static_cast<const Window*>(receiver)->getMaximumSize());
00076
00077 if (static_cast<const Window*>(receiver)->getMetricsMode() == Absolute)
00078 {
00079 CEGUI::Size dsz(System::getSingleton().getRenderer()->getSize());
00080
00081 msz.d_width /= dsz.d_width;
00082 msz.d_height /= dsz.d_height;
00083 }
00084
00085 return PropertyHelper::sizeToString(msz);
00086 }
00087
00088
00089 void RelativeMaxSize::set(PropertyReceiver* receiver, const String& value)
00090 {
00091 CEGUI::Size msz(PropertyHelper::stringToSize(value));
00092
00093 if (static_cast<Window*>(receiver)->getMetricsMode() == Absolute)
00094 {
00095 CEGUI::Size dsz(System::getSingleton().getRenderer()->getSize());
00096
00097 msz.d_width *= dsz.d_width;
00098 msz.d_height *= dsz.d_height;
00099 }
00100
00101 static_cast<Window*>(receiver)->setMaximumSize(msz);
00102 }
00103
00104
00105 String AbsoluteMinSize::get(const PropertyReceiver* receiver) const
00106 {
00107 CEGUI::Size msz(static_cast<const Window*>(receiver)->getMinimumSize());
00108
00109 if (static_cast<const Window*>(receiver)->getMetricsMode() == Relative)
00110 {
00111 CEGUI::Size dsz(System::getSingleton().getRenderer()->getSize());
00112
00113 msz.d_width *= dsz.d_width;
00114 msz.d_height *= dsz.d_height;
00115 }
00116
00117 return PropertyHelper::sizeToString(msz);
00118 }
00119
00120
00121 void AbsoluteMinSize::set(PropertyReceiver* receiver, const String& value)
00122 {
00123 CEGUI::Size msz(PropertyHelper::stringToSize(value));
00124
00125 if (static_cast<Window*>(receiver)->getMetricsMode() == Relative)
00126 {
00127 CEGUI::Size dsz(System::getSingleton().getRenderer()->getSize());
00128
00129 msz.d_width /= dsz.d_width;
00130 msz.d_height /= dsz.d_height;
00131 }
00132
00133 static_cast<Window*>(receiver)->setMinimumSize(msz);
00134 }
00135
00136
00137 String AbsoluteMaxSize::get(const PropertyReceiver* receiver) const
00138 {
00139 CEGUI::Size msz(static_cast<const Window*>(receiver)->getMaximumSize());
00140
00141 if (static_cast<const Window*>(receiver)->getMetricsMode() == Relative)
00142 {
00143 CEGUI::Size dsz(System::getSingleton().getRenderer()->getSize());
00144
00145 msz.d_width *= dsz.d_width;
00146 msz.d_height *= dsz.d_height;
00147 }
00148
00149 return PropertyHelper::sizeToString(msz);
00150 }
00151
00152
00153 void AbsoluteMaxSize::set(PropertyReceiver* receiver, const String& value)
00154 {
00155 CEGUI::Size msz(PropertyHelper::stringToSize(value));
00156
00157 if (static_cast<Window*>(receiver)->getMetricsMode() == Relative)
00158 {
00159 CEGUI::Size dsz(System::getSingleton().getRenderer()->getSize());
00160
00161 msz.d_width /= dsz.d_width;
00162 msz.d_height /= dsz.d_height;
00163 }
00164
00165 static_cast<Window*>(receiver)->setMaximumSize(msz);
00166 }
00167
00168 bool AbsoluteMaxSize::isDefault(const PropertyReceiver* receiver) const
00169 {
00170 return get(receiver) == getDefault(receiver);
00171 }
00172
00173 String AbsoluteMaxSize::getDefault(const PropertyReceiver* receiver) const
00174 {
00175 return PropertyHelper::sizeToString(System::getSingleton().getRenderer()->getSize());
00176 }
00177
00178 String MetricsMode::get(const PropertyReceiver* receiver) const
00179 {
00180 return PropertyHelper::metricsModeToString(static_cast<const Window*>(receiver)->getMetricsMode());
00181 }
00182
00183
00184 void MetricsMode::set(PropertyReceiver* receiver, const String& value)
00185 {
00186 static_cast<Window*>(receiver)->setMetricsMode(PropertyHelper::stringToMetricsMode(value));
00187 }
00188
00189
00190 String ID::get(const PropertyReceiver* receiver) const
00191 {
00192 return PropertyHelper::uintToString(static_cast<const Window*>(receiver)->getID());
00193 }
00194
00195
00196 void ID::set(PropertyReceiver* receiver, const String& value)
00197 {
00198 static_cast<Window*>(receiver)->setID(PropertyHelper::stringToUint(value));
00199 }
00200
00201
00202 String Alpha::get(const PropertyReceiver* receiver) const
00203 {
00204 return PropertyHelper::floatToString(static_cast<const Window*>(receiver)->getAlpha());
00205 }
00206
00207
00208 void Alpha::set(PropertyReceiver* receiver, const String& value)
00209 {
00210 static_cast<Window*>(receiver)->setAlpha(PropertyHelper::stringToFloat(value));
00211 }
00212
00213
00214 String Font::get(const PropertyReceiver* receiver) const
00215 {
00216 const CEGUI::Font* fnt = static_cast<const Window*>(receiver)->getFont();
00217
00218 if (fnt != NULL)
00219 {
00220 return fnt->getName();
00221 }
00222 else
00223 {
00224 return String();
00225 }
00226
00227 }
00228
00229
00230 void Font::set(PropertyReceiver* receiver, const String& value)
00231 {
00232 try
00233 {
00234 if (value.empty())
00235 {
00236 static_cast<Window*>(receiver)->setFont(System::getSingleton().getDefaultFont());
00237 }
00238 else
00239 {
00240 static_cast<Window*>(receiver)->setFont(value);
00241 }
00242 }
00243 catch (UnknownObjectException)
00244 { }
00245 }
00246
00247
00248 String Text::get(const PropertyReceiver* receiver) const
00249 {
00250 return static_cast<const Window*>(receiver)->getText();
00251 }
00252
00253
00254 void Text::set(PropertyReceiver* receiver, const String& value)
00255 {
00256 static_cast<Window*>(receiver)->setText(value);
00257 }
00258
00259
00260 String MouseCursorImage::get(const PropertyReceiver* receiver) const
00261 {
00262 const Image* img = static_cast<const Window*>(receiver)->getMouseCursor();
00263
00264 if (img != NULL)
00265 {
00266 return PropertyHelper::imageToString(img);
00267 }
00268 else
00269 {
00270 return String();
00271 }
00272
00273 }
00274
00275
00276 void MouseCursorImage::set(PropertyReceiver* receiver, const String& value)
00277 {
00278 if (!value.empty())
00279 {
00280 static_cast<Window*>(receiver)->setMouseCursor(PropertyHelper::stringToImage(value));
00281 }
00282 }
00283
00284
00285 String ClippedByParent::get(const PropertyReceiver* receiver) const
00286 {
00287 return PropertyHelper::boolToString(static_cast<const Window*>(receiver)->isClippedByParent());
00288 }
00289
00290
00291 void ClippedByParent::set(PropertyReceiver* receiver, const String& value)
00292 {
00293 static_cast<Window*>(receiver)->setClippedByParent(PropertyHelper::stringToBool(value));
00294 }
00295
00296
00297 String InheritsAlpha::get(const PropertyReceiver* receiver) const
00298 {
00299 return PropertyHelper::boolToString(static_cast<const Window*>(receiver)->inheritsAlpha());
00300 }
00301
00302
00303 void InheritsAlpha::set(PropertyReceiver* receiver, const String& value)
00304 {
00305 static_cast<Window*>(receiver)->setInheritsAlpha(PropertyHelper::stringToBool(value));
00306 }
00307
00308
00309 String AlwaysOnTop::get(const PropertyReceiver* receiver) const
00310 {
00311 return PropertyHelper::boolToString(static_cast<const Window*>(receiver)->isAlwaysOnTop());
00312 }
00313
00314
00315 void AlwaysOnTop::set(PropertyReceiver* receiver, const String& value)
00316 {
00317 static_cast<Window*>(receiver)->setAlwaysOnTop(PropertyHelper::stringToBool(value));
00318 }
00319
00320
00321 String Disabled::get(const PropertyReceiver* receiver) const
00322 {
00323 return PropertyHelper::boolToString(static_cast<const Window*>(receiver)->isDisabled());
00324 }
00325
00326
00327 void Disabled::set(PropertyReceiver* receiver, const String& value)
00328 {
00329 static_cast<Window*>(receiver)->setEnabled(!PropertyHelper::stringToBool(value));
00330 }
00331
00332
00333 String Visible::get(const PropertyReceiver* receiver) const
00334 {
00335 return PropertyHelper::boolToString(static_cast<const Window*>(receiver)->isVisible());
00336 }
00337
00338
00339 void Visible::set(PropertyReceiver* receiver, const String& value)
00340 {
00341 static_cast<Window*>(receiver)->setVisible(PropertyHelper::stringToBool(value));
00342 }
00343
00344
00345 String RestoreOldCapture::get(const PropertyReceiver* receiver) const
00346 {
00347 return PropertyHelper::boolToString(static_cast<const Window*>(receiver)->restoresOldCapture());
00348 }
00349
00350
00351 void RestoreOldCapture::set(PropertyReceiver* receiver, const String& value)
00352 {
00353 static_cast<Window*>(receiver)->setRestoreCapture(PropertyHelper::stringToBool(value));
00354 }
00355
00356
00357 String DestroyedByParent::get(const PropertyReceiver* receiver) const
00358 {
00359 return PropertyHelper::boolToString(static_cast<const Window*>(receiver)->isDestroyedByParent());
00360 }
00361
00362
00363 void DestroyedByParent::set(PropertyReceiver* receiver, const String& value)
00364 {
00365 static_cast<Window*>(receiver)->setDestroyedByParent(PropertyHelper::stringToBool(value));
00366 }
00367
00368
00369 String Width::get(const PropertyReceiver* receiver) const
00370 {
00371 return PropertyHelper::floatToString(static_cast<const Window*>(receiver)->getWidth());
00372 }
00373
00374
00375 void Width::set(PropertyReceiver* receiver, const String& value)
00376 {
00377 static_cast<Window*>(receiver)->setWidth(PropertyHelper::stringToFloat(value));
00378 }
00379
00380
00381 String RelativeWidth::get(const PropertyReceiver* receiver) const
00382 {
00383 return PropertyHelper::floatToString(static_cast<const Window*>(receiver)->getRelativeWidth());
00384 }
00385
00386
00387 void RelativeWidth::set(PropertyReceiver* receiver, const String& value)
00388 {
00389 static_cast<Window*>(receiver)->setWidth(Relative, PropertyHelper::stringToFloat(value));
00390 }
00391
00392
00393 String AbsoluteWidth::get(const PropertyReceiver* receiver) const
00394 {
00395 return PropertyHelper::floatToString(static_cast<const Window*>(receiver)->getAbsoluteWidth());
00396 }
00397
00398
00399 void AbsoluteWidth::set(PropertyReceiver* receiver, const String& value)
00400 {
00401 static_cast<Window*>(receiver)->setWidth(Absolute, PropertyHelper::stringToFloat(value));
00402 }
00403
00404
00405 String Height::get(const PropertyReceiver* receiver) const
00406 {
00407 return PropertyHelper::floatToString(static_cast<const Window*>(receiver)->getHeight());
00408 }
00409
00410
00411 void Height::set(PropertyReceiver* receiver, const String& value)
00412 {
00413 static_cast<Window*>(receiver)->setHeight(PropertyHelper::stringToFloat(value));
00414 }
00415
00416
00417 String RelativeHeight::get(const PropertyReceiver* receiver) const
00418 {
00419 return PropertyHelper::floatToString(static_cast<const Window*>(receiver)->getRelativeHeight());
00420 }
00421
00422
00423 void RelativeHeight::set(PropertyReceiver* receiver, const String& value)
00424 {
00425 static_cast<Window*>(receiver)->setHeight(Relative, PropertyHelper::stringToFloat(value));
00426 }
00427
00428
00429 String AbsoluteHeight::get(const PropertyReceiver* receiver) const
00430 {
00431 return PropertyHelper::floatToString(static_cast<const Window*>(receiver)->getAbsoluteHeight());
00432 }
00433
00434
00435 void AbsoluteHeight::set(PropertyReceiver* receiver, const String& value)
00436 {
00437 static_cast<Window*>(receiver)->setHeight(Absolute, PropertyHelper::stringToFloat(value));
00438 }
00439
00440
00441 String Size::get(const PropertyReceiver* receiver) const
00442 {
00443 return PropertyHelper::sizeToString(static_cast<const Window*>(receiver)->getSize());
00444 }
00445
00446
00447 void Size::set(PropertyReceiver* receiver, const String& value)
00448 {
00449 static_cast<Window*>(receiver)->setSize(PropertyHelper::stringToSize(value));
00450 }
00451
00452
00453 String RelativeSize::get(const PropertyReceiver* receiver) const
00454 {
00455 return PropertyHelper::sizeToString(static_cast<const Window*>(receiver)->getRelativeSize());
00456 }
00457
00458
00459 void RelativeSize::set(PropertyReceiver* receiver, const String& value)
00460 {
00461 static_cast<Window*>(receiver)->setSize(Relative, PropertyHelper::stringToSize(value));
00462 }
00463
00464
00465 String AbsoluteSize::get(const PropertyReceiver* receiver) const
00466 {
00467 return PropertyHelper::sizeToString(static_cast<const Window*>(receiver)->getAbsoluteSize());
00468 }
00469
00470
00471 void AbsoluteSize::set(PropertyReceiver* receiver, const String& value)
00472 {
00473 static_cast<Window*>(receiver)->setSize(Absolute, PropertyHelper::stringToSize(value));
00474 }
00475
00476
00477 String XPosition::get(const PropertyReceiver* receiver) const
00478 {
00479 return PropertyHelper::floatToString(static_cast<const Window*>(receiver)->getXPosition());
00480 }
00481
00482
00483 void XPosition::set(PropertyReceiver* receiver, const String& value)
00484 {
00485 static_cast<Window*>(receiver)->setXPosition(PropertyHelper::stringToFloat(value));
00486 }
00487
00488
00489 String RelativeXPosition::get(const PropertyReceiver* receiver) const
00490 {
00491 return PropertyHelper::floatToString(static_cast<const Window*>(receiver)->getRelativeXPosition());
00492 }
00493
00494
00495 void RelativeXPosition::set(PropertyReceiver* receiver, const String& value)
00496 {
00497 static_cast<Window*>(receiver)->setXPosition(Relative, PropertyHelper::stringToFloat(value));
00498 }
00499
00500
00501 String AbsoluteXPosition::get(const PropertyReceiver* receiver) const
00502 {
00503 return PropertyHelper::floatToString(static_cast<const Window*>(receiver)->getAbsoluteXPosition());
00504 }
00505
00506
00507 void AbsoluteXPosition::set(PropertyReceiver* receiver, const String& value)
00508 {
00509 static_cast<Window*>(receiver)->setXPosition(Absolute, PropertyHelper::stringToFloat(value));
00510 }
00511
00512
00513 String YPosition::get(const PropertyReceiver* receiver) const
00514 {
00515 return PropertyHelper::floatToString(static_cast<const Window*>(receiver)->getYPosition());
00516 }
00517
00518
00519 void YPosition::set(PropertyReceiver* receiver, const String& value)
00520 {
00521 static_cast<Window*>(receiver)->setYPosition(PropertyHelper::stringToFloat(value));
00522 }
00523
00524
00525 String RelativeYPosition::get(const PropertyReceiver* receiver) const
00526 {
00527 return PropertyHelper::floatToString(static_cast<const Window*>(receiver)->getRelativeYPosition());
00528 }
00529
00530
00531 void RelativeYPosition::set(PropertyReceiver* receiver, const String& value)
00532 {
00533 static_cast<Window*>(receiver)->setYPosition(Relative, PropertyHelper::stringToFloat(value));
00534 }
00535
00536
00537 String AbsoluteYPosition::get(const PropertyReceiver* receiver) const
00538 {
00539 return PropertyHelper::floatToString(static_cast<const Window*>(receiver)->getAbsoluteYPosition());
00540 }
00541
00542
00543 void AbsoluteYPosition::set(PropertyReceiver* receiver, const String& value)
00544 {
00545 static_cast<Window*>(receiver)->setYPosition(Absolute, PropertyHelper::stringToFloat(value));
00546 }
00547
00548
00549 String Position::get(const PropertyReceiver* receiver) const
00550 {
00551 return PropertyHelper::pointToString(static_cast<const Window*>(receiver)->getPosition());
00552 }
00553
00554
00555 void Position::set(PropertyReceiver* receiver, const String& value)
00556 {
00557 static_cast<Window*>(receiver)->setPosition(PropertyHelper::stringToPoint(value));
00558 }
00559
00560
00561 String RelativePosition::get(const PropertyReceiver* receiver) const
00562 {
00563 return PropertyHelper::pointToString(static_cast<const Window*>(receiver)->getRelativePosition());
00564 }
00565
00566
00567 void RelativePosition::set(PropertyReceiver* receiver, const String& value)
00568 {
00569 static_cast<Window*>(receiver)->setPosition(Relative, PropertyHelper::stringToPoint(value));
00570 }
00571
00572
00573 String AbsolutePosition::get(const PropertyReceiver* receiver) const
00574 {
00575 return PropertyHelper::pointToString(static_cast<const Window*>(receiver)->getAbsolutePosition());
00576 }
00577
00578
00579 void AbsolutePosition::set(PropertyReceiver* receiver, const String& value)
00580 {
00581 static_cast<Window*>(receiver)->setPosition(Absolute, PropertyHelper::stringToPoint(value));
00582 }
00583
00584
00585 String Rect::get(const PropertyReceiver* receiver) const
00586 {
00587 return PropertyHelper::rectToString(static_cast<const Window*>(receiver)->getRect());
00588 }
00589
00590
00591 void Rect::set(PropertyReceiver* receiver, const String& value)
00592 {
00593 static_cast<Window*>(receiver)->setAreaRect(PropertyHelper::stringToRect(value));
00594 }
00595
00596
00597 String RelativeRect::get(const PropertyReceiver* receiver) const
00598 {
00599 return PropertyHelper::rectToString(static_cast<const Window*>(receiver)->getRelativeRect());
00600 }
00601
00602
00603 void RelativeRect::set(PropertyReceiver* receiver, const String& value)
00604 {
00605 static_cast<Window*>(receiver)->setRect(Relative, PropertyHelper::stringToRect(value));
00606 }
00607
00608
00609 String AbsoluteRect::get(const PropertyReceiver* receiver) const
00610 {
00611 return PropertyHelper::rectToString(static_cast<const Window*>(receiver)->getAbsoluteRect());
00612 }
00613
00614
00615 void AbsoluteRect::set(PropertyReceiver* receiver, const String& value)
00616 {
00617 static_cast<Window*>(receiver)->setRect(Absolute, PropertyHelper::stringToRect(value));
00618 }
00619
00620
00621 String ZOrderChangeEnabled::get(const PropertyReceiver* receiver) const
00622 {
00623 return PropertyHelper::boolToString(static_cast<const Window*>(receiver)->isZOrderingEnabled());
00624 }
00625
00626
00627 void ZOrderChangeEnabled::set(PropertyReceiver* receiver, const String& value)
00628 {
00629 static_cast<Window*>(receiver)->setZOrderingEnabled(PropertyHelper::stringToBool(value));
00630 }
00631
00632
00633 String WantsMultiClickEvents::get(const PropertyReceiver* receiver) const
00634 {
00635 return PropertyHelper::boolToString(static_cast<const Window*>(receiver)->wantsMultiClickEvents());
00636 }
00637
00638
00639 void WantsMultiClickEvents::set(PropertyReceiver* receiver, const String& value)
00640 {
00641 static_cast<Window*>(receiver)->setWantsMultiClickEvents(PropertyHelper::stringToBool(value));
00642 }
00643
00644
00645 String MouseButtonDownAutoRepeat::get(const PropertyReceiver* receiver) const
00646 {
00647 return PropertyHelper::boolToString(static_cast<const Window*>(receiver)->isMouseAutoRepeatEnabled());
00648 }
00649
00650
00651 void MouseButtonDownAutoRepeat::set(PropertyReceiver* receiver, const String& value)
00652 {
00653 static_cast<Window*>(receiver)->setMouseAutoRepeatEnabled(PropertyHelper::stringToBool(value));
00654 }
00655
00656
00657 String AutoRepeatDelay::get(const PropertyReceiver* receiver) const
00658 {
00659 return PropertyHelper::floatToString(static_cast<const Window*>(receiver)->getAutoRepeatDelay());
00660 }
00661
00662
00663 void AutoRepeatDelay::set(PropertyReceiver* receiver, const String& value)
00664 {
00665 static_cast<Window*>(receiver)->setAutoRepeatDelay(PropertyHelper::stringToFloat(value));
00666 }
00667
00668
00669 String AutoRepeatRate::get(const PropertyReceiver* receiver) const
00670 {
00671 return PropertyHelper::floatToString(static_cast<const Window*>(receiver)->getAutoRepeatRate());
00672 }
00673
00674
00675 void AutoRepeatRate::set(PropertyReceiver* receiver, const String& value)
00676 {
00677 static_cast<Window*>(receiver)->setAutoRepeatRate(PropertyHelper::stringToFloat(value));
00678 }
00679
00680 }
00681
00682 }