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,8 +731,9 @@ void FButton::onTimer (FTimerEvent* ev)
//----------------------------------------------------------------------
void FButton::onAccel (FAccelEvent* ev)
{
if ( isEnabled() )
{
if ( ! isEnabled() )
return;
if ( ! hasFocus() )
{
FWidget* focused_widget = static_cast<FWidget*>(ev->focusedWidget());
@ -760,7 +761,6 @@ void FButton::onAccel (FAccelEvent* ev)
processClick();
ev->accept();
}
}
//----------------------------------------------------------------------
void FButton::onFocusIn (FFocusEvent*)

View File

@ -418,8 +418,9 @@ 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();
@ -431,7 +432,6 @@ FToggleButton* FButtonGroup::getFirstButton()
++iter;
}
}
return 0;
}
@ -439,8 +439,9 @@ 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();
@ -453,7 +454,6 @@ FToggleButton* FButtonGroup::getLastButton()
return (*iter);
}
while ( iter != begin );
}
return 0;
}
@ -461,8 +461,9 @@ 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();
@ -474,7 +475,6 @@ bool FButtonGroup::hasFocusedButton()
++iter;
}
}
return false;
}
@ -482,8 +482,9 @@ 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();
@ -495,7 +496,6 @@ bool FButtonGroup::hasCheckedButton()
++iter;
}
}
return false;
}

View File

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

View File

@ -253,10 +253,10 @@ void FFileDialog::clear()
//----------------------------------------------------------------------
int FFileDialog::numOfDirs()
{
int n = 0;
if ( dir_entries.empty() )
return 0;
if ( ! dir_entries.empty() )
{
int n = 0;
std::vector<dir_entry>::const_iterator iter, end;
iter = dir_entries.begin();
end = dir_entries.end();
@ -268,7 +268,6 @@ int FFileDialog::numOfDirs()
++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,8 +736,9 @@ void FLineEdit::onTimer (FTimerEvent*)
//----------------------------------------------------------------------
void FLineEdit::onAccel (FAccelEvent* ev)
{
if ( isEnabled() )
{
if ( ! isEnabled() )
return;
if ( ! hasFocus() )
{
FWidget* focused_widget = static_cast<FWidget*>(ev->focusedWidget());
@ -760,7 +761,6 @@ void FLineEdit::onAccel (FAccelEvent* ev)
ev->accept();
}
}
//----------------------------------------------------------------------
void FLineEdit::onHide (FHideEvent*)

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,8 +612,9 @@ 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 )
@ -631,7 +632,6 @@ void FListBox::showInsideBrackets ( int index
}
}
}
}
//----------------------------------------------------------------------
void FListBox::setGeometry (int x, int y, int w, int h, bool adjust)
@ -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,8 +433,9 @@ void FMenuItem::delAccelerator (FWidget* obj)
//----------------------------------------------------------------------
void FMenuItem::onKeyPress (FKeyEvent* ev)
{
if ( super_menu )
{
if ( ! super_menu )
return;
if ( isMenu(super_menu) )
{
FMenu* smenu = dynamic_cast<FMenu*>(super_menu);
@ -456,13 +457,13 @@ 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();
@ -505,13 +506,13 @@ 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();
@ -554,13 +555,13 @@ 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();
@ -603,13 +604,13 @@ 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();
@ -652,19 +653,24 @@ void FMenuItem::onMouseMove (FMouseEvent* ev)
}
}
}
}
//----------------------------------------------------------------------
void FMenuItem::onAccel (FAccelEvent* ev)
{
if ( isEnabled() && ! isSelected() )
{
if ( super_menu && isMenuBar(super_menu) )
if ( ! isEnabled() || isSelected() )
return;
if ( ! super_menu || ! isMenuBar(super_menu) )
{
processClicked();
return;
}
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu);
if ( mbar )
{
if ( ! mbar )
return;
if ( menu )
{
FWidget* focused_widget;
@ -706,11 +712,6 @@ void FMenuItem::onAccel (FAccelEvent* ev)
}
ev->accept();
}
}
else
processClicked();
}
}
//----------------------------------------------------------------------
void FMenuItem::onFocusIn (FFocusEvent*)

View File

@ -18,8 +18,9 @@ FMenuList::FMenuList()
FMenuList::~FMenuList() // destructor
{
// delete all items
if ( ! item_list.empty() )
{
if ( item_list.empty() )
return;
std::vector<FMenuItem*>::iterator iter;
iter = item_list.begin();
@ -29,7 +30,6 @@ FMenuList::~FMenuList() // destructor
iter = item_list.erase(iter);
}
}
}
// public methods of FMenuList

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,8 +69,9 @@ int FOptiMove::capDuration (char*& cap, int affcnt)
// cap - the term capability
// affcnt - the number of lines affected
if ( cap )
{
if ( ! cap )
return LONG_DURATION;
const char* p;
float ms = 0;
@ -99,9 +100,6 @@ int FOptiMove::capDuration (char*& cap, int affcnt)
return int(ms);
}
else
return LONG_DURATION;
}
// public methods of FOptiMove

View File

@ -49,8 +49,9 @@ void FRadioMenuItem::init (FWidget* parent)
checkable = true;
radio_button = true;
if ( parent )
{
if ( ! parent )
return;
if ( isMenu(parent) ) // Parent is menu
{
FMenu* menu_ptr = dynamic_cast<FMenu*>(parent);
@ -65,7 +66,6 @@ void FRadioMenuItem::init (FWidget* parent)
);
}
}
}
//----------------------------------------------------------------------
void FRadioMenuItem::processToggle()

View File

@ -92,8 +92,9 @@ void FStatusKey::processActivate()
//----------------------------------------------------------------------
void FStatusKey::onAccel (FAccelEvent* ev)
{
if ( ! isActivated() )
{
if ( isActivated() )
return;
setActive();
if ( statusbar() )
@ -106,7 +107,6 @@ void FStatusKey::onAccel (FAccelEvent* ev)
if ( statusbar() )
statusbar()->redraw();
}
}
//----------------------------------------------------------------------
FStatusBar* FStatusKey::statusbar() const

View File

@ -146,8 +146,9 @@ FString::FString (const std::string& s)
, bufsize(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());
@ -157,7 +158,6 @@ FString::FString (const std::string& s)
delete[] wc_string;
}
}
}
//----------------------------------------------------------------------
FString::FString (const char* s)
@ -217,14 +217,14 @@ FString::~FString() // destructor
//----------------------------------------------------------------------
inline void FString::initLength (uInt len)
{
if ( len > 0 )
{
if ( len == 0 )
return;
length = len;
bufsize = FWDBUFFER + len + 1;
string = new wchar_t[bufsize]();
std::wmemset (string, L'\0', bufsize);
}
}
//----------------------------------------------------------------------
inline void FString::_replace (const wchar_t* s)

View File

@ -101,15 +101,13 @@ fc::consoleCursorStyle FTerm::console_cursor_style;
// constructors and destructor
//----------------------------------------------------------------------
FTerm::FTerm()
: map()
: color_map()
{
resize_term = false;
if ( ! term_initialized )
{
init();
}
}
//----------------------------------------------------------------------
FTerm::~FTerm() // destructor
@ -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,8 +2998,9 @@ 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
@ -2983,7 +3025,6 @@ void FTerm::setEncoding (std::string enc)
Fputchar = &FTerm::putchar_ASCII;
}
}
}
//----------------------------------------------------------------------
std::string FTerm::getEncoding()

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,8 +485,9 @@ 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);
@ -504,7 +505,6 @@ void FToggleButton::onMouseDown (FMouseEvent* ev)
flush_out();
}
}
}
//----------------------------------------------------------------------
void FToggleButton::onMouseUp (FMouseEvent* ev)
@ -512,8 +512,9 @@ 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 ( ! checked )
@ -527,16 +528,17 @@ void FToggleButton::onMouseUp (FMouseEvent* ev)
checked = not checked;
processToggle();
}
redraw();
processClick();
}
}
//----------------------------------------------------------------------
void FToggleButton::onAccel (FAccelEvent* ev)
{
if ( isEnabled() )
{
if ( ! isEnabled() )
return;
if ( ! hasFocus() )
{
FWidget* focused_widget = static_cast<FWidget*>(ev->focusedWidget());
@ -574,7 +576,6 @@ void FToggleButton::onAccel (FAccelEvent* ev)
processClick();
ev->accept();
}
}
//----------------------------------------------------------------------
void FToggleButton::onFocusIn (FFocusEvent*)
@ -592,8 +593,9 @@ void FToggleButton::onFocusOut (FFocusEvent* out_ev)
statusBar()->drawMessage();
}
if ( group() )
{
if ( ! group() )
return;
if ( ! focus_inside_group && isRadioButton() )
{
focus_inside_group = true;
@ -622,7 +624,6 @@ void FToggleButton::onFocusOut (FFocusEvent* out_ev)
redraw();
}
}
}
//----------------------------------------------------------------------
bool FToggleButton::setChecked (bool on)

View File

@ -39,8 +39,9 @@ FToolTip::~FToolTip() // destructor
{
FApplication* fapp = static_cast<FApplication*>(getRootWidget());
if ( ! fapp->isQuit() )
{
if ( fapp->isQuit() )
return;
FWindow* parent_win = 0;
if ( FWidget* parent = getParentWidget() )
@ -51,7 +52,6 @@ FToolTip::~FToolTip() // destructor
else
switchToPrevWindow();
}
}
// private methods of FToolTip

View File

@ -58,8 +58,9 @@ 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();
@ -74,14 +75,14 @@ void FWindow::deleteFromAlwaysOnTopList (FWidget* obj)
++iter;
}
}
}
//----------------------------------------------------------------------
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();
@ -95,7 +96,6 @@ void FWindow::processAlwaysOnTop()
++iter;
}
}
}
// protected methods of FWindow
@ -319,8 +319,9 @@ void FWindow::setGeometry (int x, int y, int w, int h, bool adjust)
FWidget::setGeometry (x, y, w, h, adjust);
if ( vwin )
{
if ( ! vwin )
return;
if ( getWidth() != old_width || getHeight() != old_height )
{
FRect geometry = getTermGeometry();
@ -336,7 +337,6 @@ void FWindow::setGeometry (int x, int y, int w, int h, bool adjust)
vwin->y_offset = getTermY() - 1;
}
}
}
//----------------------------------------------------------------------
void FWindow::move (int dx, int dy)
@ -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,8 +48,9 @@ Button::Button (FWidget* parent)
//----------------------------------------------------------------------
void Button::setChecked (bool on)
{
if ( checked != on )
{
if ( checked == on )
return;
checked = on;
if ( checked )
@ -67,7 +68,6 @@ void Button::setChecked (bool on)
redraw();
}
}
//----------------------------------------------------------------------
void Button::onKeyPress (FKeyEvent* ev)

View File

@ -105,8 +105,9 @@ void Transparent::draw()
//----------------------------------------------------------------------
void Transparent::onKeyPress (FKeyEvent* ev)
{
if ( ev )
{
if ( ! ev )
return;
if ( ev->key() == 'q' && getParentWidget() )
{
if ( getParentWidget()->close() )
@ -117,7 +118,6 @@ void Transparent::onKeyPress (FKeyEvent* ev)
else
FDialog::onKeyPress(ev);
}
}
//----------------------------------------------------------------------
@ -147,8 +147,9 @@ class MainWindow : public FDialog
void onTimer (FTimerEvent*);
void onKeyPress (FKeyEvent* ev)
{
if ( ev )
{
if ( ! ev )
return;
if ( ev->key() == 'q' )
{
close();
@ -157,7 +158,6 @@ class MainWindow : public FDialog
else
FDialog::onKeyPress(ev);
}
}
public:
// Constructor

View File

@ -122,8 +122,9 @@ void ProgressDialog::onTimer (FTimerEvent*)
progressBar->setPercentage(++p);
flush_out();
if ( p == 100 )
{
if ( p != 100 )
return;
delOwnTimer();
activateWindow();
raiseWindow();
@ -139,7 +140,6 @@ void ProgressDialog::onTimer (FTimerEvent*)
updateTerminal();
flush_out();
}
}
//----------------------------------------------------------------------
void ProgressDialog::cb_reset_bar (FWidget*, void*)

View File

@ -339,8 +339,9 @@ Window::~Window()
//----------------------------------------------------------------------
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();
@ -349,7 +350,6 @@ void Window::activateWindow (FDialog* win)
updateTerminal();
}
}
//----------------------------------------------------------------------
void Window::onClose (FCloseEvent* ev)