2015-10-10 03:14:14 +02:00
|
|
|
// File: ui.cpp
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <fstream>
|
|
|
|
|
|
|
|
#include "final.h"
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class ProgressDialog
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma pack(push)
|
|
|
|
#pragma pack(1)
|
|
|
|
|
|
|
|
class ProgressDialog : public FDialog
|
|
|
|
{
|
2015-09-24 19:01:27 +02:00
|
|
|
private:
|
|
|
|
ProgressDialog (const ProgressDialog&); // Disabled copy constructor
|
|
|
|
ProgressDialog& operator = (const ProgressDialog&); // and operator '='
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
public:
|
|
|
|
FButton* reset;
|
|
|
|
FButton* more;
|
|
|
|
FButton* quit;
|
|
|
|
FProgressbar* progressBar;
|
|
|
|
|
|
|
|
public:
|
2015-10-10 03:14:14 +02:00
|
|
|
explicit ProgressDialog (FWidget* = 0); // constructor
|
2015-05-23 13:35:12 +02:00
|
|
|
~ProgressDialog(); // destructor
|
|
|
|
|
|
|
|
void onShow (FShowEvent*);
|
2015-07-02 01:00:30 +02:00
|
|
|
void onTimer (FTimerEvent*);
|
2015-05-23 13:35:12 +02:00
|
|
|
void cb_reset_bar (FWidget*, void*);
|
|
|
|
void cb_more_bar (FWidget*, void*);
|
|
|
|
void cb_exit_bar (FWidget*, void*);
|
|
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2015-09-24 19:01:27 +02:00
|
|
|
ProgressDialog::ProgressDialog (FWidget* parent)
|
|
|
|
: FDialog(parent)
|
|
|
|
, reset()
|
|
|
|
, more()
|
|
|
|
, quit()
|
|
|
|
, progressBar()
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
setGeometry (int((this->parentWidget()->getWidth()-40)/2), 7, 40, 10);
|
|
|
|
setText("Progress bar");
|
|
|
|
setTransparentShadow();
|
|
|
|
//setModal();
|
|
|
|
|
|
|
|
reset = new FButton(this);
|
|
|
|
reset->setText("&Reset");
|
|
|
|
reset->setGeometry(2, 6, 8, 1, false);
|
|
|
|
reset->setShadow();
|
|
|
|
reset->setDisable();
|
|
|
|
|
|
|
|
more = new FButton(this);
|
|
|
|
more->setText("&More");
|
|
|
|
more->setGeometry(15, 6, 8, 1, false);
|
|
|
|
more->setShadow();
|
|
|
|
more->setDisable();
|
|
|
|
|
|
|
|
quit = new FButton(this);
|
|
|
|
quit->setText("E&xit");
|
|
|
|
quit->setGeometry(28, 6, 8, 1, false);
|
|
|
|
quit->setShadow();
|
|
|
|
quit->setDisable();
|
|
|
|
|
|
|
|
progressBar = new FProgressbar(this);
|
|
|
|
progressBar->setGeometry(2, 3, 34, 1, false);
|
|
|
|
//progressBar->setPercentage(78);
|
|
|
|
progressBar->setShadow();
|
|
|
|
|
|
|
|
reset->addCallback
|
|
|
|
(
|
|
|
|
"clicked",
|
2015-09-24 19:01:27 +02:00
|
|
|
_METHOD_CALLBACK (this, &ProgressDialog::cb_reset_bar)
|
2015-05-23 13:35:12 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
more->addCallback
|
|
|
|
(
|
|
|
|
"clicked",
|
2015-09-24 19:01:27 +02:00
|
|
|
_METHOD_CALLBACK (this, &ProgressDialog::cb_more_bar)
|
2015-05-23 13:35:12 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
quit->addCallback
|
|
|
|
(
|
|
|
|
"clicked",
|
2015-09-24 19:01:27 +02:00
|
|
|
_METHOD_CALLBACK (this, &ProgressDialog::cb_exit_bar)
|
2015-05-23 13:35:12 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
ProgressDialog::~ProgressDialog()
|
|
|
|
{
|
2015-07-02 01:00:30 +02:00
|
|
|
delAllTimer();
|
2015-05-23 13:35:12 +02:00
|
|
|
delCallback(quit);
|
|
|
|
delCallback(more);
|
|
|
|
delCallback(reset);
|
|
|
|
delete(progressBar);
|
|
|
|
delete(quit);
|
|
|
|
delete(more);
|
|
|
|
delete(reset);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void ProgressDialog::onShow (FShowEvent*)
|
|
|
|
{
|
2015-07-02 01:00:30 +02:00
|
|
|
addTimer(15);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void ProgressDialog::onTimer (FTimerEvent*)
|
|
|
|
{
|
|
|
|
int p = progressBar->getPercentage();
|
2015-07-02 21:21:18 +02:00
|
|
|
progressBar->setPercentage(++p);
|
|
|
|
flush_out();
|
2015-07-02 01:00:30 +02:00
|
|
|
|
2015-07-02 21:21:18 +02:00
|
|
|
if ( p == 100 )
|
2015-07-02 01:00:30 +02:00
|
|
|
{
|
|
|
|
delAllTimer();
|
2015-07-02 21:21:18 +02:00
|
|
|
activateWindow();
|
|
|
|
raiseWindow();
|
2015-07-02 01:00:30 +02:00
|
|
|
reset->setEnable();
|
2015-07-02 21:21:18 +02:00
|
|
|
reset->setFocus();
|
2015-07-02 01:00:30 +02:00
|
|
|
more->setEnable();
|
|
|
|
quit->setEnable();
|
2015-07-02 21:21:18 +02:00
|
|
|
redraw();
|
2015-07-02 01:00:30 +02:00
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void ProgressDialog::cb_reset_bar (FWidget*, void*)
|
|
|
|
{
|
|
|
|
progressBar->reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void ProgressDialog::cb_more_bar (FWidget*, void*)
|
|
|
|
{
|
|
|
|
int p = progressBar->getPercentage();
|
|
|
|
progressBar->setPercentage(++p);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void ProgressDialog::cb_exit_bar (FWidget*, void*)
|
|
|
|
{
|
2015-09-24 19:01:27 +02:00
|
|
|
close();
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class MyDialog
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma pack(push)
|
|
|
|
#pragma pack(1)
|
|
|
|
|
|
|
|
class MyDialog : public FDialog
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
FListBox* myList;
|
2015-09-24 19:01:27 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
MyDialog (const MyDialog&); // Disabled copy constructor
|
|
|
|
MyDialog& operator = (const MyDialog&); // and operator '='
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
public:
|
2015-10-10 03:14:14 +02:00
|
|
|
explicit MyDialog (FWidget* = 0); // constructor
|
2015-05-23 13:35:12 +02:00
|
|
|
~MyDialog(); // destructor
|
|
|
|
void onClose (FCloseEvent*);
|
|
|
|
void cb_noFunctionMsg (FWidget*, void*);
|
|
|
|
void cb_about (FWidget*, void*);
|
2015-10-29 21:10:50 +01:00
|
|
|
void cb_terminfo (FWidget*, void*);
|
|
|
|
void cb_drives (FWidget*, void*);
|
2015-05-23 13:35:12 +02:00
|
|
|
void cb_input2buttonText (FWidget*, void*);
|
|
|
|
void cb_setTitlebar (FWidget*, void*);
|
|
|
|
void cb_ProgressBar (FWidget*, void*);
|
|
|
|
void cb_updateNumber (FWidget*, void*);
|
|
|
|
void cb_activateButton (FWidget*, void*);
|
|
|
|
void cb_view (FWidget*, void*);
|
|
|
|
void cb_setInput (FWidget*, void*);
|
|
|
|
void cb_exitApp (FWidget*, void*);
|
|
|
|
protected:
|
|
|
|
void adjustSize();
|
|
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2015-09-24 19:01:27 +02:00
|
|
|
MyDialog::MyDialog (FWidget* parent)
|
|
|
|
: FDialog(parent)
|
|
|
|
, myList()
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2015-11-01 22:45:23 +01:00
|
|
|
// menu bar
|
2015-10-10 03:14:14 +02:00
|
|
|
FMenuBar* Menubar = new FMenuBar(this);
|
2015-09-24 19:01:27 +02:00
|
|
|
|
2015-11-01 22:45:23 +01:00
|
|
|
// menu bar items
|
2015-10-10 03:14:14 +02:00
|
|
|
FMenu* File = new FMenu("&File", Menubar);
|
2015-10-29 21:10:50 +01:00
|
|
|
File->setStatusbarMessage("File management commands");
|
2015-10-10 03:14:14 +02:00
|
|
|
FMenu* Edit = new FMenu("&Edit", Menubar);
|
2015-11-01 22:45:23 +01:00
|
|
|
Edit->setStatusbarMessage("Cut-and-paste editing commands");
|
2015-10-10 03:14:14 +02:00
|
|
|
FMenu* View = new FMenu("&View", Menubar);
|
2015-11-01 22:45:23 +01:00
|
|
|
View->setStatusbarMessage("Show internal informations");
|
2015-10-29 21:10:50 +01:00
|
|
|
FMenuItem* Options = new FMenuItem("&Options", Menubar);
|
2015-11-01 22:45:23 +01:00
|
|
|
Options->setStatusbarMessage("Set program defaults");
|
2015-10-29 21:10:50 +01:00
|
|
|
Options->setDisable();
|
2015-10-10 03:14:14 +02:00
|
|
|
FMenuItem* Help = new FMenuItem("&Help", Menubar);
|
2015-11-01 22:45:23 +01:00
|
|
|
Help->setStatusbarMessage("Show version and copyright information");
|
2015-09-24 19:01:27 +02:00
|
|
|
|
2015-11-01 22:45:23 +01:00
|
|
|
// "File" menu items
|
2015-10-10 03:14:14 +02:00
|
|
|
FMenuItem* Open = new FMenuItem("&Open...", File);
|
2015-10-29 21:10:50 +01:00
|
|
|
Open->setStatusbarMessage("Locate and open a text file");
|
2015-11-01 22:45:23 +01:00
|
|
|
FMenuItem* Line1 = new FMenuItem(File);
|
|
|
|
Line1->setSeparator();
|
2015-10-10 03:14:14 +02:00
|
|
|
FMenuItem* Quit = new FMenuItem("&Quit", File);
|
2015-10-29 21:10:50 +01:00
|
|
|
Quit->setStatusbarMessage("Exit the program");
|
2015-10-10 03:14:14 +02:00
|
|
|
|
2015-11-01 22:45:23 +01:00
|
|
|
// "Edit" menu items
|
|
|
|
FMenuItem* Undo = new FMenuItem("Undo", Edit);
|
|
|
|
Undo->setDisable();
|
|
|
|
FMenuItem* Redo = new FMenuItem("Redo", Edit);
|
|
|
|
Redo->setDisable();
|
|
|
|
FMenuItem* Line2 = new FMenuItem(Edit);
|
|
|
|
Line2->setSeparator();
|
2015-10-10 03:14:14 +02:00
|
|
|
FMenuItem* Cut = new FMenuItem("Cu&t", Edit);
|
2015-11-01 22:45:23 +01:00
|
|
|
Cut->setStatusbarMessage("Remove the input text and put it in the clipboard");
|
2015-10-10 03:14:14 +02:00
|
|
|
FMenuItem* Copy = new FMenuItem("&Copy", Edit);
|
2015-11-01 22:45:23 +01:00
|
|
|
Copy->setStatusbarMessage("Copy the input text into the clipboad");
|
2015-10-10 03:14:14 +02:00
|
|
|
FMenuItem* Paste = new FMenuItem("&Paste", Edit);
|
2015-11-01 22:45:23 +01:00
|
|
|
Paste->setStatusbarMessage("Insert text form clipboard");
|
|
|
|
FMenuItem* Clear = new FMenuItem("C&lear", Edit);
|
|
|
|
Clear->setStatusbarMessage("Delete input text");
|
2015-10-10 03:14:14 +02:00
|
|
|
|
2015-11-01 22:45:23 +01:00
|
|
|
// "View" menu items
|
2015-10-10 03:14:14 +02:00
|
|
|
FMenuItem* Env = new FMenuItem("&Terminal info...", View);
|
2015-11-01 22:45:23 +01:00
|
|
|
Env->setStatusbarMessage("Informations about this terminal");
|
2015-10-10 03:14:14 +02:00
|
|
|
FMenuItem* Drive = new FMenuItem("&Drive symbols...", View);
|
2015-11-01 22:45:23 +01:00
|
|
|
Drive->setStatusbarMessage("Show drive symbols");
|
2015-10-10 03:14:14 +02:00
|
|
|
|
2015-11-01 22:45:23 +01:00
|
|
|
// Menu function callbacks
|
2015-10-10 03:14:14 +02:00
|
|
|
Open->addCallback
|
|
|
|
(
|
|
|
|
"clicked",
|
|
|
|
_METHOD_CALLBACK (this, &MyDialog::cb_view)
|
|
|
|
);
|
|
|
|
Quit->addCallback
|
2015-09-24 19:01:27 +02:00
|
|
|
(
|
|
|
|
"clicked",
|
|
|
|
_METHOD_CALLBACK (this, &MyDialog::cb_exitApp)
|
|
|
|
);
|
2015-10-10 03:14:14 +02:00
|
|
|
Cut->addCallback
|
|
|
|
(
|
|
|
|
"clicked",
|
|
|
|
_METHOD_CALLBACK (this, &MyDialog::cb_noFunctionMsg)
|
|
|
|
);
|
|
|
|
Copy->addCallback
|
|
|
|
(
|
|
|
|
"clicked",
|
|
|
|
_METHOD_CALLBACK (this, &MyDialog::cb_noFunctionMsg)
|
|
|
|
);
|
|
|
|
Paste->addCallback
|
|
|
|
(
|
|
|
|
"clicked",
|
|
|
|
_METHOD_CALLBACK (this, &MyDialog::cb_noFunctionMsg)
|
|
|
|
);
|
2015-11-01 22:45:23 +01:00
|
|
|
Clear->addCallback
|
|
|
|
(
|
|
|
|
"clicked",
|
|
|
|
_METHOD_CALLBACK (this, &MyDialog::cb_noFunctionMsg)
|
|
|
|
);
|
2015-10-10 03:14:14 +02:00
|
|
|
Env->addCallback
|
|
|
|
(
|
|
|
|
"clicked",
|
2015-10-29 21:10:50 +01:00
|
|
|
_METHOD_CALLBACK (this, &MyDialog::cb_terminfo)
|
2015-10-10 03:14:14 +02:00
|
|
|
);
|
|
|
|
Drive->addCallback
|
|
|
|
(
|
|
|
|
"clicked",
|
2015-10-29 21:10:50 +01:00
|
|
|
_METHOD_CALLBACK (this, &MyDialog::cb_drives)
|
2015-10-10 03:14:14 +02:00
|
|
|
);
|
|
|
|
Help->addCallback
|
|
|
|
(
|
|
|
|
"clicked",
|
|
|
|
_METHOD_CALLBACK (this, &MyDialog::cb_about)
|
|
|
|
);
|
|
|
|
|
2015-11-01 22:45:23 +01:00
|
|
|
// Buttons
|
2015-05-23 13:35:12 +02:00
|
|
|
FButton* MyButton1 = new FButton(this);
|
|
|
|
MyButton1->setGeometry(3, 3, 5, 1);
|
|
|
|
MyButton1->setText(L"&SIN");
|
|
|
|
MyButton1->setStatusbarMessage("Sine function");
|
|
|
|
MyButton1->setNoUnderline();
|
|
|
|
MyButton1->setFlat();
|
2015-06-21 23:27:10 +02:00
|
|
|
MyButton1->setDoubleFlatLine(fc::bottom);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
FButton* MyButton2 = new FButton(this);
|
|
|
|
MyButton2->setGeometry(3, 5, 5, 1);
|
|
|
|
MyButton2->setText(L"&COS");
|
|
|
|
MyButton2->setStatusbarMessage("Cosine function");
|
|
|
|
MyButton2->setNoUnderline();
|
|
|
|
MyButton2->setFlat();
|
2015-06-21 23:27:10 +02:00
|
|
|
MyButton2->setDoubleFlatLine(fc::top);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
FButton* MyButton3 = new FButton(this);
|
|
|
|
MyButton3->setGeometry(10, 3, 5, 3);
|
|
|
|
MyButton3->setText(L"&=");
|
|
|
|
MyButton3->setStatusbarMessage("Equal");
|
|
|
|
MyButton3->setNoUnderline();
|
|
|
|
MyButton3->setFlat();
|
|
|
|
|
2015-11-01 22:45:23 +01:00
|
|
|
// Radio buttons in a group
|
2015-05-23 13:35:12 +02:00
|
|
|
FButtonGroup* radioButtonGroup = new FButtonGroup("Button", this);
|
|
|
|
radioButtonGroup->setGeometry(3, 8, 14, 4);
|
|
|
|
//radioButtonGroup->unsetBorder();
|
|
|
|
|
2015-10-29 21:10:50 +01:00
|
|
|
FRadioButton* radio1 = new FRadioButton("E&nable", radioButtonGroup);
|
2015-05-23 13:35:12 +02:00
|
|
|
radio1->setGeometry(1, 1, 7, 1);
|
|
|
|
radio1->setStatusbarMessage("Enable button Test");
|
|
|
|
|
|
|
|
FRadioButton* radio2 = new FRadioButton(radioButtonGroup);
|
|
|
|
radio2->setGeometry(1, 2, 7, 1);
|
|
|
|
radio2->setText("&Disable");
|
|
|
|
radio2->setStatusbarMessage("Disable button Test");
|
|
|
|
radio2->setChecked();
|
|
|
|
//radio2->setDisable();
|
|
|
|
|
2015-11-01 22:45:23 +01:00
|
|
|
// Checkboxes in a group
|
2015-05-23 13:35:12 +02:00
|
|
|
FButtonGroup* checkButtonGroup = new FButtonGroup("Options", this);
|
|
|
|
checkButtonGroup->setGeometry(3, 12, 14, 4);
|
|
|
|
|
2015-10-29 21:10:50 +01:00
|
|
|
FCheckBox* check1 = new FCheckBox("&Bitmode", checkButtonGroup);
|
2015-05-23 13:35:12 +02:00
|
|
|
check1->setGeometry(1, 1, 7, 1);
|
|
|
|
check1->setNoUnderline();
|
|
|
|
|
|
|
|
FCheckBox* check2 = new FCheckBox("&8-Bit", checkButtonGroup);
|
|
|
|
check2->setGeometry(1, 2, 7, 1);
|
|
|
|
check2->setChecked();
|
|
|
|
check2->setNoUnderline();
|
|
|
|
|
2015-11-01 22:45:23 +01:00
|
|
|
// A text input field
|
2015-05-23 13:35:12 +02:00
|
|
|
FLineEdit* MyLineEdit = new FLineEdit(this);
|
2015-10-29 21:10:50 +01:00
|
|
|
MyLineEdit->setGeometry(22, 1, 10, 1);
|
2015-05-23 13:35:12 +02:00
|
|
|
MyLineEdit->setText( FString("EnTry").toLower());
|
|
|
|
MyLineEdit->setLabelText(L"&Input:");
|
|
|
|
MyLineEdit->setStatusbarMessage("Press Enter to set the title");
|
|
|
|
MyLineEdit->setShadow();
|
|
|
|
|
2015-11-01 22:45:23 +01:00
|
|
|
// Buttons
|
2015-05-23 13:35:12 +02:00
|
|
|
FButton* MyButton4 = new FButton(this);
|
2015-10-29 21:10:50 +01:00
|
|
|
MyButton4->setGeometry(20, 8, 12, 1);
|
|
|
|
MyButton4->setText(L"&Get input");
|
|
|
|
MyButton4->setStatusbarMessage("Take text from input field");
|
2015-05-23 13:35:12 +02:00
|
|
|
MyButton4->setShadow();
|
2015-10-29 21:10:50 +01:00
|
|
|
MyButton4->setFocus();
|
2015-05-26 23:15:49 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
FButton* MyButton5 = new FButton(this);
|
2015-10-29 21:10:50 +01:00
|
|
|
MyButton5->setGeometry(20, 11, 12, 1);
|
|
|
|
MyButton5->setText(L"&Test");
|
|
|
|
MyButton5->setStatusbarMessage("Progressbar testing dialog");
|
2015-05-23 13:35:12 +02:00
|
|
|
MyButton5->setShadow();
|
2015-10-29 21:10:50 +01:00
|
|
|
MyButton5->setDisable();
|
2015-05-26 23:15:49 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
FButton* MyButton6 = new FButton(this);
|
2015-10-29 21:10:50 +01:00
|
|
|
MyButton6->setGeometry(20, 14, 12, 1);
|
|
|
|
MyButton6->setText(L"&Quit");
|
|
|
|
MyButton6->setStatusbarMessage("Exit the program");
|
2015-05-23 13:35:12 +02:00
|
|
|
MyButton6->setShadow();
|
2015-10-29 21:10:50 +01:00
|
|
|
MyButton6->addAccelerator('x');
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2015-11-01 22:45:23 +01:00
|
|
|
// A multiple selection listbox
|
2015-05-23 13:35:12 +02:00
|
|
|
myList = new FListBox(this);
|
|
|
|
myList->setGeometry(38, 1, 14, 17);
|
|
|
|
myList->setText("Items");
|
|
|
|
myList->setStatusbarMessage("99 items in a list");
|
|
|
|
myList->setMultiSelection();
|
|
|
|
for (int z=1; z < 100; z++)
|
|
|
|
myList->insert( FString().setNumber(z) + L" placeholder" );
|
|
|
|
|
2015-11-01 22:45:23 +01:00
|
|
|
// Text labels
|
2015-05-23 13:35:12 +02:00
|
|
|
FLabel* headline = new FLabel(this);
|
2015-10-29 21:10:50 +01:00
|
|
|
headline->setGeometry(21, 3, 10, 1);
|
2015-05-23 13:35:12 +02:00
|
|
|
headline->setText(L"List items");
|
|
|
|
headline->setEmphasis();
|
|
|
|
headline->setAlignment(fc::alignCenter);
|
|
|
|
|
|
|
|
FLabel* tagged = new FLabel(L"Tagged:", this);
|
2015-10-29 21:10:50 +01:00
|
|
|
tagged->setGeometry(21, 4, 7, 1);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
FLabel* tagged_count = new FLabel(this);
|
2015-10-29 21:10:50 +01:00
|
|
|
tagged_count->setGeometry(29, 4, 5, 1);
|
2015-05-23 13:35:12 +02:00
|
|
|
tagged_count->setNumber(0);
|
|
|
|
|
2015-07-18 21:31:26 +02:00
|
|
|
FLabel* sum = new FLabel(L"Sum:", this);
|
2015-10-29 21:10:50 +01:00
|
|
|
sum->setGeometry(21, 5, 7, 3);
|
2015-05-23 13:35:12 +02:00
|
|
|
sum->setAlignment(fc::alignRight);
|
|
|
|
|
|
|
|
FLabel* sum_count = new FLabel(this);
|
2015-10-29 21:10:50 +01:00
|
|
|
sum_count->setGeometry(29, 5, 5, 3);
|
2015-05-23 13:35:12 +02:00
|
|
|
sum_count->setNumber(myList->count());
|
|
|
|
|
2015-11-01 22:45:23 +01:00
|
|
|
// Statusbar at the bottom
|
2015-05-23 13:35:12 +02:00
|
|
|
FStatusBar* statusbar = new FStatusBar(this);
|
2015-11-01 22:45:23 +01:00
|
|
|
// Statusbar keys
|
2015-05-23 13:35:12 +02:00
|
|
|
FStatusKey* key_F1 = new FStatusKey(fc::Fkey_f1, "About", statusbar);
|
|
|
|
FStatusKey* key_F2 = new FStatusKey(fc::Fkey_f2, "View", statusbar);
|
|
|
|
FStatusKey* key_F3 = new FStatusKey(fc::Fkey_f3, "Quit", statusbar);
|
|
|
|
|
2015-11-01 22:45:23 +01:00
|
|
|
// Add some function callbacks
|
2015-05-23 13:35:12 +02:00
|
|
|
MyButton1->addCallback
|
|
|
|
(
|
|
|
|
"clicked",
|
2015-09-24 19:01:27 +02:00
|
|
|
_METHOD_CALLBACK (this, &MyDialog::cb_noFunctionMsg)
|
2015-05-23 13:35:12 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
MyButton2->addCallback
|
|
|
|
(
|
|
|
|
"clicked",
|
2015-09-24 19:01:27 +02:00
|
|
|
_METHOD_CALLBACK (this, &MyDialog::cb_noFunctionMsg)
|
2015-05-23 13:35:12 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
MyButton3->addCallback
|
|
|
|
(
|
|
|
|
"clicked",
|
2015-09-24 19:01:27 +02:00
|
|
|
_METHOD_CALLBACK (this, &MyDialog::cb_noFunctionMsg)
|
2015-05-23 13:35:12 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
MyButton4->addCallback
|
|
|
|
(
|
|
|
|
"clicked",
|
2015-10-29 21:10:50 +01:00
|
|
|
_METHOD_CALLBACK (this, &MyDialog::cb_input2buttonText),
|
|
|
|
dynamic_cast<FWidget::data_ptr>(MyLineEdit)
|
2015-05-23 13:35:12 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
MyButton5->addCallback
|
|
|
|
(
|
|
|
|
"clicked",
|
2015-10-29 21:10:50 +01:00
|
|
|
_METHOD_CALLBACK (this, &MyDialog::cb_ProgressBar)
|
2015-05-23 13:35:12 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
MyButton6->addCallback
|
|
|
|
(
|
|
|
|
"clicked",
|
2015-09-24 19:01:27 +02:00
|
|
|
_METHOD_CALLBACK (this, &MyDialog::cb_exitApp)
|
2015-05-23 13:35:12 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
MyLineEdit->addCallback
|
|
|
|
(
|
|
|
|
"activate", // e.g. on <Enter>
|
2015-09-24 19:01:27 +02:00
|
|
|
_METHOD_CALLBACK (this, &MyDialog::cb_setTitlebar)
|
2015-05-23 13:35:12 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
radio1->addCallback
|
|
|
|
(
|
|
|
|
"toggled",
|
2015-09-24 19:01:27 +02:00
|
|
|
_METHOD_CALLBACK (this, &MyDialog::cb_activateButton),
|
2015-10-29 21:10:50 +01:00
|
|
|
dynamic_cast<FWidget::data_ptr>(MyButton5)
|
2015-05-23 13:35:12 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
myList->addCallback
|
|
|
|
(
|
|
|
|
"clicked",
|
2015-09-24 19:01:27 +02:00
|
|
|
_METHOD_CALLBACK (this, &MyDialog::cb_setInput),
|
2015-05-23 13:35:12 +02:00
|
|
|
dynamic_cast<FWidget::data_ptr>(MyLineEdit)
|
|
|
|
);
|
|
|
|
|
|
|
|
myList->addCallback
|
|
|
|
(
|
|
|
|
"row-selected",
|
2015-09-24 19:01:27 +02:00
|
|
|
_METHOD_CALLBACK (this, &MyDialog::cb_updateNumber),
|
2015-05-23 13:35:12 +02:00
|
|
|
dynamic_cast<FWidget::data_ptr>(tagged_count)
|
|
|
|
);
|
|
|
|
|
|
|
|
key_F1->addCallback
|
|
|
|
(
|
|
|
|
"activate",
|
2015-09-24 19:01:27 +02:00
|
|
|
_METHOD_CALLBACK (this, &MyDialog::cb_about)
|
2015-05-23 13:35:12 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
key_F2->addCallback
|
|
|
|
(
|
|
|
|
"activate",
|
2015-09-24 19:01:27 +02:00
|
|
|
_METHOD_CALLBACK (this, &MyDialog::cb_view)
|
2015-05-23 13:35:12 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
key_F3->addCallback
|
|
|
|
(
|
|
|
|
"activate",
|
2015-10-10 03:14:14 +02:00
|
|
|
_METHOD_CALLBACK (this, &MyDialog::cb_exitApp)
|
2015-05-23 13:35:12 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
MyDialog::~MyDialog()
|
2015-09-24 19:01:27 +02:00
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2015-09-24 19:01:27 +02:00
|
|
|
void MyDialog::onClose (FCloseEvent* ev)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2015-09-24 19:01:27 +02:00
|
|
|
int ret = FMessageBox::info ( this, "Quit"
|
|
|
|
, "Do you really want\n"
|
|
|
|
"to quit the program ?"
|
|
|
|
, FMessageBox::Yes
|
|
|
|
, FMessageBox::No );
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( ret == FMessageBox::Yes )
|
2015-09-24 19:01:27 +02:00
|
|
|
ev->accept();
|
2015-05-23 13:35:12 +02:00
|
|
|
else
|
2015-09-24 19:01:27 +02:00
|
|
|
ev->ignore();
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void MyDialog::cb_noFunctionMsg (FWidget* widget, void*)
|
|
|
|
{
|
|
|
|
FButton* button = static_cast<FButton*>(widget);
|
|
|
|
FString text = button->getText();
|
|
|
|
text = text.replace('&', "");
|
|
|
|
FMessageBox::error (this, "The \"" + text + "\" button has\n"
|
|
|
|
"no function");
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2015-10-10 03:14:14 +02:00
|
|
|
void MyDialog::cb_about (FWidget*, void*)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2015-09-24 19:01:27 +02:00
|
|
|
const char ver[] = F_VERSION;
|
2015-05-23 13:35:12 +02:00
|
|
|
FString line(2, wchar_t(fc::BoxDrawingsHorizontal));
|
|
|
|
|
2015-09-24 19:01:27 +02:00
|
|
|
FMessageBox info ( "About"
|
|
|
|
, line + L" The Final Cut " + line + "\n\n"
|
|
|
|
L"Version " + ver + "\n\n"
|
|
|
|
L"(c) 2015 by Markus Gans"
|
|
|
|
, FMessageBox::Ok, 0, 0, this );
|
2015-05-23 13:35:12 +02:00
|
|
|
info.setCenterText();
|
|
|
|
info.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2015-10-29 21:10:50 +01:00
|
|
|
void MyDialog::cb_terminfo (FWidget*, void*)
|
|
|
|
{
|
|
|
|
FMessageBox info1 ( "Environment"
|
|
|
|
, " Type: " + FString(getTermType()) + "\n"
|
|
|
|
" Name: " + FString(getTermName()) + "\n"
|
|
|
|
" Mode: " + FString(getEncoding()) + "\n"
|
|
|
|
"Colors: " + FString().setNumber(getMaxColor())
|
|
|
|
, FMessageBox::Ok, 0, 0, this );
|
|
|
|
info1.setHeadline("Terminal:");
|
|
|
|
info1.exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void MyDialog::cb_drives (FWidget*, void*)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2015-09-24 19:01:27 +02:00
|
|
|
FMessageBox info2 ( "Drive symbols"
|
|
|
|
, "Generic: \n\n"
|
2015-05-23 13:35:12 +02:00
|
|
|
"Network: \n\n"
|
2015-09-24 19:01:27 +02:00
|
|
|
" CD:"
|
|
|
|
, FMessageBox::Ok, 0, 0, this );
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( isNewFont() )
|
|
|
|
{
|
|
|
|
FLabel drive (NF_Drive, &info2);
|
|
|
|
drive.setGeometry (11, 2, 4, 1);
|
|
|
|
FLabel net (NF_Net_Drive, &info2);
|
|
|
|
net.setGeometry (11, 4, 4, 1);
|
|
|
|
FLabel cd (NF_CD_ROM, &info2);
|
|
|
|
cd.setGeometry (11, 6, 4, 1);
|
|
|
|
info2.exec();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FLabel drive (" - ", &info2);
|
|
|
|
drive.setGeometry (11, 2, 4, 1);
|
|
|
|
FLabel net (" N ", &info2);
|
|
|
|
net.setGeometry (11, 4, 4, 1);
|
|
|
|
FLabel cd (" CD ", &info2);
|
|
|
|
cd.setGeometry (11, 6, 4, 1);
|
|
|
|
if ( isMonochron() )
|
|
|
|
{
|
|
|
|
net.setReverseMode();
|
|
|
|
drive.setReverseMode();
|
|
|
|
cd.setReverseMode();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
net.setForegroundColor (fc::White);
|
|
|
|
net.setBackgroundColor (fc::DarkGray);
|
|
|
|
drive.setForegroundColor (fc::White);
|
|
|
|
drive.setBackgroundColor (fc::DarkGray);
|
|
|
|
cd.setForegroundColor (fc::White);
|
|
|
|
cd.setBackgroundColor (fc::DarkGray);
|
|
|
|
}
|
|
|
|
info2.exec();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void MyDialog::cb_input2buttonText (FWidget* widget, void* data_ptr)
|
|
|
|
{
|
|
|
|
FButton* button = static_cast<FButton*>(widget);
|
|
|
|
FLineEdit* lineedit = static_cast<FLineEdit*>(data_ptr);
|
|
|
|
button->setText( lineedit->getText() );
|
|
|
|
button->redraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void MyDialog::cb_setTitlebar (FWidget* widget, void*)
|
|
|
|
{
|
|
|
|
FLineEdit* lineedit = static_cast<FLineEdit*>(widget);
|
|
|
|
lineedit->setXTermTitle(lineedit->getText());
|
2015-09-24 19:01:27 +02:00
|
|
|
setText(lineedit->getText());
|
|
|
|
redraw();
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void MyDialog::cb_ProgressBar (FWidget*, void*)
|
|
|
|
{
|
|
|
|
ProgressDialog* p_dgl = new ProgressDialog(this);
|
|
|
|
p_dgl->show();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void MyDialog::cb_updateNumber (FWidget* widget, void* data_ptr)
|
|
|
|
{
|
|
|
|
FListBox* list = static_cast<FListBox*>(widget);
|
|
|
|
FLabel* num = static_cast<FLabel*>(data_ptr);
|
|
|
|
int select_num = 0;
|
|
|
|
uInt end = list->count();
|
|
|
|
for (uInt n=1; n <= end; n++)
|
|
|
|
if ( list->isSelected(int(n)) )
|
|
|
|
select_num++;
|
|
|
|
num->setNumber(select_num);
|
|
|
|
num->redraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void MyDialog::cb_activateButton (FWidget* widget, void* data_ptr)
|
|
|
|
{
|
|
|
|
FRadioButton* rb = static_cast<FRadioButton*>(widget);
|
|
|
|
FButton* button = static_cast<FButton*>(data_ptr);
|
|
|
|
if ( rb->isChecked() )
|
|
|
|
button->setEnable();
|
|
|
|
else
|
|
|
|
button->setDisable();
|
|
|
|
button->redraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2015-10-10 03:14:14 +02:00
|
|
|
void MyDialog::cb_view (FWidget*, void*)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
FString file = FFileDialog::fileOpenChooser (this);
|
|
|
|
if ( file.isNull() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
FDialog* view = new FDialog(this);
|
|
|
|
view->setText ("viewer");
|
|
|
|
view->setGeometry (1+int((getRootWidget()->getWidth()-60)/2),
|
|
|
|
int(getRootWidget()->getHeight()/6),
|
|
|
|
60,
|
|
|
|
int(getRootWidget()->getHeight()*3/4));
|
|
|
|
view->setTransparentShadow();
|
|
|
|
|
|
|
|
FTextView* scrollText = new FTextView(view);
|
|
|
|
scrollText->ignorePadding();
|
|
|
|
scrollText->setGeometry (1, 2, view->getWidth(), view->getHeight()-1);
|
|
|
|
scrollText->setFocus();
|
|
|
|
scrollText->insert(" -----------------------------------------------\n"
|
|
|
|
" line 1\n"
|
|
|
|
" -----------------------------------------------\n"
|
|
|
|
" line 3\n"
|
|
|
|
" line 4"
|
|
|
|
, -1);
|
|
|
|
scrollText->replaceRange(" File viewer", 1, 1);
|
|
|
|
scrollText->deleteRange(3, 4);
|
|
|
|
std::string line = "";
|
|
|
|
std::ifstream infile;
|
|
|
|
infile.open(file);
|
|
|
|
while ( ! infile.eof() && infile.good() )
|
|
|
|
{
|
|
|
|
getline(infile, line);
|
|
|
|
scrollText->append(line);
|
|
|
|
}
|
|
|
|
if ( infile.is_open() )
|
|
|
|
infile.close();
|
|
|
|
view->show();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void MyDialog::cb_setInput (FWidget* widget, void* data_ptr)
|
|
|
|
{
|
|
|
|
FListBox* ListBox = static_cast<FListBox*>(widget);
|
|
|
|
FLineEdit* lineedit = static_cast<FLineEdit*>(data_ptr);
|
|
|
|
lineedit->setText( ListBox->Item(ListBox->currentItem()).getText() );
|
|
|
|
lineedit->redraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2015-10-10 03:14:14 +02:00
|
|
|
void MyDialog::cb_exitApp (FWidget*, void*)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void MyDialog::adjustSize()
|
|
|
|
{
|
2015-09-24 19:01:27 +02:00
|
|
|
int h = parentWidget()->getHeight() - 4;
|
2015-05-23 13:35:12 +02:00
|
|
|
setHeight (h, false);
|
2015-06-08 20:43:19 +02:00
|
|
|
int X = int((parentWidget()->getWidth() - getWidth()) / 2);
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( X < 1 )
|
|
|
|
X = 1;
|
|
|
|
setX (X, false);
|
2015-09-24 19:01:27 +02:00
|
|
|
myList->setHeight (getHeight() - 4, false);
|
2015-05-23 13:35:12 +02:00
|
|
|
FDialog::adjustSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// main part
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
int main (int argc, char* argv[])
|
|
|
|
{
|
|
|
|
if ( argv[1] && ( strcmp(argv[1], "--help") == 0
|
|
|
|
|| strcmp(argv[1], "-h") == 0 ) )
|
|
|
|
{
|
|
|
|
std::cout << "Generic options:" << std::endl
|
|
|
|
<< " -h, --help "
|
|
|
|
<< "Display this help and exit" << std::endl;
|
|
|
|
FApplication::print_cmd_Options();
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
FApplication app(argc, argv);
|
2015-07-04 23:35:34 +02:00
|
|
|
app.setXTermTitle ("The FINAL CUT 0.1.1 (C) 2015 by Markus Gans");
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//app.setEncoding("VT100");
|
|
|
|
//app.setTermGeometry(94,30);
|
|
|
|
//app.setNewFont();
|
|
|
|
|
|
|
|
MyDialog d(&app);
|
2015-07-04 23:35:34 +02:00
|
|
|
d.setText ("The FINAL CUT 0.1.1 (C) 2015 by Markus Gans");
|
2015-09-24 19:01:27 +02:00
|
|
|
d.setGeometry (int((app.getWidth()-56)/2), 2, 56, app.getHeight()-4);
|
2015-05-23 13:35:12 +02:00
|
|
|
d.setShadow();
|
|
|
|
|
|
|
|
app.setMainWidget(&d);
|
|
|
|
d.show();
|
|
|
|
return app.exec();
|
|
|
|
}
|