Use of the C++11 auto specifier in the program code

This commit is contained in:
Markus Gans 2018-12-15 00:50:09 +01:00
parent 6ce8c5cb27
commit cef13611d1
50 changed files with 935 additions and 1212 deletions

View File

@ -1,3 +1,6 @@
2018-12-15 Markus Gans <guru.mail@muenster.de>
* Use of the C++11 auto specifier in the program code
2018-12-09 Markus Gans <guru.mail@muenster.de> 2018-12-09 Markus Gans <guru.mail@muenster.de>
* Better handling of the scrollbar maximum * Better handling of the scrollbar maximum
* Deactivate copy constructor and assignment operator with "= delete" * Deactivate copy constructor and assignment operator with "= delete"

View File

@ -254,7 +254,7 @@ Calc::Calc (FWidget* parent)
for (int key = 0; key < Calc::NUM_OF_BUTTONS; key++) for (int key = 0; key < Calc::NUM_OF_BUTTONS; key++)
{ {
Button* btn = new Button(this); auto btn = new Button(this);
button_no[key] = key; button_no[key] = key;
if ( key == Equals ) if ( key == Equals )

View File

@ -128,9 +128,8 @@ void CheckList::populate()
for (int i = 0; i <= lastItem; i++) for (int i = 0; i <= lastItem; i++)
{ {
const finalcut::FStringList line (&list[i][0], &list[i][0] + 2); const finalcut::FStringList line (&list[i][0], &list[i][0] + 2);
finalcut::FObject::FObjectIterator iter = listView.insert (line); auto iter = listView.insert (line);
finalcut::FListViewItem* item = \ auto item = static_cast<finalcut::FListViewItem*>(*iter);
static_cast<finalcut::FListViewItem*>(*iter);
item->setCheckable(true); item->setCheckable(true);
} }
} }
@ -161,13 +160,12 @@ void CheckList::onClose (finalcut::FCloseEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void CheckList::cb_showList (finalcut::FWidget*, data_ptr) void CheckList::cb_showList (finalcut::FWidget*, data_ptr)
{ {
finalcut::FListViewIterator iter = listView.beginOfList(); auto iter = listView.beginOfList();
finalcut::FString shopping_list; finalcut::FString shopping_list;
while ( iter != listView.endOfList() ) while ( iter != listView.endOfList() )
{ {
const finalcut::FListViewItem* item = \ const auto item = static_cast<finalcut::FListViewItem*>(*iter);
static_cast<finalcut::FListViewItem*>(*iter);
if ( item->isChecked() ) if ( item->isChecked() )
shopping_list << finalcut::fc::Bullet << ' ' shopping_list << finalcut::fc::Bullet << ' '

View File

@ -34,7 +34,7 @@ void preset (std::vector<finalcut::FRadioButton*>&);
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void cb_quit (finalcut::FWidget*, finalcut::FWidget::data_ptr data) void cb_quit (finalcut::FWidget*, finalcut::FWidget::data_ptr data)
{ {
finalcut::FDialog* dlg = static_cast<finalcut::FDialog*>(data); auto dlg = static_cast<finalcut::FDialog*>(data);
dlg->close(); dlg->close();
} }

View File

@ -31,7 +31,7 @@ void cb_quit (finalcut::FWidget*, finalcut::FWidget::data_ptr);
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void cb_quit (finalcut::FWidget*, finalcut::FWidget::data_ptr data) void cb_quit (finalcut::FWidget*, finalcut::FWidget::data_ptr data)
{ {
finalcut::FApplication* app = static_cast<finalcut::FApplication*>(data); auto app = static_cast<finalcut::FApplication*>(data);
app->quit(); app->quit();
} }

View File

@ -32,14 +32,14 @@ void cb_publish (finalcut::FWidget*, finalcut::FWidget::data_ptr);
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void cb_quit (finalcut::FWidget*, finalcut::FWidget::data_ptr data) void cb_quit (finalcut::FWidget*, finalcut::FWidget::data_ptr data)
{ {
finalcut::FApplication* app = static_cast<finalcut::FApplication*>(data); auto app = static_cast<finalcut::FApplication*>(data);
app->quit(); app->quit();
} }
void cb_publish (finalcut::FWidget* widget, finalcut::FWidget::data_ptr data) void cb_publish (finalcut::FWidget* widget, finalcut::FWidget::data_ptr data)
{ {
finalcut::FCheckBox* cbox1 = static_cast<finalcut::FCheckBox*>(widget); auto cbox1 = static_cast<finalcut::FCheckBox*>(widget);
finalcut::FCheckBox* cbox2 = static_cast<finalcut::FCheckBox*>(data); auto cbox2 = static_cast<finalcut::FCheckBox*>(data);
if ( cbox1->isChecked() ) if ( cbox1->isChecked() )
cbox2->setEnable(); cbox2->setEnable();

View File

@ -189,7 +189,7 @@ void Listview::onClose (finalcut::FCloseEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Listview::cb_showInMessagebox (finalcut::FWidget*, data_ptr) void Listview::cb_showInMessagebox (finalcut::FWidget*, data_ptr)
{ {
finalcut::FListViewItem* item = listView.getCurrentItem(); auto 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

@ -260,7 +260,7 @@ void Menu::defaultCallback (finalcut::FMenuList* mb)
{ {
for (uInt i = 1; i <= mb->getCount(); i++) for (uInt i = 1; i <= mb->getCount(); i++)
{ {
finalcut::FMenuItem* item = mb->getItem(int(i)); auto item = mb->getItem(int(i));
if ( item if ( item
&& item->isEnabled() && item->isEnabled()
@ -302,9 +302,8 @@ void Menu::onClose (finalcut::FCloseEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Menu::cb_message (finalcut::FWidget* widget, data_ptr) void Menu::cb_message (finalcut::FWidget* widget, data_ptr)
{ {
finalcut::FMenuItem* menuitem = \ auto menuitem = static_cast<finalcut::FMenuItem*>(widget);
static_cast<finalcut::FMenuItem*>(widget); auto text = menuitem->getText();
finalcut::FString text = menuitem->getText();
text = text.replace('&', ""); text = text.replace('&', "");
finalcut::FMessageBox::info ( this finalcut::FMessageBox::info ( this
, "Info" , "Info"

View File

@ -194,7 +194,7 @@ class AttribDemo : public finalcut::FWidget
// Event handler // Event handler
virtual void onWheel (finalcut::FWheelEvent* ev) virtual void onWheel (finalcut::FWheelEvent* ev)
{ {
AttribDlg* p = static_cast<AttribDlg*>(getParentWidget()); auto p = static_cast<AttribDlg*>(getParentWidget());
if ( p ) if ( p )
p->onWheel(ev); p->onWheel(ev);
@ -240,7 +240,7 @@ AttribDemo::AttribDemo (finalcut::FWidget* parent)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void AttribDemo::printColorLine() void AttribDemo::printColorLine()
{ {
AttribDlg* parent = static_cast<AttribDlg*>(getParent()); auto parent = static_cast<AttribDlg*>(getParent());
for (FColor color = 0; color < colors; color++) for (FColor color = 0; color < colors; color++)
{ {
@ -252,7 +252,7 @@ void AttribDemo::printColorLine()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void AttribDemo::printAltCharset() void AttribDemo::printAltCharset()
{ {
AttribDlg* parent = static_cast<AttribDlg*>(getParent()); auto parent = static_cast<AttribDlg*>(getParent());
if ( ! isMonochron() ) if ( ! isMonochron() )
setColor (wc.label_fg, wc.label_bg); setColor (wc.label_fg, wc.label_bg);

View File

@ -38,7 +38,7 @@ bool sortDescending (const finalcut::FObject*, const finalcut::FObject*);
//---------------------------------------------------------------------- //----------------------------------------------------------------------
long StringToLong (const finalcut::FString& str) long StringToLong (const finalcut::FString& str)
{ {
finalcut::FString NumString = str; auto NumString = str;
NumString = NumString.replace(",", ""); NumString = NumString.replace(",", "");
NumString = NumString.replace('.', ""); NumString = NumString.replace('.', "");
long number = NumString.toLong(); long number = NumString.toLong();
@ -49,8 +49,8 @@ long StringToLong (const finalcut::FString& str)
bool sortAscending ( const finalcut::FObject* lhs bool sortAscending ( const finalcut::FObject* lhs
, const finalcut::FObject* rhs ) , const finalcut::FObject* rhs )
{ {
const finalcut::FListViewItem* l_item = static_cast<const finalcut::FListViewItem*>(lhs); const auto& l_item = static_cast<const finalcut::FListViewItem*>(lhs);
const finalcut::FListViewItem* r_item = static_cast<const finalcut::FListViewItem*>(rhs); const auto& r_item = static_cast<const finalcut::FListViewItem*>(rhs);
const int column = l_item->getSortColumn(); const int column = l_item->getSortColumn();
switch ( column ) switch ( column )
@ -77,8 +77,8 @@ bool sortAscending ( const finalcut::FObject* lhs
bool sortDescending ( const finalcut::FObject* lhs bool sortDescending ( const finalcut::FObject* lhs
, const finalcut::FObject* rhs ) , const finalcut::FObject* rhs )
{ {
const finalcut::FListViewItem* l_item = static_cast<const finalcut::FListViewItem*>(lhs); const auto& l_item = static_cast<const finalcut::FListViewItem*>(lhs);
const finalcut::FListViewItem* r_item = static_cast<const finalcut::FListViewItem*>(rhs); const auto& r_item = static_cast<const finalcut::FListViewItem*>(rhs);
const int column = l_item->getSortColumn(); const int column = l_item->getSortColumn();
switch ( column ) switch ( column )
@ -334,15 +334,14 @@ Treeview::Treeview (finalcut::FWidget* parent)
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };
TreeItem* continent_list = continent; auto continent_list = continent;
while ( continent_list->name ) while ( continent_list->name )
{ {
TreeItem* country_list = continent_list->child_element; auto country_list = continent_list->child_element;
finalcut::FStringList continent_line ( continent_list->begin() finalcut::FStringList continent_line ( continent_list->begin()
, continent_list->end() ); , continent_list->end() );
finalcut::FListViewIterator::FObjectIterator iter = \ auto iter = listView.insert (continent_line);
listView.insert (continent_line);
while ( country_list && country_list->name ) while ( country_list && country_list->name )
{ {

View File

@ -127,7 +127,7 @@ void ProgressDialog::onShow (finalcut::FShowEvent*)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void ProgressDialog::onTimer (finalcut::FTimerEvent*) void ProgressDialog::onTimer (finalcut::FTimerEvent*)
{ {
std::size_t p = progressBar.getPercentage(); auto p = progressBar.getPercentage();
progressBar.setPercentage(++p); progressBar.setPercentage(++p);
flush_out(); flush_out();
@ -159,7 +159,7 @@ void ProgressDialog::cb_reset_bar (finalcut::FWidget*, data_ptr)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void ProgressDialog::cb_more_bar (finalcut::FWidget*, data_ptr) void ProgressDialog::cb_more_bar (finalcut::FWidget*, data_ptr)
{ {
std::size_t p = progressBar.getPercentage(); auto p = progressBar.getPercentage();
progressBar.setPercentage(++p); progressBar.setPercentage(++p);
} }
@ -733,9 +733,9 @@ void MyDialog::initWidgetsCallbacks()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MyDialog::adjustSize() void MyDialog::adjustSize()
{ {
std::size_t h = getParentWidget()->getHeight() - 4; auto h = getParentWidget()->getHeight() - 4;
setHeight (h, false); setHeight (h, false);
int X = int((getParentWidget()->getWidth() - getWidth()) / 2); auto X = int((getParentWidget()->getWidth() - getWidth()) / 2);
if ( X < 1 ) if ( X < 1 )
X = 1; X = 1;
@ -757,8 +757,8 @@ void MyDialog::onClose (finalcut::FCloseEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MyDialog::cb_noFunctionMsg (finalcut::FWidget* widget, data_ptr) void MyDialog::cb_noFunctionMsg (finalcut::FWidget* widget, data_ptr)
{ {
finalcut::FButton* button = static_cast<finalcut::FButton*>(widget); auto button = static_cast<finalcut::FButton*>(widget);
finalcut::FString text = button->getText(); auto text = button->getText();
text = text.replace('&', ""); text = text.replace('&', "");
finalcut::FMessageBox::error ( this finalcut::FMessageBox::error ( this
, "The \"" + text + "\" button has\n" , "The \"" + text + "\" button has\n"
@ -783,8 +783,8 @@ void MyDialog::cb_about (finalcut::FWidget*, data_ptr)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MyDialog::cb_terminfo (finalcut::FWidget*, data_ptr) void MyDialog::cb_terminfo (finalcut::FWidget*, data_ptr)
{ {
std::size_t x = getDesktopWidth(); auto x = getDesktopWidth();
std::size_t y = getDesktopHeight(); auto y = getDesktopHeight();
finalcut::FMessageBox info1 \ finalcut::FMessageBox info1 \
( (
"Environment" "Environment"
@ -884,16 +884,16 @@ void MyDialog::cb_clearInput (finalcut::FWidget*, data_ptr)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MyDialog::cb_input2buttonText (finalcut::FWidget* widget, data_ptr data) void MyDialog::cb_input2buttonText (finalcut::FWidget* widget, data_ptr data)
{ {
finalcut::FButton* button = static_cast<finalcut::FButton*>(widget); auto button = static_cast<finalcut::FButton*>(widget);
finalcut::FLineEdit* lineedit = static_cast<finalcut::FLineEdit*>(data); auto lineedit = static_cast<finalcut::FLineEdit*>(data);
button->setText( lineedit->getText() ); button->setText(lineedit->getText());
button->redraw(); button->redraw();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MyDialog::cb_setTitlebar (finalcut::FWidget* widget, data_ptr) void MyDialog::cb_setTitlebar (finalcut::FWidget* widget, data_ptr)
{ {
finalcut::FLineEdit* lineedit = static_cast<finalcut::FLineEdit*>(widget); auto lineedit = static_cast<finalcut::FLineEdit*>(widget);
finalcut::FString title; finalcut::FString title;
*lineedit >> title; *lineedit >> title;
setTermTitle (title); setTermTitle (title);
@ -904,17 +904,17 @@ void MyDialog::cb_setTitlebar (finalcut::FWidget* widget, data_ptr)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MyDialog::cb_ProgressBar (finalcut::FWidget*, data_ptr) void MyDialog::cb_ProgressBar (finalcut::FWidget*, data_ptr)
{ {
ProgressDialog* p_dgl = new ProgressDialog(this); auto p_dgl = new ProgressDialog(this);
p_dgl->show(); p_dgl->show();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MyDialog::cb_updateNumber (finalcut::FWidget* widget, data_ptr data) void MyDialog::cb_updateNumber (finalcut::FWidget* widget, data_ptr data)
{ {
finalcut::FListBox* list = static_cast<finalcut::FListBox*>(widget); auto list = static_cast<finalcut::FListBox*>(widget);
finalcut::FLabel* num = static_cast<finalcut::FLabel*>(data); auto num = static_cast<finalcut::FLabel*>(data);
auto count = list->getCount();
int select_num = 0; int select_num = 0;
std::size_t count = list->getCount();
for (std::size_t n = 1; n <= count; n++) for (std::size_t n = 1; n <= count; n++)
if ( list->isSelected(n) ) if ( list->isSelected(n) )
@ -928,8 +928,8 @@ void MyDialog::cb_updateNumber (finalcut::FWidget* widget, data_ptr data)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MyDialog::cb_activateButton (finalcut::FWidget* widget, data_ptr data) void MyDialog::cb_activateButton (finalcut::FWidget* widget, data_ptr data)
{ {
finalcut::FRadioButton* rb = static_cast<finalcut::FRadioButton*>(widget); auto rb = static_cast<finalcut::FRadioButton*>(widget);
finalcut::FButton* button = static_cast<finalcut::FButton*>(data); auto button = static_cast<finalcut::FButton*>(data);
if ( rb->isChecked() ) if ( rb->isChecked() )
button->setEnable(); button->setEnable();
@ -943,7 +943,7 @@ void MyDialog::cb_activateButton (finalcut::FWidget* widget, data_ptr data)
void MyDialog::cb_view (finalcut::FWidget*, data_ptr data) void MyDialog::cb_view (finalcut::FWidget*, data_ptr data)
{ {
finalcut::FString file; finalcut::FString file;
finalcut::FMenuItem* item = static_cast<finalcut::FMenuItem*>(data); auto item = static_cast<finalcut::FMenuItem*>(data);
if ( item && ! item->getText().isEmpty() ) if ( item && ! item->getText().isEmpty() )
file = item->getText(); file = item->getText();
@ -981,8 +981,8 @@ void MyDialog::cb_view (finalcut::FWidget*, data_ptr data)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MyDialog::cb_setInput (finalcut::FWidget* widget, data_ptr data) void MyDialog::cb_setInput (finalcut::FWidget* widget, data_ptr data)
{ {
finalcut::FListBox* ListBox = static_cast<finalcut::FListBox*>(widget); auto ListBox = static_cast<finalcut::FListBox*>(widget);
finalcut::FLineEdit* lineedit = static_cast<finalcut::FLineEdit*>(data); auto lineedit = static_cast<finalcut::FLineEdit*>(data);
*lineedit = ListBox->getItem(ListBox->currentItem()).getText(); *lineedit = ListBox->getItem(ListBox->currentItem()).getText();
lineedit->redraw(); lineedit->redraw();
} }

View File

@ -254,7 +254,7 @@ Window::Window (finalcut::FWidget* parent)
// 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; auto win_dat = new win_data;
win_dat->title.sprintf("Window %1d", n); win_dat->title.sprintf("Window %1d", n);
windows.push_back(win_dat); windows.push_back(win_dat);
} }
@ -263,12 +263,11 @@ Window::Window (finalcut::FWidget* parent)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
Window::~Window() Window::~Window()
{ {
std::vector<win_data*>::iterator iter; auto iter = windows.begin();
iter = windows.begin();
while ( iter != windows.end() ) while ( iter != windows.end() )
{ {
win_data* win_dat = *iter; auto win_dat = *iter;
// Remove all callbacks before Window::cb_destroyWindow() will be called // Remove all callbacks before Window::cb_destroyWindow() will be called
if ( win_dat->is_open && win_dat->dgl ) if ( win_dat->is_open && win_dat->dgl )
@ -337,7 +336,6 @@ void Window::activateWindow (finalcut::FDialog* win)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Window::adjustSize() void Window::adjustSize()
{ {
std::vector<win_data*>::const_iterator iter, first;
std::size_t w = getRootWidget()->getWidth(); std::size_t w = getRootWidget()->getWidth();
std::size_t h = getRootWidget()->getHeight(); std::size_t h = getRootWidget()->getHeight();
int X = int(1 + (w - 40) / 2) int X = int(1 + (w - 40) / 2)
@ -349,7 +347,8 @@ void Window::adjustSize()
Y = 2; Y = 2;
setPos (X, Y); setPos (X, Y);
iter = first = windows.begin(); auto first = windows.begin();
auto iter = first;
while ( iter != windows.end() ) while ( iter != windows.end() )
{ {
@ -404,10 +403,10 @@ void Window::onClose (finalcut::FCloseEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Window::cb_createWindows (finalcut::FWidget*, data_ptr) void Window::cb_createWindows (finalcut::FWidget*, data_ptr)
{ {
std::vector<win_data*>::const_iterator iter, first; auto first = windows.begin();
iter = first = windows.begin(); auto iter = first;
std::size_t w = getRootWidget()->getWidth(); auto w = getRootWidget()->getWidth();
std::size_t h = getRootWidget()->getHeight(); auto h = getRootWidget()->getHeight();
int dx = ( w > 80 ) ? int(w - 80) / 2 : 0; int dx = ( w > 80 ) ? int(w - 80) / 2 : 0;
int dy = ( h > 24 ) ? int(h - 24) / 2 : 0; int dy = ( h > 24 ) ? int(h - 24) / 2 : 0;
@ -415,8 +414,8 @@ void Window::cb_createWindows (finalcut::FWidget*, data_ptr)
{ {
if ( ! (*iter)->is_open ) if ( ! (*iter)->is_open )
{ {
win_data* win_dat = *iter; auto win_dat = *iter;
SmallWindow* win = new SmallWindow(this); auto 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);
@ -448,9 +447,8 @@ void Window::cb_closeWindows (finalcut::FWidget*, data_ptr)
if ( ! dialog_list || dialog_list->empty() ) if ( ! dialog_list || dialog_list->empty() )
return; return;
finalcut::FWidget::widgetList::const_iterator iter, first; auto iter = dialog_list->end();
iter = dialog_list->end(); auto first = dialog_list->begin();
first = dialog_list->begin();
activateWindow(this); activateWindow(this);
do do
@ -469,16 +467,14 @@ void Window::cb_next (finalcut::FWidget*, data_ptr)
if ( ! dialog_list || dialog_list->empty() ) if ( ! dialog_list || dialog_list->empty() )
return; return;
finalcut::FWidget::widgetList::const_iterator iter; auto iter = dialog_list->begin();
iter = dialog_list->begin();
while ( iter != dialog_list->end() ) while ( iter != dialog_list->end() )
{ {
if ( static_cast<finalcut::FWindow*>(*iter)->isWindowActive() ) if ( static_cast<finalcut::FWindow*>(*iter)->isWindowActive() )
{ {
finalcut::FDialog* next; finalcut::FDialog* next;
finalcut::FWidget::widgetList::const_iterator next_element; auto next_element = iter;
next_element = iter;
do do
{ {
@ -507,8 +503,7 @@ void Window::cb_previous (finalcut::FWidget*, data_ptr)
if ( ! dialog_list || dialog_list->empty() ) if ( ! dialog_list || dialog_list->empty() )
return; return;
finalcut::FWidget::widgetList::const_iterator iter; auto iter = dialog_list->end();
iter = dialog_list->end();
do do
{ {
@ -518,8 +513,7 @@ void Window::cb_previous (finalcut::FWidget*, data_ptr)
&& static_cast<finalcut::FWindow*>(*iter)->isWindowActive() ) && static_cast<finalcut::FWindow*>(*iter)->isWindowActive() )
{ {
finalcut::FDialog* prev; finalcut::FDialog* prev;
finalcut::FWidget::widgetList::const_iterator prev_element; auto prev_element = iter;
prev_element = iter;
do do
{ {
@ -543,7 +537,7 @@ void Window::cb_previous (finalcut::FWidget*, data_ptr)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Window::cb_destroyWindow (finalcut::FWidget*, data_ptr data) void Window::cb_destroyWindow (finalcut::FWidget*, data_ptr data)
{ {
win_data* win_dat = static_cast<win_data*>(data); auto win_dat = static_cast<win_data*>(data);
if ( win_dat ) if ( win_dat )
{ {

View File

@ -173,12 +173,13 @@ bool FApplication::sendEvent ( const FObject* receiver
if ( ! receiver->isWidget() ) if ( ! receiver->isWidget() )
return false; return false;
const FWidget* r_widget = static_cast<const FWidget*>(receiver); const auto r_widget = static_cast<const FWidget*>(receiver);
FWidget* widget = const_cast<FWidget*>(r_widget); auto widget = const_cast<FWidget*>(r_widget);
if ( modal_dialogs > 0 ) if ( modal_dialogs > 0 )
{ {
const FWidget* window; const FWidget* window;
if ( widget->isWindowWidget() ) if ( widget->isWindowWidget() )
window = widget; window = widget;
else else
@ -217,8 +218,8 @@ bool FApplication::sendEvent ( const FObject* receiver
return false; return false;
// For access to a protected base class member // For access to a protected base class member
const FApplication* const_w = static_cast<const FApplication*>(widget); auto const_w = static_cast<const FApplication*>(widget);
FApplication* w = const_cast<FApplication*>(const_w); auto w = const_cast<FApplication*>(const_w);
// Sends event event directly to receiver // Sends event event directly to receiver
return w->event(const_cast<FEvent*>(event)); return w->event(const_cast<FEvent*>(event));
@ -239,12 +240,10 @@ void FApplication::queueEvent ( const FObject* receiver
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::sendQueuedEvents() void FApplication::sendQueuedEvents()
{ {
eventQueue* events;
if ( ! eventInQueue() ) if ( ! eventInQueue() )
return; return;
events = event_queue; auto events = event_queue;
while ( ! eventInQueue() ) while ( ! eventInQueue() )
{ {
@ -266,7 +265,6 @@ bool FApplication::eventInQueue()
bool FApplication::removeQueuedEvent (const FObject* receiver) bool FApplication::removeQueuedEvent (const FObject* receiver)
{ {
bool retval; bool retval;
eventQueue::iterator iter;
if ( ! eventInQueue() ) if ( ! eventInQueue() )
return false; return false;
@ -275,7 +273,7 @@ bool FApplication::removeQueuedEvent (const FObject* receiver)
return false; return false;
retval = false; retval = false;
iter = event_queue->begin(); auto iter = event_queue->begin();
while ( iter != event_queue->end() ) while ( iter != event_queue->end() )
{ {
@ -499,8 +497,8 @@ inline void FApplication::findKeyboardWidget()
// Find the widget that has the keyboard focus // Find the widget that has the keyboard focus
FWidget* widget = nullptr; FWidget* widget = nullptr;
FWidget* focus = getFocusWidget(); auto focus = getFocusWidget();
FWidget* move_size = getMoveSizeWidget(); auto move_size = getMoveSizeWidget();
if ( focus ) if ( focus )
{ {
@ -644,7 +642,7 @@ inline void FApplication::sendKeyboardAccelerator()
// Windows keyboard accelerator // Windows keyboard accelerator
if ( ! accpt ) if ( ! accpt )
{ {
const FWidget* window = getActiveWindow(); auto window = static_cast<const FWidget*>(getActiveWindow());
if ( window ) if ( window )
accpt = processAccelerator (window); accpt = processAccelerator (window);
@ -653,7 +651,7 @@ inline void FApplication::sendKeyboardAccelerator()
// Global keyboard accelerator // Global keyboard accelerator
if ( ! accpt ) if ( ! accpt )
{ {
const FWidget* root_widget = getRootWidget(); auto root_widget = static_cast<const FWidget*>(getRootWidget());
if ( root_widget ) if ( root_widget )
processAccelerator (root_widget); processAccelerator (root_widget);
@ -690,11 +688,11 @@ bool FApplication::processDialogSwitchAccelerator()
if ( s > 0 && s >= n ) if ( s > 0 && s >= n )
{ {
// unset the move/size mode // unset the move/size mode
FWidget* move_size = getMoveSizeWidget(); auto move_size = getMoveSizeWidget();
if ( move_size ) if ( move_size )
{ {
FWidget* w = move_size; auto w = move_size;
setMoveSizeWidget(0); setMoveSizeWidget(0);
w->redraw(); w->redraw();
} }
@ -717,9 +715,8 @@ bool FApplication::processAccelerator (const FWidget*& widget)
&& widget->accelerator_list && widget->accelerator_list
&& ! widget->accelerator_list->empty() ) && ! widget->accelerator_list->empty() )
{ {
FWidget::Accelerators::const_iterator iter, last; auto iter = widget->accelerator_list->begin();
iter = widget->accelerator_list->begin(); auto last = widget->accelerator_list->end();
last = widget->accelerator_list->end();
while ( iter != last ) while ( iter != last )
{ {
@ -729,11 +726,11 @@ bool FApplication::processAccelerator (const FWidget*& widget)
if ( iter->key == keyboard->getKey() ) if ( iter->key == keyboard->getKey() )
{ {
// unset the move/size mode // unset the move/size mode
FWidget* move_size = getMoveSizeWidget(); auto move_size = getMoveSizeWidget();
if ( move_size ) if ( move_size )
{ {
FWidget* w = move_size; auto w = move_size;
setMoveSizeWidget(0); setMoveSizeWidget(0);
w->redraw(); w->redraw();
} }
@ -789,12 +786,12 @@ FWidget*& FApplication::determineClickedWidget()
const FPoint& mouse_position = mouse->getPos(); const FPoint& mouse_position = mouse->getPos();
// Determine the window object on the current click position // Determine the window object on the current click position
FWidget* window = FWindow::getWindowWidgetAt (mouse_position); auto window = FWindow::getWindowWidgetAt (mouse_position);
if ( window ) if ( window )
{ {
// Determine the widget at the current click position // Determine the widget at the current click position
FWidget* child = childWidgetAt (window, mouse_position); auto child = childWidgetAt (window, mouse_position);
clicked = ( child != 0 ) ? child : window; clicked = ( child != 0 ) ? child : window;
setClickedWidget (clicked); setClickedWidget (clicked);
} }
@ -807,11 +804,11 @@ void FApplication::unsetMoveSizeMode()
{ {
// Unset the move/size mode // Unset the move/size mode
FWidget* move_size = getMoveSizeWidget(); auto move_size = getMoveSizeWidget();
if ( move_size ) if ( move_size )
{ {
FWidget* w = move_size; auto w = move_size;
setMoveSizeWidget(0); setMoveSizeWidget(0);
w->redraw(); w->redraw();
} }
@ -822,8 +819,8 @@ void FApplication::closeOpenMenu()
{ {
// Close the open menu // Close the open menu
FWidget* openmenu = getOpenMenu(); auto openmenu = getOpenMenu();
FMenu* menu = static_cast<FMenu*>(openmenu); auto menu = static_cast<FMenu*>(openmenu);
if ( ! openmenu || ( mouse && mouse->isMoved()) ) if ( ! openmenu || ( mouse && mouse->isMoved()) )
return; return;
@ -837,7 +834,7 @@ void FApplication::closeOpenMenu()
} }
bool is_window_menu; bool is_window_menu;
FWidget* super = menu->getSuperMenu(); auto super = menu->getSuperMenu();
if ( super && menu->isWindowsMenu(super) ) if ( super && menu->isWindowsMenu(super) )
is_window_menu = true; is_window_menu = true;
@ -865,8 +862,8 @@ void FApplication::unselectMenubarItems()
{ {
// Unselect the menu bar items // Unselect the menu bar items
FWidget* openmenu = getOpenMenu(); auto openmenu = getOpenMenu();
FMenuBar* menu_bar = getMenuBar(); auto menu_bar = getMenuBar();
if ( openmenu || (mouse && mouse->isMoved()) ) if ( openmenu || (mouse && mouse->isMoved()) )
return; return;
@ -905,7 +902,7 @@ void FApplication::unselectMenubarItems()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::sendMouseEvent() void FApplication::sendMouseEvent()
{ {
FWidget* clicked = getClickedWidget(); auto clicked = getClickedWidget();
if ( ! clicked ) if ( ! clicked )
return; return;
@ -951,7 +948,7 @@ void FApplication::sendMouseMoveEvent ( const FPoint& widgetMousePos
if ( ! mouse ) if ( ! mouse )
return; return;
FWidget* clicked = getClickedWidget(); auto clicked = getClickedWidget();
if ( mouse->isLeftButtonPressed() ) if ( mouse->isLeftButtonPressed() )
{ {
@ -989,7 +986,7 @@ void FApplication::sendMouseLeftClickEvent ( const FPoint& widgetMousePos
if ( ! mouse ) if ( ! mouse )
return; return;
FWidget* clicked = getClickedWidget(); auto clicked = getClickedWidget();
if ( mouse->isLeftButtonDoubleClick() ) if ( mouse->isLeftButtonDoubleClick() )
{ {
@ -1013,7 +1010,7 @@ void FApplication::sendMouseLeftClickEvent ( const FPoint& widgetMousePos
, widgetMousePos , widgetMousePos
, mouse_position , mouse_position
, fc::LeftButton | key_state ); , fc::LeftButton | key_state );
FWidget* released_widget = clicked; auto released_widget = clicked;
if ( ! mouse->isRightButtonPressed() if ( ! mouse->isRightButtonPressed()
&& ! mouse->isMiddleButtonPressed() ) && ! mouse->isMiddleButtonPressed() )
@ -1031,7 +1028,7 @@ void FApplication::sendMouseRightClickEvent ( const FPoint& widgetMousePos
if ( ! mouse ) if ( ! mouse )
return; return;
FWidget* clicked = getClickedWidget(); auto clicked = getClickedWidget();
if ( mouse->isRightButtonPressed() ) if ( mouse->isRightButtonPressed() )
{ {
@ -1047,7 +1044,7 @@ void FApplication::sendMouseRightClickEvent ( const FPoint& widgetMousePos
, widgetMousePos , widgetMousePos
, mouse_position , mouse_position
, fc::RightButton | key_state ); , fc::RightButton | key_state );
FWidget* released_widget = clicked; auto released_widget = clicked;
if ( ! mouse->isLeftButtonPressed() if ( ! mouse->isLeftButtonPressed()
&& ! mouse->isMiddleButtonPressed() ) && ! mouse->isMiddleButtonPressed() )
@ -1065,7 +1062,7 @@ void FApplication::sendMouseMiddleClickEvent ( const FPoint& widgetMousePos
if ( ! mouse ) if ( ! mouse )
return; return;
FWidget* clicked = getClickedWidget(); auto clicked = getClickedWidget();
if ( mouse->isMiddleButtonPressed() ) if ( mouse->isMiddleButtonPressed() )
{ {
@ -1085,7 +1082,7 @@ void FApplication::sendMouseMiddleClickEvent ( const FPoint& widgetMousePos
, widgetMousePos , widgetMousePos
, mouse_position , mouse_position
, fc::MiddleButton | key_state ); , fc::MiddleButton | key_state );
FWidget* released_widget = clicked; auto released_widget = clicked;
if ( ! mouse->isLeftButtonPressed() if ( ! mouse->isLeftButtonPressed()
&& ! mouse->isRightButtonPressed() ) && ! mouse->isRightButtonPressed() )
@ -1104,7 +1101,7 @@ void FApplication::sendWheelEvent ( const FPoint& widgetMousePos
if ( ! mouse ) if ( ! mouse )
return; return;
FWidget* clicked = getClickedWidget(); auto clicked = getClickedWidget();
if ( mouse->isWheelUp() ) if ( mouse->isWheelUp() )
{ {
@ -1112,7 +1109,7 @@ void FApplication::sendWheelEvent ( const FPoint& widgetMousePos
, widgetMousePos , widgetMousePos
, mouse_position , mouse_position
, fc::WheelUp ); , fc::WheelUp );
FWidget* scroll_over_widget = clicked; auto scroll_over_widget = clicked;
setClickedWidget(0); setClickedWidget(0);
sendEvent(scroll_over_widget, &wheel_ev); sendEvent(scroll_over_widget, &wheel_ev);
} }
@ -1123,7 +1120,7 @@ void FApplication::sendWheelEvent ( const FPoint& widgetMousePos
, widgetMousePos , widgetMousePos
, mouse_position , mouse_position
, fc::WheelDown ); , fc::WheelDown );
FWidget* scroll_over_widget = clicked; auto scroll_over_widget = clicked;
setClickedWidget(0); setClickedWidget(0);
sendEvent (scroll_over_widget, &wheel_ev); sendEvent (scroll_over_widget, &wheel_ev);
} }
@ -1165,8 +1162,7 @@ void FApplication::processCloseWidget()
if ( close_widget && ! close_widget->empty() ) if ( close_widget && ! close_widget->empty() )
{ {
widgetList::iterator iter; auto iter = close_widget->begin();
iter = close_widget->begin();
while ( iter != close_widget->end() && *iter ) while ( iter != close_widget->end() && *iter )
{ {

View File

@ -220,7 +220,7 @@ void FButton::hide()
{ {
std::size_t s, f, size; std::size_t s, f, size;
FColor fg, bg; FColor fg, bg;
FWidget* parent_widget = getParentWidget(); auto parent_widget = getParentWidget();
FWidget::hide(); FWidget::hide();
if ( parent_widget ) if ( parent_widget )
@ -242,7 +242,7 @@ void FButton::hide()
if ( size == 0 ) if ( size == 0 )
return; return;
char* blank = createBlankArray(size + 1); auto blank = createBlankArray(size + 1);
for (std::size_t y = 0; y < getHeight() + s + (f << 1); y++) for (std::size_t y = 0; y < getHeight() + s + (f << 1); y++)
{ {
@ -291,7 +291,7 @@ void FButton::onMouseDown (FMouseEvent* ev)
if ( ! hasFocus() ) if ( ! hasFocus() )
{ {
FWidget* focused_widget = getFocusWidget(); auto focused_widget = getFocusWidget();
FFocusEvent out (fc::FocusOut_Event); FFocusEvent out (fc::FocusOut_Event);
FApplication::queueEvent(focused_widget, &out); FApplication::queueEvent(focused_widget, &out);
setFocus(); setFocus();
@ -360,7 +360,7 @@ void FButton::onAccel (FAccelEvent* ev)
if ( ! hasFocus() ) if ( ! hasFocus() )
{ {
FWidget* focused_widget = static_cast<FWidget*>(ev->focusedWidget()); auto focused_widget = static_cast<FWidget*>(ev->focusedWidget());
if ( focused_widget && focused_widget->isWidget() ) if ( focused_widget && focused_widget->isWidget() )
{ {
@ -683,7 +683,7 @@ inline void FButton::drawButtonTextLine (wchar_t button_text[])
void FButton::draw() void FButton::draw()
{ {
wchar_t* button_text; wchar_t* button_text;
FWidget* parent_widget = getParentWidget(); auto parent_widget = getParentWidget();
txtlength = text.getLength(); txtlength = text.getLength();
space_char = int(' '); space_char = int(' ');
active_focus = flags.active && flags.focus; active_focus = flags.active && flags.focus;

View File

@ -53,16 +53,14 @@ FButtonGroup::FButtonGroup (const FString& txt, FWidget* parent)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FButtonGroup::~FButtonGroup() // destructor FButtonGroup::~FButtonGroup() // destructor
{ {
FObjectIterator iter;
if ( buttonlist.empty() ) if ( buttonlist.empty() )
return; return;
iter = buttonlist.begin(); auto iter = buttonlist.begin();
while ( iter != buttonlist.end() ) while ( iter != buttonlist.end() )
{ {
FToggleButton* toggle_button = static_cast<FToggleButton*>(*iter); auto toggle_button = static_cast<FToggleButton*>(*iter);
toggle_button->setGroup(0); toggle_button->setGroup(0);
iter = buttonlist.erase(iter); iter = buttonlist.erase(iter);
} }
@ -73,14 +71,13 @@ FButtonGroup::~FButtonGroup() // destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FToggleButton* FButtonGroup::getButton (int index) const FToggleButton* FButtonGroup::getButton (int index) const
{ {
constFObjectIterator iter;
if ( buttonlist.empty() ) if ( buttonlist.empty() )
return 0; return 0;
if ( index <= 0 || index > int(getCount()) ) if ( index <= 0 || index > int(getCount()) )
return 0; return 0;
iter = buttonlist.begin(); auto iter = buttonlist.begin();
std::advance (iter, index - 1); std::advance (iter, index - 1);
return static_cast<FToggleButton*>(*iter); return static_cast<FToggleButton*>(*iter);
} }
@ -88,16 +85,16 @@ FToggleButton* FButtonGroup::getButton (int index) const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FToggleButton* FButtonGroup::getFirstButton() FToggleButton* FButtonGroup::getFirstButton()
{ {
FWidget* widget = FWidget::getFirstFocusableWidget(buttonlist); auto widget = FWidget::getFirstFocusableWidget(buttonlist);
FToggleButton* toggle_button = static_cast<FToggleButton*>(widget); auto toggle_button = static_cast<FToggleButton*>(widget);
return toggle_button; return toggle_button;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FToggleButton* FButtonGroup::getLastButton() FToggleButton* FButtonGroup::getLastButton()
{ {
FWidget* widget = FWidget::getLastFocusableWidget(buttonlist); auto widget = FWidget::getLastFocusableWidget(buttonlist);
FToggleButton* toggle_button = static_cast<FToggleButton*>(widget); auto toggle_button = static_cast<FToggleButton*>(widget);
return toggle_button; return toggle_button;
} }
@ -129,7 +126,7 @@ void FButtonGroup::setText (const FString& txt)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FButtonGroup::isChecked (int index) const bool FButtonGroup::isChecked (int index) const
{ {
FToggleButton* button = getButton(index); auto button = getButton(index);
if ( button ) if ( button )
return button->isChecked(); return button->isChecked();
@ -143,13 +140,12 @@ bool FButtonGroup::hasFocusedButton() const
if ( buttonlist.empty() ) if ( buttonlist.empty() )
return false; return false;
constFObjectIterator iter, last; auto iter = buttonlist.begin();
iter = buttonlist.begin(); auto last = buttonlist.end();
last = buttonlist.end();
while ( iter != last ) while ( iter != last )
{ {
FToggleButton* toggle_button = static_cast<FToggleButton*>(*iter); auto toggle_button = static_cast<FToggleButton*>(*iter);
if ( toggle_button->hasFocus() ) if ( toggle_button->hasFocus() )
return true; return true;
@ -166,13 +162,12 @@ bool FButtonGroup::hasCheckedButton() const
if ( buttonlist.empty() ) if ( buttonlist.empty() )
return false; return false;
constFObjectIterator iter, last; auto iter = buttonlist.begin();
iter = buttonlist.begin(); auto last = buttonlist.end();
last = buttonlist.end();
while ( iter != last ) while ( iter != last )
{ {
FToggleButton* toggle_button = static_cast<FToggleButton*>(*iter); auto toggle_button = static_cast<FToggleButton*>(*iter);
if ( toggle_button->isChecked() ) if ( toggle_button->isChecked() )
return true; return true;
@ -189,17 +184,16 @@ void FButtonGroup::hide()
std::size_t size; std::size_t size;
FColor fg, bg; FColor fg, bg;
FWidget::hide(); FWidget::hide();
FWidget* parent_widget = getParentWidget(); auto parent_widget = getParentWidget();
if ( ! buttonlist.empty() ) if ( ! buttonlist.empty() )
{ {
constFObjectIterator iter, last; auto iter = buttonlist.begin();
iter = buttonlist.begin(); auto last = buttonlist.end();
last = buttonlist.end();
while ( iter != last ) while ( iter != last )
{ {
FToggleButton* toggle_button = static_cast<FToggleButton*>(*iter); auto toggle_button = static_cast<FToggleButton*>(*iter);
toggle_button->hide(); toggle_button->hide();
++iter; ++iter;
} }
@ -222,7 +216,7 @@ void FButtonGroup::hide()
if ( size == 0 ) if ( size == 0 )
return; return;
char* blank = createBlankArray(size + 1); auto blank = createBlankArray(size + 1);
for (int y = 0; y < int(getHeight()); y++) for (int y = 0; y < int(getHeight()); y++)
{ {
@ -245,8 +239,7 @@ void FButtonGroup::insert (FToggleButton* button)
// setChecked the first FRadioButton // setChecked the first FRadioButton
if ( buttonlist.size() == 1 ) if ( buttonlist.size() == 1 )
{ {
FToggleButton* first_button; auto first_button = static_cast<FToggleButton*>(*buttonlist.begin());
first_button = static_cast<FToggleButton*>(*buttonlist.begin());
if ( isRadioButton(first_button) ) if ( isRadioButton(first_button) )
first_button->setChecked(); first_button->setChecked();
@ -265,16 +258,14 @@ void FButtonGroup::insert (FToggleButton* button)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FButtonGroup::remove (FToggleButton* button) void FButtonGroup::remove (FToggleButton* button)
{ {
FObjectIterator iter;
if ( ! button || buttonlist.empty() ) if ( ! button || buttonlist.empty() )
return; return;
iter = buttonlist.begin(); auto iter = buttonlist.begin();
while ( iter != buttonlist.end() ) while ( iter != buttonlist.end() )
{ {
FToggleButton* toggle_button = static_cast<FToggleButton*>(*iter); auto toggle_button = static_cast<FToggleButton*>(*iter);
if ( toggle_button == button ) if ( toggle_button == button )
{ {
@ -330,19 +321,18 @@ void FButtonGroup::onFocusIn (FFocusEvent* in_ev)
{ {
if ( hasCheckedButton() && ! buttonlist.empty() ) if ( hasCheckedButton() && ! buttonlist.empty() )
{ {
constFObjectIterator iter, last; auto iter = buttonlist.begin();
iter = buttonlist.begin(); auto last = buttonlist.end();
last = buttonlist.end();
while ( iter != last ) while ( iter != last )
{ {
FToggleButton* toggle_button = static_cast<FToggleButton*>(*iter); auto toggle_button = static_cast<FToggleButton*>(*iter);
if ( toggle_button->isChecked() ) if ( toggle_button->isChecked() )
{ {
if ( isRadioButton(toggle_button) ) if ( isRadioButton(toggle_button) )
{ {
FWidget* prev_element = getFocusWidget(); auto prev_element = getFocusWidget();
in_ev->ignore(); in_ev->ignore();
toggle_button->setFocus(); toggle_button->setFocus();
@ -368,7 +358,7 @@ void FButtonGroup::onFocusIn (FFocusEvent* in_ev)
if ( in_ev->isAccepted() ) if ( in_ev->isAccepted() )
{ {
in_ev->ignore(); in_ev->ignore();
FWidget* prev_element = getFocusWidget(); auto prev_element = getFocusWidget();
if ( in_ev->getFocusType() == fc::FocusNextWidget ) if ( in_ev->getFocusType() == fc::FocusNextWidget )
focusFirstChild(); focusFirstChild();
@ -393,8 +383,7 @@ void FButtonGroup::onFocusIn (FFocusEvent* in_ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FButtonGroup::cb_buttonToggled (FWidget* widget, data_ptr) void FButtonGroup::cb_buttonToggled (FWidget* widget, data_ptr)
{ {
FToggleButton* button = static_cast<FToggleButton*>(widget); auto button = static_cast<FToggleButton*>(widget);
constFObjectIterator iter, last;
if ( ! button->isChecked() ) if ( ! button->isChecked() )
return; return;
@ -402,12 +391,12 @@ void FButtonGroup::cb_buttonToggled (FWidget* widget, data_ptr)
if ( buttonlist.empty() ) if ( buttonlist.empty() )
return; return;
iter = buttonlist.begin(); auto iter = buttonlist.begin();
last = buttonlist.end(); auto last = buttonlist.end();
while ( iter != last ) while ( iter != last )
{ {
FToggleButton* toggle_button = static_cast<FToggleButton*>(*iter); auto toggle_button = static_cast<FToggleButton*>(*iter);
if ( toggle_button != button if ( toggle_button != button
&& toggle_button->isChecked() && toggle_button->isChecked()
@ -489,7 +478,6 @@ void FButtonGroup::draw()
void FButtonGroup::drawLabel() void FButtonGroup::drawLabel()
{ {
wchar_t* LabelText; wchar_t* LabelText;
std::size_t hotkeypos;
if ( text.isNull() || text.isEmpty() ) if ( text.isNull() || text.isEmpty() )
return; return;
@ -510,7 +498,7 @@ void FButtonGroup::drawLabel()
wchar_t* src = const_cast<wchar_t*>(txt.wc_str()); wchar_t* src = const_cast<wchar_t*>(txt.wc_str());
wchar_t* dest = const_cast<wchar_t*>(LabelText); wchar_t* dest = const_cast<wchar_t*>(LabelText);
unsetViewportPrint(); unsetViewportPrint();
hotkeypos = getHotkeyPos(src, dest, length); auto hotkeypos = getHotkeyPos(src, dest, length);
if ( hotkeypos != NOT_SET ) if ( hotkeypos != NOT_SET )
length--; length--;
@ -617,20 +605,19 @@ void FButtonGroup::directFocus()
if ( hasCheckedButton() && ! buttonlist.empty() ) if ( hasCheckedButton() && ! buttonlist.empty() )
{ {
constFObjectIterator iter, last; auto iter = buttonlist.begin();
iter = buttonlist.begin(); auto last = buttonlist.end();
last = buttonlist.end();
while ( iter != last ) while ( iter != last )
{ {
FToggleButton* toggle_button = static_cast<FToggleButton*>(*iter); auto toggle_button = static_cast<FToggleButton*>(*iter);
if ( toggle_button->isChecked() ) if ( toggle_button->isChecked() )
{ {
if ( isRadioButton(toggle_button) ) if ( isRadioButton(toggle_button) )
{ {
found_checked = true; found_checked = true;
FWidget* focused_widget = getFocusWidget(); auto focused_widget = getFocusWidget();
FFocusEvent out (fc::FocusOut_Event); FFocusEvent out (fc::FocusOut_Event);
FApplication::queueEvent(focused_widget, &out); FApplication::queueEvent(focused_widget, &out);
toggle_button->setFocus(); toggle_button->setFocus();
@ -653,7 +640,7 @@ void FButtonGroup::directFocus()
if ( ! found_checked ) if ( ! found_checked )
{ {
FWidget* focused_widget = getFocusWidget(); auto focused_widget = getFocusWidget();
FFocusEvent out (fc::FocusOut_Event); FFocusEvent out (fc::FocusOut_Event);
FApplication::queueEvent(focused_widget, &out); FApplication::queueEvent(focused_widget, &out);
focusFirstChild(); focusFirstChild();

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2015-2017 Markus Gans * * Copyright 2015-2018 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -61,7 +61,7 @@ void FCheckMenuItem::init (FWidget* parent)
if ( isMenu(parent) ) // Parent is menu if ( isMenu(parent) ) // Parent is menu
{ {
FMenu* menu_ptr = static_cast<FMenu*>(parent); auto menu_ptr = static_cast<FMenu*>(parent);
menu_ptr->has_checkable_items = true; menu_ptr->has_checkable_items = true;
} }
} }

View File

@ -50,7 +50,7 @@ FDialog::FDialog (const FString& txt, FWidget* parent)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FDialog::~FDialog() // destructor FDialog::~FDialog() // destructor
{ {
FApplication* fapp = static_cast<FApplication*>(getRootWidget()); auto fapp = static_cast<FApplication*>(getRootWidget());
bool is_quit = fapp->isQuit(); bool is_quit = fapp->isQuit();
delete dialog_menu; delete dialog_menu;
dgl_menuitem = nullptr; dgl_menuitem = nullptr;
@ -130,7 +130,7 @@ void FDialog::show()
if ( isModal() ) if ( isModal() )
{ {
FApplication* fapp = static_cast<FApplication*>(getRootWidget()); auto fapp = static_cast<FApplication*>(getRootWidget());
fapp->enter_loop(); fapp->enter_loop();
if ( this == getMainWidget() ) if ( this == getMainWidget() )
@ -145,7 +145,7 @@ void FDialog::hide()
if ( isModal() ) if ( isModal() )
{ {
FApplication* fapp = static_cast<FApplication*>(getRootWidget()); auto fapp = static_cast<FApplication*>(getRootWidget());
fapp->exit_loop(); fapp->exit_loop();
} }
} }
@ -334,9 +334,8 @@ void FDialog::setSize (std::size_t w, std::size_t h, bool adjust)
if ( window_list && ! window_list->empty() ) if ( window_list && ! window_list->empty() )
{ {
bool overlaid = false; bool overlaid = false;
widgetList::const_iterator iter, last; auto iter = window_list->begin();
iter = window_list->begin(); auto last = window_list->end();
last = window_list->end();
while ( iter != last ) while ( iter != last )
{ {
@ -351,7 +350,7 @@ void FDialog::setSize (std::size_t w, std::size_t h, bool adjust)
} }
// set the cursor to the focus widget // set the cursor to the focus widget
FWidget* focus = FWidget::getFocusWidget(); auto focus = FWidget::getFocusWidget();
if ( focus if ( focus
&& focus->isVisible() && focus->isVisible()
&& focus->hasVisibleCursor() ) && focus->hasVisibleCursor() )
@ -407,8 +406,8 @@ void FDialog::activateDialog()
if ( isWindowActive() ) if ( isWindowActive() )
return; return;
FWidget* old_focus = FWidget::getFocusWidget(); auto old_focus = FWidget::getFocusWidget();
FWidget* win_focus = getWindowFocusWidget(); auto win_focus = getWindowFocusWidget();
setActiveWindow(this); setActiveWindow(this);
setFocus(); setFocus();
setFocusWidget(this); setFocusWidget(this);
@ -637,12 +636,11 @@ void FDialog::onMouseDoubleClick (FMouseEvent* ev)
if ( title_button.contains(tPos) ) if ( title_button.contains(tPos) )
{ {
// Double click on title button // Double click on title button
FWidget* window_focus_widget;
dialog_menu->unselectItem(); dialog_menu->unselectItem();
dialog_menu->hide(); dialog_menu->hide();
activateWindow(); activateWindow();
raiseWindow(); raiseWindow();
window_focus_widget = getWindowFocusWidget(); auto window_focus_widget = getWindowFocusWidget();
if ( window_focus_widget ) if ( window_focus_widget )
window_focus_widget->setFocus(); window_focus_widget->setFocus();
@ -688,7 +686,7 @@ void FDialog::onWindowActive (FEvent*)
if ( ! FWidget::getFocusWidget() ) if ( ! FWidget::getFocusWidget() )
{ {
FWidget* win_focus = getWindowFocusWidget(); auto win_focus = getWindowFocusWidget();
if ( win_focus if ( win_focus
&& win_focus->isVisible() && win_focus->isVisible()
@ -731,9 +729,8 @@ void FDialog::onWindowRaised (FEvent*)
// Handle always-on-top windows // Handle always-on-top windows
if ( always_on_top_list && ! always_on_top_list->empty() ) if ( always_on_top_list && ! always_on_top_list->empty() )
{ {
widgetList::const_iterator iter, last; auto iter = always_on_top_list->begin();
iter = always_on_top_list->begin(); auto last = always_on_top_list->end();
last = always_on_top_list->end();
while ( iter != last ) while ( iter != last )
{ {
@ -746,16 +743,14 @@ void FDialog::onWindowRaised (FEvent*)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FDialog::onWindowLowered (FEvent*) void FDialog::onWindowLowered (FEvent*)
{ {
widgetList::const_iterator iter, last;
if ( ! window_list ) if ( ! window_list )
return; return;
if ( window_list->empty() ) if ( window_list->empty() )
return; return;
iter = window_list->begin(); auto iter = window_list->begin();
last = window_list->end(); auto last = window_list->end();
while ( iter != last ) while ( iter != last )
{ {
@ -829,7 +824,6 @@ void FDialog::onClose (FCloseEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FDialog::init() void FDialog::init()
{ {
FWidget* old_focus;
setTopPadding(2); setTopPadding(2);
setLeftPadding(1); setLeftPadding(1);
setBottomPadding(1); setBottomPadding(1);
@ -844,7 +838,7 @@ void FDialog::init()
setTransparentShadow(); setTransparentShadow();
setForegroundColor (wc.dialog_fg); setForegroundColor (wc.dialog_fg);
setBackgroundColor (wc.dialog_bg); setBackgroundColor (wc.dialog_bg);
old_focus = FWidget::getFocusWidget(); auto old_focus = FWidget::getFocusWidget();
if ( old_focus ) if ( old_focus )
{ {
@ -1204,9 +1198,8 @@ void FDialog::restoreOverlaidWindows()
return; return;
bool overlaid = false; bool overlaid = false;
widgetList::const_iterator iter, last; auto iter = window_list->begin();
iter = window_list->begin(); auto last = window_list->end();
last = window_list->end();
while ( iter != last ) while ( iter != last )
{ {
@ -1225,7 +1218,7 @@ void FDialog::setCursorToFocusWidget()
{ {
// Set the cursor to the focus widget // Set the cursor to the focus widget
FWidget* focus = FWidget::getFocusWidget(); auto focus = FWidget::getFocusWidget();
if ( focus if ( focus
&& focus->isVisible() && focus->isVisible()
@ -1285,9 +1278,8 @@ void FDialog::openMenu()
void FDialog::selectFirstMenuItem() void FDialog::selectFirstMenuItem()
{ {
// Focus to the first enabled menu item // Focus to the first enabled menu item
FMenuItem* first_item;
dialog_menu->selectFirstItem(); dialog_menu->selectFirstItem();
first_item = dialog_menu->getSelectedItem(); auto first_item = dialog_menu->getSelectedItem();
if ( first_item ) if ( first_item )
first_item->setFocus(); first_item->setFocus();
@ -1409,7 +1401,7 @@ inline void FDialog::passEventToSubMenu ( mouseStates& ms
try try
{ {
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p, g, b); auto _ev = new FMouseEvent (fc::MouseMove_Event, p, g, b);
dialog_menu->mouse_down = true; dialog_menu->mouse_down = true;
setClickedWidget(dialog_menu); setClickedWidget(dialog_menu);
dialog_menu->onMouseMove(_ev); dialog_menu->onMouseMove(_ev);
@ -1558,7 +1550,7 @@ void FDialog::resizeMouseUpMove (mouseStates& ms, bool mouse_up)
// Resize the dialog // Resize the dialog
if ( isResizeable() && ! resize_click_pos.isNull() ) if ( isResizeable() && ! resize_click_pos.isNull() )
{ {
FWidget* r = getRootWidget(); auto r = getRootWidget();
resize_click_pos = ms.termPos; resize_click_pos = ms.termPos;
int x2 = resize_click_pos.getX() int x2 = resize_click_pos.getX()
, y2 = resize_click_pos.getY() , y2 = resize_click_pos.getY()
@ -1659,8 +1651,7 @@ void FDialog::delDialog (FWidget* obj)
if ( ! dialog_list || dialog_list->empty() ) if ( ! dialog_list || dialog_list->empty() )
return; return;
widgetList::iterator iter; auto iter = dialog_list->begin();
iter = dialog_list->begin();
while ( iter != dialog_list->end() ) while ( iter != dialog_list->end() )
{ {

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2016-2017 Markus Gans * * Copyright 2016-2018 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -53,7 +53,7 @@ FDialogListMenu::~FDialogListMenu()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FDialogListMenu::init() void FDialogListMenu::init()
{ {
FMenuItem* menuitem = getItem(); auto menuitem = getItem();
menuitem->dialog_index = true; menuitem->dialog_index = true;
} }

View File

@ -310,7 +310,7 @@ void FFileDialog::adjustSize()
std::size_t max_width; std::size_t max_width;
std::size_t max_height; std::size_t max_height;
std::size_t h; std::size_t h;
FWidget* root_widget = getRootWidget(); auto root_widget = getRootWidget();
if ( root_widget ) if ( root_widget )
{ {
@ -352,10 +352,9 @@ void FFileDialog::init()
static const std::size_t w = 42; static const std::size_t w = 42;
static const std::size_t h = 15; static const std::size_t h = 15;
int x, y; int x, y;
FWidget* parent_widget;
setGeometry(1, 1, w, h, false); setGeometry(1, 1, w, h, false);
parent_widget = getParentWidget(); auto parent_widget = getParentWidget();
if ( parent_widget ) if ( parent_widget )
{ {
@ -468,14 +467,12 @@ inline bool FFileDialog::pattern_match ( const char* const pattern
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FFileDialog::clear() void FFileDialog::clear()
{ {
std::vector<dir_entry>::const_iterator iter, last;
if ( dir_entries.empty() ) if ( dir_entries.empty() )
return; return;
// delete all directory entries; // delete all directory entries;
iter = dir_entries.begin(); auto iter = dir_entries.begin();
last = dir_entries.end(); auto last = dir_entries.end();
while ( iter != last ) while ( iter != last )
{ {
@ -493,9 +490,8 @@ int FFileDialog::numOfDirs()
return 0; return 0;
int n = 0; int n = 0;
std::vector<dir_entry>::const_iterator iter, last; auto iter = dir_entries.begin();
iter = dir_entries.begin(); auto last = dir_entries.end();
last = dir_entries.end();
while ( iter != last ) while ( iter != last )
{ {
@ -672,9 +668,8 @@ void FFileDialog::dirEntriesToList()
if ( dir_entries.empty() ) if ( dir_entries.empty() )
return; return;
std::vector<dir_entry>::const_iterator iter, last; auto iter = dir_entries.begin();
iter = dir_entries.begin(); auto last = dir_entries.end();
last = dir_entries.end();
while ( iter != last ) while ( iter != last )
{ {
@ -720,11 +715,10 @@ int FFileDialog::changeDir (const FString& dirname)
else if ( ! dir_entries.empty() ) else if ( ! dir_entries.empty() )
{ {
std::size_t i = 1; std::size_t i = 1;
std::vector<dir_entry>::const_iterator iter, last;
const char* const baseName = \ const char* const baseName = \
basename(C_STR(lastdir.c_str())); basename(C_STR(lastdir.c_str()));
iter = dir_entries.begin(); auto iter = dir_entries.begin();
last = dir_entries.end(); auto last = dir_entries.end();
while ( iter != last ) while ( iter != last )
{ {
@ -812,10 +806,9 @@ void FFileDialog::cb_processActivate (FWidget*, data_ptr)
if ( ! dir_entries.empty() ) if ( ! dir_entries.empty() )
{ {
std::vector<dir_entry>::const_iterator iter, last;
const FString& input = filename.getText().trim(); const FString& input = filename.getText().trim();
iter = dir_entries.begin(); auto iter = dir_entries.begin();
last = dir_entries.end(); auto last = dir_entries.end();
while ( iter != last ) while ( iter != last )
{ {

View File

@ -90,7 +90,7 @@ void FKeyboard::fetchKeyCode()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const FString FKeyboard::getKeyName (FKey keynum) const FString FKeyboard::getKeyName (FKey keynum)
{ {
for (int i = 0; fc::FkeyName[i].string[0] != 0; i++) for (std::size_t i = 0; fc::FkeyName[i].string[0] != 0; i++)
if ( fc::FkeyName[i].num && fc::FkeyName[i].num == keynum ) if ( fc::FkeyName[i].num && fc::FkeyName[i].num == keynum )
return FString(fc::FkeyName[i].string); return FString(fc::FkeyName[i].string);
@ -215,7 +215,7 @@ inline FKey FKeyboard::getTermcapKey()
if ( ! key_map ) if ( ! key_map )
return NOT_SET; return NOT_SET;
for (int i = 0; key_map[i].tname[0] != 0; i++) for (std::size_t i = 0; key_map[i].tname[0] != 0; i++)
{ {
char* k = key_map[i].string; char* k = key_map[i].string;
std::size_t len = ( k ) ? std::strlen(k) : 0; std::size_t len = ( k ) ? std::strlen(k) : 0;
@ -245,7 +245,7 @@ inline FKey FKeyboard::getMetaKey()
assert ( FIFO_BUF_SIZE > 0 ); assert ( FIFO_BUF_SIZE > 0 );
for (int i = 0; fc::Fmetakey[i].string[0] != 0; i++) for (std::size_t i = 0; fc::Fmetakey[i].string[0] != 0; i++)
{ {
char* kmeta = fc::Fmetakey[i].string; // The string is never null char* kmeta = fc::Fmetakey[i].string; // The string is never null
std::size_t len = std::strlen(kmeta); std::size_t len = std::strlen(kmeta);
@ -419,7 +419,7 @@ void FKeyboard::parseKeyBuffer()
{ {
if ( bytesread + fifo_offset <= int(FIFO_BUF_SIZE) ) if ( bytesread + fifo_offset <= int(FIFO_BUF_SIZE) )
{ {
for (int i = 0; i < bytesread; i++) for (std::size_t i = 0; i < std::size_t(bytesread); i++)
{ {
fifo_buf[fifo_offset] = read_buf[i]; fifo_buf[fifo_offset] = read_buf[i];
fifo_offset++; fifo_offset++;

View File

@ -233,7 +233,7 @@ void FLabel::hide()
{ {
FColor fg, bg; FColor fg, bg;
std::size_t size; std::size_t size;
FWidget* parent_widget = getParentWidget(); auto parent_widget = getParentWidget();
FWidget::hide(); FWidget::hide();
@ -254,7 +254,7 @@ void FLabel::hide()
if ( size == 0 ) if ( size == 0 )
return; return;
char* blank = createBlankArray(size + 1); auto blank = createBlankArray(size + 1);
setPrintPos (1, 1); setPrintPos (1, 1);
print (blank); print (blank);
destroyBlankArray (blank); destroyBlankArray (blank);
@ -269,7 +269,7 @@ void FLabel::onMouseDown (FMouseEvent* ev)
if ( ! (isEnabled() && accel_widget) ) if ( ! (isEnabled() && accel_widget) )
{ {
// send click to the parent widget // send click to the parent widget
if ( FWidget* parent = getParentWidget() ) if ( auto parent = getParentWidget() )
{ {
int b = ev->getButton(); int b = ev->getButton();
const FPoint& tp = ev->getTermPos(); const FPoint& tp = ev->getTermPos();
@ -277,7 +277,7 @@ void FLabel::onMouseDown (FMouseEvent* ev)
try try
{ {
FMouseEvent* _ev = new FMouseEvent (fc::MouseDown_Event, p, tp, b); auto _ev = new FMouseEvent (fc::MouseDown_Event, p, tp, b);
FApplication::sendEvent (parent, _ev); FApplication::sendEvent (parent, _ev);
delete _ev; delete _ev;
} }
@ -294,7 +294,7 @@ void FLabel::onMouseDown (FMouseEvent* ev)
if ( ! accel_widget->hasFocus() ) if ( ! accel_widget->hasFocus() )
{ {
// focus the accelerator widget // focus the accelerator widget
FWidget* focused_widget = getFocusWidget(); auto focused_widget = getFocusWidget();
FFocusEvent out (fc::FocusOut_Event); FFocusEvent out (fc::FocusOut_Event);
FApplication::queueEvent(focused_widget, &out); FApplication::queueEvent(focused_widget, &out);
accel_widget->setFocus(); accel_widget->setFocus();
@ -321,7 +321,7 @@ void FLabel::onAccel (FAccelEvent* ev)
if ( ! accel_widget->hasFocus() ) if ( ! accel_widget->hasFocus() )
{ {
FWidget* focused_widget = static_cast<FWidget*>(ev->focusedWidget()); auto focused_widget = static_cast<FWidget*>(ev->focusedWidget());
if ( focused_widget && focused_widget->isWidget() ) if ( focused_widget && focused_widget->isWidget() )
{ {
@ -357,7 +357,7 @@ void FLabel::cb_accel_widget_destroyed (FWidget*, data_ptr)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FLabel::init() void FLabel::init()
{ {
FWidget* parent_widget = getParentWidget(); auto parent_widget = getParentWidget();
unsetFocusable(); unsetFocusable();
if ( parent_widget ) if ( parent_widget )
@ -523,8 +523,8 @@ void FLabel::drawMultiLine()
return; return;
} }
wchar_t* src = const_cast<wchar_t*>(multiline_text[y].wc_str()); auto src = const_cast<wchar_t*>(multiline_text[y].wc_str());
wchar_t* dest = const_cast<wchar_t*>(label_text); auto dest = const_cast<wchar_t*>(label_text);
if ( ! hotkey_printed ) if ( ! hotkey_printed )
hotkeypos = getHotkeyPos(src, dest, length); hotkeypos = getHotkeyPos(src, dest, length);

View File

@ -273,7 +273,7 @@ void FLineEdit::hide()
{ {
std::size_t s, size; std::size_t s, size;
FColor fg, bg; FColor fg, bg;
FWidget* parent_widget = getParentWidget(); auto parent_widget = getParentWidget();
FWidget::hide(); FWidget::hide();
@ -295,7 +295,7 @@ void FLineEdit::hide()
if ( size == 0 ) if ( size == 0 )
return; return;
char* blank = createBlankArray(size + 1); auto blank = createBlankArray(size + 1);
for (std::size_t y = 0; y < getHeight() + s; y++) for (std::size_t y = 0; y < getHeight() + s; y++)
{ {
@ -395,7 +395,7 @@ void FLineEdit::onMouseDown (FMouseEvent* ev)
if ( ! hasFocus() ) if ( ! hasFocus() )
{ {
FWidget* focused_widget = getFocusWidget(); auto focused_widget = getFocusWidget();
FFocusEvent out (fc::FocusOut_Event); FFocusEvent out (fc::FocusOut_Event);
FApplication::queueEvent(focused_widget, &out); FApplication::queueEvent(focused_widget, &out);
setFocus(); setFocus();
@ -558,7 +558,7 @@ void FLineEdit::onAccel (FAccelEvent* ev)
if ( ! hasFocus() ) if ( ! hasFocus() )
{ {
FWidget* focused_widget = static_cast<FWidget*>(ev->focusedWidget()); auto focused_widget = static_cast<FWidget*>(ev->focusedWidget());
if ( focused_widget && focused_widget->isWidget() ) if ( focused_widget && focused_widget->isWidget() )
{ {

View File

@ -135,7 +135,7 @@ void FListBox::setCurrentItem (listBoxItems::iterator iter)
void FListBox::showInsideBrackets ( std::size_t index void FListBox::showInsideBrackets ( std::size_t index
, fc::brackets_type b ) , fc::brackets_type b )
{ {
listBoxItems::iterator iter = index2iterator(index - 1); auto iter = index2iterator(index - 1);
iter->brackets = b; iter->brackets = b;
if ( b == fc::NoBrackets ) if ( b == fc::NoBrackets )
@ -217,7 +217,7 @@ void FListBox::hide()
{ {
std::size_t n, size; std::size_t n, size;
FColor fg, bg; FColor fg, bg;
FWidget* parent_widget = getParentWidget(); auto parent_widget = getParentWidget();
FWidget::hide(); FWidget::hide();
if ( parent_widget ) if ( parent_widget )
@ -238,7 +238,7 @@ void FListBox::hide()
if ( size == 0 ) if ( size == 0 )
return; return;
char* blank = createBlankArray(size + 1); auto blank = createBlankArray(size + 1);
for (int y = 0; y < int(getHeight()); y++) for (int y = 0; y < int(getHeight()); y++)
{ {
@ -295,7 +295,7 @@ void FListBox::remove (std::size_t item)
element_count = getCount(); element_count = getCount();
max_line_width = 0; max_line_width = 0;
listBoxItems::iterator iter = itemlist.begin(); auto iter = itemlist.begin();
while ( iter != itemlist.end() ) while ( iter != itemlist.end() )
{ {
@ -365,7 +365,7 @@ void FListBox::clear()
if ( size == 0 ) if ( size == 0 )
return; return;
char* blank = createBlankArray(size + 1); auto blank = createBlankArray(size + 1);
std::memset (blank, ' ', size); std::memset (blank, ' ', size);
blank[size] = '\0'; blank[size] = '\0';
@ -750,7 +750,7 @@ void FListBox::adjustYOffset (std::size_t element_count)
{ {
std::size_t height = getClientHeight(); std::size_t height = getClientHeight();
if ( height == 0 ) if ( height == 0 || element_count == 0 )
return; return;
if ( yoffset > int(element_count - height) ) if ( yoffset > int(element_count - height) )
@ -774,9 +774,6 @@ void FListBox::adjustSize()
std::size_t width = getClientWidth(); std::size_t width = getClientWidth();
std::size_t height = getClientHeight(); std::size_t height = getClientHeight();
if ( element_count == 0 )
return;
adjustYOffset (element_count); adjustYOffset (element_count);
int vmax = ( element_count > height ) int vmax = ( element_count > height )
@ -943,14 +940,11 @@ void FListBox::drawHeadline()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListBox::drawList() void FListBox::drawList()
{ {
std::size_t start, num;
listBoxItems::iterator iter;
if ( itemlist.empty() || getHeight() <= 2 || getWidth() <= 4 ) if ( itemlist.empty() || getHeight() <= 2 || getWidth() <= 4 )
return; return;
start = 0; std::size_t start = 0;
num = uInt(getHeight() - 2); std::size_t num = uInt(getHeight() - 2);
if ( num > getCount() ) if ( num > getCount() )
num = getCount(); num = getCount();
@ -966,7 +960,7 @@ void FListBox::drawList()
num = std::max(last_pos, current_pos) + 1; num = std::max(last_pos, current_pos) + 1;
} }
iter = index2iterator(start + std::size_t(yoffset)); auto iter = index2iterator(start + std::size_t(yoffset));
for (std::size_t y = start; y < num && iter != itemlist.end() ; y++) for (std::size_t y = start; y < num && iter != itemlist.end() ; y++)
{ {
@ -1277,7 +1271,7 @@ inline void FListBox::getWidgetFocus()
if ( hasFocus() ) if ( hasFocus() )
return; return;
FWidget* focused_widget = getFocusWidget(); auto focused_widget = getFocusWidget();
FFocusEvent out (fc::FocusOut_Event); FFocusEvent out (fc::FocusOut_Event);
FApplication::queueEvent(focused_widget, &out); FApplication::queueEvent(focused_widget, &out);
setFocus(); setFocus();
@ -1688,7 +1682,7 @@ inline bool FListBox::keySpace()
{ {
inc_search += L' '; inc_search += L' ';
bool inc_found = false; bool inc_found = false;
listBoxItems::iterator iter = itemlist.begin(); auto iter = itemlist.begin();
while ( iter != itemlist.end() ) while ( iter != itemlist.end() )
{ {
@ -1763,7 +1757,7 @@ inline bool FListBox::keyBackspace()
if ( inc_len > 1 ) if ( inc_len > 1 )
{ {
listBoxItems::iterator iter = itemlist.begin(); auto iter = itemlist.begin();
while ( iter != itemlist.end() ) while ( iter != itemlist.end() )
{ {
@ -1798,7 +1792,7 @@ inline bool FListBox::keyIncSearchInput (FKey key)
std::size_t inc_len = inc_search.getLength(); std::size_t inc_len = inc_search.getLength();
bool inc_found = false; bool inc_found = false;
listBoxItems::iterator iter = itemlist.begin(); auto iter = itemlist.begin();
while ( iter != itemlist.end() ) while ( iter != itemlist.end() )
{ {

View File

@ -45,10 +45,8 @@ bool sortDescendingByNumber (const FObject*, const FObject*);
//---------------------------------------------------------------------- //----------------------------------------------------------------------
long firstNumberFromString (const FString& str) long firstNumberFromString (const FString& str)
{ {
const FString::iterator last = str.end(); auto last = str.end();
FString::iterator iter = str.begin(); auto iter = str.begin();
FString::iterator first_pos;
FString::iterator last_pos;
std::size_t pos; std::size_t pos;
std::size_t length; std::size_t length;
long number; long number;
@ -66,7 +64,7 @@ long firstNumberFromString (const FString& str)
++iter; ++iter;
} }
first_pos = iter; auto first_pos = iter;
if ( first_pos == last ) if ( first_pos == last )
return 0; return 0;
@ -79,14 +77,14 @@ long firstNumberFromString (const FString& str)
++iter; ++iter;
} }
last_pos = iter; auto last_pos = iter;
if ( last_pos == last ) if ( last_pos == last )
return 0; return 0;
pos = std::size_t(std::distance(str.begin(), first_pos)) + 1; pos = std::size_t(std::distance(str.begin(), first_pos)) + 1;
length = std::size_t(std::distance(first_pos, last_pos)); length = std::size_t(std::distance(first_pos, last_pos));
const FString num_str = str.mid(pos, length); const auto& num_str = str.mid(pos, length);
try try
{ {
@ -103,11 +101,11 @@ long firstNumberFromString (const FString& str)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool sortAscendingByName (const FObject* lhs, const FObject* rhs) bool sortAscendingByName (const FObject* lhs, const FObject* rhs)
{ {
const FListViewItem* l_item = static_cast<const FListViewItem*>(lhs); const auto l_item = static_cast<const FListViewItem*>(lhs);
const FListViewItem* r_item = static_cast<const FListViewItem*>(rhs); const auto r_item = static_cast<const FListViewItem*>(rhs);
const int column = l_item->getSortColumn(); const int column = l_item->getSortColumn();
const FString l_string = l_item->getText(column); const auto& l_string = l_item->getText(column);
const FString r_string = r_item->getText(column); const auto& r_string = r_item->getText(column);
// lhs < rhs // lhs < rhs
return bool( strcasecmp(l_string.c_str(), r_string.c_str()) < 0 ); return bool( strcasecmp(l_string.c_str(), r_string.c_str()) < 0 );
@ -116,11 +114,11 @@ bool sortAscendingByName (const FObject* lhs, const FObject* rhs)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool sortDescendingByName (const FObject* lhs, const FObject* rhs) bool sortDescendingByName (const FObject* lhs, const FObject* rhs)
{ {
const FListViewItem* l_item = static_cast<const FListViewItem*>(lhs); const auto l_item = static_cast<const FListViewItem*>(lhs);
const FListViewItem* r_item = static_cast<const FListViewItem*>(rhs); const auto r_item = static_cast<const FListViewItem*>(rhs);
const int column = l_item->getSortColumn(); const int column = l_item->getSortColumn();
const FString l_string = l_item->getText(column); const auto& l_string = l_item->getText(column);
const FString r_string = r_item->getText(column); const auto& r_string = r_item->getText(column);
// lhs > rhs // lhs > rhs
return bool( strcasecmp(l_string.c_str(), r_string.c_str()) > 0 ); return bool( strcasecmp(l_string.c_str(), r_string.c_str()) > 0 );
@ -129,11 +127,11 @@ bool sortDescendingByName (const FObject* lhs, const FObject* rhs)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool sortAscendingByNumber (const FObject* lhs, const FObject* rhs) bool sortAscendingByNumber (const FObject* lhs, const FObject* rhs)
{ {
const FListViewItem* l_item = static_cast<const FListViewItem*>(lhs); const auto l_item = static_cast<const FListViewItem*>(lhs);
const FListViewItem* r_item = static_cast<const FListViewItem*>(rhs); const auto r_item = static_cast<const FListViewItem*>(rhs);
const int column = l_item->getSortColumn(); const int column = l_item->getSortColumn();
const long l_number = firstNumberFromString(l_item->getText(column)); const auto& l_number = firstNumberFromString(l_item->getText(column));
const long r_number = firstNumberFromString(r_item->getText(column)); const auto& r_number = firstNumberFromString(r_item->getText(column));
// lhs < rhs // lhs < rhs
return bool( l_number < r_number ); return bool( l_number < r_number );
@ -142,11 +140,11 @@ bool sortAscendingByNumber (const FObject* lhs, const FObject* rhs)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool sortDescendingByNumber (const FObject* lhs, const FObject* rhs) bool sortDescendingByNumber (const FObject* lhs, const FObject* rhs)
{ {
const FListViewItem* l_item = static_cast<const FListViewItem*>(lhs); const auto l_item = static_cast<const FListViewItem*>(lhs);
const FListViewItem* r_item = static_cast<const FListViewItem*>(rhs); const auto r_item = static_cast<const FListViewItem*>(rhs);
const int column = l_item->getSortColumn(); const int column = l_item->getSortColumn();
const long l_number = firstNumberFromString(l_item->getText(column)); const auto& l_number = firstNumberFromString(l_item->getText(column));
const long r_number = firstNumberFromString(r_item->getText(column)); const auto& r_number = firstNumberFromString(r_item->getText(column));
// lhs > rhs // lhs > rhs
return bool( l_number > r_number ); return bool( l_number > r_number );
@ -164,7 +162,7 @@ FListViewItem::FListViewItem (const FListViewItem& item)
, column_list(item.column_list) , column_list(item.column_list)
, data_pointer(item.data_pointer) , data_pointer(item.data_pointer)
{ {
FObject* parent = getParent(); auto parent = getParent();
if ( ! parent ) if ( ! parent )
return; return;
@ -213,7 +211,7 @@ int FListViewItem::getSortColumn() const
if ( ! *root ) if ( ! *root )
return -1; return -1;
FListView* root_obj = static_cast<FListView*>(*root); auto root_obj = static_cast<FListView*>(*root);
return root_obj->getSortColumn(); return root_obj->getSortColumn();
} }
@ -233,11 +231,11 @@ FString FListViewItem::getText (int column) const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
uInt FListViewItem::getDepth() const uInt FListViewItem::getDepth() const
{ {
FObject* parent = getParent(); auto parent = getParent();
if ( parent && parent->isInstanceOf("FListViewItem") ) if ( parent && parent->isInstanceOf("FListViewItem") )
{ {
FListViewItem* parent_item = static_cast<FListViewItem*>(parent); auto parent_item = static_cast<FListViewItem*>(parent);
return parent_item->getDepth() + 1; return parent_item->getDepth() + 1;
} }
@ -254,11 +252,11 @@ void FListViewItem::setText (int column, const FString& text)
// Convert column position to address offset (index) // Convert column position to address offset (index)
std::size_t index = uInt(column - 1); std::size_t index = uInt(column - 1);
FObject* parent = getParent(); auto parent = getParent();
if ( parent && parent->isInstanceOf("FListView") ) if ( parent && parent->isInstanceOf("FListView") )
{ {
FListView* listview = static_cast<FListView*>(parent); auto listview = static_cast<FListView*>(parent);
if ( ! listview->header[index].fixed_width ) if ( ! listview->header[index].fixed_width )
{ {
@ -294,13 +292,13 @@ FObject::FObjectIterator FListViewItem::insert ( FListViewItem* child
if ( (*parent_iter)->isInstanceOf("FListView") ) if ( (*parent_iter)->isInstanceOf("FListView") )
{ {
// Add FListViewItem to a FListView parent // Add FListViewItem to a FListView parent
FListView* parent = static_cast<FListView*>(*parent_iter); auto parent = static_cast<FListView*>(*parent_iter);
return parent->insert (child); return parent->insert (child);
} }
else if ( (*parent_iter)->isInstanceOf("FListViewItem") ) else if ( (*parent_iter)->isInstanceOf("FListViewItem") )
{ {
// Add FListViewItem to a FListViewItem parent // Add FListViewItem to a FListViewItem parent
FListViewItem* parent = static_cast<FListViewItem*>(*parent_iter); auto parent = static_cast<FListViewItem*>(*parent_iter);
return parent->insert (child); return parent->insert (child);
} }
} }
@ -342,18 +340,8 @@ void FListViewItem::sort (Compare cmp)
children.sort(cmp); children.sort(cmp);
// Sort the sublevels // Sort the sublevels
FListViewIterator iter = begin(); for (auto&& item : children)
static_cast<FListViewItem*>(item)->sort(cmp);
while ( iter != end() )
{
if ( *iter )
{
FListViewItem* item = static_cast<FListViewItem*>(*iter);
item->sort(cmp);
}
++iter;
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -371,7 +359,7 @@ FObject::FObjectIterator FListViewItem::appendItem (FListViewItem* child)
void FListViewItem::replaceControlCodes() void FListViewItem::replaceControlCodes()
{ {
// Replace the control codes characters // Replace the control codes characters
FStringList::iterator iter = column_list.begin(); auto iter = column_list.begin();
while ( iter != column_list.end() ) while ( iter != column_list.end() )
{ {
@ -392,11 +380,11 @@ std::size_t FListViewItem::getVisibleLines()
return visible_lines; return visible_lines;
} }
constFObjectIterator iter = FObject::begin(); auto iter = FObject::begin();
while ( iter != FObject::end() ) while ( iter != FObject::end() )
{ {
FListViewItem* child = static_cast<FListViewItem*>(*iter); auto child = static_cast<FListViewItem*>(*iter);
visible_lines += child->getVisibleLines(); visible_lines += child->getVisibleLines();
++iter; ++iter;
} }
@ -411,7 +399,7 @@ void FListViewItem::setCheckable (bool on)
if ( *root ) if ( *root )
{ {
FListView* root_obj = static_cast<FListView*>(*root); auto root_obj = static_cast<FListView*>(*root);
if ( ! root_obj->hasCheckableItems() && isCheckable() ) if ( ! root_obj->hasCheckableItems() && isCheckable() )
root_obj->has_checkable_items = true; root_obj->has_checkable_items = true;
@ -422,11 +410,11 @@ void FListViewItem::setCheckable (bool on)
void FListViewItem::resetVisibleLineCounter() void FListViewItem::resetVisibleLineCounter()
{ {
visible_lines = 0; visible_lines = 0;
FObject* parent = getParent(); auto parent = getParent();
if ( parent && parent->isInstanceOf("FListViewItem") ) if ( parent && parent->isInstanceOf("FListViewItem") )
{ {
FListViewItem* parent_item = static_cast<FListViewItem*>(parent); auto parent_item = static_cast<FListViewItem*>(parent);
return parent_item->resetVisibleLineCounter(); return parent_item->resetVisibleLineCounter();
} }
} }
@ -502,7 +490,7 @@ FListViewIterator& FListViewIterator::operator -= (volatile int n)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListViewIterator::nextElement (FObjectIterator& iter) void FListViewIterator::nextElement (FObjectIterator& iter)
{ {
FListViewItem* item = static_cast<FListViewItem*>(*iter); auto item = static_cast<FListViewItem*>(*iter);
if ( item->isExpandable() && item->isExpand() ) if ( item->isExpandable() && item->isExpand() )
{ {
@ -517,7 +505,7 @@ void FListViewIterator::nextElement (FObjectIterator& iter)
if ( ! iter_path.empty() ) if ( ! iter_path.empty() )
{ {
FObjectIterator& parent_iter = iter_path.top(); auto& parent_iter = iter_path.top();
if ( iter == (*parent_iter)->end() ) if ( iter == (*parent_iter)->end() )
{ {
@ -532,12 +520,11 @@ void FListViewIterator::nextElement (FObjectIterator& iter)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListViewIterator::prevElement (FObjectIterator& iter) void FListViewIterator::prevElement (FObjectIterator& iter)
{ {
FListViewItem* item; auto start_iter = iter;
FObjectIterator start_iter = iter;
if ( ! iter_path.empty() ) if ( ! iter_path.empty() )
{ {
FObjectIterator& parent_iter = iter_path.top(); auto& parent_iter = iter_path.top();
if ( start_iter == (*parent_iter)->begin() ) if ( start_iter == (*parent_iter)->begin() )
{ {
@ -549,7 +536,7 @@ void FListViewIterator::prevElement (FObjectIterator& iter)
} }
--iter; --iter;
item = static_cast<FListViewItem*>(*iter); auto item = static_cast<FListViewItem*>(*iter);
if ( iter == start_iter ) if ( iter == start_iter )
return; return;
@ -571,7 +558,7 @@ void FListViewIterator::parentElement()
if ( iter_path.empty() ) if ( iter_path.empty() )
return; return;
FObjectIterator& parent_iter = iter_path.top(); auto& parent_iter = iter_path.top();
while ( node != parent_iter ) while ( node != parent_iter )
prevElement(node); prevElement(node);
@ -603,11 +590,11 @@ FListView::~FListView() // destructor
std::size_t FListView::getCount() std::size_t FListView::getCount()
{ {
int n = 0; int n = 0;
FObjectIterator iter = itemlist.begin(); auto iter = itemlist.begin();
while ( iter != itemlist.end() ) while ( iter != itemlist.end() )
{ {
FListViewItem* item = static_cast<FListViewItem*>(*iter); auto item = static_cast<FListViewItem*>(*iter);
n += item->getVisibleLines(); n += item->getVisibleLines();
++iter; ++iter;
} }
@ -782,13 +769,13 @@ FObject::FObjectIterator FListView::insert ( FListViewItem* item
if ( (*parent_iter)->isInstanceOf("FListView") ) if ( (*parent_iter)->isInstanceOf("FListView") )
{ {
// Add FListViewItem to a FListView parent // Add FListViewItem to a FListView parent
FListView* parent = static_cast<FListView*>(*parent_iter); auto parent = static_cast<FListView*>(*parent_iter);
item_iter = parent->appendItem (item); item_iter = parent->appendItem (item);
} }
else if ( (*parent_iter)->isInstanceOf("FListViewItem") ) else if ( (*parent_iter)->isInstanceOf("FListViewItem") )
{ {
// Add FListViewItem to a FListViewItem parent // Add FListViewItem to a FListViewItem parent
FListViewItem* parent = static_cast<FListViewItem*>(*parent_iter); auto parent = static_cast<FListViewItem*>(*parent_iter);
item_iter = parent->appendItem (item); item_iter = parent->appendItem (item);
} }
else else
@ -833,7 +820,6 @@ FObject::FObjectIterator FListView::insert ( const std::vector<long>& cols
, data_ptr d , data_ptr d
, FObjectIterator parent_iter ) , FObjectIterator parent_iter )
{ {
FObjectIterator item_iter;
FStringList str_cols; FStringList str_cols;
if ( ! cols.empty() ) if ( ! cols.empty() )
@ -842,7 +828,7 @@ FObject::FObjectIterator FListView::insert ( const std::vector<long>& cols
str_cols.push_back (FString().setNumber(cols[i])); str_cols.push_back (FString().setNumber(cols[i]));
} }
item_iter = insert (str_cols, d, parent_iter); auto item_iter = insert (str_cols, d, parent_iter);
return item_iter; return item_iter;
} }
@ -996,7 +982,7 @@ void FListView::onMouseDown (FMouseEvent* ev)
if ( ! hasFocus() ) if ( ! hasFocus() )
{ {
FWidget* focused_widget = getFocusWidget(); auto focused_widget = getFocusWidget();
FFocusEvent out (fc::FocusOut_Event); FFocusEvent out (fc::FocusOut_Event);
FApplication::queueEvent(focused_widget, &out); FApplication::queueEvent(focused_widget, &out);
setFocus(); setFocus();
@ -1026,7 +1012,7 @@ void FListView::onMouseDown (FMouseEvent* ev)
if ( new_pos < int(getCount()) ) if ( new_pos < int(getCount()) )
setRelativePosition (mouse_y - 2); setRelativePosition (mouse_y - 2);
const FListViewItem* item = getCurrentItem(); const auto item = getCurrentItem();
if ( tree_view ) if ( tree_view )
{ {
@ -1084,7 +1070,7 @@ void FListView::onMouseUp (FMouseEvent* ev)
else if ( mouse_y > 1 && mouse_y < int(getHeight()) ) // List else if ( mouse_y > 1 && mouse_y < int(getHeight()) ) // List
{ {
int indent = 0; int indent = 0;
FListViewItem* item = getCurrentItem(); auto item = getCurrentItem();
if ( tree_view ) if ( tree_view )
{ {
@ -1191,7 +1177,7 @@ void FListView::onMouseDoubleClick (FMouseEvent* ev)
if ( first_visible_line.getPosition() + mouse_y - 1 > int(getCount()) ) if ( first_visible_line.getPosition() + mouse_y - 1 > int(getCount()) )
return; return;
FListViewItem* item = getCurrentItem(); auto item = getCurrentItem();
if ( tree_view && item->isExpandable() ) if ( tree_view && item->isExpandable() )
{ {
@ -1318,7 +1304,7 @@ void FListView::adjustViewport (int element_count)
{ {
int height = int(getClientHeight()); int height = int(getClientHeight());
if ( height <= 0 ) if ( height <= 0 || element_count == 0 )
return; return;
if ( element_count < height ) if ( element_count < height )
@ -1361,9 +1347,6 @@ void FListView::adjustSize()
std::size_t width = getClientWidth(); std::size_t width = getClientWidth();
std::size_t height = getClientHeight(); std::size_t height = getClientHeight();
if ( element_count == 0 )
return;
adjustViewport (int(element_count)); adjustViewport (int(element_count));
int vmax = ( element_count > height ) int vmax = ( element_count > height )
@ -1454,18 +1437,8 @@ void FListView::sort (Compare cmp)
itemlist.sort(cmp); itemlist.sort(cmp);
// Sort the sublevels // Sort the sublevels
FListViewIterator iter = itemlist.begin(); for (auto&& item : itemlist)
static_cast<FListViewItem*>(item)->sort(cmp);
while ( iter != itemlist.end() )
{
if ( *iter )
{
FListViewItem* item = static_cast<FListViewItem*>(*iter);
item->sort(cmp);
}
++iter;
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1551,7 +1524,6 @@ void FListView::draw()
void FListView::drawHeadlines() void FListView::drawHeadlines()
{ {
std::vector<charData>::const_iterator first, last; std::vector<charData>::const_iterator first, last;
headerItems::const_iterator iter;
if ( header.empty() if ( header.empty()
|| getHeight() <= 2 || getHeight() <= 2
@ -1559,7 +1531,7 @@ void FListView::drawHeadlines()
|| max_line_width < 1 ) || max_line_width < 1 )
return; return;
iter = header.begin(); headerItems::const_iterator iter = header.begin();
headerline.clear(); headerline.clear();
if ( hasCheckableItems() ) if ( hasCheckableItems() )
@ -1602,20 +1574,17 @@ void FListView::drawHeadlines()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::drawList() void FListView::drawList()
{ {
uInt page_height, y;
FListViewIterator iter;
if ( itemlist.empty() || getHeight() <= 2 || getWidth() <= 4 ) if ( itemlist.empty() || getHeight() <= 2 || getWidth() <= 4 )
return; return;
y = 0; uInt y = 0;
page_height = uInt(getHeight() - 2); uInt page_height = uInt(getHeight() - 2);
iter = first_visible_line; auto iter = first_visible_line;
while ( iter != itemlist.end() && y < page_height ) while ( iter != itemlist.end() && y < page_height )
{ {
bool is_current_line = bool( iter == current_iter ); bool is_current_line = bool( iter == current_iter );
const FListViewItem* item = static_cast<FListViewItem*>(*iter); const auto item = static_cast<FListViewItem*>(*iter);
int tree_offset = ( tree_view ) ? int(item->getDepth() << 1) + 1 : 0; int tree_offset = ( tree_view ) ? int(item->getDepth() << 1) + 1 : 0;
int checkbox_offset = ( item->isCheckable() ) ? 1 : 0; int checkbox_offset = ( item->isCheckable() ) ? 1 : 0;
setPrintPos (2, 2 + int(y)); setPrintPos (2, 2 + int(y));
@ -1941,8 +1910,7 @@ std::size_t FListView::determineLineWidth (FListViewItem* item)
std::size_t line_width = padding_space; // leading space std::size_t line_width = padding_space; // leading space
uInt column_idx = 0; uInt column_idx = 0;
uInt entries = uInt(item->column_list.size()); uInt entries = uInt(item->column_list.size());
headerItems::iterator header_iter; headerItems::iterator header_iter = header.begin();
header_iter = header.begin();
while ( header_iter != header.end() ) while ( header_iter != header.end() )
{ {
@ -2039,8 +2007,7 @@ void FListView::mouseHeaderClicked()
int checkbox_offset = ( hasCheckableItems() ) ? 4 : 0; int checkbox_offset = ( hasCheckableItems() ) ? 4 : 0;
int header_start = 2 + checkbox_offset; int header_start = 2 + checkbox_offset;
int header_pos = clicked_header_pos.getX() + xoffset; int header_pos = clicked_header_pos.getX() + xoffset;
headerItems::const_iterator iter; headerItems::const_iterator iter = header.begin();
iter = header.begin();
while ( iter != header.end() ) while ( iter != header.end() )
{ {
@ -2237,7 +2204,7 @@ void FListView::processChanged()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FListView::keySpace() inline void FListView::keySpace()
{ {
FListViewItem* item = getCurrentItem(); auto item = getCurrentItem();
if ( item->isCheckable() ) if ( item->isCheckable() )
item->setChecked(! item->isChecked()); item->setChecked(! item->isChecked());
@ -2247,7 +2214,7 @@ inline void FListView::keySpace()
inline void FListView::keyLeft (int& first_line_position_before) inline void FListView::keyLeft (int& first_line_position_before)
{ {
int position_before = current_iter.getPosition(); int position_before = current_iter.getPosition();
FListViewItem* item = getCurrentItem(); auto item = getCurrentItem();
if ( xoffset == 0 ) if ( xoffset == 0 )
{ {
@ -2264,7 +2231,7 @@ inline void FListView::keyLeft (int& first_line_position_before)
else if ( item->hasParent() ) else if ( item->hasParent() )
{ {
// Jump to parent element // Jump to parent element
FObject* parent = item->getParent(); auto parent = item->getParent();
if ( parent->isInstanceOf("FListViewItem") ) if ( parent->isInstanceOf("FListViewItem") )
{ {
@ -2301,7 +2268,7 @@ inline void FListView::keyLeft (int& first_line_position_before)
inline void FListView::keyRight (int& first_line_position_before) inline void FListView::keyRight (int& first_line_position_before)
{ {
int xoffset_end = int(max_line_width) - int(getClientWidth()); int xoffset_end = int(max_line_width) - int(getClientWidth());
FListViewItem* item = getCurrentItem(); auto item = getCurrentItem();
if ( tree_view && item->isExpandable() && ! item->isExpand() ) if ( tree_view && item->isExpandable() && ! item->isExpand() )
{ {
@ -2344,7 +2311,7 @@ inline void FListView::keyEnd()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FListView::keyPlus() inline bool FListView::keyPlus()
{ {
FListViewItem* item = getCurrentItem(); auto item = getCurrentItem();
if ( tree_view && item->isExpandable() && ! item->isExpand() ) if ( tree_view && item->isExpandable() && ! item->isExpand() )
{ {
@ -2359,7 +2326,7 @@ inline bool FListView::keyPlus()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FListView::keyMinus() inline bool FListView::keyMinus()
{ {
FListViewItem* item = getCurrentItem(); auto item = getCurrentItem();
if ( tree_view && item->isExpandable() && item->isExpand() ) if ( tree_view && item->isExpandable() && item->isExpand() )
{ {

View File

@ -53,7 +53,7 @@ FMenu::FMenu (const FString& txt, FWidget* parent)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FMenu::~FMenu() // destructor FMenu::~FMenu() // destructor
{ {
FApplication* fapp = static_cast<FApplication*>(getRootWidget()); auto fapp = static_cast<FApplication*>(getRootWidget());
if ( ! fapp->isQuit() ) if ( ! fapp->isQuit() )
switchToPrevWindow(this); // Switch to previous window switchToPrevWindow(this); // Switch to previous window
@ -100,7 +100,7 @@ void FMenu::hide()
if ( ! isSubMenu() ) if ( ! isSubMenu() )
{ {
FMenu* openmenu = static_cast<FMenu*>(getOpenMenu()); auto openmenu = static_cast<FMenu*>(getOpenMenu());
if ( openmenu && openmenu != this ) if ( openmenu && openmenu != this )
openmenu->hide(); openmenu->hide();
@ -114,18 +114,16 @@ void FMenu::hide()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenu::onKeyPress (FKeyEvent* ev) void FMenu::onKeyPress (FKeyEvent* ev)
{ {
FWidget* menu_bar;
// looking for menu hotkey // looking for menu hotkey
if ( hotkeyMenu(ev) ) if ( hotkeyMenu(ev) )
return; return;
// looking for menu bar hotkey // looking for menu bar hotkey
menu_bar = getMenuBar(); auto menu_bar = getMenuBar();
if ( menu_bar ) if ( menu_bar )
{ {
FMenuBar* mbar = static_cast<FMenuBar*>(menu_bar); auto mbar = static_cast<FMenuBar*>(menu_bar);
if ( mbar->hotkeyMenu(ev) ) if ( mbar->hotkeyMenu(ev) )
return; return;
@ -316,8 +314,7 @@ void FMenu::onMouseMove (FMouseEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenu::cb_menuitem_toggled (FWidget* widget, data_ptr) void FMenu::cb_menuitem_toggled (FWidget* widget, data_ptr)
{ {
FMenuItem* menuitem = static_cast<FMenuItem*>(widget); auto menuitem = static_cast<FMenuItem*>(widget);
std::vector<FMenuItem*>::const_iterator iter, last;
if ( ! has_checkable_items ) if ( ! has_checkable_items )
return; return;
@ -328,8 +325,8 @@ void FMenu::cb_menuitem_toggled (FWidget* widget, data_ptr)
if ( item_list.empty() ) if ( item_list.empty() )
return; return;
iter = item_list.begin(); auto iter = item_list.begin();
last = item_list.end(); auto last = item_list.end();
while ( iter != last ) while ( iter != last )
{ {
@ -373,7 +370,7 @@ bool FMenu::isRadioMenuItem (FWidget* w) const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMenu::isSubMenu() const bool FMenu::isSubMenu() const
{ {
FWidget* super = getSuperMenu(); auto super = getSuperMenu();
if ( super && isMenu(super) ) if ( super && isMenu(super) )
return true; return true;
@ -407,7 +404,7 @@ bool FMenu::isMouseOverSubMenu (const FPoint& termpos)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMenu::isMouseOverSuperMenu (const FPoint& termpos) bool FMenu::isMouseOverSuperMenu (const FPoint& termpos)
{ {
FMenu* smenu = superMenuAt (termpos); auto smenu = superMenuAt (termpos);
if ( smenu ) if ( smenu )
return true; return true;
@ -448,12 +445,12 @@ void FMenu::init(FWidget* parent)
{ {
if ( isMenuBar(parent) ) if ( isMenuBar(parent) )
{ {
FMenuBar* mbar = static_cast<FMenuBar*>(parent); auto mbar = static_cast<FMenuBar*>(parent);
mbar->calculateDimensions(); mbar->calculateDimensions();
} }
else if ( isMenu(parent) ) else if ( isMenu(parent) )
{ {
FMenu* smenu = static_cast<FMenu*>(parent); auto smenu = static_cast<FMenu*>(parent);
smenu->calculateDimensions(); smenu->calculateDimensions();
} }
@ -467,9 +464,8 @@ void FMenu::init(FWidget* parent)
void FMenu::calculateDimensions() void FMenu::calculateDimensions()
{ {
int item_X, item_Y, adjust_X; int item_X, item_Y, adjust_X;
std::vector<FMenuItem*>::const_iterator iter, last; auto iter = item_list.begin();
iter = item_list.begin(); auto last = item_list.end();
last = item_list.end();
max_item_width = 10; // minimum width max_item_width = 10; // minimum width
// find the maximum item width // find the maximum item width
@ -528,16 +524,15 @@ void FMenu::calculateDimensions()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenu::adjustItems() void FMenu::adjustItems()
{ {
std::vector<FMenuItem*>::const_iterator last, iter; auto iter = item_list.begin();
iter = item_list.begin(); auto last = item_list.end();
last = item_list.end();
while ( iter != last ) while ( iter != last )
{ {
if ( (*iter)->hasMenu() ) if ( (*iter)->hasMenu() )
{ {
int menu_X, menu_Y; int menu_X, menu_Y;
FMenu* menu = (*iter)->getMenu(); auto menu = (*iter)->getMenu();
menu_X = getTermX() + int(max_item_width) + 1; menu_X = getTermX() + int(max_item_width) + 1;
menu_X = menu->adjustX(menu_X); menu_X = menu->adjustX(menu_X);
@ -632,27 +627,27 @@ void FMenu::hideSubMenus()
void FMenu::hideSuperMenus() void FMenu::hideSuperMenus()
{ {
// hide all menus to the top // hide all menus to the top
FWidget* super = getSuperMenu(); auto super = getSuperMenu();
if ( ! super ) if ( ! super )
return; return;
if ( isMenuBar(super) ) if ( isMenuBar(super) )
{ {
FMenuBar* mbar = static_cast<FMenuBar*>(super); auto mbar = static_cast<FMenuBar*>(super);
if ( mbar->hasSelectedItem() ) if ( mbar->hasSelectedItem() )
mbar->leaveMenuBar(); mbar->leaveMenuBar();
} }
else if ( isMenu(super) ) else if ( isMenu(super) )
{ {
FMenu* m = static_cast<FMenu*>(super); auto m = static_cast<FMenu*>(super);
m->hide(); m->hide();
m->hideSuperMenus(); m->hideSuperMenus();
} }
else if ( isWindowsMenu(super) ) else if ( isWindowsMenu(super) )
{ {
FDialog* dgl = static_cast<FDialog*>(super); auto dgl = static_cast<FDialog*>(super);
dgl->leaveMenu(); dgl->leaveMenu();
} }
} }
@ -660,10 +655,9 @@ void FMenu::hideSuperMenus()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMenu::mouseDownOverList (FPoint mouse_pos) bool FMenu::mouseDownOverList (FPoint mouse_pos)
{ {
std::vector<FMenuItem*>::const_iterator iter, last;
bool focus_changed = false; bool focus_changed = false;
iter = item_list.begin(); auto iter = item_list.begin();
last = item_list.end(); auto last = item_list.end();
mouse_pos -= FPoint(getRightPadding(), getTopPadding()); mouse_pos -= FPoint(getRightPadding(), getTopPadding());
while ( iter != last ) while ( iter != last )
@ -695,7 +689,7 @@ void FMenu::mouseDownSubmenu (FMenuItem* m_item)
if ( ! hasSelectedItem() ) if ( ! hasSelectedItem() )
return; return;
FMenuItem* sel_item = getSelectedItem(); auto sel_item = getSelectedItem();
if ( ! sel_item if ( ! sel_item
|| ! sel_item->hasMenu() || ! sel_item->hasMenu()
@ -727,7 +721,7 @@ void FMenu::mouseDownSelection (FMenuItem* m_item, bool& focus_changed)
return; return;
unselectItem(); unselectItem();
FWidget* focused_widget = getFocusWidget(); auto focused_widget = getFocusWidget();
FFocusEvent out (fc::FocusOut_Event); FFocusEvent out (fc::FocusOut_Event);
FApplication::queueEvent(focused_widget, &out); FApplication::queueEvent(focused_widget, &out);
m_item->setSelected(); m_item->setSelected();
@ -743,7 +737,7 @@ void FMenu::mouseDownSelection (FMenuItem* m_item, bool& focus_changed)
if ( m_item->hasMenu() ) if ( m_item->hasMenu() )
{ {
FMenu* sub_menu = m_item->getMenu(); auto sub_menu = m_item->getMenu();
if ( ! sub_menu->isVisible() ) if ( ! sub_menu->isVisible() )
shown_sub_menu = sub_menu; shown_sub_menu = sub_menu;
} }
@ -752,9 +746,8 @@ void FMenu::mouseDownSelection (FMenuItem* m_item, bool& focus_changed)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMenu::mouseUpOverList (FPoint mouse_pos) bool FMenu::mouseUpOverList (FPoint mouse_pos)
{ {
std::vector<FMenuItem*>::const_iterator iter, last; auto iter = item_list.begin();
iter = item_list.begin(); auto last = item_list.end();
last = item_list.end();
mouse_pos -= FPoint(getRightPadding(), getTopPadding()); mouse_pos -= FPoint(getRightPadding(), getTopPadding());
while ( iter != last ) while ( iter != last )
@ -773,7 +766,7 @@ bool FMenu::mouseUpOverList (FPoint mouse_pos)
// Mouse pointer over item // Mouse pointer over item
if ( (*iter)->hasMenu() ) if ( (*iter)->hasMenu() )
{ {
FMenu* sub_menu = (*iter)->getMenu(); auto sub_menu = (*iter)->getMenu();
if ( ! sub_menu->isVisible() ) if ( ! sub_menu->isVisible() )
openSubMenu (sub_menu, SELECT_ITEM); openSubMenu (sub_menu, SELECT_ITEM);
else if ( opened_sub_menu ) else if ( opened_sub_menu )
@ -812,9 +805,8 @@ bool FMenu::mouseUpOverList (FPoint mouse_pos)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenu::mouseMoveOverList (FPoint mouse_pos, mouseStates& ms) void FMenu::mouseMoveOverList (FPoint mouse_pos, mouseStates& ms)
{ {
std::vector<FMenuItem*>::const_iterator iter, last; auto iter = item_list.begin();
iter = item_list.begin(); auto last = item_list.end();
last = item_list.end();
mouse_pos -= FPoint(getRightPadding(), getTopPadding()); mouse_pos -= FPoint(getRightPadding(), getTopPadding());
while ( iter != last ) while ( iter != last )
@ -843,7 +835,7 @@ void FMenu::mouseMoveSelection (FMenuItem* m_item, mouseStates& ms)
return; return;
// Mouse pointer over item // Mouse pointer over item
FWidget* focused_widget = getFocusWidget(); auto focused_widget = getFocusWidget();
FFocusEvent out (fc::FocusOut_Event); FFocusEvent out (fc::FocusOut_Event);
FApplication::queueEvent(focused_widget, &out); FApplication::queueEvent(focused_widget, &out);
m_item->setSelected(); m_item->setSelected();
@ -860,7 +852,7 @@ void FMenu::mouseMoveSelection (FMenuItem* m_item, mouseStates& ms)
// Sub menu handling // Sub menu handling
if ( m_item->hasMenu() ) if ( m_item->hasMenu() )
{ {
FMenu* sub_menu = m_item->getMenu(); auto sub_menu = m_item->getMenu();
if ( ! sub_menu->isVisible() ) if ( ! sub_menu->isVisible() )
shown_sub_menu = sub_menu; shown_sub_menu = sub_menu;
@ -930,7 +922,7 @@ void FMenu::passEventToSubMenu (FMouseEvent*& ev)
try try
{ {
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p, t, b); auto _ev = new FMouseEvent (fc::MouseMove_Event, p, t, b);
opened_sub_menu->mouse_down = true; opened_sub_menu->mouse_down = true;
setClickedWidget(opened_sub_menu); setClickedWidget(opened_sub_menu);
opened_sub_menu->onMouseMove(_ev); opened_sub_menu->onMouseMove(_ev);
@ -947,14 +939,14 @@ void FMenu::passEventToSuperMenu (FMouseEvent*& ev)
{ {
// Mouse event handover to super-menu // Mouse event handover to super-menu
FMenu* smenu = superMenuAt (ev->getTermPos()); auto smenu = superMenuAt (ev->getTermPos());
const FPoint& t = ev->getTermPos(); const FPoint& t = ev->getTermPos();
const FPoint& p = smenu->termToWidgetPos(t); const FPoint& p = smenu->termToWidgetPos(t);
int b = ev->getButton(); int b = ev->getButton();
try try
{ {
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p, t, b); auto _ev = new FMouseEvent (fc::MouseMove_Event, p, t, b);
smenu->mouse_down = true; smenu->mouse_down = true;
setClickedWidget(smenu); setClickedWidget(smenu);
smenu->onMouseMove(_ev); smenu->onMouseMove(_ev);
@ -971,16 +963,16 @@ void FMenu::passEventToMenuBar (FMouseEvent*& ev)
{ {
// Mouse event handover to the menu bar // Mouse event handover to the menu bar
FWidget* menu_bar = getMenuBar(); auto menu_bar = getMenuBar();
const FPoint& t = ev->getTermPos(); const FPoint& t = ev->getTermPos();
const FPoint& p = menu_bar->termToWidgetPos(t); const FPoint& p = menu_bar->termToWidgetPos(t);
int b = ev->getButton(); int b = ev->getButton();
try try
{ {
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p, t, b); auto _ev = new FMouseEvent (fc::MouseMove_Event, p, t, b);
setClickedWidget(menu_bar); setClickedWidget(menu_bar);
FMenuBar* mbar = static_cast<FMenuBar*>(menu_bar); auto mbar = static_cast<FMenuBar*>(menu_bar);
mbar->mouse_down = true; mbar->mouse_down = true;
mbar->onMouseMove(_ev); mbar->onMouseMove(_ev);
delete _ev; delete _ev;
@ -996,7 +988,7 @@ bool FMenu::containsMenuStructure (int x, int y)
{ {
// Check mouse click position for item, menu and all sub menus // Check mouse click position for item, menu and all sub menus
FMenuItem* si = getSelectedItem(); auto si = getSelectedItem();
if ( getTermGeometry().contains(x, y) ) if ( getTermGeometry().contains(x, y) )
return true; return true;
@ -1016,7 +1008,7 @@ FMenu* FMenu::superMenuAt (int x, int y)
if ( getTermGeometry().contains(x, y) ) if ( getTermGeometry().contains(x, y) )
return 0; return 0;
FWidget* super = getSuperMenu(); auto super = getSuperMenu();
if ( super && isMenu(super) ) if ( super && isMenu(super) )
{ {
@ -1024,7 +1016,7 @@ FMenu* FMenu::superMenuAt (int x, int y)
return static_cast<FMenu*>(super); return static_cast<FMenu*>(super);
else else
{ {
FMenu* smenu = static_cast<FMenu*>(getSuperMenu()); auto smenu = static_cast<FMenu*>(getSuperMenu());
if ( smenu ) if ( smenu )
return smenu->superMenuAt(x, y); return smenu->superMenuAt(x, y);
@ -1037,17 +1029,15 @@ FMenu* FMenu::superMenuAt (int x, int y)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMenu::selectNextItem() bool FMenu::selectNextItem()
{ {
std::vector<FMenuItem*>::const_iterator iter, last; auto iter = item_list.begin();
iter = item_list.begin(); auto last = item_list.end();
last = item_list.end();
while ( iter != last ) while ( iter != last )
{ {
if ( (*iter)->isSelected() ) if ( (*iter)->isSelected() )
{ {
FMenuItem* next; FMenuItem* next;
std::vector<FMenuItem*>::const_iterator next_element; auto next_element = iter;
next_element = iter;
do do
{ {
@ -1087,9 +1077,8 @@ bool FMenu::selectNextItem()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMenu::selectPrevItem() bool FMenu::selectPrevItem()
{ {
std::vector<FMenuItem*>::const_iterator iter, first; auto iter = item_list.end();
iter = item_list.end(); auto first = item_list.begin();
first = item_list.begin();
do do
{ {
@ -1098,8 +1087,7 @@ bool FMenu::selectPrevItem()
if ( (*iter)->isSelected() ) if ( (*iter)->isSelected() )
{ {
FMenuItem* prev; FMenuItem* prev;
std::vector<FMenuItem*>::const_iterator prev_element; auto prev_element = iter;
prev_element = iter;
do do
{ {
@ -1138,7 +1126,7 @@ bool FMenu::selectPrevItem()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenu::keypressMenuBar (FKeyEvent* ev) void FMenu::keypressMenuBar (FKeyEvent* ev)
{ {
FMenuBar* mbar = getMenuBar(); auto mbar = getMenuBar();
if ( mbar ) if ( mbar )
mbar->onKeyPress(ev); mbar->onKeyPress(ev);
@ -1147,9 +1135,8 @@ void FMenu::keypressMenuBar (FKeyEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMenu::hotkeyMenu (FKeyEvent* ev) bool FMenu::hotkeyMenu (FKeyEvent* ev)
{ {
std::vector<FMenuItem*>::const_iterator iter, last; auto iter = item_list.begin();
iter = item_list.begin(); auto last = item_list.end();
last = item_list.end();
while ( iter != last ) while ( iter != last )
{ {
@ -1172,7 +1159,7 @@ bool FMenu::hotkeyMenu (FKeyEvent* ev)
{ {
if ( (*iter)->hasMenu() ) if ( (*iter)->hasMenu() )
{ {
FMenu* sub_menu = (*iter)->getMenu(); auto sub_menu = (*iter)->getMenu();
unselectItem(); unselectItem();
(*iter)->setSelected(); (*iter)->setSelected();
setSelectedItem (*iter); setSelectedItem (*iter);
@ -1248,10 +1235,9 @@ void FMenu::draw()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenu::drawItems() void FMenu::drawItems()
{ {
std::vector<FMenuItem*>::const_iterator iter, last;
int y = 0; int y = 0;
iter = item_list.begin(); auto iter = item_list.begin();
last = item_list.end(); auto last = item_list.end();
while ( iter != last ) while ( iter != last )
{ {
@ -1566,7 +1552,7 @@ inline void FMenu::keyLeft (FKeyEvent* ev)
{ {
if ( isSubMenu() ) if ( isSubMenu() )
{ {
FMenu* smenu = static_cast<FMenu*>(getSuperMenu()); auto smenu = static_cast<FMenu*>(getSuperMenu());
hideSubMenus(); hideSubMenus();
hide(); hide();
@ -1590,7 +1576,7 @@ inline void FMenu::keyRight (FKeyEvent* ev)
{ {
if ( hasSelectedItem() && getSelectedItem()->hasMenu() ) if ( hasSelectedItem() && getSelectedItem()->hasMenu() )
{ {
FMenu* sub_menu = getSelectedItem()->getMenu(); auto sub_menu = getSelectedItem()->getMenu();
if ( ! sub_menu->isVisible() ) if ( ! sub_menu->isVisible() )
openSubMenu (sub_menu, SELECT_ITEM); openSubMenu (sub_menu, SELECT_ITEM);
@ -1607,7 +1593,7 @@ inline void FMenu::keyEnter()
if ( ! hasSelectedItem() ) if ( ! hasSelectedItem() )
return; return;
FMenuItem* sel_item = getSelectedItem(); auto sel_item = getSelectedItem();
if ( sel_item->hasMenu() ) if ( sel_item->hasMenu() )
openSubMenu (sel_item->getMenu(), SELECT_ITEM); openSubMenu (sel_item->getMenu(), SELECT_ITEM);
@ -1629,7 +1615,7 @@ inline void FMenu::keyEscape()
if ( isSubMenu() ) if ( isSubMenu() )
{ {
FMenu* smenu = static_cast<FMenu*>(getSuperMenu()); auto smenu = static_cast<FMenu*>(getSuperMenu());
if ( smenu->getSelectedItem() ) if ( smenu->getSelectedItem() )
smenu->getSelectedItem()->setFocus(); smenu->getSelectedItem()->setFocus();
@ -1638,7 +1624,7 @@ inline void FMenu::keyEscape()
} }
else else
{ {
FWidget* super = getSuperMenu(); auto super = getSuperMenu();
hideSuperMenus(); hideSuperMenus();
if ( getStatusBar() ) if ( getStatusBar() )

View File

@ -59,13 +59,12 @@ void FMenuBar::resetMenu()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuBar::hide() void FMenuBar::hide()
{ {
FColor fg, bg;
FWindow::hide(); FWindow::hide();
fg = wc.term_fg; FColor fg = wc.term_fg;
bg = wc.term_bg; FColor bg = wc.term_bg;
setColor (fg, bg); setColor (fg, bg);
screenWidth = getDesktopWidth(); screenWidth = getDesktopWidth();
char* blank = createBlankArray (screenWidth + 1); auto blank = createBlankArray (screenWidth + 1);
setPrintPos (1, 1); setPrintPos (1, 1);
print (blank); print (blank);
destroyBlankArray (blank); destroyBlankArray (blank);
@ -89,15 +88,14 @@ void FMenuBar::onKeyPress (FKeyEvent* ev)
case fc::Fkey_down: case fc::Fkey_down:
if ( hasSelectedItem() ) if ( hasSelectedItem() )
{ {
FMenuItem* sel_item = getSelectedItem(); auto sel_item = getSelectedItem();
if ( sel_item->hasMenu() ) if ( sel_item->hasMenu() )
{ {
FMenuItem* first_item; auto menu = sel_item->getMenu();
FMenu* menu = sel_item->getMenu();
sel_item->openMenu(); sel_item->openMenu();
menu->selectFirstItem(); menu->selectFirstItem();
first_item = menu->getSelectedItem(); auto first_item = menu->getSelectedItem();
if ( first_item ) if ( first_item )
first_item->setFocus(); first_item->setFocus();
@ -219,11 +217,11 @@ void FMenuBar::onAccel (FAccelEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuBar::cb_item_deactivated (FWidget* widget, data_ptr) void FMenuBar::cb_item_deactivated (FWidget* widget, data_ptr)
{ {
FMenuItem* menuitem = static_cast<FMenuItem*>(widget); auto menuitem = static_cast<FMenuItem*>(widget);
if ( menuitem->hasMenu() ) if ( menuitem->hasMenu() )
{ {
FMenu* menu = menuitem->getMenu(); auto menu = menuitem->getMenu();
menu->hide(); menu->hide();
menu->hideSubMenus(); menu->hideSubMenus();
} }
@ -234,8 +232,8 @@ void FMenuBar::cb_item_deactivated (FWidget* widget, data_ptr)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuBar::init() void FMenuBar::init()
{ {
FWidget* r = getRootWidget(); auto r = getRootWidget();
std::size_t w = r->getWidth(); auto w = r->getWidth();
// initialize geometry values // initialize geometry values
setGeometry (1, 1, w, 1, false); setGeometry (1, 1, w, 1, false);
setAlwaysOnTop(); setAlwaysOnTop();
@ -257,9 +255,8 @@ void FMenuBar::calculateDimensions()
{ {
int item_X = 1; int item_X = 1;
int item_Y = 1; int item_Y = 1;
std::vector<FMenuItem*>::const_iterator last, iter; auto iter = item_list.begin();
iter = item_list.begin(); auto last = item_list.end();
last = item_list.end();
// find the maximum item width // find the maximum item width
while ( iter != last ) while ( iter != last )
@ -283,17 +280,15 @@ void FMenuBar::calculateDimensions()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMenuBar::selectNextItem() bool FMenuBar::selectNextItem()
{ {
std::vector<FMenuItem*>::const_iterator iter, last; auto iter = item_list.begin();
iter = item_list.begin(); auto last = item_list.end();
last = item_list.end();
while ( iter != last ) while ( iter != last )
{ {
if ( (*iter)->isSelected() ) if ( (*iter)->isSelected() )
{ {
FMenuItem* next; FMenuItem* next;
std::vector<FMenuItem*>::const_iterator next_element; auto next_element = iter;
next_element = iter;
do do
{ {
@ -319,11 +314,10 @@ bool FMenuBar::selectNextItem()
if ( drop_down && next->hasMenu() ) if ( drop_down && next->hasMenu() )
{ {
FMenuItem* first_item; auto menu = next->getMenu();
FMenu* menu = next->getMenu();
next->openMenu(); next->openMenu();
menu->selectFirstItem(); menu->selectFirstItem();
first_item = menu->getSelectedItem(); auto first_item = menu->getSelectedItem();
if ( first_item ) if ( first_item )
first_item->setFocus(); first_item->setFocus();
@ -348,9 +342,8 @@ bool FMenuBar::selectNextItem()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMenuBar::selectPrevItem() bool FMenuBar::selectPrevItem()
{ {
std::vector<FMenuItem*>::const_iterator iter, first; auto iter = item_list.end();
iter = item_list.end(); auto first = item_list.begin();
first = item_list.begin();
do do
{ {
@ -359,8 +352,7 @@ bool FMenuBar::selectPrevItem()
if ( (*iter)->isSelected() ) if ( (*iter)->isSelected() )
{ {
FMenuItem* prev; FMenuItem* prev;
std::vector<FMenuItem*>::const_iterator prev_element; auto prev_element = iter;
prev_element = iter;
do do
{ {
@ -385,11 +377,10 @@ bool FMenuBar::selectPrevItem()
if ( drop_down && prev->hasMenu() ) if ( drop_down && prev->hasMenu() )
{ {
FMenuItem* first_item; auto menu = prev->getMenu();
FMenu* menu = prev->getMenu();
prev->openMenu(); prev->openMenu();
menu->selectFirstItem(); menu->selectFirstItem();
first_item = menu->getSelectedItem(); auto first_item = menu->getSelectedItem();
if ( first_item ) if ( first_item )
first_item->setFocus(); first_item->setFocus();
@ -414,9 +405,8 @@ bool FMenuBar::selectPrevItem()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMenuBar::hotkeyMenu (FKeyEvent*& ev) bool FMenuBar::hotkeyMenu (FKeyEvent*& ev)
{ {
std::vector<FMenuItem*>::const_iterator iter, last; auto iter = item_list.begin();
iter = item_list.begin(); auto last = item_list.end();
last = item_list.end();
while ( iter != last ) while ( iter != last )
{ {
@ -427,7 +417,7 @@ bool FMenuBar::hotkeyMenu (FKeyEvent*& ev)
if ( fc::Fmkey_meta + FKey(std::tolower(hotkey)) == key ) if ( fc::Fmkey_meta + FKey(std::tolower(hotkey)) == key )
{ {
FMenuItem* sel_item = getSelectedItem(); auto sel_item = getSelectedItem();
if ( sel_item && sel_item->hasMenu() ) if ( sel_item && sel_item->hasMenu() )
sel_item->getMenu()->unselectItem(); sel_item->getMenu()->unselectItem();
@ -436,14 +426,13 @@ bool FMenuBar::hotkeyMenu (FKeyEvent*& ev)
if ( (*iter)->hasMenu() ) if ( (*iter)->hasMenu() )
{ {
FMenuItem* first_item; auto menu = (*iter)->getMenu();
FMenu* menu = (*iter)->getMenu();
(*iter)->setSelected(); (*iter)->setSelected();
setSelectedItem(*iter); setSelectedItem(*iter);
(*iter)->setFocus(); (*iter)->setFocus();
(*iter)->openMenu(); (*iter)->openMenu();
menu->selectFirstItem(); menu->selectFirstItem();
first_item = menu->getSelectedItem(); auto first_item = menu->getSelectedItem();
if ( first_item ) if ( first_item )
first_item->setFocus(); first_item->setFocus();
@ -509,9 +498,6 @@ void FMenuBar::draw()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuBar::drawItems() void FMenuBar::drawItems()
{ {
std::vector<FMenuItem*>::const_iterator iter, last;
std::size_t x = 1;
if ( item_list.empty() ) if ( item_list.empty() )
return; return;
@ -521,8 +507,9 @@ void FMenuBar::drawItems()
setReverse(true); setReverse(true);
screenWidth = getDesktopWidth(); screenWidth = getDesktopWidth();
iter = item_list.begin(); auto iter = item_list.begin();
last = item_list.end(); auto last = item_list.end();
std::size_t x = 1;
while ( iter != last ) while ( iter != last )
{ {
@ -718,9 +705,8 @@ void FMenuBar::adjustItems()
{ {
int item_X = 1; int item_X = 1;
int item_Y = 1; int item_Y = 1;
std::vector<FMenuItem*>::const_iterator last, iter; auto iter = item_list.begin();
iter = item_list.begin(); auto last = item_list.end();
last = item_list.end();
while ( iter != last ) while ( iter != last )
{ {
@ -729,7 +715,7 @@ void FMenuBar::adjustItems()
if ( (*iter)->hasMenu() ) if ( (*iter)->hasMenu() )
{ {
FMenu* menu = (*iter)->getMenu(); auto menu = (*iter)->getMenu();
// set menu position // set menu position
menu->setPos (menu->adjustX(item_X), item_Y); menu->setPos (menu->adjustX(item_X), item_Y);
@ -749,7 +735,7 @@ void FMenuBar::selectMenuItem (FMenuItem* item)
if ( ! item->isEnabled() || item->isSelected() ) if ( ! item->isEnabled() || item->isSelected() )
return; return;
FWidget* focused_widget = getFocusWidget(); auto focused_widget = getFocusWidget();
FFocusEvent out (fc::FocusOut_Event); FFocusEvent out (fc::FocusOut_Event);
FApplication::queueEvent(focused_widget, &out); FApplication::queueEvent(focused_widget, &out);
item->setSelected(); item->setSelected();
@ -764,7 +750,7 @@ void FMenuBar::selectMenuItem (FMenuItem* item)
if ( item->hasMenu() ) if ( item->hasMenu() )
{ {
FMenu* menu = item->getMenu(); auto menu = item->getMenu();
if ( menu->hasSelectedItem() ) if ( menu->hasSelectedItem() )
{ {
@ -781,13 +767,12 @@ bool FMenuBar::activateMenu (FMenuItem* item)
if ( ! item->hasMenu() ) if ( ! item->hasMenu() )
return false; return false;
FMenu* menu = item->getMenu(); auto menu = item->getMenu();
if ( ! menu->hasSelectedItem() ) if ( ! menu->hasSelectedItem() )
{ {
FMenuItem* first_item;
menu->selectFirstItem(); menu->selectFirstItem();
first_item = menu->getSelectedItem(); auto first_item = menu->getSelectedItem();
if ( first_item ) if ( first_item )
first_item->setFocus(); first_item->setFocus();
@ -842,20 +827,16 @@ void FMenuBar::mouseDownOverList (FMouseEvent* ev)
if ( item_list.empty() ) if ( item_list.empty() )
return; return;
std::vector<FMenuItem*>::const_iterator iter, last;
int mouse_x, mouse_y;
focus_changed = false; focus_changed = false;
auto iter = item_list.begin();
iter = item_list.begin(); auto last = item_list.end();
last = item_list.end(); int mouse_x = ev->getX();
mouse_x = ev->getX(); int mouse_y = ev->getY();
mouse_y = ev->getY();
while ( iter != last ) while ( iter != last )
{ {
int x1, x2; int x1 = (*iter)->getX();
x1 = (*iter)->getX(); int x2 = (*iter)->getX() + int((*iter)->getWidth());
x2 = (*iter)->getX() + int((*iter)->getWidth());
if ( mouse_y == 1 ) if ( mouse_y == 1 )
{ {
@ -894,18 +875,15 @@ void FMenuBar::mouseUpOverList (FMouseEvent* ev)
if ( item_list.empty() ) if ( item_list.empty() )
return; return;
int mouse_x, mouse_y; auto iter = item_list.begin();
std::vector<FMenuItem*>::const_iterator iter, last; auto last = item_list.end();
iter = item_list.begin(); int mouse_x = ev->getX();
last = item_list.end(); int mouse_y = ev->getY();
mouse_x = ev->getX();
mouse_y = ev->getY();
while ( iter != last ) while ( iter != last )
{ {
int x1, x2; int x1 = (*iter)->getX();
x1 = (*iter)->getX(); int x2 = (*iter)->getX() + int((*iter)->getWidth());
x2 = (*iter)->getX() + int((*iter)->getWidth());
if ( mouse_y == 1 if ( mouse_y == 1
&& mouse_x >= x1 && mouse_x >= x1
@ -939,23 +917,20 @@ void FMenuBar::mouseMoveOverList (FMouseEvent* ev)
if ( item_list.empty() ) if ( item_list.empty() )
return; return;
std::vector<FMenuItem*>::const_iterator iter, last;
int mouse_x, mouse_y;
bool mouse_over_menubar = false;
focus_changed = false; focus_changed = false;
iter = item_list.begin(); bool mouse_over_menubar = false;
last = item_list.end(); auto iter = item_list.begin();
mouse_x = ev->getX(); auto last = item_list.end();
mouse_y = ev->getY(); int mouse_x = ev->getX();
int mouse_y = ev->getY();
if ( getTermGeometry().contains(ev->getTermPos()) ) if ( getTermGeometry().contains(ev->getTermPos()) )
mouse_over_menubar = true; mouse_over_menubar = true;
while ( iter != last ) while ( iter != last )
{ {
int x1, x2; int x1 = (*iter)->getX();
x1 = (*iter)->getX(); int x2 = (*iter)->getX() + int((*iter)->getWidth());
x2 = (*iter)->getX() + int((*iter)->getWidth());
if ( mouse_x >= x1 if ( mouse_x >= x1
&& mouse_x < x2 && mouse_x < x2
@ -1003,8 +978,8 @@ void FMenuBar::passEventToMenu (FMouseEvent*& ev)
return; return;
// Mouse event handover to the menu // Mouse event handover to the menu
FMenu* menu = getSelectedItem()->getMenu(); auto menu = getSelectedItem()->getMenu();
const FRect& menu_geometry = menu->getTermGeometry(); const auto& menu_geometry = menu->getTermGeometry();
if ( menu->getCount() > 0 if ( menu->getCount() > 0
&& menu_geometry.contains(ev->getTermPos()) ) && menu_geometry.contains(ev->getTermPos()) )
@ -1015,7 +990,7 @@ void FMenuBar::passEventToMenu (FMouseEvent*& ev)
try try
{ {
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p, t, b); auto _ev = new FMouseEvent (fc::MouseMove_Event, p, t, b);
menu->mouse_down = true; menu->mouse_down = true;
setClickedWidget(menu); setClickedWidget(menu);
menu->onMouseMove(_ev); menu->onMouseMove(_ev);

View File

@ -65,7 +65,7 @@ FMenuItem::~FMenuItem() // destructor
{ {
if ( super_menu && (isMenu(super_menu) || isMenuBar(super_menu)) ) if ( super_menu && (isMenu(super_menu) || isMenuBar(super_menu)) )
{ {
FMenuList* menu_list = getFMenuList(*super_menu); auto menu_list = getFMenuList(*super_menu);
if ( menu_list ) if ( menu_list )
menu_list->remove(this); menu_list->remove(this);
@ -84,7 +84,7 @@ FMenuItem::~FMenuItem() // destructor
bool FMenuItem::setEnable (bool on) bool FMenuItem::setEnable (bool on)
{ {
FWidget::setEnable(on); FWidget::setEnable(on);
FWidget* super = getSuperMenu(); auto super = getSuperMenu();
if ( on ) if ( on )
{ {
@ -115,7 +115,7 @@ bool FMenuItem::setFocus (bool on)
{ {
if ( ! selected ) if ( ! selected )
{ {
FMenuList* menu_list = getFMenuList(*getSuperMenu()); auto menu_list = getFMenuList(*getSuperMenu());
setSelected(); setSelected();
if ( menu_list ) if ( menu_list )
@ -127,18 +127,18 @@ bool FMenuItem::setFocus (bool on)
if ( getStatusBar() ) if ( getStatusBar() )
getStatusBar()->drawMessage(); getStatusBar()->drawMessage();
FWidget* parent = getSuperMenu(); auto parent = getSuperMenu();
if ( isMenuBar(parent) ) if ( isMenuBar(parent) )
{ {
FMenuBar* menubar_ptr = static_cast<FMenuBar*>(parent); auto menubar_ptr = static_cast<FMenuBar*>(parent);
if ( menubar_ptr ) if ( menubar_ptr )
menubar_ptr->redraw(); menubar_ptr->redraw();
} }
else if ( isMenu(parent) ) else if ( isMenu(parent) )
{ {
FMenu* menu_ptr = static_cast<FMenu*>(parent); auto menu_ptr = static_cast<FMenu*>(parent);
if ( menu_ptr ) if ( menu_ptr )
menu_ptr->redraw(); menu_ptr->redraw();
@ -198,7 +198,7 @@ void FMenuItem::setText (const FString& txt)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuItem::addAccelerator (FKey key, FWidget* obj) void FMenuItem::addAccelerator (FKey key, FWidget* obj)
{ {
FWidget* root = getRootWidget(); auto root = getRootWidget();
accelerator accel = { key, obj }; accelerator accel = { key, obj };
if ( root && root->accelerator_list ) if ( root && root->accelerator_list )
@ -209,7 +209,7 @@ void FMenuItem::addAccelerator (FKey key, FWidget* obj)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
FMenu* menu_ptr = static_cast<FMenu*>(super_menu); auto menu_ptr = static_cast<FMenu*>(super_menu);
if ( menu_ptr ) if ( menu_ptr )
menu_ptr->calculateDimensions(); menu_ptr->calculateDimensions();
@ -219,14 +219,13 @@ void FMenuItem::addAccelerator (FKey key, FWidget* obj)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuItem::delAccelerator (FWidget* obj) void FMenuItem::delAccelerator (FWidget* obj)
{ {
FWidget* root = getRootWidget(); auto root = getRootWidget();
if ( root if ( root
&& root->accelerator_list && root->accelerator_list
&& ! root->accelerator_list->empty() ) && ! root->accelerator_list->empty() )
{ {
FWidget::Accelerators::iterator iter; auto iter = root->accelerator_list->begin();
iter = root->accelerator_list->begin();
while ( iter != root->accelerator_list->end() ) while ( iter != root->accelerator_list->end() )
{ {
@ -242,7 +241,7 @@ void FMenuItem::delAccelerator (FWidget* obj)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
FMenu* menu_ptr = static_cast<FMenu*>(super_menu); auto menu_ptr = static_cast<FMenu*>(super_menu);
if ( menu_ptr ) if ( menu_ptr )
menu_ptr->calculateDimensions(); menu_ptr->calculateDimensions();
@ -255,12 +254,12 @@ void FMenuItem::openMenu()
if ( ! hasMenu() ) if ( ! hasMenu() )
return; return;
FMenu* dd_menu = getMenu(); // Drop-down menu auto dd_menu = getMenu(); // Drop-down menu
if ( dd_menu->isVisible() ) if ( dd_menu->isVisible() )
return; return;
FMenu* openmenu = static_cast<FMenu*>(getOpenMenu()); auto openmenu = static_cast<FMenu*>(getOpenMenu());
if ( openmenu && openmenu != dd_menu ) if ( openmenu && openmenu != dd_menu )
{ {
@ -288,13 +287,13 @@ void FMenuItem::onKeyPress (FKeyEvent* ev)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
FMenu* smenu = static_cast<FMenu*>(super_menu); auto smenu = static_cast<FMenu*>(super_menu);
smenu->onKeyPress(ev); smenu->onKeyPress(ev);
} }
if ( isMenuBar(super_menu) ) if ( isMenuBar(super_menu) )
{ {
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu); auto mbar = static_cast<FMenuBar*>(super_menu);
if ( mbar ) if ( mbar )
{ {
@ -314,19 +313,19 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
FMenu* smenu = static_cast<FMenu*>(super_menu); auto smenu = static_cast<FMenu*>(super_menu);
passMouseEvent (smenu, ev, fc::MouseDoubleClick_Event); passMouseEvent (smenu, ev, fc::MouseDoubleClick_Event);
} }
if ( isMenuBar(super_menu) ) if ( isMenuBar(super_menu) )
{ {
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu); auto mbar = static_cast<FMenuBar*>(super_menu);
passMouseEvent (mbar, ev, fc::MouseDoubleClick_Event); passMouseEvent (mbar, ev, fc::MouseDoubleClick_Event);
} }
if ( isWindowsMenu(super_menu) ) if ( isWindowsMenu(super_menu) )
{ {
FDialog* dgl = static_cast<FDialog*>(super_menu); auto dgl = static_cast<FDialog*>(super_menu);
passMouseEvent (dgl, ev, fc::MouseDoubleClick_Event); passMouseEvent (dgl, ev, fc::MouseDoubleClick_Event);
} }
} }
@ -339,19 +338,19 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
FMenu* smenu = static_cast<FMenu*>(super_menu); auto smenu = static_cast<FMenu*>(super_menu);
passMouseEvent (smenu, ev, fc::MouseDown_Event); passMouseEvent (smenu, ev, fc::MouseDown_Event);
} }
if ( isMenuBar(super_menu) ) if ( isMenuBar(super_menu) )
{ {
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu); auto mbar = static_cast<FMenuBar*>(super_menu);
passMouseEvent (mbar, ev, fc::MouseDown_Event); passMouseEvent (mbar, ev, fc::MouseDown_Event);
} }
if ( isWindowsMenu(super_menu) ) if ( isWindowsMenu(super_menu) )
{ {
FDialog* dgl = static_cast<FDialog*>(super_menu); auto dgl = static_cast<FDialog*>(super_menu);
passMouseEvent (dgl, ev, fc::MouseDown_Event); passMouseEvent (dgl, ev, fc::MouseDown_Event);
} }
} }
@ -364,19 +363,19 @@ void FMenuItem::onMouseUp (FMouseEvent* ev)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
FMenu* smenu = static_cast<FMenu*>(super_menu); auto smenu = static_cast<FMenu*>(super_menu);
passMouseEvent (smenu, ev, fc::MouseUp_Event); passMouseEvent (smenu, ev, fc::MouseUp_Event);
} }
if ( isMenuBar(super_menu) ) if ( isMenuBar(super_menu) )
{ {
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu); auto mbar = static_cast<FMenuBar*>(super_menu);
passMouseEvent (mbar, ev, fc::MouseUp_Event); passMouseEvent (mbar, ev, fc::MouseUp_Event);
} }
if ( isWindowsMenu(super_menu) ) if ( isWindowsMenu(super_menu) )
{ {
FDialog* dgl = static_cast<FDialog*>(super_menu); auto dgl = static_cast<FDialog*>(super_menu);
passMouseEvent (dgl, ev, fc::MouseUp_Event); passMouseEvent (dgl, ev, fc::MouseUp_Event);
} }
} }
@ -389,19 +388,19 @@ void FMenuItem::onMouseMove (FMouseEvent* ev)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
FMenu* smenu = static_cast<FMenu*>(super_menu); auto smenu = static_cast<FMenu*>(super_menu);
passMouseEvent (smenu, ev, fc::MouseMove_Event); passMouseEvent (smenu, ev, fc::MouseMove_Event);
} }
if ( isMenuBar(super_menu) ) if ( isMenuBar(super_menu) )
{ {
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu); auto mbar = static_cast<FMenuBar*>(super_menu);
passMouseEvent (mbar, ev, fc::MouseMove_Event); passMouseEvent (mbar, ev, fc::MouseMove_Event);
} }
if ( isWindowsMenu(super_menu) ) if ( isWindowsMenu(super_menu) )
{ {
FDialog* dgl = static_cast<FDialog*>(super_menu); auto dgl = static_cast<FDialog*>(super_menu);
passMouseEvent (dgl, ev, fc::MouseMove_Event); passMouseEvent (dgl, ev, fc::MouseMove_Event);
} }
} }
@ -418,20 +417,17 @@ void FMenuItem::onAccel (FAccelEvent* ev)
return; return;
} }
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu); auto mbar = static_cast<FMenuBar*>(super_menu);
if ( menu ) if ( menu )
{ {
FWidget* focused_widget;
if ( mbar->getSelectedItem() ) if ( mbar->getSelectedItem() )
mbar->getSelectedItem()->unsetSelected(); mbar->getSelectedItem()->unsetSelected();
setSelected(); setSelected();
mbar->selected_item = this; mbar->selected_item = this;
openMenu(); openMenu();
auto focused_widget = static_cast<FWidget*>(ev->focusedWidget());
focused_widget = static_cast<FWidget*>(ev->focusedWidget());
if ( focused_widget && focused_widget->isWidget() ) if ( focused_widget && focused_widget->isWidget() )
{ {
@ -482,7 +478,7 @@ void FMenuItem::onFocusOut (FFocusEvent*)
if ( super_menu && isMenuBar(super_menu) ) if ( super_menu && isMenuBar(super_menu) )
{ {
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu); auto mbar = static_cast<FMenuBar*>(super_menu);
mbar->redraw(); mbar->redraw();
} }
@ -527,12 +523,12 @@ FMenuList* FMenuItem::getFMenuList (FWidget& widget)
if ( isMenu(&widget) ) if ( isMenu(&widget) )
{ {
FMenu* Menu = static_cast<FMenu*>(&widget); auto Menu = static_cast<FMenu*>(&widget);
menu_list = static_cast<FMenuList*>(Menu); menu_list = static_cast<FMenuList*>(Menu);
} }
else if ( isMenuBar(&widget) ) else if ( isMenuBar(&widget) )
{ {
FMenuBar* Menubar = static_cast<FMenuBar*>(&widget); auto Menubar = static_cast<FMenuBar*>(&widget);
menu_list = static_cast<FMenuList*>(Menubar); menu_list = static_cast<FMenuList*>(Menubar);
} }
else else
@ -560,14 +556,14 @@ void FMenuItem::init (FWidget* parent)
if ( accel_key ) if ( accel_key )
addAccelerator (accel_key); addAccelerator (accel_key);
FMenuList* menu_list = getFMenuList(*parent); auto menu_list = getFMenuList(*parent);
if ( menu_list ) if ( menu_list )
menu_list->insert(this); menu_list->insert(this);
if ( isMenuBar(parent) ) // Parent is menubar if ( isMenuBar(parent) ) // Parent is menubar
{ {
FMenuBar* menubar_ptr = static_cast<FMenuBar*>(parent); auto menubar_ptr = static_cast<FMenuBar*>(parent);
menubar_ptr->calculateDimensions(); menubar_ptr->calculateDimensions();
if ( hotkey ) // Meta + hotkey if ( hotkey ) // Meta + hotkey
@ -582,7 +578,7 @@ 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); auto menu_ptr = static_cast<FMenu*>(parent);
menu_ptr->calculateDimensions(); menu_ptr->calculateDimensions();
} }
} }
@ -632,12 +628,12 @@ void FMenuItem::createDialogList (FMenu* winmenu)
if ( dialog_list && ! dialog_list->empty() ) if ( dialog_list && ! dialog_list->empty() )
{ {
widgetList::const_iterator iter, first; auto first = dialog_list->begin();
iter = first = dialog_list->begin(); auto iter = first;
while ( iter != dialog_list->end() && *iter ) while ( iter != dialog_list->end() && *iter )
{ {
FDialog* win = static_cast<FDialog*>(*iter); auto win = static_cast<FDialog*>(*iter);
if ( win ) if ( win )
{ {
@ -731,11 +727,11 @@ void FMenuItem::passMouseEvent ( T widget, FMouseEvent* ev
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuItem::cb_switchToDialog (FWidget*, data_ptr data) void FMenuItem::cb_switchToDialog (FWidget*, data_ptr data)
{ {
FDialog* win = static_cast<FDialog*>(data); auto win = static_cast<FDialog*>(data);
if ( win ) if ( win )
{ {
FWidget* focus = getFocusWidget(); auto focus = getFocusWidget();
FAccelEvent a_ev (fc::Accelerator_Event, focus); FAccelEvent a_ev (fc::Accelerator_Event, focus);
FApplication::sendEvent (win, &a_ev); FApplication::sendEvent (win, &a_ev);
} }
@ -744,8 +740,8 @@ void FMenuItem::cb_switchToDialog (FWidget*, data_ptr data)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuItem::cb_destroyDialog (FWidget* widget, data_ptr) void FMenuItem::cb_destroyDialog (FWidget* widget, data_ptr)
{ {
FDialog* win = static_cast<FDialog*>(widget); auto win = static_cast<FDialog*>(widget);
FApplication* fapp = static_cast<FApplication*>(getRootWidget()); auto fapp = static_cast<FApplication*>(getRootWidget());
if ( win && fapp ) if ( win && fapp )
{ {

View File

@ -259,7 +259,7 @@ void FMessageBox::adjustSize()
int X, Y; int X, Y;
std::size_t max_width; std::size_t max_width;
std::size_t max_height; std::size_t max_height;
FWidget* root_widget = getRootWidget(); auto root_widget = getRootWidget();
if ( root_widget ) if ( root_widget )
{ {
@ -521,7 +521,7 @@ void FMessageBox::adjustButtons()
if ( btn_width >= getWidth() - 4 ) if ( btn_width >= getWidth() - 4 )
{ {
std::size_t max_width; std::size_t max_width;
FWidget* root_widget = getRootWidget(); auto root_widget = getRootWidget();
setWidth(btn_width + 5); setWidth(btn_width + 5);
max_width = ( root_widget ) ? root_widget->getClientWidth() : 80; max_width = ( root_widget ) ? root_widget->getClientWidth() : 80;
setX (int((max_width - getWidth()) / 2)); setX (int((max_width - getWidth()) / 2));

View File

@ -1184,15 +1184,8 @@ FMouseControl::FMouseControl()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FMouseControl::~FMouseControl() // destructor FMouseControl::~FMouseControl() // destructor
{ {
iter = mouse_protocol.begin(); for (auto&& m : mouse_protocol)
delete m.second;
while ( iter != mouse_protocol.end() )
{
if ( iter->second )
delete iter->second;
++iter;
}
} }
@ -1200,7 +1193,7 @@ FMouseControl::~FMouseControl() // destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FPoint& FMouseControl::getPos() FPoint& FMouseControl::getPos()
{ {
FMouse* mouse_object = getMouseWithEvent(); auto mouse_object = getMouseWithEvent();
if ( mouse_object ) if ( mouse_object )
return mouse_object->getPos(); return mouse_object->getPos();
@ -1221,8 +1214,8 @@ void FMouseControl::clearEvent()
#ifdef F_HAVE_LIBGPM #ifdef F_HAVE_LIBGPM
void FMouseControl::setStdinNo (int file_descriptor) void FMouseControl::setStdinNo (int file_descriptor)
{ {
FMouse* mouse = mouse_protocol[FMouse::gpm]; auto mouse = mouse_protocol[FMouse::gpm];
FMouseGPM* gpm_mouse = static_cast<FMouseGPM*>(mouse); auto gpm_mouse = static_cast<FMouseGPM*>(mouse);
if ( gpm_mouse ) if ( gpm_mouse )
gpm_mouse->setStdinNo(file_descriptor); gpm_mouse->setStdinNo(file_descriptor);
@ -1247,15 +1240,9 @@ void FMouseControl::setMaxHeight (short y_max)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouseControl::setDblclickInterval (const long timeout) void FMouseControl::setDblclickInterval (const long timeout)
{ {
iter = mouse_protocol.begin(); for (auto&& m : mouse_protocol)
if ( m.second )
while ( iter != mouse_protocol.end() ) m.second->setDblclickInterval(timeout);
{
if ( iter->second )
iter->second->setDblclickInterval(timeout);
++iter;
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1273,7 +1260,7 @@ void FMouseControl::useXtermMouse (bool on)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMouseControl::hasData() bool FMouseControl::hasData()
{ {
FMouse* mouse_object = getMouseWithData(); auto mouse_object = getMouseWithData();
if ( mouse_object ) // with data if ( mouse_object ) // with data
return true; return true;
@ -1284,7 +1271,7 @@ bool FMouseControl::hasData()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMouseControl::hasEvent() bool FMouseControl::hasEvent()
{ {
FMouse* mouse_object = getMouseWithEvent(); auto mouse_object = getMouseWithEvent();
if ( mouse_object ) // with event if ( mouse_object ) // with event
return true; return true;
@ -1295,7 +1282,7 @@ bool FMouseControl::hasEvent()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMouseControl::isLeftButtonPressed() bool FMouseControl::isLeftButtonPressed()
{ {
FMouse* mouse_object = getMouseWithEvent(); auto mouse_object = getMouseWithEvent();
if ( mouse_object ) if ( mouse_object )
return mouse_object->isLeftButtonPressed(); return mouse_object->isLeftButtonPressed();
@ -1306,7 +1293,7 @@ bool FMouseControl::isLeftButtonPressed()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMouseControl::isLeftButtonReleased() bool FMouseControl::isLeftButtonReleased()
{ {
FMouse* mouse_object = getMouseWithEvent(); auto mouse_object = getMouseWithEvent();
if ( mouse_object ) if ( mouse_object )
return mouse_object->isLeftButtonReleased(); return mouse_object->isLeftButtonReleased();
@ -1317,7 +1304,7 @@ bool FMouseControl::isLeftButtonReleased()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMouseControl::isLeftButtonDoubleClick() bool FMouseControl::isLeftButtonDoubleClick()
{ {
FMouse* mouse_object = getMouseWithEvent(); auto mouse_object = getMouseWithEvent();
if ( mouse_object ) if ( mouse_object )
return mouse_object->isLeftButtonDoubleClick(); return mouse_object->isLeftButtonDoubleClick();
@ -1328,7 +1315,7 @@ bool FMouseControl::isLeftButtonDoubleClick()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMouseControl::isRightButtonPressed() bool FMouseControl::isRightButtonPressed()
{ {
FMouse* mouse_object = getMouseWithEvent(); auto mouse_object = getMouseWithEvent();
if ( mouse_object ) if ( mouse_object )
return mouse_object->isRightButtonPressed(); return mouse_object->isRightButtonPressed();
@ -1339,7 +1326,7 @@ bool FMouseControl::isRightButtonPressed()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMouseControl::isRightButtonReleased() bool FMouseControl::isRightButtonReleased()
{ {
FMouse* mouse_object = getMouseWithEvent(); auto mouse_object = getMouseWithEvent();
if ( mouse_object ) if ( mouse_object )
return mouse_object->isRightButtonReleased(); return mouse_object->isRightButtonReleased();
@ -1350,7 +1337,7 @@ bool FMouseControl::isRightButtonReleased()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMouseControl::isMiddleButtonPressed() bool FMouseControl::isMiddleButtonPressed()
{ {
FMouse* mouse_object = getMouseWithEvent(); auto mouse_object = getMouseWithEvent();
if ( mouse_object ) if ( mouse_object )
return mouse_object->isMiddleButtonPressed(); return mouse_object->isMiddleButtonPressed();
@ -1361,7 +1348,7 @@ bool FMouseControl::isMiddleButtonPressed()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMouseControl::isMiddleButtonReleased() bool FMouseControl::isMiddleButtonReleased()
{ {
FMouse* mouse_object = getMouseWithEvent(); auto mouse_object = getMouseWithEvent();
if ( mouse_object ) if ( mouse_object )
return mouse_object->isMiddleButtonReleased(); return mouse_object->isMiddleButtonReleased();
@ -1372,7 +1359,7 @@ bool FMouseControl::isMiddleButtonReleased()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMouseControl::isShiftKeyPressed() bool FMouseControl::isShiftKeyPressed()
{ {
FMouse* mouse_object = getMouseWithEvent(); auto mouse_object = getMouseWithEvent();
if ( mouse_object ) if ( mouse_object )
return mouse_object->isShiftKeyPressed(); return mouse_object->isShiftKeyPressed();
@ -1383,7 +1370,7 @@ bool FMouseControl::isShiftKeyPressed()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMouseControl::isControlKeyPressed() bool FMouseControl::isControlKeyPressed()
{ {
FMouse* mouse_object = getMouseWithEvent(); auto mouse_object = getMouseWithEvent();
if ( mouse_object ) if ( mouse_object )
return mouse_object->isControlKeyPressed(); return mouse_object->isControlKeyPressed();
@ -1394,7 +1381,7 @@ bool FMouseControl::isControlKeyPressed()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMouseControl::isMetaKeyPressed() bool FMouseControl::isMetaKeyPressed()
{ {
FMouse* mouse_object = getMouseWithEvent(); auto mouse_object = getMouseWithEvent();
if ( mouse_object ) if ( mouse_object )
return mouse_object->isMetaKeyPressed(); return mouse_object->isMetaKeyPressed();
@ -1405,7 +1392,7 @@ bool FMouseControl::isMetaKeyPressed()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMouseControl::isWheelUp() bool FMouseControl::isWheelUp()
{ {
FMouse* mouse_object = getMouseWithEvent(); auto mouse_object = getMouseWithEvent();
if ( mouse_object ) if ( mouse_object )
return mouse_object->isWheelUp(); return mouse_object->isWheelUp();
@ -1416,7 +1403,7 @@ bool FMouseControl::isWheelUp()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMouseControl::isWheelDown() bool FMouseControl::isWheelDown()
{ {
FMouse* mouse_object = getMouseWithEvent(); auto mouse_object = getMouseWithEvent();
if ( mouse_object ) if ( mouse_object )
return mouse_object->isWheelDown(); return mouse_object->isWheelDown();
@ -1427,7 +1414,7 @@ bool FMouseControl::isWheelDown()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMouseControl::isMoved() bool FMouseControl::isMoved()
{ {
FMouse* mouse_object = getMouseWithEvent(); auto mouse_object = getMouseWithEvent();
if ( mouse_object ) if ( mouse_object )
return mouse_object->isMoved(); return mouse_object->isMoved();
@ -1438,16 +1425,10 @@ bool FMouseControl::isMoved()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMouseControl::isInputDataPending() bool FMouseControl::isInputDataPending()
{ {
iter = mouse_protocol.begin(); for (auto&& m : mouse_protocol)
if ( m.second && m.second->isInputDataPending() )
while ( iter != mouse_protocol.end() )
{
if ( iter->second && iter->second->isInputDataPending() )
return true; return true;
++iter;
}
return false; return false;
} }
@ -1458,8 +1439,8 @@ bool FMouseControl::isGpmMouseEnabled()
if ( mouse_protocol.empty() ) if ( mouse_protocol.empty() )
return false; return false;
FMouse* mouse = mouse_protocol[FMouse::gpm]; auto mouse = mouse_protocol[FMouse::gpm];
FMouseGPM* gpm_mouse = static_cast<FMouseGPM*>(mouse); auto gpm_mouse = static_cast<FMouseGPM*>(mouse);
if ( gpm_mouse ) if ( gpm_mouse )
return gpm_mouse->isGpmMouseEnabled(); return gpm_mouse->isGpmMouseEnabled();
@ -1479,8 +1460,8 @@ void FMouseControl::enable()
#ifdef F_HAVE_LIBGPM #ifdef F_HAVE_LIBGPM
if ( use_gpm_mouse ) if ( use_gpm_mouse )
{ {
FMouse* mouse = mouse_protocol[FMouse::gpm]; auto mouse = mouse_protocol[FMouse::gpm];
FMouseGPM* gpm_mouse = static_cast<FMouseGPM*>(mouse); auto gpm_mouse = static_cast<FMouseGPM*>(mouse);
if ( gpm_mouse ) if ( gpm_mouse )
use_gpm_mouse = gpm_mouse->enableGpmMouse(); use_gpm_mouse = gpm_mouse->enableGpmMouse();
@ -1497,8 +1478,8 @@ void FMouseControl::disable()
#ifdef F_HAVE_LIBGPM #ifdef F_HAVE_LIBGPM
if ( use_gpm_mouse ) if ( use_gpm_mouse )
{ {
FMouse* mouse = mouse_protocol[FMouse::gpm]; auto mouse = mouse_protocol[FMouse::gpm];
FMouseGPM* gpm_mouse = static_cast<FMouseGPM*>(mouse); auto gpm_mouse = static_cast<FMouseGPM*>(mouse);
if ( gpm_mouse ) if ( gpm_mouse )
gpm_mouse->disableGpmMouse(); gpm_mouse->disableGpmMouse();
@ -1513,7 +1494,7 @@ void FMouseControl::disable()
void FMouseControl::setRawData ( FMouse::mouse_type mt void FMouseControl::setRawData ( FMouse::mouse_type mt
, FKeyboard::keybuffer& fifo_buf) , FKeyboard::keybuffer& fifo_buf)
{ {
FMouse* mouse = mouse_protocol[mt]; auto mouse = mouse_protocol[mt];
if ( mouse ) if ( mouse )
mouse->setRawData (fifo_buf); mouse->setRawData (fifo_buf);
@ -1522,7 +1503,7 @@ void FMouseControl::setRawData ( FMouse::mouse_type mt
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouseControl::processEvent (struct timeval* time) void FMouseControl::processEvent (struct timeval* time)
{ {
FMouse* mouse_object = getMouseWithData(); auto mouse_object = getMouseWithData();
// Clear all old mouse events // Clear all old mouse events
clearEvent(); clearEvent();
@ -1537,8 +1518,8 @@ bool FMouseControl::getGpmKeyPressed (bool pending)
if ( mouse_protocol.empty() ) if ( mouse_protocol.empty() )
return false; return false;
FMouse* mouse = mouse_protocol[FMouse::gpm]; auto mouse = mouse_protocol[FMouse::gpm];
FMouseGPM* gpm_mouse = static_cast<FMouseGPM*>(mouse); auto gpm_mouse = static_cast<FMouseGPM*>(mouse);
if ( gpm_mouse ) if ( gpm_mouse )
return gpm_mouse->getGpmKeyPressed(pending); return gpm_mouse->getGpmKeyPressed(pending);
@ -1559,8 +1540,8 @@ void FMouseControl::drawGpmPointer()
if ( mouse_protocol.empty() ) if ( mouse_protocol.empty() )
return; return;
FMouse* mouse = mouse_protocol[FMouse::gpm]; auto mouse = mouse_protocol[FMouse::gpm];
FMouseGPM* gpm_mouse = static_cast<FMouseGPM*>(mouse); auto gpm_mouse = static_cast<FMouseGPM*>(mouse);
if ( gpm_mouse ) if ( gpm_mouse )
gpm_mouse->drawGpmPointer(); gpm_mouse->drawGpmPointer();
@ -1575,15 +1556,9 @@ void FMouseControl::drawGpmPointer()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FMouse* FMouseControl::getMouseWithData() FMouse* FMouseControl::getMouseWithData()
{ {
iter = mouse_protocol.begin(); for (auto&& m : mouse_protocol)
if ( m.second && m.second->hasData() )
while ( iter != mouse_protocol.end() ) return m.second;
{
if ( iter->second && iter->second->hasData() )
return iter->second;
++iter;
}
return 0; return 0;
} }
@ -1591,15 +1566,9 @@ FMouse* FMouseControl::getMouseWithData()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FMouse* FMouseControl::getMouseWithEvent() FMouse* FMouseControl::getMouseWithEvent()
{ {
iter = mouse_protocol.begin(); for (auto&& m : mouse_protocol)
if ( m.second && m.second->hasEvent() )
while ( iter != mouse_protocol.end() ) return m.second;
{
if ( iter->second && iter->second->hasEvent() )
return iter->second;
++iter;
}
return 0; return 0;
} }

View File

@ -1455,7 +1455,7 @@ inline void FOptiAttr::change_to_default_color ( charData*& term
else if ( bg == fc::Default && term->bg_color != fc::Default ) else if ( bg == fc::Default && term->bg_color != fc::Default )
{ {
char* sgr_49; char* sgr_49;
char* op = F_orig_pair.cap; auto& op = F_orig_pair.cap;
if ( op && std::strncmp (op, CSI "39;49;25m", 11) == 0 ) if ( op && std::strncmp (op, CSI "39;49;25m", 11) == 0 )
sgr_49 = C_STR(CSI "49;25m"); sgr_49 = C_STR(CSI "49;25m");
@ -1479,11 +1479,11 @@ inline void FOptiAttr::change_current_color ( charData*& term
, FColor fg, FColor bg ) , FColor fg, FColor bg )
{ {
char* color_str; char* color_str;
char* AF = F_set_a_foreground.cap; auto& AF = F_set_a_foreground.cap;
char* AB = F_set_a_background.cap; auto& AB = F_set_a_background.cap;
char* Sf = F_set_foreground.cap; auto& Sf = F_set_foreground.cap;
char* Sb = F_set_background.cap; auto& Sb = F_set_background.cap;
char* sp = F_set_color_pair.cap; auto& sp = F_set_color_pair.cap;
bool frev = ( off.attr.bit.reverse bool frev = ( off.attr.bit.reverse
|| off.attr.bit.standout || off.attr.bit.standout
|| term->attr.bit.reverse || term->attr.bit.reverse
@ -1491,8 +1491,8 @@ inline void FOptiAttr::change_current_color ( charData*& term
if ( AF && AB ) if ( AF && AB )
{ {
FColor ansi_fg = vga2ansi(fg); auto ansi_fg = vga2ansi(fg);
FColor ansi_bg = vga2ansi(bg); auto ansi_bg = vga2ansi(bg);
if ( (term->fg_color != fg || frev) if ( (term->fg_color != fg || frev)
&& (color_str = tparm(AF, ansi_fg, 0, 0, 0, 0, 0, 0, 0, 0)) ) && (color_str = tparm(AF, ansi_fg, 0, 0, 0, 0, 0, 0, 0, 0)) )
@ -1546,9 +1546,9 @@ inline void FOptiAttr::reset (charData*& attr)
bool FOptiAttr::caused_reset_attributes (char cap[], uChar test) bool FOptiAttr::caused_reset_attributes (char cap[], uChar test)
{ {
// test if "cap" reset all attributes // test if "cap" reset all attributes
char* ue = F_exit_underline_mode.cap; auto& ue = F_exit_underline_mode.cap;
char* se = F_exit_standout_mode.cap; auto& se = F_exit_standout_mode.cap;
char* me = F_exit_attribute_mode.cap; auto& me = F_exit_attribute_mode.cap;
if ( cap ) if ( cap )
{ {
@ -1578,10 +1578,10 @@ inline bool FOptiAttr::hasCharsetEquivalence()
{ {
// Detect if alt charset and pc charset are the same sequences // Detect if alt charset and pc charset are the same sequences
char* alt_on = F_enter_alt_charset_mode.cap; auto& alt_on = F_enter_alt_charset_mode.cap;
char* alt_off = F_enter_pc_charset_mode.cap; auto& alt_off = F_enter_pc_charset_mode.cap;
char* pc_on = F_enter_pc_charset_mode.cap; auto& pc_on = F_enter_pc_charset_mode.cap;
char* pc_off = F_exit_pc_charset_mode.cap; auto& pc_off = F_exit_pc_charset_mode.cap;
if ( alt_on && pc_on && std::strcmp (alt_on, pc_on) == 0 ) if ( alt_on && pc_on && std::strcmp (alt_on, pc_on) == 0 )
return true; return true;
@ -1637,14 +1637,14 @@ inline void FOptiAttr::detectSwitchOff (charData*& term, charData*& next)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FOptiAttr::switchOn() inline bool FOptiAttr::switchOn()
{ {
charData* on_ptr = &on; auto on_ptr = &on;
return hasAttribute(on_ptr); return hasAttribute(on_ptr);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FOptiAttr::switchOff() inline bool FOptiAttr::switchOff()
{ {
charData* off_ptr = &off; auto off_ptr = &off;
return hasAttribute(off_ptr); return hasAttribute(off_ptr);
} }

View File

@ -98,9 +98,8 @@ bool FProgressbar::setShadow (bool on)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FProgressbar::hide() void FProgressbar::hide()
{ {
std::size_t s, size;
FColor fg, bg; FColor fg, bg;
FWidget* parent_widget = getParentWidget(); auto parent_widget = getParentWidget();
FWidget::hide(); FWidget::hide();
@ -116,13 +115,13 @@ void FProgressbar::hide()
} }
setColor (fg, bg); setColor (fg, bg);
s = hasShadow() ? 1 : 0; auto s = hasShadow() ? 1 : 0;
size = getWidth() + s; auto size = getWidth() + s;
if ( size == 0 ) if ( size == 0 )
return; return;
char* blank = createBlankArray(size + 1); auto blank = createBlankArray(size + 1);
for (std::size_t y = 0; y < getHeight() + s; y++) for (std::size_t y = 0; y < getHeight() + s; y++)
{ {
@ -166,7 +165,7 @@ void FProgressbar::draw()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FProgressbar::drawPercentage() void FProgressbar::drawPercentage()
{ {
FWidget* parent_widget = getParentWidget(); auto parent_widget = getParentWidget();
if ( parent_widget ) if ( parent_widget )
setColor ( parent_widget->getForegroundColor() setColor ( parent_widget->getForegroundColor()

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2015-2017 Markus Gans * * Copyright 2015-2018 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -62,7 +62,7 @@ void FRadioMenuItem::init (FWidget* parent)
if ( isMenu(parent) ) // Parent is menu if ( isMenu(parent) ) // Parent is menu
{ {
FMenu* menu_ptr = static_cast<FMenu*>(parent); auto menu_ptr = static_cast<FMenu*>(parent);
menu_ptr->has_checkable_items = true; menu_ptr->has_checkable_items = true;
addCallback // for this element addCallback // for this element

View File

@ -404,7 +404,7 @@ void FScrollView::draw()
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
if ( FWidget* p = getParentWidget() ) if ( auto p = getParentWidget() )
setColor (p->getForegroundColor(), p->getBackgroundColor()); setColor (p->getForegroundColor(), p->getBackgroundColor());
else else
setColor(); setColor();
@ -505,7 +505,7 @@ void FScrollView::onFocusIn (FFocusEvent* in_ev)
if ( hasChildren() ) if ( hasChildren() )
{ {
FWidget* prev_element = getFocusWidget(); auto prev_element = getFocusWidget();
if ( in_ev->getFocusType() == fc::FocusNextWidget ) if ( in_ev->getFocusType() == fc::FocusNextWidget )
focusFirstChild(); focusFirstChild();
@ -530,7 +530,7 @@ void FScrollView::onChildFocusIn (FFocusEvent*)
FRect widget_geometry; FRect widget_geometry;
FRect vp_geometry; FRect vp_geometry;
FWidget* focus = FWidget::getFocusWidget(); auto focus = FWidget::getFocusWidget();
if ( ! focus ) if ( ! focus )
return; return;
@ -567,11 +567,11 @@ void FScrollView::onChildFocusOut (FFocusEvent* out_ev)
{ {
// Change the focus away from FScrollView to another widget // Change the focus away from FScrollView to another widget
FWidget* focus = FWidget::getFocusWidget(); auto focus = FWidget::getFocusWidget();
if ( out_ev->getFocusType() == fc::FocusNextWidget ) if ( out_ev->getFocusType() == fc::FocusNextWidget )
{ {
FWidget* last_widget = getLastFocusableWidget(getChildren()); auto last_widget = getLastFocusableWidget(getChildren());
if ( focus == last_widget ) if ( focus == last_widget )
{ {
@ -581,7 +581,7 @@ void FScrollView::onChildFocusOut (FFocusEvent* out_ev)
} }
else if ( out_ev->getFocusType() == fc::FocusPreviousWidget ) else if ( out_ev->getFocusType() == fc::FocusPreviousWidget )
{ {
FWidget* first_widget = getFirstFocusableWidget(getChildren()); auto first_widget = getFirstFocusableWidget(getChildren());
if ( focus == first_widget ) if ( focus == first_widget )
{ {
@ -601,7 +601,7 @@ FVTerm::term_area* FScrollView::getPrintArea()
if ( use_own_print_area || ! viewport ) if ( use_own_print_area || ! viewport )
{ {
child_print_area = nullptr; child_print_area = nullptr;
term_area* area = FWidget::getPrintArea(); auto area = FWidget::getPrintArea();
child_print_area = viewport; child_print_area = viewport;
return area; return area;
} }
@ -700,7 +700,7 @@ void FScrollView::copy2area()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FPoint FScrollView::getViewportCursorPos() inline FPoint FScrollView::getViewportCursorPos()
{ {
FWidget* window = FWindow::getWindowWidget(this); auto window = FWindow::getWindowWidget(this);
if ( window ) if ( window )
{ {

View File

@ -135,8 +135,7 @@ FStatusBar::~FStatusBar() // destructor
// delete all keys // delete all keys
if ( ! key_list.empty() ) if ( ! key_list.empty() )
{ {
std::vector<FStatusKey*>::iterator iter; auto iter = key_list.begin();
iter = key_list.begin();
while ( iter != key_list.end() ) while ( iter != key_list.end() )
{ {
@ -162,9 +161,8 @@ bool FStatusBar::hasActivatedKey()
{ {
if ( ! key_list.empty() ) if ( ! key_list.empty() )
{ {
std::vector<FStatusKey*>::const_iterator iter, last; auto iter = key_list.begin();
iter = key_list.begin(); auto last = key_list.end();
last = key_list.end();
while ( iter != last ) while ( iter != last )
{ {
@ -181,13 +179,12 @@ bool FStatusBar::hasActivatedKey()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FStatusBar::hide() void FStatusBar::hide()
{ {
FColor fg, bg;
FWindow::hide(); FWindow::hide();
fg = wc.term_fg; FColor fg = wc.term_fg;
bg = wc.term_bg; FColor bg = wc.term_bg;
setColor (fg, bg); setColor (fg, bg);
screenWidth = getDesktopWidth(); screenWidth = getDesktopWidth();
char* blank = createBlankArray(screenWidth + 1); auto blank = createBlankArray(screenWidth + 1);
setPrintPos (1, 1); setPrintPos (1, 1);
print (blank); print (blank);
destroyBlankArray (blank); destroyBlankArray (blank);
@ -213,7 +210,7 @@ void FStatusBar::drawMessage()
if ( hasKeys ) if ( hasKeys )
{ {
std::vector<FStatusKey*>::const_iterator iter = key_list.end(); auto iter = key_list.end();
isLastActiveFocus = bool ( (*(iter - 1))->isActivated() isLastActiveFocus = bool ( (*(iter - 1))->isActivated()
|| (*(iter - 1))->hasMouseFocus() ); || (*(iter - 1))->hasMouseFocus() );
} }
@ -284,14 +281,12 @@ void FStatusBar::insert (FStatusKey* skey)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FStatusBar::remove (FStatusKey* skey) void FStatusBar::remove (FStatusKey* skey)
{ {
std::vector<FStatusKey*>::iterator iter;
delAccelerator (skey); delAccelerator (skey);
if ( key_list.empty() ) if ( key_list.empty() )
return; return;
iter = key_list.begin(); auto iter = key_list.begin();
while ( iter != key_list.end() ) while ( iter != key_list.end() )
{ {
@ -340,9 +335,8 @@ void FStatusBar::onMouseDown (FMouseEvent* ev)
if ( ! key_list.empty() ) if ( ! key_list.empty() )
{ {
std::vector<FStatusKey*>::const_iterator iter, last; auto iter = key_list.begin();
iter = key_list.begin(); auto last = key_list.end();
last = key_list.end();
while ( iter != last ) while ( iter != last )
{ {
@ -362,10 +356,9 @@ void FStatusBar::onMouseDown (FMouseEvent* ev)
if ( ! key_list.empty() ) if ( ! key_list.empty() )
{ {
std::vector<FStatusKey*>::const_iterator iter, last;
int X = 1; int X = 1;
iter = key_list.begin(); auto iter = key_list.begin();
last = key_list.end(); auto last = key_list.end();
while ( iter != last ) while ( iter != last )
{ {
@ -406,10 +399,9 @@ void FStatusBar::onMouseUp (FMouseEvent* ev)
if ( ! key_list.empty() ) if ( ! key_list.empty() )
{ {
std::vector<FStatusKey*>::const_iterator iter, last;
int X = 1; int X = 1;
iter = key_list.begin(); auto iter = key_list.begin();
last = key_list.end(); auto last = key_list.end();
while ( iter != last ) while ( iter != last )
{ {
@ -451,11 +443,10 @@ void FStatusBar::onMouseMove (FMouseEvent* ev)
if ( mouse_down && ! key_list.empty() ) if ( mouse_down && ! key_list.empty() )
{ {
std::vector<FStatusKey*>::const_iterator iter, last;
bool focus_changed = false; bool focus_changed = false;
int X = 1; int X = 1;
iter = key_list.begin(); auto iter = key_list.begin();
last = key_list.end(); auto last = key_list.end();
while ( iter != last ) while ( iter != last )
{ {
@ -499,11 +490,9 @@ void FStatusBar::cb_statuskey_activated (FWidget* widget, data_ptr)
{ {
if ( ! key_list.empty() ) if ( ! key_list.empty() )
{ {
std::vector<FStatusKey*>::const_iterator iter, last; auto statuskey = static_cast<FStatusKey*>(widget);
FStatusKey* statuskey = static_cast<FStatusKey*>(widget); auto iter = key_list.begin();
auto last = key_list.end();
iter = key_list.begin();
last = key_list.end();
while ( iter != last ) while ( iter != last )
{ {
@ -522,7 +511,7 @@ void FStatusBar::cb_statuskey_activated (FWidget* widget, data_ptr)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FStatusBar::init() void FStatusBar::init()
{ {
FWidget* r = getRootWidget(); auto r = getRootWidget();
std::size_t w = r->getWidth(); std::size_t w = r->getWidth();
int h = int(r->getHeight()); int h = int(r->getHeight());
// initialize geometry values // initialize geometry values
@ -550,8 +539,6 @@ void FStatusBar::draw()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FStatusBar::drawKeys() void FStatusBar::drawKeys()
{ {
keyList::const_iterator iter, last;
screenWidth = getDesktopWidth(); screenWidth = getDesktopWidth();
x = 1; x = 1;
@ -566,8 +553,8 @@ void FStatusBar::drawKeys()
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
iter = key_list.begin(); auto iter = key_list.begin();
last = key_list.end(); auto last = key_list.end();
while ( iter != last ) while ( iter != last )
{ {
@ -603,7 +590,7 @@ void FStatusBar::drawKey (keyList::const_iterator iter)
// Draw not active key // Draw not active key
std::size_t txt_length; std::size_t txt_length;
FStatusKey* item = *iter; auto item = *iter;
setColor (wc.statusbar_hotkey_fg, wc.statusbar_hotkey_bg); setColor (wc.statusbar_hotkey_fg, wc.statusbar_hotkey_bg);
x++; x++;
@ -663,7 +650,7 @@ void FStatusBar::drawActiveKey (keyList::const_iterator iter)
// Draw active key // Draw active key
std::size_t txt_length; std::size_t txt_length;
FStatusKey* item = *iter; auto item = *iter;
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);

View File

@ -91,7 +91,7 @@ FTerm::~FTerm() // destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
std::size_t FTerm::getLineNumber() std::size_t FTerm::getLineNumber()
{ {
FRect& term_geometry = data->getTermGeometry(); auto& term_geometry = data->getTermGeometry();
if ( term_geometry.getHeight() == 0 ) if ( term_geometry.getHeight() == 0 )
detectTermSize(); detectTermSize();
@ -102,7 +102,7 @@ std::size_t FTerm::getLineNumber()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
std::size_t FTerm::getColumnNumber() std::size_t FTerm::getColumnNumber()
{ {
FRect& term_geometry = data->getTermGeometry(); auto& term_geometry = data->getTermGeometry();
if ( term_geometry.getWidth() == 0 ) if ( term_geometry.getWidth() == 0 )
detectTermSize(); detectTermSize();
@ -125,7 +125,7 @@ bool FTerm::isNormal (charData*& ch)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FTerm::isCursorHideable() bool FTerm::isCursorHideable()
{ {
char* cursor_off_str = disableCursor(); const char* cursor_off_str = disableCursor();
if ( cursor_off_str && std::strlen(cursor_off_str) > 0 ) if ( cursor_off_str && std::strlen(cursor_off_str) > 0 )
return true; return true;
@ -319,7 +319,7 @@ bool FTerm::setOldFont()
int FTerm::openConsole() int FTerm::openConsole()
{ {
int fd = data->getTTYFileDescriptor(); int fd = data->getTTYFileDescriptor();
char* termfilename = data->getTermFileName(); const char* termfilename = data->getTermFileName();
static const char* terminal_devices[] = static const char* terminal_devices[] =
{ {
@ -338,7 +338,7 @@ int FTerm::openConsole()
if ( ! *termfilename ) if ( ! *termfilename )
return 0; return 0;
for (int i = 0; terminal_devices[i] != 0; i++) for (std::size_t i = 0; terminal_devices[i] != 0; i++)
{ {
fd = open(terminal_devices[i], O_RDWR, 0); fd = open(terminal_devices[i], O_RDWR, 0);
data->setTTYFileDescriptor(fd); data->setTTYFileDescriptor(fd);
@ -420,8 +420,8 @@ char* FTerm::enableCursor()
static const std::size_t SIZE = 32; static const std::size_t SIZE = 32;
static char enable_str[SIZE] = { }; static char enable_str[SIZE] = { };
char*& vs = TCAP(fc::t_cursor_visible); const auto& vs = TCAP(fc::t_cursor_visible);
char*& ve = TCAP(fc::t_cursor_normal); const auto& ve = TCAP(fc::t_cursor_normal);
if ( ve ) if ( ve )
std::strncpy (enable_str, ve, SIZE - 1); std::strncpy (enable_str, ve, SIZE - 1);
@ -432,8 +432,7 @@ char* FTerm::enableCursor()
if ( isLinuxTerm() ) if ( isLinuxTerm() )
{ {
// Restore the last used Linux console cursor style // Restore the last used Linux console cursor style
char* cstyle; const char* cstyle = linux->restoreCursorStyle();
cstyle = linux->restoreCursorStyle();
std::strncat (enable_str, cstyle, SIZE - std::strlen(enable_str) - 1); std::strncat (enable_str, cstyle, SIZE - std::strlen(enable_str) - 1);
} }
#endif // defined(__linux__) #endif // defined(__linux__)
@ -456,7 +455,7 @@ char* FTerm::disableCursor()
{ {
// Returns the cursor disable string // Returns the cursor disable string
char*& vi = TCAP(fc::t_cursor_invisible); const auto& vi = TCAP(fc::t_cursor_invisible);
if ( vi ) if ( vi )
return vi; return vi;
@ -483,7 +482,7 @@ void FTerm::detectTermSize()
close_after_detect = true; close_after_detect = true;
} }
FRect& term_geometry = data->getTermGeometry(); auto& term_geometry = data->getTermGeometry();
ret = ioctl (fd, TIOCGWINSZ, &win_size); ret = ioctl (fd, TIOCGWINSZ, &win_size);
if ( ret != 0 || win_size.ws_col == 0 || win_size.ws_row == 0 ) if ( ret != 0 || win_size.ws_col == 0 || win_size.ws_row == 0 )
@ -549,8 +548,8 @@ void FTerm::saveColorMap()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::resetColorMap() void FTerm::resetColorMap()
{ {
char*& oc = TCAP(fc::t_orig_colors); const auto& oc = TCAP(fc::t_orig_colors);
char*& op = TCAP(fc::t_orig_pair); const auto& op = TCAP(fc::t_orig_pair);
if ( oc ) if ( oc )
putstring (oc); putstring (oc);
@ -571,8 +570,8 @@ void FTerm::setPalette (FColor index, int r, int g, int b)
{ {
// Redefine RGB color value for a palette entry // Redefine RGB color value for a palette entry
char*& Ic = TCAP(fc::t_initialize_color); const auto& Ic = TCAP(fc::t_initialize_color);
char*& Ip = TCAP(fc::t_initialize_pair); const auto& Ip = TCAP(fc::t_initialize_pair);
index = FOptiAttr::vga2ansi(index); index = FOptiAttr::vga2ansi(index);
@ -682,12 +681,11 @@ fc::encoding FTerm::getEncoding()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
std::string FTerm::getEncodingString() std::string FTerm::getEncodingString()
{ {
fc::encoding term_encoding = data->getTermEncoding(); auto term_encoding = data->getTermEncoding();
FTermData::encodingMap& encoding_list = data->getEncodingList(); auto& encoding_list = data->getEncodingList();
std::map<std::string, fc::encoding>::const_iterator it, end; auto end = encoding_list.end();
end = encoding_list.end();
for (it = encoding_list.begin(); it != end; ++it ) for (auto it = encoding_list.begin(); it != end; ++it )
if ( it->second == term_encoding ) if ( it->second == term_encoding )
return it->first; return it->first;
@ -710,7 +708,7 @@ uInt FTerm::charEncode (uInt c)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
uInt FTerm::charEncode (uInt c, fc::encoding enc) uInt FTerm::charEncode (uInt c, fc::encoding enc)
{ {
for (uInt i = 0; i <= uInt(fc::lastCharItem); i++) for (std::size_t i = 0; i <= uInt(fc::lastCharItem); i++)
{ {
if ( fc::character[i][fc::UTF8] == c ) if ( fc::character[i][fc::UTF8] == c )
{ {
@ -947,7 +945,7 @@ void FTerm::init_alt_charset()
if ( TCAP(fc::t_acs_chars) ) if ( TCAP(fc::t_acs_chars) )
{ {
for (int n = 0; TCAP(fc::t_acs_chars)[n]; n += 2) for (std::size_t n = 0; TCAP(fc::t_acs_chars)[n]; n += 2)
{ {
// insert the VT100 key/value pairs into a map // insert the VT100 key/value pairs into a map
uChar p1 = uChar(TCAP(fc::t_acs_chars)[n]); uChar p1 = uChar(TCAP(fc::t_acs_chars)[n]);
@ -963,7 +961,7 @@ void FTerm::init_alt_charset()
}; };
// Update array 'character' with discovered VT100 pairs // Update array 'character' with discovered VT100 pairs
for (int n = 0; n <= fc::lastKeyItem; n++ ) for (std::size_t n = 0; n <= fc::lastKeyItem; n++ )
{ {
uChar keyChar = uChar(fc::vt100_key_to_utf8[n][vt100_key]); uChar keyChar = uChar(fc::vt100_key_to_utf8[n][vt100_key]);
uChar altChar = uChar(vt100_alt_char[keyChar]); uChar altChar = uChar(vt100_alt_char[keyChar]);
@ -1051,7 +1049,7 @@ void FTerm::init_cygwin_charmap()
if ( ! isCygwinTerminal() ) if ( ! isCygwinTerminal() )
return; return;
for (int i = 0; i <= fc::lastCharItem; i++ ) for (std::size_t i = 0; i <= fc::lastCharItem; i++ )
{ {
if ( fc::character[i][fc::UTF8] == fc::BlackUpPointingTriangle // ▲ if ( fc::character[i][fc::UTF8] == fc::BlackUpPointingTriangle // ▲
|| fc::character[i][fc::UTF8] == fc::BlackDownPointingTriangle // ▼ || fc::character[i][fc::UTF8] == fc::BlackDownPointingTriangle // ▼
@ -1082,7 +1080,7 @@ void FTerm::init_teraterm_charmap()
if ( ! isTeraTerm() ) if ( ! isTeraTerm() )
return; return;
for (int i = 0; i <= fc::lastCharItem; i++ ) for (std::size_t i = 0; i <= fc::lastCharItem; i++ )
if ( fc::character[i][fc::PC] < 0x20 ) if ( fc::character[i][fc::PC] < 0x20 )
fc::character[i][fc::PC] = fc::character[i][fc::ASCII]; fc::character[i][fc::PC] = fc::character[i][fc::ASCII];
} }
@ -1208,21 +1206,11 @@ void FTerm::init_optiAttr()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::init_font() void FTerm::init_font()
{ {
if ( init_values.vgafont ) if ( init_values.vgafont && ! setVGAFont() )
{ exitWithMessage ("VGAfont is not supported by this terminal");
bool ret = setVGAFont();
if ( ! ret ) if ( init_values.newfont && ! setNewFont() )
exitWithMessage ("VGAfont is not supported by this terminal"); exitWithMessage ("Newfont is not supported by this terminal");
}
if ( init_values.newfont )
{
bool ret = setNewFont();
if ( ! ret )
exitWithMessage ("Newfont is not supported by this terminal");
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1310,8 +1298,7 @@ inline void FTerm::init_encoding_set()
{ {
// Define the encoding set // Define the encoding set
FTermData::encodingMap& encoding_list = data->getEncodingList(); auto& encoding_list = data->getEncodingList();
encoding_list["UTF8"] = fc::UTF8; encoding_list["UTF8"] = fc::UTF8;
encoding_list["UTF-8"] = fc::UTF8; encoding_list["UTF-8"] = fc::UTF8;
encoding_list["VT100"] = fc::VT100; // VT100 line drawing encoding_list["VT100"] = fc::VT100; // VT100 line drawing
@ -1403,7 +1390,7 @@ void FTerm::init_tab_quirks()
// on the terminal and does not move the cursor to the next tab stop // on the terminal and does not move the cursor to the next tab stop
// position // position
fc::encoding enc = data->getTermEncoding(); auto enc = data->getTermEncoding();
if ( enc == fc::VT100 || enc == fc::PC ) if ( enc == fc::VT100 || enc == fc::PC )
{ {
@ -1498,9 +1485,8 @@ void FTerm::setInsertCursorStyle()
setKDECursor(fc::UnderlineCursor); setKDECursor(fc::UnderlineCursor);
#if defined(__linux__) #if defined(__linux__)
char* cstyle; const char* cstyle = linux->setCursorStyle ( fc::underscore_cursor
cstyle = linux->setCursorStyle ( fc::underscore_cursor , data->isCursorHidden() );
, data->isCursorHidden() );
putstring (cstyle); putstring (cstyle);
std::fflush(stdout); std::fflush(stdout);
#elif defined(__FreeBSD__) || defined(__DragonFly__) #elif defined(__FreeBSD__) || defined(__DragonFly__)
@ -1519,9 +1505,8 @@ void FTerm::setOverwriteCursorStyle()
setKDECursor(fc::BlockCursor); setKDECursor(fc::BlockCursor);
#if defined(__linux__) #if defined(__linux__)
char* cstyle; char* cstyle = linux->setCursorStyle ( fc::full_block_cursor
cstyle = linux->setCursorStyle ( fc::full_block_cursor , data->isCursorHidden() );
, data->isCursorHidden() );
putstring (cstyle); putstring (cstyle);
std::fflush(stdout); std::fflush(stdout);
#elif defined(__FreeBSD__) || defined(__DragonFly__) #elif defined(__FreeBSD__) || defined(__DragonFly__)
@ -2009,7 +1994,7 @@ uInt FTerm::cp437_to_unicode (uChar c)
{ {
uInt ucs = uInt(c); uInt ucs = uInt(c);
for (uInt i = 0; i <= fc::lastCP437Item; i++) for (std::size_t i = 0; i <= fc::lastCP437Item; i++)
{ {
if ( fc::cp437_to_ucs[i][0] == c ) // found if ( fc::cp437_to_ucs[i][0] == c ) // found
{ {

View File

@ -81,7 +81,6 @@ void FTermcap::init()
void FTermcap::termcap() void FTermcap::termcap()
{ {
std::vector<std::string> terminals; std::vector<std::string> terminals;
std::vector<std::string>::iterator iter;
static const int success = 1; static const int success = 1;
static const int uninitialized = -2; static const int uninitialized = -2;
static char term_buffer[2048]; static char term_buffer[2048];
@ -104,7 +103,7 @@ void FTermcap::termcap()
terminals.push_back("xterm"); // 2nd fallback if not found terminals.push_back("xterm"); // 2nd fallback if not found
terminals.push_back("ansi"); // 3rd fallback if not found terminals.push_back("ansi"); // 3rd fallback if not found
terminals.push_back("vt100"); // 4th fallback if not found terminals.push_back("vt100"); // 4th fallback if not found
iter = terminals.begin(); auto iter = terminals.begin();
while ( iter != terminals.end() ) while ( iter != terminals.end() )
{ {
@ -225,7 +224,7 @@ void FTermcap::termcapStrings (char*& buffer)
// Get termcap strings // Get termcap strings
// Read termcap output strings // Read termcap output strings
for (int i = 0; tcap[i].tname[0] != 0; i++) for (std::size_t i = 0; tcap[i].tname[0] != 0; i++)
tcap[i].string = tgetstr(tcap[i].tname, &buffer); tcap[i].string = tgetstr(tcap[i].tname, &buffer);
} }
@ -234,7 +233,7 @@ void FTermcap::termcapKeys (char*& buffer)
{ {
// Read termcap key strings // Read termcap key strings
for (int i = 0; fc::Fkey[i].tname[0] != 0; i++) for (std::size_t i = 0; fc::Fkey[i].tname[0] != 0; i++)
{ {
fc::Fkey[i].string = tgetstr(fc::Fkey[i].tname, &buffer); fc::Fkey[i].string = tgetstr(fc::Fkey[i].tname, &buffer);
@ -288,13 +287,13 @@ void FTermcap::termcapKeysVt100 (char*& buffer)
// Some terminals (e.g. PuTTY) send vt100 key codes for // Some terminals (e.g. PuTTY) send vt100 key codes for
// the arrow and function keys. // the arrow and function keys.
char* key_up_string = tgetstr(C_STR("ku"), &buffer); const char* key_up_string = tgetstr(C_STR("ku"), &buffer);
if ( (key_up_string && (std::strcmp(key_up_string, CSI "A") == 0)) if ( (key_up_string && (std::strcmp(key_up_string, CSI "A") == 0))
|| ( TCAP(fc::t_cursor_up) || ( TCAP(fc::t_cursor_up)
&& (std::strcmp(TCAP(fc::t_cursor_up), CSI "A") == 0) ) ) && (std::strcmp(TCAP(fc::t_cursor_up), CSI "A") == 0) ) )
{ {
for (int i = 0; fc::Fkey[i].tname[0] != 0; i++) for (std::size_t i = 0; fc::Fkey[i].tname[0] != 0; i++)
{ {
if ( std::strncmp(fc::Fkey[i].tname, "kux", 3) == 0 ) if ( std::strncmp(fc::Fkey[i].tname, "kux", 3) == 0 )
fc::Fkey[i].string = C_STR(CSI "A"); // Key up fc::Fkey[i].string = C_STR(CSI "A"); // Key up

View File

@ -65,7 +65,7 @@ void FTermcapQuirks::setFTermDetection (FTermDetection* td)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermcapQuirks::terminalFixup() void FTermcapQuirks::terminalFixup()
{ {
FTermDetection* td = term_detection; auto td = term_detection;
if ( td->isCygwinTerminal() ) if ( td->isCygwinTerminal() )
{ {
@ -405,7 +405,7 @@ void FTermcapQuirks::sunConsole()
C_STR(CSI "%p1%dD"); C_STR(CSI "%p1%dD");
// Sun Microsystems workstation console keys // Sun Microsystems workstation console keys
for (int i = 0; fc::Fkey[i].tname[0] != 0; i++) for (std::size_t i = 0; fc::Fkey[i].tname[0] != 0; i++)
{ {
if ( std::strncmp(fc::Fkey[i].tname, "K2", 2) == 0 ) if ( std::strncmp(fc::Fkey[i].tname, "K2", 2) == 0 )
fc::Fkey[i].string = C_STR(CSI "218z"); // center of keypad fc::Fkey[i].string = C_STR(CSI "218z"); // center of keypad

View File

@ -111,7 +111,7 @@ void FTermFreeBSD::initCharMap (uInt char_map[][fc::NUM_OF_ENCODINGS])
if ( ! isFreeBSDConsole() ) if ( ! isFreeBSDConsole() )
return; return;
for (int i = 0; i <= fc::lastCharItem; i++) for (std::size_t i = 0; i <= fc::lastCharItem; i++)
if ( char_map[i][fc::PC] < 0x1c ) if ( char_map[i][fc::PC] < 0x1c )
char_map[i][fc::PC] = char_map[i][fc::ASCII]; char_map[i][fc::PC] = char_map[i][fc::ASCII];
} }

View File

@ -198,11 +198,11 @@ void FTermLinux::initCharMap (uInt char_map[][fc::NUM_OF_ENCODINGS])
if ( screen_unicode_map.entry_ct != 0 ) if ( screen_unicode_map.entry_ct != 0 )
{ {
for (int i = 0; i <= fc::lastCharItem; i++ ) for (std::size_t i = 0; i <= fc::lastCharItem; i++ )
{ {
bool known_unicode = false; bool known_unicode = false;
for (uInt n = 0; n < screen_unicode_map.entry_ct; n++) for (std::size_t n = 0; n < screen_unicode_map.entry_ct; n++)
{ {
if ( char_map[i][fc::UTF8] == screen_unicode_map.entries[n].unicode ) if ( char_map[i][fc::UTF8] == screen_unicode_map.entries[n].unicode )
{ {
@ -893,7 +893,7 @@ bool FTermLinux::resetVGAPalette()
{0x55, 0xFF, 0xFF}, {0xFF, 0xFF, 0xFF} {0x55, 0xFF, 0xFF}, {0xFF, 0xFF, 0xFF}
}; };
for (int index = 0; index < 16; index++) for (std::size_t index = 0; index < 16; index++)
{ {
cmap.color[index].red = defaultColor[index].red; cmap.color[index].red = defaultColor[index].red;
cmap.color[index].green = defaultColor[index].green; cmap.color[index].green = defaultColor[index].green;

View File

@ -187,10 +187,8 @@ void FTextView::scrollTo (int x, int y)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTextView::hide() void FTextView::hide()
{ {
std::size_t n, size;
FColor fg, bg; FColor fg, bg;
FWidget* parent_widget = getParentWidget(); auto parent_widget = getParentWidget();
FWidget::hide(); FWidget::hide();
if ( parent_widget ) if ( parent_widget )
@ -205,13 +203,13 @@ void FTextView::hide()
} }
setColor (fg, bg); setColor (fg, bg);
n = isNewFont() ? 1 : 0; auto n = isNewFont() ? 1 : 0;
size = getWidth() + n; auto size = getWidth() + n;
if ( size == 0 ) if ( size == 0 )
return; return;
char* blank = createBlankArray(size + 1); auto blank = createBlankArray(size + 1);
for (std::size_t y = 0; y < getHeight(); y++) for (std::size_t y = 0; y < getHeight(); y++)
{ {
@ -232,10 +230,7 @@ void FTextView::append (const FString& str)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTextView::insert (const FString& str, int pos) void FTextView::insert (const FString& str, int pos)
{ {
FStringList::iterator iter;
FStringList text_split;
FString s; FString s;
std::size_t num;
if ( pos < 0 || pos >= int(getRows()) ) if ( pos < 0 || pos >= int(getRows()) )
pos = int(getRows()); pos = int(getRows());
@ -245,18 +240,17 @@ void FTextView::insert (const FString& str, int pos)
else else
s = FString(str).rtrim().expandTabs(getTabstop()); s = FString(str).rtrim().expandTabs(getTabstop());
iter = data.begin(); auto iter = data.begin();
text_split = s.split("\r\n"); auto text_split = s.split("\r\n");
num = text_split.size(); auto num = text_split.size();
for (std::size_t i = 0; i < num; i++) for (std::size_t i = 0; i < num; i++)
{ {
std::size_t len;
text_split[i] = text_split[i].removeBackspaces() text_split[i] = text_split[i].removeBackspaces()
.removeDel() .removeDel()
.replaceControlCodes() .replaceControlCodes()
.rtrim(); .rtrim();
len = text_split[i].getLength(); auto len = text_split[i].getLength();
if ( len > maxLineWidth ) if ( len > maxLineWidth )
{ {
@ -297,12 +291,10 @@ void FTextView::insert (const FString& str, int pos)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTextView::replaceRange (const FString& str, int from, int to) void FTextView::replaceRange (const FString& str, int from, int to)
{ {
FStringList::iterator iter;
if ( from > to || from >= int(getRows()) || to >= int(getRows()) ) if ( from > to || from >= int(getRows()) || to >= int(getRows()) )
return; return;
iter = data.begin(); auto iter = data.begin();
data.erase (iter + from, iter + to + 1); data.erase (iter + from, iter + to + 1);
if ( ! str.isNull() ) if ( ! str.isNull() )
@ -333,7 +325,7 @@ void FTextView::clear()
if ( size == 0 ) if ( size == 0 )
return; return;
char* blank = createBlankArray(size + 1); auto blank = createBlankArray(size + 1);
for (int y = 0; y < int(getTextHeight()); y++) for (int y = 0; y < int(getTextHeight()); y++)
{ {
@ -398,9 +390,6 @@ void FTextView::onKeyPress (FKeyEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTextView::onMouseDown (FMouseEvent* ev) void FTextView::onMouseDown (FMouseEvent* ev)
{ {
FWidget* parent;
FDialog* dialog;
if ( ev->getButton() != fc::LeftButton ) if ( ev->getButton() != fc::LeftButton )
return; return;
@ -418,12 +407,12 @@ void FTextView::onMouseDown (FMouseEvent* ev)
getStatusBar()->drawMessage(); getStatusBar()->drawMessage();
} }
parent = getParentWidget(); auto parent = getParentWidget();
if ( ! parent ) if ( ! parent )
return; return;
dialog = static_cast<FDialog*>(parent); auto dialog = static_cast<FDialog*>(parent);
if ( parent->isDialogWidget() if ( parent->isDialogWidget()
&& dialog->isResizeable() && dialog->isResizeable()
@ -436,7 +425,7 @@ void FTextView::onMouseDown (FMouseEvent* ev)
try try
{ {
FMouseEvent* _ev = new FMouseEvent (fc::MouseDown_Event, p, tp, b); auto _ev = new FMouseEvent (fc::MouseDown_Event, p, tp, b);
FApplication::sendEvent (parent, _ev); FApplication::sendEvent (parent, _ev);
delete _ev; delete _ev;
} }
@ -450,11 +439,11 @@ void FTextView::onMouseDown (FMouseEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTextView::onMouseUp (FMouseEvent* ev) void FTextView::onMouseUp (FMouseEvent* ev)
{ {
FWidget* parent = getParentWidget(); auto parent = getParentWidget();
if ( parent && parent->isDialogWidget() ) if ( parent && parent->isDialogWidget() )
{ {
FDialog* dialog = static_cast<FDialog*>(parent); auto dialog = static_cast<FDialog*>(parent);
if ( dialog->isResizeable() && ! dialog->isZoomed() ) if ( dialog->isResizeable() && ! dialog->isZoomed() )
{ {
@ -465,7 +454,7 @@ void FTextView::onMouseUp (FMouseEvent* ev)
try try
{ {
FMouseEvent* _ev = new FMouseEvent (fc::MouseUp_Event, p, tp, b); auto _ev = new FMouseEvent (fc::MouseUp_Event, p, tp, b);
FApplication::sendEvent (parent, _ev); FApplication::sendEvent (parent, _ev);
delete _ev; delete _ev;
} }
@ -486,11 +475,11 @@ void FTextView::onMouseUp (FMouseEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTextView::onMouseMove (FMouseEvent* ev) void FTextView::onMouseMove (FMouseEvent* ev)
{ {
FWidget* parent = getParentWidget(); auto parent = getParentWidget();
if ( parent && parent->isDialogWidget() ) if ( parent && parent->isDialogWidget() )
{ {
FDialog* dialog = static_cast<FDialog*>(parent); auto dialog = static_cast<FDialog*>(parent);
if ( dialog->isResizeable() && ! dialog->isZoomed() ) if ( dialog->isResizeable() && ! dialog->isZoomed() )
{ {
@ -501,7 +490,7 @@ void FTextView::onMouseMove (FMouseEvent* ev)
try try
{ {
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p, tp, b); auto _ev = new FMouseEvent (fc::MouseMove_Event, p, tp, b);
FApplication::sendEvent (parent, _ev); FApplication::sendEvent (parent, _ev);
delete _ev; delete _ev;
} }
@ -675,7 +664,7 @@ void FTextView::init()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTextView::draw() void FTextView::draw()
{ {
FWidget* parent = getParentWidget(); auto parent = getParentWidget();
bool is_text_dialog; bool is_text_dialog;
setColor(); setColor();
@ -732,7 +721,7 @@ void FTextView::drawText()
if ( data.empty() || getHeight() <= 2 || getWidth() <= 2 ) if ( data.empty() || getHeight() <= 2 || getWidth() <= 2 )
return; return;
std::size_t num = getTextHeight(); auto num = getTextHeight();
if ( num > getRows() ) if ( num > getRows() )
num = getRows(); num = getRows();
@ -744,14 +733,13 @@ void FTextView::drawText()
for (std::size_t y = 0; y < num; y++) for (std::size_t y = 0; y < num; y++)
{ {
std::size_t i, len; std::size_t i;
FString line; FString line;
const wchar_t* line_str;
setPrintPos (2, 2 - nf_offset + int(y)); setPrintPos (2, 2 - nf_offset + int(y));
line = data[y + std::size_t(yoffset)].mid ( std::size_t(1 + xoffset) line = data[y + std::size_t(yoffset)].mid ( std::size_t(1 + xoffset)
, getTextWidth() ); , getTextWidth() );
line_str = line.wc_str(); const auto line_str = line.wc_str();
len = line.getLength(); const auto len = line.getLength();
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
{ {

View File

@ -204,7 +204,7 @@ void FToggleButton::hide()
{ {
std::size_t size; std::size_t size;
FColor fg, bg; FColor fg, bg;
FWidget* parent_widget = getParentWidget(); auto parent_widget = getParentWidget();
FWidget::hide(); FWidget::hide();
if ( parent_widget ) if ( parent_widget )
@ -224,7 +224,7 @@ void FToggleButton::hide()
if ( size == 0 ) if ( size == 0 )
return; return;
char* blank = createBlankArray(size + 1); auto blank = createBlankArray(size + 1);
setPrintPos (1, 1); setPrintPos (1, 1);
print (blank); print (blank);
destroyBlankArray (blank); destroyBlankArray (blank);
@ -239,7 +239,7 @@ void FToggleButton::onMouseDown (FMouseEvent* ev)
if ( hasFocus() ) if ( hasFocus() )
return; return;
FWidget* focused_widget = getFocusWidget(); auto focused_widget = getFocusWidget();
FFocusEvent out (fc::FocusOut_Event); FFocusEvent out (fc::FocusOut_Event);
FApplication::queueEvent(focused_widget, &out); FApplication::queueEvent(focused_widget, &out);
setFocus(); setFocus();
@ -301,7 +301,7 @@ void FToggleButton::onAccel (FAccelEvent* ev)
if ( ! hasFocus() ) if ( ! hasFocus() )
{ {
FWidget* focused_widget = static_cast<FWidget*>(ev->focusedWidget()); auto focused_widget = static_cast<FWidget*>(ev->focusedWidget());
if ( focused_widget && focused_widget->isWidget() ) if ( focused_widget && focused_widget->isWidget() )
{ {
@ -470,7 +470,6 @@ void FToggleButton::draw()
void FToggleButton::drawLabel() void FToggleButton::drawLabel()
{ {
wchar_t* LabelText; wchar_t* LabelText;
std::size_t hotkeypos;
if ( ! isVisible() ) if ( ! isVisible() )
return; return;
@ -493,7 +492,7 @@ void FToggleButton::drawLabel()
FString txt = text; FString txt = text;
wchar_t* src = const_cast<wchar_t*>(txt.wc_str()); wchar_t* src = const_cast<wchar_t*>(txt.wc_str());
wchar_t* dest = const_cast<wchar_t*>(LabelText); wchar_t* dest = const_cast<wchar_t*>(LabelText);
hotkeypos = getHotkeyPos(src, dest, length); auto hotkeypos = getHotkeyPos(src, dest, length);
if ( hotkeypos != NOT_SET ) if ( hotkeypos != NOT_SET )
length--; length--;

View File

@ -49,14 +49,14 @@ FToolTip::FToolTip (const FString& txt, FWidget* parent)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FToolTip::~FToolTip() // destructor FToolTip::~FToolTip() // destructor
{ {
FApplication* fapp = static_cast<FApplication*>(getRootWidget()); auto fapp = static_cast<FApplication*>(getRootWidget());
if ( fapp->isQuit() ) if ( fapp->isQuit() )
return; return;
FWindow* parent_win = nullptr; FWindow* parent_win = nullptr;
if ( FWidget* parent = getParentWidget() ) if ( auto parent = getParentWidget() )
parent_win = getWindowWidget(parent); parent_win = getWindowWidget(parent);
if ( parent_win ) if ( parent_win )
@ -85,9 +85,9 @@ void FToolTip::draw()
clearArea(); clearArea();
drawBorder(); drawBorder();
for (int i = 0; i < int(text_num_lines); i++) for (std::size_t i = 0; i < text_num_lines; i++)
{ {
setPrintPos (3, 2 + i); setPrintPos (3, 2 + int(i));
print(text_components[i]); print(text_components[i]);
} }
@ -136,7 +136,7 @@ void FToolTip::calculateDimensions()
{ {
int x, y; int x, y;
std::size_t w, h; std::size_t w, h;
FWidget* r = getRootWidget(); auto r = getRootWidget();
max_line_width = 0; max_line_width = 0;
text_split = text.split("\n"); text_split = text.split("\n");
text_num_lines = uInt(text_split.size()); text_num_lines = uInt(text_split.size());

View File

@ -89,7 +89,7 @@ FVTerm::~FVTerm() // destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FPoint FVTerm::getPrintCursor() FPoint FVTerm::getPrintCursor()
{ {
term_area* win = getPrintArea(); auto win = getPrintArea();
if ( win ) if ( win )
return FPoint ( win->offset_left + win->cursor_x return FPoint ( win->offset_left + win->cursor_x
@ -103,7 +103,6 @@ void FVTerm::setTermXY (int x, int y)
{ {
// Sets the hardware cursor to the given (x,y) position // Sets the hardware cursor to the given (x,y) position
int term_x, term_y, term_width, term_height; int term_x, term_y, term_width, term_height;
char* move_str;
if ( term_pos->getX() == x && term_pos->getY() == y ) if ( term_pos->getX() == x && term_pos->getY() == y )
return; return;
@ -126,7 +125,7 @@ void FVTerm::setTermXY (int x, int y)
term_x = term_pos->getX(); term_x = term_pos->getX();
term_y = term_pos->getY(); term_y = term_pos->getY();
move_str = FTerm::moveCursor (term_x, term_y, x, y); const char* move_str = FTerm::moveCursor (term_x, term_y, x, y);
if ( move_str ) if ( move_str )
appendOutputBuffer(move_str); appendOutputBuffer(move_str);
@ -140,7 +139,7 @@ void FVTerm::hideCursor (bool on)
{ {
// Hides or shows the input cursor on the terminal // Hides or shows the input cursor on the terminal
char* visibility_str = FTerm::cursorsVisibility (on); const char* visibility_str = FTerm::cursorsVisibility (on);
if ( visibility_str ) if ( visibility_str )
appendOutputBuffer(visibility_str); appendOutputBuffer(visibility_str);
@ -151,7 +150,7 @@ void FVTerm::hideCursor (bool on)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::setPrintCursor (int x, int y) void FVTerm::setPrintCursor (int x, int y)
{ {
term_area* win = getPrintArea(); auto win = getPrintArea();
if ( win ) if ( win )
{ {
@ -290,8 +289,7 @@ void FVTerm::delPreprocessingHandler (FVTerm* instance)
if ( ! print_area || print_area->preprocessing_call.empty() ) if ( ! print_area || print_area->preprocessing_call.empty() )
return; return;
FPreprocessing::iterator iter; auto iter = print_area->preprocessing_call.begin();
iter = print_area->preprocessing_call.begin();
while ( iter != print_area->preprocessing_call.end() ) while ( iter != print_area->preprocessing_call.end() )
{ {
@ -324,7 +322,7 @@ int FVTerm::printf (const FString format, ...)
int FVTerm::print (const FString& s) int FVTerm::print (const FString& s)
{ {
assert ( ! s.isNull() ); assert ( ! s.isNull() );
term_area* area = getPrintArea(); auto area = getPrintArea();
if ( ! area ) if ( ! area )
{ {
@ -341,13 +339,12 @@ int FVTerm::print (const FString& s)
int FVTerm::print (term_area* area, const FString& s) int FVTerm::print (term_area* area, const FString& s)
{ {
assert ( ! s.isNull() ); assert ( ! s.isNull() );
const wchar_t* p;
std::vector<charData> term_string;
if ( ! area ) if ( ! area )
return -1; return -1;
p = s.wc_str(); std::vector<charData> term_string;
const wchar_t* p = s.wc_str();
if ( p ) if ( p )
{ {
@ -376,7 +373,7 @@ int FVTerm::print (const std::vector<charData>& term_string)
if ( term_string.empty() ) if ( term_string.empty() )
return 0; return 0;
term_area* area = getPrintArea(); auto area = getPrintArea();
if ( ! area ) if ( ! area )
{ {
@ -393,8 +390,6 @@ int FVTerm::print (const std::vector<charData>& term_string)
int FVTerm::print (term_area* area, const std::vector<charData>& term_string) int FVTerm::print (term_area* area, const std::vector<charData>& term_string)
{ {
int len = 0; int len = 0;
std::vector<charData>::const_iterator iter;
iter = term_string.begin();
uInt tabstop = uInt(getTabstop()); uInt tabstop = uInt(getTabstop());
if ( ! area ) if ( ! area )
@ -403,11 +398,11 @@ int FVTerm::print (term_area* area, const std::vector<charData>& term_string)
if ( term_string.empty() ) if ( term_string.empty() )
return 0; return 0;
while ( iter != term_string.end() ) for (auto&& ch : term_string)
{ {
bool printable_character = false; bool printable_character = false;
switch ( iter->code ) switch ( ch.code )
{ {
case '\n': case '\n':
area->cursor_y++; area->cursor_y++;
@ -434,7 +429,7 @@ int FVTerm::print (term_area* area, const std::vector<charData>& term_string)
default: default:
{ {
charData nc = *iter; // next character auto nc = ch; // next character
print (area, nc); print (area, nc);
printable_character = true; printable_character = true;
} }
@ -444,7 +439,6 @@ int FVTerm::print (term_area* area, const std::vector<charData>& term_string)
break; // end of area reached break; // end of area reached
len++; len++;
++iter;
} }
return len; return len;
@ -453,7 +447,7 @@ int FVTerm::print (term_area* area, const std::vector<charData>& term_string)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FVTerm::print (wchar_t c) int FVTerm::print (wchar_t c)
{ {
term_area* area = getPrintArea(); auto area = getPrintArea();
if ( ! area ) if ( ! area )
{ {
@ -487,7 +481,7 @@ int FVTerm::print (term_area* area, wchar_t c)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FVTerm::print (charData& term_char) int FVTerm::print (charData& term_char)
{ {
term_area* area = getPrintArea(); auto area = getPrintArea();
if ( ! area ) if ( ! area )
{ {
@ -521,9 +515,8 @@ int FVTerm::print (term_area* area, charData& term_char)
&& ax < area->width + area->right_shadow && ax < area->width + area->right_shadow
&& ay < area->height + area->bottom_shadow ) && ay < area->height + area->bottom_shadow )
{ {
charData* ac; // area character
int line_len = area->width + area->right_shadow; int line_len = area->width + area->right_shadow;
ac = &area->text[ay * line_len + ax]; auto ac = &area->text[ay * line_len + ax]; // area character
if ( *ac != nc ) // compare with an overloaded operator if ( *ac != nc ) // compare with an overloaded operator
{ {
@ -816,9 +809,6 @@ void FVTerm::restoreVTerm (const FRect& box)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::restoreVTerm (int x, int y, int w, int h) void FVTerm::restoreVTerm (int x, int y, int w, int h)
{ {
charData* tc; // terminal character
charData sc; // shown character
x--; x--;
y--; y--;
@ -850,8 +840,8 @@ void FVTerm::restoreVTerm (int x, int y, int w, int h)
for (int tx = 0; tx < w; tx++) for (int tx = 0; tx < w; tx++)
{ {
int xpos = x + tx; int xpos = x + tx;
tc = &vterm->text[ypos * vterm->width + xpos]; auto tc = &vterm->text[ypos * vterm->width + xpos]; // terminal character
sc = generateCharacter(xpos, ypos); auto sc = generateCharacter(xpos, ypos); // shown character
std::memcpy (tc, &sc, sizeof(*tc)); std::memcpy (tc, &sc, sizeof(*tc));
} }
@ -878,27 +868,22 @@ FVTerm::covered_state FVTerm::isCovered ( int x, int y
{ {
// Determines the covered state for the given position // Determines the covered state for the given position
bool found;
covered_state is_covered;
FWidget* w;
if ( ! area ) if ( ! area )
return non_covered; return non_covered;
is_covered = non_covered; auto is_covered = non_covered;
found = bool(area == vdesktop); bool found = bool(area == vdesktop);
w = static_cast<FWidget*>(area->widget); auto w = static_cast<FWidget*>(area->widget);
if ( w->window_list && ! w->window_list->empty() ) if ( w->window_list && ! w->window_list->empty() )
{ {
FWidget::widgetList::const_iterator iter, end; auto iter = w->window_list->begin();
iter = w->window_list->begin(); auto end = w->window_list->end();
end = w->window_list->end();
for (; iter != end; ++iter) for (; iter != end; ++iter)
{ {
term_area* win = (*iter)->getVWin(); auto win = (*iter)->getVWin();
if ( ! win ) if ( ! win )
continue; continue;
@ -915,9 +900,8 @@ FVTerm::covered_state FVTerm::isCovered ( int x, int y
if ( found && geometry.contains(x, y) ) if ( found && geometry.contains(x, y) )
{ {
charData* tmp;
int line_len = win->width + win->right_shadow; int line_len = win->width + win->right_shadow;
tmp = &win->text[(y - win_y) * line_len + (x - win_x)]; auto tmp = &win->text[(y - win_y) * line_len + (x - win_x)];
if ( tmp->attr.bit.trans_shadow ) if ( tmp->attr.bit.trans_shadow )
{ {
@ -948,14 +932,14 @@ void FVTerm::updateOverlappedColor ( term_area* area
int& rsh = area->right_shadow; int& rsh = area->right_shadow;
int line_len = aw + rsh; int line_len = aw + rsh;
// Area character // Area character
charData* ac = &area->text[y * line_len + x]; auto ac = &area->text[y * line_len + x];
// Terminal character // Terminal character
charData* tc = &vterm->text[ty * vterm->width + tx]; auto tc = &vterm->text[ty * vterm->width + tx];
// New character // New character
charData nc; charData nc;
std::memcpy (&nc, ac, sizeof(nc)); std::memcpy (&nc, ac, sizeof(nc));
// Overlapped character // Overlapped character
charData oc = getOverlappedCharacter (tx + 1, ty + 1, area->widget); auto oc = getOverlappedCharacter (tx + 1, ty + 1, area->widget);
nc.fg_color = oc.fg_color; nc.fg_color = oc.fg_color;
nc.bg_color = oc.bg_color; nc.bg_color = oc.bg_color;
nc.attr.bit.reverse = false; nc.attr.bit.reverse = false;
@ -979,9 +963,9 @@ void FVTerm::updateOverlappedCharacter (term_area* area, int tx, int ty)
// Restore one character on vterm // Restore one character on vterm
// Terminal character // Terminal character
charData* tc = &vterm->text[ty * vterm->width + tx]; auto tc = &vterm->text[ty * vterm->width + tx];
// Overlapped character // Overlapped character
charData oc = getCoveredCharacter (tx + 1, ty + 1, area->widget); auto oc = getCoveredCharacter (tx + 1, ty + 1, area->widget);
oc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == oc); oc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == oc);
std::memcpy (tc, &oc, sizeof(*tc)); std::memcpy (tc, &oc, sizeof(*tc));
} }
@ -996,11 +980,11 @@ void FVTerm::updateShadedCharacter ( term_area* area
int& rsh = area->right_shadow; int& rsh = area->right_shadow;
int line_len = aw + rsh; int line_len = aw + rsh;
// Area character // Area character
charData* ac = &area->text[y * line_len + x]; auto ac = &area->text[y * line_len + x];
// Terminal character // Terminal character
charData* tc = &vterm->text[ty * vterm->width + tx]; auto tc = &vterm->text[ty * vterm->width + tx];
// Overlapped character // Overlapped character
charData oc = getCoveredCharacter (tx + 1, ty + 1, area->widget); auto oc = getCoveredCharacter (tx + 1, ty + 1, area->widget);
oc.fg_color = ac->fg_color; oc.fg_color = ac->fg_color;
oc.bg_color = ac->bg_color; oc.bg_color = ac->bg_color;
oc.attr.bit.reverse = false; oc.attr.bit.reverse = false;
@ -1028,14 +1012,14 @@ void FVTerm::updateInheritBackground ( term_area* area
int& rsh = area->right_shadow; int& rsh = area->right_shadow;
int line_len = aw + rsh; int line_len = aw + rsh;
// Area character // Area character
charData* ac = &area->text[y * line_len + x]; auto ac = &area->text[y * line_len + x];
// Terminal character // Terminal character
charData* tc = &vterm->text[ty * vterm->width + tx]; auto tc = &vterm->text[ty * vterm->width + tx];
// New character // New character
charData nc; charData nc;
std::memcpy (&nc, ac, sizeof(nc)); std::memcpy (&nc, ac, sizeof(nc));
// Covered character // Covered character
charData cc = getCoveredCharacter (tx + 1, ty + 1, area->widget); auto cc = getCoveredCharacter (tx + 1, ty + 1, area->widget);
nc.bg_color = cc.bg_color; nc.bg_color = cc.bg_color;
nc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == nc); nc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == nc);
std::memcpy (tc, &nc, sizeof(*tc)); std::memcpy (tc, &nc, sizeof(*tc));
@ -1051,9 +1035,9 @@ void FVTerm::updateCharacter ( term_area* area
int& rsh = area->right_shadow; int& rsh = area->right_shadow;
int line_len = aw + rsh; int line_len = aw + rsh;
// Area character // Area character
charData* ac = &area->text[y * line_len + x]; auto ac = &area->text[y * line_len + x];
// Terminal character // Terminal character
charData* tc = &vterm->text[ty * vterm->width + tx]; auto tc = &vterm->text[ty * vterm->width + tx];
std::memcpy (tc, ac, sizeof(*tc)); std::memcpy (tc, ac, sizeof(*tc));
if ( tc->attr.bit.printed && *tc == *ac ) if ( tc->attr.bit.printed && *tc == *ac )
@ -1070,10 +1054,10 @@ bool FVTerm::updateVTermCharacter ( term_area* area
int& rsh = area->right_shadow; int& rsh = area->right_shadow;
int line_len = aw + rsh; int line_len = aw + rsh;
// Area character // Area character
charData* ac = &area->text[y * line_len + x]; auto ac = &area->text[y * line_len + x];
// Get covered state // Get covered state
covered_state is_covered = isCovered(tx, ty, area); auto is_covered = isCovered(tx, ty, area);
if ( is_covered == fully_covered ) if ( is_covered == fully_covered )
return false; return false;
@ -1112,9 +1096,8 @@ void FVTerm::callPreprocessingHandler (term_area* area)
if ( ! area->preprocessing_call.empty() ) if ( ! area->preprocessing_call.empty() )
{ {
FPreprocessing::const_iterator iter, end; auto iter = area->preprocessing_call.begin();
iter = area->preprocessing_call.begin(); auto end = area->preprocessing_call.end();
end = area->preprocessing_call.end();
while ( iter != end ) while ( iter != end )
{ {
@ -1142,13 +1125,12 @@ void FVTerm::updateVTerm()
if ( ! widget->window_list || widget->window_list->empty() ) if ( ! widget->window_list || widget->window_list->empty() )
return; return;
FWidget::widgetList::const_iterator iter, end; auto iter = widget->window_list->begin();
iter = widget->window_list->begin(); auto end = widget->window_list->end();
end = widget->window_list->end();
for (; iter != end; ++iter) for (; iter != end; ++iter)
{ {
term_area* win = (*iter)->getVWin(); auto win = (*iter)->getVWin();
if ( ! win ) if ( ! win )
continue; continue;
@ -1163,9 +1145,8 @@ void FVTerm::updateVTerm()
} }
else if ( ! win->preprocessing_call.empty() ) else if ( ! win->preprocessing_call.empty() )
{ {
FPreprocessing::const_iterator iter2, end2; auto iter2 = win->preprocessing_call.begin();
iter2 = win->preprocessing_call.begin(); auto end2 = win->preprocessing_call.end();
end2 = win->preprocessing_call.end();
while ( iter2 != end2 ) while ( iter2 != end2 )
{ {
@ -1378,10 +1359,8 @@ void FVTerm::getArea (int ax, int ay, term_area* area)
for (int y = 0; y < y_end; y++) // line loop for (int y = 0; y < y_end; y++) // line loop
{ {
charData* tc; // terminal character auto tc = &vterm->text[(ay + y) * vterm->width + ax]; // terminal character
charData* ac; // area character auto ac = &area->text[y * area->width]; // area character
tc = &vterm->text[(ay + y) * vterm->width + ax];
ac = &area->text[y * area->width];
std::memcpy (ac, tc, sizeof(*ac) * unsigned(length)); std::memcpy (ac, tc, sizeof(*ac) * unsigned(length));
if ( short(area->changes[y].xmin) > 0 ) if ( short(area->changes[y].xmin) > 0 )
@ -1433,11 +1412,9 @@ void FVTerm::getArea (int x, int y, int w, int h, term_area* area)
for (int _y = 0; _y < y_end; _y++) // line loop for (int _y = 0; _y < y_end; _y++) // line loop
{ {
charData* tc; // terminal character
charData* ac; // area character
int line_len = area->width + area->right_shadow; int line_len = area->width + area->right_shadow;
tc = &vterm->text[(y + _y - 1) * vterm->width + x - 1]; auto tc = &vterm->text[(y + _y - 1) * vterm->width + x - 1]; // terminal character
ac = &area->text[(dy + _y) * line_len + dx]; auto ac = &area->text[(dy + _y) * line_len + dx]; // area character
std::memcpy (ac, tc, sizeof(*ac) * unsigned(length)); std::memcpy (ac, tc, sizeof(*ac) * unsigned(length));
if ( short(area->changes[dy + _y].xmin) > dx ) if ( short(area->changes[dy + _y].xmin) > dx )
@ -1513,8 +1490,8 @@ void FVTerm::putArea (int ax, int ay, term_area* area)
if ( area->changes[y].trans_count == 0 ) if ( area->changes[y].trans_count == 0 )
{ {
// Line has only covered characters // Line has only covered characters
ac = &area->text[y * line_len + ol]; auto ac = &area->text[y * line_len + ol];
tc = &vterm->text[(ay + y) * vterm->width + ax]; auto tc = &vterm->text[(ay + y) * vterm->width + ax];
putAreaLine (ac, tc, length); putAreaLine (ac, tc, length);
} }
else else
@ -1561,10 +1538,9 @@ void FVTerm::scrollAreaForward (term_area* area)
for (int y = 0; y < y_max; y++) for (int y = 0; y < y_max; y++)
{ {
charData* sc; // source character
int pos1 = y * total_width; int pos1 = y * total_width;
int pos2 = (y + 1) * total_width; int pos2 = (y + 1) * total_width;
sc = &area->text[pos2]; auto sc = &area->text[pos2]; // source character
dc = &area->text[pos1]; dc = &area->text[pos1];
std::memcpy (dc, sc, sizeof(*dc) * unsigned(length)); std::memcpy (dc, sc, sizeof(*dc) * unsigned(length));
area->changes[y].xmin = 0; area->changes[y].xmin = 0;
@ -1622,10 +1598,9 @@ void FVTerm::scrollAreaReverse (term_area* area)
for (int y = y_max; y > 0; y--) for (int y = y_max; y > 0; y--)
{ {
charData* sc; // source character
int pos1 = (y - 1) * total_width; int pos1 = (y - 1) * total_width;
int pos2 = y * total_width; int pos2 = y * total_width;
sc = &area->text[pos1]; auto sc = &area->text[pos1]; // source character
dc = &area->text[pos2]; dc = &area->text[pos2];
std::memcpy (dc, sc, sizeof(*dc) * unsigned(length)); std::memcpy (dc, sc, sizeof(*dc) * unsigned(length));
area->changes[y].xmin = 0; area->changes[y].xmin = 0;
@ -1666,7 +1641,6 @@ void FVTerm::clearArea (term_area* area, int fillchar)
// Clear the area with the current attributes // Clear the area with the current attributes
charData nc; // next character charData nc; // next character
uInt w;
// Current attributes with a space character // Current attributes with a space character
std::memcpy (&nc, &next_attribute, sizeof(nc)); std::memcpy (&nc, &next_attribute, sizeof(nc));
@ -1678,7 +1652,7 @@ void FVTerm::clearArea (term_area* area, int fillchar)
return; return;
} }
w = uInt(area->width + area->right_shadow); uInt w = uInt(area->width + area->right_shadow);
if ( area->right_shadow == 0 ) if ( area->right_shadow == 0 )
{ {
@ -1725,22 +1699,19 @@ FVTerm::charData FVTerm::generateCharacter (const FPoint& pos)
FVTerm::charData FVTerm::generateCharacter (int x, int y) FVTerm::charData FVTerm::generateCharacter (int x, int y)
{ {
// Generates characters for a given position considering all areas // Generates characters for a given position considering all areas
FWidget::widgetList::const_iterator iter, end;
charData* sc; // shown character
FWidget* widget;
widget = static_cast<FWidget*>(vterm->widget); auto widget = static_cast<FWidget*>(vterm->widget);
sc = &vdesktop->text[y * vdesktop->width + x]; auto sc = &vdesktop->text[y * vdesktop->width + x]; // shown character
if ( ! widget->window_list || widget->window_list->empty() ) if ( ! widget->window_list || widget->window_list->empty() )
return *sc; return *sc;
iter = widget->window_list->begin(); auto iter = widget->window_list->begin();
end = widget->window_list->end(); auto end = widget->window_list->end();
for (; iter != end; ++iter) for (; iter != end; ++iter)
{ {
term_area* win = (*iter)->getVWin(); auto win = (*iter)->getVWin();
if ( ! win || ! win->visible ) if ( ! win || ! win->visible )
continue; continue;
@ -1755,9 +1726,8 @@ FVTerm::charData FVTerm::generateCharacter (int x, int y)
// Window is visible and contains current character // Window is visible and contains current character
if ( geometry.contains(x, y) ) if ( geometry.contains(x, y) )
{ {
charData* tmp;
int line_len = win->width + win->right_shadow; int line_len = win->width + win->right_shadow;
tmp = &win->text[(y - win_y) * line_len + (x - win_x)]; auto tmp = &win->text[(y - win_y) * line_len + (x - win_x)];
if ( ! tmp->attr.bit.transparent ) // Current character not transparent if ( ! tmp->attr.bit.transparent ) // Current character not transparent
{ {
@ -1798,8 +1768,8 @@ FVTerm::charData FVTerm::generateCharacter (int x, int y)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FVTerm::charData FVTerm::getCharacter ( character_type type FVTerm::charData FVTerm::getCharacter ( character_type type
, const FPoint& pos , const FPoint& pos
, FVTerm* obj ) , FVTerm* obj )
{ {
// Gets the overlapped or the covered character for a given position // Gets the overlapped or the covered character for a given position
return getCharacter (type, pos.getX(), pos.getY(), obj); return getCharacter (type, pos.getX(), pos.getY(), obj);
@ -1807,20 +1777,16 @@ FVTerm::charData FVTerm::getCharacter ( character_type type
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FVTerm::charData FVTerm::getCharacter ( character_type char_type FVTerm::charData FVTerm::getCharacter ( character_type char_type
, int x , int x
, int y , int y
, FVTerm* obj ) , FVTerm* obj )
{ {
// Gets the overlapped or the covered character for the position (x,y) // Gets the overlapped or the covered character for the position (x,y)
int xx, yy, layer;
charData* cc; // covered character
FWidget* w;
FWidget::widgetList::const_iterator iter, end;
x--; x--;
y--; y--;
xx = x; int xx = x;
yy = y; int yy = y;
if ( xx < 0 ) if ( xx < 0 )
xx = 0; xx = 0;
@ -1834,16 +1800,16 @@ FVTerm::charData FVTerm::getCharacter ( character_type char_type
if ( yy >= vterm->height ) if ( yy >= vterm->height )
yy = vterm->height - 1; yy = vterm->height - 1;
cc = &vdesktop->text[yy * vdesktop->width + xx]; auto cc = &vdesktop->text[yy * vdesktop->width + xx]; // covered character
w = static_cast<FWidget*>(obj); auto w = static_cast<FWidget*>(obj);
if ( ! w->window_list || w->window_list->empty() ) if ( ! w->window_list || w->window_list->empty() )
return *cc; return *cc;
// Get the window layer of this object // Get the window layer of this object
layer = FWindow::getWindowLayer(w); int layer = FWindow::getWindowLayer(w);
iter = w->window_list->begin(); auto iter = w->window_list->begin();
end = w->window_list->end(); auto end = w->window_list->end();
for (; iter != end; ++iter) for (; iter != end; ++iter)
{ {
@ -1858,7 +1824,7 @@ FVTerm::charData FVTerm::getCharacter ( character_type char_type
if ( obj && *iter != obj && significant_char ) if ( obj && *iter != obj && significant_char )
{ {
term_area* win = (*iter)->getVWin(); auto win = (*iter)->getVWin();
if ( ! win || ! win->visible ) if ( ! win || ! win->visible )
continue; continue;
@ -1881,7 +1847,7 @@ FVTerm::charData FVTerm::getCharacter ( character_type char_type
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FVTerm::charData FVTerm::getCoveredCharacter ( const FPoint& pos FVTerm::charData FVTerm::getCoveredCharacter ( const FPoint& pos
, FVTerm* obj ) , FVTerm* obj )
{ {
// Gets the covered character for a given position // Gets the covered character for a given position
return getCharacter (covered_character, pos.getX(), pos.getY(), obj); return getCharacter (covered_character, pos.getX(), pos.getY(), obj);
@ -1889,8 +1855,8 @@ FVTerm::charData FVTerm::getCoveredCharacter ( const FPoint& pos
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FVTerm::charData FVTerm::getCoveredCharacter ( int x FVTerm::charData FVTerm::getCoveredCharacter ( int x
, int y , int y
, FVTerm* obj) , FVTerm* obj)
{ {
// Gets the covered character for the position (x,y) // Gets the covered character for the position (x,y)
return getCharacter (covered_character, x, y, obj); return getCharacter (covered_character, x, y, obj);
@ -1898,7 +1864,7 @@ FVTerm::charData FVTerm::getCoveredCharacter ( int x
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FVTerm::charData FVTerm::getOverlappedCharacter ( const FPoint& pos FVTerm::charData FVTerm::getOverlappedCharacter ( const FPoint& pos
, FVTerm* obj ) , FVTerm* obj )
{ {
// Gets the overlapped character for a given position // Gets the overlapped character for a given position
return getCharacter (overlapped_character, pos.getX(), pos.getY(), obj); return getCharacter (overlapped_character, pos.getX(), pos.getY(), obj);
@ -1906,8 +1872,8 @@ FVTerm::charData FVTerm::getOverlappedCharacter ( const FPoint& pos
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FVTerm::charData FVTerm::getOverlappedCharacter ( int x FVTerm::charData FVTerm::getOverlappedCharacter ( int x
, int y , int y
, FVTerm* obj) , FVTerm* obj)
{ {
// Gets the overlapped character for the position (x,y) // Gets the overlapped character for the position (x,y)
return getCharacter (overlapped_character, x, y, obj); return getCharacter (overlapped_character, x, y, obj);
@ -2135,11 +2101,10 @@ void FVTerm::putAreaCharacter ( int x, int y, FVTerm* obj
void FVTerm::getAreaCharacter ( int x, int y, term_area* area void FVTerm::getAreaCharacter ( int x, int y, term_area* area
, charData*& cc ) , charData*& cc )
{ {
charData* tmp;
int area_x = area->offset_left; int area_x = area->offset_left;
int area_y = area->offset_top; int area_y = area->offset_top;
int line_len = area->width + area->right_shadow; int line_len = area->width + area->right_shadow;
tmp = &area->text[(y - area_y) * line_len + (x - area_x)]; auto tmp = &area->text[(y - area_y) * line_len + (x - area_x)];
// Current character not transparent // Current character not transparent
if ( ! tmp->attr.bit.transparent ) if ( ! tmp->attr.bit.transparent )
@ -2171,11 +2136,11 @@ bool FVTerm::clearTerm (int fillchar)
{ {
// Clear the real terminal and put cursor at home // Clear the real terminal and put cursor at home
char*& cl = TCAP(fc::t_clear_screen); auto& cl = TCAP(fc::t_clear_screen);
char*& cd = TCAP(fc::t_clr_eos); auto& cd = TCAP(fc::t_clr_eos);
char*& cb = TCAP(fc::t_clr_eol); auto& cb = TCAP(fc::t_clr_eol);
bool ut = FTermcap::background_color_erase; bool ut = FTermcap::background_color_erase;
charData* next = &next_attribute; auto next = &next_attribute;
bool normal = FTerm::isNormal(next); bool normal = FTerm::isNormal(next);
appendAttributes(next); appendAttributes(next);
@ -2275,8 +2240,8 @@ bool FVTerm::canClearToEOL (uInt xmin, uInt y)
// => clear to end of line // => clear to end of line
term_area*& vt = vterm; term_area*& vt = vterm;
char*& ce = TCAP(fc::t_clr_eol); auto& ce = TCAP(fc::t_clr_eol);
charData* min_char = &vt->text[y * uInt(vt->width) + xmin]; auto min_char = &vt->text[y * uInt(vt->width) + xmin];
if ( ce && min_char->code == ' ' ) if ( ce && min_char->code == ' ' )
{ {
@ -2286,7 +2251,7 @@ bool FVTerm::canClearToEOL (uInt xmin, uInt y)
for (uInt x = xmin + 1; x < uInt(vt->width); x++) for (uInt x = xmin + 1; x < uInt(vt->width); x++)
{ {
charData* ch = &vt->text[y * uInt(vt->width) + x]; auto ch = &vt->text[y * uInt(vt->width) + x];
if ( *min_char == *ch ) if ( *min_char == *ch )
beginning_whitespace++; beginning_whitespace++;
@ -2310,8 +2275,8 @@ bool FVTerm::canClearLeadingWS (uInt& xmin, uInt y)
// => clear from xmin to beginning of line // => clear from xmin to beginning of line
term_area*& vt = vterm; term_area*& vt = vterm;
char*& cb = TCAP(fc::t_clr_bol); auto& cb = TCAP(fc::t_clr_bol);
charData* first_char = &vt->text[y * uInt(vt->width)]; auto first_char = &vt->text[y * uInt(vt->width)];
if ( cb && first_char->code == ' ' ) if ( cb && first_char->code == ' ' )
{ {
@ -2321,7 +2286,7 @@ bool FVTerm::canClearLeadingWS (uInt& xmin, uInt y)
for (uInt x = 1; x < uInt(vt->width); x++) for (uInt x = 1; x < uInt(vt->width); x++)
{ {
charData* ch = &vt->text[y * uInt(vt->width) + x]; auto ch = &vt->text[y * uInt(vt->width) + x];
if ( *first_char == *ch ) if ( *first_char == *ch )
leading_whitespace++; leading_whitespace++;
@ -2348,8 +2313,8 @@ bool FVTerm::canClearTrailingWS (uInt& xmax, uInt y)
// => clear from xmax to end of line // => clear from xmax to end of line
term_area*& vt = vterm; term_area*& vt = vterm;
char*& ce = TCAP(fc::t_clr_eol); auto& ce = TCAP(fc::t_clr_eol);
charData* last_char = &vt->text[(y + 1) * uInt(vt->width) - 1]; auto last_char = &vt->text[(y + 1) * uInt(vt->width) - 1];
if ( ce && last_char->code == ' ' ) if ( ce && last_char->code == ' ' )
{ {
@ -2359,7 +2324,7 @@ bool FVTerm::canClearTrailingWS (uInt& xmax, uInt y)
for (uInt x = uInt(vt->width) - 1; x > 0 ; x--) for (uInt x = uInt(vt->width) - 1; x > 0 ; x--)
{ {
charData* ch = &vt->text[y * uInt(vt->width) + x]; auto ch = &vt->text[y * uInt(vt->width) + x];
if ( *last_char == *ch ) if ( *last_char == *ch )
trailing_whitespace++; trailing_whitespace++;
@ -2385,7 +2350,7 @@ bool FVTerm::skipUnchangedCharacters(uInt& x, uInt xmax, uInt y)
// Skip characters without changes if it is faster than redrawing // Skip characters without changes if it is faster than redrawing
term_area*& vt = vterm; term_area*& vt = vterm;
charData* print_char = &vt->text[y * uInt(vt->width) + x]; auto print_char = &vt->text[y * uInt(vt->width) + x];
print_char->attr.bit.printed = true; print_char->attr.bit.printed = true;
if ( print_char->attr.bit.no_changes ) if ( print_char->attr.bit.no_changes )
@ -2394,7 +2359,7 @@ bool FVTerm::skipUnchangedCharacters(uInt& x, uInt xmax, uInt y)
for (uInt i = x + 1; i <= xmax; i++) for (uInt i = x + 1; i <= xmax; i++)
{ {
charData* ch = &vt->text[y * uInt(vt->width) + i]; auto ch = &vt->text[y * uInt(vt->width) + i];
if ( ch->attr.bit.no_changes ) if ( ch->attr.bit.no_changes )
count++; count++;
@ -2419,11 +2384,10 @@ void FVTerm::printRange ( uInt xmin, uInt xmax, uInt y
{ {
for (uInt x = xmin; x <= xmax; x++) for (uInt x = xmin; x <= xmax; x++)
{ {
charData* print_char;
term_area*& vt = vterm; term_area*& vt = vterm;
char*& ec = TCAP(fc::t_erase_chars); auto& ec = TCAP(fc::t_erase_chars);
char*& rp = TCAP(fc::t_repeat_char); auto& rp = TCAP(fc::t_repeat_char);
print_char = &vt->text[y * uInt(vt->width) + x]; auto print_char = &vt->text[y * uInt(vt->width) + x];
print_char->attr.bit.printed = true; print_char->attr.bit.printed = true;
// skip character with no changes // skip character with no changes
@ -2458,8 +2422,8 @@ FVTerm::exit_state FVTerm::eraseCharacters ( uInt& x, uInt xmax, uInt y
// Erase a number of characters to draw simple whitespaces // Erase a number of characters to draw simple whitespaces
term_area*& vt = vterm; term_area*& vt = vterm;
char*& ec = TCAP(fc::t_erase_chars); auto& ec = TCAP(fc::t_erase_chars);
charData* print_char = &vt->text[y * uInt(vt->width) + x]; auto print_char = &vt->text[y * uInt(vt->width) + x];
if ( ! ec || print_char->code != ' ' ) if ( ! ec || print_char->code != ' ' )
return not_used; return not_used;
@ -2469,7 +2433,7 @@ FVTerm::exit_state FVTerm::eraseCharacters ( uInt& x, uInt xmax, uInt y
for (uInt i = x + 1; i <= xmax; i++) for (uInt i = x + 1; i <= xmax; i++)
{ {
charData* ch = &vt->text[y * uInt(vt->width) + i]; auto ch = &vt->text[y * uInt(vt->width) + i];
if ( *print_char == *ch ) if ( *print_char == *ch )
whitespace++; whitespace++;
@ -2520,8 +2484,8 @@ FVTerm::exit_state FVTerm::repeatCharacter (uInt& x, uInt xmax, uInt y)
// Repeat one character n-fold // Repeat one character n-fold
term_area*& vt = vterm; term_area*& vt = vterm;
char*& rp = TCAP(fc::t_repeat_char); auto& rp = TCAP(fc::t_repeat_char);
charData* print_char = &vt->text[y * uInt(vt->width) + x]; auto print_char = &vt->text[y * uInt(vt->width) + x];
if ( ! rp ) if ( ! rp )
return not_used; return not_used;
@ -2530,7 +2494,7 @@ FVTerm::exit_state FVTerm::repeatCharacter (uInt& x, uInt xmax, uInt y)
for (uInt i = x + 1; i <= xmax; i++) for (uInt i = x + 1; i <= xmax; i++)
{ {
charData* ch = &vt->text[y * uInt(vt->width) + i]; auto ch = &vt->text[y * uInt(vt->width) + i];
if ( *print_char == *ch ) if ( *print_char == *ch )
repetitions++; repetitions++;
@ -2637,10 +2601,10 @@ void FVTerm::updateTerminalLine (uInt y)
{ {
bool draw_leading_ws = false; bool draw_leading_ws = false;
bool draw_trailing_ws = false; bool draw_trailing_ws = false;
char*& ce = TCAP(fc::t_clr_eol); auto& ce = TCAP(fc::t_clr_eol);
charData* first_char = &vt->text[y * uInt(vt->width)]; auto first_char = &vt->text[y * uInt(vt->width)];
charData* last_char = &vt->text[(y + 1) * uInt(vt->width) - 1]; auto last_char = &vt->text[(y + 1) * uInt(vt->width) - 1];
charData* min_char = &vt->text[y * uInt(vt->width) + xmin]; auto min_char = &vt->text[y * uInt(vt->width) + xmin];
// Clear rest of line // Clear rest of line
bool is_eol_clean = canClearToEOL (xmin, y); bool is_eol_clean = canClearToEOL (xmin, y);
@ -2666,7 +2630,7 @@ void FVTerm::updateTerminalLine (uInt y)
{ {
if ( draw_leading_ws ) if ( draw_leading_ws )
{ {
char*& cb = TCAP(fc::t_clr_bol); auto& cb = TCAP(fc::t_clr_bol);
appendAttributes (first_char); appendAttributes (first_char);
appendOutputBuffer (cb); appendOutputBuffer (cb);
markAsPrinted (0, xmin, y); markAsPrinted (0, xmin, y);
@ -2852,11 +2816,10 @@ inline void FVTerm::appendChar (charData*& next_char)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FVTerm::appendAttributes (charData*& next_attr) inline void FVTerm::appendAttributes (charData*& next_attr)
{ {
char* attr_str; auto term_attr = &term_attribute;
charData* term_attr = &term_attribute;
// generate attribute string for the next character // generate attribute string for the next character
attr_str = FTerm::changeAttribute (term_attr, next_attr); char* attr_str = FTerm::changeAttribute (term_attr, next_attr);
if ( attr_str ) if ( attr_str )
appendOutputBuffer (attr_str); appendOutputBuffer (attr_str);
@ -2865,8 +2828,8 @@ inline void FVTerm::appendAttributes (charData*& next_attr)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FVTerm::appendLowerRight (charData*& screen_char) int FVTerm::appendLowerRight (charData*& screen_char)
{ {
char* SA = TCAP(fc::t_enter_am_mode); auto& SA = TCAP(fc::t_enter_am_mode);
char* RA = TCAP(fc::t_exit_am_mode); auto& RA = TCAP(fc::t_exit_am_mode);
if ( ! FTermcap::automatic_right_margin ) if ( ! FTermcap::automatic_right_margin )
{ {
@ -2881,11 +2844,11 @@ int FVTerm::appendLowerRight (charData*& screen_char)
else else
{ {
int x, y; int x, y;
char* IC = TCAP(fc::t_parm_ich); auto& IC = TCAP(fc::t_parm_ich);
char* im = TCAP(fc::t_enter_insert_mode); auto& im = TCAP(fc::t_enter_insert_mode);
char* ei = TCAP(fc::t_exit_insert_mode); auto& ei = TCAP(fc::t_exit_insert_mode);
char* ip = TCAP(fc::t_insert_padding); auto& ip = TCAP(fc::t_insert_padding);
char* ic = TCAP(fc::t_insert_character); auto& ic = TCAP(fc::t_insert_character);
x = int(getColumnNumber()) - 2; x = int(getColumnNumber()) - 2;
y = int(getLineNumber()) - 1; y = int(getLineNumber()) - 1;

View File

@ -104,7 +104,7 @@ FWidget::~FWidget() // destructor
// unset the local window widget focus // unset the local window widget focus
if ( flags.focus ) if ( flags.focus )
{ {
if ( FWindow* window = FWindow::getWindowWidget(this) ) if ( auto window = FWindow::getWindowWidget(this) )
window->setWindowFocusWidget(0); window->setWindowFocusWidget(0);
} }
@ -129,8 +129,8 @@ FWidget::~FWidget() // destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FWidget* FWidget::getRootWidget() const FWidget* FWidget::getRootWidget() const
{ {
FWidget* obj = const_cast<FWidget*>(this); auto obj = const_cast<FWidget*>(this);
FWidget* p_obj = getParentWidget(); auto p_obj = getParentWidget();
while ( ! obj->isRootWidget() && p_obj ) while ( ! obj->isRootWidget() && p_obj )
{ {
@ -144,7 +144,7 @@ FWidget* FWidget::getRootWidget() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FWidget* FWidget::getParentWidget() const FWidget* FWidget::getParentWidget() const
{ {
FObject* p_obj = getParent(); auto p_obj = getParent();
if ( p_obj && p_obj->isWidget() ) if ( p_obj && p_obj->isWidget() )
return static_cast<FWidget*>(p_obj); return static_cast<FWidget*>(p_obj);
@ -158,15 +158,14 @@ FWidget* FWidget::getFirstFocusableWidget (FObjectList list)
if ( list.empty() ) if ( list.empty() )
return 0; return 0;
constFObjectIterator iter, last; auto iter = list.begin();
iter = list.begin(); auto last = list.end();
last = list.end();
while ( iter != last ) while ( iter != last )
{ {
if ( (*iter)->isWidget() ) if ( (*iter)->isWidget() )
{ {
FWidget* child = static_cast<FWidget*>(*iter); auto child = static_cast<FWidget*>(*iter);
if ( child->isEnabled() && child->acceptFocus() ) if ( child->isEnabled() && child->acceptFocus() )
return child; return child;
@ -184,9 +183,8 @@ FWidget* FWidget::getLastFocusableWidget (FObjectList list)
if ( list.empty() ) if ( list.empty() )
return 0; return 0;
constFObjectIterator iter, first; auto first = list.begin();
first = list.begin(); auto iter = list.end();
iter = list.end();
do do
{ {
@ -195,7 +193,7 @@ FWidget* FWidget::getLastFocusableWidget (FObjectList list)
if ( ! (*iter)->isWidget() ) if ( ! (*iter)->isWidget() )
continue; continue;
FWidget* child = static_cast<FWidget*>(*iter); auto child = static_cast<FWidget*>(*iter);
if ( child->isEnabled() && child->acceptFocus() ) if ( child->isEnabled() && child->acceptFocus() )
return child; return child;
@ -208,11 +206,9 @@ FWidget* FWidget::getLastFocusableWidget (FObjectList list)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FPoint FWidget::getPrintPos() FPoint FWidget::getPrintPos()
{ {
const FPoint cur = getPrintCursor(); const auto cur = getPrintCursor();
int cx = cur.getX(); return FPoint ( cur.getX() - offset.getX1() - getX() + 1
int cy = cur.getY(); , cur.getY() - offset.getY1() - getY() + 1 );
return FPoint ( cx - offset.getX1() - getX() + 1
, cy - offset.getY1() - getY() + 1 );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -245,7 +241,7 @@ std::vector<bool>& FWidget::doubleFlatLine_ref (fc::sides side)
void FWidget::setMainWidget (FWidget* obj) void FWidget::setMainWidget (FWidget* obj)
{ {
main_widget = obj; main_widget = obj;
FWidget* app_object = FApplication::getApplicationObject(); auto app_object = FApplication::getApplicationObject();
if ( obj && app_object && ! getFocusWidget() ) if ( obj && app_object && ! getFocusWidget() )
app_object->focusFirstChild(); app_object->focusFirstChild();
@ -260,16 +256,13 @@ bool FWidget::setEnable (bool on)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FWidget::setFocus (bool on) bool FWidget::setFocus (bool on)
{ {
FWindow* window;
FWidget* last_focus;
if ( ! isEnabled() ) if ( ! isEnabled() )
return false; return false;
if ( flags.focus == on ) if ( flags.focus == on )
return true; return true;
last_focus = FWidget::getFocusWidget(); auto last_focus = FWidget::getFocusWidget();
// set widget focus // set widget focus
if ( on && ! flags.focus ) if ( on && ! flags.focus )
@ -286,7 +279,7 @@ bool FWidget::setFocus (bool on)
} }
} }
window = FWindow::getWindowWidget(this); auto window = FWindow::getWindowWidget(this);
// set window focus // set window focus
if ( on && window ) if ( on && window )
@ -457,7 +450,7 @@ void FWidget::setTopPadding (int top, bool adjust)
{ {
if ( isRootWidget() ) if ( isRootWidget() )
{ {
FWidget* r = rootObject; auto r = rootObject;
r->client_offset.setY1 (r->padding.top); r->client_offset.setY1 (r->padding.top);
adjustSizeGlobal(); adjustSizeGlobal();
} }
@ -478,7 +471,7 @@ void FWidget::setLeftPadding (int left, bool adjust)
{ {
if ( isRootWidget() ) if ( isRootWidget() )
{ {
FWidget* r = rootObject; auto r = rootObject;
r->client_offset.setX1 (r->padding.left); r->client_offset.setX1 (r->padding.left);
adjustSizeGlobal(); adjustSizeGlobal();
} }
@ -499,7 +492,7 @@ void FWidget::setBottomPadding (int bottom, bool adjust)
{ {
if ( isRootWidget() ) if ( isRootWidget() )
{ {
FWidget* r = rootObject; auto r = rootObject;
r->client_offset.setY2 (int(r->getHeight()) - 1 - r->padding.bottom); r->client_offset.setY2 (int(r->getHeight()) - 1 - r->padding.bottom);
adjustSizeGlobal(); adjustSizeGlobal();
} }
@ -520,7 +513,7 @@ void FWidget::setRightPadding (int right, bool adjust)
{ {
if ( isRootWidget() ) if ( isRootWidget() )
{ {
FWidget* r = rootObject; auto r = rootObject;
r->client_offset.setX2 (int(r->getWidth()) - 1 - r->padding.right); r->client_offset.setX2 (int(r->getWidth()) - 1 - r->padding.right);
adjustSizeGlobal(); adjustSizeGlobal();
} }
@ -532,7 +525,7 @@ void FWidget::setRightPadding (int right, bool adjust)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::setParentOffset() void FWidget::setParentOffset()
{ {
FWidget* p = getParentWidget(); auto p = getParentWidget();
if ( p ) if ( p )
offset = p->client_offset; offset = p->client_offset;
@ -541,7 +534,7 @@ void FWidget::setParentOffset()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::setTermOffset() void FWidget::setTermOffset()
{ {
FWidget* r = getRootWidget(); auto r = getRootWidget();
int w = int(r->getWidth()); int w = int(r->getWidth());
int h = int(r->getHeight()); int h = int(r->getHeight());
offset.setCoordinates (0, 0, w - 1, h - 1); offset.setCoordinates (0, 0, w - 1, h - 1);
@ -550,7 +543,7 @@ void FWidget::setTermOffset()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::setTermOffsetWithPadding() void FWidget::setTermOffsetWithPadding()
{ {
FWidget* r = getRootWidget(); auto r = getRootWidget();
offset.setCoordinates ( r->getLeftPadding() offset.setCoordinates ( r->getLeftPadding()
, r->getTopPadding() , r->getTopPadding()
, int(r->getWidth()) - 1 - r->getRightPadding() , int(r->getWidth()) - 1 - r->getRightPadding()
@ -633,7 +626,7 @@ bool FWidget::setCursorPos (int x, int y)
if ( ! FWindow::getWindowWidget(this) ) if ( ! FWindow::getWindowWidget(this) )
return false; return false;
term_area* area = getPrintArea(); auto area = getPrintArea();
if ( area->widget ) if ( area->widget )
{ {
@ -752,9 +745,8 @@ FWidget* FWidget::childWidgetAt (FWidget* p, int x, int y)
{ {
if ( p && p->hasChildren() ) if ( p && p->hasChildren() )
{ {
constFObjectIterator iter, last; auto iter = p->begin();
iter = p->begin(); auto last = p->end();
last = p->end();
while ( iter != last ) while ( iter != last )
{ {
@ -764,14 +756,14 @@ FWidget* FWidget::childWidgetAt (FWidget* p, int x, int y)
continue; continue;
} }
FWidget* widget = static_cast<FWidget*>(*iter); auto widget = static_cast<FWidget*>(*iter);
if ( widget->isEnabled() if ( widget->isEnabled()
&& widget->isVisible() && widget->isVisible()
&& ! widget->isWindowWidget() && ! widget->isWindowWidget()
&& widget->getTermGeometry().contains(x, y) ) && widget->getTermGeometry().contains(x, y) )
{ {
FWidget* child = childWidgetAt(widget, x, y); auto child = childWidgetAt(widget, x, y);
return ( child != 0 ) ? child : widget; return ( child != 0 ) ? child : widget;
} }
@ -785,20 +777,18 @@ FWidget* FWidget::childWidgetAt (FWidget* p, int x, int y)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FWidget::numOfFocusableChildren() int FWidget::numOfFocusableChildren()
{ {
constFObjectIterator iter, last;
if ( ! hasChildren() ) if ( ! hasChildren() )
return 0; return 0;
int num = 0; int num = 0;
iter = FObject::begin(); auto iter = FObject::begin();
last = FObject::end(); auto last = FObject::end();
while ( iter != last ) while ( iter != last )
{ {
if ( (*iter)->isWidget() ) if ( (*iter)->isWidget() )
{ {
FWidget* widget = static_cast<FWidget*>(*iter); auto widget = static_cast<FWidget*>(*iter);
if ( widget->acceptFocus() ) if ( widget->acceptFocus() )
num++; num++;
@ -859,12 +849,10 @@ void FWidget::delCallback (FCallback cb_handler)
{ {
// delete a cb_handler function pointer // delete a cb_handler function pointer
CallbackObjects::iterator iter;
if ( callback_objects.empty() ) if ( callback_objects.empty() )
return; return;
iter = callback_objects.begin(); auto iter = callback_objects.begin();
while ( iter != callback_objects.end() ) while ( iter != callback_objects.end() )
{ {
@ -880,12 +868,10 @@ void FWidget::delCallback (FWidget* cb_instance)
{ {
// delete all member function pointer from cb_instance // delete all member function pointer from cb_instance
FWidget::MemberCallbackObjects::iterator iter;
if ( member_callback_objects.empty() ) if ( member_callback_objects.empty() )
return; return;
iter = member_callback_objects.begin(); auto iter = member_callback_objects.begin();
while ( iter != member_callback_objects.end() ) while ( iter != member_callback_objects.end() )
{ {
@ -909,19 +895,19 @@ void FWidget::delCallbacks()
void FWidget::emitCallback (const FString& emit_signal) void FWidget::emitCallback (const FString& emit_signal)
{ {
// member function pointer // member function pointer
if ( ! member_callback_objects.empty() ) if ( ! member_callback_objects.empty() )
{ {
MemberCallbackObjects::const_iterator m_iter, m_end; auto m_iter = member_callback_objects.begin();
m_iter = member_callback_objects.begin(); auto m_end = member_callback_objects.end();
m_end = member_callback_objects.end();
while ( m_iter != m_end ) while ( m_iter != m_end )
{ {
if ( m_iter->cb_signal == emit_signal ) if ( m_iter->cb_signal == emit_signal )
{ {
FMemberCallback callback = m_iter->cb_handler; auto callback = m_iter->cb_handler;
// call the member function pointer // call the member function pointer
(m_iter->cb_instance->*callback)(this, m_iter->data); (m_iter->cb_instance->*callback) (this, m_iter->data);
} }
++m_iter; ++m_iter;
@ -931,17 +917,16 @@ void FWidget::emitCallback (const FString& emit_signal)
// function pointer // function pointer
if ( ! callback_objects.empty() ) if ( ! callback_objects.empty() )
{ {
CallbackObjects::const_iterator iter, last; auto iter = callback_objects.begin();
iter = callback_objects.begin(); auto last = callback_objects.end();
last = callback_objects.end();
while ( iter != last ) while ( iter != last )
{ {
if ( iter->cb_signal == emit_signal ) if ( iter->cb_signal == emit_signal )
{ {
FCallback callback = iter->cb_handler; auto callback = iter->cb_handler;
// call the function pointer // call the function pointer
callback(this, iter->data); callback (this, iter->data);
} }
++iter; ++iter;
@ -952,7 +937,7 @@ void FWidget::emitCallback (const FString& emit_signal)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::addAccelerator (FKey key, FWidget* obj) void FWidget::addAccelerator (FKey key, FWidget* obj)
{ {
FWidget* widget = FWindow::getWindowWidget(obj); auto widget = static_cast<FWidget*>(FWindow::getWindowWidget(obj));
accelerator accel = { key, obj }; accelerator accel = { key, obj };
if ( ! widget || widget == statusbar || widget == menubar ) if ( ! widget || widget == statusbar || widget == menubar )
@ -965,7 +950,7 @@ void FWidget::addAccelerator (FKey key, FWidget* obj)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::delAccelerator (FWidget* obj) void FWidget::delAccelerator (FWidget* obj)
{ {
FWidget* widget = FWindow::getWindowWidget(this); auto widget = static_cast<FWidget*>(FWindow::getWindowWidget(this));
if ( ! widget || widget == statusbar || widget == menubar ) if ( ! widget || widget == statusbar || widget == menubar )
widget = getRootWidget(); widget = getRootWidget();
@ -974,8 +959,7 @@ void FWidget::delAccelerator (FWidget* obj)
&& widget->accelerator_list && widget->accelerator_list
&& ! widget->accelerator_list->empty() ) && ! widget->accelerator_list->empty() )
{ {
FWidget::Accelerators::iterator iter; auto iter = widget->accelerator_list->begin();
iter = widget->accelerator_list->begin();
while ( iter != widget->accelerator_list->end() ) while ( iter != widget->accelerator_list->end() )
{ {
@ -1056,7 +1040,7 @@ void FWidget::show()
initScreenSettings(); initScreenSettings();
// draw the vdesktop // draw the vdesktop
FWidget* r = getRootWidget(); auto r = getRootWidget();
setColor(r->getForegroundColor(), r->getBackgroundColor()); setColor(r->getForegroundColor(), r->getBackgroundColor());
clearArea (vdesktop); clearArea (vdesktop);
init_desktop = true; init_desktop = true;
@ -1073,15 +1057,14 @@ void FWidget::show()
if ( hasChildren() ) if ( hasChildren() )
{ {
constFObjectIterator iter, last; auto iter = FObject::begin();
iter = FObject::begin(); auto last = FObject::end();
last = FObject::end();
while ( iter != last ) while ( iter != last )
{ {
if ( (*iter)->isWidget() ) if ( (*iter)->isWidget() )
{ {
FWidget* widget = static_cast<FWidget*>(*iter); auto widget = static_cast<FWidget*>(*iter);
widget->show(); widget->show();
} }
@ -1127,13 +1110,11 @@ void FWidget::hide()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FWidget::focusFirstChild() bool FWidget::focusFirstChild()
{ {
constFObjectIterator iter, last;
if ( ! hasChildren() ) if ( ! hasChildren() )
return false; return false;
iter = FObject::begin(); auto iter = FObject::begin();
last = FObject::end(); auto last = FObject::end();
while ( iter != last ) while ( iter != last )
{ {
@ -1143,7 +1124,7 @@ bool FWidget::focusFirstChild()
continue; continue;
} }
FWidget* widget = static_cast<FWidget*>(*iter); auto widget = static_cast<FWidget*>(*iter);
if ( widget->isEnabled() if ( widget->isEnabled()
&& widget->acceptFocus() && widget->acceptFocus()
@ -1171,13 +1152,11 @@ bool FWidget::focusFirstChild()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FWidget::focusLastChild() bool FWidget::focusLastChild()
{ {
constFObjectIterator iter, first;
if ( ! hasChildren() ) if ( ! hasChildren() )
return false; return false;
iter = FObject::end(); auto iter = FObject::end();
first = FObject::begin(); auto first = FObject::begin();
do do
{ {
@ -1186,7 +1165,7 @@ bool FWidget::focusLastChild()
if ( ! (*iter)->isWidget() ) if ( ! (*iter)->isWidget() )
continue; continue;
FWidget* widget = static_cast<FWidget*>(*iter); auto widget = static_cast<FWidget*>(*iter);
if ( widget->isEnabled() if ( widget->isEnabled()
&& widget->acceptFocus() && widget->acceptFocus()
@ -1211,7 +1190,7 @@ bool FWidget::focusLastChild()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::detectTermSize() void FWidget::detectTermSize()
{ {
FWidget* r = rootObject; auto r = rootObject;
FTerm::detectTermSize(); FTerm::detectTermSize();
r->adjust_wsize.setRect (1, 1, getDesktopWidth(), getDesktopHeight()); r->adjust_wsize.setRect (1, 1, getDesktopWidth(), getDesktopHeight());
r->offset.setRect (0, 0, getDesktopWidth(), getDesktopHeight()); r->offset.setRect (0, 0, getDesktopWidth(), getDesktopHeight());
@ -1275,14 +1254,14 @@ void FWidget::clearShadow()
setColor (wc.shadow_fg, wc.shadow_bg); setColor (wc.shadow_fg, wc.shadow_bg);
setInheritBackground(); // current background color will be ignored setInheritBackground(); // current background color will be ignored
} }
else if ( FWidget* p = getParentWidget() ) else if ( auto p = getParentWidget() )
setColor (wc.shadow_fg, p->getBackgroundColor()); setColor (wc.shadow_fg, p->getBackgroundColor());
if ( w <= offset.getX2() ) if ( w <= offset.getX2() )
{ {
for (int i = 1; i <= int(getHeight()); i++) for (std::size_t y = 1; y <= getHeight(); y++)
{ {
setPrintPos (w + 1, i); setPrintPos (w + 1, int(y));
print (' '); // clear █ print (' '); // clear █
} }
} }
@ -1310,14 +1289,14 @@ void FWidget::drawFlatBorder()
, y1 = 0 , y1 = 0
, y2 = int(getHeight()) + 1; , y2 = int(getHeight()) + 1;
if ( FWidget* p = getParentWidget() ) if ( auto p = getParentWidget() )
setColor (wc.dialog_fg, p->getBackgroundColor()); setColor (wc.dialog_fg, p->getBackgroundColor());
else else
setColor (wc.dialog_fg, wc.dialog_bg); setColor (wc.dialog_fg, wc.dialog_bg);
for (int y = 0; y < int(getHeight()); y++) for (std::size_t y = 0; y < getHeight(); y++)
{ {
setPrintPos (x1 - 1, y1 + y + 1); setPrintPos (x1 - 1, y1 + int(y) + 1);
if ( double_flatline_mask.left[uLong(y)] ) if ( double_flatline_mask.left[uLong(y)] )
// left+right line (on left side) // left+right line (on left side)
@ -1329,9 +1308,9 @@ void FWidget::drawFlatBorder()
setPrintPos (x2, y1 + 1); setPrintPos (x2, y1 + 1);
for (int y = 0; y < int(getHeight()); y++) for (std::size_t y = 0; y < getHeight(); y++)
{ {
if ( double_flatline_mask.right[uLong(y)] ) if ( double_flatline_mask.right[y] )
// left+right line (on right side) // left+right line (on right side)
print (fc::NF_rev_border_line_right_and_left); print (fc::NF_rev_border_line_right_and_left);
else else
@ -1343,9 +1322,9 @@ void FWidget::drawFlatBorder()
setPrintPos (x1, y1); setPrintPos (x1, y1);
for (int x = 0; x < int(getWidth()); x++) for (std::size_t x = 0; x < getWidth(); x++)
{ {
if ( double_flatline_mask.top[uLong(x)] ) if ( double_flatline_mask.top[x] )
// top+bottom line (at top) // top+bottom line (at top)
print (fc::NF_border_line_up_and_down); print (fc::NF_border_line_up_and_down);
else else
@ -1355,9 +1334,9 @@ void FWidget::drawFlatBorder()
setPrintPos (x1, y2); setPrintPos (x1, y2);
for (int x = 0; x < int(getWidth()); x++) for (std::size_t x = 0; x < getWidth(); x++)
{ {
if ( double_flatline_mask.bottom[uLong(x)] ) if ( double_flatline_mask.bottom[x] )
// top+bottom line (at bottom) // top+bottom line (at bottom)
print (fc::NF_border_line_up_and_down); print (fc::NF_border_line_up_and_down);
else else
@ -1377,28 +1356,28 @@ void FWidget::clearFlatBorder()
, y1 = 0 , y1 = 0
, y2 = int(getHeight()) + 1; , y2 = int(getHeight()) + 1;
if ( FWidget* p = getParentWidget() ) if ( auto p = getParentWidget() )
setColor (wc.dialog_fg, p->getBackgroundColor()); setColor (wc.dialog_fg, p->getBackgroundColor());
else else
setColor (wc.dialog_fg, wc.dialog_bg); setColor (wc.dialog_fg, wc.dialog_bg);
// clear on left side // clear on left side
for (int y = 0; y < int(getHeight()); y++) for (std::size_t y = 0; y < getHeight(); y++)
{ {
setPrintPos (x1 - 1, y1 + y + 1); setPrintPos (x1 - 1, y1 + int(y) + 1);
if ( double_flatline_mask.left[uLong(y)] ) if ( double_flatline_mask.left[y] )
print (fc::NF_border_line_left); print (fc::NF_border_line_left);
else else
print (' '); print (' ');
} }
// clear on right side // clear on right side
for (int y = 0; y < int(getHeight()); y++) for (std::size_t y = 0; y < getHeight(); y++)
{ {
setPrintPos (x2, y1 + y + 1); setPrintPos (x2, y1 + int(y) + 1);
if ( double_flatline_mask.right[uLong(y)] ) if ( double_flatline_mask.right[y] )
print (fc::NF_rev_border_line_right); print (fc::NF_rev_border_line_right);
else else
print (' '); print (' ');
@ -1407,9 +1386,9 @@ void FWidget::clearFlatBorder()
// clear at top // clear at top
setPrintPos (x1, y1); setPrintPos (x1, y1);
for (int x = 0; x < int(getWidth()); x++) for (std::size_t x = 0; x < getWidth(); x++)
{ {
if ( double_flatline_mask.top[uLong(x)] ) if ( double_flatline_mask.top[x] )
print (fc::NF_border_line_upper); print (fc::NF_border_line_upper);
else else
print (' '); print (' ');
@ -1418,9 +1397,9 @@ void FWidget::clearFlatBorder()
// clear at bottom // clear at bottom
setPrintPos (x1, y2); setPrintPos (x1, y2);
for (int x = 0; x < int(getWidth()); x++) for (std::size_t x = 0; x < getWidth(); x++)
{ {
if ( double_flatline_mask.bottom[uLong(x)] ) if ( double_flatline_mask.bottom[x] )
print (fc::NF_border_line_bottom); print (fc::NF_border_line_bottom);
else else
print (' '); print (' ');
@ -1457,8 +1436,8 @@ void FWidget::drawBorder (int x1, int y1, int x2, int y2)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::quit() void FWidget::quit()
{ {
FWidget* app_object = FApplication::getApplicationObject(); auto app_object = FApplication::getApplicationObject();
FApplication* fapp = static_cast<FApplication*>(app_object); auto fapp = static_cast<FApplication*>(app_object);
fapp->exit(0); fapp->exit(0);
} }
@ -1520,7 +1499,7 @@ void FWidget::delPreprocessingHandler (FVTerm* instance)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FWidget::isChildPrintArea() const bool FWidget::isChildPrintArea() const
{ {
FWidget* p_obj = static_cast<FWidget*>(getParent()); auto p_obj = static_cast<FWidget*>(getParent());
if ( p_obj if ( p_obj
&& p_obj->child_print_area && p_obj->child_print_area
@ -1559,7 +1538,7 @@ void FWidget::adjustSize()
{ {
if ( ! isRootWidget() ) if ( ! isRootWidget() )
{ {
FWidget* p = getParentWidget(); auto p = getParentWidget();
if ( isWindowWidget() ) if ( isWindowWidget() )
{ {
@ -1595,15 +1574,14 @@ void FWidget::adjustSize()
if ( hasChildren() ) if ( hasChildren() )
{ {
constFObjectIterator iter, last; auto iter = FObject::begin();
iter = FObject::begin(); auto last = FObject::end();
last = FObject::end();
while ( iter != last ) while ( iter != last )
{ {
if ( (*iter)->isWidget() ) if ( (*iter)->isWidget() )
{ {
FWidget* widget = static_cast<FWidget*>(*iter); auto widget = static_cast<FWidget*>(*iter);
if ( ! widget->isWindowWidget() ) if ( ! widget->isWindowWidget() )
widget->adjustSize(); widget->adjustSize();
@ -1624,15 +1602,8 @@ void FWidget::adjustSizeGlobal()
if ( window_list && ! window_list->empty() ) if ( window_list && ! window_list->empty() )
{ {
widgetList::const_iterator iter, last; for (auto&& window : *window_list)
iter = window_list->begin(); window->adjustSize();
last = window_list->end();
while ( iter != last )
{
(*iter)->adjustSize();
++iter;
}
} }
} }
@ -1642,16 +1613,15 @@ bool FWidget::focusNextChild()
if ( isDialogWidget() || ! hasParent() ) if ( isDialogWidget() || ! hasParent() )
return false; return false;
FWidget* parent = getParentWidget(); auto parent = getParentWidget();
if ( ! parent if ( ! parent
|| ! parent->hasChildren() || ! parent->hasChildren()
|| parent->numOfFocusableChildren() <= 1 ) || parent->numOfFocusableChildren() <= 1 )
return false; return false;
FObjectIterator iter, last; auto iter = parent->begin();
iter = parent->begin(); auto last = parent->end();
last = parent->end();
while ( iter != last ) while ( iter != last )
{ {
@ -1661,7 +1631,7 @@ bool FWidget::focusNextChild()
continue; continue;
} }
FWidget* w = static_cast<FWidget*>(*iter); auto w = static_cast<FWidget*>(*iter);
if ( w != this ) if ( w != this )
{ {
@ -1670,8 +1640,7 @@ bool FWidget::focusNextChild()
} }
FWidget* next = nullptr; FWidget* next = nullptr;
constFObjectIterator next_element; auto next_element = iter;
next_element = iter;
do do
{ {
@ -1707,16 +1676,15 @@ bool FWidget::focusPrevChild()
if ( isDialogWidget() || ! hasParent() ) if ( isDialogWidget() || ! hasParent() )
return false; return false;
FWidget* parent = getParentWidget(); auto parent = getParentWidget();
if ( ! parent if ( ! parent
|| ! parent->hasChildren() || ! parent->hasChildren()
|| parent->numOfFocusableChildren() <= 1 ) || parent->numOfFocusableChildren() <= 1 )
return false; return false;
FObjectIterator iter, first; auto iter = parent->end();
iter = parent->end(); auto first = parent->begin();
first = parent->begin();
do do
{ {
@ -1725,14 +1693,13 @@ bool FWidget::focusPrevChild()
if ( ! (*iter)->isWidget() ) if ( ! (*iter)->isWidget() )
continue; continue;
FWidget* w = static_cast<FWidget*>(*iter); auto w = static_cast<FWidget*>(*iter);
if ( w != this ) if ( w != this )
continue; continue;
FWidget* prev = nullptr; FWidget* prev = nullptr;
constFObjectIterator prev_element; auto prev_element = iter;
prev_element = iter;
do do
{ {
@ -1771,75 +1738,75 @@ bool FWidget::event (FEvent* ev)
switch ( ev->type() ) switch ( ev->type() )
{ {
case fc::KeyPress_Event: case fc::KeyPress_Event:
KeyPressEvent ( static_cast<FKeyEvent*>(ev) ); KeyPressEvent (static_cast<FKeyEvent*>(ev));
break; break;
case fc::KeyUp_Event: case fc::KeyUp_Event:
onKeyUp ( static_cast<FKeyEvent*>(ev) ); onKeyUp (static_cast<FKeyEvent*>(ev));
break; break;
case fc::KeyDown_Event: case fc::KeyDown_Event:
KeyDownEvent ( static_cast<FKeyEvent*>(ev) ); KeyDownEvent (static_cast<FKeyEvent*>(ev));
break; break;
case fc::MouseDown_Event: case fc::MouseDown_Event:
onMouseDown ( static_cast<FMouseEvent*>(ev) ); onMouseDown (static_cast<FMouseEvent*>(ev));
break; break;
case fc::MouseUp_Event: case fc::MouseUp_Event:
onMouseUp ( static_cast<FMouseEvent*>(ev) ); onMouseUp (static_cast<FMouseEvent*>(ev));
break; break;
case fc::MouseDoubleClick_Event: case fc::MouseDoubleClick_Event:
onMouseDoubleClick ( static_cast<FMouseEvent*>(ev) ); onMouseDoubleClick (static_cast<FMouseEvent*>(ev));
break; break;
case fc::MouseWheel_Event: case fc::MouseWheel_Event:
onWheel ( static_cast<FWheelEvent*>(ev) ); onWheel (static_cast<FWheelEvent*>(ev));
break; break;
case fc::MouseMove_Event: case fc::MouseMove_Event:
onMouseMove ( static_cast<FMouseEvent*>(ev) ); onMouseMove (static_cast<FMouseEvent*>(ev));
break; break;
case fc::FocusIn_Event: case fc::FocusIn_Event:
onFocusIn ( static_cast<FFocusEvent*>(ev) ); onFocusIn (static_cast<FFocusEvent*>(ev));
break; break;
case fc::FocusOut_Event: case fc::FocusOut_Event:
onFocusOut ( static_cast<FFocusEvent*>(ev) ); onFocusOut (static_cast<FFocusEvent*>(ev));
break; break;
case fc::ChildFocusIn_Event: case fc::ChildFocusIn_Event:
onChildFocusIn ( static_cast<FFocusEvent*>(ev) ); onChildFocusIn (static_cast<FFocusEvent*>(ev));
break; break;
case fc::ChildFocusOut_Event: case fc::ChildFocusOut_Event:
onChildFocusOut ( static_cast<FFocusEvent*>(ev) ); onChildFocusOut (static_cast<FFocusEvent*>(ev));
break; break;
case fc::Accelerator_Event: case fc::Accelerator_Event:
onAccel ( static_cast<FAccelEvent*>(ev) ); onAccel (static_cast<FAccelEvent*>(ev));
break; break;
case fc::Resize_Event: case fc::Resize_Event:
onResize ( static_cast<FResizeEvent*>(ev) ); onResize (static_cast<FResizeEvent*>(ev));
break; break;
case fc::Show_Event: case fc::Show_Event:
onShow ( static_cast<FShowEvent*>(ev) ); onShow (static_cast<FShowEvent*>(ev));
break; break;
case fc::Hide_Event: case fc::Hide_Event:
onHide ( static_cast<FHideEvent*>(ev) ); onHide (static_cast<FHideEvent*>(ev));
break; break;
case fc::Close_Event: case fc::Close_Event:
onClose ( static_cast<FCloseEvent*>(ev) ); onClose (static_cast<FCloseEvent*>(ev));
break; break;
case fc::Timer_Event: case fc::Timer_Event:
onTimer ( static_cast<FTimerEvent*>(ev) ); onTimer (static_cast<FTimerEvent*>(ev));
break; break;
default: default:
@ -2169,15 +2136,14 @@ void FWidget::drawWindows()
if ( ! window_list || window_list->empty() ) if ( ! window_list || window_list->empty() )
return; return;
widgetList::const_iterator iter, last; auto iter = window_list->begin();
iter = window_list->begin(); auto last = window_list->end();
last = window_list->end();
while ( iter != last ) while ( iter != last )
{ {
if ( (*iter)->isVisible() ) if ( (*iter)->isVisible() )
{ {
term_area* win = (*iter)->getVWin(); auto win = (*iter)->getVWin();
int w = win->width + win->right_shadow; int w = win->width + win->right_shadow;
int h = win->height + win->bottom_shadow; int h = win->height + win->bottom_shadow;
std::fill_n (win->text, w * h, default_char); std::fill_n (win->text, w * h, default_char);
@ -2196,15 +2162,14 @@ void FWidget::drawChildren()
if ( ! hasChildren() ) if ( ! hasChildren() )
return; return;
constFObjectIterator iter, last; auto iter = FObject::begin();
iter = FObject::begin(); auto last = FObject::end();
last = FObject::end();
while ( iter != last ) while ( iter != last )
{ {
if ( (*iter)->isWidget() ) if ( (*iter)->isWidget() )
{ {
FWidget* widget = static_cast<FWidget*>(*iter); auto widget = static_cast<FWidget*>(*iter);
if ( widget->isVisible() && ! widget->isWindowWidget() ) if ( widget->isVisible() && ! widget->isWindowWidget() )
widget->redraw(); widget->redraw();
@ -2226,9 +2191,9 @@ void FWidget::drawTransparentShadow (int x1, int y1, int x2, int y2)
setColor (wc.shadow_bg, wc.shadow_fg); setColor (wc.shadow_bg, wc.shadow_fg);
setTransShadow(); setTransShadow();
for (int i = 1; i < int(getHeight()); i++) for (std::size_t y = 1; y < getHeight(); y++)
{ {
setPrintPos (x2 + 1, y1 + i); setPrintPos (x2 + 1, y1 + int(y));
print (" "); print (" ");
} }
@ -2241,7 +2206,7 @@ void FWidget::drawTransparentShadow (int x1, int y1, int x2, int y2)
setColor (wc.shadow_bg, wc.shadow_fg); setColor (wc.shadow_bg, wc.shadow_fg);
setTransShadow(); setTransShadow();
for (std::size_t i = 2; i <= getWidth() + 1; i++) for (std::size_t x = 2; x <= getWidth() + 1; x++)
print (' '); print (' ');
unsetTransShadow(); unsetTransShadow();
@ -2266,7 +2231,7 @@ void FWidget::drawBlockShadow (int x1, int y1, int x2, int y2)
setColor (wc.shadow_fg, wc.shadow_bg); setColor (wc.shadow_fg, wc.shadow_bg);
setInheritBackground(); // current background color will be ignored setInheritBackground(); // current background color will be ignored
} }
else if ( FWidget* p = getParentWidget() ) else if ( auto p = getParentWidget() )
setColor (wc.shadow_fg, p->getBackgroundColor()); setColor (wc.shadow_fg, p->getBackgroundColor());
block = fc::FullBlock; // █ block = fc::FullBlock; // █
@ -2275,9 +2240,9 @@ void FWidget::drawBlockShadow (int x1, int y1, int x2, int y2)
if ( isWindowWidget() ) if ( isWindowWidget() )
unsetInheritBackground(); unsetInheritBackground();
for (int i = 1; i < int(getHeight()); i++) for (std::size_t y = 1; y < getHeight(); y++)
{ {
setPrintPos (x2 + 1, y1 + i); setPrintPos (x2 + 1, y1 + int(y));
print (block); // █ print (block); // █
} }
@ -2286,7 +2251,7 @@ void FWidget::drawBlockShadow (int x1, int y1, int x2, int y2)
if ( isWindowWidget() ) if ( isWindowWidget() )
setInheritBackground(); setInheritBackground();
for (std::size_t i = 1; i <= getWidth(); i++) for (std::size_t x = 1; x <= getWidth(); x++)
print (fc::UpperHalfBlock); // ▀ print (fc::UpperHalfBlock); // ▀
if ( isWindowWidget() ) if ( isWindowWidget() )

View File

@ -51,7 +51,7 @@ FWindow::FWindow(FWidget* parent)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FWindow::~FWindow() // destructor FWindow::~FWindow() // destructor
{ {
FApplication* fapp = static_cast<FApplication*>(getRootWidget()); auto fapp = static_cast<FApplication*>(getRootWidget());
if ( previous_window == this ) if ( previous_window == this )
previous_window = nullptr; previous_window = nullptr;
@ -103,7 +103,6 @@ bool FWindow::setWindowWidget (bool on)
void FWindow::setActiveWindow (FWindow* window) void FWindow::setActiveWindow (FWindow* window)
{ {
// activate FWindow object window // activate FWindow object window
widgetList::const_iterator iter, end;
if ( ! window_list ) if ( ! window_list )
return; return;
@ -111,8 +110,8 @@ void FWindow::setActiveWindow (FWindow* window)
if ( window_list->empty() ) if ( window_list->empty() )
return; return;
iter = window_list->begin(); auto iter = window_list->begin();
end = window_list->end(); auto end = window_list->end();
while ( iter != end ) while ( iter != end )
{ {
@ -127,7 +126,7 @@ void FWindow::setActiveWindow (FWindow* window)
} }
else else
{ {
FWindow* w = static_cast<FWindow*>(*iter); auto w = static_cast<FWindow*>(*iter);
if ( w->isWindowActive() ) if ( w->isWindowActive() )
{ {
@ -439,16 +438,15 @@ FWindow* FWindow::getWindowWidgetAt (int x, int y)
// returns the window object to the corresponding coordinates // returns the window object to the corresponding coordinates
if ( window_list && ! window_list->empty() ) if ( window_list && ! window_list->empty() )
{ {
widgetList::const_iterator iter, begin; auto iter = window_list->end();
iter = window_list->end(); auto begin = window_list->begin();
begin = window_list->begin();
do do
{ {
--iter; --iter;
if ( *iter ) if ( *iter )
{ {
FWindow* w = static_cast<FWindow*>(*iter); auto w = static_cast<FWindow*>(*iter);
if ( ! w->isWindowHidden() if ( ! w->isWindowHidden()
&& w->getTermGeometry().contains(x, y) ) && w->getTermGeometry().contains(x, y) )
@ -478,8 +476,7 @@ void FWindow::delWindow (FWidget* obj)
if ( ! window_list || window_list->empty() ) if ( ! window_list || window_list->empty() )
return; return;
widgetList::iterator iter; auto iter = window_list->begin();
iter = window_list->begin();
while ( iter != window_list->end() ) while ( iter != window_list->end() )
{ {
@ -497,7 +494,7 @@ void FWindow::delWindow (FWidget* obj)
FWindow* FWindow::getWindowWidget (const FWidget* obj) FWindow* FWindow::getWindowWidget (const FWidget* obj)
{ {
// returns the window object to the given widget obj // returns the window object to the given widget obj
FWidget* p_obj = obj->getParentWidget(); auto p_obj = obj->getParentWidget();
while ( ! obj->isWindowWidget() && p_obj ) while ( ! obj->isWindowWidget() && p_obj )
{ {
@ -515,7 +512,7 @@ FWindow* FWindow::getWindowWidget (const FWidget* obj)
int FWindow::getWindowLayer (const FWidget* obj) int FWindow::getWindowLayer (const FWidget* obj)
{ {
// returns the window layer from the widget obj // returns the window layer from the widget obj
widgetList::iterator iter, end;
const FWidget* window; const FWidget* window;
if ( ! window_list ) if ( ! window_list )
@ -532,8 +529,8 @@ int FWindow::getWindowLayer (const FWidget* obj)
else else
window = obj; window = obj;
iter = window_list->begin(); auto iter = window_list->begin();
end = window_list->end(); auto end = window_list->end();
while ( iter != end ) while ( iter != end )
{ {
@ -550,7 +547,6 @@ int FWindow::getWindowLayer (const FWidget* obj)
void FWindow::swapWindow (FWidget* obj1, FWidget* obj2) void FWindow::swapWindow (FWidget* obj1, FWidget* obj2)
{ {
// swaps the window layer between obj1 and obj2 // swaps the window layer between obj1 and obj2
widgetList::iterator iter, iter1, iter2, end;
if ( ! window_list ) if ( ! window_list )
return; return;
@ -564,10 +560,10 @@ void FWindow::swapWindow (FWidget* obj1, FWidget* obj2)
if ( obj2->getFlags().modal ) if ( obj2->getFlags().modal )
return; return;
iter = window_list->begin(); auto iter = window_list->begin();
end = window_list->end(); auto end = window_list->end();
iter1 = end; auto iter1 = end;
iter2 = end; auto iter2 = end;
while ( iter != end ) while ( iter != end )
{ {
@ -587,7 +583,6 @@ void FWindow::swapWindow (FWidget* obj1, FWidget* obj2)
bool FWindow::raiseWindow (FWidget* obj) bool FWindow::raiseWindow (FWidget* obj)
{ {
// raises the window widget obj to the top // raises the window widget obj to the top
widgetList::iterator iter;
if ( ! window_list ) if ( ! window_list )
return false; return false;
@ -605,7 +600,7 @@ bool FWindow::raiseWindow (FWidget* obj)
&& ! obj->isMenuWidget() ) && ! obj->isMenuWidget() )
return false; return false;
iter = window_list->begin(); auto iter = window_list->begin();
while ( iter != window_list->end() ) while ( iter != window_list->end() )
{ {
@ -629,7 +624,6 @@ bool FWindow::raiseWindow (FWidget* obj)
bool FWindow::lowerWindow (FWidget* obj) bool FWindow::lowerWindow (FWidget* obj)
{ {
// lowers the window widget obj to the bottom // lowers the window widget obj to the bottom
widgetList::iterator iter;
if ( ! window_list ) if ( ! window_list )
return false; return false;
@ -646,7 +640,7 @@ bool FWindow::lowerWindow (FWidget* obj)
if ( obj->getFlags().modal ) if ( obj->getFlags().modal )
return false; return false;
iter = window_list->begin(); auto iter = window_list->begin();
while ( iter != window_list->end() ) while ( iter != window_list->end() )
{ {
@ -701,21 +695,20 @@ void FWindow::switchToPrevWindow (FWidget* widget)
widget->updateTerminal (FVTerm::stop_refresh); widget->updateTerminal (FVTerm::stop_refresh);
bool is_activated = activatePrevWindow(); bool is_activated = activatePrevWindow();
FWindow* active_win = static_cast<FWindow*>(getActiveWindow()); auto active_win = static_cast<FWindow*>(getActiveWindow());
if ( ! is_activated ) if ( ! is_activated )
{ {
// no previous window -> looking for another window // no previous window -> looking for another window
if ( window_list && window_list->size() > 1 ) if ( window_list && window_list->size() > 1 )
{ {
widgetList::const_iterator iter, begin; auto iter = window_list->end();
iter = window_list->end(); auto begin = window_list->begin();
begin = window_list->begin();
do do
{ {
--iter; --iter;
FWindow* w = static_cast<FWindow*>(*iter); auto w = static_cast<FWindow*>(*iter);
if ( w if ( w
&& w != active_win && w != active_win
@ -733,7 +726,7 @@ void FWindow::switchToPrevWindow (FWidget* widget)
if ( active_win ) if ( active_win )
{ {
FWidget* focus = active_win->getWindowFocusWidget(); auto focus = active_win->getWindowFocusWidget();
if ( ! active_win->isWindowActive() ) if ( ! active_win->isWindowActive() )
setActiveWindow(active_win); setActiveWindow(active_win);
@ -756,7 +749,7 @@ void FWindow::switchToPrevWindow (FWidget* widget)
bool FWindow::activatePrevWindow() bool FWindow::activatePrevWindow()
{ {
// activate the previous window // activate the previous window
FWindow* w = previous_window; auto w = previous_window;
if ( w ) if ( w )
{ {
@ -787,7 +780,7 @@ void FWindow::setShadowSize (int right, int bottom)
if ( isVirtualWindow() if ( isVirtualWindow()
&& (new_right != old_right || new_bottom != old_bottom) ) && (new_right != old_right || new_bottom != old_bottom) )
{ {
FRect geometry = getTermGeometry(); auto geometry = getTermGeometry();
geometry.move(-1, -1); geometry.move(-1, -1);
resizeArea (geometry, getShadow(), vwin); resizeArea (geometry, getShadow(), vwin);
} }
@ -867,8 +860,7 @@ void FWindow::deleteFromAlwaysOnTopList (FWidget* obj)
if ( ! always_on_top_list || always_on_top_list->empty() ) if ( ! always_on_top_list || always_on_top_list->empty() )
return; return;
widgetList::iterator iter; auto iter = always_on_top_list->begin();
iter = always_on_top_list->begin();
while ( iter != always_on_top_list->end() ) while ( iter != always_on_top_list->end() )
{ {
@ -889,8 +881,7 @@ void FWindow::processAlwaysOnTop()
if ( ! always_on_top_list || always_on_top_list->empty() ) if ( ! always_on_top_list || always_on_top_list->empty() )
return; return;
widgetList::iterator iter; auto iter = always_on_top_list->begin();
iter = always_on_top_list->begin();
while ( iter != always_on_top_list->end() ) while ( iter != always_on_top_list->end() )
{ {

View File

@ -34,7 +34,7 @@
#include <limits> #include <limits>
#include <string> #include <string>
#define null NULL #define null nullptr
namespace namespace
{ {

View File

@ -150,7 +150,7 @@ void FObjectTest::noArgumentTest()
CPPUNIT_ASSERT ( o1.getChild(0) == 0 ); CPPUNIT_ASSERT ( o1.getChild(0) == 0 );
CPPUNIT_ASSERT ( o1.getChild(1) == 0 ); CPPUNIT_ASSERT ( o1.getChild(1) == 0 );
CPPUNIT_ASSERT ( o1.numOfChildren() == 0 ); CPPUNIT_ASSERT ( o1.numOfChildren() == 0 );
finalcut::FObject::FObjectList& children_list = o1.getChildren(); auto& children_list = o1.getChildren();
CPPUNIT_ASSERT ( children_list.begin() == o1.begin() ); CPPUNIT_ASSERT ( children_list.begin() == o1.begin() );
CPPUNIT_ASSERT ( children_list.begin() == o1.end() ); CPPUNIT_ASSERT ( children_list.begin() == o1.end() );
CPPUNIT_ASSERT ( children_list.end() == o1.begin() ); CPPUNIT_ASSERT ( children_list.end() == o1.begin() );
@ -162,7 +162,7 @@ void FObjectTest::noArgumentTest()
CPPUNIT_ASSERT ( ! o1.isTimerInUpdating() ); CPPUNIT_ASSERT ( ! o1.isTimerInUpdating() );
FObject_protected t; FObject_protected t;
finalcut::FEvent* ev = new finalcut::FEvent(finalcut::fc::None_Event); auto ev = new finalcut::FEvent(finalcut::fc::None_Event);
CPPUNIT_ASSERT ( ! t.event(ev) ); CPPUNIT_ASSERT ( ! t.event(ev) );
delete ev; delete ev;
@ -183,13 +183,13 @@ void FObjectTest::childObjectTest()
* -> c4 * -> c4
*/ */
finalcut::FObject obj; finalcut::FObject obj;
finalcut::FObject* c1 = new finalcut::FObject(&obj); auto c1 = new finalcut::FObject(&obj);
finalcut::FObject* c2 = new finalcut::FObject(&obj); auto c2 = new finalcut::FObject(&obj);
finalcut::FObject* c3 = new finalcut::FObject(&obj); auto c3 = new finalcut::FObject(&obj);
finalcut::FObject* c4 = new finalcut::FObject(&obj); auto c4 = new finalcut::FObject(&obj);
finalcut::FObject* c5 = new finalcut::FObject(c1); auto c5 = new finalcut::FObject(c1);
finalcut::FObject* c6 = new finalcut::FObject(c5); auto c6 = new finalcut::FObject(c5);
finalcut::FObject* c7 = new finalcut::FObject(); auto c7 = new finalcut::FObject();
CPPUNIT_ASSERT ( obj.hasChildren() ); CPPUNIT_ASSERT ( obj.hasChildren() );
CPPUNIT_ASSERT ( obj.getChild(0) == 0 ); CPPUNIT_ASSERT ( obj.getChild(0) == 0 );
@ -222,7 +222,7 @@ void FObjectTest::childObjectTest()
CPPUNIT_ASSERT ( c2->getChild(1) == 0 ); CPPUNIT_ASSERT ( c2->getChild(1) == 0 );
CPPUNIT_ASSERT ( c1->numOfChildren() == 1 ); CPPUNIT_ASSERT ( c1->numOfChildren() == 1 );
CPPUNIT_ASSERT ( c2->numOfChildren() == 0 ); CPPUNIT_ASSERT ( c2->numOfChildren() == 0 );
const finalcut::FObject::FObjectList& children_list2 = c1->getChildren(); const auto& children_list2 = c1->getChildren();
CPPUNIT_ASSERT ( children_list2.begin() == c1->begin() ); CPPUNIT_ASSERT ( children_list2.begin() == c1->begin() );
CPPUNIT_ASSERT ( children_list2.begin() != c1->end() ); CPPUNIT_ASSERT ( children_list2.begin() != c1->end() );
CPPUNIT_ASSERT ( children_list2.end() != c1->begin() ); CPPUNIT_ASSERT ( children_list2.end() != c1->begin() );
@ -249,8 +249,8 @@ void FObjectTest::removeParentTest()
{/* {/*
* obj -> child * obj -> child
*/ */
finalcut::FObject* obj = new finalcut::FObject(); auto obj = new finalcut::FObject();
finalcut::FObject* child = new finalcut::FObject(obj); auto child = new finalcut::FObject(obj);
CPPUNIT_ASSERT ( obj->hasChildren() ); CPPUNIT_ASSERT ( obj->hasChildren() );
CPPUNIT_ASSERT ( obj->numOfChildren() == 1 ); CPPUNIT_ASSERT ( obj->numOfChildren() == 1 );
@ -276,8 +276,8 @@ void FObjectTest::addTest()
{/* {/*
* obj -> child * obj -> child
*/ */
finalcut::FObject* obj = new finalcut::FObject(); auto obj = new finalcut::FObject();
finalcut::FObject* child = new finalcut::FObject(); auto child = new finalcut::FObject();
CPPUNIT_ASSERT ( ! obj->hasChildren() ); CPPUNIT_ASSERT ( ! obj->hasChildren() );
CPPUNIT_ASSERT ( obj->numOfChildren() == 0 ); CPPUNIT_ASSERT ( obj->numOfChildren() == 0 );
@ -302,8 +302,8 @@ void FObjectTest::delTest()
{/* {/*
* obj -> child * obj -> child
*/ */
finalcut::FObject* obj = new finalcut::FObject(); auto obj = new finalcut::FObject();
finalcut::FObject* child = new finalcut::FObject(obj); auto child = new finalcut::FObject(obj);
CPPUNIT_ASSERT ( obj->hasChildren() ); CPPUNIT_ASSERT ( obj->hasChildren() );
CPPUNIT_ASSERT ( obj->numOfChildren() == 1 ); CPPUNIT_ASSERT ( obj->numOfChildren() == 1 );
@ -331,10 +331,10 @@ void FObjectTest::iteratorTest()
* -> child2 * -> child2
* -> child3 * -> child3
*/ */
finalcut::FObject* obj = new finalcut::FObject(); auto obj = new finalcut::FObject();
finalcut::FObject* child1 = new finalcut::FObject(obj); auto child1 = new finalcut::FObject(obj);
finalcut::FObject* child2 = new finalcut::FObject(obj); auto child2 = new finalcut::FObject(obj);
finalcut::FObject* child3 = new finalcut::FObject(obj); auto child3 = new finalcut::FObject(obj);
CPPUNIT_ASSERT ( child1->getParent() == obj ); CPPUNIT_ASSERT ( child1->getParent() == obj );
CPPUNIT_ASSERT ( child2->getParent() == obj ); CPPUNIT_ASSERT ( child2->getParent() == obj );

View File

@ -230,7 +230,7 @@ void FTermcapQuirksTest::generalTest()
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap();
const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1;
for (int i = 0; i < last_item; i++) for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
finalcut::FTermData data; finalcut::FTermData data;
@ -297,7 +297,7 @@ void FTermcapQuirksTest::xtermTest()
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap();
const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1;
for (int i = 0; i < last_item; i++) for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
finalcut::FTermData data; finalcut::FTermData data;
@ -330,7 +330,7 @@ void FTermcapQuirksTest::freebsdTest()
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap();
const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1;
for (int i = 0; i < last_item; i++) for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
finalcut::FTermData data; finalcut::FTermData data;
@ -369,7 +369,7 @@ void FTermcapQuirksTest::cygwinTest()
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap();
const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1;
for (int i = 0; i < last_item; i++) for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
finalcut::FTermData data; finalcut::FTermData data;
@ -396,7 +396,7 @@ void FTermcapQuirksTest::linuxTest()
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap();
const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1;
for (int i = 0; i < last_item; i++) for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
finalcut::FTermData data; finalcut::FTermData data;
@ -470,7 +470,7 @@ void FTermcapQuirksTest::rxvtTest()
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap();
const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1;
for (int i = 0; i < last_item; i++) for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
finalcut::FTermData data; finalcut::FTermData data;
@ -513,7 +513,7 @@ void FTermcapQuirksTest::vteTest()
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap();
const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1;
for (int i = 0; i < last_item; i++) for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
finalcut::FTermData data; finalcut::FTermData data;
@ -539,7 +539,7 @@ void FTermcapQuirksTest::puttyTest()
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap();
const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1;
for (int i = 0; i < last_item; i++) for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
finalcut::FTermData data; finalcut::FTermData data;
@ -631,7 +631,7 @@ void FTermcapQuirksTest::teratermTest()
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap();
const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1;
for (int i = 0; i < last_item; i++) for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
finalcut::FTermData data; finalcut::FTermData data;
@ -663,7 +663,7 @@ void FTermcapQuirksTest::sunTest()
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap();
const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1;
for (int i = 0; i < last_item; i++) for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
finalcut::FTermData data; finalcut::FTermData data;
@ -686,7 +686,7 @@ void FTermcapQuirksTest::sunTest()
CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_parm_left_cursor].string CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_parm_left_cursor].string
, C_STR(CSI "%p1%dD") ); , C_STR(CSI "%p1%dD") );
for (int i = 0; finalcut::fc::Fkey[i].tname[0] != 0; i++) for (std::size_t i = 0; finalcut::fc::Fkey[i].tname[0] != 0; i++)
{ {
if ( std::strncmp(finalcut::fc::Fkey[i].tname, "K2", 2) == 0 ) // center of keypad if ( std::strncmp(finalcut::fc::Fkey[i].tname, "K2", 2) == 0 ) // center of keypad
CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string
@ -783,7 +783,7 @@ void FTermcapQuirksTest::screenTest()
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap();
const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1;
for (int i = 0; i < last_item; i++) for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
finalcut::FTermData data; finalcut::FTermData data;

View File

@ -127,13 +127,13 @@ void FTermDataTest::dataTest()
finalcut::FTermData data; finalcut::FTermData data;
CPPUNIT_ASSERT ( data.getEncodingList().size() == 0 ); CPPUNIT_ASSERT ( data.getEncodingList().size() == 0 );
finalcut::FTermData::encodingMap& encoding_list = data.getEncodingList(); auto& encoding_list = data.getEncodingList();
encoding_list["UTF8"] = finalcut::fc::UTF8; encoding_list["UTF8"] = finalcut::fc::UTF8;
encoding_list["UTF-8"] = finalcut::fc::UTF8; encoding_list["UTF-8"] = finalcut::fc::UTF8;
encoding_list["VT100"] = finalcut::fc::VT100; encoding_list["VT100"] = finalcut::fc::VT100;
encoding_list["PC"] = finalcut::fc::PC; encoding_list["PC"] = finalcut::fc::PC;
encoding_list["ASCII"] = finalcut::fc::ASCII; encoding_list["ASCII"] = finalcut::fc::ASCII;
finalcut::FTermData::encodingMap& enc_list = data.getEncodingList(); auto& enc_list = data.getEncodingList();
CPPUNIT_ASSERT ( enc_list.size() == 5 ); CPPUNIT_ASSERT ( enc_list.size() == 5 );
CPPUNIT_ASSERT ( enc_list["UTF8"] == finalcut::fc::UTF8 ); CPPUNIT_ASSERT ( enc_list["UTF8"] == finalcut::fc::UTF8 );
CPPUNIT_ASSERT ( enc_list["UTF-8"] == finalcut::fc::UTF8 ); CPPUNIT_ASSERT ( enc_list["UTF-8"] == finalcut::fc::UTF8 );

View File

@ -390,7 +390,7 @@ class FTermDetectionTest : public CPPUNIT_NS::TestFixture
pid_t forkProcess(); pid_t forkProcess();
bool isChildProcess (pid_t); bool isChildProcess (pid_t);
void terminalSimulation (console); void terminalSimulation (console);
void parseTerminalBuffer (int, console); void parseTerminalBuffer (std::size_t, console);
// Adds code needed to register the test suite // Adds code needed to register the test suite
CPPUNIT_TEST_SUITE (FTermDetectionTest); CPPUNIT_TEST_SUITE (FTermDetectionTest);
@ -2331,9 +2331,9 @@ void FTermDetectionTest::terminalSimulation (console con)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermDetectionTest::parseTerminalBuffer (int length, console con) void FTermDetectionTest::parseTerminalBuffer (std::size_t length, console con)
{ {
for (int i = 0; i < length; i++) for (std::size_t i = 0; i < length; i++)
{ {
if ( buffer[i] == ENQ[0] ) // Enquiry character if ( buffer[i] == ENQ[0] ) // Enquiry character
{ {