The command line help text is now available in all applications

This commit is contained in:
Markus Gans 2017-09-19 06:18:03 +02:00
parent 82f1b7e44c
commit fc113795b4
32 changed files with 358 additions and 319 deletions

View File

@ -1,3 +1,6 @@
2017-09-19 Markus Gans <guru.mail@muenster.de>
* The command line help text is now available in all applications
2017-09-17 Markus Gans <guru.mail@muenster.de> 2017-09-17 Markus Gans <guru.mail@muenster.de>
* FObject has received the iterator child access methods * FObject has received the iterator child access methods
begin() and end() begin() and end()

View File

@ -1014,7 +1014,10 @@ int main (int argc, char* argv[])
// Create a calculator object // Create a calculator object
Calc calculator(&app); Calc calculator(&app);
// Set calculator object as main widget
app.setMainWidget(&calculator); app.setMainWidget(&calculator);
// Show and start the application
calculator.show(); calculator.show();
return app.exec(); return app.exec();
} }

View File

@ -32,7 +32,7 @@ int main (int argc, char* argv[])
// Create the application object // Create the application object
FApplication app(argc, argv); FApplication app(argc, argv);
// Create a simple dialog box // Create a simple modal dialog box
FDialog* dgl = new FDialog(&app); FDialog* dgl = new FDialog(&app);
dgl->setModal(); dgl->setModal();
dgl->setText ("UNIX select"); dgl->setText ("UNIX select");

View File

@ -58,7 +58,10 @@ int main (int argc, char* argv[])
&app &app
); );
// Set dialog object as main widget
app.setMainWidget(&dgl); app.setMainWidget(&dgl);
// Show and start the application
dgl.show(); dgl.show();
return app.exec(); return app.exec();
} }

View File

@ -12,5 +12,7 @@ int main (int argc, char* argv[])
// Create a simple dialog box // Create a simple dialog box
FMessageBox mbox(&app); FMessageBox mbox(&app);
mbox.setText("Hello world"); mbox.setText("Hello world");
// Start the application
mbox.exec(); mbox.exec();
} }

View File

@ -113,7 +113,10 @@ int main (int argc, char* argv[])
&app &app
); );
// Set dialog object as main widget
app.setMainWidget(&dgl); app.setMainWidget(&dgl);
// Show and start the application
dgl.show(); dgl.show();
return app.exec(); return app.exec();
} }

View File

@ -70,12 +70,19 @@ void keyboard::draw()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int main (int argc, char* argv[]) int main (int argc, char* argv[])
{ {
// Create the application object
FApplication app(argc, argv); FApplication app(argc, argv);
app.setForegroundColor(fc::Default); app.setForegroundColor(fc::Default);
app.setBackgroundColor(fc::Default); app.setBackgroundColor(fc::Default);
// Create a keyboard object
keyboard key(&app); keyboard key(&app);
key.addAccelerator('q'); key.addAccelerator('q');
// Set the keyboard object as main widget
app.setMainWidget(&key); app.setMainWidget(&key);
// Show and start the application
key.show(); key.show();
return app.exec(); return app.exec();
} }

View File

@ -169,24 +169,19 @@ void Listbox::cb_exitApp (FWidget*, data_ptr)
int main (int argc, char* argv[]) int main (int argc, char* argv[])
{ {
if ( argv[1] && ( std::strcmp(argv[1], "--help") == 0 // Create the application object
|| std::strcmp(argv[1], "-h") == 0 ) )
{
std::cout << "Generic options:" << std::endl
<< " -h, --help "
<< "Display this help and exit" << std::endl;
FApplication::print_cmd_Options();
std::exit(EXIT_SUCCESS);
}
FApplication app(argc, argv); FApplication app(argc, argv);
// Create main dialog object
Listbox d(&app); Listbox d(&app);
d.setText (L"Listbox"); d.setText (L"Listbox");
d.setGeometry (int(1 + (app.getWidth() - 56) / 2), 5, 56, 16); d.setGeometry (int(1 + (app.getWidth() - 56) / 2), 5, 56, 16);
d.setShadow(); d.setShadow();
// Set dialog d as main widget
app.setMainWidget(&d); app.setMainWidget(&d);
// Show and start the application
d.show(); d.show();
return app.exec(); return app.exec();
} }

View File

@ -178,24 +178,19 @@ void Listview::cb_showInMessagebox (FWidget* widget, data_ptr)
int main (int argc, char* argv[]) int main (int argc, char* argv[])
{ {
if ( argv[1] && ( std::strcmp(argv[1], "--help") == 0 // Create the application object
|| std::strcmp(argv[1], "-h") == 0 ) )
{
std::cout << "Generic options:" << std::endl
<< " -h, --help "
<< "Display this help and exit" << std::endl;
FApplication::print_cmd_Options();
std::exit(EXIT_SUCCESS);
}
FApplication app(argc, argv); FApplication app(argc, argv);
// Create main dialog object
Listview d(&app); Listview d(&app);
d.setText (L"Weather data"); d.setText (L"Weather data");
d.setGeometry (int(1 + (app.getWidth() - 37) / 2), 3, 37, 20); d.setGeometry (int(1 + (app.getWidth() - 37) / 2), 3, 37, 20);
d.setShadow(); d.setShadow();
// Set dialog d as main widget
app.setMainWidget(&d); app.setMainWidget(&d);
// Show and start the application
d.show(); d.show();
return app.exec(); return app.exec();
} }

View File

@ -141,7 +141,10 @@ int main (int argc, char* argv[])
mb.addAccelerator('q'); // press 'q' to quit mb.addAccelerator('q'); // press 'q' to quit
mb.setShadow(); mb.setShadow();
// Set the mandelbrot object as main widget
app.setMainWidget(&mb); app.setMainWidget(&mb);
// Show and start the application
mb.show(); mb.show();
return app.exec(); return app.exec();
} }

View File

@ -279,24 +279,19 @@ void Menu::cb_exitApp (FWidget*, data_ptr)
int main (int argc, char* argv[]) int main (int argc, char* argv[])
{ {
if ( argv[1] && ( std::strcmp(argv[1], "--help") == 0 // Create the application object
|| std::strcmp(argv[1], "-h") == 0 ) )
{
std::cout << "Generic options:" << std::endl
<< " -h, --help "
<< "Display this help and exit" << std::endl;
FApplication::print_cmd_Options();
std::exit(EXIT_SUCCESS);
}
FApplication app (argc, argv); FApplication app (argc, argv);
// Create main dialog object
Menu main_dlg (&app); Menu main_dlg (&app);
main_dlg.setText ("Menu example"); main_dlg.setText ("Menu example");
main_dlg.setGeometry (int(1 + (app.getWidth() - 40) / 2), 2, 40, 6); main_dlg.setGeometry (int(1 + (app.getWidth() - 40) / 2), 2, 40, 6);
main_dlg.setShadow(); main_dlg.setShadow();
// Set dialog main_dlg as main widget
app.setMainWidget (&main_dlg); app.setMainWidget (&main_dlg);
// Show and start the application
main_dlg.show(); main_dlg.show();
return app.exec(); return app.exec();
} }

View File

@ -532,7 +532,10 @@ int main (int argc, char* argv[])
mouse_draw.setGeometry (12, 4, 60, 18); mouse_draw.setGeometry (12, 4, 60, 18);
mouse_draw.addAccelerator('q'); // press 'q' to quit mouse_draw.addAccelerator('q'); // press 'q' to quit
// Set dialog object mouse_draw as main widget
app.setMainWidget(&mouse_draw); app.setMainWidget(&mouse_draw);
// Show and start the application
mouse_draw.show(); mouse_draw.show();
return app.exec(); return app.exec();
} }

View File

@ -132,20 +132,28 @@ int main (int argc, char* argv[])
{ {
int xmax, ymax; int xmax, ymax;
// Create the application object
FApplication app(argc, argv); FApplication app(argc, argv);
// Create a FVTerm object as virtual terminal
terminal = new FVTerm(&app); terminal = new FVTerm(&app);
xmax = terminal->getColumnNumber() - 1; xmax = terminal->getColumnNumber() - 1;
ymax = terminal->getLineNumber() - 1; ymax = terminal->getLineNumber() - 1;
FString line(xmax + 1, '-'); FString line(xmax + 1, '-');
// Place the cursor in the upper left corner
terminal->setTermXY(0,0); terminal->setTermXY(0,0);
// Reset all terminal attributes
terminal->setNormal(); terminal->setNormal();
// Clear the screen
terminal->clearArea(); terminal->clearArea();
// Show the determined terminal name and text resolution
std::cout << "Terminal: " << terminal->getTermType() << "\r\n"; std::cout << "Terminal: " << terminal->getTermType() << "\r\n";
std::cout << " Columns: 0.." << xmax << "\r\n"; std::cout << " Columns: 0.." << xmax << "\r\n";
std::cout << " Lines: 0.." << ymax << "\r\n"; std::cout << " Lines: 0.." << ymax << "\r\n";
// Show the escape sequences for the following cursor movements
std::cout << std::setw(38) << "Cursor move\r\n"; std::cout << std::setw(38) << "Cursor move\r\n";
std::cout << " (From) -> (To) "; std::cout << " (From) -> (To) ";
std::cout << "escape sequence "; std::cout << "escape sequence ";
@ -169,10 +177,13 @@ int main (int argc, char* argv[])
move (3, 2, xmax, 2); move (3, 2, xmax, 2);
move (5, 5, xmax - 5, ymax - 5); move (5, 5, xmax - 5, ymax - 5);
// Waiting for keypress
keyPressed(); keyPressed();
// Show terminal speed and milliseconds for all cursor movement sequence
std::cout << "\r" << line; std::cout << "\r" << line;
terminal->printMoveDurations(); terminal->printMoveDurations();
// Waiting for keypress
keyPressed(); keyPressed();
} }

View File

@ -57,6 +57,7 @@ scrollview::scrollview (FWidget* parent)
, go_west() , go_west()
, go_north() , go_north()
{ {
// Create the four navigation buttons
go_east = new FButton(wchar_t(fc::BlackRightPointingPointer) , this); go_east = new FButton(wchar_t(fc::BlackRightPointingPointer) , this);
go_east->setGeometry (1, 1, 5, 1); go_east->setGeometry (1, 1, 5, 1);
@ -69,6 +70,7 @@ scrollview::scrollview (FWidget* parent)
go_north = new FButton(wchar_t(fc::BlackUpPointingTriangle) , this); go_north = new FButton(wchar_t(fc::BlackUpPointingTriangle) , this);
go_north->setGeometry (1, getScrollHeight() - 2, 5, 1); go_north->setGeometry (1, getScrollHeight() - 2, 5, 1);
// Add scroll function callbacks to the buttons
go_east->addCallback go_east->addCallback
( (
"clicked", "clicked",
@ -259,7 +261,10 @@ int main (int argc, char* argv[])
// Create a simple dialog box // Create a simple dialog box
scrollviewdemo svdemo(&app); scrollviewdemo svdemo(&app);
// Set dialog main_dlg as main widget
app.setMainWidget(&svdemo); app.setMainWidget(&svdemo);
// Show and start the application
svdemo.show(); svdemo.show();
return app.exec(); return app.exec();
} }

View File

@ -47,11 +47,11 @@ int main (int, char**)
std::cout << " cpp_str: \"" << cpp_str << "\"" << std::endl; std::cout << " cpp_str: \"" << cpp_str << "\"" << std::endl;
// Test: copy a character // Test: copy a character
const FString& ch('c'); const FString ch('c');
std::cout << " char: '" << ch << "'" << std::endl; std::cout << " char: '" << ch << "'" << std::endl;
// Test: copy a wide character // Test: copy a wide character
const FString& wch(L'w'); const FString wch(L'w');
std::cout << " wchar_t: '" << wch << "'" << std::endl; std::cout << " wchar_t: '" << wch << "'" << std::endl;
// Test: utf-8 string // Test: utf-8 string

View File

@ -400,11 +400,14 @@ int main (int argc, char* argv[])
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
AttribDemo* demo = new AttribDemo(dialog); AttribDemo* demo = new AttribDemo(dialog);
demo->setGeometry (1, 1, 67, 19); demo->setGeometry (1, 1, 67, 19);
// Set the dialog object as main widget
app.setMainWidget(dialog); app.setMainWidget(dialog);
dialog->show();
// Show and start the application
dialog->show();
return app.exec(); return app.exec();
} }

View File

@ -78,12 +78,19 @@ void timer::onAccel (FAccelEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int main (int argc, char* argv[]) int main (int argc, char* argv[])
{ {
// Create the application object
FApplication app(argc, argv); FApplication app(argc, argv);
app.setForegroundColor(fc::Default); app.setForegroundColor(fc::Default);
app.setBackgroundColor(fc::Default); app.setBackgroundColor(fc::Default);
// Create a timer object t
timer t(&app); timer t(&app);
t.addAccelerator('q'); t.addAccelerator('q');
// Set the timer object t as main widget
app.setMainWidget(&t); app.setMainWidget(&t);
// Show and start the application
t.show(); t.show();
return app.exec(); return app.exec();
} }

View File

@ -268,24 +268,18 @@ void MainWindow::onTimer (FTimerEvent*)
int main (int argc, char* argv[]) int main (int argc, char* argv[])
{ {
if ( argv[1] && ( std::strcmp(argv[1], "--help") == 0 // Create the application object
|| std::strcmp(argv[1], "-h") == 0 ) )
{
std::cout << "Generic options:" << std::endl
<< " -h, --help "
<< "Display this help and exit" << std::endl;
FApplication::print_cmd_Options();
std::exit(EXIT_SUCCESS);
}
FApplication app (argc, argv); FApplication app (argc, argv);
// Create main dialog object
MainWindow main_dlg (&app); MainWindow main_dlg (&app);
main_dlg.setText ("non-transparent"); main_dlg.setText ("non-transparent");
main_dlg.setGeometry (8, 16, 26, 7); main_dlg.setGeometry (8, 16, 26, 7);
// Set dialog main_dlg as main widget
app.setMainWidget (&main_dlg); app.setMainWidget (&main_dlg);
main_dlg.show();
// Show and start the application
main_dlg.show();
return app.exec(); return app.exec();
} }

View File

@ -91,6 +91,7 @@ Treeview::Treeview (FWidget* parent)
FObjectIterator iter_egypt = item_africa->begin(); FObjectIterator iter_egypt = item_africa->begin();
FListViewItem* item_egypt = static_cast<FListViewItem*>(*iter_egypt); FListViewItem* item_egypt = static_cast<FListViewItem*>(*iter_egypt);
item_egypt = item_egypt; item_egypt = item_egypt;
item_africa->expand();
// Quit button // Quit button
FButton* Quit = new FButton (this); FButton* Quit = new FButton (this);
@ -135,24 +136,19 @@ void Treeview::cb_exitApp (FWidget*, data_ptr)
int main (int argc, char* argv[]) int main (int argc, char* argv[])
{ {
if ( argv[1] && ( std::strcmp(argv[1], "--help") == 0 // Create the application object
|| std::strcmp(argv[1], "-h") == 0 ) )
{
std::cout << "Generic options:" << std::endl
<< " -h, --help "
<< "Display this help and exit" << std::endl;
FApplication::print_cmd_Options();
std::exit(EXIT_SUCCESS);
}
FApplication app(argc, argv); FApplication app(argc, argv);
// Create main dialog object
Treeview d(&app); Treeview d(&app);
d.setText (L"Continents"); d.setText (L"Continents");
d.setGeometry (int(1 + (app.getWidth() - 37) / 2), 3, 37, 20); d.setGeometry (int(1 + (app.getWidth() - 37) / 2), 3, 37, 20);
d.setShadow(); d.setShadow();
// Set dialog d as main widget
app.setMainWidget(&d); app.setMainWidget(&d);
// Show and start the application
d.show(); d.show();
return app.exec(); return app.exec();
} }

View File

@ -911,16 +911,7 @@ int main (int argc, char* argv[])
FString ver = F_VERSION; // library version FString ver = F_VERSION; // library version
FString title = "The FINAL CUT " + ver + " (C) 2017 by Markus Gans"; FString title = "The FINAL CUT " + ver + " (C) 2017 by Markus Gans";
if ( argv[1] && ( std::strcmp(argv[1], "--help") == 0 // Create the application object app
|| std::strcmp(argv[1], "-h") == 0 ) )
{
std::cout << "Generic options:" << std::endl
<< " -h, --help "
<< "Display this help and exit" << std::endl;
FApplication::print_cmd_Options();
std::exit(EXIT_SUCCESS);
}
FApplication app(argc, argv); FApplication app(argc, argv);
app.setXTermDefaultColors(true); app.setXTermDefaultColors(true);
app.setXTermTitle (title); app.setXTermTitle (title);
@ -929,12 +920,20 @@ int main (int argc, char* argv[])
//app.setTermSize(94,30); //app.setTermSize(94,30);
//app.setNewFont(); //app.setNewFont();
// Create main dialog object d
MyDialog d(&app); MyDialog d(&app);
d.setText (title); d.setText (title);
d.setGeometry (int((app.getWidth() - 56) / 2), 2, 56, app.getHeight() - 4); d.setGeometry (int((app.getWidth() - 56) / 2), 2, 56, app.getHeight() - 4);
d.setShadow(); d.setShadow();
// Set the dialog object d as the main widget of the application.
// When you close the main widget, the application will be closed.
app.setMainWidget(&d); app.setMainWidget(&d);
// Show the dialog d
d.show(); d.show();
// Start the application
// and return the result to the operating system
return app.exec(); return app.exec();
} }

View File

@ -215,7 +215,10 @@ int main (int argc, char* argv[])
// Create a simple dialog box // Create a simple dialog box
watch w(&app); watch w(&app);
// Set dialog w as main widget
app.setMainWidget(&w); app.setMainWidget(&w);
// Show and start the application
w.show(); w.show();
return app.exec(); return app.exec();
} }

View File

@ -567,24 +567,18 @@ void Window::cb_destroyWindow (FWidget*, data_ptr data)
int main (int argc, char* argv[]) int main (int argc, char* argv[])
{ {
if ( argv[1] && ( std::strcmp(argv[1], "--help") == 0 // Create the application object
|| std::strcmp(argv[1], "-h") == 0 ) )
{
std::cout << "Generic options:" << std::endl
<< " -h, --help "
<< "Display this help and exit" << std::endl;
FApplication::print_cmd_Options();
std::exit(EXIT_SUCCESS);
}
FApplication app (argc, argv); FApplication app (argc, argv);
// Create main dialog object
Window main_dlg (&app); Window main_dlg (&app);
main_dlg.setText ("Main window"); main_dlg.setText ("Main window");
main_dlg.setGeometry (int(1 + (app.getWidth() - 40) / 2), 2, 40, 6); main_dlg.setGeometry (int(1 + (app.getWidth() - 40) / 2), 2, 40, 6);
// Set dialog main_dlg as main widget
app.setMainWidget (&main_dlg); app.setMainWidget (&main_dlg);
main_dlg.show();
// Show and start the application
main_dlg.show();
return app.exec(); return app.exec();
} }

View File

@ -85,8 +85,8 @@ class FApplication : public FWidget
static void queueEvent (const FObject*, const FEvent*); static void queueEvent (const FObject*, const FEvent*);
static void sendQueuedEvents (); static void sendQueuedEvents ();
static bool eventInQueue(); static bool eventInQueue();
static bool removeQueuedEvent(const FObject*); static bool removeQueuedEvent (const FObject*);
static void print_cmd_Options(); static FWidget* showParameterUsage (const int&, char*[]);
private: private:
// Typedefs and Enumerations // Typedefs and Enumerations

View File

@ -30,6 +30,7 @@
#ifndef FLISTVIEW_H #ifndef FLISTVIEW_H
#define FLISTVIEW_H #define FLISTVIEW_H
#include <stack>
#include <vector> #include <vector>
#include "final/fscrollbar.h" #include "final/fscrollbar.h"
@ -52,8 +53,6 @@ class FListViewItem : public FObject
public: public:
// Constructor // Constructor
FListViewItem (const FListViewItem&); // copy constructor FListViewItem (const FListViewItem&); // copy constructor
explicit FListViewItem (FListViewItem*);
explicit FListViewItem (FListView*);
explicit FListViewItem (FObjectIterator); explicit FListViewItem (FObjectIterator);
FListViewItem ( const std::vector<FString>& FListViewItem ( const std::vector<FString>&
, FWidget::data_ptr , FWidget::data_ptr
@ -69,6 +68,7 @@ class FListViewItem : public FObject
const char* getClassName() const; const char* getClassName() const;
uInt getColumnCount() const; uInt getColumnCount() const;
FString getText (int) const; FString getText (int) const;
uInt getDepth() const;
// Mutator // Mutator
void setText (int, const FString&); void setText (int, const FString&);
@ -215,6 +215,7 @@ class FListView : public FWidget
}; };
typedef std::vector<Header> headerItems; typedef std::vector<Header> headerItems;
typedef std::stack<FObjectIterator> FObjectIteratorStack;
// Constants // Constants
static const int USE_MAX_SIZE = -1; static const int USE_MAX_SIZE = -1;
@ -248,6 +249,7 @@ class FListView : public FWidget
FObjectIterator root; FObjectIterator root;
FObjectList selflist; FObjectList selflist;
FObjectList itemlist; FObjectList itemlist;
FObjectIteratorStack iter_path;
headerItems header; headerItems header;
FTermBuffer headerline; FTermBuffer headerline;
FScrollbar* vbar; FScrollbar* vbar;
@ -345,13 +347,27 @@ inline void FListView::nextElement (FObjectIterator& iter)
{ {
FListViewItem* item = static_cast<FListViewItem*>(*iter); FListViewItem* item = static_cast<FListViewItem*>(*iter);
if ( item->isExpandable() ) if ( item->isExpandable() && item->isExpand() )
{ {
//iter = item->begin(); iter_path.push(iter);
++iter; iter = item->begin();
} }
else else
{
++iter; ++iter;
if ( ! iter_path.empty() )
{
FObjectIterator& parent_iter = iter_path.top();
if ( iter == (*parent_iter)->end() )
{
iter = parent_iter;
iter_path.pop();
++iter;
}
}
}
} }
#endif // FLISTVIEW_H #endif // FLISTVIEW_H

View File

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

View File

@ -38,7 +38,7 @@ FApplication::eventQueue* FApplication::event_queue = 0;
FApplication::FApplication ( const int& _argc FApplication::FApplication ( const int& _argc
, char* _argv[] , char* _argv[]
, bool disable_alt_screen ) , bool disable_alt_screen )
: FWidget(0, disable_alt_screen) : FWidget(showParameterUsage(_argc,_argv), disable_alt_screen)
, app_argc(_argc) , app_argc(_argc)
, app_argv(_argv) , app_argv(_argv)
, key(0) , key(0)
@ -290,14 +290,31 @@ bool FApplication::removeQueuedEvent (const FObject* receiver)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::print_cmd_Options () FWidget* FApplication::showParameterUsage (const int& argc, char* argv[])
{ {
std::printf ( "\nFinalCut Options:\n" if ( argc > 0 && argv[1] && ( std::strcmp(argv[1], "--help") == 0
" --encoding <name> Sets the character encoding mode\n" || std::strcmp(argv[1], "-h") == 0 ) )
" {UTF8, VT100, PC, ASCII}\n" {
" --no-optimized-cursor No cursor optimisation\n" std::cout \
" --vgafont Set the standard vga 8x16 font\n" << "Generic options:" << std::endl
" --newfont Enables the graphical font\n" ); << " -h, --help "
<< " Display this help and exit" << std::endl
<< std::endl
<< "FinalCut Options:" << std::endl
<< " --encoding <name> "
<< " Sets the character encoding mode" << std::endl
<< " "
<< " {UTF8, VT100, PC, ASCII}" << std::endl
<< " --no-optimized-cursor"
<< " No cursor optimisation" << std::endl
<< " --vgafont "
<< " Set the standard vga 8x16 font" << std::endl
<< " --newfont "
<< " Enables the graphical font" << std::endl;
std::exit(EXIT_SUCCESS);
}
return 0;
} }
@ -335,6 +352,7 @@ void FApplication::init()
std::fill_n (urxvt_mouse, sizeof(urxvt_mouse), '\0'); std::fill_n (urxvt_mouse, sizeof(urxvt_mouse), '\0');
// init bit field with 0 // init bit field with 0
std::memset(&b_state, 0x00, sizeof(b_state)); std::memset(&b_state, 0x00, sizeof(b_state));
// interpret the command line options // interpret the command line options
cmd_options(); cmd_options();
} }

View File

@ -40,8 +40,6 @@ void FCheckMenuItem::init (FWidget* parent)
if ( isMenu(parent) ) // Parent is menu if ( isMenu(parent) ) // Parent is menu
{ {
FMenu* menu_ptr = static_cast<FMenu*>(parent); FMenu* menu_ptr = static_cast<FMenu*>(parent);
if ( menu_ptr )
menu_ptr->has_checkable_items = true; menu_ptr->has_checkable_items = true;
} }
} }

View File

@ -241,7 +241,6 @@ int FFileDialog::readDir()
int start, dir_num; int start, dir_num;
const char* const dir = directory.c_str(); const char* const dir = directory.c_str();
const char* const filter = filter_pattern.c_str(); const char* const filter = filter_pattern.c_str();
errno = 0;
directory_stream = opendir(dir); directory_stream = opendir(dir);
if ( ! directory_stream ) if ( ! directory_stream )
@ -254,37 +253,40 @@ int FFileDialog::readDir()
while ( true ) while ( true )
{ {
errno = 0; int retval;
struct dirent* next = readdir (directory_stream); struct dirent next;
struct dirent* result;
if ( next ) retval = readdir_r(directory_stream, &next, &result);
if ( result && retval == 0 )
{ {
if ( next->d_name[0] == '.' && next->d_name[1] == '\0' ) if ( next.d_name[0] == '.' && next.d_name[1] == '\0' )
continue; continue;
if ( ! show_hidden if ( ! show_hidden
&& next->d_name[0] == '.' && next.d_name[0] == '.'
&& next->d_name[1] != '\0' && next.d_name[1] != '\0'
&& next->d_name[1] != '.' ) && next.d_name[1] != '.' )
{ {
continue; continue;
} }
if ( dir[0] == '/' && dir[1] == '\0' if ( dir[0] == '/' && dir[1] == '\0'
&& std::strcmp(next->d_name, "..") == 0 ) && std::strcmp(next.d_name, "..") == 0 )
continue; continue;
dir_entry entry; dir_entry entry;
entry.name = strdup(next->d_name); entry.name = strdup(next.d_name);
entry.type = next->d_type; entry.type = next.d_type;
if ( next->d_type == DT_LNK ) // symbolic link if ( next.d_type == DT_LNK ) // symbolic link
{ {
char resolved_path[MAXPATHLEN] = {}; char resolved_path[MAXPATHLEN] = {};
char symLink[MAXPATHLEN] = {}; char symLink[MAXPATHLEN] = {};
std::strncpy (symLink, dir, sizeof(symLink) - 1); std::strncpy (symLink, dir, sizeof(symLink) - 1);
std::strncat ( symLink std::strncat ( symLink
, next->d_name , next.d_name
, sizeof(symLink) - std::strlen(symLink) - 1); , sizeof(symLink) - std::strlen(symLink) - 1);
if ( realpath(symLink, resolved_path) != 0 ) // follow link if ( realpath(symLink, resolved_path) != 0 ) // follow link
@ -306,11 +308,11 @@ int FFileDialog::readDir()
else else
std::free(entry.name); std::free(entry.name);
} }
else if (errno != 0) else if ( retval > 0 )
{ {
FMessageBox::error (this, "Reading directory\n" + directory); FMessageBox::error (this, "Reading directory\n" + directory);
if ( errno != EOVERFLOW ) if ( retval == EBADF ) // Invalid directory stream descriptor
break; break;
} }
else else

View File

@ -87,6 +87,20 @@ FString FListViewItem::getText (int column) const
return column_list[uInt(column)]; return column_list[uInt(column)];
} }
//----------------------------------------------------------------------
uInt FListViewItem::getDepth() const
{
FObject* parent = getParent();
if ( parent && parent->isInstanceOf("FListViewItem") )
{
FListViewItem* parent_item = static_cast<FListViewItem*>(parent);
return parent_item->getDepth() + 1;
}
return 0;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListViewItem::setText (int column, const FString& text) void FListViewItem::setText (int column, const FString& text)
{ {
@ -226,6 +240,7 @@ FListView::FListView (FWidget* parent)
, root() , root()
, selflist() , selflist()
, itemlist() , itemlist()
, iter_path()
, header() , header()
, headerline() , headerline()
, vbar(0) , vbar(0)
@ -408,6 +423,8 @@ FObject::FObjectIterator FListView::insert ( FListViewItem* item
item_iter = parent->appendItem (item); item_iter = parent->appendItem (item);
} }
} }
else
item_iter = FObjectIterator(0);
int element_count = int(getCount()); int element_count = int(getCount());
recalculateVerticalBar (element_count); recalculateVerticalBar (element_count);
@ -1294,6 +1311,8 @@ void FListView::drawListLine ( const FListViewItem* item
, bool is_focus , bool is_focus
, bool is_current ) , bool is_current )
{ {
uInt indent = item->getDepth() << 1; // indent = 2 * depth
setColor (wc.list_fg, wc.list_bg); setColor (wc.list_fg, wc.list_bg);
if ( is_current ) if ( is_current )
@ -1329,13 +1348,24 @@ void FListView::drawListLine ( const FListViewItem* item
if ( tree_view ) if ( tree_view )
{ {
if ( indent > 0 )
line = FString(indent, L' ');
if ( item->expandable ) if ( item->expandable )
{ {
line = wchar_t(fc::BlackRightPointingPointer); if (item->is_expand )
{
line += wchar_t(fc::BlackDownPointingTriangle); // ▼
line += L' '; line += L' ';
} }
else else
line = L" "; {
line += wchar_t(fc::BlackRightPointingPointer); // ►
line += L' ';
}
}
else
line += L" ";
} }
else else
line = L" "; line = L" ";
@ -1359,6 +1389,7 @@ void FListView::drawListLine ( const FListViewItem* item
if ( tree_view && i == 1 ) if ( tree_view && i == 1 )
{ {
width -= indent;
width--; width--;
} }

View File

@ -797,15 +797,11 @@ void FMenu::init(FWidget* parent)
if ( isMenuBar(parent) ) if ( isMenuBar(parent) )
{ {
FMenuBar* mbar = static_cast<FMenuBar*>(parent); FMenuBar* mbar = static_cast<FMenuBar*>(parent);
if ( mbar )
mbar->calculateDimensions(); mbar->calculateDimensions();
} }
else if ( isMenu(parent) ) else if ( isMenu(parent) )
{ {
FMenu* smenu = static_cast<FMenu*>(parent); FMenu* smenu = static_cast<FMenu*>(parent);
if ( smenu )
smenu->calculateDimensions(); smenu->calculateDimensions();
} }

View File

@ -299,8 +299,6 @@ void FMenuItem::onKeyPress (FKeyEvent* ev)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
FMenu* smenu = static_cast<FMenu*>(super_menu); FMenu* smenu = static_cast<FMenu*>(super_menu);
if ( smenu )
smenu->onKeyPress(ev); smenu->onKeyPress(ev);
} }
@ -330,9 +328,6 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
FMenu* smenu = static_cast<FMenu*>(super_menu); FMenu* smenu = static_cast<FMenu*>(super_menu);
if ( smenu )
{
const FPoint& p2 = smenu->termToWidgetPos(t); const FPoint& p2 = smenu->termToWidgetPos(t);
try try
@ -348,7 +343,6 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
<< ex.what() << std::endl; << ex.what() << std::endl;
} }
} }
}
if ( isMenuBar(super_menu) ) if ( isMenuBar(super_menu) )
{ {
@ -409,9 +403,6 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
FMenu* smenu = static_cast<FMenu*>(super_menu); FMenu* smenu = static_cast<FMenu*>(super_menu);
if ( smenu )
{
const FPoint& p2 = smenu->termToWidgetPos(t); const FPoint& p2 = smenu->termToWidgetPos(t);
try try
@ -427,7 +418,6 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
<< ex.what() << std::endl; << ex.what() << std::endl;
} }
} }
}
if ( isMenuBar(super_menu) ) if ( isMenuBar(super_menu) )
{ {
@ -488,41 +478,29 @@ void FMenuItem::onMouseUp (FMouseEvent* ev)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
FMenu* smenu = static_cast<FMenu*>(super_menu); FMenu* smenu = static_cast<FMenu*>(super_menu);
if ( smenu )
{
const FPoint& p2 = smenu->termToWidgetPos(t); const FPoint& p2 = smenu->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseUp_Event, p2, t, b); FMouseEvent* _ev = new FMouseEvent (fc::MouseUp_Event, p2, t, b);
smenu->onMouseUp(_ev); smenu->onMouseUp(_ev);
delete _ev; delete _ev;
} }
}
if ( isMenuBar(super_menu) ) if ( isMenuBar(super_menu) )
{ {
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu); FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( mbar )
{
const FPoint& p2 = mbar->termToWidgetPos(t); const FPoint& p2 = mbar->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseUp_Event, p2, t, b); FMouseEvent* _ev = new FMouseEvent (fc::MouseUp_Event, p2, t, b);
mbar->onMouseUp(_ev); mbar->onMouseUp(_ev);
delete _ev; delete _ev;
} }
}
if ( isWindowsMenu(super_menu) ) if ( isWindowsMenu(super_menu) )
{ {
FDialog* dgl = static_cast<FDialog*>(super_menu); FDialog* dgl = static_cast<FDialog*>(super_menu);
if ( dgl )
{
const FPoint& p2 = dgl->termToWidgetPos(t); const FPoint& p2 = dgl->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseUp_Event, p2, t, b); FMouseEvent* _ev = new FMouseEvent (fc::MouseUp_Event, p2, t, b);
dgl->onMouseUp(_ev); dgl->onMouseUp(_ev);
delete _ev; delete _ev;
} }
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -537,41 +515,29 @@ void FMenuItem::onMouseMove (FMouseEvent* ev)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
FMenu* smenu = static_cast<FMenu*>(super_menu); FMenu* smenu = static_cast<FMenu*>(super_menu);
if ( smenu )
{
const FPoint& p2 = smenu->termToWidgetPos(t); const FPoint& p2 = smenu->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p2, t, b); FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p2, t, b);
smenu->onMouseMove(_ev); smenu->onMouseMove(_ev);
delete _ev; delete _ev;
} }
}
if ( isMenuBar(super_menu) ) if ( isMenuBar(super_menu) )
{ {
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu); FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( mbar )
{
const FPoint& p2 = mbar->termToWidgetPos(t); const FPoint& p2 = mbar->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p2, t, b); FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p2, t, b);
mbar->onMouseMove(_ev); mbar->onMouseMove(_ev);
delete _ev; delete _ev;
} }
}
if ( isWindowsMenu(super_menu) ) if ( isWindowsMenu(super_menu) )
{ {
FDialog* dgl = static_cast<FDialog*>(super_menu); FDialog* dgl = static_cast<FDialog*>(super_menu);
if ( dgl )
{
const FPoint& p2 = dgl->termToWidgetPos(t); const FPoint& p2 = dgl->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p2, t, b); FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p2, t, b);
dgl->onMouseMove(_ev); dgl->onMouseMove(_ev);
delete _ev; delete _ev;
} }
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -588,9 +554,6 @@ void FMenuItem::onAccel (FAccelEvent* ev)
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu); FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( ! mbar )
return;
if ( menu ) if ( menu )
{ {
FWidget* focused_widget; FWidget* focused_widget;
@ -635,6 +598,7 @@ void FMenuItem::onAccel (FAccelEvent* ev)
processClicked(); processClicked();
mbar->drop_down = false; mbar->drop_down = false;
} }
ev->accept(); ev->accept();
} }
@ -653,8 +617,6 @@ void FMenuItem::onFocusOut (FFocusEvent*)
if ( super_menu && isMenuBar(super_menu) ) if ( super_menu && isMenuBar(super_menu) )
{ {
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu); FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( mbar )
mbar->redraw(); mbar->redraw();
} }
@ -703,8 +665,9 @@ void FMenuItem::init (FWidget* parent)
setGeometry (1, 1, int(text_length + 2), 1, false); setGeometry (1, 1, int(text_length + 2), 1, false);
if ( parent ) if ( ! parent )
{ return;
FMenuList* menu_list; FMenuList* menu_list;
setSuperMenu (parent); setSuperMenu (parent);
@ -719,15 +682,11 @@ void FMenuItem::init (FWidget* parent)
if ( isMenuBar(parent) ) // Parent is menubar if ( isMenuBar(parent) ) // Parent is menubar
{ {
FMenuBar* menubar_ptr = static_cast<FMenuBar*>(parent); FMenuBar* menubar_ptr = static_cast<FMenuBar*>(parent);
if ( menubar_ptr )
{
menubar_ptr->calculateDimensions(); menubar_ptr->calculateDimensions();
if ( hotkey ) // Meta + hotkey if ( hotkey ) // Meta + hotkey
menubar_ptr->addAccelerator ( fc::Fmkey_meta + std::tolower(hotkey) menubar_ptr->addAccelerator ( fc::Fmkey_meta + std::tolower(hotkey)
, this ); , this );
}
addCallback // for this element addCallback // for this element
( (
@ -738,11 +697,8 @@ void FMenuItem::init (FWidget* parent)
else if ( isMenu(parent) ) // Parent is menu else if ( isMenu(parent) ) // Parent is menu
{ {
FMenu* menu_ptr = static_cast<FMenu*>(parent); FMenu* menu_ptr = static_cast<FMenu*>(parent);
if ( menu_ptr )
menu_ptr->calculateDimensions(); menu_ptr->calculateDimensions();
} }
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -41,8 +41,6 @@ void FRadioMenuItem::init (FWidget* parent)
if ( isMenu(parent) ) // Parent is menu if ( isMenu(parent) ) // Parent is menu
{ {
FMenu* menu_ptr = static_cast<FMenu*>(parent); FMenu* menu_ptr = static_cast<FMenu*>(parent);
if ( menu_ptr )
menu_ptr->has_checkable_items = true; menu_ptr->has_checkable_items = true;
addCallback // for this element addCallback // for this element