Fix byte access in data type char_data

This commit is contained in:
Markus Gans 2017-09-15 01:31:02 +02:00
parent 0ce3868e74
commit 0e4ba28544
16 changed files with 348 additions and 314 deletions

View File

@ -1,3 +1,6 @@
2017-09-15 Markus Gans <guru.mail@muenster.de>
* Fix byte access in data type char_data
2017-09-11 Markus Gans <guru.mail@muenster.de> 2017-09-11 Markus Gans <guru.mail@muenster.de>
* Some code improvements * Some code improvements
* Fix handling of negative numbers in FString::toLong() * Fix handling of negative numbers in FString::toLong()

View File

@ -34,7 +34,7 @@ FButtonGroup::FButtonGroup (const FString& txt, FWidget* parent)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FButtonGroup::~FButtonGroup() // destructor FButtonGroup::~FButtonGroup() // destructor
{ {
FObjectList::iterator iter; FObjectIterator iter;
if ( buttonlist.empty() ) if ( buttonlist.empty() )
return; return;
@ -54,7 +54,7 @@ FButtonGroup::~FButtonGroup() // destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FToggleButton* FButtonGroup::getButton(int index) const FToggleButton* FButtonGroup::getButton(int index) const
{ {
FObjectList::const_iterator iter; constFObjectIterator iter;
index--; index--;
if ( buttonlist.empty() ) if ( buttonlist.empty() )
@ -126,7 +126,7 @@ bool FButtonGroup::hasFocusedButton() const
if ( buttonlist.empty() ) if ( buttonlist.empty() )
return false; return false;
FObjectList::const_iterator iter, end; constFObjectIterator iter, end;
iter = buttonlist.begin(); iter = buttonlist.begin();
end = buttonlist.end(); end = buttonlist.end();
@ -149,7 +149,7 @@ bool FButtonGroup::hasCheckedButton() const
if ( buttonlist.empty() ) if ( buttonlist.empty() )
return false; return false;
FObjectList::const_iterator iter, end; constFObjectIterator iter, end;
iter = buttonlist.begin(); iter = buttonlist.begin();
end = buttonlist.end(); end = buttonlist.end();
@ -177,7 +177,7 @@ void FButtonGroup::hide()
if ( ! buttonlist.empty() ) if ( ! buttonlist.empty() )
{ {
FObjectList::const_iterator iter, end; constFObjectIterator iter, end;
iter = buttonlist.begin(); iter = buttonlist.begin();
end = buttonlist.end(); end = buttonlist.end();
@ -260,7 +260,7 @@ void FButtonGroup::insert (FToggleButton* button)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FButtonGroup::remove (FToggleButton* button) void FButtonGroup::remove (FToggleButton* button)
{ {
FObjectList::iterator iter; FObjectIterator iter;
if ( ! button || buttonlist.empty() ) if ( ! button || buttonlist.empty() )
return; return;
@ -325,7 +325,7 @@ void FButtonGroup::onFocusIn (FFocusEvent* in_ev)
{ {
if ( hasCheckedButton() && ! buttonlist.empty() ) if ( hasCheckedButton() && ! buttonlist.empty() )
{ {
FObjectList::const_iterator iter, end; constFObjectIterator iter, end;
iter = buttonlist.begin(); iter = buttonlist.begin();
end = buttonlist.end(); end = buttonlist.end();
@ -389,7 +389,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); FToggleButton* button = static_cast<FToggleButton*>(widget);
FObjectList::const_iterator iter, end; constFObjectIterator iter, end;
if ( ! button->isChecked() ) if ( ! button->isChecked() )
return; return;
@ -600,7 +600,7 @@ void FButtonGroup::directFocus()
if ( hasCheckedButton() && ! buttonlist.empty() ) if ( hasCheckedButton() && ! buttonlist.empty() )
{ {
FObjectList::const_iterator iter, end; constFObjectIterator iter, end;
iter = buttonlist.begin(); iter = buttonlist.begin();
end = buttonlist.end(); end = buttonlist.end();

View File

@ -71,7 +71,7 @@ FListBoxItem& FListBoxItem::operator = (const FListBoxItem& item)
FListBox::FListBox (FWidget* parent) FListBox::FListBox (FWidget* parent)
: FWidget(parent) : FWidget(parent)
, convertToItem(0) , convertToItem(0)
, data() , itemlist()
, source_container(0) , source_container(0)
, conv_type(FListBox::no_convert) , conv_type(FListBox::no_convert)
, vbar(0) , vbar(0)
@ -135,7 +135,7 @@ void FListBox::setCurrentItem (int index)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListBox::setCurrentItem (listBoxItems::iterator iter) void FListBox::setCurrentItem (listBoxItems::iterator iter)
{ {
int index = int(std::distance(data.begin(), iter) + 1); int index = int(std::distance(itemlist.begin(), iter) + 1);
setCurrentItem(index); setCurrentItem(index);
} }
@ -274,7 +274,7 @@ void FListBox::insert (FListBoxItem listItem)
bool has_brackets = bool(listItem.brackets); bool has_brackets = bool(listItem.brackets);
recalculateHorizontalBar (len, has_brackets); recalculateHorizontalBar (len, has_brackets);
data.push_back (listItem); itemlist.push_back (listItem);
int element_count = int(getCount()); int element_count = int(getCount());
recalculateVerticalBar (element_count); recalculateVerticalBar (element_count);
@ -309,13 +309,13 @@ void FListBox::remove (int item)
if ( int(getCount()) < item ) if ( int(getCount()) < item )
return; return;
data.erase (data.begin() + item - 1); itemlist.erase (itemlist.begin() + item - 1);
element_count = int(getCount()); element_count = int(getCount());
max_line_width = 0; max_line_width = 0;
listBoxItems::iterator iter = data.begin(); listBoxItems::iterator iter = itemlist.begin();
while ( iter != data.end() ) while ( iter != itemlist.end() )
{ {
int len = int(iter->getText().getLength()); int len = int(iter->getText().getLength());
@ -356,7 +356,7 @@ void FListBox::clear()
int size; int size;
char* blank; char* blank;
data.clear(); itemlist.clear();
current = 0; current = 0;
xoffset = 0; xoffset = 0;
@ -556,9 +556,9 @@ void FListBox::onKeyPress (FKeyEvent* ev)
{ {
inc_search += L' '; inc_search += L' ';
bool inc_found = false; bool inc_found = false;
listBoxItems::iterator iter = data.begin(); listBoxItems::iterator iter = itemlist.begin();
while ( iter != data.end() ) while ( iter != itemlist.end() )
{ {
if ( ! inc_found if ( ! inc_found
&& inc_search.toLower() && inc_search.toLower()
@ -605,9 +605,9 @@ void FListBox::onKeyPress (FKeyEvent* ev)
if ( inc_len > 1 ) if ( inc_len > 1 )
{ {
listBoxItems::iterator iter = data.begin(); listBoxItems::iterator iter = itemlist.begin();
while ( iter != data.end() ) while ( iter != itemlist.end() )
{ {
if ( inc_search.toLower() if ( inc_search.toLower()
== iter->getText().left(inc_len - 1).toLower() ) == iter->getText().left(inc_len - 1).toLower() )
@ -647,9 +647,9 @@ void FListBox::onKeyPress (FKeyEvent* ev)
uInt inc_len = inc_search.getLength(); uInt inc_len = inc_search.getLength();
bool inc_found = false; bool inc_found = false;
listBoxItems::iterator iter = data.begin(); listBoxItems::iterator iter = itemlist.begin();
while ( iter != data.end() ) while ( iter != itemlist.end() )
{ {
if ( ! inc_found if ( ! inc_found
&& inc_search.toLower() && inc_search.toLower()
@ -1376,7 +1376,7 @@ void FListBox::drawList()
bool isFocus; bool isFocus;
listBoxItems::iterator iter; listBoxItems::iterator iter;
if ( data.empty() || getHeight() <= 2 || getWidth() <= 4 ) if ( itemlist.empty() || getHeight() <= 2 || getWidth() <= 4 )
return; return;
isFocus = ((flags & fc::focus) != 0); isFocus = ((flags & fc::focus) != 0);

View File

@ -233,7 +233,7 @@ class FListBox : public FWidget
, int index ); , int index );
// Data Members // Data Members
listBoxItems data; listBoxItems itemlist;
FWidget::data_ptr source_container; FWidget::data_ptr source_container;
convert_type conv_type; convert_type conv_type;
FScrollbar* vbar; FScrollbar* vbar;
@ -267,7 +267,7 @@ inline FListBox::FListBox ( Iterator first
, FWidget* parent ) , FWidget* parent )
: FWidget(parent) : FWidget(parent)
, convertToItem(0) , convertToItem(0)
, data() , itemlist()
, source_container(0) , source_container(0)
, conv_type(FListBox::no_convert) , conv_type(FListBox::no_convert)
, vbar(0) , vbar(0)
@ -305,7 +305,7 @@ inline FListBox::FListBox ( Container container
, FWidget* parent ) , FWidget* parent )
: FWidget(parent) : FWidget(parent)
, convertToItem(0) , convertToItem(0)
, data() , itemlist()
, source_container(0) , source_container(0)
, conv_type(FListBox::no_convert) , conv_type(FListBox::no_convert)
, vbar(0) , vbar(0)
@ -337,7 +337,7 @@ inline const char* FListBox::getClassName() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline uInt FListBox::getCount() const inline uInt FListBox::getCount() const
{ return uInt(data.size()); } { return uInt(itemlist.size()); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FListBoxItem FListBox::getItem (int index) inline FListBoxItem FListBox::getItem (int index)
@ -451,7 +451,7 @@ void FListBox::insert (Container container, LazyConverter convert)
size_t size = container->size(); size_t size = container->size();
if ( size > 0 ) if ( size > 0 )
data.resize(size); itemlist.resize(size);
recalculateVerticalBar(int(size)); recalculateVerticalBar(int(size));
} }
@ -459,7 +459,7 @@ void FListBox::insert (Container container, LazyConverter convert)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FListBox::listBoxItems::iterator FListBox::index2iterator (int index) inline FListBox::listBoxItems::iterator FListBox::index2iterator (int index)
{ {
listBoxItems::iterator iter = data.begin(); listBoxItems::iterator iter = itemlist.begin();
std::advance (iter, index); std::advance (iter, index);
return iter; return iter;
} }

View File

@ -18,7 +18,7 @@
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FListViewItem::FListViewItem (const FListViewItem& item) FListViewItem::FListViewItem (const FListViewItem& item)
: FObject(item.getParent()) : FObject(item.getParent())
, column_value(item.column_value) , column_list(item.column_list)
, data_pointer(item.data_pointer) , data_pointer(item.data_pointer)
, visible_lines(1) , visible_lines(1)
, expandable(false) , expandable(false)
@ -31,83 +31,76 @@ FListViewItem::FListViewItem (const FListViewItem& item)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FListViewItem::FListViewItem (FListViewItem* parent) FListViewItem::FListViewItem (FObjectIterator parent_iter)
: FObject(parent) : FObject(0)
, column_value() , column_list()
, data_pointer(0) , data_pointer(0)
, visible_lines(1) , visible_lines(1)
, expandable(false) , expandable(false)
, is_expand(false) , is_expand(false)
{ {
// Add the FListViewItem to the parent if ( *parent_iter )
if ( ! parent ) {
if ( (*parent_iter)->isInstanceOf("FListView") )
{
// Add FListViewItem to a FListView parent
FListView* parent = static_cast<FListView*>(*parent_iter);
parent->addChild (this);
parent->insert (this);
}
else if ( (*parent_iter)->isInstanceOf("FListViewItem") )
{
// Add FListViewItem to a FListViewItem parent
FListViewItem* parent = static_cast<FListViewItem*>(*parent_iter);
parent->addChild (this);
parent->expandable = true;
}
}
}
//----------------------------------------------------------------------
FListViewItem::FListViewItem ( const std::vector<FString>& cols
, FWidget::data_ptr data
, FObjectIterator parent_iter )
: FObject(0)
, column_list(cols)
, data_pointer(data)
, visible_lines(1)
, expandable(false)
, is_expand(false)
{
if ( cols.empty() )
return; return;
parent->addChild (this);
parent->expandable = true;
}
//----------------------------------------------------------------------
FListViewItem::FListViewItem (FListView* parent)
: FObject(parent)
, column_value()
, data_pointer(0)
, visible_lines(1)
, expandable(false)
, is_expand(false)
{
// Add the FListViewItem to the parent
if ( parent )
parent->insert (this);
}
//----------------------------------------------------------------------
FListViewItem::FListViewItem ( const std::vector<FString>& cols
, FWidget::data_ptr data
, FListView* parent )
: FObject(parent)
, column_value(cols)
, data_pointer(data)
, visible_lines(1)
, expandable(false)
, is_expand(false)
{
// Replace the control codes characters // Replace the control codes characters
std::vector<FString>::iterator iter = column_value.begin(); std::vector<FString>::iterator iter = column_list.begin();
while ( iter != column_value.end() ) while ( iter != column_list.end() )
{ {
*iter = iter->replaceControlCodes(); *iter = iter->replaceControlCodes();
++iter; ++iter;
} }
// Add the FListViewItem to the parent if ( parent_iter == FObjectIterator(0) )
if ( parent ) return;
parent->insert (this);
}
//---------------------------------------------------------------------- if ( *parent_iter )
FListViewItem::FListViewItem ( const std::vector<FString>& cols
, FWidget::data_ptr data
, FListViewItem* parent )
: FObject(parent)
, column_value(cols)
, data_pointer(data)
, visible_lines(1)
, expandable(false)
, is_expand(false)
{
// Replace the control codes characters
std::vector<FString>::iterator iter = column_value.begin();
while ( iter != column_value.end() )
{ {
*iter = iter->replaceControlCodes(); if ( (*parent_iter)->isInstanceOf("FListView") )
++iter; {
// Add FListViewItem to a FListView parent
FListView* parent = static_cast<FListView*>(*parent_iter);
parent->addChild (this);
parent->insert (this);
}
else if ( (*parent_iter)->isInstanceOf("FListViewItem") )
{
// Add FListViewItem to a FListViewItem parent
FListViewItem* parent = static_cast<FListViewItem*>(*parent_iter);
parent->addChild (this);
parent->expandable = true;
}
} }
if ( parent )
parent->expandable = true;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -120,20 +113,20 @@ FListViewItem::~FListViewItem() // destructor
FString FListViewItem::getText (int column) const FString FListViewItem::getText (int column) const
{ {
if ( column < 1 if ( column < 1
|| column_value.empty() || column_list.empty()
|| column > int(column_value.size()) ) || column > int(column_list.size()) )
return *fc::empty_string; return *fc::empty_string;
column--; // Convert column position to address offset (index) column--; // Convert column position to address offset (index)
return column_value[uInt(column)]; return column_list[uInt(column)];
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListViewItem::setText (int column, const FString& text) void FListViewItem::setText (int column, const FString& text)
{ {
if ( column < 1 if ( column < 1
|| column_value.empty() || column_list.empty()
|| column > int(column_value.size()) ) || column > int(column_list.size()) )
return; return;
FObject* parent = getParent(); FObject* parent = getParent();
@ -152,7 +145,7 @@ void FListViewItem::setText (int column, const FString& text)
} }
} }
column_value[uInt(column)] = text; column_list[uInt(column)] = text;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -197,7 +190,7 @@ int FListViewItem::getVisibleLines()
} }
FObjectList children = this->getChildren(); FObjectList children = this->getChildren();
FObjectList::const_iterator iter = children.begin(); constFObjectIterator iter = children.begin();
while ( iter != children.end() ) while ( iter != children.end() )
{ {
@ -218,7 +211,9 @@ int FListViewItem::getVisibleLines()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FListView::FListView (FWidget* parent) FListView::FListView (FWidget* parent)
: FWidget(parent) : FWidget(parent)
, data() , root()
, selflist()
, itemlist()
, header() , header()
, headerline() , headerline()
, vbar(0) , vbar(0)
@ -295,7 +290,7 @@ void FListView::setColumnAlignment (int column, fc::text_alignment align)
// Set the alignment for a column // Set the alignment for a column
if ( column < 1 || header.empty() || column > int(header.size()) ) if ( column < 1 || header.empty() || column > int(header.size()) )
{beep();return;} return;
column--; // Convert column position to address offset (index) column--; // Convert column position to address offset (index)
header[uInt(column)].alignment = align; header[uInt(column)].alignment = align;
@ -342,70 +337,107 @@ int FListView::addColumn (const FString& label, int width)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::insert (FListViewItem* item) FObject::FObjectIterator FListView::insert ( FListViewItem* item
, FObjectIterator parent_iter )
{ {
static const int padding_space = 1; static const int padding_space = 1;
int line_width = padding_space; // leading space int line_width = padding_space; // leading space
uInt column_idx = 0; uInt column_idx = 0;
uInt entries = uInt(item->column_value.size()); uInt entries = uInt(item->column_list.size());
headerItems::iterator iter; FObjectIterator item_iter;
headerItems::iterator header_iter;
iter = header.begin(); if ( parent_iter == FObjectIterator(0) )
return FObjectIterator(0);
while ( iter != header.end() ) header_iter = header.begin();
while ( header_iter != header.end() )
{ {
int width = (*iter).width; int width = (*header_iter).width;
bool fixed_width = (*iter).fixed_width; bool fixed_width = (*header_iter).fixed_width;
if ( ! fixed_width ) if ( ! fixed_width )
{ {
int len; int len;
if ( column_idx < entries ) if ( column_idx < entries )
len = int(item->column_value[column_idx].getLength()); len = int(item->column_list[column_idx].getLength());
else else
len = 0; len = 0;
if ( len > width ) if ( len > width )
(*iter).width = len; (*header_iter).width = len;
} }
line_width += (*iter).width + padding_space; // width + tailing space line_width += (*header_iter).width + padding_space; // width + tailing space
column_idx++; column_idx++;
++iter; ++header_iter;
} }
recalculateHorizontalBar (line_width); recalculateHorizontalBar (line_width);
data.push_back (item);
int element_count = int(data.size()); if ( parent_iter == root )
{
addChild (item);
itemlist.push_back (item);
item_iter = --itemlist.end();
}
else if ( *parent_iter )
{
if ( (*parent_iter)->isInstanceOf("FListView") )
{
// Add FListViewItem to a FListView parent
addChild (item);
FListView* parent = static_cast<FListView*>(*parent_iter);
parent->itemlist.push_back (item);
item_iter = --parent->itemlist.end();
}
else if ( (*parent_iter)->isInstanceOf("FListViewItem") )
{
// Add FListViewItem to a FListViewItem parent
FListViewItem* parent = static_cast<FListViewItem*>(*parent_iter);
parent->expandable = true;
parent->addChild (item);
FObjectList parent_obj = parent->getChildren();
item_iter = --parent_obj.end();
}
}
int element_count = int(itemlist.size());
recalculateVerticalBar (element_count); recalculateVerticalBar (element_count);
return item_iter;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::insert ( const std::vector<FString>& cols FObject::FObjectIterator FListView::insert ( const std::vector<FString>& cols
, data_ptr d , data_ptr d
, FListView* parent ) , FObjectIterator parent_iter )
{ {
FListViewItem* item;
if ( ! *parent_iter )
parent_iter = root;
try try
{ {
if ( parent == 0 ) item = new FListViewItem (cols, d, FObjectIterator(0));
new FListViewItem (cols, d, this);
else
new FListViewItem (cols, d, parent);
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
std::cerr << "not enough memory to alloc " << ex.what() << std::endl; std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
return; return FObjectIterator(0);
} }
return insert(item, parent_iter);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::insert ( const std::vector<long>& cols FObject::FObjectIterator FListView::insert ( const std::vector<long>& cols
, data_ptr d , data_ptr d
, FListView* parent ) , FObjectIterator parent_iter )
{ {
FObjectIterator item_iter;
std::vector<FString> str_cols; std::vector<FString> str_cols;
if ( ! cols.empty() ) if ( ! cols.empty() )
@ -414,16 +446,15 @@ void FListView::insert ( const std::vector<long>& cols
str_cols.push_back (FString().setNumber(cols[i])); str_cols.push_back (FString().setNumber(cols[i]));
} }
if ( parent == 0 ) item_iter = insert (str_cols, d, parent_iter);
insert (str_cols, d, this);
else return item_iter;
insert (str_cols, d, parent);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::onKeyPress (FKeyEvent* ev) void FListView::onKeyPress (FKeyEvent* ev)
{ {
int element_count = int(data.size()); int element_count = int(itemlist.size());
int current_before = current; int current_before = current;
int xoffset_before = xoffset; int xoffset_before = xoffset;
int xoffset_end = max_line_width - getClientWidth(); int xoffset_end = max_line_width - getClientWidth();
@ -600,8 +631,8 @@ void FListView::onMouseDown (FMouseEvent* ev)
{ {
current = yoffset + mouse_y - 1; current = yoffset + mouse_y - 1;
if ( current > int(data.size()) ) if ( current > int(itemlist.size()) )
current = int(data.size()); current = int(itemlist.size());
if ( isVisible() ) if ( isVisible() )
drawList(); drawList();
@ -663,8 +694,8 @@ void FListView::onMouseMove (FMouseEvent* ev)
{ {
current = yoffset + mouse_y - 1; current = yoffset + mouse_y - 1;
if ( current > int(data.size()) ) if ( current > int(itemlist.size()) )
current = int(data.size()); current = int(itemlist.size());
if ( isVisible() ) if ( isVisible() )
drawList(); drawList();
@ -710,7 +741,7 @@ void FListView::onMouseMove (FMouseEvent* ev)
&& scroll_distance < getClientHeight() ) && scroll_distance < getClientHeight() )
scroll_distance++; scroll_distance++;
if ( ! scroll_timer && current < int(data.size()) ) if ( ! scroll_timer && current < int(itemlist.size()) )
{ {
scroll_timer = true; scroll_timer = true;
addTimer(scroll_repeat); addTimer(scroll_repeat);
@ -721,7 +752,7 @@ void FListView::onMouseMove (FMouseEvent* ev)
drag_scroll = fc::scrollDown; drag_scroll = fc::scrollDown;
} }
if ( current == int(data.size()) ) if ( current == int(itemlist.size()) )
{ {
delOwnTimer(); delOwnTimer();
drag_scroll = fc::noScroll; drag_scroll = fc::noScroll;
@ -751,7 +782,7 @@ void FListView::onMouseDoubleClick (FMouseEvent* ev)
if ( mouse_x > 1 && mouse_x < getWidth() if ( mouse_x > 1 && mouse_x < getWidth()
&& mouse_y > 1 && mouse_y < getHeight() ) && mouse_y > 1 && mouse_y < getHeight() )
{ {
if ( yoffset + mouse_y - 1 > int(data.size()) ) if ( yoffset + mouse_y - 1 > int(itemlist.size()) )
return; return;
processClick(); processClick();
@ -761,7 +792,7 @@ void FListView::onMouseDoubleClick (FMouseEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::onTimer (FTimerEvent*) void FListView::onTimer (FTimerEvent*)
{ {
int element_count = int(data.size()); int element_count = int(itemlist.size());
int current_before = current; int current_before = current;
int yoffset_before = yoffset; int yoffset_before = yoffset;
int yoffset_end = element_count - getClientHeight(); int yoffset_end = element_count - getClientHeight();
@ -832,7 +863,7 @@ void FListView::onTimer (FTimerEvent*)
void FListView::onWheel (FWheelEvent* ev) void FListView::onWheel (FWheelEvent* ev)
{ {
int element_count, current_before, yoffset_before, yoffset_end, wheel; int element_count, current_before, yoffset_before, yoffset_end, wheel;
element_count = int(data.size()); element_count = int(itemlist.size());
current_before = current; current_before = current;
yoffset_before = yoffset; yoffset_before = yoffset;
yoffset_end = element_count - getClientHeight(); yoffset_end = element_count - getClientHeight();
@ -933,7 +964,7 @@ void FListView::onFocusOut (FFocusEvent*)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::adjustYOffset() void FListView::adjustYOffset()
{ {
int element_count = int(data.size()); int element_count = int(itemlist.size());
if ( yoffset > element_count - getClientHeight() ) if ( yoffset > element_count - getClientHeight() )
yoffset = element_count - getClientHeight(); yoffset = element_count - getClientHeight();
@ -955,7 +986,7 @@ void FListView::adjustSize()
FWidget::adjustSize(); FWidget::adjustSize();
adjustYOffset(); adjustYOffset();
element_count = int(data.size()); element_count = int(itemlist.size());
vbar->setMaximum (element_count - getClientHeight()); vbar->setMaximum (element_count - getClientHeight());
vbar->setPageSize (element_count, getClientHeight()); vbar->setPageSize (element_count, getClientHeight());
vbar->setX (getWidth()); vbar->setX (getWidth());
@ -984,6 +1015,9 @@ void FListView::adjustSize()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::init() void FListView::init()
{ {
selflist.push_back(this);
root = selflist.begin();
setForegroundColor (wc.dialog_fg); setForegroundColor (wc.dialog_fg);
setBackgroundColor (wc.dialog_bg); setBackgroundColor (wc.dialog_bg);
@ -1203,17 +1237,17 @@ void FListView::drawList()
{ {
uInt start, end; uInt start, end;
bool isFocus; bool isFocus;
listViewItems::const_iterator iter; constFObjectIterator iter;
if ( data.empty() || getHeight() <= 2 || getWidth() <= 4 ) if ( itemlist.empty() || getHeight() <= 2 || getWidth() <= 4 )
return; return;
isFocus = ((flags & fc::focus) != 0); isFocus = ((flags & fc::focus) != 0);
start = 0; start = 0;
end = uInt(getHeight() - 2); end = uInt(getHeight() - 2);
if ( end > data.size() ) if ( end > itemlist.size() )
end = uInt(data.size()); end = uInt(itemlist.size());
iter = index2iterator(int(start) + yoffset); iter = index2iterator(int(start) + yoffset);
@ -1222,6 +1256,7 @@ void FListView::drawList()
bool isCurrentLine = bool( y + uInt(yoffset) + 1 == uInt(current) ); bool isCurrentLine = bool( y + uInt(yoffset) + 1 == uInt(current) );
setPrintPos (2, 2 + int(y)); setPrintPos (2, 2 + int(y));
setColor (wc.list_fg, wc.list_bg); setColor (wc.list_fg, wc.list_bg);
FListViewItem* item = static_cast<FListViewItem*>(*iter);
if ( isCurrentLine ) if ( isCurrentLine )
{ {
@ -1253,22 +1288,30 @@ void FListView::drawList()
} }
// print the entry // print the entry
FString line = " "; FString line;
if ( tree_view /*&& (*iter)->expandable*/ ) if ( tree_view )
{ {
line += ""; if ( item->expandable )
{
line = wchar_t(fc::BlackRightPointingPointer);
line += L' ';
}
else
line = L" ";
} }
else
line = L" ";
// print columns // print columns
if ( ! (*iter)->column_value.empty() ) if ( ! item->column_list.empty() )
{ {
for (uInt i = 0; i < (*iter)->column_value.size(); ) for (uInt i = 0; i < item->column_list.size(); )
{ {
static const int leading_space = 1; static const int leading_space = 1;
static const int ellipsis_length = 2; static const int ellipsis_length = 2;
const FString& text = (*iter)->column_value[i]; const FString& text = item->column_list[i];
int width = header[i].width; int width = header[i].width;
uInt txt_length = text.getLength(); uInt txt_length = text.getLength();
// Increment the value of i for the column position // Increment the value of i for the column position
@ -1277,29 +1320,34 @@ void FListView::drawList()
fc::text_alignment align = getColumnAlignment(int(i)); fc::text_alignment align = getColumnAlignment(int(i));
uInt align_offset = getAlignOffset (align, txt_length, uInt(width)); uInt align_offset = getAlignOffset (align, txt_length, uInt(width));
if ( tree_view && i == 1 )
{
width--;
}
// Insert alignment spaces // Insert alignment spaces
if ( align_offset > 0 ) if ( align_offset > 0 )
line += FString(align_offset, ' '); line += FString(align_offset, L' ');
if ( align_offset + txt_length <= uInt(width) ) if ( align_offset + txt_length <= uInt(width) )
{ {
// Insert text and tailing space // Insert text and tailing space
line += text.left(width); line += text.left(width);
line += FString ( leading_space + width line += FString ( leading_space + width
- int(align_offset + txt_length), ' '); - int(align_offset + txt_length), L' ');
} }
else if ( align == fc::alignRight ) else if ( align == fc::alignRight )
{ {
// Ellipse right align text // Ellipse right align text
line += FString (".."); line += FString (L"..");
line += text.right(width - ellipsis_length); line += text.right(width - ellipsis_length);
line += ' '; line += L' ';
} }
else else
{ {
// Ellipse left align text and center text // Ellipse left align text and center text
line += text.left(width - ellipsis_length); line += text.left(width - ellipsis_length);
line += FString (".. "); line += FString (L".. ");
} }
} }
} }
@ -1367,7 +1415,7 @@ void FListView::cb_VBarChange (FWidget*, data_ptr)
{ {
FScrollbar::sType scrollType; FScrollbar::sType scrollType;
int distance = 1; int distance = 1;
int element_count = int(data.size()); int element_count = int(itemlist.size());
int yoffset_before = yoffset; int yoffset_before = yoffset;
int yoffset_end = element_count - getClientHeight(); int yoffset_end = element_count - getClientHeight();
scrollType = vbar->getScrollType(); scrollType = vbar->getScrollType();

View File

@ -54,12 +54,10 @@ class FListViewItem : public FObject
FListViewItem (const FListViewItem&); // copy constructor FListViewItem (const FListViewItem&); // copy constructor
explicit FListViewItem (FListViewItem*); explicit FListViewItem (FListViewItem*);
explicit FListViewItem (FListView*); explicit FListViewItem (FListView*);
explicit FListViewItem (FObjectIterator);
FListViewItem ( const std::vector<FString>& FListViewItem ( const std::vector<FString>&
, FWidget::data_ptr = 0 , FWidget::data_ptr
, FListView* = 0 ); , FObjectIterator );
FListViewItem ( const std::vector<FString>&
, FWidget::data_ptr = 0
, FListViewItem* = 0 );
// Destructor // Destructor
~FListViewItem(); ~FListViewItem();
@ -91,7 +89,7 @@ class FListViewItem : public FObject
int getVisibleLines(); int getVisibleLines();
// Data Member // Data Member
std::vector<FString> column_value; std::vector<FString> column_list;
FWidget::data_ptr data_pointer; FWidget::data_ptr data_pointer;
int visible_lines; int visible_lines;
bool expandable; bool expandable;
@ -110,7 +108,7 @@ inline const char* FListViewItem::getClassName() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline uInt FListViewItem::getColumnCount() const inline uInt FListViewItem::getColumnCount() const
{ return uInt(column_value.size()); } { return uInt(column_list.size()); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FListViewItem::isExpand() inline bool FListViewItem::isExpand()
@ -131,9 +129,6 @@ inline bool FListViewItem::isExpandable()
class FListView : public FWidget class FListView : public FWidget
{ {
public: public:
// Typedef
typedef std::vector<FListViewItem*> listViewItems;
// Using-declaration // Using-declaration
using FWidget::setGeometry; using FWidget::setGeometry;
@ -147,7 +142,7 @@ class FListView : public FWidget
const char* getClassName() const; const char* getClassName() const;
fc::text_alignment getColumnAlignment (int) const; fc::text_alignment getColumnAlignment (int) const;
FString getColumnText (int) const; FString getColumnText (int) const;
FListViewItem* getCurrentItem() const; FListViewItem* getCurrentItem();
// Mutators // Mutators
void setGeometry (int, int, int, int, bool = true); void setGeometry (int, int, int, int, bool = true);
@ -159,13 +154,22 @@ class FListView : public FWidget
// Methods // Methods
virtual int addColumn (const FString&, int = USE_MAX_SIZE); virtual int addColumn (const FString&, int = USE_MAX_SIZE);
void insert (FListViewItem*); FObjectIterator insert (FListViewItem*);
void insert ( const std::vector<FString>& FObjectIterator insert (FListViewItem*, FObjectIterator);
, data_ptr = 0 FObjectIterator insert ( const std::vector<FString>&
, FListView* = 0 ); , data_ptr = 0 );
void insert ( const std::vector<long>& FObjectIterator insert ( const std::vector<FString>&
, data_ptr = 0 , FObjectIterator );
, FListView* = 0 ); FObjectIterator insert ( const std::vector<FString>&
, data_ptr
, FObjectIterator );
FObjectIterator insert ( const std::vector<long>&
, data_ptr = 0 );
FObjectIterator insert ( const std::vector<long>&
, FObjectIterator );
FObjectIterator insert ( const std::vector<long>&
, data_ptr
, FObjectIterator );
// Event handlers // Event handlers
void onKeyPress (FKeyEvent*); void onKeyPress (FKeyEvent*);
@ -225,14 +229,16 @@ class FListView : public FWidget
void recalculateVerticalBar (int); void recalculateVerticalBar (int);
void processClick(); void processClick();
void processChanged(); void processChanged();
listViewItems::iterator index2iterator (int); FObjectIterator index2iterator (int);
// Callback methods // Callback methods
void cb_VBarChange (FWidget*, data_ptr); void cb_VBarChange (FWidget*, data_ptr);
void cb_HBarChange (FWidget*, data_ptr); void cb_HBarChange (FWidget*, data_ptr);
// Data Members // Data Members
listViewItems data; FObjectIterator root;
FObjectList selflist;
FObjectList itemlist;
headerItems header; headerItems header;
FTermBuffer headerline; FTermBuffer headerline;
FScrollbar* vbar; FScrollbar* vbar;
@ -260,8 +266,12 @@ inline const char* FListView::getClassName() const
{ return "FListView"; } { return "FListView"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FListViewItem* FListView::getCurrentItem() const inline FListViewItem* FListView::getCurrentItem()
{ return data[uInt(current-1)]; } {
FObjectIterator iter = itemlist.begin();
std::advance (iter, current - 1);
return static_cast<FListViewItem*>(*iter);
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FListView::setTreeView (bool on) inline bool FListView::setTreeView (bool on)
@ -276,9 +286,35 @@ inline bool FListView::unsetTreeView()
{ return setTreeView(false); } { return setTreeView(false); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FListView::listViewItems::iterator FListView::index2iterator (int index) inline FObject::FObjectIterator FListView::insert (FListViewItem* item)
{ return insert (item, root); }
//----------------------------------------------------------------------
inline FObject::FObjectIterator
FListView::insert ( const std::vector<FString>& cols, data_ptr d )
{ return insert (cols, d, root); }
//----------------------------------------------------------------------
inline FObject::FObjectIterator
FListView::insert ( const std::vector<FString>& cols
, FObjectIterator parent_iter )
{ return insert (cols, 0, parent_iter); }
//----------------------------------------------------------------------
inline FObject::FObjectIterator
FListView::insert ( const std::vector<long>& cols, data_ptr d )
{ return insert (cols, d, root); }
//----------------------------------------------------------------------
inline FObject::FObjectIterator
FListView::insert ( const std::vector<long>& cols
, FObjectIterator parent_iter )
{ return insert (cols, 0, parent_iter); }
//----------------------------------------------------------------------
inline FObject::FObjectIterator FListView::index2iterator (int index)
{ {
listViewItems::iterator iter = data.begin(); FObjectIterator iter = itemlist.begin();
std::advance (iter, index); std::advance (iter, index);
return iter; return iter;
} }

View File

@ -89,7 +89,7 @@ inline uInt FMenuList::getCount() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FMenuItem* FMenuList::getItem (int index) const inline FMenuItem* FMenuList::getItem (int index) const
{ return (index > 0) ? item_list[uInt(index-1)] : 0; } { return (index > 0) ? item_list[uInt(index - 1)] : 0; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FMenuItem* FMenuList::getSelectedItem() const inline FMenuItem* FMenuList::getSelectedItem() const
@ -97,11 +97,11 @@ inline FMenuItem* FMenuList::getSelectedItem() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FMenuList::enableItem (int index) inline void FMenuList::enableItem (int index)
{ item_list[uInt(index-1)]->setEnable(); } { item_list[uInt(index - 1)]->setEnable(); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FMenuList::disableItem (int index) inline void FMenuList::disableItem (int index)
{ item_list[uInt(index-1)]->unsetEnable(); } { item_list[uInt(index - 1)]->unsetEnable(); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FMenuList::setSelectedItem (FMenuItem* menuitem) inline void FMenuList::setSelectedItem (FMenuItem* menuitem)
@ -109,7 +109,7 @@ inline void FMenuList::setSelectedItem (FMenuItem* menuitem)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FMenuList::isSelected(int index) const inline bool FMenuList::isSelected(int index) const
{ return (index > 0) ? item_list[uInt(index-1)]->isSelected() : false; } { return (index > 0) ? item_list[uInt(index - 1)]->isSelected() : false; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FMenuList::hasSelectedItem() const inline bool FMenuList::hasSelectedItem() const

View File

@ -85,7 +85,7 @@ FObject::~FObject() // destructor
if ( ! children.empty() ) if ( ! children.empty() )
{ {
FObjectList::const_iterator iter; constFObjectIterator iter;
iter = children.begin(); iter = children.begin();
while ( iter != children.end() ) while ( iter != children.end() )
@ -108,7 +108,7 @@ FObject* FObject::getChild (int index) const
if ( index < 0 || index >= numOfChildren() ) if ( index < 0 || index >= numOfChildren() )
return 0; return 0;
FObjectList::const_iterator iter; constFObjectIterator iter;
iter = children_list.begin(); iter = children_list.begin();
std::advance (iter, index); std::advance (iter, index);
return *iter; return *iter;

View File

@ -35,6 +35,8 @@ class FObject
public: public:
// Typedef // Typedef
typedef std::list<FObject*> FObjectList; typedef std::list<FObject*> FObjectList;
typedef FObjectList::iterator FObjectIterator;
typedef FObjectList::const_iterator constFObjectIterator;
// Constructor // Constructor
explicit FObject (FObject* = 0); explicit FObject (FObject* = 0);

View File

@ -40,33 +40,31 @@ class FOptiAttr
{ {
struct struct
{ {
// Attribute byte #0
uInt8 bold : 1; // bold
uInt8 dim : 1; // dim
uInt8 italic : 1; // italic
uInt8 underline : 1; // underline
uInt8 blink : 1; // blink
uInt8 reverse : 1; // reverse
uInt8 standout : 1; // standout
uInt8 invisible : 1; // invisible
// Attribute byte #1 // Attribute byte #1
uChar bold : 1; // bold uInt8 protect : 1; // protect mode
uChar dim : 1; // dim uInt8 crossed_out : 1; // crossed out
uChar italic : 1; // italic uInt8 dbl_underline : 1; // double underline
uChar underline : 1; // underline uInt8 alt_charset : 1; // alternate character set (vt100)
uChar blink : 1; // blink uInt8 pc_charset : 1; // pc character set (CP437)
uChar reverse : 1; // reverse uInt8 transparent : 1; // transparent
uChar standout : 1; // standout uInt8 trans_shadow : 1; // transparent shadow
uChar invisible : 1; // invisible uInt8 inherit_bg : 1; // inherit background
// Attribute byte #2 // Attribute byte #2
uChar protect : 1; // protect mode uInt8 no_changes : 1; // no changes required
uChar crossed_out : 1; // crossed out uInt8 printed : 1; // is printed to VTerm
uChar dbl_underline : 1; // double underline uInt8 : 6; // padding bits
uChar alt_charset : 1; // alternate character set (vt100)
uChar pc_charset : 1; // pc character set (CP437)
uChar transparent : 1; // transparent
uChar trans_shadow : 1; // transparent shadow
uChar inherit_bg : 1; // inherit background
// Attribute byte #3
uChar no_changes : 1; // no changes required
uChar printed : 1; // is printed to VTerm
uChar : 6; // padding bits
} bit; } bit;
uChar byte1; uInt8 byte[3];
uChar byte2;
uChar byte3;
} attr; } attr;
} char_data; } char_data;
@ -277,8 +275,8 @@ inline bool operator == ( const FOptiAttr::char_data& lhs,
return lhs.code == rhs.code return lhs.code == rhs.code
&& lhs.fg_color == rhs.fg_color && lhs.fg_color == rhs.fg_color
&& lhs.bg_color == rhs.bg_color && lhs.bg_color == rhs.bg_color
&& lhs.attr.byte1 == rhs.attr.byte1 && lhs.attr.byte[0] == rhs.attr.byte[0]
&& lhs.attr.byte2 == rhs.attr.byte2; && lhs.attr.byte[1] == rhs.attr.byte[1];
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -92,11 +92,11 @@ inline bool operator != (const FPoint& p1, const FPoint& p2)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FPoint operator + (const FPoint& p1, const FPoint& p2) inline FPoint operator + (const FPoint& p1, const FPoint& p2)
{ return FPoint(p1.xpos+p2.xpos, p1.ypos+p2.ypos); } { return FPoint(p1.xpos + p2.xpos, p1.ypos + p2.ypos); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FPoint operator - (const FPoint& p1, const FPoint& p2) inline FPoint operator - (const FPoint& p1, const FPoint& p2)
{ return FPoint(p1.xpos-p2.xpos, p1.ypos-p2.ypos); } { return FPoint(p1.xpos - p2.xpos, p1.ypos - p2.ypos); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FPoint operator - (const FPoint& p) inline FPoint operator - (const FPoint& p)

View File

@ -242,7 +242,7 @@ inline const char* FStatusBar::getClassName() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FStatusKey* FStatusBar::getStatusKey (int index) const inline FStatusKey* FStatusBar::getStatusKey (int index) const
{ return key_list[uInt(index-1)]; } { return key_list[uInt(index - 1)]; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline uInt FStatusBar::getCount() const inline uInt FStatusBar::getCount() const
@ -250,15 +250,15 @@ inline uInt FStatusBar::getCount() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FStatusBar::activateKey (int index) inline void FStatusBar::activateKey (int index)
{ key_list[uInt(index-1)]->setActive(); } { key_list[uInt(index - 1)]->setActive(); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FStatusBar::deactivateKey (int index) inline void FStatusBar::deactivateKey (int index)
{ key_list[uInt(index-1)]->unsetActive(); } { key_list[uInt(index - 1)]->unsetActive(); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FStatusBar::isActivated(int index) const inline bool FStatusBar::isActivated(int index) const
{ return key_list[uInt(index-1)]->isActivated(); } { return key_list[uInt(index - 1)]->isActivated(); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString FStatusBar::getMessage() const inline FString FStatusBar::getMessage() const

View File

@ -360,7 +360,7 @@ inline wchar_t FString::front() const
inline wchar_t FString::back() const inline wchar_t FString::back() const
{ {
assert( ! isEmpty() ); assert( ! isEmpty() );
return string[length-1]; return string[length - 1];
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -480,27 +480,12 @@ int FVTerm::print (term_area* area, const FString& s)
int ay = area->cursor_y - 1; int ay = area->cursor_y - 1;
char_data nc; // next character char_data nc; // next character
nc.code = *p; nc.code = *p;
nc.fg_color = next_attribute.fg_color; nc.fg_color = next_attribute.fg_color;
nc.bg_color = next_attribute.bg_color; nc.bg_color = next_attribute.bg_color;
nc.attr.bit.bold = next_attribute.attr.bit.bold; nc.attr.byte[0] = next_attribute.attr.byte[0];
nc.attr.bit.dim = next_attribute.attr.bit.dim; nc.attr.byte[1] = next_attribute.attr.byte[1];
nc.attr.bit.italic = next_attribute.attr.bit.italic; nc.attr.byte[2] = 0;
nc.attr.bit.underline = next_attribute.attr.bit.underline;
nc.attr.bit.blink = next_attribute.attr.bit.blink;
nc.attr.bit.reverse = next_attribute.attr.bit.reverse;
nc.attr.bit.standout = next_attribute.attr.bit.standout;
nc.attr.bit.invisible = next_attribute.attr.bit.invisible;
nc.attr.bit.protect = next_attribute.attr.bit.protect;
nc.attr.bit.crossed_out = next_attribute.attr.bit.crossed_out;
nc.attr.bit.dbl_underline = next_attribute.attr.bit.dbl_underline;
nc.attr.bit.alt_charset = next_attribute.attr.bit.alt_charset;
nc.attr.bit.pc_charset = next_attribute.attr.bit.pc_charset;
nc.attr.bit.transparent = next_attribute.attr.bit.transparent;
nc.attr.bit.trans_shadow = next_attribute.attr.bit.trans_shadow;
nc.attr.bit.inherit_bg = next_attribute.attr.bit.inherit_bg;
nc.attr.bit.no_changes = false;
nc.attr.bit.printed = false;
if ( area->cursor_x > 0 if ( area->cursor_x > 0
&& area->cursor_y > 0 && area->cursor_y > 0
@ -730,27 +715,12 @@ int FVTerm::print (term_area* area, register int c)
ax = area->cursor_x - 1; ax = area->cursor_x - 1;
ay = area->cursor_y - 1; ay = area->cursor_y - 1;
nc.code = c; nc.code = c;
nc.fg_color = next_attribute.fg_color; nc.fg_color = next_attribute.fg_color;
nc.bg_color = next_attribute.bg_color; nc.bg_color = next_attribute.bg_color;
nc.attr.bit.bold = next_attribute.attr.bit.bold; nc.attr.byte[0] = next_attribute.attr.byte[0];
nc.attr.bit.dim = next_attribute.attr.bit.dim; nc.attr.byte[1] = next_attribute.attr.byte[1];
nc.attr.bit.italic = next_attribute.attr.bit.italic; nc.attr.byte[2] = 0;
nc.attr.bit.underline = next_attribute.attr.bit.underline;
nc.attr.bit.blink = next_attribute.attr.bit.blink;
nc.attr.bit.reverse = next_attribute.attr.bit.reverse;
nc.attr.bit.standout = next_attribute.attr.bit.standout;
nc.attr.bit.invisible = next_attribute.attr.bit.invisible;
nc.attr.bit.protect = next_attribute.attr.bit.protect;
nc.attr.bit.crossed_out = next_attribute.attr.bit.crossed_out;
nc.attr.bit.dbl_underline = next_attribute.attr.bit.dbl_underline;
nc.attr.bit.alt_charset = next_attribute.attr.bit.alt_charset;
nc.attr.bit.pc_charset = next_attribute.attr.bit.pc_charset;
nc.attr.bit.transparent = next_attribute.attr.bit.transparent;
nc.attr.bit.trans_shadow = next_attribute.attr.bit.trans_shadow;
nc.attr.bit.inherit_bg = next_attribute.attr.bit.inherit_bg;
nc.attr.bit.no_changes = false;
nc.attr.bit.printed = false;
if ( area->cursor_x > 0 if ( area->cursor_x > 0
&& area->cursor_y > 0 && area->cursor_y > 0
@ -1024,27 +994,12 @@ void FVTerm::resizeArea ( int offset_left, int offset_top
area->bottom_shadow = bsh; area->bottom_shadow = bsh;
area->has_changes = false; area->has_changes = false;
default_char.code = ' '; default_char.code = ' ';
default_char.fg_color = fc::Default; default_char.fg_color = fc::Default;
default_char.bg_color = fc::Default; default_char.bg_color = fc::Default;
default_char.attr.bit.bold = 0; default_char.attr.byte[0] = 0;
default_char.attr.bit.dim = 0; default_char.attr.byte[1] = 0;
default_char.attr.bit.italic = 0; default_char.attr.byte[3] = 0;
default_char.attr.bit.underline = 0;
default_char.attr.bit.blink = 0;
default_char.attr.bit.reverse = 0;
default_char.attr.bit.standout = 0;
default_char.attr.bit.invisible = 0;
default_char.attr.bit.protect = 0;
default_char.attr.bit.crossed_out = 0;
default_char.attr.bit.dbl_underline = 0;
default_char.attr.bit.alt_charset = 0;
default_char.attr.bit.pc_charset = 0;
default_char.attr.bit.transparent = 0;
default_char.attr.bit.trans_shadow = 0;
default_char.attr.bit.inherit_bg = 0;
default_char.attr.bit.no_changes = 0;
default_char.attr.bit.printed = 0;
std::fill_n (area->text, area_size, default_char); std::fill_n (area->text, area_size, default_char);

View File

@ -172,7 +172,7 @@ FWidget* FWidget::getFirstFocusableWidget (FObjectList children)
if ( children.empty() ) if ( children.empty() )
return 0; return 0;
FObjectList::const_iterator iter, end; constFObjectIterator iter, end;
iter = children.begin(); iter = children.begin();
end = children.end(); end = children.end();
@ -198,7 +198,7 @@ FWidget* FWidget::getLastFocusableWidget (FObjectList children)
if ( children.empty() ) if ( children.empty() )
return 0; return 0;
FObjectList::const_iterator iter, begin; constFObjectIterator iter, begin;
begin = children.begin(); begin = children.begin();
iter = children.end(); iter = children.end();
@ -839,7 +839,7 @@ FWidget* FWidget::childWidgetAt (FWidget* p, int x, int y)
if ( p && p->hasChildren() ) if ( p && p->hasChildren() )
{ {
FObjectList children; FObjectList children;
FObjectList::const_iterator iter, end; constFObjectIterator iter, end;
children = p->getChildren(); children = p->getChildren();
iter = children.begin(); iter = children.begin();
@ -875,7 +875,7 @@ FWidget* FWidget::childWidgetAt (FWidget* p, int x, int y)
int FWidget::numOfFocusableChildren() int FWidget::numOfFocusableChildren()
{ {
FObjectList children; FObjectList children;
FObjectList::const_iterator iter, end; constFObjectIterator iter, end;
if ( ! this->hasChildren() ) if ( ! this->hasChildren() )
return 0; return 0;
@ -1100,25 +1100,11 @@ void FWidget::redraw()
{ {
// draw windows // draw windows
FOptiAttr::char_data default_char; FOptiAttr::char_data default_char;
default_char.code = ' '; default_char.code = ' ';
default_char.fg_color = fc::Black; default_char.fg_color = fc::Black;
default_char.bg_color = fc::Black; default_char.bg_color = fc::Black;
default_char.attr.bit.bold = 0; default_char.attr.byte[0] = 0;
default_char.attr.bit.dim = 0; default_char.attr.byte[1] = 0;
default_char.attr.bit.italic = 0;
default_char.attr.bit.underline = 0;
default_char.attr.bit.blink = 0;
default_char.attr.bit.reverse = 0;
default_char.attr.bit.standout = 0;
default_char.attr.bit.invisible = 0;
default_char.attr.bit.protect = 0;
default_char.attr.bit.crossed_out = 0;
default_char.attr.bit.dbl_underline = 0;
default_char.attr.bit.alt_charset = 0;
default_char.attr.bit.pc_charset = 0;
default_char.attr.bit.transparent = 0;
default_char.attr.bit.trans_shadow = 0;
default_char.attr.bit.inherit_bg = 0;
if ( window_list && ! window_list->empty() ) if ( window_list && ! window_list->empty() )
{ {
@ -1148,7 +1134,7 @@ void FWidget::redraw()
if ( this->hasChildren() ) if ( this->hasChildren() )
{ {
FObjectList children; FObjectList children;
FObjectList::const_iterator iter, end; constFObjectIterator iter, end;
children = this->getChildren(); children = this->getChildren();
iter = children.begin(); iter = children.begin();
@ -1246,7 +1232,7 @@ void FWidget::show()
if ( this->hasChildren() ) if ( this->hasChildren() )
{ {
FObjectList children; FObjectList children;
FObjectList::const_iterator iter, end; constFObjectIterator iter, end;
children = this->getChildren(); children = this->getChildren();
iter = children.begin(); iter = children.begin();
@ -1303,7 +1289,7 @@ void FWidget::hide()
bool FWidget::focusFirstChild() bool FWidget::focusFirstChild()
{ {
FObjectList children; FObjectList children;
FObjectList::const_iterator iter, end; constFObjectIterator iter, end;
if ( ! this->hasChildren() ) if ( ! this->hasChildren() )
return false; return false;
@ -1349,7 +1335,7 @@ bool FWidget::focusFirstChild()
bool FWidget::focusLastChild() bool FWidget::focusLastChild()
{ {
FObjectList children; FObjectList children;
FObjectList::const_iterator iter, begin; constFObjectIterator iter, begin;
if ( ! this->hasChildren() ) if ( ! this->hasChildren() )
return false; return false;
@ -1840,7 +1826,7 @@ void FWidget::adjustSize()
if ( this->hasChildren() ) if ( this->hasChildren() )
{ {
FObjectList children; FObjectList children;
FObjectList::const_iterator iter, end; constFObjectIterator iter, end;
children = this->getChildren(); children = this->getChildren();
iter = children.begin(); iter = children.begin();
@ -1896,7 +1882,7 @@ bool FWidget::focusNextChild()
if ( parent->hasChildren() && parent->numOfFocusableChildren() > 1 ) if ( parent->hasChildren() && parent->numOfFocusableChildren() > 1 )
{ {
FObjectList children; FObjectList children;
FObjectList::iterator iter, end; FObjectIterator iter, end;
children = parent->getChildren(); children = parent->getChildren();
iter = children.begin(); iter = children.begin();
@ -1915,7 +1901,7 @@ bool FWidget::focusNextChild()
if ( w == this ) if ( w == this )
{ {
FWidget* next = 0; FWidget* next = 0;
FObjectList::const_iterator next_element; constFObjectIterator next_element;
next_element = iter; next_element = iter;
do do
@ -1990,7 +1976,7 @@ bool FWidget::focusPrevChild()
if ( parent->hasChildren() && parent->numOfFocusableChildren() > 1 ) if ( parent->hasChildren() && parent->numOfFocusableChildren() > 1 )
{ {
FObjectList children; FObjectList children;
FObjectList::iterator iter, begin; FObjectIterator iter, begin;
children = parent->getChildren(); children = parent->getChildren();
iter = children.end(); iter = children.end();
@ -2008,7 +1994,7 @@ bool FWidget::focusPrevChild()
if ( w == this ) if ( w == this )
{ {
FWidget* prev = 0; FWidget* prev = 0;
FObjectList::const_iterator prev_element; constFObjectIterator prev_element;
prev_element = iter; prev_element = iter;
do do

View File

@ -57,6 +57,9 @@ Treeview::Treeview (FWidget* parent)
listView->setColumnAlignment (2, fc::alignRight); listView->setColumnAlignment (2, fc::alignRight);
listView->setColumnAlignment (3, fc::alignRight); listView->setColumnAlignment (3, fc::alignRight);
// Activate tree view
listView->setTreeView();
// Populate FListView with a list of items // Populate FListView with a list of items
std::string continent[][3] = std::string continent[][3] =
{ {
@ -77,8 +80,11 @@ Treeview::Treeview (FWidget* parent)
listView->insert (line); listView->insert (line);
} }
// Enable the tree view std::string egypt[3] = { "Egypt", "94,666,000", "87" };
listView->setTreeView(); std::vector<FString> egypt_line (&egypt[0], &egypt[0] + 3);
FObjectIterator iter_africa = listView->insert (egypt_line);
listView->insert (egypt_line, iter_africa);
// Quit button // Quit button
FButton* Quit = new FButton (this); FButton* Quit = new FButton (this);