2017-11-04 07:03:53 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* input-dialog.cpp - an input field example *
|
|
|
|
* *
|
|
|
|
* This file is part of the Final Cut widget toolkit *
|
|
|
|
* *
|
2018-09-20 23:59:01 +02:00
|
|
|
* Copyright 2015-2018 Markus Gans *
|
2017-11-04 07:03:53 +01:00
|
|
|
* *
|
|
|
|
* The 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 *
|
|
|
|
* the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* The Final Cut is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* 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>
|
|
|
|
|
2015-05-24 19:15:03 +02:00
|
|
|
|
|
|
|
// function prototypes
|
2018-09-20 23:59:01 +02:00
|
|
|
void cb_quit (finalcut::FWidget*, finalcut::FWidget::data_ptr);
|
|
|
|
void cb_publish (finalcut::FWidget*, finalcut::FWidget::data_ptr);
|
2015-05-24 19:15:03 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// callback functions
|
|
|
|
//----------------------------------------------------------------------
|
2018-09-20 23:59:01 +02:00
|
|
|
void cb_quit (finalcut::FWidget*, finalcut::FWidget::data_ptr data)
|
2015-05-24 19:15:03 +02:00
|
|
|
{
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FApplication* app = static_cast<finalcut::FApplication*>(data);
|
2015-05-24 19:15:03 +02:00
|
|
|
app->quit();
|
|
|
|
}
|
|
|
|
|
2018-09-20 23:59:01 +02:00
|
|
|
void cb_publish (finalcut::FWidget* widget, finalcut::FWidget::data_ptr data)
|
2015-05-24 19:15:03 +02:00
|
|
|
{
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FCheckBox* cbox1 = static_cast<finalcut::FCheckBox*>(widget);
|
|
|
|
finalcut::FCheckBox* cbox2 = static_cast<finalcut::FCheckBox*>(data);
|
2015-05-24 19:15:03 +02:00
|
|
|
|
|
|
|
if ( cbox1->isChecked() )
|
|
|
|
cbox2->setEnable();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cbox2->unsetChecked();
|
|
|
|
cbox2->setDisable();
|
|
|
|
}
|
|
|
|
cbox2->redraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// main part
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
int main (int argc, char* argv[])
|
|
|
|
{
|
|
|
|
// Create the application object
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FApplication app(argc, argv);
|
2015-05-24 19:15:03 +02:00
|
|
|
|
|
|
|
// Create a simple dialog box
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FDialog dgl(&app);
|
2015-05-24 19:15:03 +02:00
|
|
|
dgl.setText ("Data input");
|
2015-05-26 22:55:53 +02:00
|
|
|
dgl.setGeometry (4, 2, 37, 22);
|
2015-05-24 19:15:03 +02:00
|
|
|
dgl.setShadow();
|
|
|
|
|
|
|
|
// Create input fields
|
2018-10-03 22:23:55 +02:00
|
|
|
finalcut::FLineEdit name_field (&dgl);
|
|
|
|
finalcut::FLineEdit email_field (&dgl);
|
|
|
|
finalcut::FLineEdit org_field (&dgl);
|
|
|
|
finalcut::FLineEdit city_field (&dgl);
|
|
|
|
finalcut::FLineEdit st_field (&dgl);
|
|
|
|
finalcut::FLineEdit c_field (&dgl);
|
|
|
|
|
|
|
|
name_field.setLabelText (L"&Name");
|
|
|
|
email_field.setLabelText (L"&Email");
|
|
|
|
org_field.setLabelText (L"Or&ganization");
|
|
|
|
city_field.setLabelText (L"&City");
|
|
|
|
st_field.setLabelText (L"&State");
|
|
|
|
c_field.setLabelText (L"&Country");
|
|
|
|
|
|
|
|
name_field.setGeometry (15, 1, 19, 1);
|
|
|
|
email_field.setGeometry (15, 3, 19, 1);
|
|
|
|
org_field.setGeometry (15, 5, 19, 1);
|
|
|
|
city_field.setGeometry (15, 7, 19, 1);
|
|
|
|
st_field.setGeometry (15, 9, 19, 1);
|
|
|
|
c_field.setGeometry (15, 11, 4, 1);
|
2015-05-24 19:15:03 +02:00
|
|
|
|
|
|
|
// Create the button group
|
2018-10-03 22:23:55 +02:00
|
|
|
finalcut::FButtonGroup radioButtonGroup ("Sex", &dgl);
|
|
|
|
radioButtonGroup.setGeometry(2, 13, 13, 4);
|
2015-05-26 23:15:49 +02:00
|
|
|
|
2015-05-24 19:15:03 +02:00
|
|
|
// Create radio buttons
|
2018-10-03 22:23:55 +02:00
|
|
|
finalcut::FRadioButton male ("&Male", &radioButtonGroup);
|
|
|
|
finalcut::FRadioButton female ("&Female", &radioButtonGroup);
|
|
|
|
male.setGeometry (1, 1, 8, 1);
|
|
|
|
female.setGeometry (1, 2, 10, 1);
|
2015-05-26 23:15:49 +02:00
|
|
|
|
2015-05-24 19:15:03 +02:00
|
|
|
// Create another button group
|
2018-10-03 22:23:55 +02:00
|
|
|
finalcut::FButtonGroup checkButtonGroup ("&Data options", &dgl);
|
|
|
|
checkButtonGroup.setGeometry(16, 13, 19, 4);
|
2015-05-24 19:15:03 +02:00
|
|
|
|
|
|
|
// Create checkbox buttons
|
2018-10-03 22:23:55 +02:00
|
|
|
finalcut::FCheckBox check1 ("Save data", &checkButtonGroup);
|
|
|
|
finalcut::FCheckBox check2 ("Encrypt data", &checkButtonGroup);
|
|
|
|
check1.setGeometry (1, 1, 13, 1);
|
|
|
|
check2.setGeometry (1, 2, 16, 1);
|
|
|
|
check2.setDisable();
|
2015-05-24 19:15:03 +02:00
|
|
|
|
|
|
|
// Create a OK button
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FButton btn("&OK", &dgl);
|
2015-05-24 19:15:03 +02:00
|
|
|
btn.setGeometry (24, 18, 10, 1);
|
|
|
|
|
|
|
|
// 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",
|
2017-04-09 20:08:53 +02:00
|
|
|
F_FUNCTION_CALLBACK (&cb_publish),
|
2018-10-03 22:23:55 +02:00
|
|
|
&check2
|
2015-05-24 19:15:03 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
// Connect the button signal "clicked" with the callback function
|
|
|
|
btn.addCallback
|
|
|
|
(
|
|
|
|
"clicked",
|
2017-04-09 20:08:53 +02:00
|
|
|
F_FUNCTION_CALLBACK (&cb_quit),
|
2015-05-24 19:15:03 +02:00
|
|
|
&app
|
|
|
|
);
|
|
|
|
|
2017-09-19 06:18:03 +02:00
|
|
|
// Set dialog object as main widget
|
2015-05-24 19:15:03 +02:00
|
|
|
app.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();
|
|
|
|
}
|