Refactor the VGA attribute controller access code

This commit is contained in:
Markus Gans 2016-10-17 08:44:38 +02:00
parent 00c33a8d61
commit 1613d5bb55
25 changed files with 738 additions and 702 deletions

View File

@ -1,3 +1,6 @@
2016-10-17 Markus Gans <guru.mail@muenster.de>
* Refactor the VGA attribute controller access code
2016-10-15 Markus Gans <guru.mail@muenster.de> 2016-10-15 Markus Gans <guru.mail@muenster.de>
* Each virtual window gets its own virtual print cursor * Each virtual window gets its own virtual print cursor

View File

@ -731,35 +731,35 @@ void FButton::onTimer (FTimerEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FButton::onAccel (FAccelEvent* ev) void FButton::onAccel (FAccelEvent* ev)
{ {
if ( isEnabled() ) if ( ! isEnabled() )
return;
if ( ! hasFocus() )
{ {
if ( ! hasFocus() ) FWidget* focused_widget = static_cast<FWidget*>(ev->focusedWidget());
{ FFocusEvent out (fc::FocusOut_Event);
FWidget* focused_widget = static_cast<FWidget*>(ev->focusedWidget()); FApplication::queueEvent(focused_widget, &out);
FFocusEvent out (fc::FocusOut_Event); setFocus();
FApplication::queueEvent(focused_widget, &out);
setFocus();
if ( focused_widget ) if ( focused_widget )
focused_widget->redraw(); focused_widget->redraw();
if ( click_animation )
setDown();
else
redraw();
if ( statusBar() )
statusBar()->drawMessage();
}
else if ( click_animation )
setDown();
if ( click_animation ) if ( click_animation )
addTimer(click_time); setDown();
else
redraw();
processClick(); if ( statusBar() )
ev->accept(); statusBar()->drawMessage();
} }
else if ( click_animation )
setDown();
if ( click_animation )
addTimer(click_time);
processClick();
ev->accept();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -418,19 +418,19 @@ void FButtonGroup::cb_buttonToggled (FWidget* widget, void*)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FToggleButton* FButtonGroup::getFirstButton() FToggleButton* FButtonGroup::getFirstButton()
{ {
if ( ! buttonlist.empty() ) if ( buttonlist.empty() )
return 0;
FButtonGroup::FButtonList::const_iterator iter, end;
iter = buttonlist.begin();
end = buttonlist.end();
while ( iter != end )
{ {
FButtonGroup::FButtonList::const_iterator iter, end; if ( (*iter)->isEnabled() && (*iter)->acceptFocus() )
iter = buttonlist.begin(); return (*iter);
end = buttonlist.end();
while ( iter != end ) ++iter;
{
if ( (*iter)->isEnabled() && (*iter)->acceptFocus() )
return (*iter);
++iter;
}
} }
return 0; return 0;
@ -439,21 +439,21 @@ FToggleButton* FButtonGroup::getFirstButton()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FToggleButton* FButtonGroup::getLastButton() FToggleButton* FButtonGroup::getLastButton()
{ {
if ( ! buttonlist.empty() ) if ( buttonlist.empty() )
return 0;
FButtonGroup::FButtonList::const_iterator iter, begin;
begin = buttonlist.begin();
iter = buttonlist.end();
do
{ {
FButtonGroup::FButtonList::const_iterator iter, begin; --iter;
begin = buttonlist.begin();
iter = buttonlist.end();
do if ( (*iter)->isEnabled() && (*iter)->acceptFocus() )
{ return (*iter);
--iter;
if ( (*iter)->isEnabled() && (*iter)->acceptFocus() )
return (*iter);
}
while ( iter != begin );
} }
while ( iter != begin );
return 0; return 0;
} }
@ -461,19 +461,19 @@ FToggleButton* FButtonGroup::getLastButton()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FButtonGroup::hasFocusedButton() bool FButtonGroup::hasFocusedButton()
{ {
if ( ! buttonlist.empty() ) if ( buttonlist.empty() )
return false;
FButtonGroup::FButtonList::const_iterator iter, end;
iter = buttonlist.begin();
end = buttonlist.end();
while ( iter != end )
{ {
FButtonGroup::FButtonList::const_iterator iter, end; if ( (*iter)->hasFocus() )
iter = buttonlist.begin(); return true;
end = buttonlist.end();
while ( iter != end ) ++iter;
{
if ( (*iter)->hasFocus() )
return true;
++iter;
}
} }
return false; return false;
@ -482,19 +482,19 @@ bool FButtonGroup::hasFocusedButton()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FButtonGroup::hasCheckedButton() bool FButtonGroup::hasCheckedButton()
{ {
if ( ! buttonlist.empty() ) if ( buttonlist.empty() )
return false;
FButtonGroup::FButtonList::const_iterator iter, end;
iter = buttonlist.begin();
end = buttonlist.end();
while ( iter != end )
{ {
FButtonGroup::FButtonList::const_iterator iter, end; if ( (*iter)->isChecked() )
iter = buttonlist.begin(); return true;
end = buttonlist.end();
while ( iter != end ) ++iter;
{
if ( (*iter)->isChecked() )
return true;
++iter;
}
} }
return false; return false;

View File

@ -48,15 +48,15 @@ void FCheckMenuItem::init (FWidget* parent)
{ {
checkable = true; checkable = true;
if ( parent ) if ( ! parent )
{ return;
if ( isMenu(parent) ) // Parent is menu
{
FMenu* menu_ptr = dynamic_cast<FMenu*>(parent);
if ( menu_ptr ) if ( isMenu(parent) ) // Parent is menu
menu_ptr->has_checkable_items = true; {
} FMenu* menu_ptr = dynamic_cast<FMenu*>(parent);
if ( menu_ptr )
menu_ptr->has_checkable_items = true;
} }
} }

View File

@ -253,21 +253,20 @@ void FFileDialog::clear()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FFileDialog::numOfDirs() int FFileDialog::numOfDirs()
{ {
if ( dir_entries.empty() )
return 0;
int n = 0; int n = 0;
std::vector<dir_entry>::const_iterator iter, end;
iter = dir_entries.begin();
end = dir_entries.end();
if ( ! dir_entries.empty() ) while ( iter != end )
{ {
std::vector<dir_entry>::const_iterator iter, end; if ( (*iter).type == DT_DIR && std::strcmp((*iter).name, ".") != 0 )
iter = dir_entries.begin(); n++;
end = dir_entries.end();
while ( iter != end ) ++iter;
{
if ( (*iter).type == DT_DIR && std::strcmp((*iter).name, ".") != 0 )
n++;
++iter;
}
} }
return n; return n;
@ -499,7 +498,9 @@ void FFileDialog::adjustSize()
FFileDialog& FFileDialog::operator = (const FFileDialog& fdlg) FFileDialog& FFileDialog::operator = (const FFileDialog& fdlg)
{ {
if ( &fdlg == this ) if ( &fdlg == this )
{
return *this; return *this;
}
else else
{ {
delete open; delete open;

View File

@ -736,30 +736,30 @@ void FLineEdit::onTimer (FTimerEvent*)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FLineEdit::onAccel (FAccelEvent* ev) void FLineEdit::onAccel (FAccelEvent* ev)
{ {
if ( isEnabled() ) if ( ! isEnabled() )
return;
if ( ! hasFocus() )
{ {
if ( ! hasFocus() ) FWidget* focused_widget = static_cast<FWidget*>(ev->focusedWidget());
FFocusEvent out (fc::FocusOut_Event);
FApplication::queueEvent(focused_widget, &out);
setFocus();
if ( focused_widget )
focused_widget->redraw();
redraw();
if ( statusBar() )
{ {
FWidget* focused_widget = static_cast<FWidget*>(ev->focusedWidget()); statusBar()->drawMessage();
FFocusEvent out (fc::FocusOut_Event); updateTerminal();
FApplication::queueEvent(focused_widget, &out); flush_out();
setFocus();
if ( focused_widget )
focused_widget->redraw();
redraw();
if ( statusBar() )
{
statusBar()->drawMessage();
updateTerminal();
flush_out();
}
} }
ev->accept();
} }
ev->accept();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -594,7 +594,7 @@ void FListBox::hide()
return; return;
blank = new char[size+1]; blank = new char[size+1];
memset(blank, ' ', uLong(size)); std::memset (blank, ' ', uLong(size));
blank[size] = '\0'; blank[size] = '\0';
for (int y=0; y < getHeight(); y++) for (int y=0; y < getHeight(); y++)
@ -612,23 +612,23 @@ void FListBox::showInsideBrackets ( int index
{ {
data[uInt(index-1)].brackets = b; data[uInt(index-1)].brackets = b;
if ( b != fc::NoBrackets ) if ( b == fc::NoBrackets )
return;
int len = int(data[uInt(index-1)].getText().getLength() + 2);
if ( len > max_line_width )
{ {
int len = int(data[uInt(index-1)].getText().getLength() + 2); max_line_width = len;
if ( len > max_line_width ) if ( len >= getWidth() - nf_offset - 3 )
{ {
max_line_width = len; hbar->setMaximum(max_line_width - getWidth() + nf_offset + 4);
hbar->setPageSize(max_line_width, getWidth() - nf_offset - 4);
hbar->setValue (xoffset);
if ( len >= getWidth() - nf_offset - 3 ) if ( ! hbar->isVisible() )
{ hbar->setVisible();
hbar->setMaximum(max_line_width - getWidth() + nf_offset + 4);
hbar->setPageSize(max_line_width, getWidth() - nf_offset - 4);
hbar->setValue (xoffset);
if ( ! hbar->isVisible() )
hbar->setVisible();
}
} }
} }
} }
@ -1787,7 +1787,7 @@ void FListBox::clear()
return; return;
blank = new char[size+1]; blank = new char[size+1];
memset(blank, ' ', uLong(size)); std::memset (blank, ' ', uLong(size));
blank[size] = '\0'; blank[size] = '\0';
for (int y=0; y < getHeight()-2; y++) for (int y=0; y < getHeight()-2; y++)

View File

@ -433,27 +433,27 @@ void FMenuItem::delAccelerator (FWidget* obj)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuItem::onKeyPress (FKeyEvent* ev) void FMenuItem::onKeyPress (FKeyEvent* ev)
{ {
if ( super_menu ) if ( ! super_menu )
return;
if ( isMenu(super_menu) )
{ {
if ( isMenu(super_menu) ) FMenu* smenu = dynamic_cast<FMenu*>(super_menu);
if ( smenu )
smenu->onKeyPress(ev);
}
if ( isMenuBar(super_menu) )
{
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu);
if ( mbar )
{ {
FMenu* smenu = dynamic_cast<FMenu*>(super_menu); if ( mbar->hotkeyMenu(ev) )
return;
if ( smenu ) mbar->onKeyPress(ev);
smenu->onKeyPress(ev);
}
if ( isMenuBar(super_menu) )
{
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu);
if ( mbar )
{
if ( mbar->hotkeyMenu(ev) )
return;
mbar->onKeyPress(ev);
}
} }
} }
} }
@ -461,48 +461,48 @@ void FMenuItem::onKeyPress (FKeyEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuItem::onMouseDoubleClick (FMouseEvent* ev) void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
{ {
if ( super_menu ) if ( ! super_menu )
return;
const FPoint& t = ev->getTermPos();
int b = ev->getButton();
if ( isMenu(super_menu) )
{ {
const FPoint& t = ev->getTermPos(); FMenu* smenu = dynamic_cast<FMenu*>(super_menu);
int b = ev->getButton();
if ( isMenu(super_menu) ) if ( smenu )
{ {
FMenu* smenu = dynamic_cast<FMenu*>(super_menu); const FPoint& p2 = smenu->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseDoubleClick_Event, p2, t, b);
if ( smenu ) smenu->onMouseDoubleClick(_ev);
{ delete _ev;
const FPoint& p2 = smenu->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseDoubleClick_Event, p2, t, b);
smenu->onMouseDoubleClick(_ev);
delete _ev;
}
} }
}
if ( isMenuBar(super_menu) ) if ( isMenuBar(super_menu) )
{
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu);
if ( mbar )
{ {
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu); const FPoint& p2 = mbar->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseDoubleClick_Event, p2, t, b);
if ( mbar ) mbar->onMouseDoubleClick(_ev);
{ delete _ev;
const FPoint& p2 = mbar->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseDoubleClick_Event, p2, t, b);
mbar->onMouseDoubleClick(_ev);
delete _ev;
}
} }
}
if ( isWindowsMenu(super_menu) ) if ( isWindowsMenu(super_menu) )
{
FDialog* dgl = dynamic_cast<FDialog*>(super_menu);
if ( dgl )
{ {
FDialog* dgl = dynamic_cast<FDialog*>(super_menu); const FPoint& p2 = dgl->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseDoubleClick_Event, p2, t, b);
if ( dgl ) dgl->onMouseDoubleClick(_ev);
{ delete _ev;
const FPoint& p2 = dgl->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseDoubleClick_Event, p2, t, b);
dgl->onMouseDoubleClick(_ev);
delete _ev;
}
} }
} }
} }
@ -510,48 +510,48 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuItem::onMouseDown (FMouseEvent* ev) void FMenuItem::onMouseDown (FMouseEvent* ev)
{ {
if ( super_menu ) if ( ! super_menu )
return;
const FPoint& t = ev->getTermPos();
int b = ev->getButton();
if ( isMenu(super_menu) )
{ {
const FPoint& t = ev->getTermPos(); FMenu* smenu = dynamic_cast<FMenu*>(super_menu);
int b = ev->getButton();
if ( isMenu(super_menu) ) if ( smenu )
{ {
FMenu* smenu = dynamic_cast<FMenu*>(super_menu); const FPoint& p2 = smenu->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseDown_Event, p2, t, b);
if ( smenu ) smenu->onMouseDown(_ev);
{ delete _ev;
const FPoint& p2 = smenu->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseDown_Event, p2, t, b);
smenu->onMouseDown(_ev);
delete _ev;
}
} }
}
if ( isMenuBar(super_menu) ) if ( isMenuBar(super_menu) )
{
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu);
if ( mbar )
{ {
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu); const FPoint& p2 = mbar->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseDown_Event, p2, t, b);
if ( mbar ) mbar->onMouseDown(_ev);
{ delete _ev;
const FPoint& p2 = mbar->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseDown_Event, p2, t, b);
mbar->onMouseDown(_ev);
delete _ev;
}
} }
}
if ( isWindowsMenu(super_menu) ) if ( isWindowsMenu(super_menu) )
{
FDialog* dgl = dynamic_cast<FDialog*>(super_menu);
if ( dgl )
{ {
FDialog* dgl = dynamic_cast<FDialog*>(super_menu); const FPoint& p2 = dgl->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseDown_Event, p2, t, b);
if ( dgl ) dgl->onMouseDown(_ev);
{ delete _ev;
const FPoint& p2 = dgl->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseDown_Event, p2, t, b);
dgl->onMouseDown(_ev);
delete _ev;
}
} }
} }
} }
@ -559,48 +559,48 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuItem::onMouseUp (FMouseEvent* ev) void FMenuItem::onMouseUp (FMouseEvent* ev)
{ {
if ( super_menu ) if ( ! super_menu )
return;
const FPoint& t = ev->getTermPos();
int b = ev->getButton();
if ( isMenu(super_menu) )
{ {
const FPoint& t = ev->getTermPos(); FMenu* smenu = dynamic_cast<FMenu*>(super_menu);
int b = ev->getButton();
if ( isMenu(super_menu) ) if ( smenu )
{ {
FMenu* smenu = dynamic_cast<FMenu*>(super_menu); const FPoint& p2 = smenu->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseUp_Event, p2, t, b);
if ( smenu ) smenu->onMouseUp(_ev);
{ delete _ev;
const FPoint& p2 = smenu->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseUp_Event, p2, t, b);
smenu->onMouseUp(_ev);
delete _ev;
}
} }
}
if ( isMenuBar(super_menu) ) if ( isMenuBar(super_menu) )
{
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu);
if ( mbar )
{ {
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu); const FPoint& p2 = mbar->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseUp_Event, p2, t, b);
if ( mbar ) mbar->onMouseUp(_ev);
{ delete _ev;
const FPoint& p2 = mbar->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseUp_Event, p2, t, b);
mbar->onMouseUp(_ev);
delete _ev;
}
} }
}
if ( isWindowsMenu(super_menu) ) if ( isWindowsMenu(super_menu) )
{
FDialog* dgl = dynamic_cast<FDialog*>(super_menu);
if ( dgl )
{ {
FDialog* dgl = dynamic_cast<FDialog*>(super_menu); const FPoint& p2 = dgl->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseUp_Event, p2, t, b);
if ( dgl ) dgl->onMouseUp(_ev);
{ delete _ev;
const FPoint& p2 = dgl->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseUp_Event, p2, t, b);
dgl->onMouseUp(_ev);
delete _ev;
}
} }
} }
} }
@ -608,48 +608,48 @@ void FMenuItem::onMouseUp (FMouseEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuItem::onMouseMove (FMouseEvent* ev) void FMenuItem::onMouseMove (FMouseEvent* ev)
{ {
if ( super_menu ) if ( ! super_menu )
return;
const FPoint& t = ev->getTermPos();
int b = ev->getButton();
if ( isMenu(super_menu) )
{ {
const FPoint& t = ev->getTermPos(); FMenu* smenu = dynamic_cast<FMenu*>(super_menu);
int b = ev->getButton();
if ( isMenu(super_menu) ) if ( smenu )
{ {
FMenu* smenu = dynamic_cast<FMenu*>(super_menu); const FPoint& p2 = smenu->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p2, t, b);
if ( smenu ) smenu->onMouseMove(_ev);
{ delete _ev;
const FPoint& p2 = smenu->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p2, t, b);
smenu->onMouseMove(_ev);
delete _ev;
}
} }
}
if ( isMenuBar(super_menu) ) if ( isMenuBar(super_menu) )
{
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu);
if ( mbar )
{ {
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu); const FPoint& p2 = mbar->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p2, t, b);
if ( mbar ) mbar->onMouseMove(_ev);
{ delete _ev;
const FPoint& p2 = mbar->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p2, t, b);
mbar->onMouseMove(_ev);
delete _ev;
}
} }
}
if ( isWindowsMenu(super_menu) ) if ( isWindowsMenu(super_menu) )
{
FDialog* dgl = dynamic_cast<FDialog*>(super_menu);
if ( dgl )
{ {
FDialog* dgl = dynamic_cast<FDialog*>(super_menu); const FPoint& p2 = dgl->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p2, t, b);
if ( dgl ) dgl->onMouseMove(_ev);
{ delete _ev;
const FPoint& p2 = dgl->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p2, t, b);
dgl->onMouseMove(_ev);
delete _ev;
}
} }
} }
} }
@ -657,59 +657,60 @@ void FMenuItem::onMouseMove (FMouseEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuItem::onAccel (FAccelEvent* ev) void FMenuItem::onAccel (FAccelEvent* ev)
{ {
if ( isEnabled() && ! isSelected() ) if ( ! isEnabled() || isSelected() )
return;
if ( ! super_menu || ! isMenuBar(super_menu) )
{ {
if ( super_menu && isMenuBar(super_menu) ) processClicked();
{ return;
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu);
if ( mbar )
{
if ( menu )
{
FWidget* focused_widget;
if ( mbar->getSelectedItem() )
mbar->getSelectedItem()->unsetSelected();
setSelected();
mbar->selected_item = this;
openMenu();
focused_widget = static_cast<FWidget*>(ev->focusedWidget());
FFocusEvent out (fc::FocusOut_Event);
FApplication::queueEvent(focused_widget, &out);
menu->unselectItem();
menu->selectFirstItem();
if ( menu->getSelectedItem() )
menu->getSelectedItem()->setFocus();
if ( focused_widget )
focused_widget->redraw();
menu->redraw();
if ( statusBar() )
statusBar()->drawMessage();
mbar->redraw();
mbar->drop_down = true;
}
else
{
unsetSelected();
mbar->selected_item = 0;
mbar->redraw();
processClicked();
mbar->drop_down = false;
}
ev->accept();
}
}
else
processClicked();
} }
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu);
if ( ! mbar )
return;
if ( menu )
{
FWidget* focused_widget;
if ( mbar->getSelectedItem() )
mbar->getSelectedItem()->unsetSelected();
setSelected();
mbar->selected_item = this;
openMenu();
focused_widget = static_cast<FWidget*>(ev->focusedWidget());
FFocusEvent out (fc::FocusOut_Event);
FApplication::queueEvent(focused_widget, &out);
menu->unselectItem();
menu->selectFirstItem();
if ( menu->getSelectedItem() )
menu->getSelectedItem()->setFocus();
if ( focused_widget )
focused_widget->redraw();
menu->redraw();
if ( statusBar() )
statusBar()->drawMessage();
mbar->redraw();
mbar->drop_down = true;
}
else
{
unsetSelected();
mbar->selected_item = 0;
mbar->redraw();
processClicked();
mbar->drop_down = false;
}
ev->accept();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -18,16 +18,16 @@ FMenuList::FMenuList()
FMenuList::~FMenuList() // destructor FMenuList::~FMenuList() // destructor
{ {
// delete all items // delete all items
if ( ! item_list.empty() ) if ( item_list.empty() )
{ return;
std::vector<FMenuItem*>::iterator iter;
iter = item_list.begin();
while ( iter != item_list.end() ) std::vector<FMenuItem*>::iterator iter;
{ iter = item_list.begin();
(*iter)->setSuperMenu(0);
iter = item_list.erase(iter); while ( iter != item_list.end() )
} {
(*iter)->setSuperMenu(0);
iter = item_list.erase(iter);
} }
} }

View File

@ -375,7 +375,9 @@ void FMessageBox::adjustSize()
FMessageBox& FMessageBox::operator = (const FMessageBox& mbox) FMessageBox& FMessageBox::operator = (const FMessageBox& mbox)
{ {
if ( &mbox == this ) if ( &mbox == this )
{
return *this; return *this;
}
else else
{ {
for (uInt n=0; n < num_buttons; n++) for (uInt n=0; n < num_buttons; n++)

View File

@ -94,18 +94,6 @@ void FObject::delChild (FObject* obj)
} }
} }
//----------------------------------------------------------------------
bool FObject::event (FEvent* ev)
{
if ( ev->type() == fc::Timer_Event )
{
onTimer ( static_cast<FTimerEvent*>(ev) );
return true;
}
return false;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FObject::getCurrentTime (timeval &time) void FObject::getCurrentTime (timeval &time)
{ {
@ -255,6 +243,18 @@ bool FObject::delAllTimer()
} }
// protected methods of FObject // protected methods of FObject
//----------------------------------------------------------------------
bool FObject::event (FEvent* ev)
{
if ( ev->type() == fc::Timer_Event )
{
onTimer ( static_cast<FTimerEvent*>(ev) );
return true;
}
return false;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FObject::onTimer (FTimerEvent*) void FObject::onTimer (FTimerEvent*)
{ } { }

View File

@ -90,11 +90,10 @@ class FObject
bool delOwnTimer(); bool delOwnTimer();
bool delAllTimer(); bool delAllTimer();
bool isTimerInUpdating() const; bool isTimerInUpdating() const;
// Event handler
virtual bool event (FEvent*);
protected: protected:
// Event handler // Event handler
virtual bool event (FEvent*);
virtual void onTimer (FTimerEvent*); virtual void onTimer (FTimerEvent*);
private: private:

View File

@ -69,38 +69,36 @@ int FOptiMove::capDuration (char*& cap, int affcnt)
// cap - the term capability // cap - the term capability
// affcnt - the number of lines affected // affcnt - the number of lines affected
if ( cap ) if ( ! cap )
{
const char* p;
float ms = 0;
for (p=cap; *p; p++)
{
// check for delay with padding character
if ( p[0] == '$' && p[1] == '<' && std::strchr(p, '>') )
{
float num=0;
for (p += 2; *p != '>'; p++)
{
if ( std::isdigit(uChar(*p)) )
num = num * 10 + float(*p - '0');
else if ( *p == '*' )
num *= float(affcnt);
else if ( *p == '.' && *++p != '>' && std::isdigit(uChar(*p)) )
num += float((*p - '0') / 10.0);
}
ms += num * 10;
}
else
ms += float(char_duration);
}
return int(ms);
}
else
return LONG_DURATION; return LONG_DURATION;
const char* p;
float ms = 0;
for (p=cap; *p; p++)
{
// check for delay with padding character
if ( p[0] == '$' && p[1] == '<' && std::strchr(p, '>') )
{
float num=0;
for (p += 2; *p != '>'; p++)
{
if ( std::isdigit(uChar(*p)) )
num = num * 10 + float(*p - '0');
else if ( *p == '*' )
num *= float(affcnt);
else if ( *p == '.' && *++p != '>' && std::isdigit(uChar(*p)) )
num += float((*p - '0') / 10.0);
}
ms += num * 10;
}
else
ms += float(char_duration);
}
return int(ms);
} }

View File

@ -49,21 +49,21 @@ void FRadioMenuItem::init (FWidget* parent)
checkable = true; checkable = true;
radio_button = true; radio_button = true;
if ( parent ) if ( ! parent )
return;
if ( isMenu(parent) ) // Parent is menu
{ {
if ( isMenu(parent) ) // Parent is menu FMenu* menu_ptr = dynamic_cast<FMenu*>(parent);
{
FMenu* menu_ptr = dynamic_cast<FMenu*>(parent);
if ( menu_ptr ) if ( menu_ptr )
menu_ptr->has_checkable_items = true; menu_ptr->has_checkable_items = true;
this->addCallback this->addCallback
( (
"toggled", "toggled",
_METHOD_CALLBACK (parent, &FMenu::cb_menuitem_toggled) _METHOD_CALLBACK (parent, &FMenu::cb_menuitem_toggled)
); );
}
} }
} }

View File

@ -92,20 +92,20 @@ void FStatusKey::processActivate()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FStatusKey::onAccel (FAccelEvent* ev) void FStatusKey::onAccel (FAccelEvent* ev)
{ {
if ( ! isActivated() ) if ( isActivated() )
{ return;
setActive();
if ( statusbar() ) setActive();
statusbar()->redraw();
ev->accept(); if ( statusbar() )
// unset after get back from callback statusbar()->redraw();
unsetActive();
if ( statusbar() ) ev->accept();
statusbar()->redraw(); // unset after get back from callback
} unsetActive();
if ( statusbar() )
statusbar()->redraw();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -146,16 +146,16 @@ FString::FString (const std::string& s)
, bufsize(0) , bufsize(0)
, c_string(0) , c_string(0)
{ {
if ( ! s.empty() ) if ( s.empty() )
{ return;
const wchar_t* wc_string;
wc_string = c_to_wc_str(s.c_str());
if ( wc_string ) const wchar_t* wc_string;
{ wc_string = c_to_wc_str(s.c_str());
_replace( wc_string );
delete[] wc_string; if ( wc_string )
} {
_replace( wc_string );
delete[] wc_string;
} }
} }
@ -217,13 +217,13 @@ FString::~FString() // destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FString::initLength (uInt len) inline void FString::initLength (uInt len)
{ {
if ( len > 0 ) if ( len == 0 )
{ return;
length = len;
bufsize = FWDBUFFER + len + 1; length = len;
string = new wchar_t[bufsize](); bufsize = FWDBUFFER + len + 1;
std::wmemset (string, L'\0', bufsize); string = new wchar_t[bufsize]();
} std::wmemset (string, L'\0', bufsize);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -101,14 +101,12 @@ fc::consoleCursorStyle FTerm::console_cursor_style;
// constructors and destructor // constructors and destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FTerm::FTerm() FTerm::FTerm()
: map() : color_map()
{ {
resize_term = false; resize_term = false;
if ( ! term_initialized ) if ( ! term_initialized )
{
init(); init();
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -125,31 +123,100 @@ FTerm::~FTerm() // destructor
} }
} }
// private methods of FTerm // private methods of FTerm
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::outb_Attribute_Controller (int index, int data) inline uInt16 FTerm::getInputStatusRegisterOne()
{ {
inb (AttrC_DataSwitch); // Gets the VGA input-status-register-1
outb (index & 0x1F, AttrC_Index); uInt16 misc_read = 0x3cc; // Miscellaneous output (read port)
outb (uChar(data), AttrC_DataW); uInt16 io_base = (inb(misc_read) & 0x01) ? 0x3d0 : 0x3b0;
inb (AttrC_DataSwitch); // 0x3ba : Input status 1 MDA (read port)
outb (uChar((index & 0x1F) | 0x20), AttrC_Index); // 0x3da : Input status 1 CGA (read port)
outb (uChar(data), AttrC_DataW); return io_base + 0x0a;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FTerm::inb_Attribute_Controller (int index) uChar FTerm::readAttributeController (uChar index)
{ {
int res; // Reads a byte from the attribute controller from a given index
inb (AttrC_DataSwitch); uChar res;
outb (index & 0x1F, AttrC_Index); uInt16 attrib_cntlr_write = 0x3c0; // Attribute controller (write port)
res = inb (AttrC_DataR); uInt16 attrib_cntlr_read = 0x3c1; // Attribute controller (read port)
inb (AttrC_DataSwitch); uInt16 input_status_1 = getInputStatusRegisterOne();
outb (uChar((index & 0x1F) | 0x20), AttrC_Index);
inb (AttrC_DataR); inb (input_status_1); // switch to index mode
outb (index & 0x1f, attrib_cntlr_write);
res = inb (attrib_cntlr_read);
inb (input_status_1); // switch to data mode
index = (index & 0x1f) | 0x20; // set bit 5 (enable display)
outb (index, attrib_cntlr_write);
inb (attrib_cntlr_read);
return res; return res;
} }
//----------------------------------------------------------------------
void FTerm::writeAttributeController (uChar index, uChar data)
{
// Writes a byte from the attribute controller from a given index
uInt16 attrib_cntlr_write = 0x3c0; // Attribute controller (write port)
uInt16 input_status_1 = getInputStatusRegisterOne();
inb (input_status_1); // switch to index mode
outb (index & 0x1f, attrib_cntlr_write);
outb (data, attrib_cntlr_write);
inb (input_status_1); // switch to data mode
index = (index & 0x1f) | 0x20; // set bit 5 (enable display)
outb (index, attrib_cntlr_write);
outb (data, attrib_cntlr_write);
}
//----------------------------------------------------------------------
inline uChar FTerm::getAttributeMode()
{
// Gets the attribute mode value from the vga attribute controller
uChar attrib_mode = 0x10;
return readAttributeController(attrib_mode);
}
//----------------------------------------------------------------------
inline void FTerm::setAttributeMode(uChar data)
{
// Sets the attribute mode value from the vga attribute controller
uChar attrib_mode = 0x10;
writeAttributeController (attrib_mode, data);
}
//----------------------------------------------------------------------
int FTerm::setBlinkAsIntensity (bool on)
{
// Uses blink-bit as background intensity.
// That permits 16 colors for background
if ( getuid() != 0 ) // Direct hardware access requires root privileges
return -2;
if ( fd_tty < 0 )
return -1;
// Enable access to VGA I/O ports (from 0x3B4 with num = 0x2C)
if ( ioctl(fd_tty, KDENABIO, 0) < 0 )
return -1; // error on KDENABIO
if ( on )
setAttributeMode (getAttributeMode() & 0xF7); // clear bit 3
else
setAttributeMode (getAttributeMode() | 0x08); // set bit 3
// Disable access to VGA I/O ports
if ( ioctl(fd_tty, KDDISABIO, 0) < 0 )
return -1; // error on KDDISABIO
return 0;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FTerm::getFramebuffer_bpp () int FTerm::getFramebuffer_bpp ()
{ {
@ -183,6 +250,7 @@ int FTerm::getFramebuffer_bpp ()
::close(fd); ::close(fd);
} }
} }
return -1; return -1;
} }
@ -313,7 +381,7 @@ int FTerm::getScreenFont()
return -1; return -1;
// initialize unused padding bytes in struct // initialize unused padding bytes in struct
memset(&font, 0, sizeof(console_font_op)); std::memset (&font, 0, sizeof(console_font_op));
font.op = KD_FONT_OP_GET; font.op = KD_FONT_OP_GET;
font.flags = 0; font.flags = 0;
@ -350,7 +418,7 @@ int FTerm::setScreenFont ( uChar* fontdata, uInt count
return -1; return -1;
// initialize unused padding bytes in struct // initialize unused padding bytes in struct
memset(&font, 0x00, sizeof(console_font_op)); std::memset (&font, 0x00, sizeof(console_font_op));
font.op = KD_FONT_OP_SET; font.op = KD_FONT_OP_SET;
font.flags = 0; font.flags = 0;
@ -445,6 +513,7 @@ int FTerm::getUnicodeMap()
else else
return -1; return -1;
} }
return 0; return 0;
} }
@ -483,34 +552,6 @@ int FTerm::setUnicodeMap (struct unimapdesc* unimap)
return -1; return -1;
} }
//----------------------------------------------------------------------
int FTerm::setBlinkAsIntensity (bool on)
{
// Uses blink-bit as background intensity.
// That permits 16 colors for background
if ( getuid() != 0 ) // Direct hardware access requires root privileges
return -2;
if ( fd_tty < 0 )
return -1;
// Enable access to VGA I/O ports (from 0x3B4 with num = 0x2C)
if ( ioctl(fd_tty, KDENABIO, 0) < 0 )
return -1; // error on KDENABIO
if ( on )
outb_Attribute_Controller (0x10, inb_Attribute_Controller(0x10) & 0xF7);
else
outb_Attribute_Controller (0x10, inb_Attribute_Controller(0x10) | 0x08);
// Disable access to VGA I/O ports
if ( ioctl(fd_tty, KDDISABIO, 0) < 0 )
return -1; // error on KDDISABIO
return 0;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FTerm::isKeyTimeout (timeval* time, register long timeout) bool FTerm::isKeyTimeout (timeval* time, register long timeout)
{ {
@ -693,7 +734,7 @@ FTerm::modifier_key& FTerm::getModifierKey()
{ {
char subcode = 6; char subcode = 6;
// fill bit field with 0 // fill bit field with 0
memset (&mod_key, 0x00, sizeof(mod_key)); std::memset (&mod_key, 0x00, sizeof(mod_key));
// TIOCLINUX, subcode=6 // TIOCLINUX, subcode=6
if ( ioctl(0, TIOCLINUX, &subcode) >= 0 ) if ( ioctl(0, TIOCLINUX, &subcode) >= 0 )
@ -2827,7 +2868,7 @@ void FTerm::resetXTermHighlightBackground()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::saveColorMap() void FTerm::saveColorMap()
{ {
// ioctl (0, GIO_CMAP, &map); // ioctl (0, GIO_CMAP, &color_map);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -2855,11 +2896,11 @@ void FTerm::resetColorMap()
}; };
for (int x=0; x<16; x++) for (int x=0; x<16; x++)
{ {
map.d[x].red = CurrentColors[x].red; color_map.d[x].red = CurrentColors[x].red;
map.d[x].green = CurrentColors[x].green; color_map.d[x].green = CurrentColors[x].green;
map.d[x].blue = CurrentColors[x].blue; color_map.d[x].blue = CurrentColors[x].blue;
} }
ioctl (0, PIO_CMAP, &map); ioctl (0, PIO_CMAP, &color_map);
}*/ }*/
std::fflush(stdout); std::fflush(stdout);
@ -2957,31 +2998,31 @@ void FTerm::setEncoding (std::string enc)
// available encodings: "UTF8", "VT100", "PC" and "ASCII" // available encodings: "UTF8", "VT100", "PC" and "ASCII"
it = encoding_set->find(enc); it = encoding_set->find(enc);
if ( it != encoding_set->end() ) // found if ( it == encoding_set->end() ) // not found
return;
Encoding = it->second;
assert ( Encoding == fc::UTF8
|| Encoding == fc::VT100
|| Encoding == fc::PC
|| Encoding == fc::ASCII );
// set the new Fputchar function pointer
switch ( int(Encoding) )
{ {
Encoding = it->second; case fc::UTF8:
Fputchar = &FTerm::putchar_UTF8;
break;
assert ( Encoding == fc::UTF8 case fc::VT100:
|| Encoding == fc::VT100 case fc::PC:
|| Encoding == fc::PC if ( xterm_terminal && utf8_console )
|| Encoding == fc::ASCII );
// set the new Fputchar function pointer
switch ( int(Encoding) )
{
case fc::UTF8:
Fputchar = &FTerm::putchar_UTF8; Fputchar = &FTerm::putchar_UTF8;
break; // fall through
case fc::ASCII:
case fc::VT100: default:
case fc::PC: Fputchar = &FTerm::putchar_ASCII;
if ( xterm_terminal && utf8_console )
Fputchar = &FTerm::putchar_UTF8;
// fall through
case fc::ASCII:
default:
Fputchar = &FTerm::putchar_ASCII;
}
} }
} }

View File

@ -75,13 +75,6 @@
#define OSC ESC "]" // Operating system command (7-bit) #define OSC ESC "]" // Operating system command (7-bit)
#define SECDA ESC "[>c" // Secondary Device Attributes #define SECDA ESC "[>c" // Secondary Device Attributes
// VGA I/O-ports
#define VideoIOBase ( (inb(0x3CC) & 0x01) ? 0x3D0 : 0x3B0 )
#define AttrC_Index 0x3C0 // Attribute controller index
#define AttrC_DataW 0x3C0 // Attribute controller dataW
#define AttrC_DataR 0x3C1 // Attribute controller dataR
#define AttrC_DataSwitch (VideoIOBase+0x0A) // Attribute controller data switch
// parseKeyString return value // parseKeyString return value
#define NEED_MORE_DATA -1 #define NEED_MORE_DATA -1
@ -164,7 +157,7 @@ class FTerm
struct struct
{ {
dacreg d[16]; dacreg d[16];
} map; } color_map;
protected: protected:
static int stdin_no; static int stdin_no;
@ -190,8 +183,12 @@ class FTerm
// Disable assignment operator (=) // Disable assignment operator (=)
FTerm& operator = (const FTerm&); FTerm& operator = (const FTerm&);
static void outb_Attribute_Controller (int, int); static uInt16 getInputStatusRegisterOne();
static int inb_Attribute_Controller (int); static uChar readAttributeController (uChar);
static void writeAttributeController (uChar, uChar);
static uChar getAttributeMode();
static void setAttributeMode (uChar);
static int setBlinkAsIntensity (bool);
static int getFramebuffer_bpp(); static int getFramebuffer_bpp();
static int openConsole(); static int openConsole();
static int closeConsole(); static int closeConsole();
@ -201,7 +198,6 @@ class FTerm
static int setScreenFont (uChar*, uInt, uInt, uInt, bool = false); static int setScreenFont (uChar*, uInt, uInt, uInt, bool = false);
static int setUnicodeMap (struct unimapdesc*); static int setUnicodeMap (struct unimapdesc*);
static int getUnicodeMap (); static int getUnicodeMap ();
static int setBlinkAsIntensity (bool);
static void init_console(); static void init_console();
static uInt getBaudRate (const struct termios*); static uInt getBaudRate (const struct termios*);
static char* init_256colorTerminal(); static char* init_256colorTerminal();

View File

@ -485,24 +485,24 @@ void FToggleButton::onMouseDown (FMouseEvent* ev)
if ( ev->getButton() != fc::LeftButton ) if ( ev->getButton() != fc::LeftButton )
return; return;
if ( ! hasFocus() ) if ( hasFocus() )
return;
FWidget* focused_widget = getFocusWidget();
FFocusEvent out (fc::FocusOut_Event);
FApplication::queueEvent(focused_widget, &out);
setFocus();
if ( focused_widget )
focused_widget->redraw();
redraw();
if ( statusBar() )
{ {
FWidget* focused_widget = getFocusWidget(); statusBar()->drawMessage();
FFocusEvent out (fc::FocusOut_Event); updateTerminal();
FApplication::queueEvent(focused_widget, &out); flush_out();
setFocus();
if ( focused_widget )
focused_widget->redraw();
redraw();
if ( statusBar() )
{
statusBar()->drawMessage();
updateTerminal();
flush_out();
}
} }
} }
@ -512,68 +512,69 @@ void FToggleButton::onMouseUp (FMouseEvent* ev)
if ( ev->getButton() != fc::LeftButton ) if ( ev->getButton() != fc::LeftButton )
return; return;
if ( getTermGeometry().contains(ev->getTermPos()) ) if ( ! getTermGeometry().contains(ev->getTermPos()) )
return;
if ( isRadioButton() )
{ {
if ( isRadioButton() ) if ( ! checked )
{ {
if ( ! checked ) checked = true;
{
checked = true;
processToggle();
}
}
else
{
checked = not checked;
processToggle(); processToggle();
} }
redraw();
processClick();
} }
else
{
checked = not checked;
processToggle();
}
redraw();
processClick();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FToggleButton::onAccel (FAccelEvent* ev) void FToggleButton::onAccel (FAccelEvent* ev)
{ {
if ( isEnabled() ) if ( ! isEnabled() )
return;
if ( ! hasFocus() )
{ {
if ( ! hasFocus() ) FWidget* focused_widget = static_cast<FWidget*>(ev->focusedWidget());
{ FFocusEvent out (fc::FocusOut_Event);
FWidget* focused_widget = static_cast<FWidget*>(ev->focusedWidget()); FApplication::queueEvent(focused_widget, &out);
FFocusEvent out (fc::FocusOut_Event); setFocus();
FApplication::queueEvent(focused_widget, &out);
setFocus();
if ( focused_widget ) if ( focused_widget )
focused_widget->redraw(); focused_widget->redraw();
} }
if ( isRadioButton() ) if ( isRadioButton() )
{
if ( ! checked )
{ {
if ( ! checked ) checked = true;
{
checked = true;
processToggle();
}
}
else
{
checked = not checked;
processToggle(); processToggle();
} }
redraw();
if ( statusBar() )
{
statusBar()->drawMessage();
updateTerminal();
flush_out();
}
processClick();
ev->accept();
} }
else
{
checked = not checked;
processToggle();
}
redraw();
if ( statusBar() )
{
statusBar()->drawMessage();
updateTerminal();
flush_out();
}
processClick();
ev->accept();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -592,35 +593,35 @@ void FToggleButton::onFocusOut (FFocusEvent* out_ev)
statusBar()->drawMessage(); statusBar()->drawMessage();
} }
if ( group() ) if ( ! group() )
return;
if ( ! focus_inside_group && isRadioButton() )
{ {
if ( ! focus_inside_group && isRadioButton() ) focus_inside_group = true;
{ out_ev->ignore();
focus_inside_group = true;
out_ev->ignore();
if ( out_ev->getFocusType() == fc::FocusNextWidget ) if ( out_ev->getFocusType() == fc::FocusNextWidget )
group()->focusNextChild();
if ( out_ev->getFocusType() == fc::FocusPreviousWidget )
group()->focusPrevChild();
redraw();
}
else if ( this == group()->getLastButton()
&& out_ev->getFocusType() == fc::FocusNextWidget )
{
out_ev->ignore();
group()->focusNextChild(); group()->focusNextChild();
redraw();
} if ( out_ev->getFocusType() == fc::FocusPreviousWidget )
else if ( this == group()->getFirstButton()
&& out_ev->getFocusType() == fc::FocusPreviousWidget )
{
out_ev->ignore();
group()->focusPrevChild(); group()->focusPrevChild();
redraw();
} redraw();
}
else if ( this == group()->getLastButton()
&& out_ev->getFocusType() == fc::FocusNextWidget )
{
out_ev->ignore();
group()->focusNextChild();
redraw();
}
else if ( this == group()->getFirstButton()
&& out_ev->getFocusType() == fc::FocusPreviousWidget )
{
out_ev->ignore();
group()->focusPrevChild();
redraw();
} }
} }

View File

@ -39,18 +39,18 @@ FToolTip::~FToolTip() // destructor
{ {
FApplication* fapp = static_cast<FApplication*>(getRootWidget()); FApplication* fapp = static_cast<FApplication*>(getRootWidget());
if ( ! fapp->isQuit() ) if ( fapp->isQuit() )
{ return;
FWindow* parent_win = 0;
if ( FWidget* parent = getParentWidget() ) FWindow* parent_win = 0;
parent_win = getWindowWidget(parent);
if ( parent_win ) if ( FWidget* parent = getParentWidget() )
setActiveWindow (parent_win); parent_win = getWindowWidget(parent);
else
switchToPrevWindow(); if ( parent_win )
} setActiveWindow (parent_win);
else
switchToPrevWindow();
} }

View File

@ -58,21 +58,21 @@ FWindow::~FWindow() // destructor
void FWindow::deleteFromAlwaysOnTopList (FWidget* obj) void FWindow::deleteFromAlwaysOnTopList (FWidget* obj)
{ {
// delete the window object obj from the always-on-top list // delete the window object obj from the always-on-top list
if ( always_on_top_list && ! always_on_top_list->empty() ) if ( ! always_on_top_list || always_on_top_list->empty() )
return;
widgetList::iterator iter;
iter = always_on_top_list->begin();
while ( iter != always_on_top_list->end() )
{ {
widgetList::iterator iter; if ( *iter == obj )
iter = always_on_top_list->begin();
while ( iter != always_on_top_list->end() )
{ {
if ( *iter == obj ) always_on_top_list->erase (iter);
{ return;
always_on_top_list->erase (iter);
return;
}
++iter;
} }
++iter;
} }
} }
@ -80,20 +80,20 @@ void FWindow::deleteFromAlwaysOnTopList (FWidget* obj)
void FWindow::processAlwaysOnTop() void FWindow::processAlwaysOnTop()
{ {
// Raise all always-on-top windows // Raise all always-on-top windows
if ( always_on_top_list && ! always_on_top_list->empty() ) if ( ! always_on_top_list || always_on_top_list->empty() )
return;
widgetList::iterator iter;
iter = always_on_top_list->begin();
while ( iter != always_on_top_list->end() )
{ {
widgetList::iterator iter; delWindow (*iter);
iter = always_on_top_list->begin();
while ( iter != always_on_top_list->end() ) if ( window_list )
{ window_list->push_back(*iter);
delWindow (*iter);
if ( window_list ) ++iter;
window_list->push_back(*iter);
++iter;
}
} }
} }
@ -319,22 +319,22 @@ void FWindow::setGeometry (int x, int y, int w, int h, bool adjust)
FWidget::setGeometry (x, y, w, h, adjust); FWidget::setGeometry (x, y, w, h, adjust);
if ( vwin ) if ( ! vwin )
{ return;
if ( getWidth() != old_width || getHeight() != old_height )
{
FRect geometry = getTermGeometry();
geometry.move(-1,-1);
resizeArea (geometry, getShadow(), vwin);
}
else
{
if ( getX() != old_x )
vwin->x_offset = getTermX() - 1;
if ( getY() != old_y ) if ( getWidth() != old_width || getHeight() != old_height )
vwin->y_offset = getTermY() - 1; {
} FRect geometry = getTermGeometry();
geometry.move(-1,-1);
resizeArea (geometry, getShadow(), vwin);
}
else
{
if ( getX() != old_x )
vwin->x_offset = getTermX() - 1;
if ( getY() != old_y )
vwin->y_offset = getTermY() - 1;
} }
} }
@ -354,12 +354,6 @@ void FWindow::move (int dx, int dy)
FWindow* FWindow::getWindowWidgetAt (int x, int y) FWindow* FWindow::getWindowWidgetAt (int x, int y)
{ {
// returns the window object to the corresponding coordinates // returns the window object to the corresponding coordinates
if ( statusBar() && statusBar()->getTermGeometry().contains(x,y) )
return statusBar();
if ( menuBar() && menuBar()->getTermGeometry().contains(x,y) )
return menuBar();
if ( window_list && ! window_list->empty() ) if ( window_list && ! window_list->empty() )
{ {
widgetList::const_iterator iter, begin; widgetList::const_iterator iter, begin;
@ -761,7 +755,7 @@ bool FWindow::activatePrevWindow()
if ( w->isWindowActive() ) if ( w->isWindowActive() )
return true; return true;
if ( w && ! w->isWindowHidden() ) if ( ! w->isWindowHidden() )
{ {
setActiveWindow(w); setActiveWindow(w);
return true; return true;

View File

@ -48,25 +48,25 @@ Button::Button (FWidget* parent)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Button::setChecked (bool on) void Button::setChecked (bool on)
{ {
if ( checked != on ) if ( checked == on )
return;
checked = on;
if ( checked )
{ {
checked = on; setBackgroundColor(fc::Cyan);
setFocusForegroundColor(fc::White);
if ( checked ) setFocusBackgroundColor(fc::Cyan);
{
setBackgroundColor(fc::Cyan);
setFocusForegroundColor(fc::White);
setFocusBackgroundColor(fc::Cyan);
}
else
{
setBackgroundColor(wc.button_active_bg);
setFocusForegroundColor(wc.button_active_focus_fg);
setFocusBackgroundColor(wc.button_active_focus_bg);
}
redraw();
} }
else
{
setBackgroundColor(wc.button_active_bg);
setFocusForegroundColor(wc.button_active_focus_fg);
setFocusBackgroundColor(wc.button_active_focus_bg);
}
redraw();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -105,18 +105,18 @@ void Transparent::draw()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Transparent::onKeyPress (FKeyEvent* ev) void Transparent::onKeyPress (FKeyEvent* ev)
{ {
if ( ev ) if ( ! ev )
return;
if ( ev->key() == 'q' && getParentWidget() )
{ {
if ( ev->key() == 'q' && getParentWidget() ) if ( getParentWidget()->close() )
{ ev->accept();
if ( getParentWidget()->close() )
ev->accept();
else
ev->ignore();
}
else else
FDialog::onKeyPress(ev); ev->ignore();
} }
else
FDialog::onKeyPress(ev);
} }
@ -147,16 +147,16 @@ class MainWindow : public FDialog
void onTimer (FTimerEvent*); void onTimer (FTimerEvent*);
void onKeyPress (FKeyEvent* ev) void onKeyPress (FKeyEvent* ev)
{ {
if ( ev ) if ( ! ev )
return;
if ( ev->key() == 'q' )
{ {
if ( ev->key() == 'q' ) close();
{ ev->accept();
close();
ev->accept();
}
else
FDialog::onKeyPress(ev);
} }
else
FDialog::onKeyPress(ev);
} }
public: public:

View File

@ -122,23 +122,23 @@ void ProgressDialog::onTimer (FTimerEvent*)
progressBar->setPercentage(++p); progressBar->setPercentage(++p);
flush_out(); flush_out();
if ( p == 100 ) if ( p != 100 )
{ return;
delOwnTimer();
activateWindow();
raiseWindow();
reset->setEnable();
reset->setFocus();
more->setEnable();
quit->setEnable();
redraw();
if ( statusBar() ) delOwnTimer();
statusBar()->drawMessage(); activateWindow();
raiseWindow();
reset->setEnable();
reset->setFocus();
more->setEnable();
quit->setEnable();
redraw();
updateTerminal(); if ( statusBar() )
flush_out(); statusBar()->drawMessage();
}
updateTerminal();
flush_out();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -339,16 +339,16 @@ Window::~Window()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Window::activateWindow (FDialog* win) void Window::activateWindow (FDialog* win)
{ {
if ( win && ! win->isWindowHidden() && ! win->isWindowActive() ) if ( ! win || win->isWindowHidden() || win->isWindowActive() )
{ return;
bool has_raised = FWindow::raiseWindow(win);
win->activateDialog();
if ( has_raised ) bool has_raised = FWindow::raiseWindow(win);
win->redraw(); win->activateDialog();
updateTerminal(); if ( has_raised )
} win->redraw();
updateTerminal();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------