reorganize all constants and place them into namespaces

This commit is contained in:
Eduardo Bart
2011-08-28 13:02:26 -03:00
parent dab483caab
commit e87297c1b5
62 changed files with 527 additions and 800 deletions

View File

@@ -35,8 +35,8 @@ void UIAnchorGroup::addAnchor(const UIAnchor& anchor)
m_anchors.push_back(anchor);
}
void UIAnchorLayout::addAnchor(const UIWidgetPtr& anchoredWidget, AnchorEdge anchoredEdge,
const std::string& hookedWidgetId, AnchorEdge hookedEdge)
void UIAnchorLayout::addAnchor(const UIWidgetPtr& anchoredWidget, Fw::AnchorEdge anchoredEdge,
const std::string& hookedWidgetId, Fw::AnchorEdge hookedEdge)
{
if(!anchoredWidget)
return;
@@ -59,16 +59,16 @@ void UIAnchorLayout::removeAnchors(const UIWidgetPtr& anchoredWidget)
void UIAnchorLayout::centerIn(const UIWidgetPtr& anchoredWidget, const std::string& hookedWidgetId)
{
addAnchor(anchoredWidget, AnchorHorizontalCenter, hookedWidgetId, AnchorHorizontalCenter);
addAnchor(anchoredWidget, AnchorVerticalCenter, hookedWidgetId, AnchorVerticalCenter);
addAnchor(anchoredWidget, Fw::AnchorHorizontalCenter, hookedWidgetId, Fw::AnchorHorizontalCenter);
addAnchor(anchoredWidget, Fw::AnchorVerticalCenter, hookedWidgetId, Fw::AnchorVerticalCenter);
}
void UIAnchorLayout::fill(const UIWidgetPtr& anchoredWidget, const std::string& hookedWidgetId)
{
addAnchor(anchoredWidget, AnchorLeft, hookedWidgetId, AnchorLeft);
addAnchor(anchoredWidget, AnchorRight, hookedWidgetId, AnchorRight);
addAnchor(anchoredWidget, AnchorTop, hookedWidgetId, AnchorTop);
addAnchor(anchoredWidget, AnchorBottom, hookedWidgetId, AnchorBottom);
addAnchor(anchoredWidget, Fw::AnchorLeft, hookedWidgetId, Fw::AnchorLeft);
addAnchor(anchoredWidget, Fw::AnchorRight, hookedWidgetId, Fw::AnchorRight);
addAnchor(anchoredWidget, Fw::AnchorTop, hookedWidgetId, Fw::AnchorTop);
addAnchor(anchoredWidget, Fw::AnchorBottom, hookedWidgetId, Fw::AnchorBottom);
}
void UIAnchorLayout::update()
@@ -108,7 +108,7 @@ void UIAnchorLayout::updateWidget(const UIWidgetPtr& widget, UIAnchorGroup& anch
// calculates new rect based on anchors
for(const UIAnchor& anchor : anchorGroup.getAnchors()) {
// skip invalid anchors
if(anchor.getHookedEdge() == AnchorNone)
if(anchor.getHookedEdge() == Fw::AnchorNone)
continue;
// determine hooked widget
@@ -141,22 +141,22 @@ void UIAnchorLayout::updateWidget(const UIWidgetPtr& widget, UIAnchorGroup& anch
// determine hooked widget edge point
int point = 0;
switch(anchor.getHookedEdge()) {
case AnchorLeft:
case Fw::AnchorLeft:
point = hookedWidget->getRect().left();
break;
case AnchorRight:
case Fw::AnchorRight:
point = hookedWidget->getRect().right();
break;
case AnchorTop:
case Fw::AnchorTop:
point = hookedWidget->getRect().top();
break;
case AnchorBottom:
case Fw::AnchorBottom:
point = hookedWidget->getRect().bottom();
break;
case AnchorHorizontalCenter:
case Fw::AnchorHorizontalCenter:
point = hookedWidget->getRect().horizontalCenter();
break;
case AnchorVerticalCenter:
case Fw::AnchorVerticalCenter:
point = hookedWidget->getRect().verticalCenter();
break;
default:
@@ -166,36 +166,36 @@ void UIAnchorLayout::updateWidget(const UIWidgetPtr& widget, UIAnchorGroup& anch
}
switch(anchor.getAnchoredEdge()) {
case AnchorHorizontalCenter:
case Fw::AnchorHorizontalCenter:
newRect.moveHorizontalCenter(point + widget->getMarginLeft() - widget->getMarginRight());
horizontalMoved = true;
break;
case AnchorLeft:
case Fw::AnchorLeft:
if(!horizontalMoved) {
newRect.moveLeft(point + widget->getMarginLeft());
horizontalMoved = true;
} else
newRect.setLeft(point + widget->getMarginLeft());
break;
case AnchorRight:
case Fw::AnchorRight:
if(!horizontalMoved) {
newRect.moveRight(point - widget->getMarginRight());
horizontalMoved = true;
} else
newRect.setRight(point - widget->getMarginRight());
break;
case AnchorVerticalCenter:
case Fw::AnchorVerticalCenter:
newRect.moveVerticalCenter(point + widget->getMarginTop() - widget->getMarginBottom());
verticalMoved = true;
break;
case AnchorTop:
case Fw::AnchorTop:
if(!verticalMoved) {
newRect.moveTop(point + widget->getMarginTop());
verticalMoved = true;
} else
newRect.setTop(point + widget->getMarginTop());
break;
case AnchorBottom:
case Fw::AnchorBottom:
if(!verticalMoved) {
newRect.moveBottom(point - widget->getMarginBottom());
verticalMoved = true;

View File

@@ -28,16 +28,16 @@
class UIAnchor
{
public:
UIAnchor(AnchorEdge anchoredEdge, const std::string& hookedWidgetId, AnchorEdge hookedEdge) :
UIAnchor(Fw::AnchorEdge anchoredEdge, const std::string& hookedWidgetId, Fw::AnchorEdge hookedEdge) :
m_anchoredEdge(anchoredEdge), m_hookedEdge(hookedEdge), m_hookedWidgetId(hookedWidgetId) { }
AnchorEdge getAnchoredEdge() const { return m_anchoredEdge; }
Fw::AnchorEdge getAnchoredEdge() const { return m_anchoredEdge; }
std::string getHookedWidgetId() const { return m_hookedWidgetId; }
AnchorEdge getHookedEdge() const { return m_hookedEdge; }
Fw::AnchorEdge getHookedEdge() const { return m_hookedEdge; }
private:
AnchorEdge m_anchoredEdge;
AnchorEdge m_hookedEdge;
Fw::AnchorEdge m_anchoredEdge;
Fw::AnchorEdge m_hookedEdge;
std::string m_hookedWidgetId;
};
@@ -61,8 +61,8 @@ class UIAnchorLayout : public UILayout
public:
UIAnchorLayout(UIWidgetPtr parentWidget) : UILayout(parentWidget) { }
void addAnchor(const UIWidgetPtr& anchoredWidget, AnchorEdge anchoredEdge,
const std::string& hookedWidgetId, AnchorEdge hookedEdge);
void addAnchor(const UIWidgetPtr& anchoredWidget, Fw::AnchorEdge anchoredEdge,
const std::string& hookedWidgetId, Fw::AnchorEdge hookedEdge);
void removeAnchors(const UIWidgetPtr& anchoredWidget);
void centerIn(const UIWidgetPtr& anchoredWidget, const std::string& hookedWidgetId);
void fill(const UIWidgetPtr& anchoredWidget, const std::string& hookedWidgetId);

View File

@@ -41,7 +41,7 @@ void UIButton::render()
UIWidget::render();
Rect textRect = m_rect;
textRect.translate(m_textTranslate);
m_font->renderText(m_text, textRect, AlignCenter, m_foregroundColor);
m_font->renderText(m_text, textRect, Fw::AlignCenter, m_foregroundColor);
}
void UIButton::onStyleApply(const OTMLNodePtr& styleNode)
@@ -60,7 +60,7 @@ void UIButton::onStyleApply(const OTMLNodePtr& styleNode)
}
}
bool UIButton::onMouseRelease(const Point& mousePos, MouseButton button)
bool UIButton::onMouseRelease(const Point& mousePos, Fw::MouseButton button)
{
if(isPressed()) {
if(m_onClick && getRect().contains(mousePos))

View File

@@ -41,7 +41,7 @@ public:
protected:
virtual void onStyleApply(const OTMLNodePtr& styleNode);
virtual bool onMouseRelease(const Point& mousePos, MouseButton button);
virtual bool onMouseRelease(const Point& mousePos, Fw::MouseButton button);
SimpleCallback m_onClick;
Point m_textTranslate;

View File

@@ -28,7 +28,7 @@ void UILabel::setup()
{
UIWidget::setup();
setFocusable(false);
setAlign(AlignLeft);
setAlign(Fw::AlignLeft);
}
void UILabel::render()
@@ -66,7 +66,7 @@ void UILabel::onStyleApply(const OTMLNodePtr& styleNode)
if(node->tag() == "text")
setText(node->value());
else if(node->tag() == "align")
setAlign(fw::translateAlignment(node->value()));
setAlign(Fw::translateAlignment(node->value()));
else if(node->tag() == "offset") {
setOffset(node->value<Point>());
}

View File

@@ -34,11 +34,11 @@ public:
void resizeToText();
void setText(const std::string& text);
void setAlign(AlignmentFlag align) { m_align = align; }
void setAlign(Fw::AlignmentFlag align) { m_align = align; }
void setOffset(const Point& offset) { m_offset = offset; }
std::string getText() const { return m_text; }
AlignmentFlag getAlign() const { return m_align; }
Fw::AlignmentFlag getAlign() const { return m_align; }
Point getOffset() const { return m_offset; }
protected:
@@ -47,7 +47,7 @@ protected:
private:
std::string m_text;
Point m_offset;
AlignmentFlag m_align;
Fw::AlignmentFlag m_align;
};
#endif

View File

@@ -28,7 +28,7 @@
UILineEdit::UILineEdit()
{
m_align = AlignLeftCenter;
m_align = Fw::AlignLeftCenter;
m_cursorPos = 0;
m_startRenderPos = 0;
m_textHorizontalMargin = 3;
@@ -139,16 +139,16 @@ void UILineEdit::update()
textScreenCoords.addRight(-m_textHorizontalMargin);
m_drawArea = textScreenCoords;
if(m_align & AlignBottom) {
if(m_align & Fw::AlignBottom) {
m_drawArea.translate(0, textScreenCoords.height() - textBoxSize.height());
} else if(m_align & AlignVerticalCenter) {
} else if(m_align & Fw::AlignVerticalCenter) {
m_drawArea.translate(0, (textScreenCoords.height() - textBoxSize.height()) / 2);
} else { // AlignTop
}
if(m_align & AlignRight) {
if(m_align & Fw::AlignRight) {
m_drawArea.translate(textScreenCoords.width() - textBoxSize.width(), 0);
} else if(m_align & AlignHorizontalCenter) {
} else if(m_align & Fw::AlignHorizontalCenter) {
m_drawArea.translate((textScreenCoords.width() - textBoxSize.width()) / 2, 0);
} else { // AlignLeft
@@ -167,17 +167,17 @@ void UILineEdit::update()
Rect glyphTextureCoords = glyphsTextureCoords[glyph];
// first translate to align position
if(m_align & AlignBottom) {
if(m_align & Fw::AlignBottom) {
glyphScreenCoords.translate(0, textScreenCoords.height() - textBoxSize.height());
} else if(m_align & AlignVerticalCenter) {
} else if(m_align & Fw::AlignVerticalCenter) {
glyphScreenCoords.translate(0, (textScreenCoords.height() - textBoxSize.height()) / 2);
} else { // AlignTop
// nothing to do
}
if(m_align & AlignRight) {
if(m_align & Fw::AlignRight) {
glyphScreenCoords.translate(textScreenCoords.width() - textBoxSize.width(), 0);
} else if(m_align & AlignHorizontalCenter) {
} else if(m_align & Fw::AlignHorizontalCenter) {
glyphScreenCoords.translate((textScreenCoords.width() - textBoxSize.width()) / 2, 0);
} else { // AlignLeft
// nothing to do
@@ -243,7 +243,7 @@ void UILineEdit::setText(const std::string& text)
}
}
void UILineEdit::setAlign(AlignmentFlag align)
void UILineEdit::setAlign(Fw::AlignmentFlag align)
{
if(m_align != align) {
m_align = align;
@@ -360,10 +360,10 @@ void UILineEdit::onGeometryUpdate(const Rect& oldRect, const Rect& newRect)
update();
}
void UILineEdit::onFocusChange(bool focused, FocusReason reason)
void UILineEdit::onFocusChange(bool focused, Fw::FocusReason reason)
{
if(focused) {
if(reason == TabFocusReason)
if(reason == Fw::TabFocusReason)
setCursorPos(m_text.length());
else
blinkCursor();
@@ -386,7 +386,7 @@ bool UILineEdit::onKeyPress(uchar keyCode, char keyChar, int keyboardModifiers)
setCursorPos(m_text.length());
else if(keyCode == KC_TAB) {
if(UIWidgetPtr parent = getParent())
parent->focusNextChild(TabFocusReason);
parent->focusNextChild(Fw::TabFocusReason);
} else if(keyCode == KC_RETURN) {
if(m_onAction)
m_onAction();
@@ -398,9 +398,9 @@ bool UILineEdit::onKeyPress(uchar keyCode, char keyChar, int keyboardModifiers)
return true;
}
bool UILineEdit::onMousePress(const Point& mousePos, MouseButton button)
bool UILineEdit::onMousePress(const Point& mousePos, Fw::MouseButton button)
{
if(button == MouseLeftButton) {
if(button == Fw::MouseLeftButton) {
int pos = getTextPos(mousePos);
if(pos >= 0)
setCursorPos(pos);

View File

@@ -35,7 +35,7 @@ public:
void update();
void setText(const std::string& text);
void setAlign(AlignmentFlag align);
void setAlign(Fw::AlignmentFlag align);
void setCursorPos(int pos);
void setCursorEnabled(bool enable = true);
@@ -51,16 +51,16 @@ public:
protected:
virtual void onStyleApply(const OTMLNodePtr& styleNode);
virtual void onGeometryUpdate(const Rect& oldRect, const Rect& newRect);
virtual void onFocusChange(bool focused, FocusReason reason);
virtual void onFocusChange(bool focused, Fw::FocusReason reason);
virtual bool onKeyPress(uchar keyCode, char keyChar, int keyboardModifiers);
virtual bool onMousePress(const Point& mousePos, MouseButton button);
virtual bool onMousePress(const Point& mousePos, Fw::MouseButton button);
private:
void blinkCursor();
std::string m_text;
Rect m_drawArea;
AlignmentFlag m_align;
Fw::AlignmentFlag m_align;
int m_cursorPos;
Point m_startInternalPos;
int m_startRenderPos;

View File

@@ -60,13 +60,13 @@ void UIManager::inputEvent(const PlatformEvent& event)
// translate input event to ui events
if(m_rootWidget) {
if(event.type & EventKeyboardAction) {
int keyboardModifiers = KeyboardNoModifier;
int keyboardModifiers = Fw::KeyboardNoModifier;
if(event.ctrl)
keyboardModifiers |= KeyboardCtrlModifier;
keyboardModifiers |= Fw::KeyboardCtrlModifier;
if(event.shift)
keyboardModifiers |= KeyboardShiftModifier;
keyboardModifiers |= Fw::KeyboardShiftModifier;
if(event.alt)
keyboardModifiers |= KeyboardAltModifier;
keyboardModifiers |= Fw::KeyboardAltModifier;
if(event.type == EventKeyDown)
m_rootWidget->onKeyPress(event.keycode, event.keychar, keyboardModifiers);
@@ -74,25 +74,25 @@ void UIManager::inputEvent(const PlatformEvent& event)
m_rootWidget->onKeyRelease(event.keycode, event.keychar, keyboardModifiers);
} else if(event.type & EventMouseAction) {
if(event.type == EventMouseMove) {
m_rootWidget->updateState(HoverState);
m_rootWidget->updateState(Fw::HoverState);
m_rootWidget->onMouseMove(event.mousePos, event.mouseMoved);
}
else if(event.type & EventMouseWheel) {
MouseWheelDirection dir = MouseNoWheel;
Fw::MouseWheelDirection dir = Fw::MouseNoWheel;
if(event.type & EventDown)
dir = MouseWheelDown;
dir = Fw::MouseWheelDown;
else if(event.type & EventUp)
dir = MouseWheelUp;
dir = Fw::MouseWheelUp;
m_rootWidget->onMouseWheel(event.mousePos, dir);
} else {
MouseButton button = MouseNoButton;
Fw::MouseButton button = Fw::MouseNoButton;
if(event.type & EventMouseLeftButton)
button = MouseLeftButton;
button = Fw::MouseLeftButton;
else if(event.type & EventMouseMidButton)
button = MouseMidButton;
button = Fw::MouseMidButton;
else if(event.type & EventMouseRightButton)
button = MouseRightButton;
button = Fw::MouseRightButton;
if(event.type & EventDown)
m_rootWidget->onMousePress(event.mousePos, button);
@@ -151,7 +151,7 @@ OTMLNodePtr UIManager::getStyle(const std::string& styleName)
auto it = m_styles.find(styleName);
if(it == m_styles.end())
throw std::runtime_error(fw::mkstr("style '", styleName, "' is not a defined style"));
throw std::runtime_error(Fw::mkstr("style '", styleName, "' is not a defined style"));
return m_styles[styleName];
}

View File

@@ -36,11 +36,11 @@
UIWidget::UIWidget()
{
m_updateEventScheduled = false;
m_states = DefaultState;
m_states = Fw::DefaultState;
// generate an unique id, this is need because anchored layouts find widgets by id
static unsigned long id = 1;
m_id = fw::mkstr("widget", id++);
m_id = Fw::mkstr("widget", id++);
}
UIWidget::~UIWidget()
@@ -62,8 +62,8 @@ void UIWidget::setup()
setPressed(false);
setSizeFixed(false);
setFont(g_fonts.getDefaultFont());
setBackgroundColor(Color::white);
setForegroundColor(Color::white);
setBackgroundColor(Fw::white);
setForegroundColor(Fw::white);
setOpacity(255);
setMarginTop(0);
setMarginRight(0);
@@ -272,7 +272,7 @@ UIWidgetPtr UIWidget::backwardsGetWidgetById(const std::string& id)
return widget;
}
void UIWidget::focusChild(const UIWidgetPtr& child, FocusReason reason)
void UIWidget::focusChild(const UIWidgetPtr& child, Fw::FocusReason reason)
{
if(child && !hasChild(child)) {
logError("attempt to focus an unknown child in a UIWidget");
@@ -285,14 +285,14 @@ void UIWidget::focusChild(const UIWidgetPtr& child, FocusReason reason)
if(child) {
child->setLastFocusReason(reason);
child->updateState(FocusState);
child->updateState(ActiveState);
child->updateState(Fw::FocusState);
child->updateState(Fw::ActiveState);
}
if(oldFocused) {
oldFocused->setLastFocusReason(reason);
oldFocused->updateState(FocusState);
oldFocused->updateState(ActiveState);
oldFocused->updateState(Fw::FocusState);
oldFocused->updateState(Fw::ActiveState);
}
}
}
@@ -314,7 +314,7 @@ void UIWidget::addChild(const UIWidgetPtr& child)
// always focus new child
if(child->isFocusable() && child->isExplicitlyVisible() && child->isExplicitlyEnabled())
focusChild(child, ActiveFocusReason);
focusChild(child, Fw::ActiveFocusReason);
// create default layout
if(!m_layout)
@@ -366,7 +366,7 @@ void UIWidget::removeChild(const UIWidgetPtr& child)
if(it != m_children.end()) {
// defocus if needed
if(m_focusedChild == child)
focusChild(nullptr, ActiveFocusReason);
focusChild(nullptr, Fw::ActiveFocusReason);
// unlock child if it was locked
unlockChild(child);
@@ -385,7 +385,7 @@ void UIWidget::removeChild(const UIWidgetPtr& child)
logError("attempt to remove an unknown child from a UIWidget");
}
void UIWidget::focusNextChild(FocusReason reason)
void UIWidget::focusNextChild(Fw::FocusReason reason)
{
UIWidgetPtr toFocus;
UIWidgetList rotatedChildren(m_children);
@@ -444,7 +444,7 @@ void UIWidget::lockChild(const UIWidgetPtr& child)
// lock child focus
if(child->isFocusable())
focusChild(child, ActiveFocusReason);
focusChild(child, Fw::ActiveFocusReason);
moveChildToTop(child);
}
@@ -495,13 +495,13 @@ void UIWidget::updateLayout()
m_layout->update();
}
void UIWidget::updateState(WidgetState state)
void UIWidget::updateState(Fw::WidgetState state)
{
bool newStatus = true;
bool oldStatus = hasState(state);
bool updateChildren = false;
if(state == ActiveState) {
if(state == Fw::ActiveState) {
UIWidgetPtr widget = asUIWidget();
UIWidgetPtr parent;
do {
@@ -515,10 +515,10 @@ void UIWidget::updateState(WidgetState state)
updateChildren = true;
}
else if(state == FocusState) {
else if(state == Fw::FocusState) {
newStatus = (getParent() && getParent()->getFocusedChild() == asUIWidget());
}
else if(state == HoverState) {
else if(state == Fw::HoverState) {
updateChildren = true;
Point mousePos = g_platform.getMouseCursorPos();
UIWidgetPtr widget = asUIWidget();
@@ -532,10 +532,10 @@ void UIWidget::updateState(WidgetState state)
}
} while(widget = parent);
}
else if(state == PressedState) {
else if(state == Fw::PressedState) {
newStatus = m_pressed;
}
else if(state == DisabledState) {
else if(state == Fw::DisabledState) {
bool enabled = true;
updateChildren = true;
UIWidgetPtr widget = asUIWidget();
@@ -564,19 +564,19 @@ void UIWidget::updateState(WidgetState state)
updateStyle();
if(state == FocusState)
if(state == Fw::FocusState)
onFocusChange(newStatus, m_lastFocusReason);
else if(state == HoverState)
else if(state == Fw::HoverState)
onHoverChange(newStatus);
}
}
void UIWidget::updateStates()
{
updateState(ActiveState);
updateState(FocusState);
updateState(DisabledState);
updateState(HoverState);
updateState(Fw::ActiveState);
updateState(Fw::FocusState);
updateState(Fw::DisabledState);
updateState(Fw::HoverState);
}
void UIWidget::updateStyle()
@@ -596,23 +596,23 @@ void UIWidget::updateStyle()
// merge states styles, NOTE: order does matter
OTMLNodePtr style = m_style->get("state.active");
if(style && hasState(ActiveState))
if(style && hasState(Fw::ActiveState))
newStateStyle->merge(style);
style = m_style->get("state.focus");
if(style && hasState(FocusState))
if(style && hasState(Fw::FocusState))
newStateStyle->merge(style);
style = m_style->get("state.hover");
if(style && hasState(HoverState))
if(style && hasState(Fw::HoverState))
newStateStyle->merge(style);
style = m_style->get("state.pressed");
if(style && hasState(PressedState))
if(style && hasState(Fw::PressedState))
newStateStyle->merge(style);
style = m_style->get("state.disabled");
if(style && hasState(DisabledState))
if(style && hasState(Fw::DisabledState))
newStateStyle->merge(style);
applyStyle(newStateStyle);
@@ -725,7 +725,7 @@ void UIWidget::onStyleApply(const OTMLNodePtr& styleNode)
} else if(what == "centerIn") {
anchorLayout->centerIn(asUIWidget(), node->value());
} else {
AnchorEdge anchoredEdge = fw::translateAnchorEdge(what);
Fw::AnchorEdge anchoredEdge = Fw::translateAnchorEdge(what);
std::string anchorDescription = node->value();
std::vector<std::string> split;
@@ -734,12 +734,12 @@ void UIWidget::onStyleApply(const OTMLNodePtr& styleNode)
throw OTMLException(node, "invalid anchor description");
std::string hookedWidgetId = split[0];
AnchorEdge hookedEdge = fw::translateAnchorEdge(split[1]);
Fw::AnchorEdge hookedEdge = Fw::translateAnchorEdge(split[1]);
if(anchoredEdge == AnchorNone)
if(anchoredEdge == Fw::AnchorNone)
throw OTMLException(node, "invalid anchor edge");
if(hookedEdge == AnchorNone)
if(hookedEdge == Fw::AnchorNone)
throw OTMLException(node, "invalid anchor target edge");
anchorLayout->addAnchor(asUIWidget(), anchoredEdge, hookedWidgetId, hookedEdge);
@@ -753,7 +753,7 @@ void UIWidget::onGeometryUpdate(const Rect& oldRect, const Rect& newRect)
}
void UIWidget::onFocusChange(bool focused, FocusReason reason)
void UIWidget::onFocusChange(bool focused, Fw::FocusReason reason)
{
}
@@ -807,7 +807,7 @@ bool UIWidget::onKeyRelease(uchar keyCode, char keyChar, int keyboardModifiers)
return false;
}
bool UIWidget::onMousePress(const Point& mousePos, MouseButton button)
bool UIWidget::onMousePress(const Point& mousePos, Fw::MouseButton button)
{
// do a backup of children list, because it may change while looping it
UIWidgetList children;
@@ -824,7 +824,7 @@ bool UIWidget::onMousePress(const Point& mousePos, MouseButton button)
for(const UIWidgetPtr& child : children) {
// when a focusable item is focused it must gain focus
if(child->isFocusable())
focusChild(child, MouseFocusReason);
focusChild(child, Fw::MouseFocusReason);
bool mustEnd = child->onMousePress(mousePos, button);
@@ -838,7 +838,7 @@ bool UIWidget::onMousePress(const Point& mousePos, MouseButton button)
return false;
}
bool UIWidget::onMouseRelease(const Point& mousePos, MouseButton button)
bool UIWidget::onMouseRelease(const Point& mousePos, Fw::MouseButton button)
{
// do a backup of children list, because it may change while looping it
UIWidgetList children;
@@ -885,7 +885,7 @@ bool UIWidget::onMouseMove(const Point& mousePos, const Point& mouseMoved)
return false;
}
bool UIWidget::onMouseWheel(const Point& mousePos, MouseWheelDirection direction)
bool UIWidget::onMouseWheel(const Point& mousePos, Fw::MouseWheelDirection direction)
{
// do a backup of children list, because it may change while looping it
UIWidgetList children;

View File

@@ -41,9 +41,9 @@ public:
virtual void setup();
virtual void render();
void setEnabled(bool enabled) { m_enabled = enabled; updateState(DisabledState); }
void setEnabled(bool enabled) { m_enabled = enabled; updateState(Fw::DisabledState); }
void setVisible(bool visible) { m_visible = visible; }
void setPressed(bool pressed) { m_pressed = pressed; updateState(PressedState); }
void setPressed(bool pressed) { m_pressed = pressed; updateState(Fw::PressedState); }
void setId(const std::string& id) { m_id = id; }
void setFocusable(bool focusable) { m_focusable = focusable; }
void setStyle(const std::string& styleName);
@@ -65,7 +65,7 @@ public:
void setMarginTop(int margin) { m_marginTop = margin; updateParentLayout(); }
void setMarginBottom(int margin) { m_marginBottom = margin; updateParentLayout(); }
void setSizeFixed(bool fixed) { m_fixedSize = fixed; updateParentLayout(); }
void setLastFocusReason(FocusReason reason) { m_lastFocusReason = reason; }
void setLastFocusReason(Fw::FocusReason reason) { m_lastFocusReason = reason; }
void resize(const Size& size) { setRect(Rect(getPosition(), size)); }
void moveTo(const Point& pos) { setRect(Rect(pos, getSize())); }
@@ -74,12 +74,12 @@ public:
void disable() { setEnabled(false); }
void enable() { setEnabled(true); }
bool isActive() const { return hasState(ActiveState); }
bool isEnabled() const { return !hasState(DisabledState); }
bool isDisabled() const { return hasState(DisabledState); }
bool isFocused() const { return hasState(FocusState); }
bool isHovered() const { return hasState(HoverState); }
bool isPressed() const { return hasState(PressedState); }
bool isActive() const { return hasState(Fw::ActiveState); }
bool isEnabled() const { return !hasState(Fw::DisabledState); }
bool isDisabled() const { return hasState(Fw::DisabledState); }
bool isFocused() const { return hasState(Fw::FocusState); }
bool isHovered() const { return hasState(Fw::HoverState); }
bool isPressed() const { return hasState(Fw::PressedState); }
bool isVisible();
bool isExplicitlyEnabled() const { return m_enabled; }
bool isExplicitlyVisible() const { return m_visible; }
@@ -87,7 +87,7 @@ public:
bool isSizeFixed() const { return m_fixedSize; }
bool hasChildren() const { return m_children.size() > 0; }
bool hasChild(const UIWidgetPtr& child);
bool hasState(WidgetState state) const { return m_states & state; }
bool hasState(Fw::WidgetState state) const { return m_states & state; }
std::string getId() const { return m_id; }
int getChildCount() const { return m_children.size(); }
@@ -110,7 +110,7 @@ public:
int getMarginRight() const { return m_marginRight; }
int getMarginTop() const { return m_marginTop; }
int getMarginBottom() const { return m_marginBottom; }
FocusReason getLastFocusReason() const { return m_lastFocusReason; }
Fw::FocusReason getLastFocusReason() const { return m_lastFocusReason; }
UIWidgetList getChildren() const { return m_children; }
UIWidgetPtr getFocusedChild() const { return m_focusedChild; }
@@ -126,15 +126,15 @@ public:
void addChild(const UIWidgetPtr& child);
void insertChild(int index, const UIWidgetPtr& child);
void removeChild(const UIWidgetPtr& child);
void focusChild(const UIWidgetPtr& child, FocusReason reason);
void focusNextChild(FocusReason reason);
void focusChild(const UIWidgetPtr& child, Fw::FocusReason reason);
void focusNextChild(Fw::FocusReason reason);
void moveChildToTop(const UIWidgetPtr& child);
void lockChild(const UIWidgetPtr& child);
void unlockChild(const UIWidgetPtr& child);
void updateParentLayout();
void updateLayout();
virtual void updateState(WidgetState state);
virtual void updateState(Fw::WidgetState state);
void updateStates();
virtual void updateStyle();
void applyStyle(const OTMLNodePtr& styleNode);
@@ -153,7 +153,7 @@ protected:
/// Triggered when widget is moved or resized
virtual void onGeometryUpdate(const Rect& oldRect, const Rect& newRect);
/// Triggered when widget gets or loses focus
virtual void onFocusChange(bool focused, FocusReason reason);
virtual void onFocusChange(bool focused, Fw::FocusReason reason);
/// Triggered when the mouse enters or leaves widget area
virtual void onHoverChange(bool hovered);
/// Triggered when user presses key while widget has focus
@@ -161,19 +161,19 @@ protected:
/// Triggered when user releases key while widget has focus
virtual bool onKeyRelease(uchar keyCode, char keyChar, int keyboardModifiers);
/// Triggered when a mouse button is pressed down while mouse pointer is inside widget area
virtual bool onMousePress(const Point& mousePos, MouseButton button);
virtual bool onMousePress(const Point& mousePos, Fw::MouseButton button);
/// Triggered when a mouse button is released
virtual bool onMouseRelease(const Point& mousePos, MouseButton button);
virtual bool onMouseRelease(const Point& mousePos, Fw::MouseButton button);
/// Triggered when mouse moves (even when the mouse is outside widget area)
virtual bool onMouseMove(const Point& mousePos, const Point& mouseMoved);
/// Triggered when mouse middle button wheels inside widget area
virtual bool onMouseWheel(const Point& mousePos, MouseWheelDirection direction);
virtual bool onMouseWheel(const Point& mousePos, Fw::MouseWheelDirection direction);
friend class UIManager;
protected:
std::string m_id;
FocusReason m_lastFocusReason;
Fw::FocusReason m_lastFocusReason;
bool m_enabled;
bool m_visible;
bool m_focusable;

View File

@@ -32,7 +32,7 @@ void UIWindow::setup()
m_moving = false;
m_headHeight = 0;
m_headMargin = 0;
m_titleAlign = AlignCenter;
m_titleAlign = Fw::AlignCenter;
}
void UIWindow::render()
@@ -47,9 +47,9 @@ void UIWindow::render()
// draw window head text
Rect headTextRect = headRect;
if(m_titleAlign & AlignLeft)
if(m_titleAlign & Fw::AlignLeft)
headTextRect.addLeft(-m_headMargin);
else if(m_titleAlign & AlignRight)
else if(m_titleAlign & Fw::AlignRight)
headTextRect.addRight(-m_headMargin);
m_font->renderText(m_title, headTextRect, m_titleAlign, m_foregroundColor);
}
@@ -76,7 +76,7 @@ void UIWindow::onStyleApply(const OTMLNodePtr& styleNode)
m_headImage = BorderImage::loadFromOTML(cnode);
m_headHeight = node->valueAt("height", m_headImage->getDefaultSize().height());
m_headMargin = node->valueAt("margin", 0);
m_titleAlign = fw::translateAlignment(node->valueAt("text align", std::string("center")));
m_titleAlign = Fw::translateAlignment(node->valueAt("text align", std::string("center")));
}
else if(node->tag() == "body") {
if(OTMLNodePtr cnode = node->get("border-image"))
@@ -109,7 +109,7 @@ void UIWindow::onGeometryUpdate(const Rect& oldRect, const Rect& newRect)
setRect(boundRect);
}
void UIWindow::onFocusChange(bool focused, FocusReason reason)
void UIWindow::onFocusChange(bool focused, Fw::FocusReason reason)
{
// when a window is focused it goes to the top
if(focused) {
@@ -118,7 +118,7 @@ void UIWindow::onFocusChange(bool focused, FocusReason reason)
}
}
bool UIWindow::onMousePress(const Point& mousePos, MouseButton button)
bool UIWindow::onMousePress(const Point& mousePos, Fw::MouseButton button)
{
if(!getChildByPos(mousePos)) {
m_moving = true;
@@ -128,7 +128,7 @@ bool UIWindow::onMousePress(const Point& mousePos, MouseButton button)
return UIWidget::onMousePress(mousePos, button);
}
bool UIWindow::onMouseRelease(const Point& mousePos, MouseButton button)
bool UIWindow::onMouseRelease(const Point& mousePos, Fw::MouseButton button)
{
if(m_moving) {
m_moving = false;

View File

@@ -37,9 +37,9 @@ public:
protected:
virtual void onStyleApply(const OTMLNodePtr& styleNode);
virtual void onGeometryUpdate(const Rect& oldRect, const Rect& newRect);
virtual void onFocusChange(bool focused, FocusReason reason);
virtual bool onMousePress(const Point& mousePos, MouseButton button);
virtual bool onMouseRelease(const Point& mousePos, MouseButton button);
virtual void onFocusChange(bool focused, Fw::FocusReason reason);
virtual bool onMousePress(const Point& mousePos, Fw::MouseButton button);
virtual bool onMouseRelease(const Point& mousePos, Fw::MouseButton button);
virtual bool onMouseMove(const Point& mousePos, const Point& mouseMoved);
private:
@@ -52,7 +52,7 @@ private:
ImagePtr m_bodyImage;
int m_headHeight;
int m_headMargin;
AlignmentFlag m_titleAlign;
Fw::AlignmentFlag m_titleAlign;
};
#endif