diff --git a/.gitignore b/.gitignore index c8278ddf..02360008 100644 --- a/.gitignore +++ b/.gitignore @@ -25,7 +25,7 @@ test/.deps/ test/.libs/ test/calculator test/dialog -test/fstring +test/string test/hello test/watch test/input-dialog diff --git a/ChangeLog b/ChangeLog index 8c612e8e..d7de6d2f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,5 @@ 2015-09-22 Markus Gans + * Add the possibility to hide a virtual window * Some code optimizations 2015-09-18 Markus Gans @@ -6,11 +7,11 @@ 2015-08-08 Markus Gans * Bug fix in FDialog (use GlobalPos to move) - * Don't check mouse click position on titlebar again + * Don't check mouse click position on titlebar again while FDialog is in move 2015-07-26 Markus Gans - * init() method for the FStatusKey constructor + * init() method for the FStatusKey constructor to avoid code duplication 2015-07-18 Markus Gans @@ -40,7 +41,7 @@ * Use the object timer for the click animation in FButton 2015-06-28 Markus Gans - * Add exception handling for toLong() and toULong() + * Add exception handling for toLong() and toULong() in FString 2015-06-27 Markus Gans diff --git a/src/fdialog.cpp b/src/fdialog.cpp index 09644f18..f115ec1c 100644 --- a/src/fdialog.cpp +++ b/src/fdialog.cpp @@ -626,7 +626,7 @@ void FDialog::show() if ( ! isVisible() ) return; - FWidget::show(); + FWindow::show(); // set the cursor to the focus widget if ( FWidget::getFocusWidget() @@ -652,7 +652,7 @@ void FDialog::show() //---------------------------------------------------------------------- void FDialog::hide() { - FWidget::hide(); + FWindow::hide(); if ( isModal() ) { diff --git a/src/fmenubar.cpp b/src/fmenubar.cpp index 47aee3e3..41c74b98 100644 --- a/src/fmenubar.cpp +++ b/src/fmenubar.cpp @@ -40,6 +40,7 @@ void FMenuBar::init() xpos = 1; ypos = 1; createArea (vmenubar); + vmenubar->visible = true; // initialize geometry values setGeometry (1, 1, getColumnNumber(), 1, false); getRootWidget()->setTopPadding(1, true); @@ -386,7 +387,7 @@ void FMenuBar::hide() int fg, bg, screenWidth; char* blank; - FWidget::hide(); + FWindow::hide(); fg = wc.term_fg; bg = wc.term_bg; diff --git a/src/fstatusbar.cpp b/src/fstatusbar.cpp index 2fdffc77..ebfcaa41 100644 --- a/src/fstatusbar.cpp +++ b/src/fstatusbar.cpp @@ -181,6 +181,8 @@ void FStatusBar::init() xpos = 1; ypos = getLineNumber(); createArea (vstatusbar); + vstatusbar->visible = true; + // initialize geometry values setGeometry (1, ypos, getColumnNumber(), 1, false); getRootWidget()->setBottomPadding(1, true); @@ -502,7 +504,7 @@ void FStatusBar::hide() int fg, bg, lastLine, screenWidth; char* blank; - FWidget::hide(); + FWindow::hide(); fg = wc.term_fg; bg = wc.term_bg; diff --git a/src/fstring.cpp b/src/fstring.cpp index 5c8b9fd6..37ed6a3d 100644 --- a/src/fstring.cpp +++ b/src/fstring.cpp @@ -407,7 +407,6 @@ inline wchar_t* FString::c_to_wc_str (const char* s) const if ( ! *s ) // handle empty string return const_cast(L""); - size = int(strlen(s)) + 1; dest_size = size * int(CHAR_SIZE); src = s; @@ -1999,10 +1998,11 @@ FString FString::replaceControlCodes() const FString FString::expandTabs (uInt tabstop) const { uLong last; + std::vector tab_split; FString instr(string); FString outstr(""); - std::vector tab_split = instr.split("\t"); + tab_split = instr.split("\t"); last = tab_split.size(); for (uInt i=0; i < last; i++) { diff --git a/src/fterm.cpp b/src/fterm.cpp index 8bed529a..591d1bac 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -977,6 +977,7 @@ void FTerm::init() createVTerm(); // create virtual desktop area createArea (vdesktop); + vdesktop->visible = true; // make stdin non-blocking setNonBlockingInput(); @@ -1593,6 +1594,7 @@ void FTerm::createArea (term_area*& area) area->bottom_shadow = 0; area->changes = 0; area->text = 0; + area->visible = false; area->widget = static_cast(this); resizeArea (area); @@ -1719,7 +1721,8 @@ void FTerm::restoreVTerm (int x, int y, int w, int h) int win_y = (*iter)->getGlobalY() - 1; term_area* win = (*iter)->getVWin(); int line_len = win->width + win->right_shadow; - sc = &win->text[(y+ty-win_y) * line_len + (x+tx-win_x)]; + if ( win->visible ) + sc = &win->text[(y+ty-win_y) * line_len + (x+tx-win_x)]; } ++iter; } @@ -1734,7 +1737,8 @@ void FTerm::restoreVTerm (int x, int y, int w, int h) { int bar_x = menubar->getGlobalX() - 1; int bar_y = menubar->getGlobalY() - 1; - sc = &vmenubar->text[(y+ty-bar_y) * vmenubar->width + (x+tx-bar_x)]; + if ( vmenubar->visible ) + sc = &vmenubar->text[(y+ty-bar_y) * vmenubar->width + (x+tx-bar_x)]; } // statusbar is always on top @@ -1746,7 +1750,8 @@ void FTerm::restoreVTerm (int x, int y, int w, int h) { int bar_x = statusbar->getGlobalX() - 1; int bar_y = statusbar->getGlobalY() - 1; - sc = &vstatusbar->text[(y+ty-bar_y) * vstatusbar->width + (x+tx-bar_x)]; + if ( vstatusbar->visible ) + sc = &vstatusbar->text[(y+ty-bar_y) * vstatusbar->width + (x+tx-bar_x)]; } memcpy (tc, sc, sizeof(FTerm::char_data)); @@ -1852,6 +1857,9 @@ void FTerm::updateVTerm (FTerm::term_area* area) if ( area == 0 ) return; + if ( ! area->visible ) + return; + ax = area->widget->getGlobalX() - 1; ay = area->widget->getGlobalY() - 1; aw = area->width; @@ -2022,6 +2030,8 @@ void FTerm::putArea (const FPoint& pos, FTerm::term_area* area) { if ( area == 0 ) return; + if ( ! area->visible ) + return; putArea (pos.getX(), pos.getY(), area); } @@ -2034,6 +2044,8 @@ void FTerm::putArea (int ax, int ay, FTerm::term_area* area) if ( area == 0 ) return; + if ( ! area->visible ) + return; ax--; ay--; @@ -2132,7 +2144,8 @@ FTerm::char_data FTerm::getCoveredCharacter (int x, int y, FTerm* obj) int win_y = (*iter)->getGlobalY() - 1; term_area* win = (*iter)->getVWin(); int line_len = win->width + win->right_shadow; - cc = &win->text[(y-win_y) * line_len + (x-win_x)]; + if ( win->visible ) + cc = &win->text[(y-win_y) * line_len + (x-win_x)]; } } else @@ -2373,6 +2386,7 @@ void FTerm::createVTerm() vterm->bottom_shadow = 0; vterm->changes = 0; vterm->text = 0; + vterm->visible = true; vterm->widget = static_cast(this); resizeVTerm(); diff --git a/src/fterm.h b/src/fterm.h index 43a1d001..ee597d31 100644 --- a/src/fterm.h +++ b/src/fterm.h @@ -187,6 +187,7 @@ class FTerm FWidget* widget; line_changes* changes; char_data* text; + bool visible; } term_area; static term_area* vterm; // virtual terminal diff --git a/src/fwindow.cpp b/src/fwindow.cpp index 0ab6b680..b1dc841d 100644 --- a/src/fwindow.cpp +++ b/src/fwindow.cpp @@ -21,6 +21,7 @@ FWindow::FWindow(FWidget* parent) FWindow::~FWindow() // destructor { } + // protected methods of FWindow //---------------------------------------------------------------------- bool FWindow::event (FEvent* ev) @@ -65,7 +66,26 @@ void FWindow::onWindowRaised (FEvent*) void FWindow::onWindowLowered (FEvent*) { } + // public methods of FWindow +//---------------------------------------------------------------------- +void FWindow::show() +{ + term_area* area = getVWin(); + if ( area ) + area->visible = true; + FWidget::show(); +} + +//---------------------------------------------------------------------- +void FWindow::hide() +{ + term_area* area = getVWin(); + if ( area ) + area->visible = false; + FWidget::hide(); +} + //---------------------------------------------------------------------- FWindow* FWindow::windowWidgetAt(const FPoint& pos) { diff --git a/src/fwindow.h b/src/fwindow.h index c8c715a1..099a1f71 100644 --- a/src/fwindow.h +++ b/src/fwindow.h @@ -35,6 +35,8 @@ class FWindow : public FWidget ~FWindow (); // destructor const char* getClassName() const; + virtual void show(); + virtual void hide(); static FWindow* windowWidgetAt (const FPoint&); static FWindow* windowWidgetAt (int, int); static void addWindow (FWidget*); diff --git a/test/Makefile.am b/test/Makefile.am index 7fc03259..4e1e4f50 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -11,7 +11,7 @@ noinst_PROGRAMS = \ input-dialog \ mandelbrot \ calculator \ - fstring \ + string \ watch \ timer \ ui @@ -21,7 +21,7 @@ dialog_SOURCES = dialog.cpp input_dialog_SOURCES = input-dialog.cpp mandelbrot_SOURCES = mandelbrot.cpp calculator_SOURCES = calculator.cpp -fstring_SOURCES = fstring.cpp +string_SOURCES = string.cpp watch_SOURCES = watch.cpp timer_SOURCES = timer.cpp ui_SOURCES = ui.cpp diff --git a/test/Makefile.in b/test/Makefile.in index f6064613..ec0761af 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -83,7 +83,7 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ noinst_PROGRAMS = hello$(EXEEXT) dialog$(EXEEXT) input-dialog$(EXEEXT) \ - mandelbrot$(EXEEXT) calculator$(EXEEXT) fstring$(EXEEXT) \ + mandelbrot$(EXEEXT) calculator$(EXEEXT) string$(EXEEXT) \ watch$(EXEEXT) timer$(EXEEXT) ui$(EXEEXT) subdir = test DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ @@ -110,9 +110,6 @@ am__v_lt_1 = am_dialog_OBJECTS = dialog.$(OBJEXT) dialog_OBJECTS = $(am_dialog_OBJECTS) dialog_LDADD = $(LDADD) -am_fstring_OBJECTS = fstring.$(OBJEXT) -fstring_OBJECTS = $(am_fstring_OBJECTS) -fstring_LDADD = $(LDADD) am_hello_OBJECTS = hello.$(OBJEXT) hello_OBJECTS = $(am_hello_OBJECTS) hello_LDADD = $(LDADD) @@ -122,6 +119,9 @@ input_dialog_LDADD = $(LDADD) am_mandelbrot_OBJECTS = mandelbrot.$(OBJEXT) mandelbrot_OBJECTS = $(am_mandelbrot_OBJECTS) mandelbrot_LDADD = $(LDADD) +am_string_OBJECTS = string.$(OBJEXT) +string_OBJECTS = $(am_string_OBJECTS) +string_LDADD = $(LDADD) am_timer_OBJECTS = timer.$(OBJEXT) timer_OBJECTS = $(am_timer_OBJECTS) timer_LDADD = $(LDADD) @@ -165,12 +165,13 @@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = -SOURCES = $(calculator_SOURCES) $(dialog_SOURCES) $(fstring_SOURCES) \ - $(hello_SOURCES) $(input_dialog_SOURCES) $(mandelbrot_SOURCES) \ - $(timer_SOURCES) $(ui_SOURCES) $(watch_SOURCES) +SOURCES = $(calculator_SOURCES) $(dialog_SOURCES) $(hello_SOURCES) \ + $(input_dialog_SOURCES) $(mandelbrot_SOURCES) \ + $(string_SOURCES) $(timer_SOURCES) $(ui_SOURCES) \ + $(watch_SOURCES) DIST_SOURCES = $(calculator_SOURCES) $(dialog_SOURCES) \ - $(fstring_SOURCES) $(hello_SOURCES) $(input_dialog_SOURCES) \ - $(mandelbrot_SOURCES) $(timer_SOURCES) $(ui_SOURCES) \ + $(hello_SOURCES) $(input_dialog_SOURCES) $(mandelbrot_SOURCES) \ + $(string_SOURCES) $(timer_SOURCES) $(ui_SOURCES) \ $(watch_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ @@ -325,7 +326,7 @@ dialog_SOURCES = dialog.cpp input_dialog_SOURCES = input-dialog.cpp mandelbrot_SOURCES = mandelbrot.cpp calculator_SOURCES = calculator.cpp -fstring_SOURCES = fstring.cpp +string_SOURCES = string.cpp watch_SOURCES = watch.cpp timer_SOURCES = timer.cpp ui_SOURCES = ui.cpp @@ -381,10 +382,6 @@ dialog$(EXEEXT): $(dialog_OBJECTS) $(dialog_DEPENDENCIES) $(EXTRA_dialog_DEPENDE @rm -f dialog$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(dialog_OBJECTS) $(dialog_LDADD) $(LIBS) -fstring$(EXEEXT): $(fstring_OBJECTS) $(fstring_DEPENDENCIES) $(EXTRA_fstring_DEPENDENCIES) - @rm -f fstring$(EXEEXT) - $(AM_V_CXXLD)$(CXXLINK) $(fstring_OBJECTS) $(fstring_LDADD) $(LIBS) - hello$(EXEEXT): $(hello_OBJECTS) $(hello_DEPENDENCIES) $(EXTRA_hello_DEPENDENCIES) @rm -f hello$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(hello_OBJECTS) $(hello_LDADD) $(LIBS) @@ -397,6 +394,10 @@ mandelbrot$(EXEEXT): $(mandelbrot_OBJECTS) $(mandelbrot_DEPENDENCIES) $(EXTRA_ma @rm -f mandelbrot$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(mandelbrot_OBJECTS) $(mandelbrot_LDADD) $(LIBS) +string$(EXEEXT): $(string_OBJECTS) $(string_DEPENDENCIES) $(EXTRA_string_DEPENDENCIES) + @rm -f string$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(string_OBJECTS) $(string_LDADD) $(LIBS) + timer$(EXEEXT): $(timer_OBJECTS) $(timer_DEPENDENCIES) $(EXTRA_timer_DEPENDENCIES) @rm -f timer$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(timer_OBJECTS) $(timer_LDADD) $(LIBS) @@ -417,10 +418,10 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/calculator.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dialog.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstring.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hello.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/input-dialog.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mandelbrot.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/string.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ui.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/watch.Po@am__quote@ diff --git a/test/fstring.cpp b/test/string.cpp similarity index 100% rename from test/fstring.cpp rename to test/string.cpp