The command line help text is now available in all applications
This commit is contained in:
parent
82f1b7e44c
commit
fc113795b4
|
@ -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>
|
||||
* FObject has received the iterator child access methods
|
||||
begin() and end()
|
||||
|
|
|
@ -1014,7 +1014,10 @@ int main (int argc, char* argv[])
|
|||
// Create a calculator object
|
||||
Calc calculator(&app);
|
||||
|
||||
// Set calculator object as main widget
|
||||
app.setMainWidget(&calculator);
|
||||
|
||||
// Show and start the application
|
||||
calculator.show();
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ int main (int argc, char* argv[])
|
|||
// Create the application object
|
||||
FApplication app(argc, argv);
|
||||
|
||||
// Create a simple dialog box
|
||||
// Create a simple modal dialog box
|
||||
FDialog* dgl = new FDialog(&app);
|
||||
dgl->setModal();
|
||||
dgl->setText ("UNIX select");
|
||||
|
|
|
@ -58,7 +58,10 @@ int main (int argc, char* argv[])
|
|||
&app
|
||||
);
|
||||
|
||||
// Set dialog object as main widget
|
||||
app.setMainWidget(&dgl);
|
||||
|
||||
// Show and start the application
|
||||
dgl.show();
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -12,5 +12,7 @@ int main (int argc, char* argv[])
|
|||
// Create a simple dialog box
|
||||
FMessageBox mbox(&app);
|
||||
mbox.setText("Hello world");
|
||||
|
||||
// Start the application
|
||||
mbox.exec();
|
||||
}
|
||||
|
|
|
@ -113,7 +113,10 @@ int main (int argc, char* argv[])
|
|||
&app
|
||||
);
|
||||
|
||||
// Set dialog object as main widget
|
||||
app.setMainWidget(&dgl);
|
||||
|
||||
// Show and start the application
|
||||
dgl.show();
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -70,12 +70,19 @@ void keyboard::draw()
|
|||
//----------------------------------------------------------------------
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
// Create the application object
|
||||
FApplication app(argc, argv);
|
||||
app.setForegroundColor(fc::Default);
|
||||
app.setBackgroundColor(fc::Default);
|
||||
|
||||
// Create a keyboard object
|
||||
keyboard key(&app);
|
||||
key.addAccelerator('q');
|
||||
|
||||
// Set the keyboard object as main widget
|
||||
app.setMainWidget(&key);
|
||||
|
||||
// Show and start the application
|
||||
key.show();
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -169,24 +169,19 @@ void Listbox::cb_exitApp (FWidget*, data_ptr)
|
|||
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
if ( argv[1] && ( std::strcmp(argv[1], "--help") == 0
|
||||
|| 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);
|
||||
}
|
||||
|
||||
// Create the application object
|
||||
FApplication app(argc, argv);
|
||||
|
||||
// Create main dialog object
|
||||
Listbox d(&app);
|
||||
d.setText (L"Listbox");
|
||||
d.setGeometry (int(1 + (app.getWidth() - 56) / 2), 5, 56, 16);
|
||||
d.setShadow();
|
||||
|
||||
// Set dialog d as main widget
|
||||
app.setMainWidget(&d);
|
||||
|
||||
// Show and start the application
|
||||
d.show();
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -178,24 +178,19 @@ void Listview::cb_showInMessagebox (FWidget* widget, data_ptr)
|
|||
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
if ( argv[1] && ( std::strcmp(argv[1], "--help") == 0
|
||||
|| 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);
|
||||
}
|
||||
|
||||
// Create the application object
|
||||
FApplication app(argc, argv);
|
||||
|
||||
// Create main dialog object
|
||||
Listview d(&app);
|
||||
d.setText (L"Weather data");
|
||||
d.setGeometry (int(1 + (app.getWidth() - 37) / 2), 3, 37, 20);
|
||||
d.setShadow();
|
||||
|
||||
// Set dialog d as main widget
|
||||
app.setMainWidget(&d);
|
||||
|
||||
// Show and start the application
|
||||
d.show();
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -141,7 +141,10 @@ int main (int argc, char* argv[])
|
|||
mb.addAccelerator('q'); // press 'q' to quit
|
||||
mb.setShadow();
|
||||
|
||||
// Set the mandelbrot object as main widget
|
||||
app.setMainWidget(&mb);
|
||||
|
||||
// Show and start the application
|
||||
mb.show();
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -279,24 +279,19 @@ void Menu::cb_exitApp (FWidget*, data_ptr)
|
|||
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
if ( argv[1] && ( std::strcmp(argv[1], "--help") == 0
|
||||
|| 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);
|
||||
}
|
||||
|
||||
// Create the application object
|
||||
FApplication app (argc, argv);
|
||||
|
||||
// Create main dialog object
|
||||
Menu main_dlg (&app);
|
||||
main_dlg.setText ("Menu example");
|
||||
main_dlg.setGeometry (int(1 + (app.getWidth() - 40) / 2), 2, 40, 6);
|
||||
main_dlg.setShadow();
|
||||
|
||||
// Set dialog main_dlg as main widget
|
||||
app.setMainWidget (&main_dlg);
|
||||
|
||||
// Show and start the application
|
||||
main_dlg.show();
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -532,7 +532,10 @@ int main (int argc, char* argv[])
|
|||
mouse_draw.setGeometry (12, 4, 60, 18);
|
||||
mouse_draw.addAccelerator('q'); // press 'q' to quit
|
||||
|
||||
// Set dialog object mouse_draw as main widget
|
||||
app.setMainWidget(&mouse_draw);
|
||||
|
||||
// Show and start the application
|
||||
mouse_draw.show();
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -132,20 +132,28 @@ int main (int argc, char* argv[])
|
|||
{
|
||||
int xmax, ymax;
|
||||
|
||||
// Create the application object
|
||||
FApplication app(argc, argv);
|
||||
|
||||
// Create a FVTerm object as virtual terminal
|
||||
terminal = new FVTerm(&app);
|
||||
xmax = terminal->getColumnNumber() - 1;
|
||||
ymax = terminal->getLineNumber() - 1;
|
||||
FString line(xmax + 1, '-');
|
||||
|
||||
// Place the cursor in the upper left corner
|
||||
terminal->setTermXY(0,0);
|
||||
// Reset all terminal attributes
|
||||
terminal->setNormal();
|
||||
// Clear the screen
|
||||
terminal->clearArea();
|
||||
|
||||
// Show the determined terminal name and text resolution
|
||||
std::cout << "Terminal: " << terminal->getTermType() << "\r\n";
|
||||
std::cout << " Columns: 0.." << xmax << "\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 << " (From) -> (To) ";
|
||||
std::cout << "escape sequence ";
|
||||
|
@ -169,10 +177,13 @@ int main (int argc, char* argv[])
|
|||
move (3, 2, xmax, 2);
|
||||
move (5, 5, xmax - 5, ymax - 5);
|
||||
|
||||
// Waiting for keypress
|
||||
keyPressed();
|
||||
|
||||
// Show terminal speed and milliseconds for all cursor movement sequence
|
||||
std::cout << "\r" << line;
|
||||
terminal->printMoveDurations();
|
||||
|
||||
// Waiting for keypress
|
||||
keyPressed();
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ scrollview::scrollview (FWidget* parent)
|
|||
, go_west()
|
||||
, go_north()
|
||||
{
|
||||
// Create the four navigation buttons
|
||||
go_east = new FButton(wchar_t(fc::BlackRightPointingPointer) , this);
|
||||
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->setGeometry (1, getScrollHeight() - 2, 5, 1);
|
||||
|
||||
// Add scroll function callbacks to the buttons
|
||||
go_east->addCallback
|
||||
(
|
||||
"clicked",
|
||||
|
@ -259,7 +261,10 @@ int main (int argc, char* argv[])
|
|||
// Create a simple dialog box
|
||||
scrollviewdemo svdemo(&app);
|
||||
|
||||
// Set dialog main_dlg as main widget
|
||||
app.setMainWidget(&svdemo);
|
||||
|
||||
// Show and start the application
|
||||
svdemo.show();
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -47,11 +47,11 @@ int main (int, char**)
|
|||
std::cout << " cpp_str: \"" << cpp_str << "\"" << std::endl;
|
||||
|
||||
// Test: copy a character
|
||||
const FString& ch('c');
|
||||
const FString ch('c');
|
||||
std::cout << " char: '" << ch << "'" << std::endl;
|
||||
|
||||
// Test: copy a wide character
|
||||
const FString& wch(L'w');
|
||||
const FString wch(L'w');
|
||||
std::cout << " wchar_t: '" << wch << "'" << std::endl;
|
||||
|
||||
// Test: utf-8 string
|
||||
|
|
|
@ -400,11 +400,14 @@ int main (int argc, char* argv[])
|
|||
dialog->addAccelerator('q'); // press 'q' to quit
|
||||
dialog->setShadow();
|
||||
|
||||
// Create the attribute demo widget as a child object from the dialog
|
||||
AttribDemo* demo = new AttribDemo(dialog);
|
||||
demo->setGeometry (1, 1, 67, 19);
|
||||
|
||||
// Set the dialog object as main widget
|
||||
app.setMainWidget(dialog);
|
||||
dialog->show();
|
||||
|
||||
// Show and start the application
|
||||
dialog->show();
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -78,12 +78,19 @@ void timer::onAccel (FAccelEvent* ev)
|
|||
//----------------------------------------------------------------------
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
// Create the application object
|
||||
FApplication app(argc, argv);
|
||||
app.setForegroundColor(fc::Default);
|
||||
app.setBackgroundColor(fc::Default);
|
||||
|
||||
// Create a timer object t
|
||||
timer t(&app);
|
||||
t.addAccelerator('q');
|
||||
|
||||
// Set the timer object t as main widget
|
||||
app.setMainWidget(&t);
|
||||
|
||||
// Show and start the application
|
||||
t.show();
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -268,24 +268,18 @@ void MainWindow::onTimer (FTimerEvent*)
|
|||
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
if ( argv[1] && ( std::strcmp(argv[1], "--help") == 0
|
||||
|| 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);
|
||||
}
|
||||
|
||||
// Create the application object
|
||||
FApplication app (argc, argv);
|
||||
|
||||
// Create main dialog object
|
||||
MainWindow main_dlg (&app);
|
||||
main_dlg.setText ("non-transparent");
|
||||
main_dlg.setGeometry (8, 16, 26, 7);
|
||||
|
||||
// Set dialog main_dlg as main widget
|
||||
app.setMainWidget (&main_dlg);
|
||||
main_dlg.show();
|
||||
|
||||
// Show and start the application
|
||||
main_dlg.show();
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -91,6 +91,7 @@ Treeview::Treeview (FWidget* parent)
|
|||
FObjectIterator iter_egypt = item_africa->begin();
|
||||
FListViewItem* item_egypt = static_cast<FListViewItem*>(*iter_egypt);
|
||||
item_egypt = item_egypt;
|
||||
item_africa->expand();
|
||||
|
||||
// Quit button
|
||||
FButton* Quit = new FButton (this);
|
||||
|
@ -135,24 +136,19 @@ void Treeview::cb_exitApp (FWidget*, data_ptr)
|
|||
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
if ( argv[1] && ( std::strcmp(argv[1], "--help") == 0
|
||||
|| 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);
|
||||
}
|
||||
|
||||
// Create the application object
|
||||
FApplication app(argc, argv);
|
||||
|
||||
// Create main dialog object
|
||||
Treeview d(&app);
|
||||
d.setText (L"Continents");
|
||||
d.setGeometry (int(1 + (app.getWidth() - 37) / 2), 3, 37, 20);
|
||||
d.setShadow();
|
||||
|
||||
// Set dialog d as main widget
|
||||
app.setMainWidget(&d);
|
||||
|
||||
// Show and start the application
|
||||
d.show();
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -911,16 +911,7 @@ int main (int argc, char* argv[])
|
|||
FString ver = F_VERSION; // library version
|
||||
FString title = "The FINAL CUT " + ver + " (C) 2017 by Markus Gans";
|
||||
|
||||
if ( argv[1] && ( std::strcmp(argv[1], "--help") == 0
|
||||
|| 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);
|
||||
}
|
||||
|
||||
// Create the application object app
|
||||
FApplication app(argc, argv);
|
||||
app.setXTermDefaultColors(true);
|
||||
app.setXTermTitle (title);
|
||||
|
@ -929,12 +920,20 @@ int main (int argc, char* argv[])
|
|||
//app.setTermSize(94,30);
|
||||
//app.setNewFont();
|
||||
|
||||
// Create main dialog object d
|
||||
MyDialog d(&app);
|
||||
d.setText (title);
|
||||
d.setGeometry (int((app.getWidth() - 56) / 2), 2, 56, app.getHeight() - 4);
|
||||
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);
|
||||
|
||||
// Show the dialog d
|
||||
d.show();
|
||||
|
||||
// Start the application
|
||||
// and return the result to the operating system
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -215,7 +215,10 @@ int main (int argc, char* argv[])
|
|||
// Create a simple dialog box
|
||||
watch w(&app);
|
||||
|
||||
// Set dialog w as main widget
|
||||
app.setMainWidget(&w);
|
||||
|
||||
// Show and start the application
|
||||
w.show();
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -567,24 +567,18 @@ void Window::cb_destroyWindow (FWidget*, data_ptr data)
|
|||
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
if ( argv[1] && ( std::strcmp(argv[1], "--help") == 0
|
||||
|| 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);
|
||||
}
|
||||
|
||||
// Create the application object
|
||||
FApplication app (argc, argv);
|
||||
|
||||
// Create main dialog object
|
||||
Window main_dlg (&app);
|
||||
main_dlg.setText ("Main window");
|
||||
main_dlg.setGeometry (int(1 + (app.getWidth() - 40) / 2), 2, 40, 6);
|
||||
|
||||
// Set dialog main_dlg as main widget
|
||||
app.setMainWidget (&main_dlg);
|
||||
main_dlg.show();
|
||||
|
||||
// Show and start the application
|
||||
main_dlg.show();
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ class FApplication : public FWidget
|
|||
static void sendQueuedEvents ();
|
||||
static bool eventInQueue();
|
||||
static bool removeQueuedEvent (const FObject*);
|
||||
static void print_cmd_Options();
|
||||
static FWidget* showParameterUsage (const int&, char*[]);
|
||||
|
||||
private:
|
||||
// Typedefs and Enumerations
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#ifndef FLISTVIEW_H
|
||||
#define FLISTVIEW_H
|
||||
|
||||
#include <stack>
|
||||
#include <vector>
|
||||
|
||||
#include "final/fscrollbar.h"
|
||||
|
@ -52,8 +53,6 @@ class FListViewItem : public FObject
|
|||
public:
|
||||
// Constructor
|
||||
FListViewItem (const FListViewItem&); // copy constructor
|
||||
explicit FListViewItem (FListViewItem*);
|
||||
explicit FListViewItem (FListView*);
|
||||
explicit FListViewItem (FObjectIterator);
|
||||
FListViewItem ( const std::vector<FString>&
|
||||
, FWidget::data_ptr
|
||||
|
@ -69,6 +68,7 @@ class FListViewItem : public FObject
|
|||
const char* getClassName() const;
|
||||
uInt getColumnCount() const;
|
||||
FString getText (int) const;
|
||||
uInt getDepth() const;
|
||||
|
||||
// Mutator
|
||||
void setText (int, const FString&);
|
||||
|
@ -215,6 +215,7 @@ class FListView : public FWidget
|
|||
};
|
||||
|
||||
typedef std::vector<Header> headerItems;
|
||||
typedef std::stack<FObjectIterator> FObjectIteratorStack;
|
||||
|
||||
// Constants
|
||||
static const int USE_MAX_SIZE = -1;
|
||||
|
@ -248,6 +249,7 @@ class FListView : public FWidget
|
|||
FObjectIterator root;
|
||||
FObjectList selflist;
|
||||
FObjectList itemlist;
|
||||
FObjectIteratorStack iter_path;
|
||||
headerItems header;
|
||||
FTermBuffer headerline;
|
||||
FScrollbar* vbar;
|
||||
|
@ -345,13 +347,27 @@ inline void FListView::nextElement (FObjectIterator& iter)
|
|||
{
|
||||
FListViewItem* item = static_cast<FListViewItem*>(*iter);
|
||||
|
||||
if ( item->isExpandable() )
|
||||
if ( item->isExpandable() && item->isExpand() )
|
||||
{
|
||||
//iter = item->begin();
|
||||
++iter;
|
||||
iter_path.push(iter);
|
||||
iter = item->begin();
|
||||
}
|
||||
else
|
||||
{
|
||||
++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
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
if [ $# -gt 0 ]
|
||||
then
|
||||
eval cppcheck --enable=all "$@"
|
||||
eval cppcheck --force --enable=all -I../include/ "$@"
|
||||
else
|
||||
eval cppcheck --enable=all ../include/final/ ../src/ ../examples/
|
||||
eval cppcheck --force --enable=all -I../include/ ../src/ ../examples/
|
||||
fi
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ FApplication::eventQueue* FApplication::event_queue = 0;
|
|||
FApplication::FApplication ( const int& _argc
|
||||
, char* _argv[]
|
||||
, bool disable_alt_screen )
|
||||
: FWidget(0, disable_alt_screen)
|
||||
: FWidget(showParameterUsage(_argc,_argv), disable_alt_screen)
|
||||
, app_argc(_argc)
|
||||
, app_argv(_argv)
|
||||
, 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"
|
||||
" --encoding <name> Sets the character encoding mode\n"
|
||||
" {UTF8, VT100, PC, ASCII}\n"
|
||||
" --no-optimized-cursor No cursor optimisation\n"
|
||||
" --vgafont Set the standard vga 8x16 font\n"
|
||||
" --newfont Enables the graphical font\n" );
|
||||
if ( argc > 0 && argv[1] && ( std::strcmp(argv[1], "--help") == 0
|
||||
|| std::strcmp(argv[1], "-h") == 0 ) )
|
||||
{
|
||||
std::cout \
|
||||
<< "Generic options:" << std::endl
|
||||
<< " -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');
|
||||
// init bit field with 0
|
||||
std::memset(&b_state, 0x00, sizeof(b_state));
|
||||
|
||||
// interpret the command line options
|
||||
cmd_options();
|
||||
}
|
||||
|
|
|
@ -40,8 +40,6 @@ void FCheckMenuItem::init (FWidget* parent)
|
|||
if ( isMenu(parent) ) // Parent is menu
|
||||
{
|
||||
FMenu* menu_ptr = static_cast<FMenu*>(parent);
|
||||
|
||||
if ( menu_ptr )
|
||||
menu_ptr->has_checkable_items = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -241,7 +241,6 @@ int FFileDialog::readDir()
|
|||
int start, dir_num;
|
||||
const char* const dir = directory.c_str();
|
||||
const char* const filter = filter_pattern.c_str();
|
||||
errno = 0;
|
||||
directory_stream = opendir(dir);
|
||||
|
||||
if ( ! directory_stream )
|
||||
|
@ -254,37 +253,40 @@ int FFileDialog::readDir()
|
|||
|
||||
while ( true )
|
||||
{
|
||||
errno = 0;
|
||||
struct dirent* next = readdir (directory_stream);
|
||||
int retval;
|
||||
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;
|
||||
|
||||
if ( ! show_hidden
|
||||
&& next->d_name[0] == '.'
|
||||
&& next->d_name[1] != '\0'
|
||||
&& next->d_name[1] != '.' )
|
||||
&& next.d_name[0] == '.'
|
||||
&& next.d_name[1] != '\0'
|
||||
&& next.d_name[1] != '.' )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( dir[0] == '/' && dir[1] == '\0'
|
||||
&& std::strcmp(next->d_name, "..") == 0 )
|
||||
&& std::strcmp(next.d_name, "..") == 0 )
|
||||
continue;
|
||||
|
||||
dir_entry entry;
|
||||
entry.name = strdup(next->d_name);
|
||||
entry.type = next->d_type;
|
||||
entry.name = strdup(next.d_name);
|
||||
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 symLink[MAXPATHLEN] = {};
|
||||
std::strncpy (symLink, dir, sizeof(symLink) - 1);
|
||||
std::strncat ( symLink
|
||||
, next->d_name
|
||||
, next.d_name
|
||||
, sizeof(symLink) - std::strlen(symLink) - 1);
|
||||
|
||||
if ( realpath(symLink, resolved_path) != 0 ) // follow link
|
||||
|
@ -306,11 +308,11 @@ int FFileDialog::readDir()
|
|||
else
|
||||
std::free(entry.name);
|
||||
}
|
||||
else if (errno != 0)
|
||||
else if ( retval > 0 )
|
||||
{
|
||||
FMessageBox::error (this, "Reading directory\n" + directory);
|
||||
|
||||
if ( errno != EOVERFLOW )
|
||||
if ( retval == EBADF ) // Invalid directory stream descriptor
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -87,6 +87,20 @@ FString FListViewItem::getText (int column) const
|
|||
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)
|
||||
{
|
||||
|
@ -226,6 +240,7 @@ FListView::FListView (FWidget* parent)
|
|||
, root()
|
||||
, selflist()
|
||||
, itemlist()
|
||||
, iter_path()
|
||||
, header()
|
||||
, headerline()
|
||||
, vbar(0)
|
||||
|
@ -408,6 +423,8 @@ FObject::FObjectIterator FListView::insert ( FListViewItem* item
|
|||
item_iter = parent->appendItem (item);
|
||||
}
|
||||
}
|
||||
else
|
||||
item_iter = FObjectIterator(0);
|
||||
|
||||
int element_count = int(getCount());
|
||||
recalculateVerticalBar (element_count);
|
||||
|
@ -1294,6 +1311,8 @@ void FListView::drawListLine ( const FListViewItem* item
|
|||
, bool is_focus
|
||||
, bool is_current )
|
||||
{
|
||||
uInt indent = item->getDepth() << 1; // indent = 2 * depth
|
||||
|
||||
setColor (wc.list_fg, wc.list_bg);
|
||||
|
||||
if ( is_current )
|
||||
|
@ -1329,13 +1348,24 @@ void FListView::drawListLine ( const FListViewItem* item
|
|||
|
||||
if ( tree_view )
|
||||
{
|
||||
if ( indent > 0 )
|
||||
line = FString(indent, L' ');
|
||||
|
||||
if ( item->expandable )
|
||||
{
|
||||
line = wchar_t(fc::BlackRightPointingPointer);
|
||||
if (item->is_expand )
|
||||
{
|
||||
line += wchar_t(fc::BlackDownPointingTriangle); // ▼
|
||||
line += L' ';
|
||||
}
|
||||
else
|
||||
line = L" ";
|
||||
{
|
||||
line += wchar_t(fc::BlackRightPointingPointer); // ►
|
||||
line += L' ';
|
||||
}
|
||||
}
|
||||
else
|
||||
line += L" ";
|
||||
}
|
||||
else
|
||||
line = L" ";
|
||||
|
@ -1359,6 +1389,7 @@ void FListView::drawListLine ( const FListViewItem* item
|
|||
|
||||
if ( tree_view && i == 1 )
|
||||
{
|
||||
width -= indent;
|
||||
width--;
|
||||
}
|
||||
|
||||
|
|
|
@ -797,15 +797,11 @@ void FMenu::init(FWidget* parent)
|
|||
if ( isMenuBar(parent) )
|
||||
{
|
||||
FMenuBar* mbar = static_cast<FMenuBar*>(parent);
|
||||
|
||||
if ( mbar )
|
||||
mbar->calculateDimensions();
|
||||
}
|
||||
else if ( isMenu(parent) )
|
||||
{
|
||||
FMenu* smenu = static_cast<FMenu*>(parent);
|
||||
|
||||
if ( smenu )
|
||||
smenu->calculateDimensions();
|
||||
}
|
||||
|
||||
|
|
|
@ -299,8 +299,6 @@ void FMenuItem::onKeyPress (FKeyEvent* ev)
|
|||
if ( isMenu(super_menu) )
|
||||
{
|
||||
FMenu* smenu = static_cast<FMenu*>(super_menu);
|
||||
|
||||
if ( smenu )
|
||||
smenu->onKeyPress(ev);
|
||||
}
|
||||
|
||||
|
@ -330,9 +328,6 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
|
|||
if ( isMenu(super_menu) )
|
||||
{
|
||||
FMenu* smenu = static_cast<FMenu*>(super_menu);
|
||||
|
||||
if ( smenu )
|
||||
{
|
||||
const FPoint& p2 = smenu->termToWidgetPos(t);
|
||||
|
||||
try
|
||||
|
@ -348,7 +343,6 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
|
|||
<< ex.what() << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( isMenuBar(super_menu) )
|
||||
{
|
||||
|
@ -409,9 +403,6 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
|
|||
if ( isMenu(super_menu) )
|
||||
{
|
||||
FMenu* smenu = static_cast<FMenu*>(super_menu);
|
||||
|
||||
if ( smenu )
|
||||
{
|
||||
const FPoint& p2 = smenu->termToWidgetPos(t);
|
||||
|
||||
try
|
||||
|
@ -427,7 +418,6 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
|
|||
<< ex.what() << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( isMenuBar(super_menu) )
|
||||
{
|
||||
|
@ -488,42 +478,30 @@ void FMenuItem::onMouseUp (FMouseEvent* ev)
|
|||
if ( isMenu(super_menu) )
|
||||
{
|
||||
FMenu* smenu = static_cast<FMenu*>(super_menu);
|
||||
|
||||
if ( smenu )
|
||||
{
|
||||
const FPoint& p2 = smenu->termToWidgetPos(t);
|
||||
FMouseEvent* _ev = new FMouseEvent (fc::MouseUp_Event, p2, t, b);
|
||||
smenu->onMouseUp(_ev);
|
||||
delete _ev;
|
||||
}
|
||||
}
|
||||
|
||||
if ( isMenuBar(super_menu) )
|
||||
{
|
||||
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
|
||||
|
||||
if ( mbar )
|
||||
{
|
||||
const FPoint& p2 = mbar->termToWidgetPos(t);
|
||||
FMouseEvent* _ev = new FMouseEvent (fc::MouseUp_Event, p2, t, b);
|
||||
mbar->onMouseUp(_ev);
|
||||
delete _ev;
|
||||
}
|
||||
}
|
||||
|
||||
if ( isWindowsMenu(super_menu) )
|
||||
{
|
||||
FDialog* dgl = static_cast<FDialog*>(super_menu);
|
||||
|
||||
if ( dgl )
|
||||
{
|
||||
const FPoint& p2 = dgl->termToWidgetPos(t);
|
||||
FMouseEvent* _ev = new FMouseEvent (fc::MouseUp_Event, p2, t, b);
|
||||
dgl->onMouseUp(_ev);
|
||||
delete _ev;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuItem::onMouseMove (FMouseEvent* ev)
|
||||
|
@ -537,42 +515,30 @@ void FMenuItem::onMouseMove (FMouseEvent* ev)
|
|||
if ( isMenu(super_menu) )
|
||||
{
|
||||
FMenu* smenu = static_cast<FMenu*>(super_menu);
|
||||
|
||||
if ( smenu )
|
||||
{
|
||||
const FPoint& p2 = smenu->termToWidgetPos(t);
|
||||
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p2, t, b);
|
||||
smenu->onMouseMove(_ev);
|
||||
delete _ev;
|
||||
}
|
||||
}
|
||||
|
||||
if ( isMenuBar(super_menu) )
|
||||
{
|
||||
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
|
||||
|
||||
if ( mbar )
|
||||
{
|
||||
const FPoint& p2 = mbar->termToWidgetPos(t);
|
||||
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p2, t, b);
|
||||
mbar->onMouseMove(_ev);
|
||||
delete _ev;
|
||||
}
|
||||
}
|
||||
|
||||
if ( isWindowsMenu(super_menu) )
|
||||
{
|
||||
FDialog* dgl = static_cast<FDialog*>(super_menu);
|
||||
|
||||
if ( dgl )
|
||||
{
|
||||
const FPoint& p2 = dgl->termToWidgetPos(t);
|
||||
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p2, t, b);
|
||||
dgl->onMouseMove(_ev);
|
||||
delete _ev;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuItem::onAccel (FAccelEvent* ev)
|
||||
|
@ -588,9 +554,6 @@ void FMenuItem::onAccel (FAccelEvent* ev)
|
|||
|
||||
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
|
||||
|
||||
if ( ! mbar )
|
||||
return;
|
||||
|
||||
if ( menu )
|
||||
{
|
||||
FWidget* focused_widget;
|
||||
|
@ -635,6 +598,7 @@ void FMenuItem::onAccel (FAccelEvent* ev)
|
|||
processClicked();
|
||||
mbar->drop_down = false;
|
||||
}
|
||||
|
||||
ev->accept();
|
||||
}
|
||||
|
||||
|
@ -653,8 +617,6 @@ void FMenuItem::onFocusOut (FFocusEvent*)
|
|||
if ( super_menu && isMenuBar(super_menu) )
|
||||
{
|
||||
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
|
||||
|
||||
if ( mbar )
|
||||
mbar->redraw();
|
||||
}
|
||||
|
||||
|
@ -703,8 +665,9 @@ void FMenuItem::init (FWidget* parent)
|
|||
|
||||
setGeometry (1, 1, int(text_length + 2), 1, false);
|
||||
|
||||
if ( parent )
|
||||
{
|
||||
if ( ! parent )
|
||||
return;
|
||||
|
||||
FMenuList* menu_list;
|
||||
setSuperMenu (parent);
|
||||
|
||||
|
@ -719,15 +682,11 @@ void FMenuItem::init (FWidget* parent)
|
|||
if ( isMenuBar(parent) ) // Parent is menubar
|
||||
{
|
||||
FMenuBar* menubar_ptr = static_cast<FMenuBar*>(parent);
|
||||
|
||||
if ( menubar_ptr )
|
||||
{
|
||||
menubar_ptr->calculateDimensions();
|
||||
|
||||
if ( hotkey ) // Meta + hotkey
|
||||
menubar_ptr->addAccelerator ( fc::Fmkey_meta + std::tolower(hotkey)
|
||||
, this );
|
||||
}
|
||||
|
||||
addCallback // for this element
|
||||
(
|
||||
|
@ -738,12 +697,9 @@ void FMenuItem::init (FWidget* parent)
|
|||
else if ( isMenu(parent) ) // Parent is menu
|
||||
{
|
||||
FMenu* menu_ptr = static_cast<FMenu*>(parent);
|
||||
|
||||
if ( menu_ptr )
|
||||
menu_ptr->calculateDimensions();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
uChar FMenuItem::hotKey()
|
||||
|
|
|
@ -41,8 +41,6 @@ void FRadioMenuItem::init (FWidget* parent)
|
|||
if ( isMenu(parent) ) // Parent is menu
|
||||
{
|
||||
FMenu* menu_ptr = static_cast<FMenu*>(parent);
|
||||
|
||||
if ( menu_ptr )
|
||||
menu_ptr->has_checkable_items = true;
|
||||
|
||||
addCallback // for this element
|
||||
|
|
Loading…
Reference in New Issue