FLabel now transmits the Click events to the parent widget

This commit is contained in:
Markus Gans 2016-09-27 00:46:05 +02:00
parent 9475f34499
commit 7369ed1a10
40 changed files with 898 additions and 810 deletions

View File

@ -1,3 +1,6 @@
2016-09-26 Markus Gans <guru.mail@muenster.de>
* FLabel now transmits the Click events to the parent widget
2016-09-25 Markus Gans <guru.mail@muenster.de> 2016-09-25 Markus Gans <guru.mail@muenster.de>
* Splitting gotoxy in printPos (local position) * Splitting gotoxy in printPos (local position)
and printPosTerm (global terminal position) and printPosTerm (global terminal position)

View File

@ -48,7 +48,7 @@ FApplication::FApplication (int& _argc, char**& _argv)
, dblclick_interval(500000) // 500 ms , dblclick_interval(500000) // 500 ms
, time_keypressed() , time_keypressed()
, time_mousepressed() , time_mousepressed()
, newMousePosition() , new_mouse_position()
{ {
assert ( ! rootObj assert ( ! rootObj
&& "FApplication: There should be only one application object" ); && "FApplication: There should be only one application object" );
@ -844,7 +844,7 @@ void FApplication::getX11ButtonState (int button)
{ {
case button1_pressed: case button1_pressed:
case button1_pressed_move: case button1_pressed_move:
if ( *mouse == newMousePosition if ( *mouse == new_mouse_position
&& x11_button_state == all_buttons_released && x11_button_state == all_buttons_released
&& ! isKeyTimeout(&time_mousepressed, dblclick_interval) ) && ! isKeyTimeout(&time_mousepressed, dblclick_interval) )
{ {
@ -938,7 +938,7 @@ bool FApplication::parseX11Mouse()
x = uChar(x11_mouse[1] - 0x20); x = uChar(x11_mouse[1] - 0x20);
y = uChar(x11_mouse[2] - 0x20); y = uChar(x11_mouse[2] - 0x20);
newMousePosition.setPoint(x,y); new_mouse_position.setPoint(x,y);
// fill bit field with 0 // fill bit field with 0
memset(&b_state, 0x00, sizeof(b_state)); memset(&b_state, 0x00, sizeof(b_state));
@ -1031,7 +1031,7 @@ bool FApplication::parseSGRMouse()
y = uChar(10 * y + (*p - '0')); y = uChar(10 * y + (*p - '0'));
} }
newMousePosition.setPoint(x,y); new_mouse_position.setPoint(x,y);
// fill bit field with 0 // fill bit field with 0
memset(&b_state, 0x00, sizeof(b_state)); memset(&b_state, 0x00, sizeof(b_state));
@ -1057,7 +1057,7 @@ bool FApplication::parseSGRMouse()
{ {
case button1: case button1:
case button1_move: case button1_move:
if ( *mouse == newMousePosition if ( *mouse == new_mouse_position
&& (((x11_button_state & 0x80) >> 2) + 'M') == released && (((x11_button_state & 0x80) >> 2) + 'M') == released
&& ! isKeyTimeout(&time_mousepressed, dblclick_interval) ) && ! isKeyTimeout(&time_mousepressed, dblclick_interval) )
{ {
@ -1126,7 +1126,7 @@ bool FApplication::parseSGRMouse()
} }
} }
if ( *mouse == newMousePosition if ( *mouse == new_mouse_position
&& b_state.wheel_up != Pressed && b_state.wheel_up != Pressed
&& b_state.wheel_down != Pressed && b_state.wheel_down != Pressed
&& x11_button_state == uChar(((*p & 0x20) << 2) + button) ) && x11_button_state == uChar(((*p & 0x20) << 2) + button) )
@ -1228,7 +1228,7 @@ bool FApplication::parseUrxvtMouse()
if ( y > term->getHeight() ) if ( y > term->getHeight() )
y = uChar(term->getHeight()); y = uChar(term->getHeight());
newMousePosition.setPoint(x,y); new_mouse_position.setPoint(x,y);
// fill bit field with 0 // fill bit field with 0
memset(&b_state, 0x00, sizeof(b_state)); memset(&b_state, 0x00, sizeof(b_state));
@ -1250,7 +1250,7 @@ bool FApplication::parseUrxvtMouse()
getX11ButtonState (button & button_mask); getX11ButtonState (button & button_mask);
if ( *mouse == newMousePosition if ( *mouse == new_mouse_position
&& b_state.wheel_up != Pressed && b_state.wheel_up != Pressed
&& b_state.wheel_down != Pressed && b_state.wheel_down != Pressed
&& x11_button_state == uChar(button) ) && x11_button_state == uChar(button) )
@ -1398,10 +1398,12 @@ void FApplication::processMouseEvent()
|| b_state.wheel_up == Pressed || b_state.wheel_up == Pressed
|| b_state.wheel_down == Pressed ) ) || b_state.wheel_down == Pressed ) )
{ {
// determine the window object on the current click position
FWidget* window = FWindow::getWindowWidgetAt (*mouse); FWidget* window = FWindow::getWindowWidgetAt (*mouse);
if ( window ) if ( window )
{ {
// determine the widget at the current click position
FWidget* child = childWidgetAt (window, *mouse); FWidget* child = childWidgetAt (window, *mouse);
clicked_widget = (child != 0) ? child : window; clicked_widget = (child != 0) ? child : window;
} }

View File

@ -108,7 +108,7 @@ class FApplication : public FWidget
long dblclick_interval; long dblclick_interval;
struct timeval time_keypressed; struct timeval time_keypressed;
struct timeval time_mousepressed; struct timeval time_mousepressed;
FPoint newMousePosition; FPoint new_mouse_position;
static FWidget* main_widget; static FWidget* main_widget;
static FWidget* active_window; static FWidget* active_window;
static FWidget* focus_widget; static FWidget* focus_widget;

View File

@ -37,16 +37,16 @@ class FButton : public FWidget
{ {
private: private:
FString text; FString text;
bool button_down; bool button_down;
bool click_animation; bool click_animation;
int click_time; int click_time;
short button_fg; short button_fg;
short button_bg; short button_bg;
short button_hotkey_fg; short button_hotkey_fg;
short button_focus_fg; short button_focus_fg;
short button_focus_bg; short button_focus_bg;
short button_inactive_fg; short button_inactive_fg;
short button_inactive_bg; short button_inactive_bg;
private: private:
FButton (const FButton&); FButton (const FButton&);

View File

@ -57,6 +57,10 @@ static uInt character[][fc::NUM_OF_ENCODINGS] =
{0x25bc, '.', 0x1f, 'v'}, // ▼ - BlackDownPointingTriangle {0x25bc, '.', 0x1f, 'v'}, // ▼ - BlackDownPointingTriangle
{0x25ba, '+', 0x10, '>'}, // ► - BlackRightPointingPointer {0x25ba, '+', 0x10, '>'}, // ► - BlackRightPointingPointer
{0x25c4, ',', 0x11, '<'}, // ◄ - BlackLeftPointingPointer {0x25c4, ',', 0x11, '<'}, // ◄ - BlackLeftPointingPointer
{0x25E2,'\\', '\\','\\'}, // ◢ - BlackLowerLightTriangle
{0x25E3, '/', '/', '/'}, // ◣ - BlackLowerLeftTriangle
{0x25E4,'\\', '\\','\\'}, // ◤ - BlackUpperLeftTriangle
{0x25E5, '/', '/', '/'}, // ◥ - BlackUpperRightTriangle
{0x1ab4, 0, 0xb4, 0}, // ⊐ - NF_rev_left_arrow2 {0x1ab4, 0, 0xb4, 0}, // ⊐ - NF_rev_left_arrow2
{0x1ab5, 0, 0xb5, 0}, // ► - NF_rev_right_arrow2 {0x1ab5, 0, 0xb5, 0}, // ► - NF_rev_right_arrow2
{0x1ab7, 0, 0xb7, 0}, // ) - NF_radio_button3 {0x1ab7, 0, 0xb7, 0}, // ) - NF_radio_button3

View File

@ -1,6 +1,6 @@
#ifndef _SRC_FCONFIG_H #ifndef _SRC_FCONFIG_H
#define _SRC_FCONFIG_H 1 #define _SRC_FCONFIG_H 1
/* src/fconfig.h. Generated automatically at end of configure. */ /* src/fconfig.h. Generated automatically at end of configure. */
/* config.h. Generated from config.h.in by configure. */ /* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */ /* config.h.in. Generated from configure.ac by autoheader. */
@ -171,6 +171,6 @@
#ifndef F_VERSION #ifndef F_VERSION
#define F_VERSION "0.2.0" #define F_VERSION "0.2.0"
#endif #endif
/* once: _SRC_FCONFIG_H */ /* once: _SRC_FCONFIG_H */
#endif #endif

View File

@ -18,8 +18,8 @@ FDialog::FDialog(FWidget* parent)
, result_code(FDialog::Reject) , result_code(FDialog::Reject)
, zoom_button_pressed(false) , zoom_button_pressed(false)
, zoom_button_active(false) , zoom_button_active(false)
, TitleBarClickPos() , titlebar_click_pos()
, oldGeometry() , old_geometry()
, dialog_menu() , dialog_menu()
, dgl_menuitem() , dgl_menuitem()
, zoom_item() , zoom_item()
@ -35,8 +35,8 @@ FDialog::FDialog (const FString& txt, FWidget* parent)
, result_code(FDialog::Reject) , result_code(FDialog::Reject)
, zoom_button_pressed(false) , zoom_button_pressed(false)
, zoom_button_active(false) , zoom_button_active(false)
, TitleBarClickPos() , titlebar_click_pos()
, oldGeometry() , old_geometry()
, dialog_menu() , dialog_menu()
, dgl_menuitem() , dgl_menuitem()
, zoom_item() , zoom_item()
@ -622,9 +622,9 @@ void FDialog::onMouseDown (FMouseEvent* ev)
// click on titlebar or window: raise + activate // click on titlebar or window: raise + activate
if ( mouse_x >= 4 && mouse_x <= getWidth()-zoom_btn && mouse_y == 1 ) if ( mouse_x >= 4 && mouse_x <= getWidth()-zoom_btn && mouse_y == 1 )
TitleBarClickPos.setPoint (ev->getTermX(), ev->getTermY()); titlebar_click_pos.setPoint (ev->getTermX(), ev->getTermY());
else else
TitleBarClickPos.setPoint (0,0); titlebar_click_pos.setPoint (0,0);
has_raised = raiseWindow(); has_raised = raiseWindow();
@ -679,8 +679,8 @@ void FDialog::onMouseDown (FMouseEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FDialog::onMouseUp (FMouseEvent* ev) void FDialog::onMouseUp (FMouseEvent* ev)
{ {
int titlebar_x = TitleBarClickPos.getX(); int titlebar_x = titlebar_click_pos.getX();
int titlebar_y = TitleBarClickPos.getY(); int titlebar_y = titlebar_click_pos.getY();
int zoom_btn; int zoom_btn;
if ( (flags & fc::resizeable) == 0 ) if ( (flags & fc::resizeable) == 0 )
@ -695,15 +695,15 @@ void FDialog::onMouseUp (FMouseEvent* ev)
int mouse_x = ev->getX(); int mouse_x = ev->getX();
int mouse_y = ev->getY(); int mouse_y = ev->getY();
if ( ! TitleBarClickPos.isNull() if ( ! titlebar_click_pos.isNull()
&& titlebar_x > getTermX() + 3 && titlebar_x > getTermX() + 3
&& titlebar_x < getTermX() + getWidth() && titlebar_x < getTermX() + getWidth()
&& titlebar_y == getTermY() ) && titlebar_y == getTermY() )
{ {
FPoint currentPos(getGeometry().getX(), getGeometry().getY()); FPoint currentPos(getGeometry().getX(), getGeometry().getY());
FPoint deltaPos = ev->getTermPos() - TitleBarClickPos; FPoint deltaPos = ev->getTermPos() - titlebar_click_pos;
move (currentPos + deltaPos); move (currentPos + deltaPos);
TitleBarClickPos = ev->getTermPos(); titlebar_click_pos = ev->getTermPos();
} }
// click on titlebar menu button // click on titlebar menu button
@ -750,12 +750,12 @@ void FDialog::onMouseMove (FMouseEvent* ev)
int mouse_x = ev->getX(); int mouse_x = ev->getX();
int mouse_y = ev->getY(); int mouse_y = ev->getY();
if ( ! TitleBarClickPos.isNull() ) if ( ! titlebar_click_pos.isNull() )
{ {
FPoint currentPos(getGeometry().getX(), getGeometry().getY()); FPoint currentPos(getGeometry().getX(), getGeometry().getY());
FPoint deltaPos = ev->getTermPos() - TitleBarClickPos; FPoint deltaPos = ev->getTermPos() - titlebar_click_pos;
move (currentPos + deltaPos); move (currentPos + deltaPos);
TitleBarClickPos = ev->getTermPos(); titlebar_click_pos = ev->getTermPos();
} }
if ( dialog_menu->isVisible() && dialog_menu->isShown() ) if ( dialog_menu->isVisible() && dialog_menu->isShown() )
@ -1018,13 +1018,13 @@ void FDialog::move (int x, int y)
const FPoint& shadow = getShadow(); const FPoint& shadow = getShadow();
rsw = shadow.getX(); // right shadow width; rsw = shadow.getX(); // right shadow width;
bsh = shadow.getY(); // bottom shadow height bsh = shadow.getY(); // bottom shadow height
oldGeometry = getGeometryWithShadow(); old_geometry = getGeometryWithShadow();
FWidget::move(x,y); FWidget::move(x,y);
setPos(x, y, false); setPos(x, y, false);
putArea (getTermPos(), vwin);updateTerminal(); putArea (getTermPos(), vwin);updateTerminal();
if ( getGeometry().overlap(oldGeometry) ) if ( getGeometry().overlap(old_geometry) )
{ {
// dx > 0 : move left // dx > 0 : move left
// dx = 0 : move vertical // dx = 0 : move vertical

View File

@ -54,8 +54,8 @@ class FDialog : public FWindow
int result_code; int result_code;
bool zoom_button_pressed; bool zoom_button_pressed;
bool zoom_button_active; bool zoom_button_active;
FPoint TitleBarClickPos; FPoint titlebar_click_pos;
FRect oldGeometry; // required by move() FRect old_geometry; // required by move()
FMenu* dialog_menu; FMenu* dialog_menu;
FMenuItem* dgl_menuitem; FMenuItem* dgl_menuitem;
FMenuItem* zoom_item; FMenuItem* zoom_item;

View File

@ -166,6 +166,10 @@ class fc
LowerHalfBlock = 0x2584, // ▄ LowerHalfBlock = 0x2584, // ▄
LeftHalfBlock = 0x258c, // ▌ LeftHalfBlock = 0x258c, // ▌
RightHalfBlock = 0x2590, // ▐ RightHalfBlock = 0x2590, // ▐
BlackLowerLightTriangle = 0x25E2, // ◢
BlackLowerLeftTriangle = 0x25E3, // ◣
BlackUpperLeftTriangle = 0x25E4, // ◤
BlackUpperRightTriangle = 0x25E5, // ◥
NF_rev_left_arrow2 = 0x1ab4, // ⊐ NF_rev_left_arrow2 = 0x1ab4, // ⊐
NF_rev_right_arrow2 = 0x1ab5, // ► NF_rev_right_arrow2 = 0x1ab5, // ►
NF_radio_button3 = 0x1ab7, // ) NF_radio_button3 = 0x1ab7, // )
@ -906,7 +910,7 @@ class fc
}; };
// xterm cursor style // xterm cursor style
enum xterm_cursor_style enum xtermCursorStyle
{ {
blinking_block = 0, blinking_block = 0,
blinking_block_default = 1, blinking_block_default = 1,
@ -918,7 +922,7 @@ class fc
}; };
// linux console and framebuffer cursor style // linux console and framebuffer cursor style
enum console_cursor_style enum consoleCursorStyle
{ {
default_cursor = 0, default_cursor = 0,
invisible_cursor = 1, invisible_cursor = 1,
@ -930,7 +934,7 @@ class fc
}; };
// KDE konsole cursor style // KDE konsole cursor style
enum kde_konsole_CursorShape enum kdeKonsoleCursorShape
{ {
BlockCursor = 0, BlockCursor = 0,
IBeamCursor = 1, IBeamCursor = 1,

View File

@ -375,10 +375,24 @@ void FLabel::onMouseDown (FMouseEvent* ev)
return; return;
if ( ! (isEnabled() && accel_widget) ) if ( ! (isEnabled() && accel_widget) )
{
// send click to the parent widget
if ( FWidget* parent = getParentWidget() )
{
int b = ev->getButton();
const FPoint& tp = ev->getTermPos();
const FPoint& p = parent->termToWidgetPos(tp);
FMouseEvent* _ev = new FMouseEvent (fc::MouseDown_Event, p, tp, b);
FApplication::sendEvent (parent, _ev);
delete _ev;
}
return; return;
}
if ( ! accel_widget->hasFocus() ) if ( ! accel_widget->hasFocus() )
{ {
// focus the accelerator widget
FWidget* focused_widget = getFocusWidget(); FWidget* focused_widget = getFocusWidget();
FFocusEvent out (fc::FocusOut_Event); FFocusEvent out (fc::FocusOut_Event);
FApplication::queueEvent(focused_widget, &out); FApplication::queueEvent(focused_widget, &out);

View File

@ -17,9 +17,9 @@ FLineEdit::FLineEdit(FWidget* parent)
, text("") , text("")
, label_text("") , label_text("")
, label(new FLabel("", parent)) , label(new FLabel("", parent))
, dragScroll(FLineEdit::noScroll) , drag_scroll(FLineEdit::noScroll)
, scrollTimer(false) , scroll_timer(false)
, scrollRepeat(100) , scroll_repeat(100)
, insert_mode(true) , insert_mode(true)
, cursor_pos(0) , cursor_pos(0)
, text_offset(0) , text_offset(0)
@ -34,9 +34,9 @@ FLineEdit::FLineEdit (const FString& txt, FWidget* parent)
, text(txt) , text(txt)
, label_text("") , label_text("")
, label(new FLabel("", parent)) , label(new FLabel("", parent))
, dragScroll(FLineEdit::noScroll) , drag_scroll(FLineEdit::noScroll)
, scrollTimer(false) , scroll_timer(false)
, scrollRepeat(100) , scroll_repeat(100)
, insert_mode(true) , insert_mode(true)
, cursor_pos(0) , cursor_pos(0)
, text_offset(0) , text_offset(0)
@ -612,11 +612,11 @@ void FLineEdit::onMouseDown (FMouseEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FLineEdit::onMouseUp (FMouseEvent*) void FLineEdit::onMouseUp (FMouseEvent*)
{ {
if ( dragScroll != FLineEdit::noScroll ) if ( drag_scroll != FLineEdit::noScroll )
{ {
delOwnTimer(); delOwnTimer();
dragScroll = FLineEdit::noScroll; drag_scroll = FLineEdit::noScroll;
scrollTimer = false; scroll_timer = false;
} }
} }
@ -647,41 +647,41 @@ void FLineEdit::onMouseMove (FMouseEvent* ev)
if ( mouse_x < 2 ) if ( mouse_x < 2 )
{ {
// drag left // drag left
if ( ! scrollTimer && text_offset > 0 ) if ( ! scroll_timer && text_offset > 0 )
{ {
scrollTimer = true; scroll_timer = true;
addTimer(scrollRepeat); addTimer(scroll_repeat);
dragScroll = FLineEdit::scrollLeft; drag_scroll = FLineEdit::scrollLeft;
} }
if ( text_offset == 0 ) if ( text_offset == 0 )
{ {
delOwnTimer(); delOwnTimer();
dragScroll = FLineEdit::noScroll; drag_scroll = FLineEdit::noScroll;
} }
} }
else if ( mouse_x >= getWidth() ) else if ( mouse_x >= getWidth() )
{ {
// drag right // drag right
if ( ! scrollTimer && text_offset <= len-getWidth()+1 ) if ( ! scroll_timer && text_offset <= len-getWidth()+1 )
{ {
scrollTimer = true; scroll_timer = true;
addTimer(scrollRepeat); addTimer(scroll_repeat);
dragScroll = FLineEdit::scrollRight; drag_scroll = FLineEdit::scrollRight;
} }
if ( text_offset == len-getWidth()+2 ) if ( text_offset == len-getWidth()+2 )
{ {
delOwnTimer(); delOwnTimer();
dragScroll = FLineEdit::noScroll; drag_scroll = FLineEdit::noScroll;
} }
} }
else else
{ {
// no dragging // no dragging
delOwnTimer(); delOwnTimer();
scrollTimer = false; scroll_timer = false;
dragScroll = FLineEdit::noScroll; drag_scroll = FLineEdit::noScroll;
} }
} }
@ -690,7 +690,7 @@ void FLineEdit::onTimer (FTimerEvent*)
{ {
int len = int(text.getLength()); int len = int(text.getLength());
switch ( dragScroll ) switch ( drag_scroll )
{ {
case FLineEdit::noScroll: case FLineEdit::noScroll:
return; return;
@ -698,7 +698,7 @@ void FLineEdit::onTimer (FTimerEvent*)
case FLineEdit::scrollLeft: case FLineEdit::scrollLeft:
if ( text_offset == 0) if ( text_offset == 0)
{ {
dragScroll = FLineEdit::noScroll; drag_scroll = FLineEdit::noScroll;
return; return;
} }
@ -717,7 +717,7 @@ void FLineEdit::onTimer (FTimerEvent*)
case FLineEdit::scrollRight: case FLineEdit::scrollRight:
if ( text_offset == len-getWidth()+2 ) if ( text_offset == len-getWidth()+2 )
{ {
dragScroll = FLineEdit::noScroll; drag_scroll = FLineEdit::noScroll;
return; return;
} }

View File

@ -40,18 +40,20 @@ class FLineEdit : public FWidget
FString text; FString text;
FString label_text; FString label_text;
FLabel* label; FLabel* label;
enum drag_scroll
enum dragScroll
{ {
noScroll = 0, noScroll = 0,
scrollLeft = 1, scrollLeft = 1,
scrollRight = 2 scrollRight = 2
}; };
int dragScroll;
bool scrollTimer; dragScroll drag_scroll;
int scrollRepeat; bool scroll_timer;
bool insert_mode; int scroll_repeat;
int cursor_pos; bool insert_mode;
int text_offset; int cursor_pos;
int text_offset;
public: public:
enum label_o enum label_o
@ -59,7 +61,7 @@ class FLineEdit : public FWidget
label_above = 0, label_above = 0,
label_left = 1 label_left = 1
}; };
label_o label_orientation; label_o label_orientation;
private: private:
FLineEdit (const FLineEdit&); FLineEdit (const FLineEdit&);

View File

@ -55,16 +55,16 @@ FListBoxItem::~FListBoxItem()
FListBox::FListBox(FWidget* parent) FListBox::FListBox(FWidget* parent)
: FWidget(parent) : FWidget(parent)
, data() , data()
, VBar(0) , vbar(0)
, HBar(0) , hbar(0)
, text() , text()
, inc_search() , inc_search()
, multiSelect(false) , multi_select(false)
, mouseSelect(false) , mouse_select(false)
, dragScroll(FListBox::noScroll) , drag_scroll(FListBox::noScroll)
, scrollTimer(false) , scroll_timer(false)
, scrollRepeat(100) , scroll_repeat(100)
, scrollDistance(1) , scroll_distance(1)
, current(0) , current(0)
, last_current(-1) , last_current(-1)
, secect_from_item(-1) , secect_from_item(-1)
@ -72,7 +72,7 @@ FListBox::FListBox(FWidget* parent)
, yoffset(0) , yoffset(0)
, last_yoffset(-1) , last_yoffset(-1)
, nf_offset(0) , nf_offset(0)
, maxLineWidth(0) , max_line_width(0)
{ {
init(); init();
} }
@ -81,8 +81,8 @@ FListBox::FListBox(FWidget* parent)
FListBox::~FListBox() // destructor FListBox::~FListBox() // destructor
{ {
delOwnTimer(); delOwnTimer();
delete VBar; delete vbar;
delete HBar; delete hbar;
} }
@ -101,25 +101,25 @@ void FListBox::init()
setForegroundColor (wc.dialog_fg); setForegroundColor (wc.dialog_fg);
setBackgroundColor (wc.dialog_bg); setBackgroundColor (wc.dialog_bg);
VBar = new FScrollbar(fc::vertical, this); vbar = new FScrollbar(fc::vertical, this);
VBar->setMinimum(0); vbar->setMinimum(0);
VBar->setValue(0); vbar->setValue(0);
VBar->hide(); vbar->hide();
HBar = new FScrollbar(fc::horizontal, this); hbar = new FScrollbar(fc::horizontal, this);
HBar->setMinimum(0); hbar->setMinimum(0);
HBar->setValue(0); hbar->setValue(0);
HBar->hide(); hbar->hide();
setGeometry (1, 1, 5, 4, false); // initialize geometry values setGeometry (1, 1, 5, 4, false); // initialize geometry values
VBar->addCallback vbar->addCallback
( (
"change-value", "change-value",
_METHOD_CALLBACK (this, &FListBox::cb_VBarChange) _METHOD_CALLBACK (this, &FListBox::cb_VBarChange)
); );
HBar->addCallback hbar->addCallback
( (
"change-value", "change-value",
_METHOD_CALLBACK (this, &FListBox::cb_HBarChange) _METHOD_CALLBACK (this, &FListBox::cb_HBarChange)
@ -145,7 +145,7 @@ void FListBox::draw()
else else
drawBorder(); drawBorder();
if ( isNewFont() && ! VBar->isVisible() ) if ( isNewFont() && ! vbar->isVisible() )
{ {
setColor(); setColor();
@ -163,11 +163,11 @@ void FListBox::draw()
updateVTerm(true); updateVTerm(true);
if ( VBar->isVisible() ) if ( vbar->isVisible() )
VBar->redraw(); vbar->redraw();
if ( HBar->isVisible() ) if ( hbar->isVisible() )
HBar->redraw(); hbar->redraw();
drawList(); drawList();
isFocus = ((flags & fc::focus) != 0); isFocus = ((flags & fc::focus) != 0);
@ -521,27 +521,27 @@ void FListBox::adjustSize()
FWidget::adjustSize(); FWidget::adjustSize();
element_count = int(count()); element_count = int(count());
VBar->setMaximum(element_count - getHeight() + 2); vbar->setMaximum(element_count - getHeight() + 2);
VBar->setPageSize(element_count, getHeight() - 2); vbar->setPageSize(element_count, getHeight() - 2);
VBar->setX(getWidth()); vbar->setX(getWidth());
VBar->setHeight (getHeight()-2, false); vbar->setHeight (getHeight()-2, false);
VBar->resize(); vbar->resize();
HBar->setMaximum(maxLineWidth - getWidth() + nf_offset + 4); hbar->setMaximum(max_line_width - getWidth() + nf_offset + 4);
HBar->setPageSize(maxLineWidth, getWidth() - nf_offset - 4); hbar->setPageSize(max_line_width, getWidth() - nf_offset - 4);
HBar->setY(getHeight()); hbar->setY(getHeight());
HBar->setWidth (getWidth()-2, false); hbar->setWidth (getWidth()-2, false);
HBar->resize(); hbar->resize();
if ( element_count < getHeight() - 1 ) if ( element_count < getHeight() - 1 )
VBar->hide(); vbar->hide();
else else
VBar->setVisible(); vbar->setVisible();
if ( maxLineWidth < getWidth() - nf_offset - 3 ) if ( max_line_width < getWidth() - nf_offset - 3 )
HBar->hide(); hbar->hide();
else else
HBar->setVisible(); hbar->setVisible();
} }
// public methods of FListBox // public methods of FListBox
@ -565,7 +565,7 @@ void FListBox::setCurrentItem(int index)
xoffset = 0; xoffset = 0;
yoffset = 0; yoffset = 0;
adjustSize(); adjustSize();
VBar->setValue(yoffset); vbar->setValue(yoffset);
if ( isVisible() ) if ( isVisible() )
redraw(); redraw();
@ -622,18 +622,18 @@ void FListBox::showInsideBrackets ( int index
{ {
int len = int(data[uInt(index-1)].getText().getLength() + 2); int len = int(data[uInt(index-1)].getText().getLength() + 2);
if ( len > maxLineWidth ) if ( len > max_line_width )
{ {
maxLineWidth = len; max_line_width = len;
if ( len >= getWidth() - nf_offset - 3 ) if ( len >= getWidth() - nf_offset - 3 )
{ {
HBar->setMaximum(maxLineWidth - getWidth() + nf_offset + 4); hbar->setMaximum(max_line_width - getWidth() + nf_offset + 4);
HBar->setPageSize(maxLineWidth, getWidth() - nf_offset - 4); hbar->setPageSize(max_line_width, getWidth() - nf_offset - 4);
HBar->setValue (xoffset); hbar->setValue (xoffset);
if ( ! HBar->isVisible() ) if ( ! hbar->isVisible() )
HBar->setVisible(); hbar->setVisible();
} }
} }
} }
@ -646,13 +646,13 @@ void FListBox::setGeometry (int x, int y, int w, int h, bool adjust)
if ( isNewFont() ) if ( isNewFont() )
{ {
VBar->setGeometry (getWidth(), 2, 2, getHeight()-2); vbar->setGeometry (getWidth(), 2, 2, getHeight()-2);
HBar->setGeometry (1, getHeight(), getWidth()-2, 1); hbar->setGeometry (1, getHeight(), getWidth()-2, 1);
} }
else else
{ {
VBar->setGeometry (getWidth(), 2, 1, getHeight()-2); vbar->setGeometry (getWidth(), 2, 1, getHeight()-2);
HBar->setGeometry (2, getHeight(), getWidth()-2, 1); hbar->setGeometry (2, getHeight(), getWidth()-2, 1);
} }
} }
@ -755,8 +755,8 @@ void FListBox::onKeyPress (FKeyEvent* ev)
case fc::Fkey_right: case fc::Fkey_right:
xoffset++; xoffset++;
if ( xoffset > maxLineWidth - getWidth() + nf_offset + 4 ) if ( xoffset > max_line_width - getWidth() + nf_offset + 4 )
xoffset = maxLineWidth - getWidth() + nf_offset + 4; xoffset = max_line_width - getWidth() + nf_offset + 4;
if ( xoffset < 0 ) if ( xoffset < 0 )
xoffset = 0; xoffset = 0;
@ -979,15 +979,15 @@ void FListBox::onKeyPress (FKeyEvent* ev)
if ( isVisible() ) if ( isVisible() )
drawList(); drawList();
VBar->setValue (yoffset); vbar->setValue (yoffset);
if ( VBar->isVisible() && yoffset_before != yoffset ) if ( vbar->isVisible() && yoffset_before != yoffset )
VBar->drawBar(); vbar->drawBar();
HBar->setValue (xoffset); hbar->setValue (xoffset);
if ( HBar->isVisible() && xoffset_before != xoffset ) if ( hbar->isVisible() && xoffset_before != xoffset )
HBar->drawBar(); hbar->drawBar();
updateTerminal(); updateTerminal();
flush_out(); flush_out();
@ -1041,12 +1041,12 @@ void FListBox::onMouseDown (FMouseEvent* ev)
{ {
if ( isSelected(current) ) if ( isSelected(current) )
{ {
mouseSelect = false; mouse_select = false;
unselectItem(current); unselectItem(current);
} }
else else
{ {
mouseSelect = true; mouse_select = true;
selectItem(current); selectItem(current);
} }
@ -1058,10 +1058,10 @@ void FListBox::onMouseDown (FMouseEvent* ev)
if ( isVisible() ) if ( isVisible() )
drawList(); drawList();
VBar->setValue (yoffset); vbar->setValue (yoffset);
if ( VBar->isVisible() && yoffset_before != yoffset ) if ( vbar->isVisible() && yoffset_before != yoffset )
VBar->drawBar(); vbar->drawBar();
updateTerminal(); updateTerminal();
flush_out(); flush_out();
@ -1071,12 +1071,12 @@ void FListBox::onMouseDown (FMouseEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListBox::onMouseUp (FMouseEvent* ev) void FListBox::onMouseUp (FMouseEvent* ev)
{ {
if ( dragScroll != FListBox::noScroll ) if ( drag_scroll != FListBox::noScroll )
{ {
delOwnTimer(); delOwnTimer();
dragScroll = FListBox::noScroll; drag_scroll = FListBox::noScroll;
scrollDistance = 1; scroll_distance = 1;
scrollTimer = false; scroll_timer = false;
} }
if ( ev->getButton() == fc::LeftButton ) if ( ev->getButton() == fc::LeftButton )
@ -1143,7 +1143,7 @@ void FListBox::onMouseMove (FMouseEvent* ev)
} }
for (int i=from; i <= to; i++) for (int i=from; i <= to; i++)
{ {
if ( mouseSelect ) if ( mouse_select )
{ {
selectItem(i); selectItem(i);
processSelect(); processSelect();
@ -1161,10 +1161,10 @@ void FListBox::onMouseMove (FMouseEvent* ev)
if ( isVisible() ) if ( isVisible() )
drawList(); drawList();
VBar->setValue (yoffset); vbar->setValue (yoffset);
if ( VBar->isVisible() && yoffset_before != yoffset ) if ( vbar->isVisible() && yoffset_before != yoffset )
VBar->drawBar(); vbar->drawBar();
updateTerminal(); updateTerminal();
flush_out(); flush_out();
@ -1174,56 +1174,58 @@ void FListBox::onMouseMove (FMouseEvent* ev)
if ( mouse_y < 2 ) if ( mouse_y < 2 )
{ {
// drag up // drag up
if ( dragScroll != FListBox::noScroll && scrollDistance < getHeight()-2 ) if ( drag_scroll != FListBox::noScroll
scrollDistance++; && scroll_distance < getHeight()-2 )
scroll_distance++;
if ( ! scrollTimer && current > 1 ) if ( ! scroll_timer && current > 1 )
{ {
scrollTimer = true; scroll_timer = true;
addTimer(scrollRepeat); addTimer(scroll_repeat);
if ( ev->getButton() == fc::RightButton ) if ( ev->getButton() == fc::RightButton )
dragScroll = FListBox::scrollUpSelect; drag_scroll = FListBox::scrollUpSelect;
else else
dragScroll = FListBox::scrollUp; drag_scroll = FListBox::scrollUp;
} }
if ( current == 1 ) if ( current == 1 )
{ {
delOwnTimer(); delOwnTimer();
dragScroll = FListBox::noScroll; drag_scroll = FListBox::noScroll;
} }
} }
else if ( mouse_y >= getHeight() ) else if ( mouse_y >= getHeight() )
{ {
// drag down // drag down
if ( dragScroll != FListBox::noScroll && scrollDistance < getHeight()-2 ) if ( drag_scroll != FListBox::noScroll
scrollDistance++; && scroll_distance < getHeight()-2 )
scroll_distance++;
if ( ! scrollTimer && current < int(count()) ) if ( ! scroll_timer && current < int(count()) )
{ {
scrollTimer = true; scroll_timer = true;
addTimer(scrollRepeat); addTimer(scroll_repeat);
if ( ev->getButton() == fc::RightButton ) if ( ev->getButton() == fc::RightButton )
dragScroll = FListBox::scrollDownSelect; drag_scroll = FListBox::scrollDownSelect;
else else
dragScroll = FListBox::scrollDown; drag_scroll = FListBox::scrollDown;
} }
if ( current == int(count()) ) if ( current == int(count()) )
{ {
delOwnTimer(); delOwnTimer();
dragScroll = FListBox::noScroll; drag_scroll = FListBox::noScroll;
} }
} }
else else
{ {
// no dragging // no dragging
delOwnTimer(); delOwnTimer();
scrollTimer = false; scroll_timer = false;
scrollDistance = 1; scroll_distance = 1;
dragScroll = FListBox::noScroll; drag_scroll = FListBox::noScroll;
} }
} }
@ -1255,7 +1257,7 @@ void FListBox::onTimer (FTimerEvent*)
int current_before = current; int current_before = current;
int yoffset_before = yoffset; int yoffset_before = yoffset;
switch ( dragScroll ) switch ( drag_scroll )
{ {
case FListBox::noScroll: case FListBox::noScroll:
return; return;
@ -1264,17 +1266,17 @@ void FListBox::onTimer (FTimerEvent*)
case FListBox::scrollUpSelect: case FListBox::scrollUpSelect:
if ( current_before == 1) if ( current_before == 1)
{ {
dragScroll = FListBox::noScroll; drag_scroll = FListBox::noScroll;
return; return;
} }
current -= scrollDistance; current -= scroll_distance;
if ( current < 1 ) if ( current < 1 )
current=1; current=1;
if ( current <= yoffset ) if ( current <= yoffset )
yoffset -= scrollDistance; yoffset -= scroll_distance;
if ( yoffset < 0 ) if ( yoffset < 0 )
yoffset=0; yoffset=0;
@ -1284,17 +1286,17 @@ void FListBox::onTimer (FTimerEvent*)
case FListBox::scrollDownSelect: case FListBox::scrollDownSelect:
if ( current_before == element_count ) if ( current_before == element_count )
{ {
dragScroll = FListBox::noScroll; drag_scroll = FListBox::noScroll;
return; return;
} }
current += scrollDistance; current += scroll_distance;
if ( current > element_count ) if ( current > element_count )
current = element_count; current = element_count;
if ( current - yoffset >= getHeight() - 1 ) if ( current - yoffset >= getHeight() - 1 )
yoffset += scrollDistance; yoffset += scroll_distance;
if ( yoffset > element_count - getHeight() + 2 ) if ( yoffset > element_count - getHeight() + 2 )
yoffset = element_count - getHeight() + 2; yoffset = element_count - getHeight() + 2;
@ -1304,8 +1306,8 @@ void FListBox::onTimer (FTimerEvent*)
} }
// handle multiple selections // handle multiple selections
if ( dragScroll == FListBox::scrollUpSelect if ( drag_scroll == FListBox::scrollUpSelect
|| dragScroll == FListBox::scrollDownSelect ) || drag_scroll == FListBox::scrollDownSelect )
{ {
if ( isMultiSelection() && current_before != current ) if ( isMultiSelection() && current_before != current )
{ {
@ -1324,7 +1326,7 @@ void FListBox::onTimer (FTimerEvent*)
for (int i=from; i <= to; i++) for (int i=from; i <= to; i++)
{ {
if ( mouseSelect ) if ( mouse_select )
{ {
selectItem(i); selectItem(i);
processSelect(); processSelect();
@ -1343,10 +1345,10 @@ void FListBox::onTimer (FTimerEvent*)
if ( isVisible() ) if ( isVisible() )
drawList(); drawList();
VBar->setValue (yoffset); vbar->setValue (yoffset);
if ( VBar->isVisible() && yoffset_before != yoffset ) if ( vbar->isVisible() && yoffset_before != yoffset )
VBar->drawBar(); vbar->drawBar();
updateTerminal(); updateTerminal();
flush_out(); flush_out();
@ -1366,12 +1368,12 @@ void FListBox::onWheel (FWheelEvent* ev)
wheel = ev->getWheel(); wheel = ev->getWheel();
if ( dragScroll != FListBox::noScroll ) if ( drag_scroll != FListBox::noScroll )
{ {
delOwnTimer(); delOwnTimer();
scrollTimer = false; scroll_timer = false;
scrollDistance = 1; scroll_distance = 1;
dragScroll = FListBox::noScroll; drag_scroll = FListBox::noScroll;
} }
switch ( wheel ) switch ( wheel )
@ -1431,10 +1433,10 @@ void FListBox::onWheel (FWheelEvent* ev)
if ( isVisible() ) if ( isVisible() )
drawList(); drawList();
VBar->setValue (yoffset); vbar->setValue (yoffset);
if ( VBar->isVisible() && yoffset_before != yoffset ) if ( vbar->isVisible() && yoffset_before != yoffset )
VBar->drawBar(); vbar->drawBar();
updateTerminal(); updateTerminal();
flush_out(); flush_out();
@ -1468,7 +1470,7 @@ void FListBox::cb_VBarChange (FWidget*, void*)
int distance = 1; int distance = 1;
int element_count = int(count()); int element_count = int(count());
int yoffset_before = yoffset; int yoffset_before = yoffset;
int scrollType = VBar->getScrollType(); int scrollType = vbar->getScrollType();
switch ( scrollType ) switch ( scrollType )
{ {
@ -1508,7 +1510,7 @@ void FListBox::cb_VBarChange (FWidget*, void*)
case FScrollbar::scrollJump: case FScrollbar::scrollJump:
{ {
int val = VBar->getValue(); int val = vbar->getValue();
if ( yoffset == val ) if ( yoffset == val )
break; break;
@ -1557,10 +1559,10 @@ void FListBox::cb_VBarChange (FWidget*, void*)
if ( scrollType >= FScrollbar::scrollStepBackward if ( scrollType >= FScrollbar::scrollStepBackward
&& scrollType <= FScrollbar::scrollPageForward ) && scrollType <= FScrollbar::scrollPageForward )
{ {
VBar->setValue (yoffset); vbar->setValue (yoffset);
if ( VBar->isVisible() && yoffset_before != yoffset ) if ( vbar->isVisible() && yoffset_before != yoffset )
VBar->drawBar(); vbar->drawBar();
updateTerminal(); updateTerminal();
flush_out(); flush_out();
@ -1572,8 +1574,8 @@ void FListBox::cb_HBarChange (FWidget*, void*)
{ {
int distance = 1; int distance = 1;
int xoffset_before = xoffset; int xoffset_before = xoffset;
int xoffset_end = maxLineWidth - getWidth() + nf_offset + 4; int xoffset_end = max_line_width - getWidth() + nf_offset + 4;
int scrollType = HBar->getScrollType(); int scrollType = hbar->getScrollType();
switch ( scrollType ) switch ( scrollType )
{ {
@ -1593,8 +1595,8 @@ void FListBox::cb_HBarChange (FWidget*, void*)
case FScrollbar::scrollStepForward: case FScrollbar::scrollStepForward:
xoffset += distance; xoffset += distance;
if ( xoffset > maxLineWidth - getWidth() + nf_offset + 4 ) if ( xoffset > max_line_width - getWidth() + nf_offset + 4 )
xoffset = maxLineWidth - getWidth() + nf_offset + 4; xoffset = max_line_width - getWidth() + nf_offset + 4;
if ( xoffset < 0 ) if ( xoffset < 0 )
xoffset = 0; xoffset = 0;
@ -1603,15 +1605,15 @@ void FListBox::cb_HBarChange (FWidget*, void*)
case FScrollbar::scrollJump: case FScrollbar::scrollJump:
{ {
int val = HBar->getValue(); int val = hbar->getValue();
if ( xoffset == val ) if ( xoffset == val )
break; break;
xoffset = val; xoffset = val;
if ( xoffset > maxLineWidth - getWidth() + nf_offset + 4 ) if ( xoffset > max_line_width - getWidth() + nf_offset + 4 )
xoffset = maxLineWidth - getWidth() + nf_offset + 4; xoffset = max_line_width - getWidth() + nf_offset + 4;
if ( xoffset < 0 ) if ( xoffset < 0 )
xoffset = 0; xoffset = 0;
@ -1655,10 +1657,10 @@ void FListBox::cb_HBarChange (FWidget*, void*)
if ( scrollType >= FScrollbar::scrollStepBackward if ( scrollType >= FScrollbar::scrollStepBackward
&& scrollType <= FScrollbar::scrollWheelDown ) && scrollType <= FScrollbar::scrollWheelDown )
{ {
HBar->setValue (xoffset); hbar->setValue (xoffset);
if ( HBar->isVisible() && xoffset_before != xoffset ) if ( hbar->isVisible() && xoffset_before != xoffset )
HBar->drawBar(); hbar->drawBar();
updateTerminal(); updateTerminal();
flush_out(); flush_out();
@ -1677,18 +1679,18 @@ void FListBox::insert ( FString item
if ( b ) if ( b )
len += 2; len += 2;
if ( len > maxLineWidth ) if ( len > max_line_width )
{ {
maxLineWidth = len; max_line_width = len;
if ( len >= getWidth() - nf_offset - 3 ) if ( len >= getWidth() - nf_offset - 3 )
{ {
HBar->setMaximum(maxLineWidth - getWidth() + nf_offset + 4); hbar->setMaximum(max_line_width - getWidth() + nf_offset + 4);
HBar->setPageSize(maxLineWidth, getWidth() - nf_offset - 4); hbar->setPageSize(max_line_width, getWidth() - nf_offset - 4);
HBar->calculateSliderValues(); hbar->calculateSliderValues();
if ( ! HBar->isVisible() ) if ( ! hbar->isVisible() )
HBar->setVisible(); hbar->setVisible();
} }
} }
FListBoxItem listItem (item); FListBoxItem listItem (item);
@ -1697,12 +1699,12 @@ void FListBox::insert ( FString item
data.push_back (listItem); data.push_back (listItem);
element_count = int(count()); element_count = int(count());
VBar->setMaximum(element_count - getHeight() + 2); vbar->setMaximum(element_count - getHeight() + 2);
VBar->setPageSize(element_count, getHeight() - 2); vbar->setPageSize(element_count, getHeight() - 2);
VBar->calculateSliderValues(); vbar->calculateSliderValues();
if ( ! VBar->isVisible() && element_count >= getHeight() - 1 ) if ( ! vbar->isVisible() && element_count >= getHeight() - 1 )
VBar->setVisible(); vbar->setVisible();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1723,27 +1725,27 @@ void FListBox::remove (int item)
data.erase (data.begin() + item - 1); data.erase (data.begin() + item - 1);
element_count = int(count()); element_count = int(count());
maxLineWidth = 0; max_line_width = 0;
for (int i=0; i < element_count; i++) for (int i=0; i < element_count; i++)
{ {
int len = int(data[uInt(i)].getText().getLength()); int len = int(data[uInt(i)].getText().getLength());
if ( len > maxLineWidth ) if ( len > max_line_width )
maxLineWidth = len; max_line_width = len;
} }
HBar->setMaximum(maxLineWidth - getWidth() + nf_offset + 4); hbar->setMaximum(max_line_width - getWidth() + nf_offset + 4);
HBar->setPageSize(maxLineWidth, getWidth() - nf_offset - 4); hbar->setPageSize(max_line_width, getWidth() - nf_offset - 4);
if ( HBar->isVisible() && maxLineWidth < getWidth() - nf_offset - 3 ) if ( hbar->isVisible() && max_line_width < getWidth() - nf_offset - 3 )
HBar->hide(); hbar->hide();
VBar->setMaximum(element_count - getHeight() + 2); vbar->setMaximum(element_count - getHeight() + 2);
VBar->setPageSize(element_count, getHeight() - 2); vbar->setPageSize(element_count, getHeight() - 2);
if ( VBar->isVisible() && element_count < getHeight() - 1 ) if ( vbar->isVisible() && element_count < getHeight() - 1 )
VBar->hide(); vbar->hide();
if ( current >= item && current > 1 ) if ( current >= item && current > 1 )
current--; current--;
@ -1769,17 +1771,17 @@ void FListBox::clear()
current = 0; current = 0;
xoffset = 0; xoffset = 0;
yoffset = 0; yoffset = 0;
maxLineWidth = 0; max_line_width = 0;
last_current = -1; last_current = -1;
last_yoffset = -1; last_yoffset = -1;
VBar->setMinimum(0); vbar->setMinimum(0);
VBar->setValue(0); vbar->setValue(0);
VBar->hide(); vbar->hide();
HBar->setMinimum(0); hbar->setMinimum(0);
HBar->setValue(0); hbar->setValue(0);
HBar->hide(); hbar->hide();
// clear list from screen // clear list from screen
setColor (wc.list_fg, wc.list_bg); setColor (wc.list_fg, wc.list_bg);

View File

@ -40,9 +40,9 @@
class FListBoxItem class FListBoxItem
{ {
private: private:
FString text; FString text;
fc::brackets_type brackets; fc::brackets_type brackets;
bool selected; bool selected;
public: public:
FListBoxItem (); FListBoxItem ();
@ -90,7 +90,7 @@ inline void FListBoxItem::setText (const char* txt)
class FListBox : public FWidget class FListBox : public FWidget
{ {
private: private:
enum drag_scroll enum dragScroll
{ {
noScroll = 0, noScroll = 0,
scrollUp = 1, scrollUp = 1,
@ -98,17 +98,18 @@ class FListBox : public FWidget
scrollUpSelect = 3, scrollUpSelect = 3,
scrollDownSelect = 4 scrollDownSelect = 4
}; };
std::vector<FListBoxItem> data; std::vector<FListBoxItem> data;
FScrollbar* VBar; FScrollbar* vbar;
FScrollbar* HBar; FScrollbar* hbar;
FString text; FString text;
FString inc_search; FString inc_search;
bool multiSelect; bool multi_select;
bool mouseSelect; bool mouse_select;
int dragScroll; dragScroll drag_scroll;
bool scrollTimer; bool scroll_timer;
int scrollRepeat; int scroll_repeat;
int scrollDistance; int scroll_distance;
int current; int current;
int last_current; int last_current;
int secect_from_item; int secect_from_item;
@ -116,7 +117,7 @@ class FListBox : public FWidget
int yoffset; int yoffset;
int last_yoffset; int last_yoffset;
int nf_offset; int nf_offset;
int maxLineWidth; int max_line_width;
private: private:
FListBox (const FListBox&); FListBox (const FListBox&);
@ -232,7 +233,7 @@ inline bool FListBox::hasBrackets(int index) const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FListBox::setMultiSelection (bool on) inline void FListBox::setMultiSelection (bool on)
{ multiSelect = on; } { multi_select = on; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FListBox::setMultiSelection() inline void FListBox::setMultiSelection()
@ -244,7 +245,7 @@ inline void FListBox::unsetMultiSelection()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FListBox::isMultiSelection() const inline bool FListBox::isMultiSelection() const
{ return multiSelect; } { return multi_select; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FListBox::setEnable() inline bool FListBox::setEnable()

View File

@ -17,7 +17,7 @@ FMenu::FMenu(FWidget* parent)
, item(0) , item(0)
, super_menu(0) , super_menu(0)
, open_sub_menu(0) , open_sub_menu(0)
, maxItemWidth(0) , max_item_width(0)
, mouse_down(false) , mouse_down(false)
, has_checkable_items(false) , has_checkable_items(false)
{ {
@ -30,7 +30,7 @@ FMenu::FMenu (FString& txt, FWidget* parent)
, item(0) , item(0)
, super_menu(0) , super_menu(0)
, open_sub_menu(0) , open_sub_menu(0)
, maxItemWidth(0) , max_item_width(0)
, mouse_down(false) , mouse_down(false)
, has_checkable_items(false) , has_checkable_items(false)
{ {
@ -44,7 +44,7 @@ FMenu::FMenu (const std::string& txt, FWidget* parent)
, item(0) , item(0)
, super_menu(0) , super_menu(0)
, open_sub_menu(0) , open_sub_menu(0)
, maxItemWidth(0) , max_item_width(0)
, mouse_down(false) , mouse_down(false)
, has_checkable_items(false) , has_checkable_items(false)
{ {
@ -58,7 +58,7 @@ FMenu::FMenu (const char* txt, FWidget* parent)
, item(0) , item(0)
, super_menu(0) , super_menu(0)
, open_sub_menu(0) , open_sub_menu(0)
, maxItemWidth(0) , max_item_width(0)
, mouse_down(false) , mouse_down(false)
, has_checkable_items(false) , has_checkable_items(false)
{ {
@ -124,30 +124,30 @@ void FMenu::init(FWidget* parent)
FMenuBar* mbar = dynamic_cast<FMenuBar*>(parent); FMenuBar* mbar = dynamic_cast<FMenuBar*>(parent);
if ( mbar ) if ( mbar )
mbar->menu_dimension(); mbar->calculateDimensions();
} }
else if ( isMenu(parent) ) else if ( isMenu(parent) )
{ {
FMenu* smenu = dynamic_cast<FMenu*>(parent); FMenu* smenu = dynamic_cast<FMenu*>(parent);
if ( smenu ) if ( smenu )
smenu->menu_dimension(); smenu->calculateDimensions();
} }
setSuperMenu(parent); setSuperMenu(parent);
} }
menu_dimension(); calculateDimensions();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenu::menu_dimension() void FMenu::calculateDimensions()
{ {
int item_X, item_Y, adjust_X; int item_X, item_Y, adjust_X;
std::vector<FMenuItem*>::const_iterator iter, end; std::vector<FMenuItem*>::const_iterator iter, end;
iter = itemlist.begin(); iter = item_list.begin();
end = itemlist.end(); end = item_list.end();
maxItemWidth = 10; // minimum width max_item_width = 10; // minimum width
// find the maximum item width // find the maximum item width
while ( iter != end ) while ( iter != end )
@ -169,8 +169,8 @@ void FMenu::menu_dimension()
if ( has_checkable_items ) if ( has_checkable_items )
item_width++; item_width++;
if ( item_width > maxItemWidth ) if ( item_width > max_item_width )
maxItemWidth = item_width; max_item_width = item_width;
++iter; ++iter;
} }
@ -178,20 +178,20 @@ void FMenu::menu_dimension()
adjust_X = adjustX(getX()); adjust_X = adjustX(getX());
// set widget geometry // set widget geometry
setGeometry (adjust_X, getY(), int(maxItemWidth + 2), int(count() + 2)); setGeometry (adjust_X, getY(), int(max_item_width + 2), int(count() + 2));
// set geometry of all items // set geometry of all items
iter = itemlist.begin(); iter = item_list.begin();
item_X = 1; item_X = 1;
item_Y = 1; item_Y = 1;
while ( iter != end ) while ( iter != end )
{ {
(*iter)->setGeometry (item_X, item_Y, int(maxItemWidth), 1); (*iter)->setGeometry (item_X, item_Y, int(max_item_width), 1);
if ( (*iter)->hasMenu() ) if ( (*iter)->hasMenu() )
{ {
int menu_X = getTermX() + int(maxItemWidth) + 1; int menu_X = getTermX() + int(max_item_width) + 1;
int menu_Y = (*iter)->getTermY() - 2; int menu_Y = (*iter)->getTermY() - 2;
// set sub-menu position // set sub-menu position
(*iter)->getMenu()->setPos (menu_X, menu_Y, false); (*iter)->getMenu()->setPos (menu_X, menu_Y, false);
@ -206,8 +206,8 @@ void FMenu::menu_dimension()
void FMenu::adjustItems() void FMenu::adjustItems()
{ {
std::vector<FMenuItem*>::const_iterator end, iter; std::vector<FMenuItem*>::const_iterator end, iter;
iter = itemlist.begin(); iter = item_list.begin();
end = itemlist.end(); end = item_list.end();
while ( iter != end ) while ( iter != end )
{ {
@ -216,7 +216,7 @@ void FMenu::adjustItems()
int menu_X, menu_Y; int menu_X, menu_Y;
FMenu* menu = (*iter)->getMenu(); FMenu* menu = (*iter)->getMenu();
menu_X = getTermX() + int(maxItemWidth) + 1; menu_X = getTermX() + int(max_item_width) + 1;
menu_X = menu->adjustX(menu_X); menu_X = menu->adjustX(menu_X);
menu_Y = (*iter)->getTermY() - 2; menu_Y = (*iter)->getTermY() - 2;
@ -236,9 +236,9 @@ void FMenu::adjustItems()
int FMenu::adjustX (int x_pos) int FMenu::adjustX (int x_pos)
{ {
// Is menu outside on the right of the screen? // Is menu outside on the right of the screen?
if ( x_pos+int(maxItemWidth) >= getColumnNumber()-1 ) if ( x_pos+int(max_item_width) >= getColumnNumber()-1 )
{ {
x_pos = getColumnNumber() - int(maxItemWidth + 1); x_pos = getColumnNumber() - int(max_item_width + 1);
// Menu to large for the screen // Menu to large for the screen
if ( x_pos < 1 ) if ( x_pos < 1 )
x_pos = 1; x_pos = 1;
@ -396,8 +396,8 @@ FMenu* FMenu::superMenuAt (int x, int y)
bool FMenu::selectNextItem() bool FMenu::selectNextItem()
{ {
std::vector<FMenuItem*>::const_iterator iter, end; std::vector<FMenuItem*>::const_iterator iter, end;
iter = itemlist.begin(); iter = item_list.begin();
end = itemlist.end(); end = item_list.end();
while ( iter != end ) while ( iter != end )
{ {
@ -410,8 +410,8 @@ bool FMenu::selectNextItem()
do do
{ {
++next_element; ++next_element;
if ( next_element == itemlist.end() ) if ( next_element == item_list.end() )
next_element = itemlist.begin(); next_element = item_list.begin();
next = static_cast<FMenuItem*>(*next_element); next = static_cast<FMenuItem*>(*next_element);
} }
while ( ! next->isEnabled() while ( ! next->isEnabled()
@ -446,8 +446,8 @@ bool FMenu::selectNextItem()
bool FMenu::selectPrevItem() bool FMenu::selectPrevItem()
{ {
std::vector<FMenuItem*>::const_iterator iter, begin; std::vector<FMenuItem*>::const_iterator iter, begin;
iter = itemlist.end(); iter = item_list.end();
begin = itemlist.begin(); begin = item_list.begin();
do do
{ {
@ -461,8 +461,8 @@ bool FMenu::selectPrevItem()
do do
{ {
if ( prev_element == itemlist.begin() ) if ( prev_element == item_list.begin() )
prev_element = itemlist.end(); prev_element = item_list.end();
--prev_element; --prev_element;
prev = static_cast<FMenuItem*>(*prev_element); prev = static_cast<FMenuItem*>(*prev_element);
} }
@ -506,8 +506,8 @@ void FMenu::keypressMenuBar (FKeyEvent*& ev)
bool FMenu::hotkeyMenu (FKeyEvent*& ev) bool FMenu::hotkeyMenu (FKeyEvent*& ev)
{ {
std::vector<FMenuItem*>::const_iterator iter, end; std::vector<FMenuItem*>::const_iterator iter, end;
iter = itemlist.begin(); iter = item_list.begin();
end = itemlist.end(); end = item_list.end();
while ( iter != end ) while ( iter != end )
{ {
@ -695,8 +695,8 @@ void FMenu::drawItems()
std::vector<FMenuItem*>::const_iterator iter, end; std::vector<FMenuItem*>::const_iterator iter, end;
int c = 0; int c = 0;
int y = 0; int y = 0;
iter = itemlist.begin(); iter = item_list.begin();
end = itemlist.end(); end = item_list.end();
if ( has_checkable_items ) if ( has_checkable_items )
c = 1; c = 1;
@ -851,33 +851,33 @@ void FMenu::drawItems()
if ( has_menu ) if ( has_menu )
{ {
int len = int(maxItemWidth) - (to_char + c + 3); int len = int(max_item_width) - (to_char + c + 3);
if ( len > 0 ) if ( len > 0 )
{ {
print (FString(len, wchar_t(' '))); print (FString(len, wchar_t(' ')));
// BlackRightPointingPointer ► // BlackRightPointingPointer ►
print (wchar_t(fc::BlackRightPointingPointer)); print (wchar_t(fc::BlackRightPointingPointer));
to_char = int(maxItemWidth) - (c + 2); to_char = int(max_item_width) - (c + 2);
} }
} }
else if ( accel_key ) else if ( accel_key )
{ {
FString accel_name (getKeyName(accel_key)); FString accel_name (getKeyName(accel_key));
int accel_len = int(accel_name.getLength()); int accel_len = int(accel_name.getLength());
int len = int(maxItemWidth) - (to_char + accel_len + c + 2); int len = int(max_item_width) - (to_char + accel_len + c + 2);
if ( len > 0 ) if ( len > 0 )
{ {
FString spaces (len, wchar_t(' ')); FString spaces (len, wchar_t(' '));
print (spaces + accel_name); print (spaces + accel_name);
to_char = int(maxItemWidth) - (c + 2); to_char = int(max_item_width) - (c + 2);
} }
} }
if ( is_selected ) if ( is_selected )
{ {
for (uInt i=uInt(to_char+c); i < maxItemWidth-1; i++) for (uInt i=uInt(to_char+c); i < max_item_width - 1; i++)
print (' '); print (' ');
} }
@ -1105,15 +1105,15 @@ void FMenu::onMouseDown (FMouseEvent* ev)
mouse_down = true; mouse_down = true;
if ( ! itemlist.empty() ) if ( ! item_list.empty() )
{ {
std::vector<FMenuItem*>::const_iterator iter, end; std::vector<FMenuItem*>::const_iterator iter, end;
FMenu* show_sub_menu = 0; FMenu* show_sub_menu = 0;
bool focus_changed = false; bool focus_changed = false;
FPoint mouse_pos; FPoint mouse_pos;
iter = itemlist.begin(); iter = item_list.begin();
end = itemlist.end(); end = item_list.end();
mouse_pos = ev->getPos(); mouse_pos = ev->getPos();
mouse_pos -= FPoint(getRightPadding(),getTopPadding()); mouse_pos -= FPoint(getRightPadding(),getTopPadding());
@ -1213,12 +1213,12 @@ void FMenu::onMouseUp (FMouseEvent* ev)
{ {
mouse_down = false; mouse_down = false;
if ( ! itemlist.empty() ) if ( ! item_list.empty() )
{ {
std::vector<FMenuItem*>::const_iterator iter, end; std::vector<FMenuItem*>::const_iterator iter, end;
FPoint mouse_pos; FPoint mouse_pos;
iter = itemlist.begin(); iter = item_list.begin();
end = itemlist.end(); end = item_list.end();
mouse_pos = ev->getPos(); mouse_pos = ev->getPos();
mouse_pos -= FPoint(getRightPadding(),getTopPadding()); mouse_pos -= FPoint(getRightPadding(),getTopPadding());
@ -1292,7 +1292,7 @@ void FMenu::onMouseMove (FMouseEvent* ev)
if ( ! isActiveWindow() ) if ( ! isActiveWindow() )
setActiveWindow(this); setActiveWindow(this);
if ( mouse_down && ! itemlist.empty() ) if ( mouse_down && ! item_list.empty() )
{ {
std::vector<FMenuItem*>::const_iterator iter, end; std::vector<FMenuItem*>::const_iterator iter, end;
FMenu* smenu = 0; FMenu* smenu = 0;
@ -1305,8 +1305,8 @@ void FMenu::onMouseMove (FMouseEvent* ev)
FMenu* show_sub_menu = 0; FMenu* show_sub_menu = 0;
FPoint mouse_pos; FPoint mouse_pos;
iter = itemlist.begin(); iter = item_list.begin();
end = itemlist.end(); end = item_list.end();
mouse_pos = ev->getPos(); mouse_pos = ev->getPos();
mouse_pos -= FPoint(getRightPadding(),getTopPadding()); mouse_pos -= FPoint(getRightPadding(),getTopPadding());
@ -1572,11 +1572,11 @@ void FMenu::cb_menuitem_toggled (FWidget* widget, void*)
if ( ! menuitem->isChecked() ) if ( ! menuitem->isChecked() )
return; return;
if ( itemlist.empty() ) if ( item_list.empty() )
return; return;
iter = itemlist.begin(); iter = item_list.begin();
end = itemlist.end(); end = item_list.end();
while ( iter != end ) while ( iter != end )
{ {

View File

@ -49,7 +49,7 @@ class FMenu : public FWindow, public FMenuList
FMenuItem* item; FMenuItem* item;
FWidget* super_menu; FWidget* super_menu;
FMenu* open_sub_menu; FMenu* open_sub_menu;
uInt maxItemWidth; uInt max_item_width;
bool mouse_down; bool mouse_down;
bool has_checkable_items; bool has_checkable_items;
@ -57,7 +57,7 @@ class FMenu : public FWindow, public FMenuList
FMenu (const FMenu&); FMenu (const FMenu&);
FMenu& operator = (const FMenu&); FMenu& operator = (const FMenu&);
void init(FWidget*); void init(FWidget*);
void menu_dimension(); void calculateDimensions();
void adjustItems(); void adjustItems();
int adjustX(int); int adjustX(int);
bool isWindowsMenu (FWidget*) const; bool isWindowsMenu (FWidget*) const;

View File

@ -61,13 +61,13 @@ void FMenuBar::init()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuBar::menu_dimension() void FMenuBar::calculateDimensions()
{ {
int item_X = 1; int item_X = 1;
int item_Y = 1; int item_Y = 1;
std::vector<FMenuItem*>::const_iterator end, iter; std::vector<FMenuItem*>::const_iterator end, iter;
iter = itemlist.begin(); iter = item_list.begin();
end = itemlist.end(); end = item_list.end();
// find the maximum item width // find the maximum item width
while ( iter != end ) while ( iter != end )
@ -98,8 +98,8 @@ bool FMenuBar::isMenu (FMenuItem* mi) const
bool FMenuBar::selectNextItem() bool FMenuBar::selectNextItem()
{ {
std::vector<FMenuItem*>::const_iterator iter, end; std::vector<FMenuItem*>::const_iterator iter, end;
iter = itemlist.begin(); iter = item_list.begin();
end = itemlist.end(); end = item_list.end();
while ( iter != end ) while ( iter != end )
{ {
@ -113,8 +113,8 @@ bool FMenuBar::selectNextItem()
{ {
++next_element; ++next_element;
if ( next_element == itemlist.end() ) if ( next_element == item_list.end() )
next_element = itemlist.begin(); next_element = item_list.begin();
next = static_cast<FMenuItem*>(*next_element); next = static_cast<FMenuItem*>(*next_element);
} while ( ! next->isEnabled() } while ( ! next->isEnabled()
@ -161,8 +161,8 @@ bool FMenuBar::selectNextItem()
bool FMenuBar::selectPrevItem() bool FMenuBar::selectPrevItem()
{ {
std::vector<FMenuItem*>::const_iterator iter, begin; std::vector<FMenuItem*>::const_iterator iter, begin;
iter = itemlist.end(); iter = item_list.end();
begin = itemlist.begin(); begin = item_list.begin();
do do
{ {
@ -176,8 +176,8 @@ bool FMenuBar::selectPrevItem()
do do
{ {
if ( prev_element == itemlist.begin() ) if ( prev_element == item_list.begin() )
prev_element = itemlist.end(); prev_element = item_list.end();
--prev_element; --prev_element;
prev = static_cast<FMenuItem*>(*prev_element); prev = static_cast<FMenuItem*>(*prev_element);
@ -225,8 +225,8 @@ bool FMenuBar::selectPrevItem()
bool FMenuBar::hotkeyMenu (FKeyEvent*& ev) bool FMenuBar::hotkeyMenu (FKeyEvent*& ev)
{ {
std::vector<FMenuItem*>::const_iterator iter, end; std::vector<FMenuItem*>::const_iterator iter, end;
iter = itemlist.begin(); iter = item_list.begin();
end = itemlist.end(); end = item_list.end();
while ( iter != end ) while ( iter != end )
{ {
@ -322,7 +322,7 @@ void FMenuBar::drawItems()
int x = 1; int x = 1;
screenWidth = getColumnNumber(); screenWidth = getColumnNumber();
if ( itemlist.empty() ) if ( item_list.empty() )
return; return;
updateVTerm(false); updateVTerm(false);
@ -331,8 +331,8 @@ void FMenuBar::drawItems()
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
iter = itemlist.begin(); iter = item_list.begin();
end = itemlist.end(); end = item_list.end();
while ( iter != end ) while ( iter != end )
{ {
@ -476,8 +476,8 @@ void FMenuBar::adjustItems()
int item_X = 1; int item_X = 1;
int item_Y = 1; int item_Y = 1;
std::vector<FMenuItem*>::const_iterator end, iter; std::vector<FMenuItem*>::const_iterator end, iter;
iter = itemlist.begin(); iter = item_list.begin();
end = itemlist.end(); end = item_list.end();
while ( iter != end ) while ( iter != end )
{ {
@ -592,7 +592,7 @@ void FMenuBar::onMouseDown (FMouseEvent* ev)
{ {
mouse_down = false; mouse_down = false;
if ( ! itemlist.empty() && hasSelectedItem() ) if ( ! item_list.empty() && hasSelectedItem() )
leaveMenuBar(); leaveMenuBar();
else else
return; return;
@ -611,14 +611,14 @@ void FMenuBar::onMouseDown (FMouseEvent* ev)
if ( ! isActiveWindow() ) if ( ! isActiveWindow() )
setActiveWindow(this); setActiveWindow(this);
if ( ! itemlist.empty() ) if ( ! item_list.empty() )
{ {
std::vector<FMenuItem*>::const_iterator iter, end; std::vector<FMenuItem*>::const_iterator iter, end;
int mouse_x, mouse_y; int mouse_x, mouse_y;
bool focus_changed = false; bool focus_changed = false;
iter = itemlist.begin(); iter = item_list.begin();
end = itemlist.end(); end = item_list.end();
mouse_x = ev->getX(); mouse_x = ev->getX();
mouse_y = ev->getY(); mouse_y = ev->getY();
@ -696,12 +696,12 @@ void FMenuBar::onMouseUp (FMouseEvent* ev)
{ {
mouse_down = false; mouse_down = false;
if ( ! itemlist.empty() ) if ( ! item_list.empty() )
{ {
int mouse_x, mouse_y; int mouse_x, mouse_y;
std::vector<FMenuItem*>::const_iterator iter, end; std::vector<FMenuItem*>::const_iterator iter, end;
iter = itemlist.begin(); iter = item_list.begin();
end = itemlist.end(); end = item_list.end();
mouse_x = ev->getX(); mouse_x = ev->getX();
mouse_y = ev->getY(); mouse_y = ev->getY();
@ -784,14 +784,14 @@ void FMenuBar::onMouseMove (FMouseEvent* ev)
if ( ! isActiveWindow() ) if ( ! isActiveWindow() )
setActiveWindow(this); setActiveWindow(this);
if ( mouse_down && ! itemlist.empty() ) if ( mouse_down && ! item_list.empty() )
{ {
std::vector<FMenuItem*>::const_iterator iter, end; std::vector<FMenuItem*>::const_iterator iter, end;
int mouse_x, mouse_y; int mouse_x, mouse_y;
bool mouse_over_menubar = false; bool mouse_over_menubar = false;
bool focus_changed = false; bool focus_changed = false;
iter = itemlist.begin(); iter = item_list.begin();
end = itemlist.end(); end = item_list.end();
mouse_x = ev->getX(); mouse_x = ev->getX();
mouse_y = ev->getY(); mouse_y = ev->getY();

View File

@ -52,7 +52,7 @@ class FMenuBar : public FWindow, public FMenuList
FMenuBar (const FMenuBar&); FMenuBar (const FMenuBar&);
FMenuBar& operator = (const FMenuBar&); FMenuBar& operator = (const FMenuBar&);
void init(); void init();
void menu_dimension(); void calculateDimensions();
bool isMenu (FMenuItem*) const; bool isMenu (FMenuItem*) const;
bool selectNextItem(); bool selectNextItem();
bool selectPrevItem(); bool selectPrevItem();

View File

@ -196,7 +196,7 @@ void FMenuItem::init (FWidget* parent)
if ( menubar_ptr ) if ( menubar_ptr )
{ {
menubar_ptr->menu_dimension(); menubar_ptr->calculateDimensions();
if ( hotkey ) // Meta + hotkey if ( hotkey ) // Meta + hotkey
menubar_ptr->addAccelerator (fc::Fmkey_meta + tolower(hotkey), this); menubar_ptr->addAccelerator (fc::Fmkey_meta + tolower(hotkey), this);
@ -213,7 +213,7 @@ void FMenuItem::init (FWidget* parent)
FMenu* menu_ptr = dynamic_cast<FMenu*>(parent); FMenu* menu_ptr = dynamic_cast<FMenu*>(parent);
if ( menu_ptr ) if ( menu_ptr )
menu_ptr->menu_dimension(); menu_ptr->calculateDimensions();
} }
} }
@ -307,7 +307,7 @@ void FMenuItem::createDialogList (FMenu* winmenu)
} }
} }
winmenu->menu_dimension(); winmenu->calculateDimensions();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -393,7 +393,7 @@ void FMenuItem::addAccelerator (int key, FWidget* obj)
FMenu* menu_ptr = dynamic_cast<FMenu*>(super_menu); FMenu* menu_ptr = dynamic_cast<FMenu*>(super_menu);
if ( menu_ptr ) if ( menu_ptr )
menu_ptr->menu_dimension(); menu_ptr->calculateDimensions();
} }
} }
@ -426,7 +426,7 @@ void FMenuItem::delAccelerator (FWidget* obj)
FMenu* menu_ptr = dynamic_cast<FMenu*>(super_menu); FMenu* menu_ptr = dynamic_cast<FMenu*>(super_menu);
if ( menu_ptr ) if ( menu_ptr )
menu_ptr->menu_dimension(); menu_ptr->calculateDimensions();
} }
} }
@ -673,7 +673,7 @@ void FMenuItem::onAccel (FAccelEvent* ev)
mbar->getSelectedItem()->unsetSelected(); mbar->getSelectedItem()->unsetSelected();
setSelected(); setSelected();
mbar->selectedItem = this; mbar->selected_item = this;
openMenu(); openMenu();
focused_widget = static_cast<FWidget*>(ev->focusedWidget()); focused_widget = static_cast<FWidget*>(ev->focusedWidget());
@ -699,7 +699,7 @@ void FMenuItem::onAccel (FAccelEvent* ev)
else else
{ {
unsetSelected(); unsetSelected();
mbar->selectedItem = 0; mbar->selected_item = 0;
mbar->redraw(); mbar->redraw();
processClicked(); processClicked();
mbar->drop_down = false; mbar->drop_down = false;

View File

@ -10,23 +10,23 @@
// constructor and destructor // constructor and destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FMenuList::FMenuList() FMenuList::FMenuList()
: selectedItem() : selected_item()
, itemlist() , item_list()
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FMenuList::~FMenuList() // destructor FMenuList::~FMenuList() // destructor
{ {
// delete all items // delete all items
if ( ! itemlist.empty() ) if ( ! item_list.empty() )
{ {
std::vector<FMenuItem*>::iterator iter; std::vector<FMenuItem*>::iterator iter;
iter = itemlist.begin(); iter = item_list.begin();
while ( iter != itemlist.end() ) while ( iter != item_list.end() )
{ {
(*iter)->setSuperMenu(0); (*iter)->setSuperMenu(0);
iter = itemlist.erase(iter); iter = item_list.erase(iter);
} }
} }
} }
@ -37,10 +37,10 @@ FMenuList::~FMenuList() // destructor
void FMenuList::selectFirstItem() void FMenuList::selectFirstItem()
{ {
std::vector<FMenuItem*>::const_iterator iter, end; std::vector<FMenuItem*>::const_iterator iter, end;
iter = itemlist.begin(); iter = item_list.begin();
end = itemlist.end(); end = item_list.end();
if ( itemlist.empty() ) if ( item_list.empty() )
return; return;
if ( hasSelectedItem() ) if ( hasSelectedItem() )
@ -72,7 +72,7 @@ void FMenuList::unselectItem()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuList::insert (FMenuItem* i) void FMenuList::insert (FMenuItem* i)
{ {
itemlist.push_back(i); item_list.push_back(i);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -80,16 +80,16 @@ void FMenuList::remove (FMenuItem* i)
{ {
std::vector<FMenuItem*>::iterator iter; std::vector<FMenuItem*>::iterator iter;
if ( itemlist.empty() ) if ( item_list.empty() )
return; return;
iter = itemlist.begin(); iter = item_list.begin();
while ( iter != itemlist.end() ) while ( iter != item_list.end() )
{ {
if ( (*iter) == i ) if ( (*iter) == i )
{ {
iter = itemlist.erase(iter); iter = item_list.erase(iter);
i->setSuperMenu(0); i->setSuperMenu(0);
break; break;
} }
@ -104,11 +104,11 @@ void FMenuList::remove (int pos)
if ( int(count()) < pos ) if ( int(count()) < pos )
return; return;
itemlist.erase (itemlist.begin()+pos-1); item_list.erase (item_list.begin() + pos - 1);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuList::clear() void FMenuList::clear()
{ {
itemlist.clear(); item_list.clear();
} }

View File

@ -33,8 +33,8 @@
class FMenuList class FMenuList
{ {
protected: protected:
FMenuItem* selectedItem; FMenuItem* selected_item;
std::vector<FMenuItem*> itemlist; std::vector<FMenuItem*> item_list;
private: private:
FMenuList (const FMenuList&); FMenuList (const FMenuList&);
@ -71,34 +71,34 @@ inline const char* FMenuList::getClassName() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline uInt FMenuList::count() const inline uInt FMenuList::count() const
{ return uInt(itemlist.size()); } { return uInt(item_list.size()); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FMenuItem* FMenuList::item (int index) const inline FMenuItem* FMenuList::item (int index) const
{ return (index > 0) ? itemlist[uInt(index-1)] : 0; } { return (index > 0) ? item_list[uInt(index-1)] : 0; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FMenuList::enableItem (int index) inline void FMenuList::enableItem (int index)
{ itemlist[uInt(index-1)]->setEnable(); } { item_list[uInt(index-1)]->setEnable(); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FMenuList::disableItem (int index) inline void FMenuList::disableItem (int index)
{ itemlist[uInt(index-1)]->unsetEnable(); } { item_list[uInt(index-1)]->unsetEnable(); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FMenuList::isSelected(int index) const inline bool FMenuList::isSelected(int index) const
{ return (index > 0) ? itemlist[uInt(index-1)]->isSelected() : false; } { return (index > 0) ? item_list[uInt(index-1)]->isSelected() : false; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FMenuItem* FMenuList::getSelectedItem() const inline FMenuItem* FMenuList::getSelectedItem() const
{ return selectedItem; } { return selected_item; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FMenuList::setSelectedItem (FMenuItem* menuitem) inline void FMenuList::setSelectedItem (FMenuItem* menuitem)
{ selectedItem = menuitem; } { selected_item = menuitem; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FMenuList::hasSelectedItem() const inline bool FMenuList::hasSelectedItem() const
{ return selectedItem; } { return selected_item; }
#endif // _FMENULIST_H #endif // _FMENULIST_H

View File

@ -30,10 +30,10 @@ FMessageBox::FMessageBox(FWidget* parent)
, text() , text()
, text_components(0) , text_components(0)
, text_split() , text_split()
, maxLineWidth(0) , max_line_width(0)
, center_text(false) , center_text(false)
, emphasis_color(wc.dialog_emphasis_fg) , emphasis_color(wc.dialog_emphasis_fg)
, numButtons(0) , num_buttons(0)
, text_num_lines(0) , text_num_lines(0)
, button_digit() , button_digit()
, button() , button()
@ -49,10 +49,10 @@ FMessageBox::FMessageBox (const FMessageBox& mbox)
, text(mbox.text) , text(mbox.text)
, text_components(mbox.text_components) , text_components(mbox.text_components)
, text_split(mbox.text_split) , text_split(mbox.text_split)
, maxLineWidth(mbox.maxLineWidth) , max_line_width(mbox.max_line_width)
, center_text(mbox.center_text) , center_text(mbox.center_text)
, emphasis_color(mbox.emphasis_color) , emphasis_color(mbox.emphasis_color)
, numButtons(mbox.numButtons) , num_buttons(mbox.num_buttons)
, text_num_lines(mbox.text_num_lines) , text_num_lines(mbox.text_num_lines)
, button_digit() , button_digit()
, button() , button()
@ -75,10 +75,10 @@ FMessageBox::FMessageBox ( const FString& caption
, text(message) , text(message)
, text_components(0) , text_components(0)
, text_split() , text_split()
, maxLineWidth(0) , max_line_width(0)
, center_text(false) , center_text(false)
, emphasis_color(wc.dialog_emphasis_fg) , emphasis_color(wc.dialog_emphasis_fg)
, numButtons(0) , num_buttons(0)
, text_num_lines(0) , text_num_lines(0)
, button_digit() , button_digit()
, button() , button()
@ -90,7 +90,7 @@ FMessageBox::FMessageBox ( const FString& caption
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FMessageBox::~FMessageBox() // destructor FMessageBox::~FMessageBox() // destructor
{ {
for (uInt n=0; n < numButtons; n++) for (uInt n=0; n < num_buttons; n++)
delete button[n]; delete button[n];
delete button_digit[2]; delete button_digit[2];
@ -103,7 +103,7 @@ FMessageBox::~FMessageBox() // destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMessageBox::init(int button0, int button1, int button2) void FMessageBox::init(int button0, int button1, int button2)
{ {
msg_dimension(); calculateDimensions();
if ( (button2 && ! button1) || (button1 && ! button0) ) if ( (button2 && ! button1) || (button1 && ! button0) )
{ {
@ -114,11 +114,11 @@ void FMessageBox::init(int button0, int button1, int button2)
button0 = FMessageBox::Ok; button0 = FMessageBox::Ok;
if ( button1 == 0 && button2 == 0 ) if ( button1 == 0 && button2 == 0 )
numButtons = 1; num_buttons = 1;
else if ( button2 == 0 ) else if ( button2 == 0 )
numButtons = 2; num_buttons = 2;
else else
numButtons = 3; num_buttons = 3;
button_digit[0] = new int(button0); button_digit[0] = new int(button0);
button_digit[1] = new int(button1); button_digit[1] = new int(button1);
@ -186,7 +186,7 @@ void FMessageBox::init(int button0, int button1, int button2)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMessageBox::msg_dimension() void FMessageBox::calculateDimensions()
{ {
int x, y, w, h; int x, y, w, h;
int headline_height = 0; int headline_height = 0;
@ -194,7 +194,7 @@ void FMessageBox::msg_dimension()
text_split = text.split("\n"); text_split = text.split("\n");
text_num_lines = uInt(text_split.size()); text_num_lines = uInt(text_split.size());
text_components = &text_split[0]; text_components = &text_split[0];
maxLineWidth = 0; max_line_width = 0;
if ( ! headline_text.isNull() ) if ( ! headline_text.isNull() )
headline_height = 2; headline_height = 2;
@ -203,12 +203,12 @@ void FMessageBox::msg_dimension()
{ {
uInt len = text_components[i].getLength(); uInt len = text_components[i].getLength();
if ( len > maxLineWidth ) if ( len > max_line_width )
maxLineWidth = len; max_line_width = len;
} }
h = int(text_num_lines) + 8 + headline_height; h = int(text_num_lines) + 8 + headline_height;
w = int(maxLineWidth + 4); w = int(max_line_width + 4);
if ( w < 20 ) if ( w < 20 )
w = 20; w = 20;
@ -231,7 +231,7 @@ void FMessageBox::draw()
int head_offset = 0; int head_offset = 0;
int center_x = 0; int center_x = 0;
int msg_x = int((getWidth() - int(maxLineWidth)) / 2); // center the whole block int msg_x = int((getWidth() - int(max_line_width)) / 2); // center the whole block
updateVTerm(false); updateVTerm(false);
if ( isMonochron() ) if ( isMonochron() )
@ -243,7 +243,7 @@ void FMessageBox::draw()
uInt headline_length = headline_text.getLength(); uInt headline_length = headline_text.getLength();
if ( center_text ) // center one line if ( center_text ) // center one line
center_x = int((maxLineWidth - headline_length) / 2); center_x = int((max_line_width - headline_length) / 2);
printPos (1 + msg_x + center_x, 4); printPos (1 + msg_x + center_x, 4);
print (headline_text); print (headline_text);
@ -257,7 +257,7 @@ void FMessageBox::draw()
uInt line_length = text_components[i].getLength(); uInt line_length = text_components[i].getLength();
if ( center_text ) // center one line if ( center_text ) // center one line
center_x = int((maxLineWidth - line_length) / 2); center_x = int((max_line_width - line_length) / 2);
printPos (1 + msg_x + center_x, 4 + head_offset + i); printPos (1 + msg_x + center_x, 4 + head_offset + i);
print(text_components[i]); print(text_components[i]);
@ -274,7 +274,7 @@ void FMessageBox::resizeButtons()
{ {
uInt len[3], max_size; uInt len[3], max_size;
for (uInt n=0; n < numButtons; n++) for (uInt n=0; n < num_buttons; n++)
{ {
len[n] = button[n]->getText().getLength(); len[n] = button[n]->getText().getLength();
@ -282,21 +282,21 @@ void FMessageBox::resizeButtons()
len[n]--; len[n]--;
} }
if ( numButtons == 1 ) if ( num_buttons == 1 )
max_size = len[0]; max_size = len[0];
else else
{ {
assert ( numButtons > 1 ); assert ( num_buttons > 1 );
max_size = std::max(len[0], len[1]); max_size = std::max(len[0], len[1]);
if ( numButtons == 3 ) if ( num_buttons == 3 )
max_size = std::max(max_size, len[2]); max_size = std::max(max_size, len[2]);
} }
if ( max_size < 7 ) if ( max_size < 7 )
max_size = 7; max_size = 7;
for (uInt n=0; n < numButtons; n++) for (uInt n=0; n < num_buttons; n++)
button[n]->setWidth(int(max_size + 3), false); button[n]->setWidth(int(max_size + 3), false);
} }
@ -306,9 +306,9 @@ void FMessageBox::adjustButtons()
int btn_width=0; int btn_width=0;
int gap = 4; int gap = 4;
for (uInt n=0; n < numButtons; n++) for (uInt n=0; n < num_buttons; n++)
{ {
if ( n == numButtons-1 ) if ( n == num_buttons-1 )
btn_width += button[n]->getWidth(); btn_width += button[n]->getWidth();
else else
btn_width += button[n]->getWidth() + gap; btn_width += button[n]->getWidth() + gap;
@ -325,7 +325,7 @@ void FMessageBox::adjustButtons()
int btn_x = int((getWidth()-btn_width) / 2); int btn_x = int((getWidth()-btn_width) / 2);
for (uInt n=0; n < numButtons; n++) for (uInt n=0; n < num_buttons; n++)
{ {
if ( n == 0 ) if ( n == 0 )
button[n]->setX(btn_x); button[n]->setX(btn_x);
@ -378,7 +378,7 @@ FMessageBox& FMessageBox::operator = (const FMessageBox& mbox)
return *this; return *this;
else else
{ {
for (uInt n=0; n < numButtons; n++) for (uInt n=0; n < num_buttons; n++)
delete button[n]; delete button[n];
delete button_digit[2]; delete button_digit[2];
@ -392,10 +392,10 @@ FMessageBox& FMessageBox::operator = (const FMessageBox& mbox)
text = mbox.text; text = mbox.text;
text_components = mbox.text_components; text_components = mbox.text_components;
text_split = mbox.text_split; text_split = mbox.text_split;
maxLineWidth = mbox.maxLineWidth; max_line_width = mbox.max_line_width;
center_text = mbox.center_text; center_text = mbox.center_text;
emphasis_color = mbox.emphasis_color; emphasis_color = mbox.emphasis_color;
numButtons = mbox.numButtons; num_buttons = mbox.num_buttons;
text_num_lines = mbox.text_num_lines; text_num_lines = mbox.text_num_lines;
setTitlebarText (mbox.getTitlebarText()); setTitlebarText (mbox.getTitlebarText());
@ -414,13 +414,13 @@ void FMessageBox::setHeadline (const FString& headline)
headline_text = headline; headline_text = headline;
setHeight(getHeight() + 2, true); setHeight(getHeight() + 2, true);
for (uInt n=0; n < numButtons; n++) for (uInt n=0; n < num_buttons; n++)
button[n]->setY(getHeight()-4, false); button[n]->setY(getHeight()-4, false);
uInt len = headline_text.getLength(); uInt len = headline_text.getLength();
if ( len > maxLineWidth ) if ( len > max_line_width )
maxLineWidth = len; max_line_width = len;
if ( vwin && getHeight() != old_height ) if ( vwin && getHeight() != old_height )
resizeArea (vwin); resizeArea (vwin);
@ -444,7 +444,7 @@ void FMessageBox::setHeadline (const char* headline)
void FMessageBox::setText (const FString& txt) void FMessageBox::setText (const FString& txt)
{ {
text = txt; text = txt;
msg_dimension(); calculateDimensions();
button[0]->setY(getHeight()-4, false); button[0]->setY(getHeight()-4, false);
if ( *button_digit[1] != 0 ) if ( *button_digit[1] != 0 )

View File

@ -63,16 +63,16 @@ class FMessageBox : public FDialog
}; };
private: private:
FString headline_text; FString headline_text;
FString text; FString text;
FString* text_components; FString* text_components;
std::vector<FString> text_split; std::vector<FString> text_split;
uInt maxLineWidth; uInt max_line_width;
bool center_text; bool center_text;
short emphasis_color; short emphasis_color;
uInt numButtons; uInt num_buttons;
uInt text_num_lines; uInt text_num_lines;
int* button_digit[3]; int* button_digit[3];
FButton* button[3]; FButton* button[3];
protected: protected:
@ -80,7 +80,7 @@ class FMessageBox : public FDialog
private: private:
void init(int, int, int); void init(int, int, int);
void msg_dimension(); void calculateDimensions();
virtual void draw(); virtual void draw();
void resizeButtons(); void resizeButtons();
void adjustButtons(); void adjustButtons();

View File

@ -15,14 +15,14 @@ FObject::TimerList* FObject::timer_list = 0;
// constructors and destructor // constructors and destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FObject::FObject (FObject* parent) FObject::FObject (FObject* parent)
: parentObj(parent) : parent_obj(parent)
, children_list() , children_list()
, has_parent(false) , has_parent(false)
{ {
children_list.clear(); // no children yet children_list.clear(); // no children yet
if ( parentObj ) // add object to parent if ( parent_obj ) // add object to parent
parentObj->addChild(this); parent_obj->addChild(this);
if ( parent == 0 ) if ( parent == 0 )
{ {
@ -36,10 +36,10 @@ FObject::FObject (FObject* parent)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FObject::~FObject() // destructor FObject::~FObject() // destructor
{ {
if ( parentObj ) if ( parent_obj )
parentObj->delChild(this); parent_obj->delChild(this);
parentObj = 0; parent_obj = 0;
delOwnTimer(); // delete all timers of this object delOwnTimer(); // delete all timers of this object
if ( ! has_parent && timer_list ) if ( ! has_parent && timer_list )
@ -70,10 +70,13 @@ FObject::~FObject() // destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FObject::addChild (FObject* obj) void FObject::addChild (FObject* obj)
{ {
if ( obj->parentObj ) if ( ! obj )
obj->parentObj->delChild(obj); return;
obj->parentObj = this; if ( obj->parent_obj )
obj->parent_obj->delChild(obj);
obj->parent_obj = this;
children_list.push_back(obj); children_list.push_back(obj);
} }
@ -81,6 +84,9 @@ void FObject::addChild (FObject* obj)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FObject::delChild (FObject* obj) void FObject::delChild (FObject* obj)
{ {
if ( ! obj )
return;
if ( ! children_list.empty() ) if ( ! children_list.empty() )
{ {
obj->removeParent(); obj->removeParent();

View File

@ -29,14 +29,14 @@ typedef unsigned short uInt16;
typedef unsigned int uInt32; typedef unsigned int uInt32;
typedef u_int64_t uInt64; typedef u_int64_t uInt64;
typedef signed int sInt; typedef signed int sInt;
typedef signed long sLong; typedef signed long sLong;
typedef signed char sInt8; typedef signed char sInt8;
typedef signed short sInt16; typedef signed short sInt16;
typedef signed int sInt32; typedef signed int sInt32;
typedef int64_t sInt64; typedef int64_t sInt64;
typedef long double lDouble; typedef long double lDouble;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FObject // class FObject
@ -57,11 +57,12 @@ class FObject
timeval timeout; timeval timeout;
FObject* object; FObject* object;
}; };
typedef std::vector<timer_data> TimerList; typedef std::vector<timer_data> TimerList;
static TimerList* timer_list; static TimerList* timer_list;
private: private:
FObject* parentObj; FObject* parent_obj;
object_list children_list; object_list children_list;
bool has_parent; bool has_parent;
static bool modify_timer; static bool modify_timer;
@ -103,7 +104,7 @@ inline const char* FObject::getClassName() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FObject* FObject::getParent() const inline FObject* FObject::getParent() const
{ return parentObj; } { return parent_obj; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FObject::hasParent() const inline bool FObject::hasParent() const
@ -111,7 +112,7 @@ inline bool FObject::hasParent() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FObject::removeParent() inline void FObject::removeParent()
{ parentObj = 0; } { parent_obj = 0; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FObject::object_list FObject::getChildren() const inline FObject::object_list FObject::getChildren() const

View File

@ -63,7 +63,7 @@ void FOptiMove::calculateCharDuration()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FOptiMove::cap_duration (char*& cap, int affcnt) int FOptiMove::capDuration (char*& cap, int affcnt)
{ {
// calculate the duration in milliseconds of a given operation // calculate the duration in milliseconds of a given operation
// cap - the term capability // cap - the term capability
@ -111,7 +111,7 @@ void FOptiMove::set_cursor_home (char*& cap)
if ( cap ) if ( cap )
{ {
F_cursor_home.cap = cap; F_cursor_home.cap = cap;
F_cursor_home.duration = cap_duration(cap, 0); F_cursor_home.duration = capDuration (cap, 0);
F_cursor_home.length = int(strlen(cap)); F_cursor_home.length = int(strlen(cap));
} }
} }
@ -122,7 +122,7 @@ void FOptiMove::set_cursor_to_ll (char*& cap)
if ( cap ) if ( cap )
{ {
F_cursor_to_ll.cap = cap; F_cursor_to_ll.cap = cap;
F_cursor_to_ll.duration = cap_duration(cap, 0); F_cursor_to_ll.duration = capDuration (cap, 0);
F_cursor_to_ll.length = int(strlen(cap)); F_cursor_to_ll.length = int(strlen(cap));
} }
} }
@ -133,7 +133,7 @@ void FOptiMove::set_carriage_return (char*& cap)
if ( cap ) if ( cap )
{ {
F_carriage_return.cap = cap; F_carriage_return.cap = cap;
F_carriage_return.duration = cap_duration(cap, 0); F_carriage_return.duration = capDuration (cap, 0);
F_carriage_return.length = int(strlen(cap)); F_carriage_return.length = int(strlen(cap));
} }
} }
@ -144,7 +144,7 @@ void FOptiMove::set_tabular (char*& cap)
if ( cap ) if ( cap )
{ {
F_tab.cap = cap; F_tab.cap = cap;
F_tab.duration = cap_duration(cap, 0); F_tab.duration = capDuration (cap, 0);
F_tab.length = int(strlen(cap)); F_tab.length = int(strlen(cap));
} }
} }
@ -155,7 +155,7 @@ void FOptiMove::set_back_tab (char*& cap)
if ( cap ) if ( cap )
{ {
F_back_tab.cap = cap; F_back_tab.cap = cap;
F_back_tab.duration = cap_duration(cap, 0); F_back_tab.duration = capDuration (cap, 0);
F_back_tab.length = int(strlen(cap)); F_back_tab.length = int(strlen(cap));
} }
} }
@ -166,7 +166,7 @@ void FOptiMove::set_cursor_up (char*& cap)
if ( cap ) if ( cap )
{ {
F_cursor_up.cap = cap; F_cursor_up.cap = cap;
F_cursor_up.duration = cap_duration(cap, 0); F_cursor_up.duration = capDuration (cap, 0);
F_cursor_up.length = int(strlen(cap)); F_cursor_up.length = int(strlen(cap));
} }
} }
@ -177,7 +177,7 @@ void FOptiMove::set_cursor_down (char*& cap)
if ( cap ) if ( cap )
{ {
F_cursor_down.cap = cap; F_cursor_down.cap = cap;
F_cursor_down.duration = cap_duration(cap, 0); F_cursor_down.duration = capDuration (cap, 0);
F_cursor_down.length = int(strlen(cap)); F_cursor_down.length = int(strlen(cap));
} }
} }
@ -188,7 +188,7 @@ void FOptiMove::set_cursor_left (char*& cap)
if ( cap ) if ( cap )
{ {
F_cursor_left.cap = cap; F_cursor_left.cap = cap;
F_cursor_left.duration = cap_duration(cap, 0); F_cursor_left.duration = capDuration (cap, 0);
F_cursor_left.length = int(strlen(cap)); F_cursor_left.length = int(strlen(cap));
} }
} }
@ -199,7 +199,7 @@ void FOptiMove::set_cursor_right (char*& cap)
if ( cap ) if ( cap )
{ {
F_cursor_right.cap = cap; F_cursor_right.cap = cap;
F_cursor_right.duration = cap_duration(cap, 0); F_cursor_right.duration = capDuration (cap, 0);
F_cursor_right.length = int(strlen(cap)); F_cursor_right.length = int(strlen(cap));
} }
} }
@ -211,7 +211,7 @@ void FOptiMove::set_cursor_address (char*& cap)
{ {
char* temp = tgoto(cap, 23, 23); char* temp = tgoto(cap, 23, 23);
F_cursor_address.cap = cap; F_cursor_address.cap = cap;
F_cursor_address.duration = cap_duration(temp, 1); F_cursor_address.duration = capDuration (temp, 1);
F_cursor_address.length = int(strlen(cap)); F_cursor_address.length = int(strlen(cap));
} }
} }
@ -223,7 +223,7 @@ void FOptiMove::set_column_address (char*& cap)
{ {
char* temp = tparm(cap, 23); char* temp = tparm(cap, 23);
F_column_address.cap = cap; F_column_address.cap = cap;
F_column_address.duration = cap_duration(temp, 1); F_column_address.duration = capDuration (temp, 1);
F_column_address.length = int(strlen(cap)); F_column_address.length = int(strlen(cap));
} }
} }
@ -235,7 +235,7 @@ void FOptiMove::set_row_address (char*& cap)
{ {
char* temp = tparm(cap, 23); char* temp = tparm(cap, 23);
F_row_address.cap = cap; F_row_address.cap = cap;
F_row_address.duration = cap_duration(temp, 1); F_row_address.duration = capDuration (temp, 1);
F_row_address.length = int(strlen(cap)); F_row_address.length = int(strlen(cap));
} }
} }
@ -247,7 +247,7 @@ void FOptiMove::set_parm_up_cursor (char*& cap)
{ {
char* temp = tparm(cap, 23); char* temp = tparm(cap, 23);
F_parm_up_cursor.cap = cap; F_parm_up_cursor.cap = cap;
F_parm_up_cursor.duration = cap_duration(temp, 1); F_parm_up_cursor.duration = capDuration (temp, 1);
F_parm_up_cursor.length = int(strlen(cap)); F_parm_up_cursor.length = int(strlen(cap));
} }
} }
@ -259,7 +259,7 @@ void FOptiMove::set_parm_down_cursor (char*& cap)
{ {
char* temp = tparm(cap, 23); char* temp = tparm(cap, 23);
F_parm_down_cursor.cap = cap; F_parm_down_cursor.cap = cap;
F_parm_down_cursor.duration = cap_duration(temp, 1); F_parm_down_cursor.duration = capDuration (temp, 1);
F_parm_down_cursor.length = int(strlen(cap)); F_parm_down_cursor.length = int(strlen(cap));
} }
} }
@ -271,7 +271,7 @@ void FOptiMove::set_parm_left_cursor (char*& cap)
{ {
char* temp = tparm(cap, 23); char* temp = tparm(cap, 23);
F_parm_left_cursor.cap = cap; F_parm_left_cursor.cap = cap;
F_parm_left_cursor.duration = cap_duration(temp, 1); F_parm_left_cursor.duration = capDuration (temp, 1);
F_parm_left_cursor.length = int(strlen(cap)); F_parm_left_cursor.length = int(strlen(cap));
} }
} }
@ -283,7 +283,7 @@ void FOptiMove::set_parm_right_cursor (char*& cap)
{ {
char* temp = tparm(cap, 23); char* temp = tparm(cap, 23);
F_parm_right_cursor.cap = cap; F_parm_right_cursor.cap = cap;
F_parm_right_cursor.duration = cap_duration(temp, 1); F_parm_right_cursor.duration = capDuration (temp, 1);
F_parm_right_cursor.length = int(strlen(cap)); F_parm_right_cursor.length = int(strlen(cap));
} }
} }
@ -314,7 +314,7 @@ void FOptiMove::setTermSize (int w, int h)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FOptiMove::repeated_append (capability& o, int count, char* dst) int FOptiMove::repeatedAppend (capability& o, int count, char* dst)
{ {
register size_t src_len; register size_t src_len;
register size_t dst_len; register size_t dst_len;
@ -346,9 +346,9 @@ int FOptiMove::repeated_append (capability& o, int count, char* dst)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FOptiMove::relative_move ( char*& move int FOptiMove::relativeMove ( char*& move
, int from_x, int from_y , int from_x, int from_y
, int to_x, int to_y ) , int to_x, int to_y )
{ {
int num; int num;
int vtime = 0; int vtime = 0;
@ -386,7 +386,7 @@ int FOptiMove::relative_move ( char*& move
if ( move ) if ( move )
move[0] = '\0'; move[0] = '\0';
vtime = repeated_append (F_cursor_down, num, move); vtime = repeatedAppend (F_cursor_down, num, move);
} }
} }
else // to_y < from_y else // to_y < from_y
@ -406,7 +406,7 @@ int FOptiMove::relative_move ( char*& move
if ( move ) if ( move )
move[0] = '\0'; move[0] = '\0';
vtime = repeated_append (F_cursor_up, num, move); vtime = repeatedAppend (F_cursor_up, num, move);
} }
} }
@ -457,7 +457,7 @@ int FOptiMove::relative_move ( char*& move
if ( tab_pos > to_x ) if ( tab_pos > to_x )
break; break;
htime_r += repeated_append (F_tab, 1, str); htime_r += repeatedAppend (F_tab, 1, str);
if ( htime_r >= LONG_DURATION ) if ( htime_r >= LONG_DURATION )
break; break;
@ -468,7 +468,7 @@ int FOptiMove::relative_move ( char*& move
num = to_x - pos; num = to_x - pos;
} }
htime_r += repeated_append (F_cursor_right, num, str); htime_r += repeatedAppend (F_cursor_right, num, str);
if ( htime_r < htime ) if ( htime_r < htime )
{ {
@ -507,7 +507,7 @@ int FOptiMove::relative_move ( char*& move
if ( tab_pos < to_x ) if ( tab_pos < to_x )
break; break;
htime_l += repeated_append (F_back_tab, 1, str); htime_l += repeatedAppend (F_back_tab, 1, str);
if ( htime_l >= LONG_DURATION ) if ( htime_l >= LONG_DURATION )
break; break;
@ -518,7 +518,7 @@ int FOptiMove::relative_move ( char*& move
num = pos - to_x; num = pos - to_x;
} }
htime_l += repeated_append (F_cursor_left, num, str); htime_l += repeatedAppend (F_cursor_left, num, str);
if ( htime_l < htime ) if ( htime_l < htime )
{ {
@ -592,7 +592,7 @@ char* FOptiMove::cursor_move (int xold, int yold, int xnew, int ynew)
// Method 1: local movement // Method 1: local movement
if ( xold >= 0 && yold >= 0 ) if ( xold >= 0 && yold >= 0 )
{ {
new_time = relative_move (null_ptr, xold, yold, xnew, ynew); new_time = relativeMove (null_ptr, xold, yold, xnew, ynew);
if ( new_time < LONG_DURATION && new_time < move_time ) if ( new_time < LONG_DURATION && new_time < move_time )
{ {
@ -604,7 +604,7 @@ char* FOptiMove::cursor_move (int xold, int yold, int xnew, int ynew)
// Method 2: carriage-return + local movement // Method 2: carriage-return + local movement
if ( yold >= 0 && F_carriage_return.cap ) if ( yold >= 0 && F_carriage_return.cap )
{ {
new_time = relative_move (null_ptr, 0, yold, xnew, ynew); new_time = relativeMove (null_ptr, 0, yold, xnew, ynew);
if ( new_time < LONG_DURATION if ( new_time < LONG_DURATION
&& F_carriage_return.duration + new_time < move_time ) && F_carriage_return.duration + new_time < move_time )
@ -617,7 +617,7 @@ char* FOptiMove::cursor_move (int xold, int yold, int xnew, int ynew)
// Method 3: home-cursor + local movement // Method 3: home-cursor + local movement
if ( F_cursor_home.cap ) if ( F_cursor_home.cap )
{ {
new_time = relative_move (null_ptr, 0, 0, xnew, ynew); new_time = relativeMove (null_ptr, 0, 0, xnew, ynew);
if ( new_time < LONG_DURATION if ( new_time < LONG_DURATION
&& F_cursor_home.duration + new_time < move_time ) && F_cursor_home.duration + new_time < move_time )
@ -630,7 +630,7 @@ char* FOptiMove::cursor_move (int xold, int yold, int xnew, int ynew)
// Method 4: home-down + local movement // Method 4: home-down + local movement
if ( F_cursor_to_ll.cap ) if ( F_cursor_to_ll.cap )
{ {
new_time = relative_move (null_ptr, 0, screen_height-1, xnew, ynew); new_time = relativeMove (null_ptr, 0, screen_height-1, xnew, ynew);
if ( new_time < LONG_DURATION if ( new_time < LONG_DURATION
&& F_cursor_to_ll.duration + new_time < move_time ) && F_cursor_to_ll.duration + new_time < move_time )
@ -646,7 +646,7 @@ char* FOptiMove::cursor_move (int xold, int yold, int xnew, int ynew)
&& yold > 0 && yold > 0
&& F_cursor_left.cap ) && F_cursor_left.cap )
{ {
new_time = relative_move (null_ptr, screen_width-1, yold-1, xnew, ynew); new_time = relativeMove (null_ptr, screen_width-1, yold-1, xnew, ynew);
if ( new_time < LONG_DURATION if ( new_time < LONG_DURATION
&& F_carriage_return.cap && F_carriage_return.cap
@ -664,7 +664,7 @@ char* FOptiMove::cursor_move (int xold, int yold, int xnew, int ynew)
switch ( method ) switch ( method )
{ {
case 1: case 1:
relative_move (move_ptr, xold, yold, xnew, ynew); relativeMove (move_ptr, xold, yold, xnew, ynew);
break; break;
case 2: case 2:
@ -672,20 +672,20 @@ char* FOptiMove::cursor_move (int xold, int yold, int xnew, int ynew)
{ {
strncpy (move_ptr, F_carriage_return.cap, sizeof(move_buf) - 1); strncpy (move_ptr, F_carriage_return.cap, sizeof(move_buf) - 1);
move_ptr += F_carriage_return.length; move_ptr += F_carriage_return.length;
relative_move (move_ptr, 0, yold, xnew, ynew); relativeMove (move_ptr, 0, yold, xnew, ynew);
} }
break; break;
case 3: case 3:
strncpy (move_ptr, F_cursor_home.cap, sizeof(move_buf) - 1); strncpy (move_ptr, F_cursor_home.cap, sizeof(move_buf) - 1);
move_ptr += F_cursor_home.length; move_ptr += F_cursor_home.length;
relative_move (move_ptr, 0, 0, xnew, ynew); relativeMove (move_ptr, 0, 0, xnew, ynew);
break; break;
case 4: case 4:
strncpy (move_ptr, F_cursor_to_ll.cap, sizeof(move_buf) - 1); strncpy (move_ptr, F_cursor_to_ll.cap, sizeof(move_buf) - 1);
move_ptr += F_cursor_to_ll.length; move_ptr += F_cursor_to_ll.length;
relative_move (move_ptr, 0, screen_height-1, xnew, ynew); relativeMove (move_ptr, 0, screen_height-1, xnew, ynew);
break; break;
case 5: case 5:
@ -700,7 +700,7 @@ char* FOptiMove::cursor_move (int xold, int yold, int xnew, int ynew)
, F_cursor_left.cap , F_cursor_left.cap
, sizeof(move_buf) - strlen(move_ptr) - 1 ); , sizeof(move_buf) - strlen(move_ptr) - 1 );
move_ptr += strlen(move_buf); move_ptr += strlen(move_buf);
relative_move (move_ptr, screen_width-1, yold-1, xnew, ynew); relativeMove (move_ptr, screen_width-1, yold-1, xnew, ynew);
break; break;
default: default:

View File

@ -78,9 +78,9 @@ class FOptiMove
private: private:
void calculateCharDuration(); void calculateCharDuration();
int cap_duration (char*&, int); int capDuration (char*&, int);
int repeated_append (capability&, int, char*); int repeatedAppend (capability&, int, char*);
int relative_move (char*&, int, int, int, int); int relativeMove (char*&, int, int, int, int);
bool isTwoDirectionMove (int, int, int, int); bool isTwoDirectionMove (int, int, int, int);
bool isWideMove (int, int, int, int); bool isWideMove (int, int, int, int);

View File

@ -12,7 +12,7 @@
FProgressbar::FProgressbar(FWidget* parent) FProgressbar::FProgressbar(FWidget* parent)
: FWidget(parent) : FWidget(parent)
, percentage(-1) , percentage(-1)
, BarLength(getWidth()) , bar_length(getWidth())
{ {
unsetFocusable(); unsetFocusable();
setShadow(); setShadow();
@ -52,7 +52,7 @@ void FProgressbar::drawPercentage()
void FProgressbar::drawBar() void FProgressbar::drawBar()
{ {
int i = 1; int i = 1;
float length = float(BarLength*percentage)/100; float length = float(bar_length * percentage) / 100;
printPos (1,1); printPos (1,1);
if ( isMonochron() ) if ( isMonochron() )
@ -110,7 +110,7 @@ void FProgressbar::drawBar()
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
if ( trunc(length) >= 1 && trunc(length) < BarLength ) if ( trunc(length) >= 1 && trunc(length) < bar_length )
{ {
if ( round(length) > trunc(length) if ( round(length) > trunc(length)
|| isCygwinTerminal() || isCygwinTerminal()
@ -138,12 +138,12 @@ void FProgressbar::drawBar()
if ( getMaxColor() < 16 ) if ( getMaxColor() < 16 )
{ {
for (; i < BarLength; i++) for (; i < bar_length; i++)
print (fc::MediumShade); // ▒ print (fc::MediumShade); // ▒
} }
else else
{ {
for (; i < BarLength; i++) for (; i < bar_length; i++)
print (' '); print (' ');
} }
@ -260,7 +260,7 @@ void FProgressbar::reset()
void FProgressbar::setGeometry (int x, int y, int w, int h, bool adjust) void FProgressbar::setGeometry (int x, int y, int w, int h, bool adjust)
{ {
FWidget::setGeometry (x, y, w, h, adjust); FWidget::setGeometry (x, y, w, h, adjust);
BarLength = w; bar_length = w;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -37,7 +37,7 @@ class FProgressbar : public FWidget
{ {
private: private:
int percentage; int percentage;
int BarLength; int bar_length;
private: private:
void drawPercentage(); void drawPercentage();

View File

@ -11,16 +11,16 @@
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FScrollbar::FScrollbar(FWidget* parent) FScrollbar::FScrollbar(FWidget* parent)
: FWidget(parent) : FWidget(parent)
, scrollType(FScrollbar::noScroll) , scroll_type(FScrollbar::noScroll)
, thresholdReached(false) , threshold_reached(false)
, thresholdTime(500) , threshold_time(500)
, repeatTime(10) , repeat_time(10)
, SliderClickPos(-1) , slider_click_pos(-1)
, SliderClickStopPos(-1) , slider_click_stop_pos(-1)
, currentSliderPos(-1) , current_slider_pos(-1)
, SliderPos(0) , slider_pos(0)
, SliderLength(18) // = BarLength , slider_length(18) // = bar_length
, BarLength(18) // = length - 2 , bar_length(18) // = length - 2
, val(0) , val(0)
, min(0) , min(0)
, max(99) , max(99)
@ -38,16 +38,16 @@ FScrollbar::FScrollbar(FWidget* parent)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FScrollbar::FScrollbar(int o, FWidget* parent) FScrollbar::FScrollbar(int o, FWidget* parent)
: FWidget(parent) : FWidget(parent)
, scrollType(FScrollbar::noScroll) , scroll_type(FScrollbar::noScroll)
, thresholdReached(false) , threshold_reached(false)
, thresholdTime(500) , threshold_time(500)
, repeatTime(10) , repeat_time(10)
, SliderClickPos(-1) , slider_click_pos(-1)
, SliderClickStopPos(-1) , slider_click_stop_pos(-1)
, currentSliderPos(-1) , current_slider_pos(-1)
, SliderPos(0) , slider_pos(0)
, SliderLength(18) // = BarLength , slider_length(18) // = bar_length
, BarLength(18) // = length - 2 , bar_length(18) // = length - 2
, val(0) , val(0)
, min(0) , min(0)
, max(99) , max(99)
@ -81,15 +81,15 @@ void FScrollbar::draw()
{ {
updateVTerm(false); updateVTerm(false);
drawButtons(); drawButtons();
currentSliderPos = -1; current_slider_pos = -1;
drawBar(); drawBar();
updateVTerm(true); updateVTerm(true);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FScrollbar::getClickedScrollType (int x, int y) FScrollbar::sType FScrollbar::getClickedScrollType (int x, int y)
{ {
int stype; FScrollbar::sType stype;
if ( bar_orientation == fc::vertical ) if ( bar_orientation == fc::vertical )
{ {
@ -97,11 +97,11 @@ int FScrollbar::getClickedScrollType (int x, int y)
{ {
stype = FScrollbar::scrollStepBackward; // decrement button stype = FScrollbar::scrollStepBackward; // decrement button
} }
else if ( y >1 && y <= SliderPos+1 ) else if ( y >1 && y <= slider_pos+1 )
{ {
stype = FScrollbar::scrollPageBackward; // before slider stype = FScrollbar::scrollPageBackward; // before slider
} }
else if ( y > SliderPos+SliderLength+1 && y < getHeight() ) else if ( y > slider_pos+slider_length+1 && y < getHeight() )
{ {
stype = FScrollbar::scrollPageForward; // after slider stype = FScrollbar::scrollPageForward; // after slider
} }
@ -120,11 +120,11 @@ int FScrollbar::getClickedScrollType (int x, int y)
{ {
stype = FScrollbar::scrollStepBackward; // decrement button stype = FScrollbar::scrollStepBackward; // decrement button
} }
else if ( x >2 && x <= SliderPos+2 ) else if ( x >2 && x <= slider_pos+2 )
{ {
stype = FScrollbar::scrollPageBackward; // before slider stype = FScrollbar::scrollPageBackward; // before slider
} }
else if ( x > SliderPos+SliderLength+2 && x < getWidth()-1 ) else if ( x > slider_pos+slider_length+2 && x < getWidth()-1 )
{ {
stype = FScrollbar::scrollPageForward; // after slider stype = FScrollbar::scrollPageForward; // after slider
} }
@ -141,11 +141,11 @@ int FScrollbar::getClickedScrollType (int x, int y)
{ {
stype = FScrollbar::scrollStepBackward; // decrement button stype = FScrollbar::scrollStepBackward; // decrement button
} }
else if ( x >1 && x <= SliderPos+1 ) else if ( x >1 && x <= slider_pos+1 )
{ {
stype = FScrollbar::scrollPageBackward; // before slider stype = FScrollbar::scrollPageBackward; // before slider
} }
else if ( x > SliderPos+SliderLength+1 && x < getWidth() ) else if ( x > slider_pos+slider_length+1 && x < getWidth() )
{ {
stype = FScrollbar::scrollPageForward; // after slider stype = FScrollbar::scrollPageForward; // after slider
} }
@ -170,8 +170,8 @@ void FScrollbar::processMiddleButton (int x, int y)
{ {
if ( y >1 && y < getHeight() ) if ( y >1 && y < getHeight() )
{ {
new_val = int( round ( float(max-min) * (y-2.0-(SliderLength/2)) new_val = int( round ( float(max - min) * (y - 2.0 - (slider_length/2))
/ float(BarLength-SliderLength) ) ); / float(bar_length - slider_length) ) );
} }
else else
return; return;
@ -182,8 +182,8 @@ void FScrollbar::processMiddleButton (int x, int y)
if ( x > 1+nf && x < getWidth()-nf ) if ( x > 1+nf && x < getWidth()-nf )
{ {
new_val = int( round ( float(max-min) * (x-2.0-nf-(SliderLength/2)) new_val = int( round ( float(max - min) * (x - 2.0 - nf - (slider_length/2))
/ float(BarLength-SliderLength) ) ); / float(bar_length - slider_length) ) );
} }
else else
return; return;
@ -194,7 +194,7 @@ void FScrollbar::processMiddleButton (int x, int y)
setValue(new_val); setValue(new_val);
drawBar(); drawBar();
updateTerminal(); updateTerminal();
scrollType = FScrollbar::scrollJump; scroll_type = FScrollbar::scrollJump;
processScroll(); processScroll();
} }
} }
@ -230,50 +230,50 @@ void FScrollbar::onMouseDown (FMouseEvent* ev)
} }
// process LeftButton // process LeftButton
scrollType = getClickedScrollType(mouse_x, mouse_y); scroll_type = getClickedScrollType(mouse_x, mouse_y);
if ( bar_orientation == fc::vertical ) if ( bar_orientation == fc::vertical )
{ {
if ( mouse_y > SliderPos+1 && mouse_y <= SliderPos+SliderLength+1 ) if ( mouse_y > slider_pos+1 && mouse_y <= slider_pos+slider_length+1 )
SliderClickPos = mouse_y; // on slider slider_click_pos = mouse_y; // on slider
} }
else // horizontal else // horizontal
{ {
if ( isNewFont() ) if ( isNewFont() )
{ {
if ( mouse_x > SliderPos+2 && mouse_x <= SliderPos+SliderLength+2 ) if ( mouse_x > slider_pos+2 && mouse_x <= slider_pos+slider_length+2 )
SliderClickPos = mouse_x; // on slider slider_click_pos = mouse_x; // on slider
} }
else else
{ {
if ( mouse_x > SliderPos+1 && mouse_x <= SliderPos+SliderLength+1 ) if ( mouse_x > slider_pos+1 && mouse_x <= slider_pos+slider_length+1 )
SliderClickPos = mouse_x; // on slider slider_click_pos = mouse_x; // on slider
} }
} }
if ( SliderClickPos > 0 ) if ( slider_click_pos > 0 )
scrollType = FScrollbar::scrollJump; scroll_type = FScrollbar::scrollJump;
if ( scrollType == FScrollbar::scrollPageBackward if ( scroll_type == FScrollbar::scrollPageBackward
|| scrollType == FScrollbar::scrollPageForward ) || scroll_type == FScrollbar::scrollPageForward )
{ {
if ( bar_orientation == fc::vertical ) if ( bar_orientation == fc::vertical )
SliderClickStopPos = mouse_y - 2; slider_click_stop_pos = mouse_y - 2;
else else
if ( isNewFont() ) if ( isNewFont() )
SliderClickStopPos = mouse_x - 3; slider_click_stop_pos = mouse_x - 3;
else else
SliderClickStopPos = mouse_x - 2; slider_click_stop_pos = mouse_x - 2;
} }
else else
SliderClickStopPos = -1; slider_click_stop_pos = -1;
if ( scrollType >= FScrollbar::scrollStepBackward if ( scroll_type >= FScrollbar::scrollStepBackward
&& scrollType <= FScrollbar::scrollPageForward ) && scroll_type <= FScrollbar::scrollPageForward )
{ {
processScroll(); processScroll();
thresholdReached = false; threshold_reached = false;
addTimer(thresholdTime); addTimer(threshold_time);
} }
} }
@ -284,19 +284,19 @@ void FScrollbar::onMouseUp (FMouseEvent* ev)
&& ev->getButton() != fc::MiddleButton ) && ev->getButton() != fc::MiddleButton )
return; return;
SliderClickPos = -1; slider_click_pos = -1;
if ( scrollType != FScrollbar::noScroll ) if ( scroll_type != FScrollbar::noScroll )
{ {
delOwnTimer(); delOwnTimer();
scrollType = FScrollbar::noScroll; scroll_type = FScrollbar::noScroll;
} }
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollbar::onMouseMove (FMouseEvent* ev) void FScrollbar::onMouseMove (FMouseEvent* ev)
{ {
int mouse_x, mouse_y, newScrollType; int mouse_x, mouse_y, new_scroll_type;
if ( ev->getButton() != fc::LeftButton if ( ev->getButton() != fc::LeftButton
&& ev->getButton() != fc::MiddleButton ) && ev->getButton() != fc::MiddleButton )
@ -312,25 +312,25 @@ void FScrollbar::onMouseMove (FMouseEvent* ev)
} }
// process LeftButton // process LeftButton
newScrollType = getClickedScrollType(mouse_x, mouse_y); new_scroll_type = getClickedScrollType(mouse_x, mouse_y);
if ( scrollType == FScrollbar::scrollJump ) if ( scroll_type == FScrollbar::scrollJump )
{ {
int new_val; int new_val;
if ( bar_orientation == fc::vertical ) if ( bar_orientation == fc::vertical )
{ {
int dy = mouse_y - SliderClickPos; int dy = mouse_y - slider_click_pos;
SliderClickPos = mouse_y; slider_click_pos = mouse_y;
new_val = int( round ( float((max-min) * (SliderPos + dy)) new_val = int( round ( float((max - min) * (slider_pos + dy))
/ float(BarLength-SliderLength) ) ); / float(bar_length - slider_length) ) );
} }
else // horizontal else // horizontal
{ {
int dx = mouse_x - SliderClickPos; int dx = mouse_x - slider_click_pos;
SliderClickPos = mouse_x; slider_click_pos = mouse_x;
new_val = int( round ( float((max-min) * (SliderPos + dx)) new_val = int( round ( float((max - min) * (slider_pos + dx))
/ float(BarLength-SliderLength) ) ); / float(bar_length - slider_length) ) );
} }
if ( new_val != val ) if ( new_val != val )
@ -347,12 +347,12 @@ void FScrollbar::onMouseMove (FMouseEvent* ev)
{ {
delOwnTimer(); delOwnTimer();
} }
else if ( scrollType != FScrollbar::scrollJump ) else if ( scroll_type != FScrollbar::scrollJump )
{ {
addTimer(repeatTime); addTimer(repeat_time);
} }
if ( scrollType != newScrollType ) if ( scroll_type != new_scroll_type )
{ {
delOwnTimer(); delOwnTimer();
} }
@ -363,16 +363,16 @@ void FScrollbar::onWheel (FWheelEvent* ev)
{ {
int wheel = ev->getWheel(); int wheel = ev->getWheel();
if ( scrollType != FScrollbar::noScroll ) if ( scroll_type != FScrollbar::noScroll )
{ {
delOwnTimer(); delOwnTimer();
scrollType = FScrollbar::noScroll; scroll_type = FScrollbar::noScroll;
} }
if ( wheel == fc::WheelUp ) if ( wheel == fc::WheelUp )
scrollType = FScrollbar::scrollWheelUp; scroll_type = FScrollbar::scrollWheelUp;
else if ( wheel == fc::WheelDown ) else if ( wheel == fc::WheelDown )
scrollType = FScrollbar::scrollWheelDown; scroll_type = FScrollbar::scrollWheelDown;
processScroll(); processScroll();
} }
@ -380,20 +380,20 @@ void FScrollbar::onWheel (FWheelEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollbar::onTimer (FTimerEvent*) void FScrollbar::onTimer (FTimerEvent*)
{ {
if ( scrollType == FScrollbar::noScroll ) if ( scroll_type == FScrollbar::noScroll )
return; return;
if ( ! thresholdReached ) if ( ! threshold_reached )
{ {
thresholdReached = true; threshold_reached = true;
delOwnTimer(); delOwnTimer();
addTimer(repeatTime); addTimer(repeat_time);
} }
if ( ( scrollType == scrollPageBackward if ( ( scroll_type == FScrollbar::scrollPageBackward
&& SliderPos < SliderClickStopPos ) && slider_pos < slider_click_stop_pos )
|| ( scrollType == scrollPageForward || ( scroll_type == FScrollbar::scrollPageForward
&& SliderPos+SliderLength > SliderClickStopPos ) ) && slider_pos+slider_length > slider_click_stop_pos ) )
{ {
delOwnTimer(); delOwnTimer();
return; return;
@ -477,36 +477,36 @@ void FScrollbar::setPageSize (int document_size, int page_size)
void FScrollbar::calculateSliderValues() void FScrollbar::calculateSliderValues()
{ {
if ( isNewFont() && bar_orientation == fc::horizontal ) if ( isNewFont() && bar_orientation == fc::horizontal )
BarLength = length - 4; bar_length = length - 4;
else else
BarLength = length - 2; bar_length = length - 2;
SliderLength = int(float(BarLength) / steps); slider_length = int(float(bar_length) / steps);
if ( SliderLength < 1 ) if ( slider_length < 1 )
SliderLength = 1; slider_length = 1;
else if ( SliderLength > BarLength ) else if ( slider_length > bar_length )
SliderLength = BarLength; slider_length = bar_length;
if ( val == min ) if ( val == min )
{ {
SliderPos = 0; slider_pos = 0;
return; return;
} }
if ( val == max ) if ( val == max )
{ {
SliderPos = BarLength - SliderLength; slider_pos = bar_length - slider_length;
return; return;
} }
SliderPos = int( round ( float((BarLength-SliderLength) * val) slider_pos = int( round ( float((bar_length - slider_length) * val)
/ float(max-min) ) ); / float(max - min) ) );
if ( SliderPos < 0 ) if ( slider_pos < 0 )
SliderPos = 0; slider_pos = 0;
else if ( SliderPos > BarLength - SliderLength ) else if ( slider_pos > bar_length - slider_length )
SliderPos = BarLength - SliderLength; slider_pos = bar_length - slider_length;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -528,7 +528,7 @@ void FScrollbar::setOrientation (int o)
if ( isNewFont() ) if ( isNewFont() )
nf = 2; nf = 2;
} }
SliderLength = BarLength = length-nf-2; slider_length = bar_length = length-nf-2;
bar_orientation = o; bar_orientation = o;
} }
@ -554,13 +554,13 @@ void FScrollbar::setGeometry (int x, int y, int w, int h, bool adjust)
nf = 2; nf = 2;
} }
SliderLength = BarLength = length-nf-2; slider_length = bar_length = length-nf-2;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollbar::drawBar() void FScrollbar::drawBar()
{ {
if (SliderPos != currentSliderPos) if ( slider_pos != current_slider_pos )
{ {
int z; int z;
updateVTerm(false); updateVTerm(false);
@ -569,7 +569,7 @@ void FScrollbar::drawBar()
{ {
setColor (wc.scrollbar_fg, wc.scrollbar_bg); setColor (wc.scrollbar_fg, wc.scrollbar_bg);
for (z=1; z <= SliderPos; z++) for (z=1; z <= slider_pos; z++)
{ {
printPos (1, 1 + z); printPos (1, 1 + z);
@ -587,9 +587,9 @@ void FScrollbar::drawBar()
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
for (z=1; z <= SliderLength; z++) for (z=1; z <= slider_length; z++)
{ {
printPos (1, 1 + SliderPos + z); printPos (1, 1 + slider_pos + z);
if ( isNewFont() ) if ( isNewFont() )
print (' '); print (' ');
@ -602,7 +602,7 @@ void FScrollbar::drawBar()
setColor (wc.scrollbar_fg, wc.scrollbar_bg); setColor (wc.scrollbar_fg, wc.scrollbar_bg);
for (z=SliderPos+SliderLength+1; z <= BarLength; z++) for (z=slider_pos+slider_length+1; z <= bar_length; z++)
{ {
printPos (1, 1 + z); printPos (1, 1 + z);
@ -625,7 +625,7 @@ void FScrollbar::drawBar()
else else
printPos (2 + z, 1); printPos (2 + z, 1);
for (; z < SliderPos; z++) for (; z < slider_pos; z++)
{ {
if ( isNewFont() ) if ( isNewFont() )
print (fc::NF_border_line_upper); // ¯ print (fc::NF_border_line_upper); // ¯
@ -642,16 +642,16 @@ void FScrollbar::drawBar()
z = 0; z = 0;
for (; z < SliderLength; z++) for (; z < slider_length; z++)
print (' '); print (' ');
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
setColor (wc.scrollbar_fg, wc.scrollbar_bg); setColor (wc.scrollbar_fg, wc.scrollbar_bg);
z = SliderPos + SliderLength + 1; z = slider_pos + slider_length + 1;
for (; z <= BarLength; z++) for (; z <= bar_length; z++)
{ {
if ( isNewFont() ) if ( isNewFont() )
print (fc::NF_border_line_upper); // ¯ print (fc::NF_border_line_upper); // ¯
@ -662,7 +662,7 @@ void FScrollbar::drawBar()
} }
} }
currentSliderPos = SliderPos; current_slider_pos = slider_pos;
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);

View File

@ -35,28 +35,8 @@
class FScrollbar : public FWidget class FScrollbar : public FWidget
{ {
private:
int scrollType;
bool thresholdReached;
int thresholdTime;
int repeatTime;
int SliderClickPos;
int SliderClickStopPos;
int currentSliderPos;
int SliderPos;
int SliderLength;
int BarLength;
int val;
int min;
int max;
float steps;
int pageSize;
int length;
int bar_orientation;
int max_color;
public: public:
enum scroll_type enum sType
{ {
noScroll = 0, noScroll = 0,
scrollJump = 1, scrollJump = 1,
@ -68,45 +48,65 @@ class FScrollbar : public FWidget
scrollWheelDown = 7 scrollWheelDown = 7
}; };
private:
sType scroll_type;
bool threshold_reached;
int threshold_time;
int repeat_time;
int slider_click_pos;
int slider_click_stop_pos;
int current_slider_pos;
int slider_pos;
int slider_length;
int bar_length;
int val;
int min;
int max;
float steps;
int pageSize;
int length;
int bar_orientation;
int max_color;
private: private:
FScrollbar (const FScrollbar&); FScrollbar (const FScrollbar&);
FScrollbar& operator = (const FScrollbar&); FScrollbar& operator = (const FScrollbar&);
void init(); void init();
void draw(); void draw();
int getClickedScrollType (int, int); sType getClickedScrollType (int, int);
void processMiddleButton (int, int); void processMiddleButton (int, int);
void processScroll(); void processScroll();
public: public:
explicit FScrollbar(FWidget* = 0); // constructor explicit FScrollbar(FWidget* = 0); // constructor
FScrollbar(int = fc::vertical, FWidget* = 0); // constructor FScrollbar (int = fc::vertical, FWidget* = 0); // constructor
virtual ~FScrollbar(); virtual ~FScrollbar();
const char* getClassName() const; const char* getClassName() const;
void onMouseDown (FMouseEvent*); void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*); void onMouseUp (FMouseEvent*);
void onMouseMove (FMouseEvent*); void onMouseMove (FMouseEvent*);
void onWheel (FWheelEvent*); void onWheel (FWheelEvent*);
void onTimer (FTimerEvent*); void onTimer (FTimerEvent*);
void resize(); void resize();
void redraw(); void redraw();
void setMinimum (int); void setMinimum (int);
void setMaximum (int); void setMaximum (int);
void setRange (int, int); void setRange (int, int);
void setValue (int); void setValue (int);
int getValue() const; int getValue() const;
void setSteps (float); void setSteps (float);
void setPageSize (int, int); void setPageSize (int, int);
void calculateSliderValues(); void calculateSliderValues();
void setOrientation (int); void setOrientation (int);
// make every setGeometry from FWidget available // make every setGeometry from FWidget available
using FWidget::setGeometry; using FWidget::setGeometry;
void setGeometry (int, int, int, int, bool = true); void setGeometry (int, int, int, int, bool = true);
void drawButtons(); void drawButtons();
void drawBar(); void drawBar();
int getScrollType() const; sType getScrollType() const;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -121,7 +121,7 @@ inline int FScrollbar::getValue() const
{ return val; } { return val; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline int FScrollbar::getScrollType() const inline FScrollbar::sType FScrollbar::getScrollType() const
{ return scrollType; } { return scroll_type; }
#endif // _FSCROLLBAR_H #endif // _FSCROLLBAR_H

View File

@ -47,14 +47,14 @@ typedef unsigned short uInt16;
typedef unsigned int uInt32; typedef unsigned int uInt32;
typedef u_int64_t uInt64; typedef u_int64_t uInt64;
typedef signed int sInt; typedef signed int sInt;
typedef signed long sLong; typedef signed long sLong;
typedef signed char sInt8; typedef signed char sInt8;
typedef signed short sInt16; typedef signed short sInt16;
typedef signed int sInt32; typedef signed int sInt32;
typedef int64_t sInt64; typedef int64_t sInt64;
typedef long double lDouble; typedef long double lDouble;
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -34,7 +34,7 @@ uInt FTerm::baudrate;
uInt FTerm::tabstop; uInt FTerm::tabstop;
uInt FTerm::attr_without_color; uInt FTerm::attr_without_color;
bool FTerm::resize_term; bool FTerm::resize_term;
bool FTerm::hiddenCursor; bool FTerm::hidden_cursor;
bool FTerm::mouse_support; bool FTerm::mouse_support;
bool FTerm::raw_mode; bool FTerm::raw_mode;
bool FTerm::input_data_pending; bool FTerm::input_data_pending;
@ -93,8 +93,8 @@ char FTerm::exit_message[8192] = "";
fc::encoding FTerm::Encoding; fc::encoding FTerm::Encoding;
const FString* FTerm::xterm_font = 0; const FString* FTerm::xterm_font = 0;
const FString* FTerm::xterm_title = 0; const FString* FTerm::xterm_title = 0;
const FString* FTerm::AnswerBack = 0; const FString* FTerm::answer_back = 0;
const FString* FTerm::Sec_DA = 0; const FString* FTerm::sec_da = 0;
FOptiMove* FTerm::opti_move = 0; FOptiMove* FTerm::opti_move = 0;
FOptiAttr* FTerm::opti_attr = 0; FOptiAttr* FTerm::opti_attr = 0;
FTerm::modifier_key FTerm::mod_key; FTerm::modifier_key FTerm::mod_key;
@ -109,10 +109,9 @@ std::map<std::string,fc::encoding>* \
FTerm::encoding_set = 0; FTerm::encoding_set = 0;
FOptiAttr::char_data FTerm::term_attribute; FOptiAttr::char_data FTerm::term_attribute;
FOptiAttr::char_data FTerm::next_attribute; FOptiAttr::char_data FTerm::next_attribute;
console_font_op FTerm::screenFont; console_font_op FTerm::screen_font;
unimapdesc FTerm::screenUnicodeMap; unimapdesc FTerm::screen_unicode_map;
fc::console_cursor_style \ fc::consoleCursorStyle FTerm::console_cursor_style;
FTerm::consoleCursorStyle;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -373,10 +372,10 @@ int FTerm::getScreenFont()
if ( ret == 0 ) if ( ret == 0 )
{ {
screenFont.width = font.width; screen_font.width = font.width;
screenFont.height = font.height; screen_font.height = font.height;
screenFont.charcount = font.charcount; screen_font.charcount = font.charcount;
screenFont.data = font.data; screen_font.data = font.data;
return 0; return 0;
} }
else else
@ -484,8 +483,8 @@ int FTerm::getUnicodeMap()
if ( ret == 0 ) if ( ret == 0 )
{ {
screenUnicodeMap.entry_ct = unimap.entry_ct; screen_unicode_map.entry_ct = unimap.entry_ct;
screenUnicodeMap.entries = unimap.entries; screen_unicode_map.entries = unimap.entries;
} }
else else
return -1; return -1;
@ -734,8 +733,8 @@ void FTerm::getModifierKey()
void FTerm::init_console() void FTerm::init_console()
{ {
fd_tty = -1; fd_tty = -1;
screenUnicodeMap.entries = 0; screen_unicode_map.entries = 0;
screenFont.data = 0; screen_font.data = 0;
if ( openConsole() == 0 ) if ( openConsole() == 0 )
{ {
@ -785,15 +784,15 @@ uInt FTerm::getBaudRate (const struct termios* termios_p)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::init_consoleCharMap() void FTerm::init_consoleCharMap()
{ {
if ( screenUnicodeMap.entry_ct != 0 ) if ( screen_unicode_map.entry_ct != 0 )
{ {
for (int i=0; i <= lastCharItem; i++ ) for (int i=0; i <= lastCharItem; i++ )
{ {
bool found = false; bool found = false;
for (uInt n=0; n < screenUnicodeMap.entry_ct; n++) for (uInt n=0; n < screen_unicode_map.entry_ct; n++)
{ {
if ( character[i][fc::UTF8] == screenUnicodeMap.entries[n].unicode ) if ( character[i][fc::UTF8] == screen_unicode_map.entries[n].unicode )
{ {
found = true; found = true;
break; break;
@ -928,9 +927,9 @@ char* FTerm::parseAnswerbackMsg (char*& current_termtype)
char* new_termtype = current_termtype; char* new_termtype = current_termtype;
// send ENQ and read the answerback message // send ENQ and read the answerback message
AnswerBack = new FString(getAnswerbackMsg()); answer_back = new FString(getAnswerbackMsg());
if ( AnswerBack && *AnswerBack == FString("PuTTY") ) if ( answer_back && *answer_back == FString("PuTTY") )
{ {
putty_terminal = true; putty_terminal = true;
@ -960,36 +959,36 @@ char* FTerm::parseSecDA (char*& current_termtype)
return new_termtype; return new_termtype;
// secondary device attributes (SEC_DA) <- decTerminalID string // secondary device attributes (SEC_DA) <- decTerminalID string
Sec_DA = new FString(getSecDA()); sec_da = new FString(getSecDA());
if ( Sec_DA && Sec_DA->getLength() > 5 ) if ( sec_da && sec_da->getLength() > 5 )
{ {
uLong num_components; uLong num_components;
// remove the first 3 bytes ("\033[>") // remove the first 3 bytes ("\033[>")
FString temp = Sec_DA->right(Sec_DA->getLength() - 3); FString temp = sec_da->right(sec_da->getLength() - 3);
// remove the last byte ("c") // remove the last byte ("c")
temp.remove(temp.getLength()-1, 1); temp.remove(temp.getLength()-1, 1);
// split into components // split into components
std::vector<FString> Sec_DA_split = temp.split(';'); std::vector<FString> sec_da_split = temp.split(';');
num_components = Sec_DA_split.size(); num_components = sec_da_split.size();
if ( num_components == 3 ) if ( num_components == 3 )
sec_da_supported = true; sec_da_supported = true;
if ( num_components >= 2 ) if ( num_components >= 2 )
{ {
FString* Sec_DA_components = &Sec_DA_split[0]; FString* sec_da_components = &sec_da_split[0];
if ( ! Sec_DA_components[0].isEmpty() ) if ( ! sec_da_components[0].isEmpty() )
{ {
int terminal_id_type, terminal_id_version; int terminal_id_type, terminal_id_version;
// Read the terminal type // Read the terminal type
try try
{ {
terminal_id_type = Sec_DA_components[0].toInt(); terminal_id_type = sec_da_components[0].toInt();
} }
catch (const std::exception&) catch (const std::exception&)
{ {
@ -999,8 +998,8 @@ char* FTerm::parseSecDA (char*& current_termtype)
// Read the terminal (firmware) version // Read the terminal (firmware) version
try try
{ {
if ( Sec_DA_components[1] ) if ( sec_da_components[1] )
terminal_id_version = Sec_DA_components[1].toInt(); terminal_id_version = sec_da_components[1].toInt();
else else
terminal_id_version = -1; terminal_id_version = -1;
} }
@ -1672,7 +1671,7 @@ void FTerm::init()
NewFont = \ NewFont = \
VGAFont = \ VGAFont = \
ascii_console = \ ascii_console = \
hiddenCursor = \ hidden_cursor = \
mouse_support = \ mouse_support = \
force_vt100 = \ force_vt100 = \
tera_terminal = \ tera_terminal = \
@ -2114,11 +2113,11 @@ void FTerm::finish()
setOldFont(); setOldFont();
else else
{ {
if ( screenFont.data != 0 ) if ( screen_font.data != 0 )
delete[] screenFont.data; delete[] screen_font.data;
if ( screenUnicodeMap.entries != 0 ) if ( screen_unicode_map.entries != 0 )
delete[] screenUnicodeMap.entries; delete[] screen_unicode_map.entries;
} }
if ( encoding_set ) if ( encoding_set )
@ -2130,11 +2129,11 @@ void FTerm::finish()
if ( output_buffer ) if ( output_buffer )
delete output_buffer; delete output_buffer;
if ( Sec_DA ) if ( sec_da )
delete Sec_DA; delete sec_da;
if ( AnswerBack ) if ( answer_back )
delete AnswerBack; delete answer_back;
if ( xterm_title ) if ( xterm_title )
delete xterm_title; delete xterm_title;
@ -3295,23 +3294,23 @@ bool FTerm::setOldFont()
{ {
if ( isConsole() ) if ( isConsole() )
{ {
if ( screenFont.data ) if ( screen_font.data )
{ {
int ret = setScreenFont ( screenFont.data int ret = setScreenFont ( screen_font.data
, screenFont.charcount , screen_font.charcount
, screenFont.width , screen_font.width
, screenFont.height , screen_font.height
, true ); , true );
delete[] screenFont.data; delete[] screen_font.data;
if ( ret == 0 ) if ( ret == 0 )
retval = true; retval = true;
} }
if ( screenUnicodeMap.entries ) if ( screen_unicode_map.entries )
{ {
setUnicodeMap (&screenUnicodeMap); setUnicodeMap (&screen_unicode_map);
delete[] screenUnicodeMap.entries; delete[] screen_unicode_map.entries;
} }
} }
@ -3325,14 +3324,14 @@ bool FTerm::setOldFont()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::setConsoleCursor (fc::console_cursor_style style) void FTerm::setConsoleCursor (fc::consoleCursorStyle style)
{ {
// Set cursor style in linux console // Set cursor style in linux console
if ( linux_terminal ) if ( linux_terminal )
{ {
consoleCursorStyle = style; console_cursor_style = style;
if ( hiddenCursor ) if ( hidden_cursor )
return; return;
putstringf (CSI "?%dc", style); putstringf (CSI "?%dc", style);
@ -3583,7 +3582,7 @@ void FTerm::updateTerminal (bool on)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::setKDECursor (fc::kde_konsole_CursorShape style) void FTerm::setKDECursor (fc::kdeKonsoleCursorShape style)
{ {
// Set cursor style in KDE konsole // Set cursor style in KDE konsole
if ( kde_konsole ) if ( kde_konsole )
@ -3658,7 +3657,7 @@ FString FTerm::getXTermTitle()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::setXTermCursorStyle (fc::xterm_cursor_style style) void FTerm::setXTermCursorStyle (fc::xtermCursorStyle style)
{ {
// Set the xterm cursor style // Set the xterm cursor style
if ( (xterm || mintty_terminal) && ! (gnome_terminal || kde_konsole) ) if ( (xterm || mintty_terminal) && ! (gnome_terminal || kde_konsole) )
@ -4097,8 +4096,8 @@ bool FTerm::hideCursor (bool on)
{ {
char *vi, *vs, *ve; char *vi, *vs, *ve;
if ( on == hiddenCursor ) if ( on == hidden_cursor )
return hiddenCursor; return hidden_cursor;
vi = tcap[t_cursor_invisible].string; vi = tcap[t_cursor_invisible].string;
vs = tcap[t_cursor_visible].string; vs = tcap[t_cursor_visible].string;
@ -4109,7 +4108,7 @@ bool FTerm::hideCursor (bool on)
if ( vi ) if ( vi )
appendOutputBuffer (vi); appendOutputBuffer (vi);
hiddenCursor = true; // global hidden_cursor = true; // global
} }
else else
{ {
@ -4118,15 +4117,15 @@ bool FTerm::hideCursor (bool on)
else if ( vs ) else if ( vs )
appendOutputBuffer (vs); appendOutputBuffer (vs);
hiddenCursor = false; hidden_cursor = false;
} }
flush_out(); flush_out();
if ( ! hiddenCursor && linux_terminal ) if ( ! hidden_cursor && linux_terminal )
setConsoleCursor (consoleCursorStyle); setConsoleCursor (console_cursor_style);
return hiddenCursor; return hidden_cursor;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -4334,7 +4333,7 @@ FString FTerm::getAnswerbackMsg()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FString FTerm::getSecDA() FString FTerm::getSecDA()
{ {
FString sec_da = ""; FString sec_da_str = "";
if ( raw_mode ) if ( raw_mode )
{ {
@ -4365,12 +4364,12 @@ FString FTerm::getSecDA()
if ( n > 0 ) if ( n > 0 )
{ {
temp[n] = '\0'; temp[n] = '\0';
sec_da = temp; sec_da_str = temp;
} }
} }
} }
return sec_da; return sec_da_str;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -104,7 +104,7 @@ class FTerm
static std::map <uChar,uChar>* vt100_alt_char; static std::map <uChar,uChar>* vt100_alt_char;
static std::map <std::string,fc::encoding>* encoding_set; static std::map <std::string,fc::encoding>* encoding_set;
static bool hiddenCursor; static bool hidden_cursor;
static bool mouse_support; static bool mouse_support;
static bool raw_mode; static bool raw_mode;
static bool input_data_pending; static bool input_data_pending;
@ -168,16 +168,16 @@ class FTerm
static FOptiAttr::char_data term_attribute; static FOptiAttr::char_data term_attribute;
static FOptiAttr::char_data next_attribute; static FOptiAttr::char_data next_attribute;
static fc::console_cursor_style consoleCursorStyle; static fc::consoleCursorStyle console_cursor_style;
static struct console_font_op screenFont; static struct console_font_op screen_font;
static struct unimapdesc screenUnicodeMap; static struct unimapdesc screen_unicode_map;
static FOptiMove* opti_move; static FOptiMove* opti_move;
static FOptiAttr* opti_attr; static FOptiAttr* opti_attr;
static const FString* xterm_font; static const FString* xterm_font;
static const FString* xterm_title; static const FString* xterm_title;
static const FString* AnswerBack; static const FString* answer_back;
static const FString* Sec_DA; static const FString* sec_da;
typedef struct typedef struct
{ {
@ -336,7 +336,7 @@ class FTerm
static bool isNewFont(); static bool isNewFont();
static bool setOldFont(); static bool setOldFont();
static bool setCursorOptimisation (bool); static bool setCursorOptimisation (bool);
static void setConsoleCursor (fc::console_cursor_style); static void setConsoleCursor (fc::consoleCursorStyle);
static void getTermSize(); static void getTermSize();
static void setTermSize (int, int); static void setTermSize (int, int);
void createVTerm(); void createVTerm();
@ -344,10 +344,10 @@ class FTerm
static void putVTerm(); static void putVTerm();
static void updateTerminal(); static void updateTerminal();
static void updateTerminal (bool); static void updateTerminal (bool);
static void setKDECursor (fc::kde_konsole_CursorShape); static void setKDECursor (fc::kdeKonsoleCursorShape);
static FString getXTermFont(); static FString getXTermFont();
static FString getXTermTitle(); static FString getXTermTitle();
static void setXTermCursorStyle (fc::xterm_cursor_style); static void setXTermCursorStyle (fc::xtermCursorStyle);
static void setXTermTitle (const FString&); static void setXTermTitle (const FString&);
static void setXTermForeground (const FString&); static void setXTermForeground (const FString&);
static void setXTermBackground (const FString&); static void setXTermBackground (const FString&);
@ -553,7 +553,7 @@ inline bool FTerm::isNewFont()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTerm::isHiddenCursor() inline bool FTerm::isHiddenCursor()
{ return hiddenCursor; } { return hidden_cursor; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTerm::isMonochron() inline bool FTerm::isMonochron()

View File

@ -14,8 +14,8 @@
FTextView::FTextView(FWidget* parent) FTextView::FTextView(FWidget* parent)
: FWidget(parent) : FWidget(parent)
, data() , data()
, VBar(0) , vbar(0)
, HBar(0) , hbar(0)
, xoffset(0) , xoffset(0)
, yoffset(0) , yoffset(0)
, nf_offset(0) , nf_offset(0)
@ -27,8 +27,8 @@ FTextView::FTextView(FWidget* parent)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FTextView::~FTextView() // destructor FTextView::~FTextView() // destructor
{ {
delete VBar; delete vbar;
delete HBar; delete hbar;
} }
// private methods of FTextView // private methods of FTextView
@ -40,22 +40,22 @@ void FTextView::init()
setForegroundColor (wc.dialog_fg); setForegroundColor (wc.dialog_fg);
setBackgroundColor (wc.dialog_bg); setBackgroundColor (wc.dialog_bg);
VBar = new FScrollbar(fc::vertical, this); vbar = new FScrollbar(fc::vertical, this);
VBar->setMinimum(0); vbar->setMinimum(0);
VBar->setValue(0); vbar->setValue(0);
VBar->hide(); vbar->hide();
HBar = new FScrollbar(fc::horizontal, this); hbar = new FScrollbar(fc::horizontal, this);
HBar->setMinimum(0); hbar->setMinimum(0);
HBar->setValue(0); hbar->setValue(0);
HBar->hide(); hbar->hide();
VBar->addCallback vbar->addCallback
( (
"change-value", "change-value",
_METHOD_CALLBACK (this, &FTextView::cb_VBarChange) _METHOD_CALLBACK (this, &FTextView::cb_VBarChange)
); );
HBar->addCallback hbar->addCallback
( (
"change-value", "change-value",
_METHOD_CALLBACK (this, &FTextView::cb_HBarChange) _METHOD_CALLBACK (this, &FTextView::cb_HBarChange)
@ -77,11 +77,11 @@ void FTextView::draw()
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
if ( VBar->isVisible() ) if ( vbar->isVisible() )
VBar->redraw(); vbar->redraw();
if ( HBar->isVisible() ) if ( hbar->isVisible() )
HBar->redraw(); hbar->redraw();
updateVTerm(true); updateVTerm(true);
drawText(); drawText();
@ -190,29 +190,29 @@ void FTextView::adjustSize()
if ( yoffset < 0 ) if ( yoffset < 0 )
yoffset = 0; yoffset = 0;
VBar->setMaximum (last_line - height + 2 - nf_offset); vbar->setMaximum (last_line - height + 2 - nf_offset);
VBar->setPageSize (last_line, height - 2 + nf_offset); vbar->setPageSize (last_line, height - 2 + nf_offset);
VBar->setX (width); vbar->setX (width);
VBar->setHeight (height - 2 + nf_offset, false); vbar->setHeight (height - 2 + nf_offset, false);
VBar->setValue (yoffset); vbar->setValue (yoffset);
VBar->resize(); vbar->resize();
HBar->setMaximum (max_width - width + nf_offset + 2); hbar->setMaximum (max_width - width + nf_offset + 2);
HBar->setPageSize (max_width, width - nf_offset - 2); hbar->setPageSize (max_width, width - nf_offset - 2);
HBar->setY (height); hbar->setY (height);
HBar->setWidth (width - 2, false); hbar->setWidth (width - 2, false);
HBar->setValue (xoffset); hbar->setValue (xoffset);
HBar->resize(); hbar->resize();
if ( last_line < height + nf_offset - 1 ) if ( last_line < height + nf_offset - 1 )
VBar->hide(); vbar->hide();
else else
VBar->setVisible(); vbar->setVisible();
if ( max_width < width - nf_offset - 1 ) if ( max_width < width - nf_offset - 1 )
HBar->hide(); hbar->hide();
else else
HBar->setVisible(); hbar->setVisible();
} }
@ -338,15 +338,15 @@ void FTextView::onKeyPress (FKeyEvent* ev)
if ( isVisible() ) if ( isVisible() )
drawText(); drawText();
VBar->setValue (yoffset); vbar->setValue (yoffset);
if ( VBar->isVisible() ) if ( vbar->isVisible() )
VBar->drawBar(); vbar->drawBar();
HBar->setValue (xoffset); hbar->setValue (xoffset);
if ( HBar->isVisible() ) if ( hbar->isVisible() )
HBar->drawBar(); hbar->drawBar();
updateTerminal(); updateTerminal();
flush_out(); flush_out();
@ -417,15 +417,15 @@ void FTextView::onWheel (FWheelEvent* ev)
if ( isVisible() ) if ( isVisible() )
drawText(); drawText();
VBar->setValue (yoffset); vbar->setValue (yoffset);
if ( VBar->isVisible() ) if ( vbar->isVisible() )
VBar->drawBar(); vbar->drawBar();
HBar->setValue (xoffset); hbar->setValue (xoffset);
if ( HBar->isVisible() ) if ( hbar->isVisible() )
HBar->drawBar(); hbar->drawBar();
updateTerminal(); updateTerminal();
} }
@ -450,10 +450,11 @@ void FTextView::onFocusOut (FFocusEvent*)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTextView::cb_VBarChange (FWidget*, void*) void FTextView::cb_VBarChange (FWidget*, void*)
{ {
FScrollbar::sType scrollType;
int distance = 1; int distance = 1;
int last_line = int(getRows()); int last_line = int(getRows());
int yoffset_before = yoffset; int yoffset_before = yoffset;
int scrollType = VBar->getScrollType(); scrollType = vbar->getScrollType();
switch ( scrollType ) switch ( scrollType )
{ {
@ -481,7 +482,7 @@ void FTextView::cb_VBarChange (FWidget*, void*)
case FScrollbar::scrollJump: case FScrollbar::scrollJump:
{ {
int val = VBar->getValue(); int val = vbar->getValue();
if ( yoffset == val ) if ( yoffset == val )
break; break;
@ -524,10 +525,10 @@ void FTextView::cb_VBarChange (FWidget*, void*)
if ( scrollType >= FScrollbar::scrollStepBackward if ( scrollType >= FScrollbar::scrollStepBackward
&& scrollType <= FScrollbar::scrollPageForward ) && scrollType <= FScrollbar::scrollPageForward )
{ {
VBar->setValue (yoffset); vbar->setValue (yoffset);
if ( VBar->isVisible() && yoffset_before != yoffset ) if ( vbar->isVisible() && yoffset_before != yoffset )
VBar->drawBar(); vbar->drawBar();
updateTerminal(); updateTerminal();
} }
@ -539,7 +540,7 @@ void FTextView::cb_HBarChange (FWidget*, void*)
int distance = 1; int distance = 1;
int xoffset_before = xoffset; int xoffset_before = xoffset;
int xoffset_end = int(maxLineWidth) - getWidth() + nf_offset + 4; int xoffset_end = int(maxLineWidth) - getWidth() + nf_offset + 4;
int scrollType = HBar->getScrollType(); int scrollType = hbar->getScrollType();
switch ( scrollType ) switch ( scrollType )
{ {
@ -570,7 +571,7 @@ void FTextView::cb_HBarChange (FWidget*, void*)
case FScrollbar::scrollJump: case FScrollbar::scrollJump:
{ {
int val = HBar->getValue(); int val = hbar->getValue();
if ( xoffset == val ) if ( xoffset == val )
break; break;
@ -621,10 +622,10 @@ void FTextView::cb_HBarChange (FWidget*, void*)
if ( scrollType >= FScrollbar::scrollStepBackward if ( scrollType >= FScrollbar::scrollStepBackward
&& scrollType <= FScrollbar::scrollWheelDown ) && scrollType <= FScrollbar::scrollWheelDown )
{ {
HBar->setValue (xoffset); hbar->setValue (xoffset);
if ( HBar->isVisible() && xoffset_before != xoffset ) if ( hbar->isVisible() && xoffset_before != xoffset )
HBar->drawBar(); hbar->drawBar();
updateTerminal(); updateTerminal();
} }
@ -639,17 +640,17 @@ void FTextView::setGeometry (int x, int y, int w, int h, bool adjust)
if ( isNewFont() ) if ( isNewFont() )
{ {
VBar->setGeometry (width, 1, 2, height-1); vbar->setGeometry (width, 1, 2, height-1);
HBar->setGeometry (1, height, width-2, 1); hbar->setGeometry (1, height, width-2, 1);
} }
else else
{ {
VBar->setGeometry (width, 2, 1, height-2); vbar->setGeometry (width, 2, 1, height-2);
HBar->setGeometry (2, height, width-2, 1); hbar->setGeometry (2, height, width-2, 1);
} }
VBar->resize(); vbar->resize();
HBar->resize(); hbar->resize();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -665,10 +666,10 @@ void FTextView::setPosition (int pos)
if ( isVisible() ) if ( isVisible() )
drawText(); drawText();
VBar->setValue (yoffset); vbar->setValue (yoffset);
if ( VBar->isVisible() ) if ( vbar->isVisible() )
VBar->drawBar(); vbar->drawBar();
flush_out(); flush_out();
} }
@ -757,26 +758,26 @@ void FTextView::insert (const FString& str, int pos)
if ( len > uInt(getWidth() - nf_offset - 2) ) if ( len > uInt(getWidth() - nf_offset - 2) )
{ {
HBar->setMaximum (int(maxLineWidth) - getWidth() + nf_offset + 2); hbar->setMaximum (int(maxLineWidth) - getWidth() + nf_offset + 2);
HBar->setPageSize (int(maxLineWidth), getWidth() - nf_offset - 2); hbar->setPageSize (int(maxLineWidth), getWidth() - nf_offset - 2);
HBar->calculateSliderValues(); hbar->calculateSliderValues();
if ( ! HBar->isVisible() ) if ( ! hbar->isVisible() )
HBar->setVisible(); hbar->setVisible();
} }
} }
} }
data.insert (iter + pos, text_split.begin(), text_split.end()); data.insert (iter + pos, text_split.begin(), text_split.end());
VBar->setMaximum (int(getRows()) - getHeight() + 2 - nf_offset); vbar->setMaximum (int(getRows()) - getHeight() + 2 - nf_offset);
VBar->setPageSize (int(getRows()), getHeight() - 2 + nf_offset); vbar->setPageSize (int(getRows()), getHeight() - 2 + nf_offset);
VBar->calculateSliderValues(); vbar->calculateSliderValues();
if ( ! VBar->isVisible() && int(getRows()) >= getHeight() + nf_offset - 1 ) if ( ! vbar->isVisible() && int(getRows()) >= getHeight() + nf_offset - 1 )
VBar->setVisible(); vbar->setVisible();
if ( VBar->isVisible() && int(getRows()) < getHeight() + nf_offset - 1 ) if ( vbar->isVisible() && int(getRows()) < getHeight() + nf_offset - 1 )
VBar->hide(); vbar->hide();
processChanged(); processChanged();
} }
@ -813,13 +814,13 @@ void FTextView::clear()
yoffset = 0; yoffset = 0;
maxLineWidth = 0; maxLineWidth = 0;
VBar->setMinimum(0); vbar->setMinimum(0);
VBar->setValue(0); vbar->setValue(0);
VBar->hide(); vbar->hide();
HBar->setMinimum(0); hbar->setMinimum(0);
HBar->setValue(0); hbar->setValue(0);
HBar->hide(); hbar->hide();
// clear list from screen // clear list from screen
setColor(); setColor();

View File

@ -42,8 +42,8 @@ class FTextView : public FWidget
private: private:
typedef std::vector<FString> stringLines; typedef std::vector<FString> stringLines;
stringLines data; stringLines data;
FScrollbar* VBar; FScrollbar* vbar;
FScrollbar* HBar; FScrollbar* hbar;
int xoffset; int xoffset;
int yoffset; int yoffset;
int nf_offset; int nf_offset;

View File

@ -41,10 +41,10 @@ class FToggleButton : public FWidget
bool focus_inside_group; bool focus_inside_group;
protected: protected:
FString text; FString text;
bool checked; bool checked;
int label_offset_pos; int label_offset_pos;
int button_width; // plus margin spaces int button_width; // plus margin spaces
FButtonGroup* button_group; FButtonGroup* button_group;
private: private:

View File

@ -39,8 +39,8 @@ FWidget::FWidget (FWidget* parent)
, shown(false) , shown(false)
, focus(false) , focus(false)
, focusable(true) , focusable(true)
, visibleCursor(false) , visible_cursor(false)
, widgetCursorPosition(-1,-1) , widget_cursor_position(-1,-1)
, size_hints() , size_hints()
, double_flatline_mask() , double_flatline_mask()
, padding() , padding()
@ -1929,7 +1929,7 @@ void FWidget::move (int x, int y)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FWidget::setCursor() bool FWidget::setCursor()
{ {
FPoint* wcursor = &widgetCursorPosition; FPoint* wcursor = &widget_cursor_position;
if ( isCursorInside() ) if ( isCursorInside() )
{ {
@ -1944,7 +1944,7 @@ bool FWidget::setCursor()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FWidget::setCursorPos (register int x, register int y) bool FWidget::setCursorPos (register int x, register int y)
{ {
widgetCursorPosition.setPoint(x,y); widget_cursor_position.setPoint(x,y);
if ( isCursorInside() ) if ( isCursorInside() )
return true; return true;

View File

@ -226,8 +226,8 @@ class FWidget : public FObject, public FTerm
bool shown; bool shown;
bool focus; bool focus;
bool focusable; bool focusable;
bool visibleCursor; bool visible_cursor;
FPoint widgetCursorPosition; FPoint widget_cursor_position;
struct widget_size_hints struct widget_size_hints
{ {
@ -660,7 +660,7 @@ inline bool FWidget::isEnabled() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FWidget::setVisibleCursor (bool on) inline bool FWidget::setVisibleCursor (bool on)
{ return visibleCursor = (on) ? true : false; } { return visible_cursor = (on) ? true : false; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FWidget::setVisibleCursor() inline bool FWidget::setVisibleCursor()
@ -672,7 +672,7 @@ inline bool FWidget::unsetVisibleCursor()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FWidget::hasVisibleCursor() const inline bool FWidget::hasVisibleCursor() const
{ return visibleCursor; } { return visible_cursor; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FWidget::setFocus() inline bool FWidget::setFocus()
@ -895,7 +895,7 @@ inline int FWidget::getFlags() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FPoint FWidget::getCursorPos() inline FPoint FWidget::getCursorPos()
{ return widgetCursorPosition; } { return widget_cursor_position; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FWidget::setCursorPos (const FPoint& pos) inline bool FWidget::setCursorPos (const FPoint& pos)
@ -903,7 +903,7 @@ inline bool FWidget::setCursorPos (const FPoint& pos)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FWidget::unsetCursorPos() inline void FWidget::unsetCursorPos()
{ widgetCursorPosition.setPoint(-1,-1); } { widget_cursor_position.setPoint(-1,-1); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FWidget::printPos (const FPoint& pos) inline void FWidget::printPos (const FPoint& pos)

View File

@ -10,6 +10,55 @@
#include "fstatusbar.h" #include "fstatusbar.h"
#include "fstring.h" #include "fstring.h"
//----------------------------------------------------------------------
// class smallWindow
//----------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
class smallWindow : public FDialog
{
private:
FLabel* label;
private:
smallWindow (const smallWindow&); // Disabled copy constructor
smallWindow& operator = (const smallWindow&); // and operator '='
void adjustSize();
public:
explicit smallWindow (FWidget* = 0); // constructor
~smallWindow(); // destructor
void append (const FString&);
};
#pragma pack(pop)
//----------------------------------------------------------------------
smallWindow::smallWindow (FWidget* parent)
: FDialog(parent)
, label()
{
FString label_text = "resize \n"
"corner \u25E2";
label = new FLabel (label_text, this);
label->setAlignment (fc::alignRight);
label->setForegroundColor (fc::DarkGray);
label->setGeometry (13, 4, 8, 2);
}
//----------------------------------------------------------------------
smallWindow::~smallWindow()
{ }
//----------------------------------------------------------------------
void smallWindow::adjustSize()
{
FDialog::adjustSize();
label->setGeometry (1, getClientHeight() - 1, getClientWidth(), 2);
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class Window // class Window
@ -229,9 +278,9 @@ void Window::cb_createWindows (FWidget*, void*)
{ {
if ( ! (*iter)->is_open ) if ( ! (*iter)->is_open )
{ {
int x,y,n; int x, y, n;
win_data* win_dat = *iter; win_data* win_dat = *iter;
FDialog* win = new FDialog(this); FDialog* win = new smallWindow(this);
win_dat->dgl = win; win_dat->dgl = win;
win_dat->is_open = true; win_dat->is_open = true;
win->setText(*(win_dat)->title); win->setText(*(win_dat)->title);