widgets.h

Go to the documentation of this file.
00001 /*
00002  * widgets.h
00003  *
00004  *  Created on: Jan 8, 2013
00005  *      Author: sushil
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 
00022 
00023 
00024 namespace OgreGFX
00025 {
00026 
00027 static std::string DEFAULT_PANEL_MATERIAL = "ECSLENT/navy/material/shipInfo/overlay";
00028 static Ogre::Vector2 DEFAULT_LABEL_SIZE = Ogre::Vector2(100, 20);
00029 
00030 enum Placement
00031 {
00032     Below = 0,
00033     Right = 1
00034 };
00035 
00036 class GraphicsInteractionManager;
00037 
00041 class Widget
00042 {
00043 public:
00044     Ogre::Vector2 pos; 
00045     Ogre::Vector2 size; 
00046     Widget *parent; 
00047     GraphicsInteractionManager *gfx; 
00048     Ogre::GuiMetricsMode mode;
00049     std::string desc; 
00060     Widget(GraphicsInteractionManager *gim, Widget *aParent = 0, Ogre::Vector2 defaultPos = Ogre::Vector2::NEGATIVE_UNIT_X, Ogre::Vector2 defaultSize = Ogre::Vector2::NEGATIVE_UNIT_X, Ogre::GuiMetricsMode
00061     defaultMode = Ogre::GMM_RELATIVE);
00062     ~Widget();
00063 
00069     Ogre::Vector2 screenPos();
00070 
00077     bool cursonInMe(const Ogre::Vector2 &pos);
00078 
00083     virtual void posChanged()
00084     {
00085     };
00086 
00091     virtual void show()
00092     {
00093     };
00094 
00099     virtual void hide()
00100     {
00101     };
00102 
00107     virtual Ogre::OverlayElement* getOverlayElementToAdd()
00108     {
00109         return 0;
00110     };
00111 
00112 };
00113 
00114 class UIOutline : public Widget
00115 {
00116 public:
00117 
00118     Ogre::OverlayManager *overlayManagerPtr;
00119     Ogre::Overlay* overlay;
00120     virtual void show();
00121     virtual void hide();
00122 
00123     UIOutline(GraphicsInteractionManager *gim);
00124     ~UIOutline();
00125 
00126 };
00127 
00131 class FEPanel : public Widget
00132 {
00133 private:
00134 
00135 public:
00146     FEPanel(GraphicsInteractionManager *gim, std::string name = "FEPanel", Widget* aParent = 0,
00147             Ogre::Vector2 defaultPos = Ogre::Vector2::NEGATIVE_UNIT_X, Ogre::Vector2 defaultSize = Ogre::Vector2::NEGATIVE_UNIT_X,
00148             std::string material = DEFAULT_PANEL_MATERIAL, Ogre::GuiMetricsMode defaultMode = Ogre::GMM_RELATIVE); //: Widget(gim) {};
00149     ~FEPanel();
00150 
00151     Ogre::Overlay* overlayPtr;
00152     Ogre::OverlayManager* overlayManagerPtr;
00153     Ogre::OverlayContainer *panel;
00154     //Ogre::TextAreaOverlayElement *textArea; /*! The visual element used to display text */
00155     std::string material; 
00156     std::string name; 
00157     Ogre::Vector2 belowPos; 
00158     Ogre::Vector2 rightPos; 
00159     Ogre::Vector2 gap; 
00160     std::list<Widget*> items; 
00161     std::list<Ogre::OverlayElement*> separators; 
00162     int separatorHeight; 
00165     virtual void show();
00166     virtual void hide();
00167     virtual void posChanged();
00168 
00175     void addItem(Widget *item, Placement placement = Below);
00176 
00177     //          void getItems();
00178     //          void getOverlayElementToAdd();
00179 
00180     void addSep(int separation);
00181 
00185     void adjustSeparators();
00190     Ogre::OverlayElement* makeSep();
00191 
00196     virtual Ogre::OverlayElement* getOverlayElementToAdd();
00197 
00198 };
00199 
00202 class FELabel : public Widget
00203 {
00204 public:
00215     FELabel(GraphicsInteractionManager *gim, std::string caption = "FELabel",
00216             Widget *aParent = 0, Ogre::ColourValue color = Ogre::ColourValue::Red,
00217             Ogre::Vector2 defaultPos = Ogre::Vector2::NEGATIVE_UNIT_X, Ogre::Vector2 defaultSize = DEFAULT_LABEL_SIZE, Ogre::GuiMetricsMode defaultMode = Ogre::GMM_RELATIVE);
00218     ~FELabel();
00219 
00220     Ogre::OverlayManager* overlayManagerPtr;
00221     std::string caption; 
00222     Ogre::ColourValue color; 
00223     Ogre::Vector2 offset; 
00224     Ogre::TextAreaOverlayElement* textArea; 
00231     void setCaption(std::string val);
00232 
00233     virtual void show();
00234     virtual void hide();
00235     virtual void posChanged();
00236     virtual Ogre::OverlayElement* getOverlayElementToAdd();
00237 
00238 };
00239 
00246 class FEButton : public FEPanel, public MouseHandler
00247 {
00248 public:
00262     FEButton(GraphicsInteractionManager *gim,
00263              const std::set<OIS::KeyCode> *modifierKeys, const OIS::MouseButtonID oisMouseButtonId,
00264              std::string name = "FEButton",
00265              Widget *aParent = 0, Ogre::ColourValue color = Ogre::ColourValue::Red,
00266              Ogre::Vector2 defaultPos = Ogre::Vector2::NEGATIVE_UNIT_X,
00267              Ogre::Vector2 defaultSize = DEFAULT_LABEL_SIZE, bool (*pClickFunction)() = NULL, std::string material = DEFAULT_PANEL_MATERIAL, std::string = "BLANK", Ogre::GuiMetricsMode defaultMode = Ogre::GMM_RELATIVE);
00268     ~FEButton();
00269 
00270     bool (*pClickFunction)();
00271     bool pressed; 
00272     bool enabled; 
00278     virtual void handleMouseEvent(const OIS::MouseEvent &args);
00279     virtual void show();
00280     virtual void hide();
00281 };
00282 
00285 class FESCVButton : public FEButton
00286 {
00287 public:
00300     FESCVButton(GraphicsInteractionManager *gim,
00301                 const std::set<OIS::KeyCode> *modifierKeys, const OIS::MouseButtonID oisMouseButtonId,
00302                 std::string caption = "FEButton",
00303                 Widget *aParent = 0, Ogre::ColourValue color = Ogre::ColourValue::Red,
00304                 Ogre::Vector2 defaultPos = Ogre::Vector2::NEGATIVE_UNIT_X,
00305                 Ogre::Vector2 defaultSize = DEFAULT_LABEL_SIZE, Ogre::GuiMetricsMode defaultMode = Ogre::GMM_RELATIVE);
00306     ~FESCVButton();
00307 
00308     virtual void handleMouseEvent(const OIS::MouseEvent &args);
00309 };
00310 
00313 class FEMarineButton : public FEButton
00314 {
00315 public:
00328     FEMarineButton(GraphicsInteractionManager *gim,
00329                    const std::set<OIS::KeyCode> *modifierKeys, const OIS::MouseButtonID oisMouseButtonId,
00330                    std::string caption = "FEButton",
00331                    Widget *aParent = 0, Ogre::ColourValue color = Ogre::ColourValue::Red,
00332                    Ogre::Vector2 defaultPos = Ogre::Vector2::NEGATIVE_UNIT_X,
00333                    Ogre::Vector2 defaultSize = DEFAULT_LABEL_SIZE, Ogre::GuiMetricsMode defaultMode = Ogre::GMM_RELATIVE);
00334     ~FEMarineButton();
00335 
00336     virtual void handleMouseEvent(const OIS::MouseEvent &args);
00337 };
00338 
00342 class FELabelPair : public FEPanel
00343 {
00344 public:
00358     FELabelPair(GraphicsInteractionManager *gim, std::string caption1 = "Key", std::string caption2 = "Value",
00359                 Widget *aParent = 0, Ogre::ColourValue color = Ogre::ColourValue::Green,
00360                 Ogre::Vector2 defaultPos = Ogre::Vector2::NEGATIVE_UNIT_X,
00361                 Ogre::Vector2 defaultColumnWidths = Ogre::Vector2(100, 200), int columnHeight = DEFAULT_LABEL_SIZE.y,
00362                 std::string materialName = DEFAULT_PANEL_MATERIAL, Ogre::GuiMetricsMode defaultMode = Ogre::GMM_RELATIVE);
00363 
00364     /*dimensions/positions are in pixels */
00365     ~FELabelPair()
00366     {
00367     };
00368 
00369     FELabel *left, *right;
00370 
00371     virtual void show();
00372     virtual void hide();
00373 
00379     void setLeft(std::string val);
00380 
00386     void setRight(std::string val);
00387 
00388 };
00389 
00390 
00391 }
00392 
00393 
00394 #endif /* WIDGETS_H_ */

Generated on Fri Dec 13 14:54:16 2013 for FastECSLent by  doxygen 1.5.4