New method FObject::isWidget()
This commit is contained in:
parent
526e193fb7
commit
b1d323ef76
|
@ -1,3 +1,8 @@
|
|||
2017-06-11 Markus Gans <guru.mail@muenster.de>
|
||||
* New method FObject::isWidget()
|
||||
* Non-widget objects inherit from FObjects will no longer
|
||||
affect the widget lists
|
||||
|
||||
2017-06-05 Markus Gans <guru.mail@muenster.de>
|
||||
* The focus and active flag is set centrally in FWidget
|
||||
|
||||
|
@ -45,7 +50,7 @@
|
|||
* Replace non-printable characters for Tera Term and
|
||||
Cygwin terminal directly at start-up. Special cases
|
||||
in the code are no longer necessary.
|
||||
* New Method setInsertCursorStyle() to change the appearance
|
||||
* New method setInsertCursorStyle() to change the appearance
|
||||
of a cursor
|
||||
|
||||
2017-04-02 Markus Gans <guru.mail@muenster.de>
|
||||
|
|
|
@ -167,6 +167,9 @@ bool FApplication::sendEvent(FObject* receiver, FEvent* event)
|
|||
if ( ! receiver )
|
||||
return false;
|
||||
|
||||
if ( ! receiver->isWidget() )
|
||||
return false;
|
||||
|
||||
widget = static_cast<FWidget*>(receiver);
|
||||
|
||||
if ( modal_dialogs > 0 )
|
||||
|
|
|
@ -372,20 +372,24 @@ void FButton::onAccel (FAccelEvent* ev)
|
|||
if ( ! hasFocus() )
|
||||
{
|
||||
FWidget* focused_widget = static_cast<FWidget*>(ev->focusedWidget());
|
||||
FFocusEvent out (fc::FocusOut_Event);
|
||||
FApplication::queueEvent(focused_widget, &out);
|
||||
setFocus();
|
||||
|
||||
if ( focused_widget )
|
||||
focused_widget->redraw();
|
||||
if ( focused_widget->isWidget() )
|
||||
{
|
||||
FFocusEvent out (fc::FocusOut_Event);
|
||||
FApplication::queueEvent(focused_widget, &out);
|
||||
setFocus();
|
||||
|
||||
if ( click_animation )
|
||||
setDown();
|
||||
else
|
||||
redraw();
|
||||
if ( focused_widget )
|
||||
focused_widget->redraw();
|
||||
|
||||
if ( getStatusBar() )
|
||||
getStatusBar()->drawMessage();
|
||||
if ( click_animation )
|
||||
setDown();
|
||||
else
|
||||
redraw();
|
||||
|
||||
if ( getStatusBar() )
|
||||
getStatusBar()->drawMessage();
|
||||
}
|
||||
}
|
||||
else if ( click_animation )
|
||||
setDown();
|
||||
|
|
|
@ -219,23 +219,26 @@ void FLabel::onAccel (FAccelEvent* ev)
|
|||
if ( ! accel_widget->hasFocus() )
|
||||
{
|
||||
FWidget* focused_widget = static_cast<FWidget*>(ev->focusedWidget());
|
||||
FFocusEvent out (fc::FocusOut_Event);
|
||||
FApplication::queueEvent(focused_widget, &out);
|
||||
accel_widget->setFocus();
|
||||
|
||||
|
||||
if ( focused_widget )
|
||||
focused_widget->redraw();
|
||||
|
||||
accel_widget->redraw();
|
||||
FFocusEvent in (fc::FocusIn_Event);
|
||||
FApplication::sendEvent(accel_widget, &in);
|
||||
|
||||
if ( getStatusBar() )
|
||||
if ( focused_widget->isWidget() )
|
||||
{
|
||||
accel_widget->getStatusBar()->drawMessage();
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
FFocusEvent out (fc::FocusOut_Event);
|
||||
FApplication::queueEvent(focused_widget, &out);
|
||||
accel_widget->setFocus();
|
||||
|
||||
if ( focused_widget )
|
||||
focused_widget->redraw();
|
||||
|
||||
accel_widget->redraw();
|
||||
FFocusEvent in (fc::FocusIn_Event);
|
||||
FApplication::sendEvent(accel_widget, &in);
|
||||
|
||||
if ( getStatusBar() )
|
||||
{
|
||||
accel_widget->getStatusBar()->drawMessage();
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -541,20 +541,24 @@ void FLineEdit::onAccel (FAccelEvent* ev)
|
|||
if ( ! hasFocus() )
|
||||
{
|
||||
FWidget* focused_widget = static_cast<FWidget*>(ev->focusedWidget());
|
||||
FFocusEvent out (fc::FocusOut_Event);
|
||||
FApplication::queueEvent(focused_widget, &out);
|
||||
setFocus();
|
||||
|
||||
if ( focused_widget )
|
||||
focused_widget->redraw();
|
||||
|
||||
redraw();
|
||||
|
||||
if ( getStatusBar() )
|
||||
if ( focused_widget->isWidget() )
|
||||
{
|
||||
getStatusBar()->drawMessage();
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
FFocusEvent out (fc::FocusOut_Event);
|
||||
FApplication::queueEvent(focused_widget, &out);
|
||||
setFocus();
|
||||
|
||||
if ( focused_widget )
|
||||
focused_widget->redraw();
|
||||
|
||||
redraw();
|
||||
|
||||
if ( getStatusBar() )
|
||||
{
|
||||
getStatusBar()->drawMessage();
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -542,24 +542,28 @@ void FMenuItem::onAccel (FAccelEvent* ev)
|
|||
openMenu();
|
||||
|
||||
focused_widget = static_cast<FWidget*>(ev->focusedWidget());
|
||||
FFocusEvent out (fc::FocusOut_Event);
|
||||
FApplication::queueEvent(focused_widget, &out);
|
||||
menu->unselectItem();
|
||||
menu->selectFirstItem();
|
||||
|
||||
if ( menu->getSelectedItem() )
|
||||
menu->getSelectedItem()->setFocus();
|
||||
if ( focused_widget->isWidget() )
|
||||
{
|
||||
FFocusEvent out (fc::FocusOut_Event);
|
||||
FApplication::queueEvent(focused_widget, &out);
|
||||
menu->unselectItem();
|
||||
menu->selectFirstItem();
|
||||
|
||||
if ( focused_widget )
|
||||
focused_widget->redraw();
|
||||
if ( menu->getSelectedItem() )
|
||||
menu->getSelectedItem()->setFocus();
|
||||
|
||||
menu->redraw();
|
||||
if ( focused_widget )
|
||||
focused_widget->redraw();
|
||||
|
||||
if ( getStatusBar() )
|
||||
getStatusBar()->drawMessage();
|
||||
menu->redraw();
|
||||
|
||||
mbar->redraw();
|
||||
mbar->drop_down = true;
|
||||
if ( getStatusBar() )
|
||||
getStatusBar()->drawMessage();
|
||||
|
||||
mbar->redraw();
|
||||
mbar->drop_down = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -15,7 +15,8 @@ FObject::TimerList* FObject::timer_list = 0;
|
|||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FObject::FObject (FObject* parent)
|
||||
: parent_obj(parent)
|
||||
: widget_object(false)
|
||||
, parent_obj(parent)
|
||||
, children_list()
|
||||
, has_parent(false)
|
||||
{
|
||||
|
|
|
@ -70,6 +70,7 @@ class FObject
|
|||
bool hasChildren() const;
|
||||
bool isChild (FObject*) const;
|
||||
bool isDirectChild (FObject*) const;
|
||||
bool isWidget() const;
|
||||
bool isTimerInUpdating() const;
|
||||
|
||||
// Methods
|
||||
|
@ -102,6 +103,7 @@ class FObject
|
|||
|
||||
// Data Members
|
||||
static TimerList* timer_list;
|
||||
bool widget_object;
|
||||
|
||||
private:
|
||||
// Disable copy constructor
|
||||
|
@ -147,6 +149,10 @@ inline bool FObject::hasChildren() const
|
|||
inline bool FObject::isDirectChild (FObject* obj) const
|
||||
{ return bool( obj->getParent() == this ); }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FObject::isWidget() const
|
||||
{ return widget_object; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FObject::isTimerInUpdating() const
|
||||
{ return timer_modify_lock; }
|
||||
|
|
|
@ -297,12 +297,16 @@ void FToggleButton::onAccel (FAccelEvent* ev)
|
|||
if ( ! hasFocus() )
|
||||
{
|
||||
FWidget* focused_widget = static_cast<FWidget*>(ev->focusedWidget());
|
||||
FFocusEvent out (fc::FocusOut_Event);
|
||||
FApplication::queueEvent(focused_widget, &out);
|
||||
setFocus();
|
||||
|
||||
if ( focused_widget )
|
||||
focused_widget->redraw();
|
||||
if ( focused_widget->isWidget() )
|
||||
{
|
||||
FFocusEvent out (fc::FocusOut_Event);
|
||||
FApplication::queueEvent(focused_widget, &out);
|
||||
setFocus();
|
||||
|
||||
if ( focused_widget )
|
||||
focused_widget->redraw();
|
||||
}
|
||||
}
|
||||
|
||||
if ( isRadioButton() )
|
||||
|
|
|
@ -64,6 +64,8 @@ FWidget::FWidget (FWidget* parent, bool disable_alt_screen)
|
|||
if ( isEnabled() )
|
||||
flags |= fc::active;
|
||||
|
||||
widget_object = true;
|
||||
|
||||
if ( ! parent )
|
||||
{
|
||||
assert ( ! rootObject
|
||||
|
@ -137,6 +139,17 @@ FWidget* FWidget::getRootWidget() const
|
|||
return obj;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FWidget* FWidget::getParentWidget() const
|
||||
{
|
||||
FObject* p_obj = getParent();
|
||||
|
||||
if ( p_obj && p_obj->isWidget() )
|
||||
return static_cast<FWidget*>(p_obj);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FWidget* FWidget::getMainWidget()
|
||||
{
|
||||
|
@ -163,10 +176,13 @@ FWidget* FWidget::getFirstFocusableWidget (FObjectList children)
|
|||
|
||||
while ( iter != end )
|
||||
{
|
||||
FWidget* child = static_cast<FWidget*>(*iter);
|
||||
if ( (*iter)->isWidget() )
|
||||
{
|
||||
FWidget* child = static_cast<FWidget*>(*iter);
|
||||
|
||||
if ( child->isEnabled() && child->acceptFocus() )
|
||||
return child;
|
||||
if ( child->isEnabled() && child->acceptFocus() )
|
||||
return child;
|
||||
}
|
||||
|
||||
++iter;
|
||||
}
|
||||
|
@ -187,6 +203,10 @@ FWidget* FWidget::getLastFocusableWidget (FObjectList children)
|
|||
do
|
||||
{
|
||||
--iter;
|
||||
|
||||
if ( ! (*iter)->isWidget() )
|
||||
continue;
|
||||
|
||||
FWidget* child = static_cast<FWidget*>(*iter);
|
||||
|
||||
if ( child->isEnabled() && child->acceptFocus() )
|
||||
|
@ -824,6 +844,12 @@ FWidget* FWidget::childWidgetAt (FWidget* p, int x, int y)
|
|||
|
||||
while ( iter != end )
|
||||
{
|
||||
if ( ! (*iter)->isWidget() )
|
||||
{
|
||||
++iter;
|
||||
continue;
|
||||
}
|
||||
|
||||
FWidget* widget = static_cast<FWidget*>(*iter);
|
||||
|
||||
if ( widget->isEnabled()
|
||||
|
@ -858,10 +884,13 @@ int FWidget::numOfFocusableChildren()
|
|||
|
||||
while ( iter != end )
|
||||
{
|
||||
FWidget* widget = static_cast<FWidget*>(*iter);
|
||||
if ( (*iter)->isWidget() )
|
||||
{
|
||||
FWidget* widget = static_cast<FWidget*>(*iter);
|
||||
|
||||
if ( widget->acceptFocus() )
|
||||
num++;
|
||||
if ( widget->acceptFocus() )
|
||||
num++;
|
||||
}
|
||||
|
||||
++iter;
|
||||
}
|
||||
|
@ -1124,10 +1153,13 @@ void FWidget::redraw()
|
|||
|
||||
while ( iter != end )
|
||||
{
|
||||
FWidget* widget = static_cast<FWidget*>(*iter);
|
||||
if ( (*iter)->isWidget() )
|
||||
{
|
||||
FWidget* widget = static_cast<FWidget*>(*iter);
|
||||
|
||||
if ( widget->isVisible() && ! widget->isWindowWidget() )
|
||||
widget->redraw();
|
||||
if ( widget->isVisible() && ! widget->isWindowWidget() )
|
||||
widget->redraw();
|
||||
}
|
||||
|
||||
++iter;
|
||||
}
|
||||
|
@ -1219,8 +1251,12 @@ void FWidget::show()
|
|||
|
||||
while ( iter != end )
|
||||
{
|
||||
FWidget* widget = static_cast<FWidget*>(*iter);
|
||||
widget->show();
|
||||
if ( (*iter)->isWidget() )
|
||||
{
|
||||
FWidget* widget = static_cast<FWidget*>(*iter);
|
||||
widget->show();
|
||||
}
|
||||
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
@ -1275,6 +1311,12 @@ bool FWidget::focusFirstChild()
|
|||
|
||||
while ( iter != end )
|
||||
{
|
||||
if ( ! (*iter)->isWidget() )
|
||||
{
|
||||
++iter;
|
||||
continue;
|
||||
}
|
||||
|
||||
FWidget* widget = static_cast<FWidget*>(*iter);
|
||||
|
||||
if ( widget->isEnabled()
|
||||
|
@ -1295,8 +1337,6 @@ bool FWidget::focusFirstChild()
|
|||
return true;
|
||||
}
|
||||
|
||||
// prefix increment (++) is faster
|
||||
// than postfix for non primitive type
|
||||
++iter;
|
||||
}
|
||||
return false;
|
||||
|
@ -1318,6 +1358,10 @@ bool FWidget::focusLastChild()
|
|||
do
|
||||
{
|
||||
--iter;
|
||||
|
||||
if ( ! (*iter)->isWidget() )
|
||||
continue;
|
||||
|
||||
FWidget* widget = static_cast<FWidget*>(*iter);
|
||||
|
||||
if ( widget->isEnabled()
|
||||
|
@ -1793,11 +1837,13 @@ void FWidget::adjustSize()
|
|||
|
||||
while ( iter != end )
|
||||
{
|
||||
FWidget* widget = static_cast<FWidget*>(*iter);
|
||||
|
||||
if ( ! widget->isWindowWidget() )
|
||||
widget->adjustSize();
|
||||
if ( (*iter)->isWidget() )
|
||||
{
|
||||
FWidget* widget = static_cast<FWidget*>(*iter);
|
||||
|
||||
if ( ! widget->isWindowWidget() )
|
||||
widget->adjustSize();
|
||||
}
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
@ -1847,6 +1893,12 @@ bool FWidget::focusNextChild()
|
|||
|
||||
while ( iter != end )
|
||||
{
|
||||
if ( ! (*iter)->isWidget() )
|
||||
{
|
||||
++iter;
|
||||
continue;
|
||||
}
|
||||
|
||||
FWidget* w = static_cast<FWidget*>(*iter);
|
||||
|
||||
if ( w == this )
|
||||
|
@ -1859,6 +1911,9 @@ bool FWidget::focusNextChild()
|
|||
{
|
||||
++next_element;
|
||||
|
||||
if ( ! (*next_element)->isWidget() )
|
||||
continue;
|
||||
|
||||
if ( next_element == children.end() )
|
||||
next_element = children.begin();
|
||||
|
||||
|
@ -1932,6 +1987,10 @@ bool FWidget::focusPrevChild()
|
|||
do
|
||||
{
|
||||
--iter;
|
||||
|
||||
if ( ! (*iter)->isWidget() )
|
||||
continue;
|
||||
|
||||
FWidget* w = static_cast<FWidget*>(*iter);
|
||||
|
||||
if ( w == this )
|
||||
|
@ -1942,6 +2001,12 @@ bool FWidget::focusPrevChild()
|
|||
|
||||
do
|
||||
{
|
||||
if ( ! (*prev_element)->isWidget() )
|
||||
{
|
||||
--prev_element;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( prev_element == children.begin() )
|
||||
prev_element = children.end();
|
||||
|
||||
|
|
|
@ -546,10 +546,6 @@ class FWidget : public FVTerm
|
|||
inline const char* FWidget::getClassName() const
|
||||
{ return "FWidget"; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FWidget* FWidget::getParentWidget() const
|
||||
{ return static_cast<FWidget*>(getParent()); }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString FWidget::getStatusbarMessage() const
|
||||
{ return statusbar_message; }
|
||||
|
|
Loading…
Reference in New Issue