2015-09-25 21:37:19 +02:00
|
|
|
// File: fwidget.cpp
|
|
|
|
// Provides: class FWidget
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
#include "fapp.h"
|
2015-08-09 23:44:11 +02:00
|
|
|
#include "fmenubar.h"
|
2015-10-10 03:14:14 +02:00
|
|
|
#include "fstatusbar.h"
|
2015-05-23 13:35:12 +02:00
|
|
|
#include "fwidget.h"
|
|
|
|
#include "fwindow.h"
|
|
|
|
|
|
|
|
// 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;
|
2015-05-23 13:35:12 +02:00
|
|
|
FWidget::widgetList* FWidget::close_widget = 0;
|
|
|
|
FWidget::widget_colors FWidget::wc;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FWidget
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// constructors and destructor
|
|
|
|
//----------------------------------------------------------------------
|
2015-09-22 04:18:20 +02:00
|
|
|
FWidget::FWidget (FWidget* parent)
|
|
|
|
: FObject(parent)
|
|
|
|
, callbackObjects()
|
|
|
|
, memberCallbackObjects()
|
|
|
|
, accelerator_list()
|
|
|
|
, double_flatline_mask()
|
|
|
|
, xpos(1)
|
|
|
|
, ypos(1)
|
|
|
|
, width(1)
|
|
|
|
, height(1)
|
|
|
|
, xmin(1)
|
|
|
|
, ymin(1)
|
|
|
|
, xmax(1)
|
|
|
|
, ymax(1)
|
|
|
|
, top_padding(0)
|
|
|
|
, left_padding(0)
|
|
|
|
, bottom_padding(0)
|
|
|
|
, right_padding(0)
|
|
|
|
, client_xmin(0)
|
|
|
|
, client_ymin(0)
|
|
|
|
, client_xmax(0)
|
|
|
|
, client_ymax(0)
|
|
|
|
, shadow()
|
|
|
|
, adjustWidgetSizeShadow()
|
|
|
|
, adjustWidgetSizeGlobalShadow()
|
|
|
|
, ignore_padding(false)
|
|
|
|
, window_object(false)
|
2016-06-12 23:06:58 +02:00
|
|
|
, dialog_object(false)
|
2016-05-16 23:26:04 +02:00
|
|
|
, menu_object(false)
|
2015-09-22 04:18:20 +02:00
|
|
|
, flags(0)
|
|
|
|
, foregroundColor()
|
|
|
|
, backgroundColor()
|
|
|
|
, enable(true)
|
|
|
|
, visible(true)
|
|
|
|
, shown(false)
|
|
|
|
, focus(false)
|
|
|
|
, focusable(true)
|
|
|
|
, visibleCursor(false)
|
|
|
|
, widgetCursorPosition(-1,-1)
|
|
|
|
, widgetSize(1,1,1,1)
|
|
|
|
, adjustWidgetSize(1,1,1,1)
|
|
|
|
, adjustWidgetSizeGlobal(1,1,1,1)
|
|
|
|
, statusbar_message()
|
2015-10-14 04:06:26 +02:00
|
|
|
, print_area(0)
|
2015-09-22 04:18:20 +02:00
|
|
|
{
|
|
|
|
resize_term = false;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2015-11-05 23:25:21 +01:00
|
|
|
if ( ! parent )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
assert ( ! rootObject
|
|
|
|
&& "FTerm: There should be only one root object" );
|
|
|
|
|
|
|
|
rootObject = this;
|
|
|
|
show_root_widget = 0;
|
|
|
|
redraw_root_widget = 0;
|
|
|
|
modal_dialogs = 0;
|
|
|
|
statusbar = 0;
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-09-22 04:18:20 +02:00
|
|
|
xmin = parent->client_xmin;
|
|
|
|
ymin = parent->client_ymin;
|
|
|
|
xmax = parent->client_xmax;
|
|
|
|
ymax = parent->client_ymax;
|
2015-06-22 00:26:24 +02:00
|
|
|
double_flatline_mask.top.resize (uLong(width), false);
|
|
|
|
double_flatline_mask.right.resize (uLong(height), false);
|
|
|
|
double_flatline_mask.bottom.resize (uLong(width), false);
|
|
|
|
double_flatline_mask.left.resize (uLong(height), false);
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FWidget::~FWidget() // destructor
|
|
|
|
{
|
|
|
|
processDestroy();
|
|
|
|
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 )
|
|
|
|
{
|
|
|
|
FWindow* window = FWindow::getWindowWidget(this);
|
|
|
|
if ( window )
|
|
|
|
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 )
|
|
|
|
this->finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
// private methods of FWidget
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::init()
|
|
|
|
{
|
2015-10-17 19:40:43 +02:00
|
|
|
window_list = new widgetList();
|
2016-07-14 23:55:22 +02:00
|
|
|
dialog_list = new widgetList();
|
2015-10-17 19:40:43 +02:00
|
|
|
close_widget = new widgetList();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2015-09-22 04:18:20 +02:00
|
|
|
getTermGeometry(); // <-----.
|
|
|
|
// |
|
|
|
|
xpos = xmin; // xmin, ymin, xmax and ymax
|
|
|
|
ypos = ymin; // were determined with
|
|
|
|
width = xmax; // getTermGeometry()
|
2015-05-23 13:35:12 +02:00
|
|
|
height = ymax;
|
|
|
|
client_xmin = xmin;
|
|
|
|
client_ymin = ymin;
|
|
|
|
client_xmax = xmax;
|
|
|
|
client_ymax = ymax;
|
|
|
|
|
2015-09-22 04:18:20 +02:00
|
|
|
// xpos and ypos are initialized with the value 1
|
|
|
|
// width and height were determined with getTermGeometry()
|
2015-05-23 13:35:12 +02:00
|
|
|
widgetSize.setRect(xpos, ypos, width, height);
|
|
|
|
adjustWidgetSize.setRect(xpos, ypos, width, height);
|
|
|
|
adjustWidgetSizeShadow = adjustWidgetSize;
|
2015-09-22 04:18:20 +02:00
|
|
|
adjustWidgetSizeGlobal.setRect ( xpos + xmin - 1
|
|
|
|
, ypos + ymin - 1
|
|
|
|
, width, height );
|
2015-05-23 13:35:12 +02:00
|
|
|
adjustWidgetSizeGlobalShadow = adjustWidgetSizeGlobal;
|
|
|
|
|
2015-06-22 00:26:24 +02:00
|
|
|
double_flatline_mask.top.resize (uLong(width), false);
|
|
|
|
double_flatline_mask.right.resize (uLong(height), false);
|
|
|
|
double_flatline_mask.bottom.resize (uLong(width), false);
|
|
|
|
double_flatline_mask.left.resize (uLong(height), false);
|
2015-06-21 23:27:10 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
// default widget colors
|
|
|
|
setColorTheme();
|
|
|
|
|
|
|
|
foregroundColor = wc.term_fg;
|
|
|
|
backgroundColor = wc.term_bg;
|
|
|
|
setColor (foregroundColor, backgroundColor);
|
2016-08-06 21:43:39 +02:00
|
|
|
clearArea();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2015-10-17 19:40:43 +02:00
|
|
|
accelerator_list = new Accelerators();
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::finish()
|
|
|
|
{
|
|
|
|
delete accelerator_list;
|
2016-07-03 20:08:39 +02:00
|
|
|
accelerator_list = 0;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
if ( close_widget )
|
|
|
|
{
|
|
|
|
delete close_widget;
|
|
|
|
close_widget = 0;
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-07-14 23:55:22 +02:00
|
|
|
if ( dialog_list )
|
|
|
|
{
|
|
|
|
delete dialog_list;
|
|
|
|
dialog_list = 0;
|
|
|
|
}
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( window_list )
|
|
|
|
{
|
|
|
|
delete window_list;
|
|
|
|
window_list = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::draw()
|
2015-09-22 04:18:20 +02:00
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setColorTheme()
|
|
|
|
{
|
2015-10-23 23:57:00 +02: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_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.shadow_fg = fc::Black;
|
|
|
|
wc.shadow_bg = fc::LightGray; // only for transparent shadow
|
|
|
|
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;
|
2015-10-29 21:10:50 +01:00
|
|
|
wc.selected_current_element_focus_fg = fc::LightCyan;
|
2015-10-23 23:57:00 +02:00
|
|
|
wc.selected_current_element_focus_bg = fc::Blue;
|
2015-10-29 21:10:50 +01:00
|
|
|
wc.selected_current_element_fg = fc::LightBlue;
|
2015-10-23 23:57:00 +02:00
|
|
|
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::Black;
|
|
|
|
wc.titlebar_button_bg = fc::LightGray;
|
|
|
|
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
|
|
|
|
|
|
|
if ( kde_konsole )
|
|
|
|
wc.term_bg = fc::SteelBlue3;
|
|
|
|
|
|
|
|
if ( tera_terminal )
|
|
|
|
wc.term_bg = fc::LightBlue;
|
|
|
|
|
|
|
|
if ( max_color < 16 ) // for 8 color mode
|
|
|
|
{
|
2015-10-23 23:57:00 +02:00
|
|
|
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_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.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.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;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-14 04:06:26 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FTerm::term_area* FWidget::getPrintArea()
|
|
|
|
{
|
|
|
|
if ( print_area )
|
|
|
|
return print_area;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FWidget* area_widget = FWindow::getWindowWidget(this);
|
|
|
|
|
|
|
|
if ( area_widget )
|
|
|
|
{
|
|
|
|
term_area* area = area_widget->getVWin();
|
|
|
|
|
|
|
|
if ( area )
|
|
|
|
{
|
|
|
|
print_area = area;
|
|
|
|
return area;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
// protected methods of FWidget
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::adjustSize()
|
|
|
|
{
|
|
|
|
if ( ! isRootWidget() )
|
|
|
|
{
|
2016-08-21 21:27:44 +02:00
|
|
|
FWidget* parent_widget = getParentWidget();
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( isWindow() )
|
|
|
|
{
|
|
|
|
xmin = rootObject->client_xmin;
|
|
|
|
ymin = rootObject->client_ymin;
|
|
|
|
xmax = rootObject->client_xmax;
|
|
|
|
ymax = rootObject->client_ymax;
|
|
|
|
}
|
2016-08-21 21:27:44 +02:00
|
|
|
else if ( ignore_padding && parent_widget )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-08-21 21:27:44 +02:00
|
|
|
xmin = parent_widget->xpos + parent_widget->xmin - 1;
|
|
|
|
ymin = parent_widget->ypos + parent_widget->ymin - 1;
|
|
|
|
xmax = parent_widget->xpos + parent_widget->xmin - 2
|
|
|
|
+ parent_widget->width;
|
|
|
|
ymax = parent_widget->ypos + parent_widget->ymin - 2
|
|
|
|
+ parent_widget->height;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
2016-08-21 21:27:44 +02:00
|
|
|
else if ( parent_widget )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-08-21 21:27:44 +02:00
|
|
|
xmin = parent_widget->client_xmin;
|
|
|
|
ymin = parent_widget->client_ymin;
|
|
|
|
xmax = parent_widget->client_xmax;
|
|
|
|
ymax = parent_widget->client_ymax;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
xpos = widgetSize.getX();
|
|
|
|
ypos = widgetSize.getY();
|
|
|
|
width = widgetSize.getWidth();
|
|
|
|
height = widgetSize.getHeight();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! isWindow() )
|
|
|
|
{
|
|
|
|
while ( xpos+xmin-1+width > xmax+1 )
|
|
|
|
{
|
|
|
|
xpos--;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( xpos < 1 )
|
|
|
|
{
|
|
|
|
xpos = 1;
|
|
|
|
width--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while ( ypos+ymin-1+height > ymax+1 )
|
|
|
|
{
|
|
|
|
ypos--;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( ypos < 1 )
|
|
|
|
{
|
|
|
|
ypos = 1;
|
|
|
|
height--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while ( xmin+width-1 > xmax )
|
|
|
|
width--;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
while ( ymin+height-1 > ymax )
|
|
|
|
height--;
|
2016-01-17 23:37:52 +01:00
|
|
|
|
|
|
|
if ( width < 1 )
|
|
|
|
width = 1;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-17 23:37:52 +01:00
|
|
|
if ( height < 1 )
|
|
|
|
height = 1;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
adjustWidgetSize.setRect(xpos, ypos, width, height);
|
|
|
|
adjustWidgetSizeShadow = adjustWidgetSize + shadow;
|
2015-09-22 04:18:20 +02:00
|
|
|
adjustWidgetSizeGlobal.setRect ( xpos + xmin - 1
|
|
|
|
, ypos + ymin - 1
|
|
|
|
, width, height );
|
2015-05-23 13:35:12 +02:00
|
|
|
adjustWidgetSizeGlobalShadow = adjustWidgetSizeGlobal + shadow;
|
|
|
|
|
|
|
|
client_xmin = xpos + xmin - 1 + left_padding;
|
|
|
|
client_ymin = ypos + ymin - 1 + top_padding;
|
|
|
|
client_xmax = xpos + xmin - 2 + width - right_padding;
|
|
|
|
client_ymax = ypos + ymin - 2 + height - bottom_padding;
|
|
|
|
|
|
|
|
if ( this->hasChildren() )
|
|
|
|
{
|
|
|
|
FObject::object_list children;
|
|
|
|
FObject::object_list::const_iterator iter, end;
|
|
|
|
|
2015-09-20 05:44:50 +02:00
|
|
|
children = this->getChildren();
|
2015-05-23 13:35:12 +02:00
|
|
|
iter = children.begin();
|
|
|
|
end = children.end();
|
|
|
|
|
|
|
|
while ( iter != end )
|
|
|
|
{
|
|
|
|
FWidget* widget = static_cast<FWidget*>(*iter);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( ! widget->isWindow() )
|
|
|
|
widget->adjustSize();
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-16 21:11:32 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::adjustSizeGlobal()
|
|
|
|
{
|
|
|
|
if ( ! isRootWidget() )
|
|
|
|
{
|
|
|
|
getRootWidget()->adjustSizeGlobal();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( menubar )
|
|
|
|
menubar->adjustSize();
|
|
|
|
|
|
|
|
if ( statusbar )
|
|
|
|
statusbar->adjustSize();
|
|
|
|
|
|
|
|
if ( window_list && ! window_list->empty() )
|
|
|
|
{
|
|
|
|
widgetList::const_iterator iter, end;
|
|
|
|
iter = window_list->begin();
|
|
|
|
end = window_list->end();
|
|
|
|
|
|
|
|
while ( iter != end )
|
|
|
|
{
|
|
|
|
(*iter)->adjustSize();
|
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setStatusBar (FStatusBar* sbar)
|
|
|
|
{
|
|
|
|
if ( ! sbar || statusbar == sbar )
|
|
|
|
return;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-07-28 01:04:27 +02:00
|
|
|
if ( statusbar && sbar != 0 )
|
2015-05-23 13:35:12 +02:00
|
|
|
delete statusbar;
|
|
|
|
|
|
|
|
statusbar = sbar;
|
|
|
|
}
|
|
|
|
|
2015-08-09 23:44:11 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setMenuBar (FMenuBar* mbar)
|
|
|
|
{
|
|
|
|
if ( ! mbar || menubar == mbar )
|
|
|
|
return;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-08-09 23:44:11 +02:00
|
|
|
if ( menubar )
|
|
|
|
delete menubar;
|
|
|
|
|
|
|
|
menubar = mbar;
|
|
|
|
}
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FWidget::event (FEvent* ev)
|
|
|
|
{
|
|
|
|
switch ( ev->type() )
|
|
|
|
{
|
2016-01-17 02:57:08 +01:00
|
|
|
case fc::KeyPress_Event:
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
FKeyEvent* kev = static_cast<FKeyEvent*>(ev);
|
|
|
|
bool accpt_focus = false;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( kev->key() == fc::Fkey_tab )
|
|
|
|
accpt_focus = focusNextChild();
|
|
|
|
else if ( kev->key() == fc::Fkey_btab )
|
|
|
|
accpt_focus = focusPrevChild();
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( accpt_focus )
|
|
|
|
break;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
FWidget* widget = this;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
while ( widget )
|
|
|
|
{
|
|
|
|
widget->onKeyPress(kev);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( ! kev->isAccepted() )
|
|
|
|
{
|
|
|
|
if ( kev->key() == fc::Fkey_right
|
|
|
|
|| kev->key() == fc::Fkey_down )
|
|
|
|
accpt_focus = focusNextChild();
|
|
|
|
else if ( kev->key() == fc::Fkey_left
|
|
|
|
|| kev->key() == fc::Fkey_up )
|
|
|
|
accpt_focus = focusPrevChild();
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( accpt_focus )
|
|
|
|
break;
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( kev->isAccepted() || widget->isRootWidget() )
|
|
|
|
break;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-07-03 20:08:39 +02:00
|
|
|
widget = widget->getParentWidget();
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2016-01-17 02:57:08 +01:00
|
|
|
case fc::KeyUp_Event:
|
2015-05-23 13:35:12 +02:00
|
|
|
onKeyUp ( static_cast<FKeyEvent*>(ev) );
|
|
|
|
break;
|
|
|
|
|
2016-01-17 02:57:08 +01:00
|
|
|
case fc::KeyDown_Event:
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
FKeyEvent* kev = static_cast<FKeyEvent*>(ev);
|
|
|
|
FWidget* widget = this;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
while ( widget )
|
|
|
|
{
|
|
|
|
widget->onKeyDown(kev);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( kev->isAccepted() || widget->isRootWidget() )
|
|
|
|
break;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-07-03 20:08:39 +02:00
|
|
|
widget = widget->getParentWidget();
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2016-01-17 02:57:08 +01:00
|
|
|
case fc::MouseDown_Event:
|
2015-05-23 13:35:12 +02:00
|
|
|
onMouseDown ( static_cast<FMouseEvent*>(ev) );
|
|
|
|
break;
|
|
|
|
|
2016-01-17 02:57:08 +01:00
|
|
|
case fc::MouseUp_Event:
|
2015-05-23 13:35:12 +02:00
|
|
|
onMouseUp ( static_cast<FMouseEvent*>(ev) );
|
|
|
|
break;
|
|
|
|
|
2016-01-17 02:57:08 +01:00
|
|
|
case fc::MouseDoubleClick_Event:
|
2015-05-23 13:35:12 +02:00
|
|
|
onMouseDoubleClick ( static_cast<FMouseEvent*>(ev) );
|
|
|
|
break;
|
|
|
|
|
2016-01-17 02:57:08 +01:00
|
|
|
case fc::MouseWheel_Event:
|
2015-05-23 13:35:12 +02:00
|
|
|
onWheel ( static_cast<FWheelEvent*>(ev) );
|
|
|
|
break;
|
|
|
|
|
2016-01-17 02:57:08 +01:00
|
|
|
case fc::MouseMove_Event:
|
2015-05-23 13:35:12 +02:00
|
|
|
onMouseMove ( static_cast<FMouseEvent*>(ev) );
|
|
|
|
break;
|
|
|
|
|
2016-01-17 02:57:08 +01:00
|
|
|
case fc::FocusIn_Event:
|
2015-05-23 13:35:12 +02:00
|
|
|
onFocusIn ( static_cast<FFocusEvent*>(ev) );
|
|
|
|
break;
|
|
|
|
|
2016-01-17 02:57:08 +01:00
|
|
|
case fc::FocusOut_Event:
|
2015-05-23 13:35:12 +02:00
|
|
|
onFocusOut ( static_cast<FFocusEvent*>(ev) );
|
|
|
|
break;
|
|
|
|
|
2016-01-17 02:57:08 +01:00
|
|
|
case fc::Accelerator_Event:
|
2015-05-23 13:35:12 +02:00
|
|
|
onAccel ( static_cast<FAccelEvent*>(ev) );
|
|
|
|
break;
|
|
|
|
|
2016-01-17 02:57:08 +01:00
|
|
|
case fc::Resize_Event:
|
2015-05-23 13:35:12 +02:00
|
|
|
onResize ( static_cast<FResizeEvent*>(ev) );
|
|
|
|
break;
|
|
|
|
|
2016-01-17 02:57:08 +01:00
|
|
|
case fc::Show_Event:
|
2015-05-23 13:35:12 +02:00
|
|
|
onShow ( static_cast<FShowEvent*>(ev) );
|
|
|
|
break;
|
|
|
|
|
2016-01-17 02:57:08 +01:00
|
|
|
case fc::Hide_Event:
|
2015-05-23 13:35:12 +02:00
|
|
|
onHide ( static_cast<FHideEvent*>(ev) );
|
|
|
|
break;
|
|
|
|
|
2016-01-17 02:57:08 +01:00
|
|
|
case fc::Close_Event:
|
2015-05-23 13:35:12 +02:00
|
|
|
onClose ( static_cast<FCloseEvent*>(ev) );
|
|
|
|
break;
|
|
|
|
|
2016-01-17 02:57:08 +01:00
|
|
|
case fc::Timer_Event:
|
2015-05-23 13:35:12 +02:00
|
|
|
onTimer ( static_cast<FTimerEvent*>(ev) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::onKeyPress (FKeyEvent*)
|
2015-09-22 04:18:20 +02:00
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::onKeyUp (FKeyEvent*)
|
2015-09-22 04:18:20 +02:00
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::onKeyDown (FKeyEvent*)
|
2015-09-22 04:18:20 +02:00
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::onMouseDown (FMouseEvent*)
|
2015-09-22 04:18:20 +02:00
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::onMouseUp (FMouseEvent*)
|
2015-09-22 04:18:20 +02:00
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::onMouseDoubleClick (FMouseEvent*)
|
2015-09-22 04:18:20 +02:00
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::onWheel (FWheelEvent*)
|
2015-09-22 04:18:20 +02:00
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::onMouseMove (FMouseEvent*)
|
2015-09-22 04:18:20 +02:00
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::onFocusIn (FFocusEvent*)
|
2015-09-22 04:18:20 +02:00
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::onFocusOut (FFocusEvent*)
|
2015-09-22 04:18:20 +02:00
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::onAccel (FAccelEvent*)
|
2015-09-22 04:18:20 +02:00
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2015-09-20 05:44:50 +02:00
|
|
|
void FWidget::onResize (FResizeEvent* ev)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
rootObject->resize();
|
|
|
|
rootObject->redraw();
|
2015-09-20 05:44:50 +02:00
|
|
|
ev->accept();
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::onShow (FShowEvent*)
|
2015-09-22 04:18:20 +02:00
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::onHide (FHideEvent*)
|
2015-09-22 04:18:20 +02:00
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2015-09-20 05:44:50 +02:00
|
|
|
void FWidget::onClose (FCloseEvent* ev)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2015-09-20 05:44:50 +02:00
|
|
|
ev->accept();
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-05-22 19:18:16 +02:00
|
|
|
bool FWidget::focusNextChild()
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-08-21 21:27:44 +02:00
|
|
|
if ( isDialog() )
|
|
|
|
return false;
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( hasParent() )
|
|
|
|
{
|
2015-12-08 21:05:00 +01:00
|
|
|
FWidget* parent = static_cast<FWidget*>(getParent());
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-12-08 21:05:00 +01:00
|
|
|
if ( parent->hasChildren() && parent->numOfFocusableChildren() > 1 )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
FObject::object_list children;
|
|
|
|
FObject::object_list::iterator iter, end;
|
|
|
|
|
2016-08-20 22:27:23 +02:00
|
|
|
children = parent->getChildren();
|
2015-05-23 13:35:12 +02:00
|
|
|
iter = children.begin();
|
|
|
|
end = children.end();
|
|
|
|
|
|
|
|
while ( iter != end )
|
|
|
|
{
|
|
|
|
FWidget* w = static_cast<FWidget*>(*iter);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( w == this )
|
|
|
|
{
|
|
|
|
FWidget* next;
|
|
|
|
FObject::object_list::const_iterator next_element;
|
|
|
|
next_element = iter;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
do
|
|
|
|
{
|
|
|
|
++next_element;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( next_element == children.end() )
|
|
|
|
next_element = children.begin();
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
next = static_cast<FWidget*>(*next_element);
|
|
|
|
} while ( ! next->isEnabled()
|
|
|
|
|| ! next->acceptFocus()
|
|
|
|
|| ! next->isVisible()
|
|
|
|
|| next->isWindow() );
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-17 02:57:08 +01:00
|
|
|
FFocusEvent out (fc::FocusOut_Event);
|
|
|
|
out.setFocusType(fc::FocusNextWidget);
|
2015-05-23 13:35:12 +02:00
|
|
|
FApplication::sendEvent(this, &out);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( out.isAccepted() )
|
|
|
|
{
|
|
|
|
if ( next == this )
|
|
|
|
return false;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
next->setFocus();
|
2016-01-17 02:57:08 +01:00
|
|
|
FFocusEvent in (fc::FocusIn_Event);
|
|
|
|
in.setFocusType(fc::FocusNextWidget);
|
2015-05-23 13:35:12 +02:00
|
|
|
FApplication::sendEvent(next, &in);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( in.isAccepted() )
|
|
|
|
{
|
|
|
|
this->draw();
|
|
|
|
next->draw();
|
|
|
|
updateTerminal();
|
|
|
|
flush_out();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-05-22 19:18:16 +02:00
|
|
|
bool FWidget::focusPrevChild()
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-08-21 21:27:44 +02:00
|
|
|
if ( isDialog() )
|
|
|
|
return false;
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( hasParent() )
|
|
|
|
{
|
2015-12-08 21:05:00 +01:00
|
|
|
FWidget* parent = static_cast<FWidget*>(getParent());
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-12-08 21:05:00 +01:00
|
|
|
if ( parent->hasChildren() && parent->numOfFocusableChildren() > 1 )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
FObject::object_list children;
|
|
|
|
FObject::object_list::iterator iter, begin;
|
|
|
|
|
2016-08-20 22:27:23 +02:00
|
|
|
children = parent->getChildren();
|
2015-05-23 13:35:12 +02:00
|
|
|
iter = children.end();
|
|
|
|
begin = children.begin();
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
do
|
|
|
|
{
|
|
|
|
--iter;
|
|
|
|
FWidget* w = static_cast<FWidget*>(*iter);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( w == this )
|
|
|
|
{
|
|
|
|
FWidget* prev;
|
|
|
|
FObject::object_list::const_iterator prev_element;
|
|
|
|
prev_element = iter;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if ( prev_element == children.begin() )
|
|
|
|
prev_element = children.end();
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
--prev_element;
|
|
|
|
prev = static_cast<FWidget*>(*prev_element);
|
|
|
|
} while ( ! prev->isEnabled()
|
|
|
|
|| ! prev->acceptFocus()
|
|
|
|
|| ! prev->isVisible()
|
|
|
|
|| prev->isWindow() );
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-17 02:57:08 +01:00
|
|
|
FFocusEvent out (fc::FocusOut_Event);
|
|
|
|
out.setFocusType(fc::FocusPreviousWidget);
|
2015-05-23 13:35:12 +02:00
|
|
|
FApplication::sendEvent(this, &out);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( out.isAccepted() )
|
|
|
|
{
|
|
|
|
if ( prev == this )
|
|
|
|
return false;
|
|
|
|
prev->setFocus();
|
2016-01-17 02:57:08 +01:00
|
|
|
FFocusEvent in (fc::FocusIn_Event);
|
|
|
|
in.setFocusType(fc::FocusPreviousWidget);
|
2015-05-23 13:35:12 +02:00
|
|
|
FApplication::sendEvent(prev, &in);
|
|
|
|
if ( in.isAccepted() )
|
|
|
|
{
|
|
|
|
this->draw();
|
|
|
|
prev->draw();
|
|
|
|
updateTerminal();
|
|
|
|
flush_out();
|
|
|
|
}
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
break;
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
}
|
|
|
|
while ( iter != begin );
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// public methods of FWidget
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FWidget* FWidget::getRootWidget() const
|
|
|
|
{
|
|
|
|
FWidget* obj = const_cast<FWidget*>(this);
|
2016-07-03 20:08:39 +02:00
|
|
|
FWidget* p_obj = getParentWidget();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
while ( ! obj->isRootWidget() && p_obj )
|
|
|
|
{
|
|
|
|
obj = p_obj;
|
2016-07-03 20:08:39 +02:00
|
|
|
p_obj = p_obj->getParentWidget();
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2015-10-17 05:56:02 +02:00
|
|
|
FWidget* FWidget::getMainWidget()
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
FWidget* main_widget = static_cast<FWidget*>(FApplication::main_widget);
|
|
|
|
return main_widget;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2015-10-17 05:56:02 +02:00
|
|
|
void FWidget::setMainWidget(FWidget* obj)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
FApplication* fapp = static_cast<FApplication*>(rootObject);
|
|
|
|
fapp->setMainWidget(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FWidget* FWidget::childWidgetAt (FWidget* p, int x, int y)
|
|
|
|
{
|
|
|
|
if ( p && p->hasChildren() )
|
|
|
|
{
|
|
|
|
FObject::object_list children;
|
|
|
|
FObject::object_list::const_iterator iter, end;
|
|
|
|
|
2015-09-20 05:44:50 +02:00
|
|
|
children = p->getChildren();
|
2015-05-23 13:35:12 +02:00
|
|
|
iter = children.begin();
|
|
|
|
end = children.end();
|
|
|
|
|
|
|
|
while ( iter != end )
|
|
|
|
{
|
|
|
|
FWidget* widget = static_cast<FWidget*>(*iter);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( widget->isEnabled()
|
|
|
|
&& widget->isVisible()
|
|
|
|
&& ! widget->isWindow()
|
|
|
|
&& widget->getGeometryGlobal().contains(x,y) )
|
|
|
|
{
|
|
|
|
FWidget* child = childWidgetAt(widget, x, y);
|
|
|
|
return (child != 0) ? child : widget;
|
|
|
|
}
|
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 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2015-10-17 19:40:43 +02:00
|
|
|
FWidget* FWidget::getFocusWidget() const
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
FWidget* focus_widget = static_cast<FWidget*>(FApplication::focus_widget);
|
|
|
|
return focus_widget;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2015-10-17 19:40:43 +02:00
|
|
|
void FWidget::setFocusWidget(FWidget* obj)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
FApplication::focus_widget = obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2015-10-17 05:56:02 +02:00
|
|
|
FWidget* FWidget::getClickedWidget()
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
FWidget* clicked_widget = static_cast<FWidget*>(FApplication::clicked_widget);
|
|
|
|
return clicked_widget;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2015-10-17 05:56:02 +02:00
|
|
|
void FWidget::setClickedWidget(FWidget* obj)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
FApplication::clicked_widget = obj;
|
|
|
|
}
|
|
|
|
|
2015-10-23 00:24:20 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FWidget* FWidget::getOpenMenu()
|
|
|
|
{
|
|
|
|
FWidget* open_menu = static_cast<FWidget*>(FApplication::open_menu);
|
|
|
|
return open_menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setOpenMenu(FWidget* obj)
|
|
|
|
{
|
|
|
|
FApplication::open_menu = obj;
|
|
|
|
}
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
int FWidget::numOfFocusableChildren()
|
|
|
|
{
|
|
|
|
FObject::object_list children;
|
|
|
|
FObject::object_list::const_iterator iter, end;
|
|
|
|
|
|
|
|
if ( ! this->hasChildren() )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
int num = 0;
|
2015-09-20 05:44:50 +02:00
|
|
|
children = this->getChildren();
|
2015-05-23 13:35:12 +02:00
|
|
|
iter = children.begin();
|
|
|
|
end = children.end();
|
|
|
|
|
|
|
|
while ( iter != end )
|
|
|
|
{
|
|
|
|
FWidget* widget = static_cast<FWidget*>(*iter);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +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;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FStatusBar* FWidget::statusBar()
|
|
|
|
{
|
|
|
|
if ( statusbar )
|
|
|
|
return statusbar;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-08-09 23:44:11 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FMenuBar* FWidget::menuBar()
|
|
|
|
{
|
|
|
|
if ( menubar )
|
|
|
|
return menubar;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-11-01 22:45:23 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setStatusbarMessage (FString msg)
|
|
|
|
{
|
|
|
|
statusbar_message = msg;
|
|
|
|
}
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
2015-09-22 04:18:20 +02:00
|
|
|
void FWidget::addCallback ( FString cb_signal
|
|
|
|
, FWidget::FCallback cb_handler
|
|
|
|
, 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 };
|
2015-09-22 04:18:20 +02:00
|
|
|
callbackObjects.push_back(obj);
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2015-09-22 04:18:20 +02:00
|
|
|
void FWidget::addCallback ( FString cb_signal
|
|
|
|
, FWidget* cb_instance
|
|
|
|
, FWidget::FMemberCallback cb_handler
|
|
|
|
, 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 };
|
2015-09-22 04:18:20 +02:00
|
|
|
memberCallbackObjects.push_back(obj);
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::delCallback (FWidget::FCallback cb_handler)
|
|
|
|
{
|
|
|
|
FWidget::CallbackObjects::iterator iter;
|
|
|
|
|
|
|
|
// delete a cb_handler function pointer
|
|
|
|
if ( callbackObjects.empty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
iter = callbackObjects.begin();
|
|
|
|
|
|
|
|
while ( iter != callbackObjects.end() )
|
|
|
|
{
|
|
|
|
if ( iter->cb_handler == cb_handler )
|
2015-09-22 04:18:20 +02:00
|
|
|
iter = callbackObjects.erase(iter);
|
2015-05-23 13:35:12 +02:00
|
|
|
else
|
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::delCallback (FWidget* cb_instance)
|
|
|
|
{
|
|
|
|
FWidget::MemberCallbackObjects::iterator iter;
|
|
|
|
|
|
|
|
// delete all member function pointer from cb_instance
|
|
|
|
if ( memberCallbackObjects.empty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
iter = memberCallbackObjects.begin();
|
|
|
|
|
|
|
|
while ( iter != memberCallbackObjects.end() )
|
|
|
|
{
|
|
|
|
if ( iter->cb_instance == cb_instance )
|
|
|
|
iter = memberCallbackObjects.erase(iter);
|
|
|
|
else
|
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-30 14:34:13 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FWidget::delCallbacks()
|
|
|
|
{
|
|
|
|
// delete all callbacks from this widget
|
|
|
|
memberCallbackObjects.clear(); // member function pointer
|
|
|
|
callbackObjects.clear(); // function pointer
|
|
|
|
}
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::emitCallback (FString emit_signal)
|
|
|
|
{
|
|
|
|
// member function pointer
|
|
|
|
if ( ! memberCallbackObjects.empty() )
|
|
|
|
{
|
|
|
|
FWidget::MemberCallbackObjects::const_iterator m_iter, m_end;
|
|
|
|
m_iter = memberCallbackObjects.begin();
|
|
|
|
m_end = memberCallbackObjects.end();
|
|
|
|
|
|
|
|
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
|
|
|
|
if ( ! callbackObjects.empty() )
|
|
|
|
{
|
|
|
|
FWidget::CallbackObjects::const_iterator iter, end;
|
|
|
|
iter = callbackObjects.begin();
|
|
|
|
end = callbackObjects.end();
|
|
|
|
|
|
|
|
while ( iter != end )
|
|
|
|
{
|
|
|
|
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-07-12 23:35:33 +02:00
|
|
|
if ( widget
|
|
|
|
&& 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() )
|
|
|
|
{
|
|
|
|
terminal_updates = false;
|
|
|
|
setColor (wc.term_fg, wc.term_bg);
|
2016-08-06 21:43:39 +02:00
|
|
|
clearArea();
|
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;
|
|
|
|
default_char.code = ' ';
|
|
|
|
default_char.fg_color = fc::Black;
|
|
|
|
default_char.bg_color = fc::Black;
|
|
|
|
default_char.bold = 0;
|
|
|
|
default_char.dim = 0;
|
|
|
|
default_char.italic = 0;
|
|
|
|
default_char.underline = 0;
|
|
|
|
default_char.blink = 0;
|
|
|
|
default_char.reverse = 0;
|
|
|
|
default_char.standout = 0;
|
|
|
|
default_char.invisible = 0;
|
|
|
|
default_char.protect = 0;
|
|
|
|
default_char.crossed_out = 0;
|
|
|
|
default_char.dbl_underline = 0;
|
|
|
|
default_char.alt_charset = 0;
|
|
|
|
default_char.pc_charset = 0;
|
2016-08-14 23:27:34 +02:00
|
|
|
default_char.transparent = 0;
|
|
|
|
default_char.trans_shadow = 0;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
if ( window_list && ! window_list->empty() )
|
|
|
|
{
|
|
|
|
widgetList::const_iterator iter, end;
|
|
|
|
iter = window_list->begin();
|
|
|
|
end = window_list->end();
|
|
|
|
|
|
|
|
while ( iter != end )
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-08-09 23:44:11 +02:00
|
|
|
if ( menubar && vmenubar )
|
|
|
|
{
|
|
|
|
int w = vmenubar->width;
|
|
|
|
int h = vmenubar->height;
|
|
|
|
std::fill_n (vmenubar->text, w * h, default_char);
|
|
|
|
menubar->redraw();
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( statusbar && vstatusbar )
|
|
|
|
{
|
|
|
|
int w = vstatusbar->width;
|
|
|
|
int h = vstatusbar->height;
|
|
|
|
std::fill_n (vstatusbar->text, w * h, default_char);
|
|
|
|
statusbar->redraw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// draw child elements
|
|
|
|
if ( this->hasChildren() )
|
|
|
|
{
|
|
|
|
FObject::object_list children;
|
|
|
|
FObject::object_list::const_iterator iter, end;
|
|
|
|
|
2015-09-20 05:44:50 +02:00
|
|
|
children = this->getChildren();
|
2015-05-23 13:35:12 +02:00
|
|
|
iter = children.begin();
|
|
|
|
end = children.end();
|
|
|
|
|
|
|
|
while ( iter != end )
|
|
|
|
{
|
|
|
|
FWidget* widget = static_cast<FWidget*>(*iter);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( widget->isVisible() && ! widget->isWindow() )
|
|
|
|
widget->redraw();
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( isRootWidget() )
|
|
|
|
terminal_updates = true;
|
|
|
|
|
|
|
|
if ( redraw_root_widget == this )
|
|
|
|
{
|
|
|
|
updateTerminal();
|
|
|
|
flush_out();
|
|
|
|
redraw_root_widget = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::resize()
|
|
|
|
{
|
|
|
|
if ( isRootWidget() && openConsole() == 0 )
|
|
|
|
{
|
|
|
|
getTermGeometry();
|
|
|
|
closeConsole();
|
|
|
|
resizeVTerm();
|
|
|
|
resizeArea (vdesktop);
|
2016-05-16 23:36:13 +02:00
|
|
|
|
2015-08-09 23:44:11 +02:00
|
|
|
if ( menubar )
|
|
|
|
{
|
|
|
|
menubar->setGeometry(1, 1, width, 1, false);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-08-09 23:44:11 +02:00
|
|
|
if ( vmenubar )
|
|
|
|
resizeArea(vmenubar);
|
|
|
|
}
|
2016-05-16 23:36:13 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( statusbar )
|
|
|
|
{
|
|
|
|
statusbar->setGeometry(1, height, width, 1, false);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( vstatusbar )
|
|
|
|
resizeArea(vstatusbar);
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
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
|
2015-06-22 00:26:24 +02:00
|
|
|
double_flatline_mask.top.resize (uLong(width), false);
|
|
|
|
double_flatline_mask.right.resize (uLong(height), false);
|
|
|
|
double_flatline_mask.bottom.resize (uLong(width), false);
|
|
|
|
double_flatline_mask.left.resize (uLong(height), false);
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::show()
|
|
|
|
{
|
|
|
|
if ( ! visible )
|
|
|
|
return;
|
|
|
|
|
2016-08-21 21:27:44 +02:00
|
|
|
if ( getMainWidget() == this && ! (NewFont || VGAFont) )
|
2015-05-23 13:35:12 +02:00
|
|
|
init_consoleCharMap();
|
|
|
|
|
|
|
|
if ( ! show_root_widget )
|
|
|
|
{
|
|
|
|
terminal_updates = false;
|
|
|
|
show_root_widget = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
draw();
|
|
|
|
shown = true;
|
|
|
|
|
|
|
|
if ( this->hasChildren() )
|
|
|
|
{
|
|
|
|
FObject::object_list children;
|
|
|
|
FObject::object_list::const_iterator iter, end;
|
|
|
|
|
2015-09-20 05:44:50 +02:00
|
|
|
children = this->getChildren();
|
2015-05-23 13:35:12 +02:00
|
|
|
iter = children.begin();
|
|
|
|
end = children.end();
|
|
|
|
|
|
|
|
while ( iter != end )
|
|
|
|
{
|
|
|
|
FWidget* widget = static_cast<FWidget*>(*iter);
|
|
|
|
widget->show();
|
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( show_root_widget && show_root_widget == this )
|
|
|
|
{
|
|
|
|
terminal_updates = true;
|
|
|
|
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-08-20 22:27:23 +02:00
|
|
|
if ( ! isDialog()
|
|
|
|
&& 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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-29 21:10:50 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FWidget::setEnable (bool on)
|
|
|
|
{
|
|
|
|
return enable = (on) ? true : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FWidget::setEnable()
|
|
|
|
{
|
|
|
|
return setEnable(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FWidget::unsetEnable()
|
|
|
|
{
|
|
|
|
return setEnable(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FWidget::setDisable()
|
|
|
|
{
|
|
|
|
return setEnable(false);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
|
|
|
FObject::object_list children;
|
|
|
|
FObject::object_list::const_iterator iter, end;
|
|
|
|
|
|
|
|
if ( ! this->hasChildren() )
|
|
|
|
return false;
|
|
|
|
|
2015-09-20 05:44:50 +02:00
|
|
|
children = this->getChildren();
|
2015-05-23 13:35:12 +02:00
|
|
|
iter = children.begin();
|
|
|
|
end = children.end();
|
|
|
|
|
|
|
|
while ( iter != end )
|
|
|
|
{
|
|
|
|
FWidget* widget = static_cast<FWidget*>(*iter);
|
2016-05-16 23:26:04 +02:00
|
|
|
|
|
|
|
if ( widget->isEnabled()
|
|
|
|
&& widget->acceptFocus()
|
|
|
|
&& ! widget->isMenu() )
|
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
|
|
|
{
|
2015-07-13 00:15:57 +02:00
|
|
|
if ( ! widget->focusFirstChild() && widget->isWindow() )
|
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
|
|
|
// prefix increment (++) is faster
|
|
|
|
// than postfix for non primitive type
|
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-05-22 19:18:16 +02:00
|
|
|
bool FWidget::focusLastChild()
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
FObject::object_list children;
|
|
|
|
FObject::object_list::const_iterator iter, begin;
|
|
|
|
|
|
|
|
if ( ! this->hasChildren() )
|
|
|
|
return false;
|
|
|
|
|
2015-09-20 05:44:50 +02:00
|
|
|
children = this->getChildren();
|
2015-05-23 13:35:12 +02:00
|
|
|
iter = children.end();
|
|
|
|
begin = children.begin();
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
--iter;
|
|
|
|
FWidget* widget = static_cast<FWidget*>(*iter);
|
2016-05-16 23:26:04 +02:00
|
|
|
|
|
|
|
if ( widget->isEnabled()
|
|
|
|
&& widget->acceptFocus()
|
|
|
|
&& ! widget->isMenu() )
|
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
|
|
|
{
|
2015-07-13 00:15:57 +02:00
|
|
|
if ( ! widget->focusLastChild() && widget->isWindow() )
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while ( iter != begin );
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-06-19 23:18:53 +02:00
|
|
|
bool FWidget::setFocus (bool on)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
FWindow* window;
|
|
|
|
|
|
|
|
if ( ! enable )
|
|
|
|
return false;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( on == focus )
|
|
|
|
return true;
|
|
|
|
|
2016-06-19 20:32:03 +02:00
|
|
|
// set widget focus
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( on && ! focus )
|
|
|
|
{
|
2016-06-19 20:32:03 +02:00
|
|
|
int focusable_children = numOfFocusableChildren();
|
2016-07-03 20:08:39 +02:00
|
|
|
|
2016-08-21 21:27:44 +02:00
|
|
|
if ( FWidget::getFocusWidget() )
|
2015-05-23 13:35:12 +02:00
|
|
|
FWidget::getFocusWidget()->unsetFocus();
|
2016-07-03 20:08:39 +02:00
|
|
|
|
2016-06-19 20:32:03 +02:00
|
|
|
if ( (!isDialog() && focusable_children == 0)
|
|
|
|
|| (isDialog() && focusable_children == 1) )
|
|
|
|
{
|
2015-05-23 13:35:12 +02:00
|
|
|
FWidget::setFocusWidget(this);
|
2016-06-19 20:32:03 +02:00
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
window = FWindow::getWindowWidget(this);
|
|
|
|
|
2016-06-19 20:32:03 +02:00
|
|
|
// set window focus
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( on && window )
|
|
|
|
{
|
|
|
|
if ( ! window->isActiveWindow() )
|
|
|
|
{
|
|
|
|
bool has_raised = window->raiseWindow();
|
|
|
|
FWindow::setActiveWindow(window);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-09-15 23:07:24 +02:00
|
|
|
if ( has_raised && window->isVisible() && window->isShown() )
|
2015-05-23 13:35:12 +02:00
|
|
|
window->redraw();
|
|
|
|
}
|
2016-07-27 23:47:12 +02:00
|
|
|
window->setWindowFocusWidget(this);
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return focus = (on) ? true : false;
|
|
|
|
}
|
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setColor (register short fg, register short bg)
|
|
|
|
{
|
|
|
|
// Changes colors
|
|
|
|
next_attribute.fg_color = fg;
|
|
|
|
next_attribute.bg_color = bg;
|
|
|
|
}
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setX (int x, bool adjust)
|
|
|
|
{
|
|
|
|
if ( xpos == x && widgetSize.getX() == x )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ( ! isWindow() )
|
|
|
|
{
|
|
|
|
(x > 0) ? xpos = x : xpos = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
xpos = x;
|
|
|
|
|
|
|
|
widgetSize.setX(xpos);
|
|
|
|
adjustWidgetSize.setX(xpos);
|
|
|
|
adjustWidgetSizeShadow = adjustWidgetSize + shadow;
|
|
|
|
adjustWidgetSizeGlobal.setX(xpos + xmin - 1);
|
|
|
|
adjustWidgetSizeGlobalShadow = adjustWidgetSizeGlobal + shadow;
|
|
|
|
|
|
|
|
if ( adjust )
|
|
|
|
adjustSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setY (int y, bool adjust)
|
|
|
|
{
|
|
|
|
if ( ypos == y && widgetSize.getY() == y )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ( ! isWindow() )
|
|
|
|
{
|
|
|
|
(y > 0) ? ypos = y : ypos = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ypos = y;
|
|
|
|
|
|
|
|
widgetSize.setY(ypos);
|
|
|
|
adjustWidgetSize.setY(ypos);
|
|
|
|
adjustWidgetSizeShadow = adjustWidgetSize + shadow;
|
|
|
|
adjustWidgetSizeGlobal.setY(ypos + ymin - 1);
|
|
|
|
adjustWidgetSizeGlobalShadow = adjustWidgetSizeGlobal + shadow;
|
|
|
|
|
|
|
|
if ( adjust )
|
|
|
|
adjustSize();
|
|
|
|
}
|
|
|
|
|
2015-09-27 16:00:13 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setPos (int x, int y, bool adjust)
|
|
|
|
{
|
2015-09-28 04:31:29 +02:00
|
|
|
if ( xpos == x && widgetSize.getX() == x
|
|
|
|
&& ypos == y && widgetSize.getY() == y )
|
|
|
|
{
|
2015-09-27 16:00:13 +02:00
|
|
|
return;
|
2015-09-28 04:31:29 +02:00
|
|
|
}
|
2015-09-27 16:00:13 +02:00
|
|
|
|
|
|
|
if ( ! isWindow() )
|
|
|
|
{
|
|
|
|
(x > 0) ? xpos = x : xpos = 1;
|
|
|
|
(y > 0) ? ypos = y : ypos = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xpos = x;
|
|
|
|
ypos = y;
|
|
|
|
}
|
|
|
|
|
|
|
|
widgetSize.setPos(xpos,ypos);
|
|
|
|
adjustWidgetSize.setPos(xpos,ypos);
|
|
|
|
adjustWidgetSizeShadow = adjustWidgetSize + shadow;
|
|
|
|
adjustWidgetSizeGlobal.setPos(xpos + xmin - 1, ypos + ymin - 1);
|
|
|
|
adjustWidgetSizeGlobalShadow = adjustWidgetSizeGlobal + shadow;
|
|
|
|
|
|
|
|
if ( adjust )
|
|
|
|
adjustSize();
|
|
|
|
}
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setWidth (int w, bool adjust)
|
|
|
|
{
|
|
|
|
if ( width == w && widgetSize.getWidth() == w )
|
|
|
|
return;
|
|
|
|
|
|
|
|
(w > 0) ? width = w : width = 1;
|
|
|
|
|
|
|
|
widgetSize.setWidth(width);
|
|
|
|
adjustWidgetSize.setWidth(width);
|
|
|
|
adjustWidgetSizeShadow = adjustWidgetSize + shadow;
|
|
|
|
adjustWidgetSizeGlobal.setWidth(width);
|
|
|
|
adjustWidgetSizeGlobalShadow = adjustWidgetSizeGlobal + shadow;
|
|
|
|
|
|
|
|
if ( adjust )
|
|
|
|
adjustSize();
|
2015-06-21 23:27:10 +02:00
|
|
|
|
2015-06-22 00:26:24 +02:00
|
|
|
double_flatline_mask.top.resize (uLong(width), false);
|
|
|
|
double_flatline_mask.bottom.resize (uLong(width), false);
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setHeight (int h, bool adjust)
|
|
|
|
{
|
|
|
|
if ( height == h && widgetSize.getHeight() == h )
|
|
|
|
return;
|
|
|
|
|
|
|
|
(h > 0) ? height = h : height = 1;
|
|
|
|
|
|
|
|
widgetSize.setHeight(height);
|
|
|
|
adjustWidgetSize.setHeight(height);
|
|
|
|
adjustWidgetSizeShadow = adjustWidgetSize + shadow;
|
|
|
|
adjustWidgetSizeGlobal.setHeight(height);
|
|
|
|
adjustWidgetSizeGlobalShadow = adjustWidgetSizeGlobal + shadow;
|
|
|
|
|
|
|
|
if ( adjust )
|
|
|
|
adjustSize();
|
2015-06-21 23:27:10 +02:00
|
|
|
|
2015-06-22 00:26:24 +02:00
|
|
|
double_flatline_mask.right.resize (uLong(height), false);
|
|
|
|
double_flatline_mask.left.resize (uLong(height), false);
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setTopPadding (int t, bool adjust)
|
|
|
|
{
|
|
|
|
if ( top_padding == t )
|
|
|
|
return;
|
2016-05-16 21:11:32 +02:00
|
|
|
|
|
|
|
(t > 0) ? top_padding = t : top_padding = 0;
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( adjust )
|
2016-05-16 21:11:32 +02:00
|
|
|
{
|
|
|
|
if ( isRootWidget() )
|
|
|
|
{
|
|
|
|
FWidget* r_obj = rootObject;
|
|
|
|
r_obj->client_ymin = 1 + r_obj->top_padding;
|
|
|
|
adjustSizeGlobal();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
adjustSize();
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setLeftPadding (int l, bool adjust)
|
|
|
|
{
|
|
|
|
if ( left_padding == l )
|
|
|
|
return;
|
2016-05-16 21:11:32 +02:00
|
|
|
|
|
|
|
(l > 0) ? left_padding = l : left_padding = 0;
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( adjust )
|
2016-05-16 21:11:32 +02:00
|
|
|
{
|
|
|
|
if ( isRootWidget() )
|
|
|
|
{
|
|
|
|
FWidget* r_obj = rootObject;
|
|
|
|
r_obj->client_xmin = 1 + r_obj->left_padding;
|
|
|
|
adjustSizeGlobal();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
adjustSize();
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setBottomPadding (int b, bool adjust)
|
|
|
|
{
|
|
|
|
if ( bottom_padding == b )
|
|
|
|
return;
|
2016-05-16 21:11:32 +02:00
|
|
|
|
|
|
|
(b > 0) ? bottom_padding = b : bottom_padding = 0;
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( adjust )
|
2016-05-16 21:11:32 +02:00
|
|
|
{
|
|
|
|
if ( isRootWidget() )
|
|
|
|
{
|
|
|
|
FWidget* r_obj = rootObject;
|
|
|
|
r_obj->client_ymax = r_obj->height - r_obj->bottom_padding;
|
|
|
|
adjustSizeGlobal();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
adjustSize();
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setRightPadding (int r, bool adjust)
|
|
|
|
{
|
|
|
|
if ( right_padding == r )
|
|
|
|
return;
|
2016-05-16 21:11:32 +02:00
|
|
|
|
|
|
|
(r > 0) ? right_padding = r : right_padding = 0;
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( adjust )
|
2016-05-16 21:11:32 +02:00
|
|
|
{
|
|
|
|
if ( isRootWidget() )
|
|
|
|
{
|
|
|
|
FWidget* r_obj = rootObject;
|
|
|
|
r_obj->client_xmax = r_obj->width - r_obj->right_padding;
|
|
|
|
adjustSizeGlobal();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
adjustSize();
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::getTermGeometry()
|
|
|
|
{
|
2016-05-16 21:11:32 +02:00
|
|
|
FWidget* r_obj = rootObject;
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( openConsole() == 0 )
|
|
|
|
{
|
|
|
|
getTermSize();
|
|
|
|
closeConsole();
|
|
|
|
}
|
2016-05-16 23:26:04 +02:00
|
|
|
|
2016-05-16 21:11:32 +02:00
|
|
|
r_obj->width = term->getWidth();
|
|
|
|
r_obj->height = term->getHeight();
|
|
|
|
r_obj->xmin = 1;
|
|
|
|
r_obj->ymin = 1;
|
|
|
|
r_obj->xmax = r_obj->width;
|
|
|
|
r_obj->ymax = r_obj->height;
|
|
|
|
r_obj->client_xmin = 1 + r_obj->left_padding;
|
|
|
|
r_obj->client_ymin = 1 + r_obj->top_padding;
|
|
|
|
r_obj->client_xmax = r_obj->width - r_obj->right_padding;
|
|
|
|
r_obj->client_ymax = r_obj->height - r_obj->bottom_padding;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setTermGeometry (int w, int h)
|
|
|
|
{
|
|
|
|
// Set xterm size to w x h
|
|
|
|
if ( xterm )
|
|
|
|
{
|
2016-05-16 21:11:32 +02:00
|
|
|
FWidget* r_obj = rootObject;
|
|
|
|
r_obj->xpos = 1;
|
|
|
|
r_obj->ypos = 1;
|
|
|
|
r_obj->width = w; // columns
|
|
|
|
r_obj->height = h; // lines
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
setTermSize (w, h);
|
|
|
|
getTermGeometry();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setGeometry (int x, int y, int w, int h, bool adjust)
|
|
|
|
{
|
|
|
|
if ( xpos == x && ypos == y && width == w && height == h )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ( ! isWindow() )
|
|
|
|
{
|
|
|
|
(x > 0) ? xpos = x : xpos = 1;
|
|
|
|
(y > 0) ? ypos = y : ypos = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xpos = x;
|
|
|
|
ypos = y;
|
|
|
|
}
|
|
|
|
(w > 0) ? width = w : width = 1;
|
|
|
|
(h > 0) ? height = h : height = 1;
|
|
|
|
|
|
|
|
client_xmin = xpos + xmin - 1 + left_padding;
|
|
|
|
client_ymin = ypos + ymin - 1 + top_padding;
|
|
|
|
client_xmax = xpos + xmin - 2 + width - right_padding;
|
|
|
|
client_ymax = ypos + ymin - 2 + height - bottom_padding;
|
|
|
|
|
|
|
|
widgetSize.setRect(xpos, ypos, width, height);
|
|
|
|
adjustWidgetSize.setRect(xpos, ypos, width, height);
|
|
|
|
adjustWidgetSizeShadow = adjustWidgetSize + shadow;
|
2015-09-22 04:18:20 +02:00
|
|
|
adjustWidgetSizeGlobal.setRect ( xpos + xmin - 1
|
2015-09-28 04:31:29 +02:00
|
|
|
, ypos + ymin - 1
|
|
|
|
, width
|
|
|
|
, height );
|
2015-05-23 13:35:12 +02:00
|
|
|
adjustWidgetSizeGlobalShadow = adjustWidgetSizeGlobal + shadow;
|
|
|
|
|
|
|
|
if ( adjust )
|
|
|
|
adjustSize();
|
2015-06-21 23:27:10 +02:00
|
|
|
|
2015-06-22 00:26:24 +02:00
|
|
|
double_flatline_mask.top.resize (uLong(width), false);
|
|
|
|
double_flatline_mask.right.resize (uLong(height), false);
|
|
|
|
double_flatline_mask.bottom.resize (uLong(width), false);
|
|
|
|
double_flatline_mask.left.resize (uLong(height), false);
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::move (int x, int y)
|
|
|
|
{
|
|
|
|
if ( x == xpos && y == ypos )
|
|
|
|
return;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
// Avoid to move widget completely outside the terminal
|
|
|
|
if ( x+width < 1 || x > term->getWidth() || y < 1 || y > term->getHeight() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
xpos = x;
|
|
|
|
ypos = y;
|
2016-07-31 20:25:25 +02:00
|
|
|
widgetSize.setPos(x,y);
|
|
|
|
adjustWidgetSize.setPos(x,y);
|
2015-05-23 13:35:12 +02:00
|
|
|
adjustWidgetSizeShadow = adjustWidgetSize + shadow;
|
2016-07-31 20:25:25 +02:00
|
|
|
adjustWidgetSizeGlobal.setPos(x + xmin - 1, y + ymin - 1);
|
2015-05-23 13:35:12 +02:00
|
|
|
adjustWidgetSizeGlobalShadow = adjustWidgetSizeGlobal + shadow;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FWidget::setCursor()
|
|
|
|
{
|
|
|
|
FPoint* wcursor = &widgetCursorPosition;
|
|
|
|
|
|
|
|
if ( isCursorInside() )
|
|
|
|
{
|
|
|
|
setTermXY (wcursor->getX()-1, wcursor->getY()-1);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FWidget::setCursorPos (register int x, register int y)
|
|
|
|
{
|
|
|
|
widgetCursorPosition.setPoint(x,y);
|
|
|
|
|
|
|
|
if ( isCursorInside() )
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-08-06 21:43:39 +02:00
|
|
|
void FWidget::clearArea()
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
term_area* area;
|
|
|
|
FWindow* area_widget;
|
2016-08-14 23:27:34 +02:00
|
|
|
FOptiAttr::char_data default_char;
|
2016-01-08 01:00:05 +01:00
|
|
|
|
|
|
|
default_char.code = ' ';
|
|
|
|
default_char.fg_color = next_attribute.fg_color;
|
|
|
|
default_char.bg_color = next_attribute.bg_color;
|
|
|
|
default_char.bold = next_attribute.bold;
|
|
|
|
default_char.dim = next_attribute.dim;
|
|
|
|
default_char.italic = next_attribute.italic;
|
|
|
|
default_char.underline = next_attribute.underline;
|
|
|
|
default_char.blink = next_attribute.blink;
|
|
|
|
default_char.reverse = next_attribute.reverse;
|
|
|
|
default_char.standout = next_attribute.standout;
|
|
|
|
default_char.invisible = next_attribute.invisible;
|
|
|
|
default_char.protect = next_attribute.protect;
|
|
|
|
default_char.crossed_out = next_attribute.crossed_out;
|
|
|
|
default_char.dbl_underline = next_attribute.dbl_underline;
|
|
|
|
default_char.alt_charset = next_attribute.alt_charset;
|
|
|
|
default_char.pc_charset = next_attribute.pc_charset;
|
2016-08-14 23:27:34 +02:00
|
|
|
default_char.transparent = next_attribute.transparent;
|
|
|
|
default_char.trans_shadow = next_attribute.trans_shadow;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
area_widget = FWindow::getWindowWidget(this);
|
|
|
|
|
|
|
|
if ( area_widget )
|
|
|
|
area = area_widget->getVWin();
|
|
|
|
else
|
|
|
|
area = vdesktop;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( ! area )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ( area->right_shadow == 0 )
|
|
|
|
{
|
|
|
|
int area_size = area->width * area->height;
|
|
|
|
std::fill_n (area->text, area_size, default_char);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (int y=0; y < area->height; y++)
|
|
|
|
{
|
|
|
|
int pos = y * (area->width + area->right_shadow);
|
|
|
|
std::fill_n (&area->text[pos], area->width, default_char);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i=0; i < area->height; i++)
|
|
|
|
{
|
2016-08-14 23:27:34 +02:00
|
|
|
uInt w = uInt(area->width + area->right_shadow);
|
2015-05-23 13:35:12 +02:00
|
|
|
area->changes[i].xmin = 0;
|
2016-08-14 23:27:34 +02:00
|
|
|
area->changes[i].xmax = w - 1;
|
|
|
|
|
|
|
|
if ( default_char.transparent || default_char.trans_shadow )
|
|
|
|
area->changes[i].trans_count = w;
|
|
|
|
else
|
|
|
|
area->changes[i].trans_count = 0;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-08-06 21:43:39 +02:00
|
|
|
updateVTerm (area);
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::drawShadow()
|
|
|
|
{
|
2016-01-08 01:00:05 +01:00
|
|
|
FOptiAttr::char_data ch;
|
2015-05-23 13:35:12 +02:00
|
|
|
int x1, x2, y1, y2;
|
2016-01-24 14:53:09 +01:00
|
|
|
bool trans_shadow = ((flags & fc::trans_shadow) != 0);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2015-10-11 21:56:16 +02:00
|
|
|
if ( isMonochron() && ! trans_shadow )
|
|
|
|
return;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-08-21 21:27:44 +02:00
|
|
|
if ( (Encoding == fc::VT100 && ! (trans_shadow || isTeraTerm()) )
|
2015-10-11 21:56:16 +02:00
|
|
|
|| (Encoding == fc::ASCII && ! trans_shadow) )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
clearShadow();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
x1 = xpos+xmin-1;
|
|
|
|
x2 = xpos+xmin-2+width;
|
|
|
|
y1 = ypos+ymin-1;
|
|
|
|
y2 = ypos+ymin-2+height;
|
|
|
|
|
|
|
|
if ( trans_shadow )
|
|
|
|
{
|
|
|
|
// transparent shadow
|
|
|
|
if ( x2 < xmax )
|
|
|
|
{
|
|
|
|
gotoxy (x2+1, y1);
|
2015-10-11 21:56:16 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
for (int x=1; x <= 2; x++)
|
|
|
|
{
|
|
|
|
ch = getCoveredCharacter (x2+x, y1, this);
|
|
|
|
setColor (ch.fg_color, ch.bg_color);
|
2016-01-08 01:00:05 +01:00
|
|
|
|
2015-10-11 21:56:16 +02:00
|
|
|
if ( ch.bold )
|
2016-01-08 01:00:05 +01:00
|
|
|
setBold (true);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
if ( ch.dim )
|
|
|
|
setDim (true);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
if ( ch.italic )
|
|
|
|
setItalic (true);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-10-11 21:56:16 +02:00
|
|
|
if ( ch.underline )
|
2016-01-08 01:00:05 +01:00
|
|
|
setUnderline (true);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
if ( ch.blink )
|
|
|
|
setBlink (true);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
if ( ch.reverse )
|
|
|
|
setReverse (true);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
if ( ch.standout )
|
|
|
|
setStandout (true);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
if ( ch.invisible )
|
|
|
|
setInvisible (true);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
if ( ch.protect )
|
|
|
|
setProtected (true);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
if ( ch.crossed_out )
|
|
|
|
setCrossedOut (true);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
if ( ch.dbl_underline )
|
|
|
|
setDoubleUnderline (true);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
if ( ch.alt_charset )
|
|
|
|
setAltCharset (true);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
if ( ch.pc_charset )
|
|
|
|
setPCcharset (true);
|
2015-10-11 21:56:16 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
print (ch.code);
|
2015-10-11 21:56:16 +02:00
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
setNormal();
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
2015-10-11 21:56:16 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
setColor (wc.shadow_bg, wc.shadow_fg);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
for (int i=1; i < height && y1+i <= ymax; i++)
|
|
|
|
{
|
|
|
|
gotoxy (x2+1, y1+i);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
for (int x=1; x <= 2; x++)
|
|
|
|
{
|
|
|
|
ch = getCoveredCharacter (x2+x, y1+i, this);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( ch.code == fc::LowerHalfBlock
|
|
|
|
|| ch.code == fc::UpperHalfBlock
|
|
|
|
|| ch.code == fc::LeftHalfBlock
|
|
|
|
|| ch.code == fc::RightHalfBlock
|
|
|
|
|| ch.code == fc::FullBlock )
|
|
|
|
print (' ');
|
|
|
|
else
|
|
|
|
print (ch.code);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( y2 < ymax )
|
|
|
|
{
|
|
|
|
gotoxy (x1, y2+1);
|
2015-10-11 21:56:16 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
for (int x=0; x <= 1; x++)
|
|
|
|
{
|
|
|
|
ch = getCoveredCharacter (x1+x, y2+1, this);
|
|
|
|
setColor (ch.fg_color, ch.bg_color);
|
2016-01-08 01:00:05 +01:00
|
|
|
|
2015-10-11 21:56:16 +02:00
|
|
|
if ( ch.bold )
|
2016-01-08 01:00:05 +01:00
|
|
|
setBold (true);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
if ( ch.dim )
|
|
|
|
setDim (true);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
if ( ch.italic )
|
|
|
|
setItalic (true);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-10-11 21:56:16 +02:00
|
|
|
if ( ch.underline )
|
2016-01-08 01:00:05 +01:00
|
|
|
setUnderline (true);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
if ( ch.blink )
|
|
|
|
setBlink (true);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
if ( ch.reverse )
|
|
|
|
setReverse (true);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
if ( ch.standout )
|
|
|
|
setStandout (true);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
if ( ch.invisible )
|
|
|
|
setInvisible (true);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
if ( ch.protect )
|
|
|
|
setProtected (true);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
if ( ch.crossed_out )
|
|
|
|
setCrossedOut (true);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
if ( ch.dbl_underline )
|
|
|
|
setDoubleUnderline (true);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
if ( ch.alt_charset )
|
|
|
|
setAltCharset (true);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
if ( ch.pc_charset )
|
|
|
|
setPCcharset (true);
|
2015-10-11 21:56:16 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
print (ch.code);
|
2016-01-08 01:00:05 +01:00
|
|
|
setNormal();
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
2015-10-11 21:56:16 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
setColor (wc.shadow_bg, wc.shadow_fg);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-09-24 00:41:43 +02:00
|
|
|
for (int i=2; i <= width+1 && x1+i <= xmax; i++)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
ch = getCoveredCharacter (x1+i, y2+1, this);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( ch.code == fc::LowerHalfBlock
|
|
|
|
|| ch.code == fc::UpperHalfBlock
|
|
|
|
|| ch.code == fc::LeftHalfBlock
|
|
|
|
|| ch.code == fc::RightHalfBlock
|
|
|
|
|| ch.code == fc::FullBlock )
|
|
|
|
print (' ');
|
|
|
|
else
|
|
|
|
print (ch.code);
|
|
|
|
}
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-10-11 21:56:16 +02:00
|
|
|
if ( isMonochron() )
|
|
|
|
setReverse(false);
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-08-14 23:27:34 +02:00
|
|
|
// non-transparent shadow
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( x2 < xmax )
|
|
|
|
{
|
2015-11-16 00:43:53 +01:00
|
|
|
int block;
|
2015-05-23 13:35:12 +02:00
|
|
|
gotoxy (x2+1, y1);
|
|
|
|
ch = getCoveredCharacter (x2+1, y1, this);
|
|
|
|
setColor (wc.shadow_fg, ch.bg_color);
|
2015-10-06 05:09:18 +02:00
|
|
|
|
|
|
|
if ( isTeraTerm() )
|
|
|
|
{
|
|
|
|
block = 0xdb; // █
|
|
|
|
print (0xdc); // ▄
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
block = fc::FullBlock; // █
|
|
|
|
print (fc::LowerHalfBlock); // ▄
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
for (int i=1; i < height && y1+i <= ymax; i++)
|
|
|
|
{
|
|
|
|
gotoxy (x2+1, y1+i);
|
2015-10-06 05:09:18 +02:00
|
|
|
print (block); // █
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( y2 < ymax )
|
|
|
|
{
|
|
|
|
gotoxy (x1+1, y2+1);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
for (int i=1; i <= width && x1+i <= xmax; i++)
|
|
|
|
{
|
|
|
|
ch = getCoveredCharacter (x1+i, y2+1, this);
|
2016-01-08 01:00:05 +01:00
|
|
|
setColor (wc.shadow_fg, ch.bg_color);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-10-06 05:09:18 +02:00
|
|
|
if ( isTeraTerm() )
|
|
|
|
print (0xdf); // ▀
|
|
|
|
else
|
|
|
|
print (fc::UpperHalfBlock); // ▀
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::clearShadow()
|
|
|
|
{
|
2016-01-08 01:00:05 +01:00
|
|
|
FOptiAttr::char_data ch;
|
2015-05-23 13:35:12 +02:00
|
|
|
int x1, x2, y1, y2;
|
|
|
|
|
2015-10-11 21:56:16 +02:00
|
|
|
if ( isMonochron() )
|
|
|
|
return;
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
x1 = xpos+xmin-1;
|
|
|
|
x2 = xpos+xmin-2+width;
|
|
|
|
y1 = ypos+ymin-1;
|
|
|
|
y2 = ypos+ymin-2+height;
|
|
|
|
|
|
|
|
if ( x2 < xmax )
|
|
|
|
{
|
|
|
|
for (int i=0; i < height && y1+i <= ymax; i++)
|
|
|
|
{
|
|
|
|
gotoxy (x2+1, y1+i);
|
|
|
|
ch = getCoveredCharacter (x2+1, y1+i, this);
|
|
|
|
setColor (wc.shadow_fg, ch.bg_color);
|
|
|
|
print (' '); // clear █
|
|
|
|
}
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( y2 < ymax )
|
|
|
|
{
|
|
|
|
gotoxy (x1+1, y2+1);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
for (int i=1; i <= width && x1+i <= xmax; i++)
|
|
|
|
{
|
|
|
|
ch = getCoveredCharacter (x1+i, y2+1, this);
|
|
|
|
setColor (wc.shadow_fg, ch.bg_color);
|
|
|
|
print (' '); // clear ▀
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::drawFlatBorder()
|
|
|
|
{
|
|
|
|
int x1, x2, y1, y2;
|
|
|
|
|
|
|
|
if ( ! isNewFont() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
x1 = xpos+xmin-1;
|
|
|
|
x2 = xpos+xmin-1+width;
|
|
|
|
y1 = ypos+ymin-2;
|
|
|
|
y2 = ypos+ymin-1+height;
|
|
|
|
|
|
|
|
setColor (wc.dialog_fg, wc.dialog_bg);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-06-21 23:27:10 +02:00
|
|
|
for (int y=0; y < height; y++)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
gotoxy (x1-1, y1+y+1);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-06-22 00:26:24 +02:00
|
|
|
if ( double_flatline_mask.left[uLong(y)] )
|
2015-07-02 22:27:34 +02:00
|
|
|
print (fc::NF_rev_border_line_right_and_left); // left+right line (on left side)
|
2015-06-21 23:27:10 +02:00
|
|
|
else
|
|
|
|
print (fc::NF_rev_border_line_right); // right line (on left side)
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
gotoxy (x2, y1+1);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-06-21 23:27:10 +02:00
|
|
|
for (int y=0; y < height; y++)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2015-06-22 00:26:24 +02:00
|
|
|
if ( double_flatline_mask.right[uLong(y)] )
|
2015-07-02 22:27:34 +02:00
|
|
|
print (fc::NF_rev_border_line_right_and_left); // left+right line (on right side)
|
2015-06-21 23:27:10 +02:00
|
|
|
else
|
|
|
|
print (fc::NF_border_line_left); // left line (on right side)
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-06-21 23:27:10 +02:00
|
|
|
gotoxy (x2, y1+y+2);
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
gotoxy (x1, y1);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
for (int x=0; x < width; x++)
|
2015-06-21 23:27:10 +02:00
|
|
|
{
|
2015-06-22 00:26:24 +02:00
|
|
|
if ( double_flatline_mask.top[uLong(x)] )
|
2015-06-21 23:27:10 +02:00
|
|
|
print (fc::NF_border_line_up_and_down); // top+bottom line (at top)
|
|
|
|
else
|
|
|
|
print (fc::NF_border_line_bottom); // bottom line (at top)
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
gotoxy (x1, y2);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
for (int x=0; x < width; x++)
|
2015-06-21 23:27:10 +02:00
|
|
|
{
|
2015-06-22 00:26:24 +02:00
|
|
|
if ( double_flatline_mask.bottom[uLong(x)] )
|
2015-06-21 23:27:10 +02:00
|
|
|
print (fc::NF_border_line_up_and_down); // top+bottom line (at bottom)
|
|
|
|
else
|
|
|
|
print (fc::NF_border_line_upper); // top line (at bottom)
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::clearFlatBorder()
|
|
|
|
{
|
|
|
|
int x1, x2, y1, y2;
|
|
|
|
|
|
|
|
if ( ! isNewFont() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
x1 = xpos+xmin-1;
|
|
|
|
x2 = xpos+xmin-1+width;
|
|
|
|
y1 = ypos+ymin-2;
|
|
|
|
y2 = ypos+ymin-1+height;
|
|
|
|
|
|
|
|
setColor (wc.dialog_fg, wc.dialog_bg);
|
2015-09-24 00:41:43 +02:00
|
|
|
for (register int y=0; y < height; y++)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
gotoxy (x1-1, y1+y+1);
|
|
|
|
print (' '); // clear on left side
|
|
|
|
}
|
|
|
|
|
|
|
|
gotoxy (x2, y1+1);
|
|
|
|
for (register int y=1; y <= height; y++)
|
|
|
|
{
|
|
|
|
print (' '); // clear on right side
|
|
|
|
gotoxy (x2, y1+y+1);
|
|
|
|
}
|
|
|
|
|
|
|
|
gotoxy (x1, y1);
|
|
|
|
for (register int x=0; x < width; x++)
|
|
|
|
print (' '); // clear at bottom
|
|
|
|
|
|
|
|
gotoxy (x1, y2);
|
|
|
|
for (register int x=0; x < width; x++)
|
|
|
|
print (' '); // clear at top
|
|
|
|
}
|
|
|
|
|
2015-06-21 23:27:10 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::setDoubleFlatLine(int side, bool bit)
|
|
|
|
{
|
2015-06-22 00:26:24 +02:00
|
|
|
uLong size;
|
2015-06-21 23:27:10 +02:00
|
|
|
|
|
|
|
assert ( side == fc::top
|
|
|
|
|| side == fc::right
|
|
|
|
|| side == fc::bottom
|
|
|
|
|| side == fc::left );
|
|
|
|
|
|
|
|
switch ( side )
|
|
|
|
{
|
|
|
|
case fc::top:
|
|
|
|
size = double_flatline_mask.top.size();
|
|
|
|
double_flatline_mask.top.assign(size, bit);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case fc::right:
|
|
|
|
size = double_flatline_mask.right.size();
|
|
|
|
double_flatline_mask.right.assign(size, bit);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case fc::bottom:
|
|
|
|
size = double_flatline_mask.bottom.size();
|
|
|
|
double_flatline_mask.bottom.assign(size, bit);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case fc::left:
|
|
|
|
size = double_flatline_mask.left.size();
|
|
|
|
double_flatline_mask.left.assign(size, bit);
|
|
|
|
break;
|
2015-09-20 05:44:50 +02:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2015-06-21 23:27:10 +02:00
|
|
|
}
|
|
|
|
}
|
2015-06-22 00:26:24 +02:00
|
|
|
|
2015-06-21 23:27:10 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
std::vector<bool>& FWidget::doubleFlatLine_ref(int side)
|
|
|
|
{
|
|
|
|
assert ( side == fc::top
|
|
|
|
|| side == fc::right
|
|
|
|
|| side == fc::bottom
|
|
|
|
|| side == fc::left );
|
|
|
|
|
|
|
|
switch ( side )
|
|
|
|
{
|
|
|
|
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:
|
|
|
|
default:
|
|
|
|
return double_flatline_mask.left;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FWidget::drawBorder()
|
|
|
|
{
|
|
|
|
int x1, x2, y1, y2;
|
|
|
|
|
|
|
|
x1 = xpos+xmin-1;
|
|
|
|
x2 = xpos+xmin-2+width;
|
|
|
|
y1 = ypos+ymin-1;
|
|
|
|
y2 = ypos+ymin-2+height;
|
|
|
|
|
|
|
|
if ( x1 < xmin )
|
|
|
|
x1 = xmin;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( y1 < ymin )
|
|
|
|
y1 = ymin;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( x2 > xmax )
|
|
|
|
x2 = xmax;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( y2 > ymax )
|
|
|
|
y2 = ymax;
|
|
|
|
|
|
|
|
if ( isNewFont() )
|
|
|
|
{
|
|
|
|
setColor (wc.dialog_fg, wc.dialog_bg);
|
|
|
|
gotoxy (x1, y1);
|
|
|
|
print (fc::NF_border_corner_middle_upper_left); // ┌
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
for (int x=x1+1; x < x2; x++)
|
|
|
|
print (fc::BoxDrawingsHorizontal); // ─
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
print (fc::NF_border_corner_middle_upper_right); // ┐
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-09-24 00:41:43 +02:00
|
|
|
for (int y=y1+1; y <= y2; y++)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
gotoxy (x1, y);
|
|
|
|
print (fc::NF_border_line_left); // border left ⎸
|
|
|
|
gotoxy (x2, y);
|
|
|
|
print (fc::NF_rev_border_line_right); // border right⎹
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
gotoxy (x1, y2);
|
|
|
|
print (fc::NF_border_corner_middle_lower_left); // └
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
for (int x=x1+1; x < x2; x++)
|
|
|
|
print (fc::BoxDrawingsHorizontal); // ─
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
print (fc::NF_border_corner_middle_lower_right); // ┘
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gotoxy (x1, y1);
|
|
|
|
print (fc::BoxDrawingsDownAndRight); // ┌
|
|
|
|
|
|
|
|
for (int x=x1+1; x < x2; x++)
|
|
|
|
print (fc::BoxDrawingsHorizontal); // ─
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
print (fc::BoxDrawingsDownAndLeft); // ┐
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
for (int y=y1+1; y < y2; y++)
|
|
|
|
{
|
|
|
|
gotoxy (x1, y);
|
|
|
|
print (fc::BoxDrawingsVertical); // │
|
|
|
|
gotoxy (x2, y);
|
|
|
|
print (fc::BoxDrawingsVertical); // │
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
gotoxy (x1, y2);
|
|
|
|
print (fc::BoxDrawingsUpAndRight); // └
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
for (int x=x1+1; x < x2; x++)
|
|
|
|
print (fc::BoxDrawingsHorizontal); // ─
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
print (fc::BoxDrawingsUpAndLeft); // ┘
|
|
|
|
|
|
|
|
for (int x=x1+1; x < x2; x++)
|
|
|
|
{
|
|
|
|
gotoxy (x, y1);
|
|
|
|
print (fc::BoxDrawingsHorizontal); // ─
|
|
|
|
gotoxy (x, y2);
|
|
|
|
print (fc::BoxDrawingsHorizontal); // ─
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2015-10-17 05:59:09 +02:00
|
|
|
void FWidget::quit()
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
FApplication* fapp = static_cast<FApplication*>(rootObject);
|
|
|
|
fapp->exit(0);
|
|
|
|
}
|