2017-11-04 07:03:53 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* fwindow.cpp - Intermediate base class for all window objects *
|
|
|
|
* *
|
|
|
|
* This file is part of the Final Cut widget toolkit *
|
|
|
|
* *
|
2018-02-03 00:04:24 +01:00
|
|
|
* Copyright 2015-2018 Markus Gans *
|
2017-11-04 07:03:53 +01:00
|
|
|
* *
|
|
|
|
* The Final Cut is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU Lesser General Public License *
|
|
|
|
* as published by the Free Software Foundation; either version 3 of *
|
|
|
|
* the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* The Final Cut is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU Lesser General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Lesser General Public *
|
|
|
|
* License along with this program. If not, see *
|
|
|
|
* <http://www.gnu.org/licenses/>. *
|
|
|
|
***********************************************************************/
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-09-17 21:32:46 +02:00
|
|
|
#include "final/fapplication.h"
|
|
|
|
#include "final/fmenubar.h"
|
|
|
|
#include "final/fstatusbar.h"
|
|
|
|
#include "final/fwindow.h"
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2018-09-20 23:59:01 +02:00
|
|
|
namespace finalcut
|
|
|
|
{
|
|
|
|
|
2016-06-26 16:08:03 +02:00
|
|
|
// static attributes
|
2018-12-10 01:48:26 +01:00
|
|
|
FWindow* FWindow::previous_window = nullptr;
|
2016-06-26 16:08:03 +02:00
|
|
|
|
2016-10-11 04:57:36 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FWindow
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2016-10-11 04:57:36 +02:00
|
|
|
// constructor and destructor
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
2015-09-22 04:18:20 +02:00
|
|
|
FWindow::FWindow(FWidget* parent)
|
|
|
|
: FWidget(parent)
|
2016-08-20 22:27:23 +02:00
|
|
|
{
|
2016-09-25 23:53:48 +02:00
|
|
|
setWindowWidget();
|
2016-10-14 13:02:35 +02:00
|
|
|
FRect geometry = getTermGeometry();
|
2017-09-11 03:06:02 +02:00
|
|
|
geometry.move(-1, -1);
|
2016-10-14 13:02:35 +02:00
|
|
|
createArea (geometry, getShadow(), vwin);
|
2016-10-09 02:06:06 +02:00
|
|
|
addWindow (this);
|
2016-08-20 22:27:23 +02:00
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FWindow::~FWindow() // destructor
|
2016-06-27 23:08:32 +02:00
|
|
|
{
|
2018-12-15 00:50:09 +01:00
|
|
|
auto fapp = static_cast<FApplication*>(getRootWidget());
|
2016-10-09 02:06:06 +02:00
|
|
|
|
2016-10-13 02:16:51 +02:00
|
|
|
if ( previous_window == this )
|
2018-12-10 01:48:26 +01:00
|
|
|
previous_window = nullptr;
|
2016-10-01 23:18:49 +02:00
|
|
|
|
|
|
|
if ( isAlwaysOnTop() )
|
|
|
|
deleteFromAlwaysOnTopList (this);
|
2016-10-09 02:06:06 +02:00
|
|
|
|
2017-03-12 00:29:56 +01:00
|
|
|
// unset the global active window
|
|
|
|
if ( this == FWindow::getActiveWindow() )
|
|
|
|
unsetActiveWindow();
|
|
|
|
|
2016-10-09 02:06:06 +02:00
|
|
|
delWindow (this);
|
|
|
|
|
|
|
|
if ( ! fapp->isQuit() )
|
|
|
|
{
|
|
|
|
const FRect& t_geometry = getTermGeometryWithShadow();
|
|
|
|
restoreVTerm (t_geometry);
|
|
|
|
}
|
|
|
|
|
|
|
|
removeArea (vwin);
|
2016-10-01 23:18:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
// public methods of FWindow
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FWidget* FWindow::getWindowFocusWidget() const
|
|
|
|
{
|
|
|
|
// returns the focused widget of this window
|
|
|
|
return win_focus_widget;
|
|
|
|
}
|
2016-10-01 23:18:49 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FWindow::setWindowWidget (bool on)
|
|
|
|
{
|
|
|
|
if ( isWindowWidget() == on )
|
|
|
|
return true;
|
2016-10-17 08:44:38 +02:00
|
|
|
|
2018-11-04 23:00:06 +01:00
|
|
|
flags.window_widget = on;
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( on )
|
|
|
|
setTermOffset();
|
|
|
|
else
|
|
|
|
setParentOffset();
|
|
|
|
|
|
|
|
return on;
|
2016-06-27 23:08:32 +02:00
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-10-02 21:26:25 +02:00
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FWindow::setActiveWindow (FWindow* window)
|
2016-10-02 21:26:25 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
// activate FWindow object window
|
|
|
|
|
|
|
|
if ( ! window_list )
|
2016-10-17 08:44:38 +02:00
|
|
|
return;
|
2016-10-02 21:26:25 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( window_list->empty() )
|
|
|
|
return;
|
2016-10-02 21:26:25 +02:00
|
|
|
|
2018-12-15 00:50:09 +01:00
|
|
|
auto iter = window_list->begin();
|
|
|
|
auto end = window_list->end();
|
2016-11-02 00:37:58 +01:00
|
|
|
|
|
|
|
while ( iter != end )
|
2016-10-17 08:44:38 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( *iter == window )
|
|
|
|
{
|
|
|
|
if ( ! window->isWindowActive() )
|
|
|
|
{
|
|
|
|
window->activateWindow();
|
|
|
|
FEvent ev(fc::WindowActive_Event);
|
|
|
|
FApplication::sendEvent(window, &ev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-15 00:50:09 +01:00
|
|
|
auto w = static_cast<FWindow*>(*iter);
|
2016-10-02 21:26:25 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( w->isWindowActive() )
|
|
|
|
{
|
|
|
|
w->deactivateWindow();
|
|
|
|
FEvent ev(fc::WindowInactive_Event);
|
|
|
|
FApplication::sendEvent(*iter, &ev);
|
|
|
|
}
|
|
|
|
}
|
2016-10-17 08:44:38 +02:00
|
|
|
|
|
|
|
++iter;
|
2016-10-02 21:26:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
2017-08-12 20:10:27 +02:00
|
|
|
void FWindow::setWindowFocusWidget (const FWidget* obj)
|
2016-11-02 00:37:58 +01:00
|
|
|
{
|
|
|
|
// set focus widget of this window
|
2017-08-12 20:10:27 +02:00
|
|
|
win_focus_widget = const_cast<FWidget*>(obj);
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
2015-09-22 22:12:31 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
bool FWindow::activateWindow (bool on)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
// activate/deactivate this window
|
|
|
|
if ( on )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2018-10-21 21:06:52 +02:00
|
|
|
FWidget::setActiveWindow (this);
|
2016-11-02 00:37:58 +01:00
|
|
|
active_area = getVWin();
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2018-11-05 23:19:03 +01:00
|
|
|
return (window_active = on);
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-03-12 00:29:56 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWindow::unsetActiveWindow()
|
|
|
|
{
|
|
|
|
// unset the active FWindow object
|
2018-10-21 21:06:52 +02:00
|
|
|
FWidget::setActiveWindow (0);
|
2017-03-12 00:29:56 +01:00
|
|
|
}
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FWindow::setResizeable (bool on)
|
|
|
|
{
|
2018-11-04 23:00:06 +01:00
|
|
|
return (flags.resizeable = on);
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FWindow::setTransparentShadow (bool on)
|
|
|
|
{
|
2018-11-04 23:00:06 +01:00
|
|
|
flags.shadow = flags.trans_shadow = on;
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( on )
|
2018-11-20 21:11:04 +01:00
|
|
|
setShadowSize (2, 1);
|
2016-11-02 00:37:58 +01:00
|
|
|
else
|
2018-11-20 21:11:04 +01:00
|
|
|
setShadowSize (0, 0);
|
2016-10-01 23:18:49 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
return on;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
bool FWindow::setShadow (bool on)
|
|
|
|
{
|
|
|
|
if ( isMonochron() )
|
|
|
|
return false;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( on )
|
|
|
|
{
|
2018-11-04 23:00:06 +01:00
|
|
|
flags.shadow = true;
|
|
|
|
flags.trans_shadow = false;
|
2018-11-20 21:11:04 +01:00
|
|
|
setShadowSize (1, 1);
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-11-04 23:00:06 +01:00
|
|
|
flags.shadow = false;
|
|
|
|
flags.trans_shadow = false;
|
2018-11-20 21:11:04 +01:00
|
|
|
setShadowSize (0, 0);
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
return on;
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-09-25 23:53:48 +02:00
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
bool FWindow::setAlwaysOnTop (bool on)
|
2016-09-25 23:53:48 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( isAlwaysOnTop() == on )
|
|
|
|
return true;
|
2016-09-25 23:53:48 +02:00
|
|
|
|
2018-11-04 23:00:06 +01:00
|
|
|
flags.always_on_top = on;
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( on )
|
2016-10-14 13:02:35 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( always_on_top_list )
|
|
|
|
{
|
|
|
|
deleteFromAlwaysOnTopList (this);
|
|
|
|
always_on_top_list->push_back (this);
|
|
|
|
}
|
2016-10-14 13:02:35 +02:00
|
|
|
}
|
2016-11-02 00:37:58 +01:00
|
|
|
else
|
|
|
|
deleteFromAlwaysOnTopList (this);
|
|
|
|
|
|
|
|
return on;
|
2016-09-25 23:53:48 +02:00
|
|
|
}
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FWindow::isWindowHidden() const
|
|
|
|
{
|
|
|
|
// returns the window hidden state
|
2017-01-22 23:04:40 +01:00
|
|
|
|
|
|
|
if ( isVirtualWindow() )
|
2016-11-02 00:37:58 +01:00
|
|
|
return ! vwin->visible;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
2015-09-22 22:12:31 +02:00
|
|
|
|
2016-10-06 23:15:09 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWindow::drawBorder()
|
|
|
|
{
|
|
|
|
if ( isNewFont() )
|
|
|
|
{
|
2017-10-02 07:32:33 +02:00
|
|
|
int x1 = 1
|
2018-10-14 06:25:33 +02:00
|
|
|
, x2 = 1 + int(getWidth()) - 1
|
2017-10-02 07:32:33 +02:00
|
|
|
, y1 = 1
|
2018-10-14 06:25:33 +02:00
|
|
|
, y2 = 1 + int(getHeight()) - 1;
|
2016-10-06 23:15:09 +02:00
|
|
|
|
2016-10-11 04:57:36 +02:00
|
|
|
setPrintPos (x1, y1);
|
2017-09-11 03:06:02 +02:00
|
|
|
print (fc::NF_border_corner_upper_left); // ⎡
|
2016-10-06 23:15:09 +02:00
|
|
|
|
2017-08-27 09:50:30 +02:00
|
|
|
for (int x = x1 + 1; x < x2; x++)
|
2017-09-11 03:06:02 +02:00
|
|
|
print (fc::NF_border_line_upper); // ¯
|
2016-10-06 23:15:09 +02:00
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
print (fc::NF_rev_border_corner_upper_right); // ⎤
|
2016-10-06 23:15:09 +02:00
|
|
|
|
2017-08-27 09:50:30 +02:00
|
|
|
for (int y = y1 + 1; y < y2; y++)
|
2016-10-06 23:15:09 +02:00
|
|
|
{
|
2016-10-11 04:57:36 +02:00
|
|
|
setPrintPos (x1, y);
|
2016-10-06 23:15:09 +02:00
|
|
|
// border left ⎸
|
|
|
|
print (fc::NF_border_line_left);
|
2016-10-11 04:57:36 +02:00
|
|
|
setPrintPos (x2, y);
|
2016-10-06 23:15:09 +02:00
|
|
|
// border right⎹
|
|
|
|
print (fc::NF_rev_border_line_right);
|
|
|
|
}
|
|
|
|
|
2016-10-11 04:57:36 +02:00
|
|
|
setPrintPos (x1, y2);
|
2016-10-06 23:15:09 +02:00
|
|
|
// lower left corner border ⎣
|
|
|
|
print (fc::NF_border_corner_lower_left);
|
|
|
|
|
2018-10-14 06:25:33 +02:00
|
|
|
for (std::size_t x = 2; x < getWidth(); x++) // low line _
|
2016-10-06 23:15:09 +02:00
|
|
|
print (fc::NF_border_line_bottom);
|
|
|
|
|
2016-10-11 04:57:36 +02:00
|
|
|
setPrintPos (x2, y2);
|
2016-10-06 23:15:09 +02:00
|
|
|
// lower right corner border ⎦
|
|
|
|
print (fc::NF_rev_border_corner_lower_right);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FWidget::drawBorder();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-22 22:12:31 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWindow::show()
|
|
|
|
{
|
2017-01-22 23:04:40 +01:00
|
|
|
if ( isVirtualWindow() )
|
2016-10-14 13:02:35 +02:00
|
|
|
vwin->visible = true;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-09-22 22:12:31 +02:00
|
|
|
FWidget::show();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWindow::hide()
|
|
|
|
{
|
2017-01-22 23:04:40 +01:00
|
|
|
if ( isVirtualWindow() )
|
2016-10-14 13:02:35 +02:00
|
|
|
vwin->visible = false;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-09-22 22:12:31 +02:00
|
|
|
FWidget::hide();
|
|
|
|
}
|
|
|
|
|
2016-10-14 13:02:35 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWindow::setX (int x, bool adjust)
|
|
|
|
{
|
|
|
|
FWidget::setX (x, adjust);
|
|
|
|
|
2017-01-22 23:04:40 +01:00
|
|
|
if ( isVirtualWindow() )
|
2017-02-25 15:18:29 +01:00
|
|
|
vwin->offset_left = getTermX() - 1;
|
2016-10-14 13:02:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWindow::setY (int y, bool adjust)
|
|
|
|
{
|
|
|
|
if ( y < 1 )
|
|
|
|
y = 1;
|
|
|
|
|
|
|
|
FWidget::setY (y, adjust);
|
|
|
|
|
2017-01-22 23:04:40 +01:00
|
|
|
if ( isVirtualWindow() )
|
2017-02-25 15:18:29 +01:00
|
|
|
vwin->offset_top = getTermY() - 1;
|
2016-10-14 13:02:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWindow::setPos (int x, int y, bool adjust)
|
|
|
|
{
|
|
|
|
if ( y < 1 )
|
|
|
|
y = 1;
|
|
|
|
|
|
|
|
FWidget::setPos (x, y, adjust);
|
|
|
|
|
2017-01-22 23:04:40 +01:00
|
|
|
if ( isVirtualWindow() )
|
2016-10-14 13:02:35 +02:00
|
|
|
{
|
2017-02-25 15:18:29 +01:00
|
|
|
vwin->offset_left = getTermX() - 1;
|
|
|
|
vwin->offset_top = getTermY() - 1;
|
2016-10-14 13:02:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-11 16:48:39 +02:00
|
|
|
//----------------------------------------------------------------------
|
2018-10-14 06:25:33 +02:00
|
|
|
void FWindow::setWidth (std::size_t w, bool adjust)
|
2016-09-11 16:48:39 +02:00
|
|
|
{
|
2018-10-14 06:25:33 +02:00
|
|
|
std::size_t old_width = getWidth();
|
2016-09-11 16:48:39 +02:00
|
|
|
FWidget::setWidth (w, adjust);
|
|
|
|
|
2017-01-22 23:04:40 +01:00
|
|
|
if ( isVirtualWindow() && getWidth() != old_width )
|
2016-10-14 13:02:35 +02:00
|
|
|
{
|
|
|
|
FRect geometry = getTermGeometry();
|
2017-09-11 03:06:02 +02:00
|
|
|
geometry.move(-1, -1);
|
2016-10-14 13:02:35 +02:00
|
|
|
resizeArea (geometry, getShadow(), vwin);
|
|
|
|
}
|
2016-09-11 16:48:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2018-10-14 06:25:33 +02:00
|
|
|
void FWindow::setHeight (std::size_t h, bool adjust)
|
2016-09-11 16:48:39 +02:00
|
|
|
{
|
2018-10-14 06:25:33 +02:00
|
|
|
std::size_t old_height = getHeight();
|
2016-09-11 16:48:39 +02:00
|
|
|
FWidget::setHeight (h, adjust);
|
|
|
|
|
2017-01-22 23:04:40 +01:00
|
|
|
if ( isVirtualWindow() && getHeight() != old_height )
|
2016-10-14 13:02:35 +02:00
|
|
|
{
|
|
|
|
FRect geometry = getTermGeometry();
|
2017-09-11 03:06:02 +02:00
|
|
|
geometry.move(-1, -1);
|
2016-10-14 13:02:35 +02:00
|
|
|
resizeArea (geometry, getShadow(), vwin);
|
|
|
|
}
|
2016-09-11 16:48:39 +02:00
|
|
|
}
|
|
|
|
|
2016-09-29 04:29:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
2018-10-14 06:25:33 +02:00
|
|
|
void FWindow::setSize (std::size_t w, std::size_t h, bool adjust)
|
2016-09-29 04:29:12 +02:00
|
|
|
{
|
2018-10-14 06:25:33 +02:00
|
|
|
std::size_t old_width = getWidth();
|
|
|
|
std::size_t old_height = getHeight();
|
2016-09-29 04:29:12 +02:00
|
|
|
FWidget::setSize (w, h, adjust);
|
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
if ( isVirtualWindow()
|
2017-11-26 22:37:18 +01:00
|
|
|
&& (getWidth() != old_width || getHeight() != old_height) )
|
2016-10-14 13:02:35 +02:00
|
|
|
{
|
|
|
|
FRect geometry = getTermGeometry();
|
2017-09-11 03:06:02 +02:00
|
|
|
geometry.move(-1, -1);
|
2016-10-14 13:02:35 +02:00
|
|
|
resizeArea (geometry, getShadow(), vwin);
|
|
|
|
}
|
2016-09-29 04:29:12 +02:00
|
|
|
}
|
|
|
|
|
2016-09-11 16:48:39 +02:00
|
|
|
//----------------------------------------------------------------------
|
2018-10-24 00:16:45 +02:00
|
|
|
void FWindow::setGeometry ( int x, int y
|
|
|
|
, std::size_t w, std::size_t h
|
|
|
|
, bool adjust )
|
2016-09-11 16:48:39 +02:00
|
|
|
{
|
2017-08-06 17:02:19 +02:00
|
|
|
// Sets the geometry of the widget
|
|
|
|
|
2018-10-14 06:25:33 +02:00
|
|
|
int old_x = getX();
|
|
|
|
int old_y = getY();
|
|
|
|
std::size_t old_width = getWidth();
|
|
|
|
std::size_t old_height = getHeight();
|
2016-10-14 13:02:35 +02:00
|
|
|
|
|
|
|
if ( y < 1 )
|
|
|
|
y = 1;
|
|
|
|
|
2016-09-11 16:48:39 +02:00
|
|
|
FWidget::setGeometry (x, y, w, h, adjust);
|
|
|
|
|
2017-01-22 23:04:40 +01:00
|
|
|
if ( ! isVirtualWindow() )
|
2016-10-17 08:44:38 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
if ( getWidth() != old_width || getHeight() != old_height )
|
2016-10-14 13:02:35 +02:00
|
|
|
{
|
2016-10-17 08:44:38 +02:00
|
|
|
FRect geometry = getTermGeometry();
|
2017-09-11 03:06:02 +02:00
|
|
|
geometry.move(-1, -1);
|
2016-10-17 08:44:38 +02:00
|
|
|
resizeArea (geometry, getShadow(), vwin);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( getX() != old_x )
|
2017-02-25 15:18:29 +01:00
|
|
|
vwin->offset_left = getTermX() - 1;
|
2016-10-14 13:02:35 +02:00
|
|
|
|
2016-10-17 08:44:38 +02:00
|
|
|
if ( getY() != old_y )
|
2017-02-25 15:18:29 +01:00
|
|
|
vwin->offset_top = getTermY() - 1;
|
2016-10-14 13:02:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWindow::move (int dx, int dy)
|
|
|
|
{
|
2017-09-11 03:06:02 +02:00
|
|
|
FWidget::move (dx, dy);
|
2016-10-14 13:02:35 +02:00
|
|
|
|
2017-01-22 23:04:40 +01:00
|
|
|
if ( isVirtualWindow() )
|
2016-10-14 13:02:35 +02:00
|
|
|
{
|
2017-02-25 15:18:29 +01:00
|
|
|
vwin->offset_left = getTermX() - 1;
|
|
|
|
vwin->offset_top = getTermY() - 1;
|
2016-10-14 13:02:35 +02:00
|
|
|
}
|
2016-09-11 16:48:39 +02:00
|
|
|
}
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
2016-06-26 16:08:03 +02:00
|
|
|
FWindow* FWindow::getWindowWidgetAt (int x, int y)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-06-26 16:08:03 +02:00
|
|
|
// returns the window object to the corresponding coordinates
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( window_list && ! window_list->empty() )
|
|
|
|
{
|
2018-12-15 00:50:09 +01:00
|
|
|
auto iter = window_list->end();
|
|
|
|
auto begin = window_list->begin();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
--iter;
|
2015-10-19 00:07:07 +02:00
|
|
|
if ( *iter )
|
|
|
|
{
|
2018-12-15 00:50:09 +01:00
|
|
|
auto w = static_cast<FWindow*>(*iter);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-10-11 04:57:36 +02:00
|
|
|
if ( ! w->isWindowHidden()
|
2017-11-26 22:37:18 +01:00
|
|
|
&& w->getTermGeometry().contains(x, y) )
|
2015-10-19 00:07:07 +02:00
|
|
|
return w;
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
while ( iter != begin );
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWindow::addWindow (FWidget* obj)
|
|
|
|
{
|
2016-06-19 20:32:03 +02:00
|
|
|
// add the window object obj to the window list
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( window_list )
|
|
|
|
window_list->push_back(obj);
|
2016-10-02 21:26:25 +02:00
|
|
|
|
|
|
|
processAlwaysOnTop();
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWindow::delWindow (FWidget* obj)
|
|
|
|
{
|
2016-06-19 20:32:03 +02:00
|
|
|
// delete the window object obj from the window list
|
2016-07-14 23:55:22 +02:00
|
|
|
if ( ! window_list || window_list->empty() )
|
|
|
|
return;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2018-12-15 00:50:09 +01:00
|
|
|
auto iter = window_list->begin();
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-07-14 23:55:22 +02:00
|
|
|
while ( iter != window_list->end() )
|
|
|
|
{
|
|
|
|
if ( (*iter) == obj )
|
|
|
|
{
|
2016-08-06 21:43:39 +02:00
|
|
|
window_list->erase (iter);
|
2016-07-14 23:55:22 +02:00
|
|
|
return;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
2016-07-14 23:55:22 +02:00
|
|
|
|
|
|
|
++iter;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2017-08-12 20:10:27 +02:00
|
|
|
FWindow* FWindow::getWindowWidget (const FWidget* obj)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-06-19 20:32:03 +02:00
|
|
|
// returns the window object to the given widget obj
|
2018-12-15 00:50:09 +01:00
|
|
|
auto p_obj = obj->getParentWidget();
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-09-25 23:53:48 +02:00
|
|
|
while ( ! obj->isWindowWidget() && p_obj )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
obj = p_obj;
|
2016-07-03 20:08:39 +02:00
|
|
|
p_obj = p_obj->getParentWidget();
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-09-25 23:53:48 +02:00
|
|
|
if ( obj->isWindowWidget() )
|
2017-08-12 20:10:27 +02:00
|
|
|
return const_cast<FWindow*>(static_cast<const FWindow*>(obj));
|
2015-05-23 13:35:12 +02:00
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2017-08-12 20:10:27 +02:00
|
|
|
int FWindow::getWindowLayer (const FWidget* obj)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-06-19 20:32:03 +02:00
|
|
|
// returns the window layer from the widget obj
|
2018-12-15 00:50:09 +01:00
|
|
|
|
2017-08-12 20:10:27 +02:00
|
|
|
const FWidget* window;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
if ( ! window_list )
|
|
|
|
return -1;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( window_list->empty() )
|
|
|
|
return -1;
|
|
|
|
|
2016-09-25 23:53:48 +02:00
|
|
|
if ( ! obj->isWindowWidget() )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
if ( (window = getWindowWidget(obj)) == 0 )
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
window = obj;
|
|
|
|
|
2018-12-15 00:50:09 +01:00
|
|
|
auto iter = window_list->begin();
|
|
|
|
auto end = window_list->end();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
while ( iter != end )
|
|
|
|
{
|
|
|
|
if ( *iter == window )
|
|
|
|
break;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
|
|
|
|
return int(std::distance(window_list->begin(), iter) + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWindow::swapWindow (FWidget* obj1, FWidget* obj2)
|
|
|
|
{
|
2016-06-19 20:32:03 +02:00
|
|
|
// swaps the window layer between obj1 and obj2
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
if ( ! window_list )
|
|
|
|
return;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( window_list->empty() )
|
|
|
|
return;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2018-11-04 23:00:06 +01:00
|
|
|
if ( obj1->getFlags().modal )
|
2015-05-23 13:35:12 +02:00
|
|
|
return;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2018-11-04 23:00:06 +01:00
|
|
|
if ( obj2->getFlags().modal )
|
2015-05-23 13:35:12 +02:00
|
|
|
return;
|
|
|
|
|
2018-12-15 00:50:09 +01:00
|
|
|
auto iter = window_list->begin();
|
|
|
|
auto end = window_list->end();
|
|
|
|
auto iter1 = end;
|
|
|
|
auto iter2 = end;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
while ( iter != end )
|
|
|
|
{
|
|
|
|
if ( (*iter) == obj1 )
|
|
|
|
iter1 = iter;
|
|
|
|
else if ( (*iter) == obj2 )
|
|
|
|
iter2 = iter;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( iter1 != end && iter2 != end )
|
|
|
|
std::swap (iter1, iter2);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FWindow::raiseWindow (FWidget* obj)
|
|
|
|
{
|
2016-06-19 20:32:03 +02:00
|
|
|
// raises the window widget obj to the top
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
if ( ! window_list )
|
|
|
|
return false;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( window_list->empty() )
|
|
|
|
return false;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-09-25 23:53:48 +02:00
|
|
|
if ( ! obj->isWindowWidget() )
|
2015-05-23 13:35:12 +02:00
|
|
|
return false;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( window_list->back() == obj )
|
|
|
|
return false;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2018-11-04 23:00:06 +01:00
|
|
|
if ( window_list->back()->getFlags().modal
|
2017-11-26 22:37:18 +01:00
|
|
|
&& ! obj->isMenuWidget() )
|
2015-05-23 13:35:12 +02:00
|
|
|
return false;
|
|
|
|
|
2018-12-15 00:50:09 +01:00
|
|
|
auto iter = window_list->begin();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
while ( iter != window_list->end() )
|
|
|
|
{
|
|
|
|
if ( *iter == obj )
|
|
|
|
{
|
|
|
|
window_list->erase (iter);
|
|
|
|
window_list->push_back (obj);
|
2016-01-17 02:57:08 +01:00
|
|
|
FEvent ev(fc::WindowRaised_Event);
|
2015-05-23 13:35:12 +02:00
|
|
|
FApplication::sendEvent(obj, &ev);
|
2016-10-02 21:26:25 +02:00
|
|
|
processAlwaysOnTop();
|
2015-05-23 13:35:12 +02:00
|
|
|
return true;
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
++iter;
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FWindow::lowerWindow (FWidget* obj)
|
|
|
|
{
|
2016-06-19 20:32:03 +02:00
|
|
|
// lowers the window widget obj to the bottom
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
if ( ! window_list )
|
|
|
|
return false;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( window_list->empty() )
|
|
|
|
return false;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-09-25 23:53:48 +02:00
|
|
|
if ( ! obj->isWindowWidget() )
|
2015-05-23 13:35:12 +02:00
|
|
|
return false;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( window_list->front() == obj )
|
|
|
|
return false;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2018-11-04 23:00:06 +01:00
|
|
|
if ( obj->getFlags().modal )
|
2015-05-23 13:35:12 +02:00
|
|
|
return false;
|
|
|
|
|
2018-12-15 00:50:09 +01:00
|
|
|
auto iter = window_list->begin();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
while ( iter != window_list->end() )
|
|
|
|
{
|
|
|
|
if ( *iter == obj )
|
|
|
|
{
|
|
|
|
window_list->erase (iter);
|
|
|
|
window_list->insert (window_list->begin(), obj);
|
2016-01-17 02:57:08 +01:00
|
|
|
FEvent ev(fc::WindowLowered_Event);
|
2015-05-23 13:35:12 +02:00
|
|
|
FApplication::sendEvent(obj, &ev);
|
|
|
|
return true;
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
++iter;
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-09-11 16:48:39 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FWindow::zoomWindow()
|
|
|
|
{
|
|
|
|
if ( zoomed )
|
|
|
|
{
|
|
|
|
zoomed = false;
|
2016-09-25 23:53:48 +02:00
|
|
|
FRect oldGeometry = getTermGeometryWithShadow();
|
2016-09-11 16:48:39 +02:00
|
|
|
setGeometry (normalGeometry);
|
2016-09-25 23:53:48 +02:00
|
|
|
restoreVTerm (oldGeometry);
|
2016-09-11 16:48:39 +02:00
|
|
|
redraw();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
zoomed = true;
|
|
|
|
// save the current geometry
|
|
|
|
normalGeometry = getGeometry();
|
2016-09-25 23:53:48 +02:00
|
|
|
FRect oldGeometry = getTermGeometryWithShadow();
|
|
|
|
setGeometry (1, 1, getMaxWidth(), getMaxHeight());
|
|
|
|
restoreVTerm (oldGeometry);
|
2016-09-11 16:48:39 +02:00
|
|
|
redraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
return zoomed;
|
|
|
|
}
|
|
|
|
|
2016-06-19 20:32:03 +02:00
|
|
|
//----------------------------------------------------------------------
|
2018-12-09 18:24:31 +01:00
|
|
|
void FWindow::switchToPrevWindow (FWidget* widget)
|
2016-06-19 20:32:03 +02:00
|
|
|
{
|
|
|
|
// switch to previous window
|
2018-02-03 00:04:24 +01:00
|
|
|
|
|
|
|
// Disable terminal updates to avoid flickering
|
|
|
|
// when redrawing the focused widget
|
2018-12-09 18:24:31 +01:00
|
|
|
if ( widget )
|
|
|
|
widget->updateTerminal (FVTerm::stop_refresh);
|
2018-02-03 00:04:24 +01:00
|
|
|
|
2016-08-21 00:16:34 +02:00
|
|
|
bool is_activated = activatePrevWindow();
|
2018-12-15 00:50:09 +01:00
|
|
|
auto active_win = static_cast<FWindow*>(getActiveWindow());
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-08-21 00:16:34 +02:00
|
|
|
if ( ! is_activated )
|
|
|
|
{
|
|
|
|
// no previous window -> looking for another window
|
|
|
|
if ( window_list && window_list->size() > 1 )
|
|
|
|
{
|
2018-12-15 00:50:09 +01:00
|
|
|
auto iter = window_list->end();
|
|
|
|
auto begin = window_list->begin();
|
2016-08-21 00:16:34 +02:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
--iter;
|
2018-12-15 00:50:09 +01:00
|
|
|
auto w = static_cast<FWindow*>(*iter);
|
2016-08-21 00:16:34 +02:00
|
|
|
|
2016-10-02 21:26:25 +02:00
|
|
|
if ( w
|
2018-12-01 21:28:25 +01:00
|
|
|
&& w != active_win
|
2017-11-26 22:37:18 +01:00
|
|
|
&& ! (w->isWindowHidden() || w->isWindowActive())
|
|
|
|
&& w != static_cast<FWindow*>(getStatusBar())
|
|
|
|
&& w != static_cast<FWindow*>(getMenuBar()) )
|
2016-08-21 00:16:34 +02:00
|
|
|
{
|
|
|
|
setActiveWindow(w);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-09-09 22:03:17 +02:00
|
|
|
while ( iter != begin );
|
2016-08-21 00:16:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-01 21:28:25 +01:00
|
|
|
if ( active_win )
|
2016-06-19 20:32:03 +02:00
|
|
|
{
|
2018-12-15 00:50:09 +01:00
|
|
|
auto focus = active_win->getWindowFocusWidget();
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2018-12-01 21:28:25 +01:00
|
|
|
if ( ! active_win->isWindowActive() )
|
|
|
|
setActiveWindow(active_win);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2018-12-01 21:28:25 +01:00
|
|
|
if ( focus)
|
2016-07-24 20:18:23 +02:00
|
|
|
{
|
2018-12-01 21:28:25 +01:00
|
|
|
focus->setFocus();
|
2016-07-31 20:25:25 +02:00
|
|
|
|
2018-12-01 21:28:25 +01:00
|
|
|
if ( ! focus->isWindowWidget() )
|
|
|
|
focus->redraw();
|
2016-07-24 20:18:23 +02:00
|
|
|
}
|
2016-06-19 20:32:03 +02:00
|
|
|
}
|
2018-02-03 00:04:24 +01:00
|
|
|
|
|
|
|
// Enable terminal updates again
|
2018-12-09 18:24:31 +01:00
|
|
|
if ( widget )
|
|
|
|
widget->updateTerminal (FVTerm::continue_refresh);
|
2016-06-19 20:32:03 +02:00
|
|
|
}
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FWindow::activatePrevWindow()
|
|
|
|
{
|
2016-06-19 20:32:03 +02:00
|
|
|
// activate the previous window
|
2018-12-15 00:50:09 +01:00
|
|
|
auto w = previous_window;
|
2016-06-26 16:08:03 +02:00
|
|
|
|
2016-10-02 21:26:25 +02:00
|
|
|
if ( w )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-10-11 04:57:36 +02:00
|
|
|
if ( w->isWindowActive() )
|
2016-10-02 21:26:25 +02:00
|
|
|
return true;
|
|
|
|
|
2016-10-17 08:44:38 +02:00
|
|
|
if ( ! w->isWindowHidden() )
|
2016-10-02 21:26:25 +02:00
|
|
|
{
|
|
|
|
setActiveWindow(w);
|
|
|
|
return true;
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
2016-10-02 21:26:25 +02:00
|
|
|
|
|
|
|
return false;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FWindow::setShadowSize (int right, int bottom)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2017-10-02 07:32:33 +02:00
|
|
|
int old_right = getShadow().getX()
|
|
|
|
, old_bottom = getShadow().getY();
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
FWidget::setShadowSize (right, bottom);
|
2017-10-02 07:32:33 +02:00
|
|
|
|
|
|
|
int new_right = getShadow().getX()
|
|
|
|
, new_bottom = getShadow().getY();
|
2016-11-02 00:37:58 +01:00
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
if ( isVirtualWindow()
|
2017-11-26 22:37:18 +01:00
|
|
|
&& (new_right != old_right || new_bottom != old_bottom) )
|
2016-10-06 23:15:09 +02:00
|
|
|
{
|
2018-12-15 00:50:09 +01:00
|
|
|
auto geometry = getTermGeometry();
|
2017-09-11 03:06:02 +02:00
|
|
|
geometry.move(-1, -1);
|
2016-11-02 00:37:58 +01:00
|
|
|
resizeArea (geometry, getShadow(), vwin);
|
2016-10-06 23:15:09 +02:00
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
2015-10-19 00:07:07 +02:00
|
|
|
|
2016-10-01 23:18:49 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
// protected methods of FWindow
|
2016-10-09 02:06:06 +02:00
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FWindow::adjustSize()
|
2016-10-09 02:06:06 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
int old_x = getX();
|
|
|
|
int old_y = getY();
|
|
|
|
FWidget::adjustSize();
|
2016-10-09 02:06:06 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( zoomed )
|
|
|
|
setGeometry (1, 1, getMaxWidth(), getMaxHeight(), false);
|
2017-01-22 23:04:40 +01:00
|
|
|
else if ( isVirtualWindow() )
|
2016-11-02 00:37:58 +01:00
|
|
|
{
|
|
|
|
if ( getX() != old_x )
|
2017-02-25 15:18:29 +01:00
|
|
|
vwin->offset_left = getTermX() - 1;
|
2016-11-02 00:37:58 +01:00
|
|
|
|
|
|
|
if ( getY() != old_y )
|
2017-02-25 15:18:29 +01:00
|
|
|
vwin->offset_top = getTermY() - 1;
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
2016-10-09 02:06:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
bool FWindow::event (FEvent* ev)
|
2016-10-09 02:06:06 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
switch ( ev->type() )
|
2016-10-09 02:06:06 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
case fc::WindowActive_Event:
|
|
|
|
onWindowActive (ev);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case fc::WindowInactive_Event:
|
|
|
|
onWindowInactive (ev);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case fc::WindowRaised_Event:
|
|
|
|
onWindowRaised (ev);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case fc::WindowLowered_Event:
|
|
|
|
onWindowLowered (ev);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return FWidget::event(ev);
|
2016-10-09 02:06:06 +02:00
|
|
|
}
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
return true;
|
2016-10-09 02:06:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FWindow::onWindowActive (FEvent*)
|
|
|
|
{ }
|
2016-10-09 02:06:06 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWindow::onWindowInactive (FEvent*)
|
|
|
|
{ }
|
2016-10-09 02:06:06 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWindow::onWindowRaised (FEvent*)
|
|
|
|
{ }
|
2016-10-09 02:06:06 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FWindow::onWindowLowered (FEvent*)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
// private methods of FWindow
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWindow::deleteFromAlwaysOnTopList (FWidget* obj)
|
2016-10-09 02:06:06 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
// delete the window object obj from the always-on-top list
|
|
|
|
if ( ! always_on_top_list || always_on_top_list->empty() )
|
|
|
|
return;
|
2016-10-09 02:06:06 +02:00
|
|
|
|
2018-12-15 00:50:09 +01:00
|
|
|
auto iter = always_on_top_list->begin();
|
2016-11-02 00:37:58 +01:00
|
|
|
|
|
|
|
while ( iter != always_on_top_list->end() )
|
2016-10-14 13:02:35 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( *iter == obj )
|
|
|
|
{
|
|
|
|
always_on_top_list->erase (iter);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
++iter;
|
2016-10-14 13:02:35 +02:00
|
|
|
}
|
2016-10-09 02:06:06 +02:00
|
|
|
}
|
|
|
|
|
2016-10-01 23:18:49 +02:00
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FWindow::processAlwaysOnTop()
|
2016-10-01 23:18:49 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
// Raise all always-on-top windows
|
|
|
|
if ( ! always_on_top_list || always_on_top_list->empty() )
|
|
|
|
return;
|
2016-10-01 23:18:49 +02:00
|
|
|
|
2018-12-15 00:50:09 +01:00
|
|
|
auto iter = always_on_top_list->begin();
|
2016-10-01 23:18:49 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
while ( iter != always_on_top_list->end() )
|
2016-10-01 23:18:49 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
delWindow (*iter);
|
2016-10-01 23:18:49 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( window_list )
|
|
|
|
window_list->push_back(*iter);
|
|
|
|
|
|
|
|
++iter;
|
|
|
|
}
|
2016-10-01 23:18:49 +02:00
|
|
|
}
|
2018-09-20 23:59:01 +02:00
|
|
|
|
|
|
|
} // namespace finalcut
|