diff options
author | Thales Lima Oliveira <thaleslima.ufu@gmail.com> | 2017-10-24 21:14:59 -0200 |
---|---|---|
committer | Thales Lima Oliveira <thaleslima.ufu@gmail.com> | 2017-10-24 21:14:59 -0200 |
commit | 39a34b99185b3c046fb4427d07dd333575962e29 (patch) | |
tree | 6654d829e82410a6ab0525d2273aeb523f124523 /Project/Constant.cpp | |
parent | 43f947856a6ce58fb5b168680c53fd7652f63f46 (diff) | |
download | PSP.git-39a34b99185b3c046fb4427d07dd333575962e29.tar.gz PSP.git-39a34b99185b3c046fb4427d07dd333575962e29.tar.xz PSP.git-39a34b99185b3c046fb4427d07dd333575962e29.zip |
A lot of text bugfixes
Diffstat (limited to 'Project/Constant.cpp')
-rw-r--r-- | Project/Constant.cpp | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/Project/Constant.cpp b/Project/Constant.cpp index 1c375f1..9991d90 100644 --- a/Project/Constant.cpp +++ b/Project/Constant.cpp @@ -28,7 +28,10 @@ Constant::Constant(int id) : ControlElement(id) m_nodeList.push_back(nodeOut); } -Constant::~Constant() {} +Constant::~Constant() +{ + if(m_glText) delete m_glText; +} void Constant::Draw(wxPoint2DDouble translation, double scale) const { glLineWidth(1.0); @@ -43,11 +46,7 @@ void Constant::Draw(wxPoint2DDouble translation, double scale) const DrawRectangle(m_position, m_width, m_height, GL_LINE_LOOP); // Plot number. - glEnable(GL_TEXTURE_2D); - glColor4d(0.0, 0.0, 0.0, 1.0); - m_glStringValue->bind(); - m_glStringValue->render(m_position.m_x, m_position.m_y); - glDisable(GL_TEXTURE_2D); + m_glText->Draw(m_position); glColor4d(0.0, 0.0, 0.0, 1.0); DrawNodes(); @@ -103,19 +102,13 @@ void Constant::SetValue(double value) m_value = value; wxString text = StringFromDouble(m_value); - wxFont font(m_fontSize, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); - wxScreenDC dc; - - if(m_glStringValue) { - delete m_glStringValue; - m_glStringValue = NULL; - } - m_glStringValue = new wxGLString(text); - m_glStringValue->setFont(font); - m_glStringValue->consolidate(&dc); + if(m_glText) + m_glText->SetText(text); + else + m_glText = new OpenGLText(text); - m_width = m_glStringValue->getWidth() + 6 + 2 * m_borderSize; - m_height = m_glStringValue->getheight() + 6 + 2 * m_borderSize; + m_width = m_glText->GetWidth() + 6 + 2 * m_borderSize; + m_height = m_glText->GetHeight() + 6 + 2 * m_borderSize; UpdatePoints(); } @@ -124,7 +117,6 @@ Element* Constant::GetCopy() { Constant* copy = new Constant(m_elementID); *copy = *this; - m_glStringValue = NULL; - SetValue(m_value); + copy->m_glText = m_glText->GetCopy(); return copy; } |