New method FWidget::initLayout() for setting widget layouts after terminal initialization
This commit is contained in:
parent
0e7488f646
commit
597f9e772b
|
@ -1,3 +1,10 @@
|
|||
2021-03-28 Markus Gans <guru.mail@muenster.de>
|
||||
* Widget now have the virtual method initLayout() to set
|
||||
the widget layouts automatically before the first drawing
|
||||
on the terminal is done. Also texts in full-width characters,
|
||||
whose character width is determined automatically, should be
|
||||
calculated here.
|
||||
|
||||
2021-03-15 Markus Gans <guru.mail@muenster.de>
|
||||
* Dynamic adjustment of the terminal refresh rate between
|
||||
5 and 60 Hz
|
||||
|
|
|
@ -378,15 +378,20 @@ class dialogWidget : public FDialog
|
|||
explicit dialogWidget (FWidget* parent = nullptr)
|
||||
: FDialog{parent}
|
||||
{
|
||||
setText ("Dialog");
|
||||
setGeometry (FPoint{25, 5}, FSize{23, 4});
|
||||
label.setGeometry (FPoint{1, 1}, FSize{10, 1});
|
||||
label.setAlignment (Align::Right);
|
||||
value.setGeometry (FPoint{11, 1}, FSize{10, 1});
|
||||
id = addTimer(100);
|
||||
}
|
||||
|
||||
private:
|
||||
void initLayout()
|
||||
{
|
||||
setText ("Dialog");
|
||||
setGeometry (FPoint{25, 5}, FSize{23, 4});
|
||||
label.setGeometry (FPoint{1, 1}, FSize{10, 1});
|
||||
value.setGeometry (FPoint{11, 1}, FSize{10, 1});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
void onTimer (FTimerEvent* ev) override
|
||||
{
|
||||
if ( id == ev->getTimerId() && n < 9999999999 )
|
||||
|
@ -495,12 +500,16 @@ class dialogWidget final : public FDialog
|
|||
public:
|
||||
explicit dialogWidget (FWidget* parent = nullptr)
|
||||
: FDialog{"User event", parent}
|
||||
{ }
|
||||
|
||||
private:
|
||||
void initLayout()
|
||||
{
|
||||
FDialog::setGeometry (FPoint{25, 5}, FSize{40, 6});
|
||||
loadavg_label.setGeometry (FPoint{2, 2}, FSize{36, 1});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
private:
|
||||
void onUserEvent (FUserEvent* ev) override
|
||||
{
|
||||
const auto& lavg = ev->getData<LoadAvg>();
|
||||
|
@ -891,10 +900,6 @@ class dialogWidget : public FDialog
|
|||
explicit dialogWidget (FWidget* parent = nullptr)
|
||||
: FDialog{parent}
|
||||
{
|
||||
setText ("Callback method");
|
||||
setGeometry (FPoint{25, 5}, FSize{25, 7});
|
||||
button.setGeometry (FPoint{7, 3}, FSize{10, 1});
|
||||
|
||||
// Connect the button signal "clicked" with the callback method
|
||||
button.addCallback
|
||||
(
|
||||
|
@ -906,6 +911,14 @@ class dialogWidget : public FDialog
|
|||
}
|
||||
|
||||
private:
|
||||
void initLayout()
|
||||
{
|
||||
setText ("Callback method");
|
||||
setGeometry (FPoint{25, 5}, FSize{25, 7});
|
||||
button.setGeometry (FPoint{7, 3}, FSize{10, 1});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
FButton button{"&Quit", this};
|
||||
};
|
||||
|
||||
|
@ -954,14 +967,8 @@ class dialogWidget : public FDialog
|
|||
explicit dialogWidget (FWidget* parent = nullptr)
|
||||
: FDialog{parent}
|
||||
{
|
||||
setGeometry (FPoint{25, 5}, FSize{22, 7});
|
||||
setText ("Emit signal");
|
||||
const FSize size{5, 1};
|
||||
label.setGeometry (FPoint{8, 1}, size);
|
||||
label.setAlignment (Align::Right);
|
||||
label.setForegroundColor (FColor::Black);
|
||||
plus.setGeometry (FPoint{3, 3}, size);
|
||||
minus.setGeometry (FPoint{3, 3} + FPoint{10, 0}, size);
|
||||
plus.setNoUnderline();
|
||||
minus.setNoUnderline();
|
||||
|
||||
|
@ -976,6 +983,17 @@ class dialogWidget : public FDialog
|
|||
}
|
||||
|
||||
private:
|
||||
void initLayout()
|
||||
{
|
||||
setGeometry (FPoint{25, 5}, FSize{22, 7});
|
||||
setText ("Emit signal");
|
||||
const FSize size{5, 1};
|
||||
label.setGeometry (FPoint{8, 1}, size);
|
||||
plus.setGeometry (FPoint{3, 3}, size);
|
||||
minus.setGeometry (FPoint{3, 3} + FPoint{10, 0}, size);
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
void cb_plus()
|
||||
{
|
||||
if ( t < 100 )
|
||||
|
@ -1375,8 +1393,6 @@ class dialogWidget : public FDialog
|
|||
explicit dialogWidget (FWidget* parent = nullptr)
|
||||
: FDialog{parent}
|
||||
{
|
||||
setText ("Dialog");
|
||||
setGeometry (FPoint{28, 2}, FSize{24, 21});
|
||||
scrollview.setGeometry(FPoint{1, 1}, FSize{22, 11});
|
||||
scrollview.setScrollSize(FSize{60, 27});
|
||||
// Attention: getColorTheme() requires an initialized terminal
|
||||
|
@ -1420,6 +1436,13 @@ class dialogWidget : public FDialog
|
|||
private:
|
||||
typedef std::tuple<FString, FPoint, FPoint, FColorPair> direction;
|
||||
|
||||
void initLayout()
|
||||
{
|
||||
setText ("Dialog");
|
||||
setGeometry (FPoint{28, 2}, FSize{24, 21});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
void cb_button (const FPoint& p)
|
||||
{
|
||||
scrollview.scrollTo(p);
|
||||
|
|
|
@ -361,20 +361,15 @@ class dialogWidget final : public FDialog
|
|||
explicit dialogWidget (FWidget* parent = nullptr)
|
||||
: FDialog{"Theming test application", parent}
|
||||
{
|
||||
FDialog::setGeometry (FPoint{15, 5}, FSize{50, 9});
|
||||
Input.setGeometry (FPoint{2, 2}, FSize{39, 1});
|
||||
Input.setLabelText("File name:");
|
||||
Input.setLabelOrientation(FLineEdit::LabelOrientation::Above);
|
||||
Input.setStatusbarMessage("Enter a file name");
|
||||
Browse.setGeometry (FPoint{43, 2}, FSize{4, 1});
|
||||
Browse.addCallback
|
||||
(
|
||||
"clicked",
|
||||
this, &dialogWidget::cb_FileBrowse
|
||||
);
|
||||
Apply.setGeometry (FPoint{24, 5}, FSize{10, 1});
|
||||
Apply.setStatusbarMessage("Apply settings");
|
||||
Quit.setGeometry (FPoint{37, 5}, FSize{10, 1});
|
||||
Quit.setStatusbarMessage("Exit the program");
|
||||
Quit.addCallback
|
||||
(
|
||||
|
@ -391,6 +386,16 @@ class dialogWidget final : public FDialog
|
|||
}
|
||||
|
||||
private:
|
||||
void initLayout()
|
||||
{
|
||||
setGeometry (FPoint{15, 5}, FSize{50, 9});
|
||||
Input.setGeometry (FPoint{2, 2}, FSize{39, 1});
|
||||
Browse.setGeometry (FPoint{43, 2}, FSize{4, 1});
|
||||
Apply.setGeometry (FPoint{24, 5}, FSize{10, 1});
|
||||
Quit.setGeometry (FPoint{37, 5}, FSize{10, 1});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
void cb_FileBrowse()
|
||||
{
|
||||
auto filename = FFileDialog::fileOpenChooser(this);
|
||||
|
|
|
@ -59,6 +59,7 @@ class SegmentView final : public finalcut::FDialog
|
|||
void hexEncoding();
|
||||
void get7Segment (const wchar_t);
|
||||
void draw() override;
|
||||
void initLayout() override;
|
||||
|
||||
// Data members
|
||||
std::map<wchar_t, sevenSegment> code{};
|
||||
|
@ -71,26 +72,16 @@ class SegmentView final : public finalcut::FDialog
|
|||
SegmentView::SegmentView (finalcut::FWidget* parent)
|
||||
: FDialog{parent}
|
||||
{
|
||||
// Dialog settings
|
||||
// Avoids calling a virtual function from the constructor
|
||||
// (CERT, OOP50-CPP)
|
||||
FDialog::setText ("Seven-segment display");
|
||||
FDialog::setGeometry (FPoint{25, 5}, FSize{42, 15});
|
||||
|
||||
// Set encoding
|
||||
hexEncoding();
|
||||
|
||||
// Input field
|
||||
input.setGeometry (FPoint(2, 2), FSize{12, 1});
|
||||
input.setLabelText (L"&Hex value");
|
||||
input.setLabelText (L"&Hex-digits or (.) (:) (H) (L) (P) (U)");
|
||||
input.setLabelOrientation(finalcut::FLineEdit::LabelOrientation::Above);
|
||||
input.setMaxLength(9);
|
||||
input.setInputFilter("[:.hHlLpPuU[:xdigit:]]");
|
||||
|
||||
// Exit button
|
||||
exit.setGeometry(FPoint{28, 11}, FSize{10, 1});
|
||||
|
||||
// Add some function callbacks
|
||||
input.addCallback
|
||||
(
|
||||
|
@ -221,6 +212,19 @@ void SegmentView::draw()
|
|||
<< FPoint {4, 10} << finalcut::FString{36, ' '};
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void SegmentView::initLayout()
|
||||
{
|
||||
// Dialog settings
|
||||
FDialog::setText ("Seven-segment display");
|
||||
FDialog::setGeometry (FPoint{25, 5}, FSize{42, 15});
|
||||
// Input field
|
||||
input.setGeometry (FPoint(2, 2), FSize{12, 1});
|
||||
// Exit button
|
||||
exit.setGeometry(FPoint{28, 11}, FSize{10, 1});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// main part
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2019-2020 Markus Gans *
|
||||
* Copyright 2019-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -55,6 +55,9 @@ class Background final : public finalcut::FDialog
|
|||
Background& operator = (const Background&) = delete;
|
||||
|
||||
private:
|
||||
// Methods
|
||||
void initLayout() override;
|
||||
|
||||
// Callback method
|
||||
void cb_changed();
|
||||
void cb_choice();
|
||||
|
@ -92,14 +95,7 @@ class Background final : public finalcut::FDialog
|
|||
Background::Background (finalcut::FWidget* parent)
|
||||
: FDialog{parent}
|
||||
{
|
||||
// Dialog settings
|
||||
// Avoids calling a virtual function from the constructor
|
||||
// (CERT, OOP50-CPP)
|
||||
FDialog::setText ("Background color palette");
|
||||
FDialog::setGeometry (FPoint{25, 5}, FSize{32, 12});
|
||||
|
||||
// Combobox
|
||||
color_choice.setGeometry (FPoint{2, 2}, FSize{18, 1});
|
||||
color_choice.setLabelOrientation (finalcut::FLineEdit::LabelOrientation::Above);
|
||||
color_choice.setLabelText ("Color choice");
|
||||
color_choice.unsetEditable();
|
||||
|
@ -111,19 +107,16 @@ Background::Background (finalcut::FWidget* parent)
|
|||
}
|
||||
|
||||
// Spin boxes
|
||||
red.setGeometry (FPoint{2, 5}, FSize{7, 1});
|
||||
red.setLabelOrientation (finalcut::FLineEdit::LabelOrientation::Above);
|
||||
red.setLabelText ("Red");
|
||||
red.setRange (0, 255);
|
||||
red.setValue (0x80);
|
||||
|
||||
green.setGeometry (FPoint{12, 5}, FSize{7, 1});
|
||||
green.setLabelOrientation (finalcut::FLineEdit::LabelOrientation::Above);
|
||||
green.setLabelText ("Green");
|
||||
green.setRange (0, 255);
|
||||
green.setValue (0xa4);
|
||||
|
||||
blue.setGeometry (FPoint{22, 5}, FSize{7, 1});
|
||||
blue.setLabelOrientation (finalcut::FLineEdit::LabelOrientation::Above);
|
||||
blue.setLabelText ("Blue");
|
||||
blue.setRange (0, 255);
|
||||
|
@ -138,9 +131,6 @@ Background::Background (finalcut::FWidget* parent)
|
|||
, int(blue.getValue()) );
|
||||
}
|
||||
|
||||
// Quit button
|
||||
quit.setGeometry(FPoint{19, 8}, FSize{10, 1});
|
||||
|
||||
// Add some function callbacks
|
||||
quit.addCallback
|
||||
(
|
||||
|
@ -172,6 +162,19 @@ Background::Background (finalcut::FWidget* parent)
|
|||
//----------------------------------------------------------------------
|
||||
Background::~Background() noexcept = default; // destructor
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Background::initLayout()
|
||||
{
|
||||
FDialog::setText ("Background color palette");
|
||||
FDialog::setGeometry (FPoint{25, 5}, FSize{32, 12});
|
||||
color_choice.setGeometry (FPoint{2, 2}, FSize{18, 1});
|
||||
red.setGeometry (FPoint{2, 5}, FSize{7, 1});
|
||||
green.setGeometry (FPoint{12, 5}, FSize{7, 1});
|
||||
blue.setGeometry (FPoint{22, 5}, FSize{7, 1});
|
||||
quit.setGeometry(FPoint{19, 8}, FSize{10, 1}); // Quit button
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Background::cb_changed()
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2020 Markus Gans *
|
||||
* Copyright 2020-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -35,6 +35,7 @@ class Dialog final : public finalcut::FDialog
|
|||
explicit Dialog (FWidget* parent = nullptr);
|
||||
|
||||
private:
|
||||
void initLayout() override;
|
||||
void adjustSize() override;
|
||||
|
||||
// Event handler
|
||||
|
@ -54,14 +55,9 @@ class Dialog final : public finalcut::FDialog
|
|||
Dialog::Dialog (FWidget* parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
FDialog::setText ("Dialog");
|
||||
finalcut::FDialog::setGeometry (FPoint{26, 5}, FSize{28, 10});
|
||||
seconds.setGeometry (FPoint{10, 2}, FSize{10, 1});
|
||||
seconds.setLabelText ("Seconds");
|
||||
seconds.setRange (0, 60);
|
||||
seconds.setValue (3);
|
||||
start.setGeometry (FPoint{2, 6}, FSize{10, 1});
|
||||
quit.setGeometry (FPoint{15, 6}, FSize{10, 1});
|
||||
|
||||
// Add button callbacks
|
||||
seconds.addCallback
|
||||
|
@ -85,6 +81,17 @@ Dialog::Dialog (FWidget* parent)
|
|||
);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Dialog::initLayout()
|
||||
{
|
||||
FDialog::setText ("Dialog");
|
||||
FDialog::setGeometry (FPoint{26, 5}, FSize{28, 10});
|
||||
seconds.setGeometry (FPoint{10, 2}, FSize{10, 1});
|
||||
start.setGeometry (FPoint{2, 6}, FSize{10, 1});
|
||||
quit.setGeometry (FPoint{15, 6}, FSize{10, 1});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Dialog::adjustSize()
|
||||
{
|
||||
|
|
|
@ -112,9 +112,6 @@ void Button::onKeyPress (finalcut::FKeyEvent* ev)
|
|||
class Calc final : public finalcut::FDialog
|
||||
{
|
||||
public:
|
||||
// Using-declaration
|
||||
using FDialog::setGeometry;
|
||||
|
||||
// Constructor
|
||||
explicit Calc (finalcut::FWidget* parent = nullptr);
|
||||
|
||||
|
@ -209,6 +206,7 @@ class Calc final : public finalcut::FDialog
|
|||
void setInfixOperator (char);
|
||||
void clearInfixOperator();
|
||||
void calcInfixOperator();
|
||||
void initLayout() override;
|
||||
void adjustSize() override;
|
||||
const wchar_t* getButtonText (const ButtonName&) const;
|
||||
void mapKeyFunctions();
|
||||
|
@ -257,12 +255,6 @@ class Calc final : public finalcut::FDialog
|
|||
Calc::Calc (FWidget* parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
// Dialog settings
|
||||
// Avoids calling a virtual function from the constructor
|
||||
// (CERT, OOP50-CPP)
|
||||
FDialog::setText ("Calculator");
|
||||
FDialog::setGeometry (FPoint{19, 6}, FSize{37, 18});
|
||||
|
||||
mapKeyFunctions();
|
||||
clearInfixOperator();
|
||||
|
||||
|
@ -271,17 +263,6 @@ Calc::Calc (FWidget* parent)
|
|||
auto btn = std::make_shared<Button>(this);
|
||||
auto index = std::size_t(key);
|
||||
button_no[index] = key;
|
||||
|
||||
if ( key == ButtonName::Equals )
|
||||
btn->setGeometry(FPoint{30, 15}, FSize{5, 3});
|
||||
else
|
||||
{
|
||||
const int n = ( key <= ButtonName::Three ) ? 0 : 1;
|
||||
const int x = (int(key) + n) % 5 * 7 + 2;
|
||||
const int y = (int(key) + n) / 5 * 2 + 3;
|
||||
btn->setGeometry(FPoint{x, y}, FSize{5, 1});
|
||||
}
|
||||
|
||||
btn->setFlat();
|
||||
btn->setNoUnderline();
|
||||
btn->setText(getButtonText(key));
|
||||
|
@ -1084,6 +1065,31 @@ void Calc::calcInfixOperator()
|
|||
clearInfixOperator();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Calc::initLayout()
|
||||
{
|
||||
// Dialog settings
|
||||
FDialog::setText ("Calculator");
|
||||
FDialog::setGeometry (FPoint{19, 6}, FSize{37, 18});
|
||||
|
||||
for (ButtonName key{ButtonName::Sine}; key < ButtonName::NUM_OF_BUTTONS; key++)
|
||||
{
|
||||
auto btn = calculator_buttons[ButtonName(key)];
|
||||
|
||||
if ( key == ButtonName::Equals )
|
||||
btn->setGeometry(FPoint{30, 15}, FSize{5, 3});
|
||||
else
|
||||
{
|
||||
const int n = ( key <= ButtonName::Three ) ? 0 : 1;
|
||||
const int x = (int(key) + n) % 5 * 7 + 2;
|
||||
const int y = (int(key) + n) / 5 * 2 + 3;
|
||||
btn->setGeometry(FPoint{x, y}, FSize{5, 1});
|
||||
}
|
||||
}
|
||||
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Calc::adjustSize()
|
||||
{
|
||||
|
|
|
@ -40,9 +40,6 @@ using finalcut::FSize;
|
|||
class CheckList final : public finalcut::FDialog
|
||||
{
|
||||
public:
|
||||
// Using-declaration
|
||||
using FDialog::setGeometry;
|
||||
|
||||
// Constructor
|
||||
explicit CheckList (finalcut::FWidget* = nullptr);
|
||||
|
||||
|
@ -58,6 +55,7 @@ class CheckList final : public finalcut::FDialog
|
|||
private:
|
||||
// Method
|
||||
void populate();
|
||||
void initLayout() override;
|
||||
void adjustSize() override;
|
||||
|
||||
// Event handlers
|
||||
|
@ -76,16 +74,8 @@ class CheckList final : public finalcut::FDialog
|
|||
CheckList::CheckList (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
// Dialog settings
|
||||
// Avoids calling a virtual function from the constructor
|
||||
// (CERT, OOP50-CPP)
|
||||
FDialog::setText (L"Shopping list");
|
||||
const std::size_t nf_offset = ( finalcut::FTerm::isNewFont() ) ? 1 : 0;
|
||||
FDialog::setSize (FSize{28 + nf_offset, 13} );
|
||||
setShadow(); // Instead of the transparent window shadow
|
||||
listview.ignorePadding();
|
||||
listview.setGeometry ( FPoint{1 + int(nf_offset), 2}
|
||||
, FSize{getWidth() - nf_offset, getHeight() - 1} );
|
||||
|
||||
// Add columns to the view
|
||||
listview.addColumn ("Item");
|
||||
|
@ -140,6 +130,17 @@ void CheckList::populate()
|
|||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void CheckList::initLayout()
|
||||
{
|
||||
FDialog::setText (L"Shopping list");
|
||||
const std::size_t nf_offset = ( finalcut::FTerm::isNewFont() ) ? 1 : 0;
|
||||
FDialog::setSize (FSize{28 + nf_offset, 13} );
|
||||
listview.setGeometry ( FPoint{1 + int(nf_offset), 2}
|
||||
, FSize{getWidth() - nf_offset, getHeight() - 1} );
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void CheckList::adjustSize()
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2020 Markus Gans *
|
||||
* Copyright 2020-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -41,9 +41,6 @@ class EventLog; // class forward declaration
|
|||
class EventDialog final : public finalcut::FDialog
|
||||
{
|
||||
public:
|
||||
// Using-declaration
|
||||
using FDialog::setGeometry;
|
||||
|
||||
// Constructor
|
||||
explicit EventDialog (finalcut::FWidget* = nullptr);
|
||||
|
||||
|
@ -58,6 +55,7 @@ class EventDialog final : public finalcut::FDialog
|
|||
|
||||
private:
|
||||
// Methods
|
||||
void initLayout() override;
|
||||
finalcut::FString getMouseButtonName (const finalcut::MouseButton&) const;
|
||||
void logMouseEvent ( const finalcut::FString&
|
||||
, const finalcut::FMouseEvent& );
|
||||
|
@ -85,22 +83,25 @@ class EventDialog final : public finalcut::FDialog
|
|||
EventDialog::EventDialog (finalcut::FWidget* parent)
|
||||
: FDialog{parent}
|
||||
{
|
||||
// Dialog settings
|
||||
// Avoids calling a virtual function from the constructor
|
||||
// (CERT, OOP50-CPP)
|
||||
FDialog::setText ("Event dialog");
|
||||
FDialog::setGeometry (FPoint{15, 2}, FSize{53, 12});
|
||||
setShadow();
|
||||
label.setText("\n\nUse the keyboard or mouse\n"
|
||||
"in this dialog to create events");
|
||||
label.setAlignment(finalcut::Align::Center);
|
||||
label.setGeometry (FPoint(1, 1), getClientSize(), false);
|
||||
addTimer(60000); // Starts the timer every minute
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
EventDialog::~EventDialog() noexcept = default; // destructor
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void EventDialog::initLayout()
|
||||
{
|
||||
FDialog::setText ("Event dialog");
|
||||
FDialog::setGeometry (FPoint{15, 2}, FSize{53, 12});
|
||||
label.setGeometry (FPoint(1, 1), getClientSize(), false);
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
finalcut::FString EventDialog::getMouseButtonName (const finalcut::MouseButton& btn_state) const
|
||||
{
|
||||
|
@ -240,9 +241,6 @@ void EventDialog::onWindowLowered (finalcut::FEvent* ev)
|
|||
class EventLog final : public finalcut::FDialog, public std::ostringstream
|
||||
{
|
||||
public:
|
||||
// Using-declaration
|
||||
using FDialog::setGeometry;
|
||||
|
||||
// Constructor
|
||||
explicit EventLog (finalcut::FWidget* = nullptr);
|
||||
|
||||
|
@ -261,6 +259,7 @@ class EventLog final : public finalcut::FDialog, public std::ostringstream
|
|||
|
||||
private:
|
||||
// Method
|
||||
void initLayout() override;
|
||||
void adjustSize() override;
|
||||
|
||||
// Data members
|
||||
|
@ -272,16 +271,9 @@ class EventLog final : public finalcut::FDialog, public std::ostringstream
|
|||
EventLog::EventLog (finalcut::FWidget* parent)
|
||||
: FDialog{parent}
|
||||
{
|
||||
// Dialog settings
|
||||
// Avoids calling a virtual function from the constructor
|
||||
// (CERT, OOP50-CPP)
|
||||
FDialog::setText ("Event log");
|
||||
FDialog::setGeometry (FPoint{4, 16}, FSize{75, 8});
|
||||
FDialog::setResizeable();
|
||||
setMinimumSize (FSize{75, 5});
|
||||
setShadow();
|
||||
scrolltext.ignorePadding();
|
||||
scrolltext.setGeometry (FPoint{1, 2}, FSize{getWidth(), getHeight() - 1});
|
||||
event_dialog->setFocus();
|
||||
addTimer(250); // Starts the timer every 250 milliseconds
|
||||
}
|
||||
|
@ -307,6 +299,16 @@ void EventLog::onClose (finalcut::FCloseEvent* ev)
|
|||
finalcut::FApplication::closeConfirmationDialog (this, ev);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void EventLog::initLayout()
|
||||
{
|
||||
FDialog::setText ("Event log");
|
||||
FDialog::setGeometry (FPoint{4, 16}, FSize{75, 8});
|
||||
FDialog::setResizeable();
|
||||
scrolltext.setGeometry (FPoint{1, 2}, FSize{getWidth(), getHeight() - 1});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void EventLog::adjustSize()
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2017-2020 Markus Gans *
|
||||
* Copyright 2017-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -93,6 +93,9 @@ class Listbox final : public FDialog
|
|||
Listbox& operator = (const Listbox&) = delete;
|
||||
|
||||
private:
|
||||
// Method
|
||||
void initLayout() override;
|
||||
|
||||
// Event handlers
|
||||
void onClose (FCloseEvent*) override;
|
||||
|
||||
|
@ -113,7 +116,6 @@ Listbox::Listbox (FWidget* parent)
|
|||
|
||||
// listbox 1
|
||||
//----------
|
||||
list1.setGeometry(FPoint{2, 1}, FSize{18, 10});
|
||||
list1.setText ("FListBoxItem");
|
||||
|
||||
for (auto i{1}; i < 30; i++)
|
||||
|
@ -124,7 +126,6 @@ Listbox::Listbox (FWidget* parent)
|
|||
for (auto i{1}; i <= 15; i++)
|
||||
double_list.push_back(2 * double(i) + (double(i) / 100));
|
||||
|
||||
list2.setGeometry(FPoint{21, 1}, FSize{10, 10});
|
||||
list2.setText ("double");
|
||||
|
||||
//
|
||||
|
@ -147,11 +148,9 @@ Listbox::Listbox (FWidget* parent)
|
|||
TLD["gov"] = "Government";
|
||||
|
||||
list3.insert (TLD.begin(), TLD.end(), mapToString);
|
||||
list3.setGeometry(FPoint{32, 1}, FSize{21, 10});
|
||||
list3.setText ("key: value");
|
||||
|
||||
// Quit button
|
||||
quit.setGeometry(FPoint{42, 12}, FSize{10, 1});
|
||||
quit.setText (L"&Quit");
|
||||
|
||||
// Add quit button function callback
|
||||
|
@ -164,6 +163,16 @@ Listbox::Listbox (FWidget* parent)
|
|||
);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Listbox::initLayout()
|
||||
{
|
||||
list1.setGeometry(FPoint{2, 1}, FSize{18, 10});
|
||||
list2.setGeometry(FPoint{21, 1}, FSize{10, 10});
|
||||
list3.setGeometry(FPoint{32, 1}, FSize{21, 10});
|
||||
quit.setGeometry(FPoint{42, 12}, FSize{10, 1});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Listbox::onClose (FCloseEvent* ev)
|
||||
{
|
||||
|
|
|
@ -54,6 +54,7 @@ class Listview final : public finalcut::FDialog
|
|||
private:
|
||||
// Method
|
||||
void populate();
|
||||
void initLayout() override;
|
||||
|
||||
// Event handlers
|
||||
void onClose (finalcut::FCloseEvent*) override;
|
||||
|
@ -70,9 +71,6 @@ class Listview final : public finalcut::FDialog
|
|||
Listview::Listview (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
// Set FListView geometry
|
||||
listview.setGeometry(FPoint{2, 1}, FSize{33, 14});
|
||||
|
||||
// Add columns to the view
|
||||
listview.addColumn ("City");
|
||||
listview.addColumn ("Condition");
|
||||
|
@ -104,7 +102,6 @@ Listview::Listview (finalcut::FWidget* parent)
|
|||
populate();
|
||||
|
||||
// Quit button
|
||||
quit.setGeometry(FPoint{24, 16}, FSize{10, 1});
|
||||
quit.setText (L"&Quit");
|
||||
|
||||
// Add some function callbacks
|
||||
|
@ -178,6 +175,16 @@ void Listview::populate()
|
|||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Listview::initLayout()
|
||||
{
|
||||
// Set FListView geometry
|
||||
listview.setGeometry(FPoint{2, 1}, FSize{33, 14});
|
||||
// Set quit button geometry
|
||||
quit.setGeometry(FPoint{24, 16}, FSize{10, 1});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Listview::onClose (finalcut::FCloseEvent* ev)
|
||||
{
|
||||
|
|
|
@ -46,6 +46,7 @@ class Mandelbrot final : public finalcut::FDialog
|
|||
|
||||
private:
|
||||
// Methods
|
||||
void initLayout() override;
|
||||
void draw() override;
|
||||
void adjustSize() override;
|
||||
};
|
||||
|
@ -54,8 +55,14 @@ class Mandelbrot final : public finalcut::FDialog
|
|||
//----------------------------------------------------------------------
|
||||
Mandelbrot::Mandelbrot (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Mandelbrot::initLayout()
|
||||
{
|
||||
FDialog::setText ("Mandelbrot set");
|
||||
FDialog::setGeometry (FPoint{6, 1}, FSize{70, 23});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -162,7 +169,6 @@ int main (int argc, char* argv[])
|
|||
|
||||
// Create a simple dialog box
|
||||
Mandelbrot mb{&app};
|
||||
mb.setGeometry (FPoint{6, 1}, FSize{70, 23});
|
||||
mb.setShadow(); // Instead of the transparent window shadow
|
||||
|
||||
// Set the mandelbrot object as main widget
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2015-2020 Markus Gans *
|
||||
* Copyright 2015-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -55,6 +55,7 @@ class Menu final : public finalcut::FDialog
|
|||
void configureStyleMenuItems();
|
||||
void configureBorderMenuItems();
|
||||
void defaultCallback (const finalcut::FMenuList*);
|
||||
void initLayout() override;
|
||||
void adjustSize() override;
|
||||
|
||||
// Event handler
|
||||
|
@ -140,12 +141,10 @@ Menu::Menu (finalcut::FWidget* parent)
|
|||
// Headline labels
|
||||
Headline1 << " Key ";
|
||||
Headline1.ignorePadding();
|
||||
Headline1.setGeometry(FPoint{3, 2}, FSize{5, 1});
|
||||
Headline1.setEmphasis();
|
||||
|
||||
Headline2 << " Function ";
|
||||
Headline2.ignorePadding();
|
||||
Headline2.setGeometry(FPoint{19, 2}, FSize{10, 1});
|
||||
Headline2.setEmphasis();
|
||||
|
||||
// Info label
|
||||
|
@ -154,7 +153,6 @@ Menu::Menu (finalcut::FWidget* parent)
|
|||
<< "<Menu> Activate menu bar\n"
|
||||
<< "<Shift>+<Menu> Open dialog menu\n"
|
||||
<< "<Meta>+<X> Exit";
|
||||
Info.setGeometry(FPoint{2, 1}, FSize{36, 5});
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -194,8 +192,8 @@ void Menu::configureEditMenuItems()
|
|||
Undo.setStatusbarMessage ("Undo the previous operation");
|
||||
Redo.setDisable();
|
||||
Line3.setSeparator();
|
||||
Cut.setStatusbarMessage ( "Remove the input text "
|
||||
"and put it in the clipboard" );
|
||||
Cut.setStatusbarMessage ("Remove the input text "
|
||||
"and put it in the clipboard");
|
||||
Copy.setStatusbarMessage ("Copy the input text into the clipboad");
|
||||
Paste.setStatusbarMessage ("Insert text form clipboard");
|
||||
Line4.setSeparator();
|
||||
|
@ -286,6 +284,15 @@ void Menu::defaultCallback (const finalcut::FMenuList* mb)
|
|||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Menu::initLayout()
|
||||
{
|
||||
Headline1.setGeometry (FPoint{3, 2}, FSize{5, 1});
|
||||
Headline2.setGeometry (FPoint{19, 2}, FSize{10, 1});
|
||||
Info.setGeometry(FPoint{2, 1}, FSize{36, 5});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Menu::adjustSize()
|
||||
{
|
||||
|
|
|
@ -54,6 +54,7 @@ class ColorChooser final : public finalcut::FWidget
|
|||
|
||||
private:
|
||||
// Mutator
|
||||
void initLayout() override;
|
||||
void setSize (const FSize&, bool = true) override;
|
||||
|
||||
// Method
|
||||
|
@ -74,12 +75,9 @@ class ColorChooser final : public finalcut::FWidget
|
|||
ColorChooser::ColorChooser (finalcut::FWidget* parent)
|
||||
: FWidget{parent}
|
||||
{
|
||||
FWidget::setSize (FSize{8, 12});
|
||||
setFixedSize (FSize{8, 12});
|
||||
unsetFocusable();
|
||||
|
||||
// Text label
|
||||
headline.setGeometry (FPoint{1, 1}, FSize{8, 1});
|
||||
headline.setEmphasis();
|
||||
headline.setAlignment (finalcut::Align::Center);
|
||||
headline << "Color";
|
||||
|
@ -97,6 +95,15 @@ inline FColor ColorChooser::getBackground() const
|
|||
return bg_color;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void ColorChooser::initLayout()
|
||||
{
|
||||
FWidget::setSize (FSize{8, 12});
|
||||
setFixedSize (FSize{8, 12});
|
||||
headline.setGeometry (FPoint{1, 1}, FSize{8, 1});
|
||||
FWidget::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void ColorChooser::setSize (const FSize& size, bool adjust)
|
||||
{
|
||||
|
@ -196,6 +203,7 @@ class Brushes final : public finalcut::FWidget
|
|||
|
||||
private:
|
||||
// Mutator
|
||||
void initLayout() override;
|
||||
void setSize (const FSize&, bool = true) override;
|
||||
|
||||
// Method
|
||||
|
@ -216,17 +224,23 @@ class Brushes final : public finalcut::FWidget
|
|||
Brushes::Brushes (finalcut::FWidget* parent)
|
||||
: FWidget{parent}
|
||||
{
|
||||
FWidget::setSize (FSize{8, 4});
|
||||
setFixedSize (FSize{8, 4});
|
||||
unsetFocusable();
|
||||
|
||||
// Text label
|
||||
headline.setGeometry(FPoint{1, 1}, FSize{8, 1});
|
||||
headline.setEmphasis();
|
||||
headline.setAlignment (finalcut::Align::Center);
|
||||
headline << "Brush";
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Brushes::initLayout()
|
||||
{
|
||||
FWidget::setSize (FSize{8, 4});
|
||||
setFixedSize (FSize{8, 4});
|
||||
headline.setGeometry(FPoint{1, 1}, FSize{8, 1});
|
||||
FWidget::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Brushes::setSize (const FSize& size, bool adjust)
|
||||
{
|
||||
|
@ -310,9 +324,6 @@ inline void Brushes::setBackground (FColor color)
|
|||
class MouseDraw final : public finalcut::FDialog
|
||||
{
|
||||
public:
|
||||
// Using-declaration
|
||||
using FWidget::setGeometry;
|
||||
|
||||
// Constructor
|
||||
explicit MouseDraw (finalcut::FWidget* = nullptr);
|
||||
|
||||
|
@ -338,6 +349,7 @@ class MouseDraw final : public finalcut::FDialog
|
|||
void drawBrush (int, int, bool = false);
|
||||
void drawCanvas();
|
||||
void createCanvas();
|
||||
void initLayout() override;
|
||||
void adjustSize() override;
|
||||
|
||||
// Event handler
|
||||
|
@ -359,14 +371,12 @@ MouseDraw::MouseDraw (finalcut::FWidget* parent)
|
|||
: finalcut::FDialog{parent}
|
||||
{
|
||||
FDialog::setText ("Drawing with the mouse");
|
||||
c_chooser.setPos (FPoint{1, 1});
|
||||
|
||||
c_chooser.addCallback
|
||||
(
|
||||
"clicked",
|
||||
this, &MouseDraw::cb_colorChanged
|
||||
);
|
||||
|
||||
brush.setPos (FPoint{1, 12});
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -523,6 +533,14 @@ void MouseDraw::createCanvas()
|
|||
adjustSize();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void MouseDraw::initLayout()
|
||||
{
|
||||
c_chooser.setPos (FPoint{1, 1});
|
||||
brush.setPos (FPoint{1, 12});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void MouseDraw::adjustSize()
|
||||
{
|
||||
|
|
|
@ -49,7 +49,8 @@ class Scrollview final : public finalcut::FScrollView
|
|||
void setScrollSize (const FSize&) override;
|
||||
|
||||
private:
|
||||
// Method
|
||||
// Methods
|
||||
void initLayout() override;
|
||||
void draw() override;
|
||||
|
||||
// Callback methods
|
||||
|
@ -73,16 +74,6 @@ class Scrollview final : public finalcut::FScrollView
|
|||
Scrollview::Scrollview (finalcut::FWidget* parent)
|
||||
: finalcut::FScrollView{parent}
|
||||
{
|
||||
// Sets the navigation button geometry
|
||||
go_east.setGeometry (FPoint{1, 1}, FSize{5, 1});
|
||||
go_south.setGeometry ( FPoint{int(getScrollWidth()) - 5, 1}
|
||||
, FSize{5, 1} );
|
||||
go_west.setGeometry ( FPoint{ int(getScrollWidth()) - 5
|
||||
, int(getScrollHeight()) - 2 }
|
||||
, FSize{5, 1} );
|
||||
go_north.setGeometry ( FPoint{1, int(getScrollHeight()) - 2}
|
||||
, FSize{5, 1} );
|
||||
|
||||
// Add scroll function callbacks to the buttons
|
||||
go_east.addCallback
|
||||
(
|
||||
|
@ -109,6 +100,20 @@ Scrollview::Scrollview (finalcut::FWidget* parent)
|
|||
);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Scrollview::initLayout()
|
||||
{
|
||||
// Sets the navigation button geometry
|
||||
go_east.setGeometry (FPoint{1, 1}, FSize{5, 1});
|
||||
go_south.setGeometry ( FPoint{int(getScrollWidth()) - 5, 1}
|
||||
, FSize{5, 1} );
|
||||
go_west.setGeometry ( FPoint{ int(getScrollWidth()) - 5
|
||||
, int(getScrollHeight()) - 2 }
|
||||
, FSize{5, 1} );
|
||||
go_north.setGeometry ( FPoint{1, int(getScrollHeight()) - 2}
|
||||
, FSize{5, 1} );
|
||||
FScrollView::initLayout();
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
void Scrollview::setScrollSize (const FSize& size)
|
||||
{
|
||||
|
@ -194,6 +199,10 @@ class Scrollviewdemo final : public finalcut::FDialog
|
|||
// Destructor
|
||||
~Scrollviewdemo() override = default;
|
||||
|
||||
private:
|
||||
// Method
|
||||
void initLayout() override;
|
||||
|
||||
// Event handler
|
||||
void onClose (finalcut::FCloseEvent*) override;
|
||||
|
||||
|
@ -211,13 +220,6 @@ class Scrollviewdemo final : public finalcut::FDialog
|
|||
Scrollviewdemo::Scrollviewdemo (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
FDialog::setGeometry (FPoint{16, 3}, FSize{50, 19});
|
||||
FDialog::setText ("Scrolling viewport example");
|
||||
|
||||
// The scrolling viewport widget
|
||||
sview.setGeometry(FPoint{3, 2}, FSize{44, 12});
|
||||
sview.setScrollSize(FSize{188, 124});
|
||||
|
||||
// Quit button
|
||||
quit_btn.setGeometry(FPoint{37, 15}, FSize{10, 1});
|
||||
|
||||
|
@ -236,9 +238,15 @@ Scrollviewdemo::Scrollviewdemo (finalcut::FWidget* parent)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Scrollviewdemo::cb_quit()
|
||||
void Scrollviewdemo::initLayout()
|
||||
{
|
||||
close();
|
||||
FDialog::setGeometry (FPoint{16, 3}, FSize{50, 19});
|
||||
FDialog::setText ("Scrolling viewport example");
|
||||
|
||||
// The scrolling viewport widget
|
||||
sview.setGeometry(FPoint{3, 2}, FSize{44, 12});
|
||||
sview.setScrollSize(FSize{188, 124});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -247,6 +255,12 @@ void Scrollviewdemo::onClose (finalcut::FCloseEvent* ev)
|
|||
finalcut::FApplication::closeConfirmationDialog (this, ev);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Scrollviewdemo::cb_quit()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// main part
|
||||
|
|
|
@ -63,6 +63,7 @@ class AttribDlg final : public finalcut::FDialog
|
|||
|
||||
private:
|
||||
// Method
|
||||
void initLayout() override;
|
||||
void adjustSize() override;
|
||||
void draw() override;
|
||||
|
||||
|
@ -76,11 +77,7 @@ class AttribDlg final : public finalcut::FDialog
|
|||
AttribDlg::AttribDlg (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
next_button.setGeometry ( FPoint{int(getWidth()) - 13, int(getHeight()) - 4}
|
||||
, FSize{10, 1} );
|
||||
next_button.addAccelerator (finalcut::FKey::Right);
|
||||
back_button.setGeometry ( FPoint{int(getWidth()) - 25, int(getHeight()) - 4}
|
||||
, FSize{10, 1} );
|
||||
back_button.addAccelerator (finalcut::FKey::Left);
|
||||
|
||||
// Add function callbacks
|
||||
|
@ -167,6 +164,16 @@ void AttribDlg::cb_back()
|
|||
redraw();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void AttribDlg::initLayout()
|
||||
{
|
||||
next_button.setGeometry ( FPoint{int(getWidth()) - 13, int(getHeight()) - 4}
|
||||
, FSize{10, 1} );
|
||||
back_button.setGeometry ( FPoint{int(getWidth()) - 25, int(getHeight()) - 4}
|
||||
, FSize{10, 1} );
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void AttribDlg::adjustSize()
|
||||
{
|
||||
|
|
|
@ -58,7 +58,8 @@ class Transparent final : public finalcut::FDialog
|
|||
Transparent& operator = (const Transparent&) = delete;
|
||||
|
||||
private:
|
||||
// Method
|
||||
// Methods
|
||||
void initLayout() override;
|
||||
void draw() override;
|
||||
|
||||
// Event handlers
|
||||
|
@ -73,11 +74,16 @@ Transparent::Transparent ( finalcut::FWidget* parent
|
|||
, Transparent::Type tt )
|
||||
: finalcut::FDialog{parent}
|
||||
, type{tt}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Transparent::initLayout()
|
||||
{
|
||||
// Set statusbar text for this window
|
||||
// Avoids calling a virtual function from the constructor
|
||||
// (CERT, OOP50-CPP)
|
||||
FWidget::setStatusbarMessage("Press Q to quit");
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -166,6 +166,7 @@ class Treeview final : public finalcut::FDialog
|
|||
auto initNorthAmerica() const -> std::initializer_list<TreeItem>;
|
||||
auto initSouthAmerica() const -> std::initializer_list<TreeItem>;
|
||||
auto initOceania() const -> std::initializer_list<TreeItem>;
|
||||
void initLayout() override;
|
||||
void adjustSize() override;
|
||||
|
||||
// Event handler
|
||||
|
@ -209,9 +210,6 @@ struct Treeview::TreeItem
|
|||
Treeview::Treeview (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
// Set FListView geometry
|
||||
listview.setGeometry(FPoint{2, 1}, FSize{53, 14});
|
||||
|
||||
// Add columns to the view
|
||||
listview.addColumn ("Name", 23);
|
||||
listview.addColumn ("Population");
|
||||
|
@ -257,8 +255,7 @@ Treeview::Treeview (finalcut::FWidget* parent)
|
|||
}
|
||||
}
|
||||
|
||||
// quit button
|
||||
quit.setGeometry(FPoint{24, 16}, FSize{10, 1});
|
||||
// Quit button text
|
||||
quit.setText (L"&Quit");
|
||||
|
||||
// Callback function
|
||||
|
@ -418,6 +415,16 @@ auto Treeview::initOceania() const -> std::initializer_list<Treeview::TreeItem>
|
|||
return list;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Treeview::initLayout()
|
||||
{
|
||||
// Set FListView geometry
|
||||
listview.setGeometry(FPoint{2, 1}, FSize{53, 14});
|
||||
// Set quit button geometry
|
||||
quit.setGeometry(FPoint{24, 16}, FSize{10, 1});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Treeview::adjustSize()
|
||||
{
|
||||
|
|
|
@ -43,9 +43,6 @@ using finalcut::FSize;
|
|||
class ProgressDialog final : public finalcut::FDialog
|
||||
{
|
||||
public:
|
||||
// Using-declaration
|
||||
using FDialog::setGeometry;
|
||||
|
||||
// Constructor
|
||||
explicit ProgressDialog (finalcut::FWidget* = nullptr);
|
||||
|
||||
|
@ -59,6 +56,9 @@ class ProgressDialog final : public finalcut::FDialog
|
|||
ProgressDialog& operator = (const ProgressDialog&) = delete;
|
||||
|
||||
private:
|
||||
// Method
|
||||
void initLayout() override;
|
||||
|
||||
// Event handlers
|
||||
void onShow (finalcut::FShowEvent*) override;
|
||||
void onTimer (finalcut::FTimerEvent*) override;
|
||||
|
@ -79,29 +79,18 @@ class ProgressDialog final : public finalcut::FDialog
|
|||
ProgressDialog::ProgressDialog (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
// Dialog settings
|
||||
// Avoids calling a virtual function from the constructor
|
||||
// (CERT, OOP50-CPP)
|
||||
FDialog::setGeometry ( FPoint{int((getParentWidget()->getWidth() - 40) / 2), 7}
|
||||
, FSize{40, 10} );
|
||||
FDialog::setText("Progress bar");
|
||||
//setModal();
|
||||
|
||||
reset.setText("&Reset");
|
||||
reset.setStatusbarMessage ("Reset the progress bar");
|
||||
reset.setGeometry(FPoint{2, 6}, FSize{8, 1}, false);
|
||||
reset.setDisable();
|
||||
|
||||
more.setText("&More");
|
||||
more.setStatusbarMessage ("Increases the progress bar position");
|
||||
more.setGeometry(FPoint{15, 6}, FSize{8, 1}, false);
|
||||
more.setDisable();
|
||||
|
||||
quit.setText("E&xit");
|
||||
quit.setGeometry(FPoint{28, 6}, FSize{8, 1}, false);
|
||||
quit.setDisable();
|
||||
|
||||
progressbar.setGeometry(FPoint{2, 3}, FSize{34, 1}, false);
|
||||
//progressbar.setPercentage(78);
|
||||
|
||||
reset.addCallback
|
||||
|
@ -132,6 +121,19 @@ ProgressDialog::~ProgressDialog() // destructor
|
|||
delCallback(&reset);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void ProgressDialog::initLayout()
|
||||
{
|
||||
FDialog::setGeometry ( FPoint{int((getParentWidget()->getWidth() - 40) / 2), 7}
|
||||
, FSize{40, 10} );
|
||||
FDialog::setText("Progress bar");
|
||||
reset.setGeometry(FPoint{2, 6}, FSize{8, 1}, false);
|
||||
more.setGeometry(FPoint{15, 6}, FSize{8, 1}, false);
|
||||
quit.setGeometry(FPoint{28, 6}, FSize{8, 1}, false);
|
||||
progressbar.setGeometry(FPoint{2, 3}, FSize{34, 1}, false);
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void ProgressDialog::onShow (finalcut::FShowEvent*)
|
||||
{
|
||||
|
@ -207,6 +209,7 @@ class TextWindow final : public finalcut::FDialog
|
|||
|
||||
private:
|
||||
// Method
|
||||
void initLayout() override;
|
||||
void adjustSize() override;
|
||||
|
||||
// Data members
|
||||
|
@ -218,8 +221,6 @@ TextWindow::TextWindow (finalcut::FWidget* parent)
|
|||
: finalcut::FDialog{parent}
|
||||
{
|
||||
scrolltext.ignorePadding();
|
||||
scrolltext.setGeometry (FPoint{1, 2}, FSize{getWidth(), getHeight() - 1});
|
||||
setMinimumSize (FSize{51, 6});
|
||||
scrolltext.setFocus();
|
||||
scrolltext.insert(" -----------------------------------------------\n"
|
||||
" line 1\n"
|
||||
|
@ -237,6 +238,14 @@ void TextWindow::append (const finalcut::FString& str)
|
|||
scrolltext.append(str);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void TextWindow::initLayout()
|
||||
{
|
||||
scrolltext.setGeometry (FPoint{1, 2}, FSize{getWidth(), getHeight() - 1});
|
||||
setMinimumSize (FSize{51, 6});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void TextWindow::adjustSize()
|
||||
{
|
||||
|
@ -280,6 +289,7 @@ class MyDialog final : public finalcut::FDialog
|
|||
void initButtons();
|
||||
void initLabels();
|
||||
void initWidgetsCallbacks();
|
||||
void initLayout() override;
|
||||
void adjustSize() override;
|
||||
|
||||
// Event handlers
|
||||
|
@ -574,7 +584,6 @@ void MyDialog::initWidgets()
|
|||
initToggleButtons();
|
||||
|
||||
// A text input field
|
||||
myLineEdit.setGeometry(FPoint{22, 1}, FSize{10, 1});
|
||||
myLineEdit.setLabelText (L"&Input");
|
||||
myLineEdit.setStatusbarMessage ("Press Enter to set the title");
|
||||
myLineEdit << finalcut::FString{"EnTry"}.toLower();
|
||||
|
@ -583,9 +592,8 @@ void MyDialog::initWidgets()
|
|||
initButtons();
|
||||
|
||||
// A multiple selection listbox
|
||||
myList.setGeometry(FPoint{38, 1}, FSize{14, 17});
|
||||
myList.setText ("Items");
|
||||
|
||||
myList.setText ("Items");
|
||||
myList.setStatusbarMessage ("99 items in a list");
|
||||
myList.setMultiSelection();
|
||||
myList.reserve(100);
|
||||
|
@ -601,21 +609,18 @@ void MyDialog::initWidgets()
|
|||
void MyDialog::initFlatButtons()
|
||||
{
|
||||
// Flat buttons
|
||||
MyButton1.setGeometry(FPoint{3, 3}, FSize{5, 1});
|
||||
MyButton1.setText (L"&SIN");
|
||||
MyButton1.setStatusbarMessage ("Sine function");
|
||||
MyButton1.setNoUnderline();
|
||||
MyButton1.setFlat();
|
||||
MyButton1.setDoubleFlatLine (finalcut::Side::Bottom);
|
||||
|
||||
MyButton2.setGeometry(FPoint{3, 5}, FSize{5, 1});
|
||||
MyButton2.setText (L"&COS");
|
||||
MyButton2.setStatusbarMessage ("Cosine function");
|
||||
MyButton2.setNoUnderline();
|
||||
MyButton2.setFlat();
|
||||
MyButton2.setDoubleFlatLine (finalcut::Side::Top);
|
||||
|
||||
MyButton3.setGeometry(FPoint{10, 3}, FSize{5, 3});
|
||||
MyButton3.setText (L"&=");
|
||||
MyButton3.setStatusbarMessage ("Equal");
|
||||
MyButton3.setNoUnderline();
|
||||
|
@ -648,25 +653,16 @@ void MyDialog::initFlatButtons()
|
|||
void MyDialog::initToggleButtons()
|
||||
{
|
||||
// Radio buttons in a group
|
||||
radioButtonGroup.setGeometry(FPoint{3, 8}, FSize{14, 4});
|
||||
|
||||
//radioButtonGroup->unsetBorder();
|
||||
|
||||
radio1.setGeometry(FPoint{1, 1}, FSize{10, 1});
|
||||
radio1.setStatusbarMessage ("Enable button Test");
|
||||
|
||||
radio2.setGeometry(FPoint{1, 2}, FSize{11, 1});
|
||||
radio2.setText ("&Disable");
|
||||
radio2.setStatusbarMessage ("Disable button Test");
|
||||
radio2.setChecked();
|
||||
//radio2.setDisable();
|
||||
|
||||
// Checkboxes in a group
|
||||
checkButtonGroup.setGeometry(FPoint{3, 12}, FSize{14, 4});
|
||||
|
||||
check1.setGeometry(FPoint{1, 1}, FSize{11, 1});
|
||||
check1.setNoUnderline();
|
||||
|
||||
check2.setGeometry(FPoint{1, 2}, FSize{9, 1});
|
||||
check2.setChecked();
|
||||
check2.setNoUnderline();
|
||||
}
|
||||
|
@ -675,17 +671,15 @@ void MyDialog::initToggleButtons()
|
|||
void MyDialog::initButtons()
|
||||
{
|
||||
// Buttons
|
||||
MyButton4.setGeometry(FPoint{20, 8}, FSize{12, 1});
|
||||
|
||||
MyButton4.setText (L"&Get input");
|
||||
MyButton4.setStatusbarMessage ("Take text from input field");
|
||||
MyButton4.setFocus();
|
||||
|
||||
MyButton5.setGeometry(FPoint{20, 11}, FSize{12, 1});
|
||||
MyButton5.setText (L"&Test");
|
||||
MyButton5.setStatusbarMessage ("Progressbar testing dialog");
|
||||
MyButton5.setDisable();
|
||||
|
||||
MyButton6.setGeometry(FPoint{20, 14}, FSize{12, 1});
|
||||
MyButton6.setText (L"&Quit");
|
||||
MyButton6.setStatusbarMessage ("Exit the program");
|
||||
MyButton6.addAccelerator(FKey('x'));
|
||||
|
@ -717,20 +711,12 @@ void MyDialog::initButtons()
|
|||
void MyDialog::initLabels()
|
||||
{
|
||||
// Text labels
|
||||
headline.setGeometry(FPoint{21, 3}, FSize{10, 1});
|
||||
|
||||
headline.setEmphasis();
|
||||
headline.setAlignment (finalcut::Align::Center);
|
||||
headline = L"List items";
|
||||
|
||||
tagged.setGeometry(FPoint{21, 4}, FSize{7, 1});
|
||||
|
||||
tagged_count.setGeometry(FPoint{29, 4}, FSize{5, 1});
|
||||
tagged_count << 0;
|
||||
|
||||
sum.setGeometry(FPoint{21, 5}, FSize{7, 3});
|
||||
sum.setAlignment (finalcut::Align::Right);
|
||||
|
||||
sum_count.setGeometry(FPoint{29, 5}, FSize{5, 3});
|
||||
sum_count << myList.getCount();
|
||||
}
|
||||
|
||||
|
@ -767,6 +753,31 @@ void MyDialog::initWidgetsCallbacks()
|
|||
);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void MyDialog::initLayout()
|
||||
{
|
||||
MyButton1.setGeometry(FPoint{3, 3}, FSize{5, 1});
|
||||
MyButton2.setGeometry(FPoint{3, 5}, FSize{5, 1});
|
||||
MyButton3.setGeometry(FPoint{10, 3}, FSize{5, 3});
|
||||
MyButton4.setGeometry(FPoint{20, 8}, FSize{12, 1});
|
||||
MyButton5.setGeometry(FPoint{20, 11}, FSize{12, 1});
|
||||
MyButton6.setGeometry(FPoint{20, 14}, FSize{12, 1});
|
||||
radioButtonGroup.setGeometry(FPoint{3, 8}, FSize{14, 4});
|
||||
radio1.setGeometry(FPoint{1, 1}, FSize{10, 1});
|
||||
radio2.setGeometry(FPoint{1, 2}, FSize{11, 1});
|
||||
checkButtonGroup.setGeometry(FPoint{3, 12}, FSize{14, 4});
|
||||
check1.setGeometry(FPoint{1, 1}, FSize{11, 1});
|
||||
check2.setGeometry(FPoint{1, 2}, FSize{9, 1});
|
||||
headline.setGeometry(FPoint{21, 3}, FSize{10, 1});
|
||||
tagged.setGeometry(FPoint{21, 4}, FSize{7, 1});
|
||||
tagged_count.setGeometry(FPoint{29, 4}, FSize{5, 1});
|
||||
sum.setGeometry(FPoint{21, 5}, FSize{7, 3});
|
||||
sum_count.setGeometry(FPoint{29, 5}, FSize{5, 3});
|
||||
myLineEdit.setGeometry(FPoint{22, 1}, FSize{10, 1});
|
||||
myList.setGeometry(FPoint{38, 1}, FSize{14, 17});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void MyDialog::adjustSize()
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2015-2020 Markus Gans *
|
||||
* Copyright 2015-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -59,6 +59,7 @@ class Watch final : public finalcut::FDialog
|
|||
|
||||
protected:
|
||||
// Method
|
||||
void initLayout() override;
|
||||
void adjustSize() override;
|
||||
|
||||
private:
|
||||
|
@ -75,25 +76,12 @@ class Watch final : public finalcut::FDialog
|
|||
Watch::Watch (FWidget* parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
// Dialog settings
|
||||
// Avoids calling a virtual function from the constructor
|
||||
// (CERT, OOP50-CPP)
|
||||
FDialog::setText ("Watch");
|
||||
FDialog::setSize ({22, 13});
|
||||
|
||||
// Labels
|
||||
time_label.setGeometry(FPoint{5, 2}, FSize{5, 1});
|
||||
time_label.setEmphasis();
|
||||
time_str.setGeometry(FPoint{10, 2}, FSize{8, 1});
|
||||
|
||||
// Checkbox buttons
|
||||
clock_sw.setGeometry(FPoint{4, 4}, FSize{9, 1});
|
||||
seconds_sw.setGeometry(FPoint{2, 6}, FSize{11, 1});
|
||||
// Switch
|
||||
sec = seconds_sw.setChecked();
|
||||
|
||||
// Quit button
|
||||
quit_btn.setGeometry(FPoint{6, 9}, FSize{9, 1});
|
||||
|
||||
// Connect switch signal "toggled" with a callback member function
|
||||
clock_sw.addCallback
|
||||
(
|
||||
|
@ -185,6 +173,27 @@ void Watch::cb_seconds()
|
|||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Watch::initLayout()
|
||||
{
|
||||
// Dialog settings
|
||||
FDialog::setText ("Watch");
|
||||
FDialog::setSize ({22, 13}, false);
|
||||
|
||||
// Labels
|
||||
time_label.setGeometry(FPoint{5, 2}, FSize{5, 1});
|
||||
time_str.setGeometry(FPoint{10, 2}, FSize{8, 1});
|
||||
|
||||
// Switches
|
||||
clock_sw.setGeometry(FPoint{4, 4}, FSize{9, 1});
|
||||
seconds_sw.setGeometry(FPoint{2, 6}, FSize{11, 1});
|
||||
|
||||
// Quit button
|
||||
quit_btn.setGeometry(FPoint{6, 9}, FSize{9, 1});
|
||||
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Watch::adjustSize()
|
||||
{
|
||||
|
|
|
@ -50,6 +50,7 @@ class SmallWindow final : public finalcut::FDialog
|
|||
|
||||
private:
|
||||
// Method
|
||||
void initLayout() override;
|
||||
void adjustSize() override;
|
||||
|
||||
// Event handlers
|
||||
|
@ -77,24 +78,20 @@ SmallWindow::SmallWindow (finalcut::FWidget* parent)
|
|||
left_arrow.setForegroundColor (wc->label_inactive_fg);
|
||||
left_arrow.setEmphasis();
|
||||
left_arrow.ignorePadding();
|
||||
left_arrow.setGeometry (FPoint{2, 2}, FSize{1, 1});
|
||||
|
||||
right_arrow = arrow_up;
|
||||
right_arrow.setForegroundColor (wc->label_inactive_fg);
|
||||
right_arrow.setEmphasis();
|
||||
right_arrow.ignorePadding();
|
||||
right_arrow.setGeometry (FPoint{int(getWidth()) - 1, 2}, FSize{1, 1});
|
||||
|
||||
top_left_label.setText("menu");
|
||||
top_left_label.setForegroundColor (wc->label_inactive_fg);
|
||||
top_left_label.setEmphasis();
|
||||
top_left_label.setGeometry (FPoint{1, 1}, FSize{6, 1});
|
||||
|
||||
top_right_label.setText("zoom");
|
||||
top_right_label.setAlignment (finalcut::Align::Right);
|
||||
top_right_label.setForegroundColor (wc->label_inactive_fg);
|
||||
top_right_label.setEmphasis();
|
||||
top_right_label.setGeometry (FPoint{int(getClientWidth()) - 5, 1}, FSize{6, 1});
|
||||
|
||||
finalcut::FString bottom_label_text { "resize\n"
|
||||
"corner\n" };
|
||||
|
@ -103,7 +100,17 @@ SmallWindow::SmallWindow (finalcut::FWidget* parent)
|
|||
bottom_label.setAlignment (finalcut::Align::Right);
|
||||
bottom_label.setForegroundColor (wc->label_inactive_fg);
|
||||
bottom_label.setEmphasis();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void SmallWindow::initLayout()
|
||||
{
|
||||
left_arrow.setGeometry (FPoint{2, 2}, FSize{1, 1});
|
||||
right_arrow.setGeometry (FPoint{int(getWidth()) - 1, 2}, FSize{1, 1});
|
||||
top_left_label.setGeometry (FPoint{1, 1}, FSize{6, 1});
|
||||
top_right_label.setGeometry (FPoint{int(getClientWidth()) - 5, 1}, FSize{6, 1});
|
||||
bottom_label.setGeometry (FPoint{13, 3}, FSize{6, 3});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -199,6 +206,8 @@ class Window final : public finalcut::FDialog
|
|||
void configureFileMenuItems();
|
||||
void configureDialogButtons();
|
||||
void activateWindow (finalcut::FDialog*) const;
|
||||
|
||||
void initLayout() override;
|
||||
void adjustSize() override;
|
||||
template <typename InstanceT
|
||||
, typename CallbackT
|
||||
|
@ -317,11 +326,8 @@ void Window::configureFileMenuItems()
|
|||
void Window::configureDialogButtons()
|
||||
{
|
||||
// Dialog buttons
|
||||
CreateButton.setGeometry (FPoint{2, 2}, FSize{9, 1});
|
||||
CreateButton.setText (L"&Create");
|
||||
CloseButton.setGeometry (FPoint{15, 2}, FSize{9, 1});
|
||||
CloseButton.setText (L"C&lose");
|
||||
QuitButton.setGeometry (FPoint{28, 2}, FSize{9, 1});
|
||||
QuitButton.setText (L"&Quit");
|
||||
|
||||
// Add button callback
|
||||
|
@ -346,6 +352,15 @@ void Window::activateWindow (finalcut::FDialog* win) const
|
|||
win->redraw();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Window::initLayout()
|
||||
{
|
||||
CreateButton.setGeometry (FPoint{2, 2}, FSize{9, 1});
|
||||
CloseButton.setGeometry (FPoint{15, 2}, FSize{9, 1});
|
||||
QuitButton.setGeometry (FPoint{28, 2}, FSize{9, 1});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Window::adjustSize()
|
||||
{
|
||||
|
|
|
@ -1172,10 +1172,11 @@ void FDialog::drawTextBar()
|
|||
|
||||
const auto width = getWidth();
|
||||
const auto zoom_btn = getZoomButtonWidth();
|
||||
const auto tb_width = width - MENU_BTN - zoom_btn;
|
||||
const auto length = getColumnWidth(tb_text);
|
||||
|
||||
if ( width > length + MENU_BTN + zoom_btn )
|
||||
center_offset = (width - length - MENU_BTN - zoom_btn) / 2;
|
||||
center_offset = (tb_width - length) / 2;
|
||||
|
||||
for ( ; x <= center_offset; x++)
|
||||
print (' ');
|
||||
|
@ -1183,12 +1184,13 @@ void FDialog::drawTextBar()
|
|||
// Print title bar text
|
||||
if ( ! tb_text.isEmpty() )
|
||||
{
|
||||
if ( length <= width - MENU_BTN - zoom_btn )
|
||||
if ( length <= tb_width )
|
||||
print (tb_text);
|
||||
else
|
||||
{
|
||||
// Print ellipsis
|
||||
print (tb_text.left(width - MENU_BTN - zoom_btn - 2));
|
||||
const auto len = getLengthFromColumnWidth (tb_text, tb_width - 2);
|
||||
print (tb_text.left(len));
|
||||
print ("..");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -171,17 +171,7 @@ void FMenuItem::unsetSelected()
|
|||
void FMenuItem::setText (const FString& txt)
|
||||
{
|
||||
text.setString(txt);
|
||||
text_length = text.getLength();
|
||||
text_width = getColumnWidth(txt);
|
||||
hotkey = finalcut::getHotkey(text);
|
||||
|
||||
if ( hotkey != FKey::None )
|
||||
{
|
||||
text_length--;
|
||||
text_width--;
|
||||
}
|
||||
|
||||
updateSuperMenuDimensions();
|
||||
calculateTextDimensions();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -481,6 +471,11 @@ bool FMenuItem::isMenu (const FWidget* w) const
|
|||
return m1 || m2;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuItem::initLayout()
|
||||
{
|
||||
calculateTextDimensions();
|
||||
}
|
||||
|
||||
// private methods of FMenuItem
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -557,6 +552,23 @@ void FMenuItem::init()
|
|||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuItem::calculateTextDimensions()
|
||||
{
|
||||
text_length = text.getLength();
|
||||
text_width = getColumnWidth(text);
|
||||
hotkey = finalcut::getHotkey(text);
|
||||
|
||||
if ( hotkey != FKey::None )
|
||||
{
|
||||
text_length--;
|
||||
text_width--;
|
||||
}
|
||||
|
||||
updateMenubarDimensions();
|
||||
updateSuperMenuDimensions();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuItem::updateSuperMenuDimensions()
|
||||
{
|
||||
|
@ -567,6 +579,18 @@ void FMenuItem::updateSuperMenuDimensions()
|
|||
menu_ptr->calculateDimensions();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuItem::updateMenubarDimensions()
|
||||
{
|
||||
FWidget* parent = getParentWidget();
|
||||
|
||||
if ( ! parent || ! isMenuBar(parent) )
|
||||
return;
|
||||
|
||||
auto menubar_ptr = static_cast<FMenuBar*>(parent);
|
||||
menubar_ptr->calculateDimensions();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuItem::processEnable() const
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2014-2020 Markus Gans *
|
||||
* Copyright 2014-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -120,6 +120,13 @@ FMessageBox::ButtonType FMessageBox::exec()
|
|||
}
|
||||
|
||||
// protected methods of FMessageBox
|
||||
//----------------------------------------------------------------------
|
||||
void FMessageBox::initLayout()
|
||||
{
|
||||
calculateDimensions();
|
||||
adjustButtons();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMessageBox::adjustSize()
|
||||
{
|
||||
|
|
112
src/ftermcap.cpp
112
src/ftermcap.cpp
|
@ -42,7 +42,6 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include "final/emptyfstring.h"
|
||||
|
@ -132,6 +131,54 @@ FTermcap::Status FTermcap::paddingPrint ( const std::string& string
|
|||
|| ( ! xon_xoff_flow_control && padding_baudrate
|
||||
&& (baudrate >= padding_baudrate) );
|
||||
auto iter = string.begin();
|
||||
using iter_type = decltype(iter);
|
||||
|
||||
auto read_digits = [] (iter_type& iter, int& number)
|
||||
{
|
||||
while ( std::isdigit(int(*iter)) && number < 1000 )
|
||||
{
|
||||
number = number * 10 + (*iter - '0');
|
||||
++iter;
|
||||
}
|
||||
|
||||
number *= 10;
|
||||
};
|
||||
|
||||
auto decimal_point = [] (iter_type& iter, int& number)
|
||||
{
|
||||
if ( *iter == '.' )
|
||||
{
|
||||
++iter;
|
||||
|
||||
if ( std::isdigit(int(*iter)) )
|
||||
{
|
||||
number += (*iter - '0'); // Position after decimal point
|
||||
++iter;
|
||||
}
|
||||
|
||||
while ( std::isdigit(int(*iter)) )
|
||||
++iter;
|
||||
}
|
||||
};
|
||||
|
||||
auto asterisk_slash = [&affcnt, &has_delay] (iter_type& iter, int& number)
|
||||
{
|
||||
while ( *iter == '*' || *iter == '/' )
|
||||
{
|
||||
if ( *iter == '*' )
|
||||
{
|
||||
// Padding is proportional to the number of affected lines (suffix '*')
|
||||
number *= affcnt;
|
||||
++iter;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Padding is mandatory (suffix '/')
|
||||
has_delay = true;
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
while ( iter != string.end() )
|
||||
{
|
||||
|
@ -161,44 +208,9 @@ FTermcap::Status FTermcap::paddingPrint ( const std::string& string
|
|||
}
|
||||
|
||||
int number = 0;
|
||||
|
||||
while ( std::isdigit(int(*iter)) && number < 1000 )
|
||||
{
|
||||
number = number * 10 + (*iter - '0');
|
||||
++iter;
|
||||
}
|
||||
|
||||
number *= 10;
|
||||
|
||||
if ( *iter == '.' )
|
||||
{
|
||||
++iter;
|
||||
|
||||
if ( std::isdigit(int(*iter)) )
|
||||
{
|
||||
number += (*iter - '0'); // Position after decimal point
|
||||
++iter;
|
||||
}
|
||||
|
||||
while ( std::isdigit(int(*iter)) )
|
||||
++iter;
|
||||
}
|
||||
|
||||
while ( *iter == '*' || *iter == '/' )
|
||||
{
|
||||
if ( *iter == '*' )
|
||||
{
|
||||
// Padding is proportional to the number of affected lines (suffix '*')
|
||||
number *= affcnt;
|
||||
++iter;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Padding is mandatory (suffix '/')
|
||||
has_delay = true;
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
read_digits (iter, number);
|
||||
decimal_point (iter, number);
|
||||
asterisk_slash (iter, number);
|
||||
|
||||
if ( *iter != '>' )
|
||||
{
|
||||
|
@ -435,28 +447,6 @@ std::string FTermcap::encodeParams ( const std::string& cap
|
|||
return ( str ) ? str : std::string();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermcap::delay_output (int ms, const defaultPutChar& outc)
|
||||
{
|
||||
if ( no_padding_char )
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(ms));
|
||||
}
|
||||
else
|
||||
{
|
||||
static constexpr int baudbyte = 9; // = 7 bit + 1 parity + 1 stop
|
||||
|
||||
for ( int pad_char_count = (ms * baudrate) / (baudbyte * 1000);
|
||||
pad_char_count > 0;
|
||||
pad_char_count-- )
|
||||
{
|
||||
outc(int(PC));
|
||||
}
|
||||
|
||||
std::fflush(stdout);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// private Data Member of FTermcap - termcap capabilities
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -464,6 +464,21 @@ void FTextView::onFocusOut (FFocusEvent*)
|
|||
|
||||
|
||||
// protected methods of FTextView
|
||||
//----------------------------------------------------------------------
|
||||
void FTextView::initLayout()
|
||||
{
|
||||
if ( data.empty() )
|
||||
return;
|
||||
|
||||
for (auto&& line : data)
|
||||
{
|
||||
const auto column_width = getColumnWidth(line);
|
||||
|
||||
if ( column_width > max_line_width )
|
||||
max_line_width = column_width;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTextView::adjustSize()
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2016-2020 Markus Gans *
|
||||
* Copyright 2016-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -176,9 +176,14 @@ void FToolTip::calculateDimensions()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FToolTip::adjustSize()
|
||||
void FToolTip::initLayout()
|
||||
{
|
||||
calculateDimensions();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FToolTip::adjustSize()
|
||||
{
|
||||
FWindow::adjustSize();
|
||||
}
|
||||
|
||||
|
|
|
@ -972,6 +972,7 @@ void FWidget::show()
|
|||
show_root_widget = this;
|
||||
}
|
||||
|
||||
initWidgetLayout(); // Makes initial layout settings
|
||||
adjustSize(); // Alignment before drawing
|
||||
draw(); // Draw the widget
|
||||
flags.hidden = false;
|
||||
|
@ -1284,6 +1285,13 @@ void FWidget::initDesktop()
|
|||
init_desktop = true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidget::initLayout()
|
||||
{
|
||||
// This method must be reimplemented in a subclass to automatically
|
||||
// set the widget layouts, before the initial drawing on the terminal
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidget::adjustSize()
|
||||
{
|
||||
|
@ -1767,6 +1775,24 @@ void FWidget::initRootWidget()
|
|||
determineDesktopSize();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidget::initWidgetLayout()
|
||||
{
|
||||
initLayout();
|
||||
|
||||
if ( ! hasChildren() )
|
||||
return;
|
||||
|
||||
for (auto&& child : getChildren())
|
||||
{
|
||||
if ( child->isWidget() )
|
||||
{
|
||||
auto widget = static_cast<FWidget*>(child);
|
||||
widget->initWidgetLayout();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidget::finish()
|
||||
{
|
||||
|
|
|
@ -148,13 +148,18 @@ class FMenuItem : public FWidget
|
|||
bool isMenuBar (const FWidget*) const;
|
||||
bool isMenu (const FWidget*) const;
|
||||
|
||||
// Method
|
||||
void initLayout() override;
|
||||
|
||||
private:
|
||||
// Accessor
|
||||
FMenuList* getFMenuList (FWidget&);
|
||||
|
||||
// Methods
|
||||
void init();
|
||||
void calculateTextDimensions();
|
||||
void updateSuperMenuDimensions();
|
||||
void updateMenubarDimensions();
|
||||
void processEnable() const;
|
||||
void processDisable() const;
|
||||
void processActivate() const;
|
||||
|
|
|
@ -139,6 +139,7 @@ class FMessageBox : public FDialog
|
|||
, ButtonType = ButtonType::Reject );
|
||||
protected:
|
||||
// Method
|
||||
void initLayout() override;
|
||||
void adjustSize() override;
|
||||
void done (ButtonType);
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
|
@ -129,7 +130,8 @@ class FTermcap final
|
|||
static void termcapKeys();
|
||||
static std::string encodeParams ( const std::string&
|
||||
, const std::vector<int>& );
|
||||
static void delay_output (int, const defaultPutChar&);
|
||||
template<typename PutChar>
|
||||
static void delay_output (int, const PutChar&);
|
||||
|
||||
// Data member
|
||||
static bool initialized;
|
||||
|
@ -162,6 +164,29 @@ inline void FTermcap::setBaudrate (int baud)
|
|||
baudrate = baud;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
template<typename PutChar>
|
||||
inline void FTermcap::delay_output (int ms, const PutChar& outc)
|
||||
{
|
||||
if ( no_padding_char )
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(ms));
|
||||
}
|
||||
else
|
||||
{
|
||||
static constexpr int baudbyte = 9; // = 7 bit + 1 parity + 1 stop
|
||||
|
||||
for ( int pad_char_count = (ms * baudrate) / (baudbyte * 1000);
|
||||
pad_char_count > 0;
|
||||
pad_char_count-- )
|
||||
{
|
||||
outc(int(PC));
|
||||
}
|
||||
|
||||
std::fflush(stdout);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace finalcut
|
||||
|
||||
|
||||
|
|
|
@ -134,6 +134,7 @@ class FTextView : public FWidget
|
|||
|
||||
protected:
|
||||
// Method
|
||||
void initLayout() override;
|
||||
void adjustSize() override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -103,6 +103,7 @@ class FToolTip : public FWindow
|
|||
void init();
|
||||
void draw() override;
|
||||
void calculateDimensions();
|
||||
void initLayout() override;
|
||||
void adjustSize() override;
|
||||
|
||||
// Data members
|
||||
|
|
|
@ -349,6 +349,7 @@ class FWidget : public FVTerm, public FObject
|
|||
// Methods
|
||||
void initTerminal() override;
|
||||
void initDesktop();
|
||||
virtual void initLayout();
|
||||
virtual void adjustSize();
|
||||
void adjustSizeGlobal();
|
||||
void hideArea (const FSize&);
|
||||
|
@ -424,6 +425,7 @@ class FWidget : public FVTerm, public FObject
|
|||
// Methods
|
||||
void determineDesktopSize();
|
||||
void initRootWidget();
|
||||
void initWidgetLayout();
|
||||
void finish();
|
||||
void insufficientSpaceAdjust();
|
||||
void KeyPressEvent (FKeyEvent*);
|
||||
|
|
Loading…
Reference in New Issue