add style for colorbox in outfit window

This commit is contained in:
Eduardo Bart
2011-11-16 15:03:11 -02:00
parent c999a49dc7
commit ba62863ff7
11 changed files with 116 additions and 56 deletions

View File

@@ -163,13 +163,14 @@ bool luavalue_cast(int index, Rect& rect)
rect.setWidth(g_lua.popInteger());
g_lua.getField("height", index);
rect.setHeight(g_lua.popInteger());
return true;
} else if(g_lua.isString()) {
return Fw::cast(g_lua.toString(index), rect);
} else if(g_lua.isNil()) {
rect = Rect();
return true;
}
return true;
return false;
}
// point
@@ -196,7 +197,7 @@ bool luavalue_cast(int index, Point& point)
point = Point();
return true;
}
return true;
return false;
}
// size
@@ -223,7 +224,7 @@ bool luavalue_cast(int index, Size& size)
size = Size();
return true;
}
return true;
return false;
}
// otml nodes
@@ -270,9 +271,9 @@ bool luavalue_cast(int index, OTMLNodePtr& node)
node->writeAt(cnodeName, g_lua.toString());
g_lua.pop();
}
} else
return false;
return true;
return true;
}
return false;
}
// object ptr

View File

@@ -48,7 +48,7 @@ void UICheckBox::render()
void UICheckBox::onMouseRelease(const Point& mousePos, Fw::MouseButton button)
{
if(isPressed() && getRect().contains(mousePos))
setState(Fw::CheckedState, !isChecked());
setChecked(!isChecked());
}
void UICheckBox::onStyleApply(const OTMLNodePtr& styleNode)
@@ -68,3 +68,14 @@ void UICheckBox::onStyleApply(const OTMLNodePtr& styleNode)
}
}
}
bool UICheckBox::isChecked()
{
return hasState(Fw::CheckedState);
}
void UICheckBox::setChecked(bool checked)
{
if(setState(Fw::CheckedState, checked))
callLuaField("onCheckChange", checked);
}

View File

@@ -30,8 +30,8 @@ class UICheckBox : public UIWidget
public:
void render();
bool isChecked() { return hasState(Fw::CheckedState); }
void setChecked(bool checked) { setState(Fw::CheckedState, checked); }
bool isChecked();
void setChecked(bool checked);
void setText(const std::string& text) { m_text = text; }
std::string getText() { return m_text; }

View File

@@ -615,10 +615,10 @@ void UIWidget::updateLayout()
m_layout->update();
}
void UIWidget::setState(Fw::WidgetState state, bool on)
bool UIWidget::setState(Fw::WidgetState state, bool on)
{
if(state == Fw::InvalidState)
return;
return false;
int oldStates = m_states;
if(on)
@@ -626,8 +626,11 @@ void UIWidget::setState(Fw::WidgetState state, bool on)
else
m_states &= ~state;
if(oldStates != m_states)
if(oldStates != m_states) {
updateStyle();
return true;
}
return false;
}
bool UIWidget::hasState(Fw::WidgetState state)
@@ -700,9 +703,7 @@ void UIWidget::updateState(Fw::WidgetState state)
child->updateState(state);
}
if(newStatus != oldStatus) {
setState(state, newStatus);
if(setState(state, newStatus)) {
if(state == Fw::FocusState) {
g_dispatcher.addEvent(std::bind(&UIWidget::onFocusChange, asUIWidget(), newStatus, m_lastFocusReason));
} else if(state == Fw::HoverState)

View File

@@ -149,7 +149,7 @@ public:
void updateStates();
virtual void updateState(Fw::WidgetState state);
void setState(Fw::WidgetState state, bool on);
bool setState(Fw::WidgetState state, bool on);
bool hasState(Fw::WidgetState state);
void updateStyle();