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>
* 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)
{
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();
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();
if ( click_animation )
setDown();
else
redraw();
if ( statusBar() )
statusBar()->drawMessage();
}
else if ( click_animation )
setDown();
if ( focused_widget )
focused_widget->redraw();
if ( click_animation )
addTimer(click_time);
setDown();
else
redraw();
processClick();
ev->accept();
if ( statusBar() )
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()
{
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;
iter = buttonlist.begin();
end = buttonlist.end();
if ( (*iter)->isEnabled() && (*iter)->acceptFocus() )
return (*iter);
while ( iter != end )
{
if ( (*iter)->isEnabled() && (*iter)->acceptFocus() )
return (*iter);
++iter;
}
++iter;
}
return 0;
@ -439,21 +439,21 @@ FToggleButton* FButtonGroup::getFirstButton()
//----------------------------------------------------------------------
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;
begin = buttonlist.begin();
iter = buttonlist.end();
--iter;
do
{
--iter;
if ( (*iter)->isEnabled() && (*iter)->acceptFocus() )
return (*iter);
}
while ( iter != begin );
if ( (*iter)->isEnabled() && (*iter)->acceptFocus() )
return (*iter);
}
while ( iter != begin );
return 0;
}
@ -461,19 +461,19 @@ FToggleButton* FButtonGroup::getLastButton()
//----------------------------------------------------------------------
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;
iter = buttonlist.begin();
end = buttonlist.end();
if ( (*iter)->hasFocus() )
return true;
while ( iter != end )
{
if ( (*iter)->hasFocus() )
return true;
++iter;
}
++iter;
}
return false;
@ -482,19 +482,19 @@ bool FButtonGroup::hasFocusedButton()
//----------------------------------------------------------------------
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;
iter = buttonlist.begin();
end = buttonlist.end();
if ( (*iter)->isChecked() )
return true;
while ( iter != end )
{
if ( (*iter)->isChecked() )
return true;
++iter;
}
++iter;
}
return false;

View File

@ -48,15 +48,15 @@ void FCheckMenuItem::init (FWidget* parent)
{
checkable = true;
if ( parent )
{
if ( isMenu(parent) ) // Parent is menu
{
FMenu* menu_ptr = dynamic_cast<FMenu*>(parent);
if ( ! parent )
return;
if ( menu_ptr )
menu_ptr->has_checkable_items = true;
}
if ( isMenu(parent) ) // Parent is menu
{
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()
{
if ( dir_entries.empty() )
return 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;
iter = dir_entries.begin();
end = dir_entries.end();
if ( (*iter).type == DT_DIR && std::strcmp((*iter).name, ".") != 0 )
n++;
while ( iter != end )
{
if ( (*iter).type == DT_DIR && std::strcmp((*iter).name, ".") != 0 )
n++;
++iter;
}
++iter;
}
return n;
@ -499,7 +498,9 @@ void FFileDialog::adjustSize()
FFileDialog& FFileDialog::operator = (const FFileDialog& fdlg)
{
if ( &fdlg == this )
{
return *this;
}
else
{
delete open;

View File

@ -736,30 +736,30 @@ void FLineEdit::onTimer (FTimerEvent*)
//----------------------------------------------------------------------
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());
FFocusEvent out (fc::FocusOut_Event);
FApplication::queueEvent(focused_widget, &out);
setFocus();
if ( focused_widget )
focused_widget->redraw();
redraw();
if ( statusBar() )
{
statusBar()->drawMessage();
updateTerminal();
flush_out();
}
statusBar()->drawMessage();
updateTerminal();
flush_out();
}
ev->accept();
}
ev->accept();
}
//----------------------------------------------------------------------

View File

@ -594,7 +594,7 @@ void FListBox::hide()
return;
blank = new char[size+1];
memset(blank, ' ', uLong(size));
std::memset (blank, ' ', uLong(size));
blank[size] = '\0';
for (int y=0; y < getHeight(); y++)
@ -612,23 +612,23 @@ void FListBox::showInsideBrackets ( int index
{
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 )
{
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();
}
if ( ! hbar->isVisible() )
hbar->setVisible();
}
}
}
@ -1787,7 +1787,7 @@ void FListBox::clear()
return;
blank = new char[size+1];
memset(blank, ' ', uLong(size));
std::memset (blank, ' ', uLong(size));
blank[size] = '\0';
for (int y=0; y < getHeight()-2; y++)

View File

@ -433,27 +433,27 @@ void FMenuItem::delAccelerator (FWidget* obj)
//----------------------------------------------------------------------
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 )
smenu->onKeyPress(ev);
}
if ( isMenuBar(super_menu) )
{
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu);
if ( mbar )
{
if ( mbar->hotkeyMenu(ev) )
return;
mbar->onKeyPress(ev);
}
mbar->onKeyPress(ev);
}
}
}
@ -461,48 +461,48 @@ void FMenuItem::onKeyPress (FKeyEvent* 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();
int b = ev->getButton();
FMenu* smenu = dynamic_cast<FMenu*>(super_menu);
if ( isMenu(super_menu) )
if ( smenu )
{
FMenu* smenu = dynamic_cast<FMenu*>(super_menu);
if ( smenu )
{
const FPoint& p2 = smenu->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseDoubleClick_Event, p2, t, b);
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);
if ( mbar )
{
const FPoint& p2 = mbar->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseDoubleClick_Event, p2, t, b);
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);
if ( dgl )
{
const FPoint& p2 = dgl->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseDoubleClick_Event, p2, t, b);
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)
{
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();
int b = ev->getButton();
FMenu* smenu = dynamic_cast<FMenu*>(super_menu);
if ( isMenu(super_menu) )
if ( smenu )
{
FMenu* smenu = dynamic_cast<FMenu*>(super_menu);
if ( smenu )
{
const FPoint& p2 = smenu->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseDown_Event, p2, t, b);
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);
if ( mbar )
{
const FPoint& p2 = mbar->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseDown_Event, p2, t, b);
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);
if ( dgl )
{
const FPoint& p2 = dgl->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseDown_Event, p2, t, b);
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)
{
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();
int b = ev->getButton();
FMenu* smenu = dynamic_cast<FMenu*>(super_menu);
if ( isMenu(super_menu) )
if ( smenu )
{
FMenu* smenu = dynamic_cast<FMenu*>(super_menu);
if ( smenu )
{
const FPoint& p2 = smenu->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseUp_Event, p2, t, b);
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);
if ( mbar )
{
const FPoint& p2 = mbar->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseUp_Event, p2, t, b);
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);
if ( dgl )
{
const FPoint& p2 = dgl->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseUp_Event, p2, t, b);
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)
{
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();
int b = ev->getButton();
FMenu* smenu = dynamic_cast<FMenu*>(super_menu);
if ( isMenu(super_menu) )
if ( smenu )
{
FMenu* smenu = dynamic_cast<FMenu*>(super_menu);
if ( smenu )
{
const FPoint& p2 = smenu->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p2, t, b);
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);
if ( mbar )
{
const FPoint& p2 = mbar->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p2, t, b);
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);
if ( dgl )
{
const FPoint& p2 = dgl->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p2, t, b);
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)
{
if ( isEnabled() && ! isSelected() )
if ( ! isEnabled() || isSelected() )
return;
if ( ! super_menu || ! isMenuBar(super_menu) )
{
if ( super_menu && isMenuBar(super_menu) )
{
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();
processClicked();
return;
}
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
{
// delete all items
if ( ! item_list.empty() )
{
std::vector<FMenuItem*>::iterator iter;
iter = item_list.begin();
if ( item_list.empty() )
return;
while ( iter != item_list.end() )
{
(*iter)->setSuperMenu(0);
iter = item_list.erase(iter);
}
std::vector<FMenuItem*>::iterator iter;
iter = item_list.begin();
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)
{
if ( &mbox == this )
{
return *this;
}
else
{
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)
{
@ -255,6 +243,18 @@ bool FObject::delAllTimer()
}
// 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*)
{ }

View File

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

View File

@ -69,38 +69,36 @@ int FOptiMove::capDuration (char*& cap, int affcnt)
// cap - the term capability
// affcnt - the number of lines affected
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
if ( ! cap )
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;
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 )
menu_ptr->has_checkable_items = true;
if ( menu_ptr )
menu_ptr->has_checkable_items = true;
this->addCallback
(
"toggled",
_METHOD_CALLBACK (parent, &FMenu::cb_menuitem_toggled)
);
}
this->addCallback
(
"toggled",
_METHOD_CALLBACK (parent, &FMenu::cb_menuitem_toggled)
);
}
}

View File

@ -92,20 +92,20 @@ void FStatusKey::processActivate()
//----------------------------------------------------------------------
void FStatusKey::onAccel (FAccelEvent* ev)
{
if ( ! isActivated() )
{
setActive();
if ( isActivated() )
return;
if ( statusbar() )
statusbar()->redraw();
setActive();
ev->accept();
// unset after get back from callback
unsetActive();
if ( statusbar() )
statusbar()->redraw();
if ( statusbar() )
statusbar()->redraw();
}
ev->accept();
// 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)
, c_string(0)
{
if ( ! s.empty() )
{
const wchar_t* wc_string;
wc_string = c_to_wc_str(s.c_str());
if ( s.empty() )
return;
if ( wc_string )
{
_replace( wc_string );
delete[] wc_string;
}
const wchar_t* wc_string;
wc_string = c_to_wc_str(s.c_str());
if ( wc_string )
{
_replace( wc_string );
delete[] wc_string;
}
}
@ -217,13 +217,13 @@ FString::~FString() // destructor
//----------------------------------------------------------------------
inline void FString::initLength (uInt len)
{
if ( len > 0 )
{
length = len;
bufsize = FWDBUFFER + len + 1;
string = new wchar_t[bufsize]();
std::wmemset (string, L'\0', bufsize);
}
if ( len == 0 )
return;
length = len;
bufsize = FWDBUFFER + len + 1;
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
//----------------------------------------------------------------------
FTerm::FTerm()
: map()
: color_map()
{
resize_term = false;
if ( ! term_initialized )
{
init();
}
}
//----------------------------------------------------------------------
@ -125,31 +123,100 @@ FTerm::~FTerm() // destructor
}
}
// private methods of FTerm
//----------------------------------------------------------------------
void FTerm::outb_Attribute_Controller (int index, int data)
inline uInt16 FTerm::getInputStatusRegisterOne()
{
inb (AttrC_DataSwitch);
outb (index & 0x1F, AttrC_Index);
outb (uChar(data), AttrC_DataW);
inb (AttrC_DataSwitch);
outb (uChar((index & 0x1F) | 0x20), AttrC_Index);
outb (uChar(data), AttrC_DataW);
// Gets the VGA input-status-register-1
uInt16 misc_read = 0x3cc; // Miscellaneous output (read port)
uInt16 io_base = (inb(misc_read) & 0x01) ? 0x3d0 : 0x3b0;
// 0x3ba : Input status 1 MDA (read port)
// 0x3da : Input status 1 CGA (read port)
return io_base + 0x0a;
}
//----------------------------------------------------------------------
int FTerm::inb_Attribute_Controller (int index)
uChar FTerm::readAttributeController (uChar index)
{
int res;
inb (AttrC_DataSwitch);
outb (index & 0x1F, AttrC_Index);
res = inb (AttrC_DataR);
inb (AttrC_DataSwitch);
outb (uChar((index & 0x1F) | 0x20), AttrC_Index);
inb (AttrC_DataR);
// Reads a byte from the attribute controller from a given index
uChar res;
uInt16 attrib_cntlr_write = 0x3c0; // Attribute controller (write port)
uInt16 attrib_cntlr_read = 0x3c1; // Attribute controller (read port)
uInt16 input_status_1 = getInputStatusRegisterOne();
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;
}
//----------------------------------------------------------------------
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 ()
{
@ -183,6 +250,7 @@ int FTerm::getFramebuffer_bpp ()
::close(fd);
}
}
return -1;
}
@ -313,7 +381,7 @@ int FTerm::getScreenFont()
return -1;
// 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.flags = 0;
@ -350,7 +418,7 @@ int FTerm::setScreenFont ( uChar* fontdata, uInt count
return -1;
// 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.flags = 0;
@ -445,6 +513,7 @@ int FTerm::getUnicodeMap()
else
return -1;
}
return 0;
}
@ -483,34 +552,6 @@ int FTerm::setUnicodeMap (struct unimapdesc* unimap)
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)
{
@ -693,7 +734,7 @@ FTerm::modifier_key& FTerm::getModifierKey()
{
char subcode = 6;
// fill bit field with 0
memset (&mod_key, 0x00, sizeof(mod_key));
std::memset (&mod_key, 0x00, sizeof(mod_key));
// TIOCLINUX, subcode=6
if ( ioctl(0, TIOCLINUX, &subcode) >= 0 )
@ -2827,7 +2868,7 @@ void FTerm::resetXTermHighlightBackground()
//----------------------------------------------------------------------
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++)
{
map.d[x].red = CurrentColors[x].red;
map.d[x].green = CurrentColors[x].green;
map.d[x].blue = CurrentColors[x].blue;
color_map.d[x].red = CurrentColors[x].red;
color_map.d[x].green = CurrentColors[x].green;
color_map.d[x].blue = CurrentColors[x].blue;
}
ioctl (0, PIO_CMAP, &map);
ioctl (0, PIO_CMAP, &color_map);
}*/
std::fflush(stdout);
@ -2957,31 +2998,31 @@ void FTerm::setEncoding (std::string enc)
// available encodings: "UTF8", "VT100", "PC" and "ASCII"
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
|| Encoding == fc::VT100
|| Encoding == fc::PC
|| Encoding == fc::ASCII );
// set the new Fputchar function pointer
switch ( int(Encoding) )
{
case fc::UTF8:
case fc::VT100:
case fc::PC:
if ( xterm_terminal && utf8_console )
Fputchar = &FTerm::putchar_UTF8;
break;
case fc::VT100:
case fc::PC:
if ( xterm_terminal && utf8_console )
Fputchar = &FTerm::putchar_UTF8;
// fall through
case fc::ASCII:
default:
Fputchar = &FTerm::putchar_ASCII;
}
// 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 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
#define NEED_MORE_DATA -1
@ -164,7 +157,7 @@ class FTerm
struct
{
dacreg d[16];
} map;
} color_map;
protected:
static int stdin_no;
@ -190,8 +183,12 @@ class FTerm
// Disable assignment operator (=)
FTerm& operator = (const FTerm&);
static void outb_Attribute_Controller (int, int);
static int inb_Attribute_Controller (int);
static uInt16 getInputStatusRegisterOne();
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 openConsole();
static int closeConsole();
@ -201,7 +198,6 @@ class FTerm
static int setScreenFont (uChar*, uInt, uInt, uInt, bool = false);
static int setUnicodeMap (struct unimapdesc*);
static int getUnicodeMap ();
static int setBlinkAsIntensity (bool);
static void init_console();
static uInt getBaudRate (const struct termios*);
static char* init_256colorTerminal();

View File

@ -485,24 +485,24 @@ void FToggleButton::onMouseDown (FMouseEvent* ev)
if ( ev->getButton() != fc::LeftButton )
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();
FFocusEvent out (fc::FocusOut_Event);
FApplication::queueEvent(focused_widget, &out);
setFocus();
if ( focused_widget )
focused_widget->redraw();
redraw();
if ( statusBar() )
{
statusBar()->drawMessage();
updateTerminal();
flush_out();
}
statusBar()->drawMessage();
updateTerminal();
flush_out();
}
}
@ -512,68 +512,69 @@ void FToggleButton::onMouseUp (FMouseEvent* ev)
if ( ev->getButton() != fc::LeftButton )
return;
if ( getTermGeometry().contains(ev->getTermPos()) )
if ( ! getTermGeometry().contains(ev->getTermPos()) )
return;
if ( isRadioButton() )
{
if ( isRadioButton() )
if ( ! checked )
{
if ( ! checked )
{
checked = true;
processToggle();
}
}
else
{
checked = not checked;
checked = true;
processToggle();
}
redraw();
processClick();
}
else
{
checked = not checked;
processToggle();
}
redraw();
processClick();
}
//----------------------------------------------------------------------
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);
FApplication::queueEvent(focused_widget, &out);
setFocus();
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();
}
if ( focused_widget )
focused_widget->redraw();
}
if ( isRadioButton() )
if ( isRadioButton() )
{
if ( ! checked )
{
if ( ! checked )
{
checked = true;
processToggle();
}
}
else
{
checked = not checked;
checked = true;
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();
}
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 )
group()->focusNextChild();
if ( out_ev->getFocusType() == fc::FocusPreviousWidget )
group()->focusPrevChild();
redraw();
}
else if ( this == group()->getLastButton()
&& out_ev->getFocusType() == fc::FocusNextWidget )
{
out_ev->ignore();
if ( out_ev->getFocusType() == fc::FocusNextWidget )
group()->focusNextChild();
redraw();
}
else if ( this == group()->getFirstButton()
&& out_ev->getFocusType() == fc::FocusPreviousWidget )
{
out_ev->ignore();
if ( out_ev->getFocusType() == fc::FocusPreviousWidget )
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());
if ( ! fapp->isQuit() )
{
FWindow* parent_win = 0;
if ( fapp->isQuit() )
return;
if ( FWidget* parent = getParentWidget() )
parent_win = getWindowWidget(parent);
FWindow* parent_win = 0;
if ( parent_win )
setActiveWindow (parent_win);
else
switchToPrevWindow();
}
if ( FWidget* parent = getParentWidget() )
parent_win = getWindowWidget(parent);
if ( parent_win )
setActiveWindow (parent_win);
else
switchToPrevWindow();
}

View File

@ -58,21 +58,21 @@ FWindow::~FWindow() // destructor
void FWindow::deleteFromAlwaysOnTopList (FWidget* obj)
{
// 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;
iter = always_on_top_list->begin();
while ( iter != always_on_top_list->end() )
if ( *iter == obj )
{
if ( *iter == obj )
{
always_on_top_list->erase (iter);
return;
}
++iter;
always_on_top_list->erase (iter);
return;
}
++iter;
}
}
@ -80,20 +80,20 @@ void FWindow::deleteFromAlwaysOnTopList (FWidget* obj)
void FWindow::processAlwaysOnTop()
{
// 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;
iter = always_on_top_list->begin();
delWindow (*iter);
while ( iter != always_on_top_list->end() )
{
delWindow (*iter);
if ( window_list )
window_list->push_back(*iter);
if ( window_list )
window_list->push_back(*iter);
++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);
if ( vwin )
{
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 ( ! vwin )
return;
if ( getY() != old_y )
vwin->y_offset = getTermY() - 1;
}
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 )
vwin->y_offset = getTermY() - 1;
}
}
@ -354,12 +354,6 @@ void FWindow::move (int dx, int dy)
FWindow* FWindow::getWindowWidgetAt (int x, int y)
{
// 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() )
{
widgetList::const_iterator iter, begin;
@ -761,7 +755,7 @@ bool FWindow::activatePrevWindow()
if ( w->isWindowActive() )
return true;
if ( w && ! w->isWindowHidden() )
if ( ! w->isWindowHidden() )
{
setActiveWindow(w);
return true;

View File

@ -48,25 +48,25 @@ Button::Button (FWidget* parent)
//----------------------------------------------------------------------
void Button::setChecked (bool on)
{
if ( checked != on )
if ( checked == on )
return;
checked = on;
if ( checked )
{
checked = on;
if ( checked )
{
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();
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();
}
//----------------------------------------------------------------------

View File

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

View File

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

View File

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