From c25ee14fe74599a80abc32abc58712e74b3df21e Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Fri, 30 Sep 2016 04:55:28 +0200 Subject: [PATCH] Move or resize a window with the arrow keys --- ChangeLog | 3 + src/fapp.cpp | 19 ++++- src/fapp.h | 13 ++-- src/fbutton.h | 13 ++-- src/fbuttongroup.h | 54 ++++++++------ src/fcheckbox.h | 12 +++- src/fcheckmenuitem.h | 6 ++ src/fdialog.cpp | 150 ++++++++++++++++++++++++++++++++++----- src/fdialog.h | 21 ++++-- src/fdialoglistmenu.h | 10 ++- src/fevent.h | 6 +- src/ffiledialog.h | 31 +++++--- src/flabel.h | 17 +++-- src/flineedit.h | 14 ++-- src/flistbox.h | 37 ++++++---- src/fmenu.h | 14 +++- src/fmenubar.h | 14 +++- src/fmenuitem.h | 11 +++ src/fmenulist.h | 35 ++++----- src/fmessagebox.h | 12 +++- src/fobject.h | 8 +++ src/foptiattr.h | 13 ++-- src/foptimove.h | 6 +- src/fpoint.h | 9 ++- src/fprogressbar.h | 6 +- src/fradiobutton.h | 12 +++- src/fradiomenuitem.h | 6 ++ src/frect.h | 11 +-- src/fscrollbar.h | 10 ++- src/fstatusbar.cpp | 48 ++++++------- src/fstatusbar.h | 24 +++++-- src/fstring.h | 18 ++--- src/fswitch.h | 16 +++-- src/fterm.h | 10 ++- src/ftextview.h | 14 +++- src/ftogglebutton.h | 15 ++-- src/fwidget.cpp | 14 +++- src/fwidget.h | 15 ++-- src/fwindow.h | 11 ++- test/calculator.cpp | 19 +++-- test/keyboard.cpp | 4 ++ test/mandelbrot.cpp | 8 ++- test/menu.cpp | 18 +++-- test/term-attributes.cpp | 25 +++++-- test/timer.cpp | 4 ++ test/transparent.cpp | 30 +++++--- test/ui.cpp | 44 ++++++++---- test/watch.cpp | 17 +++-- test/windows.cpp | 55 ++++++++++---- 49 files changed, 734 insertions(+), 248 deletions(-) diff --git a/ChangeLog b/ChangeLog index 03c2b909..825703f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2016-09-30 Markus Gans + * Using arrow keys to move or to resize a window + 2016-09-28 Markus Gans * The size is now dynamically changeable with the mouse in a resizable window. diff --git a/src/fapp.cpp b/src/fapp.cpp index 2ee77964..b9e79e01 100644 --- a/src/fapp.cpp +++ b/src/fapp.cpp @@ -22,6 +22,7 @@ FWidget* FApplication::open_menu = 0; // currently open menu FPoint* FApplication::zero_point = 0; // zero point (x=0, y=0) int FApplication::quit_code = 0; bool FApplication::quit_now = false; +bool FApplication::move_size_mode = false; // move/size by keyboard std::deque* FApplication::event_queue = 0; //---------------------------------------------------------------------- @@ -248,10 +249,15 @@ void FApplication::processKeyboardEvent() FWidget* widget = 0; if ( focus_widget ) - widget = static_cast(focus_widget); + { + if ( move_size_mode ) + widget = FWindow::getWindowWidget(focus_widget); + else + widget = focus_widget; + } else { - widget = static_cast(main_widget); + widget = main_widget; if ( widget->numOfChildren() >= 1 ) widget->focusFirstChild(); @@ -436,7 +442,7 @@ void FApplication::processKeyboardEvent() // windows keyboard accelerator if ( ! accpt ) { - FWidget* window = static_cast(active_window); + FWidget* window = active_window; if ( window ) accpt = processAccelerator (window); @@ -773,6 +779,8 @@ bool FApplication::processDialogSwitchAccelerator() if ( s > 0 && s >= n ) { + // unset the move/size mode + setMoveSizeMode(false); FAccelEvent a_ev (fc::Accelerator_Event, focus_widget); sendEvent (dialog_list->at(n-1), &a_ev); return true; @@ -802,6 +810,8 @@ bool FApplication::processAccelerator (FWidget*& widget) if ( iter->key == key ) { + // unset the move/size mode + setMoveSizeMode(false); FAccelEvent a_ev (fc::Accelerator_Event, focus_widget); sendEvent (iter->object, &a_ev); accpt = a_ev.isAccepted(); @@ -1407,6 +1417,9 @@ void FApplication::processMouseEvent() FWidget* child = childWidgetAt (window, *mouse); clicked_widget = (child != 0) ? child : window; } + + // unset the move/size mode + setMoveSizeMode(false); } // close the open menu diff --git a/src/fapp.h b/src/fapp.h index a52acc0e..a4b421ba 100644 --- a/src/fapp.h +++ b/src/fapp.h @@ -109,6 +109,7 @@ class FApplication : public FWidget struct timeval time_keypressed; struct timeval time_mousepressed; FPoint new_mouse_position; + static bool move_size_mode; static FWidget* main_widget; static FWidget* active_window; static FWidget* focus_widget; @@ -116,8 +117,10 @@ class FApplication : public FWidget static FWidget* open_menu; private: - FApplication (const FApplication&); // Disabled copy constructor - FApplication& operator = (const FApplication&); // and operator '=' + // Disable copy constructor + FApplication (const FApplication&); + // Disable assignment operator (=) + FApplication& operator = (const FApplication&); void init(); void setExitMessage (std::string); @@ -149,8 +152,10 @@ class FApplication : public FWidget friend class FWindow; public: - FApplication (int&, char**& ); // constructor - virtual ~FApplication(); // destructor + // Constructor + FApplication (int&, char**& ); + // Destructor + virtual ~FApplication(); const char* getClassName() const; int argc() const; diff --git a/src/fbutton.h b/src/fbutton.h index 004951b8..89f0e6c5 100644 --- a/src/fbutton.h +++ b/src/fbutton.h @@ -49,8 +49,11 @@ class FButton : public FWidget short button_inactive_bg; private: + // Disable copy constructor FButton (const FButton&); + // Disable assignment operator (=) FButton& operator = (const FButton&); + void init(); uChar getHotkey(); void setHotkeyAccelerator(); @@ -61,9 +64,11 @@ class FButton : public FWidget friend class FDialog; public: - explicit FButton (FWidget* = 0); // constructor - FButton (const FString&, FWidget* = 0); // constructor - virtual ~FButton(); // destructor + // Constructors + explicit FButton (FWidget* = 0); + FButton (const FString&, FWidget* = 0); + // Destructor + virtual ~FButton(); const char* getClassName() const; void setForegroundColor (short); @@ -75,6 +80,7 @@ class FButton : public FWidget void setInactiveBackgroundColor (short); void hide(); + // Event handlers void onKeyPress (FKeyEvent*); void onMouseDown (FMouseEvent*); void onMouseUp (FMouseEvent*); @@ -87,7 +93,6 @@ class FButton : public FWidget bool setNoUnderline(bool); bool setNoUnderline(); bool unsetNoUnderline(); - bool setEnable(bool); bool setEnable(); bool unsetEnable(); diff --git a/src/fbuttongroup.h b/src/fbuttongroup.h index 9f380197..0aa389db 100644 --- a/src/fbuttongroup.h +++ b/src/fbuttongroup.h @@ -44,8 +44,11 @@ class FButtonGroup : public FWidget FButtonGroup::FButtonList buttonlist; private: + // Disable copy constructor FButtonGroup (const FButtonGroup&); + // Disable assignment operator (=) FButtonGroup& operator = (const FButtonGroup&); + void init(); bool isRadioButton(FToggleButton*) const; void directFocus(); @@ -57,36 +60,41 @@ class FButtonGroup : public FWidget void drawLabel(); public: - explicit FButtonGroup (FWidget* = 0); // constructor - FButtonGroup (const FString&, FWidget* = 0); // constructor - virtual ~FButtonGroup(); // destructor - const char* getClassName() const; + // Constructors + explicit FButtonGroup (FWidget* = 0); + FButtonGroup (const FString&, FWidget* = 0); + // Destructor + virtual ~FButtonGroup(); - void hide(); + const char* getClassName() const; + void hide(); FToggleButton* getFirstButton(); FToggleButton* getLastButton(); - bool hasFocusedButton(); - bool hasCheckedButton(); - void onMouseDown (FMouseEvent*); - void onAccel (FAccelEvent*); - void onFocusIn (FFocusEvent*); - void onFocusOut (FFocusEvent*); + bool hasFocusedButton(); + bool hasCheckedButton(); - void insert (FToggleButton*); - void remove (FToggleButton*); + // Event handlers + void onMouseDown (FMouseEvent*); + void onAccel (FAccelEvent*); + void onFocusIn (FFocusEvent*); + void onFocusOut (FFocusEvent*); - void cb_buttonToggled (FWidget*, void*); + void insert (FToggleButton*); + void remove (FToggleButton*); - bool setEnable(bool); - bool setEnable(); - bool unsetEnable(); - bool setDisable(); - bool setBorder(bool); - bool setBorder(); - bool unsetBorder(); - void setText (const FString&); - FString& getText(); + // Callback method + void cb_buttonToggled (FWidget*, void*); + + bool setEnable(bool); + bool setEnable(); + bool unsetEnable(); + bool setDisable(); + bool setBorder(bool); + bool setBorder(); + bool unsetBorder(); + void setText (const FString&); + FString& getText(); }; #pragma pack(pop) diff --git a/src/fcheckbox.h b/src/fcheckbox.h index 74642420..98f1cb5c 100644 --- a/src/fcheckbox.h +++ b/src/fcheckbox.h @@ -41,16 +41,22 @@ class FCheckBox : public FToggleButton { private: + // Disable copy constructor FCheckBox (const FCheckBox&); + // Disable assignment operator (=) FCheckBox& operator = (const FCheckBox&); + void init(); void draw(); void drawCheckButton(); public: - explicit FCheckBox (FWidget* = 0); // constructor - FCheckBox (const FString&, FWidget* = 0); // constructor - virtual ~FCheckBox(); // destructor + // Constructors + explicit FCheckBox (FWidget* = 0); + FCheckBox (const FString&, FWidget* = 0); + // Destructor + virtual ~FCheckBox(); + const char* getClassName() const; }; #pragma pack(pop) diff --git a/src/fcheckmenuitem.h b/src/fcheckmenuitem.h index 03d6f5fc..330f2225 100644 --- a/src/fcheckmenuitem.h +++ b/src/fcheckmenuitem.h @@ -41,18 +41,24 @@ class FCheckMenuItem : public FMenuItem { private: + // Disable copy constructor FCheckMenuItem (const FCheckMenuItem&); + // Disable assignment operator (=) FCheckMenuItem& operator = (const FCheckMenuItem&); + void init (FWidget*); void processToggle(); void processClicked(); public: + // Constructor explicit FCheckMenuItem (FWidget* = 0); FCheckMenuItem (FString&, FWidget* = 0); FCheckMenuItem (const std::string&, FWidget* = 0); FCheckMenuItem (const char*, FWidget* = 0); + // Destructor virtual ~FCheckMenuItem(); + const char* getClassName() const; }; #pragma pack(pop) diff --git a/src/fdialog.cpp b/src/fdialog.cpp index 9d8026a2..4c111b86 100644 --- a/src/fdialog.cpp +++ b/src/fdialog.cpp @@ -20,9 +20,10 @@ FDialog::FDialog(FWidget* parent) , zoom_button_active(false) , titlebar_click_pos() , resize_click_pos() - , old_geometry() + , save_geometry() , dialog_menu() , dgl_menuitem() + , move_size_item() , zoom_item() , close_item() { @@ -38,9 +39,10 @@ FDialog::FDialog (const FString& txt, FWidget* parent) , zoom_button_active(false) , titlebar_click_pos() , resize_click_pos() - , old_geometry() + , save_geometry() , dialog_menu() , dgl_menuitem() + , move_size_item() , zoom_item() , close_item() { @@ -133,6 +135,16 @@ void FDialog::init() dgl_menuitem->unsetFocusable(); } + move_size_item = new FMenuItem (dialog_menu); + move_size_item->setText ("&Move/Size"); + move_size_item->setStatusbarMessage ("Move or change the size of the window"); + + move_size_item->addCallback + ( + "clicked", + _METHOD_CALLBACK (this, &FDialog::cb_move) + ); + zoom_item = new FMenuItem (dialog_menu); setZoomItem(); zoom_item->setDisable(); @@ -161,10 +173,10 @@ void FDialog::drawBorder() int y1 = 2; int y2 = 1 + getHeight() - 1; - if ( resize_click_pos.isNull() || isZoomed() ) - setColor(); - else + if ( (getMoveSizeMode() || ! resize_click_pos.isNull()) && ! isZoomed() ) setColor (wc.dialog_resize_fg, getBackgroundColor()); + else + setColor(); if ( isNewFont() ) { @@ -278,7 +290,7 @@ void FDialog::drawTitleBar() else setColor (wc.titlebar_inactive_fg, wc.titlebar_inactive_bg); - if ( (flags & fc::resizeable) == 0 ) + if ( ! isResizeable() ) zoom_btn = 0; else if ( isNewFont() ) zoom_btn = 2; @@ -312,7 +324,7 @@ void FDialog::drawTitleBar() unsetBold(); // draw the zoom/unzoom button - if ( (flags & fc::resizeable) != 0 ) + if ( isResizeable() ) { if ( zoom_button_pressed ) setColor (wc.titlebar_button_focus_fg, wc.titlebar_button_focus_bg); @@ -457,14 +469,35 @@ void FDialog::setZoomItem() { zoom_item->setText ("&Unzoom"); zoom_item->setStatusbarMessage ("Restore the window size"); + move_size_item->setDisable(); } else { zoom_item->setText ("&Zoom"); zoom_item->setStatusbarMessage ("Enlarge the window to the entire desktop"); + move_size_item->setEnable(); } } +#include "fmessagebox.h" +//---------------------------------------------------------------------- +void FDialog::cb_move (FWidget*, void*) +{ + if ( isZoomed() ) + return; + setMoveSizeMode(true); + save_geometry = getGeometry(); + + redraw(); + + // Tooltip + // ┌──────────────────────────┐ + // │ Arrow keys: Move │ + // │Meta + Arrow keys: Resize │ + // │ Enter: Done │ + // │ Esc: Cancel │ + // └──────────────────────────┘ +} //---------------------------------------------------------------------- void FDialog::cb_zoom (FWidget*, void*) @@ -584,7 +617,7 @@ void FDialog::onKeyPress (FKeyEvent* ev) if ( ! isEnabled() ) return; - // cancel resize + // cancel resize by mouse if ( ! resize_click_pos.isNull() ) { resize_click_pos.setPoint (0,0); @@ -601,6 +634,90 @@ void FDialog::onKeyPress (FKeyEvent* ev) selectFirstMenuItem(); } + if ( getMoveSizeMode() ) + { + switch ( ev->key() ) + { + case fc::Fkey_up: + move (getX(), getY() - 1); + redraw(); + ev->accept(); + break; + + case fc::Fkey_down: + move (getX(), getY() + 1); + redraw(); + ev->accept(); + break; + + case fc::Fkey_left: + move (getX() - 1, getY()); + redraw(); + ev->accept(); + break; + + case fc::Fkey_right: + move (getX() + 1, getY()); + redraw(); + ev->accept(); + break; + + case fc::Fmkey_up: + if ( isResizeable() ) + { + setSize (getWidth(), getHeight() - 1); + ev->accept(); + } + break; + + case fc::Fmkey_down: + if ( isResizeable() && getHeight() + getY() <= getMaxHeight() ) + { + setSize (getWidth(), getHeight() + 1); + ev->accept(); + } + break; + + case fc::Fmkey_left: + if ( isResizeable() ) + { + setSize (getWidth() - 1, getHeight()); + ev->accept(); + } + break; + + case fc::Fmkey_right: + if ( isResizeable() && getWidth() + getX() <= getMaxWidth() ) + { + setSize (getWidth() + 1, getHeight()); + ev->accept(); + } + break; + + case fc::Fkey_return: + case fc::Fkey_enter: + setMoveSizeMode(false); + redraw(); + ev->accept(); + break; + + case fc::Fkey_escape: + case fc::Fkey_escape_mintty: + setMoveSizeMode(false); + move (save_geometry.getPos()); + + if ( isResizeable() ) + setSize (save_geometry.getWidth(), save_geometry.getHeight()); + + redraw(); + ev->accept(); + return; + + default: + break; + } + } + if ( this == getMainWidget() ) return; @@ -621,9 +738,9 @@ void FDialog::onMouseDown (FMouseEvent* ev) { int mouse_x = ev->getX(); int mouse_y = ev->getY(); - int zoom_btn; + int zoom_btn;; - if ( (flags & fc::resizeable) == 0 ) + if ( ! isResizeable() ) zoom_btn = 0; else if ( isNewFont() ) zoom_btn = 2; @@ -732,7 +849,7 @@ void FDialog::onMouseUp (FMouseEvent* ev) { int zoom_btn; - if ( (flags & fc::resizeable) == 0 ) + if ( ! isResizeable() ) zoom_btn = 0; else if ( isNewFont() ) zoom_btn = 2; @@ -831,7 +948,7 @@ void FDialog::onMouseMove (FMouseEvent* ev) { int zoom_btn; - if ( (flags & fc::resizeable) == 0 ) + if ( ! isResizeable() ) zoom_btn = 0; else if ( isNewFont() ) zoom_btn = 2; @@ -916,16 +1033,14 @@ void FDialog::onMouseMove (FMouseEvent* ev) void FDialog::onMouseDoubleClick (FMouseEvent* ev) { int x, y, mouse_x, mouse_y, zoom_btn; - bool is_resizeable; if ( ev->getButton() != fc::LeftButton ) return; mouse_x = ev->getX(); mouse_y = ev->getY(); - is_resizeable = bool(flags & fc::resizeable); - if ( ! is_resizeable ) + if ( ! isResizeable() ) zoom_btn = 0; else if ( isNewFont() ) zoom_btn = 2; @@ -957,7 +1072,7 @@ void FDialog::onMouseDoubleClick (FMouseEvent* ev) else close(); } - else if ( is_resizeable + else if ( isResizeable() && mouse_x >= 4 && mouse_x <= getWidth() - zoom_btn && mouse_y == 1 ) @@ -1122,6 +1237,7 @@ void FDialog::move (const FPoint& pos) void FDialog::move (int x, int y) { int dx, dy, old_x, old_y, rsw, bsh, width, height; + FRect old_geometry; if ( getX() == x && getY() == y ) return; @@ -1130,7 +1246,7 @@ void FDialog::move (int x, int y) height = getHeight(); // Avoid to move widget completely outside the terminal - if ( x+width < 1 || x > getColumnNumber() || y < 1 || y > getLineNumber() ) + if ( x+width-1 < 1 || x > getMaxWidth() || y < 1 || y > getMaxHeight() ) return; if ( isZoomed() ) diff --git a/src/fdialog.h b/src/fdialog.h index f5e44c71..755475d9 100644 --- a/src/fdialog.h +++ b/src/fdialog.h @@ -56,15 +56,19 @@ class FDialog : public FWindow bool zoom_button_active; FPoint titlebar_click_pos; FPoint resize_click_pos; - FRect old_geometry; // required by move() + FRect save_geometry; // required by move/size by keyboard FMenu* dialog_menu; FMenuItem* dgl_menuitem; + FMenuItem* move_size_item; FMenuItem* zoom_item; FMenuItem* close_item; private: + // Disable copy constructor FDialog (const FDialog&); + // Disable assignment operator (=) FDialog& operator = (const FDialog&); + void init(); // make every drawBorder from FWidget available using FWidget::drawBorder; @@ -74,8 +78,12 @@ class FDialog : public FWindow void openMenu(); void selectFirstMenuItem(); void setZoomItem(); + + // Callback methods + void cb_move (FWidget*, void*); void cb_zoom (FWidget*, void*); void cb_close (FWidget*, void*); + static void addDialog (FWidget*); static void delDialog (FWidget*); @@ -87,11 +95,15 @@ class FDialog : public FWindow virtual void onClose (FCloseEvent*); public: - explicit FDialog (FWidget* = 0); // constructor - FDialog (const FString&, FWidget* = 0); // constructor - virtual ~FDialog(); // destructor + // Constructors + explicit FDialog (FWidget* = 0); + FDialog (const FString&, FWidget* = 0); + // Destructor + virtual ~FDialog(); + virtual const char* getClassName() const; + // Event handlers void onKeyPress (FKeyEvent*); void onMouseDown (FMouseEvent*); void onMouseUp (FMouseEvent*); @@ -102,6 +114,7 @@ class FDialog : public FWindow void onWindowInactive (FEvent*); void onWindowRaised (FEvent*); void onWindowLowered (FEvent*); + void activateDialog(); void drawDialogShadow(); void show(); diff --git a/src/fdialoglistmenu.h b/src/fdialoglistmenu.h index 4cb97a60..17efb6f0 100644 --- a/src/fdialoglistmenu.h +++ b/src/fdialoglistmenu.h @@ -48,16 +48,22 @@ class FDialogListMenu : public FMenu { private: + // Disable copy constructor FDialogListMenu (const FDialogListMenu&); + // Disable assignment operator (=) FDialogListMenu& operator = (const FDialogListMenu&); + void init(); public: - explicit FDialogListMenu (FWidget* = 0); // constructor + // Constructors + explicit FDialogListMenu (FWidget* = 0); FDialogListMenu (FString&, FWidget* = 0); FDialogListMenu (const std::string&, FWidget* = 0); FDialogListMenu (const char*, FWidget* = 0); - virtual ~FDialogListMenu(); // destructor + // Destructor + virtual ~FDialogListMenu(); + virtual const char* getClassName() const; }; #pragma pack(pop) diff --git a/src/fevent.h b/src/fevent.h index dc7c7a8f..e5f49eda 100644 --- a/src/fevent.h +++ b/src/fevent.h @@ -204,8 +204,10 @@ class FFocusEvent : public FEvent // focus event class FAccelEvent : public FEvent // focus event { private: - FAccelEvent (const FAccelEvent&); // Disabled copy constructor - FAccelEvent& operator = (const FAccelEvent&); // and operator '=' + // Disable copy constructor + FAccelEvent (const FAccelEvent&); + // Disable assignment operator (=) + FAccelEvent& operator = (const FAccelEvent&); public: FAccelEvent (int, void*); diff --git a/src/ffiledialog.h b/src/ffiledialog.h index 3d135ca3..fc42d27e 100644 --- a/src/ffiledialog.h +++ b/src/ffiledialog.h @@ -78,19 +78,20 @@ class FFileDialog : public FDialog Open = 0, Save = 1 }; + private: DIR* directory_stream; std::vector dir_entries; - FString directory; - FString filter_pattern; - FListBox* filebrowser; - FLineEdit* filename; - FCheckBox* hidden; - FButton* cancel; - FButton* open; - DialogType dlg_type; - bool show_hidden; + FString directory; + FString filter_pattern; + FListBox* filebrowser; + FLineEdit* filename; + FCheckBox* hidden; + FButton* cancel; + FButton* open; + DialogType dlg_type; + bool show_hidden; private: void init(); @@ -100,6 +101,8 @@ class FFileDialog : public FDialog int numOfDirs(); int changeDir (const FString&); void printPath (const FString&); + + // Callback methods void cb_processActivate (FWidget*, void*); void cb_processRowChanged (FWidget*, void*); void cb_processClicked (FWidget*, void*); @@ -111,16 +114,22 @@ class FFileDialog : public FDialog void adjustSize(); public: + // Constructors explicit FFileDialog (FWidget* = 0); - FFileDialog (const FFileDialog&); // copy constructor + FFileDialog (const FFileDialog&); // copy constructor FFileDialog ( const FString& , const FString& , DialogType = FFileDialog::Open , FWidget* = 0 ); + // Destructor ~FFileDialog(); - FFileDialog& operator = (const FFileDialog&); // assignment + + // Assignment operator (=) + FFileDialog& operator = (const FFileDialog&); + const char* getClassName() const; + // Event handler void onKeyPress (FKeyEvent*); const FString getPath() const; diff --git a/src/flabel.h b/src/flabel.h index 468302b6..a43c2db5 100644 --- a/src/flabel.h +++ b/src/flabel.h @@ -47,7 +47,9 @@ class FLabel : public FWidget FWidget* accel_widget; private: + // Disable copy constructor FLabel (const FLabel&); + // Disable assignment operator (=) FLabel& operator = (const FLabel&); void init(); @@ -59,15 +61,22 @@ class FLabel : public FWidget void draw(); public: - explicit FLabel (FWidget* = 0); // constructor - FLabel (const FString&, FWidget* = 0); // constructor - virtual ~FLabel(); // destructor - const char* getClassName() const; + // Constructor + explicit FLabel (FWidget* = 0); + FLabel (const FString&, FWidget* = 0); + // Destructor + virtual ~FLabel(); + const char* getClassName() const; void hide(); + + // Event handlers void onMouseDown (FMouseEvent*); void onAccel (FAccelEvent*); + + // Callback method void cb_accel_widget_destroyed (FWidget*, void*); + void setAccelWidget (FWidget* = 0); FTerm* getAccelWidget(); void setAlignment(uInt); diff --git a/src/flineedit.h b/src/flineedit.h index 2daa07ad..123ead66 100644 --- a/src/flineedit.h +++ b/src/flineedit.h @@ -64,8 +64,11 @@ class FLineEdit : public FWidget label_o label_orientation; private: + // Disable copy constructor FLineEdit (const FLineEdit&); + // Disable assignment operator (=) FLineEdit& operator = (const FLineEdit&); + void init(); bool hasHotkey(); void draw(); @@ -78,11 +81,13 @@ class FLineEdit : public FWidget void adjustSize(); public: - explicit FLineEdit (FWidget* = 0); // constructor - FLineEdit (const FString&, FWidget* = 0); // constructor - virtual ~FLineEdit(); // destructor - const char* getClassName() const; + // Constructor + explicit FLineEdit (FWidget* = 0); + FLineEdit (const FString&, FWidget* = 0); + // Destructor + virtual ~FLineEdit(); + const char* getClassName() const; void hide(); bool setEnable(bool); @@ -97,6 +102,7 @@ class FLineEdit : public FWidget bool unsetShadow(); bool hasShadow(); + // Event handlers void onKeyPress (FKeyEvent*); void onMouseDown (FMouseEvent*); void onMouseUp (FMouseEvent*); diff --git a/src/flistbox.h b/src/flistbox.h index 46a58b00..960b1157 100644 --- a/src/flistbox.h +++ b/src/flistbox.h @@ -45,11 +45,14 @@ class FListBoxItem bool selected; public: + // Constructors FListBoxItem (); explicit FListBoxItem (FString&); explicit FListBoxItem (const std::string&); explicit FListBoxItem (const char*); + // Destructor virtual ~FListBoxItem(); + virtual FString getText() const; protected: @@ -120,8 +123,11 @@ class FListBox : public FWidget int max_line_width; private: + // Disable copy constructor FListBox (const FListBox&); + // Disable assignment operator (=) FListBox& operator = (const FListBox&); + void init(); void draw(); void drawLabel(); @@ -135,12 +141,15 @@ class FListBox : public FWidget void adjustSize(); public: - explicit FListBox (FWidget* = 0); // constructor - ~FListBox(); // destructor - const char* getClassName() const; + // Constructor + explicit FListBox (FWidget* = 0); + // Destructor + ~FListBox(); + const char* getClassName() const; void hide(); + // Event handlers void onKeyPress (FKeyEvent*); void onMouseDown (FMouseEvent*); void onMouseUp (FMouseEvent*); @@ -151,18 +160,20 @@ class FListBox : public FWidget void onFocusIn (FFocusEvent*); void onFocusOut (FFocusEvent*); + // Callback methods void cb_VBarChange (FWidget*, void*); void cb_HBarChange (FWidget*, void*); + uInt count() const; - FListBoxItem Item(int) const; + FListBoxItem Item (int) const; int currentItem() const; - void setCurrentItem(int); - void selectItem(int); - void unselectItem(int); - bool isSelected(int) const; - void showInsideBrackets(int, fc::brackets_type); - void showNoBrackets(int); - bool hasBrackets(int) const; + void setCurrentItem (int); + void selectItem (int); + void unselectItem (int); + bool isSelected (int) const; + void showInsideBrackets (int, fc::brackets_type); + void showNoBrackets (int); + bool hasBrackets (int) const; // make every setGeometry from FWidget available using FWidget::setGeometry; void setGeometry (int, int, int, int, bool = true); @@ -171,11 +182,11 @@ class FListBox : public FWidget void setMultiSelection (); void unsetMultiSelection (); bool isMultiSelection() const; - bool setEnable(bool); + bool setEnable (bool); bool setEnable(); bool unsetEnable(); bool setDisable(); - bool setFocus(bool); + bool setFocus (bool); bool setFocus(); bool unsetFocus(); diff --git a/src/fmenu.h b/src/fmenu.h index 1d3b7a42..c521f25d 100644 --- a/src/fmenu.h +++ b/src/fmenu.h @@ -54,8 +54,11 @@ class FMenu : public FWindow, public FMenuList bool has_checkable_items; private: + // Disable copy constructor FMenu (const FMenu&); + // Disable assignment operator (=) FMenu& operator = (const FMenu&); + void init(FWidget*); void calculateDimensions(); void adjustItems(); @@ -89,18 +92,23 @@ class FMenu : public FWindow, public FMenuList void processActivate(); public: - explicit FMenu (FWidget* = 0); // constructor + // Constructor + explicit FMenu (FWidget* = 0); FMenu (FString&, FWidget* = 0); FMenu (const std::string&, FWidget* = 0); FMenu (const char*, FWidget* = 0); - virtual ~FMenu(); // destructor + // Destructor + virtual ~FMenu(); + virtual const char* getClassName() const; + // Event handlers void onKeyPress (FKeyEvent*); void onMouseDown (FMouseEvent*); void onMouseUp (FMouseEvent*); void onMouseMove (FMouseEvent*); void onAccel (FAccelEvent*); + void show(); void hide(); // make every setGeometry from FWidget available @@ -130,6 +138,8 @@ class FMenu : public FWindow, public FMenuList void setText (FString&); void setText (const std::string&); void setText (const char*); + + // Callback method void cb_menuitem_toggled (FWidget*, void*); private: diff --git a/src/fmenubar.h b/src/fmenubar.h index c733d993..0d720db2 100644 --- a/src/fmenubar.h +++ b/src/fmenubar.h @@ -49,8 +49,11 @@ class FMenuBar : public FWindow, public FMenuList bool drop_down; private: + // Disable copy constructor FMenuBar (const FMenuBar&); + // Disable assignment operator (=) FMenuBar& operator = (const FMenuBar&); + void init(); void calculateDimensions(); bool isMenu (FMenuItem*) const; @@ -64,18 +67,25 @@ class FMenuBar : public FWindow, public FMenuList void leaveMenuBar(); public: - explicit FMenuBar (FWidget* = 0); // constructor - virtual ~FMenuBar(); // destructor + // Constructor + explicit FMenuBar (FWidget* = 0); + // Destructor + virtual ~FMenuBar(); + virtual const char* getClassName() const; + // Event handlers void onKeyPress (FKeyEvent*); void onMouseDown (FMouseEvent*); void onMouseUp (FMouseEvent*); void onMouseMove (FMouseEvent*); void onAccel (FAccelEvent*); + void hide(); void resetMenu(); void adjustSize(); + + // Callback methods void cb_item_deactivated (FWidget*, void*); private: diff --git a/src/fmenuitem.h b/src/fmenuitem.h index e9021a86..8db0bc74 100644 --- a/src/fmenuitem.h +++ b/src/fmenuitem.h @@ -58,15 +58,21 @@ class FMenuItem : public FWidget FDialog* associated_window; private: + // Disable copy constructor FMenuItem (const FMenuItem&); + // Disable assignment operator (=) FMenuItem& operator = (const FMenuItem&); + void init (FWidget*); uChar hotKey(); void processActivate(); void processDeactivate(); void createDialogList (FMenu*); + + // Callback methods void cb_switchToDialog (FWidget*, void*); void cb_destroyDialog (FWidget*, void*); + virtual void processClicked(); protected: @@ -77,6 +83,7 @@ class FMenuItem : public FWidget void setSuperMenu (FWidget*); public: + // Constructor explicit FMenuItem (FWidget* = 0); FMenuItem (FString&, FWidget* = 0); FMenuItem (const std::string&, FWidget* = 0); @@ -84,7 +91,9 @@ class FMenuItem : public FWidget FMenuItem (int, FString&, FWidget* = 0); FMenuItem (int, const std::string&, FWidget* = 0); FMenuItem (int, const char*, FWidget* = 0); + // Destructor virtual ~FMenuItem(); + const char* getClassName() const; // make every addAccelerator from FWidget available @@ -93,6 +102,8 @@ class FMenuItem : public FWidget // make every delAccelerator from FWidget available using FWidget::delAccelerator; void delAccelerator (FWidget*); + + // Event handlers void onKeyPress (FKeyEvent*); void onMouseDoubleClick (FMouseEvent*); void onMouseDown (FMouseEvent*); diff --git a/src/fmenulist.h b/src/fmenulist.h index fa7d51d6..901cdb83 100644 --- a/src/fmenulist.h +++ b/src/fmenulist.h @@ -37,29 +37,32 @@ class FMenuList std::vector item_list; private: + // Disable copy constructor FMenuList (const FMenuList&); + // Disable assignment operator (=) FMenuList& operator = (const FMenuList&); public: + // Constructor explicit FMenuList(); + // Destructor virtual ~FMenuList(); + virtual const char* getClassName() const; - - uInt count() const; - FMenuItem* item (int) const; - void enableItem (int); - void disableItem (int); - bool isSelected (int) const; - void selectFirstItem(); - void unselectItem(); - FMenuItem* getSelectedItem() const; - void setSelectedItem (FMenuItem*); - bool hasSelectedItem() const; - - virtual void insert (FMenuItem*); - virtual void remove (FMenuItem*); - void remove (int); - void clear(); + uInt count() const; + FMenuItem* item (int) const; + void enableItem (int); + void disableItem (int); + bool isSelected (int) const; + void selectFirstItem(); + void unselectItem(); + FMenuItem* getSelectedItem() const; + void setSelectedItem (FMenuItem*); + bool hasSelectedItem() const; + virtual void insert (FMenuItem*); + virtual void remove (FMenuItem*); + void remove (int); + void clear(); }; #pragma pack(pop) diff --git a/src/fmessagebox.h b/src/fmessagebox.h index 31bfc2ab..f0b253ba 100644 --- a/src/fmessagebox.h +++ b/src/fmessagebox.h @@ -84,18 +84,24 @@ class FMessageBox : public FDialog virtual void draw(); void resizeButtons(); void adjustButtons(); + + // Callback method void cb_processClick (FWidget*, void*); public: + // Constructors explicit FMessageBox (FWidget* = 0); - FMessageBox (const FMessageBox&); // copy constructor + FMessageBox (const FMessageBox&); // copy constructor FMessageBox ( const FString&, const FString& , int, int, int , FWidget* = 0 ); + // Destructor ~FMessageBox(); - FMessageBox& operator = (const FMessageBox&); // assignment - const char* getClassName() const; + // Assignment operator (=) + FMessageBox& operator = (const FMessageBox&); + + const char* getClassName() const; const FString getTitlebarText() const; void setTitlebarText (const FString&); diff --git a/src/fobject.h b/src/fobject.h index f199c1a0..9c38df4c 100644 --- a/src/fobject.h +++ b/src/fobject.h @@ -69,8 +69,11 @@ class FObject friend class FApplication; public: + // Constructor explicit FObject (FObject* = 0); + // Destructor virtual ~FObject(); + virtual const char* getClassName() const; FObject* getParent() const; @@ -81,18 +84,23 @@ class FObject void addChild (FObject*); void delChild (FObject*); int numOfChildren() const; + // Timer methods static void getCurrentTime (timeval&); int addTimer (int); bool delTimer (int); bool delOwnTimer(); bool delAllTimer(); + // Event handler virtual bool event (FEvent*); protected: + // Event handler virtual void onTimer (FTimerEvent*); private: + // Disable copy constructor FObject (const FObject&); + // Disable assignment operator (=) FObject& operator = (const FObject&); }; diff --git a/src/foptiattr.h b/src/foptiattr.h index bbbe8c6d..46d254d9 100644 --- a/src/foptiattr.h +++ b/src/foptiattr.h @@ -131,8 +131,11 @@ class FOptiAttr char_data off; private: - FOptiAttr (const FOptiAttr&); // Disabled copy constructor - FOptiAttr& operator = (const FOptiAttr&); // and operator '=' + // Disable copy constructor + FOptiAttr (const FOptiAttr&); + // Disable assignment operator (=) + FOptiAttr& operator = (const FOptiAttr&); + bool hasColor (char_data*&); bool colorChange (char_data*&, char_data*&); void resetColor (char_data*&); @@ -183,8 +186,10 @@ class FOptiAttr bool setTermDefaultColor (char_data*&); public: - explicit FOptiAttr(); // constructor - ~FOptiAttr(); // destructor + // Constructor + explicit FOptiAttr(); + // Destructor + ~FOptiAttr(); static short vga2ansi (register short); diff --git a/src/foptimove.h b/src/foptimove.h index 49ea119b..e00891a8 100644 --- a/src/foptimove.h +++ b/src/foptimove.h @@ -85,8 +85,10 @@ class FOptiMove bool isWideMove (int, int, int, int); public: - explicit FOptiMove (int = 0); // constructor - ~FOptiMove(); // destructor + // Constructor + explicit FOptiMove (int = 0); + // Destructor + ~FOptiMove(); void setBaudRate (int); void setTabStop (int); diff --git a/src/fpoint.h b/src/fpoint.h index 533166fa..ec23ce30 100644 --- a/src/fpoint.h +++ b/src/fpoint.h @@ -25,9 +25,12 @@ class FPoint short ypos; public: - FPoint (); // constructor - FPoint (int, int); // constructor - virtual ~FPoint(); // destructor + // Constructors + FPoint (); + FPoint (int, int); + // Destructor + virtual ~FPoint(); + virtual const char* getClassName(); bool isNull() const; diff --git a/src/fprogressbar.h b/src/fprogressbar.h index 5157f410..687bcf57 100644 --- a/src/fprogressbar.h +++ b/src/fprogressbar.h @@ -47,10 +47,12 @@ class FProgressbar : public FWidget virtual void draw(); public: - explicit FProgressbar(FWidget* = 0); // constructor + // Constructor + explicit FProgressbar(FWidget* = 0); + // Destructor virtual ~FProgressbar(); - const char* getClassName() const; + const char* getClassName() const; void hide(); int getPercentage(); diff --git a/src/fradiobutton.h b/src/fradiobutton.h index 357d6746..d3902c54 100644 --- a/src/fradiobutton.h +++ b/src/fradiobutton.h @@ -41,16 +41,22 @@ class FRadioButton : public FToggleButton { private: + // Disable copy constructor FRadioButton (const FRadioButton&); + // Disable assignment operator (=) FRadioButton& operator = (const FRadioButton&); + void init(); void draw(); void drawRadioButton(); public: - explicit FRadioButton (FWidget* = 0); // constructor - FRadioButton (const FString&, FWidget* = 0); // constructor - virtual ~FRadioButton(); // destructor + // Constructors + explicit FRadioButton (FWidget* = 0); + FRadioButton (const FString&, FWidget* = 0); + // Destructor + virtual ~FRadioButton(); + const char* getClassName() const; }; #pragma pack(pop) diff --git a/src/fradiomenuitem.h b/src/fradiomenuitem.h index 9ec03f42..2ea069ec 100644 --- a/src/fradiomenuitem.h +++ b/src/fradiomenuitem.h @@ -41,18 +41,24 @@ class FRadioMenuItem : public FMenuItem { private: + // Disable copy constructor FRadioMenuItem (const FRadioMenuItem&); + // Disable assignment operator (=) FRadioMenuItem& operator = (const FRadioMenuItem&); + void init (FWidget*); void processToggle(); void processClicked(); public: + // Constructor explicit FRadioMenuItem (FWidget* = 0); FRadioMenuItem (FString&, FWidget* = 0); FRadioMenuItem (const std::string&, FWidget* = 0); FRadioMenuItem (const char*, FWidget* = 0); + // Destructor virtual ~FRadioMenuItem(); + const char* getClassName() const; }; #pragma pack(pop) diff --git a/src/frect.h b/src/frect.h index d2eda96b..e1e72f9b 100644 --- a/src/frect.h +++ b/src/frect.h @@ -31,10 +31,13 @@ class FRect short Y2; public: - FRect (); // constructor - FRect (int, int, int, int); // constructor - FRect (const FPoint&, const FPoint&); // constructor - virtual ~FRect(); // destructor + // Constructors + FRect (); + FRect (int, int, int, int); + FRect (const FPoint&, const FPoint&); + // Destructor + virtual ~FRect(); + virtual const char* getClassName(); bool isNull() const; diff --git a/src/fscrollbar.h b/src/fscrollbar.h index f148b1a6..c6677458 100644 --- a/src/fscrollbar.h +++ b/src/fscrollbar.h @@ -69,7 +69,9 @@ class FScrollbar : public FWidget int max_color; private: + // Disable copy constructor FScrollbar (const FScrollbar&); + // Disable assignment operator (=) FScrollbar& operator = (const FScrollbar&); void init(); @@ -79,11 +81,15 @@ class FScrollbar : public FWidget void processScroll(); public: - explicit FScrollbar(FWidget* = 0); // constructor - FScrollbar (int = fc::vertical, FWidget* = 0); // constructor + // Constructors + explicit FScrollbar(FWidget* = 0); + FScrollbar (int = fc::vertical, FWidget* = 0); + // Destructor virtual ~FScrollbar(); + const char* getClassName() const; + // Event handlers void onMouseDown (FMouseEvent*); void onMouseUp (FMouseEvent*); void onMouseMove (FMouseEvent*); diff --git a/src/fstatusbar.cpp b/src/fstatusbar.cpp index c66a230e..823a6920 100644 --- a/src/fstatusbar.cpp +++ b/src/fstatusbar.cpp @@ -358,6 +358,30 @@ void FStatusBar::drawKeys() // public methods of FStatusBar //---------------------------------------------------------------------- +void FStatusBar::hide() +{ + int screenWidth; + short fg, bg; + char* blank; + + FWindow::hide(); + fg = wc.term_fg; + bg = wc.term_bg; + setColor (fg, bg); + screenWidth = getColumnNumber(); + + if ( screenWidth < 0 ) + return; + + blank = new char[screenWidth+1]; + memset(blank, ' ', uLong(screenWidth)); + blank[screenWidth] = '\0'; + printPos (1, 1); + print (vstatusbar, blank); + delete[] blank; +} +//---------------------------------------------------------------------- + void FStatusBar::onMouseDown (FMouseEvent* ev) { if ( hasActivatedKey() ) @@ -527,30 +551,6 @@ void FStatusBar::onMouseMove (FMouseEvent* ev) } } -//---------------------------------------------------------------------- -void FStatusBar::hide() -{ - int screenWidth; - short fg, bg; - char* blank; - - FWindow::hide(); - fg = wc.term_fg; - bg = wc.term_bg; - setColor (fg, bg); - screenWidth = getColumnNumber(); - - if ( screenWidth < 0 ) - return; - - blank = new char[screenWidth+1]; - memset(blank, ' ', uLong(screenWidth)); - blank[screenWidth] = '\0'; - printPos (1, 1); - print (vstatusbar, blank); - delete[] blank; -} - //---------------------------------------------------------------------- bool FStatusBar::hasActivatedKey() { diff --git a/src/fstatusbar.h b/src/fstatusbar.h index 3d63ca34..22fbf065 100644 --- a/src/fstatusbar.h +++ b/src/fstatusbar.h @@ -53,21 +53,28 @@ class FStatusKey : public FWidget FStatusBar* bar; private: + // Disable copy constructor FStatusKey (const FStatusKey&); + // Disable assignment operator (=) FStatusKey& operator = (const FStatusKey&); + void init (FWidget*); void processActivate(); FStatusBar* statusbar() const; void setStatusbar (FStatusBar*); public: + // Constructors explicit FStatusKey (FWidget* = 0); FStatusKey (int, FString&, FWidget* = 0); FStatusKey (int, const std::string&, FWidget* = 0); FStatusKey (int, const char*, FWidget* = 0); + // Destructor virtual ~FStatusKey(); + // Event handler void onAccel (FAccelEvent*); + void setActive(); void unsetActive(); bool isActivated() const; @@ -153,21 +160,28 @@ class FStatusBar : public FWindow int x_msg; private: + // Disable copy constructor FStatusBar (const FStatusBar&); + // Disable assignment operator (=) FStatusBar& operator = (const FStatusBar&); + void init(); void draw(); void drawKeys(); public: - explicit FStatusBar (FWidget* = 0); // constructor - virtual ~FStatusBar(); // destructor - virtual const char* getClassName() const; + // Constructor + explicit FStatusBar (FWidget* = 0); + // Destructor + virtual ~FStatusBar(); + virtual const char* getClassName() const; + void hide(); + + // Event handlers void onMouseDown (FMouseEvent*); void onMouseUp (FMouseEvent*); void onMouseMove (FMouseEvent*); - void hide(); uInt count() const; FStatusKey* key (int) const; @@ -189,6 +203,8 @@ class FStatusBar : public FWindow void clear(); void adjustSize(); + + // Callback method void cb_statuskey_activated (FWidget*, void*); }; #pragma pack(pop) diff --git a/src/fstring.h b/src/fstring.h index 02f611f4..5c45c6e1 100644 --- a/src/fstring.h +++ b/src/fstring.h @@ -82,13 +82,14 @@ class FString wchar_t* extractToken (wchar_t**, const wchar_t*, const wchar_t*); public: - FString (); // constructor - explicit FString (int); // constructor - explicit FString (uInt); // constructor - FString (int, wchar_t); // constructor - FString (uInt, wchar_t); // constructor - FString (int, char); // constructor - FString (uInt, char); // constructor + // Constructors + FString (); + explicit FString (int); + explicit FString (uInt); + FString (int, wchar_t); + FString (uInt, wchar_t); + FString (int, char); + FString (uInt, char); FString (const FString&); // implicit conversion constructor FString (const std::wstring&); // implicit conversion constructor FString (const wchar_t*); // implicit conversion constructor @@ -96,7 +97,8 @@ class FString FString (const char*); // implicit conversion constructor FString (const wchar_t); // implicit conversion constructor FString (const char); // implicit conversion constructor - virtual ~FString (); // destructor + // Destructor + virtual ~FString (); bool isNull() const; bool isEmpty() const; diff --git a/src/fswitch.h b/src/fswitch.h index 48cf64b1..4fc3f8e1 100644 --- a/src/fswitch.h +++ b/src/fswitch.h @@ -45,20 +45,28 @@ class FSwitch : public FToggleButton bool button_pressed; private: + // Disable copy constructor FSwitch (const FSwitch&); + // Disable assignment operator (=) FSwitch& operator = (const FSwitch&); + void draw(); void drawCheckButton(); public: - explicit FSwitch (FWidget* = 0); // constructor - FSwitch (const FString&, FWidget* = 0); // constructor - virtual ~FSwitch(); // destructor + // Constructors + explicit FSwitch (FWidget* = 0); + FSwitch (const FString&, FWidget* = 0); + // Destructor + virtual ~FSwitch(); + const char* getClassName() const; + void setText (FString); + + // Event handlers void onKeyPress (FKeyEvent*); void onMouseDown (FMouseEvent*); void onMouseUp (FMouseEvent*); - void setText (FString); }; #pragma pack(pop) diff --git a/src/fterm.h b/src/fterm.h index 498c8efd..bd3a46a7 100644 --- a/src/fterm.h +++ b/src/fterm.h @@ -164,7 +164,7 @@ class FTerm static bool resize_term; static char exit_message[8192]; - static struct termios term_init; + static struct termios term_init; static FOptiAttr::char_data term_attribute; static FOptiAttr::char_data next_attribute; @@ -248,7 +248,9 @@ class FTerm term_area* vwin; // virtual window private: + // Disable copy constructor FTerm (const FTerm&); + // Disable assignment operator (=) FTerm& operator = (const FTerm&); static void outb_Attribute_Controller (int, int); @@ -309,8 +311,10 @@ class FTerm FOptiAttr::char_data getOverlappedCharacter (int, int, FTerm*); public: - FTerm (); // constructor - virtual ~FTerm(); // destructor + // Constructor + FTerm (); + // Destructor + virtual ~FTerm(); virtual const char* getClassName() const; FTerm::term_area* getVWin() const; diff --git a/src/ftextview.h b/src/ftextview.h index 8be465e1..c75b9f8d 100644 --- a/src/ftextview.h +++ b/src/ftextview.h @@ -50,13 +50,17 @@ class FTextView : public FWidget uInt maxLineWidth; private: + // Disable copy constructor FTextView (const FTextView&); + // Disable assignment operator (=) FTextView& operator = (const FTextView&); void init(); void draw(); void drawText(); void processChanged(); + + // Callback methods void cb_VBarChange (FWidget*, void*); void cb_HBarChange (FWidget*, void*); @@ -64,12 +68,15 @@ class FTextView : public FWidget void adjustSize(); public: - explicit FTextView (FWidget* = 0); // constructor - ~FTextView(); // destructor - const char* getClassName() const; + // Constructor + explicit FTextView (FWidget* = 0); + // Destructor + ~FTextView(); + const char* getClassName() const; void hide(); + // Event handlers void onKeyPress (FKeyEvent*); void onMouseDown (FMouseEvent*); void onMouseUp (FMouseEvent*); @@ -77,6 +84,7 @@ class FTextView : public FWidget void onWheel (FWheelEvent*); void onFocusIn (FFocusEvent*); void onFocusOut (FFocusEvent*); + // make every setGeometry from FWidget available using FWidget::setGeometry; void setGeometry (int, int, int, int, bool = true); diff --git a/src/ftogglebutton.h b/src/ftogglebutton.h index aef8421f..457535b0 100644 --- a/src/ftogglebutton.h +++ b/src/ftogglebutton.h @@ -48,8 +48,11 @@ class FToggleButton : public FWidget FButtonGroup* button_group; private: + // Disable copy constructor FToggleButton (const FToggleButton&); + // Disable assignment operator (=) FToggleButton& operator = (const FToggleButton&); + void init(); friend class FButtonGroup; void setGroup (FButtonGroup*); @@ -67,16 +70,19 @@ class FToggleButton : public FWidget virtual void onKeyPress (FKeyEvent*); public: - explicit FToggleButton (FWidget* = 0); // constructor - FToggleButton (const FString&, FWidget* = 0); // constructor - virtual ~FToggleButton(); // destructor - virtual const char* getClassName() const; + // Constructors + explicit FToggleButton (FWidget* = 0); + FToggleButton (const FString&, FWidget* = 0); + // Destructor + virtual ~FToggleButton(); + virtual const char* getClassName() const; void hide(); // make every setGeometry from FWidget available using FWidget::setGeometry; void setGeometry (int, int, int, int, bool = true); + // Event handlers void onMouseDown (FMouseEvent*); void onMouseUp (FMouseEvent*); void onAccel (FAccelEvent*); @@ -87,7 +93,6 @@ class FToggleButton : public FWidget bool setNoUnderline (bool); bool setNoUnderline(); bool unsetNoUnderline(); - bool setEnable (bool); bool setEnable(); bool unsetEnable(); diff --git a/src/fwidget.cpp b/src/fwidget.cpp index a80ea366..a833d9d1 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -967,6 +967,18 @@ void FWidget::setOpenMenu(FWidget* obj) FApplication::open_menu = obj; } +//---------------------------------------------------------------------- +bool FWidget::getMoveSizeMode() +{ + return FApplication::move_size_mode; +} + +//---------------------------------------------------------------------- +void FWidget::setMoveSizeMode (bool on) +{ + FApplication::move_size_mode = on; +} + //---------------------------------------------------------------------- int FWidget::numOfFocusableChildren() { @@ -1918,7 +1930,7 @@ void FWidget::move (int x, int y) return; // Avoid to move widget completely outside the terminal - if ( x+getWidth() < 1 || x > term->getWidth() || y < 1 || y > term->getHeight() ) + if ( x+getWidth()-1 < 1 || x > getMaxWidth() || y < 1 || y > getMaxHeight() ) return; wsize.setPos(x,y); diff --git a/src/fwidget.h b/src/fwidget.h index ebe5ab92..16810b2f 100644 --- a/src/fwidget.h +++ b/src/fwidget.h @@ -311,8 +311,11 @@ class FWidget : public FObject, public FTerm friend class FToggleButton; private: + // Disable copy constructor FWidget (const FWidget&); + // Disable assignment operator (=) FWidget& operator = (const FWidget&); + void init(); void finish(); void processDestroy(); @@ -326,7 +329,7 @@ class FWidget : public FObject, public FTerm void adjustSizeGlobal(); virtual void setStatusBar (FStatusBar*); virtual void setMenuBar (FMenuBar*); - // Event handlers + // Event handlers bool event (FEvent*); virtual void onKeyPress (FKeyEvent*); virtual void onKeyUp (FKeyEvent*); @@ -343,13 +346,15 @@ class FWidget : public FObject, public FTerm virtual void onShow (FShowEvent*); virtual void onHide (FHideEvent*); virtual void onClose (FCloseEvent*); - // Change child focus + // Change child focus virtual bool focusNextChild(); virtual bool focusPrevChild(); public: - explicit FWidget (FWidget* = 0); // constructor - ~FWidget(); // destructor + // Constructor + explicit FWidget (FWidget* = 0); + // Destructor + ~FWidget(); const char* getClassName() const; FWidget* getRootWidget() const; @@ -363,6 +368,8 @@ class FWidget : public FObject, public FTerm static void setClickedWidget(FWidget*); static FWidget* getOpenMenu(); static void setOpenMenu(FWidget*); + static bool getMoveSizeMode(); + static void setMoveSizeMode (bool); int numOfFocusableChildren(); FWidget* getParentWidget() const; bool isRootWidget() const; diff --git a/src/fwindow.h b/src/fwindow.h index 9aadab04..6e3000a5 100644 --- a/src/fwindow.h +++ b/src/fwindow.h @@ -53,21 +53,26 @@ class FWindow : public FWidget static FWindow* previous_widget; private: + // Disable copy constructor FWindow (const FWindow&); + // Disable assignment operator (=) FWindow& operator = (const FWindow&); protected: - // Event handlers + // Event handlers bool event (FEvent*); virtual void onWindowActive (FEvent*); virtual void onWindowInactive (FEvent*); virtual void onWindowRaised (FEvent*); virtual void onWindowLowered (FEvent*); + virtual void adjustSize(); public: - explicit FWindow (FWidget* = 0); // constructor - ~FWindow (); // destructor + // Constructor + explicit FWindow (FWidget* = 0); + // Destructor + ~FWindow (); const char* getClassName() const; virtual void show(); diff --git a/test/calculator.cpp b/test/calculator.cpp index 4fdfb88c..83809654 100644 --- a/test/calculator.cpp +++ b/test/calculator.cpp @@ -25,11 +25,16 @@ const lDouble PI = 3.141592653589793238L; class Button : public FButton { -private: + private: bool checked; + public: - explicit Button (FWidget* = 0); // constructor + // Constructor + explicit Button (FWidget* = 0); + void setChecked(bool); + + // Event handler void onKeyPress (FKeyEvent*); }; #pragma pack(pop) @@ -159,11 +164,17 @@ class Calc : public FDialog void adjustSize(); public: - explicit Calc (FWidget* parent=0); // constructor - ~Calc(); // destructor + // Constructor + explicit Calc (FWidget* parent=0); + // Destructor + ~Calc(); + + // Event handlers void onKeyPress (FKeyEvent*); void onAccel (FAccelEvent*); void onClose (FCloseEvent*); + + // Callback method void cb_buttonClicked (FWidget*, void*); }; #pragma pack(pop) diff --git a/test/keyboard.cpp b/test/keyboard.cpp index ce0c5643..121e0bba 100644 --- a/test/keyboard.cpp +++ b/test/keyboard.cpp @@ -9,10 +9,14 @@ class keyboard : public FWidget { public: + // Constructor explicit keyboard (FWidget* = 0); + protected: + // Event handlers void onKeyPress (FKeyEvent*); void onAccel (FAccelEvent*); + void draw(); }; diff --git a/test/mandelbrot.cpp b/test/mandelbrot.cpp index d3aafb27..f5eb6b3a 100644 --- a/test/mandelbrot.cpp +++ b/test/mandelbrot.cpp @@ -18,8 +18,12 @@ class Mandelbrot : public FDialog void adjustSize(); public: - explicit Mandelbrot (FWidget* = 0); // constructor - ~Mandelbrot(); // destructor + // Constructor + explicit Mandelbrot (FWidget* = 0); + // Destructor + ~Mandelbrot(); + + // Callback methods void onAccel (FAccelEvent*); void onClose (FCloseEvent*); }; diff --git a/test/menu.cpp b/test/menu.cpp index 939732fa..a79ca322 100644 --- a/test/menu.cpp +++ b/test/menu.cpp @@ -21,17 +21,27 @@ class Menu : public FDialog { private: - Menu (const Menu&); // Disabled copy constructor - Menu& operator = (const Menu&); // and operator '=' + // Disable copy constructor + Menu (const Menu&); + // Disable assignment operator (=) + Menu& operator = (const Menu&); + void defaultCallback (FMenuList*); + + // Event handler void onClose (FCloseEvent*); + + // Callback methods void cb_message (FWidget*, void*); void cb_exitApp (FWidget*, void*); + void adjustSize(); public: - explicit Menu (FWidget* = 0); // constructor - ~Menu(); // destructor + // Constructor + explicit Menu (FWidget* = 0); + // Destructor + ~Menu(); }; #pragma pack(pop) diff --git a/test/term-attributes.cpp b/test/term-attributes.cpp index c11d0202..6e5dfa1b 100644 --- a/test/term-attributes.cpp +++ b/test/term-attributes.cpp @@ -22,16 +22,25 @@ class AttribDlg : public FDialog short bgcolor; private: - AttribDlg (const AttribDlg&); // Disabled copy constructor - AttribDlg& operator = (const AttribDlg&); // and operator '=' + // Disable copy constructor + AttribDlg (const AttribDlg&); + // Disable assignment operator (=) + AttribDlg& operator = (const AttribDlg&); + void adjustSize(); public: - explicit AttribDlg (FWidget* = 0); // constructor - ~AttribDlg(); // destructor + // Constructor + explicit AttribDlg (FWidget* = 0); + // Destructor + ~AttribDlg(); + + // Event handlers void onAccel (FAccelEvent*); void onWheel (FWheelEvent*); void onClose (FCloseEvent*); + + // Callback methods void cb_next (FWidget* = 0, void* = 0); void cb_back (FWidget* = 0, void* = 0); }; @@ -173,9 +182,13 @@ class AttribDemo : public FWidget void draw(); public: - explicit AttribDemo (FWidget* = 0); // constructor - ~AttribDemo() // destructor + // Constructor + explicit AttribDemo (FWidget* = 0); + // Destructor + ~AttribDemo() { } + + // Event handler void onWheel (FWheelEvent* ev) { AttribDlg* p = dynamic_cast(getParentWidget()); diff --git a/test/timer.cpp b/test/timer.cpp index 80bad1e5..e957b116 100644 --- a/test/timer.cpp +++ b/test/timer.cpp @@ -9,10 +9,14 @@ class timer : public FWidget { public: + // Constructor explicit timer (FWidget* = 0); + protected: + // Event handlers void onTimer (FTimerEvent*); void onAccel (FAccelEvent*); + void draw(); }; diff --git a/test/transparent.cpp b/test/transparent.cpp index d58d5f58..7c3a1c53 100644 --- a/test/transparent.cpp +++ b/test/transparent.cpp @@ -29,14 +29,21 @@ class Transparent : public FDialog trans_type type; private: - Transparent (const Transparent&); // Disabled copy constructor - Transparent& operator = (const Transparent&); // and operator '=' + // Disable copy constructor + Transparent (const Transparent&); + // Disable assignment operator (=) + Transparent& operator = (const Transparent&); + void draw(); + + // Event handlers void onKeyPress (FKeyEvent* ev); public: - explicit Transparent (FWidget* = 0, trans_type = transparent); // constructor - ~Transparent(); // destructor + // Constructor + explicit Transparent (FWidget* = 0, trans_type = transparent); + // Destructor + ~Transparent(); }; #pragma pack(pop) @@ -122,9 +129,14 @@ class MainWindow : public FDialog FString line2; private: - MainWindow (const MainWindow&); // Disabled copy constructor - MainWindow& operator = (const MainWindow&); // and operator '=' + // Disable copy constructor + MainWindow (const MainWindow&); + // Disable assignment operator (=) + MainWindow& operator = (const MainWindow&); + void draw(); + + // Event handlers void onClose (FCloseEvent*); void onShow (FShowEvent*); void onTimer (FTimerEvent*); @@ -138,8 +150,10 @@ class MainWindow : public FDialog } public: - explicit MainWindow (FWidget* = 0); // constructor - ~MainWindow(); // destructor + // Constructor + explicit MainWindow (FWidget* = 0); + // Destructor + ~MainWindow(); }; #pragma pack(pop) diff --git a/test/ui.cpp b/test/ui.cpp index a04f8da6..6650dca0 100644 --- a/test/ui.cpp +++ b/test/ui.cpp @@ -22,18 +22,25 @@ class ProgressDialog : public FDialog FButton* quit; private: - ProgressDialog (const ProgressDialog&); // Disabled copy constructor - ProgressDialog& operator = (const ProgressDialog&); // and operator '=' + // Disable copy constructor + ProgressDialog (const ProgressDialog&); + // Disable assignment operator (=) + ProgressDialog& operator = (const ProgressDialog&); + // Event handlers void onShow (FShowEvent*); void onTimer (FTimerEvent*); + + // Callback methods void cb_reset_bar (FWidget*, void*); void cb_more_bar (FWidget*, void*); void cb_exit_bar (FWidget*, void*); public: - explicit ProgressDialog (FWidget* = 0); // constructor - ~ProgressDialog(); // destructor + // Constructor + explicit ProgressDialog (FWidget* = 0); + // Destructor + ~ProgressDialog(); }; #pragma pack(pop) @@ -167,13 +174,18 @@ class TextWindow : public FDialog FTextView* scrollText; private: - TextWindow (const TextWindow&); // Disabled copy constructor - TextWindow& operator = (const TextWindow&); // and operator '=' + // Disable copy constructor + TextWindow (const TextWindow&); + // Disable assignment operator (=) + TextWindow& operator = (const TextWindow&); + void adjustSize(); public: - explicit TextWindow (FWidget* = 0); // constructor - ~TextWindow(); // destructor + // Constructor + explicit TextWindow (FWidget* = 0); + // Destructor + ~TextWindow(); void append (const FString&); }; @@ -232,10 +244,15 @@ class MyDialog : public FDialog FString clipboard; private: - MyDialog (const MyDialog&); // Disabled copy constructor - MyDialog& operator = (const MyDialog&); // and operator '=' + // Disable copy constructor + MyDialog (const MyDialog&); + // Disable assignment operator (=) + MyDialog& operator = (const MyDialog&); + // Event handlers void onClose (FCloseEvent*); + + // Callback methods void cb_noFunctionMsg (FWidget*, void*); void cb_about (FWidget*, void*); void cb_terminfo (FWidget*, void*); @@ -252,11 +269,14 @@ class MyDialog : public FDialog void cb_view (FWidget*, void*); void cb_setInput (FWidget*, void*); void cb_exitApp (FWidget*, void*); + void adjustSize(); public: - explicit MyDialog (FWidget* = 0); // constructor - ~MyDialog(); // destructor + // Constructor + explicit MyDialog (FWidget* = 0); + // Destructor + ~MyDialog(); }; #pragma pack(pop) diff --git a/test/watch.cpp b/test/watch.cpp index 1cfa3eac..137c8527 100644 --- a/test/watch.cpp +++ b/test/watch.cpp @@ -27,15 +27,24 @@ class watch : public FDialog FSwitch* seconds_sw; private: - watch (const watch&); // Disabled copy constructor - watch& operator = (const watch&); // and operator '=' + // Disable copy constructor + watch (const watch&); + // Disable assignment operator (=) + watch& operator = (const watch&); public: - explicit watch (FWidget* = 0); // constructor - ~watch(); // destructor + // Constructor + explicit watch (FWidget* = 0); + // Destructor + ~watch(); + void printTime(); + + // Event handlers void onTimer (FTimerEvent*); void onClose (FCloseEvent*); + + // Callback methods void cb_clock (FWidget*, void*); void cb_seconds (FWidget*, void*); void cb_exitApp (FWidget*, void*); diff --git a/test/windows.cpp b/test/windows.cpp index 59da029f..dd2db845 100644 --- a/test/windows.cpp +++ b/test/windows.cpp @@ -27,15 +27,22 @@ class smallWindow : public FDialog FLabel* bottom_label; private: - smallWindow (const smallWindow&); // Disabled copy constructor - smallWindow& operator = (const smallWindow&); // and operator '=' + // Disable copy constructor + smallWindow (const smallWindow&); + // Disable assignment operator (=) + smallWindow& operator = (const smallWindow&); + void adjustSize(); + + // Event handlers void onShow (FShowEvent*); void onTimer (FTimerEvent*); public: - explicit smallWindow (FWidget* = 0); // constructor - ~smallWindow(); // destructor + // Constructor + explicit smallWindow (FWidget* = 0); + // Destructor + ~smallWindow(); void append (const FString&); }; @@ -50,13 +57,26 @@ smallWindow::smallWindow (FWidget* parent) , top_right_label() , bottom_label() { - left_arrow = new FLabel ("\u25b2", this); + wchar_t arrow_up, arrow_down; + + if ( isCygwinTerminal() ) + { + arrow_up = L'^'; + arrow_down = L'v'; + } + else + { + arrow_up = fc::BlackUpPointingTriangle; + arrow_down = fc::BlackDownPointingTriangle; + } + + left_arrow = new FLabel (arrow_up, this); left_arrow->setForegroundColor (wc.label_inactive_fg); left_arrow->setEmphasis(); left_arrow->ignorePadding(); left_arrow->setGeometry (2, 2, 1, 1); - right_arrow = new FLabel ("\u25b2", this); + right_arrow = new FLabel (arrow_up, this); right_arrow->setForegroundColor (wc.label_inactive_fg); right_arrow->setEmphasis(); right_arrow->ignorePadding(); @@ -76,8 +96,8 @@ smallWindow::smallWindow (FWidget* parent) top_right_label->setGeometry (getClientWidth() - 5, 1, 6, 1); FString bottom_label_text = "resize\n" - "corner\n" - "\u25bc"; + "corner\n"; + bottom_label_text += arrow_down; bottom_label = new FLabel (bottom_label_text, this); bottom_label->setAlignment (fc::alignRight); bottom_label->setForegroundColor (wc.label_inactive_fg); @@ -155,21 +175,31 @@ class Window : public FDialog std::vector windows; private: - Window (const Window&); // Disabled copy constructor - Window& operator = (const Window&); // and operator '=' + // Disable copy constructor + Window (const Window&); + // Disable assignment operator (=) + Window& operator = (const Window&); + void activateWindow (FDialog*); + + // Event handlers void onClose (FCloseEvent*); + + // Callback methods void cb_createWindows (FWidget*, void*); void cb_closeWindows (FWidget*, void*); void cb_next (FWidget*, void*); void cb_previous (FWidget*, void*); void cb_exitApp (FWidget*, void*); void cb_destroyWindow (FWidget*, void*); + void adjustSize(); public: - explicit Window (FWidget* = 0); // constructor - ~Window(); // destructor + // Constructor + explicit Window (FWidget* = 0); + // Destructor + ~Window(); }; #pragma pack(pop) @@ -489,6 +519,7 @@ void Window::cb_exitApp (FWidget*, void*) void Window::cb_destroyWindow (FWidget*, void* data_ptr) { win_data* win_dat = static_cast(data_ptr); + if ( win_dat ) win_dat->is_open = false; }