More accurate interfaces through the strict use of FPoint() and FSize()

This commit is contained in:
Markus Gans 2019-01-21 03:42:18 +01:00
parent 4dcc573be7
commit eeb32bd66e
72 changed files with 1053 additions and 1018 deletions

View File

@ -1,3 +1,7 @@
2019-01-21 Markus Gans <guru.mail@muenster.de>
* More accurate interfaces through the strict use of FPoint()
and FSize()
2019-01-16 Markus Gans <guru.mail@muenster.de> 2019-01-16 Markus Gans <guru.mail@muenster.de>
* New class FSize for storing dimensions * New class FSize for storing dimensions

View File

@ -59,7 +59,7 @@ case "$1" in
;; ;;
"--fulldebug"|"fulldebug") "--fulldebug"|"fulldebug")
if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -W -Wall -Weffc++ -pedantic -pedantic-errors -Wextra -Wformat-nonliteral -Wformat-security -Wformat-y2k -Wimport -Winit-self -Winvalid-pch -Wlong-long -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wpadded -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -fstack-protector -Wstrict-aliasing -Wstrict-aliasing=3 -Wswitch -Wswitch-enum -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunreachable-code -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wsign-promo -Woverloaded-virtual -Wstrict-null-sentinel -fext-numeric-literals -Wreorder -Wnoexcept -Wnarrowing -Wliteral-suffix -Wctor-dtor-privacy" if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -W -Wall -Weffc++ -pedantic -pedantic-errors -Wextra -Wformat-nonliteral -Wformat-security -Wformat-y2k -Wimport -Winit-self -Winvalid-pch -Wlong-long -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wpadded -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -fstack-protector -Wstrict-aliasing -Wstrict-aliasing=3 -Wswitch -Wswitch-enum -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunreachable-code -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wsign-promo -Woverloaded-virtual -Wstrict-null-sentinel -fext-numeric-literals -Wreorder -Wnoexcept -Wnarrowing -Wliteral-suffix -Wctor-dtor-privacy -ftree-loop-distribute-patterns -Wmemset-transposed-args"
then then
echo "${RED}Configure failed!${NORMAL}" 1>&2 echo "${RED}Configure failed!${NORMAL}" 1>&2
exit -1 exit -1

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2016-2018 Markus Gans * * Copyright 2016-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -30,6 +30,9 @@
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
constexpr lDouble PI = 3.141592653589793238L; constexpr lDouble PI = 3.141592653589793238L;
@ -119,7 +122,6 @@ class Calc : public finalcut::FDialog
// Event handlers // Event handlers
virtual void onKeyPress (finalcut::FKeyEvent*) override; virtual void onKeyPress (finalcut::FKeyEvent*) override;
virtual void onAccel (finalcut::FAccelEvent*) override;
virtual void onClose (finalcut::FCloseEvent*) override; virtual void onClose (finalcut::FCloseEvent*) override;
// Callback method // Callback method
@ -250,8 +252,7 @@ Calc::Calc (FWidget* parent)
clearInfixOperator(); clearInfixOperator();
std::setlocale(LC_NUMERIC, "C"); std::setlocale(LC_NUMERIC, "C");
setText ("Calculator"); setText ("Calculator");
setGeometry (19, 6, 37, 18); setGeometry (FPoint(19, 6), FSize(37, 18));
addAccelerator('q'); // Press 'q' to quit
for (std::size_t key = 0; key < Calc::NUM_OF_BUTTONS; key++) for (std::size_t key = 0; key < Calc::NUM_OF_BUTTONS; key++)
{ {
@ -259,7 +260,7 @@ Calc::Calc (FWidget* parent)
button_no[key] = key; button_no[key] = key;
if ( key == Equals ) if ( key == Equals )
btn->setGeometry(30, 15, 5, 3); btn->setGeometry(FPoint(30, 15), FSize(5, 3));
else else
{ {
int x, y; int x, y;
@ -267,7 +268,7 @@ Calc::Calc (FWidget* parent)
( key <= Three ) ? n = 0 : n = 1; ( key <= Three ) ? n = 0 : n = 1;
x = int(key + n) % 5 * 7 + 2; x = int(key + n) % 5 * 7 + 2;
y = int(key + n) / 5 * 2 + 3; y = int(key + n) / 5 * 2 + 3;
btn->setGeometry(x, y, 5, 1); btn->setGeometry(FPoint(x, y), FSize(5, 1));
} }
btn->setFlat(); btn->setFlat();
@ -337,7 +338,7 @@ void Calc::drawDispay()
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
setPrintPos (3, 3); setPrintPos (FPoint(3, 3));
print(display); print(display);
print(L' '); print(L' ');
setColor(wc.dialog_fg, wc.dialog_bg); setColor(wc.dialog_fg, wc.dialog_bg);
@ -352,13 +353,13 @@ void Calc::drawDispay()
wchar_t top_line = finalcut::fc::NF_border_line_upper; wchar_t top_line = finalcut::fc::NF_border_line_upper;
wchar_t right_line = finalcut::fc::NF_rev_border_line_right; wchar_t right_line = finalcut::fc::NF_rev_border_line_right;
wchar_t left_line = finalcut::fc::NF_border_line_left; wchar_t left_line = finalcut::fc::NF_border_line_left;
setPrintPos (3, 2); setPrintPos (FPoint(3, 2));
print (finalcut::FString(33, bottom_line)); print (finalcut::FString(33, bottom_line));
setPrintPos (2, 3); setPrintPos (FPoint(2, 3));
print (right_line); print (right_line);
setPrintPos (36, 3); setPrintPos (FPoint(36, 3));
print (left_line); print (left_line);
setPrintPos (3, 4); setPrintPos (FPoint(3, 4));
finalcut::FString top_bottom_line_5 (5, top_bottom_line); finalcut::FString top_bottom_line_5 (5, top_bottom_line);
finalcut::FString top_line_2 (2, top_line); finalcut::FString top_line_2 (2, top_line);
print ( top_bottom_line_5 + top_line_2 print ( top_bottom_line_5 + top_line_2
@ -375,7 +376,7 @@ void Calc::drawDispay()
finalcut::FString separator = finalcut::FString(vertical_and_right) finalcut::FString separator = finalcut::FString(vertical_and_right)
+ finalcut::FString(35, horizontal) + finalcut::FString(35, horizontal)
+ finalcut::FString(vertical_and_left); + finalcut::FString(vertical_and_left);
setPrintPos (1, 4); setPrintPos (FPoint(1, 4));
print(separator); print(separator);
} }
} }
@ -1034,19 +1035,17 @@ void Calc::onKeyPress (finalcut::FKeyEvent* ev)
ev->accept(); ev->accept();
break; break;
case 'q':
close();
ev->accept();
break;
default: default:
finalcut::FDialog::onKeyPress(ev); finalcut::FDialog::onKeyPress(ev);
break; break;
} }
} }
//----------------------------------------------------------------------
void Calc::onAccel (finalcut::FAccelEvent* ev)
{
close();
ev->accept();
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Calc::onClose (finalcut::FCloseEvent* ev) void Calc::onClose (finalcut::FCloseEvent* ev)
{ {

View File

@ -27,6 +27,9 @@
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class CheckList // class CheckList
@ -73,9 +76,10 @@ CheckList::CheckList (finalcut::FWidget* parent)
{ {
setText (L"Shopping list"); setText (L"Shopping list");
setShadow(); setShadow();
setGeometry (int(1 + (parent->getWidth() - 30) / 2), 5, 30, 13); setGeometry ( FPoint(int(1 + (parent->getWidth() - 30) / 2), 5)
, FSize(30, 13) );
listView.ignorePadding(); listView.ignorePadding();
listView.setGeometry (1, 2, getWidth(), getHeight() - 1); listView.setGeometry (FPoint(1, 2), FSize(getWidth(), getHeight() - 1));
// Add columns to the view // Add columns to the view
listView.addColumn ("Item"); listView.addColumn ("Item");

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2017-2018 Markus Gans * * Copyright 2017-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -23,6 +23,9 @@
#include <vector> #include <vector>
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
// Typedef // Typedef
typedef std::shared_ptr<finalcut::FRadioButton> FRadioButtonPtr; typedef std::shared_ptr<finalcut::FRadioButton> FRadioButtonPtr;
@ -106,11 +109,11 @@ int main (int argc, char* argv[])
std::size_t h = 13; std::size_t h = 13;
int x = int(app.getDesktopWidth() - w) / 2; int x = int(app.getDesktopWidth() - w) / 2;
int y = int(app.getDesktopHeight() - h) / 2; int y = int(app.getDesktopHeight() - h) / 2;
dgl.setGeometry (x, y, w, h); dgl.setGeometry (FPoint(x, y), FSize(w, h));
// Create a button group // Create a button group
finalcut::FButtonGroup checkButtonGroup("choice", &dgl); finalcut::FButtonGroup checkButtonGroup("choice", &dgl);
checkButtonGroup.setGeometry (2, 1, 16, 7); checkButtonGroup.setGeometry (FPoint(2, 1), FSize(16, 7));
// Create radio buttons // Create radio buttons
std::vector<FRadioButtonPtr> os(9); std::vector<FRadioButtonPtr> os(9);
@ -120,7 +123,7 @@ int main (int argc, char* argv[])
// => checkButtonGroup.setScrollSize(...) is not required // => checkButtonGroup.setScrollSize(...) is not required
// because a FButtonGroup is self-adjusting // because a FButtonGroup is self-adjusting
for (uInt i = 0; i < os.size(); i++) for (uInt i = 0; i < os.size(); i++)
os[i]->setGeometry(1, int(1 + i), 12, 1); os[i]->setGeometry(FPoint(1, int(1 + i)), FSize(12, 1));
preset(os); preset(os);
@ -130,7 +133,7 @@ int main (int argc, char* argv[])
// Create a OK button // Create a OK button
finalcut::FButton ok("&OK", &dgl); finalcut::FButton ok("&OK", &dgl);
ok.setGeometry (10, 9, 8, 1); ok.setGeometry (FPoint(10, 9), FSize(8, 1));
// Connect the button signal "clicked" with the callback function // Connect the button signal "clicked" with the callback function
ok.addCallback ok.addCallback

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2015-2018 Markus Gans * * Copyright 2015-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -22,6 +22,9 @@
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
// function prototype // function prototype
void cb_quit (finalcut::FWidget*, FDataPtr); void cb_quit (finalcut::FWidget*, FDataPtr);
@ -47,7 +50,7 @@ int main (int argc, char* argv[])
// Create a simple dialog box // Create a simple dialog box
finalcut::FDialog dgl(&app); finalcut::FDialog dgl(&app);
dgl.setText ("FDialog"); dgl.setText ("FDialog");
dgl.setGeometry (4, 3, 41, 11); dgl.setGeometry (FPoint(4, 3), FSize(41, 11));
// Create text labels // Create text labels
finalcut::FLabel label_1(&dgl); finalcut::FLabel label_1(&dgl);
@ -62,12 +65,12 @@ int main (int argc, char* argv[])
<< "or push the button below to exit\n" << "or push the button below to exit\n"
<< "the program."; << "the program.";
label_1.setGeometry (1, 1, 38, 2); label_1.setGeometry (FPoint(1, 1), FSize(38, 2));
label_2.setGeometry (5, 3, 34, 3); label_2.setGeometry (FPoint(5, 3), FSize(34, 3));
// Create the quit button // Create the quit button
finalcut::FButton btn("&Quit", &dgl); finalcut::FButton btn("&Quit", &dgl);
btn.setGeometry (16, 7, 9, 1); btn.setGeometry (FPoint(16, 7), FSize(9, 1));
// Connect the button signal "clicked" with the callback function // Connect the button signal "clicked" with the callback function
btn.addCallback btn.addCallback

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2015-2018 Markus Gans * * Copyright 2015-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -22,11 +22,14 @@
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
// function prototypes // function prototypes
void cb_quit (finalcut::FWidget*, FDataPtr); void cb_quit (finalcut::FWidget*, FDataPtr);
void cb_publish (finalcut::FWidget*, FDataPtr); void cb_publish (finalcut::FWidget*, FDataPtr);
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// callback functions // callback functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -62,7 +65,7 @@ int main (int argc, char* argv[])
// Create a simple dialog box // Create a simple dialog box
finalcut::FDialog dgl(&app); finalcut::FDialog dgl(&app);
dgl.setText ("Data input"); dgl.setText ("Data input");
dgl.setGeometry (4, 2, 37, 22); dgl.setGeometry (FPoint(4, 2), FSize(37, 22));
dgl.setShadow(); dgl.setShadow();
// Create input fields // Create input fields
@ -80,37 +83,37 @@ int main (int argc, char* argv[])
st_field.setLabelText (L"&State"); st_field.setLabelText (L"&State");
c_field.setLabelText (L"&Country"); c_field.setLabelText (L"&Country");
name_field.setGeometry (15, 1, 19, 1); name_field.setGeometry (FPoint(15, 1), FSize(19, 1));
email_field.setGeometry (15, 3, 19, 1); email_field.setGeometry (FPoint(15, 3), FSize(19, 1));
org_field.setGeometry (15, 5, 19, 1); org_field.setGeometry (FPoint(15, 5), FSize(19, 1));
city_field.setGeometry (15, 7, 19, 1); city_field.setGeometry (FPoint(15, 7), FSize(19, 1));
st_field.setGeometry (15, 9, 19, 1); st_field.setGeometry (FPoint(15, 9), FSize(19, 1));
c_field.setGeometry (15, 11, 4, 1); c_field.setGeometry (FPoint(15, 11), FSize(4, 1));
// Create the button group // Create the button group
finalcut::FButtonGroup radioButtonGroup ("Sex", &dgl); finalcut::FButtonGroup radioButtonGroup ("Sex", &dgl);
radioButtonGroup.setGeometry(2, 13, 13, 4); radioButtonGroup.setGeometry(FPoint(2, 13), FSize(13, 4));
// Create radio buttons // Create radio buttons
finalcut::FRadioButton male ("&Male", &radioButtonGroup); finalcut::FRadioButton male ("&Male", &radioButtonGroup);
finalcut::FRadioButton female ("&Female", &radioButtonGroup); finalcut::FRadioButton female ("&Female", &radioButtonGroup);
male.setGeometry (1, 1, 8, 1); male.setGeometry (FPoint(1, 1), FSize(8, 1));
female.setGeometry (1, 2, 10, 1); female.setGeometry (FPoint(1, 2), FSize(10, 1));
// Create another button group // Create another button group
finalcut::FButtonGroup checkButtonGroup ("&Data options", &dgl); finalcut::FButtonGroup checkButtonGroup ("&Data options", &dgl);
checkButtonGroup.setGeometry(16, 13, 19, 4); checkButtonGroup.setGeometry(FPoint(16, 13), FSize(19, 4));
// Create checkbox buttons // Create checkbox buttons
finalcut::FCheckBox check1 ("Save data", &checkButtonGroup); finalcut::FCheckBox check1 ("Save data", &checkButtonGroup);
finalcut::FCheckBox check2 ("Encrypt data", &checkButtonGroup); finalcut::FCheckBox check2 ("Encrypt data", &checkButtonGroup);
check1.setGeometry (1, 1, 13, 1); check1.setGeometry (FPoint(1, 1), FSize(13, 1));
check2.setGeometry (1, 2, 16, 1); check2.setGeometry (FPoint(1, 2), FSize(16, 1));
check2.setDisable(); check2.setDisable();
// Create a OK button // Create a OK button
finalcut::FButton btn("&OK", &dgl); finalcut::FButton btn("&OK", &dgl);
btn.setGeometry (24, 18, 10, 1); btn.setGeometry (FPoint(24, 18), FSize(10, 1));
// Connect checkbox signal "clicked" with a callback function // Connect checkbox signal "clicked" with a callback function
check1.addCallback check1.addCallback

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2015-2018 Markus Gans * * Copyright 2015-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -65,7 +65,8 @@ void Keyboard::onKeyPress (finalcut::FKeyEvent* ev)
if ( is_last_line ) if ( is_last_line )
scrollAreaForward (vdesktop); scrollAreaForward (vdesktop);
setAreaCursor (1, getPrintPos().getY(), true, vdesktop); setAreaCursor ( finalcut::FPoint(1, getPrintPos().getY())
, true, vdesktop );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -78,11 +79,11 @@ void Keyboard::onAccel (finalcut::FAccelEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Keyboard::draw() void Keyboard::draw()
{ {
setPrintPos (1, 1); setPrintPos (finalcut::FPoint(1, 1));
print() << "---------------\n" print() << "---------------\n"
<< "Press Q to quit\n" << "Press Q to quit\n"
<< "---------------\n"; << "---------------\n";
setAreaCursor (1, 4, true, vdesktop); setAreaCursor (finalcut::FPoint(1, 4), true, vdesktop);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2017-2018 Markus Gans * * Copyright 2017-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -28,6 +28,8 @@
#include <final/final.h> #include <final/final.h>
using namespace finalcut; using namespace finalcut;
using finalcut::FPoint;
using finalcut::FSize;
// Global application object // Global application object
static std::weak_ptr<FString> temp_str; static std::weak_ptr<FString> temp_str;
@ -113,7 +115,7 @@ Listbox::Listbox (FWidget* parent)
// listbox 1 // listbox 1
//---------- //----------
list1.setGeometry(2, 1, 18, 10); list1.setGeometry(FPoint(2, 1), FSize(18, 10));
list1.setText ("FListBoxItem"); list1.setText ("FListBoxItem");
for (int i = 1; i < 30; i++) for (int i = 1; i < 30; i++)
@ -124,7 +126,7 @@ Listbox::Listbox (FWidget* parent)
for (double i = 1; i<=15; i++) for (double i = 1; i<=15; i++)
double_list.push_back(2 * i + (i / 100)); double_list.push_back(2 * i + (i / 100));
list2.setGeometry(21, 1, 10, 10); list2.setGeometry(FPoint(21, 1), FSize(10, 10));
list2.setText ("double"); list2.setText ("double");
// //
@ -147,11 +149,11 @@ Listbox::Listbox (FWidget* parent)
TLD["gov"] = "Government"; TLD["gov"] = "Government";
list3.insert (TLD.begin(), TLD.end(), mapToString); list3.insert (TLD.begin(), TLD.end(), mapToString);
list3.setGeometry(32, 1, 21, 10); list3.setGeometry(FPoint(32, 1), FSize(21, 10));
list3.setText ("key: value"); list3.setText ("key: value");
// Quit button // Quit button
Quit.setGeometry(42, 12, 10, 1); Quit.setGeometry(FPoint(42, 12), FSize(10, 1));
Quit.setText (L"&Quit"); Quit.setText (L"&Quit");
// Add quit button function callback // Add quit button function callback
@ -185,7 +187,8 @@ int main (int argc, char* argv[])
// Create main dialog object // Create main dialog object
Listbox d(&app); Listbox d(&app);
d.setText (L"Listbox"); d.setText (L"Listbox");
d.setGeometry (int(1 + (app.getWidth() - 56) / 2), 5, 56, 16); d.setGeometry ( FPoint(int(1 + (app.getWidth() - 56) / 2), 5)
, FSize(56, 16) );
d.setShadow(); d.setShadow();
// Set dialog d as main widget // Set dialog d as main widget

View File

@ -27,6 +27,9 @@
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class Listview // class Listview
@ -71,7 +74,7 @@ Listview::Listview (finalcut::FWidget* parent)
: finalcut::FDialog(parent) : finalcut::FDialog(parent)
{ {
// Set FListView geometry // Set FListView geometry
listView.setGeometry(2, 1, 33, 14); listView.setGeometry(FPoint(2, 1), FSize(33, 14));
// Add columns to the view // Add columns to the view
listView.addColumn ("City"); listView.addColumn ("City");
@ -104,7 +107,7 @@ Listview::Listview (finalcut::FWidget* parent)
populate(); populate();
// Quit button // Quit button
Quit.setGeometry(24, 16, 10, 1); Quit.setGeometry(FPoint(24, 16), FSize(10, 1));
Quit.setText (L"&Quit"); Quit.setText (L"&Quit");
// Add some function callbacks // Add some function callbacks
@ -214,7 +217,8 @@ int main (int argc, char* argv[])
// Create main dialog object // Create main dialog object
Listview d(&app); Listview d(&app);
d.setText (L"Weather data"); d.setText (L"Weather data");
d.setGeometry (int(1 + (app.getWidth() - 37) / 2), 3, 37, 20); d.setGeometry ( FPoint(int(1 + (app.getWidth() - 37) / 2), 3)
, FSize(37, 20) );
d.setShadow(); d.setShadow();
// Set dialog d as main widget // Set dialog d as main widget

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2015-2018 Markus Gans * * Copyright 2015-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -22,6 +22,9 @@
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class Mandelbrot // class Mandelbrot
@ -40,7 +43,7 @@ class Mandelbrot : public finalcut::FDialog
~Mandelbrot(); ~Mandelbrot();
// Event handlers // Event handlers
virtual void onAccel (finalcut::FAccelEvent*) override; virtual void onKeyPress (finalcut::FKeyEvent*) override;
virtual void onClose (finalcut::FCloseEvent*) override; virtual void onClose (finalcut::FCloseEvent*) override;
private: private:
@ -89,7 +92,7 @@ void Mandelbrot::draw()
for (y0 = y_min; y0 < y_max && current_line < Lines; y0 += dY) for (y0 = y_min; y0 < y_max && current_line < Lines; y0 += dY)
{ {
current_line++; current_line++;
setPrintPos (xoffset, yoffset + current_line); setPrintPos (FPoint(xoffset, yoffset + current_line));
for (x0 = x_min; x0 < x_max; x0 += dX) for (x0 = x_min; x0 < x_max; x0 += dX)
{ {
@ -116,10 +119,18 @@ void Mandelbrot::draw()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Mandelbrot::onAccel (finalcut::FAccelEvent* ev) void Mandelbrot::onKeyPress (finalcut::FKeyEvent* ev)
{ {
if ( ! ev )
return;
if ( ev->key() == 'q' )
{
close(); close();
ev->accept(); ev->accept();
}
else
finalcut::FDialog::onKeyPress(ev);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -133,7 +144,7 @@ void Mandelbrot::adjustSize()
{ {
std::size_t h = getParentWidget()->getHeight() - 1; std::size_t h = getParentWidget()->getHeight() - 1;
std::size_t w = getParentWidget()->getWidth() - 10; std::size_t w = getParentWidget()->getWidth() - 10;
setGeometry(6, 1, w, h, false); setGeometry(FPoint(6, 1), FSize(w, h), false);
finalcut::FDialog::adjustSize(); finalcut::FDialog::adjustSize();
} }
@ -147,8 +158,7 @@ int main (int argc, char* argv[])
// Create a simple dialog box // Create a simple dialog box
Mandelbrot mb(&app); Mandelbrot mb(&app);
mb.setGeometry (6, 1, 70, 23); mb.setGeometry (FPoint(6, 1), FSize(70, 23));
mb.addAccelerator('q'); // press 'q' to quit
mb.setShadow(); mb.setShadow();
// Set the mandelbrot object as main widget // Set the mandelbrot object as main widget

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2015-2018 Markus Gans * * Copyright 2015-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -22,6 +22,9 @@
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class Menu // class Menu
@ -140,19 +143,19 @@ Menu::Menu (finalcut::FWidget* parent)
// Headline labels // Headline labels
Headline1 << " Key "; Headline1 << " Key ";
Headline1.ignorePadding(); Headline1.ignorePadding();
Headline1.setGeometry(3, 2, 5, 1); Headline1.setGeometry(FPoint(3, 2), FSize(5, 1));
Headline1.setEmphasis(); Headline1.setEmphasis();
Headline2 << " Function "; Headline2 << " Function ";
Headline2.ignorePadding(); Headline2.ignorePadding();
Headline2.setGeometry(19, 2, 10, 1); Headline2.setGeometry(FPoint(19, 2), FSize(10, 1));
Headline2.setEmphasis(); Headline2.setEmphasis();
// Info label // Info label
Info << "<F10> Activate menu bar\n" Info << "<F10> Activate menu bar\n"
<< "<Ctrl>+<Space> Activate menu bar\n" << "<Ctrl>+<Space> Activate menu bar\n"
<< "<Meta>+<X> Exit"; << "<Meta>+<X> Exit";
Info.setGeometry(2, 1, 36, 3); Info.setGeometry(FPoint(2, 1), FSize(36, 3));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -325,7 +328,8 @@ int main (int argc, char* argv[])
// Create main dialog object // Create main dialog object
Menu main_dlg (&app); Menu main_dlg (&app);
main_dlg.setText ("Menu example"); main_dlg.setText ("Menu example");
main_dlg.setGeometry (int(1 + (app.getWidth() - 40) / 2), 2, 40, 6); main_dlg.setGeometry ( FPoint(int(1 + (app.getWidth() - 40) / 2), 2)
, FSize(40, 6) );
main_dlg.setShadow(); main_dlg.setShadow();
// Set dialog main_dlg as main widget // Set dialog main_dlg as main widget

View File

@ -22,6 +22,9 @@
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class ColorChooser // class ColorChooser
@ -67,8 +70,8 @@ class ColorChooser : public finalcut::FWidget
ColorChooser::ColorChooser (finalcut::FWidget* parent) ColorChooser::ColorChooser (finalcut::FWidget* parent)
: FWidget(parent) : FWidget(parent)
{ {
setSize (8, 12); setSize (FSize(8, 12));
setFixedSize (8, 12); setFixedSize (FSize(8, 12));
unsetFocusable(); unsetFocusable();
if ( parent ) if ( parent )
@ -82,7 +85,7 @@ ColorChooser::ColorChooser (finalcut::FWidget* parent)
} }
// Text label // Text label
headline.setGeometry (1, 1, 8, 1); headline.setGeometry (FPoint(1, 1), FSize(8, 1));
headline.setEmphasis(); headline.setEmphasis();
headline.setAlignment (finalcut::fc::alignCenter); headline.setAlignment (finalcut::fc::alignCenter);
headline << "Color"; headline << "Color";
@ -128,7 +131,7 @@ void ColorChooser::draw()
for (FColor c = 0; c < 16; c++) for (FColor c = 0; c < 16; c++)
{ {
setPrintPos (2 + (c / 8) * 3, 3 + c % 8); setPrintPos (FPoint(2 + (c / 8) * 3, 3 + c % 8));
if ( c < 6 ) if ( c < 6 )
setColor (finalcut::fc::LightGray, c); setColor (finalcut::fc::LightGray, c);
@ -209,8 +212,8 @@ class Brushes : public finalcut::FWidget
Brushes::Brushes (finalcut::FWidget* parent) Brushes::Brushes (finalcut::FWidget* parent)
: FWidget(parent) : FWidget(parent)
{ {
setSize (8, 4); setSize (FSize(8, 4));
setFixedSize (8, 4); setFixedSize (FSize(8, 4));
unsetFocusable(); unsetFocusable();
if ( parent ) if ( parent )
@ -224,7 +227,7 @@ Brushes::Brushes (finalcut::FWidget* parent)
} }
// Text label // Text label
headline.setGeometry(1, 1, 8, 1); headline.setGeometry(FPoint(1, 1), FSize(8, 1));
headline.setEmphasis(); headline.setEmphasis();
headline.setAlignment (finalcut::fc::alignCenter); headline.setAlignment (finalcut::fc::alignCenter);
headline << "Brush"; headline << "Brush";
@ -242,7 +245,7 @@ void Brushes::draw()
setColor(); setColor();
finalcut::FWidget::drawBorder (1, 2, 8, 4); finalcut::FWidget::drawBorder (1, 2, 8, 4);
setColor (fg_color, bg_color); setColor (fg_color, bg_color);
setPrintPos (2, 3); setPrintPos (FPoint(2, 3));
print(" "); print(" ");
print(finalcut::FString(3, finalcut::fc::MediumShade)); print(finalcut::FString(3, finalcut::fc::MediumShade));
@ -252,9 +255,9 @@ void Brushes::draw()
pos = 3; pos = 3;
setColor(); setColor();
setPrintPos (3 + pos, 2); setPrintPos (FPoint(3 + pos, 2));
print(finalcut::fc::BlackDownPointingTriangle); print(finalcut::fc::BlackDownPointingTriangle);
setPrintPos (3 + pos, 4); setPrintPos (FPoint(3 + pos, 4));
print(finalcut::fc::BlackUpPointingTriangle); print(finalcut::fc::BlackUpPointingTriangle);
} }
@ -324,10 +327,10 @@ class MouseDraw : public finalcut::FDialog
MouseDraw& operator = (const MouseDraw&) = delete; MouseDraw& operator = (const MouseDraw&) = delete;
// Methods // Methods
void setGeometry (int, int, std::size_t, std::size_t, bool = true) override; void setGeometry (const FPoint&, const FSize&, bool = true) override;
// Event handlers // Event handlers
virtual void onAccel (finalcut::FAccelEvent*) override; virtual void onKeyPress (finalcut::FKeyEvent*) override;
virtual void onClose (finalcut::FCloseEvent*) override; virtual void onClose (finalcut::FCloseEvent*) override;
private: private:
@ -356,16 +359,16 @@ MouseDraw::MouseDraw (finalcut::FWidget* parent)
: finalcut::FDialog(parent) : finalcut::FDialog(parent)
{ {
setText ("Drawing with the mouse"); setText ("Drawing with the mouse");
c_chooser.setPos (1, 1); c_chooser.setPos (FPoint(1, 1));
c_chooser.addCallback c_chooser.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MouseDraw::cb_colorChanged) F_METHOD_CALLBACK (this, &MouseDraw::cb_colorChanged)
); );
brush.setPos (1, 12); brush.setPos (FPoint(1, 12));
finalcut::FSize no_shadow(0, 0); FSize no_shadow(0, 0);
finalcut::FRect scroll_geometry(0, 0, 1, 1); finalcut::FRect scroll_geometry(0, 0, 1, 1);
createArea (scroll_geometry, no_shadow, canvas); createArea (scroll_geometry, no_shadow, canvas);
} }
@ -375,16 +378,15 @@ MouseDraw::~MouseDraw()
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MouseDraw::setGeometry ( int x, int y void MouseDraw::setGeometry ( const FPoint& p, const FSize& s, bool adjust)
, std::size_t w, std::size_t h
, bool adjust )
{ {
int old_w, old_h; finalcut::FDialog::setGeometry (p, s, adjust);
finalcut::FDialog::setGeometry (x, y, w, h, adjust); std::size_t w = s.getWidth();
finalcut::FSize no_shadow(0, 0); std::size_t h = s.getHeight();
finalcut::FRect scroll_geometry (0, 0, w - 11, h - 3); finalcut::FRect scroll_geometry (FPoint(0, 0), FSize(w - 11, h - 3));
old_w = canvas->width; FSize no_shadow(0, 0);
old_h = canvas->height; int old_w = canvas->width;
int old_h = canvas->height;
resizeArea (scroll_geometry, no_shadow, canvas); resizeArea (scroll_geometry, no_shadow, canvas);
if ( old_w != canvas->width || old_h != canvas->height ) if ( old_w != canvas->width || old_h != canvas->height )
@ -395,10 +397,18 @@ void MouseDraw::setGeometry ( int x, int y
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MouseDraw::onAccel (finalcut::FAccelEvent* ev) void MouseDraw::onKeyPress (finalcut::FKeyEvent* ev)
{ {
if ( ! ev )
return;
if ( ev->key() == 'q' )
{
close(); close();
ev->accept(); ev->accept();
}
else
finalcut::FDialog::onKeyPress(ev);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -418,25 +428,25 @@ void MouseDraw::draw()
{ {
for (int y = 2; y < y_max; y++) for (int y = 2; y < y_max; y++)
{ {
setPrintPos (10, y); setPrintPos (FPoint(10, y));
print (finalcut::fc::NF_rev_border_line_right); print (finalcut::fc::NF_rev_border_line_right);
} }
setPrintPos (10, y_max); setPrintPos (FPoint(10, y_max));
print (finalcut::fc::NF_rev_border_corner_lower_right); print (finalcut::fc::NF_rev_border_corner_lower_right);
} }
else else
{ {
setPrintPos (10, 2); setPrintPos (FPoint(10, 2));
print (finalcut::fc::BoxDrawingsDownAndHorizontal); print (finalcut::fc::BoxDrawingsDownAndHorizontal);
for (int y = 3; y < y_max; y++) for (int y = 3; y < y_max; y++)
{ {
setPrintPos (10, y); setPrintPos (FPoint(10, y));
print (finalcut::fc::BoxDrawingsVertical); print (finalcut::fc::BoxDrawingsVertical);
} }
setPrintPos (10, y_max); setPrintPos (FPoint(10, y_max));
print (finalcut::fc::BoxDrawingsUpAndHorizontal); print (finalcut::fc::BoxDrawingsUpAndHorizontal);
} }
@ -505,7 +515,7 @@ void MouseDraw::adjustSize()
std::size_t w = 60, h = 18; std::size_t w = 60, h = 18;
int x = 1 + int((getParentWidget()->getWidth() - w) / 2); int x = 1 + int((getParentWidget()->getWidth() - w) / 2);
int y = 1 + int((getParentWidget()->getHeight() - h) / 2); int y = 1 + int((getParentWidget()->getHeight() - h) / 2);
setGeometry (x, y, w, h, false); setGeometry (FPoint(x, y), FSize(w, h), false);
finalcut::FDialog::adjustSize(); finalcut::FDialog::adjustSize();
} }
@ -556,8 +566,7 @@ int main (int argc, char* argv[])
// Create a simple dialog box // Create a simple dialog box
MouseDraw mouse_draw(&app); MouseDraw mouse_draw(&app);
mouse_draw.setGeometry (12, 4, 60, 18); mouse_draw.setGeometry (FPoint(12, 4), FSize(60, 18));
mouse_draw.addAccelerator('q'); // press 'q' to quit
// Set dialog object mouse_draw as main widget // Set dialog object mouse_draw as main widget
app.setMainWidget(&mouse_draw); app.setMainWidget(&mouse_draw);

View File

@ -22,6 +22,9 @@
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class Scrollview // class Scrollview
@ -46,7 +49,7 @@ class Scrollview : public finalcut::FScrollView
Scrollview& operator = (const Scrollview&) = delete; Scrollview& operator = (const Scrollview&) = delete;
// Mutator // Mutator
void setScrollSize (std::size_t, std::size_t) override; void setScrollSize (const FSize&) override;
private: private:
// Method // Method
@ -75,11 +78,14 @@ Scrollview::Scrollview (finalcut::FWidget* parent)
: finalcut::FScrollView(parent) : finalcut::FScrollView(parent)
{ {
// Sets the navigation button geometry // Sets the navigation button geometry
go_east.setGeometry (1, 1, 5, 1); go_east.setGeometry (FPoint(1, 1), FSize(5, 1));
go_south.setGeometry (int(getScrollWidth()) - 5, 1, 5, 1); go_south.setGeometry ( FPoint(int(getScrollWidth()) - 5, 1)
go_west.setGeometry ( int(getScrollWidth()) - 5 , FSize(5, 1) );
, int(getScrollHeight()) - 2, 5, 1); go_west.setGeometry ( FPoint( int(getScrollWidth()) - 5
go_north.setGeometry (1, int(getScrollHeight()) - 2, 5, 1); , int(getScrollHeight()) - 2 )
, FSize(5, 1) );
go_north.setGeometry ( FPoint(1, int(getScrollHeight()) - 2)
, FSize(5, 1) );
// Add scroll function callbacks to the buttons // Add scroll function callbacks to the buttons
go_east.addCallback go_east.addCallback
@ -112,12 +118,14 @@ Scrollview::~Scrollview()
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Scrollview::setScrollSize (std::size_t width, std::size_t height) void Scrollview::setScrollSize (const FSize& size)
{ {
FScrollView::setScrollSize (width, height); FScrollView::setScrollSize (size);
go_south.setPos (int(width) - 5, 1); auto width = int(size.getWidth());
go_west.setPos (int(width) - 5, int(height) - 1); auto height = int(size.getHeight());
go_north.setPos (1, int(height) - 1); go_south.setPos (FPoint(width - 5, 1));
go_west.setPos (FPoint(width - 5, height - 1));
go_north.setPos (FPoint(1, height - 1));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -131,7 +139,7 @@ void Scrollview::draw()
for (int y = 0; y < int(getScrollHeight()); y++) for (int y = 0; y < int(getScrollHeight()); y++)
{ {
setPrintPos (1, 1 + y); setPrintPos (FPoint(1, 1 + y));
for (int x = 0; x < int(getScrollWidth()); x++) for (int x = 0; x < int(getScrollWidth()); x++)
print (32 + ((x + y) % 0x5f)); print (32 + ((x + y) % 0x5f));
@ -214,15 +222,15 @@ class Scrollviewdemo : public finalcut::FDialog
Scrollviewdemo::Scrollviewdemo (finalcut::FWidget* parent) Scrollviewdemo::Scrollviewdemo (finalcut::FWidget* parent)
: finalcut::FDialog(parent) : finalcut::FDialog(parent)
{ {
setGeometry (16, 3, 50, 19); setGeometry (FPoint(16, 3), FSize(50, 19));
setText ("Scrolling viewport example"); setText ("Scrolling viewport example");
// The scrolling viewport widget // The scrolling viewport widget
sview.setGeometry(3, 2, 44, 12); sview.setGeometry(FPoint(3, 2), FSize(44, 12));
sview.setScrollSize(188, 124); sview.setScrollSize(FSize(188, 124));
// Quit button // Quit button
quit_btn.setGeometry(37, 15, 10, 1); quit_btn.setGeometry(FPoint(37, 15), FSize(10, 1));
// Add function callback // Add function callback
quit_btn.addCallback quit_btn.addCallback
@ -232,7 +240,7 @@ Scrollviewdemo::Scrollviewdemo (finalcut::FWidget* parent)
); );
// Text label // Text label
label.setGeometry(2, 1, 46, 1); label.setGeometry(FPoint(2, 1), FSize(46, 1));
label.setEmphasis(); label.setEmphasis();
label << L"Use scrollbars to change the viewport position"; label << L"Use scrollbars to change the viewport position";
} }

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2015-2018 Markus Gans * * Copyright 2015-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -23,6 +23,9 @@
#include <functional> #include <functional>
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class AttribDlg // class AttribDlg
@ -47,7 +50,7 @@ class AttribDlg : public finalcut::FDialog
AttribDlg& operator = (const AttribDlg&) = delete; AttribDlg& operator = (const AttribDlg&) = delete;
// Event handlers // Event handlers
virtual void onAccel (finalcut::FAccelEvent*) override; virtual void onKeyPress (finalcut::FKeyEvent*) override;
virtual void onWheel (finalcut::FWheelEvent*) override; virtual void onWheel (finalcut::FWheelEvent*) override;
virtual void onClose (finalcut::FCloseEvent*) override; virtual void onClose (finalcut::FCloseEvent*) override;
@ -77,10 +80,12 @@ AttribDlg::AttribDlg (finalcut::FWidget* parent)
+ finalcut::FString(getTermType()) + finalcut::FString(getTermType())
+ ")"); + ")");
next_button.setGeometry(int(getWidth()) - 13, int(getHeight()) - 4, 10, 1); next_button.setGeometry ( FPoint(int(getWidth()) - 13, int(getHeight()) - 4)
next_button.addAccelerator(finalcut::fc::Fkey_right); , FSize(10, 1) );
back_button.setGeometry(int(getWidth()) - 25, int(getHeight()) - 4, 10, 1); next_button.addAccelerator (finalcut::fc::Fkey_right);
back_button.addAccelerator(finalcut::fc::Fkey_left); back_button.setGeometry ( FPoint(int(getWidth()) - 25, int(getHeight()) - 4)
, FSize(10, 1) );
back_button.addAccelerator (finalcut::fc::Fkey_left);
// Add function callbacks // Add function callbacks
next_button.addCallback next_button.addCallback
@ -101,10 +106,18 @@ AttribDlg::~AttribDlg()
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void AttribDlg::onAccel (finalcut::FAccelEvent* ev) void AttribDlg::onKeyPress (finalcut::FKeyEvent* ev)
{ {
if ( ! ev )
return;
if ( ev->key() == 'q' )
{
close(); close();
ev->accept(); ev->accept();
}
else
finalcut::FDialog::onKeyPress(ev);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -168,11 +181,11 @@ void AttribDlg::adjustSize()
if ( y < 1 ) if ( y < 1 )
y = 1; y = 1;
setGeometry(x, y, 69, 21, false); setGeometry(FPoint(x, y), FSize(69, 21), false);
next_button.setGeometry ( int(getWidth()) - 13, int(getHeight()) - 4 next_button.setGeometry ( FPoint(int(getWidth()) - 13, int(getHeight()) - 4)
, 10, 1, false ); , FSize(10, 1), false );
back_button.setGeometry ( int(getWidth()) - 25, int(getHeight()) - 4 back_button.setGeometry ( FPoint(int(getWidth()) - 25, int(getHeight()) - 4)
, 10, 1, false ); , FSize(10, 1), false );
finalcut::FDialog::adjustSize(); finalcut::FDialog::adjustSize();
} }
@ -260,7 +273,7 @@ void AttribDemo::printAltCharset()
if ( ! isMonochron() ) if ( ! isMonochron() )
setColor (wc.label_fg, wc.label_bg); setColor (wc.label_fg, wc.label_bg);
setPrintPos (1, 1); setPrintPos (FPoint(1, 1));
print("alternate charset: "); print("alternate charset: ");
if ( parent->bgcolor == finalcut::fc::Default ) if ( parent->bgcolor == finalcut::fc::Default )
@ -427,7 +440,7 @@ void AttribDemo::draw()
for (std::size_t y = 0; y < getParentWidget()->getHeight() - 7; y++) for (std::size_t y = 0; y < getParentWidget()->getHeight() - 7; y++)
{ {
setPrintPos (1, 2 + int(y)); setPrintPos (FPoint(1, 2 + int(y)));
if ( ! isMonochron() ) if ( ! isMonochron() )
setColor (wc.label_fg, wc.label_bg); setColor (wc.label_fg, wc.label_bg);
@ -439,7 +452,7 @@ void AttribDemo::draw()
if ( ! isMonochron() ) if ( ! isMonochron() )
setColor(wc.label_fg, wc.label_bg); setColor(wc.label_fg, wc.label_bg);
setPrintPos (1, 15); setPrintPos (FPoint(1, 15));
FColor bg = static_cast<AttribDlg*>(getParent())->bgcolor; FColor bg = static_cast<AttribDlg*>(getParent())->bgcolor;
print (" Background color:"); print (" Background color:");
@ -448,7 +461,7 @@ void AttribDemo::draw()
else else
printf ( " %d", bg); printf ( " %d", bg);
setPrintPos (16, 17); setPrintPos (FPoint(16, 17));
print ("Change background color ->"); print ("Change background color ->");
} }
@ -466,13 +479,12 @@ int main (int argc, char* argv[])
// the parent object "app" (FObject destructor). // the parent object "app" (FObject destructor).
AttribDlg dialog(&app); AttribDlg dialog(&app);
dialog.setGeometry (6, 2, 69, 21); dialog.setGeometry (FPoint(6, 2), FSize(69, 21));
dialog.addAccelerator('q'); // press 'q' to quit
dialog.setShadow(); dialog.setShadow();
// Create the attribute demo widget as a child object from the dialog // Create the attribute demo widget as a child object from the dialog
AttribDemo demo(&dialog); AttribDemo demo(&dialog);
demo.setGeometry (1, 1, 67, 19); demo.setGeometry (FPoint(1, 1), FSize(67, 19));
// Set the dialog object as main widget // Set the dialog object as main widget
app.setMainWidget(&dialog); app.setMainWidget(&dialog);

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2014-2018 Markus Gans * * Copyright 2014-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -59,11 +59,11 @@ Timer::Timer (finalcut::FWidget* parent)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Timer::draw() void Timer::draw()
{ {
setPrintPos (1, 1); setPrintPos (finalcut::FPoint(1, 1));
print() << "---------------\n" print() << "---------------\n"
<< "Press Q to quit\n" << "Press Q to quit\n"
<< "---------------\n"; << "---------------\n";
setAreaCursor (1, 4, true, vdesktop); setAreaCursor (finalcut::FPoint(1, 4), true, vdesktop);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -81,7 +81,8 @@ void Timer::onTimer (finalcut::FTimerEvent* ev)
if ( is_last_line ) if ( is_last_line )
scrollAreaForward (vdesktop); scrollAreaForward (vdesktop);
setAreaCursor (1, getPrintPos().getY(), true, vdesktop); setAreaCursor ( finalcut::FPoint(1, getPrintPos().getY())
, true, vdesktop );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2016-2018 Markus Gans * * Copyright 2016-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -22,6 +22,9 @@
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class Transparent // class Transparent
@ -108,7 +111,7 @@ void Transparent::draw()
for (int n = 1; n <= int(getClientHeight()); n++) for (int n = 1; n <= int(getClientHeight()); n++)
{ {
setPrintPos (2, 2 + n); setPrintPos (FPoint(2, 2 + n));
print(line); print(line);
} }
@ -206,17 +209,17 @@ MainWindow::MainWindow (finalcut::FWidget* parent)
// is not required in this class and would result in a double free. // is not required in this class and would result in a double free.
transpwin = new Transparent(this); transpwin = new Transparent(this);
transpwin->setText("transparent"); transpwin->setText("transparent");
transpwin->setGeometry (6, 3, 29, 12); transpwin->setGeometry (FPoint(6, 3), FSize(29, 12));
transpwin->unsetTransparentShadow(); transpwin->unsetTransparentShadow();
shadowwin = new Transparent(this, Transparent::shadow); shadowwin = new Transparent(this, Transparent::shadow);
shadowwin->setText("shadow"); shadowwin->setText("shadow");
shadowwin->setGeometry (46, 11, 29, 12); shadowwin->setGeometry (FPoint(46, 11), FSize(29, 12));
shadowwin->unsetTransparentShadow(); shadowwin->unsetTransparentShadow();
ibg = new Transparent(this, Transparent::inherit_background); ibg = new Transparent(this, Transparent::inherit_background);
ibg->setText("inherit background"); ibg->setText("inherit background");
ibg->setGeometry (42, 3, 29, 7); ibg->setGeometry (FPoint(42, 3), FSize(29, 7));
ibg->unsetTransparentShadow(); ibg->unsetTransparentShadow();
// Statusbar at the bottom // Statusbar at the bottom
@ -239,9 +242,9 @@ void MainWindow::draw()
setReverse(true); setReverse(true);
setColor(); setColor();
setPrintPos (2, 4); setPrintPos (FPoint(2, 4));
print(line1); print(line1);
setPrintPos (2, 5); setPrintPos (FPoint(2, 5));
print(line2); print(line2);
if ( isMonochron() ) if ( isMonochron() )
@ -287,7 +290,7 @@ int main (int argc, char* argv[])
// Create main dialog object // Create main dialog object
MainWindow main_dlg (&app); MainWindow main_dlg (&app);
main_dlg.setText ("non-transparent"); main_dlg.setText ("non-transparent");
main_dlg.setGeometry (8, 16, 26, 7); main_dlg.setGeometry (FPoint(8, 16), FSize(26, 7));
// Set dialog main_dlg as main widget // Set dialog main_dlg as main widget
app.setMainWidget (&main_dlg); app.setMainWidget (&main_dlg);

View File

@ -27,6 +27,9 @@
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
// Function prototypes // Function prototypes
sInt64 StringToNumber (const finalcut::FString&); sInt64 StringToNumber (const finalcut::FString&);
@ -303,7 +306,7 @@ Treeview::Treeview (finalcut::FWidget* parent)
: finalcut::FDialog(parent) : finalcut::FDialog(parent)
{ {
// Set FListView geometry // Set FListView geometry
listView.setGeometry(2, 1, 53, 14); listView.setGeometry(FPoint(2, 1), FSize(53, 14));
// Add columns to the view // Add columns to the view
listView.addColumn ("Name", 23); listView.addColumn ("Name", 23);
@ -358,7 +361,7 @@ Treeview::Treeview (finalcut::FWidget* parent)
} }
// Quit button // Quit button
Quit.setGeometry(24, 16, 10, 1); Quit.setGeometry(FPoint(24, 16), FSize(10, 1));
Quit.setText (L"&Quit"); Quit.setText (L"&Quit");
// Add some function callbacks // Add some function callbacks
@ -415,7 +418,8 @@ int main (int argc, char* argv[])
// Create main dialog object // Create main dialog object
Treeview d(&app); Treeview d(&app);
d.setText (L"Continents"); d.setText (L"Continents");
d.setGeometry (int(1 + (app.getWidth() - 57) / 2), 3, 57, 20); d.setGeometry ( FPoint(int(1 + (app.getWidth() - 57) / 2), 3)
, FSize(57, 20) );
d.setShadow(); d.setShadow();
// Set dialog d as main widget // Set dialog d as main widget

View File

@ -26,6 +26,9 @@
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class ProgressDialog // class ProgressDialog
@ -71,25 +74,26 @@ class ProgressDialog : public finalcut::FDialog
ProgressDialog::ProgressDialog (finalcut::FWidget* parent) ProgressDialog::ProgressDialog (finalcut::FWidget* parent)
: finalcut::FDialog(parent) : finalcut::FDialog(parent)
{ {
setGeometry (int((getParentWidget()->getWidth() - 40) / 2), 7, 40, 10); setGeometry ( FPoint(int((getParentWidget()->getWidth() - 40) / 2), 7)
, FSize(40, 10) );
setText("Progress bar"); setText("Progress bar");
//setModal(); //setModal();
reset.setText("&Reset"); reset.setText("&Reset");
reset.setStatusbarMessage ("Reset the progress bar"); reset.setStatusbarMessage ("Reset the progress bar");
reset.setGeometry(2, 6, 8, 1, false); reset.setGeometry(FPoint(2, 6), FSize(8, 1), false);
reset.setDisable(); reset.setDisable();
more.setText("&More"); more.setText("&More");
more.setStatusbarMessage ("Increases the progress bar position"); more.setStatusbarMessage ("Increases the progress bar position");
more.setGeometry(15, 6, 8, 1, false); more.setGeometry(FPoint(15, 6), FSize(8, 1), false);
more.setDisable(); more.setDisable();
quit.setText("E&xit"); quit.setText("E&xit");
quit.setGeometry(28, 6, 8, 1, false); quit.setGeometry(FPoint(28, 6), FSize(8, 1), false);
quit.setDisable(); quit.setDisable();
progressBar.setGeometry(2, 3, 34, 1, false); progressBar.setGeometry(FPoint(2, 3), FSize(34, 1), false);
//progressBar.setPercentage(78); //progressBar.setPercentage(78);
reset.addCallback reset.addCallback
@ -211,8 +215,8 @@ TextWindow::TextWindow (finalcut::FWidget* parent)
: finalcut::FDialog(parent) : finalcut::FDialog(parent)
{ {
scrollText.ignorePadding(); scrollText.ignorePadding();
scrollText.setGeometry (1, 2, getWidth(), getHeight() - 1); scrollText.setGeometry (FPoint(1, 2), FSize(getWidth(), getHeight() - 1));
setMinimumSize (51, 6); setMinimumSize (FSize(51, 6));
scrollText.setFocus(); scrollText.setFocus();
scrollText.insert(" -----------------------------------------------\n" scrollText.insert(" -----------------------------------------------\n"
" line 1\n" " line 1\n"
@ -238,7 +242,7 @@ void TextWindow::append (const finalcut::FString& str)
void TextWindow::adjustSize() void TextWindow::adjustSize()
{ {
finalcut::FDialog::adjustSize(); finalcut::FDialog::adjustSize();
scrollText.setGeometry (1, 2, getWidth(), getHeight() - 1); scrollText.setGeometry (FPoint(1, 2), FSize(getWidth(), getHeight() - 1));
} }
@ -550,7 +554,7 @@ void MyDialog::initWidgets()
initToggleButtons(); initToggleButtons();
// A text input field // A text input field
myLineEdit.setGeometry(22, 1, 10, 1); myLineEdit.setGeometry(FPoint(22, 1), FSize(10, 1));
myLineEdit.setLabelText (L"&Input"); myLineEdit.setLabelText (L"&Input");
myLineEdit.setStatusbarMessage ("Press Enter to set the title"); myLineEdit.setStatusbarMessage ("Press Enter to set the title");
myLineEdit << finalcut::FString("EnTry").toLower(); myLineEdit << finalcut::FString("EnTry").toLower();
@ -559,7 +563,7 @@ void MyDialog::initWidgets()
initButtons(); initButtons();
// A multiple selection listbox // A multiple selection listbox
myList.setGeometry(38, 1, 14, 17); myList.setGeometry(FPoint(38, 1), FSize(14, 17));
myList.setText ("Items"); myList.setText ("Items");
myList.setStatusbarMessage ("99 items in a list"); myList.setStatusbarMessage ("99 items in a list");
myList.setMultiSelection(); myList.setMultiSelection();
@ -575,21 +579,21 @@ void MyDialog::initWidgets()
void MyDialog::initFlatButtons() void MyDialog::initFlatButtons()
{ {
// Flat buttons // Flat buttons
MyButton1.setGeometry(3, 3, 5, 1); MyButton1.setGeometry(FPoint(3, 3), FSize(5, 1));
MyButton1.setText (L"&SIN"); MyButton1.setText (L"&SIN");
MyButton1.setStatusbarMessage ("Sine function"); MyButton1.setStatusbarMessage ("Sine function");
MyButton1.setNoUnderline(); MyButton1.setNoUnderline();
MyButton1.setFlat(); MyButton1.setFlat();
MyButton1.setDoubleFlatLine (finalcut::fc::bottom); MyButton1.setDoubleFlatLine (finalcut::fc::bottom);
MyButton2.setGeometry(3, 5, 5, 1); MyButton2.setGeometry(FPoint(3, 5), FSize(5, 1));
MyButton2.setText (L"&COS"); MyButton2.setText (L"&COS");
MyButton2.setStatusbarMessage ("Cosine function"); MyButton2.setStatusbarMessage ("Cosine function");
MyButton2.setNoUnderline(); MyButton2.setNoUnderline();
MyButton2.setFlat(); MyButton2.setFlat();
MyButton2.setDoubleFlatLine (finalcut::fc::top); MyButton2.setDoubleFlatLine (finalcut::fc::top);
MyButton3.setGeometry(10, 3, 5, 3); MyButton3.setGeometry(FPoint(10, 3), FSize(5, 3));
MyButton3.setText (L"&="); MyButton3.setText (L"&=");
MyButton3.setStatusbarMessage ("Equal"); MyButton3.setStatusbarMessage ("Equal");
MyButton3.setNoUnderline(); MyButton3.setNoUnderline();
@ -619,25 +623,25 @@ void MyDialog::initFlatButtons()
void MyDialog::initToggleButtons() void MyDialog::initToggleButtons()
{ {
// Radio buttons in a group // Radio buttons in a group
radioButtonGroup.setGeometry(3, 8, 14, 4); radioButtonGroup.setGeometry(FPoint(3, 8), FSize(14, 4));
//radioButtonGroup->unsetBorder(); //radioButtonGroup->unsetBorder();
radio1.setGeometry(1, 1, 10, 1); radio1.setGeometry(FPoint(1, 1), FSize(10, 1));
radio1.setStatusbarMessage ("Enable button Test"); radio1.setStatusbarMessage ("Enable button Test");
radio2.setGeometry(1, 2, 11, 1); radio2.setGeometry(FPoint(1, 2), FSize(11, 1));
radio2.setText ("&Disable"); radio2.setText ("&Disable");
radio2.setStatusbarMessage ("Disable button Test"); radio2.setStatusbarMessage ("Disable button Test");
radio2.setChecked(); radio2.setChecked();
//radio2.setDisable(); //radio2.setDisable();
// Checkboxes in a group // Checkboxes in a group
checkButtonGroup.setGeometry(3, 12, 14, 4); checkButtonGroup.setGeometry(FPoint(3, 12), FSize(14, 4));
check1.setGeometry(1, 1, 11, 1); check1.setGeometry(FPoint(1, 1), FSize(11, 1));
check1.setNoUnderline(); check1.setNoUnderline();
check2.setGeometry(1, 2, 9, 1); check2.setGeometry(FPoint(1, 2), FSize(9, 1));
check2.setChecked(); check2.setChecked();
check2.setNoUnderline(); check2.setNoUnderline();
} }
@ -646,17 +650,17 @@ void MyDialog::initToggleButtons()
void MyDialog::initButtons() void MyDialog::initButtons()
{ {
// Buttons // Buttons
MyButton4.setGeometry(20, 8, 12, 1); MyButton4.setGeometry(FPoint(20, 8), FSize(12, 1));
MyButton4.setText (L"&Get input"); MyButton4.setText (L"&Get input");
MyButton4.setStatusbarMessage ("Take text from input field"); MyButton4.setStatusbarMessage ("Take text from input field");
MyButton4.setFocus(); MyButton4.setFocus();
MyButton5.setGeometry(20, 11, 12, 1); MyButton5.setGeometry(FPoint(20, 11), FSize(12, 1));
MyButton5.setText (L"&Test"); MyButton5.setText (L"&Test");
MyButton5.setStatusbarMessage ("Progressbar testing dialog"); MyButton5.setStatusbarMessage ("Progressbar testing dialog");
MyButton5.setDisable(); MyButton5.setDisable();
MyButton6.setGeometry(20, 14, 12, 1); MyButton6.setGeometry(FPoint(20, 14), FSize(12, 1));
MyButton6.setText (L"&Quit"); MyButton6.setText (L"&Quit");
MyButton6.setStatusbarMessage ("Exit the program"); MyButton6.setStatusbarMessage ("Exit the program");
MyButton6.addAccelerator('x'); MyButton6.addAccelerator('x');
@ -686,20 +690,20 @@ void MyDialog::initButtons()
void MyDialog::initLabels() void MyDialog::initLabels()
{ {
// Text labels // Text labels
headline.setGeometry(21, 3, 10, 1); headline.setGeometry(FPoint(21, 3), FSize(10, 1));
headline.setEmphasis(); headline.setEmphasis();
headline.setAlignment (finalcut::fc::alignCenter); headline.setAlignment (finalcut::fc::alignCenter);
headline = L"List items"; headline = L"List items";
tagged.setGeometry(21, 4, 7, 1); tagged.setGeometry(FPoint(21, 4), FSize(7, 1));
tagged_count.setGeometry(29, 4, 5, 1); tagged_count.setGeometry(FPoint(29, 4), FSize(5, 1));
tagged_count << 0; tagged_count << 0;
sum.setGeometry(21, 5, 7, 3); sum.setGeometry(FPoint(21, 5), FSize(7, 3));
sum.setAlignment (finalcut::fc::alignRight); sum.setAlignment (finalcut::fc::alignRight);
sum_count.setGeometry(29, 5, 5, 3); sum_count.setGeometry(FPoint(29, 5), FSize(5, 3));
sum_count << myList.getCount(); sum_count << myList.getCount();
} }
@ -822,21 +826,21 @@ void MyDialog::cb_drives (finalcut::FWidget*, FDataPtr)
if ( isNewFont() ) if ( isNewFont() )
{ {
finalcut::FLabel drive (finalcut::NF_Drive, &info2); finalcut::FLabel drive (finalcut::NF_Drive, &info2);
drive.setGeometry (11, 2, 4, 1); drive.setGeometry (FPoint(11, 2), FSize(4, 1));
finalcut::FLabel net (finalcut::NF_Net_Drive, &info2); finalcut::FLabel net (finalcut::NF_Net_Drive, &info2);
net.setGeometry (11, 4, 4, 1); net.setGeometry (FPoint(11, 4), FSize(4, 1));
finalcut::FLabel cd (finalcut::NF_CD_ROM, &info2); finalcut::FLabel cd (finalcut::NF_CD_ROM, &info2);
cd.setGeometry (11, 6, 4, 1); cd.setGeometry (FPoint(11, 6), FSize(4, 1));
info2.exec(); info2.exec();
} }
else else
{ {
finalcut::FLabel drive (" - ", &info2); finalcut::FLabel drive (" - ", &info2);
drive.setGeometry (11, 2, 4, 1); drive.setGeometry (FPoint(11, 2), FSize(4, 1));
finalcut::FLabel net (" N ", &info2); finalcut::FLabel net (" N ", &info2);
net.setGeometry (11, 4, 4, 1); net.setGeometry (FPoint(11, 4), FSize(4, 1));
finalcut::FLabel cd (" CD ", &info2); finalcut::FLabel cd (" CD ", &info2);
cd.setGeometry (11, 6, 4, 1); cd.setGeometry (FPoint(11, 6), FSize(4, 1));
if ( isMonochron() ) if ( isMonochron() )
{ {
@ -962,10 +966,9 @@ void MyDialog::cb_view (finalcut::FWidget*, FDataPtr data)
const auto& view = new TextWindow(this); const auto& view = new TextWindow(this);
finalcut::FString filename(basename(const_cast<char*>(file.c_str()))); finalcut::FString filename(basename(const_cast<char*>(file.c_str())));
view->setText ("Viewer: " + filename); view->setText ("Viewer: " + filename);
view->setGeometry ( 1 + int((getRootWidget()->getWidth() - 60) / 2), view->setGeometry ( FPoint ( 1 + int((getRootWidget()->getWidth() - 60) / 2),
int(getRootWidget()->getHeight() / 6), int(getRootWidget()->getHeight() / 6) )
60, , FSize(60, getRootWidget()->getHeight() * 3 / 4) );
getRootWidget()->getHeight() * 3 / 4 );
view->setResizeable(); view->setResizeable();
std::string line = ""; std::string line = "";
std::ifstream infile; std::ifstream infile;
@ -1021,7 +1024,8 @@ int main (int argc, char* argv[])
// Create main dialog object d // Create main dialog object d
MyDialog d(&app); MyDialog d(&app);
d.setText (title); d.setText (title);
d.setGeometry (int((app.getWidth() - 56) / 2), 2, 56, app.getHeight() - 4); d.setGeometry ( FPoint(int((app.getWidth() - 56) / 2), 2)
, FSize(56, app.getHeight() - 4) );
d.setShadow(); d.setShadow();
// Set the dialog object d as the main widget of the application. // Set the dialog object d as the main widget of the application.

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2015-2018 Markus Gans * * Copyright 2015-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -23,6 +23,9 @@
#include <ctime> #include <ctime>
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class Watch // class Watch
@ -78,20 +81,20 @@ Watch::Watch (FWidget* parent)
{ {
setText ("Watch"); setText ("Watch");
int pw = int(getParentWidget()->getWidth()); int pw = int(getParentWidget()->getWidth());
setGeometry (1 + (pw - 22) / 2, 3, 22, 13); setGeometry (FPoint(1 + (pw - 22) / 2, 3), FSize(22, 13));
// Labels // Labels
time_label.setGeometry(5, 2, 5, 1); time_label.setGeometry(FPoint(5, 2), FSize(5, 1));
time_label.setEmphasis(); time_label.setEmphasis();
time_str.setGeometry(10, 2, 8, 1); time_str.setGeometry(FPoint(10, 2), FSize(8, 1));
// Checkbox buttons // Checkbox buttons
clock_sw.setGeometry(4, 4, 9, 1); clock_sw.setGeometry(FPoint(4, 4), FSize(9, 1));
seconds_sw.setGeometry(2, 6, 11, 1); seconds_sw.setGeometry(FPoint(2, 6), FSize(11, 1));
sec = seconds_sw.setChecked(); sec = seconds_sw.setChecked();
// Quit button // Quit button
quit_btn.setGeometry(6, 9, 9, 1); quit_btn.setGeometry(FPoint(6, 9), FSize(9, 1));
// Connect switch signal "toggled" with a callback member function // Connect switch signal "toggled" with a callback member function
clock_sw.addCallback clock_sw.addCallback

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2016-2018 Markus Gans * * Copyright 2016-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -23,6 +23,9 @@
#include <vector> #include <vector>
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class SmallWindow // class SmallWindow
@ -75,24 +78,24 @@ SmallWindow::SmallWindow (finalcut::FWidget* parent)
left_arrow.setForegroundColor (wc.label_inactive_fg); left_arrow.setForegroundColor (wc.label_inactive_fg);
left_arrow.setEmphasis(); left_arrow.setEmphasis();
left_arrow.ignorePadding(); left_arrow.ignorePadding();
left_arrow.setGeometry (2, 2, 1, 1); left_arrow.setGeometry (FPoint(2, 2), FSize(1, 1));
right_arrow = arrow_up; right_arrow = arrow_up;
right_arrow.setForegroundColor (wc.label_inactive_fg); right_arrow.setForegroundColor (wc.label_inactive_fg);
right_arrow.setEmphasis(); right_arrow.setEmphasis();
right_arrow.ignorePadding(); right_arrow.ignorePadding();
right_arrow.setGeometry (int(getWidth()) - 1, 2, 1, 1); right_arrow.setGeometry (FPoint(int(getWidth()) - 1, 2), FSize(1, 1));
top_left_label = "menu"; top_left_label = "menu";
top_left_label.setForegroundColor (wc.label_inactive_fg); top_left_label.setForegroundColor (wc.label_inactive_fg);
top_left_label.setEmphasis(); top_left_label.setEmphasis();
top_left_label.setGeometry (1, 1, 6, 1); top_left_label.setGeometry (FPoint(1, 1), FSize(6, 1));
top_right_label = "zoom"; top_right_label = "zoom";
top_right_label.setAlignment (finalcut::fc::alignRight); top_right_label.setAlignment (finalcut::fc::alignRight);
top_right_label.setForegroundColor (wc.label_inactive_fg); top_right_label.setForegroundColor (wc.label_inactive_fg);
top_right_label.setEmphasis(); top_right_label.setEmphasis();
top_right_label.setGeometry (int(getClientWidth()) - 5, 1, 6, 1); top_right_label.setGeometry (FPoint(int(getClientWidth()) - 5, 1), FSize(6, 1));
finalcut::FString bottom_label_text = "resize\n" finalcut::FString bottom_label_text = "resize\n"
"corner\n"; "corner\n";
@ -101,7 +104,7 @@ SmallWindow::SmallWindow (finalcut::FWidget* parent)
bottom_label.setAlignment (finalcut::fc::alignRight); bottom_label.setAlignment (finalcut::fc::alignRight);
bottom_label.setForegroundColor (wc.label_inactive_fg); bottom_label.setForegroundColor (wc.label_inactive_fg);
bottom_label.setEmphasis(); bottom_label.setEmphasis();
bottom_label.setGeometry (13, 3, 6, 3); bottom_label.setGeometry (FPoint(13, 3), FSize(6, 3));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -126,9 +129,12 @@ void SmallWindow::adjustSize()
} }
finalcut::FDialog::adjustSize(); finalcut::FDialog::adjustSize();
right_arrow.setGeometry (int(getWidth()) - 1, 2, 1, 1); right_arrow.setGeometry ( FPoint(int(getWidth()) - 1, 2)
top_right_label.setGeometry (int(getClientWidth()) - 5, 1, 6, 1); , FSize(1, 1) );
bottom_label.setGeometry (1, int(getClientHeight()) - 2, getClientWidth(), 3); top_right_label.setGeometry ( FPoint(int(getClientWidth()) - 5, 1)
, FSize(6, 1) );
bottom_label.setGeometry ( FPoint(1, int(getClientHeight()) - 2)
, FSize(getClientWidth(), 3) );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -309,11 +315,11 @@ void Window::configureFileMenuItems()
void Window::configureDialogButtons() void Window::configureDialogButtons()
{ {
// Dialog buttons // Dialog buttons
CreateButton.setGeometry (2, 2, 9, 1); CreateButton.setGeometry (FPoint(2, 2), FSize(9, 1));
CreateButton.setText (L"&Create"); CreateButton.setText (L"&Create");
CloseButton.setGeometry (15, 2, 9, 1); CloseButton.setGeometry (FPoint(15, 2), FSize(9, 1));
CloseButton.setText (L"C&lose"); CloseButton.setText (L"C&lose");
QuitButton.setGeometry (28, 2, 9, 1); QuitButton.setGeometry (FPoint(28, 2), FSize(9, 1));
QuitButton.setText (L"&Quit"); QuitButton.setText (L"&Quit");
// Add button callback // Add button callback
@ -350,7 +356,7 @@ void Window::adjustSize()
if ( Y < 2 ) if ( Y < 2 )
Y = 2; Y = 2;
setPos (X, Y); setPos (FPoint(X, Y));
auto first = windows.begin(); auto first = windows.begin();
auto iter = first; auto iter = first;
@ -361,7 +367,7 @@ void Window::adjustSize()
int n = int(std::distance(first, iter)) int n = int(std::distance(first, iter))
, x = dx + 5 + (n % 3) * 25 + int(n / 3) * 3 , x = dx + 5 + (n % 3) * 25 + int(n / 3) * 3
, y = dy + 11 + int(n / 3) * 3; , y = dy + 11 + int(n / 3) * 3;
(*iter)->dgl->setPos (x, y); (*iter)->dgl->setPos (FPoint(x, y));
} }
++iter; ++iter;
@ -426,8 +432,8 @@ void Window::cb_createWindows (finalcut::FWidget*, FDataPtr)
int n = int(std::distance(first, iter)) int n = int(std::distance(first, iter))
, x = dx + 5 + (n % 3) * 25 + int(n / 3) * 3 , x = dx + 5 + (n % 3) * 25 + int(n / 3) * 3
, y = dy + 11 + int(n / 3) * 3; , y = dy + 11 + int(n / 3) * 3;
win->setGeometry (x, y, 20, 8); win->setGeometry (FPoint(x, y), FSize(20, 8));
win->setMinimumSize (20, 8); win->setMinimumSize (FSize(20, 8));
win->setResizeable(); win->setResizeable();
win->show(); win->show();
@ -563,7 +569,8 @@ int main (int argc, char* argv[])
// Create main dialog object // Create main dialog object
Window main_dlg (&app); Window main_dlg (&app);
main_dlg.setText ("Main window"); main_dlg.setText ("Main window");
main_dlg.setGeometry (int(1 + (app.getWidth() - 40) / 2), 2, 40, 6); main_dlg.setGeometry ( FPoint(int(1 + (app.getWidth() - 40) / 2), 2)
, FSize(40, 6) );
// Set dialog main_dlg as main widget // Set dialog main_dlg as main widget
app.setMainWidget (&main_dlg); app.setMainWidget (&main_dlg);

View File

@ -188,12 +188,12 @@ bool FButton::setShadow (bool enable)
&& getEncoding() != fc::ASCII ) && getEncoding() != fc::ASCII )
{ {
flags.shadow = true; flags.shadow = true;
setShadowSize(1, 1); setShadowSize(FSize(1, 1));
} }
else else
{ {
flags.shadow = false; flags.shadow = false;
setShadowSize(0, 0); setShadowSize(FSize(0, 0));
} }
return flags.shadow; return flags.shadow;
@ -253,7 +253,7 @@ void FButton::hide()
for (std::size_t y = 0; y < getHeight() + s + (f << 1); y++) for (std::size_t y = 0; y < getHeight() + s + (f << 1); y++)
{ {
setPrintPos (1 - int(f), 1 + int(y - f)); setPrintPos (FPoint(1 - int(f), 1 + int(y - f)));
print (blank); print (blank);
} }
@ -491,7 +491,7 @@ inline std::size_t FButton::clickAnimationIndent (FWidget* parent_widget)
for (std::size_t y = 1; y <= getHeight(); y++) for (std::size_t y = 1; y <= getHeight(); y++)
{ {
setPrintPos (1, int(y)); setPrintPos (FPoint(1, int(y)));
print (' '); // clear one left █ print (' '); // clear one left █
} }
@ -514,7 +514,7 @@ inline void FButton::clearRightMargin (FWidget* parent_widget)
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); // Light background setReverse(true); // Light background
setPrintPos (1 + int(getWidth()), y); setPrintPos (FPoint(1 + int(getWidth()), y));
print (' '); // clear right print (' '); // clear right
if ( flags.active && isMonochron() ) if ( flags.active && isMonochron() )
@ -531,7 +531,7 @@ inline void FButton::drawMarginLeft()
for (std::size_t y = 0; y < getHeight(); y++) for (std::size_t y = 0; y < getHeight(); y++)
{ {
setPrintPos (1 + int(indent), 1 + int(y)); setPrintPos (FPoint(1 + int(indent), 1 + int(y)));
if ( isMonochron() && active_focus && y == vcenter_offset ) if ( isMonochron() && active_focus && y == vcenter_offset )
print (fc::BlackRightPointingPointer); // ► print (fc::BlackRightPointingPointer); // ►
@ -547,7 +547,7 @@ inline void FButton::drawMarginRight()
for (std::size_t y = 0; y < getHeight(); y++) for (std::size_t y = 0; y < getHeight(); y++)
{ {
setPrintPos (int(getWidth() + indent), 1 + int(y)); setPrintPos (FPoint(int(getWidth() + indent), 1 + int(y)));
if ( isMonochron() && active_focus && y == vcenter_offset ) if ( isMonochron() && active_focus && y == vcenter_offset )
print (fc::BlackLeftPointingPointer); // ◄ print (fc::BlackLeftPointingPointer); // ◄
@ -566,7 +566,7 @@ inline void FButton::drawTopBottomBackground()
for (std::size_t y = 0; y < vcenter_offset; y++) for (std::size_t y = 0; y < vcenter_offset; y++)
{ {
setPrintPos (2 + int(indent), 1 + int(y)); setPrintPos (FPoint(2 + int(indent), 1 + int(y)));
for (std::size_t x = 1; x < getWidth() - 1; x++) for (std::size_t x = 1; x < getWidth() - 1; x++)
print (space_char); // █ print (space_char); // █
@ -574,7 +574,7 @@ inline void FButton::drawTopBottomBackground()
for (std::size_t y = vcenter_offset + 1; y < getHeight(); y++) for (std::size_t y = vcenter_offset + 1; y < getHeight(); y++)
{ {
setPrintPos (2 + int(indent), 1 + int(y)); setPrintPos (FPoint(2 + int(indent), 1 + int(y)));
for (std::size_t x = 1; x < getWidth() - 1; x++) for (std::size_t x = 1; x < getWidth() - 1; x++)
print (space_char); // █ print (space_char); // █
@ -585,7 +585,7 @@ inline void FButton::drawTopBottomBackground()
inline void FButton::drawButtonTextLine (wchar_t button_text[]) inline void FButton::drawButtonTextLine (wchar_t button_text[])
{ {
std::size_t pos; std::size_t pos;
setPrintPos (2 + int(indent), 1 + int(vcenter_offset)); setPrintPos (FPoint(2 + int(indent), 1 + int(vcenter_offset)));
setColor (button_fg, button_bg); setColor (button_fg, button_bg);
if ( getWidth() < txtlength + 1 ) if ( getWidth() < txtlength + 1 )
@ -598,11 +598,11 @@ inline void FButton::drawButtonTextLine (wchar_t button_text[])
print (space_char); // █ print (space_char); // █
if ( hotkeypos == NOT_SET ) if ( hotkeypos == NOT_SET )
setCursorPos ( 2 + int(center_offset) setCursorPos (FPoint ( 2 + int(center_offset)
, 1 + int(vcenter_offset) ); // first character , 1 + int(vcenter_offset) )); // first character
else else
setCursorPos ( 2 + int(center_offset + hotkeypos) setCursorPos (FPoint ( 2 + int(center_offset + hotkeypos)
, 1 + int(vcenter_offset) ); // hotkey , 1 + int(vcenter_offset) )); // hotkey
if ( ! flags.active && isMonochron() ) if ( ! flags.active && isMonochron() )
setReverse(true); // Light background setReverse(true); // Light background
@ -643,7 +643,7 @@ inline void FButton::drawButtonTextLine (wchar_t button_text[])
if ( txtlength >= getWidth() - 1 ) if ( txtlength >= getWidth() - 1 )
{ {
// Print ellipsis // Print ellipsis
setPrintPos (int(getWidth() + indent) - 2, 1); setPrintPos (FPoint(int(getWidth() + indent) - 2, 1));
print (L".."); print (L"..");
} }

View File

@ -220,7 +220,7 @@ void FButtonGroup::hide()
for (int y = 0; y < int(getHeight()); y++) for (int y = 0; y < int(getHeight()); y++)
{ {
FWidget::setPrintPos (1, 1 + y); FWidget::setPrintPos (FPoint(1, 1 + y));
print (blank); print (blank);
} }
@ -296,8 +296,8 @@ void FButtonGroup::checkScrollSize (const FRect& r)
if ( ! scrollgeometry.contains(r) ) if ( ! scrollgeometry.contains(r) )
{ {
FRect new_size = scrollgeometry.combined(r); FRect r_combined = scrollgeometry.combined(r);
setScrollSize (new_size.getWidth(), new_size.getHeight()); setScrollSize (r_combined.getSize());
} }
} }
@ -449,9 +449,9 @@ void FButtonGroup::drawLabel()
length--; length--;
if ( hasBorder() ) if ( hasBorder() )
FWidget::setPrintPos (2, 1); FWidget::setPrintPos (FPoint(2, 1));
else else
FWidget::setPrintPos (0, 1); FWidget::setPrintPos (FPoint(0, 1));
drawText (LabelText, hotkeypos, length); drawText (LabelText, hotkeypos, length);
setViewportPrint(); setViewportPrint();
@ -475,7 +475,7 @@ void FButtonGroup::init()
{ {
setForegroundColor (wc.label_fg); setForegroundColor (wc.label_fg);
setBackgroundColor (wc.label_bg); setBackgroundColor (wc.label_bg);
setMinimumSize (7, 4); setMinimumSize (FSize(7, 4));
buttonlist.clear(); // no buttons yet buttonlist.clear(); // no buttons yet
} }

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2014-2017 Markus Gans * * Copyright 2014-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -72,7 +72,7 @@ void FCheckBox::drawCheckButton()
if ( ! isVisible() ) if ( ! isVisible() )
return; return;
setPrintPos (1, 1); setPrintPos (FPoint(1, 1));
setColor(); setColor();
if ( isMonochron() ) if ( isMonochron() )

View File

@ -161,9 +161,11 @@ int FDialog::exec()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FDialog::setPos (int x, int y, bool) void FDialog::setPos (const FPoint& pos, bool)
{ {
int rsw, bsh, width, height; int rsw, bsh, width, height;
int x = pos.getX();
int y = pos.getY();
FRect old_geometry; FRect old_geometry;
setPos_error = false; setPos_error = false;
@ -202,7 +204,7 @@ void FDialog::setPos (int x, int y, bool)
old_geometry = getTermGeometryWithShadow(); old_geometry = getTermGeometryWithShadow();
// move to the new position // move to the new position
FWindow::setPos(x, y, false); FWindow::setPos(pos, false);
putArea (getTermPos(), vwin); putArea (getTermPos(), vwin);
// restoring the non-covered terminal areas // restoring the non-covered terminal areas
@ -218,25 +220,25 @@ void FDialog::setPos (int x, int y, bool)
if ( dx > 0 ) if ( dx > 0 )
{ {
if ( dy > 0 ) if ( dy > 0 )
restoreVTerm ( old_x + width + rsw - dx, old_y restoreVTerm (FRect ( old_x + width + rsw - dx, old_y
, dx, height + bsh - dy ); , std::size_t(dx), std::size_t(height + bsh - dy) ));
else else
restoreVTerm ( old_x + width + rsw - dx, old_y + std::abs(dy) restoreVTerm (FRect ( old_x + width + rsw - dx, old_y + std::abs(dy)
, dx, height + bsh - std::abs(dy)); , std::size_t(dx), std::size_t(height + bsh - std::abs(dy)) ));
} }
else else
{ {
if ( dy > 0 ) if ( dy > 0 )
restoreVTerm (old_x, old_y, std::abs(dx), height + bsh - dy); restoreVTerm (FRect(old_x, old_y, std::size_t(std::abs(dx)), std::size_t(height + bsh - dy)));
else else
restoreVTerm ( old_x, old_y + std::abs(dy) restoreVTerm (FRect ( old_x, old_y + std::abs(dy)
, std::abs(dx), height + bsh - std::abs(dy) ); , std::size_t(std::abs(dx)), std::size_t(height + bsh - std::abs(dy)) ));
} }
if ( dy > 0 ) if ( dy > 0 )
restoreVTerm (old_x, old_y + height + bsh - dy, width + rsw, dy); restoreVTerm (FRect(old_x, old_y + height + bsh - dy, std::size_t(width + rsw), std::size_t(dy)));
else else
restoreVTerm (old_x, old_y, width + rsw, std::abs(dy)); restoreVTerm (FRect(old_x, old_y, std::size_t(width + rsw), std::size_t(std::abs(dy))));
} }
else else
{ {
@ -250,45 +252,45 @@ void FDialog::setPos (int x, int y, bool)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FDialog::move (int dx, int dy) void FDialog::move (const FPoint& d_pos)
{ {
setPos (getX() + dx, getY() + dy); setPos (getPos() + d_pos);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FDialog::moveUp (int n) inline bool FDialog::moveUp (int n)
{ {
move (0, -n); move (FPoint(0, -n));
return ! setPos_error; return ! setPos_error;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FDialog::moveDown (int n) inline bool FDialog::moveDown (int n)
{ {
move (0, n); move (FPoint(0, n));
return ! setPos_error; return ! setPos_error;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FDialog::moveLeft (int n) inline bool FDialog::moveLeft (int n)
{ {
move (-n, 0); move (FPoint(-n, 0));
return ! setPos_error; return ! setPos_error;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FDialog::moveRight (int n) inline bool FDialog::moveRight (int n)
{ {
move (n, 0); move (FPoint(n, 0));
return ! setPos_error; return ! setPos_error;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FDialog::setSize (std::size_t w, std::size_t h, bool adjust) void FDialog::setSize (const FSize& size, bool adjust)
{ {
setSize_error = false; setSize_error = false;
if ( getWidth() == w && getHeight() == h ) if ( getSize() == size )
{ {
setSize_error = true; setSize_error = true;
return; return;
@ -304,17 +306,17 @@ void FDialog::setSize (std::size_t w, std::size_t h, bool adjust)
, y = getTermY() , y = getTermY()
, old_width = int(getWidth()) , old_width = int(getWidth())
, old_height = int(getHeight()) , old_height = int(getHeight())
, dw = old_width - int(w) , dw = old_width - int(size.getWidth())
, dh = old_height - int(h); , dh = old_height - int(size.getHeight());
const auto& shadow = getShadow(); const auto& shadow = getShadow();
int rsw = int(shadow.getWidth()); // right shadow width; int rsw = int(shadow.getWidth()); // right shadow width;
int bsh = int(shadow.getHeight()); // bottom shadow height int bsh = int(shadow.getHeight()); // bottom shadow height
FWindow::setSize (w, h, adjust); FWindow::setSize (size, adjust);
// get adjust width and height // get adjust width and height
w = getWidth(); std::size_t w = getWidth();
h = getHeight(); std::size_t h = getHeight();
// dw > 0 : scale down width // dw > 0 : scale down width
// dw = 0 : scale only height // dw = 0 : scale only height
@ -325,10 +327,10 @@ void FDialog::setSize (std::size_t w, std::size_t h, bool adjust)
// restoring the non-covered terminal areas // restoring the non-covered terminal areas
if ( dw > 0 ) if ( dw > 0 )
restoreVTerm (x + int(w) + rsw, y, dw, int(h) + bsh + dh); // restore right restoreVTerm (FRect(x + int(w) + rsw, y, std::size_t(dw), h + std::size_t(bsh + dh))); // restore right
if ( dh > 0 ) if ( dh > 0 )
restoreVTerm (x, y + int(h) + bsh, int(w) + rsw + dw, dh); // restore bottom restoreVTerm (FRect(x, y + int(h) + bsh, w + std::size_t(rsw + dw), std::size_t(dh))); // restore bottom
redraw(); redraw();
@ -364,7 +366,7 @@ bool FDialog::reduceHeight (int n)
if ( ! isResizeable() ) if ( ! isResizeable() )
return false; return false;
setSize (getWidth(), getHeight() - std::size_t(n)); setSize (FSize(getWidth(), getHeight() - std::size_t(n)));
return ! setSize_error; return ! setSize_error;
} }
@ -374,7 +376,7 @@ bool FDialog::expandHeight (int n)
if ( ! isResizeable() || getHeight() + std::size_t(getY()) > getMaxHeight() ) if ( ! isResizeable() || getHeight() + std::size_t(getY()) > getMaxHeight() )
return false; return false;
setSize (getWidth(), getHeight() + std::size_t(n)); setSize (FSize(getWidth(), getHeight() + std::size_t(n)));
return ! setSize_error; return ! setSize_error;
} }
@ -384,7 +386,7 @@ bool FDialog::reduceWidth (int n)
if ( ! isResizeable() ) if ( ! isResizeable() )
return false; return false;
setSize (getWidth() - std::size_t(n), getHeight()); setSize (FSize(getWidth() - std::size_t(n), getHeight()));
return ! setSize_error; return ! setSize_error;
} }
@ -394,7 +396,7 @@ bool FDialog::expandWidth (int n)
if ( ! isResizeable() || getWidth() + std::size_t(getX()) > getMaxWidth() ) if ( ! isResizeable() || getWidth() + std::size_t(getX()) > getMaxWidth() )
return false; return false;
setSize (getWidth() + std::size_t(n), getHeight()); setSize (FSize(getWidth() + std::size_t(n), getHeight()));
return ! setSize_error; return ! setSize_error;
} }
@ -410,7 +412,7 @@ void FDialog::activateDialog()
setFocus(); setFocus();
setFocusWidget(this); setFocusWidget(this);
if ( win_focus && numOfFocusableChildren() > 1 ) if ( win_focus )
{ {
win_focus->setFocus(); win_focus->setFocus();
win_focus->redraw(); win_focus->redraw();
@ -771,7 +773,7 @@ void FDialog::draw()
clearArea(); clearArea();
drawBorder(); drawBorder();
drawTitleBar(); drawTitleBar();
setCursorPos(2, int(getHeight()) - 1); setCursorPos(FPoint(2, int(getHeight()) - 1));
if ( flags.shadow ) if ( flags.shadow )
drawDialogShadow(); drawDialogShadow();
@ -816,8 +818,8 @@ void FDialog::init()
ignorePadding(); ignorePadding();
setDialogWidget(); setDialogWidget();
// Initialize geometry values // Initialize geometry values
setGeometry (1, 1, 10, 10, false); setGeometry (FPoint(1, 1), FSize(10, 10), false);
setMinimumSize (15, 4); setMinimumSize (FSize(15, 4));
addDialog(this); addDialog(this);
setActiveWindow(this); setActiveWindow(this);
setTransparentShadow(); setTransparentShadow();
@ -860,7 +862,9 @@ void FDialog::initDialogMenu()
return; return;
} }
dialog_menu->setPos (getX(), getY() + 1); FPoint p = getPos();
p.y_ref()++;
dialog_menu->setPos (p);
dgl_menuitem = dialog_menu->getItem(); dgl_menuitem = dialog_menu->getItem();
dgl_menuitem->ignorePadding(); dgl_menuitem->ignorePadding();
dgl_menuitem->unsetFocusable(); dgl_menuitem->unsetFocusable();
@ -961,22 +965,22 @@ void FDialog::drawBorder()
{ {
for (int y = y1; y < y2; y++) for (int y = y1; y < y2; y++)
{ {
setPrintPos (x1, y); setPrintPos (FPoint(x1, y));
// Border left ⎸ // Border left ⎸
print (fc::NF_border_line_left); print (fc::NF_border_line_left);
setPrintPos (x2, y); setPrintPos (FPoint(x2, y));
// Border right⎹ // Border right⎹
print (fc::NF_rev_border_line_right); print (fc::NF_rev_border_line_right);
} }
setPrintPos (x1, y2); setPrintPos (FPoint(x1, y2));
// Lower left corner border ⎣ // Lower left corner border ⎣
print (fc::NF_border_corner_lower_left); print (fc::NF_border_corner_lower_left);
for (std::size_t x = 1; x < getWidth() - 1; x++) // low line _ for (std::size_t x = 1; x < getWidth() - 1; x++) // low line _
print (fc::NF_border_line_bottom); print (fc::NF_border_line_bottom);
setPrintPos (x2, y2); setPrintPos (FPoint(x2, y2));
// Lower right corner border ⎦ // Lower right corner border ⎦
print (fc::NF_rev_border_corner_lower_right); print (fc::NF_rev_border_corner_lower_right);
} }
@ -1003,7 +1007,7 @@ void FDialog::drawTitleBar()
if ( PRINT_WIN_NUMBER ) if ( PRINT_WIN_NUMBER )
{ {
// Print the number of window in stack // Print the number of window in stack
setPrintPos (getWidth() - 2, 1); setPrintPos (FPoint(int(getWidth()) - 2, 1));
printf ("(%d)", getWindowLayer(this)); printf ("(%d)", getWindowLayer(this));
} }
#endif // DEBUG #endif // DEBUG
@ -1013,7 +1017,7 @@ void FDialog::drawTitleBar()
void FDialog::drawBarButton() void FDialog::drawBarButton()
{ {
// Print the title button // Print the title button
setPrintPos (1, 1); setPrintPos (FPoint(1, 1));
if ( dialog_menu && dialog_menu->isShown() ) if ( dialog_menu && dialog_menu->isShown() )
setColor (wc.titlebar_button_focus_fg, wc.titlebar_button_focus_bg); setColor (wc.titlebar_button_focus_fg, wc.titlebar_button_focus_bg);
@ -1245,7 +1249,9 @@ void FDialog::openMenu()
else else
{ {
setOpenMenu(dialog_menu); setOpenMenu(dialog_menu);
dialog_menu->setPos (getX(), getY() + 1); FPoint pos = getPos();
pos.y_ref()++;
dialog_menu->setPos (pos);
dialog_menu->setVisible(); dialog_menu->setVisible();
dialog_menu->show(); dialog_menu->show();
dialog_menu->raiseWindow(); dialog_menu->raiseWindow();
@ -1514,7 +1520,8 @@ void FDialog::resizeMouseDown (const mouseStates& ms)
FPoint deltaPos = ms.termPos - lower_right_pos; FPoint deltaPos = ms.termPos - lower_right_pos;
int w = lower_right_pos.getX() + deltaPos.getX() - getTermX() + 1; int w = lower_right_pos.getX() + deltaPos.getX() - getTermX() + 1;
int h = lower_right_pos.getY() + deltaPos.getY() - getTermY() + 1; int h = lower_right_pos.getY() + deltaPos.getY() - getTermY() + 1;
setSize (std::size_t(w), std::size_t(h)); const FSize& size = FSize(std::size_t(w), std::size_t(h));
setSize (size, true);
} }
else else
drawBorder(); drawBorder();
@ -1557,8 +1564,9 @@ void FDialog::resizeMouseUpMove (const mouseStates& ms, bool mouse_up)
else else
h = int(getMaxHeight()) - getTermY() + y2_offset + 1; h = int(getMaxHeight()) - getTermY() + y2_offset + 1;
setSize ( ( w >= 0) ? std::size_t(w) : 0 const FSize size ( ( w >= 0) ? std::size_t(w) : 0
, ( h >= 0) ? std::size_t(h) : 0 ); , ( h >= 0) ? std::size_t(h) : 0 );
setSize (size);
} }
if ( mouse_up ) if ( mouse_up )
@ -1610,7 +1618,7 @@ inline void FDialog::cancelMoveSize()
setPos (save_geometry.getPos()); setPos (save_geometry.getPos());
if ( isResizeable() ) if ( isResizeable() )
setSize (save_geometry.getWidth(), save_geometry.getHeight()); setSize (save_geometry.getSize());
redraw(); redraw();
} }

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2014-2018 Markus Gans * * Copyright 2014-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -304,7 +304,7 @@ void FFileDialog::adjustSize()
setHeight (h, false); setHeight (h, false);
X = 1 + int((max_width - getWidth()) / 2); X = 1 + int((max_width - getWidth()) / 2);
Y = 1 + int((max_height - getHeight()) / 3); Y = 1 + int((max_height - getHeight()) / 3);
setPos(X, Y, false); setPos(FPoint(X, Y), false);
filebrowser.setHeight (h - 8, false); filebrowser.setHeight (h - 8, false);
hidden.setY (int(h) - 4, false); hidden.setY (int(h) - 4, false);
cancel.setY (int(h) - 4, false); cancel.setY (int(h) - 4, false);
@ -322,7 +322,7 @@ void FFileDialog::init()
static constexpr std::size_t h = 15; static constexpr std::size_t h = 15;
int x, y; int x, y;
setGeometry(1, 1, w, h, false); setGeometry(FPoint(1, 1), FSize(w, h), false);
auto parent_widget = getParentWidget(); auto parent_widget = getParentWidget();
if ( parent_widget ) if ( parent_widget )
@ -338,36 +338,36 @@ void FFileDialog::init()
else else
FDialog::setText("Open file"); FDialog::setText("Open file");
widgetSettings (x, y); // Create widgets widgetSettings (FPoint(x, y)); // Create widgets
initCallbacks(); initCallbacks();
setModal(); setModal();
readDir(); readDir();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FFileDialog::widgetSettings (int x, int y) inline void FFileDialog::widgetSettings (const FPoint& pos)
{ {
filename.setLabelText ("File&name"); filename.setLabelText ("File&name");
filename.setText (filter_pattern); filename.setText (filter_pattern);
filename.setGeometry (11, 1, 28, 1); filename.setGeometry (FPoint(11, 1), FSize(28, 1));
filename.setFocus(); filename.setFocus();
filebrowser.setGeometry (2, 3, 38, 6); filebrowser.setGeometry (FPoint(2, 3), FSize(38, 6));
printPath (directory); printPath (directory);
hidden.setText ("&hidden files"); hidden.setText ("&hidden files");
hidden.setGeometry (2, 10, 16, 1); hidden.setGeometry (FPoint(2, 10), FSize(16, 1));
cancel.setText ("&Cancel"); cancel.setText ("&Cancel");
cancel.setGeometry(19, 10, 9, 1); cancel.setGeometry(FPoint(19, 10), FSize(9, 1));
if ( dlg_type == FFileDialog::Save ) if ( dlg_type == FFileDialog::Save )
open.setText ("&Save"); open.setText ("&Save");
else else
open.setText ("&Open"); open.setText ("&Open");
open.setGeometry(30, 10, 9, 1); open.setGeometry(FPoint(30, 10), FSize(9, 1));
setGeometry (x, y, getWidth(), getHeight()); setPos (pos);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -234,7 +234,7 @@ void FLabel::setText (const FString& txt)
void FLabel::hide() void FLabel::hide()
{ {
FWidget::hide(); FWidget::hide();
hideSize (getWidth(), getHeight()); hideSize (getSize());
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -480,7 +480,7 @@ void FLabel::drawMultiLine()
else else
std::wcsncpy(dest, src, length); std::wcsncpy(dest, src, length);
setPrintPos (1, 1 + int(y)); setPrintPos (FPoint(1, 1 + int(y)));
if ( hotkeypos != NOT_SET ) if ( hotkeypos != NOT_SET )
{ {
@ -522,7 +522,7 @@ void FLabel::drawSingleLine()
if ( hotkeypos != NOT_SET ) if ( hotkeypos != NOT_SET )
length--; length--;
setPrintPos (1, 1); setPrintPos (FPoint(1, 1));
align_offset = getAlignOffset(length); align_offset = getAlignOffset(length);
printLine (label_text, length, hotkeypos, align_offset); printLine (label_text, length, hotkeypos, align_offset);
delete[] label_text; delete[] label_text;

View File

@ -230,12 +230,12 @@ bool FLineEdit::setShadow (bool enable)
&& getEncoding() != fc::ASCII ) && getEncoding() != fc::ASCII )
{ {
flags.shadow = true; flags.shadow = true;
setShadowSize(1, 1); setShadowSize(FSize(1, 1));
} }
else else
{ {
flags.shadow = false; flags.shadow = false;
setShadowSize(0, 0); setShadowSize(FSize(0, 0));
} }
return flags.shadow; return flags.shadow;
@ -275,8 +275,8 @@ void FLineEdit::hide()
label->hide(); label->hide();
FWidget::hide(); FWidget::hide();
std::size_t s = hasShadow() ? 1 : 0; FSize shadow = hasShadow() ? FSize(1, 1) : FSize(0, 0);
hideSize (getWidth() + s, getHeight() + s); hideSize (getSize() + shadow);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -598,12 +598,13 @@ void FLineEdit::adjustLabel()
switch ( label_orientation ) switch ( label_orientation )
{ {
case label_above: case label_above:
label->setGeometry(getX(), getY() - 1, label_length, 1); label->setGeometry ( FPoint(getX(), getY() - 1)
, FSize(label_length, 1) );
break; break;
case label_left: case label_left:
label->setGeometry(getX() - int(label_length) - 1, getY() label->setGeometry ( FPoint(getX() - int(label_length) - 1, getY())
, label_length, 1); , FSize(label_length, 1) );
break; break;
} }
} }
@ -677,7 +678,7 @@ void FLineEdit::drawInputField()
std::size_t x; std::size_t x;
FString show_text; FString show_text;
bool isActiveFocus = flags.active && flags.focus; bool isActiveFocus = flags.active && flags.focus;
setPrintPos (1, 1); setPrintPos (FPoint(1, 1));
if ( isMonochron() ) if ( isMonochron() )
{ {
@ -724,7 +725,7 @@ void FLineEdit::drawInputField()
drawShadow (); drawShadow ();
// set the cursor to the first pos. // set the cursor to the first pos.
setCursorPos (int(2 + cursor_pos - text_offset), 1); setCursorPos (FPoint(int(2 + cursor_pos - text_offset), 1));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -160,23 +160,22 @@ void FListBox::showInsideBrackets ( std::size_t index
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListBox::setGeometry ( int x, int y void FListBox::setGeometry ( const FPoint& pos, const FSize& size
, std::size_t w, std::size_t h , bool adjust)
, bool adjust )
{ {
// Set the widget geometry // Set the widget geometry
FWidget::setGeometry(x, y, w, h, adjust); FWidget::setGeometry(pos, size, adjust);
if ( isNewFont() ) if ( isNewFont() )
{ {
vbar->setGeometry (int(getWidth()), 2, 2, getHeight() - 2); vbar->setGeometry (FPoint(int(getWidth()), 2), FSize(2, getHeight() - 2));
hbar->setGeometry (1, int(getHeight()), getWidth() - 2 - nf_offset, 1); hbar->setGeometry (FPoint(1, int(getHeight())), FSize(getWidth() - 2 - nf_offset, 1));
} }
else else
{ {
vbar->setGeometry (int(getWidth()), 2, 1, getHeight() - 2); vbar->setGeometry (FPoint(int(getWidth()), 2), FSize(1, getHeight() - 2));
hbar->setGeometry (2, int(getHeight()), getWidth() - 2, 1); hbar->setGeometry (FPoint(2, int(getHeight())), FSize(getWidth() - 2, 1));
} }
} }
@ -215,7 +214,7 @@ void FListBox::setText (const FString& txt)
void FListBox::hide() void FListBox::hide()
{ {
FWidget::hide(); FWidget::hide();
hideSize (getWidth(), getHeight()); hideSize (getSize());
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -316,7 +315,7 @@ void FListBox::clear()
for (int y = 0; y < int(getHeight()) - 2; y++) for (int y = 0; y < int(getHeight()) - 2; y++)
{ {
setPrintPos (2, 2 + y); setPrintPos (FPoint(2, 2 + y));
print (blank); print (blank);
} }
@ -762,7 +761,7 @@ void FListBox::init()
{ {
initScrollbar (vbar, fc::vertical, &FListBox::cb_VBarChange); initScrollbar (vbar, fc::vertical, &FListBox::cb_VBarChange);
initScrollbar (hbar, fc::horizontal, &FListBox::cb_HBarChange); initScrollbar (hbar, fc::horizontal, &FListBox::cb_HBarChange);
setGeometry (1, 1, 5, 4, false); // initialize geometry values setGeometry (FPoint(1, 1), FSize(5, 4), false); // initialize geometry values
setForegroundColor (wc.dialog_fg); setForegroundColor (wc.dialog_fg);
setBackgroundColor (wc.dialog_bg); setBackgroundColor (wc.dialog_bg);
nf_offset = isNewFont() ? 1 : 0; nf_offset = isNewFont() ? 1 : 0;
@ -820,7 +819,7 @@ void FListBox::draw()
for (int y = 2; y < int(getHeight()); y++) for (int y = 2; y < int(getHeight()); y++)
{ {
setPrintPos (int(getWidth()), y); setPrintPos (FPoint(int(getWidth()), y));
print (' '); // clear right side of the scrollbar print (' '); // clear right side of the scrollbar
} }
} }
@ -855,7 +854,7 @@ void FListBox::drawHeadline()
FString txt = " " + text + " "; FString txt = " " + text + " ";
std::size_t length = txt.getLength(); std::size_t length = txt.getLength();
setPrintPos (2, 1); setPrintPos (FPoint(2, 1));
if ( isEnabled() ) if ( isEnabled() )
setColor(wc.label_emphasis_fg, wc.label_bg); setColor(wc.label_emphasis_fg, wc.label_bg);
@ -1061,7 +1060,7 @@ inline void FListBox::setLineAttributes ( int y
{ {
bool isCurrentLine = bool(y + yoffset + 1 == int(current)); bool isCurrentLine = bool(y + yoffset + 1 == int(current));
std::size_t inc_len = inc_search.getLength(); std::size_t inc_len = inc_search.getLength();
setPrintPos (2, 2 + int(y)); setPrintPos (FPoint(2, 2 + int(y)));
if ( isLineSelected ) if ( isLineSelected )
{ {
@ -1094,7 +1093,7 @@ inline void FListBox::setLineAttributes ( int y
setColor ( wc.selected_current_element_fg setColor ( wc.selected_current_element_fg
, wc.selected_current_element_bg ); , wc.selected_current_element_bg );
setCursorPos (3, 2 + int(y)); // first character setCursorPos (FPoint(3, 2 + int(y))); // first character
} }
else else
{ {
@ -1111,10 +1110,10 @@ inline void FListBox::setLineAttributes ( int y
{ {
serach_mark = true; serach_mark = true;
// Place the cursor on the last found character // Place the cursor on the last found character
setCursorPos (2 + b + int(inc_len), 2 + int(y)); setCursorPos (FPoint(2 + b + int(inc_len), 2 + int(y)));
} }
else // only highlighted else // only highlighted
setCursorPos (3 + b, 2 + int(y)); // first character setCursorPos (FPoint(3 + b, 2 + int(y))); // first character
} }
else else
setColor ( wc.current_element_fg setColor ( wc.current_element_fg

View File

@ -650,23 +650,22 @@ fc::sorting_type FListView::getColumnSortType (int column) const
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::setGeometry ( int x, int y void FListView::setGeometry ( const FPoint& pos, const FSize& size
, std::size_t w, std::size_t h , bool adjust)
, bool adjust )
{ {
// Set the widget geometry // Set the widget geometry
FWidget::setGeometry(x, y, w, h, adjust); FWidget::setGeometry(pos, size, adjust);
if ( isNewFont() ) if ( isNewFont() )
{ {
vbar->setGeometry (int(getWidth()), 2, 2, getHeight() - 2); vbar->setGeometry (FPoint(int(getWidth()), 2), FSize(2, getHeight() - 2));
hbar->setGeometry (1, int(getHeight()), getWidth() - 2, 1); hbar->setGeometry (FPoint(1, int(getHeight())), FSize(getWidth() - 2, 1));
} }
else else
{ {
vbar->setGeometry (int(getWidth()), 2, 1, getHeight() - 2); vbar->setGeometry (FPoint(int(getWidth()), 2), FSize(1, getHeight() - 2));
hbar->setGeometry (2, int(getHeight()), getWidth() - 2, 1); hbar->setGeometry (FPoint(2, int(getHeight())), FSize(getWidth() - 2, 1));
} }
} }
@ -756,7 +755,7 @@ int FListView::addColumn (const FString& label, int width)
void FListView::hide() void FListView::hide()
{ {
FWidget::hide(); FWidget::hide();
hideSize (getWidth(), getHeight()); hideSize (getSize());
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1374,7 +1373,7 @@ void FListView::init()
selflist.push_back(this); selflist.push_back(this);
root = selflist.begin(); root = selflist.begin();
null_iter = selflist.end(); null_iter = selflist.end();
setGeometry (1, 1, 5, 4, false); // initialize geometry values setGeometry (FPoint(1, 1), FSize(5, 4), false); // initialize geometry values
setForegroundColor (wc.dialog_fg); setForegroundColor (wc.dialog_fg);
setBackgroundColor (wc.dialog_bg); setBackgroundColor (wc.dialog_bg);
nf_offset = isNewFont() ? 1 : 0; nf_offset = isNewFont() ? 1 : 0;
@ -1470,7 +1469,7 @@ void FListView::draw()
for (int y = 2; y < int(getHeight()); y++) for (int y = 2; y < int(getHeight()); y++)
{ {
setPrintPos (int(getWidth()), y); setPrintPos (FPoint(int(getWidth()), y));
print (' '); // clear right side of the scrollbar print (' '); // clear right side of the scrollbar
} }
} }
@ -1544,7 +1543,7 @@ void FListView::drawHeadlines()
last = h.begin() + len; last = h.begin() + len;
} }
setPrintPos (2, 1); setPrintPos (FPoint(2, 1));
print() << std::vector<charData>(first, last); print() << std::vector<charData>(first, last);
} }
@ -1564,7 +1563,7 @@ void FListView::drawList()
const auto item = static_cast<FListViewItem*>(*iter); const auto item = static_cast<FListViewItem*>(*iter);
int tree_offset = ( tree_view ) ? int(item->getDepth() << 1) + 1 : 0; int tree_offset = ( tree_view ) ? int(item->getDepth() << 1) + 1 : 0;
int checkbox_offset = ( item->isCheckable() ) ? 1 : 0; int checkbox_offset = ( item->isCheckable() ) ? 1 : 0;
setPrintPos (2, 2 + int(y)); setPrintPos (FPoint(2, 2 + int(y)));
// Draw one FListViewItem // Draw one FListViewItem
drawListLine (item, flags.focus, is_current_line); drawListLine (item, flags.focus, is_current_line);
@ -1572,8 +1571,8 @@ void FListView::drawList()
if ( flags.focus && is_current_line ) if ( flags.focus && is_current_line )
{ {
setVisibleCursor (item->isCheckable()); setVisibleCursor (item->isCheckable());
setCursorPos ( 3 + tree_offset + checkbox_offset - xoffset setCursorPos (FPoint ( 3 + tree_offset + checkbox_offset - xoffset
, 2 + int(y)); // first character , 2 + int(y) )); // first character
} }
last_visible_line = iter; last_visible_line = iter;
@ -1590,7 +1589,7 @@ void FListView::drawList()
// Clean empty space after last element // Clean empty space after last element
while ( y < uInt(getClientHeight()) ) while ( y < uInt(getClientHeight()) )
{ {
setPrintPos (2, 2 + int(y)); setPrintPos (FPoint(2, 2 + int(y)));
print (FString(std::size_t(getClientWidth()), ' ')); print (FString(std::size_t(getClientWidth()), ' '));
y++; y++;
} }

View File

@ -433,7 +433,7 @@ void FMenu::init(FWidget* parent)
setLeftPadding(1); setLeftPadding(1);
setBottomPadding(1); setBottomPadding(1);
setRightPadding(1); setRightPadding(1);
setGeometry (1, 1, 10, 2, false); // initialize geometry values setGeometry (FPoint(1, 1), FSize(10, 2), false); // initialize geometry values
setTransparentShadow(); setTransparentShadow();
setMenuWidget(); setMenuWidget();
hide(); hide();
@ -498,7 +498,8 @@ void FMenu::calculateDimensions()
adjust_X = adjustX(getX()); adjust_X = adjustX(getX());
// set widget geometry // set widget geometry
setGeometry (adjust_X, getY(), max_item_width + 2, getCount() + 2); setGeometry ( FPoint(adjust_X, getY())
, FSize(max_item_width + 2, getCount() + 2) );
// set geometry of all items // set geometry of all items
iter = item_list.begin(); iter = item_list.begin();
@ -507,14 +508,14 @@ void FMenu::calculateDimensions()
while ( iter != last ) while ( iter != last )
{ {
(*iter)->setGeometry (item_X, item_Y, max_item_width, 1); (*iter)->setGeometry (FPoint(item_X, item_Y), FSize(max_item_width, 1));
if ( (*iter)->hasMenu() ) if ( (*iter)->hasMenu() )
{ {
int menu_X = getTermX() + int(max_item_width) + 1; int menu_X = getTermX() + int(max_item_width) + 1;
int menu_Y = (*iter)->getTermY() - 2; int menu_Y = (*iter)->getTermY() - 2;
// set sub-menu position // set sub-menu position
(*iter)->getMenu()->setPos (menu_X, menu_Y, false); (*iter)->getMenu()->setPos (FPoint(menu_X, menu_Y), false);
} }
item_Y++; item_Y++;
@ -540,7 +541,7 @@ void FMenu::adjustItems()
menu_Y = (*iter)->getTermY() - 2; menu_Y = (*iter)->getTermY() - 2;
// set sub-menu position // set sub-menu position
menu->setPos (menu_X, menu_Y); menu->setPos (FPoint(menu_X, menu_Y));
// call sub-menu adjustItems() // call sub-menu adjustItems()
if ( menu->getCount() > 0 ) if ( menu->getCount() > 0 )
@ -1250,7 +1251,7 @@ void FMenu::drawItems()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FMenu::drawSeparator (int y) inline void FMenu::drawSeparator (int y)
{ {
setPrintPos (1, 2 + y); setPrintPos (FPoint(1, 2 + y));
setColor (wc.menu_active_fg, wc.menu_active_bg); setColor (wc.menu_active_fg, wc.menu_active_bg);
if ( isMonochron() ) if ( isMonochron() )
@ -1497,7 +1498,7 @@ inline void FMenu::setLineAttributes (FMenuItem* menuitem, int y)
setReverse(true); setReverse(true);
} }
setPrintPos (2, 2 + y); setPrintPos (FPoint(2, 2 + y));
setColor(); setColor();
} }
@ -1513,9 +1514,9 @@ inline void FMenu::setCursorToHotkeyPosition (FMenuItem* menuitem)
if ( is_selected ) if ( is_selected )
{ {
if ( is_checkable ) if ( is_checkable )
menuitem->setCursorPos (3, 1); menuitem->setCursorPos (FPoint(3, 1));
else else
menuitem->setCursorPos (2, 1); menuitem->setCursorPos (FPoint(2, 1));
} }
} }
else else
@ -1524,9 +1525,9 @@ inline void FMenu::setCursorToHotkeyPosition (FMenuItem* menuitem)
{ {
// set cursor to the hotkey position // set cursor to the hotkey position
if ( is_checkable ) if ( is_checkable )
menuitem->setCursorPos (3 + int(hotkeypos), 1); menuitem->setCursorPos (FPoint(3 + int(hotkeypos), 1));
else else
menuitem->setCursorPos (2 + int(hotkeypos), 1); menuitem->setCursorPos (FPoint(2 + int(hotkeypos), 1));
} }
} }
} }

View File

@ -66,7 +66,7 @@ void FMenuBar::hide()
setColor (fg, bg); setColor (fg, bg);
screenWidth = getDesktopWidth(); screenWidth = getDesktopWidth();
auto blank = createBlankArray (screenWidth + 1); auto blank = createBlankArray (screenWidth + 1);
setPrintPos (1, 1); setPrintPos (FPoint(1, 1));
print (blank); print (blank);
destroyBlankArray (blank); destroyBlankArray (blank);
} }
@ -74,7 +74,7 @@ void FMenuBar::hide()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuBar::adjustSize() void FMenuBar::adjustSize()
{ {
setGeometry (1, 1, getDesktopWidth(), 1, false); setGeometry (FPoint(1, 1), FSize(getDesktopWidth(), 1), false);
adjustItems(); adjustItems();
} }
@ -236,7 +236,7 @@ void FMenuBar::init()
auto r = getRootWidget(); auto r = getRootWidget();
auto w = r->getWidth(); auto w = r->getWidth();
// initialize geometry values // initialize geometry values
setGeometry (1, 1, w, 1, false); setGeometry (FPoint(1, 1), FSize(w, 1), false);
setAlwaysOnTop(); setAlwaysOnTop();
setMenuBar(this); setMenuBar(this);
ignorePadding(); ignorePadding();
@ -254,8 +254,7 @@ void FMenuBar::init()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuBar::calculateDimensions() void FMenuBar::calculateDimensions()
{ {
int item_X = 1; FPoint item_pos (1, 1);
int item_Y = 1;
auto iter = item_list.begin(); auto iter = item_list.begin();
auto last = item_list.end(); auto last = item_list.end();
@ -266,13 +265,13 @@ void FMenuBar::calculateDimensions()
int item_width = int(len) + 2; int item_width = int(len) + 2;
// set item geometry // set item geometry
(*iter)->setGeometry (item_X, item_Y, std::size_t(item_width), 1, false); (*iter)->setGeometry (item_pos, FSize(std::size_t(item_width), 1), false);
// set menu position // set menu position
if ( (*iter)->hasMenu() ) if ( (*iter)->hasMenu() )
(*iter)->getMenu()->setPos (item_X, item_Y, false); (*iter)->getMenu()->setPos (item_pos, false);
item_X += item_width; item_pos.x_ref() += item_width;
++iter; ++iter;
} }
@ -502,7 +501,7 @@ void FMenuBar::drawItems()
if ( item_list.empty() ) if ( item_list.empty() )
return; return;
setPrintPos (1, 1); setPrintPos (FPoint(1, 1));
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
@ -665,13 +664,13 @@ inline void FMenuBar::drawEllipsis (const menuText& txtdata, std::size_t x)
if ( txtdata.startpos < screenWidth ) if ( txtdata.startpos < screenWidth )
{ {
// Print ellipsis // Print ellipsis
setPrintPos (int(screenWidth) - 1, 1); setPrintPos (FPoint(int(screenWidth) - 1, 1));
print (".."); print ("..");
} }
else if ( txtdata.startpos - 1 <= screenWidth ) else if ( txtdata.startpos - 1 <= screenWidth )
{ {
// Hide first character from text // Hide first character from text
setPrintPos (int(screenWidth), 1); setPrintPos (FPoint(int(screenWidth), 1));
print (' '); print (' ');
} }
} }
@ -719,7 +718,7 @@ void FMenuBar::adjustItems()
auto menu = (*iter)->getMenu(); auto menu = (*iter)->getMenu();
// set menu position // set menu position
menu->setPos (menu->adjustX(item_X), item_Y); menu->setPos (FPoint(menu->adjustX(item_X), item_Y));
// call menu adjustItems() // call menu adjustItems()
menu->adjustItems(); menu->adjustItems();

View File

@ -194,7 +194,7 @@ void FMenuItem::setText (const FString& txt)
if ( hotkey ) if ( hotkey )
text_length--; text_length--;
setWidth(text_length); updateSuperMenuDimensions();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -209,13 +209,7 @@ void FMenuItem::addAccelerator (FKey key, FWidget* obj)
root->accelerator_list->push_back(accel); root->accelerator_list->push_back(accel);
} }
if ( isMenu(super_menu) ) updateSuperMenuDimensions();
{
auto menu_ptr = static_cast<FMenu*>(super_menu);
if ( menu_ptr )
menu_ptr->calculateDimensions();
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -241,13 +235,7 @@ void FMenuItem::delAccelerator (FWidget* obj)
} }
} }
if ( isMenu(super_menu) ) updateSuperMenuDimensions();
{
auto menu_ptr = static_cast<FMenu*>(super_menu);
if ( menu_ptr )
menu_ptr->calculateDimensions();
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -540,7 +528,7 @@ void FMenuItem::init (FWidget* parent)
if ( hotkey ) if ( hotkey )
text_length--; text_length--;
setGeometry (1, 1, text_length + 2, 1, false); setGeometry (FPoint(1, 1), FSize(text_length + 2, 1), false);
if ( ! parent ) if ( ! parent )
return; return;
@ -603,6 +591,18 @@ uChar FMenuItem::hotKey()
return 0; return 0;
} }
//----------------------------------------------------------------------
void FMenuItem::updateSuperMenuDimensions()
{
if ( ! super_menu || ! isMenu(super_menu) )
return;
auto menu_ptr = static_cast<FMenu*>(super_menu);
if ( menu_ptr )
menu_ptr->calculateDimensions();
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuItem::processActivate() void FMenuItem::processActivate()
{ {

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2014-2018 Markus Gans * * Copyright 2014-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -165,7 +165,6 @@ void FMessageBox::setText (const FString& txt)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMessageBox::adjustSize() void FMessageBox::adjustSize()
{ {
int X, Y;
std::size_t max_width; std::size_t max_width;
std::size_t max_height; std::size_t max_height;
auto root_widget = getRootWidget(); auto root_widget = getRootWidget();
@ -182,9 +181,9 @@ void FMessageBox::adjustSize()
max_height = 24; max_height = 24;
} }
X = 1 + int((max_width - getWidth()) / 2); int x = 1 + int((max_width - getWidth()) / 2);
Y = 1 + int((max_height - getHeight()) / 3); int y = 1 + int((max_height - getHeight()) / 3);
setPos(X, Y, false); setPos(FPoint(x, y), false);
FDialog::adjustSize(); FDialog::adjustSize();
} }
@ -235,7 +234,7 @@ inline void FMessageBox::allocation (int button0, int button1, int button2)
{ {
button[0] = new FButton (this); button[0] = new FButton (this);
button[0]->setText(button_text[button0]); button[0]->setText(button_text[button0]);
button[0]->setPos(3, int(getHeight()) - 4, false); button[0]->setPos(FPoint(3, int(getHeight()) - 4), false);
button[0]->setWidth(1, false); button[0]->setWidth(1, false);
button[0]->setHeight(1, false); button[0]->setHeight(1, false);
button[0]->setFocus(); button[0]->setFocus();
@ -244,7 +243,7 @@ inline void FMessageBox::allocation (int button0, int button1, int button2)
{ {
button[1] = new FButton(this); button[1] = new FButton(this);
button[1]->setText(button_text[button1]); button[1]->setText(button_text[button1]);
button[1]->setPos(17, int(getHeight()) - 4, false); button[1]->setPos(FPoint(17, int(getHeight()) - 4), false);
button[1]->setWidth(0, false); button[1]->setWidth(0, false);
button[1]->setHeight(1, false); button[1]->setHeight(1, false);
} }
@ -253,7 +252,7 @@ inline void FMessageBox::allocation (int button0, int button1, int button2)
{ {
button[2] = new FButton(this); button[2] = new FButton(this);
button[2]->setText(button_text[button2]); button[2]->setText(button_text[button2]);
button[2]->setPos(32, int(getHeight()) - 4, false); button[2]->setPos(FPoint(32, int(getHeight()) - 4), false);
button[2]->setWidth(0, false); button[2]->setWidth(0, false);
button[2]->setHeight(1, false); button[2]->setHeight(1, false);
} }
@ -309,8 +308,8 @@ inline void FMessageBox::initCallbacks()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMessageBox::calculateDimensions() void FMessageBox::calculateDimensions()
{ {
std::size_t w, h; FSize size;
std::size_t headline_height = 0; std::size_t headline_height{0};
text_split = text.split("\n"); text_split = text.split("\n");
max_line_width = 0; max_line_width = 0;
text_num_lines = uInt(text_split.size()); text_num_lines = uInt(text_split.size());
@ -330,13 +329,13 @@ void FMessageBox::calculateDimensions()
max_line_width = len; max_line_width = len;
} }
h = text_num_lines + 8 + headline_height; size.setHeight (text_num_lines + 8 + headline_height);
w = max_line_width + 4; size.setWidth (max_line_width + 4);
if ( w < 20 ) if ( size.getWidth() < 20 )
w = 20; size.setWidth(20);
setSize (w, h); setSize(size);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -360,7 +359,7 @@ void FMessageBox::draw()
if ( center_text ) // center one line if ( center_text ) // center one line
center_x = int((max_line_width - headline_length) / 2); center_x = int((max_line_width - headline_length) / 2);
setPrintPos (1 + msg_x + center_x, 4); setPrintPos (FPoint(1 + msg_x + center_x, 4));
print (headline_text); print (headline_text);
head_offset = 2; head_offset = 2;
} }
@ -374,7 +373,7 @@ void FMessageBox::draw()
if ( center_text ) // center one line if ( center_text ) // center one line
center_x = int((max_line_width - line_length) / 2); center_x = int((max_line_width - line_length) / 2);
setPrintPos (1 + msg_x + center_x, 4 + head_offset + i); setPrintPos (FPoint(1 + msg_x + center_x, 4 + head_offset + i));
print(text_components[i]); print(text_components[i]);
} }

View File

@ -85,7 +85,7 @@ bool FPoint::isOrigin() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
std::ostream& operator << (std::ostream& outstr, const FPoint& p) std::ostream& operator << (std::ostream& outstr, const FPoint& p)
{ {
outstr << p.getX() << " " << p.getY(); outstr << p.xpos << " " << p.ypos;
return outstr; return outstr;
} }

View File

@ -66,14 +66,13 @@ void FProgressbar::setPercentage (std::size_t percentage_value)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FProgressbar::setGeometry ( int x, int y void FProgressbar::setGeometry ( const FPoint& pos, const FSize& size
, std::size_t w, std::size_t h
, bool adjust ) , bool adjust )
{ {
// Set the progress bar geometry // Set the progress bar geometry
FWidget::setGeometry (x, y, w, h, adjust); FWidget::setGeometry (pos, size, adjust);
bar_length = w; bar_length = size.getWidth();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -84,12 +83,12 @@ bool FProgressbar::setShadow (bool enable)
&& getEncoding() != fc::ASCII ) && getEncoding() != fc::ASCII )
{ {
flags.shadow = true; flags.shadow = true;
setShadowSize(1, 1); setShadowSize(FSize(1, 1));
} }
else else
{ {
flags.shadow = false; flags.shadow = false;
setShadowSize(0, 0); setShadowSize(FSize(0, 0));
} }
return enable; return enable;
@ -99,9 +98,9 @@ bool FProgressbar::setShadow (bool enable)
void FProgressbar::hide() void FProgressbar::hide()
{ {
FWidget::hide(); FWidget::hide();
std::size_t s = hasShadow() ? 1 : 0; FSize shadow = hasShadow() ? FSize(1, 1) : FSize(0, 0);
hideSize (getWidth() + s, getHeight() + s); hideSize (getSize() + shadow);
setPrintPos (int(getWidth()) - 4, 0); setPrintPos (FPoint(int(getWidth()) - 4, 0));
print (" "); // hide percentage print (" "); // hide percentage
} }
@ -147,7 +146,7 @@ void FProgressbar::drawPercentage()
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
setPrintPos (int(getWidth()) - 3, 0); setPrintPos (FPoint(int(getWidth()) - 3, 0));
if ( percentage > 100 ) if ( percentage > 100 )
print ("--- %"); print ("--- %");
@ -163,7 +162,7 @@ void FProgressbar::drawBar()
{ {
std::size_t i = 0; std::size_t i = 0;
double length; double length;
setPrintPos (1, 1); setPrintPos (FPoint(1, 1));
setColor ( wc.progressbar_bg setColor ( wc.progressbar_bg
, wc.progressbar_fg ); , wc.progressbar_fg );

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2014-2017 Markus Gans * e Copyright 2014-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -73,7 +73,7 @@ void FRadioButton::drawRadioButton()
if ( ! isVisible() ) if ( ! isVisible() )
return; return;
setPrintPos (1, 1); setPrintPos (FPoint(1, 1));
setColor(); setColor();
if ( isMonochron() ) if ( isMonochron() )

View File

@ -151,10 +151,19 @@ void FRect::setSize (const FSize& s)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FRect::setRect (const FRect& r) void FRect::setRect (const FRect& r)
{ {
setRect ( r.X1 X1 = r.X1;
, r.Y1 Y1 = r.Y1;
, std::size_t(r.X2 - r.X1 + 1) X2 = r.X2;
, std::size_t(r.Y2 - r.Y1 + 1) ); Y2 = r.Y2;
}
//----------------------------------------------------------------------
void FRect::setRect (const FPoint& p, const FSize& s)
{
X1 = p.getX();
Y1 = p.getY();
X2 = p.getX() + int(s.getWidth()) - 1;
Y2 = p.getY() + int(s.getHeight()) - 1;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -300,10 +309,10 @@ bool operator != (const FRect& r1, const FRect& r2)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
std::ostream& operator << (std::ostream& outstr, const FRect& r) std::ostream& operator << (std::ostream& outstr, const FRect& r)
{ {
outstr << r.getX1() << " " outstr << r.X1 << " "
<< r.getY1() << " " << r.Y1 << " "
<< r.getX2() << " " << r.X2 << " "
<< r.getY2(); << r.Y2;
return outstr; return outstr;
} }

View File

@ -37,7 +37,7 @@ FScrollbar::FScrollbar(FWidget* parent)
: FWidget(parent) : FWidget(parent)
{ {
// The default scrollbar orientation is vertical // The default scrollbar orientation is vertical
setGeometry(1, 1, 1, length, false); setGeometry(FPoint(1, 1), FSize(1, length), false);
init(); init();
} }
@ -148,15 +148,16 @@ void FScrollbar::setOrientation (fc::orientation o)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollbar::setGeometry ( int x, int y void FScrollbar::setGeometry ( const FPoint& pos, const FSize& size
, std::size_t w, std::size_t h
, bool adjust ) , bool adjust )
{ {
// Set the scrollbar geometry // Set the scrollbar geometry
FWidget::setGeometry (x, y, w, h, adjust); FWidget::setGeometry (pos, size, adjust);
std::size_t nf = 0; std::size_t nf = 0;
std::size_t w = size.getWidth();
std::size_t h = size.getHeight();
length = ( h > w ) ? h : w; length = ( h > w ) ? h : w;
if ( bar_orientation == fc::vertical ) if ( bar_orientation == fc::vertical )
@ -239,7 +240,7 @@ void FScrollbar::drawVerticalBar()
for (z = 1; z <= slider_pos; z++) for (z = 1; z <= slider_pos; z++)
{ {
setPrintPos (1, 1 + z); setPrintPos (FPoint(1, 1 + z));
if ( isNewFont() ) if ( isNewFont() )
{ {
@ -262,7 +263,7 @@ void FScrollbar::drawVerticalBar()
for (z = 1; z <= int(slider_length); z++) for (z = 1; z <= int(slider_length); z++)
{ {
setPrintPos (1, 1 + slider_pos + z); setPrintPos (FPoint(1, 1 + slider_pos + z));
if ( isNewFont() ) if ( isNewFont() )
print (' '); print (' ');
@ -277,7 +278,7 @@ void FScrollbar::drawVerticalBar()
for (z = slider_pos + int(slider_length) + 1; z <= int(bar_length); z++) for (z = slider_pos + int(slider_length) + 1; z <= int(bar_length); z++)
{ {
setPrintPos (1, 1 + z); setPrintPos (FPoint(1, 1 + z));
if ( isNewFont() ) if ( isNewFont() )
{ {
@ -304,9 +305,9 @@ void FScrollbar::drawHorizontalBar()
setColor (wc.scrollbar_fg, wc.scrollbar_bg); setColor (wc.scrollbar_fg, wc.scrollbar_bg);
if ( isNewFont() ) if ( isNewFont() )
setPrintPos (3, 1); setPrintPos (FPoint(3, 1));
else else
setPrintPos (2, 1); setPrintPos (FPoint(2, 1));
for (z = 0; z < slider_pos; z++) for (z = 0; z < slider_pos; z++)
{ {
@ -568,7 +569,7 @@ void FScrollbar::init()
{ {
unsetFocusable(); unsetFocusable();
ignorePadding(); ignorePadding();
setGeometry(1, 1, getWidth(), getHeight()); setGeometry(FPoint(1, 1), FSize(getWidth(), getHeight()));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -589,13 +590,13 @@ void FScrollbar::drawButtons()
if ( isNewFont() ) if ( isNewFont() )
{ {
setPrintPos (1, 1); setPrintPos (FPoint(1, 1));
if ( bar_orientation == fc::vertical ) if ( bar_orientation == fc::vertical )
{ {
print (fc::NF_rev_up_arrow1); print (fc::NF_rev_up_arrow1);
print (fc::NF_rev_up_arrow2); print (fc::NF_rev_up_arrow2);
setPrintPos (1, int(length)); setPrintPos (FPoint(1, int(length)));
print (fc::NF_rev_down_arrow1); print (fc::NF_rev_down_arrow1);
print (fc::NF_rev_down_arrow2); print (fc::NF_rev_down_arrow2);
} }
@ -603,14 +604,14 @@ void FScrollbar::drawButtons()
{ {
print (fc::NF_rev_left_arrow1); print (fc::NF_rev_left_arrow1);
print (fc::NF_rev_left_arrow2); print (fc::NF_rev_left_arrow2);
setPrintPos (int(length) - 1, 1); setPrintPos (FPoint(int(length) - 1, 1));
print (fc::NF_rev_right_arrow1); print (fc::NF_rev_right_arrow1);
print (fc::NF_rev_right_arrow2); print (fc::NF_rev_right_arrow2);
} }
} }
else else
{ {
setPrintPos (1, 1); setPrintPos (FPoint(1, 1));
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
@ -618,13 +619,13 @@ void FScrollbar::drawButtons()
if ( bar_orientation == fc::vertical ) if ( bar_orientation == fc::vertical )
{ {
print (fc::BlackUpPointingTriangle); // ▲ print (fc::BlackUpPointingTriangle); // ▲
setPrintPos (1, int(length)); setPrintPos (FPoint(1, int(length)));
print (fc::BlackDownPointingTriangle); // ▼ print (fc::BlackDownPointingTriangle); // ▼
} }
else // horizontal else // horizontal
{ {
print (fc::BlackLeftPointingPointer); // ◄ print (fc::BlackLeftPointingPointer); // ◄
setPrintPos (int(length), 1); setPrintPos (FPoint(int(length), 1));
print (fc::BlackRightPointingPointer); // ► print (fc::BlackRightPointingPointer); // ►
} }

View File

@ -106,10 +106,11 @@ void FScrollView::setScrollHeight (std::size_t height)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::setScrollSize (std::size_t width, std::size_t height) void FScrollView::setScrollSize (const FSize& size)
{ {
int xoffset_end int xoffset_end, yoffset_end;
, yoffset_end; std::size_t width = size.getWidth();
std::size_t height = size.getHeight();
if ( width < getViewportWidth() ) if ( width < getViewportWidth() )
width = getViewportWidth(); width = getViewportWidth();
@ -185,9 +186,9 @@ void FScrollView::setY (int y, bool adjust)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::setPos (int x, int y, bool adjust) void FScrollView::setPos (const FPoint& p, bool adjust)
{ {
FWidget::setPos (x, y, adjust); FWidget::setPos (p, adjust);
scroll_geometry.setPos ( getTermX() + getLeftPadding() - 1 scroll_geometry.setPos ( getTermX() + getLeftPadding() - 1
, getTermY() + getTopPadding() - 1 ); , getTermY() + getTopPadding() - 1 );
@ -224,26 +225,29 @@ void FScrollView::setHeight (std::size_t h, bool adjust)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::setSize (std::size_t w, std::size_t h, bool adjust) void FScrollView::setSize (const FSize& size, bool adjust)
{ {
FWidget::setSize (w, h, adjust); std::size_t w = size.getWidth();
std::size_t h = size.getHeight();
FWidget::setSize (size, adjust);
viewport_geometry.setSize ( w - vertical_border_spacing - nf_offset viewport_geometry.setSize ( w - vertical_border_spacing - nf_offset
, h - horizontal_border_spacing ); , h - horizontal_border_spacing );
calculateScrollbarPos(); calculateScrollbarPos();
if ( getScrollWidth() < getViewportWidth() if ( getScrollWidth() < getViewportWidth()
|| getScrollHeight() < getViewportHeight() ) || getScrollHeight() < getViewportHeight() )
setScrollSize (getViewportWidth(), getViewportHeight()); setScrollSize (getViewportSize());
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::setGeometry ( int x, int y void FScrollView::setGeometry ( const FPoint& pos, const FSize& size
, std::size_t w, std::size_t h
, bool adjust ) , bool adjust )
{ {
// Set the scroll view geometry // Set the scroll view geometry
FWidget::setGeometry (x, y, w, h, adjust); FWidget::setGeometry (pos, size, adjust);
std::size_t w = size.getWidth();
std::size_t h = size.getHeight();
scroll_geometry.setPos ( getTermX() + getLeftPadding() - 1 scroll_geometry.setPos ( getTermX() + getLeftPadding() - 1
, getTermY() + getTopPadding() - 1 ); , getTermY() + getTopPadding() - 1 );
viewport_geometry.setSize ( w - vertical_border_spacing - nf_offset viewport_geometry.setSize ( w - vertical_border_spacing - nf_offset
@ -253,7 +257,7 @@ void FScrollView::setGeometry ( int x, int y
if ( getScrollWidth() < getViewportWidth() if ( getScrollWidth() < getViewportWidth()
|| getScrollHeight() < getViewportHeight() ) || getScrollHeight() < getViewportHeight() )
{ {
setScrollSize (getViewportWidth(), getViewportHeight()); setScrollSize (getViewportSize());
} }
else if ( ! adjust && viewport ) else if ( ! adjust && viewport )
{ {
@ -263,15 +267,17 @@ void FScrollView::setGeometry ( int x, int y
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::setCursorPos (int x, int y) void FScrollView::setCursorPos (const FPoint& p)
{ {
FWidget::setCursorPos (x + getLeftPadding(), y + getTopPadding()); FWidget::setCursorPos (FPoint ( p.getX() + getLeftPadding()
, p.getY() + getTopPadding() ));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::setPrintPos (int x, int y) void FScrollView::setPrintPos (const FPoint& p)
{ {
FWidget::setPrintPos (x + getLeftPadding(), y + getTopPadding()); FWidget::setPrintPos (FPoint( p.getX() + getLeftPadding()
, p.getY() + getTopPadding() ));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -726,8 +732,8 @@ void FScrollView::init (FWidget* parent)
initScrollbar (hbar, fc::horizontal, &FScrollView::cb_HBarChange); initScrollbar (hbar, fc::horizontal, &FScrollView::cb_HBarChange);
setForegroundColor (wc.dialog_fg); setForegroundColor (wc.dialog_fg);
setBackgroundColor (wc.dialog_bg); setBackgroundColor (wc.dialog_bg);
setGeometry (1, 1, 4, 4); setGeometry (FPoint(1, 1), FSize(4, 4));
setMinimumSize (4, 4); setMinimumSize (FSize(4, 4));
int xoffset_end = int(getScrollWidth() - getViewportWidth()); int xoffset_end = int(getScrollWidth() - getViewportWidth());
int yoffset_end = int(getScrollHeight() - getViewportHeight()); int yoffset_end = int(getScrollHeight() - getViewportHeight());
nf_offset = isNewFont() ? 1 : 0; nf_offset = isNewFont() ? 1 : 0;
@ -792,13 +798,13 @@ void FScrollView::calculateScrollbarPos()
if ( isNewFont() ) if ( isNewFont() )
{ {
vbar->setGeometry (int(width), 2, 2, height - 2); vbar->setGeometry (FPoint(int(width), 2), FSize(2, height - 2));
hbar->setGeometry (1, int(height), width - 2, 1); hbar->setGeometry (FPoint(1, int(height)), FSize(width - 2, 1));
} }
else else
{ {
vbar->setGeometry (int(width), 2, 1, height - 2); vbar->setGeometry (FPoint(int(width), 2), FSize(1, height - 2));
hbar->setGeometry (2, int(height), width - 2, 1); hbar->setGeometry (FPoint(2, int(height)), FSize(width - 2, 1));
} }
vbar->resize(); vbar->resize();

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2014-2018 Markus Gans * * Copyright 2014-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -93,7 +93,7 @@ bool FSize::isEmpty() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
std::ostream& operator << (std::ostream& outstr, const FSize& s) std::ostream& operator << (std::ostream& outstr, const FSize& s)
{ {
outstr << s.getWidth() << " " << s.getHeight(); outstr << s.width << " " << s.height;
return outstr; return outstr;
} }

View File

@ -99,7 +99,7 @@ bool FStatusKey::setMouseFocus(bool enable)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FStatusKey::init (FWidget* parent) void FStatusKey::init (FWidget* parent)
{ {
setGeometry (1, 1, 1, 1); setGeometry (FPoint(1, 1), FSize(1, 1));
if ( parent && parent->isInstanceOf("FStatusBar") ) if ( parent && parent->isInstanceOf("FStatusBar") )
{ {
@ -178,7 +178,7 @@ void FStatusBar::hide()
setColor (fg, bg); setColor (fg, bg);
screenWidth = getDesktopWidth(); screenWidth = getDesktopWidth();
auto blank = createBlankArray(screenWidth + 1); auto blank = createBlankArray(screenWidth + 1);
setPrintPos (1, 1); setPrintPos (FPoint(1, 1));
print (blank); print (blank);
destroyBlankArray (blank); destroyBlankArray (blank);
} }
@ -214,7 +214,7 @@ void FStatusBar::drawMessage()
space_offset = 0; space_offset = 0;
setColor (wc.statusbar_fg, wc.statusbar_bg); setColor (wc.statusbar_fg, wc.statusbar_bg);
setPrintPos (x, 1); setPrintPos (FPoint(x, 1));
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
@ -312,7 +312,8 @@ void FStatusBar::clear()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FStatusBar::adjustSize() void FStatusBar::adjustSize()
{ {
setGeometry (1, int(getDesktopHeight()), getDesktopWidth(), 1, false); setGeometry ( FPoint(1, int(getDesktopHeight()))
, FSize(getDesktopWidth(), 1), false );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -507,7 +508,7 @@ void FStatusBar::init()
std::size_t w = r->getWidth(); std::size_t w = r->getWidth();
int h = int(r->getHeight()); int h = int(r->getHeight());
// initialize geometry values // initialize geometry values
setGeometry (1, h, w, 1, false); setGeometry (FPoint(1, h), FSize(w, 1), false);
setAlwaysOnTop(); setAlwaysOnTop();
setStatusBar(this); setStatusBar(this);
ignorePadding(); ignorePadding();
@ -540,7 +541,7 @@ void FStatusBar::drawKeys()
return; return;
} }
setPrintPos (1, 1); setPrintPos (FPoint(1, 1));
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2015-2018 Markus Gans * * Copyright 2015-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -127,7 +127,7 @@ void FSwitch::drawCheckButton()
if ( ! isVisible() ) if ( ! isVisible() )
return; return;
setPrintPos (1 + int(switch_offset_pos), 1); setPrintPos (FPoint(1 + int(switch_offset_pos), 1));
if ( checked ) if ( checked )
drawChecked(); drawChecked();
@ -181,7 +181,7 @@ void FSwitch::drawChecked()
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
setCursorPos (3 + int(switch_offset_pos), 1); setCursorPos (FPoint(3 + int(switch_offset_pos), 1));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -228,7 +228,7 @@ void FSwitch::drawUnchecked()
if ( isMonochron() || getMaxColor() < 16 ) if ( isMonochron() || getMaxColor() < 16 )
setBold(false); setBold(false);
setCursorPos (7 + int(switch_offset_pos), 1); setCursorPos (FPoint(7 + int(switch_offset_pos), 1));
} }
} // namespace finalcut } // namespace finalcut

View File

@ -527,11 +527,11 @@ void FTerm::detectTermSize()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::setTermSize (std::size_t width, std::size_t height) void FTerm::setTermSize (const FSize& size)
{ {
// Set xterm size to {width} x {height} // Set xterm size
xterm->setTermSize (width, height); xterm->setTermSize (size);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2018 Markus Gans * * Copyright 2018-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -126,12 +126,12 @@ void FTermXTerminal::setTitle (const FString& title)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermXTerminal::setTermSize (std::size_t width, std::size_t height) void FTermXTerminal::setTermSize (const FSize& size)
{ {
// Set xterm size to {term_width} x {term_height} // Set xterm size to {term_width} x {term_height}
term_width = width; term_width = size.getWidth();
term_height = height; term_height = size.getHeight();
setXTermSize(); setXTermSize();
} }

View File

@ -84,25 +84,24 @@ const FString FTextView::getText() const
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTextView::setGeometry ( int x, int y void FTextView::setGeometry ( const FPoint& pos, const FSize& size
, std::size_t w, std::size_t h , bool adjust)
, bool adjust )
{ {
// Set the text view geometry // Set the text view geometry
FWidget::setGeometry(x, y, w, h, adjust); FWidget::setGeometry(pos, size, adjust);
std::size_t width = getWidth(); std::size_t width = getWidth();
std::size_t height = getHeight(); std::size_t height = getHeight();
if ( isNewFont() ) if ( isNewFont() )
{ {
vbar->setGeometry (int(width), 1, 2, height - 1); vbar->setGeometry (FPoint(int(width), 1), FSize(2, height - 1));
hbar->setGeometry (1, int(height), width - 2, 1); hbar->setGeometry (FPoint(1, int(height)), FSize(width - 2, 1));
} }
else else
{ {
vbar->setGeometry (int(width), 2, 1, height - 2); vbar->setGeometry (FPoint(int(width), 2), FSize(1, height - 2));
hbar->setGeometry (2, int(height), width - 2, 1); hbar->setGeometry (FPoint(2, int(height)), FSize(width - 2, 1));
} }
vbar->resize(); vbar->resize();
@ -187,7 +186,7 @@ void FTextView::scrollTo (int x, int y)
void FTextView::hide() void FTextView::hide()
{ {
FWidget::hide(); FWidget::hide();
hideSize (getWidth(), getHeight()); hideSize (getSize());
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -298,7 +297,7 @@ void FTextView::clear()
for (int y = 0; y < int(getTextHeight()); y++) for (int y = 0; y < int(getTextHeight()); y++)
{ {
setPrintPos (2, 2 - nf_offset + y); setPrintPos (FPoint(2, 2 - nf_offset + y));
print (blank); print (blank);
} }
@ -671,7 +670,7 @@ void FTextView::draw()
} }
} }
setCursorPos (int(getWidth()), int(getHeight())); setCursorPos (FPoint(int(getWidth()), int(getHeight())));
updateTerminal(); updateTerminal();
flush_out(); flush_out();
} }
@ -696,7 +695,7 @@ void FTextView::drawText()
{ {
std::size_t i; std::size_t i;
FString line; FString line;
setPrintPos (2, 2 - nf_offset + int(y)); setPrintPos (FPoint(2, 2 - nf_offset + int(y)));
line = data[y + std::size_t(yoffset)].mid ( std::size_t(1 + xoffset) line = data[y + std::size_t(yoffset)].mid ( std::size_t(1 + xoffset)
, getTextWidth() ); , getTextWidth() );
const auto line_str = line.wc_str(); const auto line_str = line.wc_str();

View File

@ -76,24 +76,24 @@ FToggleButton::~FToggleButton() // destructor
// public methods of FToggleButton // public methods of FToggleButton
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FToggleButton::setGeometry ( int x, int y void FToggleButton::setGeometry ( const FPoint& pos, const FSize& s
, std::size_t w, std::size_t h
, bool adjust ) , bool adjust )
{ {
// Set the toggle button geometry // Set the toggle button geometry
FSize size = s;
std::size_t hotkey_mark = ( getHotkey(text) ) ? 1 : 0; std::size_t hotkey_mark = ( getHotkey(text) ) ? 1 : 0;
std::size_t min_width = button_width + text.getLength() - hotkey_mark; std::size_t min_width = button_width + text.getLength() - hotkey_mark;
if ( w < min_width ) if ( size.getWidth() < min_width )
w = min_width; size.setWidth(min_width);
const FRect geometry(x, y, w, h); const FRect geometry(pos, size);
if ( hasGroup() ) if ( hasGroup() )
getGroup()->checkScrollSize(geometry); getGroup()->checkScrollSize(geometry);
FWidget::setGeometry(x, y, w, h, adjust); FWidget::setGeometry(pos, size, adjust);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -203,7 +203,7 @@ void FToggleButton::setText (const FString& txt)
void FToggleButton::hide() void FToggleButton::hide()
{ {
FWidget::hide(); FWidget::hide();
hideSize (getWidth(), getHeight()); hideSize (getSize());
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -411,7 +411,7 @@ void FToggleButton::draw()
// set the cursor to the button // set the cursor to the button
if ( isRadioButton() || isCheckboxButton() ) if ( isRadioButton() || isCheckboxButton() )
setCursorPos (2, 1); setCursorPos (FPoint(2, 1));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -445,7 +445,7 @@ void FToggleButton::drawLabel()
if ( hotkeypos != NOT_SET ) if ( hotkeypos != NOT_SET )
length--; length--;
setPrintPos (1 + int(label_offset_pos), 1); setPrintPos (FPoint(1 + int(label_offset_pos), 1));
drawText (LabelText, hotkeypos, length); drawText (LabelText, hotkeypos, length);
delete[] LabelText; delete[] LabelText;
} }
@ -528,7 +528,7 @@ void FToggleButton::setGroup (FButtonGroup* btngroup)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FToggleButton::init() void FToggleButton::init()
{ {
setGeometry (1, 1, 4, 1, false); // initialize geometry values setGeometry (FPoint(1, 1), FSize(4, 1), false); // initialize geometry values
if ( isEnabled() ) if ( isEnabled() )
{ {

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2016-2018 Markus Gans * * Copyright 2016-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -87,7 +87,7 @@ void FToolTip::draw()
for (std::size_t i = 0; i < text_num_lines; i++) for (std::size_t i = 0; i < text_num_lines; i++)
{ {
setPrintPos (3, 2 + int(i)); setPrintPos (FPoint(3, 2 + int(i)));
print(text_components[i]); print(text_components[i]);
} }
@ -124,8 +124,8 @@ void FToolTip::init()
setAlwaysOnTop(); setAlwaysOnTop();
ignorePadding(); ignorePadding();
// initialize geometry values // initialize geometry values
setGeometry (1, 1, 3, 3, false); setGeometry (FPoint(1, 1), FSize(3, 3), false);
setMinimumSize (3, 3); setMinimumSize (FSize(3, 3));
setForegroundColor (wc.tooltip_fg); setForegroundColor (wc.tooltip_fg);
setBackgroundColor (wc.tooltip_bg); setBackgroundColor (wc.tooltip_bg);
calculateDimensions(); calculateDimensions();
@ -164,7 +164,7 @@ void FToolTip::calculateDimensions()
else else
x = y = 1; x = y = 1;
setGeometry (x, y, w, h); setGeometry (FPoint(x, y), FSize(w, h));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -148,8 +148,10 @@ void FVTerm::hideCursor (bool enable)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::setPrintCursor (int x, int y) void FVTerm::setPrintCursor (const FPoint& pos)
{ {
int x = pos.getX();
int y = pos.getY();
auto win = getPrintArea(); auto win = getPrintArea();
if ( win ) if ( win )
@ -177,31 +179,23 @@ void FVTerm::clearArea (int fillchar)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::createVTerm (const FRect& r) void FVTerm::createVTerm (const FSize& size)
{ {
// initialize virtual terminal // initialize virtual terminal
const FRect box(0, 0, size.getWidth(), size.getHeight());
const FSize shadow(0, 0); const FSize shadow(0, 0);
createArea (r, shadow, vterm); createArea (box, shadow, vterm);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::createVTerm (int width, int height) void FVTerm::resizeVTerm (const FSize& size)
{ {
// initialize virtual terminal // resize virtual terminal
createArea (0, 0, width, height, 0, 0, vterm);
}
//---------------------------------------------------------------------- const FRect box(0, 0, size.getWidth(), size.getHeight());
void FVTerm::resizeVTerm (const FRect& r)
{
const FSize shadow(0, 0); const FSize shadow(0, 0);
resizeArea (r, shadow, vterm); resizeArea (box, shadow, vterm);
}
//----------------------------------------------------------------------
void FVTerm::resizeVTerm (int width, int height)
{
resizeArea (0, 0, width, height, 0, 0, vterm);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -593,23 +587,8 @@ FVTerm::term_area* FVTerm::getPrintArea()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::createArea ( const FRect& r void FVTerm::createArea ( const FRect& box
, const FSize& s , const FSize& shadow
, term_area*& area )
{
createArea ( r.getX()
, r.getY()
, int(r.getWidth())
, int(r.getHeight())
, int(s.getWidth())
, int(s.getHeight())
, area );
}
//----------------------------------------------------------------------
void FVTerm::createArea ( int offset_left, int offset_top
, int width, int height
, int rsw, int bsh
, term_area*& area ) , term_area*& area )
{ {
// initialize virtual window // initialize virtual window
@ -625,34 +604,26 @@ void FVTerm::createArea ( int offset_left, int offset_top
} }
area->widget = static_cast<FWidget*>(this); area->widget = static_cast<FWidget*>(this);
resizeArea (offset_left, offset_top, width, height, rsw, bsh, area); resizeArea (box, shadow, area);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::resizeArea ( const FRect& r void FVTerm::resizeArea ( const FRect& box
, const FSize& s , const FSize& shadow
, term_area* area )
{
resizeArea ( r.getX()
, r.getY()
, int(r.getWidth())
, int(r.getHeight())
, int(s.getWidth())
, int(s.getHeight())
, area );
}
//----------------------------------------------------------------------
void FVTerm::resizeArea ( int offset_left, int offset_top
, int width, int height
, int rsw, int bsh
, term_area* area ) , term_area* area )
{ {
// Resize the virtual window to a new size. // Resize the virtual window to a new size.
int offset_left = box.getX();
int offset_top = box.getY();
int width = int(box.getWidth());
int height = int(box.getHeight());
int rsw = int(shadow.getWidth());
int bsh = int(shadow.getHeight());
assert ( offset_top >= 0 ); assert ( offset_top >= 0 );
assert ( width > 0 ); assert ( width > 0 && width + rsw > 0 );
assert ( height > 0 ); assert ( height > 0 && height + bsh > 0 );
assert ( rsw >= 0 ); assert ( rsw >= 0 );
assert ( bsh >= 0 ); assert ( bsh >= 0 );
std::size_t area_size; std::size_t area_size;
@ -701,17 +672,16 @@ void FVTerm::resizeArea ( int offset_left, int offset_top
area->bottom_shadow = bsh; area->bottom_shadow = bsh;
area->has_changes = false; area->has_changes = false;
setTextToDefault (area, width + rsw, height + bsh); FSize size(std::size_t(width + rsw), std::size_t(height + bsh));
setTextToDefault (area, size);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FVTerm::setTextToDefault ( term_area* area inline void FVTerm::setTextToDefault ( term_area* area
, int width , const FSize& size )
, int height )
{ {
charData default_char; charData default_char;
line_changes unchanged; line_changes unchanged;
int size = width * height;
default_char.code = ' '; default_char.code = ' ';
default_char.fg_color = fc::Default; default_char.fg_color = fc::Default;
@ -720,13 +690,13 @@ inline void FVTerm::setTextToDefault ( term_area* area
default_char.attr.byte[1] = 0; default_char.attr.byte[1] = 0;
default_char.attr.byte[2] = 0; default_char.attr.byte[2] = 0;
std::fill_n (area->text, size, default_char); std::fill_n (area->text, size.getArea(), default_char);
unchanged.xmin = uInt(width); unchanged.xmin = uInt(size.getWidth());
unchanged.xmax = 0; unchanged.xmax = 0;
unchanged.trans_count = 0; unchanged.trans_count = 0;
std::fill_n (area->changes, height, unchanged); std::fill_n (area->changes, size.getHeight(), unchanged);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -734,6 +704,9 @@ inline bool FVTerm::reallocateTextArea ( term_area* area
, std::size_t height , std::size_t height
, std::size_t size ) , std::size_t size )
{ {
// Reallocate "height" lines for changes
// and "size" bytes for the text area
if ( area->changes != 0 ) if ( area->changes != 0 )
delete[] area->changes; delete[] area->changes;
@ -757,6 +730,8 @@ inline bool FVTerm::reallocateTextArea ( term_area* area
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FVTerm::reallocateTextArea (term_area* area, std::size_t size) inline bool FVTerm::reallocateTextArea (term_area* area, std::size_t size)
{ {
// Reallocate "size" bytes for the text area
if ( area->text != 0 ) if ( area->text != 0 )
delete[] area->text; delete[] area->text;
@ -800,17 +775,10 @@ void FVTerm::removeArea (term_area*& area)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::restoreVTerm (const FRect& box) void FVTerm::restoreVTerm (const FRect& box)
{ {
restoreVTerm ( box.getX() int x = box.getX() - 1;
, box.getY() int y = box.getY() - 1;
, int(box.getWidth()) int w = int(box.getWidth());
, int(box.getHeight()) ); int h = int(box.getHeight());
}
//----------------------------------------------------------------------
void FVTerm::restoreVTerm (int x, int y, int w, int h)
{
x--;
y--;
if ( x < 0 ) if ( x < 0 )
x = 0; x = 0;
@ -841,7 +809,7 @@ void FVTerm::restoreVTerm (int x, int y, int w, int h)
{ {
int xpos = x + tx; int xpos = x + tx;
auto tc = &vterm->text[ypos * vterm->width + xpos]; // terminal character auto tc = &vterm->text[ypos * vterm->width + xpos]; // terminal character
auto sc = generateCharacter(xpos, ypos); // shown character auto sc = generateCharacter(FPoint(xpos, ypos)); // shown character
std::memcpy (tc, &sc, sizeof(*tc)); std::memcpy (tc, &sc, sizeof(*tc));
} }
@ -859,15 +827,6 @@ FVTerm::covered_state FVTerm::isCovered ( const FPoint& pos
{ {
// Determines the covered state for the given position // Determines the covered state for the given position
return isCovered (pos.getX(), pos.getY(), area);
}
//----------------------------------------------------------------------
FVTerm::covered_state FVTerm::isCovered ( int x, int y
, term_area* area )
{
// Determines the covered state for the given position
if ( ! area ) if ( ! area )
return non_covered; return non_covered;
@ -893,9 +852,11 @@ FVTerm::covered_state FVTerm::isCovered ( int x, int y
, std::size_t(win->width + win->right_shadow) , std::size_t(win->width + win->right_shadow)
, std::size_t(win->height + win->bottom_shadow) ); , std::size_t(win->height + win->bottom_shadow) );
if ( found && geometry.contains(x, y) ) if ( found && geometry.contains(pos) )
{ {
int line_len = win->width + win->right_shadow; int line_len = win->width + win->right_shadow;
int x = pos.getX();
int y = pos.getY();
auto tmp = &win->text[(y - win_y) * line_len + (x - win_x)]; auto tmp = &win->text[(y - win_y) * line_len + (x - win_x)];
if ( tmp->attr.bit.trans_shadow ) if ( tmp->attr.bit.trans_shadow )
@ -919,12 +880,17 @@ FVTerm::covered_state FVTerm::isCovered ( int x, int y
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::updateOverlappedColor ( term_area* area void FVTerm::updateOverlappedColor ( term_area* area
, int x, int y, int tx, int ty ) , const FPoint& area_pos
, const FPoint& terminal_pos )
{ {
// Add the overlapping color to this character // Add the overlapping color to this character
int& aw = area->width; int& aw = area->width;
int& rsh = area->right_shadow; int& rsh = area->right_shadow;
int x = area_pos.getX();
int y = area_pos.getY();
int tx = terminal_pos.getX();
int ty = terminal_pos.getY();
int line_len = aw + rsh; int line_len = aw + rsh;
// Area character // Area character
auto ac = &area->text[y * line_len + x]; auto ac = &area->text[y * line_len + x];
@ -934,7 +900,7 @@ void FVTerm::updateOverlappedColor ( term_area* area
charData nc; charData nc;
std::memcpy (&nc, ac, sizeof(nc)); std::memcpy (&nc, ac, sizeof(nc));
// Overlapped character // Overlapped character
auto oc = getOverlappedCharacter (tx + 1, ty + 1, area->widget); auto oc = getOverlappedCharacter (terminal_pos + FPoint(1, 1), area->widget);
nc.fg_color = oc.fg_color; nc.fg_color = oc.fg_color;
nc.bg_color = oc.bg_color; nc.bg_color = oc.bg_color;
nc.attr.bit.reverse = false; nc.attr.bit.reverse = false;
@ -953,33 +919,41 @@ void FVTerm::updateOverlappedColor ( term_area* area
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::updateOverlappedCharacter (term_area* area, int tx, int ty) void FVTerm::updateOverlappedCharacter ( term_area* area
, const FPoint& terminal_pos )
{ {
// Restore one character on vterm // Restore one character on vterm
// Terminal character // Terminal character
int tx = terminal_pos.getX();
int ty = terminal_pos.getY();
auto tc = &vterm->text[ty * vterm->width + tx]; auto tc = &vterm->text[ty * vterm->width + tx];
// Overlapped character // Overlapped character
auto oc = getCoveredCharacter (tx + 1, ty + 1, area->widget); auto oc = getCoveredCharacter (terminal_pos + FPoint(1, 1), area->widget);
oc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == oc); oc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == oc);
std::memcpy (tc, &oc, sizeof(*tc)); std::memcpy (tc, &oc, sizeof(*tc));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::updateShadedCharacter ( term_area* area void FVTerm::updateShadedCharacter ( term_area* area
, int x, int y, int tx, int ty ) , const FPoint& area_pos
, const FPoint& terminal_pos )
{ {
// Get covered character + add the current color // Get covered character + add the current color
int& aw = area->width; int& aw = area->width;
int& rsh = area->right_shadow; int& rsh = area->right_shadow;
int x = area_pos.getX();
int y = area_pos.getY();
int tx = terminal_pos.getX();
int ty = terminal_pos.getY();
int line_len = aw + rsh; int line_len = aw + rsh;
// Area character // Area character
auto ac = &area->text[y * line_len + x]; auto ac = &area->text[y * line_len + x];
// Terminal character // Terminal character
auto tc = &vterm->text[ty * vterm->width + tx]; auto tc = &vterm->text[ty * vterm->width + tx];
// Overlapped character // Overlapped character
auto oc = getCoveredCharacter (tx + 1, ty + 1, area->widget); auto oc = getCoveredCharacter (terminal_pos + FPoint(1, 1), area->widget);
oc.fg_color = ac->fg_color; oc.fg_color = ac->fg_color;
oc.bg_color = ac->bg_color; oc.bg_color = ac->bg_color;
oc.attr.bit.reverse = false; oc.attr.bit.reverse = false;
@ -999,12 +973,17 @@ void FVTerm::updateShadedCharacter ( term_area* area
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::updateInheritBackground ( term_area* area void FVTerm::updateInheritBackground ( term_area* area
, int x, int y, int tx, int ty ) , const FPoint& area_pos
, const FPoint& terminal_pos )
{ {
// Add the covered background to this character // Add the covered background to this character
int& aw = area->width; int& aw = area->width;
int& rsh = area->right_shadow; int& rsh = area->right_shadow;
int x = area_pos.getX();
int y = area_pos.getY();
int tx = terminal_pos.getX();
int ty = terminal_pos.getY();
int line_len = aw + rsh; int line_len = aw + rsh;
// Area character // Area character
auto ac = &area->text[y * line_len + x]; auto ac = &area->text[y * line_len + x];
@ -1014,7 +993,7 @@ void FVTerm::updateInheritBackground ( term_area* area
charData nc; charData nc;
std::memcpy (&nc, ac, sizeof(nc)); std::memcpy (&nc, ac, sizeof(nc));
// Covered character // Covered character
auto cc = getCoveredCharacter (tx + 1, ty + 1, area->widget); auto cc = getCoveredCharacter (terminal_pos + FPoint(1, 1), area->widget);
nc.bg_color = cc.bg_color; nc.bg_color = cc.bg_color;
nc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == nc); nc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == nc);
std::memcpy (tc, &nc, sizeof(*tc)); std::memcpy (tc, &nc, sizeof(*tc));
@ -1022,12 +1001,17 @@ void FVTerm::updateInheritBackground ( term_area* area
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::updateCharacter ( term_area* area void FVTerm::updateCharacter ( term_area* area
, int x, int y, int tx, int ty ) , const FPoint& area_pos
, const FPoint& terminal_pos )
{ {
// Copy a area character to the virtual terminal // Copy a area character to the virtual terminal
int& aw = area->width; int& aw = area->width;
int& rsh = area->right_shadow; int& rsh = area->right_shadow;
int x = area_pos.getX();
int y = area_pos.getY();
int tx = terminal_pos.getX();
int ty = terminal_pos.getY();
int line_len = aw + rsh; int line_len = aw + rsh;
// Area character // Area character
auto ac = &area->text[y * line_len + x]; auto ac = &area->text[y * line_len + x];
@ -1043,41 +1027,44 @@ void FVTerm::updateCharacter ( term_area* area
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FVTerm::updateVTermCharacter ( term_area* area bool FVTerm::updateVTermCharacter ( term_area* area
, int x, int y, int tx, int ty ) , const FPoint& area_pos
, const FPoint& terminal_pos )
{ {
int& aw = area->width; int& aw = area->width;
int& rsh = area->right_shadow; int& rsh = area->right_shadow;
int x = area_pos.getX();
int y = area_pos.getY();
int line_len = aw + rsh; int line_len = aw + rsh;
// Area character // Area character
auto ac = &area->text[y * line_len + x]; auto ac = &area->text[y * line_len + x];
// Get covered state // Get covered state
auto is_covered = isCovered(tx, ty, area); auto is_covered = isCovered(terminal_pos, area);
if ( is_covered == fully_covered ) if ( is_covered == fully_covered )
return false; return false;
if ( is_covered == half_covered ) if ( is_covered == half_covered )
{ {
updateOverlappedColor(area, x, y, tx, ty); updateOverlappedColor(area, area_pos, terminal_pos);
} }
else if ( ac->attr.bit.transparent ) // Transparent else if ( ac->attr.bit.transparent ) // Transparent
{ {
updateOverlappedCharacter(area, tx, ty); updateOverlappedCharacter(area, terminal_pos);
} }
else // Not transparent else // Not transparent
{ {
if ( ac->attr.bit.trans_shadow ) // Transparent shadow if ( ac->attr.bit.trans_shadow ) // Transparent shadow
{ {
updateShadedCharacter (area, x, y, tx, ty); updateShadedCharacter (area, area_pos, terminal_pos);
} }
else if ( ac->attr.bit.inherit_bg ) else if ( ac->attr.bit.inherit_bg )
{ {
updateInheritBackground (area, x, y, tx, ty); updateInheritBackground (area, area_pos, terminal_pos);
} }
else // Default else // Default
{ {
updateCharacter (area, x, y, tx, ty); updateCharacter (area, area_pos, terminal_pos);
} }
} }
@ -1212,15 +1199,15 @@ void FVTerm::updateVTerm (term_area* area)
for (int x = line_xmin; x <= line_xmax; x++) // Column loop for (int x = line_xmin; x <= line_xmax; x++) // Column loop
{ {
// Global terminal positions // Global terminal positions
int tx = ax + x int tx = ax + x;
, ty = ay + y; int ty = ay + y;
if ( tx < 0 || ty < 0 ) if ( tx < 0 || ty < 0 )
continue; continue;
tx -= ol; tx -= ol;
if ( updateVTermCharacter (area, x, y, tx, ty) ) if ( updateVTermCharacter(area, FPoint(x, y), FPoint(tx, ty)) )
modified = true; modified = true;
if ( ! modified ) if ( ! modified )
@ -1271,9 +1258,9 @@ bool FVTerm::updateVTermCursor (term_area* area)
x = ax + cx; x = ax + cx;
y = ay + cy; y = ay + cy;
if ( isInsideArea(cx, cy, area) if ( isInsideArea (FPoint(cx, cy), area)
&& isInsideTerminal(x, y) && isInsideTerminal (FPoint(x, y))
&& isCovered(x, y, area) == non_covered ) && isCovered (FPoint(x, y), area) == non_covered )
{ {
vterm->input_cursor_x = x; vterm->input_cursor_x = x;
vterm->input_cursor_y = y; vterm->input_cursor_y = y;
@ -1287,16 +1274,15 @@ bool FVTerm::updateVTermCursor (term_area* area)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FVTerm::isInsideArea (int x, int y, term_area* area) bool FVTerm::isInsideArea (const FPoint& pos, term_area* area)
{ {
// Check whether the coordinates are within the area // Check whether the coordinates are within the area
int ax = 0, ay = 0; auto aw = std::size_t(area->width);
std::size_t aw = std::size_t(area->width); auto ah = std::size_t(area->height);
std::size_t ah = std::size_t(area->height); FRect area_geometry(0, 0, aw, ah);
FRect area_geometry(ax, ay, aw, ah);
if ( area_geometry.contains(x, y) ) if ( area_geometry.contains(pos) )
return true; return true;
else else
return false; return false;
@ -1306,41 +1292,27 @@ bool FVTerm::isInsideArea (int x, int y, term_area* area)
void FVTerm::setAreaCursor ( const FPoint& pos void FVTerm::setAreaCursor ( const FPoint& pos
, bool visible , bool visible
, term_area* area ) , term_area* area )
{
setAreaCursor (pos.getX(), pos.getY(), visible, area);
}
//----------------------------------------------------------------------
void FVTerm::setAreaCursor ( int x, int y
, bool visible
, term_area* area )
{ {
if ( ! area ) if ( ! area )
return; return;
area->input_cursor_x = x - 1; area->input_cursor_x = pos.getX() - 1;
area->input_cursor_y = y - 1; area->input_cursor_y = pos.getY() - 1;
area->input_cursor_visible = visible; area->input_cursor_visible = visible;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::getArea (const FPoint& pos, term_area* area) void FVTerm::getArea (const FPoint& pos, term_area* area)
{
return getArea (pos.getX(), pos.getY(), area);
}
//----------------------------------------------------------------------
void FVTerm::getArea (int ax, int ay, term_area* area)
{ {
// Copies a block from the virtual terminal position to the given area // Copies a block from the virtual terminal position to the given area
int y_end;
int length;
if ( ! area ) if ( ! area )
return; return;
ax--; int y_end;
ay--; int length;
int ax = pos.getX() - 1;
int ay = pos.getY() - 1;
if ( area->height + ay > vterm->height ) if ( area->height + ay > vterm->height )
y_end = area->height - ay; y_end = area->height - ay;
@ -1368,26 +1340,20 @@ void FVTerm::getArea (int ax, int ay, term_area* area)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::getArea (const FRect& box, term_area* area) void FVTerm::getArea (const FRect& box, term_area* area)
{
getArea ( box.getX()
, box.getY()
, int(box.getWidth())
, int(box.getHeight())
, area );
}
//----------------------------------------------------------------------
void FVTerm::getArea (int x, int y, int w, int h, term_area* area)
{ {
// Copies a block from the virtual terminal rectangle to the given area // Copies a block from the virtual terminal rectangle to the given area
if ( ! area ) if ( ! area )
return; return;
int dx = x - area->offset_left + 1 int x = box.getX();
, dy = y - area->offset_top + 1 int y = box.getY();
, y_end int w = int(box.getWidth());
, length; int h = int(box.getHeight());
int dx = x - area->offset_left + 1;
int dy = y - area->offset_top + 1;
int y_end;
int length;
if ( x < 0 || y < 0 ) if ( x < 0 || y < 0 )
return; return;
@ -1425,20 +1391,6 @@ void FVTerm::putArea (const FPoint& pos, term_area* area)
{ {
// Copies the given area block to the virtual terminal position // Copies the given area block to the virtual terminal position
if ( ! area )
return;
if ( ! area->visible )
return;
putArea (pos.getX(), pos.getY(), area);
}
//----------------------------------------------------------------------
void FVTerm::putArea (int ax, int ay, term_area* area)
{
// Copies the given area block to the virtual terminal position
charData* tc; // terminal character charData* tc; // terminal character
charData* ac; // area character charData* ac; // area character
@ -1448,16 +1400,15 @@ void FVTerm::putArea (int ax, int ay, term_area* area)
if ( ! area->visible ) if ( ! area->visible )
return; return;
ax--; int ax = pos.getX() - 1;
ay--; int ay = pos.getY() - 1;
int aw = area->width;
int aw = area->width int ah = area->height;
, ah = area->height int rsh = area->right_shadow;
, rsh = area->right_shadow int bsh = area->bottom_shadow;
, bsh = area->bottom_shadow int ol = 0; // outside left
, ol = 0 // outside left int y_end;
, y_end int length;
, length;
if ( ax < 0 ) if ( ax < 0 )
{ {
@ -1498,7 +1449,7 @@ void FVTerm::putArea (int ax, int ay, term_area* area)
int cy = ay + y; int cy = ay + y;
ac = &area->text[y * line_len + ol + x]; ac = &area->text[y * line_len + ol + x];
tc = &vterm->text[cy * vterm->width + cx]; tc = &vterm->text[cy * vterm->width + cx];
putAreaCharacter (cx + 1, cy + 1, area->widget, ac, tc); putAreaCharacter (FPoint(cx + 1, cy + 1), area->widget, ac, tc);
} }
} }
@ -1558,7 +1509,7 @@ void FVTerm::scrollAreaForward (term_area* area)
{ {
setTermXY (0, vdesktop->height); setTermXY (0, vdesktop->height);
FTerm::scrollTermForward(); FTerm::scrollTermForward();
putArea (1, 1, vdesktop); putArea (FPoint(1, 1), vdesktop);
// avoid update lines from 0 to (y_max - 1) // avoid update lines from 0 to (y_max - 1)
for (int y = 0; y < y_max; y++) for (int y = 0; y < y_max; y++)
@ -1618,7 +1569,7 @@ void FVTerm::scrollAreaReverse (term_area* area)
{ {
setTermXY (0, 0); setTermXY (0, 0);
FTerm::scrollTermReverse(); FTerm::scrollTermReverse();
putArea (1, 1, vdesktop); putArea (FPoint(1, 1), vdesktop);
// avoid update lines from 1 to y_max // avoid update lines from 1 to y_max
for (int y = 1; y <= y_max; y++) for (int y = 1; y <= y_max; y++)
@ -1685,16 +1636,11 @@ void FVTerm::clearArea (term_area* area, int fillchar)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FVTerm::charData FVTerm::generateCharacter (const FPoint& pos) FVTerm::charData FVTerm::generateCharacter (const FPoint& pos)
{
// Generates characters for a given position considering all areas
return generateCharacter (pos.getX(), pos.getY());
}
//----------------------------------------------------------------------
FVTerm::charData FVTerm::generateCharacter (int x, int y)
{ {
// Generates characters for a given position considering all areas // Generates characters for a given position considering all areas
int x = pos.getX();
int y =pos.getY();
auto sc = &vdesktop->text[y * vdesktop->width + x]; // shown character auto sc = &vdesktop->text[y * vdesktop->width + x]; // shown character
if ( ! FWidget::window_list || FWidget::window_list->empty() ) if ( ! FWidget::window_list || FWidget::window_list->empty() )
@ -1758,24 +1704,14 @@ FVTerm::charData FVTerm::generateCharacter (int x, int y)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FVTerm::charData FVTerm::getCharacter ( character_type type FVTerm::charData FVTerm::getCharacter ( character_type char_type
, const FPoint& pos , const FPoint& pos
, FVTerm* obj ) , FVTerm* obj )
{ {
// Gets the overlapped or the covered character for a given position // Gets the overlapped or the covered character for a given position
return getCharacter (type, pos.getX(), pos.getY(), obj);
}
//---------------------------------------------------------------------- int x = pos.getX() - 1;
FVTerm::charData FVTerm::getCharacter ( character_type char_type int y = pos.getY() - 1;
, int x
, int y
, FVTerm* obj )
{
// Gets the overlapped or the covered character for the position (x,y)
x--;
y--;
int xx = x; int xx = x;
int yy = y; int yy = y;
@ -1825,7 +1761,7 @@ FVTerm::charData FVTerm::getCharacter ( character_type char_type
// Window visible and contains current character // Window visible and contains current character
if ( geometry.contains(x, y) ) if ( geometry.contains(x, y) )
getAreaCharacter (x, y, win, cc); getAreaCharacter (FPoint(x, y), win, cc);
} }
else if ( char_type == covered_character ) else if ( char_type == covered_character )
break; break;
@ -1839,16 +1775,7 @@ FVTerm::charData FVTerm::getCoveredCharacter ( const FPoint& pos
, FVTerm* obj ) , FVTerm* obj )
{ {
// Gets the covered character for a given position // Gets the covered character for a given position
return getCharacter (covered_character, pos.getX(), pos.getY(), obj); return getCharacter (covered_character, pos, obj);
}
//----------------------------------------------------------------------
FVTerm::charData FVTerm::getCoveredCharacter ( int x
, int y
, FVTerm* obj)
{
// Gets the covered character for the position (x,y)
return getCharacter (covered_character, x, y, obj);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1856,16 +1783,7 @@ FVTerm::charData FVTerm::getOverlappedCharacter ( const FPoint& pos
, FVTerm* obj ) , FVTerm* obj )
{ {
// Gets the overlapped character for a given position // Gets the overlapped character for a given position
return getCharacter (overlapped_character, pos.getX(), pos.getY(), obj); return getCharacter (overlapped_character, pos, obj);
}
//----------------------------------------------------------------------
FVTerm::charData FVTerm::getOverlappedCharacter ( int x
, int y
, FVTerm* obj)
{
// Gets the overlapped character for the position (x,y)
return getCharacter (overlapped_character, x, y, obj);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1963,7 +1881,7 @@ void FVTerm::init (bool disable_alt_screen)
// Create virtual terminal // Create virtual terminal
FRect term_geometry (0, 0, getColumnNumber(), getLineNumber()); FRect term_geometry (0, 0, getColumnNumber(), getLineNumber());
createVTerm (term_geometry); createVTerm (term_geometry.getSize());
// Create virtual desktop area // Create virtual desktop area
FSize shadow_size(0, 0); FSize shadow_size(0, 0);
@ -2039,7 +1957,7 @@ void FVTerm::putAreaLine (charData* ac, charData* tc, int length)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::putAreaCharacter ( int x, int y, FVTerm* obj void FVTerm::putAreaCharacter ( const FPoint& pos, FVTerm* obj
, charData* ac , charData* ac
, charData* tc ) , charData* tc )
{ {
@ -2047,7 +1965,7 @@ void FVTerm::putAreaCharacter ( int x, int y, FVTerm* obj
{ {
// Restore one character on vterm // Restore one character on vterm
charData ch; charData ch;
ch = getCoveredCharacter (x, y, obj); ch = getCoveredCharacter (pos, obj);
std::memcpy (tc, &ch, sizeof(*tc)); std::memcpy (tc, &ch, sizeof(*tc));
} }
else // Mot transparent else // Mot transparent
@ -2056,7 +1974,7 @@ void FVTerm::putAreaCharacter ( int x, int y, FVTerm* obj
{ {
// Get covered character + add the current color // Get covered character + add the current color
charData ch; charData ch;
ch = getCoveredCharacter (x, y, obj); ch = getCoveredCharacter (pos, obj);
ch.fg_color = ac->fg_color; ch.fg_color = ac->fg_color;
ch.bg_color = ac->bg_color; ch.bg_color = ac->bg_color;
ch.attr.bit.reverse = false; ch.attr.bit.reverse = false;
@ -2077,7 +1995,7 @@ void FVTerm::putAreaCharacter ( int x, int y, FVTerm* obj
// Add the covered background to this character // Add the covered background to this character
charData ch, cc; charData ch, cc;
std::memcpy (&ch, ac, sizeof(ch)); std::memcpy (&ch, ac, sizeof(ch));
cc = getCoveredCharacter (x, y, obj); cc = getCoveredCharacter (pos, obj);
ch.bg_color = cc.bg_color; ch.bg_color = cc.bg_color;
std::memcpy (tc, &ch, sizeof(*tc)); std::memcpy (tc, &ch, sizeof(*tc));
} }
@ -2087,12 +2005,14 @@ void FVTerm::putAreaCharacter ( int x, int y, FVTerm* obj
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::getAreaCharacter ( int x, int y, term_area* area void FVTerm::getAreaCharacter ( const FPoint& pos, term_area* area
, charData*& cc ) , charData*& cc )
{ {
int area_x = area->offset_left; int area_x = area->offset_left;
int area_y = area->offset_top; int area_y = area->offset_top;
int line_len = area->width + area->right_shadow; int line_len = area->width + area->right_shadow;
int x = pos.getX();
int y = pos.getY();
auto tmp = &area->text[(y - area_y) * line_len + (x - area_x)]; auto tmp = &area->text[(y - area_y) * line_len + (x - area_x)];
// Current character not transparent // Current character not transparent
@ -2652,7 +2572,7 @@ bool FVTerm::updateTerminalCursor()
int x = vterm->input_cursor_x; int x = vterm->input_cursor_x;
int y = vterm->input_cursor_y; int y = vterm->input_cursor_y;
if ( isInsideTerminal(x, y) ) if ( isInsideTerminal(FPoint(x, y)) )
{ {
setTermXY (x, y); setTermXY (x, y);
showCursor(); showCursor();
@ -2666,12 +2586,13 @@ bool FVTerm::updateTerminalCursor()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FVTerm::isInsideTerminal (int x, int y) bool FVTerm::isInsideTerminal (const FPoint& pos)
{ {
// Check whether the coordinates are within the virtual terminal // Check whether the coordinates are within the virtual terminal
FRect term_geometry (0, 0, getColumnNumber(), getLineNumber()); FRect term_geometry (0, 0, getColumnNumber(), getLineNumber());
if ( term_geometry.contains(x, y) ) if ( term_geometry.contains(pos) )
return true; return true;
else else
return false; return false;

View File

@ -339,25 +339,27 @@ void FWidget::setY (int y, bool adjust)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::setPos (int x, int y, bool adjust) void FWidget::setPos (const FPoint& p, bool adjust)
{ {
if ( getX() == x && wsize.getX() == x FPoint pos = p;
&& getY() == y && wsize.getY() == y )
if ( getX() == pos.getX() && wsize.getX() == pos.getX()
&& getY() == pos.getY() && wsize.getY() == pos.getY() )
{ {
return; return;
} }
if ( ! isWindowWidget() ) if ( ! isWindowWidget() )
{ {
if ( x < 1 ) if ( pos.getX() < 1 )
x = 1; pos.setX(1);
if ( y < 1 ) if ( pos.getY() < 1 )
y = 1; pos.setY(1);
} }
wsize.setPos(x, y); wsize.setPos(pos);
adjust_wsize.setPos(x, y); adjust_wsize.setPos(pos);
if ( adjust ) if ( adjust )
adjustSize(); adjustSize();
@ -408,8 +410,10 @@ void FWidget::setHeight (std::size_t height, bool adjust)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::setSize (std::size_t width, std::size_t height, bool adjust) void FWidget::setSize (const FSize& size, bool adjust)
{ {
std::size_t width = size.getWidth();
std::size_t height = size.getHeight();
width = std::min (width, size_hints.max_width); width = std::min (width, size_hints.max_width);
width = std::max (width, size_hints.min_width); width = std::max (width, size_hints.min_width);
height = std::min (height, size_hints.max_height); height = std::min (height, size_hints.max_height);
@ -552,34 +556,34 @@ void FWidget::setTermOffsetWithPadding()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::setTermSize (std::size_t w, std::size_t h) void FWidget::setTermSize (const FSize& size)
{ {
// Set xterm size to w x h // Set xterm size to width x height
if ( isXTerminal() ) if ( isXTerminal() )
{ {
rootObject->wsize.setRect(1, 1, w, h); rootObject->wsize.setRect(FPoint(1, 1), size);
rootObject->adjust_wsize = rootObject->wsize; rootObject->adjust_wsize = rootObject->wsize;
FTerm::setTermSize (w, h); // w = columns / h = lines FTerm::setTermSize(size); // width = columns / height = lines
detectTermSize(); detectTermSize();
} }
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::setGeometry ( int x, int y void FWidget::setGeometry (const FPoint& p, const FSize& s, bool adjust)
, std::size_t w, std::size_t h
, bool adjust )
{ {
// Sets the geometry of the widget relative to its parent // Sets the geometry of the widget relative to its parent
int term_x, term_y; int x = p.getX();
int y = p.getY();
std::size_t w = s.getWidth();
std::size_t h = s.getHeight();
w = std::min (w, size_hints.max_width); w = std::min (w, size_hints.max_width);
w = std::max (w, size_hints.min_width); w = std::max (w, size_hints.min_width);
h = std::min (h, size_hints.max_height); h = std::min (h, size_hints.max_height);
h = std::max (h, size_hints.min_height); h = std::max (h, size_hints.min_height);
if ( getX() == x && getY() == y && getWidth() == w && getHeight() == h ) if ( getPos() == p && getWidth() == w && getHeight() == h )
return; return;
if ( ! isWindowWidget() ) if ( ! isWindowWidget() )
@ -597,8 +601,8 @@ void FWidget::setGeometry ( int x, int y
( h < 1 ) ? wsize.setHeight(1) : wsize.setHeight(h); ( h < 1 ) ? wsize.setHeight(1) : wsize.setHeight(h);
adjust_wsize = wsize; adjust_wsize = wsize;
term_x = getTermX(); int term_x = getTermX();
term_y = getTermY(); int term_y = getTermY();
client_offset.setCoordinates ( term_x - 1 + padding.left client_offset.setCoordinates ( term_x - 1 + padding.left
, term_y - 1 + padding.top , term_y - 1 + padding.top
@ -615,11 +619,11 @@ void FWidget::setGeometry ( int x, int y
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FWidget::setCursorPos (int x, int y) bool FWidget::setCursorPos (const FPoint& pos)
{ {
// sets the input cursor position // sets the input cursor position
widget_cursor_position.setPoint(x, y); widget_cursor_position.setPoint(pos);
if ( ! flags.focus || isWindowWidget() ) if ( ! flags.focus || isWindowWidget() )
return false; return false;
@ -640,8 +644,8 @@ bool FWidget::setCursorPos (int x, int y)
widget_offsetY += (1 - area->widget->getTopPadding()); widget_offsetY += (1 - area->widget->getTopPadding());
} }
setAreaCursor ( widget_offsetX + x setAreaCursor ( FPoint ( widget_offsetX + pos.getX()
, widget_offsetY + y , widget_offsetY + pos.getY() )
, flags.visible_cursor , flags.visible_cursor
, area ); , area );
return true; return true;
@ -651,10 +655,11 @@ bool FWidget::setCursorPos (int x, int y)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::setPrintPos (int x, int y) void FWidget::setPrintPos (const FPoint& pos)
{ {
setPrintCursor ( offset.getX1() + getX() + x - 1, FPoint p{ offset.getX1() + getX() + pos.getX() - 1,
offset.getY1() + getY() + y - 1 ); offset.getY1() + getY() + pos.getY() - 1 };
setPrintCursor(p);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -742,7 +747,7 @@ void FWidget::setDoubleFlatLine (fc::sides side, int pos, bool bit)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FWidget* FWidget::childWidgetAt (FWidget* p, int x, int y) FWidget* FWidget::childWidgetAt (FWidget* p, const FPoint& pos)
{ {
if ( p && p->hasChildren() ) if ( p && p->hasChildren() )
{ {
@ -762,9 +767,9 @@ FWidget* FWidget::childWidgetAt (FWidget* p, int x, int y)
if ( widget->isEnabled() if ( widget->isEnabled()
&& widget->isShown() && widget->isShown()
&& ! widget->isWindowWidget() && ! widget->isWindowWidget()
&& widget->getTermGeometry().contains(x, y) ) && widget->getTermGeometry().contains(pos) )
{ {
auto child = childWidgetAt(widget, x, y); auto child = childWidgetAt(widget, pos);
return ( child != 0 ) ? child : widget; return ( child != 0 ) ? child : widget;
} }
@ -1017,7 +1022,7 @@ void FWidget::resize()
FRect term_geometry = getTermGeometry(); FRect term_geometry = getTermGeometry();
term_geometry.move (-1, -1); term_geometry.move (-1, -1);
resizeVTerm (term_geometry); resizeVTerm (term_geometry.getSize());
resizeArea (term_geometry, getShadow(), vdesktop); resizeArea (term_geometry, getShadow(), vdesktop);
adjustSizeGlobal(); adjustSizeGlobal();
} }
@ -1211,10 +1216,10 @@ void FWidget::detectTermSize()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::move (int dx, int dy) void FWidget::move (const FPoint& pos)
{ {
wsize.move(dx, dy); wsize.move(pos);
adjust_wsize.move(dx, dy); adjust_wsize.move(pos);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1268,14 +1273,14 @@ void FWidget::clearShadow()
{ {
for (std::size_t y = 1; y <= getHeight(); y++) for (std::size_t y = 1; y <= getHeight(); y++)
{ {
setPrintPos (w + 1, int(y)); setPrintPos (FPoint(w + 1, int(y)));
print (' '); // clear █ print (' '); // clear █
} }
} }
if ( h <= offset.getY2() ) if ( h <= offset.getY2() )
{ {
setPrintPos (2, h + 1); setPrintPos (FPoint(2, h + 1));
for (std::size_t i = 1; i <= getWidth(); i++) for (std::size_t i = 1; i <= getWidth(); i++)
print (' '); // clear ▀ print (' '); // clear ▀
@ -1303,7 +1308,7 @@ void FWidget::drawFlatBorder()
for (std::size_t y = 0; y < getHeight(); y++) for (std::size_t y = 0; y < getHeight(); y++)
{ {
setPrintPos (x1 - 1, y1 + int(y) + 1); setPrintPos (FPoint(x1 - 1, y1 + int(y) + 1));
if ( double_flatline_mask.left[uLong(y)] ) if ( double_flatline_mask.left[uLong(y)] )
// left+right line (on left side) // left+right line (on left side)
@ -1313,7 +1318,7 @@ void FWidget::drawFlatBorder()
print (fc::NF_rev_border_line_right); print (fc::NF_rev_border_line_right);
} }
setPrintPos (x2, y1 + 1); setPrintPos (FPoint(x2, y1 + 1));
for (std::size_t y = 0; y < getHeight(); y++) for (std::size_t y = 0; y < getHeight(); y++)
{ {
@ -1324,10 +1329,10 @@ void FWidget::drawFlatBorder()
// left line (on right side) // left line (on right side)
print (fc::NF_border_line_left); print (fc::NF_border_line_left);
setPrintPos (x2, y1 + int(y) + 2); setPrintPos (FPoint(x2, y1 + int(y) + 2));
} }
setPrintPos (x1, y1); setPrintPos (FPoint(x1, y1));
for (std::size_t x = 0; x < getWidth(); x++) for (std::size_t x = 0; x < getWidth(); x++)
{ {
@ -1339,7 +1344,7 @@ void FWidget::drawFlatBorder()
print (fc::NF_border_line_bottom); print (fc::NF_border_line_bottom);
} }
setPrintPos (x1, y2); setPrintPos (FPoint(x1, y2));
for (std::size_t x = 0; x < getWidth(); x++) for (std::size_t x = 0; x < getWidth(); x++)
{ {
@ -1371,7 +1376,7 @@ void FWidget::clearFlatBorder()
// clear on left side // clear on left side
for (std::size_t y = 0; y < getHeight(); y++) for (std::size_t y = 0; y < getHeight(); y++)
{ {
setPrintPos (x1 - 1, y1 + int(y) + 1); setPrintPos (FPoint(x1 - 1, y1 + int(y) + 1));
if ( double_flatline_mask.left[y] ) if ( double_flatline_mask.left[y] )
print (fc::NF_border_line_left); print (fc::NF_border_line_left);
@ -1382,7 +1387,7 @@ void FWidget::clearFlatBorder()
// clear on right side // clear on right side
for (std::size_t y = 0; y < getHeight(); y++) for (std::size_t y = 0; y < getHeight(); y++)
{ {
setPrintPos (x2, y1 + int(y) + 1); setPrintPos (FPoint(x2, y1 + int(y) + 1));
if ( double_flatline_mask.right[y] ) if ( double_flatline_mask.right[y] )
print (fc::NF_rev_border_line_right); print (fc::NF_rev_border_line_right);
@ -1391,7 +1396,7 @@ void FWidget::clearFlatBorder()
} }
// clear at top // clear at top
setPrintPos (x1, y1); setPrintPos (FPoint(x1, y1));
for (std::size_t x = 0; x < getWidth(); x++) for (std::size_t x = 0; x < getWidth(); x++)
{ {
@ -1402,7 +1407,7 @@ void FWidget::clearFlatBorder()
} }
// clear at bottom // clear at bottom
setPrintPos (x1, y2); setPrintPos (FPoint(x1, y2));
for (std::size_t x = 0; x < getWidth(); x++) for (std::size_t x = 0; x < getWidth(); x++)
{ {
@ -1614,9 +1619,9 @@ void FWidget::adjustSizeGlobal()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::hideSize (std::size_t width, std::size_t height) void FWidget::hideSize (const FSize& size)
{ {
if ( width == 0 || height == 0 ) if ( size.isEmpty() )
return; return;
FColor fg, bg; FColor fg, bg;
@ -1634,14 +1639,14 @@ void FWidget::hideSize (std::size_t width, std::size_t height)
} }
setColor (fg, bg); setColor (fg, bg);
auto blank = createBlankArray(width); auto blank = createBlankArray(size.getWidth());
if ( blank == 0 ) if ( blank == 0 )
return; return;
for (int y = 0; y < int(height); y++) for (int y = 0; y < int(size.getWidth()); y++)
{ {
setPrintPos (1, 1 + y); setPrintPos (FPoint(1, 1 + y));
print (blank); print (blank);
} }
@ -2225,7 +2230,7 @@ void FWidget::drawChildren()
void FWidget::drawTransparentShadow (int x1, int y1, int x2, int y2) void FWidget::drawTransparentShadow (int x1, int y1, int x2, int y2)
{ {
// transparent shadow // transparent shadow
setPrintPos (x2 + 1, y1); setPrintPos (FPoint(x2 + 1, y1));
setTransparent(); setTransparent();
print (" "); print (" ");
unsetTransparent(); unsetTransparent();
@ -2235,12 +2240,12 @@ void FWidget::drawTransparentShadow (int x1, int y1, int x2, int y2)
for (std::size_t y = 1; y < getHeight(); y++) for (std::size_t y = 1; y < getHeight(); y++)
{ {
setPrintPos (x2 + 1, y1 + int(y)); setPrintPos (FPoint(x2 + 1, y1 + int(y)));
print (" "); print (" ");
} }
unsetTransShadow(); unsetTransShadow();
setPrintPos (x1, y2 + 1); setPrintPos (FPoint(x1, y2 + 1));
setTransparent(); setTransparent();
print (" "); print (" ");
unsetTransparent(); unsetTransparent();
@ -2266,7 +2271,7 @@ void FWidget::drawBlockShadow (int x1, int y1, int x2, int y2)
if ( ! hasShadowCharacter() ) if ( ! hasShadowCharacter() )
return; return;
setPrintPos (x2 + 1, y1); setPrintPos (FPoint(x2 + 1, y1));
if ( isWindowWidget() ) if ( isWindowWidget() )
{ {
@ -2284,11 +2289,11 @@ void FWidget::drawBlockShadow (int x1, int y1, int x2, int y2)
for (std::size_t y = 1; y < getHeight(); y++) for (std::size_t y = 1; y < getHeight(); y++)
{ {
setPrintPos (x2 + 1, y1 + int(y)); setPrintPos (FPoint(x2 + 1, y1 + int(y)));
print (block); // █ print (block); // █
} }
setPrintPos (x1 + 1, y2 + 1); setPrintPos (FPoint(x1 + 1, y2 + 1));
if ( isWindowWidget() ) if ( isWindowWidget() )
setInheritBackground(); setInheritBackground();
@ -2305,7 +2310,7 @@ inline void FWidget::drawBox (int x1, int y1, int x2, int y2)
{ {
// Use box-drawing characters to draw a border // Use box-drawing characters to draw a border
setPrintPos (x1, y1); setPrintPos (FPoint(x1, y1));
print (fc::BoxDrawingsDownAndRight); // ┌ print (fc::BoxDrawingsDownAndRight); // ┌
for (int x = x1 + 1; x < x2; x++) for (int x = x1 + 1; x < x2; x++)
@ -2315,13 +2320,13 @@ inline void FWidget::drawBox (int x1, int y1, int x2, int y2)
for (int y = y1 + 1; y < y2; y++) for (int y = y1 + 1; y < y2; y++)
{ {
setPrintPos (x1, y); setPrintPos (FPoint(x1, y));
print (fc::BoxDrawingsVertical); // │ print (fc::BoxDrawingsVertical); // │
setPrintPos (x2, y); setPrintPos (FPoint(x2, y));
print (fc::BoxDrawingsVertical); // │ print (fc::BoxDrawingsVertical); // │
} }
setPrintPos (x1, y2); setPrintPos (FPoint(x1, y2));
print (fc::BoxDrawingsUpAndRight); // └ print (fc::BoxDrawingsUpAndRight); // └
for (int x = x1 + 1; x < x2; x++) for (int x = x1 + 1; x < x2; x++)
@ -2331,9 +2336,9 @@ inline void FWidget::drawBox (int x1, int y1, int x2, int y2)
for (int x = x1 + 1; x < x2; x++) for (int x = x1 + 1; x < x2; x++)
{ {
setPrintPos (x, y1); setPrintPos (FPoint(x, y1));
print (fc::BoxDrawingsHorizontal); // ─ print (fc::BoxDrawingsHorizontal); // ─
setPrintPos (x, y2); setPrintPos (FPoint(x, y2));
print (fc::BoxDrawingsHorizontal); // ─ print (fc::BoxDrawingsHorizontal); // ─
} }
} }
@ -2343,7 +2348,7 @@ inline void FWidget::drawNewFontBox (int x1, int y1, int x2, int y2)
{ {
// Use new graphical font characters to draw a border // Use new graphical font characters to draw a border
setPrintPos (x1, y1); setPrintPos (FPoint(x1, y1));
print (fc::NF_border_corner_middle_upper_left); // ┌ print (fc::NF_border_corner_middle_upper_left); // ┌
for (int x = x1 + 1; x < x2; x++) for (int x = x1 + 1; x < x2; x++)
@ -2353,13 +2358,13 @@ inline void FWidget::drawNewFontBox (int x1, int y1, int x2, int y2)
for (int y = y1 + 1; y <= y2; y++) for (int y = y1 + 1; y <= y2; y++)
{ {
setPrintPos (x1, y); setPrintPos (FPoint(x1, y));
print (fc::NF_border_line_left); // border left ⎸ print (fc::NF_border_line_left); // border left ⎸
setPrintPos (x2, y); setPrintPos (FPoint(x2, y));
print (fc::NF_rev_border_line_right); // border right⎹ print (fc::NF_rev_border_line_right); // border right⎹
} }
setPrintPos (x1, y2); setPrintPos (FPoint(x1, y2));
print (fc::NF_border_corner_middle_lower_left); // └ print (fc::NF_border_corner_middle_lower_left); // └
for (int x = x1 + 1; x < x2; x++) for (int x = x1 + 1; x < x2; x++)

View File

@ -179,9 +179,9 @@ bool FWindow::setTransparentShadow (bool enable)
flags.shadow = flags.trans_shadow = enable; flags.shadow = flags.trans_shadow = enable;
if ( enable ) if ( enable )
setShadowSize (2, 1); setShadowSize (FSize(2, 1));
else else
setShadowSize (0, 0); setShadowSize (FSize(0, 0));
return enable; return enable;
} }
@ -196,13 +196,13 @@ bool FWindow::setShadow (bool enable)
{ {
flags.shadow = true; flags.shadow = true;
flags.trans_shadow = false; flags.trans_shadow = false;
setShadowSize (1, 1); setShadowSize (FSize(1, 1));
} }
else else
{ {
flags.shadow = false; flags.shadow = false;
flags.trans_shadow = false; flags.trans_shadow = false;
setShadowSize (0, 0); setShadowSize (FSize(0, 0));
} }
return enable; return enable;
@ -251,7 +251,7 @@ void FWindow::drawBorder()
, y1 = 1 , y1 = 1
, y2 = 1 + int(getHeight()) - 1; , y2 = 1 + int(getHeight()) - 1;
setPrintPos (x1, y1); setPrintPos (FPoint(x1, y1));
print (fc::NF_border_corner_upper_left); // ⎡ print (fc::NF_border_corner_upper_left); // ⎡
for (int x = x1 + 1; x < x2; x++) for (int x = x1 + 1; x < x2; x++)
@ -261,22 +261,22 @@ void FWindow::drawBorder()
for (int y = y1 + 1; y < y2; y++) for (int y = y1 + 1; y < y2; y++)
{ {
setPrintPos (x1, y); setPrintPos (FPoint(x1, y));
// border left ⎸ // border left ⎸
print (fc::NF_border_line_left); print (fc::NF_border_line_left);
setPrintPos (x2, y); setPrintPos (FPoint(x2, y));
// border right⎹ // border right⎹
print (fc::NF_rev_border_line_right); print (fc::NF_rev_border_line_right);
} }
setPrintPos (x1, y2); setPrintPos (FPoint(x1, y2));
// lower left corner border ⎣ // lower left corner border ⎣
print (fc::NF_border_corner_lower_left); print (fc::NF_border_corner_lower_left);
for (std::size_t x = 2; x < getWidth(); x++) // low line _ for (std::size_t x = 2; x < getWidth(); x++) // low line _
print (fc::NF_border_line_bottom); print (fc::NF_border_line_bottom);
setPrintPos (x2, y2); setPrintPos (FPoint(x2, y2));
// lower right corner border ⎦ // lower right corner border ⎦
print (fc::NF_rev_border_corner_lower_right); print (fc::NF_rev_border_corner_lower_right);
} }
@ -326,12 +326,14 @@ void FWindow::setY (int y, bool adjust)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWindow::setPos (int x, int y, bool adjust) void FWindow::setPos (const FPoint& p, bool adjust)
{ {
if ( y < 1 ) FPoint pos = p;
y = 1;
FWidget::setPos (x, y, adjust); if ( pos.getY() < 1 )
pos.setY(1);
FWidget::setPos (pos, adjust);
if ( isVirtualWindow() ) if ( isVirtualWindow() )
{ {
@ -369,11 +371,11 @@ void FWindow::setHeight (std::size_t h, bool adjust)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWindow::setSize (std::size_t w, std::size_t h, bool adjust) void FWindow::setSize (const FSize& size, bool adjust)
{ {
std::size_t old_width = getWidth(); std::size_t old_width = getWidth();
std::size_t old_height = getHeight(); std::size_t old_height = getHeight();
FWidget::setSize (w, h, adjust); FWidget::setSize (size, adjust);
if ( isVirtualWindow() if ( isVirtualWindow()
&& (getWidth() != old_width || getHeight() != old_height) ) && (getWidth() != old_width || getHeight() != old_height) )
@ -385,9 +387,7 @@ void FWindow::setSize (std::size_t w, std::size_t h, bool adjust)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWindow::setGeometry ( int x, int y void FWindow::setGeometry ( const FPoint& p, const FSize& size, bool adjust)
, std::size_t w, std::size_t h
, bool adjust )
{ {
// Sets the geometry of the widget // Sets the geometry of the widget
@ -395,11 +395,12 @@ void FWindow::setGeometry ( int x, int y
int old_y = getY(); int old_y = getY();
std::size_t old_width = getWidth(); std::size_t old_width = getWidth();
std::size_t old_height = getHeight(); std::size_t old_height = getHeight();
FPoint pos = p;
if ( y < 1 ) if ( pos.getY() < 1 )
y = 1; pos.setY(1);
FWidget::setGeometry (x, y, w, h, adjust); FWidget::setGeometry (pos, size, adjust);
if ( ! isVirtualWindow() ) if ( ! isVirtualWindow() )
return; return;
@ -421,9 +422,9 @@ void FWindow::setGeometry ( int x, int y
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWindow::move (int dx, int dy) void FWindow::move (const FPoint& pos)
{ {
FWidget::move (dx, dy); FWidget::move(pos);
if ( isVirtualWindow() ) if ( isVirtualWindow() )
{ {
@ -676,7 +677,7 @@ bool FWindow::zoomWindow()
// save the current geometry // save the current geometry
normalGeometry = getGeometry(); normalGeometry = getGeometry();
FRect oldGeometry = getTermGeometryWithShadow(); FRect oldGeometry = getTermGeometryWithShadow();
setGeometry (1, 1, getMaxWidth(), getMaxHeight()); setGeometry (FPoint(1, 1), FSize(getMaxWidth(), getMaxHeight()));
restoreVTerm (oldGeometry); restoreVTerm (oldGeometry);
redraw(); redraw();
} }
@ -767,18 +768,13 @@ bool FWindow::activatePrevWindow()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWindow::setShadowSize (std::size_t right, std::size_t bottom) void FWindow::setShadowSize (const FSize& size)
{ {
std::size_t old_right = getShadow().getWidth(); const FSize& old_shadow = getShadow();
std::size_t old_bottom = getShadow().getHeight(); FWidget::setShadowSize (size);
const FSize& new_shadow = getShadow();
FWidget::setShadowSize (right, bottom); if ( isVirtualWindow() && (new_shadow != old_shadow) )
std::size_t new_right = getShadow().getWidth();
std::size_t new_bottom = getShadow().getHeight();
if ( isVirtualWindow()
&& (new_right != old_right || new_bottom != old_bottom) )
{ {
auto geometry = getTermGeometry(); auto geometry = getTermGeometry();
geometry.move(-1, -1); geometry.move(-1, -1);
@ -796,7 +792,7 @@ void FWindow::adjustSize()
FWidget::adjustSize(); FWidget::adjustSize();
if ( zoomed ) if ( zoomed )
setGeometry (1, 1, getMaxWidth(), getMaxHeight(), false); setGeometry (FPoint(1, 1), FSize(getMaxWidth(), getMaxHeight()), false);
else if ( isVirtualWindow() ) else if ( isVirtualWindow() )
{ {
if ( getX() != old_x ) if ( getX() != old_x )

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2012-2018 Markus Gans * * Copyright 2012-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -76,8 +76,6 @@ class FDialog : public FWindow
public: public:
// Using-declaration // Using-declaration
using FWindow::setResizeable; using FWindow::setResizeable;
using FWindow::move;
using FWindow::setPos;
// Enumeration // Enumeration
enum DialogCode enum DialogCode
@ -124,13 +122,13 @@ class FDialog : public FWindow
virtual void show() override; virtual void show() override;
virtual void hide() override; virtual void hide() override;
int exec(); int exec();
virtual void setPos (int, int, bool = true) override; virtual void setPos (const FPoint&, bool = true) override;
virtual void move (int, int) override; virtual void move (const FPoint&) override;
bool moveUp (int); bool moveUp (int);
bool moveDown (int); bool moveDown (int);
bool moveLeft (int); bool moveLeft (int);
bool moveRight (int); bool moveRight (int);
virtual void setSize (std::size_t, std::size_t, bool = true) override; virtual void setSize (const FSize&, bool = true) override;
bool reduceHeight (int); bool reduceHeight (int);
bool expandHeight (int); bool expandHeight (int);
bool reduceWidth (int); bool reduceWidth (int);

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2014-2018 Markus Gans * * Copyright 2014-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -336,7 +336,7 @@ class FTimerEvent : public FEvent // timer event
int getTimerId() const; int getTimerId() const;
protected: protected:
int id; int id{0};
}; };
#pragma pack(pop) #pragma pack(pop)
@ -353,15 +353,22 @@ class FUserEvent : public FEvent // timer event
{ {
public: public:
FUserEvent() = default; FUserEvent() = default;
// Disable copy constructor
FUserEvent (const FUserEvent&) = delete;
FUserEvent (fc::events, int); FUserEvent (fc::events, int);
~FUserEvent(); ~FUserEvent();
// Disable assignment operator (=)
FUserEvent& operator = (const FUserEvent&) = delete;
int getUserId() const; int getUserId() const;
FDataPtr getData() const; FDataPtr getData() const;
void setData (FDataPtr); void setData (FDataPtr);
protected: protected:
int uid; int uid{0};
FDataPtr data_pointer{nullptr}; FDataPtr data_pointer{nullptr};
}; };

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2014-2018 Markus Gans * * Copyright 2014-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -169,7 +169,7 @@ class FFileDialog : public FDialog
// Method // Method
void init(); void init();
void widgetSettings (int, int); void widgetSettings (const FPoint&);
void initCallbacks(); void initCallbacks();
bool pattern_match (const char* const, char[]); bool pattern_match (const char* const, char[]);
void clear(); void clear();

View File

@ -185,8 +185,7 @@ class FListBox : public FWidget
void showInsideBrackets (std::size_t, fc::brackets_type); void showInsideBrackets (std::size_t, fc::brackets_type);
void showNoBrackets (std::size_t); void showNoBrackets (std::size_t);
void showNoBrackets (listBoxItems::iterator); void showNoBrackets (listBoxItems::iterator);
virtual void setGeometry ( int, int virtual void setGeometry ( const FPoint&, const FSize&
, std::size_t, std::size_t
, bool = true ) override; , bool = true ) override;
void setMultiSelection (bool); void setMultiSelection (bool);
void setMultiSelection (); void setMultiSelection ();

View File

@ -295,8 +295,7 @@ class FListView : public FWidget
FListViewItem* getCurrentItem(); FListViewItem* getCurrentItem();
// Mutators // Mutators
virtual void setGeometry ( int, int virtual void setGeometry ( const FPoint&, const FSize&
, std::size_t, std::size_t
, bool = true ) override; , bool = true ) override;
void setColumnAlignment (int, fc::text_alignment); void setColumnAlignment (int, fc::text_alignment);
void setColumnText (int, const FString&); void setColumnText (int, const FString&);

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2015-2018 Markus Gans * * Copyright 2015-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -172,6 +172,7 @@ class FMenuItem : public FWidget
// Methods // Methods
void init (FWidget*); void init (FWidget*);
uChar hotKey(); uChar hotKey();
void updateSuperMenuDimensions();
void processActivate(); void processActivate();
void processDeactivate(); void processDeactivate();
void createDialogList (FMenu*); void createDialogList (FMenu*);

View File

@ -78,6 +78,7 @@ class FPoint
int getY() const; int getY() const;
void setX (int); void setX (int);
void setY (int); void setY (int);
void setPoint (const FPoint&);
void setPoint (int, int); void setPoint (int, int);
// Inquiry // Inquiry
@ -140,6 +141,10 @@ inline int FPoint::getX() const
inline int FPoint::getY() const inline int FPoint::getY() const
{ return ypos; } { return ypos; }
//----------------------------------------------------------------------
inline void FPoint::setPoint (const FPoint& p)
{ setPoint(p.xpos, p.ypos); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline int& FPoint::x_ref() inline int& FPoint::x_ref()
{ return xpos; } { return xpos; }

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2014-2018 Markus Gans * * Copyright 2014-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -82,9 +82,8 @@ class FProgressbar : public FWidget
// Mutators // Mutators
void setPercentage (std::size_t); void setPercentage (std::size_t);
virtual void setGeometry ( int, int virtual void setGeometry ( const FPoint&, const FSize&
, std::size_t, std::size_t , bool = true ) override;
, bool = true) override;
bool setShadow (bool); bool setShadow (bool);
bool setShadow(); bool setShadow();
bool unsetShadow(); bool unsetShadow();

View File

@ -107,6 +107,7 @@ class FRect
void setSize (std::size_t, std::size_t); void setSize (std::size_t, std::size_t);
void setSize (const FSize&); void setSize (const FSize&);
void setRect (const FRect&); void setRect (const FRect&);
void setRect (const FPoint&, const FSize&);
void setRect (int, int, std::size_t, std::size_t); void setRect (int, int, std::size_t, std::size_t);
void setCoordinates (const FPoint&, const FPoint&); void setCoordinates (const FPoint&, const FPoint&);
void setCoordinates (int, int, int, int); void setCoordinates (int, int, int, int);

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2012-2018 Markus Gans * * Copyright 2012-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -109,9 +109,8 @@ class FScrollbar : public FWidget
void setSteps (double); void setSteps (double);
void setPageSize (int, int); void setPageSize (int, int);
void setOrientation (fc::orientation); void setOrientation (fc::orientation);
virtual void setGeometry ( int, int virtual void setGeometry ( const FPoint&, const FSize&
, std::size_t, std::size_t , bool = true ) override;
, bool = true) override;
// Methods // Methods
virtual void resize() override; virtual void resize() override;

View File

@ -73,8 +73,6 @@ class FScrollView : public FWidget
public: public:
// Using-declaration // Using-declaration
using FWidget::setGeometry; using FWidget::setGeometry;
using FWidget::setPrintPos;
using FWidget::setPos;
// Constructor // Constructor
explicit FScrollView (FWidget* = nullptr); explicit FScrollView (FWidget* = nullptr);
@ -92,8 +90,10 @@ class FScrollView : public FWidget
virtual const char* getClassName() const override; virtual const char* getClassName() const override;
std::size_t getViewportWidth() const; std::size_t getViewportWidth() const;
std::size_t getViewportHeight() const; std::size_t getViewportHeight() const;
const FSize getViewportSize();
std::size_t getScrollWidth() const; std::size_t getScrollWidth() const;
std::size_t getScrollHeight() const; std::size_t getScrollHeight() const;
const FSize getScrollSize() const;
const FPoint getScrollPos() const; const FPoint getScrollPos() const;
int getScrollX() const; int getScrollX() const;
int getScrollY() const; int getScrollY() const;
@ -101,18 +101,17 @@ class FScrollView : public FWidget
// Mutator // Mutator
virtual void setScrollWidth (std::size_t); virtual void setScrollWidth (std::size_t);
virtual void setScrollHeight (std::size_t); virtual void setScrollHeight (std::size_t);
virtual void setScrollSize (std::size_t, std::size_t); virtual void setScrollSize (const FSize&);
virtual void setX (int, bool = true) override; virtual void setX (int, bool = true) override;
virtual void setY (int, bool = true) override; virtual void setY (int, bool = true) override;
virtual void setPos (int, int, bool = true) override; virtual void setPos (const FPoint&, bool = true) override;
virtual void setWidth (std::size_t, bool = true) override; virtual void setWidth (std::size_t, bool = true) override;
virtual void setHeight (std::size_t, bool = true) override; virtual void setHeight (std::size_t, bool = true) override;
virtual void setSize (std::size_t, std::size_t, bool = true) override; virtual void setSize (const FSize&, bool = true) override;
virtual void setGeometry ( int, int virtual void setGeometry ( const FPoint&, const FSize&
, std::size_t, std::size_t
, bool = true ) override; , bool = true ) override;
void setCursorPos (int, int); void setCursorPos (const FPoint&);
void setPrintPos (int, int); void setPrintPos (const FPoint&);
bool setViewportPrint (bool); bool setViewportPrint (bool);
bool setViewportPrint(); bool setViewportPrint();
bool unsetViewportPrint(); bool unsetViewportPrint();
@ -208,6 +207,10 @@ inline std::size_t FScrollView::getViewportWidth() const
inline std::size_t FScrollView::getViewportHeight() const inline std::size_t FScrollView::getViewportHeight() const
{ return getHeight() - horizontal_border_spacing; } { return getHeight() - horizontal_border_spacing; }
//----------------------------------------------------------------------
inline const FSize FScrollView::getViewportSize()
{ return FSize(getViewportWidth(), getViewportHeight()); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline std::size_t FScrollView::getScrollWidth() const inline std::size_t FScrollView::getScrollWidth() const
{ return scroll_geometry.getWidth(); } { return scroll_geometry.getWidth(); }
@ -216,6 +219,10 @@ inline std::size_t FScrollView::getScrollWidth() const
inline std::size_t FScrollView::getScrollHeight() const inline std::size_t FScrollView::getScrollHeight() const
{ return scroll_geometry.getHeight(); } { return scroll_geometry.getHeight(); }
//----------------------------------------------------------------------
inline const FSize FScrollView::getScrollSize() const
{ return scroll_geometry.getSize(); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const FPoint FScrollView::getScrollPos() const inline const FPoint FScrollView::getScrollPos() const
{ return viewport_geometry.getPos(); } { return viewport_geometry.getPos(); }

View File

@ -247,7 +247,7 @@ class FTerm final
static char* enableCursor(); static char* enableCursor();
static char* disableCursor(); static char* disableCursor();
static void detectTermSize(); static void detectTermSize();
static void setTermSize (std::size_t, std::size_t); static void setTermSize (const FSize&);
static void setTermTitle (const FString&); static void setTermTitle (const FString&);
static void setKDECursor (fc::kdeKonsoleCursorShape); static void setKDECursor (fc::kdeKonsoleCursorShape);
static void saveColorMap(); static void saveColorMap();

View File

@ -65,7 +65,7 @@ class FTermXTerminal final
static void setCursorStyle (fc::xtermCursorStyle); static void setCursorStyle (fc::xtermCursorStyle);
static void setFont (const FString&); static void setFont (const FString&);
static void setTitle (const FString&); static void setTitle (const FString&);
static void setTermSize (std::size_t, std::size_t); static void setTermSize (const FSize&);
static void setForeground (const FString&); static void setForeground (const FString&);
static void setBackground (const FString&); static void setBackground (const FString&);
static void setCursorColor (const FString&); static void setCursorColor (const FString&);

View File

@ -97,8 +97,7 @@ class FTextView : public FWidget
const FStringList& getLines() const; const FStringList& getLines() const;
// Mutators // Mutators
virtual void setGeometry ( int, int virtual void setGeometry ( const FPoint&, const FSize&
, std::size_t, std::size_t
, bool = true ) override; , bool = true ) override;
void setText (const FString&); void setText (const FString&);
void scrollToX (int); void scrollToX (int);

View File

@ -91,9 +91,8 @@ class FToggleButton : public FWidget
FString& getText(); FString& getText();
// Mutators // Mutators
virtual void setGeometry ( int, int virtual void setGeometry ( const FPoint&, const FSize&
, std::size_t, std::size_t , bool = true ) override;
, bool = true) override;
bool setNoUnderline (bool); bool setNoUnderline (bool);
bool setNoUnderline(); bool setNoUnderline();
bool unsetNoUnderline(); bool unsetNoUnderline();

View File

@ -158,7 +158,6 @@ class FVTerm
void hideCursor(); void hideCursor();
void showCursor(); void showCursor();
void setPrintCursor (const FPoint&); void setPrintCursor (const FPoint&);
void setPrintCursor (int, int);
FColor rgb2ColorIndex (uInt8, uInt8, uInt8); FColor rgb2ColorIndex (uInt8, uInt8, uInt8);
void setColor (FColor, FColor); void setColor (FColor, FColor);
static void setNormal(); static void setNormal();
@ -277,10 +276,8 @@ class FVTerm
// Methods // Methods
virtual void clearArea (int = ' '); virtual void clearArea (int = ' ');
void createVTerm (const FRect&); void createVTerm (const FSize&);
void createVTerm (int, int); void resizeVTerm (const FSize&);
void resizeVTerm (const FRect&);
void resizeVTerm (int, int);
void putVTerm(); void putVTerm();
void updateTerminal (terminal_update); void updateTerminal (terminal_update);
void updateTerminal(); void updateTerminal();
@ -340,83 +337,56 @@ class FVTerm
void createArea ( const FRect& void createArea ( const FRect&
, const FSize& , const FSize&
, term_area*& ); , term_area*& );
void createArea ( int, int, int, int
, int, int
, term_area*& );
void resizeArea ( const FRect& void resizeArea ( const FRect&
, const FSize& , const FSize&
, term_area* ); , term_area* );
void resizeArea ( int, int, int, int
, int, int
, term_area* );
static void removeArea (term_area*&); static void removeArea (term_area*&);
static void restoreVTerm (const FRect&); static void restoreVTerm (const FRect&);
static void restoreVTerm (int, int, int, int); void setTextToDefault (term_area*, const FSize&);
void setTextToDefault (term_area*, int, int);
static bool reallocateTextArea ( term_area* static bool reallocateTextArea ( term_area*
, std::size_t , std::size_t
, std::size_t ); , std::size_t );
static bool reallocateTextArea ( term_area* static bool reallocateTextArea ( term_area*
, std::size_t ); , std::size_t );
static covered_state isCovered ( const FPoint& static covered_state isCovered (const FPoint&, term_area*);
, term_area* );
static covered_state isCovered ( int, int
, term_area* );
static void updateOverlappedColor ( term_area* static void updateOverlappedColor ( term_area*
, int, int, int, int ); , const FPoint&
static void updateOverlappedCharacter (term_area*, int, int); , const FPoint& );
static void updateOverlappedCharacter ( term_area*
, const FPoint& );
static void updateShadedCharacter ( term_area* static void updateShadedCharacter ( term_area*
, int, int, int, int ); , const FPoint&
, const FPoint& );
static void updateInheritBackground ( term_area* static void updateInheritBackground ( term_area*
, int, int, int, int ); , const FPoint&
, const FPoint& );
static void updateCharacter ( term_area* static void updateCharacter ( term_area*
, int, int, int, int ); , const FPoint&
, const FPoint& );
static bool updateVTermCharacter ( term_area* static bool updateVTermCharacter ( term_area*
, int, int, int, int ); , const FPoint&
, const FPoint& );
static void callPreprocessingHandler (term_area*); static void callPreprocessingHandler (term_area*);
void updateVTerm(); void updateVTerm();
void updateVTerm (term_area*); void updateVTerm (term_area*);
bool updateVTermCursor (term_area*); bool updateVTermCursor (term_area*);
static bool isInsideArea (int, int, term_area*); static bool isInsideArea (const FPoint&, term_area*);
static void setAreaCursor ( const FPoint& static void setAreaCursor ( const FPoint&
, bool, term_area* ); , bool, term_area* );
static void setAreaCursor ( int, int
, bool, term_area*);
static void getArea (const FPoint&, term_area*); static void getArea (const FPoint&, term_area*);
static void getArea (int, int, term_area*);
static void getArea (const FRect&, term_area*); static void getArea (const FRect&, term_area*);
static void getArea (int, int, int, int, term_area*);
static void putArea (const FPoint&, term_area*); static void putArea (const FPoint&, term_area*);
static void putArea (int, int, term_area*);
void scrollAreaForward (term_area*); void scrollAreaForward (term_area*);
void scrollAreaReverse (term_area*); void scrollAreaReverse (term_area*);
void clearArea (term_area*, int = ' '); void clearArea (term_area*, int = ' ');
static charData generateCharacter (const FPoint&); static charData generateCharacter (const FPoint&);
static charData generateCharacter (int, int);
static charData getCharacter ( character_type static charData getCharacter ( character_type
, const FPoint& , const FPoint&
, FVTerm* ); , FVTerm* );
static charData getCharacter ( character_type
, int
, int, FVTerm* );
static charData getCoveredCharacter (const FPoint&, FVTerm*); static charData getCoveredCharacter (const FPoint&, FVTerm*);
static charData getCoveredCharacter (int, int, FVTerm*);
static charData getOverlappedCharacter (const FPoint&, FVTerm*); static charData getOverlappedCharacter (const FPoint&, FVTerm*);
static charData getOverlappedCharacter (int, int, FVTerm*);
void processTerminalUpdate(); void processTerminalUpdate();
static void startTerminalUpdate(); static void startTerminalUpdate();
static void finishTerminalUpdate(); static void finishTerminalUpdate();
@ -457,9 +427,9 @@ class FVTerm
static void init_characterLengths (FOptiMove*); static void init_characterLengths (FOptiMove*);
void finish(); void finish();
static void putAreaLine (charData*, charData*, int); static void putAreaLine (charData*, charData*, int);
static void putAreaCharacter ( int, int, FVTerm* static void putAreaCharacter ( const FPoint&, FVTerm*
, charData*, charData* ); , charData*, charData* );
static void getAreaCharacter ( int, int, term_area* static void getAreaCharacter ( const FPoint&, term_area*
, charData*& ); , charData*& );
bool clearTerm (int = ' '); bool clearTerm (int = ' ');
bool clearFullArea (term_area*, charData&); bool clearFullArea (term_area*, charData&);
@ -475,7 +445,7 @@ class FVTerm
bool printWrap (term_area*); bool printWrap (term_area*);
void updateTerminalLine (uInt); void updateTerminalLine (uInt);
bool updateTerminalCursor(); bool updateTerminalCursor();
bool isInsideTerminal (int, int); bool isInsideTerminal (const FPoint&);
static void markAsPrinted (uInt, uInt); static void markAsPrinted (uInt, uInt);
static void markAsPrinted (uInt, uInt, uInt); static void markAsPrinted (uInt, uInt, uInt);
static void newFontChanges (charData*&); static void newFontChanges (charData*&);
@ -646,10 +616,6 @@ inline void FVTerm::hideCursor()
inline void FVTerm::showCursor() inline void FVTerm::showCursor()
{ return hideCursor(false); } { return hideCursor(false); }
//----------------------------------------------------------------------
inline void FVTerm::setPrintCursor (const FPoint& pos)
{ setPrintCursor (pos.getX(), pos.getY()); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FVTerm::setColor (FColor fg, FColor bg) inline void FVTerm::setColor (FColor fg, FColor bg)
{ {

View File

@ -202,6 +202,7 @@ class FWidget : public FVTerm, public FObject
const FPoint getTermPos() const; const FPoint getTermPos() const;
std::size_t getWidth() const; std::size_t getWidth() const;
std::size_t getHeight() const; std::size_t getHeight() const;
const FSize getSize() const;
int getTopPadding() const; int getTopPadding() const;
int getLeftPadding() const; int getLeftPadding() const;
int getBottomPadding() const; int getBottomPadding() const;
@ -254,11 +255,9 @@ class FWidget : public FVTerm, public FObject
virtual void setX (int, bool = true); // positioning virtual void setX (int, bool = true); // positioning
virtual void setY (int, bool = true); virtual void setY (int, bool = true);
virtual void setPos (const FPoint&, bool = true); virtual void setPos (const FPoint&, bool = true);
virtual void setPos (int, int, bool = true);
virtual void setWidth (std::size_t, bool = true); virtual void setWidth (std::size_t, bool = true);
virtual void setHeight (std::size_t, bool = true); virtual void setHeight (std::size_t, bool = true);
virtual void setSize (FSize, bool = true); virtual void setSize (const FSize&, bool = true);
virtual void setSize (std::size_t, std::size_t, bool = true);
void setTopPadding (int, bool = true); void setTopPadding (int, bool = true);
void setLeftPadding (int, bool = true); void setLeftPadding (int, bool = true);
void setBottomPadding (int, bool = true); void setBottomPadding (int, bool = true);
@ -266,25 +265,20 @@ class FWidget : public FVTerm, public FObject
void setParentOffset(); void setParentOffset();
void setTermOffset(); void setTermOffset();
void setTermOffsetWithPadding(); void setTermOffsetWithPadding();
void setTermSize (std::size_t, std::size_t); void setTermSize (const FSize&);
virtual void setGeometry (const FRect&, bool = true); virtual void setGeometry (const FRect&, bool = true);
virtual void setGeometry (const FPoint&, const FSize&, bool = true); virtual void setGeometry (const FPoint&, const FSize&, bool = true);
virtual void setGeometry ( int, int virtual void setShadowSize (const FSize&);
, std::size_t, std::size_t
, bool = true );
virtual void setShadowSize (std::size_t, std::size_t);
void setMinimumWidth (std::size_t); void setMinimumWidth (std::size_t);
void setMinimumHeight (std::size_t); void setMinimumHeight (std::size_t);
void setMinimumSize (std::size_t, std::size_t); void setMinimumSize (const FSize&);
void setMaximumWidth (std::size_t); void setMaximumWidth (std::size_t);
void setMaximumHeight (std::size_t); void setMaximumHeight (const FSize&);
void setMaximumSize (std::size_t, std::size_t); void setMaximumSize (std::size_t, std::size_t);
void setFixedSize (std::size_t, std::size_t); void setFixedSize (const FSize&);
bool setCursorPos (const FPoint&); bool setCursorPos (const FPoint&);
bool setCursorPos (int, int);
void unsetCursorPos(); void unsetCursorPos();
void setPrintPos (const FPoint&); void setPrintPos (const FPoint&);
void setPrintPos (int, int);
void setDoubleFlatLine (fc::sides, bool = true); void setDoubleFlatLine (fc::sides, bool = true);
void unsetDoubleFlatLine (fc::sides); void unsetDoubleFlatLine (fc::sides);
void setDoubleFlatLine (fc::sides, int, bool = true); void setDoubleFlatLine (fc::sides, int, bool = true);
@ -305,7 +299,6 @@ class FWidget : public FVTerm, public FObject
// Methods // Methods
static FWidget* childWidgetAt (FWidget*, const FPoint&); static FWidget* childWidgetAt (FWidget*, const FPoint&);
static FWidget* childWidgetAt (FWidget*, int, int);
int numOfFocusableChildren(); int numOfFocusableChildren();
virtual bool close(); virtual bool close();
void clearStatusbarMessage(); void clearStatusbarMessage();
@ -333,7 +326,6 @@ class FWidget : public FVTerm, public FObject
FPoint termToWidgetPos (const FPoint&); FPoint termToWidgetPos (const FPoint&);
void detectTermSize(); void detectTermSize();
virtual void move (const FPoint&); virtual void move (const FPoint&);
virtual void move (int, int);
void drawShadow(); void drawShadow();
void clearShadow(); void clearShadow();
void drawFlatBorder(); void drawFlatBorder();
@ -382,7 +374,7 @@ class FWidget : public FVTerm, public FObject
// Methods // Methods
virtual void adjustSize(); virtual void adjustSize();
void adjustSizeGlobal(); void adjustSizeGlobal();
void hideSize (std::size_t, std::size_t); void hideSize (const FSize&);
virtual bool focusNextChild(); // Change child... virtual bool focusNextChild(); // Change child...
virtual bool focusPrevChild(); // ...focus virtual bool focusPrevChild(); // ...focus
@ -442,16 +434,16 @@ class FWidget : public FVTerm, public FObject
widget_size_hints() = default; widget_size_hints() = default;
~widget_size_hints() = default; ~widget_size_hints() = default;
void setMinimum (std::size_t w, std::size_t h) void setMinimum (const FSize& s)
{ {
min_width = w; min_width = s.getWidth();
min_height = h; min_height = s.getHeight();
} }
void setMaximum (std::size_t w, std::size_t h) void setMaximum (const FSize& s)
{ {
max_width = w; max_width = s.getWidth();
max_height = h; max_height = s.getHeight();
} }
std::size_t min_width{0}; std::size_t min_width{0};
@ -603,6 +595,10 @@ inline std::size_t FWidget::getWidth() const
inline std::size_t FWidget::getHeight() const inline std::size_t FWidget::getHeight() const
{ return adjust_wsize.getHeight(); } { return adjust_wsize.getHeight(); }
//----------------------------------------------------------------------
inline const FSize FWidget::getSize() const
{ return adjust_wsize.getSize(); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline int FWidget::getTopPadding() const inline int FWidget::getTopPadding() const
{ return padding.top; } { return padding.top; }
@ -804,82 +800,54 @@ inline void FWidget::setBackgroundColor (FColor color)
background_color = color; background_color = color;
} }
//----------------------------------------------------------------------
inline void FWidget::setPos (const FPoint& p, bool adjust)
{ setPos (p.getX(), p.getY(), adjust); }
//----------------------------------------------------------------------
inline void FWidget::setSize (FSize s, bool adjust)
{ setSize(s.getWidth(), s.getHeight(), adjust); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FWidget::setGeometry (const FRect& box, bool adjust) inline void FWidget::setGeometry (const FRect& box, bool adjust)
{ {
setGeometry ( box.getX() setGeometry (box.getPos(), box.getSize(), adjust);
, box.getY()
, std::size_t(box.getWidth())
, std::size_t(box.getHeight())
, adjust );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FWidget::setGeometry (const FPoint& p, const FSize& s, bool adjust) inline void FWidget::setShadowSize (const FSize& size)
{ {
setGeometry ( p.getX() // width = right shadow / height = bottom shadow
, p.getY() wshadow.setSize (size);
, s.getWidth()
, s.getHeight()
, adjust );
} }
//----------------------------------------------------------------------
inline void FWidget::setShadowSize (std::size_t right, std::size_t bottom)
{ wshadow.setSize (right, bottom); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FWidget::setMinimumWidth (std::size_t min_width) inline void FWidget::setMinimumWidth (std::size_t min_width)
{ size_hints.setMinimum (min_width, size_hints.min_height); } { size_hints.setMinimum (FSize(min_width, size_hints.min_height)); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FWidget::setMinimumHeight (std::size_t min_height) inline void FWidget::setMinimumHeight (std::size_t min_height)
{ size_hints.setMinimum (size_hints.min_width, min_height); } { size_hints.setMinimum (FSize(size_hints.min_width, min_height)); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FWidget::setMinimumSize ( std::size_t min_width inline void FWidget::setMinimumSize (const FSize& size)
, std::size_t min_height ) { size_hints.setMinimum (size); }
{ size_hints.setMinimum (min_width, min_height); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FWidget::setMaximumWidth (std::size_t max_width) inline void FWidget::setMaximumWidth (std::size_t max_width)
{ size_hints.setMaximum (max_width, size_hints.max_height); } { size_hints.setMaximum (FSize(max_width, size_hints.max_height)); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FWidget::setMaximumHeight (std::size_t max_height) inline void FWidget::setMaximumHeight (const FSize& size)
{ size_hints.setMaximum (size_hints.max_width, max_height); } { size_hints.setMaximum (size); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FWidget::setMaximumSize ( std::size_t max_width inline void FWidget::setMaximumSize ( std::size_t max_width
, std::size_t max_height ) , std::size_t max_height )
{ size_hints.setMaximum (max_width, max_height); } { size_hints.setMaximum (FSize(max_width, max_height)); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FWidget::setFixedSize (std::size_t width, std::size_t height) inline void FWidget::setFixedSize (const FSize& size)
{ {
size_hints.setMinimum (width, height); size_hints.setMinimum (size);
size_hints.setMaximum (width, height); size_hints.setMaximum (size);
} }
//----------------------------------------------------------------------
inline bool FWidget::setCursorPos (const FPoint& pos)
{ return setCursorPos (pos.getX(), pos.getY()); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FWidget::unsetCursorPos() inline void FWidget::unsetCursorPos()
{ setCursorPos(-1, -1); } { setCursorPos (FPoint(-1, -1)); }
//----------------------------------------------------------------------
inline void FWidget::setPrintPos (const FPoint& pos)
{ setPrintPos (pos.getX(), pos.getY()); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FWidget::unsetDoubleFlatLine (fc::sides side) inline void FWidget::unsetDoubleFlatLine (fc::sides side)
@ -933,10 +901,6 @@ inline bool FWidget::acceptFocus() const // is focusable
inline bool FWidget::isPaddingIgnored() inline bool FWidget::isPaddingIgnored()
{ return ignore_padding; } { return ignore_padding; }
//----------------------------------------------------------------------
inline FWidget* FWidget::childWidgetAt (FWidget* p, const FPoint& pos)
{ return childWidgetAt (p, pos.getX(), pos.getY()); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FWidget::clearStatusbarMessage() inline void FWidget::clearStatusbarMessage()
{ statusbar_message.clear(); } { statusbar_message.clear(); }
@ -956,10 +920,6 @@ inline FPoint FWidget::termToWidgetPos (const FPoint& tPos)
, tPos.getY() + 1 - offset.getY1() - adjust_wsize.getY() ); , tPos.getY() + 1 - offset.getY1() - adjust_wsize.getY() );
} }
//----------------------------------------------------------------------
inline void FWidget::move (const FPoint& pos)
{ move(pos.getX(), pos.getY()); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FWidget::drawBorder() inline void FWidget::drawBorder()
{ drawBorder (1, 1, int(getWidth()), int(getHeight())); } { drawBorder (1, 1, int(getWidth()), int(getHeight())); }

View File

@ -77,9 +77,7 @@ class FWindow : public FWidget
public: public:
// Using-declaration // Using-declaration
using FWidget::drawBorder; using FWidget::drawBorder;
using FWidget::setPos;
using FWidget::setGeometry; using FWidget::setGeometry;
using FWidget::move;
// Constructor // Constructor
explicit FWindow (FWidget* = nullptr); explicit FWindow (FWidget* = nullptr);
@ -137,14 +135,13 @@ class FWindow : public FWidget
virtual void hide() override; virtual void hide() override;
virtual void setX (int, bool = true) override; virtual void setX (int, bool = true) override;
virtual void setY (int, bool = true) override; virtual void setY (int, bool = true) override;
virtual void setPos (int, int, bool = true) override; virtual void setPos (const FPoint&, bool = true) override;
virtual void setWidth (std::size_t, bool = true) override; virtual void setWidth (std::size_t, bool = true) override;
virtual void setHeight (std::size_t, bool = true) override; virtual void setHeight (std::size_t, bool = true) override;
virtual void setSize (std::size_t, std::size_t, bool = true) override; virtual void setSize (const FSize&, bool = true) override;
virtual void setGeometry ( int, int virtual void setGeometry ( const FPoint&, const FSize&
, std::size_t, std::size_t
, bool = true ) override; , bool = true ) override;
virtual void move (int, int) override; virtual void move (const FPoint&) override;
static FWindow* getWindowWidgetAt (const FPoint&); static FWindow* getWindowWidgetAt (const FPoint&);
static FWindow* getWindowWidgetAt (int, int); static FWindow* getWindowWidgetAt (int, int);
static void addWindow (FWidget*); static void addWindow (FWidget*);
@ -157,7 +154,7 @@ class FWindow : public FWidget
bool zoomWindow (); bool zoomWindow ();
static void switchToPrevWindow (FWidget*); static void switchToPrevWindow (FWidget*);
static bool activatePrevWindow(); static bool activatePrevWindow();
virtual void setShadowSize (std::size_t, std::size_t) override; virtual void setShadowSize (const FSize&) override;
protected: protected:
// Method // Method

View File

@ -166,7 +166,8 @@ void FPointTest::additionAssignmentTest()
p2 += finalcut::FPoint ( -std::numeric_limits<int>::max() p2 += finalcut::FPoint ( -std::numeric_limits<int>::max()
, std::numeric_limits<int>::max() ); , std::numeric_limits<int>::max() );
CPPUNIT_ASSERT ( p2.getX() == 0 ); CPPUNIT_ASSERT ( p2.getX() == 0 );
CPPUNIT_ASSERT ( p2.getY() == std::numeric_limits<int>::min() + std::numeric_limits<int>::max() ); CPPUNIT_ASSERT ( p2.getY() == std::numeric_limits<int>::min()
+ std::numeric_limits<int>::max() );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -188,6 +188,15 @@ void FRectTest::assignmentTest()
CPPUNIT_ASSERT ( r3.getHeight() == 6 ); CPPUNIT_ASSERT ( r3.getHeight() == 6 );
CPPUNIT_ASSERT ( r3.getSize() == finalcut::FSize(6, 6) ); CPPUNIT_ASSERT ( r3.getSize() == finalcut::FSize(6, 6) );
r3.setRect(finalcut::FPoint(34, 8), finalcut::FSize(40, 12));
CPPUNIT_ASSERT ( r3.getX1() == 34 );
CPPUNIT_ASSERT ( r3.getY1() == 8 );
CPPUNIT_ASSERT ( r3.getX2() == 73 );
CPPUNIT_ASSERT ( r3.getY2() == 19 );
CPPUNIT_ASSERT ( r3.getWidth() == 40 );
CPPUNIT_ASSERT ( r3.getHeight() == 12 );
CPPUNIT_ASSERT ( r3.getSize() == finalcut::FSize(40, 12) );
r3.setRect(r1); r3.setRect(r1);
CPPUNIT_ASSERT ( r3 == r1 ); CPPUNIT_ASSERT ( r3 == r1 );
CPPUNIT_ASSERT ( r3.getX1() == 3 ); CPPUNIT_ASSERT ( r3.getX1() == 3 );

View File

@ -54,8 +54,11 @@ class FSizeTest : public CPPUNIT_NS::TestFixture
void subtractionAssignmentTest(); void subtractionAssignmentTest();
void equalTest(); void equalTest();
void notEqualTest(); void notEqualTest();
void greaterTest();
void LessTest();
void additionTest(); void additionTest();
void subtractionTest(); void subtractionTest();
void areaTest();
void referenceTest(); void referenceTest();
void streamInsertionTest(); void streamInsertionTest();
void streamExtractionTest(); void streamExtractionTest();
@ -73,8 +76,11 @@ class FSizeTest : public CPPUNIT_NS::TestFixture
CPPUNIT_TEST (subtractionAssignmentTest); CPPUNIT_TEST (subtractionAssignmentTest);
CPPUNIT_TEST (equalTest); CPPUNIT_TEST (equalTest);
CPPUNIT_TEST (notEqualTest); CPPUNIT_TEST (notEqualTest);
CPPUNIT_TEST (greaterTest);
CPPUNIT_TEST (LessTest);
CPPUNIT_TEST (additionTest); CPPUNIT_TEST (additionTest);
CPPUNIT_TEST (subtractionTest); CPPUNIT_TEST (subtractionTest);
CPPUNIT_TEST (areaTest);
CPPUNIT_TEST (referenceTest); CPPUNIT_TEST (referenceTest);
CPPUNIT_TEST (streamInsertionTest); CPPUNIT_TEST (streamInsertionTest);
CPPUNIT_TEST (streamExtractionTest); CPPUNIT_TEST (streamExtractionTest);
@ -134,6 +140,11 @@ void FSizeTest::assignmentTest()
CPPUNIT_ASSERT ( s2.getWidth() == 40 ); CPPUNIT_ASSERT ( s2.getWidth() == 40 );
CPPUNIT_ASSERT ( s2.getHeight() == 12 ); CPPUNIT_ASSERT ( s2.getHeight() == 12 );
const finalcut::FSize size{5, 4};
s2.setSize (size);
CPPUNIT_ASSERT ( s2.getWidth() == 5 );
CPPUNIT_ASSERT ( s2.getHeight() == 4 );
// Value limit // Value limit
const finalcut::FSize s3 ( std::numeric_limits<std::size_t>::min() const finalcut::FSize s3 ( std::numeric_limits<std::size_t>::min()
, std::numeric_limits<std::size_t>::max() ); , std::numeric_limits<std::size_t>::max() );
@ -244,6 +255,38 @@ void FSizeTest::notEqualTest()
CPPUNIT_ASSERT ( s1 != finalcut::FSize() ); CPPUNIT_ASSERT ( s1 != finalcut::FSize() );
} }
//----------------------------------------------------------------------
void FSizeTest::greaterTest()
{
const finalcut::FSize s1 (5, 9);
const finalcut::FSize s2 (3, 5);
CPPUNIT_ASSERT ( s1 > s2 );
CPPUNIT_ASSERT ( s1 >= s2 );
const finalcut::FSize s3 (5, 9);
CPPUNIT_ASSERT ( s1 >= s3 );
CPPUNIT_ASSERT ( s1 >= finalcut::FSize(4, 9) );
CPPUNIT_ASSERT ( s1 >= finalcut::FSize(5, 8) );
CPPUNIT_ASSERT ( s1 >= finalcut::FSize(4, 8) );
CPPUNIT_ASSERT ( s1 > finalcut::FSize(4, 8) );
}
//----------------------------------------------------------------------
void FSizeTest::LessTest()
{
const finalcut::FSize s1 (2, 2);
const finalcut::FSize s2 (4, 4);
CPPUNIT_ASSERT ( s1 < s2 );
CPPUNIT_ASSERT ( s1 <= s2 );
const finalcut::FSize s3 (2, 2);
CPPUNIT_ASSERT ( s1 <= s3 );
CPPUNIT_ASSERT ( s1 <= finalcut::FSize(3, 2) );
CPPUNIT_ASSERT ( s1 <= finalcut::FSize(2, 3) );
CPPUNIT_ASSERT ( s1 <= finalcut::FSize(3, 3) );
CPPUNIT_ASSERT ( s1 < finalcut::FSize(3, 3) );
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FSizeTest::additionTest() void FSizeTest::additionTest()
{ {
@ -272,6 +315,20 @@ void FSizeTest::subtractionTest()
CPPUNIT_ASSERT ( s3 - finalcut::FSize(100, 20) == finalcut::FSize(0, 0) ); CPPUNIT_ASSERT ( s3 - finalcut::FSize(100, 20) == finalcut::FSize(0, 0) );
} }
//----------------------------------------------------------------------
void FSizeTest::areaTest()
{
const finalcut::FSize s1 (99, 101);
CPPUNIT_ASSERT ( s1.getWidth() == 99 );
CPPUNIT_ASSERT ( s1.getHeight() == 101 );
CPPUNIT_ASSERT ( s1.getArea() == 9999 );
const finalcut::FSize s2 (33, 87);
CPPUNIT_ASSERT ( s2.getWidth() == 33 );
CPPUNIT_ASSERT ( s2.getHeight() == 87 );
CPPUNIT_ASSERT ( s2.getArea() == 2871 );
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FSizeTest::referenceTest() void FSizeTest::referenceTest()
{ {