2017-11-04 07:03:53 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* fwidget.cpp - Intermediate base class for all widget objects *
|
|
|
|
* *
|
|
|
|
* This file is part of the Final Cut widget toolkit *
|
|
|
|
* *
|
|
|
|
* Copyright 2015-2017 Markus Gans *
|
|
|
|
* *
|
|
|
|
* 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-11 03:06:02 +02:00
|
|
|
#include <vector>
|
|
|
|
|
2017-09-17 21:32:46 +02:00
|
|
|
#include "final/fapplication.h"
|
|
|
|
#include "final/fmenubar.h"
|
|
|
|
#include "final/fstatusbar.h"
|
|
|
|
#include "final/fwidget.h"
|
2016-10-11 04:57:36 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
// global FWidget object
|
|
|
|
static FWidget* rootObject = 0;
|
|
|
|
|
|
|
|
// static class attributes
|
|
|
|
uInt FWidget::modal_dialogs;
|
|
|
|
|
|
|
|
FStatusBar* FWidget::statusbar = 0;
|
2015-08-09 23:44:11 +02:00
|
|
|
FMenuBar* FWidget::menubar = 0;
|
2015-05-23 13:35:12 +02:00
|
|
|
FWidget* FWidget::show_root_widget = 0;
|
|
|
|
FWidget* FWidget::redraw_root_widget = 0;
|
|
|
|
FWidget::widgetList* FWidget::window_list = 0;
|
2016-07-14 23:55:22 +02:00
|
|
|
FWidget::widgetList* FWidget::dialog_list = 0;
|
2016-10-01 23:18:49 +02:00
|
|
|
FWidget::widgetList* FWidget::always_on_top_list = 0;
|
2015-05-23 13:35:12 +02:00
|
|
|
FWidget::widgetList* FWidget::close_widget = 0;
|
|
|
|
FWidget::widget_colors FWidget::wc;
|
2016-11-27 19:16:52 +01:00
|
|
|
bool FWidget::init_desktop;
|
2016-11-12 22:59:48 +01:00
|
|
|
bool FWidget::hideable;
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FWidget
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// constructors and destructor
|
|
|
|
//----------------------------------------------------------------------
|
2017-03-26 20:40:04 +02:00
|
|
|
FWidget::FWidget (FWidget* parent, bool disable_alt_screen)
|
2017-10-30 20:29:00 +01:00
|
|
|
: FVTerm(bool(! parent), disable_alt_screen)
|
|
|
|
, FObject(parent)
|
2016-10-01 23:18:49 +02:00
|
|
|
, accelerator_list(0)
|
2015-09-22 04:18:20 +02:00
|
|
|
, flags(0)
|
2016-11-02 00:37:58 +01:00
|
|
|
, callback_objects()
|
|
|
|
, member_callback_objects()
|
2015-09-22 04:18:20 +02:00
|
|
|
, enable(true)
|
|
|
|
, visible(true)
|
|
|
|
, shown(false)
|
|
|
|
, focus(false)
|
|
|
|
, focusable(true)
|
2016-11-12 22:59:48 +01:00
|
|
|
, visible_cursor(true)
|
2017-09-11 03:06:02 +02:00
|
|
|
, widget_cursor_position(-1, -1)
|
2016-09-25 23:53:48 +02:00
|
|
|
, size_hints()
|
|
|
|
, double_flatline_mask()
|
|
|
|
, padding()
|
|
|
|
, ignore_padding(false)
|
2017-09-11 03:06:02 +02:00
|
|
|
, wsize(1, 1, 1, 1)
|
|
|
|
, adjust_wsize(1, 1, 1, 1)
|
2016-09-25 23:53:48 +02:00
|
|
|
, adjust_wsize_term()
|
|
|
|
, adjust_wsize_shadow()
|
|
|
|
, adjust_wsize_term_shadow()
|
|
|
|
, offset()
|
|
|
|
, client_offset()
|
2017-09-11 03:06:02 +02:00
|
|
|
, wshadow(0, 0)
|
2016-10-09 02:06:06 +02:00
|
|
|
, foreground_color(fc::Default)
|
|
|
|
, background_color(fc::Default)
|
2016-09-25 23:53:48 +02:00
|
|
|
, statusbar_message()
|
2015-09-22 04:18:20 +02:00
|
|
|
{
|
2017-06-05 16:11:25 +02:00
|
|
|
if ( isEnabled() )
|
|
|
|
flags |= fc::active;
|
|
|
|
|
2017-06-11 17:47:50 +02:00
|
|
|
widget_object = true;
|
|
|
|
|
2015-11-05 23:25:21 +01:00
|
|
|
if ( ! parent )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
assert ( ! rootObject
|
2017-11-26 22:37:18 +01:00
|
|
|
&& "FTerm: There should be only one root object" );
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
rootObject = this;
|
|
|
|
show_root_widget = 0;
|
|
|
|
redraw_root_widget = 0;
|
|
|
|
modal_dialogs = 0;
|
|
|
|
statusbar = 0;
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-11-12 22:59:48 +01:00
|
|
|
visible_cursor = ! hideable;
|
2016-09-25 23:53:48 +02:00
|
|
|
offset = parent->client_offset;
|
|
|
|
double_flatline_mask.top.resize (uLong(getWidth()), false);
|
|
|
|
double_flatline_mask.right.resize (uLong(getHeight()), false);
|
|
|
|
double_flatline_mask.bottom.resize (uLong(getWidth()), false);
|
|
|
|
double_flatline_mask.left.resize (uLong(getHeight()), false);
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FWidget::~FWidget() // destructor
|
|
|
|
{
|
|
|
|
processDestroy();
|
2017-11-03 22:57:40 +01:00
|
|
|
delCallbacks();
|
2015-05-23 13:35:12 +02:00
|
|
|
FApplication::removeQueuedEvent(this);
|
|
|
|
|
2016-07-31 20:25:25 +02:00
|
|
|
// unset clicked widget
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( this == getClickedWidget() )
|
|
|
|
setClickedWidget(0);
|
|
|
|
|
2016-07-31 20:25:25 +02:00
|
|
|
// unset the local window widget focus
|
|
|
|
if ( focus )
|
|
|
|
{
|
2016-10-02 21:26:25 +02:00
|
|
|
if ( FWindow* window = FWindow::getWindowWidget(this) )
|
2016-07-31 20:25:25 +02:00
|
|
|
window->setWindowFocusWidget(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// unset the global widget focus
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( this == FWidget::getFocusWidget() )
|
|
|
|
FWidget::setFocusWidget(0);
|
|
|
|
|
2016-07-31 20:25:25 +02:00
|
|
|
// unset main widget
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( this == getMainWidget() )
|
|
|
|
{
|
|
|
|
setMainWidget(0);
|
|
|
|
quit();
|
|
|
|
}
|
|
|
|
|
2016-07-31 20:25:25 +02:00
|
|
|
// finish the program
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( rootObject == this )
|
2017-09-17 01:50:41 +02:00
|
|
|
finish();
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
|
|
|
|
// public methods of FWidget
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
FWidget* FWidget::getRootWidget() const
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
FWidget* obj = const_cast<FWidget*>(this);
|
|
|
|
FWidget* p_obj = getParentWidget();
|
2016-09-25 23:53:48 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
while ( ! obj->isRootWidget() && p_obj )
|
|
|
|
{
|
|
|
|
obj = p_obj;
|
|
|
|
p_obj = p_obj->getParentWidget();
|
|
|
|
}
|
2016-09-25 23:53:48 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
return obj;
|
|
|
|
}
|
2015-06-21 23:27:10 +02:00
|
|
|
|
2017-06-11 17:47:50 +02:00
|
|
|
//----------------------------------------------------------------------
|
2017-06-14 01:06:48 +02:00
|
|
|
FWidget* FWidget::getParentWidget() const
|
2017-06-11 17:47:50 +02:00
|
|
|
{
|
|
|
|
FObject* p_obj = getParent();
|
|
|
|
|
|
|
|
if ( p_obj && p_obj->isWidget() )
|
|
|
|
return static_cast<FWidget*>(p_obj);
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FWidget* FWidget::getMainWidget()
|
|
|
|
{
|
|
|
|
FWidget* main_widget = static_cast<FWidget*>(FApplication::main_widget);
|
|
|
|
return main_widget;
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FWidget* FWidget::getFocusWidget() const
|
|
|
|
{
|
|
|
|
FWidget* focus_widget = static_cast<FWidget*>(FApplication::focus_widget);
|
|
|
|
return focus_widget;
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-01-28 22:03:15 +01:00
|
|
|
//----------------------------------------------------------------------
|
2017-09-17 01:50:41 +02:00
|
|
|
FWidget* FWidget::getFirstFocusableWidget (FObjectList list)
|
2017-01-28 22:03:15 +01:00
|
|
|
{
|
2017-09-17 01:50:41 +02:00
|
|
|
if ( list.empty() )
|
2017-01-28 22:03:15 +01:00
|
|
|
return 0;
|
|
|
|
|
2017-09-17 01:50:41 +02:00
|
|
|
constFObjectIterator iter, last;
|
|
|
|
iter = list.begin();
|
|
|
|
last = list.end();
|
2017-01-28 22:03:15 +01:00
|
|
|
|
2017-09-17 01:50:41 +02:00
|
|
|
while ( iter != last )
|
2017-01-28 22:03:15 +01:00
|
|
|
{
|
2017-06-11 17:47:50 +02:00
|
|
|
if ( (*iter)->isWidget() )
|
|
|
|
{
|
|
|
|
FWidget* child = static_cast<FWidget*>(*iter);
|
2017-01-28 22:03:15 +01:00
|
|
|
|
2017-06-11 17:47:50 +02:00
|
|
|
if ( child->isEnabled() && child->acceptFocus() )
|
|
|
|
return child;
|
|
|
|
}
|
2017-01-28 22:03:15 +01:00
|
|
|
|
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2017-09-17 01:50:41 +02:00
|
|
|
FWidget* FWidget::getLastFocusableWidget (FObjectList list)
|
2017-01-28 22:03:15 +01:00
|
|
|
{
|
2017-09-17 01:50:41 +02:00
|
|
|
if ( list.empty() )
|
2017-01-28 22:03:15 +01:00
|
|
|
return 0;
|
|
|
|
|
2017-09-17 01:50:41 +02:00
|
|
|
constFObjectIterator iter, first;
|
|
|
|
first = list.begin();
|
|
|
|
iter = list.end();
|
2017-01-28 22:03:15 +01:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
--iter;
|
2017-06-11 17:47:50 +02:00
|
|
|
|
|
|
|
if ( ! (*iter)->isWidget() )
|
|
|
|
continue;
|
|
|
|
|
2017-01-28 22:03:15 +01:00
|
|
|
FWidget* child = static_cast<FWidget*>(*iter);
|
|
|
|
|
|
|
|
if ( child->isEnabled() && child->acceptFocus() )
|
|
|
|
return child;
|
|
|
|
}
|
2017-09-17 01:50:41 +02:00
|
|
|
while ( iter != first );
|
2017-01-28 22:03:15 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FWidget* FWidget::getClickedWidget()
|
|
|
|
{
|
|
|
|
FWidget* clicked_widget = static_cast<FWidget*>(FApplication::clicked_widget);
|
|
|
|
return clicked_widget;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
FWidget* FWidget::getMoveSizeWidget()
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
return FApplication::move_size_widget;
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FWidget* FWidget::getOpenMenu()
|
|
|
|
{
|
|
|
|
FWidget* open_menu = static_cast<FWidget*>(FApplication::open_menu);
|
|
|
|
return open_menu;
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FMenuBar* FWidget::getMenuBar()
|
|
|
|
{
|
|
|
|
if ( menubar )
|
|
|
|
return menubar;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FStatusBar* FWidget::getStatusBar()
|
|
|
|
{
|
|
|
|
if ( statusbar )
|
|
|
|
return statusbar;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FPoint FWidget::getPrintPos()
|
|
|
|
{
|
|
|
|
const FPoint cur = getPrintCursor();
|
|
|
|
int cx = cur.getX();
|
|
|
|
int cy = cur.getY();
|
|
|
|
return FPoint ( cx - offset.getX1() - getX() + 1
|
|
|
|
, cy - offset.getY1() - getY() + 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
std::vector<bool>& FWidget::doubleFlatLine_ref (fc::sides side)
|
|
|
|
{
|
2016-12-18 23:34:11 +01:00
|
|
|
assert ( side == fc::top
|
2017-11-26 22:37:18 +01:00
|
|
|
|| side == fc::right
|
|
|
|
|| side == fc::bottom
|
|
|
|
|| side == fc::left );
|
2016-11-02 00:37:58 +01:00
|
|
|
|
|
|
|
switch ( side )
|
2016-07-14 23:55:22 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
case fc::top:
|
|
|
|
return double_flatline_mask.top;
|
|
|
|
|
|
|
|
case fc::right:
|
|
|
|
return double_flatline_mask.right;
|
|
|
|
|
|
|
|
case fc::bottom:
|
|
|
|
return double_flatline_mask.bottom;
|
|
|
|
|
|
|
|
case fc::left:
|
|
|
|
return double_flatline_mask.left;
|
2016-07-14 23:55:22 +02:00
|
|
|
}
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
return double_flatline_mask.left;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setMainWidget (FWidget* obj)
|
|
|
|
{
|
|
|
|
FApplication* fapp = static_cast<FApplication*>(rootObject);
|
|
|
|
fapp->setMainWidget(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setFocusWidget (FWidget* obj)
|
|
|
|
{
|
|
|
|
FApplication::focus_widget = obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setClickedWidget (FWidget* obj)
|
|
|
|
{
|
|
|
|
FApplication::clicked_widget = obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setMoveSizeWidget (FWidget* obj)
|
|
|
|
{
|
|
|
|
FApplication::move_size_widget = obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setOpenMenu (FWidget* obj)
|
|
|
|
{
|
|
|
|
FApplication::open_menu = obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2017-03-26 20:40:04 +02:00
|
|
|
void FWidget::setStatusbarMessage (const FString& msg)
|
2016-11-02 00:37:58 +01:00
|
|
|
{
|
|
|
|
statusbar_message = msg;
|
|
|
|
}
|
|
|
|
|
2017-06-05 16:11:25 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FWidget::setEnable (bool on)
|
2017-06-11 17:47:50 +02:00
|
|
|
{
|
2017-06-05 16:11:25 +02:00
|
|
|
if ( on )
|
|
|
|
flags |= fc::active;
|
|
|
|
else
|
|
|
|
flags &= ~fc::active;
|
|
|
|
|
2017-09-17 21:32:46 +02:00
|
|
|
return enable = ( on ) ? true : false;
|
2017-06-05 16:11:25 +02:00
|
|
|
}
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FWidget::setFocus (bool on)
|
|
|
|
{
|
|
|
|
FWindow* window;
|
2017-01-26 00:31:07 +01:00
|
|
|
FWidget* last_focus;
|
2016-11-02 00:37:58 +01:00
|
|
|
|
|
|
|
if ( ! enable )
|
|
|
|
return false;
|
|
|
|
|
2017-06-05 16:11:25 +02:00
|
|
|
if ( on )
|
|
|
|
flags |= fc::focus;
|
|
|
|
else
|
|
|
|
flags &= ~fc::focus;
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( on == focus )
|
|
|
|
return true;
|
|
|
|
|
2017-01-26 00:31:07 +01:00
|
|
|
last_focus = FWidget::getFocusWidget();
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
// set widget focus
|
|
|
|
if ( on && ! focus )
|
2016-10-01 23:18:49 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
int focusable_children = numOfFocusableChildren();
|
|
|
|
|
2017-01-26 00:31:07 +01:00
|
|
|
if ( last_focus )
|
|
|
|
last_focus->unsetFocus();
|
2016-11-02 00:37:58 +01:00
|
|
|
|
|
|
|
if ( (!isDialogWidget() && focusable_children == 0)
|
2017-11-26 22:37:18 +01:00
|
|
|
|| (isDialogWidget() && focusable_children == 1) )
|
2016-11-02 00:37:58 +01:00
|
|
|
{
|
|
|
|
FWidget::setFocusWidget(this);
|
|
|
|
}
|
2016-10-01 23:18:49 +02:00
|
|
|
}
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
window = FWindow::getWindowWidget(this);
|
|
|
|
|
|
|
|
// set window focus
|
|
|
|
if ( on && window )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( ! window->isWindowActive() )
|
|
|
|
{
|
|
|
|
bool has_raised = window->raiseWindow();
|
|
|
|
FWindow::setActiveWindow(window);
|
|
|
|
|
|
|
|
if ( has_raised && window->isVisible() && window->isShown() )
|
|
|
|
window->redraw();
|
|
|
|
}
|
|
|
|
window->setWindowFocusWidget(this);
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
2016-11-02 00:37:58 +01:00
|
|
|
|
2017-09-17 21:32:46 +02:00
|
|
|
return focus = ( on ) ? true : false;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FWidget::setColor ()
|
|
|
|
{
|
|
|
|
// Changes colors to the widget default colors
|
|
|
|
setColor (foreground_color, background_color);
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FWidget::setX (int x, bool adjust)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( getX() == x && wsize.getX() == x )
|
|
|
|
return;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( ! isWindowWidget() && x < 1 )
|
|
|
|
x = 1;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
wsize.setX(x);
|
|
|
|
adjust_wsize.setX(x);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( adjust )
|
|
|
|
adjustSize();
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FWidget::setY (int y, bool adjust)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( getY() == y && wsize.getY() == y )
|
|
|
|
return;
|
2016-08-21 21:27:44 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( ! isWindowWidget() && y < 1 )
|
|
|
|
y = 1;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
wsize.setY(y);
|
|
|
|
adjust_wsize.setY(y);
|
|
|
|
|
|
|
|
if ( adjust )
|
|
|
|
adjustSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setPos (int x, int y, bool adjust)
|
|
|
|
{
|
2016-12-18 23:34:11 +01:00
|
|
|
if ( getX() == x && wsize.getX() == x
|
2017-11-26 22:37:18 +01:00
|
|
|
&& getY() == y && wsize.getY() == y )
|
2016-11-02 00:37:58 +01:00
|
|
|
{
|
|
|
|
return;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
2016-09-25 23:53:48 +02:00
|
|
|
if ( ! isWindowWidget() )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( x < 1 )
|
|
|
|
x = 1;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( y < 1 )
|
|
|
|
y = 1;
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
wsize.setPos(x, y);
|
|
|
|
adjust_wsize.setPos(x, y);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( adjust )
|
|
|
|
adjustSize();
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setWidth (int width, bool adjust)
|
|
|
|
{
|
|
|
|
width = std::min (width, size_hints.max_width);
|
|
|
|
width = std::max (width, size_hints.min_width);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( getWidth() == width && wsize.getWidth() == width )
|
|
|
|
return;
|
2016-01-17 23:37:52 +01:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( width < 1 )
|
|
|
|
width = 1;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
wsize.setWidth(width);
|
|
|
|
adjust_wsize.setWidth(width);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( adjust )
|
|
|
|
adjustSize();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
double_flatline_mask.top.resize (uLong(getWidth()), false);
|
|
|
|
double_flatline_mask.bottom.resize (uLong(getWidth()), false);
|
|
|
|
}
|
2016-09-25 23:53:48 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setHeight (int height, bool adjust)
|
|
|
|
{
|
|
|
|
height = std::min (height, size_hints.max_height);
|
|
|
|
height = std::max (height, size_hints.min_height);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( getHeight() == height && wsize.getHeight() == height )
|
|
|
|
return;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( height < 1 )
|
|
|
|
height = 1;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
wsize.setHeight(height);
|
|
|
|
adjust_wsize.setHeight(height);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( adjust )
|
|
|
|
adjustSize();
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
double_flatline_mask.right.resize (uLong(getHeight()), false);
|
|
|
|
double_flatline_mask.left.resize (uLong(getHeight()), false);
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
2016-05-16 21:11:32 +02:00
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FWidget::setSize (int width, int height, bool adjust)
|
2016-05-16 21:11:32 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
width = std::min (width, size_hints.max_width);
|
|
|
|
width = std::max (width, size_hints.min_width);
|
|
|
|
height = std::min (height, size_hints.max_height);
|
|
|
|
height = std::max (height, size_hints.min_height);
|
|
|
|
|
|
|
|
if ( getWidth() == width && wsize.getWidth() == width
|
2017-11-26 22:37:18 +01:00
|
|
|
&& getHeight() == height && wsize.getHeight() == height )
|
2016-05-16 21:11:32 +02:00
|
|
|
return;
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( width < 1 )
|
|
|
|
width = 1;
|
2016-05-16 21:11:32 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( height < 1 )
|
|
|
|
height = 1;
|
|
|
|
|
|
|
|
wsize.setWidth(width);
|
|
|
|
wsize.setHeight(height);
|
|
|
|
adjust_wsize.setWidth(width);
|
|
|
|
adjust_wsize.setHeight(height);
|
|
|
|
|
|
|
|
if ( adjust )
|
|
|
|
adjustSize();
|
|
|
|
|
|
|
|
double_flatline_mask.top.resize (uLong(getWidth()), false);
|
|
|
|
double_flatline_mask.right.resize (uLong(getHeight()), false);
|
|
|
|
double_flatline_mask.bottom.resize (uLong(getWidth()), false);
|
|
|
|
double_flatline_mask.left.resize (uLong(getHeight()), false);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setTopPadding (int top, bool adjust)
|
|
|
|
{
|
|
|
|
if ( padding.top == top )
|
|
|
|
return;
|
|
|
|
|
2017-01-22 23:04:40 +01:00
|
|
|
padding.top = top;
|
2016-11-02 00:37:58 +01:00
|
|
|
|
|
|
|
if ( adjust )
|
|
|
|
{
|
|
|
|
if ( isRootWidget() )
|
2016-05-16 21:11:32 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
FWidget* r = rootObject;
|
|
|
|
r->client_offset.setY1 (r->padding.top);
|
|
|
|
adjustSizeGlobal();
|
2016-05-16 21:11:32 +02:00
|
|
|
}
|
2016-11-02 00:37:58 +01:00
|
|
|
else
|
|
|
|
adjustSize();
|
2016-05-16 21:11:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FWidget::setLeftPadding (int left, bool adjust)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( padding.left == left )
|
2015-05-23 13:35:12 +02:00
|
|
|
return;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-01-22 23:04:40 +01:00
|
|
|
padding.left = left;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( adjust )
|
|
|
|
{
|
|
|
|
if ( isRootWidget() )
|
|
|
|
{
|
|
|
|
FWidget* r = rootObject;
|
|
|
|
r->client_offset.setX1 (r->padding.left);
|
|
|
|
adjustSizeGlobal();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
adjustSize();
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
2015-08-09 23:44:11 +02:00
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FWidget::setBottomPadding (int bottom, bool adjust)
|
2015-08-09 23:44:11 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( padding.bottom == bottom )
|
2015-08-09 23:44:11 +02:00
|
|
|
return;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-01-22 23:04:40 +01:00
|
|
|
padding.bottom = bottom;
|
2015-08-09 23:44:11 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( adjust )
|
|
|
|
{
|
|
|
|
if ( isRootWidget() )
|
|
|
|
{
|
|
|
|
FWidget* r = rootObject;
|
|
|
|
r->client_offset.setY2 (r->getHeight() - 1 - r->padding.bottom);
|
|
|
|
adjustSizeGlobal();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
adjustSize();
|
|
|
|
}
|
2015-08-09 23:44:11 +02:00
|
|
|
}
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FWidget::setRightPadding (int right, bool adjust)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( padding.right == right )
|
|
|
|
return;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-01-22 23:04:40 +01:00
|
|
|
padding.right = right;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( adjust )
|
|
|
|
{
|
|
|
|
if ( isRootWidget() )
|
|
|
|
{
|
|
|
|
FWidget* r = rootObject;
|
|
|
|
r->client_offset.setX2 (r->getWidth() - 1 - r->padding.right);
|
|
|
|
adjustSizeGlobal();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
adjustSize();
|
|
|
|
}
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setParentOffset()
|
|
|
|
{
|
|
|
|
FWidget* p = getParentWidget();
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( p )
|
|
|
|
offset = p->client_offset;
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setTermOffset()
|
|
|
|
{
|
|
|
|
FWidget* r = getRootWidget();
|
|
|
|
int w = r->getWidth();
|
|
|
|
int h = r->getHeight();
|
|
|
|
offset.setCoordinates (0, 0, w - 1, h - 1);
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setTermOffsetWithPadding()
|
|
|
|
{
|
|
|
|
FWidget* r = getRootWidget();
|
|
|
|
offset.setCoordinates ( r->getLeftPadding()
|
|
|
|
, r->getTopPadding()
|
|
|
|
, r->getWidth() - 1 - r->getRightPadding()
|
2017-12-02 18:52:51 +01:00
|
|
|
, r->getHeight() - 1 - r->getBottomPadding() );
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setTermSize (int w, int h)
|
|
|
|
{
|
|
|
|
// Set xterm size to w x h
|
|
|
|
if ( isXTerminal() )
|
|
|
|
{
|
|
|
|
rootObject->wsize.setRect(1, 1, w, h);
|
|
|
|
rootObject->adjust_wsize = rootObject->wsize;
|
|
|
|
FTerm::setTermSize (w, h); // w = columns / h = lines
|
|
|
|
detectTermSize();
|
|
|
|
}
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setGeometry (int x, int y, int w, int h, bool adjust)
|
|
|
|
{
|
2017-08-06 17:02:19 +02:00
|
|
|
// Sets the geometry of the widget relative to its parent
|
|
|
|
|
2017-10-02 07:32:33 +02:00
|
|
|
int term_x
|
|
|
|
, term_y;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
w = std::min (w, size_hints.max_width);
|
|
|
|
w = std::max (w, size_hints.min_width);
|
|
|
|
h = std::min (h, size_hints.max_height);
|
|
|
|
h = std::max (h, size_hints.min_height);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( getX() == x && getY() == y && getWidth() == w && getHeight() == h )
|
|
|
|
return;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( ! isWindowWidget() )
|
|
|
|
{
|
2017-09-17 21:32:46 +02:00
|
|
|
( x < 1 ) ? wsize.setX(1) : wsize.setX(x);
|
|
|
|
( y < 1 ) ? wsize.setY(1) : wsize.setY(y);
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wsize.setX(x);
|
|
|
|
wsize.setY(y);
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-09-17 21:32:46 +02:00
|
|
|
( w < 1 ) ? wsize.setWidth(1) : wsize.setWidth(w);
|
|
|
|
( h < 1 ) ? wsize.setHeight(1) : wsize.setHeight(h);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
adjust_wsize = wsize;
|
|
|
|
term_x = getTermX();
|
|
|
|
term_y = getTermY();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
client_offset.setCoordinates ( term_x - 1 + padding.left
|
|
|
|
, term_y - 1 + padding.top
|
|
|
|
, term_x - 2 + getWidth() - padding.right
|
|
|
|
, term_y - 2 + getHeight() - padding.bottom );
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
double_flatline_mask.top.resize (uLong(getWidth()), false);
|
|
|
|
double_flatline_mask.right.resize (uLong(getHeight()), false);
|
|
|
|
double_flatline_mask.bottom.resize (uLong(getWidth()), false);
|
|
|
|
double_flatline_mask.left.resize (uLong(getHeight()), false);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( adjust )
|
|
|
|
adjustSize();
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FWidget::setCursorPos (register int x, register int y)
|
|
|
|
{
|
|
|
|
// sets the input cursor position
|
2017-02-24 00:30:07 +01:00
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
widget_cursor_position.setPoint(x, y);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-02-24 00:30:07 +01:00
|
|
|
if ( (flags & fc::focus) == 0 || isWindowWidget() )
|
|
|
|
return false;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-03-08 23:48:30 +01:00
|
|
|
if ( ! FWindow::getWindowWidget(this) )
|
2017-02-24 00:30:07 +01:00
|
|
|
return false;
|
|
|
|
|
2017-03-08 23:48:30 +01:00
|
|
|
term_area* area = getPrintArea();
|
|
|
|
|
|
|
|
if ( area->widget )
|
2017-02-24 00:30:07 +01:00
|
|
|
{
|
2017-03-08 23:48:30 +01:00
|
|
|
int widget_offsetX = getTermX() - area->widget->getTermX();
|
|
|
|
int widget_offsetY = getTermY() - area->widget->getTermY();
|
|
|
|
|
|
|
|
if ( isChildPrintArea() )
|
|
|
|
{
|
|
|
|
widget_offsetX += (1 - area->widget->getLeftPadding());
|
|
|
|
widget_offsetY += (1 - area->widget->getTopPadding());
|
|
|
|
}
|
|
|
|
|
|
|
|
setAreaCursor ( widget_offsetX + x
|
|
|
|
, widget_offsetY + y
|
2017-02-24 00:30:07 +01:00
|
|
|
, visible_cursor
|
|
|
|
, area );
|
|
|
|
return true;
|
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 false;
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setPrintPos (register int x, register int y)
|
|
|
|
{
|
|
|
|
setPrintCursor ( offset.getX1() + getX() + x - 1,
|
|
|
|
offset.getY1() + getY() + y - 1 );
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setDoubleFlatLine (fc::sides side, bool bit)
|
|
|
|
{
|
|
|
|
uLong length;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-12-18 23:34:11 +01:00
|
|
|
assert ( side == fc::top
|
2017-11-26 22:37:18 +01:00
|
|
|
|| side == fc::right
|
|
|
|
|| side == fc::bottom
|
|
|
|
|| side == fc::left );
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
switch ( side )
|
|
|
|
{
|
|
|
|
case fc::top:
|
|
|
|
length = double_flatline_mask.top.size();
|
|
|
|
double_flatline_mask.top.assign(length, bit);
|
2015-05-23 13:35:12 +02:00
|
|
|
break;
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
case fc::right:
|
|
|
|
length = double_flatline_mask.right.size();
|
|
|
|
double_flatline_mask.right.assign(length, bit);
|
2015-05-23 13:35:12 +02:00
|
|
|
break;
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
case fc::bottom:
|
|
|
|
length = double_flatline_mask.bottom.size();
|
|
|
|
double_flatline_mask.bottom.assign(length, bit);
|
2015-05-23 13:35:12 +02:00
|
|
|
break;
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
case fc::left:
|
|
|
|
length = double_flatline_mask.left.size();
|
|
|
|
double_flatline_mask.left.assign(length, bit);
|
|
|
|
break;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FWidget::setDoubleFlatLine (fc::sides side, int pos, bool bit)
|
|
|
|
{
|
|
|
|
uLong length, index;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-12-18 23:34:11 +01:00
|
|
|
assert ( side == fc::top
|
2017-11-26 22:37:18 +01:00
|
|
|
|| side == fc::right
|
|
|
|
|| side == fc::bottom
|
|
|
|
|| side == fc::left );
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
assert ( pos >= 1 );
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
index = uLong(pos - 1);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
switch ( side )
|
|
|
|
{
|
|
|
|
case fc::top:
|
|
|
|
length = double_flatline_mask.top.size();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( index < length )
|
|
|
|
double_flatline_mask.top[index] = bit;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
break;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
case fc::right:
|
|
|
|
length = double_flatline_mask.right.size();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( index < length )
|
|
|
|
double_flatline_mask.right[index] = bit;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
break;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
case fc::bottom:
|
|
|
|
length = double_flatline_mask.bottom.size();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( index < length )
|
|
|
|
double_flatline_mask.bottom[index] = bit;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
break;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
case fc::left:
|
|
|
|
length = double_flatline_mask.left.size();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( index < length )
|
|
|
|
double_flatline_mask.left[index] = bit;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
FWidget* FWidget::childWidgetAt (FWidget* p, int x, int y)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( p && p->hasChildren() )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2017-09-17 01:50:41 +02:00
|
|
|
constFObjectIterator iter, last;
|
|
|
|
iter = p->begin();
|
|
|
|
last = p->end();
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-09-17 01:50:41 +02:00
|
|
|
while ( iter != last )
|
2016-11-02 00:37:58 +01:00
|
|
|
{
|
2017-06-11 17:47:50 +02:00
|
|
|
if ( ! (*iter)->isWidget() )
|
|
|
|
{
|
|
|
|
++iter;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
FWidget* widget = static_cast<FWidget*>(*iter);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-12-18 23:34:11 +01:00
|
|
|
if ( widget->isEnabled()
|
2017-11-26 22:37:18 +01:00
|
|
|
&& widget->isVisible()
|
|
|
|
&& ! widget->isWindowWidget()
|
|
|
|
&& widget->getTermGeometry().contains(x, y) )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
FWidget* child = childWidgetAt(widget, x, y);
|
2017-09-17 21:32:46 +02:00
|
|
|
return ( child != 0 ) ? child : widget;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
2016-11-02 00:37:58 +01:00
|
|
|
|
|
|
|
++iter;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
}
|
2016-11-02 00:37:58 +01:00
|
|
|
|
|
|
|
return 0;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
int FWidget::numOfFocusableChildren()
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2017-09-17 01:50:41 +02:00
|
|
|
constFObjectIterator iter, last;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-09-17 01:50:41 +02:00
|
|
|
if ( ! hasChildren() )
|
2015-05-23 13:35:12 +02:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
int num = 0;
|
2017-09-17 01:50:41 +02:00
|
|
|
iter = FObject::begin();
|
|
|
|
last = FObject::end();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-09-17 01:50:41 +02:00
|
|
|
while ( iter != last )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2017-06-11 17:47:50 +02:00
|
|
|
if ( (*iter)->isWidget() )
|
|
|
|
{
|
|
|
|
FWidget* widget = static_cast<FWidget*>(*iter);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-06-11 17:47:50 +02:00
|
|
|
if ( widget->acceptFocus() )
|
|
|
|
num++;
|
|
|
|
}
|
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 num;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FWidget::close()
|
|
|
|
{
|
2016-01-17 02:57:08 +01:00
|
|
|
FCloseEvent ev(fc::Close_Event);
|
2015-09-20 05:44:50 +02:00
|
|
|
FApplication::sendEvent(this, &ev);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2015-09-20 05:44:50 +02:00
|
|
|
if ( ev.isAccepted() )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
if ( this == getMainWidget() )
|
|
|
|
quit();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hide();
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-24 14:53:09 +01:00
|
|
|
if ( (flags & fc::modal) == 0 )
|
2015-05-23 13:35:12 +02:00
|
|
|
close_widget->push_back(this);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2017-03-26 20:40:04 +02:00
|
|
|
void FWidget::addCallback ( const FString& cb_signal
|
2017-02-18 23:37:10 +01:00
|
|
|
, FCallback cb_handler
|
2015-09-22 04:18:20 +02:00
|
|
|
, data_ptr data )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
// add a (normal) function pointer as callback
|
|
|
|
callback_data obj = { cb_signal, cb_handler, data };
|
2016-09-25 23:53:48 +02:00
|
|
|
callback_objects.push_back(obj);
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2017-03-26 20:40:04 +02:00
|
|
|
void FWidget::addCallback ( const FString& cb_signal
|
2015-09-22 04:18:20 +02:00
|
|
|
, FWidget* cb_instance
|
2017-02-18 23:37:10 +01:00
|
|
|
, FMemberCallback cb_handler
|
2015-09-22 04:18:20 +02:00
|
|
|
, data_ptr data )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
// add a member function pointer as callback
|
|
|
|
member_callback_data obj = { cb_signal, cb_instance, cb_handler, data };
|
2016-09-25 23:53:48 +02:00
|
|
|
member_callback_objects.push_back(obj);
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2017-02-18 23:37:10 +01:00
|
|
|
void FWidget::delCallback (FCallback cb_handler)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
// delete a cb_handler function pointer
|
2017-02-18 23:37:10 +01:00
|
|
|
|
|
|
|
CallbackObjects::iterator iter;
|
|
|
|
|
2016-09-25 23:53:48 +02:00
|
|
|
if ( callback_objects.empty() )
|
2015-05-23 13:35:12 +02:00
|
|
|
return;
|
|
|
|
|
2016-09-25 23:53:48 +02:00
|
|
|
iter = callback_objects.begin();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-09-25 23:53:48 +02:00
|
|
|
while ( iter != callback_objects.end() )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
if ( iter->cb_handler == cb_handler )
|
2016-09-25 23:53:48 +02:00
|
|
|
iter = callback_objects.erase(iter);
|
2015-05-23 13:35:12 +02:00
|
|
|
else
|
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::delCallback (FWidget* cb_instance)
|
|
|
|
{
|
2017-02-18 23:37:10 +01:00
|
|
|
// delete all member function pointer from cb_instance
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
FWidget::MemberCallbackObjects::iterator iter;
|
|
|
|
|
2016-09-25 23:53:48 +02:00
|
|
|
if ( member_callback_objects.empty() )
|
2015-05-23 13:35:12 +02:00
|
|
|
return;
|
|
|
|
|
2016-09-25 23:53:48 +02:00
|
|
|
iter = member_callback_objects.begin();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-09-25 23:53:48 +02:00
|
|
|
while ( iter != member_callback_objects.end() )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
if ( iter->cb_instance == cb_instance )
|
2016-09-25 23:53:48 +02:00
|
|
|
iter = member_callback_objects.erase(iter);
|
2015-05-23 13:35:12 +02:00
|
|
|
else
|
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-30 14:34:13 +02:00
|
|
|
//----------------------------------------------------------------------
|
2017-11-03 22:57:40 +01:00
|
|
|
void FWidget::delCallbacks()
|
2016-07-30 14:34:13 +02:00
|
|
|
{
|
|
|
|
// delete all callbacks from this widget
|
2017-01-15 19:48:27 +01:00
|
|
|
|
2016-09-25 23:53:48 +02:00
|
|
|
member_callback_objects.clear(); // member function pointer
|
2017-01-15 19:48:27 +01:00
|
|
|
callback_objects.clear(); // function pointer
|
2016-07-30 14:34:13 +02:00
|
|
|
}
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
2017-03-26 20:40:04 +02:00
|
|
|
void FWidget::emitCallback (const FString& emit_signal)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
// member function pointer
|
2016-09-25 23:53:48 +02:00
|
|
|
if ( ! member_callback_objects.empty() )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2017-02-18 23:37:10 +01:00
|
|
|
MemberCallbackObjects::const_iterator m_iter, m_end;
|
2016-09-25 23:53:48 +02:00
|
|
|
m_iter = member_callback_objects.begin();
|
|
|
|
m_end = member_callback_objects.end();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
while ( m_iter != m_end )
|
|
|
|
{
|
|
|
|
if ( m_iter->cb_signal == emit_signal )
|
|
|
|
{
|
|
|
|
FMemberCallback callback = m_iter->cb_handler;
|
|
|
|
// call the member function pointer
|
|
|
|
(m_iter->cb_instance->*callback)(this, m_iter->data);
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
++m_iter;
|
|
|
|
}
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
// function pointer
|
2016-09-25 23:53:48 +02:00
|
|
|
if ( ! callback_objects.empty() )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2017-09-17 01:50:41 +02:00
|
|
|
CallbackObjects::const_iterator iter, last;
|
2016-09-25 23:53:48 +02:00
|
|
|
iter = callback_objects.begin();
|
2017-09-17 01:50:41 +02:00
|
|
|
last = callback_objects.end();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-09-17 01:50:41 +02:00
|
|
|
while ( iter != last )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
if ( iter->cb_signal == emit_signal )
|
|
|
|
{
|
|
|
|
FCallback callback = iter->cb_handler;
|
|
|
|
// call the function pointer
|
|
|
|
callback(this, iter->data);
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::addAccelerator (int key, FWidget* obj)
|
|
|
|
{
|
2016-07-12 23:35:33 +02:00
|
|
|
FWidget* widget = FWindow::getWindowWidget(obj);
|
2015-05-23 13:35:12 +02:00
|
|
|
accelerator accel = { key, obj };
|
|
|
|
|
2016-07-12 23:35:33 +02:00
|
|
|
if ( ! widget || widget == statusbar || widget == menubar )
|
|
|
|
widget = getRootWidget();
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-07-12 23:35:33 +02:00
|
|
|
if ( widget && widget->accelerator_list )
|
|
|
|
widget->accelerator_list->push_back(accel);
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::delAccelerator (FWidget* obj)
|
|
|
|
{
|
2016-07-12 23:35:33 +02:00
|
|
|
FWidget* widget = FWindow::getWindowWidget(this);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-07-12 23:35:33 +02:00
|
|
|
if ( ! widget || widget == statusbar || widget == menubar )
|
|
|
|
widget = getRootWidget();
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-12-18 23:34:11 +01:00
|
|
|
if ( widget
|
2017-11-26 22:37:18 +01:00
|
|
|
&& widget->accelerator_list
|
|
|
|
&& ! widget->accelerator_list->empty() )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
FWidget::Accelerators::iterator iter;
|
2016-07-12 23:35:33 +02:00
|
|
|
iter = widget->accelerator_list->begin();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-07-12 23:35:33 +02:00
|
|
|
while ( iter != widget->accelerator_list->end() )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
if ( iter->object == obj )
|
2016-07-12 23:35:33 +02:00
|
|
|
iter = widget->accelerator_list->erase(iter);
|
2015-05-23 13:35:12 +02:00
|
|
|
else
|
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::redraw()
|
|
|
|
{
|
|
|
|
if ( ! redraw_root_widget )
|
|
|
|
redraw_root_widget = this;
|
|
|
|
|
|
|
|
if ( isRootWidget() )
|
|
|
|
{
|
2016-10-13 02:16:51 +02:00
|
|
|
startTerminalUpdate();
|
2016-10-02 21:26:25 +02:00
|
|
|
// clean desktop
|
2015-05-23 13:35:12 +02:00
|
|
|
setColor (wc.term_fg, wc.term_bg);
|
2016-10-08 02:54:32 +02:00
|
|
|
clearArea (vdesktop);
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
else if ( ! visible )
|
|
|
|
return;
|
|
|
|
|
|
|
|
draw();
|
|
|
|
|
|
|
|
if ( isRootWidget() )
|
|
|
|
{
|
|
|
|
// draw windows
|
2016-01-08 01:00:05 +01:00
|
|
|
FOptiAttr::char_data default_char;
|
2017-09-15 01:31:02 +02:00
|
|
|
default_char.code = ' ';
|
|
|
|
default_char.fg_color = fc::Black;
|
|
|
|
default_char.bg_color = fc::Black;
|
|
|
|
default_char.attr.byte[0] = 0;
|
|
|
|
default_char.attr.byte[1] = 0;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
if ( window_list && ! window_list->empty() )
|
|
|
|
{
|
2017-09-17 01:50:41 +02:00
|
|
|
widgetList::const_iterator iter, last;
|
2015-05-23 13:35:12 +02:00
|
|
|
iter = window_list->begin();
|
2017-09-17 01:50:41 +02:00
|
|
|
last = window_list->end();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-09-17 01:50:41 +02:00
|
|
|
while ( iter != last )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
if ( (*iter)->isVisible() )
|
|
|
|
{
|
|
|
|
term_area* win = (*iter)->getVWin();
|
|
|
|
int w = win->width + win->right_shadow;
|
|
|
|
int h = win->height + win->bottom_shadow;
|
|
|
|
std::fill_n (win->text, w * h, default_char);
|
|
|
|
|
|
|
|
(*iter)->redraw();
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// draw child elements
|
2017-09-17 01:50:41 +02:00
|
|
|
if ( hasChildren() )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2017-09-17 01:50:41 +02:00
|
|
|
constFObjectIterator iter, last;
|
|
|
|
iter = FObject::begin();
|
|
|
|
last = FObject::end();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-09-17 01:50:41 +02:00
|
|
|
while ( iter != last )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2017-06-11 17:47:50 +02:00
|
|
|
if ( (*iter)->isWidget() )
|
|
|
|
{
|
|
|
|
FWidget* widget = static_cast<FWidget*>(*iter);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-06-11 17:47:50 +02:00
|
|
|
if ( widget->isVisible() && ! widget->isWindowWidget() )
|
|
|
|
widget->redraw();
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( isRootWidget() )
|
2016-10-13 02:16:51 +02:00
|
|
|
finishTerminalUpdate();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
if ( redraw_root_widget == this )
|
|
|
|
{
|
|
|
|
updateTerminal();
|
|
|
|
flush_out();
|
|
|
|
redraw_root_widget = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::resize()
|
|
|
|
{
|
2016-10-13 02:16:51 +02:00
|
|
|
if ( isRootWidget() )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-10-13 02:16:51 +02:00
|
|
|
detectTermSize();
|
2016-10-14 13:02:35 +02:00
|
|
|
FRect term_geometry = getTermGeometry();
|
2017-08-27 09:50:30 +02:00
|
|
|
term_geometry.move (-1, -1);
|
2016-10-14 13:02:35 +02:00
|
|
|
|
2016-10-09 02:06:06 +02:00
|
|
|
resizeVTerm (term_geometry);
|
|
|
|
resizeArea (term_geometry, getShadow(), vdesktop);
|
2016-05-16 23:36:13 +02:00
|
|
|
adjustSizeGlobal();
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
adjustSize();
|
2015-10-11 21:56:16 +02:00
|
|
|
|
|
|
|
// resize the four double-flatline-masks
|
2016-09-25 23:53:48 +02:00
|
|
|
double_flatline_mask.top.resize (uLong(getWidth()), false);
|
|
|
|
double_flatline_mask.right.resize (uLong(getHeight()), false);
|
|
|
|
double_flatline_mask.bottom.resize (uLong(getWidth()), false);
|
|
|
|
double_flatline_mask.left.resize (uLong(getHeight()), false);
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::show()
|
|
|
|
{
|
|
|
|
if ( ! visible )
|
|
|
|
return;
|
|
|
|
|
2016-11-27 19:16:52 +01:00
|
|
|
if ( ! init_desktop )
|
2016-11-06 16:36:21 +01:00
|
|
|
{
|
2017-03-26 20:40:04 +02:00
|
|
|
#if defined(__linux__)
|
2016-11-13 22:08:40 +01:00
|
|
|
// Important: Do not use setNewFont() or setVGAFont() after
|
|
|
|
// the console character mapping has been initialized
|
2017-04-02 13:30:23 +02:00
|
|
|
initLinuxConsoleCharMap();
|
2017-03-26 20:40:04 +02:00
|
|
|
#endif
|
2016-11-13 22:08:40 +01:00
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
|
|
|
initFreeBSDConsoleCharMap();
|
2017-04-02 21:32:48 +02:00
|
|
|
#endif
|
|
|
|
|
2016-11-06 16:36:21 +01:00
|
|
|
// set xterm underline cursor
|
|
|
|
setXTermCursorStyle(fc::blinking_underline);
|
2016-11-13 22:08:40 +01:00
|
|
|
|
2016-11-06 16:36:21 +01:00
|
|
|
// set xterm color settings to defaults
|
|
|
|
setXTermDefaults();
|
2016-11-27 00:41:34 +01:00
|
|
|
|
|
|
|
// draw the vdesktop
|
|
|
|
FWidget* r = getRootWidget();
|
|
|
|
setColor(r->getForegroundColor(), r->getBackgroundColor());
|
|
|
|
clearArea (vdesktop);
|
2016-11-27 19:16:52 +01:00
|
|
|
init_desktop = true;
|
2016-11-06 16:36:21 +01:00
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
if ( ! show_root_widget )
|
|
|
|
{
|
2016-10-13 02:16:51 +02:00
|
|
|
startTerminalUpdate();
|
2015-05-23 13:35:12 +02:00
|
|
|
show_root_widget = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
draw();
|
|
|
|
shown = true;
|
|
|
|
|
2017-09-17 01:50:41 +02:00
|
|
|
if ( hasChildren() )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2017-09-17 01:50:41 +02:00
|
|
|
constFObjectIterator iter, last;
|
|
|
|
iter = FObject::begin();
|
|
|
|
last = FObject::end();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-09-17 01:50:41 +02:00
|
|
|
while ( iter != last )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2017-06-11 17:47:50 +02:00
|
|
|
if ( (*iter)->isWidget() )
|
|
|
|
{
|
|
|
|
FWidget* widget = static_cast<FWidget*>(*iter);
|
|
|
|
widget->show();
|
|
|
|
}
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( show_root_widget && show_root_widget == this )
|
|
|
|
{
|
2016-10-13 02:16:51 +02:00
|
|
|
finishTerminalUpdate();
|
2015-05-23 13:35:12 +02:00
|
|
|
updateTerminal();
|
|
|
|
flush_out();
|
|
|
|
show_root_widget = 0;
|
|
|
|
}
|
|
|
|
|
2016-01-17 02:57:08 +01:00
|
|
|
FShowEvent show_ev (fc::Show_Event);
|
2015-09-20 05:44:50 +02:00
|
|
|
FApplication::sendEvent(this, &show_ev);
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::hide()
|
|
|
|
{
|
|
|
|
if ( visible )
|
|
|
|
{
|
|
|
|
visible = false;
|
|
|
|
shown = false;
|
|
|
|
|
2016-09-25 23:53:48 +02:00
|
|
|
if ( ! isDialogWidget()
|
2017-11-26 22:37:18 +01:00
|
|
|
&& FWidget::getFocusWidget() == this
|
|
|
|
&& ! focusPrevChild() )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-08-21 21:27:44 +02:00
|
|
|
if ( FWidget::getFocusWidget() )
|
|
|
|
FWidget::getFocusWidget()->unsetFocus();
|
|
|
|
|
2016-08-20 22:27:23 +02:00
|
|
|
FWidget::setFocusWidget(getParentWidget());
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-17 02:57:08 +01:00
|
|
|
FHideEvent hide_ev (fc::Hide_Event);
|
2015-09-20 05:44:50 +02:00
|
|
|
FApplication::sendEvent(this, &hide_ev);
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-05-22 19:18:16 +02:00
|
|
|
bool FWidget::focusFirstChild()
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2017-09-17 01:50:41 +02:00
|
|
|
constFObjectIterator iter, last;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-09-17 01:50:41 +02:00
|
|
|
if ( ! hasChildren() )
|
2015-05-23 13:35:12 +02:00
|
|
|
return false;
|
|
|
|
|
2017-09-17 01:50:41 +02:00
|
|
|
iter = FObject::begin();
|
|
|
|
last = FObject::end();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-09-17 01:50:41 +02:00
|
|
|
while ( iter != last )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2017-06-11 17:47:50 +02:00
|
|
|
if ( ! (*iter)->isWidget() )
|
|
|
|
{
|
|
|
|
++iter;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
FWidget* widget = static_cast<FWidget*>(*iter);
|
2016-05-16 23:26:04 +02:00
|
|
|
|
2016-12-18 23:34:11 +01:00
|
|
|
if ( widget->isEnabled()
|
2017-11-26 22:37:18 +01:00
|
|
|
&& widget->acceptFocus()
|
|
|
|
&& ! widget->isMenuWidget() )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2015-07-13 00:15:57 +02:00
|
|
|
widget->setFocus();
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( widget->numOfChildren() >= 1 )
|
2015-07-12 21:49:30 +02:00
|
|
|
{
|
2016-09-25 23:53:48 +02:00
|
|
|
if ( ! widget->focusFirstChild() && widget->isWindowWidget() )
|
2015-07-12 23:28:45 +02:00
|
|
|
{
|
|
|
|
++iter;
|
2015-07-12 21:49:30 +02:00
|
|
|
continue;
|
2015-07-12 23:28:45 +02:00
|
|
|
}
|
2015-07-12 21:49:30 +02:00
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-05-22 19:18:16 +02:00
|
|
|
bool FWidget::focusLastChild()
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2017-09-17 01:50:41 +02:00
|
|
|
constFObjectIterator iter, first;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-09-17 01:50:41 +02:00
|
|
|
if ( ! hasChildren() )
|
2015-05-23 13:35:12 +02:00
|
|
|
return false;
|
|
|
|
|
2017-09-17 01:50:41 +02:00
|
|
|
iter = FObject::end();
|
|
|
|
first = FObject::begin();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
--iter;
|
2017-06-11 17:47:50 +02:00
|
|
|
|
|
|
|
if ( ! (*iter)->isWidget() )
|
|
|
|
continue;
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
FWidget* widget = static_cast<FWidget*>(*iter);
|
2016-05-16 23:26:04 +02:00
|
|
|
|
2016-12-18 23:34:11 +01:00
|
|
|
if ( widget->isEnabled()
|
2017-11-26 22:37:18 +01:00
|
|
|
&& widget->acceptFocus()
|
|
|
|
&& ! widget->isMenuWidget() )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2015-07-13 00:15:57 +02:00
|
|
|
widget->setFocus();
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( widget->numOfChildren() >= 1 )
|
2015-07-12 21:49:30 +02:00
|
|
|
{
|
2016-09-25 23:53:48 +02:00
|
|
|
if ( ! widget->focusLastChild() && widget->isWindowWidget() )
|
2015-07-12 21:49:30 +02:00
|
|
|
continue;
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2017-09-17 01:50:41 +02:00
|
|
|
while ( iter != first );
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FWidget::detectTermSize()
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
FWidget* r = rootObject;
|
|
|
|
FTerm::detectTermSize();
|
|
|
|
r->adjust_wsize.setRect (1, 1, getColumnNumber(), getLineNumber());
|
|
|
|
r->offset.setRect (0, 0, getColumnNumber(), getLineNumber());
|
|
|
|
r->client_offset.setCoordinates
|
|
|
|
(
|
|
|
|
r->padding.left,
|
|
|
|
r->padding.top,
|
|
|
|
getColumnNumber() - 1 - r->padding.right,
|
|
|
|
getLineNumber() - 1 - r->padding.bottom
|
|
|
|
);
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::move (int dx, int dy)
|
|
|
|
{
|
2017-09-11 03:06:02 +02:00
|
|
|
wsize.move(dx, dy);
|
|
|
|
adjust_wsize.move(dx, dy);
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::drawShadow()
|
|
|
|
{
|
|
|
|
bool trans_shadow = ((flags & fc::trans_shadow) != 0);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( isMonochron() && ! trans_shadow )
|
|
|
|
return;
|
|
|
|
|
2017-11-18 02:34:41 +01:00
|
|
|
if ( (term_encoding == fc::VT100 && ! trans_shadow)
|
2017-11-26 22:37:18 +01:00
|
|
|
|| (term_encoding == fc::ASCII && ! trans_shadow) )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
clearShadow();
|
|
|
|
return;
|
|
|
|
}
|
2016-07-03 20:08:39 +02:00
|
|
|
|
2017-10-02 07:32:33 +02:00
|
|
|
int x1 = 1
|
|
|
|
, x2 = getWidth()
|
|
|
|
, y1 = 1
|
|
|
|
, y2 = getHeight();
|
2016-07-03 20:08:39 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( trans_shadow )
|
|
|
|
{
|
|
|
|
// transparent shadow
|
2017-08-27 09:50:30 +02:00
|
|
|
setPrintPos (x2 + 1, y1);
|
2016-11-02 00:37:58 +01:00
|
|
|
setTransparent();
|
|
|
|
print (" ");
|
|
|
|
unsetTransparent();
|
|
|
|
|
|
|
|
setColor (wc.shadow_bg, wc.shadow_fg);
|
|
|
|
setTransShadow();
|
|
|
|
|
2017-08-27 09:50:30 +02:00
|
|
|
for (int i = 1; i < getHeight(); i++)
|
2016-06-19 20:32:03 +02:00
|
|
|
{
|
2017-08-27 09:50:30 +02:00
|
|
|
setPrintPos (x2 + 1, y1 + i);
|
2016-11-02 00:37:58 +01:00
|
|
|
print (" ");
|
2016-06-19 20:32:03 +02:00
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
unsetTransShadow();
|
2017-08-27 09:50:30 +02:00
|
|
|
setPrintPos (x1, y2 + 1);
|
2016-11-02 00:37:58 +01:00
|
|
|
setTransparent();
|
|
|
|
print (" ");
|
|
|
|
unsetTransparent();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
setColor (wc.shadow_bg, wc.shadow_fg);
|
|
|
|
setTransShadow();
|
|
|
|
|
2017-08-27 09:50:30 +02:00
|
|
|
for (int i = 2; i <= getWidth() + 1; i++)
|
2016-11-02 00:37:58 +01:00
|
|
|
print (' ');
|
|
|
|
|
|
|
|
unsetTransShadow();
|
|
|
|
|
|
|
|
if ( isMonochron() )
|
|
|
|
setReverse(false);
|
|
|
|
}
|
|
|
|
else
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
// non-transparent shadow
|
|
|
|
int block;
|
2016-11-13 22:08:40 +01:00
|
|
|
|
|
|
|
if ( no_shadow_character )
|
|
|
|
return;
|
|
|
|
|
2017-08-27 09:50:30 +02:00
|
|
|
setPrintPos (x2 + 1, y1);
|
2016-11-02 00:37:58 +01:00
|
|
|
|
|
|
|
if ( isWindowWidget() )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
setColor (wc.shadow_fg, wc.shadow_bg);
|
|
|
|
setInheritBackground(); // current background color will be ignored
|
|
|
|
}
|
|
|
|
else if ( FWidget* p = getParentWidget() )
|
|
|
|
setColor (wc.shadow_fg, p->getBackgroundColor());
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
block = fc::FullBlock; // █
|
|
|
|
print (fc::LowerHalfBlock); // ▄
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( isWindowWidget() )
|
|
|
|
unsetInheritBackground();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-08-27 09:50:30 +02:00
|
|
|
for (int i = 1; i < getHeight(); i++)
|
2016-11-02 00:37:58 +01:00
|
|
|
{
|
2017-08-27 09:50:30 +02:00
|
|
|
setPrintPos (x2 + 1, y1 + i);
|
2017-09-11 03:06:02 +02:00
|
|
|
print (block); // █
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
2016-01-08 01:00:05 +01:00
|
|
|
|
2017-08-27 09:50:30 +02:00
|
|
|
setPrintPos (x1 + 1, y2 + 1);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( isWindowWidget() )
|
|
|
|
setInheritBackground();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-08-27 09:50:30 +02:00
|
|
|
for (int i = 1; i <= getWidth(); i++)
|
2017-09-11 03:06:02 +02:00
|
|
|
print (fc::UpperHalfBlock); // ▀
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( isWindowWidget() )
|
|
|
|
unsetInheritBackground();
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FWidget::clearShadow()
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( isMonochron() )
|
|
|
|
return;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-11-02 16:05:34 +01:00
|
|
|
int w = getWidth()
|
|
|
|
, h = getHeight();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( isWindowWidget() )
|
|
|
|
{
|
|
|
|
setColor (wc.shadow_fg, wc.shadow_bg);
|
|
|
|
setInheritBackground(); // current background color will be ignored
|
|
|
|
}
|
|
|
|
else if ( FWidget* p = getParentWidget() )
|
|
|
|
setColor (wc.shadow_fg, p->getBackgroundColor());
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-11-02 16:05:34 +01:00
|
|
|
if ( w <= offset.getX2() )
|
2015-09-28 04:31:29 +02:00
|
|
|
{
|
2017-11-02 16:05:34 +01:00
|
|
|
for (int i = 1; i <= getHeight(); i++)
|
2016-11-02 00:37:58 +01:00
|
|
|
{
|
2017-11-02 16:05:34 +01:00
|
|
|
setPrintPos (w + 1, i);
|
2016-11-02 00:37:58 +01:00
|
|
|
print (' '); // clear █
|
|
|
|
}
|
2015-09-28 04:31:29 +02:00
|
|
|
}
|
2015-09-27 16:00:13 +02:00
|
|
|
|
2017-11-02 16:05:34 +01:00
|
|
|
if ( h <= offset.getY2() )
|
2015-09-27 16:00:13 +02:00
|
|
|
{
|
2017-11-02 16:05:34 +01:00
|
|
|
setPrintPos (2, h + 1);
|
2016-09-25 23:53:48 +02:00
|
|
|
|
2017-08-27 09:50:30 +02:00
|
|
|
for (int i = 1; i <= getWidth(); i++)
|
2017-09-11 03:06:02 +02:00
|
|
|
print (' '); // clear ▀
|
2015-09-27 16:00:13 +02:00
|
|
|
}
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( isWindowWidget() )
|
|
|
|
unsetInheritBackground();
|
2016-09-25 23:53:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FWidget::drawFlatBorder()
|
2016-09-25 23:53:48 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( ! isNewFont() )
|
2016-09-25 23:53:48 +02:00
|
|
|
return;
|
|
|
|
|
2017-10-02 07:32:33 +02:00
|
|
|
int x1 = 1
|
|
|
|
, x2 = getWidth() + 1
|
|
|
|
, y1 = 0
|
|
|
|
, y2 = getHeight() + 1;
|
2016-09-25 23:53:48 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( FWidget* p = getParentWidget() )
|
|
|
|
setColor (wc.dialog_fg, p->getBackgroundColor());
|
|
|
|
else
|
|
|
|
setColor (wc.dialog_fg, wc.dialog_bg);
|
2015-09-27 16:00:13 +02:00
|
|
|
|
2017-08-27 09:50:30 +02:00
|
|
|
for (int y = 0; y < getHeight(); y++)
|
2016-11-02 00:37:58 +01:00
|
|
|
{
|
2017-08-27 09:50:30 +02:00
|
|
|
setPrintPos (x1 - 1, y1 + y + 1);
|
2016-09-25 23:53:48 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( double_flatline_mask.left[uLong(y)] )
|
2017-09-11 03:06:02 +02:00
|
|
|
// left+right line (on left side)
|
|
|
|
print (fc::NF_rev_border_line_right_and_left);
|
2016-11-02 00:37:58 +01:00
|
|
|
else
|
2017-09-11 03:06:02 +02:00
|
|
|
// right line (on left side)
|
|
|
|
print (fc::NF_rev_border_line_right);
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
2015-09-27 16:00:13 +02:00
|
|
|
|
2017-08-27 09:50:30 +02:00
|
|
|
setPrintPos (x2, y1 + 1);
|
2016-09-25 23:53:48 +02:00
|
|
|
|
2017-08-27 09:50:30 +02:00
|
|
|
for (int y = 0; y < getHeight(); y++)
|
2016-11-02 00:37:58 +01:00
|
|
|
{
|
|
|
|
if ( double_flatline_mask.right[uLong(y)] )
|
2017-09-11 03:06:02 +02:00
|
|
|
// left+right line (on right side)
|
|
|
|
print (fc::NF_rev_border_line_right_and_left);
|
2016-11-02 00:37:58 +01:00
|
|
|
else
|
2017-09-11 03:06:02 +02:00
|
|
|
// left line (on right side)
|
|
|
|
print (fc::NF_border_line_left);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-08-27 09:50:30 +02:00
|
|
|
setPrintPos (x2, y1 + y + 2);
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
setPrintPos (x1, y1);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-08-27 09:50:30 +02:00
|
|
|
for (int x = 0; x < getWidth(); x++)
|
2016-11-02 00:37:58 +01:00
|
|
|
{
|
|
|
|
if ( double_flatline_mask.top[uLong(x)] )
|
2017-09-11 03:06:02 +02:00
|
|
|
// top+bottom line (at top)
|
|
|
|
print (fc::NF_border_line_up_and_down);
|
2016-11-02 00:37:58 +01:00
|
|
|
else
|
2017-09-11 03:06:02 +02:00
|
|
|
// bottom line (at top)
|
|
|
|
print (fc::NF_border_line_bottom);
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
2015-06-21 23:27:10 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
setPrintPos (x1, y2);
|
|
|
|
|
2017-08-27 09:50:30 +02:00
|
|
|
for (int x = 0; x < getWidth(); x++)
|
2016-11-02 00:37:58 +01:00
|
|
|
{
|
|
|
|
if ( double_flatline_mask.bottom[uLong(x)] )
|
2017-09-11 03:06:02 +02:00
|
|
|
// top+bottom line (at bottom)
|
|
|
|
print (fc::NF_border_line_up_and_down);
|
2016-11-02 00:37:58 +01:00
|
|
|
else
|
2017-09-11 03:06:02 +02:00
|
|
|
// top line (at bottom)
|
|
|
|
print (fc::NF_border_line_upper);
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FWidget::clearFlatBorder()
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( ! isNewFont() )
|
2015-05-23 13:35:12 +02:00
|
|
|
return;
|
|
|
|
|
2017-10-02 07:32:33 +02:00
|
|
|
int x1 = 1
|
|
|
|
, x2 = getWidth() + 1
|
|
|
|
, y1 = 0
|
|
|
|
, y2 = getHeight() + 1;
|
2016-09-25 23:53:48 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( FWidget* p = getParentWidget() )
|
|
|
|
setColor (wc.dialog_fg, p->getBackgroundColor());
|
|
|
|
else
|
|
|
|
setColor (wc.dialog_fg, wc.dialog_bg);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
// clear on left side
|
2017-08-27 09:50:30 +02:00
|
|
|
for (register int y = 0; y < getHeight(); y++)
|
2016-11-02 00:37:58 +01:00
|
|
|
{
|
2017-08-27 09:50:30 +02:00
|
|
|
setPrintPos (x1 - 1, y1 + y + 1);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( double_flatline_mask.left[uLong(y)] )
|
|
|
|
print (fc::NF_border_line_left);
|
|
|
|
else
|
|
|
|
print (' ');
|
|
|
|
}
|
2015-06-21 23:27:10 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
// clear on right side
|
2017-08-27 09:50:30 +02:00
|
|
|
for (register int y = 0; y < getHeight(); y++)
|
2016-11-02 00:37:58 +01:00
|
|
|
{
|
2017-08-27 09:50:30 +02:00
|
|
|
setPrintPos (x2, y1 + y + 1);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( double_flatline_mask.right[uLong(y)] )
|
|
|
|
print (fc::NF_rev_border_line_right);
|
|
|
|
else
|
|
|
|
print (' ');
|
|
|
|
}
|
2016-05-16 21:11:32 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
// clear at top
|
|
|
|
setPrintPos (x1, y1);
|
2016-05-16 21:11:32 +02:00
|
|
|
|
2017-08-27 09:50:30 +02:00
|
|
|
for (register int x = 0; x < getWidth(); x++)
|
2016-05-16 21:11:32 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( double_flatline_mask.top[uLong(x)] )
|
|
|
|
print (fc::NF_border_line_upper);
|
2016-05-16 21:11:32 +02:00
|
|
|
else
|
2016-11-02 00:37:58 +01:00
|
|
|
print (' ');
|
2016-05-16 21:11:32 +02:00
|
|
|
}
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
// clear at bottom
|
|
|
|
setPrintPos (x1, y2);
|
2016-05-16 21:11:32 +02:00
|
|
|
|
2017-08-27 09:50:30 +02:00
|
|
|
for (register int x = 0; x < getWidth(); x++)
|
2016-05-16 21:11:32 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( double_flatline_mask.bottom[uLong(x)] )
|
|
|
|
print (fc::NF_border_line_bottom);
|
2016-05-16 21:11:32 +02:00
|
|
|
else
|
2016-11-02 00:37:58 +01:00
|
|
|
print (' ');
|
2016-05-16 21:11:32 +02:00
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FWidget::drawBorder (int x1, int y1, int x2, int y2)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( x1 > x2 )
|
|
|
|
std::swap (x1, x2);
|
2016-05-16 21:11:32 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( y1 > y2 )
|
|
|
|
std::swap (y1, y2);
|
2016-05-16 21:11:32 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( x1 < 1 )
|
|
|
|
x1 = 1;
|
|
|
|
|
|
|
|
if ( y1 < 1 )
|
|
|
|
y1 = 1;
|
|
|
|
|
|
|
|
if ( x2 > getWidth() )
|
|
|
|
x2 = getWidth();
|
|
|
|
|
|
|
|
if ( y2 > getHeight() )
|
|
|
|
y2 = getHeight();
|
|
|
|
|
|
|
|
if ( isNewFont() )
|
2016-05-16 21:11:32 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
setPrintPos (x1, y1);
|
2017-09-11 03:06:02 +02:00
|
|
|
print (fc::NF_border_corner_middle_upper_left); // ┌
|
2016-11-02 00:37:58 +01: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::BoxDrawingsHorizontal); // ─
|
2016-11-02 00:37:58 +01:00
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
print (fc::NF_border_corner_middle_upper_right); // ┐
|
2016-11-02 00:37:58 +01:00
|
|
|
|
2017-08-27 09:50:30 +02:00
|
|
|
for (int y = y1 + 1; y <= y2; y++)
|
2016-05-16 21:11:32 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
setPrintPos (x1, y);
|
2017-09-11 03:06:02 +02:00
|
|
|
print (fc::NF_border_line_left); // border left ⎸
|
2016-11-02 00:37:58 +01:00
|
|
|
setPrintPos (x2, y);
|
2017-09-11 03:06:02 +02:00
|
|
|
print (fc::NF_rev_border_line_right); // border right⎹
|
2016-05-16 21:11:32 +02:00
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
setPrintPos (x1, y2);
|
2017-09-11 03:06:02 +02:00
|
|
|
print (fc::NF_border_corner_middle_lower_left); // └
|
2016-05-16 21:11:32 +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::BoxDrawingsHorizontal); // ─
|
2016-05-16 21:11:32 +02:00
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
print (fc::NF_border_corner_middle_lower_right); // ┘
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
|
|
|
else
|
2016-05-16 21:11:32 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
setPrintPos (x1, y1);
|
2017-09-11 03:06:02 +02:00
|
|
|
print (fc::BoxDrawingsDownAndRight); // ┌
|
2016-11-02 00:37:58 +01: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::BoxDrawingsHorizontal); // ─
|
2016-11-02 00:37:58 +01:00
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
print (fc::BoxDrawingsDownAndLeft); // ┐
|
2016-11-02 00:37:58 +01:00
|
|
|
|
2017-08-27 09:50:30 +02:00
|
|
|
for (int y = y1 + 1; y < y2; y++)
|
2016-05-16 21:11:32 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
setPrintPos (x1, y);
|
2017-09-11 03:06:02 +02:00
|
|
|
print (fc::BoxDrawingsVertical); // │
|
2016-11-02 00:37:58 +01:00
|
|
|
setPrintPos (x2, y);
|
2017-09-11 03:06:02 +02:00
|
|
|
print (fc::BoxDrawingsVertical); // │
|
2016-05-16 21:11:32 +02:00
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
setPrintPos (x1, y2);
|
2017-09-11 03:06:02 +02:00
|
|
|
print (fc::BoxDrawingsUpAndRight); // └
|
2016-09-25 23:53:48 +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::BoxDrawingsHorizontal); // ─
|
2016-09-25 23:53:48 +02:00
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
print (fc::BoxDrawingsUpAndLeft); // ┘
|
2016-09-25 23:53:48 +02:00
|
|
|
|
2017-08-27 09:50:30 +02:00
|
|
|
for (int x = x1 + 1; x < x2; x++)
|
2016-11-02 00:37:58 +01:00
|
|
|
{
|
|
|
|
setPrintPos (x, y1);
|
2017-09-11 03:06:02 +02:00
|
|
|
print (fc::BoxDrawingsHorizontal); // ─
|
2016-11-02 00:37:58 +01:00
|
|
|
setPrintPos (x, y2);
|
2017-09-11 03:06:02 +02:00
|
|
|
print (fc::BoxDrawingsHorizontal); // ─
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
|
|
|
}
|
2016-09-25 23:53:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FWidget::quit()
|
2016-09-25 23:53:48 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
FApplication* fapp = static_cast<FApplication*>(rootObject);
|
|
|
|
fapp->exit(0);
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
|
|
|
|
// protected methods of FWidget
|
2017-10-27 23:28:37 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FVTerm::term_area* FWidget::getPrintArea()
|
|
|
|
{
|
|
|
|
// returns the print area of this object
|
|
|
|
|
|
|
|
if ( print_area )
|
|
|
|
return print_area;
|
|
|
|
else
|
|
|
|
{
|
2017-10-30 20:29:00 +01:00
|
|
|
FWidget* obj;
|
|
|
|
FWidget* p_obj = this;
|
2017-10-27 23:28:37 +02:00
|
|
|
|
2017-10-30 20:29:00 +01:00
|
|
|
do
|
2017-10-27 23:28:37 +02:00
|
|
|
{
|
|
|
|
obj = p_obj;
|
2017-10-30 20:29:00 +01:00
|
|
|
p_obj = static_cast<FWidget*>(obj->getParent());
|
2017-10-27 23:28:37 +02:00
|
|
|
}
|
2017-10-30 20:29:00 +01:00
|
|
|
while ( ! obj->vwin && ! obj->child_print_area && p_obj );
|
2017-10-27 23:28:37 +02:00
|
|
|
|
|
|
|
if ( obj->vwin )
|
|
|
|
{
|
|
|
|
print_area = obj->vwin;
|
|
|
|
return print_area;
|
|
|
|
}
|
|
|
|
else if ( obj->child_print_area )
|
|
|
|
{
|
|
|
|
print_area = obj->child_print_area;
|
|
|
|
return print_area;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return vdesktop;
|
|
|
|
}
|
|
|
|
|
2017-10-30 20:29:00 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::addPreprocessingHandler ( FVTerm* instance
|
|
|
|
, FPreprocessingHandler handler )
|
|
|
|
{
|
|
|
|
if ( ! print_area )
|
|
|
|
FWidget::getPrintArea();
|
|
|
|
|
|
|
|
FVTerm::addPreprocessingHandler (instance, handler);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::delPreprocessingHandler (FVTerm* instance)
|
|
|
|
{
|
|
|
|
if ( ! print_area )
|
|
|
|
FWidget::getPrintArea();
|
|
|
|
|
|
|
|
FVTerm::delPreprocessingHandler (instance);
|
|
|
|
}
|
|
|
|
|
2017-10-27 23:28:37 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FWidget::isChildPrintArea() const
|
|
|
|
{
|
|
|
|
FWidget* p_obj = static_cast<FWidget*>(getParent());
|
|
|
|
|
|
|
|
if ( p_obj
|
2017-11-26 22:37:18 +01:00
|
|
|
&& p_obj->child_print_area
|
|
|
|
&& p_obj->child_print_area == print_area )
|
2017-10-27 23:28:37 +02:00
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FWidget::setStatusBar (FStatusBar* sbar)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( ! sbar || statusbar == sbar )
|
|
|
|
return;
|
|
|
|
|
2017-10-02 07:32:33 +02:00
|
|
|
if ( statusbar )
|
2016-11-02 00:37:58 +01:00
|
|
|
delete statusbar;
|
|
|
|
|
|
|
|
statusbar = sbar;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FWidget::setMenuBar (FMenuBar* mbar)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( ! mbar || menubar == mbar )
|
|
|
|
return;
|
2016-09-11 16:48:39 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( menubar )
|
|
|
|
delete menubar;
|
2016-09-25 23:53:48 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
menubar = mbar;
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::adjustSize()
|
|
|
|
{
|
|
|
|
if ( ! isRootWidget() )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
FWidget* p = getParentWidget();
|
|
|
|
|
|
|
|
if ( isWindowWidget() )
|
|
|
|
{
|
|
|
|
if ( ignore_padding && ! isDialogWidget() )
|
|
|
|
setTermOffset();
|
|
|
|
else
|
|
|
|
offset = rootObject->client_offset;
|
|
|
|
}
|
|
|
|
else if ( ignore_padding && p )
|
|
|
|
{
|
|
|
|
offset.setCoordinates ( p->getTermX() - 1
|
|
|
|
, p->getTermY() - 1
|
|
|
|
, p->getTermX() + p->getWidth() - 2
|
|
|
|
, p->getTermY() + p->getHeight() - 2 );
|
|
|
|
}
|
|
|
|
else if ( p )
|
|
|
|
offset = p->client_offset;
|
|
|
|
|
|
|
|
adjust_wsize = wsize;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
2016-09-02 23:06:47 +02:00
|
|
|
|
2017-01-22 23:04:40 +01:00
|
|
|
// Move and shrink in case of lack of space
|
|
|
|
if ( ! hasChildPrintArea() )
|
|
|
|
insufficientSpaceAdjust();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
client_offset.setCoordinates
|
|
|
|
(
|
|
|
|
getTermX() - 1 + padding.left,
|
|
|
|
getTermY() - 1 + padding.top,
|
|
|
|
getTermX() - 2 + getWidth() - padding.right,
|
|
|
|
getTermY() - 2 + getHeight() - padding.bottom
|
|
|
|
);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-09-17 01:50:41 +02:00
|
|
|
if ( hasChildren() )
|
2016-11-02 00:37:58 +01:00
|
|
|
{
|
2017-09-17 01:50:41 +02:00
|
|
|
constFObjectIterator iter, last;
|
|
|
|
iter = FObject::begin();
|
|
|
|
last = FObject::end();
|
2016-10-11 04:57:36 +02:00
|
|
|
|
2017-09-17 01:50:41 +02:00
|
|
|
while ( iter != last )
|
2016-11-02 00:37:58 +01:00
|
|
|
{
|
2017-06-11 17:47:50 +02:00
|
|
|
if ( (*iter)->isWidget() )
|
|
|
|
{
|
|
|
|
FWidget* widget = static_cast<FWidget*>(*iter);
|
2016-10-15 03:32:30 +02:00
|
|
|
|
2017-06-11 17:47:50 +02:00
|
|
|
if ( ! widget->isWindowWidget() )
|
|
|
|
widget->adjustSize();
|
|
|
|
}
|
2016-11-02 00:37:58 +01:00
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
}
|
2016-10-11 04:57:36 +02:00
|
|
|
}
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FWidget::adjustSizeGlobal()
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( ! isRootWidget() )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
getRootWidget()->adjustSizeGlobal();
|
2015-05-23 13:35:12 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( window_list && ! window_list->empty() )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2017-09-17 01:50:41 +02:00
|
|
|
widgetList::const_iterator iter, last;
|
2016-11-02 00:37:58 +01:00
|
|
|
iter = window_list->begin();
|
2017-09-17 01:50:41 +02:00
|
|
|
last = window_list->end();
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-09-17 01:50:41 +02:00
|
|
|
while ( iter != last )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
(*iter)->adjustSize();
|
|
|
|
++iter;
|
2016-08-25 01:54:10 +02:00
|
|
|
}
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FWidget::focusNextChild()
|
|
|
|
{
|
|
|
|
if ( isDialogWidget() )
|
|
|
|
return false;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( hasParent() )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2017-01-28 22:03:15 +01:00
|
|
|
FWidget* parent = getParentWidget();
|
2016-08-27 23:23:42 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( parent->hasChildren() && parent->numOfFocusableChildren() > 1 )
|
2016-08-27 23:23:42 +02:00
|
|
|
{
|
2017-09-17 01:50:41 +02:00
|
|
|
FObjectIterator iter, last;
|
|
|
|
iter = parent->begin();
|
|
|
|
last = parent->end();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-09-17 01:50:41 +02:00
|
|
|
while ( iter != last )
|
2016-11-02 00:37:58 +01:00
|
|
|
{
|
2017-06-11 17:47:50 +02:00
|
|
|
if ( ! (*iter)->isWidget() )
|
|
|
|
{
|
|
|
|
++iter;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
FWidget* w = static_cast<FWidget*>(*iter);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( w == this )
|
|
|
|
{
|
2017-06-14 01:02:02 +02:00
|
|
|
FWidget* next = 0;
|
2017-09-15 01:31:02 +02:00
|
|
|
constFObjectIterator next_element;
|
2016-11-02 00:37:58 +01:00
|
|
|
next_element = iter;
|
2016-08-27 23:23:42 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
do
|
|
|
|
{
|
|
|
|
++next_element;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-09-17 01:50:41 +02:00
|
|
|
if ( next_element == parent->end() )
|
|
|
|
next_element = parent->begin();
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-06-19 02:12:11 +02:00
|
|
|
if ( ! (*next_element)->isWidget() )
|
|
|
|
continue;
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
next = static_cast<FWidget*>(*next_element);
|
2017-06-14 01:02:02 +02:00
|
|
|
} while ( ! next
|
2017-11-26 22:37:18 +01:00
|
|
|
|| ! next->isEnabled()
|
|
|
|
|| ! next->acceptFocus()
|
|
|
|
|| ! next->isVisible()
|
|
|
|
|| next->isWindowWidget() );
|
2016-08-27 23:23:42 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
FFocusEvent out (fc::FocusOut_Event);
|
|
|
|
out.setFocusType(fc::FocusNextWidget);
|
|
|
|
FApplication::sendEvent(this, &out);
|
2016-08-27 23:23:42 +02:00
|
|
|
|
2017-01-28 22:03:15 +01:00
|
|
|
FFocusEvent cfo (fc::ChildFocusOut_Event);
|
|
|
|
cfo.setFocusType(fc::FocusNextWidget);
|
|
|
|
cfo.ignore();
|
|
|
|
FApplication::sendEvent(parent, &cfo);
|
|
|
|
|
|
|
|
if ( cfo.isAccepted() )
|
|
|
|
out.ignore();
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( out.isAccepted() )
|
|
|
|
{
|
|
|
|
if ( next == this )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
next->setFocus();
|
2017-01-28 22:03:15 +01:00
|
|
|
FFocusEvent cfi (fc::ChildFocusIn_Event);
|
|
|
|
FApplication::sendEvent(parent, &cfi);
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
FFocusEvent in (fc::FocusIn_Event);
|
|
|
|
in.setFocusType(fc::FocusNextWidget);
|
|
|
|
FApplication::sendEvent(next, &in);
|
|
|
|
|
|
|
|
if ( in.isAccepted() )
|
|
|
|
{
|
2017-09-17 01:50:41 +02:00
|
|
|
redraw();
|
2017-01-28 22:03:15 +01:00
|
|
|
next->redraw();
|
2016-11-02 00:37:58 +01:00
|
|
|
updateTerminal();
|
|
|
|
flush_out();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
2016-11-02 00:37:58 +01:00
|
|
|
return true;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
bool FWidget::focusPrevChild()
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( isDialogWidget() )
|
|
|
|
return false;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( hasParent() )
|
2016-08-27 23:23:42 +02:00
|
|
|
{
|
2017-01-28 22:03:15 +01:00
|
|
|
FWidget* parent = getParentWidget();
|
2016-08-27 23:23:42 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( parent->hasChildren() && parent->numOfFocusableChildren() > 1 )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2017-09-17 01:50:41 +02:00
|
|
|
FObjectIterator iter, first;
|
|
|
|
iter = parent->end();
|
|
|
|
first = parent->begin();
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
do
|
|
|
|
{
|
|
|
|
--iter;
|
2017-06-11 17:47:50 +02:00
|
|
|
|
|
|
|
if ( ! (*iter)->isWidget() )
|
|
|
|
continue;
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
FWidget* w = static_cast<FWidget*>(*iter);
|
2016-08-27 23:23:42 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( w == this )
|
|
|
|
{
|
2017-06-14 01:02:02 +02:00
|
|
|
FWidget* prev = 0;
|
2017-09-15 01:31:02 +02:00
|
|
|
constFObjectIterator prev_element;
|
2016-11-02 00:37:58 +01:00
|
|
|
prev_element = iter;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
do
|
|
|
|
{
|
2017-06-11 17:47:50 +02:00
|
|
|
if ( ! (*prev_element)->isWidget() )
|
|
|
|
{
|
|
|
|
--prev_element;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-09-17 01:50:41 +02:00
|
|
|
if ( prev_element == parent->begin() )
|
|
|
|
prev_element = parent->end();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
--prev_element;
|
|
|
|
prev = static_cast<FWidget*>(*prev_element);
|
2017-06-14 01:02:02 +02:00
|
|
|
} while ( ! prev
|
2017-11-26 22:37:18 +01:00
|
|
|
|| ! prev->isEnabled()
|
|
|
|
|| ! prev->acceptFocus()
|
|
|
|
|| ! prev->isVisible()
|
|
|
|
|| prev->isWindowWidget() );
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
FFocusEvent out (fc::FocusOut_Event);
|
|
|
|
out.setFocusType(fc::FocusPreviousWidget);
|
|
|
|
FApplication::sendEvent(this, &out);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-01-28 22:03:15 +01:00
|
|
|
FFocusEvent cfo (fc::ChildFocusOut_Event);
|
|
|
|
cfo.setFocusType(fc::FocusPreviousWidget);
|
|
|
|
cfo.ignore();
|
|
|
|
FApplication::sendEvent(parent, &cfo);
|
|
|
|
|
|
|
|
if ( cfo.isAccepted() )
|
|
|
|
out.ignore();
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( out.isAccepted() )
|
|
|
|
{
|
|
|
|
if ( prev == this )
|
|
|
|
return false;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
prev->setFocus();
|
2017-01-28 22:03:15 +01:00
|
|
|
FFocusEvent cfi (fc::ChildFocusIn_Event);
|
|
|
|
FApplication::sendEvent(parent, &cfi);
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
FFocusEvent in (fc::FocusIn_Event);
|
|
|
|
in.setFocusType(fc::FocusPreviousWidget);
|
|
|
|
FApplication::sendEvent(prev, &in);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( in.isAccepted() )
|
|
|
|
{
|
2017-09-17 01:50:41 +02:00
|
|
|
redraw();
|
2017-01-28 22:03:15 +01:00
|
|
|
prev->redraw();
|
2016-11-02 00:37:58 +01:00
|
|
|
updateTerminal();
|
|
|
|
flush_out();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-09-17 01:50:41 +02:00
|
|
|
while ( iter != first );
|
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 true;
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FWidget::event (FEvent* ev)
|
|
|
|
{
|
|
|
|
switch ( ev->type() )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
case fc::KeyPress_Event:
|
|
|
|
{
|
|
|
|
FKeyEvent* kev = static_cast<FKeyEvent*>(ev);
|
|
|
|
bool accpt_focus = false;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( kev->key() == fc::Fkey_tab )
|
|
|
|
accpt_focus = focusNextChild();
|
|
|
|
else if ( kev->key() == fc::Fkey_btab )
|
|
|
|
accpt_focus = focusPrevChild();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( accpt_focus )
|
|
|
|
break;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
FWidget* widget = this;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
while ( widget )
|
|
|
|
{
|
|
|
|
widget->onKeyPress(kev);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( ! kev->isAccepted() )
|
|
|
|
{
|
2016-12-18 23:34:11 +01:00
|
|
|
if ( kev->key() == fc::Fkey_right
|
2017-11-26 22:37:18 +01:00
|
|
|
|| kev->key() == fc::Fkey_down )
|
2016-11-02 00:37:58 +01:00
|
|
|
accpt_focus = focusNextChild();
|
2016-12-18 23:34:11 +01:00
|
|
|
else if ( kev->key() == fc::Fkey_left
|
2017-11-26 22:37:18 +01:00
|
|
|
|| kev->key() == fc::Fkey_up )
|
2016-11-02 00:37:58 +01:00
|
|
|
accpt_focus = focusPrevChild();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( accpt_focus )
|
|
|
|
break;
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( kev->isAccepted() || widget->isRootWidget() )
|
|
|
|
break;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
widget = widget->getParentWidget();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
case fc::KeyUp_Event:
|
|
|
|
onKeyUp ( static_cast<FKeyEvent*>(ev) );
|
|
|
|
break;
|
2016-08-27 23:23:42 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
case fc::KeyDown_Event:
|
|
|
|
{
|
|
|
|
FKeyEvent* kev = static_cast<FKeyEvent*>(ev);
|
|
|
|
FWidget* widget = this;
|
2016-09-03 15:17:48 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
while ( widget )
|
|
|
|
{
|
|
|
|
widget->onKeyDown(kev);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( kev->isAccepted() || widget->isRootWidget() )
|
|
|
|
break;
|
2016-09-03 15:17:48 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
widget = widget->getParentWidget();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
case fc::MouseDown_Event:
|
|
|
|
onMouseDown ( static_cast<FMouseEvent*>(ev) );
|
|
|
|
break;
|
2016-09-03 15:17:48 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
case fc::MouseUp_Event:
|
|
|
|
onMouseUp ( static_cast<FMouseEvent*>(ev) );
|
2015-06-21 23:27:10 +02:00
|
|
|
break;
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
case fc::MouseDoubleClick_Event:
|
|
|
|
onMouseDoubleClick ( static_cast<FMouseEvent*>(ev) );
|
2015-06-21 23:27:10 +02:00
|
|
|
break;
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
case fc::MouseWheel_Event:
|
|
|
|
onWheel ( static_cast<FWheelEvent*>(ev) );
|
2015-06-21 23:27:10 +02:00
|
|
|
break;
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
case fc::MouseMove_Event:
|
|
|
|
onMouseMove ( static_cast<FMouseEvent*>(ev) );
|
2015-06-21 23:27:10 +02:00
|
|
|
break;
|
2015-09-20 05:44:50 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
case fc::FocusIn_Event:
|
|
|
|
onFocusIn ( static_cast<FFocusEvent*>(ev) );
|
2015-09-20 05:44:50 +02:00
|
|
|
break;
|
2016-09-03 15:17:48 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
case fc::FocusOut_Event:
|
|
|
|
onFocusOut ( static_cast<FFocusEvent*>(ev) );
|
2016-09-03 15:17:48 +02:00
|
|
|
break;
|
|
|
|
|
2017-01-28 22:03:15 +01:00
|
|
|
case fc::ChildFocusIn_Event:
|
|
|
|
onChildFocusIn ( static_cast<FFocusEvent*>(ev) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case fc::ChildFocusOut_Event:
|
|
|
|
onChildFocusOut ( static_cast<FFocusEvent*>(ev) );
|
2017-01-26 00:31:07 +01:00
|
|
|
break;
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
case fc::Accelerator_Event:
|
|
|
|
onAccel ( static_cast<FAccelEvent*>(ev) );
|
2016-09-03 15:17:48 +02:00
|
|
|
break;
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
case fc::Resize_Event:
|
|
|
|
onResize ( static_cast<FResizeEvent*>(ev) );
|
|
|
|
break;
|
2016-09-03 15:17:48 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
case fc::Show_Event:
|
|
|
|
onShow ( static_cast<FShowEvent*>(ev) );
|
2016-09-03 15:17:48 +02:00
|
|
|
break;
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
case fc::Hide_Event:
|
|
|
|
onHide ( static_cast<FHideEvent*>(ev) );
|
|
|
|
break;
|
2016-09-03 15:17:48 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
case fc::Close_Event:
|
|
|
|
onClose ( static_cast<FCloseEvent*>(ev) );
|
|
|
|
break;
|
2016-09-03 15:17:48 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
case fc::Timer_Event:
|
|
|
|
onTimer ( static_cast<FTimerEvent*>(ev) );
|
2016-09-03 15:17:48 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2016-11-02 00:37:58 +01:00
|
|
|
return false;
|
2016-09-03 15:17:48 +02:00
|
|
|
}
|
2016-11-02 00:37:58 +01:00
|
|
|
return true;
|
2016-09-03 15:17:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FWidget::onKeyPress (FKeyEvent*)
|
|
|
|
{ }
|
2015-06-21 23:27:10 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::onKeyUp (FKeyEvent*)
|
|
|
|
{ }
|
2015-06-21 23:27:10 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::onKeyDown (FKeyEvent*)
|
|
|
|
{ }
|
2015-06-21 23:27:10 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::onMouseDown (FMouseEvent*)
|
|
|
|
{ }
|
2015-06-21 23:27:10 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::onMouseUp (FMouseEvent*)
|
|
|
|
{ }
|
2015-06-21 23:27:10 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FWidget::onMouseDoubleClick (FMouseEvent*)
|
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::onWheel (FWheelEvent*)
|
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::onMouseMove (FMouseEvent*)
|
|
|
|
{ }
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::onFocusIn (FFocusEvent*)
|
|
|
|
{ }
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::onFocusOut (FFocusEvent*)
|
|
|
|
{ }
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-01-26 00:31:07 +01:00
|
|
|
//----------------------------------------------------------------------
|
2017-01-28 22:03:15 +01:00
|
|
|
void FWidget::onChildFocusIn (FFocusEvent*)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::onChildFocusOut (FFocusEvent*)
|
2017-01-26 00:31:07 +01:00
|
|
|
{ }
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::onAccel (FAccelEvent*)
|
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::onResize (FResizeEvent* ev)
|
|
|
|
{
|
|
|
|
rootObject->resize();
|
|
|
|
rootObject->redraw();
|
|
|
|
ev->accept();
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::onShow (FShowEvent*)
|
|
|
|
{ }
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::onHide (FHideEvent*)
|
|
|
|
{ }
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::onClose (FCloseEvent* ev)
|
|
|
|
{
|
|
|
|
ev->accept();
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
// private methods of FWidget
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::init()
|
|
|
|
{
|
2017-08-12 22:55:29 +02:00
|
|
|
try
|
|
|
|
{
|
|
|
|
// Initialize widget lists
|
|
|
|
window_list = new widgetList();
|
|
|
|
dialog_list = new widgetList();
|
|
|
|
always_on_top_list = new widgetList();
|
|
|
|
close_widget = new widgetList();
|
|
|
|
}
|
|
|
|
catch (const std::bad_alloc& ex)
|
|
|
|
{
|
|
|
|
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-12 22:59:48 +01:00
|
|
|
char* cursor_off_str = disableCursor();
|
|
|
|
|
2017-01-15 19:48:27 +01:00
|
|
|
if ( cursor_off_str && std::strlen(cursor_off_str) > 0 )
|
2016-11-12 22:59:48 +01:00
|
|
|
hideable = true;
|
|
|
|
else
|
|
|
|
hideable = false;
|
|
|
|
|
|
|
|
visible_cursor = ! hideable;
|
|
|
|
|
2017-08-12 22:55:29 +02:00
|
|
|
// Determine width and height of the terminal
|
2016-11-02 00:37:58 +01:00
|
|
|
detectTermSize();
|
|
|
|
wsize.setRect(1, 1, getColumnNumber(), getLineNumber());
|
|
|
|
adjust_wsize = wsize;
|
|
|
|
offset.setRect(0, 0, getColumnNumber(), getLineNumber());
|
|
|
|
client_offset = offset;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
double_flatline_mask.top.resize (uLong(getWidth()), false);
|
|
|
|
double_flatline_mask.right.resize (uLong(getHeight()), false);
|
|
|
|
double_flatline_mask.bottom.resize (uLong(getWidth()), false);
|
|
|
|
double_flatline_mask.left.resize (uLong(getHeight()), false);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
// Initialize default widget colors
|
|
|
|
setColorTheme();
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
foreground_color = wc.term_fg;
|
|
|
|
background_color = wc.term_bg;
|
2016-11-27 19:16:52 +01:00
|
|
|
init_desktop = false;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-08-12 22:55:29 +02:00
|
|
|
try
|
|
|
|
{
|
|
|
|
accelerator_list = new Accelerators();
|
|
|
|
}
|
|
|
|
catch (const std::bad_alloc& ex)
|
|
|
|
{
|
|
|
|
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
|
|
|
|
}
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::finish()
|
|
|
|
{
|
|
|
|
delete accelerator_list;
|
|
|
|
accelerator_list = 0;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( close_widget )
|
|
|
|
{
|
|
|
|
delete close_widget;
|
|
|
|
close_widget = 0;
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( dialog_list )
|
|
|
|
{
|
|
|
|
delete dialog_list;
|
|
|
|
dialog_list = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( always_on_top_list )
|
|
|
|
{
|
|
|
|
delete always_on_top_list;
|
|
|
|
always_on_top_list = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( window_list )
|
|
|
|
{
|
|
|
|
delete window_list;
|
|
|
|
window_list = 0;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-22 23:04:40 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FWidget::insufficientSpaceAdjust()
|
|
|
|
{
|
|
|
|
// Move and shrink widget if there is not enough space available
|
|
|
|
|
|
|
|
if ( isWindowWidget() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// move left if not enough space
|
2017-08-27 09:50:30 +02:00
|
|
|
while ( getTermX() + getWidth() - padding.right > offset.getX2() + 2 )
|
2017-01-22 23:04:40 +01:00
|
|
|
{
|
|
|
|
adjust_wsize.x1_ref()--;
|
|
|
|
adjust_wsize.x2_ref()--;
|
|
|
|
|
|
|
|
if ( adjust_wsize.x1_ref() < 1 )
|
|
|
|
adjust_wsize.x1_ref() = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// move up if not enough space
|
2017-08-27 09:50:30 +02:00
|
|
|
while ( getTermY() + getHeight() - padding.bottom > offset.getY2() + 2 )
|
2017-01-22 23:04:40 +01:00
|
|
|
{
|
|
|
|
adjust_wsize.y1_ref()--;
|
|
|
|
adjust_wsize.y2_ref()--;
|
|
|
|
|
|
|
|
if ( adjust_wsize.y1_ref() < 1 )
|
|
|
|
adjust_wsize.y1_ref() = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// reduce the width if not enough space
|
2017-08-27 09:50:30 +02:00
|
|
|
while ( offset.getX1() + getWidth() - 1 > offset.getX2() )
|
2017-01-22 23:04:40 +01:00
|
|
|
adjust_wsize.x2_ref()--;
|
|
|
|
|
|
|
|
if ( getWidth() < size_hints.min_width )
|
|
|
|
adjust_wsize.setWidth(size_hints.min_width);
|
|
|
|
|
|
|
|
if ( getWidth() <= 0 )
|
|
|
|
adjust_wsize.setWidth(1);
|
|
|
|
|
|
|
|
// reduce the height if not enough space
|
2017-08-27 09:50:30 +02:00
|
|
|
while ( offset.getY1() + getHeight() - 1 > offset.getY2() )
|
2017-01-22 23:04:40 +01:00
|
|
|
adjust_wsize.y2_ref()--;
|
|
|
|
|
|
|
|
if ( getHeight() < size_hints.min_height )
|
|
|
|
adjust_wsize.setWidth(size_hints.min_height);
|
|
|
|
|
|
|
|
if ( getHeight() <= 0 )
|
|
|
|
adjust_wsize.setHeight(1);
|
|
|
|
}
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
void FWidget::draw()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setColorTheme()
|
2017-11-19 19:47:24 +01:00
|
|
|
{
|
|
|
|
if ( getMaxColor() < 16 ) // for 8 color mode
|
|
|
|
{
|
|
|
|
set8ColorTheme();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
set16ColorTheme();
|
|
|
|
|
|
|
|
if ( isKdeTerminal() )
|
2017-11-22 23:56:21 +01:00
|
|
|
wc.term_bg = fc::SteelBlue3;
|
2017-11-19 19:47:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::set8ColorTheme()
|
|
|
|
{
|
|
|
|
wc.term_fg = fc::Black;
|
|
|
|
wc.term_bg = fc::Blue;
|
|
|
|
wc.list_fg = fc::Black;
|
|
|
|
wc.list_bg = fc::LightGray;
|
|
|
|
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;
|
|
|
|
wc.error_box_emphasis_fg = fc::Red;
|
|
|
|
wc.error_box_bg = fc::LightGray;
|
|
|
|
wc.tooltip_fg = fc::LightGray;
|
|
|
|
wc.tooltip_bg = fc::Cyan;
|
|
|
|
wc.shadow_fg = fc::Black;
|
|
|
|
wc.shadow_bg = fc::LightGray; // only for transparent shadow
|
|
|
|
wc.current_element_focus_fg = fc::LightGray;
|
|
|
|
wc.current_element_focus_bg = fc::Red;
|
|
|
|
wc.current_element_fg = fc::LightGray;
|
|
|
|
wc.current_element_bg = fc::Blue;
|
|
|
|
wc.current_inc_search_element_fg = fc::Brown;
|
|
|
|
wc.selected_current_element_focus_fg = fc::Blue;
|
|
|
|
wc.selected_current_element_focus_bg = fc::Red;
|
|
|
|
wc.selected_current_element_fg = fc::Cyan;
|
|
|
|
wc.selected_current_element_bg = fc::Blue;
|
|
|
|
wc.label_fg = fc::Black;
|
|
|
|
wc.label_bg = fc::LightGray;
|
|
|
|
wc.label_inactive_fg = fc::Cyan;
|
|
|
|
wc.label_inactive_bg = fc::LightGray;
|
|
|
|
wc.label_hotkey_fg = fc::Red;
|
|
|
|
wc.label_hotkey_bg = fc::LightGray;
|
|
|
|
wc.label_emphasis_fg = fc::Blue;
|
|
|
|
wc.label_ellipsis_fg = fc::Black;
|
|
|
|
wc.inputfield_active_focus_fg = fc::LightGray;
|
|
|
|
wc.inputfield_active_focus_bg = fc::Blue;
|
|
|
|
wc.inputfield_active_fg = fc::Black;
|
|
|
|
wc.inputfield_active_bg = fc::Cyan;
|
|
|
|
wc.inputfield_inactive_fg = fc::Black;
|
|
|
|
wc.inputfield_inactive_bg = fc::LightGray;
|
|
|
|
wc.toggle_button_active_focus_fg = fc::LightGray;
|
|
|
|
wc.toggle_button_active_focus_bg = fc::Red;
|
|
|
|
wc.toggle_button_active_fg = fc::Black;
|
|
|
|
wc.toggle_button_active_bg = fc::LightGray;
|
|
|
|
wc.toggle_button_inactive_fg = fc::Cyan;
|
|
|
|
wc.toggle_button_inactive_bg = fc::LightGray;
|
|
|
|
wc.button_active_focus_fg = fc::LightGray;
|
|
|
|
wc.button_active_focus_bg = fc::Red;
|
|
|
|
wc.button_active_fg = fc::LightGray;
|
|
|
|
wc.button_active_bg = fc::Blue;
|
|
|
|
wc.button_inactive_fg = fc::Black;
|
|
|
|
wc.button_inactive_bg = fc::Blue;
|
|
|
|
wc.button_hotkey_fg = fc::LightGray;
|
|
|
|
wc.titlebar_active_fg = fc::LightGray;
|
|
|
|
wc.titlebar_active_bg = fc::Red;
|
|
|
|
wc.titlebar_inactive_fg = fc::Black;
|
|
|
|
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;
|
|
|
|
wc.menu_active_bg = fc::LightGray;
|
|
|
|
wc.menu_inactive_fg = fc::Cyan;
|
|
|
|
wc.menu_inactive_bg = fc::LightGray;
|
|
|
|
wc.menu_hotkey_fg = fc::Red;
|
|
|
|
wc.menu_hotkey_bg = fc::LightGray;
|
|
|
|
wc.statusbar_fg = fc::Black;
|
|
|
|
wc.statusbar_bg = fc::LightGray;
|
|
|
|
wc.statusbar_hotkey_fg = fc::Red;
|
|
|
|
wc.statusbar_hotkey_bg = fc::LightGray;
|
|
|
|
wc.statusbar_separator_fg = fc::Black;
|
|
|
|
wc.statusbar_active_fg = fc::LightGray;
|
|
|
|
wc.statusbar_active_bg = fc::Black;
|
|
|
|
wc.statusbar_active_hotkey_fg = fc::Red;
|
|
|
|
wc.statusbar_active_hotkey_bg = fc::Black;
|
|
|
|
wc.scrollbar_fg = fc::Black;
|
|
|
|
wc.scrollbar_bg = fc::LightGray;
|
|
|
|
wc.scrollbar_button_fg = fc::Black;
|
|
|
|
wc.scrollbar_button_bg = fc::LightGray;
|
|
|
|
wc.progressbar_fg = fc::Blue;
|
|
|
|
wc.progressbar_bg = fc::LightGray;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::set16ColorTheme()
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
wc.term_fg = fc::Black;
|
|
|
|
wc.term_bg = fc::LightBlue;
|
|
|
|
wc.list_fg = fc::Black;
|
|
|
|
wc.list_bg = fc::White;
|
|
|
|
wc.selected_list_fg = fc::Cyan;
|
|
|
|
wc.selected_list_bg = fc::White;
|
|
|
|
wc.dialog_fg = fc::Black;
|
|
|
|
wc.dialog_resize_fg = fc::Cyan;
|
|
|
|
wc.dialog_emphasis_fg = fc::Blue;
|
|
|
|
wc.dialog_bg = fc::White;
|
|
|
|
wc.error_box_fg = fc::White;
|
|
|
|
wc.error_box_emphasis_fg = fc::Yellow;
|
|
|
|
wc.error_box_bg = fc::LightRed;
|
|
|
|
wc.tooltip_fg = fc::Black;
|
|
|
|
wc.tooltip_bg = fc::Yellow;
|
|
|
|
wc.shadow_fg = fc::Black;
|
2017-09-11 03:06:02 +02:00
|
|
|
wc.shadow_bg = fc::LightGray; // only for transparent shadow
|
2016-11-02 00:37:58 +01:00
|
|
|
wc.current_element_focus_fg = fc::White;
|
|
|
|
wc.current_element_focus_bg = fc::Blue;
|
|
|
|
wc.current_element_fg = fc::LightGray;
|
|
|
|
wc.current_element_bg = fc::Blue;
|
|
|
|
wc.current_inc_search_element_fg = fc::LightRed;
|
|
|
|
wc.selected_current_element_focus_fg = fc::LightCyan;
|
|
|
|
wc.selected_current_element_focus_bg = fc::Blue;
|
|
|
|
wc.selected_current_element_fg = fc::LightBlue;
|
|
|
|
wc.selected_current_element_bg = fc::Blue;
|
|
|
|
wc.label_fg = fc::Black;
|
|
|
|
wc.label_bg = fc::White;
|
|
|
|
wc.label_inactive_fg = fc::LightGray;
|
|
|
|
wc.label_inactive_bg = fc::White;
|
|
|
|
wc.label_hotkey_fg = fc::Red;
|
|
|
|
wc.label_hotkey_bg = fc::White;
|
|
|
|
wc.label_emphasis_fg = fc::Blue;
|
|
|
|
wc.label_ellipsis_fg = fc::DarkGray;
|
|
|
|
wc.inputfield_active_focus_fg = fc::White;
|
|
|
|
wc.inputfield_active_focus_bg = fc::Cyan;
|
|
|
|
wc.inputfield_active_fg = fc::Black;
|
|
|
|
wc.inputfield_active_bg = fc::LightGray;
|
|
|
|
wc.inputfield_inactive_fg = fc::DarkGray;
|
|
|
|
wc.inputfield_inactive_bg = fc::LightGray;
|
|
|
|
wc.toggle_button_active_focus_fg = fc::White;
|
|
|
|
wc.toggle_button_active_focus_bg = fc::Cyan;
|
|
|
|
wc.toggle_button_active_fg = fc::Black;
|
|
|
|
wc.toggle_button_active_bg = fc::White;
|
|
|
|
wc.toggle_button_inactive_fg = fc::LightGray;
|
|
|
|
wc.toggle_button_inactive_bg = fc::White;
|
|
|
|
wc.button_active_focus_fg = fc::LightGray;
|
|
|
|
wc.button_active_focus_bg = fc::Blue;
|
|
|
|
wc.button_active_fg = fc::LightGray;
|
|
|
|
wc.button_active_bg = fc::DarkGray;
|
|
|
|
wc.button_inactive_fg = fc::DarkGray;
|
|
|
|
wc.button_inactive_bg = fc::LightGray;
|
|
|
|
wc.button_hotkey_fg = fc::White;
|
|
|
|
wc.titlebar_active_fg = fc::White;
|
|
|
|
wc.titlebar_active_bg = fc::Blue;
|
|
|
|
wc.titlebar_inactive_fg = fc::LightGray;
|
|
|
|
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;
|
|
|
|
wc.menu_active_bg = fc::White;
|
|
|
|
wc.menu_inactive_fg = fc::LightGray;
|
|
|
|
wc.menu_inactive_bg = fc::White;
|
|
|
|
wc.menu_hotkey_fg = fc::Red;
|
|
|
|
wc.menu_hotkey_bg = fc::White;
|
|
|
|
wc.statusbar_fg = fc::White;
|
|
|
|
wc.statusbar_bg = fc::Blue;
|
|
|
|
wc.statusbar_hotkey_fg = fc::LightRed;
|
|
|
|
wc.statusbar_hotkey_bg = fc::Blue;
|
|
|
|
wc.statusbar_separator_fg = fc::Black;
|
|
|
|
wc.statusbar_active_fg = fc::Blue;
|
|
|
|
wc.statusbar_active_bg = fc::White;
|
|
|
|
wc.statusbar_active_hotkey_fg = fc::DarkGray;
|
|
|
|
wc.statusbar_active_hotkey_bg = fc::White;
|
|
|
|
wc.scrollbar_fg = fc::DarkGray;
|
|
|
|
wc.scrollbar_bg = fc::LightBlue;
|
|
|
|
wc.scrollbar_button_fg = fc::Black;
|
|
|
|
wc.scrollbar_button_bg = fc::LightGray;
|
|
|
|
wc.progressbar_fg = fc::DarkGray;
|
|
|
|
wc.progressbar_bg = fc::LightBlue;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|