From 30515db9ec519ef30336d42aac537d838c1df372 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sun, 23 Jul 2017 01:19:59 +0200 Subject: [PATCH] Check an object with isInstanceOf(...) whether it is an instance of a specified class --- ChangeLog | 4 + src/flabel.cpp | 2 +- src/flabel.h | 76 ++++---- src/flistbox.cpp | 414 ++++++++++++++++++++-------------------- src/flistbox.h | 7 +- src/flistview.cpp | 430 +++++++++++++++++++++--------------------- src/flistview.h | 29 +-- src/fmenu.cpp | 9 +- src/fmenuitem.cpp | 14 +- src/fobject.h | 6 + src/fscrollview.cpp | 3 +- src/fstatusbar.cpp | 3 +- src/ftogglebutton.cpp | 12 +- 13 files changed, 506 insertions(+), 503 deletions(-) diff --git a/ChangeLog b/ChangeLog index f97ae2ad..e7132e17 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2017-07-23 Markus Gans + * Check an object with isInstanceOf(...) whether it is + an instance of a specified class + 2017-07-18 Markus Gans * New Widget class FListView (filled with FListViewItem) to allow a multi-column data view diff --git a/src/flabel.cpp b/src/flabel.cpp index 25e175fa..3a4c4737 100644 --- a/src/flabel.cpp +++ b/src/flabel.cpp @@ -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 diff --git a/src/flabel.h b/src/flabel.h index 8c015284..192a729b 100644 --- a/src/flabel.h +++ b/src/flabel.h @@ -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; } //---------------------------------------------------------------------- diff --git a/src/flistbox.cpp b/src/flistbox.cpp index 031356d7..93914393 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -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(); + } +} diff --git a/src/flistbox.h b/src/flistbox.h index 78a45ae3..19995da6 100644 --- a/src/flistbox.h +++ b/src/flistbox.h @@ -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 diff --git a/src/flistview.cpp b/src/flistview.cpp index 7ce61383..12357946 100644 --- a/src/flistview.cpp +++ b/src/flistview.cpp @@ -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(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& cols : FObject(parent) , column_line(cols) , data_pointer(data) + , alignment(fc::alignLeft) { parent->insert (this); } @@ -131,7 +137,7 @@ void FListView::insert (FListViewItem* item) iter = header.begin(); while ( iter != header.end() ) - { + { int width = (*iter).width; bool fixed_width = (*iter).fixed_width; FString text = (*iter).name; @@ -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 //---------------------------------------------------------------------- @@ -1136,7 +934,7 @@ void FListView::drawColumnLabels() last = h.end() - 1; else last = h.begin() + getWidth() + xoffset - 2; - + const std::vector header_part (first, last); setPrintPos (2, 1); print (header_part); @@ -1218,7 +1016,7 @@ void FListView::drawList() else { line += text.left(width - ellipsis_length); - line += FString (".. "); + line += FString (".. "); } } } @@ -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(); + } +} diff --git a/src/flistview.h b/src/flistview.h index 5b31d42b..b080c120 100644 --- a/src/flistview.h +++ b/src/flistview.h @@ -71,6 +71,7 @@ class FListViewItem : public FObject // Data Member std::vector 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& , 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(); @@ -157,7 +153,7 @@ class FListView : public FWidget ~Header() { } - + FString name; int width; bool fixed_width; @@ -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; diff --git a/src/fmenu.cpp b/src/fmenu.cpp index a756f529..e10680c4 100644 --- a/src/fmenu.cpp +++ b/src/fmenu.cpp @@ -710,22 +710,19 @@ bool FMenu::isWindowsMenu (FWidget* w) const //---------------------------------------------------------------------- bool FMenu::isMenuBar (FWidget* w) const { - return bool ( std::strcmp ( w->getClassName() - , const_cast("FMenuBar") ) == 0 ); + return w->isInstanceOf("FMenuBar"); } //---------------------------------------------------------------------- bool FMenu::isMenu (FWidget* w) const { - return bool ( std::strcmp ( w->getClassName() - , const_cast("FMenu") ) == 0 ); + return w->isInstanceOf("FMenu"); } //---------------------------------------------------------------------- bool FMenu::isRadioMenuItem (FWidget* w) const { - return bool ( std::strcmp ( w->getClassName() - , const_cast("FRadioMenuItem") ) == 0 ); + return w->isInstanceOf("FRadioMenuItem"); } //---------------------------------------------------------------------- diff --git a/src/fmenuitem.cpp b/src/fmenuitem.cpp index 0e77fa36..a91fe2c2 100644 --- a/src/fmenuitem.cpp +++ b/src/fmenuitem.cpp @@ -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("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("FMenu") ) == 0 ); - bool m2 = ( std::strcmp ( w->getClassName() - , const_cast("FDialogListMenu") ) == 0 ); + bool m1 = w->isInstanceOf("FMenu"); + bool m2 = w->isInstanceOf("FDialogListMenu"); return bool( m1 || m2 ); } diff --git a/src/fobject.h b/src/fobject.h index 90ebd71a..d54afc72 100644 --- a/src/fobject.h +++ b/src/fobject.h @@ -14,6 +14,7 @@ #include #include // need for gettimeofday #include +#include #include #include @@ -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; } diff --git a/src/fscrollview.cpp b/src/fscrollview.cpp index 928efad9..31508a86 100644 --- a/src/fscrollview.cpp +++ b/src/fscrollview.cpp @@ -755,8 +755,7 @@ inline FPoint FScrollView::getViewportCursorPos() void FScrollView::init (FWidget* parent) { assert ( parent != 0 ); - assert ( std::strcmp ( parent->getClassName() - , const_cast("FScrollView") ) != 0 ); + assert ( ! parent->isInstanceOf("FScrollView") ); setForegroundColor (wc.dialog_fg); setBackgroundColor (wc.dialog_bg); diff --git a/src/fstatusbar.cpp b/src/fstatusbar.cpp index bd946f66..04827501 100644 --- a/src/fstatusbar.cpp +++ b/src/fstatusbar.cpp @@ -86,8 +86,7 @@ void FStatusKey::init (FWidget* parent) { setGeometry (1,1,1,1); - if ( parent && std::strcmp ( parent->getClassName() - , const_cast("FStatusBar") ) == 0 ) + if ( parent && parent->isInstanceOf("FStatusBar") ) { setConnectedStatusbar (static_cast(parent)); diff --git a/src/ftogglebutton.cpp b/src/ftogglebutton.cpp index 37733ee3..3fab3cea 100644 --- a/src/ftogglebutton.cpp +++ b/src/ftogglebutton.cpp @@ -24,8 +24,7 @@ FToggleButton::FToggleButton (FWidget* parent) { init(); - if ( parent && std::strcmp ( parent->getClassName() - , const_cast("FButtonGroup") ) == 0 ) + if ( parent && parent->isInstanceOf("FButtonGroup") ) { setGroup( static_cast(parent) ); @@ -47,8 +46,7 @@ FToggleButton::FToggleButton (const FString& txt, FWidget* parent) init(); setText(txt); - if ( parent && std::strcmp ( parent->getClassName() - , const_cast("FButtonGroup") ) == 0 ) + if ( parent && parent->isInstanceOf("FButtonGroup") ) { setGroup( static_cast(parent) ); @@ -434,15 +432,13 @@ void FToggleButton::setHotkeyAccelerator() //---------------------------------------------------------------------- bool FToggleButton::isRadioButton() const { - return ( std::strcmp ( getClassName() - , const_cast("FRadioButton") ) == 0 ); + return isInstanceOf("FRadioButton"); } //---------------------------------------------------------------------- bool FToggleButton::isCheckboxButton() const { - return ( std::strcmp ( getClassName() - , const_cast("FCheckBox") ) == 0 ); + return isInstanceOf("FCheckBox"); } //----------------------------------------------------------------------