Fix method setPos in the class FRect

This commit is contained in:
Markus Gans 2016-07-31 20:25:25 +02:00
parent d5685aaafc
commit 0ad1228b1a
10 changed files with 70 additions and 48 deletions

View File

@ -1,3 +1,9 @@
2016-07-31 Markus Gans <guru.mail@muenster.de>
* Resetting the local window widget focus at
the end of the lifetime of a widget.
* Fix method setPos in the class FRect
* Add the windows example to show window behavior
2016-07-30 Markus Gans <guru.mail@muenster.de>
* Delete all callbacks from a widget with delCallbacks()
* Remove dialog list item callback from the associated window

View File

@ -475,8 +475,7 @@ void FFileDialog::adjustSize()
setHeight (h, false);
X = 1 + int((max_width-width)/2);
Y = 1 + int((max_height-height)/3);
setX(X, false);
setY(Y, false);
setPos(X, Y, false);
filebrowser->setHeight(h-8, false);
hidden->setY(h-4, false);
cancel->setY(h-4, false);

View File

@ -76,8 +76,11 @@ FMenu::~FMenu()
delWindow(this);
const FRect& geometry = getGeometryGlobalShadow();
restoreVTerm (geometry);
if ( ! fapp->isQuit() )
{
const FRect& geometry = getGeometryGlobalShadow();
restoreVTerm (geometry);
}
if ( vwin != 0 )
{

View File

@ -126,8 +126,7 @@ void FMessageBox::init(int button0, int button1, int button2)
button[0] = new FButton (this);
button[0]->setText(button_text[button0]);
button[0]->setX(3, false);
button[0]->setY(height-4, false);
button[0]->setPos(3, height-4, false);
button[0]->setWidth(1, false);
button[0]->setHeight(1, false);
button[0]->setFocus();
@ -137,8 +136,7 @@ void FMessageBox::init(int button0, int button1, int button2)
{
button[1] = new FButton(this);
button[1]->setText(button_text[button1]);
button[1]->setX(17, false);
button[1]->setY(height-4, false);
button[1]->setPos(17, height-4, false);
button[1]->setWidth(0, false);
button[1]->setHeight(1, false);
button[1]->setShadow();
@ -148,8 +146,7 @@ void FMessageBox::init(int button0, int button1, int button2)
{
button[2] = new FButton(this);
button[2]->setText(button_text[button2]);
button[2]->setX(32, false);
button[2]->setY(height-4, false);
button[2]->setPos(32, height-4, false);
button[2]->setWidth(0, false);
button[2]->setHeight(1, false);
button[2]->setShadow();
@ -318,7 +315,7 @@ void FMessageBox::adjustButtons()
{
setWidth(btn_width + 5);
int max_width = getRootWidget()->getClientWidth();
setX(int((max_width-width) / 2));
setX (int((max_width-width) / 2));
}
int btn_x = int((width-btn_width) / 2);
@ -352,8 +349,7 @@ void FMessageBox::adjustSize()
max_width = getRootWidget()->getClientWidth();
X = 1 + int((max_width-width)/2);
Y = 1 + int((max_height-height)/3);
setX(X, false);
setY(Y, false);
setPos(X, Y, false);
FDialog::adjustSize();
}

View File

@ -70,15 +70,23 @@ void FRect::setY (int n)
//----------------------------------------------------------------------
void FRect::setPos (int x, int y)
{
short dX = short(X2 - X1);
short dY = short(Y2 - Y1);
X1 = short(x);
Y1 = short(y);
X2 = short(X1 + dX);
Y2 = short(Y1 + dY);
}
//----------------------------------------------------------------------
void FRect::setPos (const FPoint& p)
{
short dX = short(X2 - X1);
short dY = short(Y2 - Y1);
X1 = short(p.getX());
Y1 = short(p.getY());
X2 = short(X1 + dX);
Y2 = short(Y1 + dY);
}
//----------------------------------------------------------------------

View File

@ -3015,8 +3015,7 @@ void FTerm::getTermSize()
if ( ret != 0 || win_size.ws_col == 0 || win_size.ws_row == 0 )
{
char* str;
term->setX(1);
term->setY(1);
term->setPos(1,1);
str = getenv("COLUMNS");
term->setWidth(str ? atoi(str) : 80);
str = getenv("LINES");

View File

@ -106,18 +106,30 @@ FWidget::~FWidget() // destructor
processDestroy();
FApplication::removeQueuedEvent(this);
// unset clicked widget
if ( this == getClickedWidget() )
setClickedWidget(0);
// unset the local window widget focus
if ( focus )
{
FWindow* window = FWindow::getWindowWidget(this);
if ( window )
window->setWindowFocusWidget(0);
}
// unset the global widget focus
if ( this == FWidget::getFocusWidget() )
FWidget::setFocusWidget(0);
// unset main widget
if ( this == getMainWidget() )
{
setMainWidget(0);
quit();
}
// finish the program
if ( rootObject == this )
this->finish();
}
@ -1881,13 +1893,10 @@ void FWidget::move (int x, int y)
xpos = x;
ypos = y;
widgetSize.setX(x);
widgetSize.setY(y);
adjustWidgetSize.setX(x);
adjustWidgetSize.setY(y);
widgetSize.setPos(x,y);
adjustWidgetSize.setPos(x,y);
adjustWidgetSizeShadow = adjustWidgetSize + shadow;
adjustWidgetSizeGlobal.setX(x + xmin - 1);
adjustWidgetSizeGlobal.setY(y + ymin - 1);
adjustWidgetSizeGlobal.setPos(x + xmin - 1, y + ymin - 1);
adjustWidgetSizeGlobalShadow = adjustWidgetSizeGlobal + shadow;
}

View File

@ -411,10 +411,12 @@ void FWindow::switchToPrevWindow()
if ( ! active_window->isActiveWindow() )
setActiveWindow(active_window);
if ( focus_widget && ! focus_widget->isWindow() )
if ( focus_widget )
{
focus_widget->setFocus();
focus_widget->redraw();
if ( ! focus_widget->isWindow() )
focus_widget->redraw();
}
}
}