* wrong enum used for text alignment

* wrong event function used
dev-ui
erihel 2012-08-18 21:04:51 +02:00
parent 48ad79a03c
commit 8d4a3ed579
7 changed files with 25 additions and 47 deletions

View File

@ -61,9 +61,9 @@ common/image.cpp
common/logger.cpp
common/iman.cpp
# common/metafile.cpp
common/misc.cpp
# common/misc.cpp
# common/modfile.cpp
common/profile.cpp
# common/profile.cpp
# common/restext.cpp
common/stringutils.cpp
graphics/core/color.cpp
@ -149,7 +149,7 @@ graphics/opengl/gldevice.cpp
# ui/check.cpp
# ui/color.cpp
# ui/compass.cpp
ui/control.cpp
# ui/control.cpp
# ui/displayinfo.cpp
# ui/displaytext.cpp
# ui/edit.cpp
@ -159,7 +159,7 @@ ui/control.cpp
# ui/image.cpp
# ui/interface.cpp
# ui/key.cpp
ui/label.cpp
# ui/label.cpp
# ui/list.cpp
# ui/maindialog.cpp
# ui/mainmap.cpp

View File

@ -72,12 +72,8 @@ template <typename T> inline T* CInterface::CreateControl(Math::Point pos, Math:
{
T* pc;
int index;
Event event;
if (eventMsg == EVENT_NULL) {
m_event->GetEvent(event);
eventMsg = event.type;
}
if (eventMsg == EVENT_NULL)
eventMsg = GetUniqueEventType();
if ((index = GetNextFreeControl()) < 0)
return nullptr;
@ -95,12 +91,8 @@ CWindow* CInterface::CreateWindows(Math::Point pos, Math::Point dim, int icon, E
{
CWindow* pc;
int index;
Event event;
if (eventMsg == EVENT_NULL) {
m_event->GetEvent(event);
eventMsg = event.type;
}
if (eventMsg == EVENT_NULL)
eventMsg = GetUniqueEventType();
switch (eventMsg) {
case EVENT_WINDOW0: index = 0; break;
@ -212,12 +204,8 @@ CList* CInterface::CreateList(Math::Point pos, Math::Point dim, int icon, EventT
{
CList* pc;
int index;
Event event;
if (eventMsg == EVENT_NULL) {
m_event->GetEvent(event);
eventMsg = event.type;
}
if (eventMsg == EVENT_NULL)
eventMsg = GetUniqueEventType();
if ((index = GetNextFreeControl()) < 0)
return nullptr;

View File

@ -59,12 +59,8 @@ CKey::~CKey()
bool CKey::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
char name[100];
Event event;
if (eventMsg == EVENT_NULL) {
m_event->GetEvent(event);
eventMsg = event.type;
}
if (eventMsg == EVENT_NULL)
eventMsg = GetUniqueEventType();
CControl::Create(pos, dim, icon, eventMsg);
GetResource(RES_EVENT, eventMsg, name);

View File

@ -40,12 +40,8 @@ CLabel::~CLabel()
bool CLabel::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
Event event;
if (eventMsg == EVENT_NULL) {
m_event->GetEvent(event);
eventMsg = event.type;
}
if (eventMsg == EVENT_NULL)
eventMsg = GetUniqueEventType();
CControl::Create(pos, dim, icon, eventMsg);
return true;
@ -73,9 +69,9 @@ void CLabel::Draw()
pos.y = m_pos.y + m_dim.y / 2.0f;
switch (m_textAlign) {
case Gfx::TEXT_ALIGN_LEFT: pos.x = m_pos.x; break;
case Gfx::TEXT_ALIGN_RIGHT: pos.x = m_pos.x; break;
case Gfx::TEXT_ALIGN_CENTER: pos.x = m_pos.x + m_dim.x / 2.0f; break;
case Gfx::TEXT_ALIGN_RIGHT: pos.x = m_pos.x + m_dim.x; break;
case Gfx::TEXT_ALIGN_LEFT: pos.x = m_pos.x + m_dim.x; break;
}
m_engine->GetText()->DrawText(std::string(m_name), m_fontType, m_fontSize, pos, m_dim.x, m_textAlign, 0);

View File

@ -23,6 +23,7 @@
#include <ui/control.h>
#include <common/event.h>
#include <common/misc.h>
namespace Ui {

View File

@ -42,7 +42,7 @@ CList::CList() : CControl()
for (int i = 0; i < 10; i++) {
m_tabs[i] = 0.0f;
m_justifs[i] = Gfx::TEXT_ALIGN_CENTER;
m_justifs[i] = Gfx::TEXT_ALIGN_RIGHT;
}
m_totalLine = 0;
@ -72,14 +72,10 @@ CList::~CList()
bool CList::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand)
{
Event event;
m_expand = expand;
if (eventMsg == EVENT_NULL) {
m_event->GetEvent(event);
eventMsg = event.type;
}
if (eventMsg == EVENT_NULL)
eventMsg = GetUniqueEventType();
CControl::Create(pos, dim, icon, eventMsg);
@ -131,7 +127,7 @@ bool CList::MoveAdjust()
for (int i = 0; i < m_displayLine; i++) {
m_button[i] = new CButton();
m_button[i]->Create(ppos, ddim, -1, EVENT_NULL);
m_button[i]->SetTextAlign(Gfx::TEXT_ALIGN_CENTER);
m_button[i]->SetTextAlign(Gfx::TEXT_ALIGN_RIGHT);
m_button[i]->SetState(STATE_SIMPLY);
m_button[i]->SetFontType(m_fontType);
m_button[i]->SetFontSize(m_fontSize);
@ -417,7 +413,7 @@ void CList::Draw()
ppos.y = pos.y + dim.y * 0.5f;
ppos.y -= m_engine->GetText()->GetHeight(m_fontType, m_fontSize) / 2.0f;
ddim.x = dim.x-dim.y;
DrawCase(m_text[i + m_firstLine], ppos, ddim.x, Gfx::TEXT_ALIGN_CENTER);
DrawCase(m_text[i + m_firstLine], ppos, ddim.x, Gfx::TEXT_ALIGN_RIGHT);
} else {
ppos.x = pos.x + dim.y * 0.5f;
ppos.y = pos.y + dim.y * 0.5f;
@ -505,9 +501,9 @@ void CList::Draw()
void CList::DrawCase(char *text, Math::Point pos, float width, Gfx::TextAlign justif)
{
if (justif == Gfx::TEXT_ALIGN_LEFT)
if (justif == Gfx::TEXT_ALIGN_CENTER)
pos.x += width / 2.0f;
else
else if (justif == Gfx::TEXT_ALIGN_LEFT)
pos.x += width;
m_engine->GetText()->DrawText(std::string(text), m_fontType, m_fontSize, pos, width, justif, 0);
}

View File

@ -25,6 +25,7 @@
#include <ui/scroll.h>
#include <common/event.h>
#include <common/misc.h>
#include <graphics/engine/text.h>