Go to the documentation of this file.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
00027
00028 #pragma once
00029 #include <Ogre.h>
00030
00031 #ifndef TEXT_OUTPUT_H_
00032 #define TEXT_OUTPUT_H_
00033
00034 namespace ogre_tools
00035 {
00039 class TextOutput
00040 {
00041
00042 public:
00052 TextOutput(const std::string& id, Ogre::Real pos_x, Ogre::Real pos_y, Ogre::Real width, Ogre::Real height) :
00053 id_(id)
00054 {
00055 overlayManager_ = Ogre::OverlayManager::getSingletonPtr();
00056
00057 panel_ = static_cast<Ogre::OverlayContainer*>(overlayManager_->createOverlayElement("Panel", "text_container"));
00058 panel_->setDimensions(1, 1);
00059 panel_->setPosition(0, 0);
00060
00061 overlay_ = overlayManager_->create("text_overlay");
00062 overlay_->add2D(panel_);
00063 overlay_->show();
00064
00065 textBox_ = overlayManager_->createOverlayElement("TextArea", id_);
00066 textBox_->setPosition(pos_x, pos_y);
00067 textBox_->setDimensions(width, height);
00068 textBox_->setWidth(width);
00069 textBox_->setHeight(height);
00070 textBox_->setMetricsMode(Ogre::GMM_PIXELS);
00071 textBox_->setParameter("font_name", "Arial");
00072
00073 panel_->addChild(textBox_);
00074 }
00075
00079 ~TextOutput();
00080
00085 void setText(const std::string& Text)
00086 {
00087 textBox_->setCaption(Text);
00088 }
00089
00094 void setColor(const Ogre::ColourValue& color)
00095 {
00096 textBox_->setColour(color);
00097 }
00098
00103 void setFontSize(const int& size)
00104 {
00105 std::stringstream char_height;
00106 char_height << size;
00107 textBox_->setParameter("char_height", char_height.str());
00108 }
00109
00110 private:
00111 Ogre::OverlayElement* textBox_;
00112 Ogre::OverlayManager* overlayManager_;
00113 Ogre::Overlay* overlay_;
00114 Ogre::OverlayContainer* panel_;
00115 std::string id_;
00116 };
00117 }
00118
00119 #endif