GUI state update using callbacks?
One of the aspects GUI development is setting the enabling/disabling
of widgets. This can be tricky and also burdensome to program. Today I
came up with the idea of using a callback system. It think it's an
interesting concept and I would like to know your opinions about it.
Following code will explain more:
typedef boost::function< bool() > Condition;
void setEnabled(bool inEnabled)
bool isEnabled() const
return TRUE == ::IsWindowEnabled(mHandle);
void setEnabledCondition(Condition inCondition)
mEnabledCondition = inCondition;
startTimer(boost::bind(&Widget::timerEvent, this, _1, 10); // call
setEnabled every 10 ms
void timerEvent(TimerID inTimerID)
bool enabled = mEnabledCondition();
Data * data = new Data;
Widget * submitDataButton = new Widget;
I think this would be very useful. It can be used for others methods
like "setText", "setVisible", etc..
The only thing that worries me is the idea of using a timer. I worry
that it would cause performance problems, especially since there would
be a timer for each widget. However, this could be solved by using a
However, I suspect that there might be simpler solutions that I am not
seeing right now.
Any thoughts, or ideas?
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]