Virtual windows can now store their own offset information

This commit is contained in:
Markus Gans 2016-10-14 13:02:35 +02:00
parent d9e5aac828
commit 17b59cf50d
18 changed files with 271 additions and 173 deletions

View File

@ -1,3 +1,7 @@
2016-10-14 Markus Gans <guru.mail@muenster.de>
* Virtual windows can now store their own offset information
* Correct implementation of the move() method
2016-10-13 Markus Gans <guru.mail@muenster.de>
* Reduces in the code the number of friend classes

View File

@ -107,7 +107,7 @@ void FDialog::init()
accelerator_list = new Accelerators();
// Add the dialog menu
dialog_menu = new FMenu ("-", this);
dialog_menu->move (getX(), getY()+1);
dialog_menu->setPos (getX(), getY()+1);
dgl_menuitem = dialog_menu->getItem();
if ( dgl_menuitem )
@ -154,7 +154,8 @@ void FDialog::drawBorder()
int y1 = 2;
int y2 = 1 + getHeight() - 1;
if ( (getMoveSizeWidget() || ! resize_click_pos.isNull()) && ! isZoomed() )
if ( (getMoveSizeWidget() == this || ! resize_click_pos.isNull())
&& ! isZoomed() )
setColor (wc.dialog_resize_fg, getBackgroundColor());
else
setColor();
@ -392,7 +393,7 @@ void FDialog::openMenu()
else
{
setOpenMenu(dialog_menu);
dialog_menu->move (getX(), getY()+1);
dialog_menu->setPos (getX(), getY()+1);
dialog_menu->setVisible();
drawTitleBar();
dialog_menu->show();
@ -445,6 +446,7 @@ void FDialog::cb_move (FWidget*, void*)
return;
setMoveSizeWidget(this);
drawBorder();
save_geometry = getGeometry();
tooltip = new FToolTip(this);
@ -620,22 +622,22 @@ void FDialog::onKeyPress (FKeyEvent* ev)
switch ( ev->key() )
{
case fc::Fkey_up:
move (getX(), getY() - 1);
move (0, -1);
ev->accept();
break;
case fc::Fkey_down:
move (getX(), getY() + 1);
move (0, 1);
ev->accept();
break;
case fc::Fkey_left:
move (getX() - 1, getY());
move (-1, 0);
ev->accept();
break;
case fc::Fkey_right:
move (getX() + 1, getY());
move (1, 0);
ev->accept();
break;
@ -695,7 +697,7 @@ void FDialog::onKeyPress (FKeyEvent* ev)
delete tooltip;
tooltip = 0;
move (save_geometry.getPos());
setPos (save_geometry.getPos());
if ( isResizeable() )
setSize (save_geometry.getWidth(), save_geometry.getHeight());
@ -859,9 +861,8 @@ void FDialog::onMouseUp (FMouseEvent* ev)
&& titlebar_x < getTermX() + getWidth()
&& titlebar_y == getTermY() )
{
FPoint currentPos(getGeometry().getX(), getGeometry().getY());
FPoint deltaPos = ev->getTermPos() - titlebar_click_pos;
move (currentPos + deltaPos);
move (deltaPos);
titlebar_click_pos = ev->getTermPos();
}
@ -953,9 +954,8 @@ void FDialog::onMouseMove (FMouseEvent* ev)
if ( ! titlebar_click_pos.isNull() )
{
FPoint currentPos(getGeometry().getX(), getGeometry().getY());
FPoint deltaPos = ev->getTermPos() - titlebar_click_pos;
move (currentPos + deltaPos);
move (deltaPos);
titlebar_click_pos = ev->getTermPos();
}
@ -1218,13 +1218,7 @@ int FDialog::exec()
}
//----------------------------------------------------------------------
void FDialog::move (const FPoint& pos)
{
move ( pos.getX(), pos.getY() );
}
//----------------------------------------------------------------------
void FDialog::move (int x, int y)
void FDialog::setPos (int x, int y, bool)
{
int dx, dy, old_x, old_y, rsw, bsh, width, height;
FRect old_geometry;
@ -1252,8 +1246,7 @@ void FDialog::move (int x, int y)
old_geometry = getTermGeometryWithShadow();
// move to the new position
FWidget::move(x,y);
setPos(x, y, false);
FWindow::setPos(x, y, false);
putArea (getTermPos(), vwin);
// restoring the non-covered terminal areas
@ -1311,7 +1304,7 @@ void FDialog::move (int x, int y)
}
}
FWidget::adjustSize();
FWindow::adjustSize();
// set the cursor to the focus widget
FWidget* focus_widget = FWidget::getFocusWidget();
@ -1326,6 +1319,12 @@ void FDialog::move (int x, int y)
updateTerminal();
}
//----------------------------------------------------------------------
void FDialog::move (int dx, int dy)
{
setPos (getX() + dx, getY() + dy);
}
//----------------------------------------------------------------------
void FDialog::setSize (int w, int h, bool adjust)
{

View File

@ -127,8 +127,12 @@ class FDialog : public FWindow
void show();
void hide();
int exec();
void move (const FPoint&);
void setPos (int, int, bool = true);
// make every setPos from FWindow available
using FWindow::setPos;
void move (int, int);
// make every move from FWindow available
using FWindow::move;
void setSize (int, int, bool = true);
bool setFocus (bool);

View File

@ -199,7 +199,7 @@ void FMenu::adjustItems()
menu_Y = (*iter)->getTermY() - 2;
// set sub-menu position
menu->move (menu_X, menu_Y);
menu->setPos (menu_X, menu_Y);
// call sub-menu adjustItems()
if ( menu->count() > 0 )

View File

@ -477,7 +477,7 @@ void FMenuBar::adjustItems()
FMenu* menu = (*iter)->getMenu();
// set menu position
menu->move (menu->adjustX(item_X), item_Y);
menu->setPos (menu->adjustX(item_X), item_Y);
// call menu adjustItems()
menu->adjustItems();

View File

@ -103,7 +103,7 @@ void FVTerm::init()
tcap = FTermcap().getTermcapMap();
// create virtual terminal
FRect term_geometry (1, 1, getColumnNumber(), getLineNumber());
FRect term_geometry (0, 0, getColumnNumber(), getLineNumber());
createVTerm (term_geometry);
// create virtual desktop area
@ -168,7 +168,9 @@ void FVTerm::createArea ( const FRect& r
, const FPoint& p
, FVTerm::term_area*& area )
{
createArea ( r.getWidth()
createArea ( r.getX()
, r.getY()
, r.getWidth()
, r.getHeight()
, p.getX()
, p.getY()
@ -176,26 +178,29 @@ void FVTerm::createArea ( const FRect& r
}
//----------------------------------------------------------------------
void FVTerm::createArea ( int width, int height
void FVTerm::createArea ( int x_offset, int y_offset
, int width, int height
, int rsw, int bsh
, term_area*& area )
{
// initialize virtual window
area = new term_area;
area->x_offset = 0;
area->y_offset = 0;
area->width = -1;
area->height = -1;
area->right_shadow = 0;
area->bottom_shadow = 0;
area->input_cursor_x = -1;;
area->input_cursor_y = -1;;
area->input_cursor_x = -1;
area->input_cursor_y = -1;
area->input_cursor_visible = false;
area->changes = 0;
area->text = 0;
area->visible = false;
area->widget = static_cast<FWidget*>(this);
resizeArea (width, height, rsw, bsh, area);
resizeArea (x_offset, y_offset, width, height, rsw, bsh, area);
}
//----------------------------------------------------------------------
@ -203,7 +208,9 @@ void FVTerm::resizeArea ( const FRect& r
, const FPoint& p
, FVTerm::term_area* area )
{
resizeArea ( r.getWidth()
resizeArea ( r.getX()
, r.getY()
, r.getWidth()
, r.getHeight()
, p.getX()
, p.getY()
@ -211,7 +218,8 @@ void FVTerm::resizeArea ( const FRect& r
}
//----------------------------------------------------------------------
void FVTerm::resizeArea ( int width, int height
void FVTerm::resizeArea ( int x_offset, int y_offset
, int width, int height
, int rsw, int bsh
, term_area* area )
{
@ -245,6 +253,8 @@ void FVTerm::resizeArea ( int width, int height
else
return;
area->x_offset = x_offset;
area->y_offset = y_offset;
area->width = width;
area->height = height;
area->right_shadow = rsw;
@ -362,14 +372,17 @@ void FVTerm::restoreVTerm (int x, int y, int w, int h)
while ( iter != end )
{
term_area* win = (*iter)->getVWin();
const FRect& geometry = (*iter)->getTermGeometryWithShadow();
int win_x = win->x_offset;
int win_y = win->y_offset;
FRect geometry ( win_x
, win_y
, win->width + win->right_shadow
, win->height + win->bottom_shadow );
// window visible and contains current character
if ( win && win->visible && geometry.contains(tx+x+1, ty+y+1) )
if ( win && win->visible && geometry.contains(tx+x, ty+y) )
{
FOptiAttr::char_data* tmp;
int win_x = (*iter)->getTermX() - 1;
int win_y = (*iter)->getTermY() - 1;
int line_len = win->width + win->right_shadow;
tmp = &win->text[(ty+y-win_y) * line_len + (tx+x-win_x)];
@ -440,8 +453,6 @@ FVTerm::covered_state FVTerm::isCovered ( int x, int y
is_covered = non_covered;
found = bool(area == vdesktop);
x++;
y++;
w = static_cast<FWidget*>(area->widget);
@ -454,18 +465,20 @@ FVTerm::covered_state FVTerm::isCovered ( int x, int y
while ( iter != end )
{
term_area* win = (*iter)->getVWin();
const FRect& geometry = (*iter)->getTermGeometryWithShadow();
int win_x = win->x_offset;
int win_y = win->y_offset;
FRect geometry ( win_x
, win_y
, win->width + win->right_shadow
, win->height + win->bottom_shadow );
if ( win && found
&& (*iter)->isVisible()
&& (*iter)->isShown()
&& win->visible
&& geometry.contains(x,y) )
{
FOptiAttr::char_data* tmp;
int win_x = (*iter)->getTermX() - 1;
int win_y = (*iter)->getTermY() - 1;
int line_len = win->width + win->right_shadow;
tmp = &win->text[(y-win_y-1) * line_len + (x-win_x-1)];
tmp = &win->text[(y-win_y) * line_len + (x-win_x)];
if ( tmp->trans_shadow )
{
@ -517,8 +530,8 @@ void FVTerm::updateVTerm (FVTerm::term_area* area)
if ( ! area->visible )
return;
ax = area->widget->getTermX() - 1;
ay = area->widget->getTermY() - 1;
ax = area->x_offset;
ay = area->y_offset;
aw = area->width;
ah = area->height;
rsh = area->right_shadow;
@ -674,18 +687,18 @@ bool FVTerm::updateVTermCursor (FVTerm::term_area* area)
if ( area->input_cursor_visible )
{
int cx, cy, ax, ay, x, y;
// cursor position
cx = area->input_cursor_x;
cy = area->input_cursor_y;
// widget position
// area offset
ax = area->widget->getTermX() - 1;
ay = area->widget->getTermY() - 1;
// area position
// area cursor position
cx = area->input_cursor_x;
cy = area->input_cursor_y;
// terminal position
x = ax + cx;
y = ay + cy;
if ( isInsideArea(cx, cy, area)
&& isInsideTerminal(x+1, y+1)
&& isInsideTerminal(x, y)
&& isCovered(x, y, area) == non_covered )
{
vterm->input_cursor_x = x;
@ -1113,7 +1126,7 @@ void FVTerm::clearArea (FVTerm::term_area* area)
}
//----------------------------------------------------------------------
FOptiAttr::char_data FVTerm::getCharacter ( int type
FOptiAttr::char_data FVTerm::getCharacter ( character_type type
, const FPoint& pos
, FVTerm* obj )
{
@ -1121,7 +1134,7 @@ FOptiAttr::char_data FVTerm::getCharacter ( int type
}
//----------------------------------------------------------------------
FOptiAttr::char_data FVTerm::getCharacter ( int char_type
FOptiAttr::char_data FVTerm::getCharacter ( character_type char_type
, int x
, int y
, FVTerm* obj )
@ -1175,14 +1188,17 @@ FOptiAttr::char_data FVTerm::getCharacter ( int char_type
if ( obj && *iter != obj && significant_char )
{
term_area* win = (*iter)->getVWin();
const FRect& geometry = (*iter)->getTermGeometryWithShadow();
int win_x = win->x_offset;
int win_y = win->y_offset;
FRect geometry ( win_x
, win_y
, win->width + win->right_shadow
, win->height + win->bottom_shadow );
// window visible and contains current character
if ( win && win->visible && geometry.contains(x+1,y+1) )
if ( win && win->visible && geometry.contains(x,y) )
{
FOptiAttr::char_data* tmp;
int win_x = (*iter)->getTermX() - 1;
int win_y = (*iter)->getTermY() - 1;
int line_len = win->width + win->right_shadow;
tmp = &win->text[(y-win_y) * line_len + (x-win_x)];
@ -1345,7 +1361,7 @@ void FVTerm::createVTerm (const FRect& r)
void FVTerm::createVTerm (int width, int height)
{
// initialize virtual terminal
createArea (width, height, 0, 0, vterm);
createArea (0, 0, width, height, 0, 0, vterm);
}
//----------------------------------------------------------------------
@ -1358,7 +1374,7 @@ void FVTerm::resizeVTerm (const FRect& r)
//----------------------------------------------------------------------
void FVTerm::resizeVTerm (int width, int height)
{
resizeArea (width, height, 0, 0, vterm);
resizeArea (0, 0, width, height, 0, 0, vterm);
}
//----------------------------------------------------------------------
@ -1472,7 +1488,7 @@ bool FVTerm::updateTerminalCursor()
int x = vterm->input_cursor_x;
int y = vterm->input_cursor_y;
if ( isInsideTerminal(x+1, y+1) )
if ( isInsideTerminal(x, y) )
{
setTermXY (x,y);
showCursor();
@ -1515,7 +1531,7 @@ void FVTerm::processTerminalUpdate()
bool FVTerm::isInsideTerminal (int x, int y)
{
// Check whether the coordinates are within the virtual terminal
FRect term_geometry (1, 1, getColumnNumber(), getLineNumber());
FRect term_geometry (0, 0, getColumnNumber(), getLineNumber());
if ( term_geometry.contains(x,y) )
return true;
@ -1642,17 +1658,13 @@ int FVTerm::print (FVTerm::term_area* area, const std::string& s)
int FVTerm::print (FString& s)
{
assert ( ! s.isNull() );
term_area* area;
FWidget* w;
w = static_cast<FWidget*>(this);
area = w->getPrintArea();
term_area* area = getPrintArea();
if ( ! area )
{
FWidget* root = w->getRootWidget();
if ( vdesktop )
area = vdesktop;
if ( ! root )
else
return -1;
}
@ -1666,23 +1678,23 @@ int FVTerm::print (FVTerm::term_area* area, FString& s)
register int len = 0;
const wchar_t* p;
uInt tabstop = getTabstop();
FWidget* window;
if ( ! area )
return -1;
window = area->widget;
if ( ! window )
return -1;
p = s.wc_str();
if ( p )
{
while ( *p )
{
int rsh, bsh;
int x_offset, y_offset, width, height, rsh, bsh;
x_offset = area->x_offset;
y_offset = area->y_offset;
width = area->width;
height = area->height;
rsh = area->right_shadow;
bsh = area->bottom_shadow;
switch ( *p )
{
@ -1711,8 +1723,8 @@ int FVTerm::print (FVTerm::term_area* area, FString& s)
default:
{
short x = short(cursor->getX());
short y = short(cursor->getY());
short x = short(cursor->getX() - 1);
short y = short(cursor->getY() - 1);
FOptiAttr::char_data nc; // next character
nc.code = *p;
@ -1735,8 +1747,8 @@ int FVTerm::print (FVTerm::term_area* area, FString& s)
nc.trans_shadow = next_attribute.trans_shadow;
nc.inherit_bg = next_attribute.inherit_bg;
int ax = x - window->getTermX();
int ay = y - window->getTermY();
int ax = x - x_offset;
int ay = y - y_offset;
if ( area
&& ax >= 0 && ay >= 0
@ -1779,17 +1791,13 @@ int FVTerm::print (FVTerm::term_area* area, FString& s)
}
}
rsh = area->right_shadow;
bsh = area->bottom_shadow;
const FRect& area_geometry = window->getTermGeometry();
if ( cursor->x_ref() > area_geometry.getX2()+rsh )
if ( cursor->x_ref() > x_offset + width + rsh )
{
cursor->x_ref() = short(window->getTermX());
cursor->x_ref() = short(x_offset + 1);
cursor->y_ref()++;
}
if ( cursor->y_ref() > area_geometry.getY2()+bsh )
if ( cursor->y_ref() > y_offset + height + bsh )
{
cursor->y_ref()--;
break;
@ -1808,17 +1816,13 @@ int FVTerm::print (FVTerm::term_area* area, FString& s)
//----------------------------------------------------------------------
int FVTerm::print (register int c)
{
term_area* area;
FWidget* w;
w = static_cast<FWidget*>(this);
area = w->getPrintArea();
term_area* area = getPrintArea();
if ( ! area )
{
FWidget* root = w->getRootWidget();
if ( vdesktop )
area = vdesktop;
if ( ! root )
else
return -1;
}
@ -1829,13 +1833,19 @@ int FVTerm::print (register int c)
int FVTerm::print (FVTerm::term_area* area, register int c)
{
FOptiAttr::char_data nc; // next character
FWidget* window;
int rsh, bsh, ax, ay;
int x_offset, y_offset, width, height, rsh, bsh, ax, ay;
short x, y;
if ( ! area )
return -1;
x_offset = area->x_offset;
y_offset = area->y_offset;
width = area->width;
height = area->height;
rsh = area->right_shadow;
bsh = area->bottom_shadow;
nc.code = c;
nc.fg_color = next_attribute.fg_color;
nc.bg_color = next_attribute.bg_color;
@ -1856,15 +1866,10 @@ int FVTerm::print (FVTerm::term_area* area, register int c)
nc.trans_shadow = next_attribute.trans_shadow;
nc.inherit_bg = next_attribute.inherit_bg;
x = short(cursor->getX());
y = short(cursor->getY());
window = area->widget;
if ( ! window )
return -1;
ax = x - window->getTermX();
ay = y - window->getTermY();
x = short(cursor->getX() - 1);
y = short(cursor->getY() - 1);
ax = x - x_offset;
ay = y - y_offset;
if ( ax >= 0 && ay >= 0
&& ax < area->width + area->right_shadow
@ -1904,17 +1909,14 @@ int FVTerm::print (FVTerm::term_area* area, register int c)
}
cursor->x_ref()++;
rsh = area->right_shadow;
bsh = area->bottom_shadow;
const FRect& area_geometry = window->getTermGeometry();
if ( cursor->x_ref() > area_geometry.getX2()+rsh )
if ( cursor->x_ref() > x_offset + width + rsh )
{
cursor->x_ref() = short(window->getTermX());
cursor->x_ref() = short(x_offset + 1);
cursor->y_ref()++;
}
if ( cursor->y_ref() > area_geometry.getY2()+bsh )
if ( cursor->y_ref() > y_offset + height + bsh )
{
cursor->y_ref()--;
updateVTerm (area);

View File

@ -84,6 +84,8 @@ class FVTerm : public FObject, public FTerm
typedef struct
{
int x_offset;
int y_offset;
int width;
int height;
int right_shadow;
@ -106,9 +108,9 @@ class FVTerm : public FObject, public FTerm
protected:
void createArea (const FRect&, const FPoint&, FVTerm::term_area*&);
void createArea (int, int, int, int, FVTerm::term_area*&);
void createArea (int, int, int, int, int, int, FVTerm::term_area*&);
static void resizeArea (const FRect&, const FPoint&, FVTerm::term_area*);
static void resizeArea (int, int, int, int, FVTerm::term_area*);
static void resizeArea (int, int, int, int, int, int, FVTerm::term_area*);
static void removeArea (FVTerm::term_area*&);
static void restoreVTerm (const FRect&);
static void restoreVTerm (int, int, int, int);
@ -129,8 +131,8 @@ class FVTerm : public FObject, public FTerm
static void scrollAreaForward (FVTerm::term_area*);
static void scrollAreaReverse (FVTerm::term_area*);
static void clearArea (FVTerm::term_area*);
static FOptiAttr::char_data getCharacter (int, const FPoint&, FVTerm*);
static FOptiAttr::char_data getCharacter (int, int, int, FVTerm*);
static FOptiAttr::char_data getCharacter (character_type, const FPoint&, FVTerm*);
static FOptiAttr::char_data getCharacter (character_type, int, int, FVTerm*);
static FOptiAttr::char_data getCoveredCharacter (const FPoint&, FVTerm*);
static FOptiAttr::char_data getCoveredCharacter (int, int, FVTerm*);
static FOptiAttr::char_data getOverlappedCharacter (const FPoint&, FVTerm*);

View File

@ -1293,7 +1293,9 @@ void FWidget::resize()
if ( isRootWidget() )
{
detectTermSize();
const FRect& term_geometry = getGeometry();
FRect term_geometry = getTermGeometry();
term_geometry.move(-1,-1);
resizeVTerm (term_geometry);
resizeArea (term_geometry, getShadow(), vdesktop);
adjustSizeGlobal();
@ -1584,17 +1586,10 @@ void FWidget::setPos (int x, int y, bool adjust)
if ( y < 1 )
y = 1;
wsize.setX(x);
wsize.setY(y);
adjust_wsize.setX(x);
adjust_wsize.setY(y);
}
else
{
wsize.setPos(x,y);
adjust_wsize.setPos(x,y);
}
if ( adjust )
adjustSize();
@ -1863,17 +1858,10 @@ void FWidget::setGeometry (int x, int y, int w, int h, bool adjust)
}
//----------------------------------------------------------------------
void FWidget::move (int x, int y)
void FWidget::move (int dx, int dy)
{
if ( adjust_wsize.getX() == x && adjust_wsize.getY() == y )
return;
// Avoid to move widget completely outside the terminal
if ( x+getWidth() <= 1 || x > getMaxWidth() || y < 1 || y > getMaxHeight() )
return;
wsize.setPos(x,y);
adjust_wsize.setPos(x,y);
wsize.move(dx,dy);
adjust_wsize.move(dx,dy);
}
//----------------------------------------------------------------------

View File

@ -475,8 +475,8 @@ class FWidget : public FVTerm
void setColor();
// make every setColor from FVTerm available
using FVTerm::setColor;
void setX (int, bool = true);
void setY (int, bool = true);
virtual void setX (int, bool = true);
virtual void setY (int, bool = true);
virtual void setPos (const FPoint&, bool = true);
virtual void setPos (int, int, bool = true);
virtual void setWidth (int, bool = true);

View File

@ -24,7 +24,9 @@ FWindow::FWindow(FWidget* parent)
, normalGeometry()
{
setWindowWidget();
createArea (getGeometry(), getShadow(), vwin);
FRect geometry = getTermGeometry();
geometry.move(-1,-1);
createArea (geometry, getShadow(), vwin);
addWindow (this);
}
@ -144,10 +146,20 @@ void FWindow::onWindowLowered (FEvent*)
//----------------------------------------------------------------------
void FWindow::adjustSize()
{
int old_x = getX();
int old_y = getY();
FWidget::adjustSize();
if ( zoomed )
setGeometry (1, 1, getMaxWidth(), getMaxHeight(), false);
else if ( vwin )
{
if ( getX() != old_x )
vwin->x_offset = getTermX() - 1;
if ( getY() != old_y )
vwin->y_offset = getTermY() - 1;
}
}
@ -200,10 +212,8 @@ void FWindow::drawBorder()
//----------------------------------------------------------------------
void FWindow::show()
{
term_area* area = getVWin();
if ( area )
area->visible = true;
if ( vwin )
vwin->visible = true;
FWidget::show();
}
@ -211,14 +221,48 @@ void FWindow::show()
//----------------------------------------------------------------------
void FWindow::hide()
{
term_area* area = getVWin();
if ( area )
area->visible = false;
if ( vwin )
vwin->visible = false;
FWidget::hide();
}
//----------------------------------------------------------------------
void FWindow::setX (int x, bool adjust)
{
FWidget::setX (x, adjust);
if ( vwin )
vwin->x_offset = getTermX() - 1;
}
//----------------------------------------------------------------------
void FWindow::setY (int y, bool adjust)
{
if ( y < 1 )
y = 1;
FWidget::setY (y, adjust);
if ( vwin )
vwin->y_offset = getTermY() - 1;
}
//----------------------------------------------------------------------
void FWindow::setPos (int x, int y, bool adjust)
{
if ( y < 1 )
y = 1;
FWidget::setPos (x, y, adjust);
if ( vwin )
{
vwin->x_offset = getTermX() - 1;
vwin->y_offset = getTermY() - 1;
}
}
//----------------------------------------------------------------------
void FWindow::setWidth (int w, bool adjust)
{
@ -226,7 +270,11 @@ void FWindow::setWidth (int w, bool adjust)
FWidget::setWidth (w, adjust);
if ( vwin && getWidth() != old_width )
resizeArea (getGeometry(), getShadow(), vwin);
{
FRect geometry = getTermGeometry();
geometry.move(-1,-1);
resizeArea (geometry, getShadow(), vwin);
}
}
//----------------------------------------------------------------------
@ -236,7 +284,11 @@ void FWindow::setHeight (int h, bool adjust)
FWidget::setHeight (h, adjust);
if ( vwin && getHeight() != old_height )
resizeArea (getGeometry(), getShadow(), vwin);
{
FRect geometry = getTermGeometry();
geometry.move(-1,-1);
resizeArea (geometry, getShadow(), vwin);
}
}
//----------------------------------------------------------------------
@ -247,18 +299,55 @@ void FWindow::setSize (int w, int h, bool adjust)
FWidget::setSize (w, h, adjust);
if ( vwin && (getWidth() != old_width || getHeight() != old_height) )
resizeArea (getGeometry(), getShadow(), vwin);
{
FRect geometry = getTermGeometry();
geometry.move(-1,-1);
resizeArea (geometry, getShadow(), vwin);
}
}
//----------------------------------------------------------------------
void FWindow::setGeometry (int x, int y, int w, int h, bool adjust)
{
int old_x = getX();
int old_y = getY();
int old_width = getWidth();
int old_height = getHeight();
if ( y < 1 )
y = 1;
FWidget::setGeometry (x, y, w, h, adjust);
if ( vwin && (getWidth() != old_width || getHeight() != old_height) )
resizeArea (getGeometry(), getShadow(), vwin);
if ( vwin )
{
if ( getWidth() != old_width || getHeight() != old_height )
{
FRect geometry = getTermGeometry();
geometry.move(-1,-1);
resizeArea (geometry, getShadow(), vwin);
}
else
{
if ( getX() != old_x )
vwin->x_offset = getTermX() - 1;
if ( getY() != old_y )
vwin->y_offset = getTermY() - 1;
}
}
}
//----------------------------------------------------------------------
void FWindow::move (int dx, int dy)
{
FWidget::move (dx,dy);
if ( vwin )
{
vwin->x_offset = getTermX() - 1;
vwin->y_offset = getTermY() - 1;
}
}
//----------------------------------------------------------------------
@ -699,10 +788,8 @@ bool FWindow::activateWindow (bool on)
bool FWindow::isWindowHidden() const
{
// returns the window hidden state
term_area* area = getVWin();
if ( area )
return ! area->visible;
if ( vwin )
return ! vwin->visible;
else
return false;
}
@ -770,7 +857,11 @@ void FWindow::setShadowSize (int right, int bottom)
new_bottom = getShadow().getY();
if ( vwin && (new_right != old_right || new_bottom != old_bottom) )
resizeArea (getGeometry(), getShadow(), vwin);
{
FRect geometry = getTermGeometry();
geometry.move(-1,-1);
resizeArea (geometry, getShadow(), vwin);
}
}
//----------------------------------------------------------------------

View File

@ -88,12 +88,20 @@ class FWindow : public FWidget
virtual void drawBorder();
virtual void show();
virtual void hide();
virtual void setX (int, bool = true);
virtual void setY (int, bool = true);
virtual void setPos (int, int, bool = true);
// make every setPos from FWidget available
using FWidget::setPos;
virtual void setWidth (int, bool = true);
virtual void setHeight (int, bool = true);
virtual void setSize (int, int, bool = true);
// make every setGeometry from FWidget available
using FWidget::setGeometry;
void setGeometry (int, int, int, int, bool = true);
virtual void move (int, int);
// make every move from FWidget available
using FWidget::move;
static FWindow* getWindowWidgetAt (const FPoint&);
static FWindow* getWindowWidgetAt (int, int);
static void addWindow (FWidget*);

View File

@ -539,7 +539,7 @@ void Window::adjustSize()
if ( Y < 2)
Y = 2;
move (X, Y);
setPos (X, Y);
iter = begin = windows.begin();
while ( iter != windows.end() )
@ -550,7 +550,7 @@ void Window::adjustSize()
n = int(std::distance(begin, iter));
x = dx + 5 + (n%3)*25 + int(n/3)*3;
y = dy + 11 + int(n/3)*3;
(*iter)->dgl->move (x, y);
(*iter)->dgl->setPos (x, y);
}
++iter;