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>
* New Widget class FListView (filled with FListViewItem)
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
&& align != fc::alignCenter

View File

@ -52,37 +52,37 @@ class FLabel : public FWidget
virtual ~FLabel();
// Accessors
const char* getClassName() const;
FTerm* getAccelWidget();
uInt getAlignment();
FString& getText();
const char* getClassName() const;
FTerm* getAccelWidget();
fc::text_alignment getAlignment();
FString& getText();
// Mutators
void setAccelWidget (FWidget* = 0);
void setAlignment(uInt);
bool setEmphasis(bool);
bool setEmphasis();
bool unsetEmphasis();
bool setReverseMode(bool);
bool setReverseMode();
bool unsetReverseMode();
bool setEnable (bool);
void setNumber(long);
void setText (const FString&);
void setAccelWidget (FWidget* = 0);
void setAlignment(fc::text_alignment);
bool setEmphasis(bool);
bool setEmphasis();
bool unsetEmphasis();
bool setReverseMode(bool);
bool setReverseMode();
bool unsetReverseMode();
bool setEnable (bool);
void setNumber(long);
void setText (const FString&);
// Inquiries
bool hasEmphasis();
bool hasReverseMode();
bool hasEmphasis();
bool hasReverseMode();
// Methods
void hide();
void hide();
// Event handlers
void onMouseDown (FMouseEvent*);
void onAccel (FAccelEvent*);
void onMouseDown (FMouseEvent*);
void onAccel (FAccelEvent*);
// Callback method
void cb_accel_widget_destroyed (FWidget*, data_ptr);
void cb_accel_widget_destroyed (FWidget*, data_ptr);
private:
// Typedef
@ -95,24 +95,24 @@ class FLabel : public FWidget
FLabel& operator = (const FLabel&);
// Methods
void init();
uChar getHotkey();
int getHotkeyPos (wchar_t*&, wchar_t*&, uInt);
void setHotkeyAccelerator();
int getXOffset (int);
void printLine (wchar_t*&, uInt, int, int = 0);
void draw();
void init();
uChar getHotkey();
int getHotkeyPos (wchar_t*&, wchar_t*&, uInt);
void setHotkeyAccelerator();
int getXOffset (int);
void printLine (wchar_t*&, uInt, int, int = 0);
void draw();
// Data Members
multiLineText multiline_text;
bool multiline;
FString text;
uInt alignment;
short emphasis_color;
short ellipsis_color;
bool emphasis;
bool reverse_mode;
FWidget* accel_widget;
multiLineText multiline_text;
bool multiline;
FString text;
fc::text_alignment alignment;
short emphasis_color;
short ellipsis_color;
bool emphasis;
bool reverse_mode;
FWidget* accel_widget;
};
#pragma pack(pop)
@ -127,7 +127,7 @@ inline FTerm* FLabel::getAccelWidget ()
{ return accel_widget; }
//----------------------------------------------------------------------
inline uInt FLabel::getAlignment()
inline fc::text_alignment FLabel::getAlignment()
{ return alignment; }
//----------------------------------------------------------------------

View File

@ -1158,213 +1158,6 @@ void FListBox::onFocusOut (FFocusEvent*)
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
//----------------------------------------------------------------------
@ -1860,3 +1653,210 @@ void FListBox::processChanged()
{
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 onFocusOut (FFocusEvent*);
// Callback methods
void cb_VBarChange (FWidget*, data_ptr);
void cb_HBarChange (FWidget*, data_ptr);
protected:
// Methods
@ -224,6 +221,10 @@ class FListBox : public FWidget
void processChanged();
listBoxItems::iterator index2iterator (int);
// Callback methods
void cb_VBarChange (FWidget*, data_ptr);
void cb_HBarChange (FWidget*, data_ptr);
// Function Pointer
void (*convertToItem) ( FListBoxItem&
, FWidget::data_ptr

View File

@ -19,8 +19,12 @@ FListViewItem::FListViewItem (const FListViewItem& item)
: FObject(item.getParent())
, column_line(item.column_line)
, 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)
, column_line()
, data_pointer(0)
, alignment(fc::alignLeft)
{
parent->insert (this);
}
@ -39,6 +44,7 @@ FListViewItem::FListViewItem ( const std::vector<FString>& cols
: FObject(parent)
, column_line(cols)
, data_pointer(data)
, alignment(fc::alignLeft)
{
parent->insert (this);
}
@ -700,214 +706,6 @@ void FListView::onFocusOut (FFocusEvent*)
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
//----------------------------------------------------------------------
@ -1280,3 +1078,211 @@ void FListView::processChanged()
{
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
std::vector<FString> column_line;
FWidget::data_ptr data_pointer;
fc::text_alignment alignment;
};
#pragma pack(pop)
@ -122,7 +123,6 @@ class FListView : public FWidget
void insert ( const std::vector<long>&
, data_ptr = 0
, FListView* = 0 );
listViewItems::iterator index2iterator (int);
// Event handlers
void onKeyPress (FKeyEvent*);
@ -135,10 +135,6 @@ class FListView : public FWidget
void onFocusIn (FFocusEvent*);
void onFocusOut (FFocusEvent*);
// Callback methods
void cb_VBarChange (FWidget*, data_ptr);
void cb_HBarChange (FWidget*, data_ptr);
protected:
// Methods
void adjustYOffset();
@ -175,14 +171,19 @@ class FListView : public FWidget
FListView& operator = (const FListView&);
// Methods
void init();
void draw();
void drawColumnLabels();
void drawList();
void recalculateHorizontalBar (int);
void recalculateVerticalBar (int);
void processClick();
void processChanged();
void init();
void draw();
void drawColumnLabels();
void drawList();
void recalculateHorizontalBar (int);
void recalculateVerticalBar (int);
void processClick();
void processChanged();
listViewItems::iterator index2iterator (int);
// Callback methods
void cb_VBarChange (FWidget*, data_ptr);
void cb_HBarChange (FWidget*, data_ptr);
// Data Members
listViewItems data;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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