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>
<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>
&nbsp;

View File

@ -745,7 +745,7 @@ void FLineEdit::drawInputField()
if ( isActiveFocus && getMaxColor() < 16 )
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 )
{

View File

@ -1534,12 +1534,12 @@ inline void FListView::mapKeyFunctions()
key_map[fc::Fkey_return] = 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_up] = [&] { stepBackward(); };
key_map[fc::Fkey_down] = [&] { stepForward(); };
key_map[fc::Fkey_up] = [this] { stepBackward(); };
key_map[fc::Fkey_down] = [this] { stepForward(); };
key_map[fc::Fkey_left] = std::bind(&FListView::collapseAndScrollLeft, this);
key_map[fc::Fkey_right] = std::bind(&FListView::expandAndScrollRight, this);
key_map[fc::Fkey_ppage] = [&] { stepBackward(int(getClientHeight()) - 1); };
key_map[fc::Fkey_npage] = [&] { stepForward(int(getClientHeight()) - 1); };
key_map[fc::Fkey_ppage] = [this] { stepBackward(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_end] = std::bind(&FListView::lastPos, 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)
{
@ -467,9 +479,26 @@ void FMenu::init(FWidget* parent)
setSuperMenu(parent);
}
initCallbacks();
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()
{
@ -686,7 +715,7 @@ void FMenu::mouseDownSubmenu (const FMenuItem* m_item)
if ( ! sel_item
|| ! sel_item->hasMenu()
|| sel_item->getMenu() != opened_sub_menu )
return;
return;
if ( sel_item != m_item )
hideSubMenus();

View File

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

View File

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

View File

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

View File

@ -598,7 +598,7 @@ bool FTerm::canChangeColorPalette()
|| isOpenBSDTerm()
|| isSunTerminal()
|| isAnsiTerminal() )
return false;
return false;
return FTermcap::can_change_color_palette;
}

View File

@ -559,7 +559,7 @@ void FTermcapQuirks::ecma48()
// Test for standard ECMA-48 (ANSI X3.64) terminal
if ( ! TCAP(fc::t_exit_underline_mode)
|| std::strncmp(TCAP(fc::t_exit_underline_mode), CSI "24m", 5) != 0 )
return;
return;
// Seems to be a ECMA-48 (ANSI X3.64) compatible terminal
TCAP(fc::t_enter_dbl_underline_mode) = \

View File

@ -571,14 +571,14 @@ void FTextView::init()
//----------------------------------------------------------------------
inline void FTextView::mapKeyFunctions()
{
key_map[fc::Fkey_up] = [&] { scrollBy (0, -1); };
key_map[fc::Fkey_down] = [&] { scrollBy (0, 1); };
key_map[fc::Fkey_left] = [&] { scrollBy (-1, 0); };
key_map[fc::Fkey_right] = [&] { scrollBy (1, 0); };
key_map[fc::Fkey_ppage] = [&] { scrollBy (0, -int(getTextHeight())); };
key_map[fc::Fkey_npage] = [&] { scrollBy (0, int(getTextHeight())); };
key_map[fc::Fkey_home] = [&] { scrollToY (0); };
key_map[fc::Fkey_end] = [&] { scrollToY (int(getRows() - getTextHeight())); };
key_map[fc::Fkey_up] = [this] { scrollBy (0, -1); };
key_map[fc::Fkey_down] = [this] { scrollBy (0, 1); };
key_map[fc::Fkey_left] = [this] { scrollBy (-1, 0); };
key_map[fc::Fkey_right] = [this] { scrollBy (1, 0); };
key_map[fc::Fkey_ppage] = [this] { scrollBy (0, -int(getTextHeight())); };
key_map[fc::Fkey_npage] = [this] { scrollBy (0, int(getTextHeight())); };
key_map[fc::Fkey_home] = [this] { scrollToY (0); };
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)
{
if ( enable )
emitCallback("enable");
else
emitCallback("disable");
return (flags.active = enable);
}
@ -1814,7 +1819,7 @@ void FWidget::KeyPressEvent (FKeyEvent* kev)
{
const FKey key = kev->key();
if ( [&] ()
if ( [this, &key] ()
{
if ( isFocusNextKey(key) )
return focusNextChild();

View File

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

View File

@ -91,67 +91,67 @@ class FDialog : public FWindow
FDialog& operator = (const FDialog&) = delete;
// Accessors
const FString getClassName() const override;
FString getText() const;
const FString getClassName() const override;
virtual const FString getText() const;
// Mutators
bool setDialogWidget (bool);
bool setDialogWidget();
bool unsetDialogWidget();
bool setModal (bool);
bool setModal();
bool unsetModal();
bool setResizeable (bool) override;
bool setScrollable (bool);
bool setScrollable();
bool unsetScrollable();
bool setBorder (bool);
bool setBorder();
bool unsetBorder();
void setText (const FString&);
bool setDialogWidget (bool);
bool setDialogWidget();
bool unsetDialogWidget();
bool setModal (bool);
bool setModal();
bool unsetModal();
bool setResizeable (bool) override;
bool setScrollable (bool);
bool setScrollable();
bool unsetScrollable();
bool setBorder (bool);
bool setBorder();
bool unsetBorder();
virtual void setText (const FString&);
// Inquiries
bool isModal() const;
bool isScrollable() const;
bool hasBorder() const;
bool isModal() const;
bool isScrollable() const;
bool hasBorder() const;
// Methods
void show() override;
void hide() override;
int exec();
void setPos (const FPoint&, bool = true) override;
void move (const FPoint&) override;
bool moveUp (int);
bool moveDown (int);
bool moveLeft (int);
bool moveRight (int);
void setSize (const FSize&, bool = true) override;
bool reduceHeight (int);
bool expandHeight (int);
bool reduceWidth (int);
bool expandWidth (int);
void activateDialog();
void show() override;
void hide() override;
int exec();
void setPos (const FPoint&, bool = true) override;
void move (const FPoint&) override;
bool moveUp (int);
bool moveDown (int);
bool moveLeft (int);
bool moveRight (int);
void setSize (const FSize&, bool = true) override;
bool reduceHeight (int);
bool expandHeight (int);
bool reduceWidth (int);
bool expandWidth (int);
void activateDialog();
// Event handlers
void onKeyPress (FKeyEvent*) override;
void onMouseDown (FMouseEvent*) override;
void onMouseUp (FMouseEvent*) override;
void onMouseMove (FMouseEvent*) override;
void onMouseDoubleClick (FMouseEvent*) override;
void onAccel (FAccelEvent*) override;
void onWindowActive (FEvent*) override;
void onWindowInactive (FEvent*) override;
void onWindowRaised (FEvent*) override;
void onWindowLowered (FEvent*) override;
void onKeyPress (FKeyEvent*) override;
void onMouseDown (FMouseEvent*) override;
void onMouseUp (FMouseEvent*) override;
void onMouseMove (FMouseEvent*) override;
void onMouseDoubleClick (FMouseEvent*) override;
void onAccel (FAccelEvent*) override;
void onWindowActive (FEvent*) override;
void onWindowInactive (FEvent*) override;
void onWindowRaised (FEvent*) override;
void onWindowLowered (FEvent*) override;
protected:
// Methods
virtual void done (int);
void draw() override;
void drawDialogShadow();
virtual void done (int);
void draw() override;
void drawDialogShadow();
// Event handlers
void onClose (FCloseEvent*) override;
void onClose (FCloseEvent*) override;
private:
// Typedef
@ -169,65 +169,65 @@ class FDialog : public FWindow
static constexpr bool PRINT_WIN_NUMBER = false; // Only for debug
// Methods
void init();
void initDialogMenu();
void initMoveSizeMenuItem (FMenu*);
void initZoomMenuItem (FMenu*);
void initCloseMenuItem (FMenu*);
void drawBorder() override;
void drawTitleBar();
void drawBarButton();
void drawZoomButton();
void drawRestoreSizeButton();
void drawZoomedButton();
void drawTextBar();
void restoreOverlaidWindows();
void setCursorToFocusWidget();
void leaveMenu();
void openMenu();
void selectFirstMenuItem();
void setZoomItem();
std::size_t getZoomButtonWidth();
void activateZoomButton (const mouseStates&);
void deactivateZoomButton();
void leaveZoomButton (const mouseStates&);
void pressZoomButton (const mouseStates&);
bool isMouseOverMenu (const FPoint&);
void passEventToSubMenu (const mouseStates&, const FMouseEvent*);
void moveSizeKey (FKeyEvent*);
void raiseActivateDialog();
void lowerActivateDialog();
bool isOutsideTerminal (const FPoint&);
bool isLowerRightResizeCorner (const mouseStates&);
void resizeMouseDown (const mouseStates&);
void resizeMouseUpMove (const mouseStates&, bool = false);
void cancelMouseResize();
void acceptMoveSize();
void cancelMoveSize();
static void addDialog (FWidget*);
static void delDialog (const FWidget*);
void init();
void initDialogMenu();
void initMoveSizeMenuItem (FMenu*);
void initZoomMenuItem (FMenu*);
void initCloseMenuItem (FMenu*);
void drawBorder() override;
void drawTitleBar();
void drawBarButton();
void drawZoomButton();
void drawRestoreSizeButton();
void drawZoomedButton();
void drawTextBar();
void restoreOverlaidWindows();
void setCursorToFocusWidget();
void leaveMenu();
void openMenu();
void selectFirstMenuItem();
void setZoomItem();
std::size_t getZoomButtonWidth();
void activateZoomButton (const mouseStates&);
void deactivateZoomButton();
void leaveZoomButton (const mouseStates&);
void pressZoomButton (const mouseStates&);
bool isMouseOverMenu (const FPoint&);
void passEventToSubMenu (const mouseStates&, const FMouseEvent*);
void moveSizeKey (FKeyEvent*);
void raiseActivateDialog();
void lowerActivateDialog();
bool isOutsideTerminal (const FPoint&);
bool isLowerRightResizeCorner (const mouseStates&);
void resizeMouseDown (const mouseStates&);
void resizeMouseUpMove (const mouseStates&, bool = false);
void cancelMouseResize();
void acceptMoveSize();
void cancelMoveSize();
static void addDialog (FWidget*);
static void delDialog (const FWidget*);
// Callback methods
void cb_move (const FWidget*, const FDataPtr);
void cb_zoom (const FWidget*, const FDataPtr);
void cb_close (const FWidget*, const FDataPtr);
void cb_move (const FWidget*, const FDataPtr);
void cb_zoom (const FWidget*, const FDataPtr);
void cb_close (const FWidget*, const FDataPtr);
// Data members
FString tb_text{}; // title bar text
int result_code{FDialog::Reject};
bool zoom_button_pressed{false};
bool zoom_button_active{false};
bool setPos_error{false};
bool setSize_error{false};
FPoint titlebar_click_pos{};
FPoint resize_click_pos{};
FRect save_geometry{}; // required by keyboard move/size
FMenu* dialog_menu{nullptr};
FMenuItem* dgl_menuitem{nullptr};
FMenuItem* move_size_item{nullptr};
FMenuItem* zoom_item{nullptr};
FMenuItem* close_item{nullptr};
FToolTip* tooltip{nullptr};
FString tb_text{}; // title bar text
int result_code{FDialog::Reject};
bool zoom_button_pressed{false};
bool zoom_button_active{false};
bool setPos_error{false};
bool setSize_error{false};
FPoint titlebar_click_pos{};
FPoint resize_click_pos{};
FRect save_geometry{}; // required by keyboard move/size
FMenu* dialog_menu{nullptr};
FMenuItem* dgl_menuitem{nullptr};
FMenuItem* move_size_item{nullptr};
FMenuItem* zoom_item{nullptr};
FMenuItem* close_item{nullptr};
FToolTip* tooltip{nullptr};
// Friend function from FMenu
friend void FMenu::hideSuperMenus();
@ -239,7 +239,7 @@ inline const FString FDialog::getClassName() const
{ return "FDialog"; }
//----------------------------------------------------------------------
inline FString FDialog::getText() const
inline const FString FDialog::getText() const
{ return tb_text; }
//----------------------------------------------------------------------

View File

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

View File

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

View File

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

View File

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

View File

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