Merge pull request #13 from gansm/master

Merge
This commit is contained in:
Markus Gans 2018-10-05 00:12:23 +02:00 committed by GitHub
commit da2bea4268
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
109 changed files with 4075 additions and 2787 deletions

View File

@ -1,3 +1,26 @@
2018-10-03 Markus Gans <guru.mail@muenster.de>
* At the end of the lifetime of an FMenuItem object,
delete its entry from the object list of the parent object
* Reduce the use of the new operators in the examples
* Adding a unit test for the FTermData class
2018-10-01 Markus Gans <guru.mail@muenster.de>
* Extract FTerm data members into the data class FTermData
2018-09-28 Markus Gans <guru.mail@muenster.de>
* FListView now has the ability to sort by columns
2018-09-27 Markus Gans <guru.mail@muenster.de>
* Move time event processing from FApplication to FObject
2018-09-26 Markus Gans <guru.mail@muenster.de>
* The FListViewItem class now has a getData() and a setData() method
similar to the FListBoxItem class.
2018-09-24 Markus Gans <guru.mail@muenster.de>
* Stricter use of the keyword virtual
* Add a first steps document
2018-09-20 Markus Gans <guru.mail@muenster.de>
* Added pkg-config file finalcut.pc
* The entire library source code is now encapsulated under

View File

@ -1,4 +1,5 @@
![The Final Cut](logo/png/finalcut-logo.png)
![FINAL CUT](logo/svg/finalcut-logo.svg)
============================================
### Building and code analysis
*Travis CI:*<br />
@ -10,6 +11,9 @@
*Class Reference:*<br />
&#160;&#160;&#160;&#160;&#160;[![documented](https://codedocs.xyz/gansm/finalcut.svg)](https://codedocs.xyz/gansm/finalcut/hierarchy.html)
The Final Cut is a C++ class library and widget toolkit with full mouse support for creating a [text-based user interface](https://en.wikipedia.org/wiki/Text-based_user_interface). The library supports the programmer to develop an application for the text console. It allows the simultaneous handling of multiple text windows on the screen.
The C++ class design was inspired by the Qt framework. It provides common controls like dialog boxes, push buttons, check boxes, radio buttons, input lines, list boxes, status bars and so on.
### Installation
```bash
> git clone git://github.com/gansm/finalcut.git
@ -29,29 +33,47 @@
* Cygwin
* Solaris
The Final Cut
=============
The Final Cut is a C++ class library and widget toolkit with full mouse support for creating a [text-based user interface](https://en.wikipedia.org/wiki/Text-based_user_interface). The library supports the programmer to develop an application for the text console. It allows the simultaneous handling of multiple text windows on the screen.
The C++ class design was inspired by the Qt framework. It provides common controls like dialog boxes, push buttons, check boxes, radio buttons, input lines, list boxes, status bars and so on.
### First steps
![](doc/fileopen-dialog.png)
[How to use the library](doc/first-steps.md)
![](doc/progress-bar.png)
### Screenshots
![](doc/textview.png)
The FFileDialog widget:
![](doc/Mandelbrot.png)
![FFileDialog](doc/fileopen-dialog.png)
The Final Cut FProgressbar widget:
![FProgressbar](doc/progress-bar.png)
Scrollable text in the FTextView widget:
![FTextView](doc/textview.png)
The Mandelbrot set example:
![Mandelbrot set](doc/Mandelbrot.png)
newfont
-------
A [graphical text font](fonts/) for X11 and the Linux console.
![](doc/newfont1.png)
![ui example in newfont mode](doc/newfont1.png)
![](doc/newfont2.png)
![](doc/calculator.png)
Newfont drive symbols:
![drive symbols](doc/newfont2.png)
The calculator example in newfont mode:
![calculator](doc/calculator.png)
Virtual terminal

View File

@ -3,7 +3,13 @@
if test "$1" = "update"
then
# Update generated configuration files
autoreconf --force --install --verbose --warnings=all
if which autoreconf >/dev/null
then
autoreconf --force --install --verbose --warnings=all
else
echo "Update failed, please install autoconf first"
exit 1
fi
else
# Set up an m4 environment
aclocal

View File

@ -28,7 +28,16 @@ test "$CPU_COUNT" -eq 0 && CPU_COUNT=1
if [ -n "$1" ]
then
test ! -f ./configure && autoreconf --install --force
if [ ! -f ./configure ]
then
if which autoreconf >/dev/null
then
autoreconf --install --force
else
echo "Build failed, please install autoconf first"
exit -1
fi
fi
fi
# Build commands

100
doc/first-steps.md Normal file
View File

@ -0,0 +1,100 @@
First steps with the Final Cut widget toolkit
=============================================
How to use the library
----------------------
At the beginning of this introduction to the Final Cut
we will start with a small example.
It creates an empty 30×10 character dialog.
**File:** *dialog.cpp*
```cpp
#include <final/final.h>
int main (int argc, char* argv[])
{
finalcut::FApplication app(argc, argv);
finalcut::FDialog dialog(&app);
dialog.setText ("A dialog");
dialog.setGeometry (25, 5, 30, 10);
app.setMainWidget(&dialog);
dialog.show();
return app.exec();
}
```
*(Note: Use mouse or <kbd>Shift</kbd>+<kbd>F10</kbd> or
<kbd>Ctrl</kbd>+<kbd>^</kbd> to close the dialog)*
After entering the source code in *dialog.cpp* you can compile
the above program with gcc:
```cpp
g++ -O2 -lfinal dialog.cpp -o dialog
```
How it works
------------
```cpp
#include <final/final.h>
```
All final cut programs must include the *final.h* header.
```cpp
finalcut::FApplication app(argc, argv);
```
In this line creates the `finalcut::FApplication` object `app` with
the command line arguments `argc` and `argv`. This object manages
the application main event loop. It receives keyboard and mouse events
and sends them to the target widgets. Before widgets can be created,
an application object must be created! Only one `finalcut::FApplication`
object should be created.
The next line
```cpp
finalcut::FDialog dialog(&app);
```
creates the `finalcut::FDialog` object `dialog` with the object `app`
as parent object. The `finalcut::FDialog` class is the base class for
creating dialog windows.
```cpp
dialog.setText ("A dialog");
```
The title bar of the dialog box gets the text "A dialog".
```cpp
dialog.setGeometry (25, 5, 30, 10);
```
The dialog window geometry is set to a width of 30 characters and
a height of 10 characters. The window in the terminal is positioned
at the positions x=25 and y=5 (note: x=1 and y=1 represents the upper
left corner).
```cpp
app.setMainWidget(&dialog);
```
The `dialog` object is selected as the main widget for the application.
When the user closes a main widget, the application will be closed.
```cpp
dialog.show();
```
A window or widget is not visible directly after its creation.
Only the call of `show()` makes it (and its child objects,
if available) visible.
```cpp
return app.exec();
```
The last line calls `exec()` to start the application and return
the result to the operating system. When the application starts,
it enters the main event loop. This loop doesn't end until the
window/application is closed.

View File

@ -16,7 +16,7 @@ INCLUDES = -I../src/include -I/usr/include/final
RM = rm -f
ifdef DEBUG
OPTIMIZE = -O0 -fsanitize=undefined
OPTIMIZE = -O0 -fsanitize=bool,bounds,enum,float-cast-overflow,function,null
else
OPTIMIZE = -O2
endif

View File

@ -49,7 +49,7 @@ class Button : public finalcut::FButton
void setChecked(bool);
// Event handler
void onKeyPress (finalcut::FKeyEvent*);
virtual void onKeyPress (finalcut::FKeyEvent*);
private:
// Data Member
@ -118,12 +118,12 @@ class Calc : public finalcut::FDialog
~Calc();
// Event handlers
void onKeyPress (finalcut::FKeyEvent*);
void onAccel (finalcut::FAccelEvent*);
void onClose (finalcut::FCloseEvent*);
virtual void onKeyPress (finalcut::FKeyEvent*);
virtual void onAccel (finalcut::FAccelEvent*);
virtual void onClose (finalcut::FCloseEvent*);
// Callback method
void cb_buttonClicked (finalcut::FWidget*, data_ptr);
void cb_buttonClicked (finalcut::FWidget*, data_ptr);
private:
// Typedef and Enumeration
@ -212,7 +212,7 @@ class Calc : public finalcut::FDialog
void setInfixOperator (char);
void clearInfixOperator();
void calcInfixOperator();
void adjustSize();
virtual void adjustSize();
const wchar_t* getButtonText (int);
void mapKeyFunctions();

View File

@ -96,68 +96,66 @@ int main (int argc, char* argv[])
// Create the application object
finalcut::FApplication app(argc, argv);
// Create a simple modal dialog box
finalcut::FDialog* dgl = new finalcut::FDialog(&app);
dgl->setModal();
dgl->setText ("UNIX select");
w = 20;
h = 13;
x = (app.getDesktopWidth() - w) / 2;
y = (app.getDesktopHeight() - h) / 2;
dgl->setGeometry (x, y, w, h);
{ // Create a simple modal dialog box in this scope
finalcut::FDialog dgl(&app);
dgl.setModal();
dgl.setText ("UNIX select");
w = 20;
h = 13;
x = (app.getDesktopWidth() - w) / 2;
y = (app.getDesktopHeight() - h) / 2;
dgl.setGeometry (x, y, w, h);
// Create a button group
finalcut::FButtonGroup* checkButtonGroup = new finalcut::FButtonGroup("choice", dgl);
checkButtonGroup->setGeometry (2, 1, 16, 7);
// Create a button group
finalcut::FButtonGroup checkButtonGroup("choice", &dgl);
checkButtonGroup.setGeometry (2, 1, 16, 7);
// Create radio buttons
std::vector<finalcut::FRadioButton*> os (9);
populateChoice (os, checkButtonGroup);
// Create radio buttons
std::vector<finalcut::FRadioButton*> os (9);
populateChoice (os, &checkButtonGroup);
// Set the radio button geometry
// => checkButtonGroup->setScrollSize(...) is not required
// because a FButtonGroup is self-adjusting
for (uInt i = 0; i < os.size(); i++)
os[i]->setGeometry(1, int(1 + i), 12, 1);
// Set the radio button geometry
// => checkButtonGroup.setScrollSize(...) is not required
// because a FButtonGroup is self-adjusting
for (uInt i = 0; i < os.size(); i++)
os[i]->setGeometry(1, int(1 + i), 12, 1);
preset(os);
preset(os);
// Scroll to the focused child element
finalcut::FFocusEvent cfi (finalcut::fc::ChildFocusIn_Event);
finalcut::FApplication::sendEvent(checkButtonGroup, &cfi);
// Scroll to the focused child element
finalcut::FFocusEvent cfi (finalcut::fc::ChildFocusIn_Event);
finalcut::FApplication::sendEvent(&checkButtonGroup, &cfi);
// Create a OK button
finalcut::FButton* ok = new finalcut::FButton("&OK", dgl);
ok->setGeometry (10, 9, 8, 1);
// Create a OK button
finalcut::FButton ok("&OK", &dgl);
ok.setGeometry (10, 9, 8, 1);
// Connect the button signal "clicked" with the callback function
ok->addCallback
(
"clicked",
F_FUNCTION_CALLBACK (&cb_quit),
dgl
);
// Connect the button signal "clicked" with the callback function
ok.addCallback
(
"clicked",
F_FUNCTION_CALLBACK (&cb_quit),
&dgl
);
// Show the dialog
dgl->show();
// Show the dialog
dgl.show();
// Get the checked radio button text
for (int n = 1; n <= int(checkButtonGroup->getCount()); n++)
{
if ( checkButtonGroup->isChecked(n) )
// Get the checked radio button text
for (int n = 1; n <= int(checkButtonGroup.getCount()); n++)
{
label_text = checkButtonGroup->getButton(n)->getText();
break;
if ( checkButtonGroup.isChecked(n) )
{
label_text = checkButtonGroup.getButton(n)->getText();
break;
}
}
}
} // Hide and destroy the dialog object
// Hide and destroy the dialog object
delete dgl;
// Create and show tooltip for two seconds
finalcut::FToolTip* tooltip = new finalcut::FToolTip(&app);
tooltip->setText ("You have chosen " + label_text);
tooltip->show();
finalcut::FToolTip tooltip(&app);
tooltip.setText ("You have chosen " + label_text);
tooltip.show();
sleep(2);
delete tooltip;
}

View File

@ -66,64 +66,58 @@ int main (int argc, char* argv[])
dgl.setShadow();
// Create input fields
finalcut::FLineEdit* name_field = new finalcut::FLineEdit(&dgl);
finalcut::FLineEdit* email_field = new finalcut::FLineEdit(&dgl);
finalcut::FLineEdit* org_field = new finalcut::FLineEdit(&dgl);
finalcut::FLineEdit* city_field = new finalcut::FLineEdit(&dgl);
finalcut::FLineEdit* st_field = new finalcut::FLineEdit(&dgl);
finalcut::FLineEdit* c_field = new finalcut::FLineEdit(&dgl);
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.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);
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);
// Create the button group
finalcut::FButtonGroup* radioButtonGroup = \
new finalcut::FButtonGroup("Sex", &dgl);
radioButtonGroup->setGeometry(2, 13, 13, 4);
finalcut::FButtonGroup radioButtonGroup ("Sex", &dgl);
radioButtonGroup.setGeometry(2, 13, 13, 4);
// Create radio buttons
finalcut::FRadioButton* male = \
new finalcut::FRadioButton("&Male", radioButtonGroup);
finalcut::FRadioButton* female = \
new finalcut::FRadioButton("&Female", radioButtonGroup);
male->setGeometry(1, 1, 8, 1);
female->setGeometry(1, 2, 10, 1);
finalcut::FRadioButton male ("&Male", &radioButtonGroup);
finalcut::FRadioButton female ("&Female", &radioButtonGroup);
male.setGeometry (1, 1, 8, 1);
female.setGeometry (1, 2, 10, 1);
// Create another button group
finalcut::FButtonGroup* checkButtonGroup = \
new finalcut::FButtonGroup("&Data options", &dgl);
checkButtonGroup->setGeometry(16, 13, 19, 4);
finalcut::FButtonGroup checkButtonGroup ("&Data options", &dgl);
checkButtonGroup.setGeometry(16, 13, 19, 4);
// Create checkbox buttons
finalcut::FCheckBox* check1 = \
new finalcut::FCheckBox("Save data", checkButtonGroup);
finalcut::FCheckBox* check2 = \
new finalcut::FCheckBox("Encrypt data", checkButtonGroup);
check1->setGeometry(1, 1, 13, 1);
check2->setGeometry(1, 2, 16, 1);
check2->setDisable();
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();
// Create a OK button
finalcut::FButton btn("&OK", &dgl);
btn.setGeometry (24, 18, 10, 1);
// Connect checkbox signal "clicked" with a callback function
check1->addCallback
check1.addCallback
(
"clicked",
F_FUNCTION_CALLBACK (&cb_publish),
check2
&check2
);
// Connect the button signal "clicked" with the callback function

View File

@ -34,10 +34,12 @@ class Keyboard : public finalcut::FWidget
protected:
// Event handlers
void onKeyPress (finalcut::FKeyEvent*);
void onAccel (finalcut::FAccelEvent*);
virtual void onKeyPress (finalcut::FKeyEvent*);
virtual void onAccel (finalcut::FAccelEvent*);
void draw();
private:
// Methods
virtual void draw();
};
//----------------------------------------------------------------------

View File

@ -88,10 +88,14 @@ class Listbox : public finalcut::FDialog
Listbox& operator = (const Listbox&);
// Event handlers
void onClose (finalcut::FCloseEvent*);
virtual void onClose (finalcut::FCloseEvent*);
// Data Member
std::list<double>* double_list;
std::list<double> double_list;
finalcut::FListBox list1;
finalcut::FListBox list2;
finalcut::FListBox list3;
finalcut::FButton Quit;
};
#pragma pack(pop)
@ -99,38 +103,41 @@ class Listbox : public finalcut::FDialog
Listbox::Listbox (finalcut::FWidget* parent)
: finalcut::FDialog(parent)
, double_list()
, list1(this)
, list2(this)
, list3(this)
, Quit(this)
{
temp_str = new finalcut::FString;
// listbox 1
finalcut::FListBox* list1 = new finalcut::FListBox (this);
list1->setGeometry(2, 1, 18, 10);
list1->setText ("FListBoxItem");
//----------
list1.setGeometry(2, 1, 18, 10);
list1.setText ("FListBoxItem");
for (int i = 1; i < 30; i++)
list1->insert (L"----- " + (finalcut::FString() << i) + L" -----");
list1.insert (L"----- " + (finalcut::FString() << i) + L" -----");
// listbox 2
double_list = new std::list<double>;
//----------
for (double i = 1; i<=15; i++)
double_list->push_back(2 * i + (i / 100));
double_list.push_back(2 * i + (i / 100));
finalcut::FListBox* list2 = new finalcut::FListBox (this);
list2->setGeometry(21, 1, 10, 10);
list2->setText ("double");
list2.setGeometry(21, 1, 10, 10);
list2.setText ("double");
//
// Import via lazy conversion on print
//
list2->insert (double_list, doubleToItem);
list2.insert (&double_list, doubleToItem);
//
// Direct import of the complete list
//
//list2->insert (double_list->begin(), double_list->end(), doubleToString);
//list2.insert (double_list.begin(), double_list.end(), doubleToString);
// listbox 3
//----------
std::map<finalcut::FString, finalcut::FString> TLD;
TLD["com"] = "Commercial";
TLD["org"] = "Organization";
@ -138,18 +145,16 @@ Listbox::Listbox (finalcut::FWidget* parent)
TLD["edu"] = "Education";
TLD["gov"] = "Government";
finalcut::FListBox* list3;
list3 = new finalcut::FListBox (TLD.begin(), TLD.end(), mapToString, this);
list3->setGeometry(32, 1, 21, 10);
list3->setText ("key: value");
list3.insert (TLD.begin(), TLD.end(), mapToString);
list3.setGeometry(32, 1, 21, 10);
list3.setText ("key: value");
// Quit button
finalcut::FButton* Quit = new finalcut::FButton (this);
Quit->setGeometry(42, 12, 10, 1);
Quit->setText (L"&Quit");
Quit.setGeometry(42, 12, 10, 1);
Quit.setText (L"&Quit");
// Add quit button function callback
Quit->addCallback
Quit.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &finalcut::FApplication::cb_exitApp)
@ -160,7 +165,6 @@ Listbox::Listbox (finalcut::FWidget* parent)
Listbox::~Listbox() // destructor
{
delete temp_str;
delete double_list;
}
//----------------------------------------------------------------------

View File

@ -50,52 +50,68 @@ class Listview : public finalcut::FDialog
Listview& operator = (const Listview&);
// Method
void populate (finalcut::FListView*);
void populate();
// Event handlers
void onClose (finalcut::FCloseEvent*);
virtual void onClose (finalcut::FCloseEvent*);
// Callback method
void cb_showInMessagebox (finalcut::FWidget*, data_ptr);
// Data Members
finalcut::FListView listView;
finalcut::FButton Quit;
};
#pragma pack(pop)
//----------------------------------------------------------------------
Listview::Listview (finalcut::FWidget* parent)
: finalcut::FDialog(parent)
, listView(this)
, Quit(this)
{
// Create FListView object
finalcut::FListView* listView = new finalcut::FListView (this);
listView->setGeometry(2, 1, 33, 14);
listView.setGeometry(2, 1, 33, 14);
// Add columns to the view
listView->addColumn ("City");
listView->addColumn ("Condition");
listView->addColumn ("Temp.");
listView->addColumn ("Humidity");
listView->addColumn ("Pressure", 10);
listView.addColumn ("City");
listView.addColumn ("Condition");
listView.addColumn ("Temp.");
listView.addColumn ("Humidity");
listView.addColumn ("Pressure", 10);
// Set right alignment for the third, fourth, and fifth column
listView->setColumnAlignment (3, finalcut::fc::alignRight);
listView->setColumnAlignment (4, finalcut::fc::alignRight);
listView->setColumnAlignment (5, finalcut::fc::alignRight);
listView.setColumnAlignment (3, finalcut::fc::alignRight);
listView.setColumnAlignment (4, finalcut::fc::alignRight);
listView.setColumnAlignment (5, finalcut::fc::alignRight);
// Set the type of sorting
listView.setColumnSortType (1, finalcut::fc::by_name);
listView.setColumnSortType (2, finalcut::fc::by_name);
listView.setColumnSortType (3, finalcut::fc::by_number);
listView.setColumnSortType (4, finalcut::fc::by_number);
listView.setColumnSortType (5, finalcut::fc::by_number);
// Sort in ascending order by the 1st column
listView.setColumnSort (1, finalcut::fc::ascending);
// The sorting occurs later automatically at insert().
// Otherwise you could start the sorting directly with sort()
// Populate FListView with a list of items
populate (listView);
populate();
// Quit button
finalcut::FButton* Quit = new finalcut::FButton (this);
Quit->setGeometry(24, 16, 10, 1);
Quit->setText (L"&Quit");
Quit.setGeometry(24, 16, 10, 1);
Quit.setText (L"&Quit");
// Add some function callbacks
Quit->addCallback
Quit.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &finalcut::FApplication::cb_exitApp)
);
listView->addCallback
listView.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &Listview::cb_showInMessagebox)
@ -107,7 +123,7 @@ Listview::~Listview() // destructor
{ }
//----------------------------------------------------------------------
void Listview::populate (finalcut::FListView* listView)
void Listview::populate()
{
std::string weather[][5] =
{
@ -159,7 +175,7 @@ void Listview::populate (finalcut::FListView* listView)
for (int i = 0; i <= lastItem; i++)
{
finalcut::FStringList line (&weather[i][0], &weather[i][0] + 5);
listView->insert (line);
listView.insert (line);
}
}
@ -170,10 +186,9 @@ void Listview::onClose (finalcut::FCloseEvent* ev)
}
//----------------------------------------------------------------------
void Listview::cb_showInMessagebox (finalcut::FWidget* widget, data_ptr)
void Listview::cb_showInMessagebox (finalcut::FWidget*, data_ptr)
{
finalcut::FListView* listView = static_cast<finalcut::FListView*>(widget);
finalcut::FListViewItem* item = listView->getCurrentItem();
finalcut::FListViewItem* item = listView.getCurrentItem();
finalcut::FMessageBox info ( "Weather in " + item->getText(1)
, " Condition: " + item->getText(2) + "\n"
"Temperature: " + item->getText(3) + "\n"

View File

@ -40,13 +40,13 @@ class Mandelbrot : public finalcut::FDialog
~Mandelbrot();
// Event handlers
void onAccel (finalcut::FAccelEvent*);
void onClose (finalcut::FCloseEvent*);
virtual void onAccel (finalcut::FAccelEvent*);
virtual void onClose (finalcut::FCloseEvent*);
private:
// Methods
virtual void draw();
void adjustSize();
virtual void adjustSize();
};
#pragma pack(pop)

View File

@ -47,81 +47,161 @@ class Menu : public finalcut::FDialog
Menu& operator = (const Menu&);
// Methods
void createFileMenuItems (finalcut::FMenu*);
void createEditMenuItems (finalcut::FMenu*);
void createChoiceMenuItems (finalcut::FMenu*);
void createColorMenuItems (finalcut::FMenu*);
void createStyleMenuItems (finalcut::FMenu*);
void createBorderMenuItems (finalcut::FMenu*);
void createBorderColorMenuItems (finalcut::FMenu*);
void createBorderStyleMenuItems (finalcut::FMenu*);
void configureFileMenuItems();
void configureEditMenuItems();
void configureChoiceMenuItems();
void configureColorMenuItems();
void configureStyleMenuItems();
void configureBorderMenuItems();
void defaultCallback (finalcut::FMenuList*);
void adjustSize();
virtual void adjustSize();
// Event handler
void onClose (finalcut::FCloseEvent*);
virtual void onClose (finalcut::FCloseEvent*);
// Callback method
void cb_message (finalcut::FWidget*, data_ptr);
// Data Members
finalcut::FString line;
finalcut::FMenuBar Menubar;
finalcut::FMenu File;
finalcut::FMenu Edit;
finalcut::FMenu Choice;
finalcut::FMenuItem Window;
finalcut::FMenuItem Help;
finalcut::FMenuItem New;
finalcut::FMenuItem Open;
finalcut::FMenuItem Save;
finalcut::FMenuItem SaveAs;
finalcut::FMenuItem Close;
finalcut::FMenuItem Line1;
finalcut::FMenuItem Print;
finalcut::FMenuItem Line2;
finalcut::FMenuItem Quit;
finalcut::FMenuItem Undo;
finalcut::FMenuItem Redo;
finalcut::FMenuItem Line3;
finalcut::FMenuItem Cut;
finalcut::FMenuItem Copy;
finalcut::FMenuItem Paste;
finalcut::FMenuItem Line4;
finalcut::FMenuItem Search;
finalcut::FMenuItem Next;
finalcut::FMenuItem Line5;
finalcut::FMenuItem SelectAll;
finalcut::FMenu Color;
finalcut::FMenu Style;
finalcut::FMenu Border;
finalcut::FRadioMenuItem Color1;
finalcut::FRadioMenuItem Color2;
finalcut::FRadioMenuItem Color3;
finalcut::FRadioMenuItem Color4;
finalcut::FRadioMenuItem Color5;
finalcut::FCheckMenuItem Bold;
finalcut::FCheckMenuItem Italic;
finalcut::FMenu BColor;
finalcut::FMenu BStyle;
finalcut::FRadioMenuItem BColor1;
finalcut::FRadioMenuItem BColor2;
finalcut::FRadioMenuItem BStyle1;
finalcut::FRadioMenuItem BStyle2;
finalcut::FRadioMenuItem BStyle3;
finalcut::FRadioMenuItem BStyle4;
finalcut::FStatusBar Statusbar;
finalcut::FLabel Headline1;
finalcut::FLabel Headline2;
finalcut::FLabel Info;
};
#pragma pack(pop)
//----------------------------------------------------------------------
Menu::Menu (finalcut::FWidget* parent)
: finalcut::FDialog(parent)
, line(13, wchar_t(finalcut::fc::BoxDrawingsHorizontal))
, Menubar(this)
, File("&File", &Menubar)
, Edit("&Edit", &Menubar)
, Choice("&Choice", &Menubar)
, Window("&Window", &Menubar)
, Help("&Help", &Menubar)
, New("&New", &File)
, Open("&Open...", &File)
, Save("&Save", &File)
, SaveAs("&Save as...", &File)
, Close("&Close", &File)
, Line1(&File)
, Print("&Print", &File)
, Line2(&File)
, Quit("&Quit", &File)
, Undo(finalcut::fc::Fckey_z, "&Undo", &Edit)
, Redo(finalcut::fc::Fckey_y, "&Redo", &Edit)
, Line3(&Edit)
, Cut(finalcut::fc::Fckey_x, "Cu&t", &Edit)
, Copy(finalcut::fc::Fckey_c, "&Copy", &Edit)
, Paste(finalcut::fc::Fckey_v, "&Paste", &Edit)
, Line4(&Edit)
, Search(finalcut::fc::Fckey_f, "&Search", &Edit)
, Next(finalcut::fc::Fkey_f3, "Search &next", &Edit)
, Line5(&Edit)
, SelectAll(finalcut::fc::Fckey_a, "Select &all", &Edit)
, Color("&Color", &Choice)
, Style("&Style", &Choice)
, Border("&Border", &Choice)
, Color1("Red", &Color)
, Color2("Green", &Color)
, Color3("Yellow", &Color)
, Color4("Brue", &Color)
, Color5("Black", &Color)
, Bold("Bold", &Style)
, Italic("Italic", &Style)
, BColor("&Color", &Border)
, BStyle("&Style", &Border)
, BColor1("Red", &BColor)
, BColor2("Blue", &BColor)
, BStyle1(line, &BStyle)
, BStyle2("-------------", &BStyle)
, BStyle3("- - - - - - -", &BStyle)
, BStyle4("- - - - -", &BStyle)
, Statusbar(this)
, Headline1(this)
, Headline2(this)
, Info(this)
{
// Menu bar
finalcut::FMenuBar* Menubar = new finalcut::FMenuBar(this);
// Menu bar items
finalcut::FMenu* File = \
new finalcut::FMenu ("&File", Menubar);
File->setStatusbarMessage ("File management commands");
finalcut::FMenu* Edit = \
new finalcut::FMenu ("&Edit", Menubar);
Edit->setStatusbarMessage ("Cut-and-paste editing commands");
finalcut::FMenu* Choice = \
new finalcut::FMenu ("&Choice", Menubar);
Choice->setStatusbarMessage ("Choice menu");
finalcut::FMenuItem* Window = \
new finalcut::FMenuItem ("&Window", Menubar);
Window->setDisable();
finalcut::FMenuItem* Help = \
new finalcut::FMenuItem ("&Help", Menubar);
Help->setStatusbarMessage ("Show version and copyright information");
// Menu bar itms
File.setStatusbarMessage ("File management commands");
Edit.setStatusbarMessage ("Cut-and-paste editing commands");
Choice.setStatusbarMessage ("Choice menu");
Window.setDisable();
Help.setStatusbarMessage ("Show version and copyright information");
// Menu items
createFileMenuItems (File);
createEditMenuItems (Edit);
createChoiceMenuItems (Choice);
configureFileMenuItems();
configureEditMenuItems();
configureChoiceMenuItems();
// Add default menu item callback
defaultCallback (Menubar);
defaultCallback (&Menubar);
// Statusbar at the bottom
finalcut::FStatusBar* Statusbar = \
new finalcut::FStatusBar (this);
Statusbar->setMessage("Status bar message");
Statusbar.setMessage("Status bar message");
// Headline labels
finalcut::FLabel* Headline1 = \
new finalcut::FLabel(" Key ", this);
Headline1->ignorePadding();
Headline1->setGeometry(3, 2, 5, 1);
Headline1->setEmphasis();
Headline1 << " Key ";
Headline1.ignorePadding();
Headline1.setGeometry(3, 2, 5, 1);
Headline1.setEmphasis();
finalcut::FLabel* Headline2 = \
new finalcut::FLabel(" Function ", this);
Headline2->ignorePadding();
Headline2->setGeometry(19, 2, 10, 1);
Headline2->setEmphasis();
Headline2 << " Function ";
Headline2.ignorePadding();
Headline2.setGeometry(19, 2, 10, 1);
Headline2.setEmphasis();
// Info label
finalcut::FLabel* Info = \
new finalcut::FLabel( "<F10> Activate menu bar\n"
"<Ctrl>+<Space> Activate menu bar\n"
"<Meta>+<X> Exit", this );
Info->setGeometry(2, 1, 36, 3);
Info << "<F10> Activate menu bar\n"
<< "<Ctrl>+<Space> Activate menu bar\n"
<< "<Meta>+<X> Exit";
Info.setGeometry(2, 1, 36, 3);
}
//----------------------------------------------------------------------
@ -129,45 +209,27 @@ Menu::~Menu()
{ }
//----------------------------------------------------------------------
void Menu::createFileMenuItems (finalcut::FMenu* File)
void Menu::configureFileMenuItems()
{
// "File" menu items
finalcut::FMenuItem* New = \
new finalcut::FMenuItem ("&New", File);
New->addAccelerator (finalcut::fc::Fckey_n); // Ctrl + N
New->setStatusbarMessage ("Create a new file");
finalcut::FMenuItem* Open = \
new finalcut::FMenuItem ("&Open...", File);
Open->addAccelerator (finalcut::fc::Fckey_o); // Ctrl + O
Open->setStatusbarMessage ("Locate and open a text file");
finalcut::FMenuItem* Save = \
new finalcut::FMenuItem ("&Save", File);
Save->addAccelerator (finalcut::fc::Fckey_s); // Ctrl + S
Save->setStatusbarMessage ("Save the file");
finalcut::FMenuItem* SaveAs = \
new finalcut::FMenuItem ("&Save as...", File);
SaveAs->setStatusbarMessage ("Save the current file under a different name");
finalcut::FMenuItem* Close = \
new finalcut::FMenuItem ("&Close", File);
Close->addAccelerator (finalcut::fc::Fckey_w); // Ctrl + W
Close->setStatusbarMessage ("Close the current file");
finalcut::FMenuItem* Line1 = \
new finalcut::FMenuItem (File);
Line1->setSeparator();
finalcut::FMenuItem* Print = \
new finalcut::FMenuItem ("&Print", File);
Print->addAccelerator (finalcut::fc::Fckey_p); // Ctrl + P
Print->setStatusbarMessage ("Print the current file");
finalcut::FMenuItem* Line2 = \
new finalcut::FMenuItem (File);
Line2->setSeparator();
finalcut::FMenuItem* Quit = \
new finalcut::FMenuItem ("&Quit", File);
Quit->addAccelerator (finalcut::fc::Fmkey_x); // Meta/Alt + X
Quit->setStatusbarMessage ("Exit the program");
New.addAccelerator (finalcut::fc::Fckey_n); // Ctrl + N
New.setStatusbarMessage ("Create a new file");
Open.addAccelerator (finalcut::fc::Fckey_o); // Ctrl + O
Open.setStatusbarMessage ("Locate and open a text file");
Save.addAccelerator (finalcut::fc::Fckey_s); // Ctrl + S
Save.setStatusbarMessage ("Save the file");
SaveAs.setStatusbarMessage ("Save the current file under a different name");
Close.addAccelerator (finalcut::fc::Fckey_w); // Ctrl + W
Close.setStatusbarMessage ("Close the current file");
Line1.setSeparator();
Print.addAccelerator (finalcut::fc::Fckey_p); // Ctrl + P
Print.setStatusbarMessage ("Print the current file");
Line2.setSeparator();
Quit.addAccelerator (finalcut::fc::Fmkey_x); // Meta/Alt + X
Quit.setStatusbarMessage ("Exit the program");
// Add quit menu item callback
Quit->addCallback
Quit.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &finalcut::FApplication::cb_exitApp)
@ -175,138 +237,73 @@ void Menu::createFileMenuItems (finalcut::FMenu* File)
}
//----------------------------------------------------------------------
void Menu::createEditMenuItems (finalcut::FMenu* Edit)
void Menu::configureEditMenuItems()
{
// "Edit" menu items
finalcut::FMenuItem* Undo = \
new finalcut::FMenuItem (finalcut::fc::Fckey_z, "&Undo", Edit);
Undo->setStatusbarMessage ("Undo the previous operation");
finalcut::FMenuItem* Redo = \
new finalcut::FMenuItem (finalcut::fc::Fckey_y, "&Redo", Edit);
Redo->setDisable();
finalcut::FMenuItem* Line3 = \
new finalcut::FMenuItem (Edit);
Line3->setSeparator();
finalcut::FMenuItem* Cut = \
new finalcut::FMenuItem (finalcut::fc::Fckey_x, "Cu&t", Edit);
Cut->setStatusbarMessage ( "Remove the input text "
"and put it in the clipboard" );
finalcut::FMenuItem* Copy = \
new finalcut::FMenuItem (finalcut::fc::Fckey_c, "&Copy", Edit);
Copy->setStatusbarMessage ("Copy the input text into the clipboad");
finalcut::FMenuItem* Paste = \
new finalcut::FMenuItem (finalcut::fc::Fckey_v, "&Paste", Edit);
Paste->setStatusbarMessage ("Insert text form clipboard");
finalcut::FMenuItem* Line4 = \
new finalcut::FMenuItem (Edit);
Line4->setSeparator();
finalcut::FMenuItem* Search = \
new finalcut::FMenuItem (finalcut::fc::Fckey_f, "&Search", Edit);
Search->setStatusbarMessage ("Search for text");
finalcut::FMenuItem* Next = \
new finalcut::FMenuItem (finalcut::fc::Fkey_f3, "Search &next", Edit);
Next->setStatusbarMessage ("Repeat the last search command");
finalcut::FMenuItem* Line5 = \
new finalcut::FMenuItem (Edit);
Line5->setSeparator();
finalcut::FMenuItem* SelectAll = \
new finalcut::FMenuItem (finalcut::fc::Fckey_a, "Select &all", Edit);
SelectAll->setStatusbarMessage ("Select the whole text");
Undo.setStatusbarMessage ("Undo the previous operation");
Redo.setDisable();
Line3.setSeparator();
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();
Search.setStatusbarMessage ("Search for text");
Next.setStatusbarMessage ("Repeat the last search command");
Line5.setSeparator();
SelectAll.setStatusbarMessage ("Select the whole text");
}
//----------------------------------------------------------------------
void Menu::createChoiceMenuItems (finalcut::FMenu* Choice)
void Menu::configureChoiceMenuItems()
{
// "Choice" menu items
finalcut::FMenu* Color = new finalcut::FMenu ("&Color", Choice);
Color->setStatusbarMessage ("Choose a color");
finalcut::FMenu* Style = new finalcut::FMenu ("&Style", Choice);
Style->setStatusbarMessage ("Choose a Style");
finalcut::FMenu* Border = new finalcut::FMenu ("&Border", Choice);
Border->setStatusbarMessage ("Choose Border");
Color.setStatusbarMessage ("Choose a color");
Style.setStatusbarMessage ("Choose a Style");
Border.setStatusbarMessage ("Choose Border");
createColorMenuItems (Color);
createStyleMenuItems (Style);
createBorderMenuItems (Border);
configureColorMenuItems();
configureStyleMenuItems();
configureBorderMenuItems();
}
//----------------------------------------------------------------------
void Menu::createColorMenuItems (finalcut::FMenu* Color)
void Menu::configureColorMenuItems()
{
// "Color" menu items
finalcut::FRadioMenuItem* Color1 = \
new finalcut::FRadioMenuItem ("Red", Color);
Color1->setStatusbarMessage ("Set text red");
finalcut::FRadioMenuItem* Color2 = \
new finalcut::FRadioMenuItem ("Green", Color);
Color2->setStatusbarMessage ("Set text green");
finalcut::FRadioMenuItem* Color3 = \
new finalcut::FRadioMenuItem ("Yellow", Color);
Color3->setStatusbarMessage ("Set text yellow");
finalcut::FRadioMenuItem* Color4 = \
new finalcut::FRadioMenuItem ("Brue", Color);
Color4->setStatusbarMessage ("Set text brue");
finalcut::FRadioMenuItem* Color5 = \
new finalcut::FRadioMenuItem ("Black", Color);
Color5->setStatusbarMessage ("Set text black");
Color5->setChecked();
Color1.setStatusbarMessage ("Set text red");
Color2.setStatusbarMessage ("Set text green");
Color3.setStatusbarMessage ("Set text yellow");
Color4.setStatusbarMessage ("Set text brue");
Color5.setStatusbarMessage ("Set text black");
Color5.setChecked();
}
//----------------------------------------------------------------------
void Menu::createStyleMenuItems (finalcut::FMenu* Style)
void Menu::configureStyleMenuItems()
{
// "Style" menu items
finalcut::FCheckMenuItem* Bold = \
new finalcut::FCheckMenuItem ("Bold", Style);
Bold->setStatusbarMessage ("Set text bold");
finalcut::FCheckMenuItem* Italic = \
new finalcut::FCheckMenuItem ("Italic", Style);
Italic->setStatusbarMessage ("Set text italic");
Bold.setStatusbarMessage ("Set text bold");
Italic.setStatusbarMessage ("Set text italic");
}
//----------------------------------------------------------------------
void Menu::createBorderMenuItems (finalcut::FMenu* Border)
void Menu::configureBorderMenuItems()
{
// "Border" menu items
finalcut::FMenu* BColor = new finalcut::FMenu ("&Color", Border);
BColor->setStatusbarMessage ("Choose the border color");
finalcut::FMenu* BStyle = new finalcut::FMenu ("&Style", Border);
BStyle->setStatusbarMessage ("Choose the border Style");
BColor.setStatusbarMessage ("Choose the border color");
BStyle.setStatusbarMessage ("Choose the border Style");
createBorderColorMenuItems (BColor);
createBorderStyleMenuItems (BStyle);
}
//----------------------------------------------------------------------
void Menu::createBorderColorMenuItems (finalcut::FMenu* BColor)
{
// "BColor" menu items
finalcut::FRadioMenuItem* BColor1 = \
new finalcut::FRadioMenuItem ("Red", BColor);
BColor1->setStatusbarMessage ("Set red border");
finalcut::FRadioMenuItem* BColor2 = \
new finalcut::FRadioMenuItem ("Blue", BColor);
BColor2->setStatusbarMessage ("Set blue border");
}
BColor1.setStatusbarMessage ("Set red border");
BColor2.setStatusbarMessage ("Set blue border");
//----------------------------------------------------------------------
void Menu::createBorderStyleMenuItems (finalcut::FMenu* BStyle)
{
// "BStyle" menu items
finalcut::FString line(13, wchar_t(finalcut::fc::BoxDrawingsHorizontal));
finalcut::FRadioMenuItem* BStyle1 = \
new finalcut::FRadioMenuItem (line, BStyle);
BStyle1->setChecked();
BStyle1->setStatusbarMessage ("Set border 1");
finalcut::FRadioMenuItem* BStyle2 = \
new finalcut::FRadioMenuItem ("-------------", BStyle);
BStyle2->setStatusbarMessage ("Set border 2");
finalcut::FRadioMenuItem* BStyle3 = \
new finalcut::FRadioMenuItem ("- - - - - - -", BStyle);
BStyle3->setStatusbarMessage ("Set border 3");
finalcut::FRadioMenuItem* BStyle4 = \
new finalcut::FRadioMenuItem ("- - - - -", BStyle);
BStyle4->setStatusbarMessage ("Set border 4");
BStyle1.setChecked();
BStyle1.setStatusbarMessage ("Set border 1");
BStyle2.setStatusbarMessage ("Set border 2");
BStyle3.setStatusbarMessage ("Set border 3");
BStyle4.setStatusbarMessage ("Set border 4");
}
//----------------------------------------------------------------------

View File

@ -50,14 +50,15 @@ class ColorChooser : public finalcut::FWidget
ColorChooser& operator = (const ColorChooser&);
// Method
void draw();
virtual void draw();
// Event handler
void onMouseDown (finalcut::FMouseEvent*);
virtual void onMouseDown (finalcut::FMouseEvent*);
// Data Members
short fg_color;
short bg_color;
finalcut::FLabel headline;
};
#pragma pack(pop)
@ -66,6 +67,7 @@ ColorChooser::ColorChooser (finalcut::FWidget* parent)
: FWidget(parent)
, fg_color(finalcut::fc::White)
, bg_color(finalcut::fc::Black)
, headline(this)
{
setSize (8, 12);
setFixedSize (8, 12);
@ -73,16 +75,19 @@ ColorChooser::ColorChooser (finalcut::FWidget* parent)
if ( parent )
{
setForegroundColor(parent->getForegroundColor());
setBackgroundColor(parent->getBackgroundColor());
short fg = parent->getForegroundColor();
short bg = parent->getBackgroundColor();
setForegroundColor(fg);
setBackgroundColor(bg);
headline.setForegroundColor(fg);
headline.setBackgroundColor(bg);
}
// Text label
finalcut::FLabel* headline = new finalcut::FLabel (this);
headline->setGeometry(1, 1, 8, 1);
headline->setEmphasis();
headline->setAlignment (finalcut::fc::alignCenter);
*headline << "Color";
headline.setGeometry (1, 1, 8, 1);
headline.setEmphasis();
headline.setAlignment (finalcut::fc::alignCenter);
headline << "Color";
}
//----------------------------------------------------------------------
@ -188,15 +193,16 @@ class Brushes : public finalcut::FWidget
Brushes& operator = (const Brushes&);
// Method
void draw();
virtual void draw();
// Event handler
void onMouseDown (finalcut::FMouseEvent*);
virtual void onMouseDown (finalcut::FMouseEvent*);
// Data Members
wchar_t brush;
short fg_color;
short bg_color;
finalcut::FLabel headline;
};
#pragma pack(pop)
@ -206,6 +212,7 @@ Brushes::Brushes (finalcut::FWidget* parent)
, brush(L' ')
, fg_color(finalcut::fc::White)
, bg_color(finalcut::fc::Black)
, headline(this)
{
setSize (8, 4);
setFixedSize (8, 4);
@ -213,16 +220,19 @@ Brushes::Brushes (finalcut::FWidget* parent)
if ( parent )
{
setForegroundColor(parent->getForegroundColor());
setBackgroundColor(parent->getBackgroundColor());
short fg = parent->getForegroundColor();
short bg = parent->getBackgroundColor();
setForegroundColor(fg);
setBackgroundColor(bg);
headline.setForegroundColor(fg);
headline.setBackgroundColor(bg);
}
// Text label
finalcut::FLabel* headline = new finalcut::FLabel (this);
headline->setGeometry(1, 1, 8, 1);
headline->setEmphasis();
headline->setAlignment (finalcut::fc::alignCenter);
*headline << "Brush";
headline.setGeometry(1, 1, 8, 1);
headline.setEmphasis();
headline.setAlignment (finalcut::fc::alignCenter);
headline << "Brush";
}
//----------------------------------------------------------------------
@ -316,8 +326,8 @@ class MouseDraw : public finalcut::FDialog
void setGeometry (int, int, int, int, bool = true);
// Event handlers
void onAccel (finalcut::FAccelEvent*);
void onClose (finalcut::FCloseEvent*);
virtual void onAccel (finalcut::FAccelEvent*);
virtual void onClose (finalcut::FCloseEvent*);
private:
// Disable copy constructor
@ -329,19 +339,19 @@ class MouseDraw : public finalcut::FDialog
virtual void draw();
void drawBrush (int, int, bool = false);
void drawCanvas();
void adjustSize();
virtual void adjustSize();
// Event handler
void onMouseDown (finalcut::FMouseEvent*);
void onMouseMove (finalcut::FMouseEvent*);
virtual void onMouseDown (finalcut::FMouseEvent*);
virtual void onMouseMove (finalcut::FMouseEvent*);
// Callback methods
void cb_colorChanged (finalcut::FWidget*, data_ptr);
// Data Members
term_area* canvas;
ColorChooser* c_chooser;
Brushes* brush;
term_area* canvas;
ColorChooser c_chooser;
Brushes brush;
};
#pragma pack(pop)
@ -349,20 +359,18 @@ class MouseDraw : public finalcut::FDialog
MouseDraw::MouseDraw (finalcut::FWidget* parent)
: finalcut::FDialog(parent)
, canvas(0)
, c_chooser()
, brush()
, c_chooser(this)
, brush(this)
{
setText ("Drawing with the mouse");
c_chooser = new ColorChooser(this);
c_chooser->setPos (1, 1);
c_chooser->addCallback
c_chooser.setPos (1, 1);
c_chooser.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &MouseDraw::cb_colorChanged)
);
brush = new Brushes(this);
brush->setPos (1, 12);
brush.setPos (1, 12);
finalcut::FPoint no_shadow(0,0);
finalcut::FRect scroll_geometry(0, 0, 1, 1);
@ -450,15 +458,15 @@ void MouseDraw::drawBrush (int x, int y, bool swap_color)
if ( x > 10 && x < Cols && y > 2 && y < Lines )
{
if ( swap_color )
setColor (c_chooser->getBackground(), c_chooser->getForeground());
setColor (c_chooser.getBackground(), c_chooser.getForeground());
else
setColor (c_chooser->getForeground(), c_chooser->getBackground());
setColor (c_chooser.getForeground(), c_chooser.getBackground());
// set canvas print cursor position
canvas->cursor_x = x - canvas->offset_left - 10;
canvas->cursor_y = y - canvas->offset_top - 2;
// print on canvas
print (canvas, brush->getBrush());
print (canvas, brush.getBrush());
// copy canvas to the dialog
drawCanvas();
}
@ -539,9 +547,9 @@ void MouseDraw::onMouseMove (finalcut::FMouseEvent* ev)
//----------------------------------------------------------------------
void MouseDraw::cb_colorChanged (finalcut::FWidget*, data_ptr)
{
brush->setForeground (c_chooser->getForeground());
brush->setBackground (c_chooser->getBackground());
brush->redraw();
brush.setForeground (c_chooser.getForeground());
brush.setBackground (c_chooser.getBackground());
brush.redraw();
}

View File

@ -49,7 +49,7 @@ class Scrollview : public finalcut::FScrollView
Scrollview& operator = (const Scrollview&);
// Method
void draw();
virtual void draw();
// Callback methods
void cb_go_east (finalcut::FWidget*, data_ptr);
@ -58,58 +58,55 @@ class Scrollview : public finalcut::FScrollView
void cb_go_north (finalcut::FWidget*, data_ptr);
// Data Members
finalcut::FButton* go_east;
finalcut::FButton* go_south;
finalcut::FButton* go_west;
finalcut::FButton* go_north;
wchar_t pointer_right;
wchar_t pointer_down;
wchar_t pointer_left;
wchar_t pointer_up;
finalcut::FButton go_east;
finalcut::FButton go_south;
finalcut::FButton go_west;
finalcut::FButton go_north;
};
#pragma pack(pop)
//----------------------------------------------------------------------
Scrollview::Scrollview (finalcut::FWidget* parent)
: finalcut::FScrollView(parent)
, go_east()
, go_south()
, go_west()
, go_north()
, pointer_right(wchar_t(finalcut::fc::BlackRightPointingPointer))
, pointer_down(wchar_t(finalcut::fc::BlackDownPointingTriangle))
, pointer_left(wchar_t(finalcut::fc::BlackLeftPointingPointer))
, pointer_up(wchar_t(finalcut::fc::BlackUpPointingTriangle))
, go_east(pointer_right, this)
, go_south(pointer_down, this)
, go_west(pointer_left, this)
, go_north(pointer_up, this)
{
// Create the four navigation buttons
wchar_t pointer_right = wchar_t(finalcut::fc::BlackRightPointingPointer);
go_east = new finalcut::FButton(pointer_right, this);
go_east->setGeometry (1, 1, 5, 1);
wchar_t pointer_down = wchar_t(finalcut::fc::BlackDownPointingTriangle);
go_south = new finalcut::FButton(pointer_down, this);
go_south->setGeometry (getScrollWidth() - 5, 1, 5, 1);
wchar_t pointer_left = wchar_t(finalcut::fc::BlackLeftPointingPointer);
go_west = new finalcut::FButton(pointer_left, this);
go_west->setGeometry (getScrollWidth() - 5, getScrollHeight() - 2, 5, 1);
wchar_t pointer_up = wchar_t(finalcut::fc::BlackUpPointingTriangle);
go_north = new finalcut::FButton(pointer_up, this);
go_north->setGeometry (1, getScrollHeight() - 2, 5, 1);
// Sets the navigation button geometry
go_east.setGeometry (1, 1, 5, 1);
go_south.setGeometry (getScrollWidth() - 5, 1, 5, 1);
go_west.setGeometry (getScrollWidth() - 5, getScrollHeight() - 2, 5, 1);
go_north.setGeometry (1, getScrollHeight() - 2, 5, 1);
// Add scroll function callbacks to the buttons
go_east->addCallback
go_east.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &Scrollview::cb_go_east)
);
go_south->addCallback
go_south.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &Scrollview::cb_go_south)
);
go_west->addCallback
go_west.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &Scrollview::cb_go_west)
);
go_north->addCallback
go_north.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &Scrollview::cb_go_north)
@ -124,9 +121,9 @@ Scrollview::~Scrollview()
void Scrollview::setScrollSize (int width, int height)
{
FScrollView::setScrollSize (width, height);
go_south->setPos (width - 5, 1);
go_west->setPos (width - 5, height - 1);
go_north->setPos (1, height - 1);
go_south.setPos (width - 5, 1);
go_west.setPos (width - 5, height - 1);
go_north.setPos (1, height - 1);
}
//----------------------------------------------------------------------
@ -156,36 +153,36 @@ void Scrollview::draw()
void Scrollview::cb_go_east (finalcut::FWidget*, data_ptr)
{
scrollToX (getScrollWidth() - getViewportWidth() + 1);
go_south->setFocus();
go_east->redraw();
go_south->redraw();
go_south.setFocus();
go_east.redraw();
go_south.redraw();
}
//----------------------------------------------------------------------
void Scrollview::cb_go_south (finalcut::FWidget*, data_ptr)
{
scrollToY (getScrollHeight() - getViewportHeight() + 1);
go_west->setFocus();
go_south->redraw();
go_west->redraw();
go_west.setFocus();
go_south.redraw();
go_west.redraw();
}
//----------------------------------------------------------------------
void Scrollview::cb_go_west (finalcut::FWidget*, data_ptr)
{
scrollToX (1);
go_north->setFocus();
go_west->redraw();
go_north->redraw();
go_north.setFocus();
go_west.redraw();
go_north.redraw();
}
//----------------------------------------------------------------------
void Scrollview::cb_go_north (finalcut::FWidget*, data_ptr)
{
scrollToY (1);
go_east->setFocus();
go_north->redraw();
go_east->redraw();
go_east.setFocus();
go_north.redraw();
go_east.redraw();
}
@ -206,10 +203,15 @@ class Scrollviewdemo : public finalcut::FDialog
~Scrollviewdemo();
// Event handler
void onClose (finalcut::FCloseEvent*);
virtual void onClose (finalcut::FCloseEvent*);
// Callback method
void cb_quit (finalcut::FWidget* = 0, data_ptr = 0);
// Data Members
Scrollview sview;
finalcut::FButton quit_btn;
finalcut::FLabel label;
};
#pragma pack(pop)
@ -217,31 +219,31 @@ class Scrollviewdemo : public finalcut::FDialog
//----------------------------------------------------------------------
Scrollviewdemo::Scrollviewdemo (finalcut::FWidget* parent)
: finalcut::FDialog(parent)
, sview(this)
, quit_btn("&Quit", this)
, label(this)
{
setGeometry (16, 3, 50, 19);
setText ("Scrolling viewport example");
// The scrolling viewport widget
Scrollview* sview = new Scrollview (this);
sview->setGeometry(3, 2, 44, 12);
sview->setScrollSize(188, 124);
sview.setGeometry(3, 2, 44, 12);
sview.setScrollSize(188, 124);
// Quit button
finalcut::FButton* button = new finalcut::FButton("&Quit", this);
button->setGeometry(37, 15, 10, 1);
quit_btn.setGeometry(37, 15, 10, 1);
// Add function callback
button->addCallback
quit_btn.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &Scrollviewdemo::cb_quit)
);
// Text label
finalcut::FLabel* label = new finalcut::FLabel (this);
label->setGeometry(2, 1, 46, 1);
label->setEmphasis();
*label << L"Use scrollbars to change the viewport position";
label.setGeometry(2, 1, 46, 1);
label.setEmphasis();
label << L"Use scrollbars to change the viewport position";
}
//----------------------------------------------------------------------

View File

@ -40,9 +40,9 @@ class AttribDlg : public finalcut::FDialog
~AttribDlg();
// Event handlers
void onAccel (finalcut::FAccelEvent*);
void onWheel (finalcut::FWheelEvent*);
void onClose (finalcut::FCloseEvent*);
virtual void onAccel (finalcut::FAccelEvent*);
virtual void onWheel (finalcut::FWheelEvent*);
virtual void onClose (finalcut::FCloseEvent*);
// Callback methods
void cb_next (finalcut::FWidget* = 0, data_ptr = 0);
@ -58,11 +58,11 @@ class AttribDlg : public finalcut::FDialog
AttribDlg& operator = (const AttribDlg&);
// Method
void adjustSize();
virtual void adjustSize();
// Data Members
finalcut::FButton* next_button;
finalcut::FButton* back_button;
finalcut::FButton next_button;
finalcut::FButton back_button;
};
#pragma pack(pop)
@ -70,28 +70,26 @@ class AttribDlg : public finalcut::FDialog
AttribDlg::AttribDlg (finalcut::FWidget* parent)
: finalcut::FDialog(parent)
, bgcolor(wc.label_bg)
, next_button()
, back_button()
, next_button("&Next >", this)
, back_button("< &Back", this)
{
setText ( "A terminal attributes test ("
+ finalcut::FString(getTermType())
+ ")");
next_button = new finalcut::FButton("&Next >", this);
next_button->setGeometry(getWidth() - 13, getHeight() - 4, 10, 1);
next_button->addAccelerator(finalcut::fc::Fkey_right);
back_button = new finalcut::FButton("< &Back", this);
back_button->setGeometry(getWidth() - 25, getHeight() - 4, 10, 1);
back_button->addAccelerator(finalcut::fc::Fkey_left);
next_button.setGeometry(getWidth() - 13, getHeight() - 4, 10, 1);
next_button.addAccelerator(finalcut::fc::Fkey_right);
back_button.setGeometry(getWidth() - 25, getHeight() - 4, 10, 1);
back_button.addAccelerator(finalcut::fc::Fkey_left);
// Add function callbacks
next_button->addCallback
next_button.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &AttribDlg::cb_next)
);
back_button->addCallback
back_button.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &AttribDlg::cb_back)
@ -167,8 +165,8 @@ void AttribDlg::adjustSize()
y = 1;
setGeometry(x, y, 69, 21, false);
next_button->setGeometry(getWidth() - 13, getHeight() - 4, 10, 1, false);
back_button->setGeometry(getWidth() - 25, getHeight() - 4, 10, 1, false);
next_button.setGeometry(getWidth() - 13, getHeight() - 4, 10, 1, false);
back_button.setGeometry(getWidth() - 25, getHeight() - 4, 10, 1, false);
finalcut::FDialog::adjustSize();
}
@ -191,7 +189,7 @@ class AttribDemo : public finalcut::FWidget
{ }
// Event handler
void onWheel (finalcut::FWheelEvent* ev)
virtual void onWheel (finalcut::FWheelEvent* ev)
{
AttribDlg* p = static_cast<AttribDlg*>(getParentWidget());
@ -216,7 +214,7 @@ class AttribDemo : public finalcut::FWidget
void printStandout();
void printInvisible();
void printProtected();
void draw();
virtual void draw();
// Data Member
int colors;
@ -492,20 +490,20 @@ int main (int argc, char* argv[])
// Create a dialog box object.
// This object will be automatically deleted by
// the parent object "app" (FObject destructor).
AttribDlg* dialog = new AttribDlg(&app);
AttribDlg dialog(&app);
dialog->setGeometry (6, 2, 69, 21);
dialog->addAccelerator('q'); // press 'q' to quit
dialog->setShadow();
dialog.setGeometry (6, 2, 69, 21);
dialog.addAccelerator('q'); // press 'q' to quit
dialog.setShadow();
// Create the attribute demo widget as a child object from the dialog
AttribDemo* demo = new AttribDemo(dialog);
demo->setGeometry (1, 1, 67, 19);
AttribDemo demo(&dialog);
demo.setGeometry (1, 1, 67, 19);
// Set the dialog object as main widget
app.setMainWidget(dialog);
app.setMainWidget(&dialog);
// Show and start the application
dialog->show();
dialog.show();
return app.exec();
}

View File

@ -39,18 +39,32 @@ void booleans();
void numeric();
void string(finalcut::FTermcap::tcap_map*&);
//----------------------------------------------------------------------
// struct data
//----------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
struct termcap_string
struct data
{
const std::string name;
const finalcut::fc::termcaps cap;
static int getNumberOfItems();
struct termcap_string
{
const std::string name;
const finalcut::fc::termcaps cap;
};
static termcap_string strings[];
};
#pragma pack(pop)
// String data array
static const termcap_string strings[] =
//----------------------------------------------------------------------
// struct data - string data array
//----------------------------------------------------------------------
data::termcap_string data::strings[] =
{
{ "t_bell", finalcut::fc::t_bell },
{ "t_erase_chars", finalcut::fc::t_erase_chars },
@ -136,7 +150,12 @@ static const termcap_string strings[] =
{ "t_key_mouse", finalcut::fc::t_key_mouse }
};
const int last_item = int ( sizeof(strings) / sizeof(strings[0]) ) - 1;
// data inline functions
//----------------------------------------------------------------------
inline int data::getNumberOfItems()
{
return int ( sizeof(strings) / sizeof(strings[0]) ) - 1;
}
//----------------------------------------------------------------------
@ -272,10 +291,10 @@ void string(finalcut::FTermcap::tcap_map*& tcap)
{
std::cout << "\r\n[String]\r\n";
for (int n = 0; n <= last_item; n++ )
for (int n = 0; n <= data::getNumberOfItems(); n++ )
{
const std::string name = strings[n].name;
const finalcut::fc::termcaps cap = strings[n].cap;
const std::string name = data::strings[n].name;
const finalcut::fc::termcaps cap = data::strings[n].cap;
tcapString (name, tcap[cap].string);
}
}

View File

@ -35,11 +35,11 @@ class Timer : public finalcut::FWidget
protected:
// Method
void draw();
virtual void draw();
// Event handlers
void onTimer (finalcut::FTimerEvent*);
void onAccel (finalcut::FAccelEvent*);
virtual void onTimer (finalcut::FTimerEvent*);
virtual void onAccel (finalcut::FAccelEvent*);
};
//----------------------------------------------------------------------

View File

@ -41,7 +41,6 @@ class Transparent : public finalcut::FDialog
inherit_background = 2
} trans_type;
public:
// Constructor
explicit Transparent (finalcut::FWidget* = 0, trans_type = transparent);
@ -56,10 +55,10 @@ class Transparent : public finalcut::FDialog
Transparent& operator = (const Transparent&);
// Method
void draw();
virtual void draw();
// Event handlers
void onKeyPress (finalcut::FKeyEvent* ev);
virtual void onKeyPress (finalcut::FKeyEvent* ev);
// Data Members
trans_type type;
@ -150,9 +149,11 @@ void Transparent::onKeyPress (finalcut::FKeyEvent* ev)
class MainWindow : public finalcut::FDialog
{
private:
finalcut::FString line1;
finalcut::FString line2;
public:
// Constructor
explicit MainWindow (finalcut::FWidget* = 0);
// Destructor
~MainWindow();
private:
// Disable copy constructor
@ -160,13 +161,13 @@ class MainWindow : public finalcut::FDialog
// Disable assignment operator (=)
MainWindow& operator = (const MainWindow&);
void draw();
virtual void draw();
// Event handlers
void onClose (finalcut::FCloseEvent*);
void onShow (finalcut::FShowEvent*);
void onTimer (finalcut::FTimerEvent*);
void onKeyPress (finalcut::FKeyEvent* ev)
virtual void onClose (finalcut::FCloseEvent*);
virtual void onShow (finalcut::FShowEvent*);
virtual void onTimer (finalcut::FTimerEvent*);
virtual void onKeyPress (finalcut::FKeyEvent* ev)
{
if ( ! ev )
return;
@ -180,11 +181,13 @@ class MainWindow : public finalcut::FDialog
finalcut::FDialog::onKeyPress(ev);
}
public:
// Constructor
explicit MainWindow (finalcut::FWidget* = 0);
// Destructor
~MainWindow();
// Data Members
finalcut::FString line1;
finalcut::FString line2;
Transparent transpwin;
Transparent shadowwin;
Transparent ibg;
finalcut::FStatusBar status_bar;
};
#pragma pack(pop)
@ -193,28 +196,28 @@ MainWindow::MainWindow (finalcut::FWidget* parent)
: FDialog(parent)
, line1()
, line2()
, transpwin(this)
, shadowwin(this, Transparent::shadow)
, ibg(this, Transparent::inherit_background)
, status_bar(this)
{
line1 = " .-. .-. .-.";
line2 = "`._.' `._.' `._.' ";
Transparent* transpwin = new Transparent(this);
transpwin->setText("transparent");
transpwin->setGeometry (6, 3, 29, 12);
transpwin->unsetTransparentShadow();
transpwin.setText("transparent");
transpwin.setGeometry (6, 3, 29, 12);
transpwin.unsetTransparentShadow();
Transparent* shadowwin = new Transparent(this, Transparent::shadow);
shadowwin->setText("shadow");
shadowwin->setGeometry (46, 11, 29, 12);
shadowwin->unsetTransparentShadow();
shadowwin.setText("shadow");
shadowwin.setGeometry (46, 11, 29, 12);
shadowwin.unsetTransparentShadow();
Transparent* ibg = new Transparent(this, Transparent::inherit_background);
ibg->setText("inherit background");
ibg->setGeometry (42, 3, 29, 7);
ibg->unsetTransparentShadow();
ibg.setText("inherit background");
ibg.setGeometry (42, 3, 29, 7);
ibg.unsetTransparentShadow();
// Statusbar at the bottom
finalcut::FStatusBar* status_bar = new finalcut::FStatusBar (this);
status_bar->setMessage("Press Q to quit");
status_bar.setMessage("Press Q to quit");
addAccelerator('q');
unsetTransparentShadow();

View File

@ -53,20 +53,21 @@ class Treeview : public finalcut::FDialog
Treeview& operator = (const Treeview&);
// Methods
void adjustSize();
TreeItem* getAfrica();
TreeItem* getAsia();
TreeItem* getEurope();
TreeItem* getNorthAmerica();
TreeItem* getSouthAmerica();
TreeItem* getOceania();
virtual void adjustSize();
// Event handlers
void onClose (finalcut::FCloseEvent*);
// Data Members
finalcut::FListView* listView;
finalcut::FButton* Quit;
bool initialized;
finalcut::FListView listView;
finalcut::FButton Quit;
static TreeItem africa[];
static TreeItem asia[];
static TreeItem europe[];
static TreeItem north_america[];
static TreeItem south_america[];
static TreeItem oceania[];
};
#pragma pack(pop)
@ -94,192 +95,154 @@ struct Treeview::TreeItem
#pragma pack(pop)
//----------------------------------------------------------------------
Treeview::TreeItem* Treeview::getAfrica()
{
static TreeItem africa[] =
{
{ "Algeria", "40,400,000", "15.9", 0 },
{ "Angola", "25,789,024", "20.69", 0 },
{ "Botswana", "2,250,260", "3.7", 0 },
{ "Cameroon", "22,534,532", "39.7", 0 },
{ "Chad", "13,670,084", "8.6", 0 },
{ "Egypt", "94,666,000", "87", 0 },
{ "Ethiopia", "102,374,044", "92.7", 0 },
{ "Ivory Coast", "23,740,424", "63.9", 0 },
{ "Libya", "6,541,948", "3.55", 0 },
{ "Madagascar", "24,430,325", "35.2", 0 },
{ "Mali", "14,517,176", "11.7", 0 },
{ "Mauritania", "4,301,018", "3.4", 0 },
{ "Mozambique", "24,692,144", "28.7", 0 },
{ "Namibia", "2,113,077", "2.54", 0 },
{ "Niger", "20,672,987", "12.1", 0 },
{ "Nigeria", "185,989,640", "197.2", 0 },
{ "Somalia", "14,317,996", "19.31", 0 },
{ "South Africa", "54,956,900", "42.4", 0 },
{ "South Sudan", "12,340,000", "13.33", 0 },
{ "Sudan", "39,578,828", "21.3", 0 },
{ "Tanzania", "51,820,00", "47.5", 0 },
{ "Zambia", "16,212,000", "17.2", 0 },
{ 0, 0, 0, 0 }
};
return africa;
}
// class Treeview - array data
//----------------------------------------------------------------------
Treeview::TreeItem* Treeview::getAsia()
Treeview::TreeItem Treeview::africa[] =
{
static TreeItem asia[] =
{
{ "Afghanistan", "34,656,032", "49.88", 0 },
{ "China", "1,403,500,365", "145.0", 0 },
{ "India", "1,324,171,354", "393.9", 0 },
{ "Indonesia", "261,115,456", "124.66", 0 },
{ "Iran", "80,829,192", "48.0", 0 },
{ "Iraq", "37,202,572", "82.7", 0 },
{ "Japan", "126,740,000", "336.0", 0 },
{ "Kazakhstan", "17,987,736", "6.49", 0 },
{ "Mongolia", "3,081,677", "1.97", 0 },
{ "Myanmar", "51,486,253", "76.0", 0 },
{ "Pakistan", "207,774,520", "244.4", 0 },
{ "Russia", "144,463,451", "8.4", 0 },
{ "Saudi Arabia", "33,000,000", "15.0", 0 },
{ "Thailand", "68,863,514", "132.1", 0 },
{ "Turkey", "79,814,871", "102.0", 0 },
{ "Turkmenistan", "5,662,544", "10.5", 0 },
{ "Uzbekistan", "32,979,000", "70.5", 0 },
{ "Vietnam", "94,569,072", "276.03", 0 },
{ "Yemen", "27,584,213", "44.7", 0 },
{ 0, 0, 0, 0 }
};
{ "Algeria", "40,400,000", "15.9", 0 },
{ "Angola", "25,789,024", "20.69", 0 },
{ "Botswana", "2,250,260", "3.7", 0 },
{ "Cameroon", "22,534,532", "39.7", 0 },
{ "Chad", "13,670,084", "8.6", 0 },
{ "Egypt", "94,666,000", "87", 0 },
{ "Ethiopia", "102,374,044", "92.7", 0 },
{ "Ivory Coast", "23,740,424", "63.9", 0 },
{ "Libya", "6,541,948", "3.55", 0 },
{ "Madagascar", "24,430,325", "35.2", 0 },
{ "Mali", "14,517,176", "11.7", 0 },
{ "Mauritania", "4,301,018", "3.4", 0 },
{ "Mozambique", "24,692,144", "28.7", 0 },
{ "Namibia", "2,113,077", "2.54", 0 },
{ "Niger", "20,672,987", "12.1", 0 },
{ "Nigeria", "185,989,640", "197.2", 0 },
{ "Somalia", "14,317,996", "19.31", 0 },
{ "South Africa", "54,956,900", "42.4", 0 },
{ "South Sudan", "12,340,000", "13.33", 0 },
{ "Sudan", "39,578,828", "21.3", 0 },
{ "Tanzania", "51,820,00", "47.5", 0 },
{ "Zambia", "16,212,000", "17.2", 0 },
{ 0, 0, 0, 0 }
};
return asia;
}
//----------------------------------------------------------------------
Treeview::TreeItem* Treeview::getEurope()
Treeview::TreeItem Treeview::asia[] =
{
static TreeItem europe[] =
{
{ "Austria", "8,794,267", "104.0", 0 },
{ "Belarus", "9,498,700", "45.8", 0 },
{ "Bulgaria", "7,101,859", "64.9", 0 },
{ "Czech Republic", "10,610,947", "134.0", 0 },
{ "Finland", "5,506,312", "16.0", 0 },
{ "France", "66,991,000", "103.0", 0 },
{ "Germany", "82,175,700", "227.0", 0 },
{ "Greece", "11,183,716", "82.0", 0 },
{ "Hungary", "9,797,561", "105.3", 0 },
{ "Iceland", "332,529", "3.2", 0 },
{ "Italy", "60,589,445", "201.3", 0 },
{ "Norway", "5,267,146", "15.8", 0 },
{ "Poland", "38,634,007", "123.0", 0 },
{ "Portugal", "10,309,573", "115.0", 0 },
{ "Romania", "19,638,000", "84.4", 0 },
{ "Serbia", "7,058,322", "91.1", 0 },
{ "Spain", "46,468,102", "92.0", 0 },
{ "Sweden", "10,065,389", "22.0", 0 },
{ "United Kingdom", "65,648,000", "270.7", 0 },
{ 0, 0, 0, 0 }
};
{ "Afghanistan", "34,656,032", "49.88", 0 },
{ "China", "1,403,500,365", "145.0", 0 },
{ "India", "1,324,171,354", "393.9", 0 },
{ "Indonesia", "261,115,456", "124.66", 0 },
{ "Iran", "80,829,192", "48.0", 0 },
{ "Iraq", "37,202,572", "82.7", 0 },
{ "Japan", "126,740,000", "336.0", 0 },
{ "Kazakhstan", "17,987,736", "6.49", 0 },
{ "Mongolia", "3,081,677", "1.97", 0 },
{ "Myanmar", "51,486,253", "76.0", 0 },
{ "Pakistan", "207,774,520", "244.4", 0 },
{ "Russia", "144,463,451", "8.4", 0 },
{ "Saudi Arabia", "33,000,000", "15.0", 0 },
{ "Thailand", "68,863,514", "132.1", 0 },
{ "Turkey", "79,814,871", "102.0", 0 },
{ "Turkmenistan", "5,662,544", "10.5", 0 },
{ "Uzbekistan", "32,979,000", "70.5", 0 },
{ "Vietnam", "94,569,072", "276.03", 0 },
{ "Yemen", "27,584,213", "44.7", 0 },
{ 0, 0, 0, 0 }
};
return europe;
}
//----------------------------------------------------------------------
Treeview::TreeItem* Treeview::getNorthAmerica()
Treeview::TreeItem Treeview::europe[] =
{
static TreeItem north_america[] =
{
{ "Canada", "35,151,728", "3.92", 0 },
{ "Cuba", "11,239,224", "102.3", 0 },
{ "Greenland", "56,483", "0.028", 0 },
{ "Guatemala", "16,582,469", "129.0", 0 },
{ "Honduras", "9,112,867", "64.0", 0 },
{ "Mexico", "119,530,753", "61.0", 0 },
{ "Nicaragua", "6,167,237", "51.0", 0 },
{ "USA", "325,365,189", "35.0", 0 },
{ 0, 0, 0, 0 }
};
{ "Austria", "8,794,267", "104.0", 0 },
{ "Belarus", "9,498,700", "45.8", 0 },
{ "Bulgaria", "7,101,859", "64.9", 0 },
{ "Czech Republic", "10,610,947", "134.0", 0 },
{ "Finland", "5,506,312", "16.0", 0 },
{ "France", "66,991,000", "103.0", 0 },
{ "Germany", "82,175,700", "227.0", 0 },
{ "Greece", "11,183,716", "82.0", 0 },
{ "Hungary", "9,797,561", "105.3", 0 },
{ "Iceland", "332,529", "3.2", 0 },
{ "Italy", "60,589,445", "201.3", 0 },
{ "Norway", "5,267,146", "15.8", 0 },
{ "Poland", "38,634,007", "123.0", 0 },
{ "Portugal", "10,309,573", "115.0", 0 },
{ "Romania", "19,638,000", "84.4", 0 },
{ "Serbia", "7,058,322", "91.1", 0 },
{ "Spain", "46,468,102", "92.0", 0 },
{ "Sweden", "10,065,389", "22.0", 0 },
{ "United Kingdom", "65,648,000", "270.7", 0 },
{ 0, 0, 0, 0 }
};
return north_america;
}
//----------------------------------------------------------------------
Treeview::TreeItem* Treeview::getSouthAmerica()
Treeview::TreeItem Treeview::north_america[] =
{
static TreeItem south_america[] =
{
{ "Argentina", "43,847,430", "14.4", 0 },
{ "Bolivia", "11,410,651", "10.4", 0 },
{ "Brazil", "208,064,000", "24.35", 0 },
{ "Chile", "18,006,407", "24.0", 0 },
{ "Colombia", "49,364,592", "40.74", 0 },
{ "Ecuador", "16,385,068", "58.95", 0 },
{ "Guyana", "773,303", "3.502", 0 },
{ "Paraguay", "6,725,308", "17.2", 0 },
{ "Peru", "31,826,018", "23.0", 0 },
{ "Venezuela", "31,568,179", "33.75", 0 },
{ 0, 0, 0, 0 }
};
{ "Canada", "35,151,728", "3.92", 0 },
{ "Cuba", "11,239,224", "102.3", 0 },
{ "Greenland", "56,483", "0.028", 0 },
{ "Guatemala", "16,582,469", "129.0", 0 },
{ "Honduras", "9,112,867", "64.0", 0 },
{ "Mexico", "119,530,753", "61.0", 0 },
{ "Nicaragua", "6,167,237", "51.0", 0 },
{ "USA", "325,365,189", "35.0", 0 },
{ 0, 0, 0, 0 }
};
return south_america;
}
//----------------------------------------------------------------------
Treeview::TreeItem* Treeview::getOceania()
Treeview::TreeItem Treeview::south_america[] =
{
static TreeItem oceania[] =
{
{ "Australia", "24,675,900", "3.2", 0 },
{ "Papua New Guinea", "7,059,653", "15.0", 0 },
{ "Papua", "3,486,432", "11.0", 0 },
{ "New Zealand", "4,823,090", "17.5", 0 },
{ "West Papua", "877,437", "6.3", 0 },
{ "Solomon Islands", "599,419", "18.1", 0 },
{ "New Caledonia", "268,767", "14.5", 0 },
{ "Fiji", "898,76", "46.4", 0 },
{ "Hawaii", "1,428,557", "82.6", 0 },
{ "Vanuatu", "270,402", "19.7", 0 },
{ "French Polynesia", "280,208", "76.0", 0 },
{ "Samoa", "192,342", "68.0", 0 },
{ "Kiribati", "110,136", "152.0", 0 },
{ 0, 0, 0, 0 }
};
{ "Argentina", "43,847,430", "14.4", 0 },
{ "Bolivia", "11,410,651", "10.4", 0 },
{ "Brazil", "208,064,000", "24.35", 0 },
{ "Chile", "18,006,407", "24.0", 0 },
{ "Colombia", "49,364,592", "40.74", 0 },
{ "Ecuador", "16,385,068", "58.95", 0 },
{ "Guyana", "773,303", "3.502", 0 },
{ "Paraguay", "6,725,308", "17.2", 0 },
{ "Peru", "31,826,018", "23.0", 0 },
{ "Venezuela", "31,568,179", "33.75", 0 },
{ 0, 0, 0, 0 }
};
return oceania;
}
Treeview::TreeItem Treeview::oceania[] =
{
{ "Australia", "24,675,900", "3.2", 0 },
{ "Papua New Guinea", "7,059,653", "15.0", 0 },
{ "Papua", "3,486,432", "11.0", 0 },
{ "New Zealand", "4,823,090", "17.5", 0 },
{ "West Papua", "877,437", "6.3", 0 },
{ "Solomon Islands", "599,419", "18.1", 0 },
{ "New Caledonia", "268,767", "14.5", 0 },
{ "Fiji", "898,76", "46.4", 0 },
{ "Hawaii", "1,428,557", "82.6", 0 },
{ "Vanuatu", "270,402", "19.7", 0 },
{ "French Polynesia", "280,208", "76.0", 0 },
{ "Samoa", "192,342", "68.0", 0 },
{ "Kiribati", "110,136", "152.0", 0 },
{ 0, 0, 0, 0 }
};
// constructors and destructor
//----------------------------------------------------------------------
Treeview::Treeview (finalcut::FWidget* parent)
: finalcut::FDialog(parent)
, listView()
, Quit()
, initialized(false)
, listView(this)
, Quit(this)
{
// Create FListView object
listView = new finalcut::FListView (this);
listView->setGeometry(2, 1, 53, 14);
listView.setGeometry(2, 1, 53, 14);
// Add columns to the view
listView->addColumn ("Name", 23);
listView->addColumn ("Population");
listView->addColumn ("Density/km²");
listView.addColumn ("Name", 23);
listView.addColumn ("Population");
listView.addColumn ("Density/km²");
// Set right alignment for the second and third column
listView->setColumnAlignment (2, finalcut::fc::alignRight);
listView->setColumnAlignment (3, finalcut::fc::alignRight);
listView.setColumnAlignment (2, finalcut::fc::alignRight);
listView.setColumnAlignment (3, finalcut::fc::alignRight);
// Activate tree view
listView->setTreeView();
listView.setTreeView();
// Populate FListView with a list of items
TreeItem* africa = getAfrica();
TreeItem* asia = getAsia();
TreeItem* europe = getEurope();
TreeItem* north_america = getNorthAmerica();
TreeItem* south_america = getSouthAmerica();
TreeItem* oceania = getOceania();
static TreeItem continent[] =
{
{ "Africa", "944,000,000", "31.2", africa },
@ -300,13 +263,13 @@ Treeview::Treeview (finalcut::FWidget* parent)
finalcut::FStringList continent_line ( continent_list->begin()
, continent_list->end() );
finalcut::FListViewIterator::FObjectIterator iter = \
listView->insert (continent_line);
listView.insert (continent_line);
while ( country_list && country_list->name )
{
finalcut::FStringList country_line ( country_list->begin()
, country_list->end() );
listView->insert (country_line, iter);
listView.insert (country_line, iter);
country_list++;
}
@ -314,16 +277,17 @@ Treeview::Treeview (finalcut::FWidget* parent)
}
// Quit button
Quit = new finalcut::FButton (this);
Quit->setGeometry(24, 16, 10, 1);
Quit->setText (L"&Quit");
Quit.setGeometry(24, 16, 10, 1);
Quit.setText (L"&Quit");
// Add some function callbacks
Quit->addCallback
Quit.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &finalcut::FApplication::cb_exitApp)
);
initialized = true;
}
//----------------------------------------------------------------------
@ -342,11 +306,11 @@ void Treeview::adjustSize()
setX (X, false);
if ( listView )
listView->setHeight (getHeight() - 6, false);
if ( Quit )
Quit->setY(getHeight() - 4);
if ( initialized )
{
listView.setHeight (getHeight() - 6, false);
Quit.setY(getHeight() - 4);
}
finalcut::FDialog::adjustSize();
}

View File

@ -50,8 +50,8 @@ class ProgressDialog : public finalcut::FDialog
ProgressDialog& operator = (const ProgressDialog&);
// Event handlers
void onShow (finalcut::FShowEvent*);
void onTimer (finalcut::FTimerEvent*);
virtual void onShow (finalcut::FShowEvent*);
virtual void onTimer (finalcut::FTimerEvent*);
// Callback methods
void cb_reset_bar (finalcut::FWidget*, data_ptr);
@ -59,59 +59,55 @@ class ProgressDialog : public finalcut::FDialog
void cb_exit_bar (finalcut::FWidget*, data_ptr);
// Data Members
finalcut::FProgressbar* progressBar;
finalcut::FButton* reset;
finalcut::FButton* more;
finalcut::FButton* quit;
finalcut::FProgressbar progressBar;
finalcut::FButton reset;
finalcut::FButton more;
finalcut::FButton quit;
};
#pragma pack(pop)
//----------------------------------------------------------------------
ProgressDialog::ProgressDialog (finalcut::FWidget* parent)
: finalcut::FDialog(parent)
, progressBar()
, reset()
, more()
, quit()
, progressBar(this)
, reset(this)
, more(this)
, quit(this)
{
setGeometry (int((getParentWidget()->getWidth() - 40) / 2), 7, 40, 10);
setText("Progress bar");
//setModal();
reset = new finalcut::FButton(this);
reset->setText("&Reset");
reset->setStatusbarMessage ("Reset the progress bar");
reset->setGeometry(2, 6, 8, 1, false);
reset->setDisable();
reset.setText("&Reset");
reset.setStatusbarMessage ("Reset the progress bar");
reset.setGeometry(2, 6, 8, 1, false);
reset.setDisable();
more = new finalcut::FButton(this);
more->setText("&More");
more->setStatusbarMessage ("Increases the progress bar position");
more->setGeometry(15, 6, 8, 1, false);
more->setDisable();
more.setText("&More");
more.setStatusbarMessage ("Increases the progress bar position");
more.setGeometry(15, 6, 8, 1, false);
more.setDisable();
quit = new finalcut::FButton(this);
quit->setText("E&xit");
quit->setGeometry(28, 6, 8, 1, false);
quit->setDisable();
quit.setText("E&xit");
quit.setGeometry(28, 6, 8, 1, false);
quit.setDisable();
progressBar = new finalcut::FProgressbar(this);
progressBar->setGeometry(2, 3, 34, 1, false);
//progressBar->setPercentage(78);
progressBar.setGeometry(2, 3, 34, 1, false);
//progressBar.setPercentage(78);
reset->addCallback
reset.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &ProgressDialog::cb_reset_bar)
);
more->addCallback
more.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &ProgressDialog::cb_more_bar)
);
quit->addCallback
quit.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &ProgressDialog::cb_exit_bar)
@ -122,13 +118,9 @@ ProgressDialog::ProgressDialog (finalcut::FWidget* parent)
ProgressDialog::~ProgressDialog() // destructor
{
delOwnTimer();
delCallback(quit);
delCallback(more);
delCallback(reset);
delete(progressBar);
delete(quit);
delete(more);
delete(reset);
delCallback(&quit);
delCallback(&more);
delCallback(&reset);
}
//----------------------------------------------------------------------
@ -140,8 +132,8 @@ void ProgressDialog::onShow (finalcut::FShowEvent*)
//----------------------------------------------------------------------
void ProgressDialog::onTimer (finalcut::FTimerEvent*)
{
int p = progressBar->getPercentage();
progressBar->setPercentage(++p);
int p = progressBar.getPercentage();
progressBar.setPercentage(++p);
flush_out();
if ( p != 100 )
@ -150,10 +142,10 @@ void ProgressDialog::onTimer (finalcut::FTimerEvent*)
delOwnTimer();
activateWindow();
raiseWindow();
reset->setEnable();
reset->setFocus();
more->setEnable();
quit->setEnable();
reset.setEnable();
reset.setFocus();
more.setEnable();
quit.setEnable();
redraw();
if ( getStatusBar() )
@ -166,14 +158,14 @@ void ProgressDialog::onTimer (finalcut::FTimerEvent*)
//----------------------------------------------------------------------
void ProgressDialog::cb_reset_bar (finalcut::FWidget*, data_ptr)
{
progressBar->reset();
progressBar.reset();
}
//----------------------------------------------------------------------
void ProgressDialog::cb_more_bar (finalcut::FWidget*, data_ptr)
{
int p = progressBar->getPercentage();
progressBar->setPercentage(++p);
int p = progressBar.getPercentage();
progressBar.setPercentage(++p);
}
//----------------------------------------------------------------------
@ -208,31 +200,30 @@ class TextWindow : public finalcut::FDialog
TextWindow& operator = (const TextWindow&);
// Method
void adjustSize();
virtual void adjustSize();
// Data Members
finalcut::FTextView* scrollText;
finalcut::FTextView scrollText;
};
#pragma pack(pop)
//----------------------------------------------------------------------
TextWindow::TextWindow (finalcut::FWidget* parent)
: finalcut::FDialog(parent)
, scrollText()
, scrollText(this)
{
scrollText = new finalcut::FTextView(this);
scrollText->ignorePadding();
scrollText->setGeometry (1, 2, getWidth(), getHeight() - 1);
scrollText.ignorePadding();
scrollText.setGeometry (1, 2, getWidth(), getHeight() - 1);
setMinimumSize (51, 6);
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);
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);
}
//----------------------------------------------------------------------
@ -242,14 +233,14 @@ TextWindow::~TextWindow() // destructor
//----------------------------------------------------------------------
void TextWindow::append (const finalcut::FString& str)
{
scrollText->append(str);
scrollText.append(str);
}
//----------------------------------------------------------------------
void TextWindow::adjustSize()
{
finalcut::FDialog::adjustSize();
scrollText->setGeometry (1, 2, getWidth(), getHeight() - 1);
scrollText.setGeometry (1, 2, getWidth(), getHeight() - 1);
}
@ -281,7 +272,6 @@ class MyDialog : public finalcut::FDialog
void initEditMenuCallbacks();
void initViewMenuCallbacks();
void initHelpMenuCallback();
void initStatusBar();
void initStatusBarCallbacks();
void initWidgets();
void initFlatButtons();
@ -289,10 +279,10 @@ class MyDialog : public finalcut::FDialog
void initButtons();
void initLabels();
void initWidgetsCallbacks();
void adjustSize();
virtual void adjustSize();
// Event handlers
void onClose (finalcut::FCloseEvent*);
virtual void onClose (finalcut::FCloseEvent*);
// Callback methods
void cb_noFunctionMsg (finalcut::FWidget*, data_ptr);
@ -312,71 +302,115 @@ class MyDialog : public finalcut::FDialog
void cb_setInput (finalcut::FWidget*, data_ptr);
// Data Members
finalcut::FMenuItem* Open;
finalcut::FMenuItem* Quit;
finalcut::FMenuItem* File1;
finalcut::FMenuItem* File2;
finalcut::FMenuItem* File3;
finalcut::FMenuItem* Cut;
finalcut::FMenuItem* Copy;
finalcut::FMenuItem* Paste;
finalcut::FMenuItem* Clear;
finalcut::FMenuItem* Env;
finalcut::FMenuItem* Drive;
finalcut::FMenuItem* Help;
finalcut::FStatusKey* key_F1;
finalcut::FStatusKey* key_F2;
finalcut::FStatusKey* key_F3;
finalcut::FButton* MyButton1;
finalcut::FButton* MyButton2;
finalcut::FButton* MyButton3;
finalcut::FButton* MyButton4;
finalcut::FButton* MyButton5;
finalcut::FButton* MyButton6;
finalcut::FRadioButton* radio1;
finalcut::FLabel* tagged_count;
finalcut::FLineEdit* myLineEdit;
finalcut::FListBox* myList;
finalcut::FString clipboard;
bool initialized;
finalcut::FMenuBar Menubar;
finalcut::FMenu File; // Menu bar items
finalcut::FMenu Edit;
finalcut::FMenu View;
finalcut::FMenuItem Options;
finalcut::FDialogListMenu Window;
finalcut::FMenuItem Help;
finalcut::FMenuItem Open; // "File" menu items
finalcut::FMenu Recent;
finalcut::FMenuItem Line1;
finalcut::FMenuItem Quit;
finalcut::FMenuItem File1; // "Recent" menu items
finalcut::FMenuItem File2;
finalcut::FMenuItem File3;
finalcut::FMenuItem Undo;
finalcut::FMenuItem Redo;
finalcut::FMenuItem Line2;
finalcut::FMenuItem Cut;
finalcut::FMenuItem Copy;
finalcut::FMenuItem Paste;
finalcut::FMenuItem Clear;
finalcut::FMenuItem Env;
finalcut::FMenuItem Drive;
finalcut::FStatusBar Statusbar;
finalcut::FStatusKey key_F1;
finalcut::FStatusKey key_F2;
finalcut::FStatusKey key_F3;
finalcut::FButton MyButton1;
finalcut::FButton MyButton2;
finalcut::FButton MyButton3;
finalcut::FButtonGroup radioButtonGroup;
finalcut::FRadioButton radio1;
finalcut::FRadioButton radio2;
finalcut::FButtonGroup checkButtonGroup;
finalcut::FCheckBox check1;
finalcut::FCheckBox check2;
finalcut::FLineEdit myLineEdit;
finalcut::FButton MyButton4;
finalcut::FButton MyButton5;
finalcut::FButton MyButton6;
finalcut::FListBox myList;
finalcut::FLabel headline;
finalcut::FLabel tagged;
finalcut::FLabel tagged_count;
finalcut::FLabel sum;
finalcut::FLabel sum_count;
finalcut::FString clipboard;
};
#pragma pack(pop)
//----------------------------------------------------------------------
MyDialog::MyDialog (finalcut::FWidget* parent)
: finalcut::FDialog(parent)
, Open()
, Quit()
, File1()
, File2()
, File3()
, Cut()
, Copy()
, Paste()
, Clear()
, Env()
, Drive()
, Help()
, key_F1()
, key_F2()
, key_F3()
, MyButton1()
, MyButton2()
, MyButton3()
, MyButton4()
, MyButton5()
, MyButton6()
, radio1()
, tagged_count()
, myLineEdit()
, myList()
, initialized(false)
, Menubar(this)
, File("&File", &Menubar)
, Edit("&Edit", &Menubar)
, View("&View", &Menubar)
, Options("&Options", &Menubar)
, Window("&Window", &Menubar)
, Help("&Help", &Menubar)
, Open("&Open...", &File)
, Recent("&System files", &File)
, Line1(&File)
, Quit("&Quit", &File)
, File1("/etc/services", &Recent)
, File2("/etc/fstab", &Recent)
, File3("/etc/passwd", &Recent)
, Undo(finalcut::fc::Fckey_z, "Undo", &Edit)
, Redo(finalcut::fc::Fckey_y, "Redo", &Edit)
, Line2(&Edit)
, Cut(finalcut::fc::Fckey_x, "Cu&t", &Edit)
, Copy(finalcut::fc::Fckey_c, "&Copy", &Edit)
, Paste(finalcut::fc::Fckey_v, "&Paste", &Edit)
, Clear(finalcut::fc::Fkey_dc, "C&lear", &Edit)
, Env("&Terminal...", &View)
, Drive("&Drive symbols...", &View)
, Statusbar(this)
, key_F1(finalcut::fc::Fkey_f1, "About", &Statusbar)
, key_F2(finalcut::fc::Fkey_f2, "View", &Statusbar)
, key_F3(finalcut::fc::Fkey_f3, "Quit", &Statusbar)
, MyButton1(this)
, MyButton2(this)
, MyButton3(this)
, radioButtonGroup("Button", this)
, radio1("E&nable", &radioButtonGroup)
, radio2(&radioButtonGroup)
, checkButtonGroup("Options", this)
, check1("&Bitmode", &checkButtonGroup)
, check2("&8-Bit", &checkButtonGroup)
, myLineEdit(this)
, MyButton4(this)
, MyButton5(this)
, MyButton6(this)
, myList(this)
, headline(this)
, tagged(L"Tagged:", this)
, tagged_count(this)
, sum(L"Sum:", this)
, sum_count(this)
, clipboard()
{
initMenu(); // Initialize the program menu
initMenuCallbacks(); // Initialize program menu callbacks
initStatusBar(); // Initialize the status bar
initStatusBarCallbacks(); // Initialize status bar callbacks
initWidgets(); // Initialize the dialog widgets
initWidgetsCallbacks(); // Initialize dialog widget callbacks
initialized = true;
}
//----------------------------------------------------------------------
@ -386,69 +420,36 @@ MyDialog::~MyDialog() // destructor
//----------------------------------------------------------------------
void MyDialog::initMenu()
{
// Menu bar
finalcut::FMenuBar* Menubar = new finalcut::FMenuBar (this);
// Menu bar items
finalcut::FMenu* File = new finalcut::FMenu ("&File", Menubar);
File->setStatusbarMessage ("File management commands");
finalcut::FMenu* Edit = new finalcut::FMenu ("&Edit", Menubar);
Edit->setStatusbarMessage ("Cut-and-paste editing commands");
finalcut::FMenu* View = new finalcut::FMenu ("&View", Menubar);
View->setStatusbarMessage ("Show internal informations");
finalcut::FMenuItem* Options = \
new finalcut::FMenuItem ("&Options", Menubar);
Options->setStatusbarMessage ("Set program defaults");
Options->setDisable();
finalcut::FDialogListMenu* Window = \
new finalcut::FDialogListMenu ("&Window", Menubar);
Window->setStatusbarMessage ("List of all the active dialogs");
Help = new finalcut::FMenuItem ("&Help", Menubar);
Help->setStatusbarMessage ("Show version and copyright information");
File.setStatusbarMessage ("File management commands");
Edit.setStatusbarMessage ("Cut-and-paste editing commands");
View.setStatusbarMessage ("Show internal informations");
Options.setStatusbarMessage ("Set program defaults");
Options.setDisable();
Window.setStatusbarMessage ("List of all the active dialogs");
Help.setStatusbarMessage ("Show version and copyright information");
// "File" menu items
Open = new finalcut::FMenuItem ("&Open...", File);
Open->addAccelerator (finalcut::fc::Fckey_o); // Ctrl + O
Open->setStatusbarMessage ("Locate and open a text file");
finalcut::FMenu* Recent = new finalcut::FMenu ("&System files", File);
Recent->setStatusbarMessage ("View text file");
finalcut::FMenuItem* Line1 = new finalcut::FMenuItem (File);
Line1->setSeparator();
Quit = new finalcut::FMenuItem ("&Quit", File);
Quit->addAccelerator (finalcut::fc::Fmkey_x); // Meta/Alt + X
Quit->setStatusbarMessage ("Exit the program");
// "Recent" menu items
File1 = new finalcut::FMenuItem ("/etc/services", Recent);
File2 = new finalcut::FMenuItem ("/etc/fstab", Recent);
File3 = new finalcut::FMenuItem ("/etc/passwd", Recent);
Open.addAccelerator (finalcut::fc::Fckey_o); // Ctrl + O
Open.setStatusbarMessage ("Locate and open a text file");
Recent.setStatusbarMessage ("View text file");
Line1.setSeparator();
Quit.addAccelerator (finalcut::fc::Fmkey_x); // Meta/Alt + X
Quit.setStatusbarMessage ("Exit the program");
// "Edit" menu items
finalcut::FMenuItem* Undo = \
new finalcut::FMenuItem (finalcut::fc::Fckey_z, "Undo", Edit);
Undo->setDisable();
finalcut::FMenuItem* Redo = \
new finalcut::FMenuItem (finalcut::fc::Fckey_y, "Redo", Edit);
Redo->setDisable();
finalcut::FMenuItem* Line2 = \
new finalcut::FMenuItem (Edit);
Line2->setSeparator();
Cut = new finalcut::FMenuItem (finalcut::fc::Fckey_x, "Cu&t", Edit);
Cut->setStatusbarMessage ( "Remove the input text"
" and put it in the clipboard" );
Copy= new finalcut::FMenuItem (finalcut::fc::Fckey_c, "&Copy", Edit);
Copy->setStatusbarMessage ("Copy the input text into the clipboad");
Paste = new finalcut::FMenuItem (finalcut::fc::Fckey_v, "&Paste", Edit);
Paste->setStatusbarMessage ("Insert text form clipboard");
Clear = new finalcut::FMenuItem (finalcut::fc::Fkey_dc, "C&lear", Edit);
Clear->setStatusbarMessage ("Delete input text");
Undo.setDisable();
Redo.setDisable();
Line2.setSeparator();
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");
Clear.setStatusbarMessage ("Delete input text");
// "View" menu items
Env = new finalcut::FMenuItem ("&Terminal...", View);
Env->setStatusbarMessage ("Informations about this terminal");
Drive = new finalcut::FMenuItem ("&Drive symbols...", View);
Drive->setStatusbarMessage ("Show drive symbols");
Env.setStatusbarMessage ("Informations about this terminal");
Drive.setStatusbarMessage ("Show drive symbols");
}
//----------------------------------------------------------------------
@ -465,38 +466,38 @@ void MyDialog::initMenuCallbacks()
void MyDialog::initFileMenuCallbacks()
{
// File menu
Open->addCallback
Open.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_view)
);
Quit->addCallback
Quit.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &finalcut::FApplication::cb_exitApp)
);
// System files submenu
File1->addCallback
File1.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_view),
static_cast<finalcut::FWidget::data_ptr>(File1)
static_cast<finalcut::FWidget::data_ptr>(&File1)
);
File2->addCallback
File2.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_view),
static_cast<finalcut::FWidget::data_ptr>(File2)
static_cast<finalcut::FWidget::data_ptr>(&File2)
);
File3->addCallback
File3.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_view),
static_cast<finalcut::FWidget::data_ptr>(File3)
static_cast<finalcut::FWidget::data_ptr>(&File3)
);
}
@ -504,25 +505,25 @@ void MyDialog::initFileMenuCallbacks()
void MyDialog::initEditMenuCallbacks()
{
// Edit menu
Cut->addCallback
Cut.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_cutClipboard)
);
Copy->addCallback
Copy.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_copyClipboard)
);
Paste->addCallback
Paste.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_pasteClipboard)
);
Clear->addCallback
Clear.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_clearInput)
@ -533,13 +534,13 @@ void MyDialog::initEditMenuCallbacks()
void MyDialog::initViewMenuCallbacks()
{
// View menu
Env->addCallback
Env.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_terminfo)
);
Drive->addCallback
Drive.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_drives)
@ -549,43 +550,31 @@ void MyDialog::initViewMenuCallbacks()
//----------------------------------------------------------------------
void MyDialog::initHelpMenuCallback()
{
Help->addCallback
Help.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_about)
);
}
//----------------------------------------------------------------------
void MyDialog::initStatusBar()
{
// Statusbar at the bottom
finalcut::FStatusBar* Statusbar = new finalcut::FStatusBar (this);
// Statusbar keys
key_F1 = new finalcut::FStatusKey (finalcut::fc::Fkey_f1, "About", Statusbar);
key_F2 = new finalcut::FStatusKey (finalcut::fc::Fkey_f2, "View", Statusbar);
key_F3 = new finalcut::FStatusKey (finalcut::fc::Fkey_f3, "Quit", Statusbar);
}
//----------------------------------------------------------------------
void MyDialog::initStatusBarCallbacks()
{
// Add statusbar function callbacks
key_F1->addCallback
key_F1.addCallback
(
"activate",
F_METHOD_CALLBACK (this, &MyDialog::cb_about)
);
key_F2->addCallback
key_F2.addCallback
(
"activate",
F_METHOD_CALLBACK (this, &MyDialog::cb_view)
);
key_F3->addCallback
key_F3.addCallback
(
"activate",
F_METHOD_CALLBACK (this, &finalcut::FApplication::cb_exitApp)
@ -602,24 +591,22 @@ void MyDialog::initWidgets()
initToggleButtons();
// A text input field
myLineEdit = new finalcut::FLineEdit (this);
myLineEdit->setGeometry(22, 1, 10, 1);
myLineEdit->setLabelText (L"&Input");
myLineEdit->setStatusbarMessage ("Press Enter to set the title");
*myLineEdit << finalcut::FString("EnTry").toLower();
myLineEdit.setGeometry(22, 1, 10, 1);
myLineEdit.setLabelText (L"&Input");
myLineEdit.setStatusbarMessage ("Press Enter to set the title");
myLineEdit << finalcut::FString("EnTry").toLower();
// Buttons
initButtons();
// A multiple selection listbox
myList = new finalcut::FListBox (this);
myList->setGeometry(38, 1, 14, 17);
myList->setText ("Items");
myList->setStatusbarMessage ("99 items in a list");
myList->setMultiSelection();
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 (finalcut::FString() << z << L" placeholder");
myList.insert (finalcut::FString() << z << L" placeholder");
// Text labels
initLabels();
@ -629,43 +616,40 @@ void MyDialog::initWidgets()
void MyDialog::initFlatButtons()
{
// Flat buttons
MyButton1 = new finalcut::FButton (this);
MyButton1->setGeometry(3, 3, 5, 1);
MyButton1->setText (L"&SIN");
MyButton1->setStatusbarMessage ("Sine function");
MyButton1->setNoUnderline();
MyButton1->setFlat();
MyButton1->setDoubleFlatLine (finalcut::fc::bottom);
MyButton1.setGeometry(3, 3, 5, 1);
MyButton1.setText (L"&SIN");
MyButton1.setStatusbarMessage ("Sine function");
MyButton1.setNoUnderline();
MyButton1.setFlat();
MyButton1.setDoubleFlatLine (finalcut::fc::bottom);
MyButton2 = new finalcut::FButton (this);
MyButton2->setGeometry(3, 5, 5, 1);
MyButton2->setText (L"&COS");
MyButton2->setStatusbarMessage ("Cosine function");
MyButton2->setNoUnderline();
MyButton2->setFlat();
MyButton2->setDoubleFlatLine (finalcut::fc::top);
MyButton2.setGeometry(3, 5, 5, 1);
MyButton2.setText (L"&COS");
MyButton2.setStatusbarMessage ("Cosine function");
MyButton2.setNoUnderline();
MyButton2.setFlat();
MyButton2.setDoubleFlatLine (finalcut::fc::top);
MyButton3 = new finalcut::FButton (this);
MyButton3->setGeometry(10, 3, 5, 3);
MyButton3->setText (L"&=");
MyButton3->setStatusbarMessage ("Equal");
MyButton3->setNoUnderline();
MyButton3->setFlat();
MyButton3.setGeometry(10, 3, 5, 3);
MyButton3.setText (L"&=");
MyButton3.setStatusbarMessage ("Equal");
MyButton3.setNoUnderline();
MyButton3.setFlat();
// Add button callback functions
MyButton1->addCallback
MyButton1.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_noFunctionMsg)
);
MyButton2->addCallback
MyButton2.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_noFunctionMsg)
);
MyButton3->addCallback
MyButton3.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_noFunctionMsg)
@ -676,77 +660,63 @@ void MyDialog::initFlatButtons()
void MyDialog::initToggleButtons()
{
// Radio buttons in a group
finalcut::FButtonGroup* radioButtonGroup = \
new finalcut::FButtonGroup ("Button", this);
radioButtonGroup->setGeometry(3, 8, 14, 4);
radioButtonGroup.setGeometry(3, 8, 14, 4);
//radioButtonGroup->unsetBorder();
radio1 = new finalcut::FRadioButton ("E&nable", radioButtonGroup);
radio1->setGeometry(1, 1, 10, 1);
radio1->setStatusbarMessage ("Enable button Test");
radio1.setGeometry(1, 1, 10, 1);
radio1.setStatusbarMessage ("Enable button Test");
finalcut::FRadioButton* radio2 = \
new finalcut::FRadioButton (radioButtonGroup);
radio2->setGeometry(1, 2, 11, 1);
radio2->setText ("&Disable");
radio2->setStatusbarMessage ("Disable button Test");
radio2->setChecked();
//radio2->setDisable();
radio2.setGeometry(1, 2, 11, 1);
radio2.setText ("&Disable");
radio2.setStatusbarMessage ("Disable button Test");
radio2.setChecked();
//radio2.setDisable();
// Checkboxes in a group
finalcut::FButtonGroup* checkButtonGroup = \
new finalcut::FButtonGroup ("Options", this);
checkButtonGroup->setGeometry(3, 12, 14, 4);
checkButtonGroup.setGeometry(3, 12, 14, 4);
finalcut::FCheckBox* check1 = \
new finalcut::FCheckBox ("&Bitmode", checkButtonGroup);
check1->setGeometry(1, 1, 11, 1);
check1->setNoUnderline();
check1.setGeometry(1, 1, 11, 1);
check1.setNoUnderline();
finalcut::FCheckBox* check2 = \
new finalcut::FCheckBox ("&8-Bit", checkButtonGroup);
check2->setGeometry(1, 2, 9, 1);
check2->setChecked();
check2->setNoUnderline();
check2.setGeometry(1, 2, 9, 1);
check2.setChecked();
check2.setNoUnderline();
}
//----------------------------------------------------------------------
void MyDialog::initButtons()
{
// Buttons
MyButton4 = new finalcut::FButton (this);
MyButton4->setGeometry(20, 8, 12, 1);
MyButton4->setText (L"&Get input");
MyButton4->setStatusbarMessage ("Take text from input field");
MyButton4->setFocus();
MyButton4.setGeometry(20, 8, 12, 1);
MyButton4.setText (L"&Get input");
MyButton4.setStatusbarMessage ("Take text from input field");
MyButton4.setFocus();
MyButton5 = new finalcut::FButton (this);
MyButton5->setGeometry(20, 11, 12, 1);
MyButton5->setText (L"&Test");
MyButton5->setStatusbarMessage ("Progressbar testing dialog");
MyButton5->setDisable();
MyButton5.setGeometry(20, 11, 12, 1);
MyButton5.setText (L"&Test");
MyButton5.setStatusbarMessage ("Progressbar testing dialog");
MyButton5.setDisable();
MyButton6 = new finalcut::FButton (this);
MyButton6->setGeometry(20, 14, 12, 1);
MyButton6->setText (L"&Quit");
MyButton6->setStatusbarMessage ("Exit the program");
MyButton6->addAccelerator('x');
MyButton6.setGeometry(20, 14, 12, 1);
MyButton6.setText (L"&Quit");
MyButton6.setStatusbarMessage ("Exit the program");
MyButton6.addAccelerator('x');
// Add button callback functions
MyButton4->addCallback
MyButton4.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_input2buttonText),
static_cast<finalcut::FWidget::data_ptr>(myLineEdit)
static_cast<finalcut::FWidget::data_ptr>(&myLineEdit)
);
MyButton5->addCallback
MyButton5.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_ProgressBar)
);
MyButton6->addCallback
MyButton6.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &finalcut::FApplication::cb_exitApp)
@ -757,26 +727,21 @@ void MyDialog::initButtons()
void MyDialog::initLabels()
{
// Text labels
finalcut::FLabel* headline = new finalcut::FLabel (this);
headline->setGeometry(21, 3, 10, 1);
headline->setEmphasis();
headline->setAlignment (finalcut::fc::alignCenter);
*headline = L"List items";
headline.setGeometry(21, 3, 10, 1);
headline.setEmphasis();
headline.setAlignment (finalcut::fc::alignCenter);
headline = L"List items";
finalcut::FLabel* tagged = new finalcut::FLabel (L"Tagged:", this);
tagged->setGeometry(21, 4, 7, 1);
tagged.setGeometry(21, 4, 7, 1);
tagged_count = new finalcut::FLabel(this);
tagged_count->setGeometry(29, 4, 5, 1);
*tagged_count << 0;
tagged_count.setGeometry(29, 4, 5, 1);
tagged_count << 0;
finalcut::FLabel* sum = new finalcut::FLabel (L"Sum:", this);
sum->setGeometry(21, 5, 7, 3);
sum->setAlignment (finalcut::fc::alignRight);
sum.setGeometry(21, 5, 7, 3);
sum.setAlignment (finalcut::fc::alignRight);
finalcut::FLabel* sum_count = new finalcut::FLabel (this);
sum_count->setGeometry(29, 5, 5, 3);
*sum_count << myList->getCount();
sum_count.setGeometry(29, 5, 5, 3);
sum_count << myList.getCount();
}
//----------------------------------------------------------------------
@ -784,31 +749,31 @@ void MyDialog::initWidgetsCallbacks()
{
// Add some function callbacks
myLineEdit->addCallback
myLineEdit.addCallback
(
"activate", // e.g. on <Enter>
F_METHOD_CALLBACK (this, &MyDialog::cb_setTitlebar)
);
radio1->addCallback
radio1.addCallback
(
"toggled",
F_METHOD_CALLBACK (this, &MyDialog::cb_activateButton),
static_cast<finalcut::FWidget::data_ptr>(MyButton5)
static_cast<finalcut::FWidget::data_ptr>(&MyButton5)
);
myList->addCallback
myList.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_setInput),
static_cast<finalcut::FWidget::data_ptr>(myLineEdit)
static_cast<finalcut::FWidget::data_ptr>(&myLineEdit)
);
myList->addCallback
myList.addCallback
(
"row-selected",
F_METHOD_CALLBACK (this, &MyDialog::cb_updateNumber),
static_cast<finalcut::FWidget::data_ptr>(tagged_count)
static_cast<finalcut::FWidget::data_ptr>(&tagged_count)
);
}
@ -824,8 +789,8 @@ void MyDialog::adjustSize()
setX (X, false);
if ( myList )
myList->setHeight (getHeight() - 3, false);
if ( initialized )
myList.setHeight (getHeight() - 3, false);
finalcut::FDialog::adjustSize();
}
@ -937,42 +902,30 @@ void MyDialog::cb_drives (finalcut::FWidget*, data_ptr)
//----------------------------------------------------------------------
void MyDialog::cb_cutClipboard (finalcut::FWidget*, data_ptr)
{
if ( ! myLineEdit )
return;
clipboard = myLineEdit->getText();
myLineEdit->clear();
myLineEdit->redraw();
clipboard = myLineEdit.getText();
myLineEdit.clear();
myLineEdit.redraw();
}
//----------------------------------------------------------------------
void MyDialog::cb_copyClipboard (finalcut::FWidget*, data_ptr)
{
if ( ! myLineEdit )
return;
clipboard = myLineEdit->getText();
clipboard = myLineEdit.getText();
}
//----------------------------------------------------------------------
void MyDialog::cb_pasteClipboard (finalcut::FWidget*, data_ptr)
{
if ( ! myLineEdit )
return;
*myLineEdit = clipboard;
myLineEdit->redraw();
myLineEdit = clipboard;
myLineEdit.redraw();
}
//----------------------------------------------------------------------
void MyDialog::cb_clearInput (finalcut::FWidget*, data_ptr)
{
if ( ! myLineEdit )
return;
clipboard.clear();
myLineEdit->clear();
myLineEdit->redraw();
myLineEdit.clear();
myLineEdit.redraw();
}
//----------------------------------------------------------------------

View File

@ -44,8 +44,8 @@ class Watch : public finalcut::FDialog
void printTime();
// Event handlers
void onTimer (finalcut::FTimerEvent*);
void onClose (finalcut::FCloseEvent*);
virtual void onTimer (finalcut::FTimerEvent*);
virtual void onClose (finalcut::FCloseEvent*);
// Callback methods
void cb_clock (finalcut::FWidget*, data_ptr);
@ -53,7 +53,7 @@ class Watch : public finalcut::FDialog
protected:
// Method
void adjustSize();
virtual void adjustSize();
private:
// Disable copy constructor
@ -63,11 +63,12 @@ class Watch : public finalcut::FDialog
Watch& operator = (const Watch&);
// Data Members
bool sec;
finalcut::FLabel* time_label;
finalcut::FLabel* time_str;
finalcut::FSwitch* clock_sw;
finalcut::FSwitch* seconds_sw;
bool sec;
finalcut::FLabel time_label;
finalcut::FLabel time_str;
finalcut::FSwitch clock_sw;
finalcut::FSwitch seconds_sw;
finalcut::FButton quit_btn;
};
#pragma pack(pop)
@ -75,49 +76,45 @@ class Watch : public finalcut::FDialog
Watch::Watch (FWidget* parent)
: finalcut::FDialog(parent)
, sec(true)
, time_label(0)
, time_str(0)
, clock_sw(0)
, seconds_sw(0)
, time_label(L"Time", this)
, time_str(L"--:--:--", this)
, clock_sw(L"Clock", this)
, seconds_sw(L"Seconds", this)
, quit_btn(L"&Quit", this)
{
setText ("Watch");
int pw = getParentWidget()->getWidth();
setGeometry (1 + (pw - 22) / 2, 3, 22, 13);
// Create labels
time_label = new finalcut::FLabel(L"Time", this);
time_label->setGeometry(5, 2, 5, 1);
time_label->setEmphasis();
time_str = new finalcut::FLabel(L"--:--:--", this);
time_str->setGeometry(10, 2, 8, 1);
// Labels
time_label.setGeometry(5, 2, 5, 1);
time_label.setEmphasis();
time_str.setGeometry(10, 2, 8, 1);
// Create checkbox buttons
clock_sw = new finalcut::FSwitch(L"Clock", this);
seconds_sw = new finalcut::FSwitch(L"Seconds", this);
clock_sw->setGeometry(4, 4, 9, 1);
seconds_sw->setGeometry(2, 6, 11, 1);
sec = seconds_sw->setChecked();
// Checkbox buttons
clock_sw.setGeometry(4, 4, 9, 1);
seconds_sw.setGeometry(2, 6, 11, 1);
sec = seconds_sw.setChecked();
// Create button
finalcut::FButton* quit_btn = new finalcut::FButton(L"&Quit", this);
quit_btn->setGeometry(6, 9, 9, 1);
// Quit button
quit_btn.setGeometry(6, 9, 9, 1);
// Connect switch signal "toggled" with a callback member function
clock_sw->addCallback
clock_sw.addCallback
(
"toggled",
F_METHOD_CALLBACK (this, &Watch::cb_clock)
);
// Connect switch signal "toggled" with a callback member function
seconds_sw->addCallback
seconds_sw.addCallback
(
"toggled",
F_METHOD_CALLBACK (this, &Watch::cb_seconds)
);
// Connect button signal "clicked" with a callback member function
quit_btn->addCallback
quit_btn.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &finalcut::FApplication::cb_exitApp)
@ -145,8 +142,8 @@ void Watch::printTime()
else
str.sprintf("%02d:%02d ", now.tm_hour, now.tm_min);
*time_str = str;
time_str->redraw();
time_str = str;
time_str.redraw();
}
//----------------------------------------------------------------------
@ -164,7 +161,7 @@ void Watch::onClose (finalcut::FCloseEvent* ev)
//----------------------------------------------------------------------
void Watch::cb_clock (finalcut::FWidget*, data_ptr)
{
if ( clock_sw->isChecked() )
if ( clock_sw.isChecked() )
{
printTime();
addTimer(1000);
@ -172,29 +169,29 @@ void Watch::cb_clock (finalcut::FWidget*, data_ptr)
else
{
delAllTimer();
*time_str = "--:--:--";
time_str->redraw();
time_str = "--:--:--";
time_str.redraw();
}
}
//----------------------------------------------------------------------
void Watch::cb_seconds (finalcut::FWidget*, data_ptr)
{
if ( seconds_sw->isChecked() )
if ( seconds_sw.isChecked() )
sec = true;
else
sec = false;
if ( clock_sw->isChecked() )
if ( clock_sw.isChecked() )
printTime();
else
{
if ( sec )
*time_str = "--:--:--";
time_str = "--:--:--";
else
*time_str = "--:-- ";
time_str = "--:-- ";
time_str->redraw();
time_str.redraw();
}
}

View File

@ -48,68 +48,65 @@ class SmallWindow : public finalcut::FDialog
SmallWindow& operator = (const SmallWindow&);
// Method
void adjustSize();
virtual void adjustSize();
// Event handlers
void onShow (finalcut::FShowEvent*);
void onTimer (finalcut::FTimerEvent*);
virtual void onShow (finalcut::FShowEvent*);
virtual void onTimer (finalcut::FTimerEvent*);
// Data Members
finalcut::FLabel* left_arrow;
finalcut::FLabel* right_arrow;
finalcut::FLabel* top_left_label;
finalcut::FLabel* top_right_label;
finalcut::FLabel* bottom_label;
finalcut::FLabel left_arrow;
finalcut::FLabel right_arrow;
finalcut::FLabel top_left_label;
finalcut::FLabel top_right_label;
finalcut::FLabel bottom_label;
};
#pragma pack(pop)
//----------------------------------------------------------------------
SmallWindow::SmallWindow (finalcut::FWidget* parent)
: finalcut::FDialog(parent)
, left_arrow()
, right_arrow()
, top_left_label()
, top_right_label()
, bottom_label()
, left_arrow(this)
, right_arrow(this)
, top_left_label(this)
, top_right_label(this)
, bottom_label(this)
{
wchar_t arrow_up, arrow_down;
arrow_up = finalcut::fc::BlackUpPointingTriangle;
arrow_down = finalcut::fc::BlackDownPointingTriangle;
left_arrow = new finalcut::FLabel (arrow_up, this);
left_arrow->setForegroundColor (wc.label_inactive_fg);
left_arrow->setEmphasis();
left_arrow->ignorePadding();
left_arrow->setGeometry (2, 2, 1, 1);
left_arrow = arrow_up;
left_arrow.setForegroundColor (wc.label_inactive_fg);
left_arrow.setEmphasis();
left_arrow.ignorePadding();
left_arrow.setGeometry (2, 2, 1, 1);
right_arrow = new finalcut::FLabel (arrow_up, this);
right_arrow->setForegroundColor (wc.label_inactive_fg);
right_arrow->setEmphasis();
right_arrow->ignorePadding();
right_arrow->setGeometry (getWidth() - 1, 2, 1, 1);
right_arrow = arrow_up;
right_arrow.setForegroundColor (wc.label_inactive_fg);
right_arrow.setEmphasis();
right_arrow.ignorePadding();
right_arrow.setGeometry (getWidth() - 1, 2, 1, 1);
const finalcut::FString& top_left_label_text = "menu";
top_left_label = new finalcut::FLabel (top_left_label_text, this);
top_left_label->setForegroundColor (wc.label_inactive_fg);
top_left_label->setEmphasis();
top_left_label->setGeometry (1, 1, 6, 1);
top_left_label = "menu";
top_left_label.setForegroundColor (wc.label_inactive_fg);
top_left_label.setEmphasis();
top_left_label.setGeometry (1, 1, 6, 1);
const finalcut::FString& top_right_label_text = "zoom";
top_right_label = new finalcut::FLabel (top_right_label_text, this);
top_right_label->setAlignment (finalcut::fc::alignRight);
top_right_label->setForegroundColor (wc.label_inactive_fg);
top_right_label->setEmphasis();
top_right_label->setGeometry (getClientWidth() - 5, 1, 6, 1);
top_right_label = "zoom";
top_right_label.setAlignment (finalcut::fc::alignRight);
top_right_label.setForegroundColor (wc.label_inactive_fg);
top_right_label.setEmphasis();
top_right_label.setGeometry (getClientWidth() - 5, 1, 6, 1);
finalcut::FString bottom_label_text = "resize\n"
"corner\n";
bottom_label_text += arrow_down;
bottom_label = new finalcut::FLabel (bottom_label_text, this);
bottom_label->setAlignment (finalcut::fc::alignRight);
bottom_label->setForegroundColor (wc.label_inactive_fg);
bottom_label->setEmphasis();
bottom_label->setGeometry (13, 3, 6, 3);
bottom_label = bottom_label_text;
bottom_label.setAlignment (finalcut::fc::alignRight);
bottom_label.setForegroundColor (wc.label_inactive_fg);
bottom_label.setEmphasis();
bottom_label.setGeometry (13, 3, 6, 3);
}
//----------------------------------------------------------------------
@ -124,19 +121,19 @@ void SmallWindow::adjustSize()
{
if ( isZoomed() )
{
*top_right_label = "unzoom";
bottom_label->hide();
top_right_label = "unzoom";
bottom_label.hide();
}
else
{
*top_right_label = "zoom";
bottom_label->setVisible();
top_right_label = "zoom";
bottom_label.setVisible();
}
finalcut::FDialog::adjustSize();
right_arrow->setGeometry (getWidth() - 1, 2, 1, 1);
top_right_label->setGeometry (getClientWidth() - 5, 1, 6, 1);
bottom_label->setGeometry (1, getClientHeight() - 2, getClientWidth(), 3);
right_arrow.setGeometry (getWidth() - 1, 2, 1, 1);
top_right_label.setGeometry (getClientWidth() - 5, 1, 6, 1);
bottom_label.setGeometry (1, getClientHeight() - 2, getClientWidth(), 3);
}
//----------------------------------------------------------------------
@ -148,16 +145,16 @@ void SmallWindow::onShow (finalcut::FShowEvent*)
//----------------------------------------------------------------------
void SmallWindow::onTimer (finalcut::FTimerEvent*)
{
left_arrow->unsetEmphasis();
left_arrow->redraw();
right_arrow->unsetEmphasis();
right_arrow->redraw();
top_left_label->unsetEmphasis();
top_left_label->redraw();
top_right_label->unsetEmphasis();
top_right_label->redraw();
bottom_label->unsetEmphasis();
bottom_label->redraw();
left_arrow.unsetEmphasis();
left_arrow.redraw();
right_arrow.unsetEmphasis();
right_arrow.redraw();
top_left_label.unsetEmphasis();
top_left_label.redraw();
top_right_label.unsetEmphasis();
top_right_label.redraw();
bottom_label.unsetEmphasis();
bottom_label.redraw();
updateTerminal();
delOwnTimer();
}
@ -183,13 +180,27 @@ class Window : public finalcut::FDialog
// Typedefs
typedef void (Window::*WindowCallback)(finalcut::FWidget*, data_ptr);
typedef void (finalcut::FApplication::*FAppCallback)(finalcut::FWidget*, data_ptr);
typedef struct
class win_data
{
bool is_open;
finalcut::FString* title;
SmallWindow* dgl;
}
win_data;
public:
win_data()
: is_open(false)
, title()
, dgl(0)
{ }
// Data Members
bool is_open;
finalcut::FString title;
SmallWindow* dgl;
private:
// Disable copy constructor
win_data (const win_data&);
// Disable assignment operator (=)
win_data& operator = (const win_data&);
};
// Disable copy constructor
Window (const Window&);
@ -198,15 +209,15 @@ class Window : public finalcut::FDialog
Window& operator = (const Window&);
// Method
void createFileMenuItems (finalcut::FMenu*);
void createDialogButtons();
void configureFileMenuItems();
void configureDialogButtons();
void activateWindow (finalcut::FDialog*);
void adjustSize();
virtual void adjustSize();
void addClickedCallback (finalcut::FWidget*, WindowCallback);
void addClickedCallback (finalcut::FWidget*, FAppCallback);
// Event handlers
void onClose (finalcut::FCloseEvent*);
virtual void onClose (finalcut::FCloseEvent*);
// Callback methods
void cb_createWindows (finalcut::FWidget*, data_ptr);
@ -216,7 +227,22 @@ class Window : public finalcut::FDialog
void cb_destroyWindow (finalcut::FWidget*, data_ptr);
// Data Members
std::vector<win_data*> windows;
std::vector<win_data*> windows;
finalcut::FString drop_down_symbol;
finalcut::FMenuBar Menubar;
finalcut::FMenu File;
finalcut::FDialogListMenu DglList;
finalcut::FStatusBar Statusbar;
finalcut::FMenuItem New;
finalcut::FMenuItem Close;
finalcut::FMenuItem Line1;
finalcut::FMenuItem Next;
finalcut::FMenuItem Previous;
finalcut::FMenuItem Line2;
finalcut::FMenuItem Quit;
finalcut::FButton CreateButton;
finalcut::FButton CloseButton;
finalcut::FButton QuitButton;
};
#pragma pack(pop)
@ -224,42 +250,42 @@ class Window : public finalcut::FDialog
Window::Window (finalcut::FWidget* parent)
: finalcut::FDialog(parent)
, windows()
, drop_down_symbol(wchar_t(finalcut::fc::BlackDownPointingTriangle))
, Menubar(this)
, File("&File", &Menubar)
, DglList(drop_down_symbol, &Menubar)
, Statusbar(this)
, New("&New", &File)
, Close("&Close", &File)
, Line1(&File)
, Next("Ne&xt window", &File)
, Previous("&Previous window", &File)
, Line2(&File)
, Quit("&Quit", &File)
, CreateButton(this)
, CloseButton(this)
, QuitButton(this)
{
finalcut::FMenu* File;
finalcut::FDialogListMenu* DglList;
finalcut::FString drop_down_symbol;
finalcut::FMenuBar* Menubar;
finalcut::FStatusBar* Statusbar;
// Menu bar
Menubar = new finalcut::FMenuBar (this);
// Menu bar item
File = new finalcut::FMenu ("&File", Menubar);
File->setStatusbarMessage ("File management commands");
File.setStatusbarMessage ("File management commands");
// Dialog list menu item
drop_down_symbol = wchar_t(finalcut::fc::BlackDownPointingTriangle);
DglList = new finalcut::FDialogListMenu (drop_down_symbol, Menubar);
DglList->setStatusbarMessage ("List of all the active dialogs");
DglList.setStatusbarMessage ("List of all the active dialogs");
// File menu items
createFileMenuItems (File);
configureFileMenuItems();
// Dialog buttons
createDialogButtons();
configureDialogButtons();
// Statusbar at the bottom
Statusbar = new finalcut::FStatusBar (this);
Statusbar->setMessage("Status bar message");
Statusbar.setMessage("Status bar message");
// Generate data vector for the windows
for (int n = 1; n <= 6; n++)
{
win_data* win_dat = new win_data;
win_dat->is_open = false;
win_dat->title = new finalcut::FString();
win_dat->title->sprintf("Window %d", n);
win_dat->title.sprintf("Window %d", n);
windows.push_back(win_dat);
}
}
@ -278,68 +304,49 @@ Window::~Window()
if ( win_dat->is_open && win_dat->dgl )
win_dat->dgl->delCallbacks();
delete win_dat->title;
delete win_dat;
iter = windows.erase(iter);
}
}
//----------------------------------------------------------------------
void Window::createFileMenuItems (finalcut::FMenu* File)
void Window::configureFileMenuItems()
{
// "File" menu item
finalcut::FMenuItem* New = new finalcut::FMenuItem ("&New", File);
New->setStatusbarMessage ("Create the windows");
finalcut::FMenuItem* Close = new finalcut::FMenuItem ("&Close", File);
Close->setStatusbarMessage ("Close the windows");
finalcut::FMenuItem* Line1 = new finalcut::FMenuItem (File);
Line1->setSeparator();
finalcut::FMenuItem* Next = new finalcut::FMenuItem ("Ne&xt window", File);
Next->addAccelerator (finalcut::fc::Fmkey_npage); // Meta/Alt + PgDn
Next->setStatusbarMessage ("Switch to the next window");
finalcut::FMenuItem* Previous = new finalcut::FMenuItem ("&Previous window", File);
Previous->addAccelerator (finalcut::fc::Fmkey_ppage); // Meta/Alt + PgUp
Previous->setStatusbarMessage ("Switch to the previous window");
finalcut::FMenuItem* Line2 = new finalcut::FMenuItem (File);
Line2->setSeparator();
finalcut::FMenuItem* Quit = new finalcut::FMenuItem ("&Quit", File);
Quit->addAccelerator (finalcut::fc::Fmkey_x); // Meta/Alt + X
Quit->setStatusbarMessage ("Exit the program");
// "File" menu item setting
New.setStatusbarMessage ("Create the windows");
Close.setStatusbarMessage ("Close the windows");
Line1.setSeparator();
Next.addAccelerator (finalcut::fc::Fmkey_npage); // Meta/Alt + PgDn
Next.setStatusbarMessage ("Switch to the next window");
Previous.addAccelerator (finalcut::fc::Fmkey_ppage); // Meta/Alt + PgUp
Previous.setStatusbarMessage ("Switch to the previous window");
Line2.setSeparator();
Quit.addAccelerator (finalcut::fc::Fmkey_x); // Meta/Alt + X
Quit.setStatusbarMessage ("Exit the program");
// Add menu item callback
addClickedCallback (New, &Window::cb_createWindows);
addClickedCallback (Close, &Window::cb_closeWindows);
addClickedCallback (Next, &Window::cb_next);
addClickedCallback (Previous, &Window::cb_previous);
addClickedCallback (Quit, &finalcut::FApplication::cb_exitApp);
addClickedCallback (&New, &Window::cb_createWindows);
addClickedCallback (&Close, &Window::cb_closeWindows);
addClickedCallback (&Next, &Window::cb_next);
addClickedCallback (&Previous, &Window::cb_previous);
addClickedCallback (&Quit, &finalcut::FApplication::cb_exitApp);
}
//----------------------------------------------------------------------
void Window::createDialogButtons()
void Window::configureDialogButtons()
{
// Dialog buttons
finalcut::FButton* CreateButton = new finalcut::FButton (this);
CreateButton->setGeometry(2, 2, 9, 1);
CreateButton->setText (L"&Create");
finalcut::FButton* CloseButton = new finalcut::FButton (this);
CloseButton->setGeometry(15, 2, 9, 1);
CloseButton->setText (L"C&lose");
finalcut::FButton* QuitButton = new finalcut::FButton (this);
QuitButton->setGeometry(28, 2, 9, 1);
QuitButton->setText (L"&Quit");
CreateButton.setGeometry (2, 2, 9, 1);
CreateButton.setText (L"&Create");
CloseButton.setGeometry (15, 2, 9, 1);
CloseButton.setText (L"C&lose");
QuitButton.setGeometry (28, 2, 9, 1);
QuitButton.setText (L"&Quit");
// Add button callback
addClickedCallback (CreateButton, &Window::cb_createWindows);
addClickedCallback (CloseButton, &Window::cb_closeWindows);
addClickedCallback (QuitButton, &finalcut::FApplication::cb_exitApp);
addClickedCallback (&CreateButton, &Window::cb_createWindows);
addClickedCallback (&CloseButton, &Window::cb_closeWindows);
addClickedCallback (&QuitButton, &finalcut::FApplication::cb_exitApp);
}
//----------------------------------------------------------------------
@ -442,7 +449,7 @@ void Window::cb_createWindows (finalcut::FWidget*, data_ptr)
SmallWindow* win = new SmallWindow(this);
win_dat->dgl = win;
win_dat->is_open = true;
win->setText(*(win_dat)->title);
win->setText(win_dat->title);
int n = int(std::distance(first, iter))
, x = dx + 5 + (n % 3) * 25 + int(n / 3) * 3
, y = dy + 11 + int(n / 3) * 3;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -11,7 +11,7 @@
version="1.1"
width="100%"
height="100%"
viewBox="0 0 750 128"
viewBox="0 0 650 128"
id="svg2"
style="fill-rule:evenodd">
<metadata
@ -27,7 +27,142 @@
</rdf:RDF>
</metadata>
<defs
id="defs43" />
id="defs43">
<linearGradient
x1="165.74928"
y1="57.311855"
x2="674.01331"
y2="57.311855"
id="linearGradient3784"
xlink:href="#a"
gradientUnits="userSpaceOnUse" />
<linearGradient
x1="165.74928"
y1="57.311855"
x2="674.01331"
y2="57.311855"
id="linearGradient3792"
xlink:href="#a"
gradientUnits="userSpaceOnUse" />
<linearGradient
x1="165.74928"
y1="57.311855"
x2="674.01331"
y2="57.311855"
id="linearGradient3792-9"
xlink:href="#a-8"
gradientUnits="userSpaceOnUse" />
<radialGradient
cx="134.06599"
cy="79.788696"
r="40.1213"
fx="134.06599"
fy="79.788696"
id="a-8"
gradientUnits="userSpaceOnUse">
<stop
id="stop5-1"
style="stop-color:#ffffff;stop-opacity:1"
offset="0" />
<stop
id="stop7-0"
style="stop-color:#999999;stop-opacity:1"
offset="1" />
</radialGradient>
<linearGradient
x1="165.74928"
y1="57.311855"
x2="674.01331"
y2="57.311855"
id="linearGradient3808"
xlink:href="#a-8"
gradientUnits="userSpaceOnUse" />
<radialGradient
cx="134.06599"
cy="79.788696"
r="40.1213"
fx="134.06599"
fy="79.788696"
id="radialGradient3810"
gradientUnits="userSpaceOnUse">
<stop
id="stop3812"
style="stop-color:#ffffff;stop-opacity:1"
offset="0" />
<stop
id="stop3814"
style="stop-color:#999999;stop-opacity:1"
offset="1" />
</radialGradient>
<linearGradient
x1="165.74928"
y1="57.311855"
x2="674.01331"
y2="57.311855"
id="linearGradient3818"
xlink:href="#a-8"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(-153.08409,-173.48831)" />
<linearGradient
x1="165.74928"
y1="57.311855"
x2="674.01331"
y2="57.311855"
id="linearGradient3792-0"
xlink:href="#a-1"
gradientUnits="userSpaceOnUse" />
<radialGradient
cx="134.06599"
cy="79.788696"
r="40.1213"
fx="134.06599"
fy="79.788696"
id="a-1"
gradientUnits="userSpaceOnUse">
<stop
id="stop5-0"
style="stop-color:#ffffff;stop-opacity:1"
offset="0" />
<stop
id="stop7-2"
style="stop-color:#999999;stop-opacity:1"
offset="1" />
</radialGradient>
<linearGradient
x1="165.74928"
y1="57.311855"
x2="674.01331"
y2="57.311855"
id="linearGradient3861"
xlink:href="#a-1"
gradientUnits="userSpaceOnUse" />
<radialGradient
cx="134.06599"
cy="79.788696"
r="40.1213"
fx="134.06599"
fy="79.788696"
id="radialGradient3863"
gradientUnits="userSpaceOnUse">
<stop
id="stop3865"
style="stop-color:#ffffff;stop-opacity:1"
offset="0" />
<stop
id="stop3867"
style="stop-color:#999999;stop-opacity:1"
offset="1" />
</radialGradient>
<linearGradient
x1="165.74928"
y1="57.311855"
x2="674.01331"
y2="57.311855"
id="linearGradient3871"
xlink:href="#a-1"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(0.378418,-0.44196145)" />
</defs>
<radialGradient
cx="134.06599"
cy="79.788696"
@ -107,6 +242,18 @@
xlink:href="#e"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.9999964,0,0,1,-39.981171,-27.394473)" />
<text
x="160.94762"
y="93.333893"
transform="scale(0.95126779,1.0512287)"
id="text37-5"
style="font-size:96px;font-style:normal;font-variant:normal;font-weight:600;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0;word-spacing:0;writing-mode:lr-tb;text-anchor:start;fill:#9f9f9f;fill-opacity:0.6206896;fill-rule:evenodd;stroke:none;font-family:FreeSans;-inkscape-font-specification:FreeSans Semi-Bold">
<tspan
x="160.94762"
y="93.333893"
id="tspan3006-1"
style="font-size:96px;font-style:normal;font-variant:normal;font-weight:600;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#9f9f9f;fill-opacity:0.6206896;stroke:none;font-family:FreeSans;-inkscape-font-specification:FreeSans Semi-Bold">FINAL CUT</tspan>
</text>
<g
id="g23"
style="stroke:#000000;stroke-width:0.70560098">
@ -142,15 +289,15 @@
id="path35"
style="fill:url(#f);stroke:#000000;stroke-width:0.70560002" />
<text
x="471.83469"
x="158.56929"
y="91.775856"
transform="scale(0.95126779,1.0512287)"
id="text37"
style="font-size:96px;font-weight:600;letter-spacing:0;word-spacing:0;writing-mode:lr-tb;text-anchor:middle;fill:#083c99;fill-rule:evenodd;stroke:#00173d;font-family:FreeSans">
style="font-size:96px;font-style:normal;font-variant:normal;font-weight:600;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0;word-spacing:0;writing-mode:lr-tb;text-anchor:start;fill:#083c99;fill-opacity:0.88747732;fill-rule:evenodd;stroke:none;font-family:FreeSans;-inkscape-font-specification:FreeSans Semi-Bold">
<tspan
x="471.83469"
x="158.56929"
y="91.775856"
id="tspan39"
style="font-size:96px;font-weight:600;writing-mode:lr-tb;text-anchor:middle;fill:#083c99;stroke:#00173d;font-family:FreeSans">The Final Cut</tspan>
id="tspan3006"
style="font-size:96px;font-style:normal;font-variant:normal;font-weight:600;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#083c99;fill-opacity:0.88747732;stroke:none;font-family:FreeSans;-inkscape-font-specification:FreeSans Semi-Bold">FINAL CUT</tspan>
</text>
</svg>

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 9.7 KiB

View File

@ -2,8 +2,8 @@
if [ $# -gt 0 ]
then
eval cppcheck --force --enable=all -I../include/ "$@"
eval cppcheck --force --enable=all -I../src/include/ "$@"
else
eval cppcheck --force --enable=all -I../include/ ../src/ ../examples/
eval cppcheck --force --enable=all -I../src/include/ ../src/ ../examples/
fi

View File

@ -1,8 +1,9 @@
#!/bin/bash
find ../src/ \
../include/final/ \
../src/include/final/ \
../examples/ \
../test/ \
-regextype posix-egrep \
-regex ".*\\.(cpp|h)$" \
-exec sed -i 's/ *$//' "{}" \;

View File

@ -1,3 +1,3 @@
#!/bin/sh
strace -c ../examples/.libs/ui
LD_LIBRARY_PATH=../src/.libs strace -c ../examples/.libs/ui

View File

@ -42,6 +42,7 @@ libfinal_la_SOURCES = \
fkey_map.cpp \
ftextview.cpp \
fstatusbar.cpp \
ftermcap.cpp \
ftermcapquirks.cpp \
ftermxterminal.cpp \
ftermfreebsd.cpp \
@ -108,7 +109,6 @@ finalcutinclude_HEADERS = \
include/final/fscrollview.h \
include/final/fstatusbar.h \
include/final/fstring.h \
include/final/ftcap_map.h \
include/final/ftermcap.h \
include/final/ftermcapquirks.h \
include/final/ftermxterminal.h \

View File

@ -12,10 +12,11 @@ INCLUDE_HEADERS = \
fapplication.h \
fbuttongroup.h \
fbutton.h \
ftogglebutton.h \
fcheckbox.h \
fswitch.h \
fdialog.h \
fevent.h \
fwindow.h \
ffiledialog.h \
final.h \
flabel.h \
@ -23,15 +24,12 @@ INCLUDE_HEADERS = \
flistbox.h \
flistview.h \
fmenu.h \
fmouse.h \
fkeyboard.h \
fdialoglistmenu.h \
fmenubar.h \
fradiomenuitem.h \
fcheckmenuitem.h \
fmessagebox.h \
ftooltip.h \
fobject.h \
foptiattr.h \
foptimove.h \
ftermbuffer.h \
@ -43,6 +41,8 @@ INCLUDE_HEADERS = \
fscrollview.h \
fstatusbar.h \
fstring.h \
fmouse.h \
fkeyboard.h \
ftermcap.h \
fterm.h \
ftermios.h \
@ -54,11 +54,11 @@ INCLUDE_HEADERS = \
ftermlinux.h \
fvterm.h \
ftextview.h \
ftogglebutton.h \
fcolorpalette.h \
fwidgetcolors.h \
fwidget.h \
fwindow.h
fevent.h \
fobject.h \
# compiler parameter
CXX = clang++
@ -87,8 +87,6 @@ OBJS = \
flistbox.o \
flistview.o \
fmenu.o \
fmouse.o \
fkeyboard.o \
fdialoglistmenu.o \
fmenubar.o \
fmenuitem.o \
@ -96,14 +94,17 @@ OBJS = \
fcheckmenuitem.o \
fmenulist.o \
fdialog.o \
fscrollview.o \
fwindow.o \
fscrollview.o \
fmessagebox.o \
ftooltip.o \
ffiledialog.o \
fkey_map.o \
ftextview.o \
fstatusbar.o \
fmouse.o \
fkeyboard.o \
ftermcap.o \
fterm.o \
ftermios.o \
ftermdetection.o \
@ -113,7 +114,6 @@ OBJS = \
ftermopenbsd.o \
ftermlinux.o \
fvterm.o \
fevent.o \
foptiattr.o \
foptimove.o \
ftermbuffer.o \
@ -121,12 +121,14 @@ OBJS = \
fcolorpalette.o \
fwidgetcolors.o \
fwidget.o \
fevent.o \
fobject.o
TERMCAP := $(shell test -n "$$(ldd {/usr,}/lib64/libncursesw.so.5 2>/dev/null | grep libtinfo)" && echo "-ltinfo" || echo "-lncurses")
ifdef DEBUG
OPTIMIZE = -O0 -fsanitize=undefined
OPTIMIZE = -O0 -fsanitize=bool,bounds,enum,float-cast-overflow,function,null
# OPTIMIZE = -O0 -fsanitize=undefined
else
OPTIMIZE = -O2
endif

View File

@ -12,10 +12,11 @@ INCLUDE_HEADERS = \
fapplication.h \
fbuttongroup.h \
fbutton.h \
ftogglebutton.h \
fcheckbox.h \
fswitch.h \
fdialog.h \
fevent.h \
fwindow.h \
ffiledialog.h \
final.h \
flabel.h \
@ -23,15 +24,12 @@ INCLUDE_HEADERS = \
flistbox.h \
flistview.h \
fmenu.h \
fmouse.h \
fkeyboard.h \
fdialoglistmenu.h \
fmenubar.h \
fradiomenuitem.h \
fcheckmenuitem.h \
fmessagebox.h \
ftooltip.h \
fobject.h \
foptiattr.h \
foptimove.h \
ftermbuffer.h \
@ -43,6 +41,8 @@ INCLUDE_HEADERS = \
fscrollview.h \
fstatusbar.h \
fstring.h \
fmouse.h \
fkeyboard.h \
ftermcap.h \
fterm.h \
ftermios.h \
@ -54,11 +54,11 @@ INCLUDE_HEADERS = \
ftermlinux.h \
fvterm.h \
ftextview.h \
ftogglebutton.h \
fcolorpalette.h \
fwidgetcolors.h \
fwidget.h \
fwindow.h
fevent.h \
fobject.h
# compiler parameter
CXX = g++
@ -87,8 +87,6 @@ OBJS = \
flistbox.o \
flistview.o \
fmenu.o \
fmouse.o \
fkeyboard.o \
fdialoglistmenu.o \
fmenubar.o \
fmenuitem.o \
@ -96,14 +94,17 @@ OBJS = \
fcheckmenuitem.o \
fmenulist.o \
fdialog.o \
fscrollview.o \
fwindow.o \
fscrollview.o \
fmessagebox.o \
ftooltip.o \
ffiledialog.o \
fkey_map.o \
ftextview.o \
fstatusbar.o \
fmouse.o \
fkeyboard.o \
ftermcap.o \
fterm.o \
ftermios.o \
ftermdetection.o \
@ -113,7 +114,6 @@ OBJS = \
ftermopenbsd.o \
ftermlinux.o \
fvterm.o \
fevent.o \
foptiattr.o \
foptimove.o \
ftermbuffer.o \
@ -121,6 +121,7 @@ OBJS = \
fcolorpalette.o \
fwidgetcolors.o \
fwidget.o \
fevent.o \
fobject.o
TERMCAP := $(shell test -n "$$(ldd {/usr,}/lib64/libncursesw.so.5 2>/dev/null | grep libtinfo)" && echo "-ltinfo" || echo "-lncurses")

View File

@ -1149,51 +1149,6 @@ void FApplication::processResizeEvent()
}
}
//----------------------------------------------------------------------
int FApplication::processTimerEvent()
{
FObject::TimerList::iterator iter, last;
timeval currentTime;
int activated = 0;
getCurrentTime (&currentTime);
if ( isTimerInUpdating() )
return 0;
if ( ! timer_list )
return 0;
if ( timer_list->empty() )
return 0;
iter = timer_list->begin();
last = timer_list->end();
while ( iter != last )
{
if ( ! iter->id
|| ! iter->object
|| currentTime < iter->timeout ) // no timer expired
break;
iter->timeout += iter->interval;
if ( iter->timeout < currentTime )
iter->timeout = currentTime + iter->interval;
if ( iter->interval.tv_usec > 0 || iter->interval.tv_sec > 0 )
activated++;
FTimerEvent t_ev(fc::Timer_Event, iter->id);
sendEvent(iter->object, &t_ev);
++iter;
}
return activated;
}
//----------------------------------------------------------------------
void FApplication::processCloseWidget()
{
@ -1219,7 +1174,7 @@ void FApplication::processCloseWidget()
//----------------------------------------------------------------------
bool FApplication::processNextEvent()
{
int num_events = 0;
uInt num_events = 0;
processKeyboardEvent();
processMouseEvent();
@ -1233,4 +1188,11 @@ bool FApplication::processNextEvent()
return ( num_events > 0 );
}
//----------------------------------------------------------------------
void FApplication::performTimerAction ( const FObject* receiver
, const FEvent* event )
{
sendEvent(receiver, event);
}
} // namespace finalcut

View File

@ -1548,15 +1548,31 @@ inline void FDialog::lowerActivateDialog()
updateTerminal();
}
//----------------------------------------------------------------------
bool FDialog::isLowerRightResizeCorner (mouseStates& ms)
{
// 3 characters in the lower right corner |
// x
// -----xx
if ( (ms.mouse_x == getWidth() && ms.mouse_y == getHeight() - 1)
|| ( ( ms.mouse_x == getWidth() - 1
|| ms.mouse_x == getWidth() ) && ms.mouse_y == getHeight() ) )
{
return true;
}
else
{
return false;
}
}
//----------------------------------------------------------------------
void FDialog::resizeMouseDown (mouseStates& ms)
{
// Click on the lower right resize corner
if ( isResizeable()
&& ( (ms.mouse_x == getWidth() && ms.mouse_y == getHeight())
|| (ms.mouse_x == getWidth() - 1 && ms.mouse_y == getHeight())
|| (ms.mouse_x == getWidth() && ms.mouse_y == getHeight() - 1) ) )
if ( isResizeable() && isLowerRightResizeCorner(ms) )
{
resize_click_pos = ms.termPos;
FPoint lower_right_pos = getTermGeometry().getLowerRightPos();

View File

@ -33,7 +33,7 @@ bool sortByName ( const FFileDialog::dir_entry& lhs
, const FFileDialog::dir_entry& rhs )
{
// lhs < rhs
return bool(strcasecmp(lhs.name, rhs.name) < 0);
return bool( strcasecmp(lhs.name, rhs.name) < 0 );
}
//----------------------------------------------------------------------
@ -60,8 +60,8 @@ FFileDialog::FFileDialog (FWidget* parent)
, dir_entries()
, directory()
, filter_pattern()
, filebrowser()
, filename()
, filebrowser()
, hidden()
, cancel()
, open()
@ -78,8 +78,8 @@ FFileDialog::FFileDialog (const FFileDialog& fdlg)
, dir_entries()
, directory(fdlg.directory)
, filter_pattern(fdlg.filter_pattern)
, filebrowser()
, filename()
, filebrowser()
, hidden()
, cancel()
, open()
@ -102,11 +102,11 @@ FFileDialog::FFileDialog ( const FString& dirname
, dir_entries()
, directory()
, filter_pattern(filter)
, filebrowser()
, filename()
, hidden()
, cancel()
, open()
, filename(this)
, filebrowser(this)
, hidden(this)
, cancel(this)
, open(this)
, dlg_type(type)
, show_hidden(false)
{
@ -119,7 +119,6 @@ FFileDialog::FFileDialog ( const FString& dirname
//----------------------------------------------------------------------
FFileDialog::~FFileDialog() // destructor
{
deallocation();
clear();
}
@ -134,11 +133,6 @@ FFileDialog& FFileDialog::operator = (const FFileDialog& fdlg)
}
else
{
delete open;
delete cancel;
delete hidden;
delete filebrowser;
delete filename;
clear();
if ( fdlg.getParentWidget() )
@ -160,7 +154,7 @@ FFileDialog& FFileDialog::operator = (const FFileDialog& fdlg)
//----------------------------------------------------------------------
const FString FFileDialog::getSelectedFile() const
{
uLong n = uLong(filebrowser->currentItem() - 1);
uLong n = uLong(filebrowser.currentItem() - 1);
if ( dir_entries[n].directory )
return FString("");
@ -222,7 +216,7 @@ bool FFileDialog::setShowHiddenFiles (bool on)
show_hidden = on;
readDir();
filebrowser->redraw();
filebrowser.redraw();
return show_hidden;
}
@ -234,7 +228,7 @@ void FFileDialog::onKeyPress (FKeyEvent* ev)
FDialog::onKeyPress (ev);
if ( ! filebrowser->hasFocus() )
if ( ! filebrowser.hasFocus() )
return;
int key = ev->key();
@ -374,10 +368,10 @@ void FFileDialog::adjustSize()
X = 1 + int((max_width - getWidth()) / 2);
Y = 1 + int((max_height - getHeight()) / 3);
setPos(X, Y, false);
filebrowser->setHeight (h - 8, false);
hidden->setY (h - 4, false);
cancel->setY (h - 4, false);
open->setY (h - 4, false);
filebrowser.setHeight (h - 8, false);
hidden.setY (h - 4, false);
cancel.setY (h - 4, false);
open.setY (h - 4, false);
FDialog::adjustSize();
printPath(directory);
}
@ -408,92 +402,72 @@ void FFileDialog::init()
else
FDialog::setText("Open file");
allocation (x, y); // Create widgets
widgetSettings (x, y); // Create widgets
initCallbacks();
setModal();
readDir();
}
//----------------------------------------------------------------------
inline void FFileDialog::allocation (int x, int y)
inline void FFileDialog::widgetSettings (int x, int y)
{
try
{
filename = new FLineEdit(this);
filename->setLabelText("File&name");
filename->setText(filter_pattern);
filename->setGeometry(11, 1, 28, 1);
filename->setFocus();
filename.setLabelText ("File&name");
filename.setText (filter_pattern);
filename.setGeometry (11, 1, 28, 1);
filename.setFocus();
filebrowser = new FListBox(this);
filebrowser->setGeometry(2, 3, 38, 6);
printPath(directory);
filebrowser.setGeometry (2, 3, 38, 6);
printPath (directory);
hidden = new FCheckBox("&hidden files", this);
hidden->setGeometry(2, 10, 16, 1);
hidden.setText ("&hidden files");
hidden.setGeometry (2, 10, 16, 1);
cancel = new FButton("&Cancel", this);
cancel->setGeometry(19, 10, 9, 1);
cancel.setText ("&Cancel");
cancel.setGeometry(19, 10, 9, 1);
if ( dlg_type == FFileDialog::Save )
open = new FButton("&Save", this);
else
open = new FButton("&Open", this);
if ( dlg_type == FFileDialog::Save )
open.setText ("&Save");
else
open.setText ("&Open");
open->setGeometry(30, 10, 9, 1);
setGeometry (x, y, getWidth(), getHeight());
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
return;
}
}
//----------------------------------------------------------------------
inline void FFileDialog::deallocation()
{
delete open;
delete cancel;
delete hidden;
delete filebrowser;
delete filename;
open.setGeometry(30, 10, 9, 1);
setGeometry (x, y, getWidth(), getHeight());
}
//----------------------------------------------------------------------
void FFileDialog::initCallbacks()
{
filename->addCallback
filename.addCallback
(
"activate",
F_METHOD_CALLBACK (this, &FFileDialog::cb_processActivate)
);
filebrowser->addCallback
filebrowser.addCallback
(
"row-changed",
F_METHOD_CALLBACK (this, &FFileDialog::cb_processRowChanged)
);
filebrowser->addCallback
filebrowser.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &FFileDialog::cb_processClicked)
);
hidden->addCallback
hidden.addCallback
(
"toggled",
F_METHOD_CALLBACK (this, &FFileDialog::cb_processShowHidden)
);
cancel->addCallback
cancel.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &FFileDialog::cb_processCancel)
);
open->addCallback
open.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &FFileDialog::cb_processOpen)
@ -725,7 +699,7 @@ void FFileDialog::dirEntriesToList()
{
// Fill list with directory entries
filebrowser->clear();
filebrowser.clear();
if ( dir_entries.empty() )
return;
@ -737,9 +711,9 @@ void FFileDialog::dirEntriesToList()
while ( iter != last )
{
if ( iter->directory )
filebrowser->insert(FString(iter->name), fc::SquareBrackets);
filebrowser.insert(FString(iter->name), fc::SquareBrackets);
else
filebrowser->insert(FString(iter->name));
filebrowser.insert(FString(iter->name));
++iter;
}
@ -774,7 +748,7 @@ int FFileDialog::changeDir (const FString& dirname)
if ( newdir == FString("..") )
{
if ( lastdir == FString('/') )
filename->setText('/');
filename.setText('/');
else if ( ! dir_entries.empty() )
{
int i = 1;
@ -788,8 +762,8 @@ int FFileDialog::changeDir (const FString& dirname)
{
if ( std::strcmp(iter->name, baseName) == 0 )
{
filebrowser->setCurrentItem(i);
filename->setText(FString(baseName) + '/');
filebrowser.setCurrentItem(i);
filename.setText(FString(baseName) + '/');
break;
}
@ -803,14 +777,14 @@ int FFileDialog::changeDir (const FString& dirname)
FString firstname = dir_entries[0].name;
if ( dir_entries[0].directory )
filename->setText(firstname + '/');
filename.setText(firstname + '/');
else
filename->setText(firstname);
filename.setText(firstname);
}
printPath(directory);
filename->redraw();
filebrowser->redraw();
filename.redraw();
filebrowser.redraw();
// fall through
default:
return 0;
@ -821,12 +795,12 @@ int FFileDialog::changeDir (const FString& dirname)
void FFileDialog::printPath (const FString& txt)
{
const FString& path = txt;
const uInt max_width = uInt(filebrowser->getWidth()) - 4;
const uInt max_width = uInt(filebrowser.getWidth()) - 4;
if ( path.getLength() > max_width )
filebrowser->setText(".." + path.right(max_width - 2));
filebrowser.setText(".." + path.right(max_width - 2));
else
filebrowser->setText(path);
filebrowser.setText(path);
}
//----------------------------------------------------------------------
@ -845,24 +819,24 @@ const FString FFileDialog::getHomeDir()
//----------------------------------------------------------------------
void FFileDialog::cb_processActivate (FWidget*, data_ptr)
{
if ( filename->getText().includes('*')
|| filename->getText().includes('?') )
if ( filename.getText().includes('*')
|| filename.getText().includes('?') )
{
setFilter(filename->getText());
setFilter(filename.getText());
readDir();
filebrowser->redraw();
filebrowser.redraw();
}
else if ( filename->getText().getLength() == 0 )
else if ( filename.getText().getLength() == 0 )
{
setFilter("*");
readDir();
filebrowser->redraw();
filebrowser.redraw();
}
else if ( filename->getText().trim() == FString("..")
|| filename->getText().includes('/')
|| filename->getText().includes('~') )
else if ( filename.getText().trim() == FString("..")
|| filename.getText().includes('/')
|| filename.getText().includes('~') )
{
changeDir(filename->getText().trim());
changeDir(filename.getText().trim());
}
else
{
@ -871,7 +845,7 @@ void FFileDialog::cb_processActivate (FWidget*, data_ptr)
if ( ! dir_entries.empty() )
{
std::vector<dir_entry>::const_iterator iter, last;
const FString& input = filename->getText().trim();
const FString& input = filename.getText().trim();
iter = dir_entries.begin();
last = dir_entries.end();
@ -898,7 +872,7 @@ void FFileDialog::cb_processActivate (FWidget*, data_ptr)
//----------------------------------------------------------------------
void FFileDialog::cb_processRowChanged (FWidget*, data_ptr)
{
const int n = filebrowser->currentItem();
const int n = filebrowser.currentItem();
if ( n == 0 )
return;
@ -906,17 +880,17 @@ void FFileDialog::cb_processRowChanged (FWidget*, data_ptr)
const FString& name = dir_entries[uLong(n - 1)].name;
if ( dir_entries[uLong(n - 1)].directory )
filename->setText( name + '/' );
filename.setText( name + '/' );
else
filename->setText( name );
filename.setText( name );
filename->redraw();
filename.redraw();
}
//----------------------------------------------------------------------
void FFileDialog::cb_processClicked (FWidget*, data_ptr)
{
const uLong n = uLong(filebrowser->currentItem() - 1);
const uLong n = uLong(filebrowser.currentItem() - 1);
if ( dir_entries[n].directory )
changeDir(dir_entries[n].name);

View File

@ -79,7 +79,7 @@ FKeyboard::FKeyboard()
, keypressed_cmd()
, keyreleased_cmd()
, escape_key_cmd()
, termcap_map(0)
, key_map(0)
{
// Initialize keyboard values
time_keypressed.tv_sec = 0;
@ -123,7 +123,7 @@ const FString FKeyboard::getKeyName (int keynum)
//----------------------------------------------------------------------
void FKeyboard::setTermcapMap (fc::fkeymap* keymap)
{
termcap_map = keymap;
key_map = keymap;
}
//----------------------------------------------------------------------
@ -232,10 +232,10 @@ inline int FKeyboard::getTermcapKey()
assert ( fifo_buf_size > 0 );
if ( ! termcap_map )
if ( ! key_map )
return -1;
fc::fkeymap* keymap = reinterpret_cast<fc::fkeymap*>(termcap_map);
fc::fkeymap* keymap = reinterpret_cast<fc::fkeymap*>(key_map);
for (int i = 0; keymap[i].tname[0] != 0; i++)
{
char* k = keymap[i].string;
@ -515,9 +515,9 @@ int FKeyboard::keyCorrection (const int& keycode)
if ( linux )
key_correction = linux->modifierKeyCorrection(keycode);
else
key_correction = key;
key_correction = keycode;
#else
key_correction = key;
key_correction = keycode;
#endif
return key_correction;

View File

@ -34,6 +34,123 @@ namespace finalcut
// Static class attribute
FObject::FObjectIterator FListView::null_iter;
// Function prototypes
long firstNumberFromString (const FString&);
bool sortAscendingByName (const FObject*, const FObject*);
bool sortDescendingByName (const FObject*, const FObject*);
bool sortAscendingByNumber (const FObject*, const FObject*);
bool sortDescendingByNumber (const FObject*, const FObject*);
// non-member functions
//----------------------------------------------------------------------
long firstNumberFromString (const FString& str)
{
const FString::iterator last = str.end();
FString::iterator iter = str.begin();
FString::iterator first_pos;
FString::iterator last_pos;
long number;
while ( iter != last )
{
if ( wchar_t(*iter) >= L'0' && wchar_t(*iter) <= L'9' )
{
if ( wchar_t(*(iter - 1)) == L'-' )
--iter;
break;
}
++iter;
}
first_pos = iter;
if ( first_pos == last )
return 0;
while ( iter != last )
{
if ( wchar_t(*iter) < L'0' || wchar_t(*iter) > L'9' )
break;
++iter;
}
last_pos = iter;
if ( last_pos == last )
return 0;
uInt pos = uInt(std::distance(str.begin(), first_pos)) + 1;
uInt length = uInt(std::distance(first_pos, last_pos));
const FString num_str = str.mid(pos, length);
try
{
number = num_str.toLong();
}
catch (const std::exception&)
{
return 0;
}
return number;
}
//----------------------------------------------------------------------
bool sortAscendingByName (const FObject* lhs, const FObject* rhs)
{
const FListViewItem* l_item = static_cast<const FListViewItem*>(lhs);
const FListViewItem* r_item = static_cast<const FListViewItem*>(rhs);
const int column = l_item->getSortColumn();
const FString l_string = l_item->getText(column);
const FString r_string = r_item->getText(column);
// lhs < rhs
return bool( strcasecmp(l_string.c_str(), r_string.c_str()) < 0 );
}
//----------------------------------------------------------------------
bool sortDescendingByName (const FObject* lhs, const FObject* rhs)
{
const FListViewItem* l_item = static_cast<const FListViewItem*>(lhs);
const FListViewItem* r_item = static_cast<const FListViewItem*>(rhs);
const int column = l_item->getSortColumn();
const FString l_string = l_item->getText(column);
const FString r_string = r_item->getText(column);
// lhs > rhs
return bool( strcasecmp(l_string.c_str(), r_string.c_str()) > 0 );
}
//----------------------------------------------------------------------
bool sortAscendingByNumber (const FObject* lhs, const FObject* rhs)
{
const FListViewItem* l_item = static_cast<const FListViewItem*>(lhs);
const FListViewItem* r_item = static_cast<const FListViewItem*>(rhs);
const int column = l_item->getSortColumn();
const long l_number = firstNumberFromString(l_item->getText(column));
const long r_number = firstNumberFromString(r_item->getText(column));
// lhs < rhs
return bool( l_number < r_number );
}
//----------------------------------------------------------------------
bool sortDescendingByNumber (const FObject* lhs, const FObject* rhs)
{
const FListViewItem* l_item = static_cast<const FListViewItem*>(lhs);
const FListViewItem* r_item = static_cast<const FListViewItem*>(rhs);
const int column = l_item->getSortColumn();
const long l_number = firstNumberFromString(l_item->getText(column));
const long r_number = firstNumberFromString(r_item->getText(column));
// lhs > rhs
return bool( l_number > r_number );
}
//----------------------------------------------------------------------
// class FListViewItem
//----------------------------------------------------------------------
@ -44,6 +161,7 @@ FListViewItem::FListViewItem (const FListViewItem& item)
: FObject(item.getParent())
, column_list(item.column_list)
, data_pointer(item.data_pointer)
, root()
, visible_lines(1)
, expandable(false)
, is_expand(false)
@ -68,6 +186,7 @@ FListViewItem::FListViewItem (FObjectIterator parent_iter)
: FObject((*parent_iter)->getParent())
, column_list()
, data_pointer(0)
, root()
, visible_lines(1)
, expandable(false)
, is_expand(false)
@ -82,6 +201,7 @@ FListViewItem::FListViewItem ( const FStringList& cols
: FObject(0)
, column_list(cols)
, data_pointer(data)
, root()
, visible_lines(1)
, expandable(false)
, is_expand(false)
@ -99,6 +219,16 @@ FListViewItem::~FListViewItem() // destructor
// public methods of FListViewItem
//----------------------------------------------------------------------
int FListViewItem::getSortColumn() const
{
if ( ! *root )
return -1;
FListView* root_obj = static_cast<FListView*>(*root);
return root_obj->getSortColumn();
}
//----------------------------------------------------------------------
FString FListViewItem::getText (int column) const
{
@ -208,11 +338,40 @@ void FListViewItem::collapse()
}
// private methods of FListView
//----------------------------------------------------------------------
template<typename Compare>
void FListViewItem::sort (Compare cmp)
{
if ( ! expandable )
return;
// Sort the top level
FObject::FObjectList& children_list = getChildren();
if ( ! children_list.empty() )
children_list.sort(cmp);
// Sort the sublevels
FListViewIterator iter = children_list.begin();
while ( iter != children_list.end() )
{
if ( *iter )
{
FListViewItem* item = static_cast<FListViewItem*>(*iter);
item->sort(cmp);
}
++iter;
}
}
//----------------------------------------------------------------------
FObject::FObjectIterator FListViewItem::appendItem (FListViewItem* child)
{
expandable = true;
resetVisibleLineCounter();
child->root = root;
addChild (child);
// Return iterator to child/last element
return --FObject::end();
@ -288,9 +447,6 @@ FListViewIterator::FListViewIterator (FObjectIterator iter)
, position(0)
{ }
//----------------------------------------------------------------------
FListViewIterator::~FListViewIterator() // destructor
{ }
// FListViewIterator operators
//----------------------------------------------------------------------
@ -454,6 +610,11 @@ FListView::FListView (FWidget* parent)
, xoffset(0)
, nf_offset(0)
, max_line_width(1)
, sort_column(-1)
, sort_type()
, sort_order(fc::unsorted)
, user_defined_ascending(0)
, user_defined_descending(0)
{
init();
}
@ -507,6 +668,24 @@ FString FListView::getColumnText (int column) const
return header[uInt(column)].name;
}
//----------------------------------------------------------------------
fc::sorting_type FListView::getColumnSortType (int column) const
{
fc::sorting_type type;
std::size_t size = uInt(column);
try
{
type = sort_type.at(size);
}
catch (const std::out_of_range&)
{
type = fc::unknown;
}
return type;
}
//----------------------------------------------------------------------
void FListView::setGeometry (int x, int y, int w, int h, bool adjust)
{
@ -559,6 +738,34 @@ void FListView::setColumnText (int column, const FString& label)
header[uInt(column)].name = label;
}
//----------------------------------------------------------------------
void FListView::setColumnSortType (int column, fc::sorting_type type)
{
// Sets the sort type by which the list is to be sorted
if ( column < 1 || header.empty() || column > int(header.size()) )
return;
std::size_t size = uInt(column + 1);
if ( sort_type.empty() || sort_type.size() < size )
sort_type.resize(size);
sort_type[uInt(column)] = type;
}
//----------------------------------------------------------------------
void FListView::setColumnSort (int column, fc::sorting_order order)
{
// Sets the column to sort by + the sorting order
if ( column < 1 || header.empty() || column > int(header.size()) )
column = -1;
sort_column = column;
sort_order = order;
}
//----------------------------------------------------------------------
int FListView::addColumn (const FString& label, int width)
{
@ -582,42 +789,14 @@ int FListView::addColumn (const FString& label, int width)
FObject::FObjectIterator FListView::insert ( FListViewItem* item
, FObjectIterator parent_iter )
{
static const int padding_space = 1;
int line_width = padding_space; // leading space
uInt column_idx = 0;
uInt entries = uInt(item->column_list.size());
FObjectIterator item_iter;
headerItems::iterator header_iter;
int line_width;
int element_count;
if ( parent_iter == FListView::null_iter )
return FListView::null_iter;
// Determine the line width
header_iter = header.begin();
while ( header_iter != header.end() )
{
int width = header_iter->width;
bool fixed_width = header_iter->fixed_width;
if ( ! fixed_width )
{
int len;
if ( column_idx < entries )
len = int(item->column_list[column_idx].getLength());
else
len = 0;
if ( len > width )
header_iter->width = len;
}
line_width += header_iter->width + padding_space; // width + trailing space
column_idx++;
++header_iter;
}
line_width = determineLineWidth (item);
recalculateHorizontalBar (line_width);
if ( parent_iter == root )
@ -652,7 +831,10 @@ FObject::FObjectIterator FListView::insert ( FListViewItem* item
first_visible_line = itemlist.begin();
}
int element_count = int(getCount());
// Sort list by a column (only if activated)
sort();
element_count = int(getCount());
recalculateVerticalBar (element_count);
return item_iter;
}
@ -703,6 +885,55 @@ FObject::FObjectIterator FListView::insert ( const std::vector<long>& cols
return item_iter;
}
//----------------------------------------------------------------------
void FListView::sort()
{
// Sorts the list view according to the specified setting
if ( sort_column < 1 && sort_column > int(header.size()) )
return;
switch ( getColumnSortType(sort_column) )
{
case fc::unknown:
case fc::by_name:
if ( sort_order == fc::ascending )
{
sort (sortAscendingByName);
}
else if ( sort_order == fc::descending )
{
sort (sortDescendingByName);
}
break;
case fc::by_number:
if ( sort_order == fc::ascending )
{
sort (sortAscendingByNumber);
}
else if ( sort_order == fc::descending )
{
sort (sortDescendingByNumber);
}
break;
case fc::user_defined:
if ( sort_order == fc::ascending && user_defined_ascending )
{
sort (user_defined_ascending);
}
else if ( sort_order == fc::descending && user_defined_descending )
{
sort (user_defined_descending);
}
break;
}
current_iter = itemlist.begin();
first_visible_line = itemlist.begin();
}
//----------------------------------------------------------------------
void FListView::onKeyPress (FKeyEvent* ev)
{
@ -1189,6 +1420,28 @@ void FListView::init()
setRightPadding(1 + nf_offset);
}
//----------------------------------------------------------------------
template<typename Compare>
void FListView::sort (Compare cmp)
{
// Sort the top level
itemlist.sort(cmp);
// Sort the sublevels
FListViewIterator iter = itemlist.begin();
while ( iter != itemlist.end() )
{
if ( *iter )
{
FListViewItem* item = static_cast<FListViewItem*>(*iter);
item->sort(cmp);
}
++iter;
}
}
//----------------------------------------------------------------------
uInt FListView::getAlignOffset ( fc::text_alignment align
, uInt txt_length
@ -1581,6 +1834,42 @@ void FListView::updateDrawing (bool draw_vbar, bool draw_hbar)
flush_out();
}
//----------------------------------------------------------------------
int FListView::determineLineWidth (FListViewItem* item)
{
static const int padding_space = 1;
int line_width = padding_space; // leading space
uInt column_idx = 0;
uInt entries = uInt(item->column_list.size());
headerItems::iterator header_iter;
header_iter = header.begin();
while ( header_iter != header.end() )
{
int width = header_iter->width;
bool fixed_width = header_iter->fixed_width;
if ( ! fixed_width )
{
int len;
if ( column_idx < entries )
len = int(item->column_list[column_idx].getLength());
else
len = 0;
if ( len > width )
header_iter->width = len;
}
line_width += header_iter->width + padding_space; // width + trailing space
column_idx++;
++header_iter;
}
return line_width;
}
//----------------------------------------------------------------------
void FListView::recalculateHorizontalBar (int len)
{
@ -1751,6 +2040,7 @@ void FListView::stopDragScroll()
//----------------------------------------------------------------------
FObject::FObjectIterator FListView::appendItem (FListViewItem* item)
{
item->root = root;
addChild (item);
itemlist.push_back (item);
return --itemlist.end();

View File

@ -38,7 +38,7 @@ namespace finalcut
//----------------------------------------------------------------------
FMenu::FMenu(FWidget* parent)
: FWindow(parent)
, item(0)
, item()
, super_menu(0)
, opened_sub_menu(0)
, shown_sub_menu(0)
@ -53,7 +53,7 @@ FMenu::FMenu(FWidget* parent)
//----------------------------------------------------------------------
FMenu::FMenu (const FString& txt, FWidget* parent)
: FWindow(parent)
, item(0)
, item(txt, parent)
, super_menu(0)
, opened_sub_menu(0)
, shown_sub_menu(0)
@ -62,16 +62,6 @@ FMenu::FMenu (const FString& txt, FWidget* parent)
, mouse_down(false)
, has_checkable_items(false)
{
try
{
item = new FMenuItem(txt, parent);
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
return;
}
init(parent);
}
@ -104,9 +94,7 @@ bool FMenu::setMenuWidget (bool on)
void FMenu::setStatusbarMessage (const FString& msg)
{
FWidget::setStatusbarMessage(msg);
if ( item )
item->setStatusbarMessage(msg);
item.setStatusbarMessage(msg);
}
//----------------------------------------------------------------------
@ -474,9 +462,7 @@ void FMenu::init(FWidget* parent)
setForegroundColor (wc.menu_active_fg);
setBackgroundColor (wc.menu_active_bg);
if ( item )
item->setMenu(this);
item.setMenu(this);
if ( parent )
{
@ -500,9 +486,7 @@ void FMenu::init(FWidget* parent)
//----------------------------------------------------------------------
void FMenu::calculateDimensions()
{
int item_X
, item_Y
, adjust_X;
int item_X, item_Y, adjust_X;
std::vector<FMenuItem*>::const_iterator iter, last;
iter = item_list.begin();
last = item_list.end();
@ -1038,7 +1022,7 @@ bool FMenu::containsMenuStructure (int x, int y)
return true;
else if ( si && si->hasMenu() && opened_sub_menu )
return si->getMenu()->containsMenuStructure(x, y);
else if ( item && item->getTermGeometry().contains(x, y) )
else if ( item.getTermGeometry().contains(x, y) )
return true;
else
return false;

View File

@ -53,6 +53,13 @@ FMenuBar::~FMenuBar() // destructor
// public methods of FMenuBar
//----------------------------------------------------------------------
void FMenuBar::resetMenu()
{
unselectItem();
drop_down = false;
}
//----------------------------------------------------------------------
void FMenuBar::hide()
{
@ -85,13 +92,6 @@ void FMenuBar::hide()
delete[] blank;
}
//----------------------------------------------------------------------
void FMenuBar::resetMenu()
{
unselectItem();
drop_down = false;
}
//----------------------------------------------------------------------
void FMenuBar::adjustSize()
{

View File

@ -99,6 +99,14 @@ FMenuItem::FMenuItem (int k, const FString& txt, FWidget* parent)
//----------------------------------------------------------------------
FMenuItem::~FMenuItem() // destructor
{
if ( super_menu && (isMenu(super_menu) || isMenuBar(super_menu)) )
{
FMenuList* menu_list = dynamic_cast<FMenuList*>(super_menu);
if ( menu_list )
menu_list->remove(this);
}
delAccelerator();
// remove dialog list item callback from the dialog

View File

@ -240,22 +240,8 @@ int FObject::addTimer (int interval)
timeval time_interval;
timeval currentTime;
int id = 1;
timer_modify_lock = true;
if ( ! timer_list )
{
try
{
timer_list = new TimerList();
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
return -1;
}
}
// find an unused timer id
if ( ! timer_list->empty() )
{
@ -389,4 +375,52 @@ bool FObject::event (FEvent* ev)
void FObject::onTimer (FTimerEvent*)
{ }
//----------------------------------------------------------------------
uInt FObject::processTimerEvent()
{
FObject::TimerList::iterator iter, last;
timeval currentTime;
uInt activated = 0;
getCurrentTime (&currentTime);
if ( isTimerInUpdating() )
return 0;
if ( ! timer_list )
return 0;
if ( timer_list->empty() )
return 0;
iter = timer_list->begin();
last = timer_list->end();
while ( iter != last )
{
if ( ! iter->id
|| ! iter->object
|| currentTime < iter->timeout ) // no timer expired
break;
iter->timeout += iter->interval;
if ( iter->timeout < currentTime )
iter->timeout = currentTime + iter->interval;
if ( iter->interval.tv_usec > 0 || iter->interval.tv_sec > 0 )
activated++;
FTimerEvent t_ev(fc::Timer_Event, iter->id);
performTimerAction (iter->object, &t_ev);
++iter;
}
return activated;
}
//----------------------------------------------------------------------
void FObject::performTimerAction (const FObject*, const FEvent*)
{ }
} // namespace finalcut

View File

@ -57,6 +57,7 @@ FOptiMove::FOptiMove (int baud)
, F_clr_eol()
, automatic_left_margin(false)
, eat_nl_glitch(false)
, move_buf()
, char_duration(1)
, baudrate(baud)
, tabstop(0)
@ -64,7 +65,10 @@ FOptiMove::FOptiMove (int baud)
, screen_height(24)
{
assert ( baud >= 0 );
move_buf[0] = '\0';
// Initialize arrays with '\0'
std::fill_n (move_buf, sizeof(move_buf), '\0');
calculateCharDuration();
// ANSI set cursor address preset for undefined terminals
@ -830,7 +834,7 @@ inline int FOptiMove::horizontalMove (char hmove[], int from_x, int to_x)
// Move to fixed column position1
std::strncat ( hmove
, tparm(F_column_address.cap, to_x, 0, 0, 0, 0, 0, 0, 0, 0)
, BUF_SIZE - std::strlen(hmove) );
, BUF_SIZE - std::strlen(hmove) - 1);
hmove[BUF_SIZE - 1] = '\0';
htime = F_column_address.duration;
}
@ -853,7 +857,7 @@ inline void FOptiMove::rightMove ( char hmove[], int& htime
{
std::strncpy ( hmove
, tparm(F_parm_right_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0)
, BUF_SIZE );
, BUF_SIZE - 1);
hmove[BUF_SIZE - 1] = '\0';
htime = F_parm_right_cursor.duration;
}
@ -908,7 +912,7 @@ inline void FOptiMove::leftMove ( char hmove[], int& htime
{
std::strncpy ( hmove
, tparm(F_parm_left_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0)
, BUF_SIZE );
, BUF_SIZE - 1);
hmove[BUF_SIZE - 1] = '\0';
htime = F_parm_left_cursor.duration;
}
@ -973,7 +977,7 @@ inline bool FOptiMove::isMethod0Faster ( int& move_time
if ( move_xy )
{
char* move_ptr = move_buf;
std::strncpy (move_ptr, move_xy, BUF_SIZE);
std::strncpy (move_ptr, move_xy, BUF_SIZE - 1);
move_ptr[BUF_SIZE - 1] = '\0';
move_time = F_cursor_address.duration;
return true;
@ -1123,7 +1127,7 @@ void FOptiMove::moveByMethod ( int method
case 2:
if ( F_carriage_return.cap )
{
std::strncpy (move_ptr, F_carriage_return.cap, BUF_SIZE);
std::strncpy (move_ptr, F_carriage_return.cap, BUF_SIZE - 1);
move_ptr[BUF_SIZE - 1] ='\0';
move_ptr += F_carriage_return.length;
relativeMove (move_ptr, 0, yold, xnew, ynew);
@ -1131,14 +1135,14 @@ void FOptiMove::moveByMethod ( int method
break;
case 3:
std::strncpy (move_ptr, F_cursor_home.cap, BUF_SIZE);
std::strncpy (move_ptr, F_cursor_home.cap, BUF_SIZE - 1);
move_ptr[BUF_SIZE - 1] ='\0';
move_ptr += F_cursor_home.length;
relativeMove (move_ptr, 0, 0, xnew, ynew);
break;
case 4:
std::strncpy (move_ptr, F_cursor_to_ll.cap, BUF_SIZE);
std::strncpy (move_ptr, F_cursor_to_ll.cap, BUF_SIZE - 1);
move_ptr[BUF_SIZE - 1] ='\0';
move_ptr += F_cursor_to_ll.length;
relativeMove (move_ptr, 0, screen_height - 1, xnew, ynew);

View File

@ -99,7 +99,7 @@ bool FStatusKey::setMouseFocus(bool on)
if ( on == mouse_focus )
return true;
return mouse_focus = ( on ) ? true : false;
return mouse_focus = on;
}

View File

@ -2675,32 +2675,41 @@ inline void FString::_assign (const wchar_t s[])
length = new_length;
}
//----------------------------------------------------------------------
inline void FString::_insert (uInt len, const wchar_t s[])
{
if ( len == 0 ) // String s is a null or a empty string
return;
if ( string )
delete[](string);
length = len;
bufsize = FWDBUFFER + length + 1;
try
{
string = new wchar_t[bufsize]();
}
catch (const std::bad_alloc& ex)
{
std::cerr << bad_alloc_str << " " << ex.what() << std::endl;
return;
}
std::wcsncpy (string, s, bufsize);
string[bufsize - 1] = L'\0';
}
//----------------------------------------------------------------------
inline void FString::_insert (uInt pos, uInt len, const wchar_t s[])
{
if ( len == 0 ) // String s is a null or a empty string
return;
if ( ! string )
if ( ! string ) // string is null
{
// string is null
length = len;
bufsize = FWDBUFFER + length + 1;
try
{
string = new wchar_t[bufsize]();
}
catch (const std::bad_alloc& ex)
{
std::cerr << bad_alloc_str << " " << ex.what() << std::endl;
return;
}
std::wcsncpy (string, s, bufsize);
string[bufsize - 1] = L'\0';
return;
_insert (len, s);
}
else
{

View File

@ -40,7 +40,7 @@ FSwitch::FSwitch(FWidget* parent)
}
//----------------------------------------------------------------------
FSwitch::FSwitch ( const FString& txt, FWidget* parent )
FSwitch::FSwitch (const FString& txt, FWidget* parent)
: FToggleButton(txt, parent)
, switch_offset_pos(0)
, button_pressed(false)

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,9 @@
/***********************************************************************
* ftcap_map.h - Internally used termcap capabilities *
* ftermcap.cpp - Provides access to terminal capabilities *
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2015-2017 Markus Gans *
* Copyright 2015-2018 Markus Gans *
* *
* The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
@ -20,22 +20,41 @@
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#ifndef FTCAPMAP_H
#define FTCAPMAP_H
#if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
#error "Only <final/final.h> can be included directly."
#endif
#include "final/ftermcap.h"
namespace finalcut
{
namespace fc
{
// static class attributes
bool FTermcap::background_color_erase = false;
bool FTermcap::automatic_left_margin = false;
bool FTermcap::automatic_right_margin = false;
bool FTermcap::eat_nl_glitch = false;
bool FTermcap::ansi_default_color = false;
bool FTermcap::osc_support = false;
bool FTermcap::no_utf8_acs_chars = false;
int FTermcap::max_color = 1;
int FTermcap::tabstop = 8;
int FTermcap::attr_without_color = 0;
static FTermcap::tcap_map term_caps[] =
//----------------------------------------------------------------------
// class FTermcap
//----------------------------------------------------------------------
// constructors and destructor
//----------------------------------------------------------------------
FTermcap::FTermcap()
{ }
//----------------------------------------------------------------------
FTermcap::~FTermcap() // destructor
{ }
// private Data Member of FTermcap - termcap capabilities
//----------------------------------------------------------------------
FTermcap::tcap_map FTermcap::tcap[] =
{
// .------------- term string
// | .-------- Tcap-code
@ -140,8 +159,4 @@ static FTermcap::tcap_map term_caps[] =
* "XX", "Us" and "Ue" are unofficial and they are only used here.
*/
} // namespace fc
} // namespace finalcut
#endif // FTCAPMAP_H

View File

@ -26,8 +26,8 @@ namespace finalcut
{
// static class attributes
char FTermcapQuirks::termtype[256] = { };
FTermcap::tcap_map* FTermcapQuirks::tcap = 0;
FTermData* FTermcapQuirks::fterm_data = 0;
FTermDetection* FTermcapQuirks::term_detection = 0;
@ -38,7 +38,9 @@ FTermDetection* FTermcapQuirks::term_detection = 0;
// constructors and destructor
//----------------------------------------------------------------------
FTermcapQuirks::FTermcapQuirks()
{ }
{
tcap = FTermcap::getTermcapMap();
}
//----------------------------------------------------------------------
FTermcapQuirks::~FTermcapQuirks() // destructor
@ -47,16 +49,9 @@ FTermcapQuirks::~FTermcapQuirks() // destructor
// public methods of FTermcapQuirks
//----------------------------------------------------------------------
void FTermcapQuirks::setTerminalType (const char tt[])
void FTermcapQuirks::setTermData (FTermData* data)
{
std::strncpy (termtype, tt, sizeof(termtype));
termtype[sizeof(termtype) - 1] = '\0';
}
//----------------------------------------------------------------------
void FTermcapQuirks::setTermcapMap (FTermcap::tcap_map* tc)
{
tcap = tc;
fterm_data = data;
}
//----------------------------------------------------------------------
@ -255,6 +250,8 @@ void FTermcapQuirks::init_termcap_xterm_quirks()
void FTermcapQuirks::init_termcap_rxvt_quirks()
{
// Set enter/exit alternative charset mode for rxvt terminal
const char* termtype = fterm_data->getTermType();
if ( std::strncmp(termtype, "rxvt-16color", 12) == 0 )
{
TCAP(fc::t_enter_alt_charset_mode) = \

View File

@ -31,8 +31,8 @@ FTermDetection::terminalType FTermDetection::terminal_type = \
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
FTermDetection::colorEnv FTermDetection::color_env;
FTermDetection::secondaryDA FTermDetection::secondary_da;
FTermData* FTermDetection::fterm_data = 0;
char FTermDetection::termtype[256] = { };
char FTermDetection::termfilename[256] = { };
char FTermDetection::ttytypename[256] = { };
bool FTermDetection::decscusr_support;
bool FTermDetection::terminal_detection;
@ -89,13 +89,9 @@ FTermDetection::~FTermDetection() // destructor
// public methods of FTermDetection
//----------------------------------------------------------------------
void FTermDetection::setTermFileName (char term_filename[])
void FTermDetection::setTermData (FTermData* data)
{
if ( ! term_filename )
return;
std::strncpy (termfilename, term_filename, sizeof(termfilename));
termfilename[sizeof(termfilename) - 1] = '\0';
fterm_data = data;
}
//----------------------------------------------------------------------
@ -128,6 +124,7 @@ void FTermDetection::getSystemTermType()
{
// Import the untrusted environment variable TERM
const char* const& term_env = std::getenv(C_STR("TERM"));
const char* termfilename = fterm_data->getTermFileName();
if ( term_env )
{
@ -164,6 +161,7 @@ bool FTermDetection::getTTYtype()
// vt100 ttys0
// Get term basename
const char* termfilename = fterm_data->getTermFileName();
const char* term_basename = std::strrchr(termfilename, '/');
if ( term_basename == 0 )
@ -221,6 +219,7 @@ bool FTermDetection::getTTYSFileEntry()
// Analyse /etc/ttys and get the term name
// get term basename
const char* termfilename = fterm_data->getTermFileName();
const char* term_basename = std::strrchr(termfilename, '/');
if ( term_basename == 0 )

View File

@ -38,8 +38,8 @@ namespace finalcut
console_font_op FTermLinux::screen_font;
unimapdesc FTermLinux::screen_unicode_map;
bool FTermLinux::NewFont;
bool FTermLinux::VGAFont;
bool FTermLinux::new_font;
bool FTermLinux::vga_font;
bool FTermLinux::shadow_character = true;
bool FTermLinux::half_block_character = true;
bool FTermLinux::has_saved_palette = false;
@ -194,7 +194,7 @@ void FTermLinux::initCharMap (uInt char_map[][fc::NUM_OF_ENCODINGS])
{
uInt c1, c2, c3, c4, c5;
if ( NewFont || VGAFont )
if ( new_font || vga_font )
return;
if ( screen_unicode_map.entry_ct != 0 )
@ -255,7 +255,7 @@ void FTermLinux::finish()
//----------------------------------------------------------------------
bool FTermLinux::loadVGAFont()
{
VGAFont = true;
vga_font = true;
if ( FTerm::openConsole() == 0 )
{
@ -265,7 +265,7 @@ bool FTermLinux::loadVGAFont()
int ret = setScreenFont(fc::__8x16std, 256, 8, 16);
if ( ret != 0 )
VGAFont = false;
vga_font = false;
// unicode character mapping
struct unimapdesc unimap;
@ -275,24 +275,24 @@ bool FTermLinux::loadVGAFont()
setUnicodeMap(&unimap);
}
else
VGAFont = false;
vga_font = false;
FTerm::detectTermSize();
FTerm::closeConsole();
}
else
VGAFont = false;
vga_font = false;
if ( VGAFont )
if ( vga_font )
shadow_character = half_block_character = true;
return VGAFont;
return vga_font;
}
//----------------------------------------------------------------------
bool FTermLinux::loadNewFont()
{
NewFont = true;
new_font = true;
if ( FTerm::openConsole() == 0 )
{
@ -302,7 +302,7 @@ bool FTermLinux::loadNewFont()
int ret = setScreenFont(fc::__8x16graph, 256, 8, 16);
if ( ret != 0 )
NewFont = false;
new_font = false;
// unicode character mapping
struct unimapdesc unimap;
@ -312,18 +312,18 @@ bool FTermLinux::loadNewFont()
setUnicodeMap(&unimap);
}
else
NewFont = false;
new_font = false;
FTerm::detectTermSize();
FTerm::closeConsole();
}
else
NewFont = false;
new_font = false;
if ( VGAFont )
if ( vga_font )
shadow_character = half_block_character = true;
return NewFont;
return new_font;
}
//----------------------------------------------------------------------
@ -363,7 +363,7 @@ bool FTermLinux::loadOldFont (uInt char_map[][fc::NUM_OF_ENCODINGS])
}
if ( retval )
VGAFont = NewFont = false;
vga_font = new_font = false;
return retval;
}

View File

@ -31,9 +31,8 @@ namespace finalcut
bool FTermXTerminal::mouse_support;
bool FTermXTerminal::meta_sends_esc;
bool FTermXTerminal::xterm_default_colors;
FTermcap::tcap_map* FTermXTerminal::tcap = 0;
FTermDetection* FTermXTerminal::term_detection = 0;
fc::xtermCursorStyle FTermXTerminal::cursor_style = fc::unknown_cursor_style;
int FTermXTerminal::term_width = 80;
int FTermXTerminal::term_height = 24;
const FString* FTermXTerminal::xterm_font = 0;
const FString* FTermXTerminal::xterm_title = 0;
const FString* FTermXTerminal::foreground_color = 0;
@ -42,6 +41,9 @@ const FString* FTermXTerminal::cursor_color = 0;
const FString* FTermXTerminal::mouse_foreground_color = 0;
const FString* FTermXTerminal::mouse_background_color = 0;
const FString* FTermXTerminal::highlight_background_color = 0;
FTermcap::tcap_map* FTermXTerminal::tcap = 0;
FTermDetection* FTermXTerminal::term_detection = 0;
fc::xtermCursorStyle FTermXTerminal::cursor_style = fc::unknown_cursor_style;
//----------------------------------------------------------------------
@ -56,6 +58,8 @@ FTermXTerminal::FTermXTerminal()
mouse_support = \
meta_sends_esc = \
xterm_default_colors = false;
tcap = FTermcap::getTermcapMap();
}
//----------------------------------------------------------------------
@ -121,6 +125,16 @@ void FTermXTerminal::setTitle (const FString& title)
setXTermTitle();
}
//----------------------------------------------------------------------
void FTermXTerminal::setTermSize (int width, int height)
{
// Set xterm size to {term_width} x {term_height}
term_width = width;
term_height = height;
setXTermSize();
}
//----------------------------------------------------------------------
void FTermXTerminal::setForeground (const FString& fg)
{
@ -398,6 +412,16 @@ void FTermXTerminal::setXTermTitle()
}
}
//----------------------------------------------------------------------
void FTermXTerminal::setXTermSize()
{
if ( term_detection->isXTerminal() )
{
FTerm::putstringf (CSI "8;%d;%dt", term_height, term_width);
std::fflush(stdout);
}
}
//----------------------------------------------------------------------
void FTermXTerminal::setXTermFont()
{

View File

@ -64,7 +64,8 @@ FToggleButton::FToggleButton (const FString& txt, FWidget* parent)
, focus_inside_group(true)
, text()
{
init(txt);
FToggleButton::setText(txt); // call own method
init();
if ( parent && parent->isInstanceOf("FButtonGroup") )
{
@ -611,13 +612,6 @@ void FToggleButton::setGroup (FButtonGroup* btngroup)
button_group = btngroup;
}
//----------------------------------------------------------------------
void FToggleButton::init (const FString& txt)
{
setText(txt);
init();
}
//----------------------------------------------------------------------
void FToggleButton::init()
{

View File

@ -51,8 +51,7 @@ FPoint* FVTerm::term_pos = 0;
FVTerm::term_area* FVTerm::vterm = 0;
FVTerm::term_area* FVTerm::vdesktop = 0;
FVTerm::term_area* FVTerm::active_area = 0;
FVTerm::termcap_map* FVTerm::tcap = 0;
FTermcap::tcap_map* FTermcap::tcap = 0;
FTermcap::tcap_map* FVTerm::tcap = 0;
FKeyboard* FVTerm::keyboard = 0;
FVTerm::charData FVTerm::term_attribute;
FVTerm::charData FVTerm::next_attribute;
@ -2099,7 +2098,7 @@ void FVTerm::init()
std::memcpy (&next_attribute, &term_attribute, sizeof(charData));
// Receive the terminal capabilities
tcap = FTermcap().getTermcapMap();
tcap = FTermcap::getTermcapMap();
// Create virtual terminal
FRect term_geometry (0, 0, getColumnNumber(), getLineNumber());

View File

@ -361,7 +361,7 @@ bool FWidget::setEnable (bool on)
else
flags &= ~fc::active;
return enable = ( on ) ? true : false;
return enable = on;
}
//----------------------------------------------------------------------
@ -414,7 +414,7 @@ bool FWidget::setFocus (bool on)
window->setWindowFocusWidget(this);
}
return focus = ( on ) ? true : false;
return focus = on;
}
//----------------------------------------------------------------------

View File

@ -174,7 +174,7 @@ bool FWindow::activateWindow (bool on)
active_area = getVWin();
}
return window_active = ( on ) ? true : false;
return window_active = on;
}
//----------------------------------------------------------------------

View File

@ -89,11 +89,11 @@ class FApplication : public FWidget
virtual ~FApplication();
// Accessors
const char* getClassName() const;
int getArgc() const;
char** getArgv() const;
FWidget* getMainWidget() const;
FWidget* getFocusWidget() const;
const char* getClassName() const;
int getArgc() const;
char** getArgv() const;
FWidget* getMainWidget() const;
virtual FWidget* getFocusWidget() const;
// Mutator
void setMainWidget (FWidget*);
@ -175,9 +175,10 @@ class FApplication : public FWidget
void sendWheelEvent (const FPoint&, const FPoint&);
void processMouseEvent();
void processResizeEvent();
int processTimerEvent();
void processCloseWidget();
bool processNextEvent();
virtual void performTimerAction ( const FObject*
, const FEvent* );
// Data Members
int app_argc;

View File

@ -89,13 +89,13 @@ class FButton : public FWidget
bool setNoUnderline(bool);
bool setNoUnderline();
bool unsetNoUnderline();
bool setEnable(bool);
bool setEnable();
bool unsetEnable();
bool setDisable();
bool setFocus(bool);
bool setFocus();
bool unsetFocus();
virtual bool setEnable(bool);
virtual bool setEnable();
virtual bool unsetEnable();
virtual bool setDisable();
virtual bool setFocus(bool);
virtual bool setFocus();
virtual bool unsetFocus();
bool setFlat(bool);
bool setFlat();
bool unsetFlat();
@ -117,17 +117,17 @@ class FButton : public FWidget
bool hasClickAnimation();
// Methods
void hide();
virtual void hide();
// Event handlers
void onKeyPress (FKeyEvent*);
void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*);
void onMouseMove (FMouseEvent*);
void onTimer (FTimerEvent*);
void onAccel (FAccelEvent*);
void onFocusIn (FFocusEvent*);
void onFocusOut (FFocusEvent*);
virtual void onKeyPress (FKeyEvent*);
virtual void onMouseDown (FMouseEvent*);
virtual void onMouseUp (FMouseEvent*);
virtual void onMouseMove (FMouseEvent*);
virtual void onTimer (FTimerEvent*);
virtual void onAccel (FAccelEvent*);
virtual void onFocusIn (FFocusEvent*);
virtual void onFocusOut (FFocusEvent*);
private:
// Disable copy constructor
@ -149,7 +149,7 @@ class FButton : public FWidget
void drawMarginRight();
void drawTopBottomBackground();
void drawButtonTextLine (wchar_t[]);
void draw();
virtual void draw();
void updateStatusBar();
void updateButtonColor();
void processClick();

View File

@ -87,10 +87,10 @@ class FButtonGroup : public FScrollView
FString& getText();
// Mutator
bool setEnable(bool);
bool setEnable();
bool unsetEnable();
bool setDisable();
virtual bool setEnable(bool);
virtual bool setEnable();
virtual bool unsetEnable();
virtual bool setDisable();
void setText (const FString&);
// Inquiries
@ -99,16 +99,16 @@ class FButtonGroup : public FScrollView
bool hasCheckedButton() const;
// Methods
void hide();
virtual void hide();
void insert (FToggleButton*);
void remove (FToggleButton*);
void checkScrollSize (FToggleButton*);
void checkScrollSize (const FRect&);
// Event handlers
void onMouseDown (FMouseEvent*);
void onAccel (FAccelEvent*);
void onFocusIn (FFocusEvent*);
virtual void onMouseDown (FMouseEvent*);
virtual void onAccel (FAccelEvent*);
virtual void onFocusIn (FFocusEvent*);
// Callback method
void cb_buttonToggled (FWidget*, data_ptr);

View File

@ -79,7 +79,7 @@ enum events
Timer_Event // timer event occur
};
// Properties of a widget
// Properties of a widget
enum widget_flags
{
shadow = 0x00000001,
@ -1039,6 +1039,21 @@ enum sides
left = 3
};
enum sorting_type
{
by_name,
by_number,
user_defined,
unknown
};
enum sorting_order
{
ascending,
descending,
unsorted
};
enum brackets_type
{
NoBrackets = 0,

View File

@ -90,9 +90,9 @@ class FCheckBox : public FToggleButton
FCheckBox& operator = (const FCheckBox&);
// Methods
void init();
void draw();
void drawCheckButton();
void init();
virtual void draw();
void drawCheckButton();
};
#pragma pack(pop)

View File

@ -104,7 +104,7 @@ class FDialog : public FWindow
bool setModal (bool);
bool setModal();
bool unsetModal();
bool setResizeable (bool);
virtual bool setResizeable (bool);
bool setScrollable (bool);
bool setScrollable();
bool unsetScrollable();
@ -115,16 +115,16 @@ class FDialog : public FWindow
bool isScrollable();
// Methods
void show();
void hide();
virtual void show();
virtual void hide();
int exec();
void setPos (int, int, bool = true);
void move (int, int);
virtual void setPos (int, int, bool = true);
virtual void move (int, int);
bool moveUp (int);
bool moveDown (int);
bool moveLeft (int);
bool moveRight (int);
void setSize (int, int, bool = true);
virtual void setSize (int, int, bool = true);
bool reduceHeight (int);
bool expandHeight (int);
bool reduceWidth (int);
@ -132,16 +132,16 @@ class FDialog : public FWindow
void activateDialog();
// Event handlers
void onKeyPress (FKeyEvent*);
void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*);
void onMouseMove (FMouseEvent*);
void onMouseDoubleClick (FMouseEvent*);
void onAccel (FAccelEvent*);
void onWindowActive (FEvent*);
void onWindowInactive (FEvent*);
void onWindowRaised (FEvent*);
void onWindowLowered (FEvent*);
virtual void onKeyPress (FKeyEvent*);
virtual void onMouseDown (FMouseEvent*);
virtual void onMouseUp (FMouseEvent*);
virtual void onMouseMove (FMouseEvent*);
virtual void onMouseDoubleClick (FMouseEvent*);
virtual void onAccel (FAccelEvent*);
virtual void onWindowActive (FEvent*);
virtual void onWindowInactive (FEvent*);
virtual void onWindowRaised (FEvent*);
virtual void onWindowLowered (FEvent*);
protected:
// Methods
@ -207,6 +207,7 @@ class FDialog : public FWindow
void moveSizeKey (FKeyEvent*);
void raiseActivateDialog();
void lowerActivateDialog();
bool isLowerRightResizeCorner (mouseStates&);
void resizeMouseDown (mouseStates&);
void resizeMouseUpMove (mouseStates&, bool = false);
void cancelMouseResize();

View File

@ -109,7 +109,7 @@ class FFileDialog : public FDialog
, DialogType = FFileDialog::Open
, FWidget* = 0 );
// Destructor
~FFileDialog();
virtual ~FFileDialog();
// Assignment operator (=)
FFileDialog& operator = (const FFileDialog&);
@ -129,7 +129,7 @@ class FFileDialog : public FDialog
bool unsetShowHiddenFiles();
// Event handler
void onKeyPress (FKeyEvent*);
virtual void onKeyPress (FKeyEvent*);
// Methods
static const FString fileOpenChooser ( FWidget*
@ -141,7 +141,7 @@ class FFileDialog : public FDialog
protected:
// Method
void adjustSize();
virtual void adjustSize();
private:
// Typedef
@ -163,10 +163,9 @@ class FFileDialog : public FDialog
// Method
void init();
void allocation (int, int);
void deallocation();
void widgetSettings (int, int);
void initCallbacks();
inline bool pattern_match (const char* const, char[]);
bool pattern_match (const char* const, char[]);
void clear();
int numOfDirs();
void sortDir();
@ -191,11 +190,11 @@ class FFileDialog : public FDialog
dirEntries dir_entries;
FString directory;
FString filter_pattern;
FListBox* filebrowser;
FLineEdit* filename;
FCheckBox* hidden;
FButton* cancel;
FButton* open;
FLineEdit filename;
FListBox filebrowser;
FCheckBox hidden;
FButton cancel;
FButton open;
DialogType dlg_type;
bool show_hidden;

View File

@ -177,7 +177,7 @@ class FKeyboard
FKeyboardCommand escape_key_cmd;
static timeval time_keypressed;
fc::fkeymap* termcap_map;
fc::fkeymap* key_map;
#if defined(__linux__)
#undef linux

View File

@ -107,7 +107,7 @@ class FLabel : public FWidget
bool setReverseMode(bool);
bool setReverseMode();
bool unsetReverseMode();
bool setEnable (bool);
virtual bool setEnable (bool);
void setNumber (uLong);
void setNumber (long);
void setNumber (float, int = FLT_DIG);
@ -120,12 +120,12 @@ class FLabel : public FWidget
bool hasReverseMode();
// Methods
void hide();
virtual void hide();
void clear();
// Event handlers
void onMouseDown (FMouseEvent*);
void onAccel (FAccelEvent*);
virtual void onMouseDown (FMouseEvent*);
virtual void onAccel (FAccelEvent*);
// Callback method
void cb_accel_widget_destroyed (FWidget*, data_ptr);
@ -143,7 +143,7 @@ class FLabel : public FWidget
int getHotkeyPos (wchar_t[], wchar_t[], uInt);
void setHotkeyAccelerator();
int getAlignOffset (int);
void draw();
virtual void draw();
void drawMultiLine();
void drawSingleLine();
void printLine (wchar_t[], uInt, int, int = 0);

View File

@ -96,46 +96,46 @@ class FLineEdit : public FWidget
const FLineEdit& operator >> (FString&);
// Accessors
const char* getClassName() const;
FString getText() const;
int getLabelOrientation();
const char* getClassName() const;
FString getText() const;
int getLabelOrientation();
// Mutators
void setText (const FString&);
void setLabelText (const FString&);
void setLabelOrientation(const label_o);
bool setEnable(bool);
bool setEnable();
bool unsetEnable();
bool setDisable();
bool setFocus(bool);
bool setFocus();
bool unsetFocus();
bool setShadow(bool);
bool setShadow();
bool unsetShadow();
void setText (const FString&);
void setLabelText (const FString&);
void setLabelOrientation(const label_o);
virtual bool setEnable(bool);
virtual bool setEnable();
virtual bool unsetEnable();
virtual bool setDisable();
virtual bool setFocus(bool);
virtual bool setFocus();
virtual bool unsetFocus();
bool setShadow(bool);
bool setShadow();
bool unsetShadow();
// Inquiry
bool hasShadow();
bool hasShadow();
// Methods
void hide();
void clear();
virtual void hide();
void clear();
// Event handlers
void onKeyPress (FKeyEvent*);
void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*);
void onMouseMove (FMouseEvent*);
void onTimer (FTimerEvent*);
void onAccel (FAccelEvent*);
void onHide (FHideEvent*);
void onFocusIn (FFocusEvent*);
void onFocusOut (FFocusEvent*);
virtual void onKeyPress (FKeyEvent*);
virtual void onMouseDown (FMouseEvent*);
virtual void onMouseUp (FMouseEvent*);
virtual void onMouseMove (FMouseEvent*);
virtual void onTimer (FTimerEvent*);
virtual void onAccel (FAccelEvent*);
virtual void onHide (FHideEvent*);
virtual void onFocusIn (FFocusEvent*);
virtual void onFocusOut (FFocusEvent*);
protected:
void adjustLabel();
void adjustSize();
void adjustLabel();
virtual void adjustSize();
private:
// Enumeration
@ -153,33 +153,33 @@ class FLineEdit : public FWidget
FLineEdit& operator = (const FLineEdit&);
// Methods
void init();
bool hasHotkey();
void draw();
void drawInputField();
void keyLeft();
void keyRight();
void keyHome();
void keyEnd();
void keyDel();
void keyBackspace();
void keyInsert();
void keyEnter();
bool keyInput (int);
void processActivate();
void processChanged();
void init();
bool hasHotkey();
virtual void draw();
void drawInputField();
void keyLeft();
void keyRight();
void keyHome();
void keyEnd();
void keyDel();
void keyBackspace();
void keyInsert();
void keyEnter();
bool keyInput (int);
void processActivate();
void processChanged();
// Data Members
FString text;
FString label_text;
FLabel* label;
label_o label_orientation;
dragScroll drag_scroll;
bool scroll_timer;
int scroll_repeat;
bool insert_mode;
int cursor_pos;
int text_offset;
FString text;
FString label_text;
FLabel* label;
label_o label_orientation;
dragScroll drag_scroll;
bool scroll_timer;
int scroll_repeat;
bool insert_mode;
int cursor_pos;
int text_offset;
};
#pragma pack(pop)

View File

@ -153,7 +153,7 @@ class FListBox : public FWidget
FListBox (Container, LazyConverter, FWidget* = 0);
// Destructor
~FListBox();
virtual ~FListBox();
// Accessors
const char* getClassName() const;
@ -173,14 +173,14 @@ class FListBox : public FWidget
void showInsideBrackets (int, fc::brackets_type);
void showNoBrackets (int);
void showNoBrackets (listBoxItems::iterator);
void setGeometry (int, int, int, int, bool = true);
virtual void setGeometry (int, int, int, int, bool = true);
void setMultiSelection (bool);
void setMultiSelection ();
void unsetMultiSelection ();
bool setDisable();
bool setFocus (bool);
bool setFocus();
bool unsetFocus();
virtual bool setDisable();
virtual bool setFocus (bool);
virtual bool setFocus();
virtual bool unsetFocus();
void setText (const FString&);
// Inquiries
@ -191,7 +191,7 @@ class FListBox : public FWidget
bool hasBrackets (listBoxItems::iterator) const;
// Methods
void hide();
virtual void hide();
template <class Iterator, class InsertConverter>
void insert (Iterator, Iterator, InsertConverter);
template <class Container, class LazyConverter>
@ -209,21 +209,20 @@ class FListBox : public FWidget
void clear();
// Event handlers
void onKeyPress (FKeyEvent*);
void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*);
void onMouseMove (FMouseEvent*);
void onMouseDoubleClick (FMouseEvent*);
void onWheel (FWheelEvent*);
void onTimer (FTimerEvent*);
void onFocusIn (FFocusEvent*);
void onFocusOut (FFocusEvent*);
virtual void onKeyPress (FKeyEvent*);
virtual void onMouseDown (FMouseEvent*);
virtual void onMouseUp (FMouseEvent*);
virtual void onMouseMove (FMouseEvent*);
virtual void onMouseDoubleClick (FMouseEvent*);
virtual void onWheel (FWheelEvent*);
virtual void onTimer (FTimerEvent*);
virtual void onFocusIn (FFocusEvent*);
virtual void onFocusOut (FFocusEvent*);
protected:
// Methods
void adjustYOffset();
void adjustSize();
void adjustYOffset();
virtual void adjustSize();
private:
// Enumeration
@ -244,53 +243,53 @@ class FListBox : public FWidget
static FString& getString (listBoxItems::iterator);
// Methods
void init();
void draw();
void drawLabel();
void drawList();
void drawListLine (int, listBoxItems::iterator, bool);
void printLeftBracket (fc::brackets_type);
void printRightBracket (fc::brackets_type);
void drawListBracketsLine (int, listBoxItems::iterator, bool);
void setLineAttributes (int, bool, bool, bool&);
void unsetAttributes();
void updateDrawing (bool, bool);
void recalculateHorizontalBar (int, bool);
void recalculateVerticalBar (int);
void getWidgetFocus();
void multiSelection (int);
void multiSelectionUpTo (int);
void wheelUp (int);
void wheelDown (int);
bool dragScrollUp();
bool dragScrollDown();
void dragUp (int);
void dragDown (int);
void stopDragScroll();
void prevListItem (int);
void nextListItem (int);
void scrollToX (int);
void scrollToY (int);
void scrollLeft (int);
void scrollRight (int);
void keyUp();
void keyDown();
void keyLeft();
void keyRight();
void keyPgUp();
void keyPgDn();
void keyHome();
void keyEnd();
bool keyEsc();
void keyEnter();
bool keySpace();
bool keyInsert();
bool keyBackspace();
bool keyIncSearchInput (int);
void processClick();
void processSelect();
void processChanged();
void lazyConvert (listBoxItems::iterator, int);
void init();
virtual void draw();
void drawLabel();
void drawList();
void drawListLine (int, listBoxItems::iterator, bool);
void printLeftBracket (fc::brackets_type);
void printRightBracket (fc::brackets_type);
void drawListBracketsLine (int, listBoxItems::iterator, bool);
void setLineAttributes (int, bool, bool, bool&);
void unsetAttributes();
void updateDrawing (bool, bool);
void recalculateHorizontalBar (int, bool);
void recalculateVerticalBar (int);
void getWidgetFocus();
void multiSelection (int);
void multiSelectionUpTo (int);
void wheelUp (int);
void wheelDown (int);
bool dragScrollUp();
bool dragScrollDown();
void dragUp (int);
void dragDown (int);
void stopDragScroll();
void prevListItem (int);
void nextListItem (int);
void scrollToX (int);
void scrollToY (int);
void scrollLeft (int);
void scrollRight (int);
void keyUp();
void keyDown();
void keyLeft();
void keyRight();
void keyPgUp();
void keyPgDn();
void keyHome();
void keyEnd();
bool keyEsc();
void keyEnter();
bool keySpace();
bool keyInsert();
bool keyBackspace();
bool keyIncSearchInput (int);
void processClick();
void processSelect();
void processChanged();
void lazyConvert (listBoxItems::iterator, int);
listBoxItems::iterator index2iterator (int);
// Callback methods
@ -298,9 +297,9 @@ class FListBox : public FWidget
void cb_HBarChange (FWidget*, data_ptr);
// Function Pointer
void (*convertToItem) ( FListBoxItem&
, FWidget::data_ptr
, int index );
void (*convertToItem) ( FListBoxItem&
, FWidget::data_ptr
, int index );
// Data Members
listBoxItems itemlist;

View File

@ -84,7 +84,7 @@ class FListViewItem : public FObject
, FObjectIterator );
// Destructor
~FListViewItem();
virtual ~FListViewItem();
// Assignment operator (=)
FListViewItem& operator = (const FListViewItem&);
@ -92,12 +92,14 @@ class FListViewItem : public FObject
// Accessors
const char* getClassName() const;
uInt getColumnCount() const;
int getSortColumn() const;
FString getText (int) const;
FWidget::data_ptr getData() const;
uInt getDepth() const;
// Mutator
void setText (int, const FString&);
void setData (FWidget::data_ptr);
// Inquiry
bool isExpand() const;
@ -113,6 +115,8 @@ class FListViewItem : public FObject
bool isExpandable() const;
// Methods
template<typename Compare>
void sort (Compare);
FObjectIterator appendItem (FListViewItem*);
void replaceControlCodes();
int getVisibleLines();
@ -121,6 +125,7 @@ class FListViewItem : public FObject
// Data Members
FStringList column_list;
FWidget::data_ptr data_pointer;
FObjectIterator root;
int visible_lines;
bool expandable;
bool is_expand;
@ -141,6 +146,14 @@ inline const char* FListViewItem::getClassName() const
inline uInt FListViewItem::getColumnCount() const
{ return uInt(column_list.size()); }
//----------------------------------------------------------------------
inline FWidget::data_ptr FListViewItem::getData() const
{ return data_pointer; }
//----------------------------------------------------------------------
inline void FListViewItem::setData (FWidget::data_ptr data)
{ data_pointer = data; }
//----------------------------------------------------------------------
inline bool FListViewItem::isExpand() const
{ return is_expand; }
@ -166,12 +179,9 @@ class FListViewIterator
typedef std::stack<FObjectIterator> FObjectIteratorStack;
// Constructor
FListViewIterator ();
explicit FListViewIterator ();
FListViewIterator (FObjectIterator);
// Destructor
~FListViewIterator();
// Overloaded operators
FListViewIterator& operator ++ (); // prefix
FListViewIterator operator ++ (int); // postfix
@ -246,19 +256,30 @@ class FListView : public FWidget
explicit FListView (FWidget* = 0);
// Destructor
~FListView();
virtual ~FListView();
// Accessors
const char* getClassName() const;
uInt getCount();
fc::text_alignment getColumnAlignment (int) const;
FString getColumnText (int) const;
fc::sorting_type getColumnSortType (int) const;
fc::sorting_order getSortOrder() const;
int getSortColumn() const;
FListViewItem* getCurrentItem();
// Mutators
void setGeometry (int, int, int, int, bool = true);
virtual void setGeometry (int, int, int, int, bool = true);
void setColumnAlignment (int, fc::text_alignment);
void setColumnText (int, const FString&);
void setColumnSortType (int,fc::sorting_type \
= fc::by_name);
void setColumnSort (int, fc::sorting_order \
= fc::ascending);
template<typename Compare>
void setUserAscendingCompare (Compare);
template<typename Compare>
void setUserDescendingCompare (Compare);
bool setTreeView (bool);
bool setTreeView();
bool unsetTreeView();
@ -283,17 +304,18 @@ class FListView : public FWidget
, FObjectIterator );
FObjectIterator beginOfList();
FObjectIterator endOfList();
virtual void sort();
// Event handlers
void onKeyPress (FKeyEvent*);
void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*);
void onMouseMove (FMouseEvent*);
void onMouseDoubleClick (FMouseEvent*);
void onWheel (FWheelEvent*);
void onTimer (FTimerEvent*);
void onFocusIn (FFocusEvent*);
void onFocusOut (FFocusEvent*);
virtual void onKeyPress (FKeyEvent*);
virtual void onMouseDown (FMouseEvent*);
virtual void onMouseUp (FMouseEvent*);
virtual void onMouseMove (FMouseEvent*);
virtual void onMouseDoubleClick (FMouseEvent*);
virtual void onWheel (FWheelEvent*);
virtual void onTimer (FTimerEvent*);
virtual void onFocusIn (FFocusEvent*);
virtual void onFocusOut (FFocusEvent*);
// Data Members
static FObjectIterator null_iter;
@ -301,12 +323,13 @@ class FListView : public FWidget
protected:
// Methods
void adjustViewport();
void adjustSize();
virtual void adjustSize();
private:
// Typedef
struct Header; // forward declaration
typedef std::vector<Header> headerItems;
typedef std::vector<fc::sorting_type> sortTypes;
// Constants
static const int USE_MAX_SIZE = -1;
@ -319,8 +342,10 @@ class FListView : public FWidget
// Methods
void init();
template<typename Compare>
void sort (Compare);
uInt getAlignOffset (fc::text_alignment, uInt, uInt);
void draw();
virtual void draw();
void drawColumnLabels();
void drawList();
void drawListLine (const FListViewItem*, bool, bool);
@ -330,6 +355,7 @@ class FListView : public FWidget
void drawColumnEllipsis ( headerItems::const_iterator&
, const FString& );
void updateDrawing (bool, bool);
int determineLineWidth (FListViewItem* item);
void recalculateHorizontalBar (int);
void recalculateVerticalBar (int);
void wheelUp (int);
@ -383,6 +409,11 @@ class FListView : public FWidget
int xoffset;
int nf_offset;
int max_line_width;
int sort_column;
sortTypes sort_type;
fc::sorting_order sort_order;
bool (*user_defined_ascending) (const FObject*, const FObject*);
bool (*user_defined_descending) (const FObject*, const FObject*);
// Friend class
friend class FListViewItem;
@ -399,16 +430,13 @@ class FListView : public FWidget
struct FListView::Header
{
public:
Header()
explicit Header()
: name()
, width (0)
, fixed_width (false)
, alignment (fc::alignLeft)
{ }
~Header()
{ }
FString name;
int width;
bool fixed_width;
@ -422,13 +450,31 @@ struct FListView::Header
inline const char* FListView::getClassName() const
{ return "FListView"; }
//----------------------------------------------------------------------
inline fc::sorting_order FListView::getSortOrder() const
{ return sort_order; }
//----------------------------------------------------------------------
inline int FListView::getSortColumn() const
{ return sort_column; }
//----------------------------------------------------------------------
inline FListViewItem* FListView::getCurrentItem()
{ return static_cast<FListViewItem*>(*current_iter); }
//----------------------------------------------------------------------
template<typename Compare>
inline void FListView::setUserAscendingCompare (Compare cmp)
{ user_defined_ascending = cmp; }
//----------------------------------------------------------------------
template<typename Compare>
inline void FListView::setUserDescendingCompare (Compare cmp)
{ user_defined_descending = cmp; }
//----------------------------------------------------------------------
inline bool FListView::setTreeView (bool on)
{ return tree_view = ( on ) ? true : false; }
{ return tree_view = on; }
//----------------------------------------------------------------------
inline bool FListView::setTreeView()
@ -444,24 +490,24 @@ inline FObject::FObjectIterator FListView::insert (FListViewItem* item)
//----------------------------------------------------------------------
inline FObject::FObjectIterator
FListView::insert ( const FStringList& cols, data_ptr d )
FListView::insert (const FStringList& cols, data_ptr d)
{ return insert (cols, d, root); }
//----------------------------------------------------------------------
inline FObject::FObjectIterator
FListView::insert ( const FStringList& cols
, FObjectIterator parent_iter )
FListView::insert ( const FStringList& cols
, FObjectIterator parent_iter )
{ return insert (cols, 0, parent_iter); }
//----------------------------------------------------------------------
inline FObject::FObjectIterator
FListView::insert ( const std::vector<long>& cols, data_ptr d )
FListView::insert (const std::vector<long>& cols, data_ptr d)
{ return insert (cols, d, root); }
//----------------------------------------------------------------------
inline FObject::FObjectIterator
FListView::insert ( const std::vector<long>& cols
, FObjectIterator parent_iter )
FListView::insert ( const std::vector<long>& cols
, FObjectIterator parent_iter )
{ return insert (cols, 0, parent_iter); }
//----------------------------------------------------------------------

View File

@ -87,19 +87,19 @@ class FMenu : public FWindow, public FMenuList
// Accessors
virtual const char* getClassName() const;
FString getText() const;
FMenuItem* getItem() const;
FMenuItem* getItem();
// Mutators
bool setEnable(bool);
bool setEnable();
bool unsetEnable();
bool setDisable();
virtual bool setEnable(bool);
virtual bool setEnable();
virtual bool unsetEnable();
virtual bool setDisable();
void setSelected();
void unsetSelected();
bool setMenuWidget (bool);
bool setMenuWidget();
bool unsetMenuWidget();
void setStatusbarMessage (const FString&);
virtual void setStatusbarMessage (const FString&);
void setMenu (FMenu*);
void setText (const FString&);
@ -110,15 +110,15 @@ class FMenu : public FWindow, public FMenuList
bool hasMenu() const;
// Methods
void show();
void hide();
virtual void show();
virtual void hide();
// Event handlers
void onKeyPress (FKeyEvent*);
void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*);
void onMouseMove (FMouseEvent*);
void onAccel (FAccelEvent*);
virtual void onKeyPress (FKeyEvent*);
virtual void onMouseDown (FMouseEvent*);
virtual void onMouseUp (FMouseEvent*);
virtual void onMouseMove (FMouseEvent*);
virtual void onAccel (FAccelEvent*);
// Callback method
void cb_menuitem_toggled (FWidget*, data_ptr);
@ -200,7 +200,7 @@ class FMenu : public FWindow, public FMenuList
void keypressMenuBar (FKeyEvent*);
bool hotkeyMenu (FKeyEvent*);
int getHotkeyPos (wchar_t[], wchar_t[], uInt);
void draw();
virtual void draw();
void drawItems();
void drawSeparator (int);
void drawMenuLine (FMenuItem*, int);
@ -228,7 +228,7 @@ class FMenu : public FWindow, public FMenuList
friend class FRadioMenuItem;
// Data Members
FMenuItem* item;
FMenuItem item;
FWidget* super_menu;
FMenu* opened_sub_menu;
FMenu* shown_sub_menu;
@ -247,35 +247,35 @@ inline const char* FMenu::getClassName() const
//----------------------------------------------------------------------
inline FString FMenu::getText() const
{ return item->getText(); }
{ return item.getText(); }
//----------------------------------------------------------------------
inline FMenuItem* FMenu::getItem() const
{ return item; }
inline FMenuItem* FMenu::getItem()
{ return &item; }
//----------------------------------------------------------------------
inline bool FMenu::setEnable(bool on)
{ return item->setEnable(on); }
{ return item.setEnable(on); }
//----------------------------------------------------------------------
inline bool FMenu::setEnable()
{ return item->setEnable(); }
{ return item.setEnable(); }
//----------------------------------------------------------------------
inline bool FMenu::unsetEnable()
{ return item->unsetEnable(); }
{ return item.unsetEnable(); }
//----------------------------------------------------------------------
inline bool FMenu::setDisable()
{ return item->setDisable(); }
{ return item.setDisable(); }
//----------------------------------------------------------------------
inline void FMenu::setSelected()
{ item->setSelected(); }
{ item.setSelected(); }
//----------------------------------------------------------------------
inline void FMenu::unsetSelected()
{ item->unsetSelected(); }
{ item.unsetSelected(); }
//----------------------------------------------------------------------
inline bool FMenu::setMenuWidget()
@ -287,27 +287,27 @@ inline bool FMenu::unsetMenuWidget()
//----------------------------------------------------------------------
inline void FMenu::setMenu (FMenu* m)
{ item->setMenu(m); }
{ item.setMenu(m); }
//----------------------------------------------------------------------
inline void FMenu::setText (const FString& txt)
{ item->setText(txt); }
{ item.setText(txt); }
//----------------------------------------------------------------------
inline bool FMenu::isEnabled() const
{ return item->isEnabled(); }
{ return item.isEnabled(); }
//----------------------------------------------------------------------
inline bool FMenu::isSelected() const
{ return item->isSelected(); }
{ return item.isSelected(); }
//----------------------------------------------------------------------
inline bool FMenu::hasHotkey() const
{ return item->hasHotkey(); }
{ return item.hasHotkey(); }
//----------------------------------------------------------------------
inline bool FMenu::hasMenu() const
{ return item->hasMenu(); }
{ return item.hasMenu(); }
//----------------------------------------------------------------------
inline FWidget* FMenu::getSuperMenu() const
@ -327,7 +327,7 @@ inline FMenu* FMenu::superMenuAt (const FPoint& p)
//----------------------------------------------------------------------
inline void FMenu::onAccel (FAccelEvent* ev)
{ item->onAccel(ev); }
{ item.onAccel(ev); }
} // namespace finalcut

View File

@ -86,19 +86,19 @@ class FMenuBar : public FWindow, public FMenuList
virtual const char* getClassName() const;
// Methods
void hide();
void resetMenu();
void adjustSize();
void resetMenu();
virtual void hide();
virtual void adjustSize();
// Event handlers
void onKeyPress (FKeyEvent*);
void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*);
void onMouseMove (FMouseEvent*);
void onAccel (FAccelEvent*);
virtual void onKeyPress (FKeyEvent*);
virtual void onMouseDown (FMouseEvent*);
virtual void onMouseUp (FMouseEvent*);
virtual void onMouseMove (FMouseEvent*);
virtual void onAccel (FAccelEvent*);
// Callback methods
void cb_item_deactivated (FWidget*, data_ptr);
void cb_item_deactivated (FWidget*, data_ptr);
private:
// Typedef
@ -115,46 +115,46 @@ class FMenuBar : public FWindow, public FMenuList
FMenuBar (const FMenuBar&);
// Disable assignment operator (=)
FMenuBar& operator = (const FMenuBar&);
FMenuBar& operator = (const FMenuBar&);
// Inquiry
bool isMenu (FMenuItem*) const;
bool isMenu (FMenuItem*) const;
// Methods
void init();
void calculateDimensions();
bool selectNextItem();
bool selectPrevItem();
bool hotkeyMenu (FKeyEvent*&);
int getHotkeyPos (wchar_t[], wchar_t[], uInt);
void draw();
void drawItems();
void drawItem (FMenuItem*, int&);
void setLineAttributes (FMenuItem*);
void drawMenuText (menuText&);
void drawEllipsis (menuText&, int);
void drawLeadingSpace (int&);
void drawTrailingSpace (int&);
void adjustItems();
bool activateMenu (FMenuItem*);
bool clickItem (FMenuItem*);
void unselectMenuItem (FMenuItem*);
void selectMenuItem (FMenuItem*);
void mouseDownOverList (FMouseEvent*);
void mouseUpOverList (FMouseEvent*);
void mouseMoveOverList (FMouseEvent*);
void passEventToMenu (FMouseEvent*&);
void leaveMenuBar();
void init();
void calculateDimensions();
bool selectNextItem();
bool selectPrevItem();
bool hotkeyMenu (FKeyEvent*&);
int getHotkeyPos (wchar_t[], wchar_t[], uInt);
virtual void draw();
void drawItems();
void drawItem (FMenuItem*, int&);
void setLineAttributes (FMenuItem*);
void drawMenuText (menuText&);
void drawEllipsis (menuText&, int);
void drawLeadingSpace (int&);
void drawTrailingSpace (int&);
void adjustItems();
bool activateMenu (FMenuItem*);
bool clickItem (FMenuItem*);
void unselectMenuItem (FMenuItem*);
void selectMenuItem (FMenuItem*);
void mouseDownOverList (FMouseEvent*);
void mouseUpOverList (FMouseEvent*);
void mouseMoveOverList (FMouseEvent*);
void passEventToMenu (FMouseEvent*&);
void leaveMenuBar();
// Friend classes
friend class FMenu;
friend class FMenuItem;
// Data Members
bool mouse_down;
bool drop_down;
bool focus_changed;
int screenWidth;
bool mouse_down;
bool drop_down;
bool focus_changed;
int screenWidth;
};
#pragma pack(pop)

View File

@ -90,74 +90,74 @@ class FMenuItem : public FWidget
virtual ~FMenuItem();
// Accessors
const char* getClassName() const;
int getHotkey() const;
FMenu* getMenu() const;
uInt getTextLength() const;
FString getText() const;
const char* getClassName() const;
int getHotkey() const;
FMenu* getMenu() const;
uInt getTextLength() const;
FString getText() const;
// Mutators
bool setEnable (bool);
bool setFocus (bool);
bool setFocus();
bool unsetFocus();
void setSelected();
void unsetSelected();
void setSeparator();
void unsetSeparator();
void setChecked();
void unsetChecked();
void setMenu (FMenu*);
void setText (const FString&);
virtual bool setEnable (bool);
virtual bool setFocus (bool);
virtual bool setFocus();
virtual bool unsetFocus();
void setSelected();
void unsetSelected();
void setSeparator();
void unsetSeparator();
void setChecked();
void unsetChecked();
void setMenu (FMenu*);
void setText (const FString&);
// Inquiries
bool isSelected() const;
bool isSeparator() const;
bool isChecked() const;
bool hasHotkey() const;
bool hasMenu() const;
bool isSelected() const;
bool isSeparator() const;
bool isChecked() const;
bool hasHotkey() const;
bool hasMenu() const;
// Methods
void addAccelerator (int, FWidget*);
void delAccelerator (FWidget*);
void openMenu();
virtual void addAccelerator (int, FWidget*);
virtual void delAccelerator (FWidget*);
void openMenu();
// Event handlers
void onKeyPress (FKeyEvent*);
void onMouseDoubleClick (FMouseEvent*);
void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*);
void onMouseMove (FMouseEvent*);
void onAccel (FAccelEvent*);
void onFocusIn (FFocusEvent*);
void onFocusOut (FFocusEvent*);
virtual void onKeyPress (FKeyEvent*);
virtual void onMouseDoubleClick (FMouseEvent*);
virtual void onMouseDown (FMouseEvent*);
virtual void onMouseUp (FMouseEvent*);
virtual void onMouseMove (FMouseEvent*);
virtual void onAccel (FAccelEvent*);
virtual void onFocusIn (FFocusEvent*);
virtual void onFocusOut (FFocusEvent*);
protected:
// Accessor
FWidget* getSuperMenu() const;
FWidget* getSuperMenu() const;
// Mutator
void setSuperMenu (FWidget*);
void setSuperMenu (FWidget*);
// Inquiries
bool isWindowsMenu (FWidget*) const;
bool isMenuBar (FWidget*) const;
bool isMenu (FWidget*) const;
bool isWindowsMenu (FWidget*) const;
bool isMenuBar (FWidget*) const;
bool isMenu (FWidget*) const;
// Data Members
FString text;
bool selected;
bool separator;
bool checkable;
bool checked;
bool radio_button;
bool dialog_index;
uInt text_length;
int hotkey;
int accel_key;
FMenu* menu;
FWidget* super_menu;
FDialog* associated_window;
FString text;
bool selected;
bool separator;
bool checkable;
bool checked;
bool radio_button;
bool dialog_index;
uInt text_length;
int hotkey;
int accel_key;
FMenu* menu;
FWidget* super_menu;
FDialog* associated_window;
private:
// Disable copy constructor
@ -167,17 +167,17 @@ class FMenuItem : public FWidget
FMenuItem& operator = (const FMenuItem&);
// Methods
void init (FWidget*);
uChar hotKey();
void processActivate();
void processDeactivate();
void createDialogList (FMenu*);
void init (FWidget*);
uChar hotKey();
void processActivate();
void processDeactivate();
void createDialogList (FMenu*);
template<class T>
void passMouseEvent (T, FMouseEvent*, fc::events);
void passMouseEvent (T, FMouseEvent*, fc::events);
// Callback methods
void cb_switchToDialog (FWidget*, data_ptr);
void cb_destroyDialog (FWidget*, data_ptr);
void cb_switchToDialog (FWidget*, data_ptr);
void cb_destroyDialog (FWidget*, data_ptr);
virtual void processClicked();

View File

@ -101,7 +101,7 @@ class FMessageBox : public FDialog
, int, int, int
, FWidget* = 0 );
// Destructor
~FMessageBox();
virtual ~FMessageBox();
// Assignment operator (=)
FMessageBox& operator = (const FMessageBox&);
@ -142,7 +142,7 @@ class FMessageBox : public FDialog
, int = 0 );
protected:
// Method
void adjustSize();
virtual void adjustSize();
// Callback method
void cb_processClick (FWidget*, data_ptr);

View File

@ -71,37 +71,38 @@ class FObject
virtual ~FObject();
// Accessors
virtual const char* getClassName() const;
FObject* getParent() const;
FObject* getChild (int) const;
const FObjectList& getChildren() const;
int numOfChildren() const;
FObjectIterator begin();
FObjectIterator end();
constFObjectIterator begin() const;
constFObjectIterator end() const;
virtual const char* getClassName() const;
FObject* getParent() const;
FObject* getChild (int) const;
FObjectList& getChildren();
const FObjectList& getChildren() const;
int numOfChildren() const;
FObjectIterator begin();
FObjectIterator end();
constFObjectIterator begin() const;
constFObjectIterator end() const;
// Inquiries
bool hasParent() const;
bool hasChildren() const;
bool isChild (FObject*) const;
bool isDirectChild (FObject*) const;
bool isWidget() const;
bool isInstanceOf (const char[]) const;
bool isTimerInUpdating() const;
bool hasParent() const;
bool hasChildren() const;
bool isChild (FObject*) const;
bool isDirectChild (FObject*) const;
bool isWidget() const;
bool isInstanceOf (const char[]) const;
bool isTimerInUpdating() const;
// Methods
void removeParent();
void addChild (FObject*);
void delChild (FObject*);
void removeParent();
void addChild (FObject*);
void delChild (FObject*);
// Timer methods
static void getCurrentTime (timeval*);
static bool isTimeout (timeval*, long);
int addTimer (int);
bool delTimer (int);
bool delOwnTimer();
bool delAllTimer();
static void getCurrentTime (timeval*);
static bool isTimeout (timeval*, long);
int addTimer (int);
bool delTimer (int);
bool delOwnTimer();
bool delAllTimer();
protected:
struct timer_data
@ -115,13 +116,18 @@ class FObject
// Typedef
typedef std::vector<timer_data> TimerList;
// Event handler
virtual bool event (FEvent*);
virtual void onTimer (FTimerEvent*);
// Accessor
TimerList* getTimerList() const;
// Data Members
static TimerList* timer_list;
bool widget_object;
// Method
uInt processTimerEvent();
// Event handler
virtual bool event (FEvent*);
virtual void onTimer (FTimerEvent*);
// Data Member
bool widget_object;
private:
// Disable copy constructor
@ -130,11 +136,15 @@ class FObject
// Disable assignment operator (=)
FObject& operator = (const FObject&);
// Method
virtual void performTimerAction (const FObject*, const FEvent*);
// Data Members
FObject* parent_obj;
FObjectList children_list;
bool has_parent;
static bool timer_modify_lock;
FObject* parent_obj;
FObjectList children_list;
bool has_parent;
static bool timer_modify_lock;
static TimerList* timer_list;
};
#pragma pack(pop)
@ -147,6 +157,10 @@ inline const char* FObject::getClassName() const
inline FObject* FObject::getParent() const
{ return parent_obj; }
//----------------------------------------------------------------------
inline FObject::FObjectList& FObject::getChildren()
{ return children_list; }
//----------------------------------------------------------------------
inline const FObject::FObjectList& FObject::getChildren() const
{ return children_list; }
@ -195,7 +209,9 @@ inline bool FObject::isInstanceOf (const char classname[]) const
inline bool FObject::isTimerInUpdating() const
{ return timer_modify_lock; }
} // namespace finalcut
//----------------------------------------------------------------------
inline FObject::TimerList* FObject::getTimerList() const
{ return timer_list; }
//----------------------------------------------------------------------
@ -252,4 +268,6 @@ static inline bool operator < (const timeval& t1, const timeval& t2)
|| (t1.tv_sec == t2.tv_sec && t1.tv_usec < t2.tv_usec);
}
} // namespace finalcut
#endif // FOBJECT_H

View File

@ -159,7 +159,7 @@ class FOptiAttr
explicit FOptiAttr();
// Destructor
~FOptiAttr();
virtual ~FOptiAttr();
// Friend operator functions
friend bool operator == (const charData&, const charData&);

View File

@ -110,7 +110,7 @@ class FOptiMove
explicit FOptiMove (int = 0);
// Destructor
~FOptiMove();
virtual ~FOptiMove();
// Accessors
const char* getClassName() const;

View File

@ -82,7 +82,7 @@ class FProgressbar : public FWidget
// Mutators
void setPercentage (int);
void setGeometry (int, int, int, int, bool = true);
virtual void setGeometry (int, int, int, int, bool = true);
bool setShadow (bool);
bool setShadow();
bool unsetShadow();
@ -91,7 +91,7 @@ class FProgressbar : public FWidget
bool hasShadow();
// Methods
void hide();
virtual void hide();
void reset();
private:

View File

@ -90,9 +90,9 @@ class FRadioButton : public FToggleButton
FRadioButton& operator = (const FRadioButton&);
// Methods
void init();
void draw();
void drawRadioButton();
void init();
virtual void draw();
void drawRadioButton();
};
#pragma pack(pop)

View File

@ -91,34 +91,34 @@ class FScrollbar : public FWidget
virtual ~FScrollbar();
// Accessors
const char* getClassName() const;
int getValue() const;
sType getScrollType() const;
const char* getClassName() const;
int getValue() const;
sType getScrollType() const;
// Mutators
void setMinimum (int);
void setMaximum (int);
void setRange (int, int);
void setValue (int);
void setSteps (double);
void setPageSize (int, int);
void setOrientation (int);
void setGeometry (int, int, int, int, bool = true);
void setMinimum (int);
void setMaximum (int);
void setRange (int, int);
void setValue (int);
void setSteps (double);
void setPageSize (int, int);
void setOrientation (int);
virtual void setGeometry (int, int, int, int, bool = true);
// Methods
void resize();
void redraw();
void calculateSliderValues();
void drawVerticalBar();
void drawHorizontalBar();
void drawBar();
virtual void resize();
virtual void redraw();
void calculateSliderValues();
void drawVerticalBar();
void drawHorizontalBar();
void drawBar();
// Event handlers
void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*);
void onMouseMove (FMouseEvent*);
void onWheel (FWheelEvent*);
void onTimer (FTimerEvent*);
virtual void onMouseDown (FMouseEvent*);
virtual void onMouseUp (FMouseEvent*);
virtual void onMouseMove (FMouseEvent*);
virtual void onWheel (FWheelEvent*);
virtual void onTimer (FTimerEvent*);
private:
// Disable copy constructor
@ -128,37 +128,37 @@ class FScrollbar : public FWidget
FScrollbar& operator = (const FScrollbar&);
// Methods
void init();
void draw();
void drawButtons();
sType getClickedScrollType (int, int);
sType getVerticalClickedScrollType (int);
sType getHorizontalClickedScrollType (int);
int getSliderClickPos (int, int);
void jumpToClickPos (int, int);
void jumpToClickPos (int);
void avoidScrollOvershoot();
void processScroll();
void init();
virtual void draw();
void drawButtons();
sType getClickedScrollType (int, int);
sType getVerticalClickedScrollType (int);
sType getHorizontalClickedScrollType (int);
int getSliderClickPos (int, int);
void jumpToClickPos (int, int);
void jumpToClickPos (int);
void avoidScrollOvershoot();
void processScroll();
// Data Members
sType scroll_type;
bool threshold_reached;
int threshold_time;
int repeat_time;
int slider_click_pos;
int slider_click_stop_pos;
int current_slider_pos;
int slider_pos;
int slider_length;
int bar_length;
int val;
int min;
int max;
double steps;
int pagesize;
int length;
int bar_orientation;
int max_color;
sType scroll_type;
bool threshold_reached;
int threshold_time;
int repeat_time;
int slider_click_pos;
int slider_click_stop_pos;
int current_slider_pos;
int slider_pos;
int slider_length;
int bar_length;
int val;
int min;
int max;
double steps;
int pagesize;
int length;
int bar_orientation;
int max_color;
};
#pragma pack(pop)

View File

@ -100,7 +100,7 @@ class FScrollView : public FWidget
virtual void setWidth (int, bool = true);
virtual void setHeight (int, bool = true);
virtual void setSize (int, int, bool = true);
void setGeometry (int, int, int, int, bool = true);
virtual void setGeometry (int, int, int, int, bool = true);
void setCursorPos (int, int);
void setPrintPos (int, int);
bool setViewportPrint (bool);
@ -126,11 +126,11 @@ class FScrollView : public FWidget
virtual void draw();
// Event handlers
void onKeyPress (FKeyEvent*);
void onWheel (FWheelEvent*);
void onFocusIn (FFocusEvent*);
void onChildFocusIn (FFocusEvent*);
void onChildFocusOut (FFocusEvent*);
virtual void onKeyPress (FKeyEvent*);
virtual void onWheel (FWheelEvent*);
virtual void onFocusIn (FFocusEvent*);
virtual void onChildFocusIn (FFocusEvent*);
virtual void onChildFocusOut (FFocusEvent*);
protected:
// Using-declaration
@ -140,7 +140,7 @@ class FScrollView : public FWidget
term_area* getPrintArea();
// Method
void adjustSize();
virtual void adjustSize();
void copy2area();
private:

View File

@ -92,6 +92,8 @@ class FStatusKey : public FWidget
virtual FString getText() const;
// Mutators
void setKey (int);
void setText (const FString&);
void setActive();
void unsetActive();
bool setMouseFocus(bool);
@ -103,12 +105,7 @@ class FStatusKey : public FWidget
bool hasMouseFocus() const;
// Event handler
void onAccel (FAccelEvent*);
protected:
// Mutators
void setKey (int);
void setText (const FString&);
virtual void onAccel (FAccelEvent*);
private:
// Disable copy constructor
@ -149,6 +146,14 @@ inline int FStatusKey::getKey() const
inline FString FStatusKey::getText() const
{ return text; }
//----------------------------------------------------------------------
inline void FStatusKey::setKey (int k)
{ key = k; }
//----------------------------------------------------------------------
inline void FStatusKey::setText (const FString& txt)
{ text = txt; }
//----------------------------------------------------------------------
inline void FStatusKey::unsetActive()
{ active = false; }
@ -169,14 +174,6 @@ inline bool FStatusKey::isActivated() const
inline bool FStatusKey::hasMouseFocus() const
{ return mouse_focus; }
//----------------------------------------------------------------------
inline void FStatusKey::setKey (int k)
{ key = k; }
//----------------------------------------------------------------------
inline void FStatusKey::setText (const FString& txt)
{ text = txt; }
//----------------------------------------------------------------------
inline FStatusBar* FStatusKey::getConnectedStatusbar() const
{ return bar; }
@ -218,19 +215,19 @@ class FStatusBar : public FWindow
bool hasActivatedKey();
// Methods
void hide();
virtual void hide();
void drawMessage();
void clearMessage();
void insert (FStatusKey*);
void remove (FStatusKey*);
void remove (int);
void clear();
void adjustSize();
virtual void adjustSize();
// Event handlers
void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*);
void onMouseMove (FMouseEvent*);
virtual void onMouseDown (FMouseEvent*);
virtual void onMouseUp (FMouseEvent*);
virtual void onMouseMove (FMouseEvent*);
// Callback method
void cb_statuskey_activated (FWidget*, data_ptr);
@ -247,7 +244,7 @@ class FStatusBar : public FWindow
// Methods
void init();
void draw();
virtual void draw();
void drawKeys();
void drawKey (keyList::const_iterator);
void drawActiveKey (keyList::const_iterator);

View File

@ -382,6 +382,7 @@ class FString
// Methods
void initLength (uInt);
void _assign (const wchar_t[]);
void _insert (uInt, const wchar_t[]);
void _insert (uInt, uInt, const wchar_t[]);
void _remove (uInt, uInt);
char* wc_to_c_str (const wchar_t[]) const;

View File

@ -80,15 +80,15 @@ class FSwitch : public FToggleButton
virtual ~FSwitch();
// Accessor
const char* getClassName() const;
const char* getClassName() const;
// Mutator
void setText (const FString&);
virtual void setText (const FString&);
// Event handlers
void onKeyPress (FKeyEvent*);
void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*);
virtual void onKeyPress (FKeyEvent*);
virtual void onMouseDown (FMouseEvent*);
virtual void onMouseUp (FMouseEvent*);
private:
// Disable copy constructor
@ -98,14 +98,14 @@ class FSwitch : public FToggleButton
FSwitch& operator = (const FSwitch&);
// Methods
void draw();
void drawCheckButton();
void drawChecked();
void drawUnchecked();
virtual void draw();
void drawCheckButton();
void drawChecked();
void drawUnchecked();
// Data Members
int switch_offset_pos;
bool button_pressed;
int switch_offset_pos;
bool button_pressed;
};
#pragma pack(pop)

View File

@ -139,7 +139,6 @@
#include "final/fkey_map.h"
#include "final/fkeyboard.h"
#include "final/fmouse.h"
#include "final/fobject.h"
#include "final/foptiattr.h"
#include "final/foptimove.h"
#include "final/fpoint.h"
@ -147,6 +146,7 @@
#include "final/fstring.h"
#include "final/ftermcap.h"
#include "final/ftermcapquirks.h"
#include "final/ftermdata.h"
#include "final/ftermdetection.h"
#if defined(__linux__)
@ -187,147 +187,138 @@ class FTerm
virtual ~FTerm();
// Accessors
virtual const char* getClassName() const;
static FKeyboard* getKeyboard();
static FMouseControl* getMouseControl();
static int getLineNumber();
static int getColumnNumber();
static const FString getKeyName (int);
virtual const char* getClassName() const;
static FKeyboard* getKeyboard();
static FMouseControl* getMouseControl();
static int getLineNumber();
static int getColumnNumber();
static const FString getKeyName (int);
static int getTTYFileDescriptor();
static char* getTermType();
static char* getTermFileName();
static int getTabstop();
static int getMaxColor();
static int getTTYFileDescriptor();
static char* getTermType();
static char* getTermFileName();
static int getTabstop();
static int getMaxColor();
#if DEBUG
static const FString& getAnswerbackString();
static const FString& getSecDAString();
static const char* getTermType_256color();
static const char* getTermType_Answerback();
static const char* getTermType_SecDA();
static int getFramebufferBpp();
static const FString& getAnswerbackString();
static const FString& getSecDAString();
static const char* getTermType_256color();
static const char* getTermType_Answerback();
static const char* getTermType_SecDA();
static int getFramebufferBpp();
#endif // DEBUG
// Inquiries
static bool isCursorHidden();
static bool isNormal (charData*&);
static bool isRaw();
static bool hasPCcharset();
static bool hasUTF8();
static bool hasVT100();
static bool hasASCII();
static bool isMonochron();
static bool isXTerminal();
static bool isAnsiTerminal();
static bool isRxvtTerminal();
static bool isUrxvtTerminal();
static bool isMltermTerminal();
static bool isPuttyTerminal();
static bool isKdeTerminal();
static bool isGnomeTerminal();
static bool isKtermTerminal();
static bool isTeraTerm();
static bool isSunTerminal();
static bool isCygwinTerminal();
static bool isMinttyTerm();
static bool isLinuxTerm();
static bool isFreeBSDTerm();
static bool isNetBSDTerm();
static bool isOpenBSDTerm();
static bool isScreenTerm();
static bool isTmuxTerm();
static bool isNewFont();
static bool isUTF8();
static bool isNormal (charData*&);
static bool isRaw();
static bool hasUTF8();
static bool hasVT100();
static bool hasASCII();
static bool isMonochron();
static bool isXTerminal();
static bool isAnsiTerminal();
static bool isRxvtTerminal();
static bool isUrxvtTerminal();
static bool isMltermTerminal();
static bool isPuttyTerminal();
static bool isKdeTerminal();
static bool isGnomeTerminal();
static bool isKtermTerminal();
static bool isTeraTerm();
static bool isSunTerminal();
static bool isCygwinTerminal();
static bool isMinttyTerm();
static bool isLinuxTerm();
static bool isFreeBSDTerm();
static bool isNetBSDTerm();
static bool isOpenBSDTerm();
static bool isScreenTerm();
static bool isTmuxTerm();
static bool isNewFont();
// Mutators
static void setTermType (const char[]);
static void setInsertCursor (bool on);
static void setInsertCursor();
static void unsetInsertCursor();
static bool setCursorOptimisation (bool);
static void redefineDefaultColors (bool);
static void setDblclickInterval (const long);
static void disableAltScreen();
static bool setUTF8 (bool);
static bool setUTF8();
static bool unsetUTF8();
static void setTermType (const char[]);
static void setInsertCursor (bool on);
static void setInsertCursor();
static void unsetInsertCursor();
static void redefineDefaultColors (bool);
static void setDblclickInterval (const long);
static bool setUTF8 (bool);
static bool setUTF8();
static bool unsetUTF8();
// Methods
static bool setVGAFont();
static bool setNewFont();
static bool setOldFont();
static int openConsole();
static int closeConsole();
static char* moveCursor (int, int, int, int);
static char* cursorsVisibility (bool);
static void printMoveDurations();
static char* enableCursor();
static char* disableCursor();
static void detectTermSize();
static void setTermSize (int, int);
static void setTermTitle(const FString&);
static void setKDECursor (fc::kdeKonsoleCursorShape);
static void saveColorMap();
static void resetColorMap();
static void setPalette (short, int, int, int);
static void setBeep (int, int);
static void resetBeep();
static void beep();
static bool setVGAFont();
static bool setNewFont();
static bool setOldFont();
static int openConsole();
static int closeConsole();
static char* moveCursor (int, int, int, int);
static char* cursorsVisibility (bool);
static void printMoveDurations();
static char* enableCursor();
static char* disableCursor();
static void detectTermSize();
static void setTermSize (int, int);
static void setTermTitle(const FString&);
static void setKDECursor (fc::kdeKonsoleCursorShape);
static void saveColorMap();
static void resetColorMap();
static void setPalette (short, int, int, int);
static void setBeep (int, int);
static void resetBeep();
static void beep();
static void setEncoding (fc::encoding);
static fc::encoding getEncoding();
static std::string getEncodingString();
static bool charEncodable (uInt);
static uInt charEncode (uInt);
static uInt charEncode (uInt, fc::encoding);
static void setEncoding (fc::encoding);
static fc::encoding getEncoding();
static std::string getEncodingString();
static bool charEncodable (uInt);
static uInt charEncode (uInt);
static uInt charEncode (uInt, fc::encoding);
static bool scrollTermForward();
static bool scrollTermReverse();
static bool scrollTermForward();
static bool scrollTermReverse();
// function pointer -> static function
static int (*Fputchar)(int);
static int (*Fputchar)(int);
static void putstringf (const char[], ...)
static void putstringf (const char[], ...)
#if defined(__clang__)
__attribute__((__format__ (__printf__, 1, 2)))
#elif defined(__GNUC__)
__attribute__ ((format (printf, 1, 2)))
#endif
;
static void putstring (const char[], int = 1);
;
static void putstring (const char[], int = 1);
#if defined(__sun) && defined(__SVR4)
static int putchar_ASCII (char);
static int putchar_ASCII (char);
#endif
static int putchar_ASCII (int);
static int putchar_UTF8 (int);
#if DEBUG
static int framebuffer_bpp;
#endif
static int putchar_ASCII (int);
static int putchar_UTF8 (int);
protected:
// Inquiries
static bool hasChangedTermSize();
static bool hasShadowCharacter();
static bool hasHalfBlockCharacter();
static bool hasAlternateScreen();
static bool hasChangedTermSize();
static bool hasShadowCharacter();
static bool hasHalfBlockCharacter();
static bool hasAlternateScreen();
// Accessors
FOptiMove* getFOptiMove();
FOptiMove* getFOptiMove();
// Methods
static void initScreenSettings();
static char* changeAttribute ( charData*&
, charData*& );
static void changeTermSizeFinished();
static void exitWithMessage (std::string)
static void initScreenSettings();
static char* changeAttribute ( charData*&
, charData*& );
static void changeTermSizeFinished();
static void exitWithMessage (const FString&)
#if defined(__clang__) || defined(__GNUC__)
__attribute__((noreturn))
#endif
;
;
// Data Members
static struct initializationValues
{
@ -374,107 +365,72 @@ class FTerm
} init_values;
private:
// Typedefs
typedef FTermcap::tcap_map termcap_map;
// Disable copy constructor
FTerm (const FTerm&);
// Disable assignment operator (=)
FTerm& operator = (const FTerm&);
// Methods
static void init_global_values();
static void oscPrefix();
static void oscPostfix();
static void init_alt_charset();
static void init_pc_charset();
static void init_cygwin_charmap();
static void init_teraterm_charmap();
static void init_fixed_max_color();
static void init_keyboard();
static void init_termcap();
static void init_termcap_error (int);
static void init_termcap_variables(char*&);
static void init_termcap_booleans();
static void init_termcap_numerics();
static void init_termcap_strings (char*&);
static void init_termcap_keys (char*&);
static void init_OptiMove();
static void init_OptiAttr();
static void init_font();
static void init_locale();
static void init_encoding();
static void init_encoding_set();
static void init_term_encoding();
static void init_individual_term_encoding();
static bool init_force_vt100_encoding();
static void init_utf8_without_alt_charset();
static void init_tab_quirks();
static void init_captureFontAndTitle();
static void redefineColorPalette();
static void restoreColorPalette();
static void setInsertCursorStyle();
static void setOverwriteCursorStyle();
static void enableMouse();
static void disableMouse();
static void useAlternateScreenBuffer();
static void useNormalScreenBuffer();
void allocationValues();
void deallocationValues();
void init();
void initOSspecifics();
void finish();
void finishOSspecifics1();
void finish_encoding();
static uInt cp437_to_unicode (uChar);
static void setSignalHandler();
static void resetSignalHandler();
static void signal_handler (int);
static void init_global_values (bool);
static void init_terminal_device_path();
static void oscPrefix();
static void oscPostfix();
static void init_alt_charset();
static void init_pc_charset();
static void init_cygwin_charmap();
static void init_teraterm_charmap();
static void init_fixed_max_color();
static void init_keyboard();
static void init_termcap();
static void init_termcap_error (int);
static void init_termcap_variables(char*&);
static void init_termcap_booleans();
static void init_termcap_numerics();
static void init_termcap_strings (char*&);
static void init_termcap_keys_vt100 (char*&);
static void init_termcap_keys (char*&);
static void init_OptiMove();
static void init_OptiAttr();
static void init_font();
static void init_locale();
static void init_encoding();
static void init_encoding_set();
static void init_term_encoding();
static void init_individual_term_encoding();
static void init_force_vt100_encoding();
static void init_utf8_without_alt_charset();
static void init_tab_quirks();
static void init_captureFontAndTitle();
static void redefineColorPalette();
static void restoreColorPalette();
static void setInsertCursorStyle();
static void setOverwriteCursorStyle();
static void enableMouse();
static void disableMouse();
static void useAlternateScreenBuffer();
static void useNormalScreenBuffer();
void allocationValues();
void deallocationValues();
void init (bool);
void initOSspecifics();
void initTermspecifics();
void finish();
void finishOSspecifics1();
void finish_encoding();
static uInt cp437_to_unicode (uChar);
static void setSignalHandler();
static void resetSignalHandler();
static void signal_handler (int);
// Data Members
static std::map <uChar,uChar>* vt100_alt_char;
static std::map <std::string,fc::encoding>* encoding_set;
static FTermData* data;
static FTermcap::tcap_map* tcap;
static fc::encoding term_encoding;
static bool shadow_character;
static bool half_block_character;
static bool cursor_optimisation;
static bool hidden_cursor;
static bool use_alternate_screen;
static bool pc_charset_console;
static bool utf8_state;
static bool utf8_console;
static bool utf8_linux_terminal;
static bool force_vt100;
static bool vt100_console;
static bool ascii_console;
static bool NewFont;
static bool VGAFont;
static bool monochron;
static char termtype[256];
static char termfilename[256];
static char exit_message[8192];
static char* locale_name;
static char* locale_xterm;
static FRect* term; // current terminal geometry
static int fd_tty;
static uInt baudrate;
static bool resize_term;
static fc::linuxConsoleCursorStyle \
linux_console_cursor_style;
static struct console_font_op \
screen_font;
static struct unimapdesc \
screen_unicode_map;
static FOptiMove* opti_move;
static FOptiAttr* opti_attr;
static FTermDetection* term_detection;
static FTermXTerminal* xterm;
static FKeyboard* keyboard;
static FMouseControl* mouse;
#if defined(__linux__)
#undef linux
@ -488,10 +444,6 @@ class FTerm
#if defined(__NetBSD__) || defined(__OpenBSD__)
static FTermOpenBSD* openbsd;
#endif
static FMouseControl* mouse;
static const FString* save_xterm_font;
static const FString* save_xterm_title;
};
#pragma pack(pop)
@ -511,15 +463,15 @@ inline FMouseControl* FTerm::getMouseControl()
//----------------------------------------------------------------------
inline int FTerm::getTTYFileDescriptor()
{ return fd_tty; }
{ return data->getTTYFileDescriptor(); }
//----------------------------------------------------------------------
inline char* FTerm::getTermType()
{ return termtype; }
{ return data->getTermType(); }
//----------------------------------------------------------------------
inline char* FTerm::getTermFileName()
{ return termfilename; }
{ return data->getTermFileName(); }
//----------------------------------------------------------------------
inline int FTerm::getTabstop()
@ -552,32 +504,16 @@ inline const char* FTerm::getTermType_SecDA()
//----------------------------------------------------------------------
inline int FTerm::getFramebufferBpp()
{ return framebuffer_bpp; }
{ return data->getFramebufferBpp(); }
#endif // DEBUG
//----------------------------------------------------------------------
inline bool FTerm::isCursorHidden()
{ return hidden_cursor; }
//----------------------------------------------------------------------
inline bool FTerm::hasPCcharset()
{ return pc_charset_console; }
//----------------------------------------------------------------------
inline bool FTerm::hasUTF8()
{ return utf8_console; }
//----------------------------------------------------------------------
inline bool FTerm::hasVT100()
{ return vt100_console; }
//----------------------------------------------------------------------
inline bool FTerm::hasASCII()
{ return ascii_console; }
{ return data->hasUTF8Console(); }
//----------------------------------------------------------------------
inline bool FTerm::isMonochron()
{ return monochron; }
{ return data->isMonochron(); }
//----------------------------------------------------------------------
inline bool FTerm::isXTerminal()
@ -657,11 +593,7 @@ inline bool FTerm::isTmuxTerm()
//----------------------------------------------------------------------
inline bool FTerm::isNewFont()
{ return NewFont; }
//----------------------------------------------------------------------
inline bool FTerm::isUTF8()
{ return utf8_state; }
{ return data->isNewFont(); }
//----------------------------------------------------------------------
inline void FTerm::setInsertCursor()
@ -671,14 +603,6 @@ inline void FTerm::setInsertCursor()
inline void FTerm::unsetInsertCursor()
{ setInsertCursor(false); }
//----------------------------------------------------------------------
inline bool FTerm::setCursorOptimisation (bool on)
{ return cursor_optimisation = ( on ) ? true : false; }
//----------------------------------------------------------------------
inline void FTerm::disableAltScreen()
{ use_alternate_screen = false; }
//----------------------------------------------------------------------
inline bool FTerm::setUTF8()
{ return setUTF8(true); }
@ -689,19 +613,19 @@ inline bool FTerm::unsetUTF8()
//----------------------------------------------------------------------
inline bool FTerm::hasChangedTermSize()
{ return resize_term; }
{ return data->hasTermResized(); }
//----------------------------------------------------------------------
inline bool FTerm::hasShadowCharacter()
{ return shadow_character; }
{ return data->hasShadowCharacter(); }
//----------------------------------------------------------------------
inline bool FTerm::hasHalfBlockCharacter()
{ return half_block_character; }
{ return data->hasHalfBlockCharacter(); }
//----------------------------------------------------------------------
inline bool FTerm::hasAlternateScreen()
{ return use_alternate_screen; }
{ return data->hasAlternateScreen(); }
//----------------------------------------------------------------------
inline FOptiMove* FTerm::getFOptiMove()
@ -709,7 +633,7 @@ inline FOptiMove* FTerm::getFOptiMove()
//----------------------------------------------------------------------
inline void FTerm::changeTermSizeFinished()
{ resize_term = false; }
{ data->setTermResized(false); }
} // namespace finalcut

View File

@ -3,7 +3,7 @@
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2016-2017 Markus Gans *
* Copyright 2016-2018 Markus Gans *
* *
* The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
@ -61,12 +61,10 @@ class FTermcap
tcap_map;
// Constructors
FTermcap()
{ }
FTermcap();
// Destructor
~FTermcap()
{ }
~FTermcap();
// Accessors
const char* getClassName() const;
@ -76,12 +74,6 @@ class FTermcap
return tcap;
}
// Mutator
static void setTermcapMap (tcap_map* t)
{
tcap = t;
}
// Data Members
static bool background_color_erase;
static bool automatic_left_margin;
@ -95,16 +87,17 @@ class FTermcap
static int attr_without_color;
private:
// Data Members
static tcap_map* tcap;
// Data Member
static tcap_map tcap[];
};
#pragma pack(pop)
// FOptiMove inline functions
// FTermcap inline functions
//----------------------------------------------------------------------
inline const char* FTermcap::getClassName() const
{ return "FTermcap"; }
} // namespace finalcut
#endif // FTERMCAP_H

View File

@ -38,6 +38,7 @@
#include "final/fc.h"
#include "final/fterm.h"
#include "final/ftermcap.h"
#include "final/ftermdata.h"
#include "final/ftermdetection.h"
namespace finalcut
@ -57,14 +58,13 @@ class FTermcapQuirks
FTermcapQuirks();
// Destructor
~FTermcapQuirks();
virtual ~FTermcapQuirks();
// Accessor
const char* getClassName() const;
// Mutator
static void setTerminalType (const char[]);
static void setTermcapMap (FTermcap::tcap_map*);
static void setTermData (FTermData*);
static void setFTermDetection (FTermDetection*);
// Methods
@ -87,8 +87,8 @@ class FTermcapQuirks
static void init_termcap_general_quirks();
// Data Members
static char termtype[256];
static FTermcap::tcap_map* tcap;
static FTermData* fterm_data;
static FTermDetection* term_detection;
};
#pragma pack(pop)

View File

@ -0,0 +1,397 @@
/***********************************************************************
* ftermdata.h - Data class for FTerm *
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2018 Markus Gans *
* *
* 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/>. *
***********************************************************************/
/* Standalone class
*
*
*
* FTermData
*
*/
#ifndef FTERMDATA_H
#define FTERMDATA_H
#if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
#error "Only <final/final.h> can be included directly."
#endif
#include <map>
#include "final/fc.h"
#include "final/frect.h"
#include "final/fstring.h"
#include "final/ftypes.h"
namespace finalcut
{
//----------------------------------------------------------------------
// class FTermData
//----------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
class FTermData
{
public:
// Typedefs
typedef std::map<std::string,fc::encoding> encodingMap;
// Constructors
FTermData();
// Destructor
~FTermData();
// Accessors
const char* getClassName() const;
encodingMap& getEncodingList();
fc::encoding getTermEncoding() const;
FRect& getTermGeometry();
int getTTYFileDescriptor() const;
uInt getBaudrate() const;
char* getTermType();
char* getTermFileName();
const FString& getXtermFont() const;
const FString& getXtermTitle() const;
#if DEBUG
int getFramebufferBpp() const;
#endif
// Inquiries
bool hasShadowCharacter() const;
bool hasHalfBlockCharacter() const;
bool hasCursorOptimisation() const;
bool isCursorHidden() const;
bool hasAlternateScreen() const;
bool hasASCIIConsole() const;
bool hasVT100Console() const;
bool hasUTF8Console() const;
bool isUTF8() const;
bool isNewFont() const;
bool isVGAFont() const;
bool isMonochron() const;
bool hasTermResized() const;
// Mutators
void setTermEncoding(fc::encoding);
void setTTYFileDescriptor (int);
void setBaudrate (uInt);
void supportShadowCharacter (bool);
void supportHalfBlockCharacter (bool);
void supportCursorOptimisation (bool);
void setCursorHidden (bool);
void useAlternateScreen (bool);
void setASCIIConsole (bool);
void setVT100Console (bool);
void setUTF8Console (bool);
void setUTF8 (bool);
void setNewFont (bool);
void setVGAFont (bool);
void setMonochron (bool);
void setTermResized (bool);
void setTermType (const char[]);
void setTermFileName (const char[]);
void setXtermFont (const FString&);
void setXtermTitle (const FString&);
#if DEBUG
void setFramebufferBpp (int);
#endif
private:
// Disable copy constructor
FTermData (const FTermData&);
// Disable assignment operator (=)
FTermData& operator = (const FTermData&);
// Data Members
encodingMap encoding_list;
fc::encoding term_encoding;
FRect term_geometry; // current terminal geometry
int fd_tty;
uInt baudrate;
bool shadow_character;
bool half_block_character;
bool cursor_optimisation;
bool hidden_cursor;
bool use_alternate_screen;
bool ascii_console;
bool vt100_console;
bool utf8_console;
bool utf8_state;
bool new_font;
bool vga_font;
bool monochron;
bool resize_term;
char termtype[256];
char termfilename[256];
FString xterm_font;
FString xterm_title;
#if DEBUG
int framebuffer_bpp;
#endif
};
#pragma pack(pop)
// FTermData inline functions
//----------------------------------------------------------------------
inline FTermData::FTermData()
: encoding_list()
, term_encoding(fc::UNKNOWN)
, term_geometry()
, fd_tty(-1) // Teletype (tty) file descriptor is still undefined
, baudrate(0)
, shadow_character(true)
, half_block_character(true)
, cursor_optimisation(true)
, hidden_cursor(false) // Global cursor hidden state
, use_alternate_screen(true)
, ascii_console(false)
, vt100_console(false)
, utf8_console(false)
, utf8_state(false)
, new_font(false)
, vga_font(false)
, monochron(false)
, resize_term(false)
, termtype()
, termfilename()
, xterm_font()
, xterm_title()
#if DEBUG
, framebuffer_bpp(-1)
#endif
{
// Initialize arrays with '\0'
std::fill_n (termtype, sizeof(termtype), '\0');
std::fill_n (termfilename, sizeof(termfilename), '\0');
}
//----------------------------------------------------------------------
inline FTermData::~FTermData()
{ }
//----------------------------------------------------------------------
inline const char* FTermData::getClassName() const
{ return "FTermData"; }
//----------------------------------------------------------------------
inline FTermData::encodingMap& FTermData::getEncodingList()
{ return encoding_list; }
//----------------------------------------------------------------------
inline fc::encoding FTermData::getTermEncoding() const
{ return term_encoding; }
//----------------------------------------------------------------------
inline FRect& FTermData::getTermGeometry()
{ return term_geometry; }
//----------------------------------------------------------------------
inline int FTermData::getTTYFileDescriptor() const
{ return fd_tty; }
//----------------------------------------------------------------------
inline uInt FTermData::getBaudrate() const
{ return baudrate; }
//----------------------------------------------------------------------
inline char* FTermData::getTermType()
{ return termtype; }
//----------------------------------------------------------------------
inline char* FTermData::getTermFileName()
{ return termfilename; }
//----------------------------------------------------------------------
inline const FString& FTermData::getXtermFont() const
{ return xterm_font; }
//----------------------------------------------------------------------
inline const FString& FTermData::getXtermTitle() const
{ return xterm_title; }
//----------------------------------------------------------------------
#if DEBUG
inline int FTermData::getFramebufferBpp() const
{ return framebuffer_bpp; }
#endif
//----------------------------------------------------------------------
inline bool FTermData::hasShadowCharacter() const
{ return shadow_character; }
//----------------------------------------------------------------------
inline bool FTermData::hasHalfBlockCharacter() const
{ return half_block_character; }
//----------------------------------------------------------------------
inline bool FTermData::hasCursorOptimisation() const
{ return cursor_optimisation; }
//----------------------------------------------------------------------
inline bool FTermData::isCursorHidden() const
{ return hidden_cursor; }
//----------------------------------------------------------------------
inline bool FTermData::hasAlternateScreen() const
{ return use_alternate_screen; }
//----------------------------------------------------------------------
inline bool FTermData::hasASCIIConsole() const
{ return ascii_console; }
//----------------------------------------------------------------------
inline bool FTermData::hasVT100Console() const
{ return vt100_console; }
//----------------------------------------------------------------------
inline bool FTermData::hasUTF8Console() const
{ return utf8_console; }
//----------------------------------------------------------------------
inline bool FTermData::isUTF8() const
{ return utf8_state; }
//----------------------------------------------------------------------
inline bool FTermData::isNewFont() const
{ return new_font; }
//----------------------------------------------------------------------
inline bool FTermData::isVGAFont() const
{ return vga_font; }
//----------------------------------------------------------------------
inline bool FTermData::isMonochron() const
{ return monochron; }
//----------------------------------------------------------------------
inline bool FTermData::hasTermResized() const
{ return resize_term; }
//----------------------------------------------------------------------
inline void FTermData::setTermEncoding (fc::encoding enc)
{ term_encoding = enc; }
//----------------------------------------------------------------------
inline void FTermData::setTTYFileDescriptor (int fd)
{ fd_tty = fd; }
//----------------------------------------------------------------------
inline void FTermData::setBaudrate (uInt baud)
{ baudrate = baud; }
//----------------------------------------------------------------------
inline void FTermData::supportShadowCharacter (bool available)
{ shadow_character = available; }
//----------------------------------------------------------------------
inline void FTermData::supportHalfBlockCharacter (bool available)
{ half_block_character = available; }
//----------------------------------------------------------------------
inline void FTermData::supportCursorOptimisation (bool available)
{ cursor_optimisation = available; }
//----------------------------------------------------------------------
inline void FTermData::setCursorHidden (bool hidden_state)
{ hidden_cursor = hidden_state; }
//----------------------------------------------------------------------
inline void FTermData::useAlternateScreen (bool use)
{ use_alternate_screen = use; }
//----------------------------------------------------------------------
inline void FTermData::setASCIIConsole (bool ascii)
{ ascii_console = ascii; }
//----------------------------------------------------------------------
inline void FTermData::setVT100Console (bool vt100)
{ vt100_console = vt100; }
//----------------------------------------------------------------------
inline void FTermData::setUTF8Console (bool utf8)
{ utf8_console = utf8; }
//----------------------------------------------------------------------
inline void FTermData::setUTF8 (bool utf8)
{ utf8_state = utf8; }
//----------------------------------------------------------------------
inline void FTermData::setNewFont (bool nfont)
{ new_font = nfont; }
//----------------------------------------------------------------------
inline void FTermData::setVGAFont (bool vga)
{ vga_font = vga; }
//----------------------------------------------------------------------
inline void FTermData::setMonochron (bool mono)
{ monochron = mono; }
//----------------------------------------------------------------------
inline void FTermData::setTermResized (bool resize)
{ resize_term = resize; }
//----------------------------------------------------------------------
inline void FTermData::setTermType (const char name[])
{
if ( ! name )
return;
std::strncpy (termtype, name, sizeof(termtype));
termtype[sizeof(termtype) - 1] = '\0';
}
//----------------------------------------------------------------------
inline void FTermData::setTermFileName (const char file_name[])
{
if ( ! file_name )
return;
std::strncpy (termfilename, file_name, sizeof(termfilename));
termfilename[sizeof(termfilename) - 1] = '\0';
}
//----------------------------------------------------------------------
inline void FTermData::setXtermFont (const FString& font)
{ xterm_font = font; }
//----------------------------------------------------------------------
inline void FTermData::setXtermTitle (const FString& title)
{ xterm_title = title; }
//----------------------------------------------------------------------
#if DEBUG
inline void FTermData::setFramebufferBpp (int bpp)
{ framebuffer_bpp = bpp; }
#endif
} // namespace finalcut
#endif // FTERMDATA_H

View File

@ -43,6 +43,7 @@
#include "final/fc.h"
#include "final/fconfig.h"
#include "final/ftermdata.h"
#include "final/ftermios.h"
#include "final/ftypes.h"
@ -91,12 +92,11 @@ class FTermDetection
FTermDetection();
// Destructor
~FTermDetection();
virtual ~FTermDetection();
// Accessor
const char* getClassName() const;
static char* getTermType();
static char* getTermFileName();
static int getGnomeTerminalID();
terminalType& getTermTypeStruct();
@ -153,7 +153,7 @@ class FTermDetection
static void setScreenTerm (bool);
static void setTmuxTerm (bool);
static void setTerminalDetection (bool);
static void setTermFileName (char[]);
static void setTermData (FTermData*);
static void setTtyTypeFileName (char[]);
// Methods
@ -199,7 +199,6 @@ class FTermDetection
// Data Members
static char termtype[256];
static char termfilename[256];
static char ttytypename[256];
static bool decscusr_support;
static bool terminal_detection;
@ -207,6 +206,7 @@ class FTermDetection
static int gnome_terminal_id;
static const FString* answer_back;
static const FString* sec_da;
static FTermData* fterm_data;
static terminalType terminal_type;
static struct colorEnv
@ -256,10 +256,6 @@ inline const char* FTermDetection::getClassName() const
inline char* FTermDetection::getTermType()
{ return termtype; }
//----------------------------------------------------------------------
inline char* FTermDetection::getTermFileName()
{ return termfilename; }
//----------------------------------------------------------------------
inline int FTermDetection::getGnomeTerminalID()
{ return gnome_terminal_id; }

View File

@ -66,7 +66,7 @@ class FTermFreeBSD
FTermFreeBSD();
// Destructor
~FTermFreeBSD();
virtual ~FTermFreeBSD();
// Accessors
const char* getClassName() const;

View File

@ -57,7 +57,7 @@ class FTermios
FTermios();
// Destructor
~FTermios();
virtual ~FTermios();
// Accessors
const char* getClassName() const;

View File

@ -73,7 +73,7 @@ class FTermLinux
FTermLinux();
// Destructor
~FTermLinux();
virtual ~FTermLinux();
// Accessors
const char* getClassName() const;
@ -169,8 +169,8 @@ class FTermLinux
// Data Members
#if defined(__linux__)
static bool VGAFont;
static bool NewFont;
static bool vga_font;
static bool new_font;
static bool shadow_character;
static bool half_block_character;
static bool has_saved_palette;
@ -210,11 +210,11 @@ inline bool FTermLinux::hasHalfBlockCharacter()
//----------------------------------------------------------------------
inline bool FTermLinux::isVGAFontUsed()
{ return VGAFont; }
{ return vga_font; }
//----------------------------------------------------------------------
inline bool FTermLinux::isNewFontUsed()
{ return NewFont; }
{ return new_font; }
#endif // defined(__linux__)
} // namespace finalcut

View File

@ -59,7 +59,7 @@ class FTermOpenBSD
FTermOpenBSD();
// Destructor
~FTermOpenBSD();
virtual ~FTermOpenBSD();
// Accessor
const char* getClassName() const;

View File

@ -57,15 +57,15 @@ class FTermXTerminal
FTermXTerminal();
// Destructor
~FTermXTerminal();
virtual ~FTermXTerminal();
// Mutators
static void setTermcapMap (FTermcap::tcap_map*);
static void setFTermDetection (FTermDetection*);
static void redefineDefaultColors (bool);
static void setCursorStyle (fc::xtermCursorStyle);
static void setFont (const FString&);
static void setTitle (const FString&);
static void setTermSize (int, int);
static void setForeground (const FString&);
static void setBackground (const FString&);
static void setCursorColor (const FString&);
@ -110,6 +110,7 @@ class FTermXTerminal
static void setXTermCursorStyle();
static void setXTermFont();
static void setXTermTitle();
static void setXTermSize();
static void setXTermForeground();
static void setXTermBackground();
static void setXTermCursorColor();
@ -135,9 +136,11 @@ class FTermXTerminal
static void disableXTermMetaSendsESC();
// Data Members
static FTermcap::tcap_map* tcap;
static FTermDetection* term_detection;
static fc::xtermCursorStyle cursor_style;
static bool mouse_support;
static bool meta_sends_esc;
static bool xterm_default_colors;
static int term_width;
static int term_height;
static const FString* xterm_font;
static const FString* xterm_title;
static const FString* foreground_color;
@ -146,9 +149,9 @@ class FTermXTerminal
static const FString* mouse_foreground_color;
static const FString* mouse_background_color;
static const FString* highlight_background_color;
static bool mouse_support;
static bool meta_sends_esc;
static bool xterm_default_colors;
static FTermcap::tcap_map* tcap;
static FTermDetection* term_detection;
static fc::xtermCursorStyle cursor_style;
};
#pragma pack(pop)
@ -157,10 +160,6 @@ class FTermXTerminal
inline const char* FTermXTerminal::getClassName() const
{ return "FTermXTerminal"; }
//----------------------------------------------------------------------
inline void FTermXTerminal::setTermcapMap (FTermcap::tcap_map* tc)
{ tcap = tc; }
//----------------------------------------------------------------------
inline void FTermXTerminal::setFTermDetection (FTermDetection* td)
{ term_detection = td; }

View File

@ -80,7 +80,7 @@ class FTextView : public FWidget
explicit FTextView (FWidget* = 0);
// Destructor
~FTextView();
virtual ~FTextView();
// Accessors
const char* getClassName() const;
@ -90,7 +90,7 @@ class FTextView : public FWidget
const FStringList& getLines() const;
// Mutators
void setGeometry (int, int, int, int, bool = true);
virtual void setGeometry (int, int, int, int, bool = true);
void setText (const FString&);
void scrollToX (int);
void scrollToY (int);
@ -99,7 +99,7 @@ class FTextView : public FWidget
void scrollBy (int, int);
// Methods
void hide();
virtual void hide();
void append (const FString&);
void insert (const FString&, int);
void replaceRange (const FString&, int, int);
@ -108,17 +108,17 @@ class FTextView : public FWidget
void clear();
// Event handlers
void onKeyPress (FKeyEvent*);
void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*);
void onMouseMove (FMouseEvent*);
void onWheel (FWheelEvent*);
void onFocusIn (FFocusEvent*);
void onFocusOut (FFocusEvent*);
virtual void onKeyPress (FKeyEvent*);
virtual void onMouseDown (FMouseEvent*);
virtual void onMouseUp (FMouseEvent*);
virtual void onMouseMove (FMouseEvent*);
virtual void onWheel (FWheelEvent*);
virtual void onFocusIn (FFocusEvent*);
virtual void onFocusOut (FFocusEvent*);
protected:
// Method
void adjustSize();
virtual void adjustSize();
private:
// Disable copy constructor
@ -133,7 +133,7 @@ class FTextView : public FWidget
// Methods
void init();
void draw();
virtual void draw();
void drawText();
void processChanged();
void drawHBar();

View File

@ -85,17 +85,17 @@ class FToggleButton : public FWidget
FString& getText();
// Mutators
void setGeometry (int, int, int, int, bool = true);
virtual void setGeometry (int, int, int, int, bool = true);
bool setNoUnderline (bool);
bool setNoUnderline();
bool unsetNoUnderline();
bool setEnable (bool);
bool setEnable();
bool unsetEnable();
bool setDisable();
bool setFocus (bool);
bool setFocus();
bool unsetFocus();
virtual bool setEnable (bool);
virtual bool setEnable();
virtual bool unsetEnable();
virtual bool setDisable();
virtual bool setFocus (bool);
virtual bool setFocus();
virtual bool unsetFocus();
bool setChecked (bool);
bool setChecked();
bool unsetChecked();
@ -105,15 +105,15 @@ class FToggleButton : public FWidget
bool isChecked();
// Methods
void hide();
virtual void hide();
// Event handlers
void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*);
void onWheel (FWheelEvent*);
void onAccel (FAccelEvent*);
void onFocusIn (FFocusEvent*);
void onFocusOut (FFocusEvent*);
virtual void onMouseDown (FMouseEvent*);
virtual void onMouseUp (FMouseEvent*);
virtual void onWheel (FWheelEvent*);
virtual void onAccel (FAccelEvent*);
virtual void onFocusIn (FFocusEvent*);
virtual void onFocusOut (FFocusEvent*);
protected:
// Accessor
@ -153,7 +153,6 @@ class FToggleButton : public FWidget
void setGroup (FButtonGroup*);
// Methods
void init (const FString&);
void init();
int getHotkeyPos (wchar_t[], wchar_t[], uInt);
void drawText (wchar_t[], int, uInt);

View File

@ -90,11 +90,11 @@ class FToolTip : public FWindow
// Methods
virtual void draw();
void show();
void hide();
virtual void show();
virtual void hide();
// Event handler
void onMouseDown (FMouseEvent*);
virtual void onMouseDown (FMouseEvent*);
private:
// Disable copy constructor

View File

@ -116,7 +116,7 @@ class FVTerm : public FTerm
explicit FVTerm (bool, bool = false);
// Destructor
~FVTerm();
virtual ~FVTerm();
// Overloaded operators
template<class type> FVTerm& operator << (const type&);
@ -440,7 +440,7 @@ class FVTerm : public FTerm
static charData s_ch; // shadow character
static charData i_ch; // inherit background character
static FPoint* term_pos; // terminal cursor position
static termcap_map* tcap;
static FTermcap::tcap_map* tcap;
static FKeyboard* keyboard;
static bool terminal_update_complete;
static bool terminal_update_pending;

View File

@ -146,7 +146,7 @@ class FWidget : public FVTerm, public FObject
explicit FWidget (FWidget* = 0, bool = false);
// Destructor
~FWidget();
virtual ~FWidget();
// Accessors
const char* getClassName() const;
@ -349,7 +349,7 @@ class FWidget : public FVTerm, public FObject
virtual bool focusPrevChild(); // ...focus
// Event handlers
bool event (FEvent*);
virtual bool event (FEvent*);
virtual void onKeyPress (FKeyEvent*);
virtual void onKeyUp (FKeyEvent*);
virtual void onKeyDown (FKeyEvent*);
@ -860,7 +860,7 @@ inline FPoint FWidget::termToWidgetPos (const FPoint& tPos)
//----------------------------------------------------------------------
inline void FWidget::move (const FPoint& pos)
{ move( pos.getX(), pos.getY() ); }
{ move(pos.getX(), pos.getY()); }
//----------------------------------------------------------------------
inline void FWidget::drawBorder()

View File

@ -85,7 +85,7 @@ class FWindow : public FWidget
explicit FWindow (FWidget* = 0);
// Destructor
~FWindow ();
virtual ~FWindow ();
// Accessors
const char* getClassName() const;
@ -157,7 +157,7 @@ class FWindow : public FWidget
virtual void adjustSize();
// Event handlers
bool event (FEvent*);
virtual bool event (FEvent*);
virtual void onWindowActive (FEvent*);
virtual void onWindowInactive (FEvent*);
virtual void onWindowRaised (FEvent*);

View File

@ -10,6 +10,7 @@ noinst_PROGRAMS = \
fobject_test \
fmouse_test \
fkeyboard_test \
ftermdata_test \
ftermdetection_test \
ftermcapquirks_test \
foptimove_test \
@ -21,6 +22,7 @@ noinst_PROGRAMS = \
fobject_test_SOURCES = fobject-test.cpp
fmouse_test_SOURCES = fmouse-test.cpp
fkeyboard_test_SOURCES = fkeyboard-test.cpp
ftermdata_test_SOURCES = ftermdata-test.cpp
ftermdetection_test_SOURCES = ftermdetection-test.cpp
ftermcapquirks_test_SOURCES = ftermcapquirks-test.cpp
foptimove_test_SOURCES = foptimove-test.cpp
@ -32,6 +34,7 @@ frect_test_SOURCES = frect-test.cpp
TESTS = fobject_test \
fmouse_test \
fkeyboard_test \
ftermdata_test \
ftermdetection_test \
ftermcapquirks_test \
foptimove_test \

View File

@ -356,7 +356,8 @@ void FKeyboardTest::escapeKeyTest()
// Normal escape (needs a timeout)
input("\033");
processInput();
usleep(100000);
// Wait 100 ms (= 100,000,000 ns)
nanosleep ((const struct timespec[]){{0, 100000000L}}, NULL);
keyboard->escapeKeyHandling();
std::cout << " - Key: " << keyboard->getKeyName(key_pressed) << std::endl;
CPPUNIT_ASSERT ( key_pressed == finalcut::fc::Fkey_escape );
@ -2085,7 +2086,8 @@ void FKeyboardTest::metaKeyTest()
// shifted meta-O
input("\033O");
processInput();
usleep(100000); // Substring keys needs a timeout
// Wait 100 ms - Substring keys needs a timeout
nanosleep ((const struct timespec[]){{0, 100000000L}}, NULL);
keyboard->escapeKeyHandling();
std::cout << " - Key: " << keyboard->getKeyName(key_pressed) << std::endl;
CPPUNIT_ASSERT ( key_pressed == finalcut::fc::Fmkey_O );
@ -2171,7 +2173,8 @@ void FKeyboardTest::metaKeyTest()
// meta-[
input("\033[");
processInput();
usleep(100000); // Substring keys needs a timeout
// Wait 100 ms - Substring keys needs a timeout
nanosleep ((const struct timespec[]){{0, 100000000L}}, NULL);
keyboard->escapeKeyHandling();
std::cout << " - Key: " << keyboard->getKeyName(key_pressed) << std::endl;
CPPUNIT_ASSERT ( key_pressed == finalcut::fc::Fmkey_left_square_bracket );
@ -2187,7 +2190,8 @@ void FKeyboardTest::metaKeyTest()
// meta-]
input("\033]");
processInput();
usleep(100000); // Substring keys needs a timeout
// Wait 100 ms - Substring keys needs a timeout
nanosleep ((const struct timespec[]){{0, 100000000L}}, NULL);
keyboard->escapeKeyHandling();
std::cout << " - Key: " << keyboard->getKeyName(key_pressed) << std::endl;
CPPUNIT_ASSERT ( key_pressed == finalcut::fc::Fmkey_right_square_bracket );

View File

@ -1,5 +1,5 @@
/***********************************************************************
* fmouse-test.cpp - finalcut::FMouse unit tests *
* fmouse-test.cpp - FMouse unit tests *
* *
* This file is part of the Final Cut widget toolkit *
* *
@ -199,6 +199,8 @@ void FMouseTest::noArgumentTest()
//----------------------------------------------------------------------
void FMouseTest::doubleClickTest()
{
using finalcut::operator -;
FMouse_protected mouse;
CPPUNIT_ASSERT ( mouse.getDblclickInterval() == 500000 ); // 500 ms
timeval tv = { 0, 0 };

Some files were not shown because too many files have changed in this diff Show More