1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
#if defined(Hiro_Widget)
auto mWidget::allocate() -> pObject* {
return new pWidget(*this);
}
//
auto mWidget::doDrop(vector<string> names) const -> void {
if(state.onDrop) return state.onDrop(names);
}
auto mWidget::doMouseEnter() const -> void {
if(state.onMouseEnter) return state.onMouseEnter();
}
auto mWidget::doMouseLeave() const -> void {
if(state.onMouseLeave) return state.onMouseLeave();
}
auto mWidget::doMouseMove(Position position) const -> void {
if(state.onMouseMove) return state.onMouseMove(position);
}
auto mWidget::doMousePress(Mouse::Button button) const -> void {
if(state.onMousePress) return state.onMousePress(button);
}
auto mWidget::doMouseRelease(Mouse::Button button) const -> void {
if(state.onMouseRelease) return state.onMouseRelease(button);
}
auto mWidget::droppable() const -> bool {
return state.droppable;
}
auto mWidget::focusable() const -> bool {
return state.focusable;
}
auto mWidget::mouseCursor() const -> MouseCursor {
return state.mouseCursor;
}
auto mWidget::onDrop(const function<void (vector<string>)>& callback) -> type& {
state.onDrop = callback;
return *this;
}
auto mWidget::onMouseEnter(const function<void ()>& callback) -> type& {
state.onMouseEnter = callback;
return *this;
}
auto mWidget::onMouseLeave(const function<void ()>& callback) -> type& {
state.onMouseLeave = callback;
return *this;
}
auto mWidget::onMouseMove(const function<void (Position)>& callback) -> type& {
state.onMouseMove = callback;
return *this;
}
auto mWidget::onMousePress(const function<void (Mouse::Button)>& callback) -> type& {
state.onMousePress = callback;
return *this;
}
auto mWidget::onMouseRelease(const function<void (Mouse::Button)>& callback) -> type& {
state.onMouseRelease = callback;
return *this;
}
auto mWidget::remove() -> type& {
//TODO: how to implement this after removing mLayout?
//if(auto layout = parentLayout()) layout->remove(layout->sizable(offset()));
setParent();
return *this;
}
auto mWidget::setDroppable(bool droppable) -> type& {
state.droppable = droppable;
signal(setDroppable, droppable);
return *this;
}
auto mWidget::setFocusable(bool focusable) -> type& {
state.focusable = focusable;
signal(setFocusable, focusable);
return *this;
}
auto mWidget::setMouseCursor(const MouseCursor& mouseCursor) -> type& {
state.mouseCursor = mouseCursor;
signal(setMouseCursor, mouseCursor);
return *this;
}
auto mWidget::setToolTip(const string& toolTip) -> type& {
state.toolTip = toolTip;
//TODO: allow this option to dynamically control tool tips
if(!Application::state().toolTips) return *this;
signal(setToolTip, toolTip);
return *this;
}
auto mWidget::toolTip() const -> string {
return state.toolTip;
}
#endif
|