Reduce the use of the new operators in the examples

This commit is contained in:
Markus Gans 2018-10-03 22:23:55 +02:00
parent 03bd7bd6da
commit d5e345ab68
31 changed files with 1190 additions and 1266 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -58,6 +58,7 @@ class ColorChooser : public finalcut::FWidget
// Data Members // Data Members
short fg_color; short fg_color;
short bg_color; short bg_color;
finalcut::FLabel headline;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -66,6 +67,7 @@ ColorChooser::ColorChooser (finalcut::FWidget* parent)
: FWidget(parent) : FWidget(parent)
, fg_color(finalcut::fc::White) , fg_color(finalcut::fc::White)
, bg_color(finalcut::fc::Black) , bg_color(finalcut::fc::Black)
, headline(this)
{ {
setSize (8, 12); setSize (8, 12);
setFixedSize (8, 12); setFixedSize (8, 12);
@ -73,16 +75,19 @@ ColorChooser::ColorChooser (finalcut::FWidget* parent)
if ( parent ) if ( parent )
{ {
setForegroundColor(parent->getForegroundColor()); short fg = parent->getForegroundColor();
setBackgroundColor(parent->getBackgroundColor()); short bg = parent->getBackgroundColor();
setForegroundColor(fg);
setBackgroundColor(bg);
headline.setForegroundColor(fg);
headline.setBackgroundColor(bg);
} }
// Text label // Text label
finalcut::FLabel* headline = new finalcut::FLabel (this); headline.setGeometry (1, 1, 8, 1);
headline->setGeometry(1, 1, 8, 1); headline.setEmphasis();
headline->setEmphasis(); headline.setAlignment (finalcut::fc::alignCenter);
headline->setAlignment (finalcut::fc::alignCenter); headline << "Color";
*headline << "Color";
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -197,6 +202,7 @@ class Brushes : public finalcut::FWidget
wchar_t brush; wchar_t brush;
short fg_color; short fg_color;
short bg_color; short bg_color;
finalcut::FLabel headline;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -206,6 +212,7 @@ Brushes::Brushes (finalcut::FWidget* parent)
, brush(L' ') , brush(L' ')
, fg_color(finalcut::fc::White) , fg_color(finalcut::fc::White)
, bg_color(finalcut::fc::Black) , bg_color(finalcut::fc::Black)
, headline(this)
{ {
setSize (8, 4); setSize (8, 4);
setFixedSize (8, 4); setFixedSize (8, 4);
@ -213,16 +220,19 @@ Brushes::Brushes (finalcut::FWidget* parent)
if ( parent ) if ( parent )
{ {
setForegroundColor(parent->getForegroundColor()); short fg = parent->getForegroundColor();
setBackgroundColor(parent->getBackgroundColor()); short bg = parent->getBackgroundColor();
setForegroundColor(fg);
setBackgroundColor(bg);
headline.setForegroundColor(fg);
headline.setBackgroundColor(bg);
} }
// Text label // Text label
finalcut::FLabel* headline = new finalcut::FLabel (this); headline.setGeometry(1, 1, 8, 1);
headline->setGeometry(1, 1, 8, 1); headline.setEmphasis();
headline->setEmphasis(); headline.setAlignment (finalcut::fc::alignCenter);
headline->setAlignment (finalcut::fc::alignCenter); headline << "Brush";
*headline << "Brush";
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -340,8 +350,8 @@ class MouseDraw : public finalcut::FDialog
// Data Members // Data Members
term_area* canvas; term_area* canvas;
ColorChooser* c_chooser; ColorChooser c_chooser;
Brushes* brush; Brushes brush;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -349,20 +359,18 @@ class MouseDraw : public finalcut::FDialog
MouseDraw::MouseDraw (finalcut::FWidget* parent) MouseDraw::MouseDraw (finalcut::FWidget* parent)
: finalcut::FDialog(parent) : finalcut::FDialog(parent)
, canvas(0) , canvas(0)
, c_chooser() , c_chooser(this)
, brush() , brush(this)
{ {
setText ("Drawing with the mouse"); setText ("Drawing with the mouse");
c_chooser = new ColorChooser(this); c_chooser.setPos (1, 1);
c_chooser->setPos (1, 1); c_chooser.addCallback
c_chooser->addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MouseDraw::cb_colorChanged) 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::FPoint no_shadow(0,0);
finalcut::FRect scroll_geometry(0, 0, 1, 1); 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 ( x > 10 && x < Cols && y > 2 && y < Lines )
{ {
if ( swap_color ) if ( swap_color )
setColor (c_chooser->getBackground(), c_chooser->getForeground()); setColor (c_chooser.getBackground(), c_chooser.getForeground());
else else
setColor (c_chooser->getForeground(), c_chooser->getBackground()); setColor (c_chooser.getForeground(), c_chooser.getBackground());
// set canvas print cursor position // set canvas print cursor position
canvas->cursor_x = x - canvas->offset_left - 10; canvas->cursor_x = x - canvas->offset_left - 10;
canvas->cursor_y = y - canvas->offset_top - 2; canvas->cursor_y = y - canvas->offset_top - 2;
// print on canvas // print on canvas
print (canvas, brush->getBrush()); print (canvas, brush.getBrush());
// copy canvas to the dialog // copy canvas to the dialog
drawCanvas(); drawCanvas();
} }
@ -539,9 +547,9 @@ void MouseDraw::onMouseMove (finalcut::FMouseEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MouseDraw::cb_colorChanged (finalcut::FWidget*, data_ptr) void MouseDraw::cb_colorChanged (finalcut::FWidget*, data_ptr)
{ {
brush->setForeground (c_chooser->getForeground()); brush.setForeground (c_chooser.getForeground());
brush->setBackground (c_chooser->getBackground()); brush.setBackground (c_chooser.getBackground());
brush->redraw(); brush.redraw();
} }

View File

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

View File

@ -61,8 +61,8 @@ class AttribDlg : public finalcut::FDialog
virtual void adjustSize(); virtual void adjustSize();
// Data Members // Data Members
finalcut::FButton* next_button; finalcut::FButton next_button;
finalcut::FButton* back_button; finalcut::FButton back_button;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -70,28 +70,26 @@ class AttribDlg : public finalcut::FDialog
AttribDlg::AttribDlg (finalcut::FWidget* parent) AttribDlg::AttribDlg (finalcut::FWidget* parent)
: finalcut::FDialog(parent) : finalcut::FDialog(parent)
, bgcolor(wc.label_bg) , bgcolor(wc.label_bg)
, next_button() , next_button("&Next >", this)
, back_button() , back_button("< &Back", this)
{ {
setText ( "A terminal attributes test (" setText ( "A terminal attributes test ("
+ finalcut::FString(getTermType()) + finalcut::FString(getTermType())
+ ")"); + ")");
next_button = new finalcut::FButton("&Next >", this); next_button.setGeometry(getWidth() - 13, getHeight() - 4, 10, 1);
next_button->setGeometry(getWidth() - 13, getHeight() - 4, 10, 1); next_button.addAccelerator(finalcut::fc::Fkey_right);
next_button->addAccelerator(finalcut::fc::Fkey_right); back_button.setGeometry(getWidth() - 25, getHeight() - 4, 10, 1);
back_button = new finalcut::FButton("< &Back", this); back_button.addAccelerator(finalcut::fc::Fkey_left);
back_button->setGeometry(getWidth() - 25, getHeight() - 4, 10, 1);
back_button->addAccelerator(finalcut::fc::Fkey_left);
// Add function callbacks // Add function callbacks
next_button->addCallback next_button.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &AttribDlg::cb_next) F_METHOD_CALLBACK (this, &AttribDlg::cb_next)
); );
back_button->addCallback back_button.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &AttribDlg::cb_back) F_METHOD_CALLBACK (this, &AttribDlg::cb_back)
@ -167,8 +165,8 @@ void AttribDlg::adjustSize()
y = 1; y = 1;
setGeometry(x, y, 69, 21, false); setGeometry(x, y, 69, 21, false);
next_button->setGeometry(getWidth() - 13, 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); back_button.setGeometry(getWidth() - 25, getHeight() - 4, 10, 1, false);
finalcut::FDialog::adjustSize(); finalcut::FDialog::adjustSize();
} }
@ -492,20 +490,20 @@ int main (int argc, char* argv[])
// Create a dialog box object. // Create a dialog box object.
// This object will be automatically deleted by // This object will be automatically deleted by
// the parent object "app" (FObject destructor). // the parent object "app" (FObject destructor).
AttribDlg* dialog = new AttribDlg(&app); AttribDlg dialog(&app);
dialog->setGeometry (6, 2, 69, 21); dialog.setGeometry (6, 2, 69, 21);
dialog->addAccelerator('q'); // press 'q' to quit dialog.addAccelerator('q'); // press 'q' to quit
dialog->setShadow(); dialog.setShadow();
// Create the attribute demo widget as a child object from the dialog // Create the attribute demo widget as a child object from the dialog
AttribDemo* demo = new AttribDemo(dialog); AttribDemo demo(&dialog);
demo->setGeometry (1, 1, 67, 19); demo.setGeometry (1, 1, 67, 19);
// Set the dialog object as main widget // Set the dialog object as main widget
app.setMainWidget(dialog); app.setMainWidget(&dialog);
// Show and start the application // Show and start the application
dialog->show(); dialog.show();
return app.exec(); return app.exec();
} }

View File

@ -39,18 +39,32 @@ void booleans();
void numeric(); void numeric();
void string(finalcut::FTermcap::tcap_map*&); void string(finalcut::FTermcap::tcap_map*&);
//----------------------------------------------------------------------
// struct data
//----------------------------------------------------------------------
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
struct termcap_string struct data
{ {
static int getNumberOfItems();
struct termcap_string
{
const std::string name; const std::string name;
const finalcut::fc::termcaps cap; const finalcut::fc::termcaps cap;
};
static termcap_string strings[];
}; };
#pragma pack(pop) #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_bell", finalcut::fc::t_bell },
{ "t_erase_chars", finalcut::fc::t_erase_chars }, { "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 } { "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"; 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 std::string name = data::strings[n].name;
const finalcut::fc::termcaps cap = strings[n].cap; const finalcut::fc::termcaps cap = data::strings[n].cap;
tcapString (name, tcap[cap].string); tcapString (name, tcap[cap].string);
} }
} }

View File

@ -41,7 +41,6 @@ class Transparent : public finalcut::FDialog
inherit_background = 2 inherit_background = 2
} trans_type; } trans_type;
public:
// Constructor // Constructor
explicit Transparent (finalcut::FWidget* = 0, trans_type = transparent); explicit Transparent (finalcut::FWidget* = 0, trans_type = transparent);
@ -150,9 +149,11 @@ void Transparent::onKeyPress (finalcut::FKeyEvent* ev)
class MainWindow : public finalcut::FDialog class MainWindow : public finalcut::FDialog
{ {
private: public:
finalcut::FString line1; // Constructor
finalcut::FString line2; explicit MainWindow (finalcut::FWidget* = 0);
// Destructor
~MainWindow();
private: private:
// Disable copy constructor // Disable copy constructor
@ -180,11 +181,13 @@ class MainWindow : public finalcut::FDialog
finalcut::FDialog::onKeyPress(ev); finalcut::FDialog::onKeyPress(ev);
} }
public: // Data Members
// Constructor finalcut::FString line1;
explicit MainWindow (finalcut::FWidget* = 0); finalcut::FString line2;
// Destructor Transparent transpwin;
~MainWindow(); Transparent shadowwin;
Transparent ibg;
finalcut::FStatusBar status_bar;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -193,28 +196,28 @@ MainWindow::MainWindow (finalcut::FWidget* parent)
: FDialog(parent) : FDialog(parent)
, line1() , line1()
, line2() , line2()
, transpwin(this)
, shadowwin(this, Transparent::shadow)
, ibg(this, Transparent::inherit_background)
, status_bar(this)
{ {
line1 = " .-. .-. .-."; line1 = " .-. .-. .-.";
line2 = "`._.' `._.' `._.' "; line2 = "`._.' `._.' `._.' ";
Transparent* transpwin = new Transparent(this); transpwin.setText("transparent");
transpwin->setText("transparent"); transpwin.setGeometry (6, 3, 29, 12);
transpwin->setGeometry (6, 3, 29, 12); transpwin.unsetTransparentShadow();
transpwin->unsetTransparentShadow();
Transparent* shadowwin = new Transparent(this, Transparent::shadow); shadowwin.setText("shadow");
shadowwin->setText("shadow"); shadowwin.setGeometry (46, 11, 29, 12);
shadowwin->setGeometry (46, 11, 29, 12); shadowwin.unsetTransparentShadow();
shadowwin->unsetTransparentShadow();
Transparent* ibg = new Transparent(this, Transparent::inherit_background); ibg.setText("inherit background");
ibg->setText("inherit background"); ibg.setGeometry (42, 3, 29, 7);
ibg->setGeometry (42, 3, 29, 7); ibg.unsetTransparentShadow();
ibg->unsetTransparentShadow();
// Statusbar at the bottom // 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'); addAccelerator('q');
unsetTransparentShadow(); unsetTransparentShadow();

View File

@ -54,19 +54,20 @@ class Treeview : public finalcut::FDialog
// Methods // Methods
virtual void adjustSize(); virtual void adjustSize();
TreeItem* getAfrica();
TreeItem* getAsia();
TreeItem* getEurope();
TreeItem* getNorthAmerica();
TreeItem* getSouthAmerica();
TreeItem* getOceania();
// Event handlers // Event handlers
void onClose (finalcut::FCloseEvent*); void onClose (finalcut::FCloseEvent*);
// Data Members // Data Members
finalcut::FListView* listView; bool initialized;
finalcut::FButton* Quit; 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) #pragma pack(pop)
@ -94,10 +95,10 @@ struct Treeview::TreeItem
#pragma pack(pop) #pragma pack(pop)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
Treeview::TreeItem* Treeview::getAfrica() // class Treeview - array data
//----------------------------------------------------------------------
Treeview::TreeItem Treeview::africa[] =
{ {
static TreeItem africa[] =
{
{ "Algeria", "40,400,000", "15.9", 0 }, { "Algeria", "40,400,000", "15.9", 0 },
{ "Angola", "25,789,024", "20.69", 0 }, { "Angola", "25,789,024", "20.69", 0 },
{ "Botswana", "2,250,260", "3.7", 0 }, { "Botswana", "2,250,260", "3.7", 0 },
@ -121,16 +122,10 @@ Treeview::TreeItem* Treeview::getAfrica()
{ "Tanzania", "51,820,00", "47.5", 0 }, { "Tanzania", "51,820,00", "47.5", 0 },
{ "Zambia", "16,212,000", "17.2", 0 }, { "Zambia", "16,212,000", "17.2", 0 },
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };
return africa; Treeview::TreeItem Treeview::asia[] =
}
//----------------------------------------------------------------------
Treeview::TreeItem* Treeview::getAsia()
{ {
static TreeItem asia[] =
{
{ "Afghanistan", "34,656,032", "49.88", 0 }, { "Afghanistan", "34,656,032", "49.88", 0 },
{ "China", "1,403,500,365", "145.0", 0 }, { "China", "1,403,500,365", "145.0", 0 },
{ "India", "1,324,171,354", "393.9", 0 }, { "India", "1,324,171,354", "393.9", 0 },
@ -151,16 +146,10 @@ Treeview::TreeItem* Treeview::getAsia()
{ "Vietnam", "94,569,072", "276.03", 0 }, { "Vietnam", "94,569,072", "276.03", 0 },
{ "Yemen", "27,584,213", "44.7", 0 }, { "Yemen", "27,584,213", "44.7", 0 },
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };
return asia; Treeview::TreeItem Treeview::europe[] =
}
//----------------------------------------------------------------------
Treeview::TreeItem* Treeview::getEurope()
{ {
static TreeItem europe[] =
{
{ "Austria", "8,794,267", "104.0", 0 }, { "Austria", "8,794,267", "104.0", 0 },
{ "Belarus", "9,498,700", "45.8", 0 }, { "Belarus", "9,498,700", "45.8", 0 },
{ "Bulgaria", "7,101,859", "64.9", 0 }, { "Bulgaria", "7,101,859", "64.9", 0 },
@ -181,16 +170,11 @@ Treeview::TreeItem* Treeview::getEurope()
{ "Sweden", "10,065,389", "22.0", 0 }, { "Sweden", "10,065,389", "22.0", 0 },
{ "United Kingdom", "65,648,000", "270.7", 0 }, { "United Kingdom", "65,648,000", "270.7", 0 },
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };
return europe;
}
//---------------------------------------------------------------------- Treeview::TreeItem Treeview::north_america[] =
Treeview::TreeItem* Treeview::getNorthAmerica()
{ {
static TreeItem north_america[] =
{
{ "Canada", "35,151,728", "3.92", 0 }, { "Canada", "35,151,728", "3.92", 0 },
{ "Cuba", "11,239,224", "102.3", 0 }, { "Cuba", "11,239,224", "102.3", 0 },
{ "Greenland", "56,483", "0.028", 0 }, { "Greenland", "56,483", "0.028", 0 },
@ -200,16 +184,10 @@ Treeview::TreeItem* Treeview::getNorthAmerica()
{ "Nicaragua", "6,167,237", "51.0", 0 }, { "Nicaragua", "6,167,237", "51.0", 0 },
{ "USA", "325,365,189", "35.0", 0 }, { "USA", "325,365,189", "35.0", 0 },
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };
return north_america; Treeview::TreeItem Treeview::south_america[] =
}
//----------------------------------------------------------------------
Treeview::TreeItem* Treeview::getSouthAmerica()
{ {
static TreeItem south_america[] =
{
{ "Argentina", "43,847,430", "14.4", 0 }, { "Argentina", "43,847,430", "14.4", 0 },
{ "Bolivia", "11,410,651", "10.4", 0 }, { "Bolivia", "11,410,651", "10.4", 0 },
{ "Brazil", "208,064,000", "24.35", 0 }, { "Brazil", "208,064,000", "24.35", 0 },
@ -221,16 +199,10 @@ Treeview::TreeItem* Treeview::getSouthAmerica()
{ "Peru", "31,826,018", "23.0", 0 }, { "Peru", "31,826,018", "23.0", 0 },
{ "Venezuela", "31,568,179", "33.75", 0 }, { "Venezuela", "31,568,179", "33.75", 0 },
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };
return south_america; Treeview::TreeItem Treeview::oceania[] =
}
//----------------------------------------------------------------------
Treeview::TreeItem* Treeview::getOceania()
{ {
static TreeItem oceania[] =
{
{ "Australia", "24,675,900", "3.2", 0 }, { "Australia", "24,675,900", "3.2", 0 },
{ "Papua New Guinea", "7,059,653", "15.0", 0 }, { "Papua New Guinea", "7,059,653", "15.0", 0 },
{ "Papua", "3,486,432", "11.0", 0 }, { "Papua", "3,486,432", "11.0", 0 },
@ -245,41 +217,32 @@ Treeview::TreeItem* Treeview::getOceania()
{ "Samoa", "192,342", "68.0", 0 }, { "Samoa", "192,342", "68.0", 0 },
{ "Kiribati", "110,136", "152.0", 0 }, { "Kiribati", "110,136", "152.0", 0 },
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };
return oceania;
}
// constructors and destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
Treeview::Treeview (finalcut::FWidget* parent) Treeview::Treeview (finalcut::FWidget* parent)
: finalcut::FDialog(parent) : finalcut::FDialog(parent)
, listView() , initialized(false)
, Quit() , listView(this)
, Quit(this)
{ {
// Create FListView object // 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 // Add columns to the view
listView->addColumn ("Name", 23); listView.addColumn ("Name", 23);
listView->addColumn ("Population"); listView.addColumn ("Population");
listView->addColumn ("Density/km²"); listView.addColumn ("Density/km²");
// Set right alignment for the second and third column // Set right alignment for the second and third column
listView->setColumnAlignment (2, finalcut::fc::alignRight); listView.setColumnAlignment (2, finalcut::fc::alignRight);
listView->setColumnAlignment (3, finalcut::fc::alignRight); listView.setColumnAlignment (3, finalcut::fc::alignRight);
// Activate tree view // Activate tree view
listView->setTreeView(); listView.setTreeView();
// Populate FListView with a list of items // 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[] = static TreeItem continent[] =
{ {
{ "Africa", "944,000,000", "31.2", africa }, { "Africa", "944,000,000", "31.2", africa },
@ -300,13 +263,13 @@ Treeview::Treeview (finalcut::FWidget* parent)
finalcut::FStringList continent_line ( continent_list->begin() finalcut::FStringList continent_line ( continent_list->begin()
, continent_list->end() ); , continent_list->end() );
finalcut::FListViewIterator::FObjectIterator iter = \ finalcut::FListViewIterator::FObjectIterator iter = \
listView->insert (continent_line); listView.insert (continent_line);
while ( country_list && country_list->name ) while ( country_list && country_list->name )
{ {
finalcut::FStringList country_line ( country_list->begin() finalcut::FStringList country_line ( country_list->begin()
, country_list->end() ); , country_list->end() );
listView->insert (country_line, iter); listView.insert (country_line, iter);
country_list++; country_list++;
} }
@ -314,16 +277,17 @@ Treeview::Treeview (finalcut::FWidget* parent)
} }
// Quit button // Quit button
Quit = new finalcut::FButton (this); Quit.setGeometry(24, 16, 10, 1);
Quit->setGeometry(24, 16, 10, 1); Quit.setText (L"&Quit");
Quit->setText (L"&Quit");
// Add some function callbacks // Add some function callbacks
Quit->addCallback Quit.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &finalcut::FApplication::cb_exitApp) F_METHOD_CALLBACK (this, &finalcut::FApplication::cb_exitApp)
); );
initialized = true;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -342,11 +306,11 @@ void Treeview::adjustSize()
setX (X, false); setX (X, false);
if ( listView ) if ( initialized )
listView->setHeight (getHeight() - 6, false); {
listView.setHeight (getHeight() - 6, false);
if ( Quit ) Quit.setY(getHeight() - 4);
Quit->setY(getHeight() - 4); }
finalcut::FDialog::adjustSize(); finalcut::FDialog::adjustSize();
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1466,7 +1466,7 @@ void FTerm::init_locale()
char* locale_xterm; char* locale_xterm;
const char* termtype = data->getTermType(); const char* termtype = data->getTermType();
locale_name = std::setlocale (LC_ALL, ""); locale_name = std::setlocale (LC_ALL, "");
locale_name = std::setlocale (LC_NUMERIC, ""); std::setlocale (LC_NUMERIC, "");
// Get XTERM_LOCALE // Get XTERM_LOCALE
locale_xterm = std::getenv("XTERM_LOCALE"); locale_xterm = std::getenv("XTERM_LOCALE");
@ -1506,7 +1506,7 @@ void FTerm::init_locale()
// Fallback to C // Fallback to C
if ( ! locale_name ) if ( ! locale_name )
locale_name = C_STR("C"); std::setlocale (LC_ALL, "C");
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -163,8 +163,7 @@ class FFileDialog : public FDialog
// Method // Method
void init(); void init();
void allocation (int, int); void widgetSettings (int, int);
void deallocation();
void initCallbacks(); void initCallbacks();
bool pattern_match (const char* const, char[]); bool pattern_match (const char* const, char[]);
void clear(); void clear();
@ -191,11 +190,11 @@ class FFileDialog : public FDialog
dirEntries dir_entries; dirEntries dir_entries;
FString directory; FString directory;
FString filter_pattern; FString filter_pattern;
FListBox* filebrowser; FLineEdit filename;
FLineEdit* filename; FListBox filebrowser;
FCheckBox* hidden; FCheckBox hidden;
FButton* cancel; FButton cancel;
FButton* open; FButton open;
DialogType dlg_type; DialogType dlg_type;
bool show_hidden; bool show_hidden;

View File

@ -92,6 +92,8 @@ class FStatusKey : public FWidget
virtual FString getText() const; virtual FString getText() const;
// Mutators // Mutators
void setKey (int);
void setText (const FString&);
void setActive(); void setActive();
void unsetActive(); void unsetActive();
bool setMouseFocus(bool); bool setMouseFocus(bool);
@ -105,11 +107,6 @@ class FStatusKey : public FWidget
// Event handler // Event handler
virtual void onAccel (FAccelEvent*); virtual void onAccel (FAccelEvent*);
protected:
// Mutators
void setKey (int);
void setText (const FString&);
private: private:
// Disable copy constructor // Disable copy constructor
FStatusKey (const FStatusKey&); FStatusKey (const FStatusKey&);
@ -149,6 +146,14 @@ inline int FStatusKey::getKey() const
inline FString FStatusKey::getText() const inline FString FStatusKey::getText() const
{ return text; } { return text; }
//----------------------------------------------------------------------
inline void FStatusKey::setKey (int k)
{ key = k; }
//----------------------------------------------------------------------
inline void FStatusKey::setText (const FString& txt)
{ text = txt; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FStatusKey::unsetActive() inline void FStatusKey::unsetActive()
{ active = false; } { active = false; }
@ -169,14 +174,6 @@ inline bool FStatusKey::isActivated() const
inline bool FStatusKey::hasMouseFocus() const inline bool FStatusKey::hasMouseFocus() const
{ return mouse_focus; } { 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 inline FStatusBar* FStatusKey::getConnectedStatusbar() const
{ return bar; } { return bar; }

View File

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

View File

@ -477,7 +477,8 @@ void FObjectTest::performTimerActionTest()
while ( loop < 10 ) while ( loop < 10 )
{ {
num_events += t.processEvent(); num_events += t.processEvent();
usleep(100000); // Wait 100 ms
nanosleep ((const struct timespec[]){{0, 100000000L}}, NULL);
loop++; loop++;
} }

View File

@ -1,5 +1,5 @@
/*********************************************************************** /***********************************************************************
* foptiattr_test.cpp - finalcut::FOptiAttr unit tests * * foptiattr_test.cpp - FOptiAttr unit tests *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *

View File

@ -1,5 +1,5 @@
/*********************************************************************** /***********************************************************************
* foptimove-test.cpp - finalcut::FOptiMove unit tests * * foptimove-test.cpp - FOptiMove unit tests *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *

View File

@ -1,5 +1,5 @@
/*********************************************************************** /***********************************************************************
* fpoint-test.cpp - finalcut::FPoint unit tests * * fpoint-test.cpp - FPoint unit tests *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *

View File

@ -1,5 +1,5 @@
/*********************************************************************** /***********************************************************************
* frect-test.cpp - finalcut::FRect unit tests * * frect-test.cpp - FRect unit tests *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *

View File

@ -1,5 +1,5 @@
/*********************************************************************** /***********************************************************************
* fstring-test.cpp - finalcut::FString unit tests * * fstring-test.cpp - FString unit tests *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *

View File

@ -1,5 +1,5 @@
/*********************************************************************** /***********************************************************************
* ftermcapquirks-test.cpp - finalcut::FTermcapQuirks unit tests * * ftermcapquirks-test.cpp - FTermcapQuirks unit tests *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *

View File

@ -1,5 +1,5 @@
/*********************************************************************** /***********************************************************************
* ftermdetection-test.cpp - finalcut::FTermDetection unit tests * * ftermdetection-test.cpp - FTermDetection unit tests *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
@ -2198,7 +2198,8 @@ pid_t FTermDetectionTest::forkProcess()
// Wait until the child process is ready for input // Wait until the child process is ready for input
while ( ! *shared_state && i < timeout ) while ( ! *shared_state && i < timeout )
{ {
usleep(10000); // wait 10 ms // Wait 10 ms (= 10,000,000 ns)
nanosleep ((const struct timespec[]){{0, 10000000L}}, NULL);
i++; i++;
} }