2017-11-04 07:03:53 +01:00
|
|
|
/***********************************************************************
|
2019-09-28 03:13:06 +02:00
|
|
|
* input-dialog.cpp - An input field example *
|
2017-11-04 07:03:53 +01:00
|
|
|
* *
|
2020-07-08 21:32:47 +02:00
|
|
|
* This file is part of the FINAL CUT widget toolkit *
|
2017-11-04 07:03:53 +01:00
|
|
|
* *
|
2020-04-13 12:40:11 +02:00
|
|
|
* Copyright 2015-2020 Markus Gans *
|
2017-11-04 07:03:53 +01: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 *
|
2017-11-04 07:03:53 +01: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 *
|
2017-11-04 07:03:53 +01: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/>. *
|
|
|
|
***********************************************************************/
|
2015-05-24 19:15:03 +02:00
|
|
|
|
2017-10-31 00:41:59 +01:00
|
|
|
#include <final/final.h>
|
|
|
|
|
2019-01-21 03:42:18 +01:00
|
|
|
using finalcut::FPoint;
|
|
|
|
using finalcut::FSize;
|
2015-05-24 19:15:03 +02:00
|
|
|
|
|
|
|
// function prototypes
|
2020-08-12 22:28:02 +02:00
|
|
|
void cb_quit (const finalcut::FApplication&);
|
|
|
|
void cb_publish (const finalcut::FCheckBox&, finalcut::FCheckBox&);
|
2015-05-24 19:15:03 +02:00
|
|
|
|
2019-01-21 03:42:18 +01:00
|
|
|
|
2015-05-24 19:15:03 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// callback functions
|
|
|
|
//----------------------------------------------------------------------
|
2020-08-12 22:28:02 +02:00
|
|
|
void cb_quit (const finalcut::FApplication& app)
|
2015-05-24 19:15:03 +02:00
|
|
|
{
|
2020-08-11 23:04:46 +02:00
|
|
|
app.quit();
|
2015-05-24 19:15:03 +02:00
|
|
|
}
|
|
|
|
|
2020-08-11 23:04:46 +02:00
|
|
|
//----------------------------------------------------------------------
|
2020-08-12 22:28:02 +02:00
|
|
|
void cb_publish ( const finalcut::FCheckBox& cbox1
|
|
|
|
, finalcut::FCheckBox& cbox2 )
|
2015-05-24 19:15:03 +02:00
|
|
|
{
|
2020-08-11 23:04:46 +02:00
|
|
|
if ( cbox1.isChecked() )
|
|
|
|
cbox2.setEnable();
|
2015-05-24 19:15:03 +02:00
|
|
|
else
|
|
|
|
{
|
2020-08-11 23:04:46 +02:00
|
|
|
cbox2.unsetChecked();
|
|
|
|
cbox2.setDisable();
|
2015-05-24 19:15:03 +02:00
|
|
|
}
|
2019-01-27 13:44:13 +01:00
|
|
|
|
2020-08-11 23:04:46 +02:00
|
|
|
cbox2.redraw();
|
2015-05-24 19:15:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// 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};
|
2015-05-24 19:15:03 +02:00
|
|
|
|
|
|
|
// Create a simple dialog box
|
2020-05-02 00:07:35 +02:00
|
|
|
finalcut::FDialog dgl{&app};
|
2015-05-24 19:15:03 +02:00
|
|
|
dgl.setText ("Data input");
|
2020-05-02 00:07:35 +02:00
|
|
|
dgl.setGeometry (FPoint{4, 2}, FSize{37, 22});
|
2020-10-05 04:24:14 +02:00
|
|
|
dgl.setShadow(); // Instead of the transparent window shadow
|
2015-05-24 19:15:03 +02:00
|
|
|
|
|
|
|
// Create input fields
|
2020-05-02 00:07:35 +02:00
|
|
|
finalcut::FLineEdit name_field {&dgl};
|
|
|
|
finalcut::FLineEdit pw_field {&dgl};
|
|
|
|
finalcut::FLineEdit email_field {&dgl};
|
|
|
|
finalcut::FLineEdit city_field {&dgl};
|
|
|
|
finalcut::FLineEdit st_field {&dgl};
|
|
|
|
finalcut::FLineEdit c_field {&dgl};
|
2018-10-03 22:23:55 +02:00
|
|
|
|
2019-10-20 20:06:33 +02:00
|
|
|
// Set input type to password
|
|
|
|
pw_field.setInputType (finalcut::FLineEdit::password);
|
|
|
|
|
2018-10-03 22:23:55 +02:00
|
|
|
name_field.setLabelText (L"&Name");
|
2019-10-20 20:06:33 +02:00
|
|
|
pw_field.setLabelText (L"&Password");
|
2018-10-03 22:23:55 +02:00
|
|
|
email_field.setLabelText (L"&Email");
|
|
|
|
city_field.setLabelText (L"&City");
|
|
|
|
st_field.setLabelText (L"&State");
|
|
|
|
c_field.setLabelText (L"&Country");
|
|
|
|
|
2020-05-02 00:07:35 +02:00
|
|
|
name_field.setGeometry (FPoint{11, 1}, FSize{23, 1});
|
|
|
|
pw_field.setGeometry (FPoint{11, 3}, FSize{23, 1});
|
|
|
|
email_field.setGeometry (FPoint{11, 5}, FSize{23, 1});
|
|
|
|
city_field.setGeometry (FPoint{11, 7}, FSize{23, 1});
|
|
|
|
st_field.setGeometry (FPoint{11, 9}, FSize{23, 1});
|
|
|
|
c_field.setGeometry (FPoint{11, 11}, FSize{4, 1});
|
2015-05-24 19:15:03 +02:00
|
|
|
|
|
|
|
// Create the button group
|
2020-09-25 00:48:58 +02:00
|
|
|
finalcut::FButtonGroup radiobutton_group {"Sex", &dgl};
|
|
|
|
radiobutton_group.setGeometry(FPoint{2, 13}, FSize{13, 4});
|
2015-05-26 23:15:49 +02:00
|
|
|
|
2015-05-24 19:15:03 +02:00
|
|
|
// Create radio buttons
|
2020-09-25 00:48:58 +02:00
|
|
|
finalcut::FRadioButton male {"&Male", &radiobutton_group};
|
|
|
|
finalcut::FRadioButton female {"&Female", &radiobutton_group};
|
2020-05-02 00:07:35 +02:00
|
|
|
male.setGeometry (FPoint{1, 1}, FSize{8, 1});
|
|
|
|
female.setGeometry (FPoint{1, 2}, FSize{10, 1});
|
2015-05-26 23:15:49 +02:00
|
|
|
|
2015-05-24 19:15:03 +02:00
|
|
|
// Create another button group
|
2020-09-25 00:48:58 +02:00
|
|
|
finalcut::FButtonGroup checkbutton_group {"&Data options", &dgl};
|
|
|
|
checkbutton_group.setGeometry(FPoint{16, 13}, FSize{19, 4});
|
2015-05-24 19:15:03 +02:00
|
|
|
|
|
|
|
// Create checkbox buttons
|
2020-09-25 00:48:58 +02:00
|
|
|
finalcut::FCheckBox check1 {"Save data", &checkbutton_group};
|
|
|
|
finalcut::FCheckBox check2 {"Encrypt data", &checkbutton_group};
|
2020-05-02 00:07:35 +02:00
|
|
|
check1.setGeometry (FPoint{1, 1}, FSize{13, 1});
|
|
|
|
check2.setGeometry (FPoint{1, 2}, FSize{16, 1});
|
2018-10-03 22:23:55 +02:00
|
|
|
check2.setDisable();
|
2015-05-24 19:15:03 +02:00
|
|
|
|
|
|
|
// Create a OK button
|
2020-05-02 00:07:35 +02:00
|
|
|
finalcut::FButton btn {"&OK", &dgl};
|
|
|
|
btn.setGeometry (FPoint{24, 18}, FSize{10, 1});
|
2015-05-24 19:15:03 +02:00
|
|
|
|
|
|
|
// Connect checkbox signal "clicked" with a callback function
|
2018-10-03 22:23:55 +02:00
|
|
|
check1.addCallback
|
2015-05-24 19:15:03 +02:00
|
|
|
(
|
|
|
|
"clicked",
|
2019-10-05 23:20:07 +02:00
|
|
|
&cb_publish,
|
2020-08-11 23:04:46 +02:00
|
|
|
std::ref(check1),
|
|
|
|
std::ref(check2)
|
2015-05-24 19:15:03 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
// Connect the button signal "clicked" with the callback function
|
|
|
|
btn.addCallback
|
|
|
|
(
|
|
|
|
"clicked",
|
2019-10-05 23:20:07 +02:00
|
|
|
&cb_quit,
|
2020-08-11 23:04:46 +02:00
|
|
|
std::ref(app)
|
2015-05-24 19:15:03 +02:00
|
|
|
);
|
|
|
|
|
2017-09-19 06:18:03 +02:00
|
|
|
// Set dialog object as main widget
|
2020-04-13 12:40:11 +02:00
|
|
|
finalcut::FWidget::setMainWidget(&dgl);
|
2017-09-19 06:18:03 +02:00
|
|
|
|
|
|
|
// Show and start the application
|
2015-05-24 19:15:03 +02:00
|
|
|
dgl.show();
|
|
|
|
return app.exec();
|
|
|
|
}
|