2019-09-28 03:13:06 +02:00
|
|
|
|
/***********************************************************************
|
|
|
|
|
* fullwidth-letter.cpp - Demonstrates use of full-width characters *
|
|
|
|
|
* *
|
2020-07-08 21:32:47 +02:00
|
|
|
|
* This file is part of the FINAL CUT widget toolkit *
|
2019-09-28 03:13:06 +02:00
|
|
|
|
* *
|
2020-04-13 12:40:11 +02:00
|
|
|
|
* Copyright 2019-2020 Markus Gans *
|
2019-09-28 03:13:06 +02:00
|
|
|
|
* *
|
2020-07-08 21:32:47 +02:00
|
|
|
|
* FINAL CUT is free software; you can redistribute it and/or modify *
|
|
|
|
|
* it under the terms of the GNU Lesser General Public License as *
|
|
|
|
|
* published by the Free Software Foundation; either version 3 of *
|
2019-09-28 03:13:06 +02:00
|
|
|
|
* the License, or (at your option) any later version. *
|
|
|
|
|
* *
|
2020-07-08 21:32:47 +02:00
|
|
|
|
* FINAL CUT is distributed in the hope that it will be useful, but *
|
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
2019-09-28 03:13:06 +02:00
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
|
* GNU Lesser General Public License for more details. *
|
|
|
|
|
* *
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public *
|
|
|
|
|
* License along with this program. If not, see *
|
|
|
|
|
* <http://www.gnu.org/licenses/>. *
|
|
|
|
|
***********************************************************************/
|
|
|
|
|
|
|
|
|
|
#include <final/final.h>
|
|
|
|
|
|
|
|
|
|
#define full(...) finalcut::getFullWidth(__VA_ARGS__)
|
|
|
|
|
|
|
|
|
|
using finalcut::FPoint;
|
|
|
|
|
using finalcut::FSize;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
// main part
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
int main (int argc, char* argv[])
|
|
|
|
|
{
|
|
|
|
|
// Create the application object
|
2020-05-02 00:07:35 +02:00
|
|
|
|
finalcut::FApplication app{argc, argv};
|
2019-09-28 03:13:06 +02:00
|
|
|
|
|
|
|
|
|
// Create a simple dialog box
|
2020-05-02 00:07:35 +02:00
|
|
|
|
finalcut::FDialog dgl{&app};
|
2019-09-28 03:13:06 +02:00
|
|
|
|
dgl.setText (full("Dialog"));
|
2020-05-02 00:07:35 +02:00
|
|
|
|
dgl.setSize (FSize{37, 16});
|
|
|
|
|
dgl.setPos ({ int(app.getDesktopWidth() - dgl.getWidth()) / 2
|
|
|
|
|
, int(app.getDesktopHeight() - dgl.getHeight()) / 2});
|
2019-09-28 03:13:06 +02:00
|
|
|
|
dgl.setShadow();
|
|
|
|
|
|
|
|
|
|
// Create input fields
|
2020-05-02 00:07:35 +02:00
|
|
|
|
finalcut::FLineEdit field1 {&dgl};
|
2019-09-28 03:13:06 +02:00
|
|
|
|
field1.setLabelText (full("Input"));
|
|
|
|
|
field1.setText (L"你好"); // Nǐ hǎo (chinese)
|
|
|
|
|
field1.setStatusbarMessage (full("Type your text here"));
|
2020-05-02 00:07:35 +02:00
|
|
|
|
field1.setGeometry (FPoint{15, 1}, FSize{19, 1});
|
2019-09-28 03:13:06 +02:00
|
|
|
|
|
2020-05-02 00:07:35 +02:00
|
|
|
|
finalcut::FLineEdit field2 {&dgl};
|
2019-09-28 03:13:06 +02:00
|
|
|
|
field2.setLabelText (L"Comment");
|
|
|
|
|
field2.setText (full(L"Hello"));
|
|
|
|
|
field2.setStatusbarMessage (full("Post a comment"));
|
2020-05-02 00:07:35 +02:00
|
|
|
|
field2.setGeometry (FPoint{15, 3}, FSize{19, 1});
|
2019-09-28 03:13:06 +02:00
|
|
|
|
|
|
|
|
|
// Create the button group
|
2020-05-02 00:07:35 +02:00
|
|
|
|
finalcut::FButtonGroup group {full("Side"), &dgl};
|
|
|
|
|
group.setGeometry(FPoint{2, 5}, FSize{32, 3});
|
2019-09-28 03:13:06 +02:00
|
|
|
|
|
|
|
|
|
// Create radio buttons
|
2020-05-02 00:07:35 +02:00
|
|
|
|
finalcut::FRadioButton left {"&" + full("Left"), &group};
|
|
|
|
|
finalcut::FRadioButton right {"&" + full("Right"), &group};
|
2019-09-28 03:13:06 +02:00
|
|
|
|
left.setStatusbarMessage (full("Prefer the left side"));
|
|
|
|
|
right.setStatusbarMessage (full("Prefer the right side"));
|
2020-05-02 00:07:35 +02:00
|
|
|
|
left.setGeometry (FPoint{1, 1}, FSize{8, 1});
|
|
|
|
|
right.setGeometry (FPoint{15, 1}, FSize{10, 1});
|
2019-09-28 03:13:06 +02:00
|
|
|
|
|
|
|
|
|
// Create a scrollable text field
|
2020-05-02 00:07:35 +02:00
|
|
|
|
finalcut::FTextView scroll_text {&dgl};
|
|
|
|
|
scroll_text.setGeometry (FPoint{2, 8}, FSize{32, 3});
|
2019-09-28 03:13:06 +02:00
|
|
|
|
finalcut::FString text_line{"FINAL CUT supports "
|
|
|
|
|
"full-width characters."};
|
2019-09-29 22:28:58 +02:00
|
|
|
|
scroll_text << full(text_line);
|
2019-09-28 03:13:06 +02:00
|
|
|
|
scroll_text.setStatusbarMessage ("You can scroll right and "
|
|
|
|
|
"left with the arrow keys");
|
|
|
|
|
|
|
|
|
|
// Create a OK button
|
2020-05-02 00:07:35 +02:00
|
|
|
|
finalcut::FButton btn {"&OK", &dgl};
|
2019-09-28 03:13:06 +02:00
|
|
|
|
btn.setStatusbarMessage (full("Press Enter to exit the dialog"));
|
2020-05-02 00:07:35 +02:00
|
|
|
|
btn.setGeometry (FPoint{24, 12}, FSize{10, 1});
|
2019-09-28 03:13:06 +02:00
|
|
|
|
|
|
|
|
|
// Create the status bar
|
2020-05-02 00:07:35 +02:00
|
|
|
|
finalcut::FStatusBar sbar {&dgl};
|
2020-12-31 20:45:10 +01:00
|
|
|
|
finalcut::FStatusKey key_F1 (finalcut::FKey::F1, "Info", &sbar);
|
2019-09-28 03:13:06 +02:00
|
|
|
|
|
|
|
|
|
// Create the menu bar
|
2020-05-02 00:07:35 +02:00
|
|
|
|
finalcut::FMenuBar Menubar {&dgl};
|
2019-09-28 03:13:06 +02:00
|
|
|
|
|
|
|
|
|
// Create menu bar items
|
|
|
|
|
finalcut::FMenu File{L"&File", &Menubar};
|
|
|
|
|
finalcut::FMenuItem Edit{L"&Edit", &Menubar};
|
|
|
|
|
finalcut::FMenuItem Exit{L"E&xit", &Menubar};
|
|
|
|
|
|
|
|
|
|
// Create file menu items
|
|
|
|
|
finalcut::FMenuItem Open{"&Open", &File};
|
|
|
|
|
finalcut::FMenuItem Print{"&Print", &File};
|
|
|
|
|
finalcut::FMenuItem Line{&File};
|
|
|
|
|
Line.setSeparator();
|
|
|
|
|
finalcut::FMenuItem Quit{"&Quit", &File};
|
2020-12-31 20:45:10 +01:00
|
|
|
|
Quit.addAccelerator (finalcut::FKey::Ctrl_q); // Ctrl + Q
|
2019-09-28 03:13:06 +02:00
|
|
|
|
|
|
|
|
|
// Callback lambda expressions
|
|
|
|
|
auto cb_exit = \
|
2020-08-12 22:28:02 +02:00
|
|
|
|
[] (const finalcut::FApplication& a)
|
2019-09-28 03:13:06 +02:00
|
|
|
|
{
|
2020-08-11 23:04:46 +02:00
|
|
|
|
a.quit();
|
2019-09-28 03:13:06 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
auto cb_tooltip = \
|
2020-10-14 23:43:34 +02:00
|
|
|
|
[] (finalcut::FDialog* a)
|
2019-09-28 03:13:06 +02:00
|
|
|
|
{
|
|
|
|
|
finalcut::FToolTip tooltip(a);
|
|
|
|
|
tooltip.setText (full("A tooltip with\ncharacters\n"
|
|
|
|
|
"in full-width\nfor 3 seconds"));
|
|
|
|
|
tooltip.show();
|
|
|
|
|
sleep(3);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Connect the signals with the callback lambda expressions
|
2020-08-11 23:04:46 +02:00
|
|
|
|
btn.addCallback ("clicked", cb_exit, std::ref(app));
|
|
|
|
|
Exit.addCallback ("clicked", cb_exit, std::ref(app));
|
|
|
|
|
Quit.addCallback ("clicked", cb_exit, std::ref(app));
|
2020-10-14 23:43:34 +02:00
|
|
|
|
key_F1.addCallback ("activate", cb_tooltip, &dgl);
|
2019-09-28 03:13:06 +02:00
|
|
|
|
|
|
|
|
|
// Set dialog object as main widget
|
2020-04-13 12:40:11 +02:00
|
|
|
|
finalcut::FWidget::setMainWidget(&dgl);
|
2019-09-28 03:13:06 +02:00
|
|
|
|
|
|
|
|
|
// Show and start the application
|
|
|
|
|
dgl.show();
|
|
|
|
|
return app.exec();
|
|
|
|
|
}
|