Add a transparent example program + improve transparent shadow

This commit is contained in:
Markus Gans 2016-08-21 21:27:44 +02:00
parent f870506194
commit 7d0cf3383e
26 changed files with 464 additions and 167 deletions

1
.gitignore vendored
View File

@ -31,6 +31,7 @@ test/watch
test/menu test/menu
test/windows test/windows
test/term-attributes test/term-attributes
test/transparent
test/input-dialog test/input-dialog
test/mandelbrot test/mandelbrot
test/keyboard test/keyboard

View File

@ -1,3 +1,7 @@
2016-08-21 Markus Gans <guru.mail@muenster.de>
* Improved transparent shadow background
* Add "transparent" example to demonstrate transparency
2016-08-20 Markus Gans <guru.mail@muenster.de> 2016-08-20 Markus Gans <guru.mail@muenster.de>
* Switch back to the own dialog when you closing a dialog menu * Switch back to the own dialog when you closing a dialog menu
* switchToPrevWindow() is looking for another window * switchToPrevWindow() is looking for another window

View File

@ -54,7 +54,7 @@ FApplication::FApplication (int& _argc, char**& _argv)
&& "FApplication: There should be only one application object" ); && "FApplication: There should be only one application object" );
rootObj = this; rootObj = this;
if ( ! _argc || ! _argv ) if ( ! (_argc && _argv) )
{ {
static char* empty = const_cast<char*>(""); static char* empty = const_cast<char*>("");
_argc = 0; _argc = 0;
@ -466,7 +466,7 @@ int FApplication::modifierKeyCorrection (int& key_id)
getModifierKey(); getModifierKey();
modifier_key& m = mod_key; modifier_key& m = mod_key;
if ( ! m.shift && ! m.ctrl && ! m.alt ) if ( ! (m.shift || m.ctrl || m.alt) )
{ {
return key_id; return key_id;
} }
@ -1752,15 +1752,18 @@ void FApplication::setMainWidget (FWidget* widget)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FApplication::exec() // run int FApplication::exec() // run
{ {
FWidget* focus_widget;
quit_now = false; quit_now = false;
quit_code = 0; quit_code = 0;
// set the cursor to the focus widget // set the cursor to the focus widget
if ( getFocusWidget() focus_widget = getFocusWidget();
&& getFocusWidget()->isVisible()
&& getFocusWidget()->hasVisibleCursor() ) if ( focus_widget
&& focus_widget->isVisible()
&& focus_widget->hasVisibleCursor() )
{ {
getFocusWidget()->setCursor(); focus_widget->setCursor();
showCursor(); showCursor();
flush_out(); flush_out();
} }
@ -1779,7 +1782,7 @@ int FApplication::enter_loop() // event loop
old_app_exit_loop = app_exit_loop; old_app_exit_loop = app_exit_loop;
app_exit_loop = false; app_exit_loop = false;
while ( ! quit_now && ! app_exit_loop ) while ( ! (quit_now || app_exit_loop) )
processNextEvent(); processNextEvent();
app_exit_loop = old_app_exit_loop; app_exit_loop = old_app_exit_loop;

View File

@ -134,6 +134,7 @@ void FButton::draw()
register wchar_t* dest; register wchar_t* dest;
wchar_t* ButtonText; wchar_t* ButtonText;
FString txt; FString txt;
FWidget* parent_widget = getParentWidget();
int active_focus; int active_focus;
int d, i, j, x, mono_offset, margin; int d, i, j, x, mono_offset, margin;
int length, hotkeypos, hotkey_offset, space; int length, hotkeypos, hotkey_offset, space;
@ -173,8 +174,10 @@ void FButton::draw()
clearFlatBorder(); clearFlatBorder();
clearShadow(); clearShadow();
setColor ( getParentWidget()->getForegroundColor()
, getParentWidget()->getBackgroundColor() ); if ( parent_widget )
setColor ( parent_widget->getForegroundColor()
, parent_widget->getBackgroundColor() );
for (int y=1; y <= height; y++) for (int y=1; y <= height; y++)
{ {
@ -243,7 +246,9 @@ void FButton::draw()
} }
else if ( ! isMonochron() ) else if ( ! isMonochron() )
{ {
setColor (button_bg, getParentWidget()->getBackgroundColor()); if ( parent_widget )
setColor (button_bg, parent_widget->getBackgroundColor());
gotoxy (xpos+xmin-1+d, ypos+ymin-1); gotoxy (xpos+xmin-1+d, ypos+ymin-1);
for (int y=1; y <= height; y++) for (int y=1; y <= height; y++)
@ -265,8 +270,9 @@ void FButton::draw()
&& (is_Flat || ! hasShadow() || isMonochron()) ) && (is_Flat || ! hasShadow() || isMonochron()) )
{ {
// clear the right █ from button down // clear the right █ from button down
setColor ( getParentWidget()->getForegroundColor() if ( parent_widget )
, getParentWidget()->getBackgroundColor() ); setColor ( parent_widget->getForegroundColor()
, parent_widget->getBackgroundColor() );
for (int y=1; y <= height; y++) for (int y=1; y <= height; y++)
{ {
@ -365,8 +371,10 @@ void FButton::draw()
if ( is_NonFlatShadow && ! button_down ) if ( is_NonFlatShadow && ! button_down )
{ {
setColor ( getParentWidget()->getForegroundColor() if ( parent_widget )
, getParentWidget()->getBackgroundColor() ); setColor ( parent_widget->getForegroundColor()
, parent_widget->getBackgroundColor() );
print(' '); // restore background after button down print(' '); // restore background after button down
drawShadow(); drawShadow();
} }
@ -488,10 +496,20 @@ void FButton::hide()
int s, f, size; int s, f, size;
short fg, bg; short fg, bg;
char* blank; char* blank;
FWidget* parent_widget = getParentWidget();
FWidget::hide(); FWidget::hide();
fg = getParentWidget()->getForegroundColor();
bg = getParentWidget()->getBackgroundColor(); if ( parent_widget )
{
fg = parent_widget->getForegroundColor();
bg = parent_widget->getBackgroundColor();
}
else
{
fg = wc.dialog_fg;
bg = wc.dialog_bg;
}
setColor (fg, bg); setColor (fg, bg);
s = hasShadow() ? 1 : 0; s = hasShadow() ? 1 : 0;
f = isFlat() ? 1 : 0; f = isFlat() ? 1 : 0;

View File

@ -102,7 +102,10 @@ void FButtonGroup::directFocus()
if ( focused_widget ) if ( focused_widget )
focused_widget->redraw(); focused_widget->redraw();
getFocusWidget()->redraw(); focused_widget = getFocusWidget();
if ( focused_widget )
focused_widget->redraw();
} }
break; break;
@ -122,7 +125,10 @@ void FButtonGroup::directFocus()
if ( focused_widget ) if ( focused_widget )
focused_widget->redraw(); focused_widget->redraw();
getFocusWidget()->redraw(); focused_widget = getFocusWidget();
if ( focused_widget )
focused_widget->redraw();
} }
} }
@ -283,6 +289,7 @@ void FButtonGroup::hide()
short fg, bg; short fg, bg;
char* blank; char* blank;
FWidget::hide(); FWidget::hide();
FWidget* parent_widget = getParentWidget();
if ( ! buttonlist.empty() ) if ( ! buttonlist.empty() )
{ {
@ -297,10 +304,18 @@ void FButtonGroup::hide()
} }
} }
fg = getParentWidget()->getForegroundColor(); if ( parent_widget )
bg = getParentWidget()->getBackgroundColor(); {
setColor (fg, bg); fg = parent_widget->getForegroundColor();
bg = parent_widget->getBackgroundColor();
}
else
{
fg = wc.dialog_fg;
bg = wc.dialog_bg;
}
setColor (fg, bg);
size = width; size = width;
blank = new char[size+1]; blank = new char[size+1];
memset(blank, ' ', uLong(size)); memset(blank, ' ', uLong(size));
@ -318,7 +333,7 @@ void FButtonGroup::hide()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FButtonGroup::insert (FToggleButton* button) void FButtonGroup::insert (FToggleButton* button)
{ {
if ( button->group() ) if ( button && button->group() )
button->group()->remove(button); button->group()->remove(button);
// setChecked the first FRadioButton // setChecked the first FRadioButton
@ -533,6 +548,7 @@ void FButtonGroup::onFocusIn (FFocusEvent* in_ev)
if ( prev_element ) if ( prev_element )
prev_element->redraw(); prev_element->redraw();
if ( getFocusWidget() )
getFocusWidget()->redraw(); getFocusWidget()->redraw();
} }
else if ( in_ev->getFocusType() == fc::FocusPreviousWidget ) else if ( in_ev->getFocusType() == fc::FocusPreviousWidget )
@ -544,6 +560,7 @@ void FButtonGroup::onFocusIn (FFocusEvent* in_ev)
if ( prev_element ) if ( prev_element )
prev_element->redraw(); prev_element->redraw();
if ( getFocusWidget() )
getFocusWidget()->redraw(); getFocusWidget()->redraw();
} }
} }

View File

@ -158,7 +158,7 @@ void FDialog::drawBorder()
{ {
short fg; short fg;
if ( ! isRootWidget() ) if ( ! isRootWidget() && getParentWidget() )
fg = getParentWidget()->getForegroundColor(); fg = getParentWidget()->getForegroundColor();
else else
fg = wc.term_fg; fg = wc.term_fg;
@ -306,7 +306,10 @@ void FDialog::leaveMenu()
dialog_menu->hide(); dialog_menu->hide();
activateWindow(); activateWindow();
raiseWindow(); raiseWindow();
if ( getWindowFocusWidget() )
getWindowFocusWidget()->setFocus(); getWindowFocusWidget()->setFocus();
redraw(); redraw();
if ( statusBar() ) if ( statusBar() )
@ -752,7 +755,7 @@ void FDialog::onMouseDoubleClick (FMouseEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FDialog::onAccel (FAccelEvent*) void FDialog::onAccel (FAccelEvent*)
{ {
if ( ! isHiddenWindow() && ! isActiveWindow() ) if ( ! (isHiddenWindow() || isActiveWindow()) )
{ {
bool has_raised = raiseWindow(); bool has_raised = raiseWindow();
activateDialog(); activateDialog();
@ -771,12 +774,13 @@ void FDialog::onWindowActive (FEvent*)
drawTitleBar(); drawTitleBar();
if ( ! FWidget::getFocusWidget() ) if ( ! FWidget::getFocusWidget() )
{
if ( getWindowFocusWidget()
&& getWindowFocusWidget()->isVisible()
&& getWindowFocusWidget()->isShown() )
{ {
FWidget* win_focus_widget = getWindowFocusWidget(); FWidget* win_focus_widget = getWindowFocusWidget();
if ( win_focus_widget
&& win_focus_widget->isVisible()
&& win_focus_widget->isShown() )
{
win_focus_widget->setFocus(); win_focus_widget->setFocus();
win_focus_widget->redraw(); win_focus_widget->redraw();
} }
@ -808,7 +812,7 @@ void FDialog::onWindowRaised (FEvent*)
{ {
widgetList::const_iterator iter, end; widgetList::const_iterator iter, end;
if ( ! isVisible() || ! isShown() ) if ( ! (isVisible() && isShown()) )
return; return;
putArea (getGlobalPos(), vwin); putArea (getGlobalPos(), vwin);
@ -869,12 +873,14 @@ void FDialog::show()
FWindow::show(); FWindow::show();
// set the cursor to the focus widget // set the cursor to the focus widget
if ( FWidget::getFocusWidget() FWidget* focus_widget = FWidget::getFocusWidget();
&& FWidget::getFocusWidget()->isVisible()
&& FWidget::getFocusWidget()->hasVisibleCursor() if ( focus_widget
&& FWidget::getFocusWidget()->isCursorInside() ) && focus_widget->isVisible()
&& focus_widget->hasVisibleCursor()
&& focus_widget->isCursorInside() )
{ {
FWidget::getFocusWidget()->setCursor(); focus_widget->setCursor();
showCursor(); showCursor();
flush_out(); flush_out();
} }
@ -1003,14 +1009,15 @@ void FDialog::move (int x, int y)
FWidget::adjustSize(); FWidget::adjustSize();
// set the cursor to the focus widget // set the cursor to the focus widget
if ( FWidget::getFocusWidget() FWidget* focus_widget = FWidget::getFocusWidget();
&& FWidget::getFocusWidget()->isVisible() if ( focus_widget
&& FWidget::getFocusWidget()->hasVisibleCursor() ) && focus_widget->isVisible()
&& focus_widget->hasVisibleCursor() )
{ {
FPoint cursor_pos = FWidget::getFocusWidget()->getCursorPos(); FPoint cursor_pos = focus_widget->getCursorPos();
cursor_pos -= FPoint(dx,dy); cursor_pos -= FPoint(dx,dy);
if ( ! FWidget::getFocusWidget()->setCursorPos(cursor_pos) ) if ( ! focus_widget->setCursorPos(cursor_pos) )
hideCursor(); hideCursor();
} }

View File

@ -105,6 +105,7 @@ FFileDialog::~FFileDialog() // destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FFileDialog::init() void FFileDialog::init()
{ {
FWidget* parent_widget;
int x, y; int x, y;
height = 15; height = 15;
width = 42; width = 42;
@ -115,8 +116,15 @@ void FFileDialog::init()
if ( width < 20 ) if ( width < 20 )
width = 20; width = 20;
x = 1 + int((getParentWidget()->getWidth()-width)/2); parent_widget = getParentWidget();
y = 1 + int((getParentWidget()->getHeight()-height)/3);
if ( parent_widget )
{
x = 1 + int((parent_widget->getWidth()-width)/2);
y = 1 + int((parent_widget->getHeight()-height)/3);
}
else
x = y = 1;
if ( dlg_type == FFileDialog::Save ) if ( dlg_type == FFileDialog::Save )
FDialog::setText("Save file"); FDialog::setText("Save file");
@ -461,10 +469,21 @@ void FFileDialog::cb_processShowHidden (FWidget*, void*)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FFileDialog::adjustSize() void FFileDialog::adjustSize()
{ {
int X, Y; int h, X, Y, max_width, max_height;
int max_height = getRootWidget()->getClientHeight(); FWidget* root_widget = getRootWidget();
int max_width = getRootWidget()->getClientWidth();
int h = max_height - 6; if ( root_widget )
{
max_width = root_widget->getClientWidth();
max_height = root_widget->getClientHeight();
}
else
{
max_width = 80;
max_height = 24;
}
h = max_height - 6;
if ( h < 15 ) // minimum if ( h < 15 ) // minimum
h = 15; h = 15;
@ -499,7 +518,10 @@ FFileDialog& FFileDialog::operator = (const FFileDialog& fdlg)
delete filebrowser; delete filebrowser;
delete filename; delete filename;
clear(); clear();
if ( fdlg.getParentWidget() )
fdlg.getParentWidget()->addChild (this); fdlg.getParentWidget()->addChild (this);
directory = fdlg.directory; directory = fdlg.directory;
filter_pattern = fdlg.filter_pattern; filter_pattern = fdlg.filter_pattern;
dlg_type = fdlg.dlg_type; dlg_type = fdlg.dlg_type;

View File

@ -55,12 +55,23 @@ FLabel::~FLabel() // destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FLabel::init() void FLabel::init()
{ {
FWidget* parent_widget = getParentWidget();
if ( isEnabled() ) if ( isEnabled() )
flags |= fc::active; flags |= fc::active;
unsetFocusable(); unsetFocusable();
foregroundColor = getParentWidget()->getForegroundColor();
backgroundColor = getParentWidget()->getBackgroundColor(); if ( parent_widget )
{
foregroundColor = parent_widget->getForegroundColor();
backgroundColor = parent_widget->getBackgroundColor();
}
else
{
foregroundColor = wc.dialog_fg;
backgroundColor = wc.dialog_bg;
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -327,10 +338,21 @@ void FLabel::hide()
{ {
short fg, bg; short fg, bg;
char* blank; char* blank;
FWidget* parent_widget = getParentWidget();
FWidget::hide(); FWidget::hide();
fg = getParentWidget()->getForegroundColor();
bg = getParentWidget()->getBackgroundColor(); if ( parent_widget )
{
fg = parent_widget->getForegroundColor();
bg = parent_widget->getBackgroundColor();
}
else
{
fg = wc.dialog_fg;
bg = wc.dialog_bg;
}
setColor (fg, bg); setColor (fg, bg);
blank = new char[width+1]; blank = new char[width+1];
memset(blank, ' ', uLong(width)); memset(blank, ' ', uLong(width));
@ -345,7 +367,7 @@ void FLabel::onMouseDown (FMouseEvent* ev)
if ( ev->getButton() != fc::LeftButton ) if ( ev->getButton() != fc::LeftButton )
return; return;
if ( ! isEnabled() || ! accel_widget ) if ( ! (isEnabled() && accel_widget) )
return; return;
if ( ! accel_widget->hasFocus() ) if ( ! accel_widget->hasFocus() )
@ -372,7 +394,7 @@ void FLabel::onMouseDown (FMouseEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FLabel::onAccel (FAccelEvent* ev) void FLabel::onAccel (FAccelEvent* ev)
{ {
if ( ! isEnabled() || ! accel_widget ) if ( ! (isEnabled() && accel_widget) )
return; return;
if ( ! accel_widget->hasFocus() ) if ( ! accel_widget->hasFocus() )

View File

@ -289,10 +289,21 @@ void FLineEdit::hide()
int s, size, lable_Length; int s, size, lable_Length;
short fg, bg; short fg, bg;
char* blank; char* blank;
FWidget* parent_widget = getParentWidget();
FWidget::hide(); FWidget::hide();
fg = getParentWidget()->getForegroundColor();
bg = getParentWidget()->getBackgroundColor(); if ( parent_widget )
{
fg = parent_widget->getForegroundColor();
bg = parent_widget->getBackgroundColor();
}
else
{
fg = wc.dialog_fg;
bg = wc.dialog_bg;
}
setColor (fg, bg); setColor (fg, bg);
s = hasShadow() ? 1 : 0; s = hasShadow() ? 1 : 0;
size = width + s; size = width + s;

View File

@ -585,10 +585,21 @@ void FListBox::hide()
int n, size; int n, size;
short fg, bg; short fg, bg;
char* blank; char* blank;
FWidget* parent_widget = getParentWidget();
FWidget::hide(); FWidget::hide();
fg = getParentWidget()->getForegroundColor();
bg = getParentWidget()->getBackgroundColor(); if ( parent_widget )
{
fg = parent_widget->getForegroundColor();
bg = parent_widget->getBackgroundColor();
}
else
{
fg = wc.dialog_fg;
bg = wc.dialog_bg;
}
setColor (fg, bg); setColor (fg, bg);
n = isNewFont() ? 1 : 0; n = isNewFont() ? 1 : 0;
size = width + n; size = width + n;
@ -1018,8 +1029,10 @@ void FListBox::onMouseDown (FMouseEvent* ev)
FFocusEvent out (fc::FocusOut_Event); FFocusEvent out (fc::FocusOut_Event);
FApplication::queueEvent(focused_widget, &out); FApplication::queueEvent(focused_widget, &out);
setFocus(); setFocus();
if ( focused_widget ) if ( focused_widget )
focused_widget->redraw(); focused_widget->redraw();
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
} }

View File

@ -998,7 +998,10 @@ void FMenu::onKeyPress (FKeyEvent* ev)
FMenu* smenu = reinterpret_cast<FMenu*>(getSuperMenu()); FMenu* smenu = reinterpret_cast<FMenu*>(getSuperMenu());
hideSubMenus(); hideSubMenus();
hide(); hide();
if ( smenu->getSelectedItem() )
smenu->getSelectedItem()->setFocus(); smenu->getSelectedItem()->setFocus();
smenu->redraw(); smenu->redraw();
if ( statusBar() ) if ( statusBar() )
@ -1034,7 +1037,10 @@ void FMenu::onKeyPress (FKeyEvent* ev)
if ( isSubMenu() ) if ( isSubMenu() )
{ {
FMenu* smenu = reinterpret_cast<FMenu*>(getSuperMenu()); FMenu* smenu = reinterpret_cast<FMenu*>(getSuperMenu());
if ( smenu->getSelectedItem() )
smenu->getSelectedItem()->setFocus(); smenu->getSelectedItem()->setFocus();
smenu->redraw(); smenu->redraw();
} }
else else
@ -1045,7 +1051,7 @@ void FMenu::onKeyPress (FKeyEvent* ev)
if ( statusBar() ) if ( statusBar() )
statusBar()->clearMessage(); statusBar()->clearMessage();
if ( ! super || ! isWindowsMenu(super) ) if ( ! (super && isWindowsMenu(super)) )
switchToPrevWindow(); switchToPrevWindow();
} }
@ -1088,7 +1094,10 @@ void FMenu::onMouseDown (FMouseEvent* ev)
open_sub_menu->hideSubMenus(); open_sub_menu->hideSubMenus();
open_sub_menu->hide(); open_sub_menu->hide();
open_sub_menu = 0; open_sub_menu = 0;
if ( getSelectedItem() )
getSelectedItem()->setFocus(); getSelectedItem()->setFocus();
redraw(); redraw();
if ( statusBar() ) if ( statusBar() )
@ -1150,8 +1159,10 @@ void FMenu::onMouseDown (FMouseEvent* ev)
raiseWindow (open_sub_menu); raiseWindow (open_sub_menu);
open_sub_menu->redraw(); open_sub_menu->redraw();
sel_item->setFocus(); sel_item->setFocus();
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
updateTerminal(); updateTerminal();
flush_out(); flush_out();
} }
@ -1504,12 +1515,14 @@ void FMenu::show()
FWindow::show(); FWindow::show();
// set the cursor to the focus widget // set the cursor to the focus widget
if ( FWidget::getFocusWidget() FWidget* focus_widget = FWidget::getFocusWidget();
&& FWidget::getFocusWidget()->isVisible()
&& FWidget::getFocusWidget()->hasVisibleCursor() if ( focus_widget
&& FWidget::getFocusWidget()->isCursorInside() ) && focus_widget->isVisible()
&& focus_widget->hasVisibleCursor()
&& focus_widget->isCursorInside() )
{ {
FWidget::getFocusWidget()->setCursor(); focus_widget->setCursor();
showCursor(); showCursor();
flush_out(); flush_out();
} }

View File

@ -50,7 +50,10 @@ void FMenuBar::init()
// initialize geometry values // initialize geometry values
setGeometry (1, 1, getColumnNumber(), 1, false); setGeometry (1, 1, getColumnNumber(), 1, false);
setMenuBar(this); setMenuBar(this);
if ( getRootWidget() )
getRootWidget()->setTopPadding(1, true); getRootWidget()->setTopPadding(1, true);
addAccelerator (fc::Fkey_f10); addAccelerator (fc::Fkey_f10);
addAccelerator (fc::Fckey_space); addAccelerator (fc::Fckey_space);
foregroundColor = wc.menu_active_fg; foregroundColor = wc.menu_active_fg;

View File

@ -681,6 +681,8 @@ void FMenuItem::onAccel (FAccelEvent* ev)
FApplication::queueEvent(focused_widget, &out); FApplication::queueEvent(focused_widget, &out);
menu->unselectItem(); menu->unselectItem();
menu->selectFirstItem(); menu->selectFirstItem();
if ( menu->getSelectedItem() )
menu->getSelectedItem()->setFocus(); menu->getSelectedItem()->setFocus();
if ( focused_widget ) if ( focused_widget )

View File

@ -194,6 +194,7 @@ void FMessageBox::msg_dimension()
{ {
int x, y, w, h; int x, y, w, h;
int headline_height = 0; int headline_height = 0;
FWidget* parent_widget = getParentWidget();
text_split = text.split("\n"); text_split = text.split("\n");
text_num_lines = uInt(text_split.size()); text_num_lines = uInt(text_split.size());
text_components = &text_split[0]; text_components = &text_split[0];
@ -216,8 +217,14 @@ void FMessageBox::msg_dimension()
if ( w < 20 ) if ( w < 20 )
w = 20; w = 20;
x = 1 + int((getParentWidget()->getWidth()-w)/2); if ( parent_widget )
y = 1 + int((getParentWidget()->getHeight()-h)/3); {
x = 1 + int((parent_widget->getWidth()-w)/2);
y = 1 + int((parent_widget->getHeight()-h)/3);
}
else
x = y = 1;
setGeometry (x, y, w, h); setGeometry (x, y, w, h);
} }
@ -313,8 +320,10 @@ void FMessageBox::adjustButtons()
if ( btn_width >= width-4 ) if ( btn_width >= width-4 )
{ {
int max_width;
FWidget* root_widget = getRootWidget();
setWidth(btn_width + 5); setWidth(btn_width + 5);
int max_width = getRootWidget()->getClientWidth(); max_width = ( root_widget ) ? root_widget->getClientWidth() : 80;
setX (int((max_width-width) / 2)); setX (int((max_width-width) / 2));
} }
@ -345,8 +354,19 @@ void FMessageBox::cb_processClick (FWidget*, void* data_ptr)
void FMessageBox::adjustSize() void FMessageBox::adjustSize()
{ {
int X, Y, max_width, max_height; int X, Y, max_width, max_height;
max_height = getRootWidget()->getClientHeight(); FWidget* root_widget = getRootWidget();
max_width = getRootWidget()->getClientWidth();
if ( root_widget )
{
max_width = root_widget->getClientWidth();
max_height = root_widget->getClientHeight();
}
else
{
max_width = 80;
max_height = 24;
}
X = 1 + int((max_width-width)/2); X = 1 + int((max_width-width)/2);
Y = 1 + int((max_height-height)/3); Y = 1 + int((max_height-height)/3);
setPos(X, Y, false); setPos(X, Y, false);
@ -369,6 +389,7 @@ FMessageBox& FMessageBox::operator = (const FMessageBox& mbox)
delete button_digit[1]; delete button_digit[1];
delete button_digit[0]; delete button_digit[0];
if ( mbox.getParentWidget() )
mbox.getParentWidget()->addChild (this); mbox.getParentWidget()->addChild (this);
headline_text = mbox.headline_text; headline_text = mbox.headline_text;

View File

@ -202,7 +202,7 @@ void FOptiAttr::change_color (char_data*& term, char_data*& next)
char* sp = F_set_color_pair.cap; char* sp = F_set_color_pair.cap;
short fg, bg; short fg, bg;
if ( monochron || ! term || ! next ) if ( monochron || ! (term && next) )
return; return;
fg = next->fg_color; fg = next->fg_color;
@ -399,7 +399,7 @@ bool FOptiAttr::caused_reset_attributes (char*& cap, uChar test)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FOptiAttr::detectSwitchOn (char_data*& term, char_data*& next) inline void FOptiAttr::detectSwitchOn (char_data*& term, char_data*& next)
{ {
if ( ! term || ! next ) if ( ! (term && next) )
return; return;
on.bold = ! term->bold && next->bold; on.bold = ! term->bold && next->bold;
@ -420,7 +420,7 @@ inline void FOptiAttr::detectSwitchOn (char_data*& term, char_data*& next)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FOptiAttr::detectSwitchOff (char_data*& term, char_data*& next) inline void FOptiAttr::detectSwitchOff (char_data*& term, char_data*& next)
{ {
if ( ! term || ! next ) if ( ! (term && next) )
return; return;
off.bold = term->bold && ! next->bold; off.bold = term->bold && ! next->bold;
@ -1330,7 +1330,7 @@ char* FOptiAttr::change_attribute (char_data*& term, char_data*& next)
fake_reverse = false; fake_reverse = false;
attr_buf[0] = '\0'; attr_buf[0] = '\0';
if ( ! term || ! next ) if ( ! (term && next) )
return attr_buf; return attr_buf;
prevent_no_color_video_attributes (next); prevent_no_color_video_attributes (next);

View File

@ -25,8 +25,13 @@ FProgressbar::~FProgressbar()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FProgressbar::drawPercentage() void FProgressbar::drawPercentage()
{ {
setColor ( getParentWidget()->getForegroundColor() FWidget* parent_widget = getParentWidget();
, getParentWidget()->getBackgroundColor() );
if ( parent_widget )
setColor ( parent_widget->getForegroundColor()
, parent_widget->getBackgroundColor() );
else
setColor ( wc.dialog_fg, wc.dialog_bg );
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
@ -71,12 +76,15 @@ void FProgressbar::drawBar()
print (fc::MediumShade); print (fc::MediumShade);
} }
if ( getParentWidget() )
{
if ( round(length) >= 1) if ( round(length) >= 1)
setColor ( wc.progressbar_fg setColor ( wc.progressbar_fg
, getParentWidget()->getBackgroundColor() ); , getParentWidget()->getBackgroundColor() );
else else
setColor ( wc.progressbar_bg setColor ( wc.progressbar_bg
, getParentWidget()->getBackgroundColor() ); , getParentWidget()->getBackgroundColor() );
}
if ( ! isMonochron() && getMaxColor() >= 16 ) if ( ! isMonochron() && getMaxColor() >= 16 )
{ {
@ -169,10 +177,21 @@ void FProgressbar::hide()
int s, size; int s, size;
short fg, bg; short fg, bg;
char* blank; char* blank;
FWidget* parent_widget = getParentWidget();
FWidget::hide(); FWidget::hide();
fg = getParentWidget()->getForegroundColor();
bg = getParentWidget()->getBackgroundColor(); if ( parent_widget )
{
fg = parent_widget->getForegroundColor();
bg = parent_widget->getBackgroundColor();
}
else
{
fg = wc.dialog_fg;
bg = wc.dialog_bg;
}
setColor (fg, bg); setColor (fg, bg);
s = hasShadow() ? 1 : 0; s = hasShadow() ? 1 : 0;
size = width + s; size = width + s;

View File

@ -77,6 +77,8 @@ void FStatusKey::init (FWidget* parent)
, const_cast<char*>("FStatusBar") ) == 0 ) , const_cast<char*>("FStatusBar") ) == 0 )
{ {
setStatusbar( static_cast<FStatusBar*>(parent) ); setStatusbar( static_cast<FStatusBar*>(parent) );
if ( statusbar() )
statusbar()->insert(this); statusbar()->insert(this);
} }
} }
@ -93,10 +95,15 @@ void FStatusKey::onAccel (FAccelEvent* ev)
if ( ! isActivated() ) if ( ! isActivated() )
{ {
setActive(); setActive();
if ( statusbar() )
statusbar()->redraw(); statusbar()->redraw();
ev->accept(); ev->accept();
// unset after get back from callback // unset after get back from callback
unsetActive(); unsetActive();
if ( statusbar() )
statusbar()->redraw(); statusbar()->redraw();
} }
} }
@ -196,7 +203,10 @@ void FStatusBar::init()
// initialize geometry values // initialize geometry values
setGeometry (1, ypos, getColumnNumber(), 1, false); setGeometry (1, ypos, getColumnNumber(), 1, false);
setStatusBar(this); setStatusBar(this);
if ( getRootWidget() )
getRootWidget()->setBottomPadding(1, true); getRootWidget()->setBottomPadding(1, true);
foregroundColor = wc.statusbar_fg; foregroundColor = wc.statusbar_fg;
backgroundColor = wc.statusbar_bg; backgroundColor = wc.statusbar_bg;
unsetFocusable(); unsetFocusable();
@ -217,11 +227,15 @@ void FStatusBar::drawKeys()
{ {
std::vector<FStatusKey*>::const_iterator iter, end; std::vector<FStatusKey*>::const_iterator iter, end;
int screenWidth, lastLine; int screenWidth, lastLine;
x = 1;
if ( ! vstatusbar )
return;
screenWidth = getColumnNumber(); screenWidth = getColumnNumber();
lastLine = getLineNumber(); lastLine = getLineNumber();
width = screenWidth; width = screenWidth;
ypos = lastLine; ypos = lastLine;
x = 1;
if ( keylist.empty() ) if ( keylist.empty() )
{ {
@ -577,7 +591,7 @@ void FStatusBar::drawMessage()
int termWidth, lastLine, space_offset; int termWidth, lastLine, space_offset;
bool isLastActiveFocus, hasKeys; bool isLastActiveFocus, hasKeys;
if ( ! isVisible() ) if ( ! (isVisible() && vstatusbar) )
return; return;
if ( x < 0 || x_msg < 0 ) if ( x < 0 || x_msg < 0 )

View File

@ -1225,7 +1225,7 @@ FString FString::ltrim() const
FString s(string); FString s(string);
// handle NULL and empty string // handle NULL and empty string
if ( ! string || ! *string ) if ( ! (string && *string) )
return s; return s;
p = s.string; p = s.string;
@ -1244,7 +1244,7 @@ FString FString::rtrim() const
FString s(string); FString s(string);
// handle NULL and empty string // handle NULL and empty string
if ( ! string || ! *string ) if ( ! (string && *string) )
return s; return s;
p = s.string; p = s.string;
@ -1264,7 +1264,7 @@ FString FString::rtrim() const
FString FString::trim() const FString FString::trim() const
{ {
// handle NULL and empty string // handle NULL and empty string
if ( ! string || ! *string ) if ( ! (string && *string) )
return (*this); return (*this);
FString s(ltrim()); FString s(ltrim());
@ -1278,7 +1278,7 @@ FString FString::left(uInt len) const
FString s(string); FString s(string);
// handle NULL and empty string // handle NULL and empty string
if ( ! string || ! *string ) if ( ! (string && *string) )
return s; return s;
if ( len > length ) if ( len > length )
@ -1296,7 +1296,7 @@ FString FString::right(uInt len) const
FString s(string); FString s(string);
// handle NULL and empty string // handle NULL and empty string
if ( ! string || ! *string ) if ( ! (string && *string) )
return s; return s;
if ( len > length ) if ( len > length )
@ -1315,7 +1315,7 @@ FString FString::mid(uInt pos, uInt len) const
FString s(string); FString s(string);
// handle NULL and empty string // handle NULL and empty string
if ( ! string || ! *string ) if ( ! (string && *string) )
return s; return s;
if ( pos == 0 ) if ( pos == 0 )
@ -1342,7 +1342,7 @@ std::vector<FString> FString::split (const FString& delimiter)
std::vector<FString> stringList; std::vector<FString> stringList;
// handle NULL and empty string // handle NULL and empty string
if ( ! string || ! *string ) if ( ! (string && *string) )
return stringList; return stringList;
rest = 0; rest = 0;
@ -1545,7 +1545,7 @@ bool FString::operator < (const FString& s) const
if ( ! string && s.string ) if ( ! string && s.string )
return true; return true;
if ( ! string && ! s.string ) if ( ! (string || s.string) )
return false; return false;
return (wcscmp(string, s.string) < 0); return (wcscmp(string, s.string) < 0);
@ -1605,7 +1605,7 @@ bool FString::operator <= (const FString& s) const
if ( ! string && s.string ) if ( ! string && s.string )
return true; return true;
if ( ! string && ! s.string ) if ( ! (string || s.string) )
return true; return true;
return (wcscmp(string, s.string) <= 0); return (wcscmp(string, s.string) <= 0);
@ -1662,7 +1662,7 @@ bool FString::operator == (const FString& s) const
if ( (string && ! s.string ) || (! string && s.string) ) if ( (string && ! s.string ) || (! string && s.string) )
return false; return false;
if ( ! string && ! s.string ) if ( ! (string || s.string) )
return true; return true;
return (wcscmp(string, s.string) == 0); return (wcscmp(string, s.string) == 0);
@ -1719,7 +1719,7 @@ bool FString::operator != (const FString& s) const
if ( (string && ! s.string ) || (! string && s.string) ) if ( (string && ! s.string ) || (! string && s.string) )
return true; return true;
if ( ! string && ! s.string ) if ( ! (string || s.string) )
return false; return false;
return (wcscmp(string, s.string) != 0); return (wcscmp(string, s.string) != 0);
@ -1779,7 +1779,7 @@ bool FString::operator >= (const FString& s) const
if ( ! string && s.string ) if ( ! string && s.string )
return false; return false;
if ( ! string && ! s.string ) if ( ! (string || s.string) )
return true; return true;
return (wcscmp(string, s.string) >= 0); return (wcscmp(string, s.string) >= 0);
@ -1839,7 +1839,7 @@ bool FString::operator > (const FString& s) const
if ( ! string && s.string ) if ( ! string && s.string )
return false; return false;
if ( ! string && ! s.string ) if ( ! (string || s.string) )
return false; return false;
return (wcscmp(string, s.string) > 0); return (wcscmp(string, s.string) > 0);
@ -1935,7 +1935,7 @@ FString FString::replace (const FString& from, const FString& to)
FString s(string); FString s(string);
// handle NULL and empty string // handle NULL and empty string
if ( ! string || ! *string ) if ( ! (string && *string) )
return s; return s;
if ( from.isNull() || to.isNull() ) if ( from.isNull() || to.isNull() )
@ -2219,7 +2219,7 @@ FString FString::replace (const wchar_t from, const FString& to)
FString s(string); FString s(string);
// handle NULL and empty string // handle NULL and empty string
if ( ! string || ! *string ) if ( ! (string && *string) )
return s; return s;
if ( to.isNull() ) if ( to.isNull() )
@ -2337,7 +2337,7 @@ FString FString::replace (const char from, const char to)
FString s(string); FString s(string);
// handle NULL and empty string // handle NULL and empty string
if ( ! string || ! *string ) if ( ! (string && *string) )
return s; return s;
p = s.string; p = s.string;

View File

@ -1900,7 +1900,7 @@ void FTerm::init()
if ( ! gnome_terminal ) if ( ! gnome_terminal )
setXTermCursorColor("rgb:ffff/ffff/ffff"); setXTermCursorColor("rgb:ffff/ffff/ffff");
if ( ! mintty_terminal && ! rxvt_terminal && ! screen_terminal ) if ( ! (mintty_terminal || rxvt_terminal || screen_terminal) )
{ {
// mintty and rxvt can't reset these settings // mintty and rxvt can't reset these settings
setXTermBackground("rgb:8080/a4a4/ecec"); setXTermBackground("rgb:8080/a4a4/ecec");
@ -2025,7 +2025,7 @@ void FTerm::finish()
resetXTermHighlightBackground(); resetXTermHighlightBackground();
setXTermCursorStyle(fc::steady_block); setXTermCursorStyle(fc::steady_block);
if ( max_color >= 16 && ! kde_konsole && ! tera_terminal ) if ( max_color >= 16 && ! (kde_konsole || tera_terminal) )
{ {
// reset screen settings // reset screen settings
setPalette (fc::Cyan, 0x18, 0xb2, 0xb2); setPalette (fc::Cyan, 0x18, 0xb2, 0xb2);
@ -2431,15 +2431,16 @@ void FTerm::restoreVTerm (int x, int y, int w, int h)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FTerm::isCovered (int x, int y, FTerm::term_area* area) const FTerm::covered_state FTerm::isCovered (int x, int y, FTerm::term_area* area) const
{ {
bool covered, found; bool found;
FTerm::covered_state is_covered;
FWidget* w; FWidget* w;
if ( ! area ) if ( ! area )
return false; return non_covered;
covered = false; is_covered = non_covered;
found = bool(area == vdesktop); found = bool(area == vdesktop);
x++; x++;
y++; y++;
@ -2468,9 +2469,13 @@ bool FTerm::isCovered (int x, int y, FTerm::term_area* area) const
int line_len = win->width + win->right_shadow; int line_len = win->width + win->right_shadow;
tmp = &win->text[(y-win_y-1) * line_len + (x-win_x-1)]; tmp = &win->text[(y-win_y-1) * line_len + (x-win_x-1)];
if ( ! tmp->transparent ) if ( tmp->trans_shadow )
{ {
covered = true; is_covered = half_covered;
}
else if ( ! tmp->transparent )
{
is_covered = fully_covered;
break; break;
} }
} }
@ -2493,7 +2498,7 @@ bool FTerm::isCovered (int x, int y, FTerm::term_area* area) const
if ( area != vmenubar && menubar if ( area != vmenubar && menubar
&& menubar->getGeometryGlobal().contains(x,y) ) && menubar->getGeometryGlobal().contains(x,y) )
{ {
covered = true; is_covered = fully_covered;
} }
// statusbar is always on top // statusbar is always on top
@ -2507,10 +2512,10 @@ bool FTerm::isCovered (int x, int y, FTerm::term_area* area) const
if ( area != vstatusbar && statusbar if ( area != vstatusbar && statusbar
&& statusbar->getGeometryGlobal().contains(x,y) ) && statusbar->getGeometryGlobal().contains(x,y) )
{ {
covered = true; is_covered = fully_covered;
} }
return covered; return is_covered;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -2573,6 +2578,7 @@ void FTerm::updateVTerm (FTerm::term_area* area)
for (register int x=line_xmin; x <= line_xmax; x++) // column loop for (register int x=line_xmin; x <= line_xmax; x++) // column loop
{ {
int gx, gy, line_len; int gx, gy, line_len;
FTerm::covered_state is_covered;
gx = ax + x; // global position gx = ax + x; // global position
gy = ay + y; gy = ay + y;
@ -2582,10 +2588,21 @@ void FTerm::updateVTerm (FTerm::term_area* area)
line_len = aw + rsh; line_len = aw + rsh;
ac = &area->text[y * line_len + x]; ac = &area->text[y * line_len + x];
tc = &vterm->text[gy * vterm->width + gx - ol]; tc = &vterm->text[gy * vterm->width + gx - ol];
is_covered = isCovered(gx-ol, gy, area); // get covered state
if ( ! isCovered(gx-ol, gy, area) ) if ( is_covered != fully_covered )
{ {
if ( ac->transparent ) // transparent if ( is_covered == half_covered )
{
// add the overlapping color to this character
FOptiAttr::char_data ch, oc;
memcpy (&ch, ac, sizeof(FOptiAttr::char_data));
oc = getOverlappedCharacter (gx+1, gy+1, area->widget);
ch.fg_color = oc.fg_color;
ch.bg_color = oc.bg_color;
memcpy (tc, &ch, sizeof(FOptiAttr::char_data));
}
else if ( ac->transparent ) // transparent
{ {
// restore one character on vterm // restore one character on vterm
FOptiAttr::char_data ch; FOptiAttr::char_data ch;
@ -2831,8 +2848,12 @@ void FTerm::putArea (int ax, int ay, FTerm::term_area* area)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FOptiAttr::char_data FTerm::getCoveredCharacter (int x, int y, FTerm* obj) FOptiAttr::char_data FTerm::getCharacter ( int char_type
, int x
, int y
, FTerm* obj )
{ {
// get the overlapped or the covered character for a position
int xx,yy; int xx,yy;
FOptiAttr::char_data* cc; // covered character FOptiAttr::char_data* cc; // covered character
FOptiAttr::char_data s_ch; // shadow character FOptiAttr::char_data s_ch; // shadow character
@ -2867,7 +2888,14 @@ FOptiAttr::char_data FTerm::getCoveredCharacter (int x, int y, FTerm* obj)
while ( iter != end ) while ( iter != end )
{ {
if ( obj && *iter != obj && layer >= FWindow::getWindowLayer(*iter) ) bool significant_char;
if ( char_type == covered_character )
significant_char = bool(layer >= FWindow::getWindowLayer(*iter));
else
significant_char = bool(layer < FWindow::getWindowLayer(*iter));
if ( obj && *iter != obj && significant_char )
{ {
term_area* win = (*iter)->getVWin(); term_area* win = (*iter)->getVWin();
const FRect& geometry = (*iter)->getGeometryGlobalShadow(); const FRect& geometry = (*iter)->getGeometryGlobalShadow();
@ -2899,7 +2927,7 @@ FOptiAttr::char_data FTerm::getCoveredCharacter (int x, int y, FTerm* obj)
} }
} }
} }
else else if ( char_type == covered_character )
break; break;
++iter; ++iter;
@ -2909,7 +2937,6 @@ FOptiAttr::char_data FTerm::getCoveredCharacter (int x, int y, FTerm* obj)
return *cc; return *cc;
} }
// public methods of FTerm // public methods of FTerm
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FTerm::setVGAFont() bool FTerm::setVGAFont()
@ -3038,7 +3065,7 @@ bool FTerm::setOldFont()
{ {
bool retval; bool retval;
if ( ! NewFont && ! VGAFont ) if ( ! (NewFont || VGAFont) )
return false; return false;
retval = \ retval = \
@ -3437,7 +3464,7 @@ FString FTerm::getXTermTitle()
void FTerm::setXTermCursorStyle (fc::xterm_cursor_style style) void FTerm::setXTermCursorStyle (fc::xterm_cursor_style style)
{ {
// Set the xterm cursor style // Set the xterm cursor style
if ( (xterm || mintty_terminal) && ! gnome_terminal && ! kde_konsole ) if ( (xterm || mintty_terminal) && ! (gnome_terminal || kde_konsole) )
{ {
putstringf (CSI "%d q", style); putstringf (CSI "%d q", style);
fflush(stdout); fflush(stdout);

View File

@ -199,6 +199,19 @@ class FTerm
uChar : 4; // padding bits uChar : 4; // padding bits
} mod_key; } mod_key;
enum covered_state
{
non_covered,
half_covered,
fully_covered
};
enum character_type
{
overlapped_character,
covered_character
};
protected: protected:
static bool NewFont; static bool NewFont;
static bool VGAFont; static bool VGAFont;
@ -276,8 +289,8 @@ class FTerm
void resizeArea (FTerm::term_area*); void resizeArea (FTerm::term_area*);
void restoreVTerm (const FRect&); void restoreVTerm (const FRect&);
void restoreVTerm (int, int, int, int); void restoreVTerm (int, int, int, int);
bool isCovered (const FPoint&, FTerm::term_area*) const; FTerm::covered_state isCovered (const FPoint&, FTerm::term_area*) const;
bool isCovered (int, int, FTerm::term_area*) const; FTerm::covered_state isCovered (int, int, FTerm::term_area*) const;
void updateVTerm (FTerm::term_area*); void updateVTerm (FTerm::term_area*);
void updateVTerm (bool); void updateVTerm (bool);
void getArea (const FPoint&, FTerm::term_area*); void getArea (const FPoint&, FTerm::term_area*);
@ -286,8 +299,12 @@ class FTerm
void getArea (int, int, int, int, FTerm::term_area*); void getArea (int, int, int, int, FTerm::term_area*);
void putArea (const FPoint&, FTerm::term_area*); void putArea (const FPoint&, FTerm::term_area*);
void putArea (int, int, FTerm::term_area*); void putArea (int, int, FTerm::term_area*);
FOptiAttr::char_data getCharacter (int, const FPoint&, FTerm*);
FOptiAttr::char_data getCharacter (int, int, int, FTerm*);
FOptiAttr::char_data getCoveredCharacter (const FPoint&, FTerm*); FOptiAttr::char_data getCoveredCharacter (const FPoint&, FTerm*);
FOptiAttr::char_data getCoveredCharacter (int, int, FTerm*); FOptiAttr::char_data getCoveredCharacter (int, int, FTerm*);
FOptiAttr::char_data getOverlappedCharacter (const FPoint&, FTerm*);
FOptiAttr::char_data getOverlappedCharacter (int, int, FTerm*);
public: public:
FTerm (); // constructor FTerm (); // constructor
@ -438,7 +455,8 @@ class FTerm
// FTerm inline functions // FTerm inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTerm::isCovered(const FPoint& pos, FTerm::term_area* area) const inline FTerm::covered_state FTerm::isCovered ( const FPoint& pos
, FTerm::term_area* area) const
{ return isCovered (pos.getX(), pos.getY(), area); } { return isCovered (pos.getX(), pos.getY(), area); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -455,9 +473,25 @@ inline void FTerm::getArea (const FRect& box, FTerm::term_area* area)
, area ); , area );
} }
//----------------------------------------------------------------------
inline FOptiAttr::char_data FTerm::getCharacter (int type, const FPoint& pos, FTerm* obj)
{ return getCharacter (type, pos.getX(), pos.getY(), obj); }
//----------------------------------------------------------------------
inline FOptiAttr::char_data FTerm::getCoveredCharacter (int x, int y, FTerm* obj)
{ return getCharacter (covered_character, x, y, obj); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FOptiAttr::char_data FTerm::getCoveredCharacter (const FPoint& pos, FTerm* obj) inline FOptiAttr::char_data FTerm::getCoveredCharacter (const FPoint& pos, FTerm* obj)
{ return getCoveredCharacter (pos.getX(), pos.getY(), obj); } { return getCharacter (covered_character, pos.getX(), pos.getY(), obj); }
//----------------------------------------------------------------------
inline FOptiAttr::char_data FTerm::getOverlappedCharacter (int x, int y, FTerm* obj)
{ return getCharacter (overlapped_character, x, y, obj); }
//----------------------------------------------------------------------
inline FOptiAttr::char_data FTerm::getOverlappedCharacter (const FPoint& pos, FTerm* obj)
{ return getCharacter (overlapped_character, pos.getX(), pos.getY(), obj); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FTerm::getClassName() const inline const char* FTerm::getClassName() const

View File

@ -205,10 +205,21 @@ void FTextView::hide()
int n, size; int n, size;
short fg, bg; short fg, bg;
char* blank; char* blank;
FWidget* parent_widget = getParentWidget();
FWidget::hide(); FWidget::hide();
fg = getParentWidget()->getForegroundColor();
bg = getParentWidget()->getBackgroundColor(); if ( parent_widget )
{
fg = parent_widget->getForegroundColor();
bg = parent_widget->getBackgroundColor();
}
else
{
fg = wc.dialog_fg;
bg = wc.dialog_bg;
}
setColor (fg, bg); setColor (fg, bg);
n = isNewFont() ? 1 : 0; n = isNewFont() ? 1 : 0;
size = width + n; size = width + n;

View File

@ -28,6 +28,8 @@ FToggleButton::FToggleButton(FWidget* parent)
, const_cast<char*>("FButtonGroup") ) == 0 ) , const_cast<char*>("FButtonGroup") ) == 0 )
{ {
setGroup( static_cast<FButtonGroup*>(parent) ); setGroup( static_cast<FButtonGroup*>(parent) );
if ( group() )
group()->insert(this); // insert into button group group()->insert(this); // insert into button group
} }
} }
@ -49,6 +51,8 @@ FToggleButton::FToggleButton (const FString& txt, FWidget* parent)
, const_cast<char*>("FButtonGroup") ) == 0 ) , const_cast<char*>("FButtonGroup") ) == 0 )
{ {
setGroup( static_cast<FButtonGroup*>(parent) ); setGroup( static_cast<FButtonGroup*>(parent) );
if ( group() )
group()->insert( this ); // insert into button group group()->insert( this ); // insert into button group
} }
} }
@ -361,12 +365,22 @@ void FToggleButton::hide()
int size; int size;
short fg, bg; short fg, bg;
char* blank; char* blank;
FWidget* parent_widget = getParentWidget();
FWidget::hide(); FWidget::hide();
fg = getParentWidget()->getForegroundColor();
bg = getParentWidget()->getBackgroundColor();
setColor (fg, bg);
if ( parent_widget )
{
fg = parent_widget->getForegroundColor();
bg = parent_widget->getBackgroundColor();
}
else
{
fg = wc.dialog_fg;
bg = wc.dialog_bg;
}
setColor (fg, bg);
size = width; size = width;
blank = new char[size+1]; blank = new char[size+1];
memset(blank, ' ', uLong(size)); memset(blank, ' ', uLong(size));

View File

@ -413,6 +413,8 @@ void FWidget::adjustSize()
{ {
if ( ! isRootWidget() ) if ( ! isRootWidget() )
{ {
FWidget* parent_widget = getParentWidget();
if ( isWindow() ) if ( isWindow() )
{ {
xmin = rootObject->client_xmin; xmin = rootObject->client_xmin;
@ -420,21 +422,21 @@ void FWidget::adjustSize()
xmax = rootObject->client_xmax; xmax = rootObject->client_xmax;
ymax = rootObject->client_ymax; ymax = rootObject->client_ymax;
} }
else if ( ignore_padding ) else if ( ignore_padding && parent_widget )
{ {
xmin = getParentWidget()->xpos + getParentWidget()->xmin - 1; xmin = parent_widget->xpos + parent_widget->xmin - 1;
ymin = getParentWidget()->ypos + getParentWidget()->ymin - 1; ymin = parent_widget->ypos + parent_widget->ymin - 1;
xmax = getParentWidget()->xpos + getParentWidget()->xmin - 2 xmax = parent_widget->xpos + parent_widget->xmin - 2
+ getParentWidget()->width; + parent_widget->width;
ymax = getParentWidget()->ypos + getParentWidget()->ymin - 2 ymax = parent_widget->ypos + parent_widget->ymin - 2
+ getParentWidget()->height; + parent_widget->height;
} }
else else if ( parent_widget )
{ {
xmin = getParentWidget()->client_xmin; xmin = parent_widget->client_xmin;
ymin = getParentWidget()->client_ymin; ymin = parent_widget->client_ymin;
xmax = getParentWidget()->client_xmax; xmax = parent_widget->client_xmax;
ymax = getParentWidget()->client_ymax; ymax = parent_widget->client_ymax;
} }
xpos = widgetSize.getX(); xpos = widgetSize.getX();
@ -759,6 +761,9 @@ void FWidget::onClose (FCloseEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FWidget::focusNextChild() bool FWidget::focusNextChild()
{ {
if ( isDialog() )
return false;
if ( hasParent() ) if ( hasParent() )
{ {
FWidget* parent = static_cast<FWidget*>(getParent()); FWidget* parent = static_cast<FWidget*>(getParent());
@ -829,6 +834,9 @@ bool FWidget::focusNextChild()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FWidget::focusPrevChild() bool FWidget::focusPrevChild()
{ {
if ( isDialog() )
return false;
if ( hasParent() ) if ( hasParent() )
{ {
FWidget* parent = static_cast<FWidget*>(getParent()); FWidget* parent = static_cast<FWidget*>(getParent());
@ -1379,7 +1387,7 @@ void FWidget::show()
if ( ! visible ) if ( ! visible )
return; return;
if ( getMainWidget() == this && ! NewFont && ! VGAFont ) if ( getMainWidget() == this && ! (NewFont || VGAFont) )
init_consoleCharMap(); init_consoleCharMap();
if ( ! show_root_widget ) if ( ! show_root_widget )
@ -1432,7 +1440,9 @@ void FWidget::hide()
&& FWidget::getFocusWidget() == this && FWidget::getFocusWidget() == this
&& ! focusPrevChild() ) && ! focusPrevChild() )
{ {
if ( FWidget::getFocusWidget() )
FWidget::getFocusWidget()->unsetFocus(); FWidget::getFocusWidget()->unsetFocus();
FWidget::setFocusWidget(getParentWidget()); FWidget::setFocusWidget(getParentWidget());
} }
@ -1561,7 +1571,7 @@ bool FWidget::setFocus (bool on)
{ {
int focusable_children = numOfFocusableChildren(); int focusable_children = numOfFocusableChildren();
if ( FWidget::getFocusWidget() != 0 ) if ( FWidget::getFocusWidget() )
FWidget::getFocusWidget()->unsetFocus(); FWidget::getFocusWidget()->unsetFocus();
if ( (!isDialog() && focusable_children == 0) if ( (!isDialog() && focusable_children == 0)
@ -2001,7 +2011,7 @@ void FWidget::drawShadow()
if ( isMonochron() && ! trans_shadow ) if ( isMonochron() && ! trans_shadow )
return; return;
if ( (Encoding == fc::VT100 && ! trans_shadow && ! isTeraTerm() ) if ( (Encoding == fc::VT100 && ! (trans_shadow || isTeraTerm()) )
|| (Encoding == fc::ASCII && ! trans_shadow) ) || (Encoding == fc::ASCII && ! trans_shadow) )
{ {
clearShadow(); clearShadow();

View File

@ -454,7 +454,7 @@ bool FWindow::activatePrevWindow()
// activate the previous window // activate the previous window
FWindow* w = previous_widget; FWindow* w = previous_widget;
if ( w && ! w->isHiddenWindow() && ! w->isActiveWindow() ) if ( w && ! (w->isHiddenWindow() || w->isActiveWindow()) )
{ {
setActiveWindow(w); setActiveWindow(w);
return true; return true;

View File

@ -14,6 +14,7 @@ noinst_PROGRAMS = \
calculator \ calculator \
watch \ watch \
term-attributes \ term-attributes \
transparent \
keyboard \ keyboard \
timer \ timer \
windows \ windows \
@ -28,6 +29,7 @@ mandelbrot_SOURCES = mandelbrot.cpp
calculator_SOURCES = calculator.cpp calculator_SOURCES = calculator.cpp
watch_SOURCES = watch.cpp watch_SOURCES = watch.cpp
term_attributes_SOURCES = term-attributes.cpp term_attributes_SOURCES = term-attributes.cpp
transparent_SOURCES = transparent.cpp
keyboard_SOURCES = keyboard.cpp keyboard_SOURCES = keyboard.cpp
timer_SOURCES = timer.cpp timer_SOURCES = timer.cpp
windows_SOURCES = windows.cpp windows_SOURCES = windows.cpp

View File

@ -85,8 +85,8 @@ host_triplet = @host@
noinst_PROGRAMS = hello$(EXEEXT) dialog$(EXEEXT) input-dialog$(EXEEXT) \ noinst_PROGRAMS = hello$(EXEEXT) dialog$(EXEEXT) input-dialog$(EXEEXT) \
string-operations$(EXEEXT) mandelbrot$(EXEEXT) \ string-operations$(EXEEXT) mandelbrot$(EXEEXT) \
calculator$(EXEEXT) watch$(EXEEXT) term-attributes$(EXEEXT) \ calculator$(EXEEXT) watch$(EXEEXT) term-attributes$(EXEEXT) \
keyboard$(EXEEXT) timer$(EXEEXT) windows$(EXEEXT) \ transparent$(EXEEXT) keyboard$(EXEEXT) timer$(EXEEXT) \
menu$(EXEEXT) ui$(EXEEXT) windows$(EXEEXT) menu$(EXEEXT) ui$(EXEEXT)
subdir = test subdir = test
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/depcomp $(top_srcdir)/depcomp
@ -136,6 +136,9 @@ term_attributes_LDADD = $(LDADD)
am_timer_OBJECTS = timer.$(OBJEXT) am_timer_OBJECTS = timer.$(OBJEXT)
timer_OBJECTS = $(am_timer_OBJECTS) timer_OBJECTS = $(am_timer_OBJECTS)
timer_LDADD = $(LDADD) timer_LDADD = $(LDADD)
am_transparent_OBJECTS = transparent.$(OBJEXT)
transparent_OBJECTS = $(am_transparent_OBJECTS)
transparent_LDADD = $(LDADD)
am_ui_OBJECTS = ui.$(OBJEXT) am_ui_OBJECTS = ui.$(OBJEXT)
ui_OBJECTS = $(am_ui_OBJECTS) ui_OBJECTS = $(am_ui_OBJECTS)
ui_LDADD = $(LDADD) ui_LDADD = $(LDADD)
@ -183,14 +186,14 @@ SOURCES = $(calculator_SOURCES) $(dialog_SOURCES) $(hello_SOURCES) \
$(input_dialog_SOURCES) $(keyboard_SOURCES) \ $(input_dialog_SOURCES) $(keyboard_SOURCES) \
$(mandelbrot_SOURCES) $(menu_SOURCES) \ $(mandelbrot_SOURCES) $(menu_SOURCES) \
$(string_operations_SOURCES) $(term_attributes_SOURCES) \ $(string_operations_SOURCES) $(term_attributes_SOURCES) \
$(timer_SOURCES) $(ui_SOURCES) $(watch_SOURCES) \ $(timer_SOURCES) $(transparent_SOURCES) $(ui_SOURCES) \
$(windows_SOURCES) $(watch_SOURCES) $(windows_SOURCES)
DIST_SOURCES = $(calculator_SOURCES) $(dialog_SOURCES) \ DIST_SOURCES = $(calculator_SOURCES) $(dialog_SOURCES) \
$(hello_SOURCES) $(input_dialog_SOURCES) $(keyboard_SOURCES) \ $(hello_SOURCES) $(input_dialog_SOURCES) $(keyboard_SOURCES) \
$(mandelbrot_SOURCES) $(menu_SOURCES) \ $(mandelbrot_SOURCES) $(menu_SOURCES) \
$(string_operations_SOURCES) $(term_attributes_SOURCES) \ $(string_operations_SOURCES) $(term_attributes_SOURCES) \
$(timer_SOURCES) $(ui_SOURCES) $(watch_SOURCES) \ $(timer_SOURCES) $(transparent_SOURCES) $(ui_SOURCES) \
$(windows_SOURCES) $(watch_SOURCES) $(windows_SOURCES)
am__can_run_installinfo = \ am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \ case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \ n|no|NO) false;; \
@ -347,6 +350,7 @@ mandelbrot_SOURCES = mandelbrot.cpp
calculator_SOURCES = calculator.cpp calculator_SOURCES = calculator.cpp
watch_SOURCES = watch.cpp watch_SOURCES = watch.cpp
term_attributes_SOURCES = term-attributes.cpp term_attributes_SOURCES = term-attributes.cpp
transparent_SOURCES = transparent.cpp
keyboard_SOURCES = keyboard.cpp keyboard_SOURCES = keyboard.cpp
timer_SOURCES = timer.cpp timer_SOURCES = timer.cpp
windows_SOURCES = windows.cpp windows_SOURCES = windows.cpp
@ -436,6 +440,10 @@ timer$(EXEEXT): $(timer_OBJECTS) $(timer_DEPENDENCIES) $(EXTRA_timer_DEPENDENCIE
@rm -f timer$(EXEEXT) @rm -f timer$(EXEEXT)
$(AM_V_CXXLD)$(CXXLINK) $(timer_OBJECTS) $(timer_LDADD) $(LIBS) $(AM_V_CXXLD)$(CXXLINK) $(timer_OBJECTS) $(timer_LDADD) $(LIBS)
transparent$(EXEEXT): $(transparent_OBJECTS) $(transparent_DEPENDENCIES) $(EXTRA_transparent_DEPENDENCIES)
@rm -f transparent$(EXEEXT)
$(AM_V_CXXLD)$(CXXLINK) $(transparent_OBJECTS) $(transparent_LDADD) $(LIBS)
ui$(EXEEXT): $(ui_OBJECTS) $(ui_DEPENDENCIES) $(EXTRA_ui_DEPENDENCIES) ui$(EXEEXT): $(ui_OBJECTS) $(ui_DEPENDENCIES) $(EXTRA_ui_DEPENDENCIES)
@rm -f ui$(EXEEXT) @rm -f ui$(EXEEXT)
$(AM_V_CXXLD)$(CXXLINK) $(ui_OBJECTS) $(ui_LDADD) $(LIBS) $(AM_V_CXXLD)$(CXXLINK) $(ui_OBJECTS) $(ui_LDADD) $(LIBS)
@ -464,6 +472,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/string-operations.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/string-operations.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/term-attributes.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/term-attributes.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timer.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/transparent.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ui.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ui.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/watch.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/watch.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/windows.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/windows.Po@am__quote@