Replacing the widget position variables by FRect objects

This commit is contained in:
Markus Gans 2016-09-25 23:53:48 +02:00
parent 9551924b73
commit 9475f34499
46 changed files with 1830 additions and 1534 deletions

View File

@ -1,3 +1,21 @@
2016-09-25 Markus Gans <guru.mail@muenster.de>
* Splitting gotoxy in printPos (local position)
and printPosTerm (global terminal position)
* Replacing the widget position variables by FRect objects
* Rename getGeometryShadow() to getGeometryWithShadow()
* Rename getGeometryGlobal() to getTermGeometry()
* Rename getGeometryGlobalShadow() to getTermGeometryWithShadow()
* Rename globalToLocalPos() to termToWidgetPos()
* Rename getGlobalX() to getTermX()
* Rename getGlobalY() to getTermY()
* Rename getGlobalPos() to getTermPos()
* setColor() without parameters sets the default widget colors
* New methods setMinimumSize(), setMaximumSize(), setFixedSize()
and setSize()
2016-09-12 Markus Gans <guru.mail@muenster.de>
* Activate the title bar menu with ctrl+^
2016-09-11 Markus Gans <guru.mail@muenster.de>
* New zoom interaction-elements to maximize a FDialog
@ -346,7 +364,7 @@
2015-08-08 Markus Gans <guru.mail@muenster.de>
* Bug fix in FDialog (use GlobalPos to move)
* Don't check mouse click position on titlebar again
* Don't check mouse click position on title bar again
while FDialog is in move
2015-07-26 Markus Gans <guru.mail@muenster.de>

View File

@ -1444,7 +1444,7 @@ void FApplication::processMouseEvent()
&& menuBar()->hasSelectedItem()
&& ! b_state.mouse_moved )
{
if ( ! menuBar()->getGeometryGlobal().contains(*mouse) )
if ( ! menuBar()->getTermGeometry().contains(*mouse) )
{
if ( statusBar() )
statusBar()->clearMessage();
@ -1466,7 +1466,7 @@ void FApplication::processMouseEvent()
if ( clicked_widget )
{
FPoint localMousePos;
FPoint widgetMousePos;
int key_state = 0;
if ( b_state.shift_button == Pressed )
@ -1478,14 +1478,14 @@ void FApplication::processMouseEvent()
if ( b_state.control_button == Pressed )
key_state |= fc::ControlButton;
localMousePos = clicked_widget->globalToLocalPos(*mouse);
widgetMousePos = clicked_widget->termToWidgetPos(*mouse);
if ( b_state.mouse_moved )
{
if ( b_state.left_button == Pressed )
{
FMouseEvent m_down_ev ( fc::MouseMove_Event
, localMousePos
, widgetMousePos
, *mouse
, fc::LeftButton | key_state );
sendEvent (clicked_widget, &m_down_ev);
@ -1494,7 +1494,7 @@ void FApplication::processMouseEvent()
if ( b_state.right_button == Pressed )
{
FMouseEvent m_down_ev ( fc::MouseMove_Event
, localMousePos
, widgetMousePos
, *mouse
, fc::RightButton | key_state );
sendEvent (clicked_widget, &m_down_ev);
@ -1503,7 +1503,7 @@ void FApplication::processMouseEvent()
if ( b_state.middle_button == Pressed )
{
FMouseEvent m_down_ev ( fc::MouseMove_Event
, localMousePos
, widgetMousePos
, *mouse
, fc::MiddleButton | key_state );
sendEvent (clicked_widget, &m_down_ev);
@ -1514,7 +1514,7 @@ void FApplication::processMouseEvent()
if ( b_state.left_button == DoubleClick )
{
FMouseEvent m_dblclick_ev ( fc::MouseDoubleClick_Event
, localMousePos
, widgetMousePos
, *mouse
, fc::LeftButton | key_state );
sendEvent (clicked_widget, &m_dblclick_ev);
@ -1522,7 +1522,7 @@ void FApplication::processMouseEvent()
else if ( b_state.left_button == Pressed )
{
FMouseEvent m_down_ev ( fc::MouseDown_Event
, localMousePos
, widgetMousePos
, *mouse
, fc::LeftButton | key_state );
sendEvent (clicked_widget, &m_down_ev);
@ -1530,7 +1530,7 @@ void FApplication::processMouseEvent()
else if ( b_state.left_button == Released )
{
FMouseEvent m_up_ev ( fc::MouseUp_Event
, localMousePos
, widgetMousePos
, *mouse
, fc::LeftButton | key_state );
FWidget* released_widget = clicked_widget;
@ -1545,7 +1545,7 @@ void FApplication::processMouseEvent()
if ( b_state.right_button == Pressed )
{
FMouseEvent m_down_ev ( fc::MouseDown_Event
, localMousePos
, widgetMousePos
, *mouse
, fc::RightButton | key_state );
sendEvent (clicked_widget, &m_down_ev);
@ -1553,7 +1553,7 @@ void FApplication::processMouseEvent()
else if ( b_state.right_button == Released )
{
FMouseEvent m_up_ev ( fc::MouseUp_Event
, localMousePos
, widgetMousePos
, *mouse
, fc::RightButton | key_state );
FWidget* released_widget = clicked_widget;
@ -1568,7 +1568,7 @@ void FApplication::processMouseEvent()
if ( b_state.middle_button == Pressed )
{
FMouseEvent m_down_ev ( fc::MouseDown_Event
, localMousePos
, widgetMousePos
, *mouse
, fc::MiddleButton | key_state );
sendEvent (clicked_widget, &m_down_ev);
@ -1580,7 +1580,7 @@ void FApplication::processMouseEvent()
else if ( b_state.middle_button == Released )
{
FMouseEvent m_up_ev ( fc::MouseUp_Event
, localMousePos
, widgetMousePos
, *mouse
, fc::MiddleButton | key_state );
FWidget* released_widget = clicked_widget;
@ -1598,7 +1598,7 @@ void FApplication::processMouseEvent()
if ( b_state.wheel_up == Pressed )
{
FWheelEvent wheel_ev ( fc::MouseWheel_Event
, localMousePos
, widgetMousePos
, *mouse
, fc::WheelUp );
FWidget* scroll_over_widget = clicked_widget;
@ -1609,7 +1609,7 @@ void FApplication::processMouseEvent()
if ( b_state.wheel_down == Pressed )
{
FWheelEvent wheel_ev ( fc::MouseWheel_Event
, localMousePos
, widgetMousePos
, *mouse
, fc::WheelDown );
FWidget* scroll_over_widget = clicked_widget;
@ -1865,7 +1865,7 @@ bool FApplication::sendEvent(FObject* receiver, FEvent* event)
if ( modal_dialogs > 0 )
{
FWidget* window;
if ( widget->isWindow() )
if ( widget->isWindowWidget() )
window = widget;
else
window = FWindow::getWindowWidget(widget);
@ -1873,7 +1873,7 @@ bool FApplication::sendEvent(FObject* receiver, FEvent* event)
// block events for widgets in non modal windows
if ( window
&& (window->getFlags() & fc::modal) == 0
&& ! window->isMenu() )
&& ! window->isMenuWidget() )
{
switch ( event->type() )
{

View File

@ -180,9 +180,9 @@ void FButton::draw()
setColor ( parent_widget->getForegroundColor()
, parent_widget->getBackgroundColor() );
for (int y=1; y <= height; y++)
for (int y=1; y <= getHeight(); y++)
{
gotoxy (xpos+xmin-1, ypos+ymin-2+y);
printPos (1, y);
print (' '); // clear one left █
}
@ -221,7 +221,7 @@ void FButton::draw()
if ( hotkeypos != -1 )
hotkey_offset = 1;
if ( (length - hotkey_offset + mono_offset - hotkey_offset) <= width )
if ( (length - hotkey_offset + mono_offset - hotkey_offset) <= getWidth() )
margin = 1;
else
margin = 0;
@ -233,11 +233,11 @@ void FButton::draw()
{
if ( margin == 1 )
{
setColor (foregroundColor, button_bg);
setColor (getForegroundColor(), button_bg);
for (int y=0; y < height; y++)
for (int y=0; y < getHeight(); y++)
{
gotoxy (xpos+xmin-1+d, ypos+ymin-1+y);
printPos (1+d, 1+y);
print (space); // full block █
}
}
@ -250,19 +250,17 @@ void FButton::draw()
if ( parent_widget )
setColor (button_bg, parent_widget->getBackgroundColor());
gotoxy (xpos+xmin-1+d, ypos+ymin-1);
for (int y=1; y <= height; y++)
for (int y=0; y < getHeight(); y++)
{
// Cygwin terminal use IBM Codepage 850
printPos (1+d, 1+y);
// Cygwin terminal use IBM Codepage 850
if ( isCygwinTerminal() )
print (fc::FullBlock); // █
else if ( isTeraTerm() )
print (0xdb);
else
print (fc::RightHalfBlock); // ▐
gotoxy (xpos+xmin-1+d, ypos+ymin-1+y);
}
}
@ -275,12 +273,12 @@ void FButton::draw()
setColor ( parent_widget->getForegroundColor()
, parent_widget->getBackgroundColor() );
for (int y=1; y <= height; y++)
for (int y=1; y <= getHeight(); y++)
{
if ( isMonochron() )
setReverse(true);
gotoxy (xpos+xmin-1+width, ypos+ymin-2+y);
printPos (1+getWidth(), y);
print (' '); // clear right
if ( isMonochron() )
@ -291,31 +289,29 @@ void FButton::draw()
if ( hotkeypos != -1 )
length--;
i = width - length - 1;
i = getWidth() - length - 1;
i = int(i / 2);
if ( height > 1 )
j = int((height-1) / 2);
if ( getHeight() > 1 )
j = int((getHeight()-1) / 2);
else
j=0;
gotoxy (xpos+xmin-1+margin+d, ypos+ymin-1+j);
printPos (1+margin+d, 1+j);
setColor (button_fg, button_bg);
for (x=0; x < i; x++)
print (space); // █
print (space); // █
if ( hotkeypos == -1 )
setCursorPos ( xpos+xmin-1+margin+i
, ypos+ymin-1+j ); // first character
setCursorPos (1+margin+i, 1+j ); // first character
else
setCursorPos ( xpos+xmin-1+margin+i+hotkeypos
, ypos+ymin-1+j ); // hotkey
setCursorPos (1+margin+i+hotkeypos, 1+j ); // hotkey
if ( is_ActiveFocus && (isMonochron() || getMaxColor() < 16) )
setBold();
for (int z=0; x < i+length && z < width; z++,x++)
for (int z=0; x < i+length && z < getWidth(); z++,x++)
{
if ( (z == hotkeypos) && is_Active )
{
@ -346,23 +342,23 @@ void FButton::draw()
if ( is_ActiveFocus && (isMonochron() || getMaxColor() < 16) )
unsetBold();
for (x=i+length; x < width-1; x++)
for (x=i+length; x < getWidth()-1; x++)
print (space); // █
if ( height > 1 )
if ( getHeight() > 1 )
{
for (i=0; i < j; i++)
{
gotoxy (xpos+xmin+d, ypos+ymin-1+i);
printPos (2+d, 1+i);
for (int z=1; z < width; z++)
for (int z=1; z < getWidth(); z++)
print (space); // █
}
for (i=j+1; i < height; i++)
for (i=j+1; i < getHeight(); i++)
{
gotoxy (xpos+xmin+d, ypos+ymin-1+i);
printPos (2+d, 1+i);
for (int z=1; z < width; z++)
for (int z=1; z < getWidth(); z++)
print (space); // █
}
}
@ -411,8 +407,8 @@ void FButton::updateButtonColor()
}
else
{
button_fg = foregroundColor;
button_bg = backgroundColor;
button_fg = getForegroundColor();
button_bg = getBackgroundColor() ;
}
}
else // inactive
@ -514,14 +510,18 @@ void FButton::hide()
setColor (fg, bg);
s = hasShadow() ? 1 : 0;
f = isFlat() ? 1 : 0;
size = width + s + (f << 1);
size = getWidth() + s + (f << 1);
if ( size < 0 )
return;
blank = new char[size+1];
memset(blank, ' ', uLong(size));
blank[size] = '\0';
for (int y=0; y < height+s+(f << 1); y++)
for (int y=0; y < getHeight()+s+(f << 1); y++)
{
gotoxy (xpos+xmin-1-f, ypos+ymin-1+y-f);
printPos (1-f, 1+y-f);
print (blank);
}
@ -679,9 +679,9 @@ void FButton::onMouseDown (FMouseEvent* ev)
statusBar()->drawMessage();
}
FPoint gPos = ev->getGlobalPos();
FPoint tPos = ev->getTermPos();
if ( getGeometryGlobal().contains(gPos) )
if ( getTermGeometry().contains(tPos) )
setDown();
}
@ -695,7 +695,7 @@ void FButton::onMouseUp (FMouseEvent* ev)
{
setUp();
if ( getGeometryGlobal().contains(ev->getGlobalPos()) )
if ( getTermGeometry().contains(ev->getTermPos()) )
processClick();
}
}
@ -706,11 +706,11 @@ void FButton::onMouseMove (FMouseEvent* ev)
if ( ev->getButton() != fc::LeftButton )
return;
FPoint gPos = ev->getGlobalPos();
FPoint tPos = ev->getTermPos();
if ( click_animation )
{
if ( getGeometryGlobal().contains(gPos) )
if ( getTermGeometry().contains(tPos) )
setDown();
else
setUp();

View File

@ -54,16 +54,16 @@ FButtonGroup::~FButtonGroup() // destructor
//----------------------------------------------------------------------
void FButtonGroup::init()
{
top_padding = 1;
left_padding = 1;
bottom_padding = 1;
right_padding = 1;
setTopPadding(1);
setLeftPadding(1);
setBottomPadding(1);
setRightPadding(1);
if ( isEnabled() )
flags |= fc::active;
foregroundColor = wc.label_fg;
backgroundColor = wc.label_bg;
setForegroundColor (wc.label_fg);
setBackgroundColor (wc.label_bg);
buttonlist.clear(); // no buttons yet
}
@ -152,7 +152,7 @@ void FButtonGroup::draw()
if ( isMonochron() )
setReverse(true);
setColor (foregroundColor, backgroundColor);
setColor();
if ( border )
drawBorder();
@ -252,9 +252,9 @@ void FButtonGroup::drawLabel()
length--;
if ( border )
gotoxy (xpos+xmin, ypos+ymin-1);
printPos (2, 1);
else
gotoxy (xpos+xmin-2, ypos+ymin-1);
printPos (0, 1);
if ( isEnabled() )
setColor(wc.label_emphasis_fg, wc.label_bg);
@ -319,14 +319,18 @@ void FButtonGroup::hide()
}
setColor (fg, bg);
size = width;
size = getWidth();
if ( size < 0 )
return;
blank = new char[size+1];
memset(blank, ' ', uLong(size));
blank[size] = '\0';
for (int y=0; y < height; y++)
for (int y=0; y < getHeight(); y++)
{
gotoxy (xpos+xmin-1, ypos+ymin-1+y);
printPos (1, 1+y);
print (blank);
}

View File

@ -53,8 +53,8 @@ void FCheckBox::drawCheckButton()
if ( ! isVisible() )
return;
gotoxy (xpos+xmin-1, ypos+ymin-1);
setColor (foregroundColor, backgroundColor);
printPos (1,1);
setColor();
if ( isMonochron() )
{

View File

@ -63,8 +63,8 @@ FDialog::~FDialog() // destructor
if ( ! is_quit )
{
const FRect& geometry = getGeometryGlobalShadow();
restoreVTerm (geometry);
const FRect& t_geometry = getTermGeometryWithShadow();
restoreVTerm (t_geometry);
}
if ( vwin != 0 )
@ -86,34 +86,23 @@ FDialog::~FDialog() // destructor
//----------------------------------------------------------------------
void FDialog::init()
{
FWidget* old_focus;
FWidget* rootObj = getRootWidget();
xmin = 1 + rootObj->getLeftPadding();
ymin = 1 + rootObj->getTopPadding();
xmax = rootObj->getWidth();
ymax = rootObj->getHeight();
width = 10;
height = 10;
client_xmin = 1;
client_ymin = 1;
client_xmax = width;
client_ymax = height;
top_padding = 2;
left_padding = 1;
bottom_padding = 1;
right_padding = 1;
FWidget* old_focus;
setTopPadding(2);
setLeftPadding(1);
setBottomPadding(1);
setRightPadding(1);
ignorePadding();
setDialogWidget();
// initialize geometry values
setGeometry (1, 1, 10, 10, false);
createArea (vwin);
setGeometry (1, 1, 10, 10, false); // initialize geometry values
ignore_padding = true;
dialog_object = true;
addDialog(this);
addWindow(this);
setActiveWindow(this);
setTransparentShadow();
foregroundColor = wc.dialog_fg;
backgroundColor = wc.dialog_bg;
setForegroundColor (wc.dialog_fg);
setBackgroundColor (wc.dialog_bg);
if ( hasFocus() )
flags |= fc::focus;
@ -132,7 +121,7 @@ void FDialog::init()
accelerator_list = new Accelerators();
// Add the dialog menu
dialog_menu = new FMenu ("-", this);
dialog_menu->move (xpos, ypos+1);
dialog_menu->move (getX(), getY()+1);
dgl_menuitem = dialog_menu->getItem();
if ( dgl_menuitem )
@ -141,8 +130,8 @@ void FDialog::init()
dgl_menuitem->unsetFocusable();
}
zoom_item = new FMenuItem ("&Zoom", dialog_menu);
zoom_item->setStatusbarMessage ("Enlarge or restore the window size");
zoom_item = new FMenuItem (dialog_menu);
setZoomItem();
zoom_item->setDisable();
zoom_item->addCallback
@ -164,48 +153,47 @@ void FDialog::init()
//----------------------------------------------------------------------
void FDialog::drawBorder()
{
int x1, x2, y1, y2;
x1 = xpos+xmin-1;
x2 = xpos+xmin-2+width;
y1 = ypos+ymin;
y2 = ypos+ymin-2+height;
int x1 = 1;
int x2 = 1 + getWidth() - 1;
int y1 = 2;
int y2 = 1 + getHeight() - 1;
//if ( resize )
// setColor (wc.dialog_resize_fg, backgroundColor);
// setColor (wc.dialog_resize_fg, getBackgroundColor());
if ( isNewFont() )
{
for (int y=y1; y <= y2; y++)
{
gotoxy (x1, y);
printPos (x1, y);
// border left ⎸
print (fc::NF_border_line_left);
gotoxy (x2, y);
printPos (x2, y);
// border right⎹
print (fc::NF_rev_border_line_right);
}
gotoxy (x1, y2);
printPos (x1, y2);
// lower left corner border ⎣
print (fc::NF_border_corner_lower_left);
for (int x=1; x < width-1; x++) // low line _
for (int x=1; x < getWidth()-1; x++) // low line _
print (fc::NF_border_line_bottom);
gotoxy (x2, y2);
printPos (x2, y2);
// lower right corner border ⎦
print (fc::NF_rev_border_corner_lower_right);
}
else
{
gotoxy (x1, y1);
printPos (x1, y1);
print (fc::BoxDrawingsDownAndRight); // ┌
for (int x=x1+1; x < x2; x++)
print (fc::BoxDrawingsHorizontal); // ─
print (fc::BoxDrawingsDownAndLeft); // ┐
gotoxy (x1, y2);
printPos (x1, y2);
print (fc::BoxDrawingsUpAndRight); // └
for (int x=x1+1; x < x2; x++)
@ -215,9 +203,9 @@ void FDialog::drawBorder()
for (int y=y1+1; y < y2; y++)
{
gotoxy (x1, y);
printPos (x1, y);
print (fc::BoxDrawingsVertical); // │
gotoxy (x2, y);
printPos (x2, y);
print (fc::BoxDrawingsVertical); // │
}
@ -231,7 +219,7 @@ void FDialog::drawTitleBar()
const int menu_btn = 3;
// draw the title button
gotoxy (xpos+xmin-1, ypos+ymin-1);
printPos (1, 1);
if ( dialog_menu && dialog_menu->isVisible() )
setColor (wc.titlebar_button_focus_fg, wc.titlebar_button_focus_bg);
@ -293,7 +281,7 @@ void FDialog::drawTitleBar()
zoom_btn = 3;
length = int(tb_text.getLength());
i = width - length - menu_btn - zoom_btn;
i = getWidth() - length - menu_btn - zoom_btn;
i = int(i/2);
for (x=1; x <= i; x++)
@ -304,7 +292,7 @@ void FDialog::drawTitleBar()
print (tb_text);
// fill the rest of the bar
for (; x+1+length < width-zoom_btn-1; x++)
for (; x+1+length < getWidth()-zoom_btn-1; x++)
print (' ');
if ( getMaxColor() < 16 )
@ -380,7 +368,7 @@ void FDialog::drawTitleBar()
setReverse(false);
/* print the number of window in stack */
//gotoxy(xpos+xmin+width-4, ypos+ymin-1);
//printPos (getWidth()-2, 1);
//printf ("(%d)", getWindowLayer(this));
}
@ -405,6 +393,66 @@ void FDialog::leaveMenu()
flush_out();
}
//----------------------------------------------------------------------
void FDialog::openMenu()
{
// open the titlebar menu
if ( ! dialog_menu )
return;
if ( dialog_menu->isVisible() )
{
leaveMenu();
drawTitleBar();
}
else
{
setOpenMenu(dialog_menu);
dialog_menu->move (getX(), getY()+1);
dialog_menu->setVisible();
drawTitleBar();
dialog_menu->show();
dialog_menu->raiseWindow(dialog_menu);
dialog_menu->redraw();
}
}
//----------------------------------------------------------------------
void FDialog::selectFirstMenuItem()
{
// focus to the first enabled menu item
FMenuItem* first_item;
dialog_menu->selectFirstItem();
first_item = dialog_menu->getSelectedItem();
if ( first_item )
first_item->setFocus();
dialog_menu->redraw();
if ( statusBar() )
statusBar()->drawMessage();
updateTerminal();
flush_out();
}
//----------------------------------------------------------------------
void FDialog::setZoomItem()
{
if ( isZoomed() )
{
zoom_item->setText ("&Unzoom");
zoom_item->setStatusbarMessage ("Restore the window size");
}
else
{
zoom_item->setText ("&Zoom");
zoom_item->setStatusbarMessage ("Enlarge the window to the entire desktop");
}
}
//----------------------------------------------------------------------
void FDialog::cb_zoom (FWidget*, void*)
{
@ -413,6 +461,7 @@ void FDialog::cb_zoom (FWidget*, void*)
setClickedWidget(0);
drawTitleBar();
zoomWindow();
setZoomItem();
}
//----------------------------------------------------------------------
@ -471,7 +520,7 @@ void FDialog::drawDialogShadow()
return;
drawShadow();
gotoxy (xpos+xmin-1, ypos+ymin-1+height);
printPos (1, 1+getHeight());
setTransparent();
print(' ');
unsetTransparent();
@ -480,17 +529,9 @@ void FDialog::drawDialogShadow()
//----------------------------------------------------------------------
void FDialog::draw()
{
/*if ( isZoomed() && ! isRootWidget() )
{
xpos = 1;
ypos = 1;
width = xmax;
height = ymax;
}*/
updateVTerm(false);
// fill the background
setColor (foregroundColor, backgroundColor);
setColor();
if ( isMonochron() )
setReverse(true);
@ -527,7 +568,19 @@ void FDialog::onClose (FCloseEvent* ev)
//----------------------------------------------------------------------
void FDialog::onKeyPress (FKeyEvent* ev)
{
if ( ! isEnabled() || this == getMainWidget() )
if ( ! isEnabled() )
return;
if ( ev->key() == fc::Fckey_caret ) // Ctrl+^
{
ev->accept();
// open the titlebar menu
openMenu();
// focus to the first enabled item
selectFirstMenuItem();
}
if ( this == getMainWidget() )
return;
if ( ev->key() == fc::Fkey_escape
@ -568,8 +621,8 @@ void FDialog::onMouseDown (FMouseEvent* ev)
bool has_raised;
// click on titlebar or window: raise + activate
if ( mouse_x >= 4 && mouse_x <= width-zoom_btn && mouse_y == 1 )
TitleBarClickPos.setPoint (ev->getGlobalX(), ev->getGlobalY());
if ( mouse_x >= 4 && mouse_x <= getWidth()-zoom_btn && mouse_y == 1 )
TitleBarClickPos.setPoint (ev->getTermX(), ev->getTermY());
else
TitleBarClickPos.setPoint (0,0);
@ -583,24 +636,8 @@ void FDialog::onMouseDown (FMouseEvent* ev)
// click on titlebar menu button
if ( mouse_x < 4 && mouse_y == 1 )
{
if ( dialog_menu->isVisible() )
{
leaveMenu();
drawTitleBar();
}
else
{
setOpenMenu(dialog_menu);
dialog_menu->move (xpos, ypos+1);
dialog_menu->setVisible();
drawTitleBar();
dialog_menu->show();
dialog_menu->raiseWindow(dialog_menu);
dialog_menu->redraw();
}
}
else if ( mouse_x > width-zoom_btn && mouse_y == 1 )
openMenu();
else if ( mouse_x > getWidth()-zoom_btn && mouse_y == 1 )
{
zoom_button_pressed = true;
zoom_button_active = true;
@ -617,7 +654,7 @@ void FDialog::onMouseDown (FMouseEvent* ev)
if ( ev->getButton() == fc::RightButton )
{
// click on titlebar: just activate
if ( mouse_x >= 4 && mouse_x <= width && mouse_y == 1 )
if ( mouse_x >= 4 && mouse_x <= getWidth() && mouse_y == 1 )
{
if ( ! isActiveWindow() )
activateDialog();
@ -627,7 +664,7 @@ void FDialog::onMouseDown (FMouseEvent* ev)
if ( ev->getButton() == fc::MiddleButton )
{
// click on titlebar: lower + activate
if ( mouse_x >= 4 && mouse_x <= width && mouse_y == 1 )
if ( mouse_x >= 4 && mouse_x <= getWidth() && mouse_y == 1 )
{
bool has_lowered = lowerWindow();
@ -659,14 +696,14 @@ void FDialog::onMouseUp (FMouseEvent* ev)
int mouse_y = ev->getY();
if ( ! TitleBarClickPos.isNull()
&& titlebar_x > xpos+xmin+2
&& titlebar_x < xpos+xmin+width
&& titlebar_y == ypos+ymin-1 )
&& titlebar_x > getTermX() + 3
&& titlebar_x < getTermX() + getWidth()
&& titlebar_y == getTermY() )
{
FPoint currentPos(getGeometry().getX(), getGeometry().getY());
FPoint deltaPos = ev->getGlobalPos() - TitleBarClickPos;
FPoint deltaPos = ev->getTermPos() - TitleBarClickPos;
move (currentPos + deltaPos);
TitleBarClickPos = ev->getGlobalPos();
TitleBarClickPos = ev->getTermPos();
}
// click on titlebar menu button
@ -675,27 +712,16 @@ void FDialog::onMouseUp (FMouseEvent* ev)
&& dialog_menu->isVisible()
&& ! dialog_menu->hasSelectedItem() )
{
FMenuItem* first_item;
dialog_menu->selectFirstItem();
first_item = dialog_menu->getSelectedItem();
if ( first_item )
first_item->setFocus();
dialog_menu->redraw();
if ( statusBar() )
statusBar()->drawMessage();
updateTerminal();
flush_out();
// Sets focus to the first item
selectFirstMenuItem();
}
else if ( mouse_x > width - zoom_btn
else if ( mouse_x > getWidth() - zoom_btn
&& mouse_y == 1
&& zoom_button_pressed )
{
// zoom to maximum or restore the window size
zoomWindow();
setZoomItem();
}
}
@ -727,21 +753,21 @@ void FDialog::onMouseMove (FMouseEvent* ev)
if ( ! TitleBarClickPos.isNull() )
{
FPoint currentPos(getGeometry().getX(), getGeometry().getY());
FPoint deltaPos = ev->getGlobalPos() - TitleBarClickPos;
FPoint deltaPos = ev->getTermPos() - TitleBarClickPos;
move (currentPos + deltaPos);
TitleBarClickPos = ev->getGlobalPos();
TitleBarClickPos = ev->getTermPos();
}
if ( dialog_menu->isVisible() && dialog_menu->isShown() )
{
// Mouse event handover to the menu
const FRect& menu_geometry = dialog_menu->getGeometryGlobal();
const FRect& menu_geometry = dialog_menu->getTermGeometry();
if ( dialog_menu->count() > 0
&& menu_geometry.contains(ev->getGlobalPos()) )
&& menu_geometry.contains(ev->getTermPos()) )
{
const FPoint& g = ev->getGlobalPos();
const FPoint& p = dialog_menu->globalToLocalPos(g);
const FPoint& g = ev->getTermPos();
const FPoint& p = dialog_menu->termToWidgetPos(g);
int b = ev->getButton();
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p, g, b);
dialog_menu->mouse_down = true;
@ -751,7 +777,7 @@ void FDialog::onMouseMove (FMouseEvent* ev)
}
}
if ( mouse_x > width - zoom_btn && mouse_y == 1 && zoom_button_active )
if ( mouse_x > getWidth() - zoom_btn && mouse_y == 1 && zoom_button_active )
{
zoom_button_pressed = true;
drawTitleBar();
@ -768,18 +794,31 @@ void FDialog::onMouseMove (FMouseEvent* ev)
//----------------------------------------------------------------------
void FDialog::onMouseDoubleClick (FMouseEvent* ev)
{
int x, y;
int x, y, mouse_x, mouse_y, zoom_btn;
bool is_resizeable;
if ( ev->getButton() != fc::LeftButton )
return;
x = xpos + xmin - 1;
y = ypos + ymin - 1;
FRect title_button(x, y, 3, 1);
FPoint gPos = ev->getGlobalPos();
mouse_x = ev->getX();
mouse_y = ev->getY();
is_resizeable = bool(flags & fc::resizeable);
if ( title_button.contains(gPos) )
if ( ! is_resizeable )
zoom_btn = 0;
else if ( isNewFont() )
zoom_btn = 2;
else
zoom_btn = 3;
x = getTermX();
y = getTermY();
FRect title_button(x, y, 3, 1);
FPoint tPos = ev->getTermPos();
if ( title_button.contains(tPos) )
{
// double click on title button
FWidget* window_focus_widget;
dialog_menu->unselectItem();
dialog_menu->hide();
@ -797,6 +836,15 @@ void FDialog::onMouseDoubleClick (FMouseEvent* ev)
else
close();
}
else if ( is_resizeable
&& mouse_x >= 4
&& mouse_x <= getWidth() - zoom_btn
&& mouse_y == 1 )
{
// double click on titlebar
zoomWindow(); // window zoom/unzoom
setZoomItem();
}
}
//----------------------------------------------------------------------
@ -862,7 +910,7 @@ void FDialog::onWindowRaised (FEvent*)
if ( ! (isVisible() && isShown()) )
return;
putArea (getGlobalPos(), vwin);
putArea (getTermPos(), vwin);
if ( ! window_list )
return;
@ -887,7 +935,7 @@ void FDialog::onWindowLowered (FEvent*)
while ( iter != end )
{
putArea ((*iter)->getGlobalPos(), (*iter)->getVWin());
putArea ((*iter)->getTermPos(), (*iter)->getVWin());
++iter;
}
}
@ -952,29 +1000,29 @@ void FDialog::move (const FPoint& pos)
//----------------------------------------------------------------------
void FDialog::move (int x, int y)
{
int dx, dy, old_x, old_y;
int dx, dy, old_x, old_y, rsw, bsh;
if ( x == xpos && y == ypos )
if ( getX() == x && getY() == y )
return;
if ( x+width < 1 || x > getColumnNumber() || y < 1 || y > getLineNumber() )
if ( x+getWidth() < 1 || x > getColumnNumber() || y < 1 || y > getLineNumber() )
return;
if ( isZoomed() )
return;
dx = xpos - x;
dy = ypos - y;
old_x = getGlobalX();
old_y = getGlobalY();
short& rsw = shadow.x_ref(); // right shadow width;
short& bsh = shadow.y_ref(); // bottom shadow height
oldGeometry = getGeometryShadow();
dx = getX() - x;
dy = getY() - y;
old_x = getTermX();
old_y = getTermY();
const FPoint& shadow = getShadow();
rsw = shadow.getX(); // right shadow width;
bsh = shadow.getY(); // bottom shadow height
oldGeometry = getGeometryWithShadow();
FWidget::move(x,y);
xpos = x;
ypos = y;
putArea (getGlobalPos(), vwin);updateTerminal();
setPos(x, y, false);
putArea (getTermPos(), vwin);updateTerminal();
if ( getGeometry().overlap(oldGeometry) )
{
@ -988,25 +1036,25 @@ void FDialog::move (int x, int y)
if ( dx > 0 )
{
if ( dy > 0 )
restoreVTerm (old_x+width+rsw-dx, old_y, dx, height+bsh-dy);
restoreVTerm (old_x+getWidth()+rsw-dx, old_y, dx, getHeight()+bsh-dy);
else
restoreVTerm (old_x+width+rsw-dx, old_y+abs(dy), dx, height+bsh-abs(dy));
restoreVTerm (old_x+getWidth()+rsw-dx, old_y+abs(dy), dx, getHeight()+bsh-abs(dy));
}
else
{
if ( dy > 0 )
restoreVTerm (old_x, old_y, abs(dx), height+bsh-dy);
restoreVTerm (old_x, old_y, abs(dx), getHeight()+bsh-dy);
else
restoreVTerm (old_x, old_y+abs(dy), abs(dx), height+bsh-abs(dy));
restoreVTerm (old_x, old_y+abs(dy), abs(dx), getHeight()+bsh-abs(dy));
}
if ( dy > 0 )
restoreVTerm (old_x, old_y+height+bsh-dy, width+rsw, dy);
restoreVTerm (old_x, old_y+getHeight()+bsh-dy, getWidth()+rsw, dy);
else
restoreVTerm (old_x, old_y, width+rsw, abs(dy));
restoreVTerm (old_x, old_y, getWidth()+rsw, abs(dy));
}
else
{
restoreVTerm (old_x, old_y, width+rsw, height+bsh);
restoreVTerm (old_x, old_y, getWidth()+rsw, getHeight()+bsh);
}
// handle overlaid windows
@ -1020,7 +1068,7 @@ void FDialog::move (int x, int y)
while ( iter != end )
{
if ( overlaid )
putArea ((*iter)->getGlobalPos(), (*iter)->getVWin());
putArea ((*iter)->getTermPos(), (*iter)->getVWin());
if ( vwin == (*iter)->getVWin() )
overlaid = true;
@ -1038,7 +1086,6 @@ void FDialog::move (int x, int y)
&& focus_widget->hasVisibleCursor() )
{
FPoint cursor_pos = focus_widget->getCursorPos();
cursor_pos -= FPoint(dx,dy);
if ( ! focus_widget->setCursorPos(cursor_pos) )
hideCursor();
@ -1069,7 +1116,7 @@ void FDialog::activateDialog()
if ( ! focusFirstChild() )
old_focus->unsetFocus();
if ( ! old_focus->isWindow() )
if ( ! old_focus->isWindowWidget() )
old_focus->redraw();
}
@ -1092,6 +1139,26 @@ bool FDialog::setFocus (bool on)
return on;
}
//----------------------------------------------------------------------
bool FDialog::setDialogWidget (bool on)
{
if ( isDialogWidget() == on )
return true;
if ( on )
{
flags |= fc::dialog_widget;
setTermOffsetWithPadding();
}
else
{
flags &= ~fc::dialog_widget;
setParentOffset();
}
return on;
}
//----------------------------------------------------------------------
bool FDialog::setModal (bool on)
{
@ -1119,17 +1186,13 @@ bool FDialog::setTransparentShadow (bool on)
{
flags |= fc::shadow;
flags |= fc::trans_shadow;
shadow.setPoint(2,1);
adjustWidgetSizeShadow = getGeometry() + getShadow();
adjustWidgetSizeGlobalShadow = getGeometryGlobal() + getShadow();
setShadowSize (2,1);
}
else
{
flags &= ~fc::shadow;
flags &= ~fc::trans_shadow;
shadow.setPoint(0,0);
adjustWidgetSizeShadow = getGeometry() + getShadow();
adjustWidgetSizeGlobalShadow = getGeometryGlobal() + getShadow();
setShadowSize (0,0);
}
resizeArea (vwin);
@ -1146,17 +1209,13 @@ bool FDialog::setShadow (bool on)
{
flags |= fc::shadow;
flags &= ~fc::trans_shadow;
shadow.setPoint(1,1);
adjustWidgetSizeShadow = getGeometry() + getShadow();
adjustWidgetSizeGlobalShadow = getGeometryGlobal() + getShadow();
setShadowSize (1,1);
}
else
{
flags &= ~fc::shadow;
flags &= ~fc::trans_shadow;
shadow.setPoint(0,0);
adjustWidgetSizeShadow = getGeometry() + getShadow();
adjustWidgetSizeGlobalShadow = getGeometryGlobal() + getShadow();
setShadowSize (0,0);
}
resizeArea (vwin);

View File

@ -65,9 +65,14 @@ class FDialog : public FWindow
FDialog (const FDialog&);
FDialog& operator = (const FDialog&);
void init();
void drawBorder();
// make every drawBorder from FWidget available
using FWidget::drawBorder;
virtual void drawBorder();
void drawTitleBar();
void leaveMenu();
void openMenu();
void selectFirstMenuItem();
void setZoomItem();
void cb_zoom (FWidget*, void*);
void cb_close (FWidget*, void*);
static void addDialog (FWidget*);
@ -104,26 +109,29 @@ class FDialog : public FWindow
void move (const FPoint&);
void move (int, int);
bool setFocus(bool);
bool setFocus (bool);
bool setFocus();
bool unsetFocus();
bool setModal(bool);
bool setDialogWidget (bool);
bool setDialogWidget();
bool unsetDialogWidget();
bool setModal (bool);
bool setModal();
bool unsetModal();
bool isModal();
bool setScrollable(bool);
bool setScrollable (bool);
bool setScrollable();
bool unsetScrollable();
bool isScrollable();
bool setResizeable(bool);
bool setResizeable (bool);
bool setResizeable();
bool unsetResizeable();
bool isResizeable();
bool setTransparentShadow(bool);
bool setTransparentShadow (bool);
bool setTransparentShadow();
bool unsetTransparentShadow();
bool hasTransparentShadow();
bool setShadow(bool);
bool setShadow (bool);
bool setShadow();
bool unsetShadow();
bool hasShadow();
@ -148,6 +156,14 @@ inline bool FDialog::setFocus()
inline bool FDialog::unsetFocus()
{ return setFocus(false); }
//----------------------------------------------------------------------
inline bool FDialog::setDialogWidget()
{ return setDialogWidget(true); }
//----------------------------------------------------------------------
inline bool FDialog::unsetDialogWidget()
{ return setDialogWidget(false); }
//----------------------------------------------------------------------
inline bool FDialog::setModal()
{ return setModal(true); }

View File

@ -51,15 +51,18 @@ class fc
// properties of a widget
enum widget_flags
{
shadow = 0x00000001,
trans_shadow = 0x00000002,
active = 0x00000004,
focus = 0x00000008,
scrollable = 0x00000010,
resizeable = 0x00000020,
modal = 0x00000040,
flat = 0x00000080,
no_underline = 0x00000100
shadow = 0x00000001,
trans_shadow = 0x00000002,
active = 0x00000004,
focus = 0x00000008,
scrollable = 0x00000010,
resizeable = 0x00000020,
modal = 0x00000040,
window_widget = 0x00000080,
dialog_widget = 0x00000100,
menu_widget = 0x00000200,
flat = 0x00000400,
no_underline = 0x00000800
};
// internal character encoding

View File

@ -63,18 +63,18 @@ FMouseEvent::FMouseEvent ( int ev_type // constructor
, int button )
: FEvent(ev_type)
, p(pos)
, g()
, tp()
, b(button)
{ }
//----------------------------------------------------------------------
FMouseEvent::FMouseEvent ( int ev_type // constructor
, const FPoint& pos
, const FPoint& globalPos
, const FPoint& termPos
, int button )
: FEvent(ev_type)
, p(pos)
, g(globalPos)
, tp(termPos)
, b(button)
{ }
@ -87,8 +87,8 @@ const FPoint& FMouseEvent::getPos() const
{ return p; }
//----------------------------------------------------------------------
const FPoint& FMouseEvent::getGlobalPos() const
{ return g; }
const FPoint& FMouseEvent::getTermPos() const
{ return tp; }
//----------------------------------------------------------------------
int FMouseEvent::getX() const
@ -99,12 +99,12 @@ int FMouseEvent::getY() const
{ return p.getY(); }
//----------------------------------------------------------------------
int FMouseEvent::getGlobalX() const
{ return g.getX(); }
int FMouseEvent::getTermX() const
{ return tp.getX(); }
//----------------------------------------------------------------------
int FMouseEvent::getGlobalY() const
{ return g.getY(); }
int FMouseEvent::getTermY() const
{ return tp.getY(); }
//----------------------------------------------------------------------
int FMouseEvent::getButton() const
@ -120,18 +120,18 @@ FWheelEvent::FWheelEvent ( int ev_type // constructor
, int wheel )
: FEvent(ev_type)
, p(pos)
, g()
, tp()
, w(wheel)
{ }
//----------------------------------------------------------------------
FWheelEvent::FWheelEvent ( int ev_type // constructor
, const FPoint& pos
, const FPoint& globalPos
, const FPoint& termPos
, int wheel )
: FEvent(ev_type)
, p(pos)
, g(globalPos)
, tp(termPos)
, w(wheel)
{ }
@ -144,8 +144,8 @@ const FPoint& FWheelEvent::getPos() const
{ return p; }
//----------------------------------------------------------------------
const FPoint& FWheelEvent::getGlobalPos() const
{ return g; }
const FPoint& FWheelEvent::getTermPos() const
{ return tp; }
//----------------------------------------------------------------------
int FWheelEvent::getX() const
@ -156,12 +156,12 @@ int FWheelEvent::getY() const
{ return p.getY(); }
//----------------------------------------------------------------------
int FWheelEvent::getGlobalX() const
{ return g.getX(); }
int FWheelEvent::getTermX() const
{ return tp.getX(); }
//----------------------------------------------------------------------
int FWheelEvent::getGlobalY() const
{ return g.getY(); }
int FWheelEvent::getTermY() const
{ return tp.getY(); }
//----------------------------------------------------------------------
int FWheelEvent::getWheel() const

View File

@ -119,16 +119,16 @@ class FMouseEvent : public FEvent // mouse event
~FMouseEvent();
const FPoint& getPos() const;
const FPoint& getGlobalPos() const;
const FPoint& getTermPos() const;
int getX() const;
int getY() const;
int getGlobalX() const;
int getGlobalY() const;
int getTermX() const;
int getTermY() const;
int getButton() const;
protected:
FPoint p;
FPoint g;
FPoint tp;
int b;
};
@ -150,16 +150,16 @@ class FWheelEvent : public FEvent // wheel event
~FWheelEvent();
const FPoint& getPos() const;
const FPoint& getGlobalPos() const;
const FPoint& getTermPos() const;
int getX() const;
int getY() const;
int getGlobalX() const;
int getGlobalY() const;
int getTermX() const;
int getTermY() const;
int getWheel() const;
protected:
FPoint p;
FPoint g;
FPoint tp;
int w;
};

View File

@ -106,22 +106,16 @@ FFileDialog::~FFileDialog() // destructor
void FFileDialog::init()
{
FWidget* parent_widget;
int x, y;
height = 15;
width = 42;
if ( width < 15 )
width = 15;
if ( width < 20 )
width = 20;
int x, y, w, h;
w = 42;
h = 15;
setGeometry(1, 1, w, h, false);
parent_widget = getParentWidget();
if ( parent_widget )
{
x = 1 + int((parent_widget->getWidth()-width)/2);
y = 1 + int((parent_widget->getHeight()-height)/3);
x = 1 + int((parent_widget->getWidth()-w)/2);
y = 1 + int((parent_widget->getHeight()-h)/3);
}
else
x = y = 1;
@ -153,7 +147,7 @@ void FFileDialog::init()
open = new FButton("&Open",this);
open->setGeometry(30, 10, 9, 1);
setGeometry (x, y, width, height);
setGeometry (x, y, getWidth(), getHeight());
filename->addCallback
(
@ -488,10 +482,10 @@ void FFileDialog::adjustSize()
h = 30;
setHeight (h, false);
X = 1 + int((max_width-width)/2);
Y = 1 + int((max_height-height)/3);
X = 1 + int((max_width - getWidth()) / 2);
Y = 1 + int((max_height - getHeight()) / 3);
setPos(X, Y, false);
filebrowser->setHeight(h-8, false);
filebrowser->setHeight (h-8, false);
hidden->setY(h-4, false);
cancel->setY(h-4, false);
open->setY(h-4, false);

View File

@ -64,13 +64,13 @@ void FLabel::init()
if ( parent_widget )
{
foregroundColor = parent_widget->getForegroundColor();
backgroundColor = parent_widget->getBackgroundColor();
setForegroundColor (parent_widget->getForegroundColor());
setBackgroundColor (parent_widget->getBackgroundColor());
}
else
{
foregroundColor = wc.dialog_fg;
backgroundColor = wc.dialog_bg;
setForegroundColor (wc.dialog_fg);
setBackgroundColor (wc.dialog_bg);
}
}
@ -153,14 +153,14 @@ int FLabel::getXOffset(int length)
return 0;
case fc::alignCenter:
if ( length < width )
return int((width - length) / 2);
if ( length < getWidth() )
return int((getWidth() - length) / 2);
else
return 0;
case fc::alignRight:
if ( length < width )
return width - length;
if ( length < getWidth() )
return getWidth() - length;
else
return 0;
@ -183,10 +183,10 @@ void FLabel::printLine ( wchar_t*& line
for (int x=0; x < xoffset; x++)
print (' ');
if ( length <= uInt(width) )
if ( length <= uInt(getWidth()) )
to_char = int(length);
else
to_char = width - 2;
to_char = getWidth() - 2;
if ( hasReverseMode() )
setReverse(true);
@ -214,23 +214,23 @@ void FLabel::printLine ( wchar_t*& line
unsetUnderline();
if ( hasEmphasis() )
setColor (emphasis_color, backgroundColor);
setColor (emphasis_color, getBackgroundColor());
else
setColor (foregroundColor, backgroundColor);
setColor();
}
else
print ( line[z] );
}
if ( length > uInt(width) )
if ( length > uInt(getWidth()) )
{
setColor (ellipsis_color, backgroundColor);
setColor (ellipsis_color, getBackgroundColor());
print ("..");
setColor (foregroundColor, backgroundColor);
setColor();
}
else
{
for (int x=xoffset+to_char; x < width; x++)
for (int x=xoffset+to_char; x < getWidth(); x++)
print (' ');
}
@ -260,19 +260,19 @@ void FLabel::draw()
}
if ( hasEmphasis() )
setColor (emphasis_color, backgroundColor);
setColor (emphasis_color, getBackgroundColor());
else
setColor (foregroundColor, backgroundColor);
setColor();
hotkeypos = -1;
if ( multiline && height > 1 )
if ( multiline && getHeight() > 1 )
{
uInt y = 0;
uInt text_lines = uInt(multiline_text.size());
bool hotkey_printed = false;
while ( y < text_lines && y < uInt(height) )
while ( y < text_lines && y < uInt(getHeight()) )
{
length = multiline_text[y].getLength();
LabelText = new wchar_t[length+1]();
@ -284,7 +284,7 @@ void FLabel::draw()
else
wcsncpy(dest, src, length);
gotoxy (xpos+xmin-1, ypos+ymin-1+int(y));
printPos (1, 1+int(y));
if ( hotkeypos != -1 )
{
@ -314,7 +314,7 @@ void FLabel::draw()
if ( hotkeypos != -1 )
length--;
gotoxy (xpos+xmin-1, ypos+ymin-1);
printPos (1,1);
xoffset = getXOffset (int(length));
printLine (LabelText, length, hotkeypos, xoffset);
delete[] LabelText;
@ -337,6 +337,7 @@ void FLabel::draw()
void FLabel::hide()
{
short fg, bg;
int size;
char* blank;
FWidget* parent_widget = getParentWidget();
@ -354,9 +355,15 @@ void FLabel::hide()
}
setColor (fg, bg);
blank = new char[width+1];
memset(blank, ' ', uLong(width));
blank[width] = '\0';
size = getWidth();
if ( size < 0 )
return;
blank = new char[size+1];
memset(blank, ' ', uLong(size));
blank[getWidth()] = '\0';
printPos (1,1);
print (blank);
delete[] blank;
}

View File

@ -22,7 +22,7 @@ FLineEdit::FLineEdit(FWidget* parent)
, scrollRepeat(100)
, insert_mode(true)
, cursor_pos(0)
, offset(0)
, text_offset(0)
, label_orientation(FLineEdit::label_left)
{
init();
@ -39,7 +39,7 @@ FLineEdit::FLineEdit (const FString& txt, FWidget* parent)
, scrollRepeat(100)
, insert_mode(true)
, cursor_pos(0)
, offset(0)
, text_offset(0)
, label_orientation(FLineEdit::label_left)
{
init();
@ -80,19 +80,19 @@ void FLineEdit::init()
if ( hasFocus() )
{
foregroundColor = wc.inputfield_active_focus_fg;
backgroundColor = wc.inputfield_active_focus_bg;
setForegroundColor (wc.inputfield_active_focus_fg);
setBackgroundColor (wc.inputfield_active_focus_bg);
}
else
{
foregroundColor = wc.inputfield_active_fg;
backgroundColor = wc.inputfield_active_bg;
setForegroundColor (wc.inputfield_active_fg);
setBackgroundColor (wc.inputfield_active_bg);
}
}
else // inactive
{
foregroundColor = wc.inputfield_inactive_fg;
backgroundColor = wc.inputfield_inactive_bg;
setForegroundColor (wc.inputfield_inactive_fg);
setBackgroundColor (wc.inputfield_inactive_bg);
}
}
@ -137,7 +137,7 @@ void FLineEdit::drawInputField()
isShadow = ((flags & fc::shadow) != 0 );
updateVTerm(false);
gotoxy (xpos+xmin-1, ypos+ymin-1);
printPos (1, 1);
if ( isMonochron() )
{
@ -186,8 +186,8 @@ void FLineEdit::drawInputField()
if ( isActiveFocus && getMaxColor() < 16 )
setBold();
setColor (foregroundColor, backgroundColor);
show_text = text.mid(uInt(1+offset), uInt(width-2));
setColor();
show_text = text.mid(uInt(1+text_offset), uInt(getWidth()-2));
if ( isUTF8_linux_terminal() )
{
@ -203,7 +203,7 @@ void FLineEdit::drawInputField()
x = int(show_text.getLength());
while ( x < width-1 )
while ( x < getWidth()-1 )
{
print (' ');
x++;
@ -224,7 +224,7 @@ void FLineEdit::drawInputField()
updateVTerm(true);
// set the cursor to the first pos.
setCursorPos (xpos+xmin+cursor_pos-offset, ypos+ymin-1);
setCursorPos (2+cursor_pos-text_offset, 1);
if ( isCursorInside() && hasFocus() && isHiddenCursor() )
showCursor();
@ -266,11 +266,11 @@ void FLineEdit::adjustLabel()
switch ( label_orientation )
{
case label_above:
label->setGeometry(xpos, ypos-1, label_length, 1);
label->setGeometry(getX(), getY()-1, label_length, 1);
break;
case label_left:
label->setGeometry(xpos-label_length, ypos, label_length, 1);
label->setGeometry(getX()-label_length, getY(), label_length, 1);
break;
}
}
@ -287,7 +287,7 @@ void FLineEdit::adjustSize()
//----------------------------------------------------------------------
void FLineEdit::hide()
{
int s, size, lable_Length;
int s, size;
short fg, bg;
char* blank;
FWidget* parent_widget = getParentWidget();
@ -307,42 +307,25 @@ void FLineEdit::hide()
setColor (fg, bg);
s = hasShadow() ? 1 : 0;
size = width + s;
size = getWidth() + s;
if ( size < 0 )
return;
blank = new char[size+1];
memset(blank, ' ', uLong(size));
blank[size] = '\0';
for (int y=0; y < height+s; y++)
for (int y=0; y < getHeight()+s; y++)
{
gotoxy (xpos+xmin-1, ypos+ymin-1+y);
printPos (1, 1+y);
print (blank);
}
delete[] blank;
lable_Length = int(label_text.getLength());
if ( lable_Length > 0 )
{
assert ( label_orientation == label_above
|| label_orientation == label_left );
switch ( label_orientation )
{
case label_above:
gotoxy (xpos+xmin-1, ypos+ymin-2);
break;
case label_left:
gotoxy (xpos+xmin-int(lable_Length)-1, ypos+ymin-1);
break;
}
blank = new char[lable_Length+1];
memset(blank, ' ', uLong(size));
blank[lable_Length] = '\0';
print (blank);
delete[] blank;
}
if ( label )
label->hide();
}
//----------------------------------------------------------------------
@ -356,20 +339,20 @@ bool FLineEdit::setEnable (bool on)
if ( hasFocus() )
{
foregroundColor = wc.inputfield_active_focus_fg;
backgroundColor = wc.inputfield_active_focus_bg;
setForegroundColor (wc.inputfield_active_focus_fg);
setBackgroundColor (wc.inputfield_active_focus_bg);
}
else
{
foregroundColor = wc.inputfield_active_fg;
backgroundColor = wc.inputfield_active_bg;
setForegroundColor (wc.inputfield_active_fg);
setBackgroundColor (wc.inputfield_active_bg);
}
}
else
{
flags &= ~fc::active;
foregroundColor = wc.inputfield_inactive_fg;
backgroundColor = wc.inputfield_inactive_bg;
setForegroundColor (wc.inputfield_inactive_fg);
setBackgroundColor (wc.inputfield_inactive_bg);
}
return on;
@ -386,8 +369,8 @@ bool FLineEdit::setFocus (bool on)
if ( isEnabled() )
{
foregroundColor = wc.inputfield_active_focus_fg;
backgroundColor = wc.inputfield_active_focus_bg;
setForegroundColor (wc.inputfield_active_focus_fg);
setBackgroundColor (wc.inputfield_active_focus_bg);
if ( statusBar() )
{
@ -405,8 +388,8 @@ bool FLineEdit::setFocus (bool on)
if ( isEnabled() )
{
foregroundColor = wc.inputfield_active_fg;
backgroundColor = wc.inputfield_active_bg;
setForegroundColor (wc.inputfield_active_fg);
setBackgroundColor (wc.inputfield_active_bg);
if ( statusBar() )
statusBar()->clearMessage();
@ -443,8 +426,8 @@ void FLineEdit::onKeyPress (FKeyEvent* ev)
if ( cursor_pos < 0 )
cursor_pos=0;
if ( cursor_pos < offset )
offset--;
if ( cursor_pos < text_offset )
text_offset--;
ev->accept();
break;
@ -455,22 +438,22 @@ void FLineEdit::onKeyPress (FKeyEvent* ev)
if ( cursor_pos >= len )
cursor_pos=len;
if ( cursor_pos-offset >= width-2 && offset <= len-width+1 )
offset++;
if ( cursor_pos-text_offset >= getWidth()-2 && text_offset <= len-getWidth()+1 )
text_offset++;
ev->accept();
break;
case fc::Fkey_home:
cursor_pos=0;
offset=0;
text_offset=0;
ev->accept();
break;
case fc::Fkey_end:
cursor_pos=len;
if ( cursor_pos >= width-1 )
offset=len-width+2;
if ( cursor_pos >= getWidth()-1 )
text_offset=len-getWidth()+2;
ev->accept();
break;
@ -487,8 +470,8 @@ void FLineEdit::onKeyPress (FKeyEvent* ev)
if ( cursor_pos < 0 )
cursor_pos=0;
if ( offset > 0 && len-offset < width-1 )
offset--;
if ( text_offset > 0 && len-text_offset < getWidth()-1 )
text_offset--;
ev->accept();
break;
@ -501,8 +484,8 @@ void FLineEdit::onKeyPress (FKeyEvent* ev)
processChanged();
cursor_pos--;
if ( offset > 0 )
offset--;
if ( text_offset > 0 )
text_offset--;
}
ev->accept();
@ -567,8 +550,8 @@ void FLineEdit::onKeyPress (FKeyEvent* ev)
}
cursor_pos++;
if ( cursor_pos >= width-1 )
offset++;
if ( cursor_pos >= getWidth()-1 )
text_offset++;
ev->accept();
}
@ -613,10 +596,10 @@ void FLineEdit::onMouseDown (FMouseEvent* ev)
mouse_x = ev->getX();
mouse_y = ev->getY();
if ( mouse_x >= 2 && mouse_x <= width && mouse_y == 1 )
if ( mouse_x >= 2 && mouse_x <= getWidth() && mouse_y == 1 )
{
int len = int(text.getLength());
cursor_pos = offset + mouse_x - 2;
cursor_pos = text_offset + mouse_x - 2;
if ( cursor_pos >= len )
cursor_pos = len;
@ -649,9 +632,9 @@ void FLineEdit::onMouseMove (FMouseEvent* ev)
mouse_x = ev->getX();
mouse_y = ev->getY();
if ( mouse_x >= 2 && mouse_x <= width && mouse_y == 1 )
if ( mouse_x >= 2 && mouse_x <= getWidth() && mouse_y == 1 )
{
cursor_pos = offset + mouse_x - 2;
cursor_pos = text_offset + mouse_x - 2;
if ( cursor_pos >= len )
cursor_pos=len;
@ -664,30 +647,30 @@ void FLineEdit::onMouseMove (FMouseEvent* ev)
if ( mouse_x < 2 )
{
// drag left
if ( ! scrollTimer && offset > 0 )
if ( ! scrollTimer && text_offset > 0 )
{
scrollTimer = true;
addTimer(scrollRepeat);
dragScroll = FLineEdit::scrollLeft;
}
if ( offset == 0 )
if ( text_offset == 0 )
{
delOwnTimer();
dragScroll = FLineEdit::noScroll;
}
}
else if ( mouse_x >= width )
else if ( mouse_x >= getWidth() )
{
// drag right
if ( ! scrollTimer && offset <= len-width+1 )
if ( ! scrollTimer && text_offset <= len-getWidth()+1 )
{
scrollTimer = true;
addTimer(scrollRepeat);
dragScroll = FLineEdit::scrollRight;
}
if ( offset == len-width+2 )
if ( text_offset == len-getWidth()+2 )
{
delOwnTimer();
dragScroll = FLineEdit::noScroll;
@ -713,16 +696,16 @@ void FLineEdit::onTimer (FTimerEvent*)
return;
case FLineEdit::scrollLeft:
if ( offset == 0)
if ( text_offset == 0)
{
dragScroll = FLineEdit::noScroll;
return;
}
offset--;
text_offset--;
if ( offset < 0 )
offset = 0;
if ( text_offset < 0 )
text_offset = 0;
cursor_pos--;
@ -732,16 +715,16 @@ void FLineEdit::onTimer (FTimerEvent*)
break;
case FLineEdit::scrollRight:
if ( offset == len-width+2 )
if ( text_offset == len-getWidth()+2 )
{
dragScroll = FLineEdit::noScroll;
return;
}
offset++;
text_offset++;
if ( offset > len-width+2 )
offset = len-width+2;
if ( text_offset > len-getWidth()+2 )
text_offset = len-getWidth()+2;
cursor_pos++;
@ -857,7 +840,7 @@ void FLineEdit::onFocusOut (FFocusEvent*)
//----------------------------------------------------------------------
void FLineEdit::clearText()
{
offset = 0;
text_offset = 0;
cursor_pos = 0;
text.clear();
}
@ -865,7 +848,7 @@ void FLineEdit::clearText()
//----------------------------------------------------------------------
void FLineEdit::setText (FString txt)
{
offset = 0;
text_offset = 0;
cursor_pos = 0;
if ( txt )

View File

@ -51,7 +51,7 @@ class FLineEdit : public FWidget
int scrollRepeat;
bool insert_mode;
int cursor_pos;
int offset;
int text_offset;
public:
enum label_o

View File

@ -98,8 +98,8 @@ void FListBox::init()
nf_offset = isNewFont() ? 1 : 0;
foregroundColor = wc.dialog_fg;
backgroundColor = wc.dialog_bg;
setForegroundColor (wc.dialog_fg);
setBackgroundColor (wc.dialog_bg);
VBar = new FScrollbar(fc::vertical, this);
VBar->setMinimum(0);
@ -135,29 +135,24 @@ void FListBox::draw()
current = 1;
updateVTerm(false);
setColor (foregroundColor, backgroundColor);
setColor();
if ( isMonochron() )
setReverse(true);
if ( isNewFont() )
width--;
drawBorder (1, getWidth() - 1, 1, getHeight());
else
drawBorder();
drawBorder();
if ( isNewFont() )
if ( isNewFont() && ! VBar->isVisible() )
{
width++;
setColor();
if ( ! VBar->isVisible() )
for (int y=2; y < getHeight(); y++)
{
setColor (foregroundColor, backgroundColor);
for (int y=ypos+ymin; y < ypos+ymin+height-2; y++)
{
gotoxy(xpos+xmin+width-2, y);
print (' '); // clear right side of the scrollbar
}
printPos (getWidth(),y);
print (' '); // clear right side of the scrollbar
}
}
@ -201,18 +196,18 @@ void FListBox::drawLabel()
txt = " " + text + " ";
length = txt.getLength();
gotoxy (xpos+xmin, ypos+ymin-1);
printPos (2, 1);
if ( isEnabled() )
setColor(wc.label_emphasis_fg, wc.label_bg);
else
setColor(wc.label_inactive_fg, wc.label_inactive_bg);
if ( length <= uInt(width-2) )
if ( length <= uInt(getWidth()-2) )
print (txt);
else
{
print (text.left(uInt(width-4)));
print (text.left(uInt(getWidth()-4)));
setColor (wc.label_ellipsis_fg, wc.label_bg);
print("..");
}
@ -225,12 +220,12 @@ void FListBox::drawList()
uInt start, end, inc_len;
bool isFocus;
if ( data.empty() || height < 4 || width < 5 )
if ( data.empty() || getHeight() < 4 || getWidth() < 5 )
return;
isFocus = ((flags & fc::focus) != 0);
start = 0;
end = uInt(height-2);
end = uInt(getHeight()-2);
inc_len = inc_search.getLength();
if ( end > count() )
@ -251,7 +246,7 @@ void FListBox::drawList()
for (uInt y=start; y < end; y++)
{
gotoxy (xpos+xmin, ypos+ymin+int(y));
printPos (2, 2 + int(y));
bool serach_mark = false;
bool lineHasBrackets = hasBrackets(int(y) + yoffset + 1);
bool isLineSelected = isSelected(int(y) + yoffset + 1);
@ -288,8 +283,7 @@ void FListBox::drawList()
setColor ( wc.selected_current_element_fg
, wc.selected_current_element_bg );
setCursorPos ( xpos+xmin+1
, ypos+ymin+int(y) ); // first character
setCursorPos (3, 2 + int(y)); // first character
}
else
{
@ -300,17 +294,15 @@ void FListBox::drawList()
{
setColor ( wc.current_element_focus_fg
, wc.current_element_focus_bg );
int b = ( lineHasBrackets ) ? 1: 0;
if ( inc_len > 0 )
if ( inc_len > 0 ) // incremental search
{
serach_mark = true;
int b = ( lineHasBrackets ) ? 1: 0;
setCursorPos ( xpos+xmin+int(inc_len)+b
, ypos+ymin+int(y) ); // last found character
setCursorPos (2 + b + int(inc_len), 2 + int(y)); // last found character
}
else
setCursorPos ( xpos+xmin+1
, ypos+ymin+int(y) ); // first character
else // only highlighted
setCursorPos (3 + b, 2 + int(y)); // first character
}
else
setColor ( wc.current_element_fg
@ -370,12 +362,12 @@ void FListBox::drawList()
element = data[y+uInt(yoffset)].getText()
.mid ( uInt(1+xoffset)
, uInt(width-nf_offset-5) );
, uInt(getWidth()-nf_offset-5) );
}
else
element = data[y+uInt(yoffset)].getText()
.mid ( uInt(xoffset)
, uInt(width-nf_offset-4) );
, uInt(getWidth()-nf_offset-4) );
element_str = element.wc_str();
len = element.getLength();
@ -395,7 +387,7 @@ void FListBox::drawList()
full_length = int(data[y+uInt(yoffset)].getText().getLength());
if ( b+i < uInt(width-nf_offset-4) && xoffset <= full_length+1 )
if ( b+i < uInt(getWidth()-nf_offset-4) && xoffset <= full_length+1 )
{
if ( serach_mark && i == inc_len )
setColor ( wc.current_element_focus_fg
@ -432,7 +424,7 @@ void FListBox::drawList()
i++;
}
for (; b+i < uInt(width-nf_offset-3); i++)
for (; b+i < uInt(getWidth()-nf_offset-3); i++)
print (' ');
}
else // line has no brackets
@ -441,7 +433,7 @@ void FListBox::drawList()
uInt i, len;
element = data[y+uInt(yoffset)].getText()
.mid ( uInt(1+xoffset)
, uInt(width-nf_offset-4) );
, uInt(getWidth()-nf_offset-4) );
element_str = element.wc_str();
len = element.getLength();
@ -464,7 +456,7 @@ void FListBox::drawList()
i++;
}
for (; i < uInt(width-nf_offset-3); i++)
for (; i < uInt(getWidth()-nf_offset-3); i++)
print (' ');
}
}
@ -508,8 +500,8 @@ void FListBox::adjustYOffset()
{
int element_count = int(count());
if ( yoffset > element_count - height + 2 )
yoffset = element_count - height + 2;
if ( yoffset > element_count - getHeight() + 2 )
yoffset = element_count - getHeight() + 2;
if ( yoffset < 0 )
yoffset = 0;
@ -517,8 +509,8 @@ void FListBox::adjustYOffset()
if ( current < yoffset )
current = yoffset;
if ( current >= yoffset + height - 1 )
yoffset = current - height + 2;
if ( current >= yoffset + getHeight() - 1 )
yoffset = current - getHeight() + 2;
}
//----------------------------------------------------------------------
@ -529,24 +521,24 @@ void FListBox::adjustSize()
FWidget::adjustSize();
element_count = int(count());
VBar->setMaximum(element_count - height + 2);
VBar->setPageSize(element_count, height - 2);
VBar->setX(width);
VBar->setHeight (height-2, false);
VBar->setMaximum(element_count - getHeight() + 2);
VBar->setPageSize(element_count, getHeight() - 2);
VBar->setX(getWidth());
VBar->setHeight (getHeight()-2, false);
VBar->resize();
HBar->setMaximum(maxLineWidth - width + nf_offset + 4);
HBar->setPageSize(maxLineWidth, width - nf_offset - 4);
HBar->setY(height);
HBar->setWidth (width-2, false);
HBar->setMaximum(maxLineWidth - getWidth() + nf_offset + 4);
HBar->setPageSize(maxLineWidth, getWidth() - nf_offset - 4);
HBar->setY(getHeight());
HBar->setWidth (getWidth()-2, false);
HBar->resize();
if ( element_count < height - 1 )
if ( element_count < getHeight() - 1 )
VBar->hide();
else
VBar->setVisible();
if ( maxLineWidth < width - nf_offset - 3 )
if ( maxLineWidth < getWidth() - nf_offset - 3 )
HBar->hide();
else
HBar->setVisible();
@ -602,14 +594,18 @@ void FListBox::hide()
setColor (fg, bg);
n = isNewFont() ? 1 : 0;
size = width + n;
size = getWidth() + n;
if ( size < 0 )
return;
blank = new char[size+1];
memset(blank, ' ', uLong(size));
blank[size] = '\0';
for (int y=0; y < height; y++)
for (int y=0; y < getHeight(); y++)
{
gotoxy (xpos+xmin-1, ypos+ymin-1+y);
printPos (1, 1 + y);
print (blank);
}
@ -630,10 +626,10 @@ void FListBox::showInsideBrackets ( int index
{
maxLineWidth = len;
if ( len >= width - nf_offset - 3 )
if ( len >= getWidth() - nf_offset - 3 )
{
HBar->setMaximum(maxLineWidth - width + nf_offset + 4);
HBar->setPageSize(maxLineWidth, width - nf_offset - 4);
HBar->setMaximum(maxLineWidth - getWidth() + nf_offset + 4);
HBar->setPageSize(maxLineWidth, getWidth() - nf_offset - 4);
HBar->setValue (xoffset);
if ( ! HBar->isVisible() )
@ -650,13 +646,13 @@ void FListBox::setGeometry (int x, int y, int w, int h, bool adjust)
if ( isNewFont() )
{
VBar->setGeometry(width, 2, 2, height-2);
HBar->setGeometry(1, height, width-2, 1);
VBar->setGeometry (getWidth(), 2, 2, getHeight()-2);
HBar->setGeometry (1, getHeight(), getWidth()-2, 1);
}
else
{
VBar->setGeometry(width, 2, 1, height-2);
HBar->setGeometry(2, height, width-2, 1);
VBar->setGeometry (getWidth(), 2, 1, getHeight()-2);
HBar->setGeometry (2, getHeight(), getWidth()-2, 1);
}
}
@ -739,7 +735,7 @@ void FListBox::onKeyPress (FKeyEvent* ev)
if ( current > element_count )
current = element_count;
if ( current - yoffset >= height - 1 )
if ( current - yoffset >= getHeight() - 1 )
yoffset++;
inc_search.clear();
@ -759,8 +755,8 @@ void FListBox::onKeyPress (FKeyEvent* ev)
case fc::Fkey_right:
xoffset++;
if ( xoffset > maxLineWidth - width + nf_offset + 4 )
xoffset = maxLineWidth - width + nf_offset + 4;
if ( xoffset > maxLineWidth - getWidth() + nf_offset + 4 )
xoffset = maxLineWidth - getWidth() + nf_offset + 4;
if ( xoffset < 0 )
xoffset = 0;
@ -770,14 +766,14 @@ void FListBox::onKeyPress (FKeyEvent* ev)
break;
case fc::Fkey_ppage:
current -= height-3;
current -= getHeight()-3;
if ( current < 1 )
current=1;
if ( current <= yoffset )
{
yoffset -= height-3;
yoffset -= getHeight()-3;
if ( yoffset < 0 )
yoffset=0;
@ -788,17 +784,17 @@ void FListBox::onKeyPress (FKeyEvent* ev)
break;
case fc::Fkey_npage:
current += height-3;
current += getHeight()-3;
if ( current > element_count )
current = element_count;
if ( current - yoffset >= height - 1 )
if ( current - yoffset >= getHeight() - 1 )
{
yoffset += height-3;
yoffset += getHeight()-3;
if ( yoffset > element_count - height + 2 )
yoffset = element_count - height + 2;
if ( yoffset > element_count - getHeight() + 2 )
yoffset = element_count - getHeight() + 2;
}
inc_search.clear();
@ -815,8 +811,8 @@ void FListBox::onKeyPress (FKeyEvent* ev)
case fc::Fkey_end:
current = element_count;
if ( current >= height - 1 )
yoffset = element_count - height + 2;
if ( current >= getHeight() - 1 )
yoffset = element_count - getHeight() + 2;
inc_search.clear();
ev->accept();
@ -836,7 +832,7 @@ void FListBox::onKeyPress (FKeyEvent* ev)
if ( current > element_count )
current = element_count;
if ( current-yoffset >= height - 1 )
if ( current-yoffset >= getHeight() - 1 )
yoffset++;
ev->accept();
@ -1030,8 +1026,8 @@ void FListBox::onMouseDown (FMouseEvent* ev)
mouse_x = ev->getX();
mouse_y = ev->getY();
if ( mouse_x > 1 && mouse_x < width
&& mouse_y > 1 && mouse_y < height )
if ( mouse_x > 1 && mouse_x < getWidth()
&& mouse_y > 1 && mouse_y < getHeight() )
{
current = yoffset + mouse_y - 1;
@ -1088,8 +1084,8 @@ void FListBox::onMouseUp (FMouseEvent* ev)
int mouse_x = ev->getX();
int mouse_y = ev->getY();
if ( mouse_x > 1 && mouse_x < width
&& mouse_y > 1 && mouse_y < height )
if ( mouse_x > 1 && mouse_x < getWidth()
&& mouse_y > 1 && mouse_y < getHeight() )
{
processChanged();
@ -1118,8 +1114,8 @@ void FListBox::onMouseMove (FMouseEvent* ev)
mouse_x = ev->getX();
mouse_y = ev->getY();
if ( mouse_x > 1 && mouse_x < width
&& mouse_y > 1 && mouse_y < height )
if ( mouse_x > 1 && mouse_x < getWidth()
&& mouse_y > 1 && mouse_y < getHeight() )
{
current = yoffset + mouse_y - 1;
@ -1178,7 +1174,7 @@ void FListBox::onMouseMove (FMouseEvent* ev)
if ( mouse_y < 2 )
{
// drag up
if ( dragScroll != FListBox::noScroll && scrollDistance < height-2 )
if ( dragScroll != FListBox::noScroll && scrollDistance < getHeight()-2 )
scrollDistance++;
if ( ! scrollTimer && current > 1 )
@ -1198,10 +1194,10 @@ void FListBox::onMouseMove (FMouseEvent* ev)
dragScroll = FListBox::noScroll;
}
}
else if ( mouse_y >= height )
else if ( mouse_y >= getHeight() )
{
// drag down
if ( dragScroll != FListBox::noScroll && scrollDistance < height-2 )
if ( dragScroll != FListBox::noScroll && scrollDistance < getHeight()-2 )
scrollDistance++;
if ( ! scrollTimer && current < int(count()) )
@ -1242,8 +1238,8 @@ void FListBox::onMouseDoubleClick (FMouseEvent* ev)
mouse_x = ev->getX();
mouse_y = ev->getY();
if ( mouse_x > 1 && mouse_x < width
&& mouse_y > 1 && mouse_y < height )
if ( mouse_x > 1 && mouse_x < getWidth()
&& mouse_y > 1 && mouse_y < getHeight() )
{
if ( yoffset + mouse_y - 1 > int(count()) )
return;
@ -1297,11 +1293,11 @@ void FListBox::onTimer (FTimerEvent*)
if ( current > element_count )
current = element_count;
if ( current - yoffset >= height - 1 )
if ( current - yoffset >= getHeight() - 1 )
yoffset += scrollDistance;
if ( yoffset > element_count - height + 2 )
yoffset = element_count - height + 2;
if ( yoffset > element_count - getHeight() + 2 )
yoffset = element_count - getHeight() + 2;
default:
break;
@ -1363,7 +1359,7 @@ void FListBox::onWheel (FWheelEvent* ev)
element_count = int(count());
current_before = current;
yoffset_before = yoffset;
yoffset_end = element_count - height + 2;
yoffset_end = element_count - getHeight() + 2;
if ( yoffset_end < 0 )
yoffset_end = 0;
@ -1477,7 +1473,7 @@ void FListBox::cb_VBarChange (FWidget*, void*)
switch ( scrollType )
{
case FScrollbar::scrollPageBackward:
distance = height-2;
distance = getHeight()-2;
// fall through
case FScrollbar::scrollStepBackward:
current -= distance;
@ -1494,7 +1490,7 @@ void FListBox::cb_VBarChange (FWidget*, void*)
break;
case FScrollbar::scrollPageForward:
distance = height-2;
distance = getHeight()-2;
// fall through
case FScrollbar::scrollStepForward:
current += distance;
@ -1502,11 +1498,11 @@ void FListBox::cb_VBarChange (FWidget*, void*)
if ( current > element_count )
current = element_count;
if ( current - yoffset >= height - 1 )
if ( current - yoffset >= getHeight() - 1 )
yoffset += distance;
if ( yoffset > element_count - height + 2 )
yoffset = element_count - height + 2;
if ( yoffset > element_count - getHeight() + 2 )
yoffset = element_count - getHeight() + 2;
break;
@ -1520,8 +1516,8 @@ void FListBox::cb_VBarChange (FWidget*, void*)
int c = current - yoffset;
yoffset = val;
if ( yoffset > element_count - height + 2 )
yoffset = element_count - height + 2;
if ( yoffset > element_count - getHeight() + 2 )
yoffset = element_count - getHeight() + 2;
if ( yoffset < 0 )
yoffset = 0;
@ -1576,13 +1572,13 @@ void FListBox::cb_HBarChange (FWidget*, void*)
{
int distance = 1;
int xoffset_before = xoffset;
int xoffset_end = maxLineWidth - width + nf_offset + 4;
int xoffset_end = maxLineWidth - getWidth() + nf_offset + 4;
int scrollType = HBar->getScrollType();
switch ( scrollType )
{
case FScrollbar::scrollPageBackward:
distance = width - nf_offset - 4;
distance = getWidth() - nf_offset - 4;
// fall through
case FScrollbar::scrollStepBackward:
xoffset -= distance;
@ -1592,13 +1588,13 @@ void FListBox::cb_HBarChange (FWidget*, void*)
break;
case FScrollbar::scrollPageForward:
distance = width - nf_offset - 4;
distance = getWidth() - nf_offset - 4;
// fall through
case FScrollbar::scrollStepForward:
xoffset += distance;
if ( xoffset > maxLineWidth - width + nf_offset + 4 )
xoffset = maxLineWidth - width + nf_offset + 4;
if ( xoffset > maxLineWidth - getWidth() + nf_offset + 4 )
xoffset = maxLineWidth - getWidth() + nf_offset + 4;
if ( xoffset < 0 )
xoffset = 0;
@ -1614,8 +1610,8 @@ void FListBox::cb_HBarChange (FWidget*, void*)
xoffset = val;
if ( xoffset > maxLineWidth - width + nf_offset + 4 )
xoffset = maxLineWidth - width + nf_offset + 4;
if ( xoffset > maxLineWidth - getWidth() + nf_offset + 4 )
xoffset = maxLineWidth - getWidth() + nf_offset + 4;
if ( xoffset < 0 )
xoffset = 0;
@ -1685,10 +1681,10 @@ void FListBox::insert ( FString item
{
maxLineWidth = len;
if ( len >= width - nf_offset - 3 )
if ( len >= getWidth() - nf_offset - 3 )
{
HBar->setMaximum(maxLineWidth - width + nf_offset + 4);
HBar->setPageSize(maxLineWidth, width - nf_offset - 4);
HBar->setMaximum(maxLineWidth - getWidth() + nf_offset + 4);
HBar->setPageSize(maxLineWidth, getWidth() - nf_offset - 4);
HBar->calculateSliderValues();
if ( ! HBar->isVisible() )
@ -1701,11 +1697,11 @@ void FListBox::insert ( FString item
data.push_back (listItem);
element_count = int(count());
VBar->setMaximum(element_count - height + 2);
VBar->setPageSize(element_count, height - 2);
VBar->setMaximum(element_count - getHeight() + 2);
VBar->setPageSize(element_count, getHeight() - 2);
VBar->calculateSliderValues();
if ( ! VBar->isVisible() && element_count >= height - 1 )
if ( ! VBar->isVisible() && element_count >= getHeight() - 1 )
VBar->setVisible();
}
@ -1737,16 +1733,16 @@ void FListBox::remove (int item)
maxLineWidth = len;
}
HBar->setMaximum(maxLineWidth - width + nf_offset + 4);
HBar->setPageSize(maxLineWidth, width - nf_offset - 4);
HBar->setMaximum(maxLineWidth - getWidth() + nf_offset + 4);
HBar->setPageSize(maxLineWidth, getWidth() - nf_offset - 4);
if ( HBar->isVisible() && maxLineWidth < width - nf_offset - 3 )
if ( HBar->isVisible() && maxLineWidth < getWidth() - nf_offset - 3 )
HBar->hide();
VBar->setMaximum(element_count - height + 2);
VBar->setPageSize(element_count, height - 2);
VBar->setMaximum(element_count - getHeight() + 2);
VBar->setPageSize(element_count, getHeight() - 2);
if ( VBar->isVisible() && element_count < height - 1 )
if ( VBar->isVisible() && element_count < getHeight() - 1 )
VBar->hide();
if ( current >= item && current > 1 )
@ -1755,8 +1751,8 @@ void FListBox::remove (int item)
if ( current > element_count )
current = element_count;
if ( yoffset > element_count - height + 2 )
yoffset = element_count - height + 2;
if ( yoffset > element_count - getHeight() + 2 )
yoffset = element_count - getHeight() + 2;
if ( yoffset < 0 )
yoffset = 0;
@ -1787,14 +1783,18 @@ void FListBox::clear()
// clear list from screen
setColor (wc.list_fg, wc.list_bg);
size = width - 2;
size = getWidth() - 2;
if ( size < 0 )
return;
blank = new char[size+1];
memset(blank, ' ', uLong(size));
blank[size] = '\0';
for (int y=0; y < height-2; y++)
for (int y=0; y < getHeight()-2; y++)
{
gotoxy (xpos+xmin, ypos+ymin+y);
printPos (2, 2 + y);
print (blank);
}

View File

@ -43,6 +43,7 @@ class FListBoxItem
FString text;
fc::brackets_type brackets;
bool selected;
public:
FListBoxItem ();
explicit FListBoxItem (FString&);
@ -50,10 +51,12 @@ class FListBoxItem
explicit FListBoxItem (const char*);
virtual ~FListBoxItem();
virtual FString getText() const;
protected:
void setText (FString&);
void setText (const std::string&);
void setText (const char*);
private:
friend class FListBox;
};

View File

@ -78,8 +78,8 @@ FMenu::~FMenu()
if ( ! fapp->isQuit() )
{
const FRect& geometry = getGeometryGlobalShadow();
restoreVTerm (geometry);
const FRect& t_geometry = getTermGeometryWithShadow();
restoreVTerm (t_geometry);
}
if ( vwin != 0 )
@ -99,30 +99,20 @@ FMenu::~FMenu()
//----------------------------------------------------------------------
void FMenu::init(FWidget* parent)
{
FWidget* rootObj = getRootWidget();
xmin = 1 + rootObj->getLeftPadding();
ymin = 1 + rootObj->getTopPadding();
xmax = rootObj->getWidth();
ymax = rootObj->getHeight();
width = 10;
height = 2;
client_xmin = 1;
client_ymin = 1;
client_xmax = width;
client_ymax = height;
top_padding = 1;
left_padding = 1;
bottom_padding = 1;
right_padding = 1;
setTopPadding(1);
setLeftPadding(1);
setBottomPadding(1);
setRightPadding(1);
createArea (vwin);
setMenuWidget();
setGeometry (1, 1, 10, 2, false); // initialize geometry values
setTransparentShadow();
menu_object = true;
setMenuWidget();
addWindow(this);
hide();
foregroundColor = wc.menu_active_fg;
backgroundColor = wc.menu_active_bg;
setForegroundColor (wc.menu_active_fg);
setBackgroundColor (wc.menu_active_bg);
if ( item )
item->setMenu(this);
@ -185,10 +175,10 @@ void FMenu::menu_dimension()
++iter;
}
adjust_X = adjustX(xpos);
adjust_X = adjustX(getX());
// set widget geometry
setGeometry (adjust_X, ypos, int(maxItemWidth + 2), int(count() + 2));
setGeometry (adjust_X, getY(), int(maxItemWidth + 2), int(count() + 2));
// set geometry of all items
iter = itemlist.begin();
@ -201,8 +191,8 @@ void FMenu::menu_dimension()
if ( (*iter)->hasMenu() )
{
int menu_X = getGlobalX() + int(maxItemWidth) + 1;
int menu_Y = (*iter)->getGlobalY() - 2;
int menu_X = getTermX() + int(maxItemWidth) + 1;
int menu_Y = (*iter)->getTermY() - 2;
// set sub-menu position
(*iter)->getMenu()->setPos (menu_X, menu_Y, false);
}
@ -226,9 +216,9 @@ void FMenu::adjustItems()
int menu_X, menu_Y;
FMenu* menu = (*iter)->getMenu();
menu_X = getGlobalX() + int(maxItemWidth) + 1;
menu_X = getTermX() + int(maxItemWidth) + 1;
menu_X = menu->adjustX(menu_X);
menu_Y = (*iter)->getGlobalY() - 2;
menu_Y = (*iter)->getTermY() - 2;
// set sub-menu position
menu->move (menu_X, menu_Y);
@ -260,7 +250,7 @@ int FMenu::adjustX (int x_pos)
//----------------------------------------------------------------------
bool FMenu::isWindowsMenu (FWidget* w) const
{
return w->isDialog();
return w->isDialogWidget();
}
//----------------------------------------------------------------------
@ -364,33 +354,33 @@ void FMenu::hideSuperMenus()
}
//----------------------------------------------------------------------
bool FMenu::containsMenuStructure (int x, int y) const
bool FMenu::containsMenuStructure (int x, int y)
{
// Check mouse click position for item, menu and all sub menus
FMenuItem* si = getSelectedItem();
if ( getGeometryGlobal().contains(x,y) )
if ( getTermGeometry().contains(x,y) )
return true;
else if ( si && si->hasMenu() && open_sub_menu )
return si->getMenu()->containsMenuStructure(x,y);
else if ( item && item->getGeometryGlobal().contains(x,y) )
else if ( item && item->getTermGeometry().contains(x,y) )
return true;
else
return false;
}
//----------------------------------------------------------------------
FMenu* FMenu::superMenuAt (int x, int y) const
FMenu* FMenu::superMenuAt (int x, int y)
{
// Check mouse click position for super menu
if ( getGeometryGlobal().contains(x,y) )
if ( getTermGeometry().contains(x,y) )
return 0;
FWidget* super = getSuperMenu();
if ( super && isMenu(super) )
{
if ( super->getGeometryGlobal().contains(x,y) )
if ( super->getTermGeometry().contains(x,y) )
return dynamic_cast<FMenu*>(super);
else
{
@ -620,7 +610,7 @@ void FMenu::draw()
area = area_widget->getVWin();
if ( area )
putArea (xpos+xmin-1, ypos+ymin-1, area);
putArea (getTermX(), getTermY(), area);
}
}
else
@ -630,15 +620,14 @@ void FMenu::draw()
//----------------------------------------------------------------------
void FMenu::drawBorder()
{
int x1, x2, y1, y2;
x1 = xpos+xmin-1;
x2 = xpos+xmin-2+width;
y1 = ypos+ymin-1;
y2 = ypos+ymin-2+height;
int x1 = 1;
int x2 = 1 + getWidth() - 1;
int y1 = 1;
int y2 = 1 + getHeight() - 1;
if ( isNewFont() )
{
gotoxy (x1, y1);
printPos (x1, y1);
print (fc::NF_border_corner_upper_left); // ⎡
for (int x=x1+1; x < x2; x++)
@ -648,35 +637,35 @@ void FMenu::drawBorder()
for (int y=y1+1; y <= y2; y++)
{
gotoxy (x1, y);
printPos (x1, y);
// border left ⎸
print (fc::NF_border_line_left);
gotoxy (x2, y);
printPos (x2, y);
// border right⎹
print (fc::NF_rev_border_line_right);
}
gotoxy (x1, y2);
printPos (x1, y2);
// lower left corner border ⎣
print (fc::NF_border_corner_lower_left);
for (int x=1; x < width-1; x++) // low line _
for (int x=1; x < getWidth()-1; x++) // low line _
print (fc::NF_border_line_bottom);
gotoxy (x2, y2);
printPos (x2, y2);
// lower right corner border ⎦
print (fc::NF_rev_border_corner_lower_right);
}
else
{
gotoxy (x1, y1);
printPos (x1, y1);
print (fc::BoxDrawingsDownAndRight); // ┌
for (int x=x1+1; x < x2; x++)
print (fc::BoxDrawingsHorizontal); // ─
print (fc::BoxDrawingsDownAndLeft); // ┐
gotoxy (x1, y2);
printPos (x1, y2);
print (fc::BoxDrawingsUpAndRight); // └
for (int x=x1+1; x < x2; x++)
@ -686,9 +675,9 @@ void FMenu::drawBorder()
for (int y=y1+1; y < y2; y++)
{
gotoxy (x1, y);
printPos (x1, y);
print (fc::BoxDrawingsVertical); // │
gotoxy (x2, y);
printPos (x2, y);
print (fc::BoxDrawingsVertical); // │
}
}
@ -740,16 +729,16 @@ void FMenu::drawItems()
{
if ( is_selected )
{
foregroundColor = wc.menu_active_focus_fg;
backgroundColor = wc.menu_active_focus_bg;
setForegroundColor (wc.menu_active_focus_fg);
setBackgroundColor (wc.menu_active_focus_bg);
if ( isMonochron() )
setReverse(false);
}
else
{
foregroundColor = wc.menu_active_fg;
backgroundColor = wc.menu_active_bg;
setForegroundColor (wc.menu_active_fg);
setBackgroundColor (wc.menu_active_bg);
if ( isMonochron() )
setReverse(true);
@ -757,15 +746,15 @@ void FMenu::drawItems()
}
else
{
foregroundColor = wc.menu_inactive_fg;
backgroundColor = wc.menu_inactive_bg;
setForegroundColor (wc.menu_inactive_fg);
setBackgroundColor (wc.menu_inactive_bg);
if ( isMonochron() )
setReverse(true);
}
gotoxy (xpos+xmin, ypos+ymin+y);
setColor (foregroundColor, backgroundColor);
printPos (2, 2 + y);
setColor();
if ( has_checkable_items )
{
@ -792,14 +781,14 @@ void FMenu::drawItems()
}
else
{
setColor (wc.menu_inactive_fg, backgroundColor);
setColor (wc.menu_inactive_fg, getBackgroundColor());
if ( getEncoding() == "ASCII" )
print ('-');
else
print (fc::SmallBullet);
setColor (foregroundColor, backgroundColor);
setColor();
}
}
else
@ -818,14 +807,12 @@ void FMenu::drawItems()
if ( hotkeypos == -1 )
{
if ( is_selected )
setCursorPos ( xpos+xmin+1
, ypos+ymin+y ); // first character
setCursorPos (1, 2 + y); // first character
}
else
{
if ( is_selected )
setCursorPos ( xpos+xmin+1+hotkeypos
, ypos+ymin+y ); // hotkey
setCursorPos (1 + hotkeypos, 2 + y); // hotkey
txt_length--;
to_char--;
@ -856,7 +843,7 @@ void FMenu::drawItems()
if ( ! is_noUnderline )
unsetUnderline();
setColor (foregroundColor, backgroundColor);
setColor();
}
else
print (item_text[z]);
@ -911,7 +898,7 @@ void FMenu::drawItems()
//----------------------------------------------------------------------
inline void FMenu::drawSeparator(int y)
{
gotoxy (xpos+xmin-1, ypos+ymin+y);
printPos (1, 2 + y);
setColor (wc.menu_active_fg, wc.menu_active_bg);
if ( isMonochron() )
@ -920,14 +907,14 @@ inline void FMenu::drawSeparator(int y)
if ( isNewFont() )
{
print (fc::NF_border_line_vertical_right);
FString line(width-2, wchar_t(fc::BoxDrawingsHorizontal));
FString line(getWidth()-2, wchar_t(fc::BoxDrawingsHorizontal));
print (line);
print (fc::NF_rev_border_line_vertical_left);
}
else
{
print (fc::BoxDrawingsVerticalAndRight);
FString line(width-2, wchar_t(fc::BoxDrawingsHorizontal));
FString line(getWidth()-2, wchar_t(fc::BoxDrawingsHorizontal));
print (line);
print (fc::BoxDrawingsVerticalAndLeft);
}
@ -1323,19 +1310,19 @@ void FMenu::onMouseMove (FMouseEvent* ev)
mouse_pos = ev->getPos();
mouse_pos -= FPoint(getRightPadding(),getTopPadding());
if ( getGeometryGlobal().contains(ev->getGlobalPos()) )
if ( getTermGeometry().contains(ev->getTermPos()) )
mouse_over_menu = true;
if ( open_sub_menu )
{
const FRect& submenu_geometry = open_sub_menu->getGeometryGlobal();
if ( submenu_geometry.contains(ev->getGlobalPos()) )
const FRect& submenu_geometry = open_sub_menu->getTermGeometry();
if ( submenu_geometry.contains(ev->getTermPos()) )
mouse_over_submenu = true;
}
if ( isSubMenu() )
{
smenu = superMenuAt (ev->getGlobalPos());
smenu = superMenuAt (ev->getTermPos());
if ( smenu )
mouse_over_supermenu = true;
@ -1343,7 +1330,7 @@ void FMenu::onMouseMove (FMouseEvent* ev)
if ( menuBar()
&& isMenuBar(menuBar())
&& menuBar()->getGeometryGlobal().contains(ev->getGlobalPos()) )
&& menuBar()->getTermGeometry().contains(ev->getTermPos()) )
{
mouse_over_menubar = true;
}
@ -1416,10 +1403,10 @@ void FMenu::onMouseMove (FMouseEvent* ev)
if ( mouse_over_submenu )
{
// Mouse event handover to sub-menu
const FPoint& g = ev->getGlobalPos();
const FPoint& p = open_sub_menu->globalToLocalPos(g);
const FPoint& t = ev->getTermPos();
const FPoint& p = open_sub_menu->termToWidgetPos(t);
int b = ev->getButton();
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p, g, b);
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p, t, b);
open_sub_menu->mouse_down = true;
setClickedWidget(open_sub_menu);
open_sub_menu->onMouseMove(_ev);
@ -1429,10 +1416,10 @@ void FMenu::onMouseMove (FMouseEvent* ev)
else if ( ! mouse_over_menu && mouse_over_supermenu )
{
// Mouse event handover to super-menu
const FPoint& g = ev->getGlobalPos();
const FPoint& p = smenu->globalToLocalPos(g);
const FPoint& t = ev->getTermPos();
const FPoint& p = smenu->termToWidgetPos(t);
int b = ev->getButton();
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p, g, b);
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p, t, b);
smenu->mouse_down = true;
setClickedWidget(smenu);
smenu->onMouseMove(_ev);
@ -1443,10 +1430,10 @@ void FMenu::onMouseMove (FMouseEvent* ev)
{
// Mouse event handover to the menu bar
FWidget* menubar = menuBar();
const FPoint& g = ev->getGlobalPos();
const FPoint& p = menubar->globalToLocalPos(g);
const FPoint& t = ev->getTermPos();
const FPoint& p = menubar->termToWidgetPos(t);
int b = ev->getButton();
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p, g, b);
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p, t, b);
setClickedWidget(menubar);
FMenuBar* mbar = reinterpret_cast<FMenuBar*>(menubar);
mbar->mouse_down = true;
@ -1534,7 +1521,8 @@ void FMenu::hide()
if ( isVisible() )
{
FWindow::hide();
restoreVTerm (getGeometryGlobalShadow());
const FRect& t_geometry = getTermGeometryWithShadow();
restoreVTerm (t_geometry);
updateTerminal();
flush_out();
@ -1555,11 +1543,11 @@ void FMenu::hide()
//----------------------------------------------------------------------
void FMenu::setGeometry (int xx, int yy, int ww, int hh, bool adjust)
{
int old_width = width;
int old_height = height;
int old_width = getWidth();
int old_height = getHeight();
FWidget::setGeometry (xx, yy, ww, hh, adjust);
if ( vwin && (width != old_width || height != old_height) )
if ( vwin && (getWidth() != old_width || getHeight() != old_height) )
resizeArea (vwin);
}
@ -1603,6 +1591,20 @@ void FMenu::cb_menuitem_toggled (FWidget* widget, void*)
}
}
//----------------------------------------------------------------------
bool FMenu::setMenuWidget (bool on)
{
if ( isMenuWidget() == on )
return true;
if ( on )
flags |= fc::menu_widget;
else
flags &= ~fc::menu_widget;
return on;
}
//----------------------------------------------------------------------
bool FMenu::setTransparentShadow (bool on)
{
@ -1610,17 +1612,13 @@ bool FMenu::setTransparentShadow (bool on)
{
flags |= fc::shadow;
flags |= fc::trans_shadow;
shadow.setPoint(2,1);
adjustWidgetSizeShadow = getGeometry() + getShadow();
adjustWidgetSizeGlobalShadow = getGeometryGlobal() + getShadow();
setShadowSize (2,1);
}
else
{
flags &= ~fc::shadow;
flags &= ~fc::trans_shadow;
shadow.setPoint(0,0);
adjustWidgetSizeShadow = getGeometry() + getShadow();
adjustWidgetSizeGlobalShadow = getGeometryGlobal() + getShadow();
setShadowSize (0,0);
}
resizeArea (vwin);

View File

@ -46,45 +46,47 @@
class FMenu : public FWindow, public FMenuList
{
private:
FMenuItem* item;
FWidget* super_menu;
FMenu* open_sub_menu;
uInt maxItemWidth;
bool mouse_down;
bool has_checkable_items;
FMenuItem* item;
FWidget* super_menu;
FMenu* open_sub_menu;
uInt maxItemWidth;
bool mouse_down;
bool has_checkable_items;
private:
FMenu (const FMenu&);
FMenu& operator = (const FMenu&);
void init(FWidget*);
void menu_dimension();
void adjustItems();
int adjustX(int);
bool isWindowsMenu (FWidget*) const;
bool isMenuBar (FWidget*) const;
bool isMenu (FWidget*) const;
bool isRadioMenuItem (FWidget*) const;
FWidget* getSuperMenu() const;
void setSuperMenu (FWidget*);
bool isSubMenu() const;
void openSubMenu (FMenu*);
void hideSubMenus();
void hideSuperMenus();
bool containsMenuStructure (const FPoint&) const;
bool containsMenuStructure (int, int) const;
FMenu* superMenuAt (const FPoint&) const;
FMenu* superMenuAt (int, int) const;
bool selectNextItem();
bool selectPrevItem();
void keypressMenuBar (FKeyEvent*&);
bool hotkeyMenu (FKeyEvent*&);
int getHotkeyPos (wchar_t*&, wchar_t*&, uInt);
void draw();
void drawBorder();
void drawMenuShadow();
void drawItems();
void drawSeparator(int);
void processActivate();
void init(FWidget*);
void menu_dimension();
void adjustItems();
int adjustX(int);
bool isWindowsMenu (FWidget*) const;
bool isMenuBar (FWidget*) const;
bool isMenu (FWidget*) const;
bool isRadioMenuItem (FWidget*) const;
FWidget* getSuperMenu() const;
void setSuperMenu (FWidget*);
bool isSubMenu() const;
void openSubMenu (FMenu*);
void hideSubMenus();
void hideSuperMenus();
bool containsMenuStructure (const FPoint&);
bool containsMenuStructure (int, int);
FMenu* superMenuAt (const FPoint&);
FMenu* superMenuAt (int, int);
bool selectNextItem();
bool selectPrevItem();
void keypressMenuBar (FKeyEvent*&);
bool hotkeyMenu (FKeyEvent*&);
int getHotkeyPos (wchar_t*&, wchar_t*&, uInt);
void draw();
// make every drawBorder from FWidget available
using FWidget::drawBorder;
virtual void drawBorder();
void drawMenuShadow();
void drawItems();
void drawSeparator(int);
void processActivate();
public:
explicit FMenu (FWidget* = 0); // constructor
@ -115,6 +117,9 @@ class FMenu : public FWindow, public FMenuList
void setSelected();
void unsetSelected();
bool isSelected() const;
bool setMenuWidget (bool);
bool setMenuWidget();
bool unsetMenuWidget();
bool hasHotkey() const;
void setMenu (FMenu*);
bool hasMenu() const;
@ -148,11 +153,11 @@ inline void FMenu::setSuperMenu (FWidget* smenu)
{ super_menu = smenu; }
//----------------------------------------------------------------------
inline bool FMenu::containsMenuStructure (const FPoint& p) const
inline bool FMenu::containsMenuStructure (const FPoint& p)
{ return containsMenuStructure (p.getX(), p.getY()); }
//----------------------------------------------------------------------
inline FMenu* FMenu::superMenuAt (const FPoint& p) const
inline FMenu* FMenu::superMenuAt (const FPoint& p)
{ return superMenuAt (p.getX(), p.getY()); }
//----------------------------------------------------------------------
@ -202,6 +207,13 @@ inline void FMenu::unsetSelected()
//----------------------------------------------------------------------
inline bool FMenu::isSelected() const
{ return item->isSelected(); }
//----------------------------------------------------------------------
inline bool FMenu::setMenuWidget()
{ return setMenuWidget(true); }
//----------------------------------------------------------------------
inline bool FMenu::unsetMenuWidget()
{ return setMenuWidget(false); }
//----------------------------------------------------------------------
inline bool FMenu::hasHotkey() const

View File

@ -41,14 +41,13 @@ FMenuBar::~FMenuBar()
//----------------------------------------------------------------------
void FMenuBar::init()
{
xmin = ymin = 1;
xpos = 1;
ypos = 1;
FWidget* r = getRootWidget();
int w = r->getWidth();
// initialize geometry values
setGeometry (1, 1, w, 1, false);
createArea (vmenubar);
vmenubar->visible = true;
ignore_padding = true;
// initialize geometry values
setGeometry (1, 1, getColumnNumber(), 1, false);
ignorePadding();
setMenuBar(this);
if ( getRootWidget() )
@ -56,8 +55,8 @@ void FMenuBar::init()
addAccelerator (fc::Fkey_f10);
addAccelerator (fc::Fckey_space);
foregroundColor = wc.menu_active_fg;
backgroundColor = wc.menu_active_bg;
setForegroundColor (wc.menu_active_fg);
setBackgroundColor (wc.menu_active_bg);
unsetFocusable();
}
@ -312,9 +311,6 @@ int FMenuBar::getHotkeyPos (wchar_t*& src, wchar_t*& dest, uInt length)
//----------------------------------------------------------------------
void FMenuBar::draw()
{
xmin = ymin = 1;
height = 1;
xpos = 1;
drawItems();
}
@ -325,14 +321,12 @@ void FMenuBar::drawItems()
int screenWidth;
int x = 1;
screenWidth = getColumnNumber();
width = screenWidth;
ypos = 1;
if ( itemlist.empty() )
return;
updateVTerm(false);
gotoxy (1,1);
printPos (1,1);
if ( isMonochron() )
setReverse(true);
@ -361,22 +355,23 @@ void FMenuBar::drawItems()
{
if ( isMonochron() )
setReverse(false);
foregroundColor = wc.menu_active_focus_fg;
backgroundColor = wc.menu_active_focus_bg;
setForegroundColor (wc.menu_active_focus_fg);
setBackgroundColor (wc.menu_active_focus_bg);
}
else
{
foregroundColor = wc.menu_active_fg;
backgroundColor = wc.menu_active_bg;
setForegroundColor (wc.menu_active_fg);
setBackgroundColor (wc.menu_active_bg);
}
}
else
{
foregroundColor = wc.menu_inactive_fg;
backgroundColor = wc.menu_inactive_bg;
setForegroundColor (wc.menu_inactive_fg);
setBackgroundColor (wc.menu_inactive_bg);
}
setColor (foregroundColor, backgroundColor);
setColor();
if ( x < screenWidth )
{
@ -431,7 +426,7 @@ void FMenuBar::drawItems()
if ( ! is_noUnderline )
unsetUnderline();
setColor (foregroundColor, backgroundColor);
setColor();
}
else
print (vmenubar, item_text[z]);
@ -441,12 +436,12 @@ void FMenuBar::drawItems()
{
if ( startpos < screenWidth )
{
gotoxy(screenWidth-1,1);
printPos (screenWidth - 1, 1);
print (vmenubar, "..");
}
else if ( startpos-1 <= screenWidth )
{
gotoxy(screenWidth,1);
printPos (screenWidth, 1);
print (vmenubar, ' ');
}
}
@ -646,7 +641,7 @@ void FMenuBar::onMouseDown (FMouseEvent* ev)
(*iter)->setSelected();
(*iter)->setFocus();
if ( focused_widget && ! focused_widget->isWindow() )
if ( focused_widget && ! focused_widget->isWindowWidget() )
focused_widget->redraw();
(*iter)->openMenu();
@ -800,7 +795,7 @@ void FMenuBar::onMouseMove (FMouseEvent* ev)
mouse_x = ev->getX();
mouse_y = ev->getY();
if ( getGeometryGlobal().contains(ev->getGlobalPos()) )
if ( getTermGeometry().contains(ev->getTermPos()) )
mouse_over_menubar = true;
while ( iter != end )
@ -822,7 +817,7 @@ void FMenuBar::onMouseMove (FMouseEvent* ev)
(*iter)->setSelected();
(*iter)->setFocus();
if ( focused_widget && ! focused_widget->isWindow() )
if ( focused_widget && ! focused_widget->isWindowWidget() )
focused_widget->redraw();
(*iter)->openMenu();
@ -863,16 +858,16 @@ void FMenuBar::onMouseMove (FMouseEvent* ev)
{
// Mouse event handover to the menu
FMenu* menu = getSelectedItem()->getMenu();
const FRect& menu_geometry = menu->getGeometryGlobal();
const FRect& menu_geometry = menu->getTermGeometry();
if ( menu->count() > 0
&& menu_geometry.contains(ev->getGlobalPos()) )
&& menu_geometry.contains(ev->getTermPos()) )
{
FMouseEvent* _ev;
const FPoint& g = ev->getGlobalPos();
const FPoint& p = menu->globalToLocalPos(g);
const FPoint& t = ev->getTermPos();
const FPoint& p = menu->termToWidgetPos(t);
int b = ev->getButton();
_ev = new FMouseEvent (fc::MouseMove_Event, p, g, b);
_ev = new FMouseEvent (fc::MouseMove_Event, p, t, b);
menu->mouse_down = true;
setClickedWidget(menu);
menu->onMouseMove(_ev);
@ -921,10 +916,14 @@ void FMenuBar::hide()
bg = wc.term_bg;
setColor (fg, bg);
screenWidth = getColumnNumber();
if ( screenWidth < 0 )
return;
blank = new char[screenWidth+1];
memset(blank, ' ', uLong(screenWidth));
blank[screenWidth] = '\0';
gotoxy (1,1);
printPos (1,1);
print (vmenubar, blank);
delete[] blank;
}
@ -939,25 +938,10 @@ void FMenuBar::resetMenu()
//----------------------------------------------------------------------
void FMenuBar::adjustSize()
{
xmin = ymin = 1;
height = 1;
xpos = 1;
width = getColumnNumber();
ypos = 1;
setGeometry (1, 1, getColumnNumber(), 1, false);
adjustItems();
}
//----------------------------------------------------------------------
void FMenuBar::setGeometry (int xx, int yy, int ww, int hh, bool adjust)
{
int old_width = width;
int old_height = height;
FWidget::setGeometry (xx, yy, ww, hh, adjust);
if ( vmenubar && (width != old_width || height != old_height) )
resizeArea (vmenubar);
}
//----------------------------------------------------------------------
void FMenuBar::cb_item_deactivated (FWidget* widget, void*)
{

View File

@ -76,9 +76,6 @@ class FMenuBar : public FWindow, public FMenuList
void hide();
void resetMenu();
void adjustSize();
// make every setGeometry from FWidget available
using FWidget::setGeometry;
void setGeometry (int, int, int, int, bool = true);
void cb_item_deactivated (FWidget*, void*);
private:

View File

@ -348,7 +348,7 @@ void FMenuItem::processClicked()
//----------------------------------------------------------------------
bool FMenuItem::isWindowsMenu (FWidget* w) const
{
return ( ! w ) ? false : w->isDialog();
return ( ! w ) ? false : w->isDialogWidget();
}
//----------------------------------------------------------------------
@ -463,7 +463,7 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
{
if ( super_menu )
{
const FPoint& g = ev->getGlobalPos();
const FPoint& t = ev->getTermPos();
int b = ev->getButton();
if ( isMenu(super_menu) )
@ -472,8 +472,8 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
if ( smenu )
{
const FPoint& p2 = smenu->globalToLocalPos(g);
FMouseEvent* _ev = new FMouseEvent (fc::MouseDoubleClick_Event, p2, g, b);
const FPoint& p2 = smenu->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseDoubleClick_Event, p2, t, b);
smenu->onMouseDoubleClick(_ev);
delete _ev;
}
@ -485,8 +485,8 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
if ( mbar )
{
const FPoint& p2 = mbar->globalToLocalPos(g);
FMouseEvent* _ev = new FMouseEvent (fc::MouseDoubleClick_Event, p2, g, b);
const FPoint& p2 = mbar->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseDoubleClick_Event, p2, t, b);
mbar->onMouseDoubleClick(_ev);
delete _ev;
}
@ -498,8 +498,8 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
if ( dgl )
{
const FPoint& p2 = dgl->globalToLocalPos(g);
FMouseEvent* _ev = new FMouseEvent (fc::MouseDoubleClick_Event, p2, g, b);
const FPoint& p2 = dgl->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseDoubleClick_Event, p2, t, b);
dgl->onMouseDoubleClick(_ev);
delete _ev;
}
@ -512,7 +512,7 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
{
if ( super_menu )
{
const FPoint& g = ev->getGlobalPos();
const FPoint& t = ev->getTermPos();
int b = ev->getButton();
if ( isMenu(super_menu) )
@ -521,8 +521,8 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
if ( smenu )
{
const FPoint& p2 = smenu->globalToLocalPos(g);
FMouseEvent* _ev = new FMouseEvent (fc::MouseDown_Event, p2, g, b);
const FPoint& p2 = smenu->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseDown_Event, p2, t, b);
smenu->onMouseDown(_ev);
delete _ev;
}
@ -534,8 +534,8 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
if ( mbar )
{
const FPoint& p2 = mbar->globalToLocalPos(g);
FMouseEvent* _ev = new FMouseEvent (fc::MouseDown_Event, p2, g, b);
const FPoint& p2 = mbar->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseDown_Event, p2, t, b);
mbar->onMouseDown(_ev);
delete _ev;
}
@ -547,8 +547,8 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
if ( dgl )
{
const FPoint& p2 = dgl->globalToLocalPos(g);
FMouseEvent* _ev = new FMouseEvent (fc::MouseDown_Event, p2, g, b);
const FPoint& p2 = dgl->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseDown_Event, p2, t, b);
dgl->onMouseDown(_ev);
delete _ev;
}
@ -561,7 +561,7 @@ void FMenuItem::onMouseUp (FMouseEvent* ev)
{
if ( super_menu )
{
const FPoint& g = ev->getGlobalPos();
const FPoint& t = ev->getTermPos();
int b = ev->getButton();
if ( isMenu(super_menu) )
@ -570,8 +570,8 @@ void FMenuItem::onMouseUp (FMouseEvent* ev)
if ( smenu )
{
const FPoint& p2 = smenu->globalToLocalPos(g);
FMouseEvent* _ev = new FMouseEvent (fc::MouseUp_Event, p2, g, b);
const FPoint& p2 = smenu->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseUp_Event, p2, t, b);
smenu->onMouseUp(_ev);
delete _ev;
}
@ -583,8 +583,8 @@ void FMenuItem::onMouseUp (FMouseEvent* ev)
if ( mbar )
{
const FPoint& p2 = mbar->globalToLocalPos(g);
FMouseEvent* _ev = new FMouseEvent (fc::MouseUp_Event, p2, g, b);
const FPoint& p2 = mbar->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseUp_Event, p2, t, b);
mbar->onMouseUp(_ev);
delete _ev;
}
@ -596,8 +596,8 @@ void FMenuItem::onMouseUp (FMouseEvent* ev)
if ( dgl )
{
const FPoint& p2 = dgl->globalToLocalPos(g);
FMouseEvent* _ev = new FMouseEvent (fc::MouseUp_Event, p2, g, b);
const FPoint& p2 = dgl->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseUp_Event, p2, t, b);
dgl->onMouseUp(_ev);
delete _ev;
}
@ -610,7 +610,7 @@ void FMenuItem::onMouseMove (FMouseEvent* ev)
{
if ( super_menu )
{
const FPoint& g = ev->getGlobalPos();
const FPoint& t = ev->getTermPos();
int b = ev->getButton();
if ( isMenu(super_menu) )
@ -619,8 +619,8 @@ void FMenuItem::onMouseMove (FMouseEvent* ev)
if ( smenu )
{
const FPoint& p2 = smenu->globalToLocalPos(g);
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p2, g, b);
const FPoint& p2 = smenu->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p2, t, b);
smenu->onMouseMove(_ev);
delete _ev;
}
@ -632,8 +632,8 @@ void FMenuItem::onMouseMove (FMouseEvent* ev)
if ( mbar )
{
const FPoint& p2 = mbar->globalToLocalPos(g);
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p2, g, b);
const FPoint& p2 = mbar->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p2, t, b);
mbar->onMouseMove(_ev);
delete _ev;
}
@ -645,8 +645,8 @@ void FMenuItem::onMouseMove (FMouseEvent* ev)
if ( dgl )
{
const FPoint& p2 = dgl->globalToLocalPos(g);
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p2, g, b);
const FPoint& p2 = dgl->termToWidgetPos(t);
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p2, t, b);
dgl->onMouseMove(_ev);
delete _ev;
}

View File

@ -126,7 +126,7 @@ void FMessageBox::init(int button0, int button1, int button2)
button[0] = new FButton (this);
button[0]->setText(button_text[button0]);
button[0]->setPos(3, height-4, false);
button[0]->setPos(3, getHeight()-4, false);
button[0]->setWidth(1, false);
button[0]->setHeight(1, false);
button[0]->setFocus();
@ -135,7 +135,7 @@ void FMessageBox::init(int button0, int button1, int button2)
{
button[1] = new FButton(this);
button[1]->setText(button_text[button1]);
button[1]->setPos(17, height-4, false);
button[1]->setPos(17, getHeight()-4, false);
button[1]->setWidth(0, false);
button[1]->setHeight(1, false);
}
@ -144,7 +144,7 @@ void FMessageBox::init(int button0, int button1, int button2)
{
button[2] = new FButton(this);
button[2]->setText(button_text[button2]);
button[2]->setPos(32, height-4, false);
button[2]->setPos(32, getHeight()-4, false);
button[2]->setWidth(0, false);
button[2]->setHeight(1, false);
}
@ -231,7 +231,7 @@ void FMessageBox::draw()
int head_offset = 0;
int center_x = 0;
int msg_x = int((width - int(maxLineWidth)) / 2); // center the whole block
int msg_x = int((getWidth() - int(maxLineWidth)) / 2); // center the whole block
updateVTerm(false);
if ( isMonochron() )
@ -239,18 +239,18 @@ void FMessageBox::draw()
if ( ! headline_text.isNull() )
{
setColor(emphasis_color, backgroundColor);
setColor(emphasis_color, getBackgroundColor());
uInt headline_length = headline_text.getLength();
if ( center_text ) // center one line
center_x = int((maxLineWidth - headline_length) / 2);
gotoxy (xpos+xmin-1+msg_x+center_x, ypos+ymin+2);
printPos (1 + msg_x + center_x, 4);
print (headline_text);
head_offset = 2;
}
setColor(foregroundColor, backgroundColor);
setColor();
for (int i=0; i < int(text_num_lines); i++)
{
@ -259,7 +259,7 @@ void FMessageBox::draw()
if ( center_text ) // center one line
center_x = int((maxLineWidth - line_length) / 2);
gotoxy (xpos+xmin-1+msg_x+center_x, ypos+ymin+2+head_offset+i);
printPos (1 + msg_x + center_x, 4 + head_offset + i);
print(text_components[i]);
}
@ -314,16 +314,16 @@ void FMessageBox::adjustButtons()
btn_width += button[n]->getWidth() + gap;
}
if ( btn_width >= width-4 )
if ( btn_width >= getWidth()-4 )
{
int max_width;
FWidget* root_widget = getRootWidget();
setWidth(btn_width + 5);
max_width = ( root_widget ) ? root_widget->getClientWidth() : 80;
setX (int((max_width-width) / 2));
setX (int((max_width-getWidth()) / 2));
}
int btn_x = int((width-btn_width) / 2);
int btn_x = int((getWidth()-btn_width) / 2);
for (uInt n=0; n < numButtons; n++)
{
@ -363,8 +363,8 @@ void FMessageBox::adjustSize()
max_height = 24;
}
X = 1 + int((max_width-width)/2);
Y = 1 + int((max_height-height)/3);
X = 1 + int((max_width-getWidth())/2);
Y = 1 + int((max_height-getHeight())/3);
setPos(X, Y, false);
FDialog::adjustSize();
}
@ -410,19 +410,19 @@ FMessageBox& FMessageBox::operator = (const FMessageBox& mbox)
//----------------------------------------------------------------------
void FMessageBox::setHeadline (const FString& headline)
{
int old_height = height;
int old_height = getHeight();
headline_text = headline;
setHeight(height + 2, true);
setHeight(getHeight() + 2, true);
for (uInt n=0; n < numButtons; n++)
button[n]->setY(height-4, false);
button[n]->setY(getHeight()-4, false);
uInt len = headline_text.getLength();
if ( len > maxLineWidth )
maxLineWidth = len;
if ( vwin && height != old_height )
if ( vwin && getHeight() != old_height )
resizeArea (vwin);
}
@ -445,13 +445,13 @@ void FMessageBox::setText (const FString& txt)
{
text = txt;
msg_dimension();
button[0]->setY(height-4, false);
button[0]->setY(getHeight()-4, false);
if ( *button_digit[1] != 0 )
button[1]->setY(height-4, false);
button[1]->setY(getHeight()-4, false);
if ( *button_digit[2] != 0 )
button[2]->setY(height-4, false);
button[2]->setY(getHeight()-4, false);
adjustButtons();
}
@ -520,8 +520,8 @@ int FMessageBox::error ( FWidget* parent
mbox->beep();
mbox->setHeadline("Warning:");
mbox->setCenterText();
mbox->foregroundColor = mbox->wc.error_box_fg;
mbox->backgroundColor = mbox->wc.error_box_bg;
mbox->setForegroundColor(mbox->wc.error_box_fg);
mbox->setBackgroundColor(mbox->wc.error_box_bg);
mbox->emphasis_color = mbox->wc.error_box_emphasis_fg;
reply = mbox->exec();
delete mbox;

View File

@ -12,7 +12,7 @@
FProgressbar::FProgressbar(FWidget* parent)
: FWidget(parent)
, percentage(-1)
, BarLength(width)
, BarLength(getWidth())
{
unsetFocusable();
setShadow();
@ -37,7 +37,7 @@ void FProgressbar::drawPercentage()
if ( isMonochron() )
setReverse(true);
gotoxy (xpos+xmin+width-5, ypos+ymin-2);
printPos (getWidth() - 3, 0);
if ( percentage < 0 || percentage > 100 )
print ("--- %");
@ -53,7 +53,7 @@ void FProgressbar::drawBar()
{
int i = 1;
float length = float(BarLength*percentage)/100;
gotoxy (xpos+xmin-1, ypos+ymin-1);
printPos (1,1);
if ( isMonochron() )
{
@ -195,19 +195,23 @@ void FProgressbar::hide()
setColor (fg, bg);
s = hasShadow() ? 1 : 0;
size = width + s;
size = getWidth() + s;
if ( size < 0 )
return;
blank = new char[size+1];
memset(blank, ' ', uLong(size));
blank[size] = '\0';
for (int y=0; y < height+s; y++)
for (int y=0; y < getHeight()+s; y++)
{
gotoxy (xpos+xmin-1, ypos+ymin-1+y);
printPos (1, 1 + y);
print (blank);
}
delete[] blank;
gotoxy (xpos+xmin+width-5, ypos+ymin-2);
printPos (getWidth() - 4, 0);
print (" "); // hide percentage
}

View File

@ -54,8 +54,8 @@ void FRadioButton::drawRadioButton()
if ( ! isVisible() )
return;
gotoxy (xpos+xmin-1, ypos+ymin-1);
setColor (foregroundColor, backgroundColor);
printPos (1,1);
setColor();
if ( isMonochron() )
{

View File

@ -116,6 +116,21 @@ void FRect::setRect (int x, int y, int width, int height)
Y2 = short(y+height-1);
}
//----------------------------------------------------------------------
void FRect::setCoordinates (const FPoint& p1, const FPoint& p2)
{
setCoordinates (p1.getX(), p1.getY(), p2.getX(), p2.getY());
}
//----------------------------------------------------------------------
void FRect::setCoordinates (int x1, int y1, int x2, int y2)
{
X1 = short(x1);
Y1 = short(y1);
X2 = short(x2);
Y2 = short(y2);
}
//----------------------------------------------------------------------
void FRect::move (int dx, int dy)
{
@ -174,6 +189,16 @@ FRect FRect::intersect (const FRect& r) const
return new_rect;
}
//----------------------------------------------------------------------
FRect& FRect::operator = (const FRect& r)
{
X1 = short(r.getX1());
Y1 = short(r.getY1());
X2 = short(r.getX2());
Y2 = short(r.getY2());
return *this;
}
//----------------------------------------------------------------------
FRect operator + (const FRect& r, const FPoint& p)
{

View File

@ -37,37 +37,45 @@ class FRect
virtual ~FRect(); // destructor
virtual const char* getClassName();
bool isNull() const;
int getX1() const;
int getY1() const;
int getX2() const;
int getY2() const;
int getX() const;
int getY() const;
FPoint getPos() const;
int getWidth() const;
int getHeight() const;
bool isNull() const;
int getX1() const;
int getY1() const;
int getX2() const;
int getY2() const;
int getX() const;
int getY() const;
FPoint getPos() const;
int getWidth() const;
int getHeight() const;
void setX1 (int);
void setY1 (int);
void setX2 (int);
void setY2 (int);
void setX (int);
void setY (int);
void setPos (int, int);
void setPos (const FPoint&);
void setWidth (int);
void setHeight (int);
void setRect (const FRect&);
void setRect (int, int, int, int);
short& x1_ref();
short& y1_ref();
short& x2_ref();
short& y2_ref();
void setX1 (int);
void setY1 (int);
void setX2 (int);
void setY2 (int);
void setX (int);
void setY (int);
void setPos (int, int);
void setPos (const FPoint&);
void setWidth (int);
void setHeight (int);
void setRect (const FRect&);
void setRect (int, int, int, int);
void setCoordinates (const FPoint&, const FPoint&);
void setCoordinates (int, int, int, int);
void move (int, int);
void move (const FPoint&);
bool contains (int, int) const;
bool contains (const FPoint&) const;
bool contains (const FRect&) const;
bool overlap (const FRect&) const;
FRect intersect (const FRect&) const;
void move (int, int);
void move (const FPoint&);
bool contains (int, int) const;
bool contains (const FPoint&) const;
bool contains (const FRect&) const;
bool overlap (const FRect&) const;
FRect intersect (const FRect&) const;
FRect& operator = (const FRect&);
friend FRect operator + (const FRect&, const FPoint&);
friend FRect operator - (const FRect&, const FPoint&);
@ -90,8 +98,8 @@ inline FRect::FRect()
inline FRect::FRect (int x, int y, int width, int height)
: X1(short(x))
, Y1(short(y))
, X2(short(x+width-1))
, Y2(short(y+height-1))
, X2(short(x + width - 1))
, Y2(short(y + height - 1))
{ }
//----------------------------------------------------------------------
@ -134,4 +142,20 @@ inline int FRect::getWidth() const
inline int FRect::getHeight() const
{ return Y2 - Y1 + 1; }
//----------------------------------------------------------------------
inline short& FRect::x1_ref()
{ return X1; }
//----------------------------------------------------------------------
inline short& FRect::y1_ref()
{ return Y1; }
//----------------------------------------------------------------------
inline short& FRect::x2_ref()
{ return X2; }
//----------------------------------------------------------------------
inline short& FRect::y2_ref()
{ return Y2; }
#endif // _FRECT_H

View File

@ -31,8 +31,7 @@ FScrollbar::FScrollbar(FWidget* parent)
, max_color(getMaxColor())
{
// The default scrollbar orientation is vertical
width = 1;
height = length;
setGeometry(1, 1, 1, length, false);
init();
}
@ -72,9 +71,9 @@ FScrollbar::~FScrollbar()
//----------------------------------------------------------------------
void FScrollbar::init()
{
setGeometry(1, 1, width, height);
ignore_padding = true;
unsetFocusable();
ignorePadding();
setGeometry(1, 1, getWidth(), getHeight());
}
//----------------------------------------------------------------------
@ -102,11 +101,11 @@ int FScrollbar::getClickedScrollType (int x, int y)
{
stype = FScrollbar::scrollPageBackward; // before slider
}
else if ( y > SliderPos+SliderLength+1 && y < height )
else if ( y > SliderPos+SliderLength+1 && y < getHeight() )
{
stype = FScrollbar::scrollPageForward; // after slider
}
else if ( y == height )
else if ( y == getHeight() )
{
stype = FScrollbar::scrollStepForward; // increment button
}
@ -125,11 +124,11 @@ int FScrollbar::getClickedScrollType (int x, int y)
{
stype = FScrollbar::scrollPageBackward; // before slider
}
else if ( x > SliderPos+SliderLength+2 && x < width-1 )
else if ( x > SliderPos+SliderLength+2 && x < getWidth()-1 )
{
stype = FScrollbar::scrollPageForward; // after slider
}
else if ( x == width-1 || x == width )
else if ( x == getWidth()-1 || x == getWidth() )
{
stype = FScrollbar::scrollStepForward; // increment button
}
@ -146,11 +145,11 @@ int FScrollbar::getClickedScrollType (int x, int y)
{
stype = FScrollbar::scrollPageBackward; // before slider
}
else if ( x > SliderPos+SliderLength+1 && x < width )
else if ( x > SliderPos+SliderLength+1 && x < getWidth() )
{
stype = FScrollbar::scrollPageForward; // after slider
}
else if ( x == width )
else if ( x == getWidth() )
{
stype = FScrollbar::scrollStepForward; // increment button
}
@ -169,7 +168,7 @@ void FScrollbar::processMiddleButton (int x, int y)
if ( bar_orientation == fc::vertical )
{
if ( y >1 && y < height )
if ( y >1 && y < getHeight() )
{
new_val = int( round ( float(max-min) * (y-2.0-(SliderLength/2))
/ float(BarLength-SliderLength) ) );
@ -181,7 +180,7 @@ void FScrollbar::processMiddleButton (int x, int y)
{
int nf = isNewFont() ? 1 : 0;
if ( x > 1+nf && x < width-nf )
if ( x > 1+nf && x < getWidth()-nf )
{
new_val = int( round ( float(max-min) * (x-2.0-nf-(SliderLength/2))
/ float(BarLength-SliderLength) ) );
@ -343,8 +342,8 @@ void FScrollbar::onMouseMove (FMouseEvent* ev)
}
}
if ( mouse_x < 1 || mouse_x > width
|| mouse_y < 1 || mouse_y > height )
if ( mouse_x < 1 || mouse_x > getWidth()
|| mouse_y < 1 || mouse_y > getHeight() )
{
delOwnTimer();
}
@ -514,17 +513,17 @@ void FScrollbar::calculateSliderValues()
void FScrollbar::setOrientation (int o)
{
int nf = 0;
length = (height > width) ? height : width;
length = (getHeight() > getWidth()) ? getHeight() : getWidth();
if ( o == fc::vertical && bar_orientation == fc::horizontal )
{
width = 1;
height = length;
setWidth(1);
setHeight(length);
}
else if ( o == fc::horizontal && bar_orientation == fc::vertical )
{
height = 1;
width = length;
setWidth(length);
setHeight(1);
if ( isNewFont() )
nf = 2;
@ -543,17 +542,18 @@ void FScrollbar::setGeometry (int x, int y, int w, int h, bool adjust)
if ( bar_orientation == fc::vertical )
{
width = isNewFont() ? 2 : 1;
height = length;
setWidth(isNewFont() ? 2 : 1);
setHeight(length);
}
else // horizontal
{
height = 1;
width = length;
setWidth(length);
setHeight(1);
if ( isNewFont() )
nf = 2;
}
SliderLength = BarLength = length-nf-2;
}
@ -571,7 +571,7 @@ void FScrollbar::drawBar()
for (z=1; z <= SliderPos; z++)
{
gotoxy (xpos+xmin-1, ypos+ymin-1+z);
printPos (1, 1 + z);
if ( isNewFont() )
print (fc::NF_border_line_left); // ⎸
@ -589,9 +589,11 @@ void FScrollbar::drawBar()
for (z=1; z <= SliderLength; z++)
{
gotoxy (xpos+xmin-1, ypos+ymin-1+SliderPos+z);
printPos (1, 1 + SliderPos + z);
if ( isNewFont() )
print (' ');
print (' ');
}
@ -602,7 +604,7 @@ void FScrollbar::drawBar()
for (z=SliderPos+SliderLength+1; z <= BarLength; z++)
{
gotoxy (xpos+xmin-1, ypos+ymin-1+z);
printPos (1, 1 + z);
if ( isNewFont() )
print (fc::NF_border_line_left); // ⎸
@ -619,9 +621,9 @@ void FScrollbar::drawBar()
z = 0;
if ( isNewFont() )
gotoxy (xpos+xmin+1+z, ypos+ymin-1);
printPos (3 + z, 1);
else
gotoxy (xpos+xmin+z, ypos+ymin-1);
printPos (2 + z, 1);
for (; z < SliderPos; z++)
{
@ -676,13 +678,13 @@ void FScrollbar::drawButtons()
if ( isNewFont() )
{
gotoxy (xpos+xmin-1, ypos+ymin-1);
printPos (1,1);
if ( bar_orientation == fc::vertical )
{
print (fc::NF_rev_up_arrow1);
print (fc::NF_rev_up_arrow2);
gotoxy (xpos+xmin-1, ypos+ymin+length-2);
printPos (1, length);
print (fc::NF_rev_down_arrow1);
print (fc::NF_rev_down_arrow2);
}
@ -690,14 +692,14 @@ void FScrollbar::drawButtons()
{
print (fc::NF_rev_left_arrow1);
print (fc::NF_rev_left_arrow2);
gotoxy (xpos+xmin+length-3, ypos+ymin-1);
printPos (length-1, 1);
print (fc::NF_rev_right_arrow1);
print (fc::NF_rev_right_arrow2);
}
}
else
{
gotoxy (xpos+xmin-1, ypos+ymin-1);
printPos (1,1);
if ( isMonochron() )
setReverse(true);
@ -709,7 +711,7 @@ void FScrollbar::drawButtons()
else
print (fc::BlackUpPointingTriangle); // ▲
gotoxy (xpos+xmin-1, ypos+ymin+length-2);
printPos (1, length);
if ( isCygwinTerminal() )
print ('v');
@ -719,9 +721,8 @@ void FScrollbar::drawButtons()
else // horizontal
{
print (fc::BlackLeftPointingPointer); // ◄
gotoxy (xpos+xmin+length-2, ypos+ymin-1);
printPos (length, 1);
print (fc::BlackRightPointingPointer); // ►
}
if ( isMonochron() )

View File

@ -192,32 +192,30 @@ FStatusBar::~FStatusBar()
//----------------------------------------------------------------------
void FStatusBar::init()
{
xmin = ymin = 1;
xpos = 1;
ypos = getLineNumber();
FWidget* r = getRootWidget();
int w = r->getWidth();
int h = r->getHeight();
// initialize geometry values
setGeometry (1, h, w, 1, false);
createArea (vstatusbar);
vstatusbar->visible = true;
ignore_padding = true;
ignorePadding();
mouse_down = false;
// initialize geometry values
setGeometry (1, ypos, getColumnNumber(), 1, false);
setStatusBar(this);
if ( getRootWidget() )
getRootWidget()->setBottomPadding(1, true);
foregroundColor = wc.statusbar_fg;
backgroundColor = wc.statusbar_bg;
setForegroundColor (wc.statusbar_fg);
setBackgroundColor (wc.statusbar_bg);
unsetFocusable();
}
//----------------------------------------------------------------------
void FStatusBar::draw()
{
xmin = ymin = 1;
height = 1;
xpos = 1;
drawKeys();
drawMessage();
}
@ -226,15 +224,12 @@ void FStatusBar::draw()
void FStatusBar::drawKeys()
{
std::vector<FStatusKey*>::const_iterator iter, end;
int screenWidth, lastLine;
int screenWidth;
if ( ! vstatusbar )
return;
screenWidth = getColumnNumber();
lastLine = getLineNumber();
width = screenWidth;
ypos = lastLine;
x = 1;
if ( keylist.empty() )
@ -244,7 +239,7 @@ void FStatusBar::drawKeys()
}
updateVTerm(false);
gotoxy (1, lastLine);
printPos (1, 1);
if ( isMonochron() )
setReverse(true);
@ -535,7 +530,7 @@ void FStatusBar::onMouseMove (FMouseEvent* ev)
//----------------------------------------------------------------------
void FStatusBar::hide()
{
int lastLine, screenWidth;
int screenWidth;
short fg, bg;
char* blank;
@ -543,27 +538,19 @@ void FStatusBar::hide()
fg = wc.term_fg;
bg = wc.term_bg;
setColor (fg, bg);
lastLine = getLineNumber();
screenWidth = getColumnNumber();
if ( screenWidth < 0 )
return;
blank = new char[screenWidth+1];
memset(blank, ' ', uLong(screenWidth));
blank[screenWidth] = '\0';
gotoxy (1, lastLine);
printPos (1, 1);
print (vstatusbar, blank);
delete[] blank;
}
//----------------------------------------------------------------------
void FStatusBar::setGeometry (int xx, int yy, int ww, int hh, bool adjust)
{
int old_width = width;
int old_height = height;
FWidget::setGeometry (xx, yy, ww, hh, adjust);
if ( vstatusbar && (width != old_width || height != old_height) )
resizeArea (vstatusbar);
}
//----------------------------------------------------------------------
bool FStatusBar::hasActivatedKey()
{
@ -588,7 +575,7 @@ bool FStatusBar::hasActivatedKey()
//----------------------------------------------------------------------
void FStatusBar::drawMessage()
{
int termWidth, lastLine, space_offset;
int termWidth, space_offset;
bool isLastActiveFocus, hasKeys;
if ( ! (isVisible() && vstatusbar) )
@ -599,7 +586,6 @@ void FStatusBar::drawMessage()
x = x_msg;
termWidth = getColumnNumber();
lastLine = getLineNumber();
space_offset = 1;
hasKeys = bool(! keylist.empty());
@ -617,7 +603,7 @@ void FStatusBar::drawMessage()
updateVTerm(false);
setColor (wc.statusbar_fg, wc.statusbar_bg);
gotoxy (x, lastLine);
printPos (x, 1);
if ( isMonochron() )
setReverse(true);
@ -739,11 +725,7 @@ void FStatusBar::clear()
//----------------------------------------------------------------------
void FStatusBar::adjustSize()
{
xmin = ymin = 1;
height = 1;
xpos = 1;
width = getColumnNumber();
ypos = getLineNumber();
setGeometry (1, getLineNumber(), getColumnNumber(), 1, false);
}
//----------------------------------------------------------------------

View File

@ -168,9 +168,6 @@ class FStatusBar : public FWindow
void onMouseUp (FMouseEvent*);
void onMouseMove (FMouseEvent*);
void hide();
// make every setGeometry from FWidget available
using FWidget::setGeometry;
void setGeometry (int, int, int, int, bool = true);
uInt count() const;
FStatusKey* key (int) const;

View File

@ -54,7 +54,7 @@ void FSwitch::drawCheckButton()
wchar_t on[6] = L" On ";
wchar_t off[6] = L" Off ";
gotoxy (xpos+xmin-1+switch_offset_pos, ypos+ymin-1);
printPos (1 + switch_offset_pos, 1);
if ( checked )
{
@ -98,8 +98,7 @@ void FSwitch::drawCheckButton()
if ( isMonochron() )
setReverse(false);
setCursorPos ( xpos + xmin + 1 + switch_offset_pos
, ypos + ymin - 1 );
setCursorPos (3 + switch_offset_pos, 1);
}
else
{
@ -141,8 +140,7 @@ void FSwitch::drawCheckButton()
if ( isMonochron() || getMaxColor() < 16 )
setBold(false);
setCursorPos ( xpos + xmin + 5 + switch_offset_pos
, ypos + ymin - 1 );
setCursorPos (7 + switch_offset_pos, 1);
}
}

View File

@ -2374,14 +2374,14 @@ void FTerm::restoreVTerm (int x, int y, int w, int h)
while ( iter != end )
{
term_area* win = (*iter)->getVWin();
const FRect& geometry = (*iter)->getGeometryGlobalShadow();
const FRect& geometry = (*iter)->getTermGeometryWithShadow();
// window visible and contains current character
if ( win && win->visible && geometry.contains(tx+x+1, ty+y+1) )
{
FOptiAttr::char_data* tmp;
int win_x = (*iter)->getGlobalX() - 1;
int win_y = (*iter)->getGlobalY() - 1;
int win_x = (*iter)->getTermX() - 1;
int win_y = (*iter)->getTermY() - 1;
int line_len = win->width + win->right_shadow;
tmp = &win->text[(ty+y-win_y) * line_len + (tx+x-win_x)];
@ -2426,10 +2426,10 @@ void FTerm::restoreVTerm (int x, int y, int w, int h)
menubar = reinterpret_cast<FWidget*>(FWidget::menuBar());
if ( vmenubar && menubar
&& menubar->getGeometryGlobal().contains(x+tx+1, y+ty+1) )
&& menubar->getTermGeometry().contains(x+tx+1, y+ty+1) )
{
int bar_x = menubar->getGlobalX() - 1;
int bar_y = menubar->getGlobalY() - 1;
int bar_x = menubar->getTermX() - 1;
int bar_y = menubar->getTermY() - 1;
if ( vmenubar->visible )
sc = &vmenubar->text[(y+ty-bar_y) * vmenubar->width + (x+tx-bar_x)];
@ -2440,10 +2440,10 @@ void FTerm::restoreVTerm (int x, int y, int w, int h)
statusbar = reinterpret_cast<FWidget*>(FWidget::statusBar());
if ( vstatusbar && statusbar
&& statusbar->getGeometryGlobal().contains(x+tx+1, y+ty+1) )
&& statusbar->getTermGeometry().contains(x+tx+1, y+ty+1) )
{
int bar_x = statusbar->getGlobalX() - 1;
int bar_y = statusbar->getGlobalY() - 1;
int bar_x = statusbar->getTermX() - 1;
int bar_y = statusbar->getTermY() - 1;
if ( vstatusbar->visible )
sc = &vstatusbar->text[(y+ty-bar_y) * vstatusbar->width + (x+tx-bar_x)];
@ -2486,7 +2486,7 @@ FTerm::covered_state FTerm::isCovered (int x, int y, FTerm::term_area* area) con
while ( iter != end )
{
term_area* win = (*iter)->getVWin();
const FRect& geometry = (*iter)->getGeometryGlobalShadow();
const FRect& geometry = (*iter)->getTermGeometryWithShadow();
if ( win && found
&& (*iter)->isVisible()
@ -2494,8 +2494,8 @@ FTerm::covered_state FTerm::isCovered (int x, int y, FTerm::term_area* area) con
&& geometry.contains(x,y) )
{
FOptiAttr::char_data* tmp;
int win_x = (*iter)->getGlobalX() - 1;
int win_y = (*iter)->getGlobalY() - 1;
int win_x = (*iter)->getTermX() - 1;
int win_y = (*iter)->getTermY() - 1;
int line_len = win->width + win->right_shadow;
tmp = &win->text[(y-win_y-1) * line_len + (x-win_x-1)];
@ -2526,7 +2526,7 @@ FTerm::covered_state FTerm::isCovered (int x, int y, FTerm::term_area* area) con
menubar = 0;
if ( area != vmenubar && menubar
&& menubar->getGeometryGlobal().contains(x,y) )
&& menubar->getTermGeometry().contains(x,y) )
{
is_covered = fully_covered;
}
@ -2540,7 +2540,7 @@ FTerm::covered_state FTerm::isCovered (int x, int y, FTerm::term_area* area) con
statusbar = 0;
if ( area != vstatusbar && statusbar
&& statusbar->getGeometryGlobal().contains(x,y) )
&& statusbar->getTermGeometry().contains(x,y) )
{
is_covered = fully_covered;
}
@ -2568,8 +2568,8 @@ void FTerm::updateVTerm (FTerm::term_area* area)
if ( ! area->visible )
return;
ax = area->widget->getGlobalX() - 1;
ay = area->widget->getGlobalY() - 1;
ax = area->widget->getTermX() - 1;
ay = area->widget->getTermY() - 1;
aw = area->width;
ah = area->height;
rsh = area->right_shadow;
@ -2609,7 +2609,8 @@ void FTerm::updateVTerm (FTerm::term_area* area)
{
int gx, gy, line_len;
FTerm::covered_state is_covered;
gx = ax + x; // global position
// global terminal positions
gx = ax + x;
gy = ay + y;
if ( gx < 0 || gy < 0 )
@ -2761,8 +2762,8 @@ void FTerm::getArea (int x, int y, int w, int h, FTerm::term_area* area)
if ( ! area )
return;
dx = x - area->widget->getGlobalX();
dy = y - area->widget->getGlobalY();
dx = x - area->widget->getTermX();
dy = y - area->widget->getTermY();
if ( x < 0 || y < 0 )
return;
@ -3071,14 +3072,14 @@ FOptiAttr::char_data FTerm::getCharacter ( int char_type
if ( obj && *iter != obj && significant_char )
{
term_area* win = (*iter)->getVWin();
const FRect& geometry = (*iter)->getGeometryGlobalShadow();
const FRect& geometry = (*iter)->getTermGeometryWithShadow();
// window visible and contains current character
if ( win && win->visible && geometry.contains(x+1,y+1) )
{
FOptiAttr::char_data* tmp;
int win_x = (*iter)->getGlobalX() - 1;
int win_y = (*iter)->getGlobalY() - 1;
int win_x = (*iter)->getTermX() - 1;
int win_y = (*iter)->getTermY() - 1;
int line_len = win->width + win->right_shadow;
tmp = &win->text[(y-win_y) * line_len + (x-win_x)];
@ -4107,6 +4108,7 @@ bool FTerm::hideCursor (bool on)
{
if ( vi )
appendOutputBuffer (vi);
hiddenCursor = true; // global
}
else
@ -4118,6 +4120,7 @@ bool FTerm::hideCursor (bool on)
hiddenCursor = false;
}
flush_out();
if ( ! hiddenCursor && linux_terminal )
@ -4135,6 +4138,8 @@ bool FTerm::isCursorInside()
int x = w->getCursorPos().getX();
int y = w->getCursorPos().getY();
x += w->getTermX() - 1;
y += w->getTermY() - 1;
if ( term->contains(x,y) )
return true;
@ -4573,8 +4578,8 @@ int FTerm::print (FTerm::term_area* area, FString& s)
nc.trans_shadow = next_attribute.trans_shadow;
nc.inherit_bg = next_attribute.inherit_bg;
int ax = x - area_widget->getGlobalX();
int ay = y - area_widget->getGlobalY();
int ax = x - area_widget->getTermX();
int ay = y - area_widget->getTermY();
if ( area
&& ax >= 0 && ay >= 0
@ -4619,11 +4624,11 @@ int FTerm::print (FTerm::term_area* area, FString& s)
rsh = area->right_shadow;
bsh = area->bottom_shadow;
const FRect& area_geometry = area_widget->getGeometryGlobal();
const FRect& area_geometry = area_widget->getTermGeometry();
if ( cursor->x_ref() > area_geometry.getX2()+rsh )
{
cursor->x_ref() = short(area_widget->getGlobalX());
cursor->x_ref() = short(area_widget->getTermX());
cursor->y_ref()++;
}
@ -4701,8 +4706,8 @@ int FTerm::print (FTerm::term_area* area, register int c)
if ( ! area_widget )
return -1;
ax = x - area_widget->getGlobalX();
ay = y - area_widget->getGlobalY();
ax = x - area_widget->getTermX();
ay = y - area_widget->getTermY();
if ( ax >= 0 && ay >= 0
&& ax < area->width + area->right_shadow
@ -4744,11 +4749,11 @@ int FTerm::print (FTerm::term_area* area, register int c)
cursor->x_ref()++;
rsh = area->right_shadow;
bsh = area->bottom_shadow;
const FRect& area_geometry = area_widget->getGeometryGlobal();
const FRect& area_geometry = area_widget->getTermGeometry();
if ( cursor->x_ref() > area_geometry.getX2()+rsh )
{
cursor->x_ref() = short(area_widget->getGlobalX());
cursor->x_ref() = short(area_widget->getTermX());
cursor->y_ref()++;
}

View File

@ -410,6 +410,8 @@ class FTerm
static FString getAnswerbackMsg();
static FString getSecDA();
static void printPosTerm (const FPoint&);
static void printPosTerm (register int, register int);
int printf (const wchar_t*, ...);
int printf (const char*, ...)
#if defined(__clang__)
@ -656,5 +658,13 @@ inline bool FTerm::unsetRawMode()
inline bool FTerm::setCookedMode()
{ return setRawMode(false); }
//----------------------------------------------------------------------
inline void FTerm::printPosTerm (const FPoint& pos)
{ printPosTerm (pos.getX(), pos.getY()); }
//----------------------------------------------------------------------
inline void FTerm::printPosTerm (register int x, register int y)
{ cursor->setPoint(x,y); }
#endif // _FTERM_H

View File

@ -37,8 +37,8 @@ void FTextView::init()
{
nf_offset = isNewFont() ? 1 : 0;
foregroundColor = wc.dialog_fg;
backgroundColor = wc.dialog_bg;
setForegroundColor (wc.dialog_fg);
setBackgroundColor (wc.dialog_bg);
VBar = new FScrollbar(fc::vertical, this);
VBar->setMinimum(0);
@ -66,7 +66,7 @@ void FTextView::init()
void FTextView::draw()
{
updateVTerm(false);
setColor (foregroundColor, backgroundColor);
setColor();
if ( isMonochron() )
setReverse(true);
@ -100,7 +100,7 @@ void FTextView::draw()
}
}
setCursorPos(1,1);
setCursorPos (getWidth(), getHeight());
updateTerminal();
flush_out();
}
@ -110,17 +110,17 @@ void FTextView::drawText()
{
uInt start, end;
if ( data.empty() || height < 4 || width < 5 )
if ( data.empty() || getHeight() < 4 || getWidth() < 5 )
return;
start = 0;
end = uInt(height+nf_offset-2);
end = uInt(getHeight() + nf_offset - 2);
if ( end > getRows() )
end = getRows();
updateVTerm(false);
setColor (foregroundColor, backgroundColor);
setColor();
if ( isMonochron() )
setReverse(true);
@ -130,9 +130,9 @@ void FTextView::drawText()
uInt i, len;
FString line;
const wchar_t* line_str;
gotoxy (xpos+xmin, ypos+ymin-nf_offset+int(y));
printPos (2, 2 - nf_offset + int(y));
line = data[y+uInt(yoffset)].mid ( uInt(1 + xoffset)
, uInt(width - nf_offset - 2) );
, uInt(getWidth() - nf_offset - 2) );
line_str = line.wc_str();
len = line.getLength();
@ -152,7 +152,7 @@ void FTextView::drawText()
print ('.');
}
for (; i < uInt(width - nf_offset - 2); i++)
for (; i < uInt(getWidth() - nf_offset - 2); i++)
print (' ');
}
@ -173,25 +173,43 @@ void FTextView::processChanged()
void FTextView::adjustSize()
{
FWidget::adjustSize();
int width = getWidth();
int height = getHeight();
int last_line = int(getRows());
int max_width = int(maxLineWidth);
VBar->setMaximum (int(getRows()) - height + 2 - nf_offset);
VBar->setPageSize (int(getRows()), height - 2 + nf_offset);
if ( xoffset > max_width - width - nf_offset - 1 )
xoffset = max_width - width - nf_offset - 1;
if ( xoffset < 0 )
xoffset = 0;
if ( yoffset > last_line - height - nf_offset + 2 )
yoffset = last_line - height - nf_offset + 2;
if ( yoffset < 0 )
yoffset = 0;
VBar->setMaximum (last_line - height + 2 - nf_offset);
VBar->setPageSize (last_line, height - 2 + nf_offset);
VBar->setX (width);
VBar->setHeight (height - 2 + nf_offset, false);
VBar->setValue (yoffset);
VBar->resize();
HBar->setMaximum (int(maxLineWidth) - width + nf_offset + 2);
HBar->setPageSize (int(maxLineWidth), width - nf_offset - 2);
HBar->setMaximum (max_width - width + nf_offset + 2);
HBar->setPageSize (max_width, width - nf_offset - 2);
HBar->setY (height);
HBar->setWidth (width - 2, false);
HBar->setValue (xoffset);
HBar->resize();
if ( int(getRows()) < height + nf_offset - 1 )
if ( last_line < height + nf_offset - 1 )
VBar->hide();
else
VBar->setVisible();
if ( int(maxLineWidth) < width-nf_offset - 1 )
if ( max_width < width - nf_offset - 1 )
HBar->hide();
else
HBar->setVisible();
@ -222,14 +240,18 @@ void FTextView::hide()
setColor (fg, bg);
n = isNewFont() ? 1 : 0;
size = width + n;
size = getWidth() + n;
if ( size < 0 )
return;
blank = new char[size+1];
memset(blank, ' ', uLong(size));
blank[size] = '\0';
for (int y=0; y < height; y++)
for (int y=0; y < getHeight(); y++)
{
gotoxy (xpos+xmin-1, ypos+ymin-1+y);
printPos (1, 1 + y);
print (blank);
}
@ -253,14 +275,14 @@ void FTextView::onKeyPress (FKeyEvent* ev)
break;
case fc::Fkey_down:
if ( yoffset + height + nf_offset <= last_line + 1 )
if ( yoffset + getHeight() + nf_offset <= last_line + 1 )
yoffset++;
ev->accept();
break;
case fc::Fkey_right:
if ( xoffset + width - nf_offset <= int(maxLineWidth) + 1 )
if ( xoffset + getWidth() - nf_offset <= int(maxLineWidth) + 1 )
xoffset++;
ev->accept();
@ -274,7 +296,7 @@ void FTextView::onKeyPress (FKeyEvent* ev)
break;
case fc::Fkey_ppage:
yoffset -= height-2;
yoffset -= getHeight()-2;
if ( yoffset < 0 )
yoffset = 0;
@ -283,11 +305,11 @@ void FTextView::onKeyPress (FKeyEvent* ev)
break;
case fc::Fkey_npage:
if ( last_line >= height )
yoffset += height-2;
if ( last_line >= getHeight() )
yoffset += getHeight()-2;
if ( yoffset > last_line - height - nf_offset + 2 )
yoffset = last_line - height - nf_offset + 2;
if ( yoffset > last_line - getHeight() - nf_offset + 2 )
yoffset = last_line - getHeight() - nf_offset + 2;
if ( yoffset < 0 )
yoffset = 0;
@ -301,8 +323,8 @@ void FTextView::onKeyPress (FKeyEvent* ev)
break;
case fc::Fkey_end:
if ( last_line >= height )
yoffset = last_line - height - nf_offset + 2;
if ( last_line >= getHeight() )
yoffset = last_line - getHeight() - nf_offset + 2;
ev->accept();
break;
@ -373,7 +395,7 @@ void FTextView::onWheel (FWheelEvent* ev)
case fc::WheelDown:
{
int yoffset_end = last_line - height - nf_offset + 2;
int yoffset_end = last_line - getHeight() - nf_offset + 2;
if ( yoffset_end < 0 )
yoffset_end = 0;
@ -436,7 +458,7 @@ void FTextView::cb_VBarChange (FWidget*, void*)
switch ( scrollType )
{
case FScrollbar::scrollPageBackward:
distance = height+nf_offset-2;
distance = getHeight() + nf_offset - 2;
// fall through
case FScrollbar::scrollStepBackward:
yoffset -= distance;
@ -447,13 +469,13 @@ void FTextView::cb_VBarChange (FWidget*, void*)
break;
case FScrollbar::scrollPageForward:
distance = height+nf_offset-2;
distance = getHeight() + nf_offset - 2;
// fall through
case FScrollbar::scrollStepForward:
yoffset += distance;
if ( yoffset > last_line - height - nf_offset + 2 )
yoffset = last_line - height - nf_offset + 2;
if ( yoffset > last_line - getHeight() - nf_offset + 2 )
yoffset = last_line - getHeight() - nf_offset + 2;
break;
@ -466,8 +488,8 @@ void FTextView::cb_VBarChange (FWidget*, void*)
yoffset = val;
if ( yoffset > last_line - height - nf_offset + 2 )
yoffset = last_line - height - nf_offset + 2;
if ( yoffset > last_line - getHeight() - nf_offset + 2 )
yoffset = last_line - getHeight() - nf_offset + 2;
if ( yoffset < 0 )
yoffset = 0;
@ -516,13 +538,13 @@ void FTextView::cb_HBarChange (FWidget*, void*)
{
int distance = 1;
int xoffset_before = xoffset;
int xoffset_end = int(maxLineWidth) - width + nf_offset + 4;
int xoffset_end = int(maxLineWidth) - getWidth() + nf_offset + 4;
int scrollType = HBar->getScrollType();
switch ( scrollType )
{
case FScrollbar::scrollPageBackward:
distance = width - nf_offset - 4;
distance = getWidth() - nf_offset - 4;
// fall through
case FScrollbar::scrollStepBackward:
xoffset -= distance;
@ -533,13 +555,13 @@ void FTextView::cb_HBarChange (FWidget*, void*)
break;
case FScrollbar::scrollPageForward:
distance = width - nf_offset - 4;
distance = getWidth() - nf_offset - 4;
// fall through
case FScrollbar::scrollStepForward:
xoffset += distance;
if ( xoffset > int(maxLineWidth) - width + nf_offset + 4 )
xoffset = int(maxLineWidth) - width + nf_offset + 4;
if ( xoffset > int(maxLineWidth) - getWidth() + nf_offset + 4 )
xoffset = int(maxLineWidth) - getWidth() + nf_offset + 4;
if ( xoffset < 0 )
xoffset = 0;
@ -555,8 +577,8 @@ void FTextView::cb_HBarChange (FWidget*, void*)
xoffset = val;
if ( xoffset > int(maxLineWidth) - width + nf_offset + 4 )
xoffset = int(maxLineWidth) - width + nf_offset + 4;
if ( xoffset > int(maxLineWidth) - getWidth() + nf_offset + 4 )
xoffset = int(maxLineWidth) - getWidth() + nf_offset + 4;
if ( xoffset < 0 )
xoffset = 0;
@ -612,6 +634,8 @@ void FTextView::cb_HBarChange (FWidget*, void*)
void FTextView::setGeometry (int x, int y, int w, int h, bool adjust)
{
FWidget::setGeometry(x, y, w, h, adjust);
int width = getWidth();
int height = getHeight();
if ( isNewFont() )
{
@ -623,6 +647,9 @@ void FTextView::setGeometry (int x, int y, int w, int h, bool adjust)
VBar->setGeometry (width, 2, 1, height-2);
HBar->setGeometry (2, height, width-2, 1);
}
VBar->resize();
HBar->resize();
}
//----------------------------------------------------------------------
@ -630,7 +657,7 @@ void FTextView::setPosition (int pos)
{
int last_line = int(getRows());
if ( pos < 0 || pos > last_line - height + 2 )
if ( pos < 0 || pos > last_line - getHeight() + 2 )
return;
yoffset = pos;
@ -728,10 +755,10 @@ void FTextView::insert (const FString& str, int pos)
{
maxLineWidth = len;
if ( len > uInt(width-nf_offset-2) )
if ( len > uInt(getWidth() - nf_offset - 2) )
{
HBar->setMaximum (int(maxLineWidth) - width + nf_offset + 2);
HBar->setPageSize (int(maxLineWidth), width - nf_offset - 2);
HBar->setMaximum (int(maxLineWidth) - getWidth() + nf_offset + 2);
HBar->setPageSize (int(maxLineWidth), getWidth() - nf_offset - 2);
HBar->calculateSliderValues();
if ( ! HBar->isVisible() )
@ -741,14 +768,14 @@ void FTextView::insert (const FString& str, int pos)
}
data.insert (iter + pos, text_split.begin(), text_split.end());
VBar->setMaximum (int(getRows()) - height + 2 - nf_offset);
VBar->setPageSize (int(getRows()), height - 2 + nf_offset);
VBar->setMaximum (int(getRows()) - getHeight() + 2 - nf_offset);
VBar->setPageSize (int(getRows()), getHeight() - 2 + nf_offset);
VBar->calculateSliderValues();
if ( ! VBar->isVisible() && int(getRows()) >= height + nf_offset - 1 )
if ( ! VBar->isVisible() && int(getRows()) >= getHeight() + nf_offset - 1 )
VBar->setVisible();
if ( VBar->isVisible() && int(getRows()) < height + nf_offset - 1 )
if ( VBar->isVisible() && int(getRows()) < getHeight() + nf_offset - 1 )
VBar->hide();
processChanged();
@ -795,15 +822,19 @@ void FTextView::clear()
HBar->hide();
// clear list from screen
setColor (foregroundColor, backgroundColor);
size = width - 2;
setColor();
size = getWidth() - 2;
if ( size < 0 )
return;
blank = new char[size+1];
memset(blank, ' ', uLong(size));
blank[size] = '\0';
for (int y=0; y < height+nf_offset-2; y++)
for (int y=0; y < getHeight() + nf_offset - 2; y++)
{
gotoxy (xpos+xmin, ypos+ymin-nf_offset+y);
printPos (2, 2 - nf_offset + y);
print (blank);
}

View File

@ -85,19 +85,19 @@ void FToggleButton::init()
if ( hasFocus() )
{
foregroundColor = wc.toggle_button_active_focus_fg;
backgroundColor = wc.toggle_button_active_focus_bg;
setForegroundColor (wc.toggle_button_active_focus_fg);
setBackgroundColor (wc.toggle_button_active_focus_bg);
}
else
{
foregroundColor = wc.toggle_button_active_fg;
backgroundColor = wc.toggle_button_active_bg;
setForegroundColor (wc.toggle_button_active_fg);
setBackgroundColor (wc.toggle_button_active_bg);
}
}
else // inactive
{
foregroundColor = wc.label_inactive_fg;
backgroundColor = wc.label_inactive_bg;
setForegroundColor (wc.label_inactive_fg);
setBackgroundColor (wc.label_inactive_bg);
}
}
@ -176,7 +176,7 @@ void FToggleButton::draw()
// set the cursor to the button
if ( isRadioButton() || isCheckboxButton() )
{
setCursorPos (xpos+xmin, ypos+ymin-1);
setCursorPos (2, 1);
if ( isCursorInside() && hasFocus() )
{
@ -232,7 +232,7 @@ void FToggleButton::drawLabel()
if ( hotkeypos != -1 )
length--;
gotoxy (xpos+xmin-1+label_offset_pos, ypos+ymin-1);
printPos (1 + label_offset_pos, 1);
if ( isMonochron() )
setReverse(true);
@ -381,11 +381,15 @@ void FToggleButton::hide()
}
setColor (fg, bg);
size = width;
size = getWidth();
if ( size < 0 )
return;
blank = new char[size+1];
memset(blank, ' ', uLong(size));
blank[size] = '\0';
gotoxy (xpos+xmin-1, ypos+ymin-1);
printPos (1, 1);
print (blank);
delete[] blank;
}
@ -424,21 +428,21 @@ bool FToggleButton::setEnable (bool on)
if ( hasFocus() )
{
foregroundColor = wc.toggle_button_active_focus_fg;
backgroundColor = wc.toggle_button_active_focus_bg;
setForegroundColor (wc.toggle_button_active_focus_fg);
setBackgroundColor (wc.toggle_button_active_focus_bg);
}
else
{
foregroundColor = wc.toggle_button_active_fg;
backgroundColor = wc.toggle_button_active_bg;
setForegroundColor (wc.toggle_button_active_fg);
setBackgroundColor (wc.toggle_button_active_bg);
}
}
else
{
flags &= ~fc::active;
delAccelerator();
foregroundColor = wc.toggle_button_inactive_fg;
backgroundColor = wc.toggle_button_inactive_bg;
setForegroundColor (wc.toggle_button_inactive_fg);
setBackgroundColor (wc.toggle_button_inactive_bg);
}
return on;
@ -458,8 +462,8 @@ bool FToggleButton::setFocus (bool on)
if ( isRadioButton() )
focus_inside_group = false;
foregroundColor = wc.toggle_button_active_focus_fg;
backgroundColor = wc.toggle_button_active_focus_bg;
setForegroundColor (wc.toggle_button_active_focus_fg);
setBackgroundColor (wc.toggle_button_active_focus_bg);
if ( isCursorInside() && (isRadioButton() || isCheckboxButton()) )
showCursor();
@ -480,8 +484,8 @@ bool FToggleButton::setFocus (bool on)
if ( isEnabled() )
{
foregroundColor = wc.toggle_button_active_fg;
backgroundColor = wc.toggle_button_active_bg;
setForegroundColor (wc.toggle_button_active_fg);
setBackgroundColor (wc.toggle_button_active_bg);
hideCursor();
if ( statusBar() )
@ -525,7 +529,7 @@ void FToggleButton::onMouseUp (FMouseEvent* ev)
if ( ev->getButton() != fc::LeftButton )
return;
if ( getGeometryGlobal().contains(ev->getGlobalPos()) )
if ( getTermGeometry().contains(ev->getTermPos()) )
{
if ( isRadioButton() )
{

File diff suppressed because it is too large Load Diff

View File

@ -107,7 +107,7 @@ class FWidget : public FObject, public FTerm
};
typedef std::vector<callback_data> CallbackObjects;
CallbackObjects callbackObjects;
CallbackObjects callback_objects;
struct member_callback_data
{
@ -118,7 +118,7 @@ class FWidget : public FObject, public FTerm
};
typedef std::vector<member_callback_data> MemberCallbackObjects;
MemberCallbackObjects memberCallbackObjects;
MemberCallbackObjects member_callback_objects;
struct accelerator
{
@ -217,6 +217,44 @@ class FWidget : public FObject, public FTerm
} wc;
// widget_colors wc;
int flags;
static uInt modal_dialogs;
private:
bool enable;
bool visible;
bool shown;
bool focus;
bool focusable;
bool visibleCursor;
FPoint widgetCursorPosition;
struct widget_size_hints
{
widget_size_hints()
: min_width (INT_MIN)
, min_height (INT_MIN)
, max_width (INT_MAX)
, max_height (INT_MAX)
{ }
~widget_size_hints()
{ }
void setMinimum (int w, int h)
{
min_width = w;
min_height = h;
}
void setMaximum (int w, int h)
{
max_width = w;
max_height = h;
}
int min_width;
int min_height;
int max_width;
int max_height;
} size_hints;
struct dbl_line_mask
{
dbl_line_mask() : top(), right(), bottom(), left()
@ -229,52 +267,45 @@ class FWidget : public FObject, public FTerm
std::vector<bool> left;
} double_flatline_mask;
int xpos;
int ypos;
int width;
int height;
int xmin;
int ymin;
int xmax;
int ymax;
int top_padding;
int left_padding;
int bottom_padding;
int right_padding;
int client_xmin;
int client_ymin;
int client_xmax;
int client_ymax;
FPoint shadow;
FRect adjustWidgetSizeShadow;
FRect adjustWidgetSizeGlobalShadow;
bool ignore_padding;
bool window_object;
bool dialog_object;
bool menu_object;
int flags;
short foregroundColor;
short backgroundColor;
static uInt modal_dialogs;
struct widget_padding
{
widget_padding() : top(0), left(0), bottom(0), right(0)
{ }
~widget_padding()
{ }
int top;
int left;
int bottom;
int right;
} padding;
private:
bool enable;
bool visible;
bool shown;
bool focus;
bool focusable;
bool visibleCursor;
FPoint widgetCursorPosition;
FRect widgetSize;
FRect adjustWidgetSize;
FRect adjustWidgetSizeGlobal;
FString statusbar_message;
bool ignore_padding;
// widget size
FRect wsize;
FRect adjust_wsize;
FRect adjust_wsize_term;
FRect adjust_wsize_shadow;
FRect adjust_wsize_term_shadow;
// widget offset
FRect offset;
// offset of the widget client area
FRect client_offset;
// widget shadow size (on the right and bottom side)
FPoint wshadow;
// default widget foreground and background color
short foreground_color;
short background_color;
term_area* print_area;
FString statusbar_message;
static FStatusBar* statusbar;
static FMenuBar* menubar;
static FWidget* show_root_widget;
static FWidget* redraw_root_widget;
term_area* print_area;
static FMenuBar* menubar;
static FWidget* show_root_widget;
static FWidget* redraw_root_widget;
friend class FTerm;
friend class FApplication;
friend class FToggleButton;
@ -335,9 +366,9 @@ class FWidget : public FObject, public FTerm
int numOfFocusableChildren();
FWidget* getParentWidget() const;
bool isRootWidget() const;
bool isWindow() const;
bool isDialog() const;
bool isMenu() const;
bool isWindowWidget() const;
bool isDialogWidget() const;
bool isMenuWidget() const;
virtual bool close();
static FStatusBar* statusBar();
@ -401,9 +432,9 @@ class FWidget : public FObject, public FTerm
int getX() const;
int getY() const;
const FPoint getPos() const;
int getGlobalX() const;
int getGlobalY() const;
const FPoint getGlobalPos() const;
int getTermX() const;
int getTermY() const;
const FPoint getTermPos() const;
int getWidth() const;
int getHeight() const;
int getTopPadding() const;
@ -413,15 +444,16 @@ class FWidget : public FObject, public FTerm
int getClientWidth() const;
int getClientHeight() const;
int getMaxWidth() const;
int getMinHeight() const;
int getMaxHeight() const;
const FPoint& getShadow() const;
const FRect& getGeometry() const;
const FRect& getGeometryShadow() const;
const FRect& getGeometryGlobal() const;
const FRect& getGeometryGlobalShadow() const;
FPoint globalToLocalPos (const FPoint&);
const FRect& getGeometryWithShadow();
const FRect& getTermGeometry();
const FRect& getTermGeometryWithShadow();
FPoint termToWidgetPos (const FPoint&);
void setForegroundColor (short);
void setBackgroundColor (short);
void setColor();
void setColor (short, short);
void setX (int, bool = true);
void setY (int, bool = true);
@ -429,14 +461,22 @@ class FWidget : public FObject, public FTerm
virtual void setPos (int, int, bool = true);
void setWidth (int, bool = true);
void setHeight (int, bool = true);
void setSize (int, int, bool = true);
void setTopPadding (int, bool = true);
void setLeftPadding (int, bool = true);
void setBottomPadding (int, bool = true);
void setRightPadding (int, bool = true);
void getTermGeometry();
void setTermGeometry (int, int);
void setParentOffset();
void setTermOffset();
void setTermOffsetWithPadding();
void getTermSize();
void setTermSize (int, int);
virtual void setGeometry (const FRect&, bool = true);
virtual void setGeometry (int, int, int, int, bool = true);
void setShadowSize (int, int);
void setMinimumSize (int, int);
void setMaximumSize (int, int);
void setFixedSize (int, int);
virtual void move (const FPoint&);
virtual void move (int, int);
int getFlags() const;
@ -447,8 +487,8 @@ class FWidget : public FObject, public FTerm
bool setCursorPos (register int, register int);
void unsetCursorPos();
static void gotoxy (const FPoint&);
static void gotoxy (register int, register int);
void printPos (const FPoint&);
void printPos (register int, register int);
static void setNormal();
@ -541,6 +581,7 @@ class FWidget : public FObject, public FTerm
void setDoubleFlatLine (int, int, bool = true);
void unsetDoubleFlatLine (int, int);
std::vector<bool>& doubleFlatLine_ref (int);
virtual void drawBorder (int, int, int, int);
virtual void drawBorder();
static void quit();
@ -602,16 +643,16 @@ inline bool FWidget::isShown() const
{ return shown; }
//----------------------------------------------------------------------
inline bool FWidget::isWindow() const
{ return window_object; }
inline bool FWidget::isWindowWidget() const
{ return ((flags & fc::window_widget) != 0); }
//----------------------------------------------------------------------
inline bool FWidget::isDialog() const
{ return dialog_object; }
inline bool FWidget::isDialogWidget() const
{ return ((flags & fc::dialog_widget) != 0); }
//----------------------------------------------------------------------
inline bool FWidget::isMenu() const
{ return menu_object; }
inline bool FWidget::isMenuWidget() const
{ return ((flags & fc::menu_widget) != 0); }
//----------------------------------------------------------------------
inline bool FWidget::isEnabled() const
@ -671,41 +712,41 @@ inline void FWidget::unsetFocusable()
//----------------------------------------------------------------------
inline short FWidget::getForegroundColor() const
{ return foregroundColor; }
{ return foreground_color; }
//----------------------------------------------------------------------
inline short FWidget::getBackgroundColor() const
{ return backgroundColor; }
{ return background_color; }
//----------------------------------------------------------------------
inline int FWidget::getX() const
{ return xpos; }
inline int FWidget::getX() const // x-position relative to the widget
{ return adjust_wsize.getX(); }
//----------------------------------------------------------------------
inline int FWidget::getY() const
{ return ypos; }
inline int FWidget::getY() const // y-position relative to the widget
{ return adjust_wsize.getY(); }
//----------------------------------------------------------------------
inline const FPoint FWidget::getPos() const
{ return adjustWidgetSize.getPos(); }
inline const FPoint FWidget::getPos() const // position relative to the widget
{ return adjust_wsize.getPos(); }
//----------------------------------------------------------------------
inline int FWidget::getGlobalX() const
{ return xpos+xmin-1; }
inline int FWidget::getTermX() const // x-position on terminal
{ return offset.getX1() + adjust_wsize.getX(); }
//----------------------------------------------------------------------
inline int FWidget::getGlobalY() const
{ return ypos+ymin-1; }
inline int FWidget::getTermY() const // y-position on terminal
{ return offset.getY1() + adjust_wsize.getY(); }
//----------------------------------------------------------------------
inline const FPoint FWidget::getGlobalPos() const
{ return FPoint(xpos+xmin-1, ypos+ymin-1); }
inline const FPoint FWidget::getTermPos() const // position on terminal
{ return FPoint(getTermX(), getTermY()); }
//----------------------------------------------------------------------
inline FPoint FWidget::globalToLocalPos (const FPoint& gPos)
inline FPoint FWidget::termToWidgetPos (const FPoint& tPos)
{
return FPoint ( gPos.getX() - xpos - xmin + 2
, gPos.getY() - ypos - ymin + 2 );
return FPoint ( tPos.getX() + 1 - offset.getX1() - adjust_wsize.getX()
, tPos.getY() + 1 - offset.getY1() - adjust_wsize.getY() );
}
//----------------------------------------------------------------------
@ -713,7 +754,7 @@ inline void FWidget::setForegroundColor (short color)
{
// valid colors -1..254
if ( color == fc::Default || color >> 8 == 0 )
foregroundColor = color;
foreground_color = color;
}
//----------------------------------------------------------------------
@ -721,7 +762,7 @@ inline void FWidget::setBackgroundColor (short color)
{
// valid colors -1..254
if ( color == fc::Default || color >> 8 == 0 )
backgroundColor = color;
background_color = color;
}
//----------------------------------------------------------------------
@ -730,63 +771,90 @@ inline void FWidget::setPos (const FPoint& p, bool adjust)
//----------------------------------------------------------------------
inline int FWidget::getWidth() const
{ return width; }
{ return adjust_wsize.getWidth(); }
//----------------------------------------------------------------------
inline int FWidget::getHeight() const
{ return height; }
{ return adjust_wsize.getHeight(); }
//----------------------------------------------------------------------
inline int FWidget::getTopPadding() const
{ return top_padding; }
{ return padding.top; }
//----------------------------------------------------------------------
inline int FWidget::getLeftPadding() const
{ return left_padding; }
{ return padding.left; }
//----------------------------------------------------------------------
inline int FWidget::getBottomPadding() const
{ return bottom_padding; }
{ return padding.bottom; }
//----------------------------------------------------------------------
inline int FWidget::getRightPadding() const
{ return right_padding; }
{ return padding.right; }
//----------------------------------------------------------------------
inline int FWidget::getClientWidth() const
{ return client_xmax-client_xmin+1; }
{ return client_offset.getWidth(); }
//----------------------------------------------------------------------
inline int FWidget::getClientHeight() const
{ return client_ymax-client_ymin+1; }
{ return client_offset.getHeight(); }
//----------------------------------------------------------------------
inline int FWidget::getMaxWidth() const
{ return xmax-xmin+1; }
{ return offset.getWidth(); }
//----------------------------------------------------------------------
inline int FWidget::getMinHeight() const
{ return ymax-ymin+1; }
inline int FWidget::getMaxHeight() const
{ return offset.getHeight(); }
//----------------------------------------------------------------------
inline const FPoint& FWidget::getShadow() const
{ return shadow; }
{ return wshadow; }
//----------------------------------------------------------------------
inline const FRect& FWidget::getGeometry() const
{ return adjustWidgetSize; }
{ return adjust_wsize; }
//----------------------------------------------------------------------
inline const FRect& FWidget::getGeometryShadow() const
{ return adjustWidgetSizeShadow; }
inline const FRect& FWidget::getGeometryWithShadow()
{
adjust_wsize_shadow.setCoordinates
(
adjust_wsize.x1_ref(),
adjust_wsize.y1_ref(),
adjust_wsize.x2_ref() + wshadow.x_ref(),
adjust_wsize.y2_ref() + wshadow.y_ref()
);
return adjust_wsize_shadow;
}
//----------------------------------------------------------------------
inline const FRect& FWidget::getGeometryGlobal() const
{ return adjustWidgetSizeGlobal; }
inline const FRect& FWidget::getTermGeometry()
{
adjust_wsize_term.setCoordinates
(
adjust_wsize.x1_ref() + offset.x1_ref(),
adjust_wsize.y1_ref() + offset.y1_ref(),
adjust_wsize.x2_ref() + offset.x1_ref(),
adjust_wsize.y2_ref() + offset.y1_ref()
);
return adjust_wsize_term;
}
//----------------------------------------------------------------------
inline const FRect& FWidget::getGeometryGlobalShadow() const
{ return adjustWidgetSizeGlobalShadow; }
inline const FRect& FWidget::getTermGeometryWithShadow()
{
adjust_wsize_term_shadow.setCoordinates
(
adjust_wsize.x1_ref() + offset.x1_ref(),
adjust_wsize.y1_ref() + offset.y1_ref(),
adjust_wsize.x2_ref() + offset.x1_ref() + wshadow.x_ref(),
adjust_wsize.y2_ref() + offset.y1_ref() + wshadow.y_ref()
);
return adjust_wsize_term_shadow;
}
//----------------------------------------------------------------------
inline void FWidget::setGeometry (const FRect& box, bool adjust)
@ -798,6 +866,25 @@ inline void FWidget::setGeometry (const FRect& box, bool adjust)
, adjust );
}
//----------------------------------------------------------------------
inline void FWidget::setShadowSize (int right, int bottom)
{ wshadow.setPoint (right, bottom); }
//----------------------------------------------------------------------
inline void FWidget::setMinimumSize (int min_width, int min_height)
{ size_hints.setMinimum (min_width, min_height); }
//----------------------------------------------------------------------
inline void FWidget::setMaximumSize (int max_width, int max_height)
{ size_hints.setMaximum (max_width, max_height); }
//----------------------------------------------------------------------
inline void FWidget::setFixedSize (int width, int height)
{
size_hints.setMinimum (width, height);
size_hints.setMaximum (width, height);
}
//----------------------------------------------------------------------
inline void FWidget::move (const FPoint& pos)
{ move( pos.getX(), pos.getY() ); }
@ -819,12 +906,15 @@ inline void FWidget::unsetCursorPos()
{ widgetCursorPosition.setPoint(-1,-1); }
//----------------------------------------------------------------------
inline void FWidget::gotoxy (const FPoint& pos)
{ gotoxy (pos.getX(), pos.getY()); }
inline void FWidget::printPos (const FPoint& pos)
{ printPos (pos.getX(), pos.getY()); }
//----------------------------------------------------------------------
inline void FWidget::gotoxy (register int x, register int y)
{ cursor->setPoint(x,y); }
inline void FWidget::printPos (register int x, register int y)
{
cursor->setPoint ( offset.getX1() + adjust_wsize.getX() - 1 + x,
offset.getY1() + adjust_wsize.getY() - 1 + y );
}
//----------------------------------------------------------------------
inline void FWidget::setNormal()
@ -1107,13 +1197,17 @@ inline bool FWidget::isInheritBackground()
{ return next_attribute.inherit_bg; }
//----------------------------------------------------------------------
inline void FWidget::unsetDoubleFlatLine(int side)
inline void FWidget::unsetDoubleFlatLine (int side)
{ setDoubleFlatLine(side, false); }
//----------------------------------------------------------------------
inline void FWidget::unsetDoubleFlatLine(int side, int pos)
inline void FWidget::unsetDoubleFlatLine (int side, int pos)
{ setDoubleFlatLine(side, pos, false); }
//----------------------------------------------------------------------
inline void FWidget::drawBorder()
{ drawBorder (1, getWidth(), 1, getHeight()); }
// NewFont elements
//----------------------------------------------------------------------

View File

@ -21,10 +21,8 @@ FWindow::FWindow(FWidget* parent)
, zoomed(false)
, win_focus_widget(0)
, normalGeometry()
, maxGeometry()
, minGeometry()
{
window_object = true;
setWindowWidget();
}
//----------------------------------------------------------------------
@ -79,6 +77,15 @@ void FWindow::onWindowRaised (FEvent*)
void FWindow::onWindowLowered (FEvent*)
{ }
//----------------------------------------------------------------------
void FWindow::adjustSize()
{
FWidget::adjustSize();
if ( zoomed )
setGeometry (1, 1, getMaxWidth(), getMaxHeight(), false);
}
// public methods of FWindow
//----------------------------------------------------------------------
@ -106,31 +113,31 @@ void FWindow::hide()
//----------------------------------------------------------------------
void FWindow::setWidth (int w, bool adjust)
{
int old_width = width;
int old_width = getWidth();
FWidget::setWidth (w, adjust);
if ( vwin && width != old_width )
if ( vwin && getWidth() != old_width )
resizeArea (vwin);
}
//----------------------------------------------------------------------
void FWindow::setHeight (int h, bool adjust)
{
int old_height = height;
int old_height = getHeight();
FWidget::setHeight (h, adjust);
if ( vwin && height != old_height )
if ( vwin && getHeight() != old_height )
resizeArea (vwin);
}
//----------------------------------------------------------------------
void FWindow::setGeometry (int x, int y, int w, int h, bool adjust)
{
int old_width = width;
int old_height = height;
int old_width = getWidth();
int old_height = getHeight();
FWidget::setGeometry (x, y, w, h, adjust);
if ( vwin && (width != old_width || height != old_height) )
if ( vwin && (getWidth() != old_width || getHeight() != old_height) )
resizeArea (vwin);
}
@ -138,10 +145,10 @@ void FWindow::setGeometry (int x, int y, int w, int h, bool adjust)
FWindow* FWindow::getWindowWidgetAt (int x, int y)
{
// returns the window object to the corresponding coordinates
if ( statusBar() && statusBar()->getGeometryGlobal().contains(x,y) )
if ( statusBar() && statusBar()->getTermGeometry().contains(x,y) )
return statusBar();
if ( menuBar() && menuBar()->getGeometryGlobal().contains(x,y) )
if ( menuBar() && menuBar()->getTermGeometry().contains(x,y) )
return menuBar();
if ( window_list && ! window_list->empty() )
@ -158,7 +165,7 @@ FWindow* FWindow::getWindowWidgetAt (int x, int y)
FWindow* w = static_cast<FWindow*>(*iter);
if ( ! w->isHiddenWindow()
&& w->getGeometryGlobal().contains(x,y) )
&& w->getTermGeometry().contains(x,y) )
return w;
}
}
@ -205,13 +212,13 @@ FWindow* FWindow::getWindowWidget (FWidget* obj)
// returns the window object to the given widget obj
FWidget* p_obj = obj->getParentWidget();
while ( ! obj->isWindow() && p_obj )
while ( ! obj->isWindowWidget() && p_obj )
{
obj = p_obj;
p_obj = p_obj->getParentWidget();
}
if ( obj->isWindow() )
if ( obj->isWindowWidget() )
return static_cast<FWindow*>(obj);
else
return 0;
@ -230,7 +237,7 @@ int FWindow::getWindowLayer (FWidget* obj)
if ( window_list->empty() )
return -1;
if ( ! obj->isWindow() )
if ( ! obj->isWindowWidget() )
{
if ( (window = getWindowWidget(obj)) == 0 )
return -1;
@ -301,14 +308,14 @@ bool FWindow::raiseWindow (FWidget* obj)
if ( window_list->empty() )
return false;
if ( ! obj->isWindow() )
if ( ! obj->isWindowWidget() )
return false;
if ( window_list->back() == obj )
return false;
if ( (window_list->back()->getFlags() & fc::modal) != 0
&& ! obj->isMenu() )
&& ! obj->isMenuWidget() )
return false;
iter = window_list->begin();
@ -342,7 +349,7 @@ bool FWindow::lowerWindow (FWidget* obj)
if ( window_list->empty() )
return false;
if ( ! obj->isWindow() )
if ( ! obj->isWindowWidget() )
return false;
if ( window_list->front() == obj )
@ -376,9 +383,9 @@ bool FWindow::zoomWindow()
if ( zoomed )
{
zoomed = false;
FRect currentGeometry = getGeometryShadow();
FRect oldGeometry = getTermGeometryWithShadow();
setGeometry (normalGeometry);
restoreVTerm (currentGeometry);
restoreVTerm (oldGeometry);
redraw();
}
else
@ -386,13 +393,35 @@ bool FWindow::zoomWindow()
zoomed = true;
// save the current geometry
normalGeometry = getGeometry();
setGeometry (1, 1, getMaxWidth(), getMinHeight());
FRect oldGeometry = getTermGeometryWithShadow();
setGeometry (1, 1, getMaxWidth(), getMaxHeight());
restoreVTerm (oldGeometry);
redraw();
}
return zoomed;
}
//----------------------------------------------------------------------
bool FWindow::setWindowWidget (bool on)
{
if ( isWindowWidget() == on )
return true;
if ( on )
{
flags |= fc::window_widget;
setTermOffset();
}
else
{
flags &= ~fc::window_widget;
setParentOffset();
}
return on;
}
//----------------------------------------------------------------------
FWindow* FWindow::getActiveWindow()
{
@ -500,7 +529,7 @@ void FWindow::switchToPrevWindow()
{
focus_widget->setFocus();
if ( ! focus_widget->isWindow() )
if ( ! focus_widget->isWindowWidget() )
focus_widget->redraw();
}
}

View File

@ -48,8 +48,6 @@ class FWindow : public FWidget
bool zoomed;
FWidget* win_focus_widget;
FRect normalGeometry;
FRect maxGeometry;
FRect minGeometry;
protected:
static FWindow* previous_widget;
@ -65,6 +63,7 @@ class FWindow : public FWidget
virtual void onWindowInactive (FEvent*);
virtual void onWindowRaised (FEvent*);
virtual void onWindowLowered (FEvent*);
virtual void adjustSize();
public:
explicit FWindow (FWidget* = 0); // constructor
@ -91,6 +90,9 @@ class FWindow : public FWidget
bool lowerWindow ();
bool zoomWindow ();
bool isZoomed() const;
bool setWindowWidget (bool);
bool setWindowWidget();
bool unsetWindowWidget();
static FWindow* getActiveWindow();
static void setActiveWindow (FWindow*);
FWidget* getWindowFocusWidget() const;
@ -127,6 +129,14 @@ inline bool FWindow::lowerWindow()
inline bool FWindow::isZoomed() const
{ return zoomed; }
//----------------------------------------------------------------------
inline bool FWindow::setWindowWidget()
{ return setWindowWidget(true); }
//----------------------------------------------------------------------
inline bool FWindow::unsetWindowWidget()
{ return setWindowWidget(false); }
//----------------------------------------------------------------------
inline bool FWindow::activateWindow()
{ return activateWindow(true); }

View File

@ -250,13 +250,11 @@ Calc::Calc (FWidget* parent)
btn->setNoUnderline();
btn->setText(button_text[key]);
btn->setDoubleFlatLine(fc::top);
btn->setDoubleFlatLine(fc::bottom);
if ( isNewFont() )
btn->unsetClickAnimation();
if ( key <= Three )
btn->setDoubleFlatLine(fc::bottom);
btn->addCallback
(
"clicked",
@ -318,7 +316,7 @@ void Calc::drawDispay()
if ( isMonochron() )
setReverse(false);
gotoxy (xpos+xmin+1, ypos+ymin+1);
printPos (3,3);
print(display);
print(L' ');
setColor(wc.dialog_fg, wc.dialog_bg);
@ -329,15 +327,15 @@ void Calc::drawDispay()
if ( isNewFont() )
{
FString bottom_line(33, wchar_t(fc::NF_border_line_bottom));
gotoxy (xpos+xmin+1, ypos+ymin);
print(bottom_line);
gotoxy (xpos+xmin+0, ypos+ymin+1);
printPos (3,2);
print (bottom_line);
printPos (2,3);
print (wchar_t(fc::NF_rev_border_line_right));
gotoxy (xpos+xmin+34, ypos+ymin+1);
printPos (36,3);
print (wchar_t(fc::NF_border_line_left));
FString top_bottom_line_5(5, wchar_t(fc::NF_border_line_up_and_down));
FString top_line_2(2, wchar_t(fc::NF_border_line_upper));
gotoxy (xpos+xmin+1, ypos+ymin+2);
printPos (3,4);
print ( top_bottom_line_5 + top_line_2
+ top_bottom_line_5 + top_line_2
+ top_bottom_line_5 + top_line_2
@ -349,7 +347,7 @@ void Calc::drawDispay()
FString separator = FString(wchar_t(fc::BoxDrawingsVerticalAndRight))
+ FString(35, wchar_t(fc::BoxDrawingsHorizontal))
+ FString(wchar_t(fc::BoxDrawingsVerticalAndLeft));
gotoxy (xpos+xmin-1, ypos+ymin+2);
printPos (1,4);
print(separator);
}
@ -415,8 +413,8 @@ bool Calc::isOperatorKey(int key)
//----------------------------------------------------------------------
void Calc::setDisplay (lDouble d)
{
char buffer[32];
snprintf (buffer, sizeof(buffer), "%31.11Lg", d);
char buffer[33];
snprintf (buffer, sizeof(buffer), "%32.11Lg", d);
input = buffer;
}

View File

@ -46,7 +46,7 @@ void keyboard::draw()
setNormal();
setColor(fc::Default, fc::Default);
clearArea();
gotoxy (1,1);
printPosTerm (1,1);
print ("---------------\n");
print ("Press Q to quit\n");
print ("---------------\n");

View File

@ -52,8 +52,8 @@ void Mandelbrot::draw()
y_max = 1.05;
max_iter = 99;
xoffset = xpos+xmin;
yoffset = ypos+ymin;
xoffset = 2;
yoffset = 2;
Cols = getClientWidth();
Lines = getClientHeight();
current_line = 1;
@ -63,7 +63,7 @@ void Mandelbrot::draw()
for (y0=y_min; y0 < y_max && current_line <= Lines; y0+=dY)
{
gotoxy (xoffset, yoffset+current_line);
printPos (xoffset, yoffset+current_line);
for (x0=x_min; x0 < x_max; x0+=dX)
{

View File

@ -218,7 +218,7 @@ void AttribDemo::printAltCharset()
if ( ! isMonochron() )
setColor (wc.label_fg, wc.label_bg);
gotoxy (xpos + xmin - 1, ypos + ymin - 1);
printPos (1,1);
print("alternate charset: ");
if ( parent->bgcolor == fc::Default )
@ -249,8 +249,7 @@ void AttribDemo::draw()
for (int y=0; y < getParentWidget()->getHeight()-7; y++)
{
gotoxy ( xpos + xmin - 1,
ypos + ymin + y );
printPos (1, 2+y);
if ( ! isMonochron() )
setColor (wc.label_fg, wc.label_bg);
@ -354,7 +353,7 @@ void AttribDemo::draw()
if ( ! isMonochron() )
setColor(wc.label_fg, wc.label_bg);
gotoxy (xpos + xmin - 1, ypos + ymin + 13);
printPos (1, 15);
short bg = static_cast<AttribDlg*>(getParent())->bgcolor;
print (" Background color:");
@ -363,7 +362,7 @@ void AttribDemo::draw()
else
printf ( " %d", bg);
gotoxy (xpos + xmin + 14, ypos + ymin + 15);
printPos (16, 17);
print ("Change background color ->");
updateVTerm(true);
}

View File

@ -51,7 +51,7 @@ void timer::draw()
setNormal();
setColor (fc::Default, fc::Default);
clearArea();
gotoxy (1,1);
printPosTerm (1,1);
print ("---------------\n");
print ("Press Q to quit\n");
print ("---------------\n");

View File

@ -78,7 +78,7 @@ void Transparent::draw()
for (int n=1; n <= getClientHeight(); n++)
{
gotoxy(xpos+xmin, ypos+ymin+n);
printPos (2, 2+n);
print(line);
}
@ -192,10 +192,10 @@ void MainWindow::draw()
if ( isMonochron() )
setReverse(true);
setColor(foregroundColor, backgroundColor);
gotoxy(xpos+xmin, ypos+ymin+2);
setColor();
printPos (2,4);
print(line1);
gotoxy(xpos+xmin, ypos+ymin+3);
printPos (2,5);
print(line2);
if ( isMonochron() )

View File

@ -68,7 +68,7 @@ ProgressDialog::ProgressDialog (FWidget* parent)
progressBar = new FProgressbar(this);
progressBar->setGeometry(2, 3, 34, 1, false);
//progressBar->setPercentage(78);<
//progressBar->setPercentage(78);
reset->addCallback
(
@ -211,8 +211,8 @@ void TextWindow::append (const FString& str)
//----------------------------------------------------------------------
void TextWindow::adjustSize()
{
scrollText->setGeometry (1, 2, getWidth(), getHeight()-1);
FDialog::adjustSize();
scrollText->setGeometry (1, 2, getWidth(), getHeight()-1);
}
@ -888,7 +888,7 @@ int main (int argc, char* argv[])
app.setXTermTitle (title);
//app.setEncoding("VT100");
//app.setTermGeometry(94,30);
//app.setTermSize(94,30);
//app.setNewFont();
MyDialog d(&app);

View File

@ -239,6 +239,7 @@ void Window::cb_createWindows (FWidget*, void*)
x = dx + 5 + (n%3)*25 + int(n/3)*3;
y = dy + 11 + int(n/3)*3;
win->setGeometry (x, y, 20, 8);
win->setMinimumSize (20, 8);
win->setResizeable();
win->show();
@ -305,7 +306,7 @@ void Window::cb_next (FWidget*, void*)
} while ( ! next->isEnabled()
|| ! next->acceptFocus()
|| ! next->isVisible()
|| ! next->isWindow() );
|| ! next->isWindowWidget() );
activateWindow(next);
break;
@ -328,7 +329,7 @@ void Window::cb_previous (FWidget*, void*)
{
--iter;
if ( (*iter)->isDialog()
if ( (*iter)->isDialogWidget()
&& static_cast<FWindow*>(*iter)->isActiveWindow() )
{
FDialog* prev;
@ -345,7 +346,7 @@ void Window::cb_previous (FWidget*, void*)
} while ( ! prev->isEnabled()
|| ! prev->acceptFocus()
|| ! prev->isVisible()
|| ! prev->isWindow() );
|| ! prev->isWindowWidget() );
activateWindow(prev);
break;