Fix method setPos in the class FRect
This commit is contained in:
parent
d5685aaafc
commit
0ad1228b1a
|
@ -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
|
||||
|
|
48
src/fapp.cpp
48
src/fapp.cpp
|
@ -321,42 +321,42 @@ void FApplication::processKeyboardEvent()
|
|||
// Remove founded entry
|
||||
for (n=len; n < fifo_buf_size; n++)
|
||||
fifo_buf[n-len] = fifo_buf[n];
|
||||
|
||||
|
||||
n = fifo_buf_size-len-1;
|
||||
|
||||
|
||||
// Fill rest with '\0'
|
||||
for (; n < fifo_buf_size; n++)
|
||||
fifo_buf[n-len] = '\0';
|
||||
|
||||
|
||||
input_data_pending = bool(fifo_buf[0] != '\0');
|
||||
processMouseEvent();
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case fc::Fkey_extended_mouse:
|
||||
{
|
||||
int n = 3;
|
||||
int len = int(strlen(fifo_buf));
|
||||
|
||||
|
||||
while ( n < len && n < fifo_buf_size )
|
||||
{
|
||||
sgr_mouse[n-3] = fifo_buf[n];
|
||||
n++;
|
||||
|
||||
|
||||
if ( fifo_buf[n] == 'M' || fifo_buf[n] == 'm' )
|
||||
len = n + 1;
|
||||
}
|
||||
|
||||
|
||||
sgr_mouse[n-3] = '\0';
|
||||
|
||||
|
||||
for (n=len; n < fifo_buf_size; n++) // Remove founded entry
|
||||
fifo_buf[n-len] = fifo_buf[n];
|
||||
|
||||
|
||||
n = fifo_buf_size-len-1;
|
||||
|
||||
|
||||
for (; n < fifo_buf_size; n++) // Fill rest with '\0'
|
||||
fifo_buf[n-len] = '\0';
|
||||
|
||||
|
||||
input_data_pending = bool(fifo_buf[0] != '\0');
|
||||
processMouseEvent();
|
||||
}
|
||||
|
@ -366,26 +366,26 @@ void FApplication::processKeyboardEvent()
|
|||
{
|
||||
int n = 2;
|
||||
int len = int(strlen(fifo_buf));
|
||||
|
||||
|
||||
while ( n < len && n < fifo_buf_size )
|
||||
{
|
||||
urxvt_mouse[n-2] = fifo_buf[n];
|
||||
n++;
|
||||
|
||||
|
||||
if ( fifo_buf[n] == 'M' || fifo_buf[n] == 'm' )
|
||||
len = n + 1;
|
||||
}
|
||||
|
||||
|
||||
urxvt_mouse[n-2] = '\0';
|
||||
|
||||
|
||||
for (n=len; n < fifo_buf_size; n++) // Remove founded entry
|
||||
fifo_buf[n-len] = fifo_buf[n];
|
||||
|
||||
|
||||
n = fifo_buf_size-len-1;
|
||||
|
||||
|
||||
for (; n < fifo_buf_size; n++) // Fill rest with '\0'
|
||||
fifo_buf[n-len] = '\0';
|
||||
|
||||
|
||||
input_data_pending = bool(fifo_buf[0] != '\0');
|
||||
processMouseEvent();
|
||||
}
|
||||
|
@ -396,11 +396,11 @@ void FApplication::processKeyboardEvent()
|
|||
// send key down event
|
||||
FKeyEvent k_down_ev (fc::KeyDown_Event, key);
|
||||
sendEvent (widget, &k_down_ev);
|
||||
|
||||
|
||||
// send key press event
|
||||
FKeyEvent k_press_ev (fc::KeyPress_Event, key);
|
||||
sendEvent (widget, &k_press_ev);
|
||||
|
||||
|
||||
if ( ! open_menu
|
||||
&& ! k_press_ev.isAccepted()
|
||||
&& ! k_down_ev.isAccepted() )
|
||||
|
@ -409,21 +409,21 @@ void FApplication::processKeyboardEvent()
|
|||
// switch to a specific dialog with Meta + 1..9
|
||||
if ( ! accpt )
|
||||
accpt = processDialogSwitchAccelerator();
|
||||
|
||||
|
||||
// windows keyboard accelerator
|
||||
if ( ! accpt )
|
||||
{
|
||||
FWidget* window = static_cast<FWidget*>(active_window);
|
||||
|
||||
|
||||
if ( window )
|
||||
accpt = processAccelerator (window);
|
||||
}
|
||||
|
||||
|
||||
// global keyboard accelerator
|
||||
if ( ! accpt )
|
||||
{
|
||||
FWidget* root_widget = getRootWidget();
|
||||
|
||||
|
||||
if ( root_widget )
|
||||
accpt = processAccelerator (root_widget);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 )
|
||||
{
|
||||
|
|
|
@ -299,7 +299,7 @@ void FMenuItem::createDialogList (FMenu* winmenu)
|
|||
"destroy",
|
||||
_METHOD_CALLBACK (win_item, &FMenuItem::cb_destroyDialog)
|
||||
);
|
||||
|
||||
|
||||
win_item->associated_window = win;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue