FObject has received the iterator child access methods begin() and end()

This commit is contained in:
Markus Gans 2017-09-17 01:50:41 +02:00
parent 37f8ee81c9
commit 4df0418aee
22 changed files with 329 additions and 312 deletions

View File

@ -1,3 +1,7 @@
2017-09-17 Markus Gans <guru.mail@muenster.de>
* FObject has received the iterator child access methods
begin() and end()
2017-09-15 Markus Gans <guru.mail@muenster.de>
* Fix byte access in data type char_data

View File

@ -1044,11 +1044,11 @@ bool FApplication::processAccelerator (const FWidget*& widget)
&& widget->accelerator_list
&& ! widget->accelerator_list->empty() )
{
FWidget::Accelerators::const_iterator iter, end;
FWidget::Accelerators::const_iterator iter, last;
iter = widget->accelerator_list->begin();
end = widget->accelerator_list->end();
last = widget->accelerator_list->end();
while ( iter != end )
while ( iter != last )
{
if ( quit_now || app_exit_loop )
break;
@ -1918,7 +1918,7 @@ void FApplication::processResizeEvent()
//----------------------------------------------------------------------
int FApplication::processTimerEvent()
{
FObject::TimerList::iterator iter, end;
FObject::TimerList::iterator iter, last;
timeval currentTime;
int activated = 0;
@ -1934,9 +1934,9 @@ int FApplication::processTimerEvent()
return 0;
iter = timer_list->begin();
end = timer_list->end();
last = timer_list->end();
while ( iter != end )
while ( iter != last )
{
if ( ! (*iter).id
|| ! (*iter).object

View File

@ -126,11 +126,11 @@ bool FButtonGroup::hasFocusedButton() const
if ( buttonlist.empty() )
return false;
constFObjectIterator iter, end;
constFObjectIterator iter, last;
iter = buttonlist.begin();
end = buttonlist.end();
last = buttonlist.end();
while ( iter != end )
while ( iter != last )
{
FToggleButton* toggle_button = static_cast<FToggleButton*>(*iter);
@ -149,11 +149,11 @@ bool FButtonGroup::hasCheckedButton() const
if ( buttonlist.empty() )
return false;
constFObjectIterator iter, end;
constFObjectIterator iter, last;
iter = buttonlist.begin();
end = buttonlist.end();
last = buttonlist.end();
while ( iter != end )
while ( iter != last )
{
FToggleButton* toggle_button = static_cast<FToggleButton*>(*iter);
@ -177,11 +177,11 @@ void FButtonGroup::hide()
if ( ! buttonlist.empty() )
{
constFObjectIterator iter, end;
constFObjectIterator iter, last;
iter = buttonlist.begin();
end = buttonlist.end();
last = buttonlist.end();
while ( iter != end )
while ( iter != last )
{
FToggleButton* toggle_button = static_cast<FToggleButton*>(*iter);
toggle_button->hide();
@ -325,11 +325,11 @@ void FButtonGroup::onFocusIn (FFocusEvent* in_ev)
{
if ( hasCheckedButton() && ! buttonlist.empty() )
{
constFObjectIterator iter, end;
constFObjectIterator iter, last;
iter = buttonlist.begin();
end = buttonlist.end();
last = buttonlist.end();
while ( iter != end )
while ( iter != last )
{
FToggleButton* toggle_button = static_cast<FToggleButton*>(*iter);
@ -389,7 +389,7 @@ void FButtonGroup::onFocusIn (FFocusEvent* in_ev)
void FButtonGroup::cb_buttonToggled (FWidget* widget, data_ptr)
{
FToggleButton* button = static_cast<FToggleButton*>(widget);
constFObjectIterator iter, end;
constFObjectIterator iter, last;
if ( ! button->isChecked() )
return;
@ -398,9 +398,9 @@ void FButtonGroup::cb_buttonToggled (FWidget* widget, data_ptr)
return;
iter = buttonlist.begin();
end = buttonlist.end();
last = buttonlist.end();
while ( iter != end )
while ( iter != last )
{
FToggleButton* toggle_button = static_cast<FToggleButton*>(*iter);
@ -600,11 +600,11 @@ void FButtonGroup::directFocus()
if ( hasCheckedButton() && ! buttonlist.empty() )
{
constFObjectIterator iter, end;
constFObjectIterator iter, last;
iter = buttonlist.begin();
end = buttonlist.end();
last = buttonlist.end();
while ( iter != end )
while ( iter != last )
{
FToggleButton* toggle_button = static_cast<FToggleButton*>(*iter);

View File

@ -249,11 +249,11 @@ void FDialog::setPos (int x, int y, bool)
if ( window_list && ! window_list->empty() )
{
bool overlaid = false;
widgetList::const_iterator iter, end;
widgetList::const_iterator iter, last;
iter = window_list->begin();
end = window_list->end();
last = window_list->end();
while ( iter != end )
while ( iter != last )
{
if ( overlaid )
putArea ((*iter)->getTermPos(), (*iter)->getVWin());
@ -335,11 +335,11 @@ void FDialog::setSize (int w, int h, bool adjust)
if ( window_list && ! window_list->empty() )
{
bool overlaid = false;
widgetList::const_iterator iter, end;
widgetList::const_iterator iter, last;
iter = window_list->begin();
end = window_list->end();
last = window_list->end();
while ( iter != end )
while ( iter != last )
{
if ( overlaid )
putArea ((*iter)->getTermPos(), (*iter)->getVWin());
@ -949,11 +949,11 @@ void FDialog::onWindowRaised (FEvent*)
// handle always-on-top windows
if ( always_on_top_list && ! always_on_top_list->empty() )
{
widgetList::const_iterator iter, end;
widgetList::const_iterator iter, last;
iter = always_on_top_list->begin();
end = always_on_top_list->end();
last = always_on_top_list->end();
while ( iter != end )
while ( iter != last )
{
putArea ((*iter)->getTermPos(), (*iter)->getVWin());
++iter;
@ -964,7 +964,7 @@ void FDialog::onWindowRaised (FEvent*)
//----------------------------------------------------------------------
void FDialog::onWindowLowered (FEvent*)
{
widgetList::const_iterator iter, end;
widgetList::const_iterator iter, last;
if ( ! window_list )
return;
@ -973,9 +973,9 @@ void FDialog::onWindowLowered (FEvent*)
return;
iter = window_list->begin();
end = window_list->end();
last = window_list->end();
while ( iter != end )
while ( iter != last )
{
putArea ((*iter)->getTermPos(), (*iter)->getVWin());
++iter;

View File

@ -346,11 +346,11 @@ int FFileDialog::readDir()
if ( ! dir_entries.empty() )
{
std::vector<dir_entry>::const_iterator iter, end;
std::vector<dir_entry>::const_iterator iter, last;
iter = dir_entries.begin();
end = dir_entries.end();
last = dir_entries.end();
while ( iter != end )
while ( iter != last )
{
if ( (*iter).type == DT_DIR )
filebrowser->insert(FString((*iter).name), fc::SquareBrackets);
@ -612,16 +612,16 @@ inline bool FFileDialog::pattern_match ( const char* const pattern
//----------------------------------------------------------------------
void FFileDialog::clear()
{
std::vector<dir_entry>::const_iterator iter, end;
std::vector<dir_entry>::const_iterator iter, last;
if ( dir_entries.empty() )
return;
// delete all directory entries;
iter = dir_entries.begin();
end = dir_entries.end();
last = dir_entries.end();
while ( iter != end )
while ( iter != last )
{
std::free ((*iter).name);
++iter;
@ -637,11 +637,11 @@ int FFileDialog::numOfDirs()
return 0;
int n = 0;
std::vector<dir_entry>::const_iterator iter, end;
std::vector<dir_entry>::const_iterator iter, last;
iter = dir_entries.begin();
end = dir_entries.end();
last = dir_entries.end();
while ( iter != end )
while ( iter != last )
{
if ( (*iter).type == DT_DIR && std::strcmp((*iter).name, ".") != 0 )
n++;
@ -685,13 +685,13 @@ int FFileDialog::changeDir (const FString& dirname)
else if ( ! dir_entries.empty() )
{
int i = 1;
std::vector<dir_entry>::const_iterator iter, end;
std::vector<dir_entry>::const_iterator iter, last;
const char* const baseName = \
basename(const_cast<char*>(lastdir.c_str()));
iter = dir_entries.begin();
end = dir_entries.end();
last = dir_entries.end();
while ( iter != end )
while ( iter != last )
{
if ( std::strcmp((*iter).name, baseName) == 0 )
{
@ -777,12 +777,12 @@ void FFileDialog::cb_processActivate (FWidget*, data_ptr)
if ( ! dir_entries.empty() )
{
std::vector<dir_entry>::const_iterator iter, end;
std::vector<dir_entry>::const_iterator iter, last;
const FString& input = filename->getText().trim();
iter = dir_entries.begin();
end = dir_entries.end();
last = dir_entries.end();
while ( iter != end )
while ( iter != last )
{
if ( (*iter).name && input && ! input.isNull()
&& std::strcmp((*iter).name, input) == 0

View File

@ -1372,7 +1372,7 @@ void FListBox::drawLabel()
void FListBox::drawList()
{
FString element;
uInt start, end, inc_len;
uInt start, num, inc_len;
bool isFocus;
listBoxItems::iterator iter;
@ -1381,11 +1381,11 @@ void FListBox::drawList()
isFocus = ((flags & fc::focus) != 0);
start = 0;
end = uInt(getHeight() - 2);
num = uInt(getHeight() - 2);
inc_len = inc_search.getLength();
if ( end > getCount() )
end = getCount();
if ( num > getCount() )
num = getCount();
if ( last_yoffset >= 0
&& last_yoffset == yoffset
@ -1395,12 +1395,12 @@ void FListBox::drawList()
uInt last_pos = uInt(current - yoffset) - 1;
uInt current_pos = uInt(last_current - yoffset) - 1;
start = std::min(last_pos, current_pos);
end = std::max(last_pos, current_pos) + 1;
num = std::max(last_pos, current_pos) + 1;
}
iter = index2iterator(int(start) + yoffset);
for (uInt y = start; y < end; y++)
for (uInt y = start; y < num; y++)
{
bool serach_mark = false;
bool lineHasBrackets = hasBrackets(iter);

View File

@ -118,7 +118,7 @@ void FListViewItem::setText (int column, const FString& text)
FObject::FObjectIterator FListViewItem::insert (FListViewItem* child)
{
// Add a FListViewItem as child element
if ( ! child || ! hasChildren() )
if ( ! child )
return FObjectIterator(0);
return appendItem(child);
@ -174,8 +174,7 @@ FObject::FObjectIterator FListViewItem::appendItem (FListViewItem* child)
{
expandable = true;
addChild (child);
FObjectList children = getChildren();
return --children.end();
return --FObject::end();
}
//----------------------------------------------------------------------
@ -203,10 +202,9 @@ int FListViewItem::getVisibleLines()
return visible_lines;
}
FObjectList children = this->getChildren();
constFObjectIterator iter = children.begin();
constFObjectIterator iter = FObject::begin();
while ( iter != children.end() )
while ( iter != FObject::end() )
{
FListViewItem* child = static_cast<FListViewItem*>(*iter);
visible_lines += child->getVisibleLines();

View File

@ -174,6 +174,8 @@ class FListView : public FWidget
FObjectIterator insert ( const std::vector<long>&
, data_ptr
, FObjectIterator );
FObjectIterator beginOfList();
FObjectIterator endOfList();
// Event handlers
void onKeyPress (FKeyEvent*);
@ -322,6 +324,14 @@ inline FObject::FObjectIterator
, FObjectIterator parent_iter )
{ return insert (cols, 0, parent_iter); }
//----------------------------------------------------------------------
inline FObject::FObjectIterator FListView::beginOfList()
{ return itemlist.begin(); }
//----------------------------------------------------------------------
inline FObject::FObjectIterator FListView::endOfList()
{ return itemlist.end(); }
//----------------------------------------------------------------------
inline FObject::FObjectIterator FListView::index2iterator (int index)
{
@ -333,6 +343,14 @@ inline FObject::FObjectIterator FListView::index2iterator (int index)
//----------------------------------------------------------------------
inline void FListView::nextElement (FObjectIterator& iter)
{
FListViewItem* item = static_cast<FListViewItem*>(*iter);
if ( item->isExpandable() )
{
//iter = item->begin();
++iter;
}
else
++iter;
}

View File

@ -293,17 +293,17 @@ void FMenu::onMouseDown (FMouseEvent* ev)
if ( ! item_list.empty() )
{
std::vector<FMenuItem*>::const_iterator iter, end;
std::vector<FMenuItem*>::const_iterator iter, last;
FMenu* show_sub_menu = 0;
bool focus_changed = false;
FPoint mouse_pos;
iter = item_list.begin();
end = item_list.end();
last = item_list.end();
mouse_pos = ev->getPos();
mouse_pos -= FPoint(getRightPadding(), getTopPadding());
while ( iter != end )
while ( iter != last )
{
int x1, x2, y, mouse_x, mouse_y;
x1 = (*iter)->getX();
@ -401,14 +401,14 @@ void FMenu::onMouseUp (FMouseEvent* ev)
if ( ! item_list.empty() )
{
std::vector<FMenuItem*>::const_iterator iter, end;
std::vector<FMenuItem*>::const_iterator iter, last;
FPoint mouse_pos;
iter = item_list.begin();
end = item_list.end();
last = item_list.end();
mouse_pos = ev->getPos();
mouse_pos -= FPoint(getRightPadding(), getTopPadding());
while ( iter != end )
while ( iter != last )
{
int x1, x2, y;
x1 = (*iter)->getX();
@ -480,7 +480,7 @@ void FMenu::onMouseMove (FMouseEvent* ev)
if ( mouse_down && ! item_list.empty() )
{
std::vector<FMenuItem*>::const_iterator iter, end;
std::vector<FMenuItem*>::const_iterator iter, last;
FMenu* smenu = 0;
bool focus_changed = false;
bool mouse_over_menu = false;
@ -492,7 +492,7 @@ void FMenu::onMouseMove (FMouseEvent* ev)
FPoint mouse_pos;
iter = item_list.begin();
end = item_list.end();
last = item_list.end();
mouse_pos = ev->getPos();
mouse_pos -= FPoint(getRightPadding(), getTopPadding());
@ -521,7 +521,7 @@ void FMenu::onMouseMove (FMouseEvent* ev)
mouse_over_menubar = true;
}
while ( iter != end )
while ( iter != last )
{
int x1, x2, y, mouse_x, mouse_y;
x1 = (*iter)->getX();
@ -710,7 +710,7 @@ void FMenu::onMouseMove (FMouseEvent* ev)
void FMenu::cb_menuitem_toggled (FWidget* widget, data_ptr)
{
FMenuItem* menuitem = static_cast<FMenuItem*>(widget);
std::vector<FMenuItem*>::const_iterator iter, end;
std::vector<FMenuItem*>::const_iterator iter, last;
if ( ! has_checkable_items )
return;
@ -722,9 +722,9 @@ void FMenu::cb_menuitem_toggled (FWidget* widget, data_ptr)
return;
iter = item_list.begin();
end = item_list.end();
last = item_list.end();
while ( iter != end )
while ( iter != last )
{
if ( (*iter) != menuitem
&& (*iter)->isChecked()
@ -819,13 +819,13 @@ void FMenu::init(FWidget* parent)
void FMenu::calculateDimensions()
{
int item_X, item_Y, adjust_X;
std::vector<FMenuItem*>::const_iterator iter, end;
std::vector<FMenuItem*>::const_iterator iter, last;
iter = item_list.begin();
end = item_list.end();
last = item_list.end();
max_item_width = 10; // minimum width
// find the maximum item width
while ( iter != end )
while ( iter != last )
{
uInt item_width = (*iter)->getTextLength() + 2;
int accel_key = (*iter)->accel_key;
@ -860,7 +860,7 @@ void FMenu::calculateDimensions()
item_X = 1;
item_Y = 1;
while ( iter != end )
while ( iter != last )
{
(*iter)->setGeometry (item_X, item_Y, int(max_item_width), 1);
@ -880,11 +880,11 @@ void FMenu::calculateDimensions()
//----------------------------------------------------------------------
void FMenu::adjustItems()
{
std::vector<FMenuItem*>::const_iterator end, iter;
std::vector<FMenuItem*>::const_iterator last, iter;
iter = item_list.begin();
end = item_list.end();
last = item_list.end();
while ( iter != end )
while ( iter != last )
{
if ( (*iter)->hasMenu() )
{
@ -1034,11 +1034,11 @@ FMenu* FMenu::superMenuAt (int x, int y)
//----------------------------------------------------------------------
bool FMenu::selectNextItem()
{
std::vector<FMenuItem*>::const_iterator iter, end;
std::vector<FMenuItem*>::const_iterator iter, last;
iter = item_list.begin();
end = item_list.end();
last = item_list.end();
while ( iter != end )
while ( iter != last )
{
if ( (*iter)->isSelected() )
{
@ -1084,9 +1084,9 @@ bool FMenu::selectNextItem()
//----------------------------------------------------------------------
bool FMenu::selectPrevItem()
{
std::vector<FMenuItem*>::const_iterator iter, begin;
std::vector<FMenuItem*>::const_iterator iter, first;
iter = item_list.end();
begin = item_list.begin();
first = item_list.begin();
do
{
@ -1127,7 +1127,7 @@ bool FMenu::selectPrevItem()
break;
}
}
while ( iter != begin );
while ( iter != first );
return true;
}
@ -1144,11 +1144,11 @@ void FMenu::keypressMenuBar (FKeyEvent*& ev)
//----------------------------------------------------------------------
bool FMenu::hotkeyMenu (FKeyEvent*& ev)
{
std::vector<FMenuItem*>::const_iterator iter, end;
std::vector<FMenuItem*>::const_iterator iter, last;
iter = item_list.begin();
end = item_list.end();
last = item_list.end();
while ( iter != end )
while ( iter != last )
{
if ( (*iter)->hasHotkey() )
{
@ -1242,16 +1242,16 @@ void FMenu::draw()
//----------------------------------------------------------------------
void FMenu::drawItems()
{
std::vector<FMenuItem*>::const_iterator iter, end;
std::vector<FMenuItem*>::const_iterator iter, last;
int c = 0;
int y = 0;
iter = item_list.begin();
end = item_list.end();
last = item_list.end();
if ( has_checkable_items )
c = 1;
while ( iter != end )
while ( iter != last )
{
if ( (*iter)->isSeparator() )
{

View File

@ -169,16 +169,16 @@ void FMenuBar::onMouseDown (FMouseEvent* ev)
if ( ! item_list.empty() )
{
std::vector<FMenuItem*>::const_iterator iter, end;
std::vector<FMenuItem*>::const_iterator iter, last;
int mouse_x, mouse_y;
bool focus_changed = false;
iter = item_list.begin();
end = item_list.end();
last = item_list.end();
mouse_x = ev->getX();
mouse_y = ev->getY();
while ( iter != end )
while ( iter != last )
{
int x1, x2;
x1 = (*iter)->getX();
@ -255,13 +255,13 @@ void FMenuBar::onMouseUp (FMouseEvent* ev)
if ( ! item_list.empty() )
{
int mouse_x, mouse_y;
std::vector<FMenuItem*>::const_iterator iter, end;
std::vector<FMenuItem*>::const_iterator iter, last;
iter = item_list.begin();
end = item_list.end();
last = item_list.end();
mouse_x = ev->getX();
mouse_y = ev->getY();
while ( iter != end )
while ( iter != last )
{
int x1, x2;
x1 = (*iter)->getX();
@ -338,19 +338,19 @@ void FMenuBar::onMouseMove (FMouseEvent* ev)
if ( mouse_down && ! item_list.empty() )
{
std::vector<FMenuItem*>::const_iterator iter, end;
std::vector<FMenuItem*>::const_iterator iter, last;
int mouse_x, mouse_y;
bool mouse_over_menubar = false;
bool focus_changed = false;
iter = item_list.begin();
end = item_list.end();
last = item_list.end();
mouse_x = ev->getX();
mouse_y = ev->getY();
if ( getTermGeometry().contains(ev->getTermPos()) )
mouse_over_menubar = true;
while ( iter != end )
while ( iter != last )
{
int x1, x2;
x1 = (*iter)->getX();
@ -506,12 +506,12 @@ void FMenuBar::calculateDimensions()
{
int item_X = 1;
int item_Y = 1;
std::vector<FMenuItem*>::const_iterator end, iter;
std::vector<FMenuItem*>::const_iterator last, iter;
iter = item_list.begin();
end = item_list.end();
last = item_list.end();
// find the maximum item width
while ( iter != end )
while ( iter != last )
{
uInt len = (*iter)->getTextLength();
int item_width = int(len + 2);
@ -532,11 +532,11 @@ void FMenuBar::calculateDimensions()
//----------------------------------------------------------------------
bool FMenuBar::selectNextItem()
{
std::vector<FMenuItem*>::const_iterator iter, end;
std::vector<FMenuItem*>::const_iterator iter, last;
iter = item_list.begin();
end = item_list.end();
last = item_list.end();
while ( iter != end )
while ( iter != last )
{
if ( (*iter)->isSelected() )
{
@ -597,9 +597,9 @@ bool FMenuBar::selectNextItem()
//----------------------------------------------------------------------
bool FMenuBar::selectPrevItem()
{
std::vector<FMenuItem*>::const_iterator iter, begin;
std::vector<FMenuItem*>::const_iterator iter, first;
iter = item_list.end();
begin = item_list.begin();
first = item_list.begin();
do
{
@ -655,7 +655,7 @@ bool FMenuBar::selectPrevItem()
break;
}
}
while ( iter != begin );
while ( iter != first );
return true;
}
@ -663,11 +663,11 @@ bool FMenuBar::selectPrevItem()
//----------------------------------------------------------------------
bool FMenuBar::hotkeyMenu (FKeyEvent*& ev)
{
std::vector<FMenuItem*>::const_iterator iter, end;
std::vector<FMenuItem*>::const_iterator iter, last;
iter = item_list.begin();
end = item_list.end();
last = item_list.end();
while ( iter != end )
while ( iter != last )
{
if ( (*iter)->isEnabled() )
{
@ -756,7 +756,7 @@ void FMenuBar::draw()
//----------------------------------------------------------------------
void FMenuBar::drawItems()
{
std::vector<FMenuItem*>::const_iterator iter, end;
std::vector<FMenuItem*>::const_iterator iter, last;
int screenWidth;
int x = 1;
screenWidth = getColumnNumber();
@ -770,9 +770,9 @@ void FMenuBar::drawItems()
setReverse(true);
iter = item_list.begin();
end = item_list.end();
last = item_list.end();
while ( iter != end )
while ( iter != last )
{
wchar_t* src;
wchar_t* dest;
@ -922,11 +922,11 @@ void FMenuBar::adjustItems()
{
int item_X = 1;
int item_Y = 1;
std::vector<FMenuItem*>::const_iterator end, iter;
std::vector<FMenuItem*>::const_iterator last, iter;
iter = item_list.begin();
end = item_list.end();
last = item_list.end();
while ( iter != end )
while ( iter != last )
{
// get item width
int item_width = (*iter)->getWidth();

View File

@ -728,7 +728,7 @@ void FMenuItem::init (FWidget* parent)
, this );
}
this->addCallback
addCallback // for this element
(
"deactivate",
F_METHOD_CALLBACK (parent, &FMenuBar::cb_item_deactivated)
@ -789,8 +789,8 @@ void FMenuItem::createDialogList (FMenu* winmenu)
if ( dialog_list && ! dialog_list->empty() )
{
widgetList::const_iterator iter, begin;
iter = begin = dialog_list->begin();
widgetList::const_iterator iter, first;
iter = first = dialog_list->begin();
while ( iter != dialog_list->end() && *iter )
{
@ -799,7 +799,7 @@ void FMenuItem::createDialogList (FMenu* winmenu)
if ( win )
{
FMenuItem* win_item;
int n = int(std::distance(begin, iter));
int n = int(std::distance(first, iter));
// get the dialog title
const FString& name = win->getText();

View File

@ -79,14 +79,14 @@ FObject::~FObject() // destructor
}
// delete children objects
FObjectList children = this->getChildren();
if ( ! children.empty() )
if ( hasChildren() )
{
constFObjectIterator iter;
iter = children.begin();
constFObjectIterator iter, last;
FObjectList delete_list = children_list;
iter = delete_list.begin();
last = delete_list.end();
while ( iter != children.end() )
while ( iter != last )
{
delete (*iter);
++iter;
@ -100,14 +100,14 @@ FObject* FObject::getChild (int index) const
{
index--;
if ( children_list.empty() )
if ( ! hasChildren() )
return 0;
if ( index < 0 || index >= numOfChildren() )
return 0;
constFObjectIterator iter;
iter = children_list.begin();
iter = begin();
std::advance (iter, index);
return *iter;
}
@ -146,7 +146,7 @@ void FObject::delChild (FObject* obj)
if ( ! obj )
return;
if ( ! children_list.empty() )
if ( hasChildren() )
{
obj->removeParent();
children_list.remove(obj);
@ -183,7 +183,7 @@ void FObject::getCurrentTime (timeval* time)
//----------------------------------------------------------------------
int FObject::addTimer (int interval)
{
FObject::TimerList::iterator iter, end;
FObject::TimerList::iterator iter, last;
timeval time_interval;
timeval currentTime;
int id = 1;
@ -207,9 +207,9 @@ int FObject::addTimer (int interval)
if ( ! timer_list->empty() )
{
iter = timer_list->begin();
end = timer_list->end();
last = timer_list->end();
while ( iter != end )
while ( iter != last )
{
if ( (*iter).id == id )
{
@ -233,9 +233,9 @@ int FObject::addTimer (int interval)
// insert in list sorted by timeout
iter = timer_list->begin();
end = timer_list->end();
last = timer_list->end();
while ( iter != end && (*iter).timeout < t.timeout )
while ( iter != last && (*iter).timeout < t.timeout )
++iter;
timer_list->insert (iter, t);
@ -247,19 +247,19 @@ int FObject::addTimer (int interval)
//----------------------------------------------------------------------
bool FObject::delTimer (int id)
{
FObject::TimerList::iterator iter, end;
FObject::TimerList::iterator iter, last;
if ( id <= 0 || id > int(timer_list->size()) )
return false;
timer_modify_lock = true;
iter = timer_list->begin();
end = timer_list->end();
last = timer_list->end();
while ( iter != end && (*iter).id != id )
while ( iter != last && (*iter).id != id )
++iter;
if ( iter != end )
if ( iter != last )
{
timer_list->erase(iter);
timer_modify_lock = false;

View File

@ -50,6 +50,10 @@ class FObject
FObject* getChild (int) const;
const FObjectList& getChildren() const;
int numOfChildren() const;
FObjectIterator begin();
FObjectIterator end();
constFObjectIterator begin() const;
constFObjectIterator end() const;
// Inquiries
bool hasParent() const;
@ -124,6 +128,22 @@ inline const FObject::FObjectList& FObject::getChildren() const
inline int FObject::numOfChildren() const
{ return int(children_list.size()); }
//----------------------------------------------------------------------
inline FObject::FObjectIterator FObject::begin()
{ return children_list.begin(); }
//----------------------------------------------------------------------
inline FObject::FObjectIterator FObject::end()
{ return children_list.end(); }
//----------------------------------------------------------------------
inline FObject::constFObjectIterator FObject::begin() const
{ return children_list.begin(); }
//----------------------------------------------------------------------
inline FObject::constFObjectIterator FObject::end() const
{ return children_list.end(); }
//----------------------------------------------------------------------
inline bool FObject::hasParent() const
{ return has_parent; }

View File

@ -45,7 +45,7 @@ void FRadioMenuItem::init (FWidget* parent)
if ( menu_ptr )
menu_ptr->has_checkable_items = true;
this->addCallback
addCallback // for this element
(
"toggled",
F_METHOD_CALLBACK (parent, &FMenu::cb_menuitem_toggled)

View File

@ -154,11 +154,11 @@ bool FStatusBar::hasActivatedKey()
{
if ( ! key_list.empty() )
{
std::vector<FStatusKey*>::const_iterator iter, end;
std::vector<FStatusKey*>::const_iterator iter, last;
iter = key_list.begin();
end = key_list.end();
last = key_list.end();
while ( iter != end )
while ( iter != last )
{
if ( (*iter)->isActivated() )
return true;
@ -348,11 +348,11 @@ void FStatusBar::onMouseDown (FMouseEvent* ev)
if ( ! key_list.empty() )
{
std::vector<FStatusKey*>::const_iterator iter, end;
std::vector<FStatusKey*>::const_iterator iter, last;
iter = key_list.begin();
end = key_list.end();
last = key_list.end();
while ( iter != end )
while ( iter != last )
{
(*iter)->unsetMouseFocus();
++iter;
@ -370,12 +370,12 @@ void FStatusBar::onMouseDown (FMouseEvent* ev)
if ( ! key_list.empty() )
{
std::vector<FStatusKey*>::const_iterator iter, end;
std::vector<FStatusKey*>::const_iterator iter, last;
int X = 1;
iter = key_list.begin();
end = key_list.end();
last = key_list.end();
while ( iter != end )
while ( iter != last )
{
int x1, x2, mouse_x, mouse_y, kname_len, txt_length;
@ -416,12 +416,12 @@ void FStatusBar::onMouseUp (FMouseEvent* ev)
if ( ! key_list.empty() )
{
std::vector<FStatusKey*>::const_iterator iter, end;
std::vector<FStatusKey*>::const_iterator iter, last;
int X = 1;
iter = key_list.begin();
end = key_list.end();
last = key_list.end();
while ( iter != end )
while ( iter != last )
{
int x1, x2, kname_len, txt_length;
x1 = X;
@ -462,13 +462,13 @@ void FStatusBar::onMouseMove (FMouseEvent* ev)
if ( mouse_down && ! key_list.empty() )
{
std::vector<FStatusKey*>::const_iterator iter, end;
std::vector<FStatusKey*>::const_iterator iter, last;
bool focus_changed = false;
int X = 1;
iter = key_list.begin();
end = key_list.end();
last = key_list.end();
while ( iter != end )
while ( iter != last )
{
int x1, x2, mouse_x, mouse_y, kname_len, txt_length;
x1 = X;
@ -511,13 +511,13 @@ void FStatusBar::cb_statuskey_activated (FWidget* widget, data_ptr)
{
if ( ! key_list.empty() )
{
std::vector<FStatusKey*>::const_iterator iter, end;
std::vector<FStatusKey*>::const_iterator iter, last;
FStatusKey* statuskey = static_cast<FStatusKey*>(widget);
iter = key_list.begin();
end = key_list.end();
last = key_list.end();
while ( iter != end )
while ( iter != last )
{
if ( (*iter) != statuskey && (*iter)->isActivated() )
(*iter)->unsetActive();
@ -562,7 +562,7 @@ void FStatusBar::draw()
//----------------------------------------------------------------------
void FStatusBar::drawKeys()
{
std::vector<FStatusKey*>::const_iterator iter, end;
std::vector<FStatusKey*>::const_iterator iter, last;
int screenWidth;
screenWidth = getColumnNumber();
@ -580,9 +580,9 @@ void FStatusBar::drawKeys()
setReverse(true);
iter = key_list.begin();
end = key_list.end();
last = key_list.end();
while ( iter != end )
while ( iter != last )
{
int kname_len = int(getKeyName((*iter)->getKey()).getLength());

View File

@ -185,7 +185,7 @@ void FTextView::insert (const FString& str, int pos)
stringLines::iterator iter;
stringLines text_split;
FString s;
uLong end;
uLong num;
if ( pos < 0 || pos >= int(getRows()) )
pos = int(getRows());
@ -197,9 +197,9 @@ void FTextView::insert (const FString& str, int pos)
iter = data.begin();
text_split = s.split("\r\n");
end = text_split.size();
num = text_split.size();
for (uInt i = 0; i < end; i++)
for (uInt i = 0; i < num; i++)
{
uInt len;
text_split[i] = text_split[i].removeBackspaces()
@ -239,24 +239,24 @@ void FTextView::insert (const FString& str, int pos)
}
//----------------------------------------------------------------------
void FTextView::replaceRange (const FString& str, int start, int end)
void FTextView::replaceRange (const FString& str, int from, int to)
{
stringLines::iterator iter;
if ( start > end )
if ( from > to )
return;
if ( start < 0 || start >= int(getRows()) )
if ( from < 0 || from >= int(getRows()) )
return;
if ( end < 0 || end >= int(getRows()) )
if ( to < 0 || to >= int(getRows()) )
return;
iter = data.begin();
data.erase (iter + start, iter + end + 1);
data.erase (iter + from, iter + to + 1);
if ( ! str.isNull() )
insert(str, start);
insert(str, from);
}
//----------------------------------------------------------------------
@ -740,23 +740,22 @@ void FTextView::draw()
//----------------------------------------------------------------------
void FTextView::drawText()
{
uInt start, end;
uInt num;
if ( data.empty() || getHeight() <= 2 || getWidth() <= 2 )
return;
start = 0;
end = uInt(getHeight() + nf_offset - 2);
num = uInt(getHeight() + nf_offset - 2);
if ( end > getRows() )
end = getRows();
if ( num > getRows() )
num = getRows();
setColor();
if ( isMonochron() )
setReverse(true);
for (uInt y = start; y < end; y++)
for (uInt y = 0; y < num; y++)
{
uInt i, len;
FString line;

View File

@ -140,8 +140,8 @@ inline const FTextView::stringLines& FTextView::getLines() const
{ return data; }
//----------------------------------------------------------------------
inline void FTextView::deleteRange (int start, int end)
{ replaceRange (FString(), start, end); }
inline void FTextView::deleteRange (int from, int to)
{ replaceRange (FString(), from, to); }
//----------------------------------------------------------------------
inline void FTextView::deleteLine (int pos)

View File

@ -277,7 +277,7 @@ void FVTerm::delPreprocessingHandler (FVTerm* instance)
if ( ! print_area || print_area->preprocessing_call.empty() )
return;
FPreprocessing::iterator iter, end;
FPreprocessing::iterator iter;
iter = print_area->preprocessing_call.begin();
while ( iter != print_area->preprocessing_call.end() )
@ -820,7 +820,7 @@ bool FVTerm::isChildPrintArea() const
if ( p_obj
&& p_obj->child_print_area
&& p_obj->child_print_area == this->print_area )
&& p_obj->child_print_area == print_area )
return true;
else
return false;

View File

@ -121,7 +121,7 @@ FWidget::~FWidget() // destructor
// finish the program
if ( rootObject == this )
this->finish();
finish();
}
@ -167,16 +167,16 @@ FWidget* FWidget::getFocusWidget() const
}
//----------------------------------------------------------------------
FWidget* FWidget::getFirstFocusableWidget (FObjectList children)
FWidget* FWidget::getFirstFocusableWidget (FObjectList list)
{
if ( children.empty() )
if ( list.empty() )
return 0;
constFObjectIterator iter, end;
iter = children.begin();
end = children.end();
constFObjectIterator iter, last;
iter = list.begin();
last = list.end();
while ( iter != end )
while ( iter != last )
{
if ( (*iter)->isWidget() )
{
@ -193,14 +193,14 @@ FWidget* FWidget::getFirstFocusableWidget (FObjectList children)
}
//----------------------------------------------------------------------
FWidget* FWidget::getLastFocusableWidget (FObjectList children)
FWidget* FWidget::getLastFocusableWidget (FObjectList list)
{
if ( children.empty() )
if ( list.empty() )
return 0;
constFObjectIterator iter, begin;
begin = children.begin();
iter = children.end();
constFObjectIterator iter, first;
first = list.begin();
iter = list.end();
do
{
@ -214,7 +214,7 @@ FWidget* FWidget::getLastFocusableWidget (FObjectList children)
if ( child->isEnabled() && child->acceptFocus() )
return child;
}
while ( iter != begin );
while ( iter != first );
return 0;
}
@ -838,14 +838,11 @@ FWidget* FWidget::childWidgetAt (FWidget* p, int x, int y)
{
if ( p && p->hasChildren() )
{
FObjectList children;
constFObjectIterator iter, end;
constFObjectIterator iter, last;
iter = p->begin();
last = p->end();
children = p->getChildren();
iter = children.begin();
end = children.end();
while ( iter != end )
while ( iter != last )
{
if ( ! (*iter)->isWidget() )
{
@ -874,18 +871,16 @@ FWidget* FWidget::childWidgetAt (FWidget* p, int x, int y)
//----------------------------------------------------------------------
int FWidget::numOfFocusableChildren()
{
FObjectList children;
constFObjectIterator iter, end;
constFObjectIterator iter, last;
if ( ! this->hasChildren() )
if ( ! hasChildren() )
return 0;
int num = 0;
children = this->getChildren();
iter = children.begin();
end = children.end();
iter = FObject::begin();
last = FObject::end();
while ( iter != end )
while ( iter != last )
{
if ( (*iter)->isWidget() )
{
@ -1022,11 +1017,11 @@ void FWidget::emitCallback (const FString& emit_signal)
// function pointer
if ( ! callback_objects.empty() )
{
CallbackObjects::const_iterator iter, end;
CallbackObjects::const_iterator iter, last;
iter = callback_objects.begin();
end = callback_objects.end();
last = callback_objects.end();
while ( iter != end )
while ( iter != last )
{
if ( iter->cb_signal == emit_signal )
{
@ -1108,11 +1103,11 @@ void FWidget::redraw()
if ( window_list && ! window_list->empty() )
{
widgetList::const_iterator iter, end;
widgetList::const_iterator iter, last;
iter = window_list->begin();
end = window_list->end();
last = window_list->end();
while ( iter != end )
while ( iter != last )
{
if ( (*iter)->isVisible() )
{
@ -1131,16 +1126,13 @@ void FWidget::redraw()
else
{
// draw child elements
if ( this->hasChildren() )
if ( hasChildren() )
{
FObjectList children;
constFObjectIterator iter, end;
constFObjectIterator iter, last;
iter = FObject::begin();
last = FObject::end();
children = this->getChildren();
iter = children.begin();
end = children.end();
while ( iter != end )
while ( iter != last )
{
if ( (*iter)->isWidget() )
{
@ -1229,16 +1221,13 @@ void FWidget::show()
draw();
shown = true;
if ( this->hasChildren() )
if ( hasChildren() )
{
FObjectList children;
constFObjectIterator iter, end;
constFObjectIterator iter, last;
iter = FObject::begin();
last = FObject::end();
children = this->getChildren();
iter = children.begin();
end = children.end();
while ( iter != end )
while ( iter != last )
{
if ( (*iter)->isWidget() )
{
@ -1288,17 +1277,15 @@ void FWidget::hide()
//----------------------------------------------------------------------
bool FWidget::focusFirstChild()
{
FObjectList children;
constFObjectIterator iter, end;
constFObjectIterator iter, last;
if ( ! this->hasChildren() )
if ( ! hasChildren() )
return false;
children = this->getChildren();
iter = children.begin();
end = children.end();
iter = FObject::begin();
last = FObject::end();
while ( iter != end )
while ( iter != last )
{
if ( ! (*iter)->isWidget() )
{
@ -1334,15 +1321,13 @@ bool FWidget::focusFirstChild()
//----------------------------------------------------------------------
bool FWidget::focusLastChild()
{
FObjectList children;
constFObjectIterator iter, begin;
constFObjectIterator iter, first;
if ( ! this->hasChildren() )
if ( ! hasChildren() )
return false;
children = this->getChildren();
iter = children.end();
begin = children.begin();
iter = FObject::end();
first = FObject::begin();
do
{
@ -1368,7 +1353,7 @@ bool FWidget::focusLastChild()
return true;
}
}
while ( iter != begin );
while ( iter != first );
return false;
}
@ -1823,16 +1808,13 @@ void FWidget::adjustSize()
getTermY() - 2 + getHeight() - padding.bottom
);
if ( this->hasChildren() )
if ( hasChildren() )
{
FObjectList children;
constFObjectIterator iter, end;
constFObjectIterator iter, last;
iter = FObject::begin();
last = FObject::end();
children = this->getChildren();
iter = children.begin();
end = children.end();
while ( iter != end )
while ( iter != last )
{
if ( (*iter)->isWidget() )
{
@ -1857,11 +1839,11 @@ void FWidget::adjustSizeGlobal()
if ( window_list && ! window_list->empty() )
{
widgetList::const_iterator iter, end;
widgetList::const_iterator iter, last;
iter = window_list->begin();
end = window_list->end();
last = window_list->end();
while ( iter != end )
while ( iter != last )
{
(*iter)->adjustSize();
++iter;
@ -1881,14 +1863,11 @@ bool FWidget::focusNextChild()
if ( parent->hasChildren() && parent->numOfFocusableChildren() > 1 )
{
FObjectList children;
FObjectIterator iter, end;
FObjectIterator iter, last;
iter = parent->begin();
last = parent->end();
children = parent->getChildren();
iter = children.begin();
end = children.end();
while ( iter != end )
while ( iter != last )
{
if ( ! (*iter)->isWidget() )
{
@ -1908,8 +1887,8 @@ bool FWidget::focusNextChild()
{
++next_element;
if ( next_element == children.end() )
next_element = children.begin();
if ( next_element == parent->end() )
next_element = parent->begin();
if ( ! (*next_element)->isWidget() )
continue;
@ -1948,7 +1927,7 @@ bool FWidget::focusNextChild()
if ( in.isAccepted() )
{
this->redraw();
redraw();
next->redraw();
updateTerminal();
flush_out();
@ -1975,12 +1954,9 @@ bool FWidget::focusPrevChild()
if ( parent->hasChildren() && parent->numOfFocusableChildren() > 1 )
{
FObjectList children;
FObjectIterator iter, begin;
children = parent->getChildren();
iter = children.end();
begin = children.begin();
FObjectIterator iter, first;
iter = parent->end();
first = parent->begin();
do
{
@ -2005,8 +1981,8 @@ bool FWidget::focusPrevChild()
continue;
}
if ( prev_element == children.begin() )
prev_element = children.end();
if ( prev_element == parent->begin() )
prev_element = parent->end();
--prev_element;
prev = static_cast<FWidget*>(*prev_element);
@ -2043,7 +2019,7 @@ bool FWidget::focusPrevChild()
if ( in.isAccepted() )
{
this->redraw();
redraw();
prev->redraw();
updateTerminal();
flush_out();
@ -2053,7 +2029,7 @@ bool FWidget::focusPrevChild()
break;
}
}
while ( iter != begin );
while ( iter != first );
}
}

View File

@ -80,9 +80,11 @@ Treeview::Treeview (FWidget* parent)
listView->insert (line);
}
FObjectIterator iter_africa = listView->beginOfList();
std::string egypt[3] = { "Egypt", "94,666,000", "87" };
std::vector<FString> egypt_line (&egypt[0], &egypt[0] + 3);
FObjectIterator iter_africa = listView->insert (egypt_line);
//FObjectIterator iter_africa = listView->insert (egypt_line);
listView->insert (egypt_line, iter_africa);

View File

@ -53,7 +53,7 @@ ProgressDialog::ProgressDialog (FWidget* parent)
, more()
, quit()
{
setGeometry (int((this->getParentWidget()->getWidth() - 40) / 2), 7, 40, 10);
setGeometry (int((getParentWidget()->getWidth() - 40) / 2), 7, 40, 10);
setText("Progress bar");
//setModal();
@ -823,9 +823,9 @@ void MyDialog::cb_updateNumber (FWidget* widget, data_ptr data)
FListBox* list = static_cast<FListBox*>(widget);
FLabel* num = static_cast<FLabel*>(data);
int select_num = 0;
uInt end = list->getCount();
uInt count = list->getCount();
for (uInt n = 1; n <= end; n++)
for (uInt n = 1; n <= count; n++)
if ( list->isSelected(int(n)) )
select_num++;

View File

@ -356,7 +356,7 @@ void Window::activateWindow (FDialog* win)
void Window::adjustSize()
{
int w, h, X, Y, dx, dy;
std::vector<win_data*>::const_iterator iter, begin;
std::vector<win_data*>::const_iterator iter, first;
w = getRootWidget()->getWidth();
h = getRootWidget()->getHeight();
X = int(1 + (w - 40) / 2);
@ -368,14 +368,14 @@ void Window::adjustSize()
Y = 2;
setPos (X, Y);
iter = begin = windows.begin();
iter = first = windows.begin();
while ( iter != windows.end() )
{
if ( (*iter)->is_open )
{
int x, y, n;
n = int(std::distance(begin, iter));
n = int(std::distance(first, iter));
x = dx + 5 + (n % 3) * 25 + int(n / 3) * 3;
y = dy + 11 + int(n / 3) * 3;
(*iter)->dgl->setPos (x, y);
@ -408,8 +408,8 @@ void Window::onClose (FCloseEvent* ev)
void Window::cb_createWindows (FWidget*, data_ptr)
{
int w, h, dx, dy;
std::vector<win_data*>::const_iterator iter, begin;
iter = begin = windows.begin();
std::vector<win_data*>::const_iterator iter, first;
iter = first = windows.begin();
w = getRootWidget()->getWidth();
h = getRootWidget()->getHeight();
dx = (w > 80) ? (w - 80) / 2 : 0;
@ -425,7 +425,7 @@ void Window::cb_createWindows (FWidget*, data_ptr)
win_dat->dgl = win;
win_dat->is_open = true;
win->setText(*(win_dat)->title);
n = int(std::distance(begin, iter));
n = int(std::distance(first, iter));
x = dx + 5 + (n % 3) * 25 + int(n / 3) * 3;
y = dy + 11 + int(n / 3) * 3;
win->setGeometry (x, y, 20, 8);
@ -453,9 +453,9 @@ void Window::cb_closeWindows (FWidget*, data_ptr)
if ( ! dialog_list || dialog_list->empty() )
return;
widgetList::const_iterator iter, begin;
widgetList::const_iterator iter, first;
iter = dialog_list->end();
begin = dialog_list->begin();
first = dialog_list->begin();
activateWindow(this);
do
@ -465,7 +465,7 @@ void Window::cb_closeWindows (FWidget*, data_ptr)
if ( (*iter) != this )
(*iter)->close();
}
while ( iter != begin );
while ( iter != first );
}
//----------------------------------------------------------------------