00001
00002
00003
00004
00005
00006
00007
00008 #ifndef WIDGETS_H_
00009 #define WIDGETS_H_
00010
00011 #include <OgreVector2.h>
00012 #include <OgreColourValue.h>
00013 #include <OgreOverlayManager.h>
00014 #include <OgreOverlayContainer.h>
00015 #include <OgreOverlayElement.h>
00016 #include <OgreTextAreaOverlayElement.h>
00017 #include <OISMouse.h>
00018
00019
00020 #include <inputHandlers.h>
00021 #include "commandFactory.h"
00022 #include "GraphicsInteractionManager.h"
00023
00024
00025
00026
00027 namespace OgreGFX
00028 {
00029
00030 static std::string DEFAULT_PANEL_MATERIAL = "ECSLENT/navy/material/shipInfo/overlay";
00031 static Ogre::Vector2 DEFAULT_LABEL_SIZE = Ogre::Vector2(100, 20);
00032
00033 enum Placement
00034 {
00035 Below = 0,
00036 Right = 1
00037 };
00038
00039 class GraphicsInteractionManager;
00040
00044 class Widget
00045 {
00046 public:
00047 Ogre::Vector2 pos;
00048 Ogre::Vector2 size;
00049 Widget *parent;
00050 GraphicsInteractionManager *gfx;
00051 Ogre::GuiMetricsMode mode;
00052 std::string desc;
00064 Widget(GraphicsInteractionManager *gim, Widget *aParent = 0, Ogre::Vector2 defaultPos = Ogre::Vector2::NEGATIVE_UNIT_X, Ogre::Vector2 defaultSize = Ogre::Vector2::NEGATIVE_UNIT_X, Ogre::GuiMetricsMode
00065 defaultMode = Ogre::GMM_RELATIVE);
00066 ~Widget();
00067
00073 Ogre::Vector2 screenPos();
00074
00081 bool cursonInMe(const Ogre::Vector2 &pos);
00082
00087 virtual void posChanged()
00088 {
00089 };
00090
00095 virtual void show()
00096 {
00097 };
00098
00103 virtual void hide()
00104 {
00105 };
00106
00111 virtual Ogre::OverlayElement* getOverlayElementToAdd()
00112 {
00113 return 0;
00114 };
00115
00116 };
00117
00118 class UIOutline : public Widget
00119 {
00120 public:
00121
00122 Ogre::OverlayManager *overlayManagerPtr;
00123 Ogre::Overlay* overlay;
00124 virtual void show();
00125 virtual void hide();
00126
00127 UIOutline(GraphicsInteractionManager *gim);
00128 ~UIOutline();
00129
00130 };
00131
00132 class FEProgressBar : public Widget
00133 {
00134 private:
00135
00136 public:
00137 FEProgressBar(GraphicsInteractionManager *gim, std::string name = "FEProgressBar", Widget* aParent = 0,
00138 Ogre::Vector2 defaultPos = Ogre::Vector2::NEGATIVE_UNIT_X, Ogre::Vector2 defaultSize = Ogre::Vector2::NEGATIVE_UNIT_X,
00139 std::string barMaterial = DEFAULT_PANEL_MATERIAL, std::string fillMaterial = DEFAULT_PANEL_MATERIAL, Ogre::GuiMetricsMode defaultMode = Ogre::GMM_RELATIVE);
00140 ~FEProgressBar();
00141
00142
00143 Ogre::OverlayManager* overlayManagerPtr;
00144 Ogre::OverlayContainer *progressBar;
00145
00146 std::string barMaterial;
00147 std::string fillMaterial;
00148 std::string name;
00149 double percentFull;
00150
00151 void UpdateFillPercent();
00152 virtual void show();
00153 virtual void hide();
00154 virtual void posChanged();
00155 virtual Ogre::OverlayElement* getOverlayElementToAdd();
00156
00157 };
00158
00162 class FEPanel : public Widget
00163 {
00164 private:
00165
00166 public:
00178 FEPanel(GraphicsInteractionManager *gim, std::string name = "FEPanel", Widget* aParent = 0,
00179 Ogre::Vector2 defaultPos = Ogre::Vector2::NEGATIVE_UNIT_X, Ogre::Vector2 defaultSize = Ogre::Vector2::NEGATIVE_UNIT_X,
00180 std::string material = DEFAULT_PANEL_MATERIAL, Ogre::GuiMetricsMode defaultMode = Ogre::GMM_RELATIVE);
00181 ~FEPanel();
00182
00183 Ogre::Overlay* overlayPtr;
00184 Ogre::OverlayManager* overlayManagerPtr;
00185 Ogre::OverlayContainer *panel;
00186
00187 std::string material;
00188 std::string name;
00189 Ogre::Vector2 belowPos;
00190 Ogre::Vector2 rightPos;
00191 Ogre::Vector2 gap;
00192 std::list<Widget*> items;
00193 std::list<Ogre::OverlayElement*> separators;
00194 int separatorHeight;
00197 virtual void show();
00198 virtual void hide();
00199 virtual void posChanged();
00200
00207 void addItem(Widget *item, Placement placement = Below);
00208
00209
00210
00211
00212 void addSep(int separation);
00213
00217 void adjustSeparators();
00222 Ogre::OverlayElement* makeSep();
00223
00228 virtual Ogre::OverlayElement* getOverlayElementToAdd();
00229
00230 };
00231
00234 class FELabel : public Widget
00235 {
00236 public:
00248 FELabel(GraphicsInteractionManager *gim, std::string caption = "FELabel",
00249 Widget *aParent = 0, Ogre::ColourValue color = Ogre::ColourValue::Red,
00250 Ogre::Vector2 defaultPos = Ogre::Vector2::NEGATIVE_UNIT_X, Ogre::Vector2 defaultSize = DEFAULT_LABEL_SIZE, Ogre::GuiMetricsMode defaultMode = Ogre::GMM_RELATIVE);
00251 ~FELabel();
00252
00253 Ogre::OverlayManager* overlayManagerPtr;
00254 std::string caption;
00255 Ogre::ColourValue color;
00256 Ogre::Vector2 offset;
00257 Ogre::TextAreaOverlayElement* textArea;
00264 virtual void setCaption(std::string val);
00265
00266 virtual void show();
00267 virtual void hide();
00268 virtual void posChanged();
00269 virtual Ogre::OverlayElement* getOverlayElementToAdd();
00270
00271 };
00272
00273 class FELineWrapLabel : public FELabel
00274 {
00275 public:
00276 FELineWrapLabel(GraphicsInteractionManager *gim, std::string caption = "FELineWrapLabel",
00277 Widget *aParent = 0, Ogre::ColourValue color = Ogre::ColourValue::Red,
00278 Ogre::Vector2 defaultPos = Ogre::Vector2::NEGATIVE_UNIT_X, Ogre::Vector2 defaultSize = DEFAULT_LABEL_SIZE, Ogre::GuiMetricsMode defaultMode = Ogre::GMM_RELATIVE, double lines = 1);
00279
00280 ~FELineWrapLabel();
00281 virtual void setCaption(std::string val);
00282
00283 double lines;
00284
00285 };
00286
00293 class FEButton : public FEPanel, public MouseHandler, public KeyHandler
00294 {
00295 public:
00311 FEButton(GraphicsInteractionManager *gim, const OIS::KeyCode keyCode,
00312 const std::set<OIS::KeyCode> *modifierKeys, const OIS::MouseButtonID oisMouseButtonId,
00313 std::string name = "FEButton", FastEcslent::CommandFactory* command = NULL,
00314 Widget *aParent = 0,
00315 Ogre::Vector2 defaultPos = Ogre::Vector2::NEGATIVE_UNIT_X,
00316 Ogre::Vector2 defaultSize = DEFAULT_LABEL_SIZE,std::string material = DEFAULT_PANEL_MATERIAL, std::string desc = "BLANK", Ogre::GuiMetricsMode defaultMode = Ogre::GMM_RELATIVE);
00317 ~FEButton();
00318
00319 FastEcslent::CommandFactory* commandFactory;
00320 bool pressed;
00321 bool enabled;
00328 virtual void handleMouseEvent(const OIS::MouseEvent &args);
00329 virtual void handleKeyEvent();
00330 virtual void show();
00331 virtual void hide();
00332 bool processButtonFirstEvent(bool buttonActivated);
00333 bool processButtonSecondEvent(bool buttonActivated);
00334 };
00335
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00438 class FELabelPair : public FEPanel
00439 {
00440 public:
00454 FELabelPair(GraphicsInteractionManager *gim, std::string caption1 = "Key", std::string caption2 = "Value",
00455 Widget *aParent = 0, Ogre::ColourValue color = Ogre::ColourValue::Green,
00456 Ogre::Vector2 defaultPos = Ogre::Vector2::NEGATIVE_UNIT_X,
00457 Ogre::Vector2 defaultColumnWidths = Ogre::Vector2(100, 200), int columnHeight = DEFAULT_LABEL_SIZE.y,
00458 std::string materialName = DEFAULT_PANEL_MATERIAL, Ogre::GuiMetricsMode defaultMode = Ogre::GMM_RELATIVE);
00459
00460
00461 ~FELabelPair()
00462 {
00463 };
00464
00465 FELabel *left, *right;
00466
00467 virtual void show();
00468 virtual void hide();
00469
00475 void setLeft(std::string val);
00476
00482 void setRight(std::string val);
00483
00484 };
00485
00486
00487 }
00488
00489
00490 #endif