Check an object with isInstanceOf(...) whether it is an instance of a specified class

This commit is contained in:
Markus Gans 2017-07-23 01:19:59 +02:00
parent d8c41b879d
commit 30515db9ec
13 changed files with 506 additions and 503 deletions

View File

@ -1,3 +1,7 @@
2017-07-23 Markus Gans <guru.mail@muenster.de>
* Check an object with isInstanceOf(...) whether it is
an instance of a specified class
2017-07-18 Markus Gans <guru.mail@muenster.de> 2017-07-18 Markus Gans <guru.mail@muenster.de>
* New Widget class FListView (filled with FListViewItem) * New Widget class FListView (filled with FListViewItem)
to allow a multi-column data view to allow a multi-column data view

View File

@ -66,7 +66,7 @@ void FLabel::setAccelWidget (FWidget* widget)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FLabel::setAlignment (uInt align) void FLabel::setAlignment (fc::text_alignment align)
{ {
if ( align != fc::alignLeft if ( align != fc::alignLeft
&& align != fc::alignCenter && align != fc::alignCenter

View File

@ -54,12 +54,12 @@ class FLabel : public FWidget
// Accessors // Accessors
const char* getClassName() const; const char* getClassName() const;
FTerm* getAccelWidget(); FTerm* getAccelWidget();
uInt getAlignment(); fc::text_alignment getAlignment();
FString& getText(); FString& getText();
// Mutators // Mutators
void setAccelWidget (FWidget* = 0); void setAccelWidget (FWidget* = 0);
void setAlignment(uInt); void setAlignment(fc::text_alignment);
bool setEmphasis(bool); bool setEmphasis(bool);
bool setEmphasis(); bool setEmphasis();
bool unsetEmphasis(); bool unsetEmphasis();
@ -107,7 +107,7 @@ class FLabel : public FWidget
multiLineText multiline_text; multiLineText multiline_text;
bool multiline; bool multiline;
FString text; FString text;
uInt alignment; fc::text_alignment alignment;
short emphasis_color; short emphasis_color;
short ellipsis_color; short ellipsis_color;
bool emphasis; bool emphasis;
@ -127,7 +127,7 @@ inline FTerm* FLabel::getAccelWidget ()
{ return accel_widget; } { return accel_widget; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline uInt FLabel::getAlignment() inline fc::text_alignment FLabel::getAlignment()
{ return alignment; } { return alignment; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -1158,213 +1158,6 @@ void FListBox::onFocusOut (FFocusEvent*)
inc_search.clear(); inc_search.clear();
} }
//----------------------------------------------------------------------
void FListBox::cb_VBarChange (FWidget*, data_ptr)
{
FScrollbar::sType scrollType;
int distance = 1;
int element_count = int(getCount());
int yoffset_before = yoffset;
int yoffset_end = element_count - getClientHeight();
scrollType = vbar->getScrollType();
switch ( scrollType )
{
case FScrollbar::noScroll:
break;
case FScrollbar::scrollPageBackward:
distance = getClientHeight();
// fall through
case FScrollbar::scrollStepBackward:
current -= distance;
if ( current < 1 )
current=1;
if ( current <= yoffset )
yoffset -= distance;
if ( yoffset < 0 )
yoffset = 0;
break;
case FScrollbar::scrollPageForward:
distance = getClientHeight();
// fall through
case FScrollbar::scrollStepForward:
current += distance;
if ( current > element_count )
current = element_count;
if ( current - yoffset > getClientHeight() )
yoffset += distance;
if ( yoffset > yoffset_end )
yoffset = yoffset_end;
break;
case FScrollbar::scrollJump:
{
int val = vbar->getValue();
if ( yoffset == val )
break;
int c = current - yoffset;
yoffset = val;
if ( yoffset > yoffset_end )
yoffset = yoffset_end;
if ( yoffset < 0 )
yoffset = 0;
current = yoffset + c;
if ( current < yoffset )
current = yoffset;
if ( current > element_count )
current = element_count;
break;
}
case FScrollbar::scrollWheelUp:
{
FWheelEvent wheel_ev (fc::MouseWheel_Event, FPoint(2,2), fc::WheelUp);
onWheel(&wheel_ev);
}
break;
case FScrollbar::scrollWheelDown:
{
FWheelEvent wheel_ev (fc::MouseWheel_Event, FPoint(2,2), fc::WheelDown);
onWheel(&wheel_ev);
}
break;
}
if ( isVisible() )
drawList();
if ( scrollType >= FScrollbar::scrollStepBackward
&& scrollType <= FScrollbar::scrollPageForward )
{
vbar->setValue (yoffset);
if ( vbar->isVisible() && yoffset_before != yoffset )
vbar->drawBar();
updateTerminal();
flush_out();
}
}
//----------------------------------------------------------------------
void FListBox::cb_HBarChange (FWidget*, data_ptr)
{
static const int padding_space = 2; // 1 leading space + 1 tailing space
FScrollbar::sType scrollType;
int distance = 1;
int xoffset_before = xoffset;
int xoffset_end = max_line_width - getClientWidth() + padding_space;
scrollType = hbar->getScrollType();
switch ( scrollType )
{
case FScrollbar::noScroll:
break;
case FScrollbar::scrollPageBackward:
distance = getClientWidth() - padding_space;
// fall through
case FScrollbar::scrollStepBackward:
xoffset -= distance;
if ( xoffset < 0 )
xoffset = 0;
break;
case FScrollbar::scrollPageForward:
distance = getClientWidth() - padding_space;
// fall through
case FScrollbar::scrollStepForward:
xoffset += distance;
if ( xoffset > xoffset_end )
xoffset = xoffset_end;
if ( xoffset < 0 )
xoffset = 0;
break;
case FScrollbar::scrollJump:
{
int val = hbar->getValue();
if ( xoffset == val )
break;
xoffset = val;
if ( xoffset > xoffset_end )
xoffset = xoffset_end;
if ( xoffset < 0 )
xoffset = 0;
break;
}
case FScrollbar::scrollWheelUp:
if ( xoffset == 0 )
break;
xoffset -= 4;
if ( xoffset < 0 )
xoffset=0;
break;
case FScrollbar::scrollWheelDown:
if ( xoffset == xoffset_end )
break;
xoffset += 4;
if ( xoffset > xoffset_end )
xoffset = xoffset_end;
break;
}
if ( isVisible() )
{
drawList();
updateTerminal();
flush_out();
}
if ( scrollType >= FScrollbar::scrollStepBackward
&& scrollType <= FScrollbar::scrollWheelDown )
{
hbar->setValue (xoffset);
if ( hbar->isVisible() && xoffset_before != xoffset )
hbar->drawBar();
updateTerminal();
flush_out();
}
}
// protected methods of FListBox // protected methods of FListBox
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1860,3 +1653,210 @@ void FListBox::processChanged()
{ {
emitCallback("row-changed"); emitCallback("row-changed");
} }
//----------------------------------------------------------------------
void FListBox::cb_VBarChange (FWidget*, data_ptr)
{
FScrollbar::sType scrollType;
int distance = 1;
int element_count = int(getCount());
int yoffset_before = yoffset;
int yoffset_end = element_count - getClientHeight();
scrollType = vbar->getScrollType();
switch ( scrollType )
{
case FScrollbar::noScroll:
break;
case FScrollbar::scrollPageBackward:
distance = getClientHeight();
// fall through
case FScrollbar::scrollStepBackward:
current -= distance;
if ( current < 1 )
current=1;
if ( current <= yoffset )
yoffset -= distance;
if ( yoffset < 0 )
yoffset = 0;
break;
case FScrollbar::scrollPageForward:
distance = getClientHeight();
// fall through
case FScrollbar::scrollStepForward:
current += distance;
if ( current > element_count )
current = element_count;
if ( current - yoffset > getClientHeight() )
yoffset += distance;
if ( yoffset > yoffset_end )
yoffset = yoffset_end;
break;
case FScrollbar::scrollJump:
{
int val = vbar->getValue();
if ( yoffset == val )
break;
int c = current - yoffset;
yoffset = val;
if ( yoffset > yoffset_end )
yoffset = yoffset_end;
if ( yoffset < 0 )
yoffset = 0;
current = yoffset + c;
if ( current < yoffset )
current = yoffset;
if ( current > element_count )
current = element_count;
break;
}
case FScrollbar::scrollWheelUp:
{
FWheelEvent wheel_ev (fc::MouseWheel_Event, FPoint(2,2), fc::WheelUp);
onWheel(&wheel_ev);
}
break;
case FScrollbar::scrollWheelDown:
{
FWheelEvent wheel_ev (fc::MouseWheel_Event, FPoint(2,2), fc::WheelDown);
onWheel(&wheel_ev);
}
break;
}
if ( isVisible() )
drawList();
if ( scrollType >= FScrollbar::scrollStepBackward
&& scrollType <= FScrollbar::scrollPageForward )
{
vbar->setValue (yoffset);
if ( vbar->isVisible() && yoffset_before != yoffset )
vbar->drawBar();
updateTerminal();
flush_out();
}
}
//----------------------------------------------------------------------
void FListBox::cb_HBarChange (FWidget*, data_ptr)
{
static const int padding_space = 2; // 1 leading space + 1 tailing space
FScrollbar::sType scrollType;
int distance = 1;
int xoffset_before = xoffset;
int xoffset_end = max_line_width - getClientWidth() + padding_space;
scrollType = hbar->getScrollType();
switch ( scrollType )
{
case FScrollbar::noScroll:
break;
case FScrollbar::scrollPageBackward:
distance = getClientWidth() - padding_space;
// fall through
case FScrollbar::scrollStepBackward:
xoffset -= distance;
if ( xoffset < 0 )
xoffset = 0;
break;
case FScrollbar::scrollPageForward:
distance = getClientWidth() - padding_space;
// fall through
case FScrollbar::scrollStepForward:
xoffset += distance;
if ( xoffset > xoffset_end )
xoffset = xoffset_end;
if ( xoffset < 0 )
xoffset = 0;
break;
case FScrollbar::scrollJump:
{
int val = hbar->getValue();
if ( xoffset == val )
break;
xoffset = val;
if ( xoffset > xoffset_end )
xoffset = xoffset_end;
if ( xoffset < 0 )
xoffset = 0;
break;
}
case FScrollbar::scrollWheelUp:
if ( xoffset == 0 )
break;
xoffset -= 4;
if ( xoffset < 0 )
xoffset=0;
break;
case FScrollbar::scrollWheelDown:
if ( xoffset == xoffset_end )
break;
xoffset += 4;
if ( xoffset > xoffset_end )
xoffset = xoffset_end;
break;
}
if ( isVisible() )
{
drawList();
updateTerminal();
flush_out();
}
if ( scrollType >= FScrollbar::scrollStepBackward
&& scrollType <= FScrollbar::scrollWheelDown )
{
hbar->setValue (xoffset);
if ( hbar->isVisible() && xoffset_before != xoffset )
hbar->drawBar();
updateTerminal();
flush_out();
}
}

View File

@ -185,9 +185,6 @@ class FListBox : public FWidget
void onFocusIn (FFocusEvent*); void onFocusIn (FFocusEvent*);
void onFocusOut (FFocusEvent*); void onFocusOut (FFocusEvent*);
// Callback methods
void cb_VBarChange (FWidget*, data_ptr);
void cb_HBarChange (FWidget*, data_ptr);
protected: protected:
// Methods // Methods
@ -224,6 +221,10 @@ class FListBox : public FWidget
void processChanged(); void processChanged();
listBoxItems::iterator index2iterator (int); listBoxItems::iterator index2iterator (int);
// Callback methods
void cb_VBarChange (FWidget*, data_ptr);
void cb_HBarChange (FWidget*, data_ptr);
// Function Pointer // Function Pointer
void (*convertToItem) ( FListBoxItem& void (*convertToItem) ( FListBoxItem&
, FWidget::data_ptr , FWidget::data_ptr

View File

@ -19,8 +19,12 @@ FListViewItem::FListViewItem (const FListViewItem& item)
: FObject(item.getParent()) : FObject(item.getParent())
, column_line(item.column_line) , column_line(item.column_line)
, data_pointer(item.data_pointer) , data_pointer(item.data_pointer)
, alignment(fc::alignLeft)
{ {
//item.getParentWidget()->insert (this); FObject* parent = getParent();
if ( parent && parent->isInstanceOf("FListView") )
static_cast<FListView*>(parent)->insert (this);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -28,6 +32,7 @@ FListViewItem::FListViewItem (FListView* parent)
: FObject(parent) : FObject(parent)
, column_line() , column_line()
, data_pointer(0) , data_pointer(0)
, alignment(fc::alignLeft)
{ {
parent->insert (this); parent->insert (this);
} }
@ -39,6 +44,7 @@ FListViewItem::FListViewItem ( const std::vector<FString>& cols
: FObject(parent) : FObject(parent)
, column_line(cols) , column_line(cols)
, data_pointer(data) , data_pointer(data)
, alignment(fc::alignLeft)
{ {
parent->insert (this); parent->insert (this);
} }
@ -700,214 +706,6 @@ void FListView::onFocusOut (FFocusEvent*)
delOwnTimer(); delOwnTimer();
} }
//----------------------------------------------------------------------
void FListView::cb_VBarChange (FWidget*, data_ptr)
{
FScrollbar::sType scrollType;
int distance = 1;
int element_count = int(data.size());
int yoffset_before = yoffset;
int yoffset_end = element_count - getClientHeight();
scrollType = vbar->getScrollType();
switch ( scrollType )
{
case FScrollbar::noScroll:
break;
case FScrollbar::scrollPageBackward:
distance = getClientHeight();
// fall through
case FScrollbar::scrollStepBackward:
current -= distance;
if ( current < 1 )
current=1;
if ( current <= yoffset )
yoffset -= distance;
if ( yoffset < 0 )
yoffset = 0;
break;
case FScrollbar::scrollPageForward:
distance = getClientHeight();
// fall through
case FScrollbar::scrollStepForward:
current += distance;
if ( current > element_count )
current = element_count;
if ( current - yoffset > getClientHeight() )
yoffset += distance;
if ( yoffset > yoffset_end )
yoffset = yoffset_end;
break;
case FScrollbar::scrollJump:
{
int val = vbar->getValue();
if ( yoffset == val )
break;
int c = current - yoffset;
yoffset = val;
if ( yoffset > yoffset_end )
yoffset = yoffset_end;
if ( yoffset < 0 )
yoffset = 0;
current = yoffset + c;
if ( current < yoffset )
current = yoffset;
if ( current > element_count )
current = element_count;
break;
}
case FScrollbar::scrollWheelUp:
{
FWheelEvent wheel_ev (fc::MouseWheel_Event, FPoint(2,2), fc::WheelUp);
onWheel(&wheel_ev);
}
break;
case FScrollbar::scrollWheelDown:
{
FWheelEvent wheel_ev (fc::MouseWheel_Event, FPoint(2,2), fc::WheelDown);
onWheel(&wheel_ev);
}
break;
}
if ( isVisible() )
drawList();
if ( scrollType >= FScrollbar::scrollStepBackward
&& scrollType <= FScrollbar::scrollPageForward )
{
vbar->setValue (yoffset);
if ( vbar->isVisible() && yoffset_before != yoffset )
vbar->drawBar();
updateTerminal();
flush_out();
}
}
//----------------------------------------------------------------------
void FListView::cb_HBarChange (FWidget*, data_ptr)
{
static const int padding_space = 2; // 1 leading space + 1 tailing space
FScrollbar::sType scrollType;
int distance = 1;
int xoffset_before = xoffset;
int xoffset_end = max_line_width - getClientWidth() + padding_space + 2;
scrollType = hbar->getScrollType();
switch ( scrollType )
{
case FScrollbar::noScroll:
break;
case FScrollbar::scrollPageBackward:
distance = getClientWidth() - padding_space;
// fall through
case FScrollbar::scrollStepBackward:
xoffset -= distance;
if ( xoffset < 0 )
xoffset = 0;
break;
case FScrollbar::scrollPageForward:
distance = getClientWidth() - padding_space;
// fall through
case FScrollbar::scrollStepForward:
xoffset += distance;
if ( xoffset > xoffset_end )
xoffset = xoffset_end;
if ( xoffset < 0 )
xoffset = 0;
break;
case FScrollbar::scrollJump:
{
int val = hbar->getValue();
if ( xoffset == val )
break;
xoffset = val;
if ( xoffset > xoffset_end )
xoffset = xoffset_end;
if ( xoffset < 0 )
xoffset = 0;
break;
}
case FScrollbar::scrollWheelUp:
if ( xoffset == 0 )
break;
xoffset -= 4;
if ( xoffset < 0 )
xoffset=0;
break;
case FScrollbar::scrollWheelDown:
if ( xoffset == xoffset_end )
break;
xoffset += 4;
if ( xoffset > xoffset_end )
xoffset = xoffset_end;
break;
}
if ( isVisible() )
{
drawColumnLabels();
drawList();
updateTerminal();
flush_out();
}
if ( scrollType >= FScrollbar::scrollStepBackward
&& scrollType <= FScrollbar::scrollWheelDown )
{
hbar->setValue (xoffset);
if ( hbar->isVisible() && xoffset_before != xoffset )
hbar->drawBar();
updateTerminal();
flush_out();
}
}
// protected methods of FListView // protected methods of FListView
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1280,3 +1078,211 @@ void FListView::processChanged()
{ {
emitCallback("row-changed"); emitCallback("row-changed");
} }
//----------------------------------------------------------------------
void FListView::cb_VBarChange (FWidget*, data_ptr)
{
FScrollbar::sType scrollType;
int distance = 1;
int element_count = int(data.size());
int yoffset_before = yoffset;
int yoffset_end = element_count - getClientHeight();
scrollType = vbar->getScrollType();
switch ( scrollType )
{
case FScrollbar::noScroll:
break;
case FScrollbar::scrollPageBackward:
distance = getClientHeight();
// fall through
case FScrollbar::scrollStepBackward:
current -= distance;
if ( current < 1 )
current=1;
if ( current <= yoffset )
yoffset -= distance;
if ( yoffset < 0 )
yoffset = 0;
break;
case FScrollbar::scrollPageForward:
distance = getClientHeight();
// fall through
case FScrollbar::scrollStepForward:
current += distance;
if ( current > element_count )
current = element_count;
if ( current - yoffset > getClientHeight() )
yoffset += distance;
if ( yoffset > yoffset_end )
yoffset = yoffset_end;
break;
case FScrollbar::scrollJump:
{
int val = vbar->getValue();
if ( yoffset == val )
break;
int c = current - yoffset;
yoffset = val;
if ( yoffset > yoffset_end )
yoffset = yoffset_end;
if ( yoffset < 0 )
yoffset = 0;
current = yoffset + c;
if ( current < yoffset )
current = yoffset;
if ( current > element_count )
current = element_count;
break;
}
case FScrollbar::scrollWheelUp:
{
FWheelEvent wheel_ev (fc::MouseWheel_Event, FPoint(2,2), fc::WheelUp);
onWheel(&wheel_ev);
}
break;
case FScrollbar::scrollWheelDown:
{
FWheelEvent wheel_ev (fc::MouseWheel_Event, FPoint(2,2), fc::WheelDown);
onWheel(&wheel_ev);
}
break;
}
if ( isVisible() )
drawList();
if ( scrollType >= FScrollbar::scrollStepBackward
&& scrollType <= FScrollbar::scrollPageForward )
{
vbar->setValue (yoffset);
if ( vbar->isVisible() && yoffset_before != yoffset )
vbar->drawBar();
updateTerminal();
flush_out();
}
}
//----------------------------------------------------------------------
void FListView::cb_HBarChange (FWidget*, data_ptr)
{
static const int padding_space = 2; // 1 leading space + 1 tailing space
FScrollbar::sType scrollType;
int distance = 1;
int xoffset_before = xoffset;
int xoffset_end = max_line_width - getClientWidth() + padding_space + 2;
scrollType = hbar->getScrollType();
switch ( scrollType )
{
case FScrollbar::noScroll:
break;
case FScrollbar::scrollPageBackward:
distance = getClientWidth() - padding_space;
// fall through
case FScrollbar::scrollStepBackward:
xoffset -= distance;
if ( xoffset < 0 )
xoffset = 0;
break;
case FScrollbar::scrollPageForward:
distance = getClientWidth() - padding_space;
// fall through
case FScrollbar::scrollStepForward:
xoffset += distance;
if ( xoffset > xoffset_end )
xoffset = xoffset_end;
if ( xoffset < 0 )
xoffset = 0;
break;
case FScrollbar::scrollJump:
{
int val = hbar->getValue();
if ( xoffset == val )
break;
xoffset = val;
if ( xoffset > xoffset_end )
xoffset = xoffset_end;
if ( xoffset < 0 )
xoffset = 0;
break;
}
case FScrollbar::scrollWheelUp:
if ( xoffset == 0 )
break;
xoffset -= 4;
if ( xoffset < 0 )
xoffset=0;
break;
case FScrollbar::scrollWheelDown:
if ( xoffset == xoffset_end )
break;
xoffset += 4;
if ( xoffset > xoffset_end )
xoffset = xoffset_end;
break;
}
if ( isVisible() )
{
drawColumnLabels();
drawList();
updateTerminal();
flush_out();
}
if ( scrollType >= FScrollbar::scrollStepBackward
&& scrollType <= FScrollbar::scrollWheelDown )
{
hbar->setValue (xoffset);
if ( hbar->isVisible() && xoffset_before != xoffset )
hbar->drawBar();
updateTerminal();
flush_out();
}
}

View File

@ -71,6 +71,7 @@ class FListViewItem : public FObject
// Data Member // Data Member
std::vector<FString> column_line; std::vector<FString> column_line;
FWidget::data_ptr data_pointer; FWidget::data_ptr data_pointer;
fc::text_alignment alignment;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -122,7 +123,6 @@ class FListView : public FWidget
void insert ( const std::vector<long>& void insert ( const std::vector<long>&
, data_ptr = 0 , data_ptr = 0
, FListView* = 0 ); , FListView* = 0 );
listViewItems::iterator index2iterator (int);
// Event handlers // Event handlers
void onKeyPress (FKeyEvent*); void onKeyPress (FKeyEvent*);
@ -135,10 +135,6 @@ class FListView : public FWidget
void onFocusIn (FFocusEvent*); void onFocusIn (FFocusEvent*);
void onFocusOut (FFocusEvent*); void onFocusOut (FFocusEvent*);
// Callback methods
void cb_VBarChange (FWidget*, data_ptr);
void cb_HBarChange (FWidget*, data_ptr);
protected: protected:
// Methods // Methods
void adjustYOffset(); void adjustYOffset();
@ -183,6 +179,11 @@ class FListView : public FWidget
void recalculateVerticalBar (int); void recalculateVerticalBar (int);
void processClick(); void processClick();
void processChanged(); void processChanged();
listViewItems::iterator index2iterator (int);
// Callback methods
void cb_VBarChange (FWidget*, data_ptr);
void cb_HBarChange (FWidget*, data_ptr);
// Data Members // Data Members
listViewItems data; listViewItems data;

View File

@ -710,22 +710,19 @@ bool FMenu::isWindowsMenu (FWidget* w) const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMenu::isMenuBar (FWidget* w) const bool FMenu::isMenuBar (FWidget* w) const
{ {
return bool ( std::strcmp ( w->getClassName() return w->isInstanceOf("FMenuBar");
, const_cast<char*>("FMenuBar") ) == 0 );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMenu::isMenu (FWidget* w) const bool FMenu::isMenu (FWidget* w) const
{ {
return bool ( std::strcmp ( w->getClassName() return w->isInstanceOf("FMenu");
, const_cast<char*>("FMenu") ) == 0 );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMenu::isRadioMenuItem (FWidget* w) const bool FMenu::isRadioMenuItem (FWidget* w) const
{ {
return bool ( std::strcmp ( w->getClassName() return w->isInstanceOf("FRadioMenuItem");
, const_cast<char*>("FRadioMenuItem") ) == 0 );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -606,17 +606,13 @@ void FMenuItem::onFocusOut (FFocusEvent*)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMenuItem::isWindowsMenu (FWidget* w) const bool FMenuItem::isWindowsMenu (FWidget* w) const
{ {
return ( ! w ) ? false : w->isDialogWidget(); return ( w ) ? w->isDialogWidget() : false;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMenuItem::isMenuBar (FWidget* w) const bool FMenuItem::isMenuBar (FWidget* w) const
{ {
if ( ! w ) return ( w ) ? w->isInstanceOf("FMenuBar") : false;
return false;
else
return bool( std::strcmp ( w->getClassName()
, const_cast<char*>("FMenuBar") ) == 0 );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -625,10 +621,8 @@ bool FMenuItem::isMenu (FWidget* w) const
if ( ! w ) if ( ! w )
return false; return false;
bool m1 = ( std::strcmp ( w->getClassName() bool m1 = w->isInstanceOf("FMenu");
, const_cast<char*>("FMenu") ) == 0 ); bool m2 = w->isInstanceOf("FDialogListMenu");
bool m2 = ( std::strcmp ( w->getClassName()
, const_cast<char*>("FDialogListMenu") ) == 0 );
return bool( m1 || m2 ); return bool( m1 || m2 );
} }

View File

@ -14,6 +14,7 @@
#include <stdint.h> #include <stdint.h>
#include <sys/time.h> // need for gettimeofday #include <sys/time.h> // need for gettimeofday
#include <cstdlib> #include <cstdlib>
#include <cstring>
#include <list> #include <list>
#include <vector> #include <vector>
@ -71,6 +72,7 @@ class FObject
bool isChild (FObject*) const; bool isChild (FObject*) const;
bool isDirectChild (FObject*) const; bool isDirectChild (FObject*) const;
bool isWidget() const; bool isWidget() const;
bool isInstanceOf (const char*) const;
bool isTimerInUpdating() const; bool isTimerInUpdating() const;
// Methods // Methods
@ -153,6 +155,10 @@ inline bool FObject::isDirectChild (FObject* obj) const
inline bool FObject::isWidget() const inline bool FObject::isWidget() const
{ return widget_object; } { return widget_object; }
//----------------------------------------------------------------------
inline bool FObject::isInstanceOf (const char* classname) const
{ return ( classname ) ? bool(strcmp(classname, getClassName()) == 0) : false; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FObject::isTimerInUpdating() const inline bool FObject::isTimerInUpdating() const
{ return timer_modify_lock; } { return timer_modify_lock; }

View File

@ -755,8 +755,7 @@ inline FPoint FScrollView::getViewportCursorPos()
void FScrollView::init (FWidget* parent) void FScrollView::init (FWidget* parent)
{ {
assert ( parent != 0 ); assert ( parent != 0 );
assert ( std::strcmp ( parent->getClassName() assert ( ! parent->isInstanceOf("FScrollView") );
, const_cast<char*>("FScrollView") ) != 0 );
setForegroundColor (wc.dialog_fg); setForegroundColor (wc.dialog_fg);
setBackgroundColor (wc.dialog_bg); setBackgroundColor (wc.dialog_bg);

View File

@ -86,8 +86,7 @@ void FStatusKey::init (FWidget* parent)
{ {
setGeometry (1,1,1,1); setGeometry (1,1,1,1);
if ( parent && std::strcmp ( parent->getClassName() if ( parent && parent->isInstanceOf("FStatusBar") )
, const_cast<char*>("FStatusBar") ) == 0 )
{ {
setConnectedStatusbar (static_cast<FStatusBar*>(parent)); setConnectedStatusbar (static_cast<FStatusBar*>(parent));

View File

@ -24,8 +24,7 @@ FToggleButton::FToggleButton (FWidget* parent)
{ {
init(); init();
if ( parent && std::strcmp ( parent->getClassName() if ( parent && parent->isInstanceOf("FButtonGroup") )
, const_cast<char*>("FButtonGroup") ) == 0 )
{ {
setGroup( static_cast<FButtonGroup*>(parent) ); setGroup( static_cast<FButtonGroup*>(parent) );
@ -47,8 +46,7 @@ FToggleButton::FToggleButton (const FString& txt, FWidget* parent)
init(); init();
setText(txt); setText(txt);
if ( parent && std::strcmp ( parent->getClassName() if ( parent && parent->isInstanceOf("FButtonGroup") )
, const_cast<char*>("FButtonGroup") ) == 0 )
{ {
setGroup( static_cast<FButtonGroup*>(parent) ); setGroup( static_cast<FButtonGroup*>(parent) );
@ -434,15 +432,13 @@ void FToggleButton::setHotkeyAccelerator()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FToggleButton::isRadioButton() const bool FToggleButton::isRadioButton() const
{ {
return ( std::strcmp ( getClassName() return isInstanceOf("FRadioButton");
, const_cast<char*>("FRadioButton") ) == 0 );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FToggleButton::isCheckboxButton() const bool FToggleButton::isCheckboxButton() const
{ {
return ( std::strcmp ( getClassName() return isInstanceOf("FCheckBox");
, const_cast<char*>("FCheckBox") ) == 0 );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------