2016-07-31 20:28:45 +02:00
|
|
|
// File: windows.cpp
|
|
|
|
|
|
|
|
#include "fapp.h"
|
|
|
|
#include "fdialog.h"
|
|
|
|
#include "fdialoglistmenu.h"
|
|
|
|
#include "flabel.h"
|
|
|
|
#include "fmenubar.h"
|
|
|
|
#include "fmenu.h"
|
|
|
|
#include "fmessagebox.h"
|
|
|
|
#include "fstatusbar.h"
|
|
|
|
#include "fstring.h"
|
|
|
|
|
2016-09-27 00:46:05 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class smallWindow
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma pack(push)
|
|
|
|
#pragma pack(1)
|
|
|
|
|
|
|
|
class smallWindow : public FDialog
|
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
public:
|
|
|
|
// Constructor
|
|
|
|
explicit smallWindow (FWidget* = 0);
|
|
|
|
|
|
|
|
// Destructor
|
|
|
|
~smallWindow();
|
2016-09-27 00:46:05 +02:00
|
|
|
|
|
|
|
private:
|
2016-09-30 04:55:28 +02:00
|
|
|
// Disable copy constructor
|
|
|
|
smallWindow (const smallWindow&);
|
2016-11-02 00:37:58 +01:00
|
|
|
|
2016-09-30 04:55:28 +02:00
|
|
|
// Disable assignment operator (=)
|
|
|
|
smallWindow& operator = (const smallWindow&);
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
// Method
|
2016-09-27 00:46:05 +02:00
|
|
|
void adjustSize();
|
2016-09-30 04:55:28 +02:00
|
|
|
|
|
|
|
// Event handlers
|
2016-09-29 04:29:12 +02:00
|
|
|
void onShow (FShowEvent*);
|
|
|
|
void onTimer (FTimerEvent*);
|
2016-09-27 00:46:05 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
// Data Members
|
|
|
|
FLabel* left_arrow;
|
|
|
|
FLabel* right_arrow;
|
|
|
|
FLabel* top_left_label;
|
|
|
|
FLabel* top_right_label;
|
|
|
|
FLabel* bottom_label;
|
2016-09-27 00:46:05 +02:00
|
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
smallWindow::smallWindow (FWidget* parent)
|
|
|
|
: FDialog(parent)
|
2016-09-29 04:29:12 +02:00
|
|
|
, left_arrow()
|
|
|
|
, right_arrow()
|
|
|
|
, top_left_label()
|
|
|
|
, top_right_label()
|
|
|
|
, bottom_label()
|
2016-09-27 00:46:05 +02:00
|
|
|
{
|
2016-09-30 04:55:28 +02:00
|
|
|
wchar_t arrow_up, arrow_down;
|
|
|
|
|
2017-04-05 00:30:52 +02:00
|
|
|
arrow_up = fc::BlackUpPointingTriangle;
|
|
|
|
arrow_down = fc::BlackDownPointingTriangle;
|
2016-09-30 04:55:28 +02:00
|
|
|
|
|
|
|
left_arrow = new FLabel (arrow_up, this);
|
2016-09-29 04:29:12 +02:00
|
|
|
left_arrow->setForegroundColor (wc.label_inactive_fg);
|
|
|
|
left_arrow->setEmphasis();
|
|
|
|
left_arrow->ignorePadding();
|
|
|
|
left_arrow->setGeometry (2, 2, 1, 1);
|
|
|
|
|
2016-09-30 04:55:28 +02:00
|
|
|
right_arrow = new FLabel (arrow_up, this);
|
2016-09-29 04:29:12 +02:00
|
|
|
right_arrow->setForegroundColor (wc.label_inactive_fg);
|
|
|
|
right_arrow->setEmphasis();
|
|
|
|
right_arrow->ignorePadding();
|
|
|
|
right_arrow->setGeometry (getWidth() - 1, 2, 1, 1);
|
|
|
|
|
|
|
|
FString top_left_label_text = "menu";
|
|
|
|
top_left_label = new FLabel (top_left_label_text, this);
|
|
|
|
top_left_label->setForegroundColor (wc.label_inactive_fg);
|
|
|
|
top_left_label->setEmphasis();
|
|
|
|
top_left_label->setGeometry (1, 1, 6, 1);
|
|
|
|
|
|
|
|
FString top_right_label_text = "zoom";
|
|
|
|
top_right_label = new FLabel (top_right_label_text, this);
|
|
|
|
top_right_label->setAlignment (fc::alignRight);
|
|
|
|
top_right_label->setForegroundColor (wc.label_inactive_fg);
|
|
|
|
top_right_label->setEmphasis();
|
|
|
|
top_right_label->setGeometry (getClientWidth() - 5, 1, 6, 1);
|
|
|
|
|
|
|
|
FString bottom_label_text = "resize\n"
|
2016-09-30 04:55:28 +02:00
|
|
|
"corner\n";
|
|
|
|
bottom_label_text += arrow_down;
|
2016-09-29 04:29:12 +02:00
|
|
|
bottom_label = new FLabel (bottom_label_text, this);
|
|
|
|
bottom_label->setAlignment (fc::alignRight);
|
|
|
|
bottom_label->setForegroundColor (wc.label_inactive_fg);
|
|
|
|
bottom_label->setEmphasis();
|
|
|
|
bottom_label->setGeometry (13, 3, 6, 3);
|
2016-09-27 00:46:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
smallWindow::~smallWindow()
|
2016-09-29 04:29:12 +02:00
|
|
|
{
|
|
|
|
delOwnTimer();
|
|
|
|
}
|
2016-09-27 00:46:05 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void smallWindow::adjustSize()
|
|
|
|
{
|
2016-09-29 04:29:12 +02:00
|
|
|
if ( isZoomed() )
|
|
|
|
{
|
|
|
|
top_right_label->setText("unzoom");
|
|
|
|
bottom_label->hide();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
top_right_label->setText("zoom");
|
|
|
|
bottom_label->setVisible();
|
|
|
|
}
|
|
|
|
|
2016-09-27 00:46:05 +02:00
|
|
|
FDialog::adjustSize();
|
2016-09-29 04:29:12 +02:00
|
|
|
right_arrow->setGeometry (getWidth() - 1, 2, 1, 1);
|
|
|
|
top_right_label->setGeometry (getClientWidth() - 5, 1, 6, 1);
|
|
|
|
bottom_label->setGeometry (1, getClientHeight() - 2, getClientWidth(), 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void smallWindow::onShow (FShowEvent*)
|
|
|
|
{
|
|
|
|
addTimer(1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void smallWindow::onTimer (FTimerEvent*)
|
|
|
|
{
|
|
|
|
left_arrow->unsetEmphasis();
|
|
|
|
left_arrow->redraw();
|
|
|
|
right_arrow->unsetEmphasis();
|
|
|
|
right_arrow->redraw();
|
|
|
|
top_left_label->unsetEmphasis();
|
|
|
|
top_left_label->redraw();
|
|
|
|
top_right_label->unsetEmphasis();
|
|
|
|
top_right_label->redraw();
|
|
|
|
bottom_label->unsetEmphasis();
|
|
|
|
bottom_label->redraw();
|
|
|
|
updateTerminal();
|
|
|
|
delOwnTimer();
|
2016-09-27 00:46:05 +02:00
|
|
|
}
|
|
|
|
|
2016-07-31 20:28:45 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class Window
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma pack(push)
|
|
|
|
#pragma pack(1)
|
|
|
|
|
|
|
|
class Window : public FDialog
|
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
public:
|
|
|
|
// Constructor
|
|
|
|
explicit Window (FWidget* = 0);
|
|
|
|
|
|
|
|
// Destructor
|
|
|
|
~Window();
|
|
|
|
|
2016-07-31 20:28:45 +02:00
|
|
|
private:
|
2016-11-02 00:37:58 +01:00
|
|
|
// Typedef
|
2016-07-31 20:28:45 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
2016-09-29 04:29:12 +02:00
|
|
|
bool is_open;
|
2016-07-31 20:28:45 +02:00
|
|
|
FString* title;
|
|
|
|
FDialog* dgl;
|
|
|
|
}
|
|
|
|
win_data;
|
|
|
|
|
2016-09-30 04:55:28 +02:00
|
|
|
// Disable copy constructor
|
|
|
|
Window (const Window&);
|
2016-11-02 00:37:58 +01:00
|
|
|
|
2016-09-30 04:55:28 +02:00
|
|
|
// Disable assignment operator (=)
|
|
|
|
Window& operator = (const Window&);
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
// Method
|
2016-07-31 20:28:45 +02:00
|
|
|
void activateWindow (FDialog*);
|
2016-11-02 00:37:58 +01:00
|
|
|
void adjustSize();
|
2016-09-30 04:55:28 +02:00
|
|
|
|
|
|
|
// Event handlers
|
2016-07-31 20:28:45 +02:00
|
|
|
void onClose (FCloseEvent*);
|
2016-09-30 04:55:28 +02:00
|
|
|
|
|
|
|
// Callback methods
|
2017-02-24 00:30:07 +01:00
|
|
|
void cb_createWindows (FWidget*, data_ptr);
|
|
|
|
void cb_closeWindows (FWidget*, data_ptr);
|
|
|
|
void cb_next (FWidget*, data_ptr);
|
|
|
|
void cb_previous (FWidget*, data_ptr);
|
|
|
|
void cb_exitApp (FWidget*, data_ptr);
|
|
|
|
void cb_destroyWindow (FWidget*, data_ptr);
|
2016-09-30 04:55:28 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
// Data Members
|
|
|
|
std::vector<win_data*> windows;
|
2016-07-31 20:28:45 +02:00
|
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
Window::Window (FWidget* parent)
|
|
|
|
: FDialog(parent)
|
|
|
|
, windows()
|
|
|
|
{
|
2016-11-20 21:15:43 +01:00
|
|
|
FString drop_down_symbol;
|
2016-07-31 20:28:45 +02:00
|
|
|
// menu bar
|
|
|
|
FMenuBar* Menubar = new FMenuBar (this);
|
|
|
|
|
|
|
|
// menu bar item
|
|
|
|
FMenu* File = new FMenu ("&File", Menubar);
|
|
|
|
File->setStatusbarMessage ("File management commands");
|
|
|
|
|
|
|
|
// dialog list menu item
|
2017-04-05 00:30:52 +02:00
|
|
|
drop_down_symbol = wchar_t(fc::BlackDownPointingTriangle);
|
2016-11-20 21:15:43 +01:00
|
|
|
|
2016-07-31 20:28:45 +02:00
|
|
|
FDialogListMenu* DglList = new FDialogListMenu (drop_down_symbol, Menubar);
|
|
|
|
DglList->setStatusbarMessage ("List of all the active dialogs");
|
|
|
|
|
|
|
|
// "File" menu item
|
|
|
|
FMenuItem* New = new FMenuItem ("&New", File);
|
|
|
|
New->setStatusbarMessage ("Create the windows");
|
|
|
|
|
|
|
|
FMenuItem* Close = new FMenuItem ("&Close", File);
|
|
|
|
Close->setStatusbarMessage ("Close the windows");
|
|
|
|
|
|
|
|
FMenuItem* Line1 = new FMenuItem (File);
|
|
|
|
Line1->setSeparator();
|
|
|
|
|
|
|
|
FMenuItem* Next = new FMenuItem ("Ne&xt window", File);
|
|
|
|
Next->addAccelerator (fc::Fmkey_npage); // Meta/Alt + PgDn
|
|
|
|
Next->setStatusbarMessage ("Switch to the next window");
|
|
|
|
|
|
|
|
FMenuItem* Previous = new FMenuItem ("&Previous window", File);
|
|
|
|
Previous->addAccelerator (fc::Fmkey_ppage); // Meta/Alt + PgUp
|
|
|
|
Previous->setStatusbarMessage ("Switch to the previous window");
|
|
|
|
|
|
|
|
FMenuItem* Line2 = new FMenuItem (File);
|
|
|
|
Line2->setSeparator();
|
|
|
|
|
|
|
|
FMenuItem* Quit = new FMenuItem ("&Quit", File);
|
|
|
|
Quit->addAccelerator (fc::Fmkey_x); // Meta/Alt + X
|
|
|
|
Quit->setStatusbarMessage ("Exit the program");
|
|
|
|
|
|
|
|
// Statusbar at the bottom
|
|
|
|
FStatusBar* statusbar = new FStatusBar (this);
|
|
|
|
statusbar->setMessage("Status bar message");
|
|
|
|
|
|
|
|
// Buttons
|
|
|
|
FButton* CreateButton = new FButton (this);
|
|
|
|
CreateButton->setGeometry(2, 2, 9, 1);
|
|
|
|
CreateButton->setText (L"&Create");
|
|
|
|
|
|
|
|
FButton* CloseButton = new FButton (this);
|
|
|
|
CloseButton->setGeometry(15, 2, 9, 1);
|
|
|
|
CloseButton->setText (L"C&lose");
|
|
|
|
|
|
|
|
FButton* QuitButton = new FButton (this);
|
|
|
|
QuitButton->setGeometry(28, 2, 9, 1);
|
|
|
|
QuitButton->setText (L"&Quit");
|
|
|
|
|
|
|
|
// Add menu item callback
|
|
|
|
New->addCallback
|
|
|
|
(
|
|
|
|
"clicked",
|
|
|
|
_METHOD_CALLBACK (this, &Window::cb_createWindows)
|
|
|
|
);
|
|
|
|
|
|
|
|
Close->addCallback
|
|
|
|
(
|
|
|
|
"clicked",
|
|
|
|
_METHOD_CALLBACK (this, &Window::cb_closeWindows)
|
|
|
|
);
|
|
|
|
|
|
|
|
Next->addCallback
|
|
|
|
(
|
|
|
|
"clicked",
|
|
|
|
_METHOD_CALLBACK (this, &Window::cb_next)
|
|
|
|
);
|
|
|
|
|
|
|
|
Previous->addCallback
|
|
|
|
(
|
|
|
|
"clicked",
|
|
|
|
_METHOD_CALLBACK (this, &Window::cb_previous)
|
|
|
|
);
|
|
|
|
|
|
|
|
Quit->addCallback
|
|
|
|
(
|
|
|
|
"clicked",
|
|
|
|
_METHOD_CALLBACK (this, &Window::cb_exitApp)
|
|
|
|
);
|
|
|
|
|
|
|
|
// Add button callback
|
|
|
|
CreateButton->addCallback
|
|
|
|
(
|
|
|
|
"clicked",
|
|
|
|
_METHOD_CALLBACK (this, &Window::cb_createWindows)
|
|
|
|
);
|
|
|
|
|
|
|
|
CloseButton->addCallback
|
|
|
|
(
|
|
|
|
"clicked",
|
|
|
|
_METHOD_CALLBACK (this, &Window::cb_closeWindows)
|
|
|
|
);
|
|
|
|
|
|
|
|
QuitButton->addCallback
|
|
|
|
(
|
|
|
|
"clicked",
|
|
|
|
_METHOD_CALLBACK (this, &Window::cb_exitApp)
|
|
|
|
);
|
|
|
|
|
|
|
|
for (int n=1; n <= 6; n++)
|
|
|
|
{
|
|
|
|
win_data* win_dat = new win_data;
|
|
|
|
win_dat->is_open = false;
|
|
|
|
win_dat->title = new FString();
|
|
|
|
win_dat->title->sprintf("Window %d", n);
|
|
|
|
windows.push_back(win_dat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
Window::~Window()
|
|
|
|
{
|
|
|
|
std::vector<win_data*>::iterator iter;
|
|
|
|
iter = windows.begin();
|
|
|
|
|
|
|
|
while ( iter != windows.end() )
|
|
|
|
{
|
|
|
|
delete (*iter)->title;
|
|
|
|
delete *iter;
|
|
|
|
iter = windows.erase(iter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void Window::activateWindow (FDialog* win)
|
|
|
|
{
|
2016-10-17 08:44:38 +02:00
|
|
|
if ( ! win || win->isWindowHidden() || win->isWindowActive() )
|
|
|
|
return;
|
2016-07-31 20:28:45 +02:00
|
|
|
|
2016-10-17 08:44:38 +02:00
|
|
|
bool has_raised = FWindow::raiseWindow(win);
|
|
|
|
win->activateDialog();
|
2016-07-31 20:28:45 +02:00
|
|
|
|
2016-10-17 08:44:38 +02:00
|
|
|
if ( has_raised )
|
|
|
|
win->redraw();
|
|
|
|
|
|
|
|
updateTerminal();
|
2016-07-31 20:28:45 +02:00
|
|
|
}
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void Window::adjustSize()
|
|
|
|
{
|
|
|
|
int w,h,X,Y,dx,dy;
|
|
|
|
std::vector<win_data*>::const_iterator iter, begin;
|
|
|
|
w = getRootWidget()->getWidth();
|
|
|
|
h = getRootWidget()->getHeight();
|
|
|
|
X = int(1 + (w - 40) / 2);
|
|
|
|
Y = int(1 + (h - 22) / 2);
|
|
|
|
dx = (w > 80) ? (w - 80) / 2 : 0;
|
|
|
|
dy = (h > 24) ? (h - 24) / 2 : 0;
|
|
|
|
|
|
|
|
if ( Y < 2)
|
|
|
|
Y = 2;
|
|
|
|
|
|
|
|
setPos (X, Y);
|
|
|
|
iter = begin = windows.begin();
|
|
|
|
|
|
|
|
while ( iter != windows.end() )
|
|
|
|
{
|
|
|
|
if ( (*iter)->is_open )
|
|
|
|
{
|
|
|
|
int x,y,n;
|
|
|
|
n = int(std::distance(begin, iter));
|
|
|
|
x = dx + 5 + (n%3)*25 + int(n/3)*3;
|
|
|
|
y = dy + 11 + int(n/3)*3;
|
|
|
|
(*iter)->dgl->setPos (x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
|
|
|
|
FDialog::adjustSize();
|
|
|
|
}
|
|
|
|
|
2016-07-31 20:28:45 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void Window::onClose (FCloseEvent* ev)
|
|
|
|
{
|
|
|
|
int ret = FMessageBox::info ( this, "Quit"
|
|
|
|
, "Do you really want\n"
|
|
|
|
"to quit the program ?"
|
|
|
|
, FMessageBox::Yes
|
|
|
|
, FMessageBox::No );
|
|
|
|
if ( ret == FMessageBox::Yes )
|
|
|
|
{
|
|
|
|
cb_closeWindows(0,0);
|
|
|
|
ev->accept();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ev->ignore();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2017-02-24 00:30:07 +01:00
|
|
|
void Window::cb_createWindows (FWidget*, data_ptr)
|
2016-07-31 20:28:45 +02:00
|
|
|
{
|
2016-08-20 22:27:23 +02:00
|
|
|
int w,h,dx,dy;
|
2016-07-31 20:28:45 +02:00
|
|
|
std::vector<win_data*>::const_iterator iter, begin;
|
|
|
|
iter = begin = windows.begin();
|
2016-08-20 22:27:23 +02:00
|
|
|
w = getRootWidget()->getWidth();
|
|
|
|
h = getRootWidget()->getHeight();
|
|
|
|
dx = (w > 80) ? (w - 80) / 2 : 0;
|
|
|
|
dy = (h > 24) ? (h - 24) / 2 : 0;
|
2016-07-31 20:28:45 +02:00
|
|
|
|
|
|
|
while ( iter != windows.end() )
|
|
|
|
{
|
|
|
|
if ( ! (*iter)->is_open )
|
|
|
|
{
|
2016-09-27 00:46:05 +02:00
|
|
|
int x, y, n;
|
2016-07-31 20:28:45 +02:00
|
|
|
win_data* win_dat = *iter;
|
2016-09-27 00:46:05 +02:00
|
|
|
FDialog* win = new smallWindow(this);
|
2016-07-31 20:28:45 +02:00
|
|
|
win_dat->dgl = win;
|
|
|
|
win_dat->is_open = true;
|
|
|
|
win->setText(*(win_dat)->title);
|
|
|
|
n = int(std::distance(begin, iter));
|
2016-08-20 22:27:23 +02:00
|
|
|
x = dx + 5 + (n%3)*25 + int(n/3)*3;
|
|
|
|
y = dy + 11 + int(n/3)*3;
|
2016-07-31 20:28:45 +02:00
|
|
|
win->setGeometry (x, y, 20, 8);
|
2016-09-25 23:53:48 +02:00
|
|
|
win->setMinimumSize (20, 8);
|
2016-09-11 16:48:39 +02:00
|
|
|
win->setResizeable();
|
2016-07-31 20:28:45 +02:00
|
|
|
win->show();
|
|
|
|
|
|
|
|
win->addCallback
|
|
|
|
(
|
|
|
|
"destroy",
|
|
|
|
_METHOD_CALLBACK (this, &Window::cb_destroyWindow),
|
|
|
|
static_cast<FWidget::data_ptr>(win_dat)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
|
|
|
|
activateWindow(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2017-02-24 00:30:07 +01:00
|
|
|
void Window::cb_closeWindows (FWidget*, data_ptr)
|
2016-07-31 20:28:45 +02:00
|
|
|
{
|
|
|
|
if ( ! dialog_list || dialog_list->empty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
widgetList::const_iterator iter, begin;
|
|
|
|
iter = dialog_list->end();
|
|
|
|
begin = dialog_list->begin();
|
|
|
|
activateWindow(this);
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
--iter;
|
|
|
|
|
|
|
|
if ( (*iter) != this )
|
|
|
|
(*iter)->close();
|
|
|
|
}
|
|
|
|
while ( iter != begin );
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2017-02-24 00:30:07 +01:00
|
|
|
void Window::cb_next (FWidget*, data_ptr)
|
2016-07-31 20:28:45 +02:00
|
|
|
{
|
|
|
|
if ( ! dialog_list || dialog_list->empty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
widgetList::const_iterator iter;
|
|
|
|
iter = dialog_list->begin();
|
|
|
|
|
|
|
|
while ( iter != dialog_list->end() )
|
|
|
|
{
|
2016-10-11 04:57:36 +02:00
|
|
|
if ( static_cast<FWindow*>(*iter)->isWindowActive() )
|
2016-07-31 20:28:45 +02:00
|
|
|
{
|
|
|
|
FDialog* next;
|
|
|
|
widgetList::const_iterator next_element;
|
|
|
|
next_element = iter;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
++next_element;
|
|
|
|
|
|
|
|
if ( next_element == dialog_list->end() )
|
|
|
|
next_element = dialog_list->begin();
|
|
|
|
|
|
|
|
next = static_cast<FDialog*>(*next_element);
|
2016-12-18 23:34:11 +01:00
|
|
|
} while ( ! next->isEnabled()
|
|
|
|
|| ! next->acceptFocus()
|
|
|
|
|| ! next->isVisible()
|
|
|
|
|| ! next->isWindowWidget() );
|
2016-07-31 20:28:45 +02:00
|
|
|
|
|
|
|
activateWindow(next);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2017-02-24 00:30:07 +01:00
|
|
|
void Window::cb_previous (FWidget*, data_ptr)
|
2016-07-31 20:28:45 +02:00
|
|
|
{
|
|
|
|
if ( ! dialog_list || dialog_list->empty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
widgetList::const_iterator iter;
|
|
|
|
iter = dialog_list->end();
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
--iter;
|
|
|
|
|
2016-09-25 23:53:48 +02:00
|
|
|
if ( (*iter)->isDialogWidget()
|
2016-12-18 23:34:11 +01:00
|
|
|
&& static_cast<FWindow*>(*iter)->isWindowActive() )
|
2016-07-31 20:28:45 +02:00
|
|
|
{
|
|
|
|
FDialog* prev;
|
|
|
|
widgetList::const_iterator prev_element;
|
|
|
|
prev_element = iter;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if ( prev_element == dialog_list->begin() )
|
|
|
|
prev_element = dialog_list->end();
|
|
|
|
|
|
|
|
--prev_element;
|
|
|
|
prev = static_cast<FDialog*>(*prev_element);
|
2016-12-18 23:34:11 +01:00
|
|
|
} while ( ! prev->isEnabled()
|
|
|
|
|| ! prev->acceptFocus()
|
|
|
|
|| ! prev->isVisible()
|
|
|
|
|| ! prev->isWindowWidget() );
|
2016-07-31 20:28:45 +02:00
|
|
|
|
|
|
|
activateWindow(prev);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while ( iter != dialog_list->begin() );
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2017-02-24 00:30:07 +01:00
|
|
|
void Window::cb_exitApp (FWidget*, data_ptr)
|
2016-07-31 20:28:45 +02:00
|
|
|
{
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2017-02-24 00:30:07 +01:00
|
|
|
void Window::cb_destroyWindow (FWidget*, data_ptr data)
|
2016-07-31 20:28:45 +02:00
|
|
|
{
|
2017-02-24 00:30:07 +01:00
|
|
|
win_data* win_dat = static_cast<win_data*>(data);
|
2016-09-30 04:55:28 +02:00
|
|
|
|
2016-07-31 20:28:45 +02:00
|
|
|
if ( win_dat )
|
|
|
|
win_dat->is_open = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// main part
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
int main (int argc, char* argv[])
|
|
|
|
{
|
2016-12-18 23:34:11 +01:00
|
|
|
if ( argv[1] && ( std::strcmp(argv[1], "--help") == 0
|
|
|
|
|| std::strcmp(argv[1], "-h") == 0 ) )
|
2016-07-31 20:28:45 +02:00
|
|
|
{
|
|
|
|
std::cout << "Generic options:" << std::endl
|
|
|
|
<< " -h, --help "
|
|
|
|
<< "Display this help and exit" << std::endl;
|
|
|
|
FApplication::print_cmd_Options();
|
2016-10-06 23:15:09 +02:00
|
|
|
std::exit(EXIT_SUCCESS);
|
2016-07-31 20:28:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
FApplication app (argc, argv);
|
|
|
|
|
|
|
|
Window main_dlg (&app);
|
|
|
|
main_dlg.setText ("Main window");
|
|
|
|
main_dlg.setGeometry (int(1+(app.getWidth()-40)/2), 2, 40, 6);
|
|
|
|
|
|
|
|
app.setMainWidget (&main_dlg);
|
|
|
|
main_dlg.show();
|
|
|
|
|
|
|
|
return app.exec();
|
|
|
|
}
|