Correction of some virtual methods

This commit is contained in:
Markus Gans 2020-04-18 13:33:42 +02:00
parent 6de04a3edd
commit 136b57eac6
18 changed files with 199 additions and 150 deletions

View File

@ -472,7 +472,7 @@ use `delCallbacks()` to remove all existing callbacks from an object.
<dd>"clicked"<br />"toggled"</dd> <dd>"clicked"<br />"toggled"</dd>
<dt>FWidget</dt> <dt>FWidget</dt>
<dd>"destroy"<br />"focus-in"<br />"focus-out"<br />"mouse-press"<br />"mouse-release"<br />"mouse-move"<br />"mouse-wheel-down"<br />"mouse-wheel-up"</dd> <dd>"destroy"<br />"enable"<br />"disable"<br />"focus-in"<br />"focus-out"<br />"mouse-press"<br />"mouse-release"<br />"mouse-move"<br />"mouse-wheel-down"<br />"mouse-wheel-up"</dd>
</dl> </dl>
&nbsp; &nbsp;

View File

@ -745,7 +745,7 @@ void FLineEdit::drawInputField()
if ( isActiveFocus && getMaxColor() < 16 ) if ( isActiveFocus && getMaxColor() < 16 )
setBold(); setBold();
const std::size_t text_offset_column = [&] () -> std::size_t const std::size_t text_offset_column = [this] () -> std::size_t
{ {
switch ( input_type ) switch ( input_type )
{ {

View File

@ -1534,12 +1534,12 @@ inline void FListView::mapKeyFunctions()
key_map[fc::Fkey_return] = std::bind(&FListView::processClick, this); key_map[fc::Fkey_return] = std::bind(&FListView::processClick, this);
key_map[fc::Fkey_enter] = std::bind(&FListView::processClick, this); key_map[fc::Fkey_enter] = std::bind(&FListView::processClick, this);
key_map[fc::Fkey_space] = std::bind(&FListView::toggleCheckbox, this); key_map[fc::Fkey_space] = std::bind(&FListView::toggleCheckbox, this);
key_map[fc::Fkey_up] = [&] { stepBackward(); }; key_map[fc::Fkey_up] = [this] { stepBackward(); };
key_map[fc::Fkey_down] = [&] { stepForward(); }; key_map[fc::Fkey_down] = [this] { stepForward(); };
key_map[fc::Fkey_left] = std::bind(&FListView::collapseAndScrollLeft, this); key_map[fc::Fkey_left] = std::bind(&FListView::collapseAndScrollLeft, this);
key_map[fc::Fkey_right] = std::bind(&FListView::expandAndScrollRight, this); key_map[fc::Fkey_right] = std::bind(&FListView::expandAndScrollRight, this);
key_map[fc::Fkey_ppage] = [&] { stepBackward(int(getClientHeight()) - 1); }; key_map[fc::Fkey_ppage] = [this] { stepBackward(int(getClientHeight()) - 1); };
key_map[fc::Fkey_npage] = [&] { stepForward(int(getClientHeight()) - 1); }; key_map[fc::Fkey_npage] = [this] { stepForward(int(getClientHeight()) - 1); };
key_map[fc::Fkey_home] = std::bind(&FListView::firstPos, this); key_map[fc::Fkey_home] = std::bind(&FListView::firstPos, this);
key_map[fc::Fkey_end] = std::bind(&FListView::lastPos, this); key_map[fc::Fkey_end] = std::bind(&FListView::lastPos, this);
key_map_result[FKey('+')] = std::bind(&FListView::expandSubtree, this); key_map_result[FKey('+')] = std::bind(&FListView::expandSubtree, this);

View File

@ -316,6 +316,18 @@ void FMenu::onMouseMove (FMouseEvent* ev)
} }
} }
//----------------------------------------------------------------------
void FMenu::cb_menuitemEnabled (FWidget*, const FDataPtr)
{
setEnable();
}
//----------------------------------------------------------------------
void FMenu::cb_menuitemDisabled (FWidget*, const FDataPtr)
{
setDisable();
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenu::cb_menuitemToggled (FWidget* widget, const FDataPtr) void FMenu::cb_menuitemToggled (FWidget* widget, const FDataPtr)
{ {
@ -467,9 +479,26 @@ void FMenu::init(FWidget* parent)
setSuperMenu(parent); setSuperMenu(parent);
} }
initCallbacks();
calculateDimensions(); calculateDimensions();
} }
//----------------------------------------------------------------------
void FMenu::initCallbacks()
{
menuitem.addCallback
(
"enable",
F_METHOD_CALLBACK (this, &FMenu::cb_menuitemEnabled)
);
menuitem.addCallback
(
"disable",
F_METHOD_CALLBACK (this, &FMenu::cb_menuitemEnabled)
);
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenu::calculateDimensions() void FMenu::calculateDimensions()
{ {

View File

@ -564,6 +564,18 @@ void FMenuItem::updateSuperMenuDimensions()
menu_ptr->calculateDimensions(); menu_ptr->calculateDimensions();
} }
//----------------------------------------------------------------------
void FMenuItem::processEnable()
{
emitCallback("enable");
}
//----------------------------------------------------------------------
void FMenuItem::processDisable()
{
emitCallback("disable");
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuItem::processActivate() void FMenuItem::processActivate()
{ {

View File

@ -277,9 +277,9 @@ void FScrollView::setGeometry ( const FPoint& pos, const FSize& size
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::setCursorPos (const FPoint& p) bool FScrollView::setCursorPos (const FPoint& p)
{ {
FWidget::setCursorPos (FPoint ( p.getX() + getLeftPadding() return FWidget::setCursorPos (FPoint ( p.getX() + getLeftPadding()
, p.getY() + getTopPadding() )); , p.getY() + getTopPadding() ));
} }
@ -751,15 +751,15 @@ void FScrollView::init (const FWidget* parent)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FScrollView::mapKeyFunctions() inline void FScrollView::mapKeyFunctions()
{ {
key_map[fc::Fkey_up] = [&] { scrollBy (0, -1); }; key_map[fc::Fkey_up] = [this] { scrollBy (0, -1); };
key_map[fc::Fkey_down] = [&] { scrollBy (0, 1); }; key_map[fc::Fkey_down] = [this] { scrollBy (0, 1); };
key_map[fc::Fkey_left] = [&] { scrollBy (-1, 0); }; key_map[fc::Fkey_left] = [this] { scrollBy (-1, 0); };
key_map[fc::Fkey_right] = [&] { scrollBy (1, 0); }; key_map[fc::Fkey_right] = [this] { scrollBy (1, 0); };
key_map[fc::Fkey_ppage] = [&] { scrollBy (0, -int(getViewportHeight())); }; key_map[fc::Fkey_ppage] = [this] { scrollBy (0, -int(getViewportHeight())); };
key_map[fc::Fkey_npage] = [&] { scrollBy (0, int(getViewportHeight())); }; key_map[fc::Fkey_npage] = [this] { scrollBy (0, int(getViewportHeight())); };
key_map[fc::Fkey_home] = [&] { scrollToY (1); }; key_map[fc::Fkey_home] = [this] { scrollToY (1); };
key_map[fc::Fkey_end] = \ key_map[fc::Fkey_end] = \
[&] () [this] ()
{ {
int yoffset_end = int(getScrollHeight() - getViewportHeight()); int yoffset_end = int(getScrollHeight() - getViewportHeight());
scrollToY (1 + yoffset_end); scrollToY (1 + yoffset_end);

View File

@ -325,7 +325,7 @@ void FSpinBox::draw()
{ {
const auto& wc = getFWidgetColors(); const auto& wc = getFWidgetColors();
const FColorPair inc_button_color = [&] () const FColorPair inc_button_color = [this, &wc] ()
{ {
if ( value == max ) if ( value == max )
return FColorPair ( wc.scrollbar_button_inactive_fg return FColorPair ( wc.scrollbar_button_inactive_fg
@ -335,7 +335,7 @@ void FSpinBox::draw()
, wc.scrollbar_button_bg ); , wc.scrollbar_button_bg );
}(); }();
const FColorPair dec_button_color = [&] () const FColorPair dec_button_color = [this, &wc] ()
{ {
if ( value == min ) if ( value == min )
return FColorPair ( wc.scrollbar_button_inactive_fg return FColorPair ( wc.scrollbar_button_inactive_fg

View File

@ -571,14 +571,14 @@ void FTextView::init()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FTextView::mapKeyFunctions() inline void FTextView::mapKeyFunctions()
{ {
key_map[fc::Fkey_up] = [&] { scrollBy (0, -1); }; key_map[fc::Fkey_up] = [this] { scrollBy (0, -1); };
key_map[fc::Fkey_down] = [&] { scrollBy (0, 1); }; key_map[fc::Fkey_down] = [this] { scrollBy (0, 1); };
key_map[fc::Fkey_left] = [&] { scrollBy (-1, 0); }; key_map[fc::Fkey_left] = [this] { scrollBy (-1, 0); };
key_map[fc::Fkey_right] = [&] { scrollBy (1, 0); }; key_map[fc::Fkey_right] = [this] { scrollBy (1, 0); };
key_map[fc::Fkey_ppage] = [&] { scrollBy (0, -int(getTextHeight())); }; key_map[fc::Fkey_ppage] = [this] { scrollBy (0, -int(getTextHeight())); };
key_map[fc::Fkey_npage] = [&] { scrollBy (0, int(getTextHeight())); }; key_map[fc::Fkey_npage] = [this] { scrollBy (0, int(getTextHeight())); };
key_map[fc::Fkey_home] = [&] { scrollToY (0); }; key_map[fc::Fkey_home] = [this] { scrollToY (0); };
key_map[fc::Fkey_end] = [&] { scrollToY (int(getRows() - getTextHeight())); }; key_map[fc::Fkey_end] = [this] { scrollToY (int(getRows() - getTextHeight())); };
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -269,6 +269,11 @@ bool FWidget::setVisible (bool enable)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FWidget::setEnable (bool enable) bool FWidget::setEnable (bool enable)
{ {
if ( enable )
emitCallback("enable");
else
emitCallback("disable");
return (flags.active = enable); return (flags.active = enable);
} }
@ -1814,7 +1819,7 @@ void FWidget::KeyPressEvent (FKeyEvent* kev)
{ {
const FKey key = kev->key(); const FKey key = kev->key();
if ( [&] () if ( [this, &key] ()
{ {
if ( isFocusNextKey(key) ) if ( isFocusNextKey(key) )
return focusNextChild(); return focusNextChild();

View File

@ -81,8 +81,8 @@ class FButton : public FWidget
FString& getText(); FString& getText();
// Mutators // Mutators
void setForegroundColor (FColor); void setForegroundColor (FColor) override;
void setBackgroundColor (FColor); void setBackgroundColor (FColor) override;
void setHotkeyForegroundColor (FColor); void setHotkeyForegroundColor (FColor);
void setFocusForegroundColor (FColor); void setFocusForegroundColor (FColor);
void setFocusBackgroundColor (FColor); void setFocusBackgroundColor (FColor);

View File

@ -92,7 +92,7 @@ class FDialog : public FWindow
// Accessors // Accessors
const FString getClassName() const override; const FString getClassName() const override;
FString getText() const; virtual const FString getText() const;
// Mutators // Mutators
bool setDialogWidget (bool); bool setDialogWidget (bool);
@ -108,7 +108,7 @@ class FDialog : public FWindow
bool setBorder (bool); bool setBorder (bool);
bool setBorder(); bool setBorder();
bool unsetBorder(); bool unsetBorder();
void setText (const FString&); virtual void setText (const FString&);
// Inquiries // Inquiries
bool isModal() const; bool isModal() const;
@ -239,7 +239,7 @@ inline const FString FDialog::getClassName() const
{ return "FDialog"; } { return "FDialog"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString FDialog::getText() const inline const FString FDialog::getText() const
{ return tb_text; } { return tb_text; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -71,6 +71,9 @@ class FMenuItem;
class FMenu : public FWindow, public FMenuList class FMenu : public FWindow, public FMenuList
{ {
public: public:
// Using-declaration
using FMenuList::getItem;
// Constructor // Constructor
explicit FMenu (FWidget* = nullptr); explicit FMenu (FWidget* = nullptr);
explicit FMenu (const FString&, FWidget* = nullptr); explicit FMenu (const FString&, FWidget* = nullptr);
@ -104,7 +107,6 @@ class FMenu : public FWindow, public FMenuList
void setText (const FString&); void setText (const FString&);
// Inquiries // Inquiries
bool isEnabled() const;
bool isSelected() const; bool isSelected() const;
bool hasHotkey() const; bool hasHotkey() const;
bool hasMenu() const; bool hasMenu() const;
@ -121,6 +123,8 @@ class FMenu : public FWindow, public FMenuList
void onAccel (FAccelEvent*) override; void onAccel (FAccelEvent*) override;
// Callback method // Callback method
void cb_menuitemEnabled (FWidget*, const FDataPtr);
void cb_menuitemDisabled (FWidget*, const FDataPtr);
void cb_menuitemToggled (FWidget*, const FDataPtr); void cb_menuitemToggled (FWidget*, const FDataPtr);
private: private:
@ -167,6 +171,7 @@ class FMenu : public FWindow, public FMenuList
// Methods // Methods
void init(FWidget*); void init(FWidget*);
void initCallbacks();
void calculateDimensions(); void calculateDimensions();
void adjustItems(); void adjustItems();
int adjustX(int); int adjustX(int);
@ -290,10 +295,6 @@ inline void FMenu::setMenu (FMenu* m)
inline void FMenu::setText (const FString& txt) inline void FMenu::setText (const FString& txt)
{ menuitem.setText(txt); } { menuitem.setText(txt); }
//----------------------------------------------------------------------
inline bool FMenu::isEnabled() const
{ return menuitem.isEnabled(); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FMenu::isSelected() const inline bool FMenu::isSelected() const
{ return menuitem.isSelected(); } { return menuitem.isSelected(); }

View File

@ -156,6 +156,8 @@ class FMenuItem : public FWidget
// Methods // Methods
void init (FWidget*); void init (FWidget*);
void updateSuperMenuDimensions(); void updateSuperMenuDimensions();
void processEnable();
void processDisable();
void processActivate(); void processActivate();
void processDeactivate(); void processDeactivate();
void createDialogList (FMenu*); void createDialogList (FMenu*);

View File

@ -104,7 +104,7 @@ class FMessageBox : public FDialog
const FString getClassName() const override; const FString getClassName() const override;
const FString getTitlebarText() const; const FString getTitlebarText() const;
const FString getHeadline() const; const FString getHeadline() const;
const FString getText() const; const FString getText() const override;
// Mutator // Mutator
void setTitlebarText (const FString&); void setTitlebarText (const FString&);
@ -112,7 +112,7 @@ class FMessageBox : public FDialog
bool setCenterText(bool); bool setCenterText(bool);
bool setCenterText(); bool setCenterText();
bool unsetCenterText(); bool unsetCenterText();
void setText (const FString&); void setText (const FString&) override;
// Methods // Methods
template <typename messageType> template <typename messageType>

View File

@ -103,8 +103,8 @@ class FScrollView : public FWidget
void setSize (const FSize&, bool = true) override; void setSize (const FSize&, bool = true) override;
void setGeometry ( const FPoint&, const FSize& void setGeometry ( const FPoint&, const FSize&
, bool = true ) override; , bool = true ) override;
void setCursorPos (const FPoint&); bool setCursorPos (const FPoint&) override;
void setPrintPos (const FPoint&); void setPrintPos (const FPoint&) override;
bool setViewportPrint (bool); bool setViewportPrint (bool);
bool setViewportPrint(); bool setViewportPrint();
bool unsetViewportPrint(); bool unsetViewportPrint();

View File

@ -259,8 +259,8 @@ class FWidget : public FVTerm, public FObject
bool ignorePadding (bool); // ignore padding from bool ignorePadding (bool); // ignore padding from
bool ignorePadding(); // the parent widget bool ignorePadding(); // the parent widget
bool acceptPadding(); bool acceptPadding();
void setForegroundColor (FColor); virtual void setForegroundColor (FColor);
void setBackgroundColor (FColor); virtual void setBackgroundColor (FColor);
void setColor(); void setColor();
FWidgetFlags& setFlags(); FWidgetFlags& setFlags();
// Positioning and sizes mutators... // Positioning and sizes mutators...
@ -285,9 +285,9 @@ class FWidget : public FVTerm, public FObject
void setMaximumHeight (std::size_t); void setMaximumHeight (std::size_t);
void setMaximumSize (const FSize&); void setMaximumSize (const FSize&);
void setFixedSize (const FSize&); void setFixedSize (const FSize&);
bool setCursorPos (const FPoint&); virtual bool setCursorPos (const FPoint&);
void unsetCursorPos(); void unsetCursorPos();
void setPrintPos (const FPoint&); virtual void setPrintPos (const FPoint&);
void setDoubleFlatLine (fc::sides, bool = true); void setDoubleFlatLine (fc::sides, bool = true);
void unsetDoubleFlatLine (fc::sides); void unsetDoubleFlatLine (fc::sides);
void setDoubleFlatLine (fc::sides, int, bool = true); void setDoubleFlatLine (fc::sides, int, bool = true);