diff --git a/ChangeLog b/ChangeLog index 34cacf92..2b5c3e6d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2015-10-17 Markus Gans + * More faster header inline code + 2015-10-16 Markus Gans * Fixed: calculator behavior for negative values in trigonometric functions diff --git a/src/fapp.cpp b/src/fapp.cpp index 2a00e96b..b5328471 100644 --- a/src/fapp.cpp +++ b/src/fapp.cpp @@ -148,7 +148,7 @@ void FApplication::cmd_options () //---------------------------------------------------------------------- #ifdef F_HAVE_LIBGPM -inline int FApplication::gpmEvent(bool clear) +int FApplication::gpmEvent (bool clear) { register int result; register int max = (gpm_fd > stdin_no) ? gpm_fd : stdin_no; @@ -948,13 +948,10 @@ void FApplication::processMouseEvent() || b_state.wheel_up == Pressed || b_state.wheel_down == Pressed ) ) { - FWidget* window = FWindow::windowWidgetAt ( mouse->getX() - , mouse->getY() ); + FWidget* window = FWindow::windowWidgetAt (*mouse); if ( window ) { - FWidget* child = childWidgetAt ( window - , mouse->getX() - , mouse->getY() ); + FWidget* child = childWidgetAt (window, *mouse); clicked_widget = (child != 0) ? child : window; } } diff --git a/src/fapp.h b/src/fapp.h index 2e57d5d3..10107899 100644 --- a/src/fapp.h +++ b/src/fapp.h @@ -129,7 +129,7 @@ class FApplication : public FWidget bool parseUrxvtMouse(); #ifdef F_HAVE_LIBGPM - int gpmEvent(bool = true); + int gpmEvent (bool = true); bool processGpmEvent(); #endif diff --git a/src/fbutton.cpp b/src/fbutton.cpp index fc28e852..90bb360d 100644 --- a/src/fbutton.cpp +++ b/src/fbutton.cpp @@ -146,9 +146,9 @@ void FButton::draw() space = int(' '); if ( isMonochron() || getMaxColor() < 16 ) - ButtonText = new wchar_t[length+3]; + ButtonText = new wchar_t[length+3](); else - ButtonText = new wchar_t[length+1]; + ButtonText = new wchar_t[length+1](); txt = text; src = const_cast(txt.wc_str()); diff --git a/src/fbuttongroup.cpp b/src/fbuttongroup.cpp index a76e7193..c61caa3a 100644 --- a/src/fbuttongroup.cpp +++ b/src/fbuttongroup.cpp @@ -208,7 +208,7 @@ void FButtonGroup::drawLabel() txt = " " + text + " "; length = txt.getLength(); hotkeypos = -1; - LabelText = new wchar_t[length+1]; + LabelText = new wchar_t[length+1](); src = const_cast(txt.wc_str()); dest = const_cast(LabelText); diff --git a/src/fdialog.cpp b/src/fdialog.cpp index 45560471..886df726 100644 --- a/src/fdialog.cpp +++ b/src/fdialog.cpp @@ -123,7 +123,7 @@ void FDialog::init() setFocus(); old_focus->redraw(); } - accelerator_list = new Accelerators; + accelerator_list = new Accelerators(); } //---------------------------------------------------------------------- diff --git a/src/flabel.cpp b/src/flabel.cpp index a7411938..104b72e2 100644 --- a/src/flabel.cpp +++ b/src/flabel.cpp @@ -255,7 +255,7 @@ void FLabel::draw() while ( y < text_lines && y < uInt(height) ) { length = multiline_text[y].getLength(); - LabelText = new wchar_t[length+1]; + LabelText = new wchar_t[length+1](); src = const_cast(multiline_text[y].wc_str()); dest = const_cast(LabelText); @@ -285,7 +285,7 @@ void FLabel::draw() else { length = text.getLength(); - LabelText = new wchar_t[length+1]; + LabelText = new wchar_t[length+1](); src = const_cast(text.wc_str()); dest = const_cast(LabelText); diff --git a/src/fmenu.cpp b/src/fmenu.cpp index 6ee8b319..774009c0 100644 --- a/src/fmenu.cpp +++ b/src/fmenu.cpp @@ -324,7 +324,7 @@ void FMenu::drawItems() txt = (*iter)->getText(); txt_length = uInt(txt.getLength()); - item_text = new wchar_t[txt_length+1]; + item_text = new wchar_t[txt_length+1](); src = const_cast(txt.wc_str()); dest = const_cast(item_text); to_char = int(txt_length); diff --git a/src/fmenubar.cpp b/src/fmenubar.cpp index a5f5cd5b..927c4492 100644 --- a/src/fmenubar.cpp +++ b/src/fmenubar.cpp @@ -180,7 +180,7 @@ void FMenuBar::drawItems() txt = (*iter)->getText(); txt_length = uInt(txt.getLength()); - item_text = new wchar_t[txt_length+1]; + item_text = new wchar_t[txt_length+1](); src = const_cast(txt.wc_str()); dest = const_cast(item_text); diff --git a/src/fobject.cpp b/src/fobject.cpp index ad1e871b..d67c3c0a 100644 --- a/src/fobject.cpp +++ b/src/fobject.cpp @@ -27,7 +27,7 @@ FObject::FObject (FObject* parent) if ( parent == 0 ) { modify_timer = false; - timer_list = new TimerList; + timer_list = new TimerList(); } else has_parent = true; @@ -132,7 +132,7 @@ int FObject::addTimer (int interval) modify_timer = true; if ( ! timer_list ) - timer_list = new TimerList; + timer_list = new TimerList(); // find an unused timer id if ( ! timer_list->empty() ) diff --git a/src/fstatusbar.cpp b/src/fstatusbar.cpp index c072a848..7116218e 100644 --- a/src/fstatusbar.cpp +++ b/src/fstatusbar.cpp @@ -114,7 +114,7 @@ void FStatusKey::setStatusbar (FStatusBar* sb) // public methods of FStatusKey //---------------------------------------------------------------------- -inline void FStatusKey::setActive() +void FStatusKey::setActive() { active = true; processActivate(); diff --git a/src/fterm.cpp b/src/fterm.cpp index 76d3982c..70f9077c 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -288,10 +288,8 @@ int FTerm::getScreenFont() font.width = 32; font.height = 32; font.charcount = 512; - font.data = new uChar[data_size]; - // initialize with 0 - memset(font.data, 0, data_size); + font.data = new uChar[data_size](); // font operation ret = ioctl (fd_tty, KDFONTOP, &font); @@ -337,7 +335,7 @@ int FTerm::setScreenFont ( uChar* fontdata, uInt count try { - font.data = new uChar[data_size]; + font.data = new uChar[data_size](); // initialize with 0 } catch (const std::bad_alloc& ex) { @@ -345,9 +343,6 @@ int FTerm::setScreenFont ( uChar* fontdata, uInt count return -1; } - // initialize with 0 - memset(font.data, 0, data_size); - for (uInt i=0; i < count; i++) memcpy ( const_cast(font.data + bytes_per_line*32*i) , &fontdata[i * font.height] @@ -397,7 +392,7 @@ int FTerm::getUnicodeMap() try { - unimap.entries = new struct unipair[count]; + unimap.entries = new struct unipair[count](); } catch (const std::bad_alloc& ex) { @@ -1920,15 +1915,6 @@ void FTerm::restoreVTerm (int x, int y, int w, int h) } } -//---------------------------------------------------------------------- -inline bool FTerm::isCovered(const FPoint& pos, FTerm::term_area* area) const -{ - if ( area == 0 ) - return false; - - return isCovered (pos.getX(), pos.getY(), area); -} - //---------------------------------------------------------------------- bool FTerm::isCovered(int x, int y, FTerm::term_area* area) const { @@ -2084,14 +2070,6 @@ void FTerm::setUpdateVTerm (bool on) updateVTerm (last_area); } -//---------------------------------------------------------------------- -inline void FTerm::getArea (const FPoint& pos, FTerm::term_area* area) -{ - if ( area == 0 ) - return; - getArea (pos.getX(), pos.getY(), area); -} - //---------------------------------------------------------------------- void FTerm::getArea (int ax, int ay, FTerm::term_area* area) { @@ -2128,16 +2106,6 @@ void FTerm::getArea (int ax, int ay, FTerm::term_area* area) } } -//---------------------------------------------------------------------- -inline void FTerm::getArea (const FRect& box, FTerm::term_area* area) -{ - getArea ( box.getX() - , box.getY() - , box.getWidth() - , box.getHeight() - , area ); -} - //---------------------------------------------------------------------- void FTerm::getArea (int x, int y, int w, int h, FTerm::term_area* area) { @@ -2250,12 +2218,6 @@ void FTerm::putArea (int ax, int ay, FTerm::term_area* area) } } -//---------------------------------------------------------------------- -inline FTerm::char_data FTerm::getCoveredCharacter (const FPoint& pos, FTerm* obj) -{ - return getCoveredCharacter (pos.getX(), pos.getY(), obj); -} - //---------------------------------------------------------------------- FTerm::char_data FTerm::getCoveredCharacter (int x, int y, FTerm* obj) { @@ -2703,18 +2665,18 @@ void FTerm::setKDECursor(fc::kde_konsole_CursorShape style) //---------------------------------------------------------------------- FString FTerm::getXTermFont() { - FString font = ""; + FString font(""); if ( raw_mode && non_blocking_stdin ) { int n; char temp[150] = {}; - putstring("\033]50;?\07"); // get font + putstring ("\033]50;?\07"); // get font fflush(stdout); usleep(150000); // wait 150 ms // read the answer n = int(read(fileno(stdin), &temp, sizeof(temp)-1)); - // Esc \ = OSC String Terminator + // Esc + \ = OSC string terminator if ( n >= 2 && temp[n-1] == '\\' && temp[n-2] == 0x1b ) { temp[n-2] = '\0'; @@ -2730,7 +2692,7 @@ FString FTerm::getXTermFont() //---------------------------------------------------------------------- FString FTerm::getXTermTitle() { - FString title = ""; + FString title(""); if ( kde_konsole ) return title; @@ -2739,12 +2701,12 @@ FString FTerm::getXTermTitle() { int n; char temp[512] = {}; - putstring("\033[21t"); // get title + putstring ("\033[21t"); // get title fflush(stdout); usleep(150000); // wait 150 ms // read the answer n = int(read(fileno(stdin), &temp, sizeof(temp)-1)); - // Esc \ = OSC String Terminator + // Esc + \ = OSC string terminator if ( n >= 2 && temp[n-1] == '\\' && temp[n-2] == 0x1b ) { temp[n-2] = '\0'; @@ -3713,7 +3675,7 @@ int FTerm::printf (const char* format, ...) if ( len >= int(sizeof(buf)) ) { - buffer = new char[len+1]; + buffer = new char[len+1](); va_start (args, format); vsnprintf (buffer, uLong(len+1), format, args); va_end (args); @@ -4017,7 +3979,7 @@ inline void FTerm::appendCharacter (char_data*& screen_char) } //---------------------------------------------------------------------- -inline void FTerm::appendAttributes (char_data*& screen_attr) +void FTerm::appendAttributes (char_data*& screen_attr) { if ( screen_attr->fg_color != fg_term_color || screen_attr->bg_color != bg_term_color ) diff --git a/src/fterm.h b/src/fterm.h index 57468c56..bb84817f 100644 --- a/src/fterm.h +++ b/src/fterm.h @@ -431,15 +431,37 @@ class FTerm }; #pragma pack(pop) + +// FTerm inline functions +//---------------------------------------------------------------------- +inline bool FTerm::isCovered(const FPoint& pos, FTerm::term_area* area) const +{ return isCovered (pos.getX(), pos.getY(), area); } + +//---------------------------------------------------------------------- +inline void FTerm::getArea (const FPoint& pos, FTerm::term_area* area) +{ return getArea (pos.getX(), pos.getY(), area); } + +//---------------------------------------------------------------------- +inline void FTerm::getArea (const FRect& box, FTerm::term_area* area) +{ + getArea ( box.getX() + , box.getY() + , box.getWidth() + , box.getHeight() + , area ); +} + +//---------------------------------------------------------------------- +inline FTerm::char_data FTerm::getCoveredCharacter (const FPoint& pos, FTerm* obj) +{ return getCoveredCharacter (pos.getX(), pos.getY(), obj); } + //---------------------------------------------------------------------- inline const char* FTerm::getClassName() const { return "FTerm"; } //---------------------------------------------------------------------- inline FTerm::term_area* FTerm::getVWin() const -{ - return vwin; -} +{ return vwin; } //---------------------------------------------------------------------- inline int FTerm::getLineNumber() diff --git a/src/ftogglebutton.cpp b/src/ftogglebutton.cpp index 39c8042b..2bf7c024 100644 --- a/src/ftogglebutton.cpp +++ b/src/ftogglebutton.cpp @@ -198,7 +198,7 @@ void FToggleButton::drawLabel() length = text.getLength(); hotkeypos = -1; - LabelText = new wchar_t[length+1]; + LabelText = new wchar_t[length+1](); txt = text; src = const_cast(txt.wc_str()); dest = const_cast(LabelText); diff --git a/src/fwidget.cpp b/src/fwidget.cpp index 85bb81b1..d738f6a0 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -124,8 +124,8 @@ FWidget::~FWidget() // destructor //---------------------------------------------------------------------- void FWidget::init() { - window_list = new widgetList; - close_widget = new widgetList; + window_list = new widgetList(); + close_widget = new widgetList(); getTermGeometry(); // <-----. // | @@ -161,7 +161,7 @@ void FWidget::init() setColor (foregroundColor, backgroundColor); clrscr(); - accelerator_list = new Accelerators; + accelerator_list = new Accelerators(); } //---------------------------------------------------------------------- @@ -181,12 +181,6 @@ void FWidget::finish() } } -//---------------------------------------------------------------------- -inline void FWidget::processDestroy() -{ - emitCallback("destroy"); -} - //---------------------------------------------------------------------- void FWidget::draw() { } @@ -386,12 +380,6 @@ FTerm::term_area* FWidget::getPrintArea() } } -//---------------------------------------------------------------------- -inline void FWidget::setPrintArea(term_area* area) -{ - print_area = area; -} - // protected methods of FWidget //---------------------------------------------------------------------- void FWidget::adjustSize() @@ -839,12 +827,6 @@ void FWidget::setMainWidget(FWidget* obj) fapp->setMainWidget(obj); } -//---------------------------------------------------------------------- -inline FWidget* FWidget::childWidgetAt (FWidget* p, const FPoint& pos) -{ - return childWidgetAt (p, pos.getX(), pos.getY()); -} - //---------------------------------------------------------------------- FWidget* FWidget::childWidgetAt (FWidget* p, int x, int y) { @@ -875,14 +857,14 @@ FWidget* FWidget::childWidgetAt (FWidget* p, int x, int y) } //---------------------------------------------------------------------- -inline FWidget* FWidget::getFocusWidget() const +FWidget* FWidget::getFocusWidget() const { FWidget* focus_widget = static_cast(FApplication::focus_widget); return focus_widget; } //---------------------------------------------------------------------- -inline void FWidget::setFocusWidget(FWidget* obj) +void FWidget::setFocusWidget(FWidget* obj) { FApplication::focus_widget = obj; } @@ -1330,18 +1312,6 @@ void FWidget::hide() } } -//---------------------------------------------------------------------- -inline bool FWidget::setEnable(bool on) -{ - return enable = (on) ? true : false; -} - -//---------------------------------------------------------------------- -inline bool FWidget::setVisibleCursor(bool on) -{ - return visibleCursor = (on) ? true : false; -} - //---------------------------------------------------------------------- bool FWidget::focusFirstChild (void) { @@ -1446,27 +1416,6 @@ bool FWidget::setFocus(bool on) return focus = (on) ? true : false; } -//---------------------------------------------------------------------- -FPoint FWidget::globalToLocalPos (const FPoint& gPos) -{ - return FPoint ( gPos.getX() - xpos - xmin + 2 - , gPos.getY() - ypos - ymin + 2 ); -} - -//---------------------------------------------------------------------- -void FWidget::setForegroundColor (int color) -{ - if ( color >> 8 == 0 ) // valid colors 0..254 - foregroundColor = color; -} - -//---------------------------------------------------------------------- -void FWidget::setBackgroundColor (int color) -{ - if ( color >> 8 == 0 ) // valid colors 0..254 - backgroundColor = color; -} - //---------------------------------------------------------------------- void FWidget::setX (int x, bool adjust) { @@ -1513,12 +1462,6 @@ void FWidget::setY (int y, bool adjust) adjustSize(); } -//---------------------------------------------------------------------- -inline void FWidget::setPos (const FPoint& p, bool adjust) -{ - setPos (p.getX(), p.getY(), adjust); -} - //---------------------------------------------------------------------- void FWidget::setPos (int x, int y, bool adjust) { @@ -1668,16 +1611,6 @@ void FWidget::setTermGeometry (int w, int h) } } -//---------------------------------------------------------------------- -inline void FWidget::setGeometry (const FRect& box, bool adjust) -{ - setGeometry ( box.getX() - , box.getY() - , box.getWidth() - , box.getHeight() - , adjust ); -} - //---------------------------------------------------------------------- void FWidget::setGeometry (int x, int y, int w, int h, bool adjust) { @@ -1720,12 +1653,6 @@ void FWidget::setGeometry (int x, int y, int w, int h, bool adjust) double_flatline_mask.left.resize (uLong(height), false); } -//---------------------------------------------------------------------- -inline void FWidget::move (const FPoint& pos) -{ - move( pos.getX(), pos.getY() ); -} - //---------------------------------------------------------------------- void FWidget::move (int x, int y) { @@ -1761,12 +1688,6 @@ bool FWidget::setCursor() return false; } -//---------------------------------------------------------------------- -bool FWidget::setCursorPos (const FPoint& pos) -{ - return setCursorPos (pos.getX(), pos.getY()); -} - //---------------------------------------------------------------------- bool FWidget::setCursorPos (register int x, register int y) { @@ -1778,24 +1699,6 @@ bool FWidget::setCursorPos (register int x, register int y) return false; } -//---------------------------------------------------------------------- -inline void FWidget::unsetCursorPos() -{ - widgetCursorPosition.setPoint(-1,-1); -} - -//---------------------------------------------------------------------- -void FWidget::gotoxy (const FPoint& pos) -{ - gotoxy (pos.getX(), pos.getY()); -} - -//---------------------------------------------------------------------- -void FWidget::gotoxy (register int x, register int y) -{ - cursor->setPoint(x,y); -} - //---------------------------------------------------------------------- void FWidget::clrscr() { @@ -1841,24 +1744,6 @@ void FWidget::clrscr() putArea (xpos+xmin-1, ypos+ymin-1, area); } -//---------------------------------------------------------------------- -bool FWidget::setBold (register bool on) -{ - return (bold = on); -} - -//---------------------------------------------------------------------- -bool FWidget::setReverse (register bool on) -{ - return (reverse = on); -} - -//---------------------------------------------------------------------- -bool FWidget::setUnderline (register bool on) -{ - return (underline = on); -} - //---------------------------------------------------------------------- void FWidget::drawShadow() { diff --git a/src/fwidget.h b/src/fwidget.h index 5e8485aa..20c32893 100644 --- a/src/fwidget.h +++ b/src/fwidget.h @@ -285,37 +285,37 @@ class FWidget : public FObject, public FTerm private: FWidget (const FWidget&); FWidget& operator = (const FWidget&); - void init(); - void finish(); - void processDestroy(); - virtual void draw(); - static void setColorTheme(); - term_area* getPrintArea(); - void setPrintArea(term_area*); + void init(); + void finish(); + void processDestroy(); + virtual void draw(); + static void setColorTheme(); + term_area* getPrintArea(); + void setPrintArea (term_area*); protected: - virtual void adjustSize(); - virtual void setStatusBar (FStatusBar*); - virtual void setMenuBar (FMenuBar*); + virtual void adjustSize(); + virtual void setStatusBar (FStatusBar*); + virtual void setMenuBar (FMenuBar*); // Event handlers - bool event (FEvent*); - virtual void onKeyPress (FKeyEvent*); - virtual void onKeyUp (FKeyEvent*); - virtual void onKeyDown (FKeyEvent*); - virtual void onMouseDown (FMouseEvent*); - virtual void onMouseUp (FMouseEvent*); - virtual void onMouseDoubleClick (FMouseEvent*); - virtual void onWheel (FWheelEvent*); - virtual void onMouseMove (FMouseEvent*); - virtual void onFocusIn (FFocusEvent*); - virtual void onFocusOut (FFocusEvent*); - virtual void onAccel (FAccelEvent*); - virtual void onResize (FResizeEvent*); - virtual void onShow (FShowEvent*); - virtual void onHide (FHideEvent*); - virtual void onClose (FCloseEvent*); - virtual bool focusNextChild (void); - virtual bool focusPrevChild (void); + bool event (FEvent*); + virtual void onKeyPress (FKeyEvent*); + virtual void onKeyUp (FKeyEvent*); + virtual void onKeyDown (FKeyEvent*); + virtual void onMouseDown (FMouseEvent*); + virtual void onMouseUp (FMouseEvent*); + virtual void onMouseDoubleClick (FMouseEvent*); + virtual void onWheel (FWheelEvent*); + virtual void onMouseMove (FMouseEvent*); + virtual void onFocusIn (FFocusEvent*); + virtual void onFocusOut (FFocusEvent*); + virtual void onAccel (FAccelEvent*); + virtual void onResize (FResizeEvent*); + virtual void onShow (FShowEvent*); + virtual void onHide (FHideEvent*); + virtual void onClose (FCloseEvent*); + virtual bool focusNextChild (void); + virtual bool focusPrevChild (void); public: explicit FWidget (FWidget* = 0); // constructor @@ -339,143 +339,156 @@ class FWidget : public FObject, public FTerm static FStatusBar* statusBar(); static FMenuBar* menuBar(); - void setStatusbarMessage (FString); - void clearStatusbarMessage(); - FString getStatusbarMessage(); + void setStatusbarMessage (FString); + void clearStatusbarMessage(); + FString getStatusbarMessage(); - void addCallback ( FString - , FCallback - , void* = null ); - void addCallback ( FString - , FWidget* - , FMemberCallback - , void* = null ); - void delCallback (FCallback); - void delCallback (FWidget*); - void emitCallback (FString); + void addCallback ( FString + , FCallback + , void* = null ); + void addCallback ( FString + , FWidget* + , FMemberCallback + , void* = null ); + void delCallback (FCallback); + void delCallback (FWidget*); + void emitCallback (FString); - void addAccelerator (int key); - void addAccelerator (int, FWidget*); - void delAccelerator (FWidget*); + void addAccelerator (int key); + void addAccelerator (int, FWidget*); + void delAccelerator (FWidget*); - virtual void redraw(); - virtual void resize(); - virtual void show(); - virtual void hide(); - bool setVisible(); - bool isVisible() const; - bool isShown() const; + virtual void redraw(); + virtual void resize(); + virtual void show(); + virtual void hide(); + bool setVisible(); + bool isVisible() const; + bool isShown() const; - virtual bool setEnable(bool); - virtual bool setEnable(); - virtual bool unsetEnable(); - virtual bool setDisable(); - bool isEnabled() const; + virtual bool setEnable(bool); + virtual bool setEnable(); + virtual bool unsetEnable(); + virtual bool setDisable(); + bool isEnabled() const; - virtual bool setVisibleCursor(bool); - virtual bool setVisibleCursor(); - virtual bool unsetVisibleCursor(); - bool hasVisibleCursor() const; + virtual bool setVisibleCursor(bool); + virtual bool setVisibleCursor(); + virtual bool unsetVisibleCursor(); + bool hasVisibleCursor() const; - virtual bool focusFirstChild (void); - virtual bool focusLastChild (void); - virtual bool setFocus(bool); - virtual bool setFocus(); - virtual bool unsetFocus(); - bool hasFocus() const; - bool acceptFocus() const; - void setFocusable(); - void unsetFocusable(); + virtual bool focusFirstChild (void); + virtual bool focusLastChild (void); + virtual bool setFocus(bool); + virtual bool setFocus(); + virtual bool unsetFocus(); + bool hasFocus() const; + bool acceptFocus() const; + void setFocusable(); + void unsetFocusable(); - bool ignorePadding(bool); - bool ignorePadding(); - bool acceptPadding(); + bool ignorePadding(bool); + bool ignorePadding(); + bool acceptPadding(); - int getForegroundColor() const; - int getBackgroundColor() const; - int getX() const; - int getY() const; - const FPoint getPos() const; - int getGlobalX() const; - int getGlobalY() const; - const FPoint getGlobalPos() const; - int getWidth() const; - int getHeight() const; - int getTopPadding() const; - int getLeftPadding() const; - int getBottomPadding() const; - int getRightPadding() const; - int getClientWidth() const; - int getClientHeight() const; - const FPoint& getShadow() const; - const FRect& getGeometry() const; - const FRect& getGeometryShadow() const; - const FRect& getGeometryGlobal() const; - const FRect& getGeometryGlobalShadow() const; - FPoint globalToLocalPos(const FPoint&); - void setForegroundColor (int); - void setBackgroundColor (int); - void setX (int, bool = true); - void setY (int, bool = true); - void setPos (const FPoint&, bool = true); - void setPos (int, int, bool = true); - void setWidth (int, bool = true); - void setHeight (int, bool = true); - void setTopPadding (int, bool = true); - void setLeftPadding (int, bool = true); - void setBottomPadding (int, bool = true); - void setRightPadding (int, bool = true); - void getTermGeometry(); - void setTermGeometry (int, int); - virtual void setGeometry (const FRect&, bool = true); - virtual void setGeometry (int, int, int, int, bool = true); - virtual void move (const FPoint&); - virtual void move (int x, int y); - int getFlags() const; + int getForegroundColor() const; + int getBackgroundColor() const; + int getX() const; + int getY() const; + const FPoint getPos() const; + int getGlobalX() const; + int getGlobalY() const; + const FPoint getGlobalPos() const; + int getWidth() const; + int getHeight() const; + int getTopPadding() const; + int getLeftPadding() const; + int getBottomPadding() const; + int getRightPadding() const; + int getClientWidth() const; + int getClientHeight() const; + const FPoint& getShadow() const; + const FRect& getGeometry() const; + const FRect& getGeometryShadow() const; + const FRect& getGeometryGlobal() const; + const FRect& getGeometryGlobalShadow() const; + FPoint globalToLocalPos (const FPoint&); + void setForegroundColor (int); + void setBackgroundColor (int); + void setX (int, bool = true); + void setY (int, bool = true); + void setPos (const FPoint&, bool = true); + void setPos (int, int, bool = true); + void setWidth (int, bool = true); + void setHeight (int, bool = true); + void setTopPadding (int, bool = true); + void setLeftPadding (int, bool = true); + void setBottomPadding (int, bool = true); + void setRightPadding (int, bool = true); + void getTermGeometry(); + void setTermGeometry (int, int); + virtual void setGeometry (const FRect&, bool = true); + virtual void setGeometry (int, int, int, int, bool = true); + virtual void move (const FPoint&); + virtual void move (int x, int y); + int getFlags() const; - bool setCursor(); - FPoint getCursorPos(); - bool setCursorPos (const FPoint&); - bool setCursorPos (register int, register int); - void unsetCursorPos(); + bool setCursor(); + FPoint getCursorPos(); + bool setCursorPos (const FPoint&); + bool setCursorPos (register int, register int); + void unsetCursorPos(); - static void gotoxy (const FPoint&); - static void gotoxy (register int, register int); - void clrscr(); + static void gotoxy (const FPoint&); + static void gotoxy (register int, register int); + void clrscr(); - static bool setBold(register bool); - static bool setBold(); - static bool unsetBold(); - static bool isBold(); + static bool setBold(register bool); + static bool setBold(); + static bool unsetBold(); + static bool isBold(); - static bool setReverse(register bool); - static bool setReverse(); - static bool unsetReverse(); - static bool isReverse(); + static bool setReverse(register bool); + static bool setReverse(); + static bool unsetReverse(); + static bool isReverse(); - static bool setUnderline(register bool); - static bool setUnderline(); - static bool unsetUnderline(); - static bool isUnderline(); + static bool setUnderline(register bool); + static bool setUnderline(); + static bool unsetUnderline(); + static bool isUnderline(); - void drawShadow(); - void clearShadow(); - void drawFlatBorder(); - void clearFlatBorder(); - void setDoubleFlatLine(int, bool = true); - void unsetDoubleFlatLine(int); + void drawShadow(); + void clearShadow(); + void drawFlatBorder(); + void clearFlatBorder(); + void setDoubleFlatLine(int, bool = true); + void unsetDoubleFlatLine(int); std::vector& doubleFlatLine_ref(int); - virtual void drawBorder(); + virtual void drawBorder(); - static void quit(); + static void quit(); }; #pragma pack(pop) +// FWidget inline functions +//---------------------------------------------------------------------- +inline void FWidget::processDestroy() +{ emitCallback("destroy"); } + +//---------------------------------------------------------------------- +inline void FWidget::setPrintArea (term_area* area) +{ print_area = area; } + //---------------------------------------------------------------------- inline const char* FWidget::getClassName() const { return "FWidget"; } +//---------------------------------------------------------------------- +inline FWidget* FWidget::childWidgetAt (FWidget* p, const FPoint& pos) +{ return childWidgetAt (p, pos.getX(), pos.getY()); } + //---------------------------------------------------------------------- inline FWidget* FWidget::parentWidget() const { return static_cast(getParent()); } @@ -512,6 +525,10 @@ inline bool FWidget::isShown() const inline bool FWidget::isWindow() const { return window_object; } +//---------------------------------------------------------------------- +inline bool FWidget::setEnable (bool on) +{ return enable = (on) ? true : false; } + //---------------------------------------------------------------------- inline bool FWidget::setEnable() { return setEnable(true); } @@ -528,6 +545,10 @@ inline bool FWidget::setDisable() inline bool FWidget::isEnabled() const { return enable; } +//---------------------------------------------------------------------- +inline bool FWidget::setVisibleCursor (bool on) +{ return visibleCursor = (on) ? true : false; } + //---------------------------------------------------------------------- inline bool FWidget::setVisibleCursor() { return setVisibleCursor(true); } @@ -608,6 +629,31 @@ inline int FWidget::getGlobalY() const inline const FPoint FWidget::getGlobalPos() const { return FPoint(xpos+xmin-1, ypos+ymin-1); } +//---------------------------------------------------------------------- +inline FPoint FWidget::globalToLocalPos (const FPoint& gPos) +{ + return FPoint ( gPos.getX() - xpos - xmin + 2 + , gPos.getY() - ypos - ymin + 2 ); +} + +//---------------------------------------------------------------------- +inline void FWidget::setForegroundColor (int color) +{ + if ( color >> 8 == 0 ) // valid colors 0..254 + foregroundColor = color; +} + +//---------------------------------------------------------------------- +inline void FWidget::setBackgroundColor (int color) +{ + if ( color >> 8 == 0 ) // valid colors 0..254 + backgroundColor = color; +} + +//---------------------------------------------------------------------- +inline void FWidget::setPos (const FPoint& p, bool adjust) +{ setPos (p.getX(), p.getY(), adjust); } + //---------------------------------------------------------------------- inline int FWidget::getWidth() const { return width; } @@ -660,6 +706,20 @@ inline const FRect& FWidget::getGeometryGlobal() const inline const FRect& FWidget::getGeometryGlobalShadow() const { return adjustWidgetSizeGlobalShadow; } +//---------------------------------------------------------------------- +inline void FWidget::setGeometry (const FRect& box, bool adjust) +{ + setGeometry ( box.getX() + , box.getY() + , box.getWidth() + , box.getHeight() + , adjust ); +} + +//---------------------------------------------------------------------- +inline void FWidget::move (const FPoint& pos) +{ move( pos.getX(), pos.getY() ); } + //---------------------------------------------------------------------- inline int FWidget::getFlags() const { return flags; } @@ -668,6 +728,26 @@ inline int FWidget::getFlags() const inline FPoint FWidget::getCursorPos() { return widgetCursorPosition; } +//---------------------------------------------------------------------- +inline bool FWidget::setCursorPos (const FPoint& pos) +{ return setCursorPos (pos.getX(), pos.getY()); } + +//---------------------------------------------------------------------- +inline void FWidget::unsetCursorPos() +{ widgetCursorPosition.setPoint(-1,-1); } + +//---------------------------------------------------------------------- +inline void FWidget::gotoxy (const FPoint& pos) +{ gotoxy (pos.getX(), pos.getY()); } + +//---------------------------------------------------------------------- +inline void FWidget::gotoxy (register int x, register int y) +{ cursor->setPoint(x,y); } + +//---------------------------------------------------------------------- +inline bool FWidget::setBold (register bool on) +{ return (bold = on); } + //---------------------------------------------------------------------- inline bool FWidget::setBold() { return setBold(true); } @@ -680,6 +760,10 @@ inline bool FWidget::unsetBold() inline bool FWidget::isBold() { return bold; } +//---------------------------------------------------------------------- +inline bool FWidget::setReverse (register bool on) +{ return (reverse = on); } + //---------------------------------------------------------------------- inline bool FWidget::setReverse() { return setReverse(true); } @@ -692,6 +776,10 @@ inline bool FWidget::unsetReverse() inline bool FWidget::isReverse() { return reverse; } +//---------------------------------------------------------------------- +inline bool FWidget::setUnderline (register bool on) +{ return (underline = on); } + //---------------------------------------------------------------------- inline bool FWidget::setUnderline() { return setUnderline(true); } diff --git a/src/fwindow.cpp b/src/fwindow.cpp index 1e3d60a7..165434c0 100644 --- a/src/fwindow.cpp +++ b/src/fwindow.cpp @@ -86,12 +86,6 @@ void FWindow::hide() FWidget::hide(); } -//---------------------------------------------------------------------- -FWindow* FWindow::windowWidgetAt(const FPoint& pos) -{ - return windowWidgetAt(pos.getX(), pos.getY()); -} - //---------------------------------------------------------------------- FWindow* FWindow::windowWidgetAt(int x, int y) { diff --git a/src/fwindow.h b/src/fwindow.h index 434f0125..b6f2ea0e 100644 --- a/src/fwindow.h +++ b/src/fwindow.h @@ -91,6 +91,10 @@ class FWindow : public FWidget inline const char* FWindow::getClassName() const { return "FWindow"; } +//---------------------------------------------------------------------- +inline FWindow* FWindow::windowWidgetAt (const FPoint& pos) +{ return windowWidgetAt(pos.getX(), pos.getY()); } + //---------------------------------------------------------------------- inline bool FWindow::raiseWindow() { return raiseWindow(this); }