diff --git a/ChangeLog b/ChangeLog index 44bb1bd0..1bfce560 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2016-09-11 Markus Gans + * New zoom interaction-elements to maximize a FDialog + +2016-09-08 Markus Gans + * Different color when focusing the title bar button + * Move clearArea() from FWidget to FTerm + * Move setWidth(), setHeight() and setGeometry from + FDialog to FWindow + 2016-09-04 Markus Gans * FButton, FLineEdit and FProgressbar has shadow now enabled by default diff --git a/src/fdialog.cpp b/src/fdialog.cpp index 5a207a81..e86d464a 100644 --- a/src/fdialog.cpp +++ b/src/fdialog.cpp @@ -16,11 +16,14 @@ FDialog::FDialog(FWidget* parent) : FWindow(parent) , tb_text() , result_code(FDialog::Reject) - , maximized(false) + , zoom_button_pressed(false) + , zoom_button_active(false) , TitleBarClickPos() , oldGeometry() , dialog_menu() , dgl_menuitem() + , zoom_item() + , close_item() { init(); } @@ -30,11 +33,14 @@ FDialog::FDialog (const FString& txt, FWidget* parent) : FWindow(parent) , tb_text(txt) , result_code(FDialog::Reject) - , maximized(false) + , zoom_button_pressed(false) + , zoom_button_active(false) , TitleBarClickPos() , oldGeometry() , dialog_menu() , dgl_menuitem() + , zoom_item() + , close_item() { init(); } @@ -80,7 +86,6 @@ FDialog::~FDialog() // destructor //---------------------------------------------------------------------- void FDialog::init() { - FMenuItem* close_item; FWidget* old_focus; FWidget* rootObj = getRootWidget(); @@ -136,8 +141,18 @@ void FDialog::init() dgl_menuitem->unsetFocusable(); } + zoom_item = new FMenuItem ("&Zoom", dialog_menu); + zoom_item->setStatusbarMessage ("Enlarge or restore the window size"); + zoom_item->setDisable(); + + zoom_item->addCallback + ( + "clicked", + _METHOD_CALLBACK (this, &FDialog::cb_zoom) + ); + close_item = new FMenuItem ("&Close", dialog_menu); - close_item->setStatusbarMessage ("Close window"); + close_item->setStatusbarMessage ("Close this window"); close_item->addCallback ( @@ -155,18 +170,13 @@ void FDialog::drawBorder() y1 = ypos+ymin; y2 = ypos+ymin-2+height; + //if ( resize ) + // setColor (wc.dialog_resize_fg, backgroundColor); + if ( isNewFont() ) { - short fg; - - if ( ! isRootWidget() && getParentWidget() ) - fg = getParentWidget()->getForegroundColor(); - else - fg = wc.term_fg; - for (int y=y1; y <= y2; y++) { - setColor (fg, backgroundColor); gotoxy (x1, y); // border left ⎸ print (fc::NF_border_line_left); @@ -175,19 +185,16 @@ void FDialog::drawBorder() print (fc::NF_rev_border_line_right); } - if ( (flags & fc::shadow) == 0 ) - { - setColor (fg, backgroundColor); - gotoxy (x1, y2); - // lower left corner border ⎣ - print (fc::NF_border_corner_lower_left); - for (int x=1; x < width-1; x++) // low line _ - print (fc::NF_border_line_bottom); - gotoxy (x2, y2); - // lower right corner border ⎦ - print (fc::NF_rev_border_corner_lower_right); - } + gotoxy (x1, y2); + // lower left corner border ⎣ + print (fc::NF_border_corner_lower_left); + for (int x=1; x < width-1; x++) // low line _ + print (fc::NF_border_line_bottom); + + gotoxy (x2, y2); + // lower right corner border ⎦ + print (fc::NF_rev_border_corner_lower_right); } else { @@ -220,12 +227,16 @@ void FDialog::drawBorder() //---------------------------------------------------------------------- void FDialog::drawTitleBar() { - int i,x; - uInt length = tb_text.getLength(); + int i,x,length, zoom_btn; + const int menu_btn = 3; // draw the title button gotoxy (xpos+xmin-1, ypos+ymin-1); - setColor (wc.titlebar_button_fg, wc.titlebar_button_bg); + + if ( dialog_menu->isVisible() ) + setColor (wc.titlebar_button_focus_fg, wc.titlebar_button_focus_bg); + else + setColor (wc.titlebar_button_fg, wc.titlebar_button_bg); if ( isMonochron() ) { @@ -274,7 +285,15 @@ void FDialog::drawTitleBar() else setColor (wc.titlebar_inactive_fg, wc.titlebar_inactive_bg); - i = width - 3 - int(length); + if ( (flags & fc::resizeable) == 0 ) + zoom_btn = 0; + else if ( isNewFont() ) + zoom_btn = 2; + else + zoom_btn = 3; + + length = int(tb_text.getLength()); + i = width - length - menu_btn - zoom_btn; i = int(i/2); for (x=1; x <= i; x++) @@ -285,12 +304,78 @@ void FDialog::drawTitleBar() print (tb_text); // fill the rest of the bar - for (; x+1+int(length) < width-1; x++) + for (; x+1+length < width-zoom_btn-1; x++) print (' '); if ( getMaxColor() < 16 ) unsetBold(); + // draw the zoom/unzoom button + if ( (flags & fc::resizeable) != 0 ) + { + if ( zoom_button_pressed ) + setColor (wc.titlebar_button_focus_fg, wc.titlebar_button_focus_bg); + else + setColor (wc.titlebar_button_fg, wc.titlebar_button_bg); + + if ( isZoomed() ) + { + if ( isNewFont() ) + { + print (fc::NF_rev_down_pointing_triangle1); + print (fc::NF_rev_down_pointing_triangle2); + } + else + { + if ( isMonochron() ) + { + print ('['); + print (fc::BlackDownPointingTriangle); // ▼ + print (']'); + } + else + { + print (' '); + + if ( isCygwinTerminal() ) + print ('v'); + else + print (fc::BlackDownPointingTriangle); // ▼ + + print (' '); + } + } + } + else // is not zoomed + { + if ( isNewFont() ) + { + print (fc::NF_rev_up_pointing_triangle1); + print (fc::NF_rev_up_pointing_triangle2); + } + else + { + if ( isMonochron() ) + { + print ('['); + print (fc::BlackUpPointingTriangle); // ▲ + print (']'); + } + else + { + print (' '); + + if ( isCygwinTerminal() ) + print ('^'); + else + print (fc::BlackUpPointingTriangle); // ▲ + + print (' '); + } + } + } + } + if ( isMonochron() ) setReverse(false); @@ -320,6 +405,16 @@ void FDialog::leaveMenu() flush_out(); } +//---------------------------------------------------------------------- +void FDialog::cb_zoom (FWidget*, void*) +{ + dialog_menu->unselectItem(); + dialog_menu->hide(); + setClickedWidget(0); + drawTitleBar(); + zoomWindow(); +} + //---------------------------------------------------------------------- void FDialog::cb_close (FWidget*, void*) { @@ -372,61 +467,26 @@ void FDialog::done(int result) //---------------------------------------------------------------------- void FDialog::drawDialogShadow() { - if ((flags & fc::trans_shadow) != 0) - { - // transparent shadow - drawShadow(); + if ( isMonochron() && (flags & fc::trans_shadow) == 0 ) + return; - if ( isNewFont() && ((flags & fc::scrollable) == 0) ) - { - // left of the shadow ▀▀ - gotoxy (xpos+xmin-1, ypos+ymin-1+height); - setColor (wc.shadow_fg, wc.shadow_bg); - // current background color will be ignored - setInheritBackground(); - - for (int x=0; x <= 1; x++) - print (fc::NF_border_line_upper); // high line ⎺ - - unsetInheritBackground(); - } - } - else - { - if ( isMonochron() ) - return; - - drawShadow(); - // left of the shadow ▀▀ - gotoxy (xpos+xmin-1, ypos+ymin-1+height); - - if ( isNewFont() && ((flags & fc::scrollable) == 0) ) - { - setColor (wc.shadow_fg, wc.shadow_bg); - // current background color will be ignored - setInheritBackground(); - print (fc::NF_border_line_upper); // high line ⎺ - unsetInheritBackground(); - } - else - { - setTransparent(); - print(' '); - unsetTransparent(); - } - } + drawShadow(); + gotoxy (xpos+xmin-1, ypos+ymin-1+height); + setTransparent(); + print(' '); + unsetTransparent(); } //---------------------------------------------------------------------- void FDialog::draw() { - if ( maximized && ! isRootWidget() ) + /*if ( isZoomed() && ! isRootWidget() ) { xpos = 1; ypos = 1; width = xmax; height = ymax; - } + }*/ updateVTerm(false); // fill the background @@ -439,62 +499,9 @@ void FDialog::draw() drawBorder(); drawTitleBar(); - if ( ! maximized && (flags & fc::shadow) != 0 ) + if ( (flags & fc::shadow) != 0 ) drawDialogShadow(); - if ( (flags & fc::resizeable) != 0 ) - { - if ( isMonochron() ) - setReverse(false); - - if ( maximized ) - { - if ( isNewFont() ) - { - gotoxy (xpos+xmin+width-3, ypos+ymin-1); - setColor (wc.titlebar_button_fg, wc.titlebar_button_bg); - print (fc::NF_rev_down_pointing_triangle1); - print (fc::NF_rev_down_pointing_triangle2); - } - else - { - gotoxy (xpos+xmin+width-4, ypos+ymin-1); - setColor (wc.titlebar_button_fg, wc.titlebar_button_bg); - print (' '); - - if ( isCygwinTerminal() ) - print ('v'); - else - print (fc::BlackDownPointingTriangle); // ▼ - - print (' '); - } - } - else - { - if ( isNewFont() ) - { - gotoxy (xpos+xmin+width-3, ypos+ymin-1); - setColor (wc.titlebar_button_fg, wc.titlebar_button_bg); - print (fc::NF_rev_up_pointing_triangle1); - print (fc::NF_rev_up_pointing_triangle2); - } - else - { - gotoxy (xpos+xmin+width-4, ypos+ymin-1); - setColor (wc.titlebar_button_fg, wc.titlebar_button_bg); - print (' '); - - if ( isCygwinTerminal() ) - print ('^'); - else - print (fc::BlackUpPointingTriangle); // ▲ - - print (' '); - } - } - } - if ( isMonochron() ) setReverse(false); @@ -540,13 +547,28 @@ void FDialog::onMouseDown (FMouseEvent* ev) { int mouse_x = ev->getX(); int mouse_y = ev->getY(); + int zoom_btn; + + if ( (flags & fc::resizeable) == 0 ) + zoom_btn = 0; + else if ( isNewFont() ) + zoom_btn = 2; + else + zoom_btn = 3; + + if ( zoom_button_pressed || zoom_button_active ) + { + zoom_button_pressed = false; + zoom_button_active = false; + drawTitleBar(); + } if ( ev->getButton() == fc::LeftButton ) { bool has_raised; // click on titlebar or window: raise + activate - if ( mouse_x >= 4 && mouse_x <= width && mouse_y == 1 ) + if ( mouse_x >= 4 && mouse_x <= width-zoom_btn && mouse_y == 1 ) TitleBarClickPos.setPoint (ev->getGlobalX(), ev->getGlobalY()); else TitleBarClickPos.setPoint (0,0); @@ -563,17 +585,27 @@ void FDialog::onMouseDown (FMouseEvent* ev) if ( mouse_x < 4 && mouse_y == 1 ) { if ( dialog_menu->isVisible() ) + { leaveMenu(); + drawTitleBar(); + } else { setOpenMenu(dialog_menu); dialog_menu->move (xpos, ypos+1); dialog_menu->setVisible(); + drawTitleBar(); dialog_menu->show(); dialog_menu->raiseWindow(dialog_menu); dialog_menu->redraw(); } } + else if ( mouse_x > width-zoom_btn && mouse_y == 1 ) + { + zoom_button_pressed = true; + zoom_button_active = true; + drawTitleBar(); + } } else // ev->getButton() != fc::LeftButton { @@ -612,6 +644,14 @@ void FDialog::onMouseUp (FMouseEvent* ev) { int titlebar_x = TitleBarClickPos.getX(); int titlebar_y = TitleBarClickPos.getY(); + int zoom_btn; + + if ( (flags & fc::resizeable) == 0 ) + zoom_btn = 0; + else if ( isNewFont() ) + zoom_btn = 2; + else + zoom_btn = 3; if ( ev->getButton() == fc::LeftButton ) { @@ -650,14 +690,40 @@ void FDialog::onMouseUp (FMouseEvent* ev) updateTerminal(); flush_out(); } + else if ( mouse_x > width - zoom_btn + && mouse_y == 1 + && zoom_button_pressed ) + { + // zoom to maximum or restore the window size + zoomWindow(); + } + } + + if ( zoom_button_pressed || zoom_button_active ) + { + zoom_button_pressed = false; + zoom_button_active = false; + drawTitleBar(); } } //---------------------------------------------------------------------- void FDialog::onMouseMove (FMouseEvent* ev) { + int zoom_btn; + + if ( (flags & fc::resizeable) == 0 ) + zoom_btn = 0; + else if ( isNewFont() ) + zoom_btn = 2; + else + zoom_btn = 3; + if ( ev->getButton() == fc::LeftButton ) { + int mouse_x = ev->getX(); + int mouse_y = ev->getY(); + if ( ! TitleBarClickPos.isNull() ) { FPoint currentPos(getGeometry().getX(), getGeometry().getY()); @@ -684,6 +750,18 @@ void FDialog::onMouseMove (FMouseEvent* ev) delete _ev; } } + + if ( mouse_x > width - zoom_btn && mouse_y == 1 && zoom_button_active ) + { + zoom_button_pressed = true; + drawTitleBar(); + } + else if ( zoom_button_pressed ) + { + zoom_button_pressed = false; + drawTitleBar(); + } + } } @@ -882,6 +960,9 @@ void FDialog::move (int x, int y) if ( x+width < 1 || x > getColumnNumber() || y < 1 || y > getLineNumber() ) return; + if ( isZoomed() ) + return; + dx = xpos - x; dy = ypos - y; old_x = getGlobalX(); @@ -998,37 +1079,6 @@ void FDialog::activateDialog() updateTerminal(); } -//---------------------------------------------------------------------- -void FDialog::setWidth (int w, bool adjust) -{ - int old_width = width; - FWidget::setWidth (w, adjust); - - if ( vwin && width != old_width ) - resizeArea (vwin); -} - -//---------------------------------------------------------------------- -void FDialog::setHeight (int h, bool adjust) -{ - int old_height = height; - FWidget::setHeight (h, adjust); - - if ( vwin && height != old_height ) - resizeArea (vwin); -} - -//---------------------------------------------------------------------- -void FDialog::setGeometry (int x, int y, int w, int h, bool adjust) -{ - int old_width = width; - int old_height = height; - FWidget::setGeometry (x, y, w, h, adjust); - - if ( vwin && (width != old_width || height != old_height) ) - resizeArea (vwin); -} - //---------------------------------------------------------------------- bool FDialog::setFocus (bool on) { @@ -1128,21 +1178,15 @@ bool FDialog::setScrollable (bool on) bool FDialog::setResizeable (bool on) { if ( on ) + { flags |= fc::resizeable; + zoom_item->setEnable(); + } else + { flags &= ~fc::resizeable; + zoom_item->setDisable(); + } return on; } - -//---------------------------------------------------------------------- -bool FDialog::setMaximized() -{ - if ( maximized ) - return true; - - maximized = true; - //setGeometry (1, 1, xmax, ymax); - - return maximized; -} diff --git a/src/fdialog.h b/src/fdialog.h index 93917de3..aa4bc389 100644 --- a/src/fdialog.h +++ b/src/fdialog.h @@ -52,11 +52,14 @@ class FDialog : public FWindow private: FString tb_text; // title bar text int result_code; - bool maximized; + bool zoom_button_pressed; + bool zoom_button_active; FPoint TitleBarClickPos; FRect oldGeometry; // required by move() FMenu* dialog_menu; FMenuItem* dgl_menuitem; + FMenuItem* zoom_item; + FMenuItem* close_item; private: FDialog (const FDialog&); @@ -65,6 +68,7 @@ class FDialog : public FWindow void drawBorder(); void drawTitleBar(); void leaveMenu(); + void cb_zoom (FWidget*, void*); void cb_close (FWidget*, void*); static void addDialog (FWidget*); static void delDialog (FWidget*); @@ -100,11 +104,6 @@ class FDialog : public FWindow void move (const FPoint&); void move (int, int); - void setWidth (int, bool = true); - void setHeight (int, bool = true); - // make every setGeometry from FWidget available - using FWidget::setGeometry; - void setGeometry (int, int, int, int, bool = true); bool setFocus(bool); bool setFocus(); bool unsetFocus(); @@ -120,8 +119,6 @@ class FDialog : public FWindow bool setResizeable(); bool unsetResizeable(); bool isResizeable(); - bool setMaximized(); - bool isMaximized() const; bool setTransparentShadow(bool); bool setTransparentShadow(); bool unsetTransparentShadow(); @@ -187,10 +184,6 @@ inline bool FDialog::unsetResizeable() inline bool FDialog::isResizeable() { return ((flags & fc::resizeable) != 0); } -//---------------------------------------------------------------------- -inline bool FDialog::isMaximized() const -{ return maximized; } - //---------------------------------------------------------------------- inline bool FDialog::setTransparentShadow() { return setTransparentShadow(true); } diff --git a/src/fterm.cpp b/src/fterm.cpp index 3813342e..e30da496 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -2921,6 +2921,101 @@ void FTerm::putArea (int ax, int ay, FTerm::term_area* area) } } +//---------------------------------------------------------------------- +void FTerm::clearArea() +{ + term_area* area; + FWindow* area_widget; + FWidget* widget; + FOptiAttr::char_data default_char; + int total_width; + uInt w; + + default_char.code = ' '; + default_char.fg_color = next_attribute.fg_color; + default_char.bg_color = next_attribute.bg_color; + default_char.bold = next_attribute.bold; + default_char.dim = next_attribute.dim; + default_char.italic = next_attribute.italic; + default_char.underline = next_attribute.underline; + default_char.blink = next_attribute.blink; + default_char.reverse = next_attribute.reverse; + default_char.standout = next_attribute.standout; + default_char.invisible = next_attribute.invisible; + default_char.protect = next_attribute.protect; + default_char.crossed_out = next_attribute.crossed_out; + default_char.dbl_underline = next_attribute.dbl_underline; + default_char.alt_charset = next_attribute.alt_charset; + default_char.pc_charset = next_attribute.pc_charset; + default_char.transparent = next_attribute.transparent; + default_char.trans_shadow = next_attribute.trans_shadow; + default_char.inherit_bg = next_attribute.inherit_bg; + + widget = static_cast(this); + area_widget = FWindow::getWindowWidget(widget); + + if ( area_widget ) + area = area_widget->getVWin(); + else + area = vdesktop; + + if ( ! area ) + return; + + total_width = area->width + area->right_shadow; + w = uInt(total_width); + + if ( area->right_shadow == 0 ) + { + int area_size = area->width * area->height; + std::fill_n (area->text, area_size, default_char); + } + else + { + FOptiAttr::char_data t_char = default_char; + t_char.transparent = true; + + for (int y=0; y < area->height; y++) + { + int pos = y * total_width; + std::fill_n (&area->text[pos], total_width, default_char); + std::fill_n (&area->text[pos+area->width], area->right_shadow, t_char); + } + + for (int y=0; y < area->bottom_shadow; y++) + { + int pos = total_width * (y + area->height); + std::fill_n (&area->text[pos], total_width, t_char); + } + } + + for (int i=0; i < area->height; i++) + { + + area->changes[i].xmin = 0; + area->changes[i].xmax = w - 1; + + if ( default_char.transparent + || default_char.trans_shadow + || default_char.inherit_bg ) + area->changes[i].trans_count = w; + else if ( area->right_shadow != 0 ) + area->changes[i].trans_count = uInt(area->right_shadow); + else + area->changes[i].trans_count = 0; + } + + for (int i=0; i < area->bottom_shadow; i++) + { + int y = area->height + i; + area->changes[y].xmin = 0; + area->changes[y].xmax = w - 1; + area->changes[y].trans_count = w; + } + + updateVTerm (area); +} + //---------------------------------------------------------------------- FOptiAttr::char_data FTerm::getCharacter ( int char_type , int x diff --git a/src/fterm.h b/src/fterm.h index f7842c4c..5c774934 100644 --- a/src/fterm.h +++ b/src/fterm.h @@ -300,6 +300,7 @@ class FTerm void getArea (int, int, int, int, FTerm::term_area*); void putArea (const FPoint&, FTerm::term_area*); void putArea (int, int, FTerm::term_area*); + void clearArea(); FOptiAttr::char_data getCharacter (int, const FPoint&, FTerm*); FOptiAttr::char_data getCharacter (int, int, int, FTerm*); FOptiAttr::char_data getCoveredCharacter (const FPoint&, FTerm*); diff --git a/src/fwidget.cpp b/src/fwidget.cpp index 49980c79..86b08d00 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -218,6 +218,7 @@ void FWidget::setColorTheme() wc.selected_list_fg = fc::Cyan; wc.selected_list_bg = fc::White; wc.dialog_fg = fc::Black; + wc.dialog_resize_fg = fc::Red; wc.dialog_emphasis_fg = fc::Blue; wc.dialog_bg = fc::White; wc.error_box_fg = fc::White; @@ -267,6 +268,8 @@ void FWidget::setColorTheme() wc.titlebar_inactive_bg = fc::DarkGray; wc.titlebar_button_fg = fc::DarkGray; wc.titlebar_button_bg = fc::LightGray; + wc.titlebar_button_focus_fg = fc::LightGray; + wc.titlebar_button_focus_bg = fc::Black; wc.menu_active_focus_fg = fc::White; wc.menu_active_focus_bg = fc::Blue; wc.menu_active_fg = fc::Black; @@ -306,6 +309,7 @@ void FWidget::setColorTheme() wc.selected_list_fg = fc::Blue; wc.selected_list_bg = fc::LightGray; wc.dialog_fg = fc::Black; + wc.dialog_resize_fg = fc::Red; wc.dialog_emphasis_fg = fc::Blue; wc.dialog_bg = fc::LightGray; wc.error_box_fg = fc::Black; @@ -355,6 +359,8 @@ void FWidget::setColorTheme() wc.titlebar_inactive_bg = fc::LightGray; wc.titlebar_button_fg = fc::Black; wc.titlebar_button_bg = fc::LightGray; + wc.titlebar_button_focus_fg = fc::LightGray; + wc.titlebar_button_focus_bg = fc::Black; wc.menu_active_focus_fg = fc::LightGray; wc.menu_active_focus_bg = fc::Blue; wc.menu_active_fg = fc::Black; @@ -1854,6 +1860,8 @@ void FWidget::setTermGeometry (int w, int h) //---------------------------------------------------------------------- void FWidget::setGeometry (int x, int y, int w, int h, bool adjust) { + int global_x, global_y; + if ( xpos == x && ypos == y && width == w && height == h ) return; @@ -1876,13 +1884,12 @@ void FWidget::setGeometry (int x, int y, int w, int h, bool adjust) client_xmax = xpos + xmin - 2 + width - right_padding; client_ymax = ypos + ymin - 2 + height - bottom_padding; - widgetSize.setRect(xpos, ypos, width, height); - adjustWidgetSize.setRect(xpos, ypos, width, height); + widgetSize.setRect (xpos, ypos, width, height); + adjustWidgetSize.setRect (xpos, ypos, width, height); adjustWidgetSizeShadow = adjustWidgetSize + shadow; - adjustWidgetSizeGlobal.setRect ( xpos + xmin - 1 - , ypos + ymin - 1 - , width - , height ); + global_x = xpos + xmin - 1; + global_y = ypos + ymin - 1; + adjustWidgetSizeGlobal.setRect (global_x, global_y, width, height); adjustWidgetSizeGlobalShadow = adjustWidgetSizeGlobal + shadow; double_flatline_mask.top.resize (uLong(width), false); @@ -1938,99 +1945,6 @@ bool FWidget::setCursorPos (register int x, register int y) return false; } -//---------------------------------------------------------------------- -void FWidget::clearArea() -{ - term_area* area; - FWindow* area_widget; - FOptiAttr::char_data default_char; - int total_width; - uInt w; - - default_char.code = ' '; - default_char.fg_color = next_attribute.fg_color; - default_char.bg_color = next_attribute.bg_color; - default_char.bold = next_attribute.bold; - default_char.dim = next_attribute.dim; - default_char.italic = next_attribute.italic; - default_char.underline = next_attribute.underline; - default_char.blink = next_attribute.blink; - default_char.reverse = next_attribute.reverse; - default_char.standout = next_attribute.standout; - default_char.invisible = next_attribute.invisible; - default_char.protect = next_attribute.protect; - default_char.crossed_out = next_attribute.crossed_out; - default_char.dbl_underline = next_attribute.dbl_underline; - default_char.alt_charset = next_attribute.alt_charset; - default_char.pc_charset = next_attribute.pc_charset; - default_char.transparent = next_attribute.transparent; - default_char.trans_shadow = next_attribute.trans_shadow; - default_char.inherit_bg = next_attribute.inherit_bg; - - area_widget = FWindow::getWindowWidget(this); - - if ( area_widget ) - area = area_widget->getVWin(); - else - area = vdesktop; - - if ( ! area ) - return; - - total_width = area->width + area->right_shadow; - w = uInt(total_width); - - if ( area->right_shadow == 0 ) - { - int area_size = area->width * area->height; - std::fill_n (area->text, area_size, default_char); - } - else - { - FOptiAttr::char_data t_char = default_char; - t_char.transparent = true; - - for (int y=0; y < area->height; y++) - { - int pos = y * total_width; - std::fill_n (&area->text[pos], total_width, default_char); - std::fill_n (&area->text[pos+area->width], area->right_shadow, t_char); - } - - for (int y=0; y < area->bottom_shadow; y++) - { - int pos = total_width * (y + area->height); - std::fill_n (&area->text[pos], total_width, t_char); - } - } - - for (int i=0; i < area->height; i++) - { - - area->changes[i].xmin = 0; - area->changes[i].xmax = w - 1; - - if ( default_char.transparent - || default_char.trans_shadow - || default_char.inherit_bg ) - area->changes[i].trans_count = w; - else if ( area->right_shadow != 0 ) - area->changes[i].trans_count = uInt(area->right_shadow); - else - area->changes[i].trans_count = 0; - } - - for (int i=0; i < area->bottom_shadow; i++) - { - int y = area->height + i; - area->changes[y].xmin = 0; - area->changes[y].xmax = w - 1; - area->changes[y].trans_count = w; - } - - updateVTerm (area); -} - //---------------------------------------------------------------------- void FWidget::drawShadow() { @@ -2279,7 +2193,7 @@ void FWidget::clearFlatBorder() if ( double_flatline_mask.right[uLong(y)] ) print (fc::NF_rev_border_line_right); else - print (' '); + print (' '); } // clear at top diff --git a/src/fwidget.h b/src/fwidget.h index 85ad935d..55b9bf8e 100644 --- a/src/fwidget.h +++ b/src/fwidget.h @@ -162,6 +162,7 @@ class FWidget : public FObject, public FTerm short inputfield_inactive_fg; short inputfield_inactive_bg; short dialog_fg; + short dialog_resize_fg; short dialog_emphasis_fg; short dialog_bg; short error_box_fg; @@ -188,6 +189,8 @@ class FWidget : public FObject, public FTerm short titlebar_inactive_bg; short titlebar_button_fg; short titlebar_button_bg; + short titlebar_button_focus_fg; + short titlebar_button_focus_bg; short menu_active_focus_fg; short menu_active_focus_bg; short menu_active_fg; @@ -409,6 +412,8 @@ class FWidget : public FObject, public FTerm int getRightPadding() const; int getClientWidth() const; int getClientHeight() const; + int getMaxWidth() const; + int getMinHeight() const; const FPoint& getShadow() const; const FRect& getGeometry() const; const FRect& getGeometryShadow() const; @@ -444,7 +449,6 @@ class FWidget : public FObject, public FTerm static void gotoxy (const FPoint&); static void gotoxy (register int, register int); - void clearArea(); static void setNormal(); @@ -756,6 +760,14 @@ inline int FWidget::getClientWidth() const inline int FWidget::getClientHeight() const { return client_ymax-client_ymin+1; } +//---------------------------------------------------------------------- +inline int FWidget::getMaxWidth() const +{ return xmax-xmin+1; } + +//---------------------------------------------------------------------- +inline int FWidget::getMinHeight() const +{ return ymax-ymin+1; } + //---------------------------------------------------------------------- inline const FPoint& FWidget::getShadow() const { return shadow; } diff --git a/src/fwindow.cpp b/src/fwindow.cpp index a609244f..cbc801b6 100644 --- a/src/fwindow.cpp +++ b/src/fwindow.cpp @@ -18,7 +18,11 @@ FWindow* FWindow::previous_widget = 0; FWindow::FWindow(FWidget* parent) : FWidget(parent) , window_active(false) + , zoomed(false) , win_focus_widget(0) + , normalGeometry() + , maxGeometry() + , minGeometry() { window_object = true; } @@ -99,6 +103,37 @@ void FWindow::hide() FWidget::hide(); } +//---------------------------------------------------------------------- +void FWindow::setWidth (int w, bool adjust) +{ + int old_width = width; + FWidget::setWidth (w, adjust); + + if ( vwin && width != old_width ) + resizeArea (vwin); +} + +//---------------------------------------------------------------------- +void FWindow::setHeight (int h, bool adjust) +{ + int old_height = height; + FWidget::setHeight (h, adjust); + + if ( vwin && height != old_height ) + resizeArea (vwin); +} + +//---------------------------------------------------------------------- +void FWindow::setGeometry (int x, int y, int w, int h, bool adjust) +{ + int old_width = width; + int old_height = height; + FWidget::setGeometry (x, y, w, h, adjust); + + if ( vwin && (width != old_width || height != old_height) ) + resizeArea (vwin); +} + //---------------------------------------------------------------------- FWindow* FWindow::getWindowWidgetAt (int x, int y) { @@ -335,6 +370,29 @@ bool FWindow::lowerWindow (FWidget* obj) return false; } +//---------------------------------------------------------------------- +bool FWindow::zoomWindow() +{ + if ( zoomed ) + { + zoomed = false; + FRect currentGeometry = getGeometryShadow(); + setGeometry (normalGeometry); + restoreVTerm (currentGeometry); + redraw(); + } + else + { + zoomed = true; + // save the current geometry + normalGeometry = getGeometry(); + setGeometry (1, 1, getMaxWidth(), getMinHeight()); + redraw(); + } + + return zoomed; +} + //---------------------------------------------------------------------- FWindow* FWindow::getActiveWindow() { diff --git a/src/fwindow.h b/src/fwindow.h index 9567dba7..e0b05b26 100644 --- a/src/fwindow.h +++ b/src/fwindow.h @@ -45,7 +45,11 @@ class FWindow : public FWidget { private: bool window_active; + bool zoomed; FWidget* win_focus_widget; + FRect normalGeometry; + FRect maxGeometry; + FRect minGeometry; protected: static FWindow* previous_widget; @@ -69,6 +73,11 @@ class FWindow : public FWidget const char* getClassName() const; virtual void show(); virtual void hide(); + void setWidth (int, bool = true); + void setHeight (int, bool = true); + // make every setGeometry from FWidget available + using FWidget::setGeometry; + void setGeometry (int, int, int, int, bool = true); static FWindow* getWindowWidgetAt (const FPoint&); static FWindow* getWindowWidgetAt (int, int); static void addWindow (FWidget*); @@ -80,6 +89,8 @@ class FWindow : public FWidget bool raiseWindow (); static bool lowerWindow (FWidget*); bool lowerWindow (); + bool zoomWindow (); + bool isZoomed() const; static FWindow* getActiveWindow(); static void setActiveWindow (FWindow*); FWidget* getWindowFocusWidget() const; @@ -112,6 +123,10 @@ inline bool FWindow::raiseWindow() inline bool FWindow::lowerWindow() { return lowerWindow(this); } +//---------------------------------------------------------------------- +inline bool FWindow::isZoomed() const +{ return zoomed; } + //---------------------------------------------------------------------- inline bool FWindow::activateWindow() { return activateWindow(true); } diff --git a/test/ui.cpp b/test/ui.cpp index 4765bcc2..f4ee3c11 100644 --- a/test/ui.cpp +++ b/test/ui.cpp @@ -154,6 +154,68 @@ void ProgressDialog::cb_exit_bar (FWidget*, void*) } +//---------------------------------------------------------------------- +// class TextWindow +//---------------------------------------------------------------------- + +#pragma pack(push) +#pragma pack(1) + +class TextWindow : public FDialog +{ + private: + FTextView* scrollText; + + private: + TextWindow (const TextWindow&); // Disabled copy constructor + TextWindow& operator = (const TextWindow&); // and operator '=' + void adjustSize(); + + public: + explicit TextWindow (FWidget* = 0); // constructor + ~TextWindow(); // destructor + + void append (const FString&); +}; +#pragma pack(pop) + +//---------------------------------------------------------------------- +TextWindow::TextWindow (FWidget* parent) + : FDialog(parent) + , scrollText() +{ + scrollText = new FTextView(this); + scrollText->ignorePadding(); + scrollText->setGeometry (1, 2, getWidth(), getHeight()-1); + scrollText->setFocus(); + scrollText->insert(" -----------------------------------------------\n" + " line 1\n" + " -----------------------------------------------\n" + " line 3\n" + " line 4" + , -1); + scrollText->replaceRange(" File viewer", 1, 1); + scrollText->deleteRange(3, 4); +} + +//---------------------------------------------------------------------- +TextWindow::~TextWindow() +{ } + +//---------------------------------------------------------------------- +void TextWindow::append (const FString& str) +{ + scrollText->append(str); +} + +//---------------------------------------------------------------------- +void TextWindow::adjustSize() +{ + scrollText->setGeometry (1, 2, getWidth(), getHeight()-1); + FDialog::adjustSize(); +} + + //---------------------------------------------------------------------- // class MyDialog //---------------------------------------------------------------------- @@ -745,26 +807,15 @@ void MyDialog::cb_view (FWidget*, void* data_ptr) if ( file.isNull() ) return; - FDialog* view = new FDialog(this); + TextWindow* view = new TextWindow(this); FString filename(basename(const_cast(file.c_str()))); view->setText ("Viewer: " + filename); view->setGeometry (1+int((getRootWidget()->getWidth()-60)/2), int(getRootWidget()->getHeight()/6), 60, int(getRootWidget()->getHeight()*3/4)); + view->setResizeable(); - FTextView* scrollText = new FTextView(view); - scrollText->ignorePadding(); - scrollText->setGeometry (1, 2, view->getWidth(), view->getHeight()-1); - scrollText->setFocus(); - scrollText->insert(" -----------------------------------------------\n" - " line 1\n" - " -----------------------------------------------\n" - " line 3\n" - " line 4" - , -1); - scrollText->replaceRange(" File viewer", 1, 1); - scrollText->deleteRange(3, 4); std::string line = ""; std::ifstream infile; infile.open(file); @@ -772,7 +823,7 @@ void MyDialog::cb_view (FWidget*, void* data_ptr) while ( ! infile.eof() && infile.good() ) { getline(infile, line); - scrollText->append(line); + view->append(line); } if ( infile.is_open() ) diff --git a/test/windows.cpp b/test/windows.cpp index fc860169..cd713039 100644 --- a/test/windows.cpp +++ b/test/windows.cpp @@ -239,6 +239,7 @@ void Window::cb_createWindows (FWidget*, void*) x = dx + 5 + (n%3)*25 + int(n/3)*3; y = dy + 11 + int(n/3)*3; win->setGeometry (x, y, 20, 8); + win->setResizeable(); win->show(); win->addCallback