Better code readability: control structures (if/else, while, switch) are now separated by a blank line.

This commit is contained in:
Markus Gans 2016-07-09 00:01:59 +02:00
parent 2b40854e2f
commit 9766ee4b6f
41 changed files with 1916 additions and 219 deletions

View File

@ -1,3 +1,7 @@
2016-07-08 Markus Gans <guru.mail@muenster.de>
* Better code readability: control structures (if/else, while, switch)
are now separated by a blank line.
2016-07-06 Markus Gans <guru.mail@muenster.de> 2016-07-06 Markus Gans <guru.mail@muenster.de>
* Stop terminal updates during processCloseWidget() is working * Stop terminal updates during processCloseWidget() is working

View File

@ -68,8 +68,10 @@ FApplication::~FApplication() // destructor
{ {
if ( zero_point ) if ( zero_point )
delete zero_point; delete zero_point;
if ( event_queue ) if ( event_queue )
delete event_queue; delete event_queue;
rootObj = 0; rootObj = 0;
} }
@ -130,6 +132,7 @@ void FApplication::cmd_options ()
{ {
FString encoding(optarg); FString encoding(optarg);
encoding = encoding.toUpper(); encoding = encoding.toUpper();
if ( encoding.includes("UTF8") if ( encoding.includes("UTF8")
|| encoding.includes("VT100") || encoding.includes("VT100")
|| encoding.includes("PC") || encoding.includes("PC")
@ -166,14 +169,18 @@ int FApplication::gpmEvent (bool clear)
tv.tv_sec = 0; tv.tv_sec = 0;
tv.tv_usec = 100000; // 100 ms tv.tv_usec = 100000; // 100 ms
result = select (max+1, &ifds, 0, 0, &tv); result = select (max+1, &ifds, 0, 0, &tv);
if ( FD_ISSET(stdin_no, &ifds) ) if ( FD_ISSET(stdin_no, &ifds) )
{ {
if ( clear ) if ( clear )
FD_CLR (stdin_no, &ifds); FD_CLR (stdin_no, &ifds);
return keyboard_event; return keyboard_event;
} }
if ( clear && FD_ISSET(gpm_fd, &ifds) ) if ( clear && FD_ISSET(gpm_fd, &ifds) )
FD_CLR (gpm_fd, &ifds); FD_CLR (gpm_fd, &ifds);
if (result > 0) if (result > 0)
return mouse_event; return mouse_event;
else else
@ -193,8 +200,10 @@ inline bool FApplication::KeyPressed()
tv.tv_sec = 0; tv.tv_sec = 0;
tv.tv_usec = 100000; // 100 ms tv.tv_usec = 100000; // 100 ms
result = select (stdin_no+1, &ifds, 0, 0, &tv); result = select (stdin_no+1, &ifds, 0, 0, &tv);
if ( FD_ISSET(stdin_no, &ifds) ) if ( FD_ISSET(stdin_no, &ifds) )
FD_CLR (stdin_no, &ifds); FD_CLR (stdin_no, &ifds);
return (result > 0); return (result > 0);
} }
@ -219,6 +228,7 @@ void FApplication::processKeyboardEvent()
else else
{ {
widget = static_cast<FWidget*>(main_widget); widget = static_cast<FWidget*>(main_widget);
if ( widget->numOfChildren() >= 1 ) if ( widget->numOfChildren() >= 1 )
widget->focusFirstChild(); widget->focusFirstChild();
} }
@ -239,6 +249,7 @@ void FApplication::processKeyboardEvent()
{ {
gpmMouseEvent = false; gpmMouseEvent = false;
int type = gpmEvent(); int type = gpmEvent();
switch ( type ) switch ( type )
{ {
case mouse_event: case mouse_event:
@ -276,6 +287,7 @@ void FApplication::processKeyboardEvent()
fifo_buf[fifo_offset] = k_buf[i]; fifo_buf[fifo_offset] = k_buf[i];
fifo_offset++; fifo_offset++;
} }
fifo_in_use = true; fifo_in_use = true;
} }
@ -302,9 +314,12 @@ void FApplication::processKeyboardEvent()
for (n=len; n < fifo_buf_size; n++) // Remove founded entry for (n=len; n < fifo_buf_size; n++) // Remove founded entry
fifo_buf[n-len] = fifo_buf[n]; fifo_buf[n-len] = fifo_buf[n];
n = fifo_buf_size-len-1; n = fifo_buf_size-len-1;
for (; n < fifo_buf_size; n++) // Fill rest with '\0' for (; n < fifo_buf_size; n++) // Fill rest with '\0'
fifo_buf[n-len] = '\0'; fifo_buf[n-len] = '\0';
input_data_pending = bool(fifo_buf[0] != '\0'); input_data_pending = bool(fifo_buf[0] != '\0');
processMouseEvent(); processMouseEvent();
} }
@ -317,15 +332,21 @@ void FApplication::processKeyboardEvent()
{ {
sgr_mouse[n-3] = fifo_buf[n]; sgr_mouse[n-3] = fifo_buf[n];
n++; n++;
if ( fifo_buf[n] == 'M' || fifo_buf[n] == 'm' ) if ( fifo_buf[n] == 'M' || fifo_buf[n] == 'm' )
len = n + 1; len = n + 1;
} }
sgr_mouse[n-3] = '\0'; sgr_mouse[n-3] = '\0';
for (n=len; n < fifo_buf_size; n++) // Remove founded entry for (n=len; n < fifo_buf_size; n++) // Remove founded entry
fifo_buf[n-len] = fifo_buf[n]; fifo_buf[n-len] = fifo_buf[n];
n = fifo_buf_size-len-1; n = fifo_buf_size-len-1;
for (; n < fifo_buf_size; n++) // Fill rest with '\0' for (; n < fifo_buf_size; n++) // Fill rest with '\0'
fifo_buf[n-len] = '\0'; fifo_buf[n-len] = '\0';
input_data_pending = bool(fifo_buf[0] != '\0'); input_data_pending = bool(fifo_buf[0] != '\0');
processMouseEvent(); processMouseEvent();
} }
@ -338,15 +359,21 @@ void FApplication::processKeyboardEvent()
{ {
urxvt_mouse[n-2] = fifo_buf[n]; urxvt_mouse[n-2] = fifo_buf[n];
n++; n++;
if ( fifo_buf[n] == 'M' || fifo_buf[n] == 'm' ) if ( fifo_buf[n] == 'M' || fifo_buf[n] == 'm' )
len = n + 1; len = n + 1;
} }
urxvt_mouse[n-2] = '\0'; urxvt_mouse[n-2] = '\0';
for (n=len; n < fifo_buf_size; n++) // Remove founded entry for (n=len; n < fifo_buf_size; n++) // Remove founded entry
fifo_buf[n-len] = fifo_buf[n]; fifo_buf[n-len] = fifo_buf[n];
n = fifo_buf_size-len-1; n = fifo_buf_size-len-1;
for (; n < fifo_buf_size; n++) // Fill rest with '\0' for (; n < fifo_buf_size; n++) // Fill rest with '\0'
fifo_buf[n-len] = '\0'; fifo_buf[n-len] = '\0';
input_data_pending = bool(fifo_buf[0] != '\0'); input_data_pending = bool(fifo_buf[0] != '\0');
processMouseEvent(); processMouseEvent();
} }
@ -366,8 +393,10 @@ void FApplication::processKeyboardEvent()
{ {
// keyboard accelerator // keyboard accelerator
FWidget* window = static_cast<FWidget*>(active_window); FWidget* window = static_cast<FWidget*>(active_window);
if ( ! window ) if ( ! window )
window = getRootWidget(); window = getRootWidget();
if ( window if ( window
&& window->accelerator_list && window->accelerator_list
&& ! window->accelerator_list->empty() ) && ! window->accelerator_list->empty() )
@ -380,27 +409,33 @@ void FApplication::processKeyboardEvent()
{ {
if ( quit_now || app_exit_loop ) if ( quit_now || app_exit_loop )
break; break;
if ( iter->key == key ) if ( iter->key == key )
{ {
FAccelEvent a_ev (fc::Accelerator_Event, focus_widget); FAccelEvent a_ev (fc::Accelerator_Event, focus_widget);
sendEvent (iter->object, &a_ev); sendEvent (iter->object, &a_ev);
break; break;
}; };
++iter; ++iter;
} }
} }
} }
} // end of else } // end of else
} }
fifo_offset = int(strlen(fifo_buf)); fifo_offset = int(strlen(fifo_buf));
} }
// send key up event // send key up event
FKeyEvent k_up_ev (fc::KeyUp_Event, key); FKeyEvent k_up_ev (fc::KeyUp_Event, key);
sendEvent (widget, &k_up_ev); sendEvent (widget, &k_up_ev);
key = 0; key = 0;
} }
std::fill_n (k_buf, sizeof(k_buf), '\0'); std::fill_n (k_buf, sizeof(k_buf), '\0');
} }
// special case: Esc key // special case: Esc key
if ( fifo_in_use if ( fifo_in_use
&& fifo_offset == 1 && fifo_offset == 1
@ -542,8 +577,10 @@ bool FApplication::parseX11Mouse()
if ( (x11_mouse[0] & key_shift) == key_shift ) if ( (x11_mouse[0] & key_shift) == key_shift )
b_state.shift_button = Pressed; b_state.shift_button = Pressed;
if ( (x11_mouse[0] & key_meta) == key_meta ) if ( (x11_mouse[0] & key_meta) == key_meta )
b_state.meta_button = Pressed; b_state.meta_button = Pressed;
if ( (x11_mouse[0] & key_ctrl) == key_ctrl ) if ( (x11_mouse[0] & key_ctrl) == key_ctrl )
b_state.control_button = Pressed; b_state.control_button = Pressed;
@ -564,6 +601,7 @@ bool FApplication::parseX11Mouse()
{ {
return false; return false;
} }
mouse->setPoint(x,y); mouse->setPoint(x,y);
x11_button_state = uChar(x11_mouse[0]); x11_button_state = uChar(x11_mouse[0]);
x11_mouse[0] = '\0'; x11_mouse[0] = '\0';
@ -606,6 +644,7 @@ bool FApplication::parseSGRMouse()
{ {
if ( *p < '0' || *p > '9') if ( *p < '0' || *p > '9')
return false; return false;
button = 10 * button + (*p - '0'); button = 10 * button + (*p - '0');
p++; p++;
} }
@ -621,6 +660,7 @@ bool FApplication::parseSGRMouse()
{ {
if ( *p < '0' || *p > '9') if ( *p < '0' || *p > '9')
return false; return false;
y = uChar(10 * y + (*p - '0')); y = uChar(10 * y + (*p - '0'));
} }
@ -629,8 +669,10 @@ bool FApplication::parseSGRMouse()
if ( (button & key_shift) == key_shift ) if ( (button & key_shift) == key_shift )
b_state.shift_button = Pressed; b_state.shift_button = Pressed;
if ( (button & key_meta) == key_meta ) if ( (button & key_meta) == key_meta )
b_state.meta_button = Pressed; b_state.meta_button = Pressed;
if ( (button & key_ctrl) == key_ctrl ) if ( (button & key_ctrl) == key_ctrl )
b_state.control_button = Pressed; b_state.control_button = Pressed;
@ -715,6 +757,7 @@ bool FApplication::parseSGRMouse()
break; break;
} }
} }
if ( *mouse == newMousePosition if ( *mouse == newMousePosition
&& b_state.wheel_up != Pressed && b_state.wheel_up != Pressed
&& b_state.wheel_down != Pressed && b_state.wheel_down != Pressed
@ -722,6 +765,7 @@ bool FApplication::parseSGRMouse()
{ {
return false; return false;
} }
mouse->setPoint(x,y); mouse->setPoint(x,y);
x11_button_state = uChar(((*p & 0x20) << 2) + button); x11_button_state = uChar(((*p & 0x20) << 2) + button);
sgr_mouse[0] = '\0'; sgr_mouse[0] = '\0';
@ -769,6 +813,7 @@ bool FApplication::parseUrxvtMouse()
{ {
if ( *p < '0' || *p > '9') if ( *p < '0' || *p > '9')
return false; return false;
button = 10 * button + (*p - '0'); button = 10 * button + (*p - '0');
p++; p++;
} }
@ -778,10 +823,12 @@ bool FApplication::parseUrxvtMouse()
p++; p++;
x_neg = true; x_neg = true;
} }
while ( *p && *p != ';' ) while ( *p && *p != ';' )
{ {
if ( *p < '0' || *p > '9') if ( *p < '0' || *p > '9')
return false; return false;
x = uChar(10 * x + (*p - '0')); x = uChar(10 * x + (*p - '0'));
p++; p++;
} }
@ -791,20 +838,25 @@ bool FApplication::parseUrxvtMouse()
p++; p++;
y_neg = true; y_neg = true;
} }
while ( *p && *p != 'M' ) while ( *p && *p != 'M' )
{ {
if ( *p < '0' || *p > '9') if ( *p < '0' || *p > '9')
return false; return false;
y = uChar(10 * y + (*p - '0')); y = uChar(10 * y + (*p - '0'));
p++; p++;
} }
if ( x_neg || x == 0 ) if ( x_neg || x == 0 )
x = 1; x = 1;
if ( y_neg || y == 0 ) if ( y_neg || y == 0 )
y = 1; y = 1;
if ( x > term->getWidth() ) if ( x > term->getWidth() )
x = uChar(term->getWidth()); x = uChar(term->getWidth());
if ( y > term->getHeight() ) if ( y > term->getHeight() )
y = uChar(term->getHeight()); y = uChar(term->getHeight());
@ -813,8 +865,10 @@ bool FApplication::parseUrxvtMouse()
if ( (button & key_shift) == key_shift ) if ( (button & key_shift) == key_shift )
b_state.shift_button = Pressed; b_state.shift_button = Pressed;
if ( (button & key_meta) == key_meta ) if ( (button & key_meta) == key_meta )
b_state.meta_button = Pressed; b_state.meta_button = Pressed;
if ( (button & key_ctrl) == key_ctrl ) if ( (button & key_ctrl) == key_ctrl )
b_state.control_button = Pressed; b_state.control_button = Pressed;
@ -834,6 +888,7 @@ bool FApplication::parseUrxvtMouse()
{ {
return false; return false;
} }
mouse->setPoint(x,y); mouse->setPoint(x,y);
x11_button_state = uChar(button); x11_button_state = uChar(button);
urxvt_mouse[0] = '\0'; urxvt_mouse[0] = '\0';
@ -849,6 +904,7 @@ bool FApplication::processGpmEvent()
if ( Gpm_GetEvent(&gpm_ev) == 1 ) if ( Gpm_GetEvent(&gpm_ev) == 1 )
{ {
Gpm_FitEvent (&gpm_ev); Gpm_FitEvent (&gpm_ev);
if ( gpm_ev.type & GPM_DRAG && gpm_ev.wdx == 0 && gpm_ev.wdy == 0 ) if ( gpm_ev.type & GPM_DRAG && gpm_ev.wdx == 0 && gpm_ev.wdy == 0 )
b_state.mouse_moved = true; b_state.mouse_moved = true;
@ -868,35 +924,45 @@ bool FApplication::processGpmEvent()
else else
b_state.left_button = Pressed; b_state.left_button = Pressed;
} }
if ( gpm_ev.buttons & GPM_B_MIDDLE ) if ( gpm_ev.buttons & GPM_B_MIDDLE )
b_state.middle_button = Pressed; b_state.middle_button = Pressed;
if ( gpm_ev.buttons & GPM_B_RIGHT ) if ( gpm_ev.buttons & GPM_B_RIGHT )
b_state.right_button = Pressed; b_state.right_button = Pressed;
if ( gpm_ev.buttons & GPM_B_UP ) if ( gpm_ev.buttons & GPM_B_UP )
b_state.wheel_up = Pressed; b_state.wheel_up = Pressed;
if ( gpm_ev.buttons & GPM_B_DOWN ) if ( gpm_ev.buttons & GPM_B_DOWN )
b_state.wheel_down = Pressed; b_state.wheel_down = Pressed;
// keyboard modifiers // keyboard modifiers
if ( gpm_ev.modifiers & (1 << KG_SHIFT) ) if ( gpm_ev.modifiers & (1 << KG_SHIFT) )
b_state.shift_button = Pressed; b_state.shift_button = Pressed;
if ( gpm_ev.modifiers & ((1 << KG_ALT) | (1 << KG_ALTGR)) ) if ( gpm_ev.modifiers & ((1 << KG_ALT) | (1 << KG_ALTGR)) )
b_state.meta_button = Pressed; b_state.meta_button = Pressed;
if ( gpm_ev.modifiers & (1 << KG_CTRL) ) if ( gpm_ev.modifiers & (1 << KG_CTRL) )
b_state.control_button = Pressed; b_state.control_button = Pressed;
break; break;
case GPM_UP: case GPM_UP:
if ( gpm_ev.buttons & GPM_B_LEFT ) if ( gpm_ev.buttons & GPM_B_LEFT )
b_state.left_button = Released; b_state.left_button = Released;
if ( gpm_ev.buttons & GPM_B_MIDDLE ) if ( gpm_ev.buttons & GPM_B_MIDDLE )
b_state.middle_button = Released; b_state.middle_button = Released;
if ( gpm_ev.buttons & GPM_B_RIGHT ) if ( gpm_ev.buttons & GPM_B_RIGHT )
b_state.right_button = Released; b_state.right_button = Released;
default: default:
break; break;
} }
mouse->setPoint(gpm_ev.x, gpm_ev.y); mouse->setPoint(gpm_ev.x, gpm_ev.y);
if ( gpmEvent(false) == mouse_event ) if ( gpmEvent(false) == mouse_event )
@ -909,6 +975,7 @@ bool FApplication::processGpmEvent()
return true; return true;
} }
gpmMouseEvent = false; gpmMouseEvent = false;
return false; return false;
} }
@ -962,6 +1029,7 @@ void FApplication::processMouseEvent()
|| b_state.wheel_down == Pressed ) ) || b_state.wheel_down == Pressed ) )
{ {
FWidget* window = FWindow::getWindowWidgetAt (*mouse); FWidget* window = FWindow::getWindowWidgetAt (*mouse);
if ( window ) if ( window )
{ {
FWidget* child = childWidgetAt (window, *mouse); FWidget* child = childWidgetAt (window, *mouse);
@ -984,8 +1052,10 @@ void FApplication::processMouseEvent()
// No widget was been clicked // No widget was been clicked
if ( ! clicked_widget ) if ( ! clicked_widget )
FWindow::switchToPrevWindow(); FWindow::switchToPrevWindow();
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
updateTerminal(); updateTerminal();
flush_out(); flush_out();
} }
@ -1000,14 +1070,17 @@ void FApplication::processMouseEvent()
{ {
if ( statusBar() ) if ( statusBar() )
statusBar()->clearMessage(); statusBar()->clearMessage();
menuBar()->resetMenu(); menuBar()->resetMenu();
menuBar()->redraw(); menuBar()->redraw();
// No widget was been clicked // No widget was been clicked
if ( ! clicked_widget ) if ( ! clicked_widget )
FWindow::switchToPrevWindow(); FWindow::switchToPrevWindow();
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
updateTerminal(); updateTerminal();
flush_out(); flush_out();
} }
@ -1020,8 +1093,10 @@ void FApplication::processMouseEvent()
if ( b_state.shift_button == Pressed ) if ( b_state.shift_button == Pressed )
key_state |= fc::ShiftButton; key_state |= fc::ShiftButton;
if ( b_state.meta_button == Pressed ) if ( b_state.meta_button == Pressed )
key_state |= fc::MetaButton; key_state |= fc::MetaButton;
if ( b_state.control_button == Pressed ) if ( b_state.control_button == Pressed )
key_state |= fc::ControlButton; key_state |= fc::ControlButton;
@ -1037,6 +1112,7 @@ void FApplication::processMouseEvent()
, fc::LeftButton | key_state ); , fc::LeftButton | key_state );
sendEvent (clicked_widget, &m_down_ev); sendEvent (clicked_widget, &m_down_ev);
} }
if ( b_state.right_button == Pressed ) if ( b_state.right_button == Pressed )
{ {
FMouseEvent m_down_ev ( fc::MouseMove_Event FMouseEvent m_down_ev ( fc::MouseMove_Event
@ -1045,6 +1121,7 @@ void FApplication::processMouseEvent()
, fc::RightButton | key_state ); , fc::RightButton | key_state );
sendEvent (clicked_widget, &m_down_ev); sendEvent (clicked_widget, &m_down_ev);
} }
if ( b_state.middle_button == Pressed ) if ( b_state.middle_button == Pressed )
{ {
FMouseEvent m_down_ev ( fc::MouseMove_Event FMouseEvent m_down_ev ( fc::MouseMove_Event
@ -1113,6 +1190,7 @@ void FApplication::processMouseEvent()
, *mouse , *mouse
, fc::MiddleButton | key_state ); , fc::MiddleButton | key_state );
sendEvent (clicked_widget, &m_down_ev); sendEvent (clicked_widget, &m_down_ev);
// gnome-terminal sends no released on middle click // gnome-terminal sends no released on middle click
if ( gnome_terminal ) if ( gnome_terminal )
clicked_widget = 0; clicked_widget = 0;
@ -1124,9 +1202,13 @@ void FApplication::processMouseEvent()
, *mouse , *mouse
, fc::MiddleButton | key_state ); , fc::MiddleButton | key_state );
FWidget* released_widget = clicked_widget; FWidget* released_widget = clicked_widget;
if ( b_state.right_button != Pressed if ( b_state.right_button != Pressed
&& b_state.left_button != Pressed ) && b_state.left_button != Pressed )
clicked_widget = 0; {
clicked_widget = 0;
}
sendEvent (released_widget, &m_up_ev); sendEvent (released_widget, &m_up_ev);
} }
} }
@ -1152,6 +1234,7 @@ void FApplication::processMouseEvent()
clicked_widget = 0; clicked_widget = 0;
sendEvent (scroll_over_widget, &wheel_ev); sendEvent (scroll_over_widget, &wheel_ev);
} }
} }
#ifdef F_HAVE_LIBGPM #ifdef F_HAVE_LIBGPM
@ -1187,6 +1270,7 @@ int FApplication::processTimerEvent()
if ( ! timer_list ) if ( ! timer_list )
return 0; return 0;
if ( timer_list->empty() ) if ( timer_list->empty() )
return 0; return 0;
@ -1245,6 +1329,7 @@ void FApplication::processTerminalUpdate()
void FApplication::processCloseWidget() void FApplication::processCloseWidget()
{ {
updateTerminal(false); updateTerminal(false);
if ( close_widget && ! close_widget->empty() ) if ( close_widget && ! close_widget->empty() )
{ {
widgetList::iterator iter; widgetList::iterator iter;
@ -1255,6 +1340,7 @@ void FApplication::processCloseWidget()
delete *iter; delete *iter;
++iter; ++iter;
} }
close_widget->clear(); close_widget->clear();
} }
updateTerminal(true); updateTerminal(true);
@ -1314,6 +1400,7 @@ int FApplication::exec() // run
showCursor(); showCursor();
flush_out(); flush_out();
} }
enter_loop(); enter_loop();
return quit_code; return quit_code;
} }
@ -1327,12 +1414,12 @@ int FApplication::enter_loop() // event loop
old_app_exit_loop = app_exit_loop; old_app_exit_loop = app_exit_loop;
app_exit_loop = false; app_exit_loop = false;
while ( ! quit_now && ! app_exit_loop ) while ( ! quit_now && ! app_exit_loop )
processNextEvent(); processNextEvent();
app_exit_loop = old_app_exit_loop; app_exit_loop = old_app_exit_loop;
loop_level--; loop_level--;
return 0; return 0;
} }
@ -1347,8 +1434,10 @@ void FApplication::exit (int retcode)
{ {
if ( ! rootObj ) // no global app object if ( ! rootObj ) // no global app object
return; return;
if ( quit_now ) // don't overwrite quit code if ( quit_now ) // don't overwrite quit code
return; return;
quit_now = true; quit_now = true;
quit_code = retcode; quit_code = retcode;
} }
@ -1470,6 +1559,7 @@ bool FApplication::removeQueuedEvent(FObject* receiver)
if ( ! eventInQueue() ) if ( ! eventInQueue() )
return false; return false;
if ( ! receiver ) if ( ! receiver )
return false; return false;
@ -1486,5 +1576,6 @@ bool FApplication::removeQueuedEvent(FObject* receiver)
else else
++iter; ++iter;
} }
return retval; return retval;
} }

View File

@ -92,6 +92,7 @@ uChar FButton::getHotkey()
return 0;; return 0;;
} }
} }
return 0; return 0;
} }
@ -99,6 +100,7 @@ uChar FButton::getHotkey()
void FButton::setHotkeyAccelerator() void FButton::setHotkeyAccelerator()
{ {
int hotkey = getHotkey(); int hotkey = getHotkey();
if ( hotkey ) if ( hotkey )
{ {
if ( isalpha(hotkey) || isdigit(hotkey) ) if ( isalpha(hotkey) || isdigit(hotkey) )
@ -132,6 +134,7 @@ void FButton::draw()
register wchar_t* dest; register wchar_t* dest;
wchar_t* ButtonText; wchar_t* ButtonText;
FString txt; FString txt;
int active_focus;
int d, i, j, x, mono_offset, margin; int d, i, j, x, mono_offset, margin;
int length, hotkeypos, hotkey_offset, space; int length, hotkeypos, hotkey_offset, space;
bool is_ActiveFocus, is_Active, is_Focus, is_Flat; bool is_ActiveFocus, is_Active, is_Focus, is_Flat;
@ -151,30 +154,34 @@ void FButton::draw()
src = const_cast<wchar_t*>(txt.wc_str()); src = const_cast<wchar_t*>(txt.wc_str());
dest = const_cast<wchar_t*>(ButtonText); dest = const_cast<wchar_t*>(ButtonText);
int active_focus = fc::active + fc::focus; active_focus = fc::active + fc::focus;
is_ActiveFocus = ((flags & active_focus) == active_focus); is_ActiveFocus = ((flags & active_focus) == active_focus);
is_Active = ((flags & fc::active) != 0); is_Active = ((flags & fc::active) != 0);
is_Focus = ((flags & fc::focus) != 0); is_Focus = ((flags & fc::focus) != 0);
is_Flat = isFlat(); is_Flat = isFlat();
is_NonFlatShadow = ((flags & (fc::shadow+fc::flat)) == fc::shadow); is_NonFlatShadow = ((flags & (fc::shadow+fc::flat)) == fc::shadow);
is_NoUnderline = ((flags & fc::no_underline) != 0); is_NoUnderline = ((flags & fc::no_underline) != 0);
setUpdateVTerm(false); setUpdateVTerm(false);
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
if ( button_down && click_animation ) if ( button_down && click_animation )
{ {
// noshadow + indent one character to the right // noshadow + indent one character to the right
if ( is_Flat ) if ( is_Flat )
clearFlatBorder(); clearFlatBorder();
clearShadow(); clearShadow();
setColor ( getParentWidget()->getForegroundColor() setColor ( getParentWidget()->getForegroundColor()
, getParentWidget()->getBackgroundColor() ); , getParentWidget()->getBackgroundColor() );
for (int y=1; y <= height; y++) for (int y=1; y <= height; y++)
{ {
gotoxy (xpos+xmin-1, ypos+ymin-2+y); gotoxy (xpos+xmin-1, ypos+ymin-2+y);
print (' '); // clear one left █ print (' '); // clear one left █
} }
d = 1; d = 1;
} }
else else
@ -203,8 +210,10 @@ void FButton::draw()
i++; i++;
src++; src++;
} }
*dest++ = *src++; *dest++ = *src++;
} }
if ( hotkeypos != -1 ) if ( hotkeypos != -1 )
hotkey_offset = 1; hotkey_offset = 1;
@ -221,12 +230,14 @@ void FButton::draw()
if ( margin == 1 ) if ( margin == 1 )
{ {
setColor (foregroundColor, button_bg); setColor (foregroundColor, button_bg);
for (int y=0; y < height; y++) for (int y=0; y < height; y++)
{ {
gotoxy (xpos+xmin-1+d, ypos+ymin-1+y); gotoxy (xpos+xmin-1+d, ypos+ymin-1+y);
print (space); // full block █ print (space); // full block █
} }
} }
if ( ! button_down ) if ( ! button_down )
drawFlatBorder(); drawFlatBorder();
} }
@ -234,6 +245,7 @@ void FButton::draw()
{ {
setColor (button_bg, getParentWidget()->getBackgroundColor()); setColor (button_bg, getParentWidget()->getBackgroundColor());
gotoxy (xpos+xmin-1+d, ypos+ymin-1); gotoxy (xpos+xmin-1+d, ypos+ymin-1);
for (int y=1; y <= height; y++) for (int y=1; y <= height; y++)
{ {
// Cygwin terminal use IBM Codepage 850 // Cygwin terminal use IBM Codepage 850
@ -243,6 +255,7 @@ void FButton::draw()
print (0xdb); print (0xdb);
else else
print (fc::RightHalfBlock); // ▐ print (fc::RightHalfBlock); // ▐
gotoxy (xpos+xmin-1+d, ypos+ymin-1+y); gotoxy (xpos+xmin-1+d, ypos+ymin-1+y);
} }
} }
@ -254,12 +267,15 @@ void FButton::draw()
// clear the right █ from button down // clear the right █ from button down
setColor ( getParentWidget()->getForegroundColor() setColor ( getParentWidget()->getForegroundColor()
, getParentWidget()->getBackgroundColor() ); , getParentWidget()->getBackgroundColor() );
for (int y=1; y <= height; y++) for (int y=1; y <= height; y++)
{ {
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
gotoxy (xpos+xmin-1+width, ypos+ymin-2+y); gotoxy (xpos+xmin-1+width, ypos+ymin-2+y);
print (' '); // clear right print (' '); // clear right
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
} }
@ -297,15 +313,21 @@ void FButton::draw()
if ( (z == hotkeypos) && is_Active ) if ( (z == hotkeypos) && is_Active )
{ {
setColor (button_hotkey_fg, button_bg); setColor (button_hotkey_fg, button_bg);
if ( ! is_ActiveFocus && getMaxColor() < 16 ) if ( ! is_ActiveFocus && getMaxColor() < 16 )
setBold(); setBold();
if ( ! is_NoUnderline ) if ( ! is_NoUnderline )
setUnderline(); setUnderline();
print ( ButtonText[z] ); print ( ButtonText[z] );
if ( ! is_ActiveFocus && getMaxColor() < 16 ) if ( ! is_ActiveFocus && getMaxColor() < 16 )
unsetBold(); unsetBold();
if ( ! is_NoUnderline ) if ( ! is_NoUnderline )
unsetUnderline(); unsetUnderline();
setColor (button_fg, button_bg); setColor (button_fg, button_bg);
} }
else else
@ -325,12 +347,14 @@ void FButton::draw()
for (i=0; i < j; i++) for (i=0; i < j; i++)
{ {
gotoxy (xpos+xmin+d, ypos+ymin-1+i); gotoxy (xpos+xmin+d, ypos+ymin-1+i);
for (int z=1; z < width; z++) for (int z=1; z < width; z++)
print (space); // █ print (space); // █
} }
for (i=j+1; i < height; i++) for (i=j+1; i < height; i++)
{ {
gotoxy (xpos+xmin+d, ypos+ymin-1+i); gotoxy (xpos+xmin+d, ypos+ymin-1+i);
for (int z=1; z < width; z++) for (int z=1; z < width; z++)
print (space); // █ print (space); // █
} }
@ -357,6 +381,7 @@ void FButton::draw()
{ {
FString msg = getStatusbarMessage(); FString msg = getStatusbarMessage();
FString curMsg = statusBar()->getMessage(); FString curMsg = statusBar()->getMessage();
if ( curMsg != msg ) if ( curMsg != msg )
{ {
statusBar()->setMessage(msg); statusBar()->setMessage(msg);
@ -423,6 +448,7 @@ void FButton::setFocusForegroundColor (short color)
// valid colors -1..254 // valid colors -1..254
if ( color == fc::Default || color >> 8 == 0 ) if ( color == fc::Default || color >> 8 == 0 )
button_focus_fg = color; button_focus_fg = color;
updateButtonColor(); updateButtonColor();
} }
@ -432,6 +458,7 @@ void FButton::setFocusBackgroundColor (short color)
// valid colors -1..254 // valid colors -1..254
if ( color == fc::Default || color >> 8 == 0 ) if ( color == fc::Default || color >> 8 == 0 )
button_focus_bg = color; button_focus_bg = color;
updateButtonColor(); updateButtonColor();
} }
@ -441,6 +468,7 @@ void FButton::setInactiveForegroundColor (short color)
// valid colors -1..254 // valid colors -1..254
if ( color == fc::Default || color >> 8 == 0 ) if ( color == fc::Default || color >> 8 == 0 )
button_inactive_fg = color; button_inactive_fg = color;
updateButtonColor(); updateButtonColor();
} }
@ -450,6 +478,7 @@ void FButton::setInactiveBackgroundColor (short color)
// valid colors -1..254 // valid colors -1..254
if ( color == fc::Default || color >> 8 == 0 ) if ( color == fc::Default || color >> 8 == 0 )
button_inactive_bg = color; button_inactive_bg = color;
updateButtonColor(); updateButtonColor();
} }
@ -461,22 +490,22 @@ void FButton::hide()
char* blank; char* blank;
FWidget::hide(); FWidget::hide();
fg = getParentWidget()->getForegroundColor(); fg = getParentWidget()->getForegroundColor();
bg = getParentWidget()->getBackgroundColor(); bg = getParentWidget()->getBackgroundColor();
setColor (fg, bg); setColor (fg, bg);
s = hasShadow() ? 1 : 0; s = hasShadow() ? 1 : 0;
f = isFlat() ? 1 : 0; f = isFlat() ? 1 : 0;
size = width + s + (f << 1); size = width + s + (f << 1);
blank = new char[size+1]; blank = new char[size+1];
memset(blank, ' ', uLong(size)); memset(blank, ' ', uLong(size));
blank[size] = '\0'; blank[size] = '\0';
for (int y=0; y < height+s+(f << 1); y++) for (int y=0; y < height+s+(f << 1); y++)
{ {
gotoxy (xpos+xmin-1-f, ypos+ymin-1+y-f); gotoxy (xpos+xmin-1-f, ypos+ymin-1+y-f);
print (blank); print (blank);
} }
delete[] blank; delete[] blank;
} }
@ -487,6 +516,7 @@ bool FButton::setNoUnderline (bool on)
flags |= fc::no_underline; flags |= fc::no_underline;
else else
flags &= ~fc::no_underline; flags &= ~fc::no_underline;
return on; return on;
} }
@ -505,6 +535,7 @@ bool FButton::setEnable (bool on)
flags &= ~fc::active; flags &= ~fc::active;
delAccelerator(); delAccelerator();
} }
updateButtonColor(); updateButtonColor();
return on; return on;
} }
@ -524,6 +555,7 @@ bool FButton::setFocus (bool on)
{ {
FString msg = getStatusbarMessage(); FString msg = getStatusbarMessage();
FString curMsg = statusBar()->getMessage(); FString curMsg = statusBar()->getMessage();
if ( curMsg != msg ) if ( curMsg != msg )
statusBar()->setMessage(msg); statusBar()->setMessage(msg);
} }
@ -536,6 +568,7 @@ bool FButton::setFocus (bool on)
if ( isEnabled() && statusBar() ) if ( isEnabled() && statusBar() )
statusBar()->clearMessage(); statusBar()->clearMessage();
} }
updateButtonColor(); updateButtonColor();
return on; return on;
} }
@ -553,12 +586,13 @@ bool FButton::setFlat (bool on)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FButton::setShadow (bool on) bool FButton::setShadow (bool on)
{ {
if ( on if ( on
&& (Encoding != fc::VT100 || isTeraTerm() ) && (Encoding != fc::VT100 || isTeraTerm() )
&& Encoding != fc::ASCII ) && Encoding != fc::ASCII )
flags |= fc::shadow; flags |= fc::shadow;
else else
flags &= ~fc::shadow; flags &= ~fc::shadow;
return on; return on;
} }
@ -570,6 +604,7 @@ bool FButton::setDown (bool on)
button_down = on; button_down = on;
redraw(); redraw();
} }
return on; return on;
} }
@ -617,12 +652,16 @@ void FButton::onMouseDown (FMouseEvent* ev)
FFocusEvent out (fc::FocusOut_Event); FFocusEvent out (fc::FocusOut_Event);
FApplication::queueEvent(focused_widget, &out); FApplication::queueEvent(focused_widget, &out);
setFocus(); setFocus();
if ( focused_widget ) if ( focused_widget )
focused_widget->redraw(); focused_widget->redraw();
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
} }
FPoint gPos = ev->getGlobalPos(); FPoint gPos = ev->getGlobalPos();
if ( getGeometryGlobal().contains(gPos) ) if ( getGeometryGlobal().contains(gPos) )
setDown(); setDown();
} }
@ -636,6 +675,7 @@ void FButton::onMouseUp (FMouseEvent* ev)
if ( button_down ) if ( button_down )
{ {
setUp(); setUp();
if ( getGeometryGlobal().contains(ev->getGlobalPos()) ) if ( getGeometryGlobal().contains(ev->getGlobalPos()) )
processClick(); processClick();
} }
@ -648,6 +688,7 @@ void FButton::onMouseMove (FMouseEvent* ev)
return; return;
FPoint gPos = ev->getGlobalPos(); FPoint gPos = ev->getGlobalPos();
if ( click_animation ) if ( click_animation )
{ {
if ( getGeometryGlobal().contains(gPos) ) if ( getGeometryGlobal().contains(gPos) )
@ -675,17 +716,21 @@ void FButton::onAccel (FAccelEvent* ev)
FFocusEvent out (fc::FocusOut_Event); FFocusEvent out (fc::FocusOut_Event);
FApplication::queueEvent(focused_widget, &out); FApplication::queueEvent(focused_widget, &out);
setFocus(); setFocus();
if ( focused_widget ) if ( focused_widget )
focused_widget->redraw(); focused_widget->redraw();
if ( click_animation ) if ( click_animation )
setDown(); setDown();
else else
redraw(); redraw();
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
} }
else if ( click_animation ) else if ( click_animation )
setDown(); setDown();
if ( click_animation ) if ( click_animation )
addTimer(click_time); addTimer(click_time);
@ -718,5 +763,6 @@ void FButton::setText (const FString& txt)
text = txt; text = txt;
else else
text = ""; text = "";
detectHotkey(); detectHotkey();
} }

View File

@ -64,7 +64,6 @@ void FButtonGroup::init()
foregroundColor = wc.label_fg; foregroundColor = wc.label_fg;
backgroundColor = wc.label_bg; backgroundColor = wc.label_bg;
buttonlist.clear(); // no buttons yet buttonlist.clear(); // no buttons yet
} }
@ -99,12 +98,16 @@ void FButtonGroup::directFocus()
FFocusEvent out (fc::FocusOut_Event); FFocusEvent out (fc::FocusOut_Event);
FApplication::queueEvent(focused_widget, &out); FApplication::queueEvent(focused_widget, &out);
(*iter)->setFocus(); (*iter)->setFocus();
if ( focused_widget ) if ( focused_widget )
focused_widget->redraw(); focused_widget->redraw();
getFocusWidget()->redraw(); getFocusWidget()->redraw();
} }
break; break;
} }
++iter; ++iter;
} }
} }
@ -115,8 +118,10 @@ void FButtonGroup::directFocus()
FFocusEvent out (fc::FocusOut_Event); FFocusEvent out (fc::FocusOut_Event);
FApplication::queueEvent(focused_widget, &out); FApplication::queueEvent(focused_widget, &out);
focusFirstChild(); focusFirstChild();
if ( focused_widget ) if ( focused_widget )
focused_widget->redraw(); focused_widget->redraw();
getFocusWidget()->redraw(); getFocusWidget()->redraw();
} }
} }
@ -134,14 +139,20 @@ void FButtonGroup::directFocus()
void FButtonGroup::draw() void FButtonGroup::draw()
{ {
setUpdateVTerm(false); setUpdateVTerm(false);
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
setColor (foregroundColor, backgroundColor); setColor (foregroundColor, backgroundColor);
if ( border ) if ( border )
drawBorder(); drawBorder();
drawLabel(); drawLabel();
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
setUpdateVTerm(true); setUpdateVTerm(true);
} }
@ -246,16 +257,21 @@ void FButtonGroup::drawLabel()
if ( (z == hotkeypos) && isActive ) if ( (z == hotkeypos) && isActive )
{ {
setColor (wc.label_hotkey_fg, wc.label_hotkey_bg); setColor (wc.label_hotkey_fg, wc.label_hotkey_bg);
if ( ! isNoUnderline ) if ( ! isNoUnderline )
setUnderline(); setUnderline();
print ( LabelText[z] ); print ( LabelText[z] );
if ( ! isNoUnderline ) if ( ! isNoUnderline )
unsetUnderline(); unsetUnderline();
setColor (wc.label_emphasis_fg, wc.label_bg); setColor (wc.label_emphasis_fg, wc.label_bg);
} }
else else
print ( LabelText[z] ); print ( LabelText[z] );
} }
delete[] LabelText; delete[] LabelText;
} }
@ -267,6 +283,7 @@ void FButtonGroup::hide()
short fg, bg; short fg, bg;
char* blank; char* blank;
FWidget::hide(); FWidget::hide();
if ( ! buttonlist.empty() ) if ( ! buttonlist.empty() )
{ {
FButtonGroup::FButtonList::const_iterator iter, end; FButtonGroup::FButtonList::const_iterator iter, end;
@ -288,11 +305,13 @@ void FButtonGroup::hide()
blank = new char[size+1]; blank = new char[size+1];
memset(blank, ' ', uLong(size)); memset(blank, ' ', uLong(size));
blank[size] = '\0'; blank[size] = '\0';
for (int y=0; y < height; y++) for (int y=0; y < height; y++)
{ {
gotoxy (xpos+xmin-1, ypos+ymin-1+y); gotoxy (xpos+xmin-1, ypos+ymin-1+y);
print (blank); print (blank);
} }
delete[] blank; delete[] blank;
} }
@ -332,7 +351,6 @@ void FButtonGroup::remove (FToggleButton* button)
{ {
iter = buttonlist.erase(iter); iter = buttonlist.erase(iter);
button->setGroup(0); button->setGroup(0);
button->delCallback(this); button->delCallback(this);
break; break;
} }
@ -349,6 +367,7 @@ void FButtonGroup::cb_buttonToggled (FWidget* widget, void*)
if ( ! button->isChecked() ) if ( ! button->isChecked() )
return; return;
if ( buttonlist.empty() ) if ( buttonlist.empty() )
return; return;
@ -362,9 +381,11 @@ void FButtonGroup::cb_buttonToggled (FWidget* widget, void*)
&& isRadioButton(*iter) ) && isRadioButton(*iter) )
{ {
(*iter)->unsetChecked(); (*iter)->unsetChecked();
if ( (*iter)->isVisible() && (*iter)->isShown() ) if ( (*iter)->isVisible() && (*iter)->isShown() )
(*iter)->redraw(); (*iter)->redraw();
} }
++iter; ++iter;
} }
} }
@ -382,9 +403,11 @@ FToggleButton* FButtonGroup::getFirstButton()
{ {
if ( (*iter)->isEnabled() && (*iter)->acceptFocus() ) if ( (*iter)->isEnabled() && (*iter)->acceptFocus() )
return (*iter); return (*iter);
++iter; ++iter;
} }
} }
return 0; return 0;
} }
@ -396,14 +419,17 @@ FToggleButton* FButtonGroup::getLastButton()
FButtonGroup::FButtonList::const_iterator iter, begin; FButtonGroup::FButtonList::const_iterator iter, begin;
begin = buttonlist.begin(); begin = buttonlist.begin();
iter = buttonlist.end(); iter = buttonlist.end();
do do
{ {
--iter; --iter;
if ( (*iter)->isEnabled() && (*iter)->acceptFocus() ) if ( (*iter)->isEnabled() && (*iter)->acceptFocus() )
return (*iter); return (*iter);
} }
while ( iter != begin ); while ( iter != begin );
} }
return 0; return 0;
} }
@ -420,9 +446,11 @@ bool FButtonGroup::hasFocusedButton()
{ {
if ( (*iter)->hasFocus() ) if ( (*iter)->hasFocus() )
return true; return true;
++iter; ++iter;
} }
} }
return false; return false;
} }
@ -439,9 +467,11 @@ bool FButtonGroup::hasCheckedButton()
{ {
if ( (*iter)->isChecked() ) if ( (*iter)->isChecked() )
return true; return true;
++iter; ++iter;
} }
} }
return false; return false;
} }
@ -450,6 +480,7 @@ void FButtonGroup::onMouseDown (FMouseEvent* ev)
{ {
if ( ev->getButton() != fc::LeftButton ) if ( ev->getButton() != fc::LeftButton )
return; return;
directFocus(); directFocus();
} }
@ -477,15 +508,20 @@ void FButtonGroup::onFocusIn (FFocusEvent* in_ev)
in_ev->ignore(); in_ev->ignore();
FWidget* prev_element = getFocusWidget(); FWidget* prev_element = getFocusWidget();
(*iter)->setFocus(); (*iter)->setFocus();
if ( prev_element ) if ( prev_element )
prev_element->redraw(); prev_element->redraw();
(*iter)->redraw(); (*iter)->redraw();
} }
break; break;
} }
++iter; ++iter;
} }
} }
if ( in_ev->isAccepted() ) if ( in_ev->isAccepted() )
{ {
if ( in_ev->getFocusType() == fc::FocusNextWidget ) if ( in_ev->getFocusType() == fc::FocusNextWidget )
@ -493,8 +529,10 @@ void FButtonGroup::onFocusIn (FFocusEvent* in_ev)
in_ev->ignore(); in_ev->ignore();
FWidget* prev_element = getFocusWidget(); FWidget* prev_element = getFocusWidget();
focusFirstChild(); focusFirstChild();
if ( prev_element ) if ( prev_element )
prev_element->redraw(); prev_element->redraw();
getFocusWidget()->redraw(); getFocusWidget()->redraw();
} }
else if ( in_ev->getFocusType() == fc::FocusPreviousWidget ) else if ( in_ev->getFocusType() == fc::FocusPreviousWidget )
@ -502,11 +540,14 @@ void FButtonGroup::onFocusIn (FFocusEvent* in_ev)
in_ev->ignore(); in_ev->ignore();
FWidget* prev_element = getFocusWidget(); FWidget* prev_element = getFocusWidget();
focusLastChild(); focusLastChild();
if ( prev_element ) if ( prev_element )
prev_element->redraw(); prev_element->redraw();
getFocusWidget()->redraw(); getFocusWidget()->redraw();
} }
} }
if ( statusBar() ) if ( statusBar() )
{ {
statusBar()->drawMessage(); statusBar()->drawMessage();
@ -534,6 +575,7 @@ bool FButtonGroup::setEnable (bool on)
flags &= ~fc::active; flags &= ~fc::active;
delAccelerator(); delAccelerator();
} }
return on; return on;
} }
@ -544,6 +586,7 @@ bool FButtonGroup::setBorder(bool on)
border = true; border = true;
else else
border = false; border = false;
return on; return on;
} }
@ -551,6 +594,7 @@ bool FButtonGroup::setBorder(bool on)
void FButtonGroup::setText (const FString& txt) void FButtonGroup::setText (const FString& txt)
{ {
text = txt; text = txt;
if ( isEnabled() ) if ( isEnabled() )
{ {
delAccelerator(); delAccelerator();

View File

@ -44,7 +44,6 @@ void FCheckBox::draw()
drawCheckButton(); drawCheckButton();
drawLabel(); drawLabel();
setUpdateVTerm(true); setUpdateVTerm(true);
FToggleButton::draw(); FToggleButton::draw();
} }
@ -64,6 +63,7 @@ void FCheckBox::drawCheckButton()
else else
setReverse(true); setReverse(true);
} }
if ( checked ) if ( checked )
{ {
if ( isNewFont() ) if ( isNewFont() )
@ -86,6 +86,7 @@ void FCheckBox::drawCheckButton()
print (']'); print (']');
} }
} }
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
} }

View File

@ -53,6 +53,7 @@ void FCheckMenuItem::init (FWidget* parent)
if ( isMenu(parent) ) // Parent is menu if ( isMenu(parent) ) // Parent is menu
{ {
FMenu* menu_ptr = dynamic_cast<FMenu*>(parent); FMenu* menu_ptr = dynamic_cast<FMenu*>(parent);
if ( menu_ptr ) if ( menu_ptr )
menu_ptr->has_checkable_items = true; menu_ptr->has_checkable_items = true;
} }

View File

@ -44,17 +44,18 @@ FDialog::FDialog (const FString& txt, FWidget* parent)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FDialog::~FDialog() // destructor FDialog::~FDialog() // destructor
{ {
FApplication* fapp;
delete accelerator_list; delete accelerator_list;
accelerator_list = 0; accelerator_list = 0;
activatePrevWindow(); activatePrevWindow();
delWindow(this); delWindow(this);
fapp = static_cast<FApplication*>(getRootWidget());
FApplication* fapp = static_cast<FApplication*>(getRootWidget());
if ( ! fapp->quit_now ) if ( ! fapp->quit_now )
{ {
const FRect& geometry = getGeometryGlobalShadow(); const FRect& geometry = getGeometryGlobalShadow();
restoreVTerm (geometry); restoreVTerm (geometry);
getParentWidget()->redraw(); getParentWidget()->redraw();
} }
@ -67,10 +68,13 @@ FDialog::~FDialog() // destructor
while ( iter != end ) while ( iter != end )
{ {
putArea ((*iter)->getGlobalPos(), (*iter)->getVWin()); putArea ((*iter)->getGlobalPos(), (*iter)->getVWin());
if ( ! maximized && ((*iter)->getFlags() & fc::shadow) != 0 ) if ( ! maximized && ((*iter)->getFlags() & fc::shadow) != 0 )
static_cast<FDialog*>(*iter)->drawDialogShadow(); static_cast<FDialog*>(*iter)->drawDialogShadow();
++iter; ++iter;
} }
setFocusWidget(0); setFocusWidget(0);
updateTerminal(); updateTerminal();
flush_out(); flush_out();
@ -80,10 +84,13 @@ FDialog::~FDialog() // destructor
{ {
if ( vwin->changes != 0 ) if ( vwin->changes != 0 )
delete[] vwin->changes; delete[] vwin->changes;
if ( vwin->text != 0 ) if ( vwin->text != 0 )
delete[] vwin->text; delete[] vwin->text;
delete vwin; delete vwin;
} }
if ( isModal() ) if ( isModal() )
unsetModal(); unsetModal();
} }
@ -92,7 +99,10 @@ FDialog::~FDialog() // destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FDialog::init() void FDialog::init()
{ {
FWidget* rootObj = getRootWidget(); FMenuItem* close_item;
FWidget* old_focus;
FWidget* rootObj = getRootWidget();
xmin = 1 + rootObj->getLeftPadding(); xmin = 1 + rootObj->getLeftPadding();
ymin = 1 + rootObj->getTopPadding(); ymin = 1 + rootObj->getTopPadding();
xmax = rootObj->getWidth(); xmax = rootObj->getWidth();
@ -120,28 +130,30 @@ void FDialog::init()
if ( hasFocus() ) if ( hasFocus() )
flags |= fc::focus; flags |= fc::focus;
if ( isEnabled() ) if ( isEnabled() )
flags |= fc::active; flags |= fc::active;
FWidget* old_focus = FWidget::getFocusWidget(); old_focus = FWidget::getFocusWidget();
if ( old_focus ) if ( old_focus )
{ {
setFocus(); setFocus();
old_focus->redraw(); old_focus->redraw();
} }
accelerator_list = new Accelerators();
accelerator_list = new Accelerators();
dialog_menu = new FMenu ("-", this); dialog_menu = new FMenu ("-", this);
dialog_menu->move (xpos, ypos+1); dialog_menu->move (xpos, ypos+1);
dgl_menuitem = dialog_menu->getItem(); dgl_menuitem = dialog_menu->getItem();
if ( dgl_menuitem ) if ( dgl_menuitem )
{ {
dgl_menuitem->ignorePadding(); dgl_menuitem->ignorePadding();
dgl_menuitem->unsetFocusable(); dgl_menuitem->unsetFocusable();
} }
FMenuItem* close_item = new FMenuItem ("&Close", dialog_menu); close_item = new FMenuItem ("&Close", dialog_menu);
close_item->setStatusbarMessage ("Close window"); close_item->setStatusbarMessage ("Close window");
close_item->addCallback close_item->addCallback
@ -163,10 +175,12 @@ void FDialog::drawBorder()
if ( isNewFont() ) if ( isNewFont() )
{ {
short fg; short fg;
if ( ! isRootWidget() ) if ( ! isRootWidget() )
fg = getParentWidget()->getForegroundColor(); fg = getParentWidget()->getForegroundColor();
else else
fg = wc.term_fg; fg = wc.term_fg;
for (int y=y1; y <= y2; y++) for (int y=y1; y <= y2; y++)
{ {
setColor (fg, backgroundColor); setColor (fg, backgroundColor);
@ -177,6 +191,7 @@ void FDialog::drawBorder()
// border right⎹ // border right⎹
print (fc::NF_rev_border_line_right); print (fc::NF_rev_border_line_right);
} }
if ( (flags & fc::shadow) == 0 ) if ( (flags & fc::shadow) == 0 )
{ {
setColor (fg, backgroundColor); setColor (fg, backgroundColor);
@ -189,19 +204,23 @@ void FDialog::drawBorder()
// lower right corner border ⎦ // lower right corner border ⎦
print (fc::NF_rev_border_corner_lower_right); print (fc::NF_rev_border_corner_lower_right);
} }
} }
else else
{ {
gotoxy (x1, y1); gotoxy (x1, y1);
print (fc::BoxDrawingsDownAndRight); // ┌ print (fc::BoxDrawingsDownAndRight); // ┌
for (int x=x1+1; x < x2; x++) for (int x=x1+1; x < x2; x++)
print (fc::BoxDrawingsHorizontal); // ─ print (fc::BoxDrawingsHorizontal); // ─
print (fc::BoxDrawingsDownAndLeft); // ┐
print (fc::BoxDrawingsDownAndLeft); // ┐
gotoxy (x1, y2); gotoxy (x1, y2);
print (fc::BoxDrawingsUpAndRight); // └ print (fc::BoxDrawingsUpAndRight); // └
for (int x=x1+1; x < x2; x++) for (int x=x1+1; x < x2; x++)
print (fc::BoxDrawingsHorizontal); // ─ print (fc::BoxDrawingsHorizontal); // ─
print (fc::BoxDrawingsUpAndLeft); // ┘ print (fc::BoxDrawingsUpAndLeft); // ┘
for (int y=y1+1; y < y2; y++) for (int y=y1+1; y < y2; y++)
@ -211,6 +230,7 @@ void FDialog::drawBorder()
gotoxy (x2, y); gotoxy (x2, y);
print (fc::BoxDrawingsVertical); // │ print (fc::BoxDrawingsVertical); // │
} }
} }
} }
@ -223,6 +243,7 @@ void FDialog::drawTitleBar()
// draw the title button // draw the title button
gotoxy (xpos+xmin-1, ypos+ymin-1); gotoxy (xpos+xmin-1, ypos+ymin-1);
setColor (wc.titlebar_button_fg, wc.titlebar_button_bg); setColor (wc.titlebar_button_fg, wc.titlebar_button_bg);
if ( isMonochron() ) if ( isMonochron() )
{ {
if ( isActiveWindow() ) if ( isActiveWindow() )
@ -241,25 +262,30 @@ void FDialog::drawTitleBar()
else if ( isMonochron() ) else if ( isMonochron() )
{ {
print ('['); print ('[');
if ( dgl_menuitem ) if ( dgl_menuitem )
print (dgl_menuitem->getText()); print (dgl_menuitem->getText());
else else
print ('-'); print ('-');
print (']'); print (']');
} }
else else
{ {
print (' '); print (' ');
if ( dgl_menuitem ) if ( dgl_menuitem )
print (dgl_menuitem->getText()); print (dgl_menuitem->getText());
else else
print ('-'); print ('-');
print (' '); print (' ');
} }
// fill with spaces (left of the title) // fill with spaces (left of the title)
if ( getMaxColor() < 16 ) if ( getMaxColor() < 16 )
setBold(); setBold();
if ( isActiveWindow() || dialog_menu->isVisible() ) if ( isActiveWindow() || dialog_menu->isVisible() )
setColor (wc.titlebar_active_fg, wc.titlebar_active_bg); setColor (wc.titlebar_active_fg, wc.titlebar_active_bg);
else else
@ -281,6 +307,7 @@ void FDialog::drawTitleBar()
if ( getMaxColor() < 16 ) if ( getMaxColor() < 16 )
unsetBold(); unsetBold();
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
@ -299,8 +326,10 @@ void FDialog::leaveMenu()
raiseWindow(); raiseWindow();
getFocusWidget()->setFocus(); getFocusWidget()->setFocus();
redraw(); redraw();
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
updateTerminal(); updateTerminal();
flush_out(); flush_out();
} }
@ -337,6 +366,7 @@ void FDialog::drawDialogShadow()
FOptiAttr::char_data ch; FOptiAttr::char_data ch;
// left of the shadow ▀▀ // left of the shadow ▀▀
gotoxy (xpos+xmin-1, ypos+ymin-1+height); gotoxy (xpos+xmin-1, ypos+ymin-1+height);
for (int x=0; x <= 1; x++) for (int x=0; x <= 1; x++)
{ {
ch = getCoveredCharacter (xpos+xmin-1+x, ypos+ymin-1+height, this); ch = getCoveredCharacter (xpos+xmin-1+x, ypos+ymin-1+height, this);
@ -348,12 +378,12 @@ void FDialog::drawDialogShadow()
} }
else else
{ {
FOptiAttr::char_data ch;
if ( isMonochron() ) if ( isMonochron() )
return; return;
drawShadow(); drawShadow();
FOptiAttr::char_data ch;
ch = getCoveredCharacter (xpos+xmin-1, ypos+ymin-1+height, this); ch = getCoveredCharacter (xpos+xmin-1, ypos+ymin-1+height, this);
// left of the shadow ▀▀ // left of the shadow ▀▀
gotoxy (xpos+xmin-1, ypos+ymin-1+height); gotoxy (xpos+xmin-1, ypos+ymin-1+height);
@ -370,33 +400,44 @@ void FDialog::drawDialogShadow()
if ( ch.bold ) if ( ch.bold )
setBold(); setBold();
if ( ch.dim ) if ( ch.dim )
setDim(); setDim();
if ( ch.italic ) if ( ch.italic )
setItalic(); setItalic();
if ( ch.underline ) if ( ch.underline )
setUnderline(); setUnderline();
if ( ch.blink ) if ( ch.blink )
setBlink(); setBlink();
if ( ch.reverse ) if ( ch.reverse )
setReverse(); setReverse();
if ( ch.standout ) if ( ch.standout )
setStandout(); setStandout();
if ( ch.invisible ) if ( ch.invisible )
setInvisible(); setInvisible();
if ( ch.protect ) if ( ch.protect )
setProtected(); setProtected();
if ( ch.crossed_out ) if ( ch.crossed_out )
setCrossedOut(); setCrossedOut();
if ( ch.dbl_underline ) if ( ch.dbl_underline )
setDoubleUnderline(); setDoubleUnderline();
if ( ch.alt_charset ) if ( ch.alt_charset )
setAltCharset (true); setAltCharset (true);
if ( ch.pc_charset ) if ( ch.pc_charset )
setPCcharset (true); setPCcharset (true);
print (ch.code); print (ch.code);
setNormal(); setNormal();
} }
} }
@ -414,9 +455,9 @@ void FDialog::draw()
} }
setUpdateVTerm(false); setUpdateVTerm(false);
// fill the background // fill the background
setColor (foregroundColor, backgroundColor); setColor (foregroundColor, backgroundColor);
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
@ -469,8 +510,10 @@ void FDialog::draw()
} }
} }
} }
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
setUpdateVTerm(true); setUpdateVTerm(true);
} }
@ -500,6 +543,7 @@ void FDialog::onKeyPress (FKeyEvent* ev)
|| ev->key() == fc::Fkey_escape_mintty ) || ev->key() == fc::Fkey_escape_mintty )
{ {
ev->accept(); ev->accept();
if ( isModal() ) if ( isModal() )
done (FDialog::Reject); done (FDialog::Reject);
else else
@ -515,13 +559,15 @@ void FDialog::onMouseDown (FMouseEvent* ev)
if ( ev->getButton() == fc::LeftButton ) if ( ev->getButton() == fc::LeftButton )
{ {
bool has_raised;
// click on titlebar or window: raise + activate // click on titlebar or window: raise + activate
if ( mouse_x >= 4 && mouse_x <= width && mouse_y == 1 ) if ( mouse_x >= 4 && mouse_x <= width && mouse_y == 1 )
TitleBarClickPos.setPoint (ev->getGlobalX(), ev->getGlobalY()); TitleBarClickPos.setPoint (ev->getGlobalX(), ev->getGlobalY());
else else
TitleBarClickPos.setPoint (0,0); TitleBarClickPos.setPoint (0,0);
bool has_raised = raiseWindow(); has_raised = raiseWindow();
if ( ! isActiveWindow() ) if ( ! isActiveWindow() )
{ {
@ -532,6 +578,7 @@ void FDialog::onMouseDown (FMouseEvent* ev)
{ {
focus_widget->setFocus(); focus_widget->setFocus();
focus_widget->redraw(); focus_widget->redraw();
if ( old_focus ) if ( old_focus )
old_focus->redraw(); old_focus->redraw();
} }
@ -540,8 +587,10 @@ void FDialog::onMouseDown (FMouseEvent* ev)
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
updateTerminal(); updateTerminal();
} }
if ( has_raised ) if ( has_raised )
redraw(); redraw();
@ -577,10 +626,12 @@ void FDialog::onMouseDown (FMouseEvent* ev)
{ {
FWidget* old_focus = FWidget::getFocusWidget(); FWidget* old_focus = FWidget::getFocusWidget();
setActiveWindow(this); setActiveWindow(this);
if ( focus_widget ) if ( focus_widget )
{ {
focus_widget->setFocus(); focus_widget->setFocus();
focus_widget->redraw(); focus_widget->redraw();
if ( old_focus ) if ( old_focus )
old_focus->redraw(); old_focus->redraw();
} }
@ -589,6 +640,7 @@ void FDialog::onMouseDown (FMouseEvent* ev)
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
updateTerminal(); updateTerminal();
} }
} }
@ -605,10 +657,12 @@ void FDialog::onMouseDown (FMouseEvent* ev)
{ {
FWidget* old_focus = FWidget::getFocusWidget(); FWidget* old_focus = FWidget::getFocusWidget();
setActiveWindow(this); setActiveWindow(this);
if ( focus_widget ) if ( focus_widget )
{ {
focus_widget->setFocus(); focus_widget->setFocus();
focus_widget->redraw(); focus_widget->redraw();
if ( old_focus ) if ( old_focus )
old_focus->redraw(); old_focus->redraw();
} }
@ -617,6 +671,7 @@ void FDialog::onMouseDown (FMouseEvent* ev)
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
updateTerminal(); updateTerminal();
} }
else if ( has_lowered ) else if ( has_lowered )
@ -656,11 +711,15 @@ void FDialog::onMouseUp (FMouseEvent* ev)
FMenuItem* first_item; FMenuItem* first_item;
dialog_menu->selectFirstItem(); dialog_menu->selectFirstItem();
first_item = dialog_menu->getSelectedItem(); first_item = dialog_menu->getSelectedItem();
if ( first_item ) if ( first_item )
first_item->setFocus(); first_item->setFocus();
dialog_menu->redraw(); dialog_menu->redraw();
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
updateTerminal(); updateTerminal();
flush_out(); flush_out();
} }
@ -712,8 +771,8 @@ void FDialog::onMouseDoubleClick (FMouseEvent* ev)
x = xpos + xmin - 1; x = xpos + xmin - 1;
y = ypos + ymin - 1; y = ypos + ymin - 1;
FRect title_button(x, y, 3, 1); FRect title_button(x, y, 3, 1);
FPoint gPos = ev->getGlobalPos(); FPoint gPos = ev->getGlobalPos();
if ( title_button.contains(gPos) ) if ( title_button.contains(gPos) )
{ {
dialog_menu->unselectItem(); dialog_menu->unselectItem();
@ -774,6 +833,7 @@ void FDialog::onWindowRaised (FEvent*)
if ( ! window_list ) if ( ! window_list )
return; return;
if ( window_list->empty() ) if ( window_list->empty() )
return; return;
@ -783,10 +843,12 @@ void FDialog::onWindowRaised (FEvent*)
while ( iter != end ) while ( iter != end )
{ {
if ( *iter != this if ( *iter != this && ! maximized
&& ! maximized && ((*iter)->getFlags() & fc::shadow) != 0 )
&& ((*iter)->getFlags() & fc::shadow) != 0 ) {
static_cast<FDialog*>(*iter)->drawDialogShadow(); static_cast<FDialog*>(*iter)->drawDialogShadow();
}
++iter; ++iter;
} }
} }
@ -798,6 +860,7 @@ void FDialog::onWindowLowered (FEvent*)
if ( ! window_list ) if ( ! window_list )
return; return;
if ( window_list->empty() ) if ( window_list->empty() )
return; return;
@ -807,8 +870,10 @@ void FDialog::onWindowLowered (FEvent*)
while ( iter != end ) while ( iter != end )
{ {
putArea ((*iter)->getGlobalPos(), (*iter)->getVWin()); putArea ((*iter)->getGlobalPos(), (*iter)->getVWin());
if ( ! maximized && ((*iter)->getFlags() & fc::shadow) != 0 ) if ( ! maximized && ((*iter)->getFlags() & fc::shadow) != 0 )
static_cast<FDialog*>(*iter)->drawDialogShadow(); static_cast<FDialog*>(*iter)->drawDialogShadow();
++iter; ++iter;
} }
} }
@ -875,6 +940,7 @@ void FDialog::move (int x, int y)
if ( x == xpos && y == ypos ) if ( x == xpos && y == ypos )
return; return;
if ( x+width < 1 || x > getColumnNumber() || y < 1 || y > getLineNumber() ) if ( x+width < 1 || x > getColumnNumber() || y < 1 || y > getLineNumber() )
return; return;
@ -889,7 +955,6 @@ void FDialog::move (int x, int y)
FWidget::move(x,y); FWidget::move(x,y);
xpos = x; xpos = x;
ypos = y; ypos = y;
putArea (getGlobalPos(), vwin); putArea (getGlobalPos(), vwin);
if ( getGeometry().overlap(oldGeometry) ) if ( getGeometry().overlap(oldGeometry) )
@ -941,11 +1006,14 @@ void FDialog::move (int x, int y)
if ( overlaid ) if ( overlaid )
{ {
putArea ((*iter)->getGlobalPos(), (*iter)->getVWin()); putArea ((*iter)->getGlobalPos(), (*iter)->getVWin());
if ( ! maximized && ((*iter)->getFlags() & fc::shadow) != 0 ) if ( ! maximized && ((*iter)->getFlags() & fc::shadow) != 0 )
static_cast<FDialog*>(*iter)->drawDialogShadow(); static_cast<FDialog*>(*iter)->drawDialogShadow();
} }
if ( vwin == (*iter)->getVWin() ) if ( vwin == (*iter)->getVWin() )
overlaid = true; overlaid = true;
++iter; ++iter;
} }
} }
@ -959,9 +1027,11 @@ void FDialog::move (int x, int y)
{ {
FPoint cursor_pos = FWidget::getFocusWidget()->getCursorPos(); FPoint cursor_pos = FWidget::getFocusWidget()->getCursorPos();
cursor_pos -= FPoint(dx,dy); cursor_pos -= FPoint(dx,dy);
if ( ! FWidget::getFocusWidget()->setCursorPos(cursor_pos) ) if ( ! FWidget::getFocusWidget()->setCursorPos(cursor_pos) )
hideCursor(); hideCursor();
} }
updateTerminal(); updateTerminal();
} }
@ -970,6 +1040,7 @@ void FDialog::setWidth (int w, bool adjust)
{ {
int old_width = width; int old_width = width;
FWidget::setWidth (w, adjust); FWidget::setWidth (w, adjust);
if ( vwin && width != old_width ) if ( vwin && width != old_width )
resizeArea (vwin); resizeArea (vwin);
} }
@ -979,6 +1050,7 @@ void FDialog::setHeight (int h, bool adjust)
{ {
int old_height = height; int old_height = height;
FWidget::setHeight (h, adjust); FWidget::setHeight (h, adjust);
if ( vwin && height != old_height ) if ( vwin && height != old_height )
resizeArea (vwin); resizeArea (vwin);
} }
@ -989,6 +1061,7 @@ void FDialog::setGeometry (int x, int y, int w, int h, bool adjust)
int old_width = width; int old_width = width;
int old_height = height; int old_height = height;
FWidget::setGeometry (x, y, w, h, adjust); FWidget::setGeometry (x, y, w, h, adjust);
if ( vwin && (width != old_width || height != old_height) ) if ( vwin && (width != old_width || height != old_height) )
resizeArea (vwin); resizeArea (vwin);
} }
@ -1014,6 +1087,7 @@ bool FDialog::setFocus (bool on)
flags |= fc::focus; flags |= fc::focus;
else else
flags &= ~fc::focus; flags &= ~fc::focus;
return on; return on;
} }
@ -1033,6 +1107,7 @@ bool FDialog::setModal (bool on)
flags &= ~fc::modal; flags &= ~fc::modal;
modal_dialogs--; modal_dialogs--;
} }
return on; return on;
} }
@ -1055,6 +1130,7 @@ bool FDialog::setTransparentShadow (bool on)
adjustWidgetSizeShadow = getGeometry() + getShadow(); adjustWidgetSizeShadow = getGeometry() + getShadow();
adjustWidgetSizeGlobalShadow = getGeometryGlobal() + getShadow(); adjustWidgetSizeGlobalShadow = getGeometryGlobal() + getShadow();
} }
resizeArea (vwin); resizeArea (vwin);
return on; return on;
} }
@ -1081,6 +1157,7 @@ bool FDialog::setShadow (bool on)
adjustWidgetSizeShadow = getGeometry() + getShadow(); adjustWidgetSizeShadow = getGeometry() + getShadow();
adjustWidgetSizeGlobalShadow = getGeometryGlobal() + getShadow(); adjustWidgetSizeGlobalShadow = getGeometryGlobal() + getShadow();
} }
resizeArea (vwin); resizeArea (vwin);
return on; return on;
} }
@ -1092,6 +1169,7 @@ bool FDialog::setScrollable (bool on)
flags |= fc::scrollable; flags |= fc::scrollable;
else else
flags &= ~fc::scrollable; flags &= ~fc::scrollable;
return on; return on;
} }
@ -1102,6 +1180,7 @@ bool FDialog::setResizeable (bool on)
flags |= fc::resizeable; flags |= fc::resizeable;
else else
flags &= ~fc::resizeable; flags &= ~fc::resizeable;
return on; return on;
} }
@ -1112,6 +1191,7 @@ bool FDialog::setMaximized()
return true; return true;
maximized = true; maximized = true;
// setGeometry(1, 1, xmax, ymax); //setGeometry (1, 1, xmax, ymax);
return maximized; return maximized;
} }

View File

@ -50,6 +50,7 @@ FDialogListMenu::~FDialogListMenu()
void FDialogListMenu::init() void FDialogListMenu::init()
{ {
FMenuItem* menuitem = getItem(); FMenuItem* menuitem = getItem();
if ( menuitem ) if ( menuitem )
menuitem->dialog_list = true; menuitem->dialog_list = true;
} }

View File

@ -61,6 +61,7 @@ FFileDialog::FFileDialog (const FFileDialog& fdlg)
{ {
if ( directory ) if ( directory )
setPath(directory); setPath(directory);
init(); init();
} }
@ -84,6 +85,7 @@ FFileDialog::FFileDialog ( const FString& dirname
{ {
if ( dirname ) if ( dirname )
setPath(dirname); setPath(dirname);
init(); init();
} }
@ -105,11 +107,14 @@ void FFileDialog::init()
{ {
int x, y; int x, y;
height = 15; height = 15;
width = 42; width = 42;
if ( width < 15 ) if ( width < 15 )
width = 15; width = 15;
if ( width < 20 ) if ( width < 20 )
width = 20; width = 20;
x = 1 + int((getParentWidget()->getWidth()-width)/2); x = 1 + int((getParentWidget()->getWidth()-width)/2);
y = 1 + int((getParentWidget()->getHeight()-height)/3); y = 1 + int((getParentWidget()->getHeight()-height)/3);
@ -140,9 +145,9 @@ void FFileDialog::init()
open = new FButton("&Save",this); open = new FButton("&Save",this);
else else
open = new FButton("&Open",this); open = new FButton("&Open",this);
open->setGeometry(30, 10, 9, 1); open->setGeometry(30, 10, 9, 1);
open->setShadow(); open->setShadow();
setGeometry (x, y, width, height); setGeometry (x, y, width, height);
filename->addCallback filename->addCallback
@ -150,34 +155,39 @@ void FFileDialog::init()
"activate", "activate",
_METHOD_CALLBACK (this, &FFileDialog::cb_processActivate) _METHOD_CALLBACK (this, &FFileDialog::cb_processActivate)
); );
filebrowser->addCallback filebrowser->addCallback
( (
"row-changed", "row-changed",
_METHOD_CALLBACK (this, &FFileDialog::cb_processRowChanged) _METHOD_CALLBACK (this, &FFileDialog::cb_processRowChanged)
); );
filebrowser->addCallback filebrowser->addCallback
( (
"clicked", "clicked",
_METHOD_CALLBACK (this, &FFileDialog::cb_processClicked) _METHOD_CALLBACK (this, &FFileDialog::cb_processClicked)
); );
hidden->addCallback hidden->addCallback
( (
"toggled", "toggled",
_METHOD_CALLBACK (this, &FFileDialog::cb_processShowHidden) _METHOD_CALLBACK (this, &FFileDialog::cb_processShowHidden)
); );
cancel->addCallback cancel->addCallback
( (
"clicked", "clicked",
_METHOD_CALLBACK (this, &FFileDialog::cb_processCancel) _METHOD_CALLBACK (this, &FFileDialog::cb_processCancel)
); );
open->addCallback open->addCallback
( (
"clicked", "clicked",
_METHOD_CALLBACK (this, &FFileDialog::cb_processOpen) _METHOD_CALLBACK (this, &FFileDialog::cb_processOpen)
); );
setModal(); setModal();
setTransparentShadow(); setTransparentShadow();
readDir(); readDir();
} }
@ -205,6 +215,7 @@ inline bool FFileDialog::pattern_match ( const char* pattern
, const char* fname ) , const char* fname )
{ {
char search[128] = {}; char search[128] = {};
if ( show_hidden && fname[0] == '.' && fname[1] != '\0' ) // hidden files if ( show_hidden && fname[0] == '.' && fname[1] != '\0' ) // hidden files
{ {
search[0] = '.'; search[0] = '.';
@ -245,6 +256,7 @@ void FFileDialog::clear()
int FFileDialog::numOfDirs() int FFileDialog::numOfDirs()
{ {
int n = 0; int n = 0;
if ( ! dir_entries.empty() ) if ( ! dir_entries.empty() )
{ {
std::vector<dir_entry>::const_iterator iter, end; std::vector<dir_entry>::const_iterator iter, end;
@ -255,9 +267,11 @@ int FFileDialog::numOfDirs()
{ {
if ( (*iter).type == DT_DIR && strcmp((*iter).name, ".") != 0 ) if ( (*iter).type == DT_DIR && strcmp((*iter).name, ".") != 0 )
n++; n++;
++iter; ++iter;
} }
} }
return n; return n;
} }
@ -296,7 +310,6 @@ int FFileDialog::changeDir (const FString& dirname)
int i = 1; int i = 1;
std::vector<dir_entry>::const_iterator iter, end; std::vector<dir_entry>::const_iterator iter, end;
const char* baseName = basename(const_cast<char*>(lastdir.c_str())); const char* baseName = basename(const_cast<char*>(lastdir.c_str()));
iter = dir_entries.begin(); iter = dir_entries.begin();
end = dir_entries.end(); end = dir_entries.end();
@ -308,6 +321,7 @@ int FFileDialog::changeDir (const FString& dirname)
filename->setText(FString(baseName) + '/'); filename->setText(FString(baseName) + '/');
break; break;
} }
i++; i++;
++iter; ++iter;
} }
@ -316,11 +330,13 @@ int FFileDialog::changeDir (const FString& dirname)
else else
{ {
FString firstname = dir_entries[0].name; FString firstname = dir_entries[0].name;
if ( dir_entries[0].type == DT_DIR ) if ( dir_entries[0].type == DT_DIR )
filename->setText(firstname + '/'); filename->setText(firstname + '/');
else else
filename->setText(firstname); filename->setText(firstname);
} }
printPath(directory); printPath(directory);
filename->redraw(); filename->redraw();
filebrowser->redraw(); filebrowser->redraw();
@ -367,11 +383,11 @@ void FFileDialog::cb_processActivate (FWidget*, void*)
else else
{ {
bool found = false; bool found = false;
if ( ! dir_entries.empty() ) if ( ! dir_entries.empty() )
{ {
std::vector<dir_entry>::const_iterator iter, end; std::vector<dir_entry>::const_iterator iter, end;
FString input = filename->getText().trim(); FString input = filename->getText().trim();
iter = dir_entries.begin(); iter = dir_entries.begin();
end = dir_entries.end(); end = dir_entries.end();
@ -383,9 +399,11 @@ void FFileDialog::cb_processActivate (FWidget*, void*)
changeDir(input); changeDir(input);
break; break;
} }
++iter; ++iter;
} }
} }
if ( ! found ) if ( ! found )
done (FDialog::Accept); done (FDialog::Accept);
} }
@ -395,13 +413,17 @@ void FFileDialog::cb_processActivate (FWidget*, void*)
void FFileDialog::cb_processRowChanged (FWidget*, void*) void FFileDialog::cb_processRowChanged (FWidget*, void*)
{ {
int n = filebrowser->currentItem(); int n = filebrowser->currentItem();
if ( n == 0 ) if ( n == 0 )
return; return;
FString name = dir_entries[uLong(n-1)].name; FString name = dir_entries[uLong(n-1)].name;
if ( dir_entries[uLong(n-1)].type == DT_DIR ) if ( dir_entries[uLong(n-1)].type == DT_DIR )
filename->setText( name + '/' ); filename->setText( name + '/' );
else else
filename->setText( name ); filename->setText( name );
filename->redraw(); filename->redraw();
} }
@ -443,10 +465,13 @@ void FFileDialog::adjustSize()
int max_height = getRootWidget()->getClientHeight(); int max_height = getRootWidget()->getClientHeight();
int max_width = getRootWidget()->getClientWidth(); int max_width = getRootWidget()->getClientWidth();
int h = max_height - 6; int h = max_height - 6;
if ( h < 15 ) // minimum if ( h < 15 ) // minimum
h = 15; h = 15;
if ( h > 30 ) // maximum if ( h > 30 ) // maximum
h = 30; h = 30;
setHeight (h, false); setHeight (h, false);
X = 1 + int((max_width-width)/2); X = 1 + int((max_width-width)/2);
Y = 1 + int((max_height-height)/3); Y = 1 + int((max_height-height)/3);
@ -475,9 +500,7 @@ FFileDialog& FFileDialog::operator = (const FFileDialog& fdlg)
delete filebrowser; delete filebrowser;
delete filename; delete filename;
clear(); clear();
fdlg.getParentWidget()->addChild (this); fdlg.getParentWidget()->addChild (this);
directory = fdlg.directory; directory = fdlg.directory;
filter_pattern = fdlg.filter_pattern; filter_pattern = fdlg.filter_pattern;
dlg_type = fdlg.dlg_type; dlg_type = fdlg.dlg_type;
@ -485,8 +508,8 @@ FFileDialog& FFileDialog::operator = (const FFileDialog& fdlg)
if ( directory ) if ( directory )
setPath(directory); setPath(directory);
init();
init();
return *this; return *this;
} }
} }
@ -530,6 +553,7 @@ void FFileDialog::setPath (const FString& dir)
directory = '/'; directory = '/';
return; return;
} }
if ( S_ISLNK(sb.st_mode) ) if ( S_ISLNK(sb.st_mode) )
{ {
if ( lstat(dirname, &sb) != 0 ) if ( lstat(dirname, &sb) != 0 )
@ -538,6 +562,7 @@ void FFileDialog::setPath (const FString& dir)
return; return;
} }
} }
if ( ! S_ISDIR(sb.st_mode) ) if ( ! S_ISDIR(sb.st_mode) )
{ {
directory = '/'; directory = '/';
@ -575,10 +600,12 @@ const FString FFileDialog::getSelectedFile() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FFileDialog::readDir() int FFileDialog::readDir()
{ {
int start, dir_num;
const char* dir = directory.c_str(); const char* dir = directory.c_str();
const char* filter = filter_pattern.c_str(); const char* filter = filter_pattern.c_str();
errno = 0; errno = 0;
directory_stream = opendir(dir); directory_stream = opendir(dir);
if ( ! directory_stream ) if ( ! directory_stream )
{ {
FMessageBox::error (this, "Can't open directory\n" + directory); FMessageBox::error (this, "Can't open directory\n" + directory);
@ -591,17 +618,23 @@ int FFileDialog::readDir()
{ {
errno = 0; errno = 0;
struct dirent* next = readdir (directory_stream); struct dirent* next = readdir (directory_stream);
if ( next ) if ( next )
{ {
if ( next->d_name[0] == '.' && next->d_name[1] == '\0' ) if ( next->d_name[0] == '.' && next->d_name[1] == '\0' )
continue; continue;
if ( ! show_hidden if ( ! show_hidden
&& next->d_name[0] == '.' && next->d_name[0] == '.'
&& next->d_name[1] != '\0' && next->d_name[1] != '\0'
&& next->d_name[1] != '.' ) && next->d_name[1] != '.' )
{
continue; continue;
}
if ( dir[0] == '/' && dir[1] == '\0' && strcmp(next->d_name, "..") == 0 ) if ( dir[0] == '/' && dir[1] == '\0' && strcmp(next->d_name, "..") == 0 )
continue; continue;
dir_entry entry; dir_entry entry;
entry.name = strdup(next->d_name); entry.name = strdup(next->d_name);
entry.type = next->d_type; entry.type = next->d_type;
@ -616,6 +649,7 @@ int FFileDialog::readDir()
if ( realpath(symLink, resolved_path) != 0 ) // follow link if ( realpath(symLink, resolved_path) != 0 ) // follow link
{ {
struct stat sb; struct stat sb;
if ( lstat(resolved_path, &sb) == 0 ) if ( lstat(resolved_path, &sb) == 0 )
{ {
if ( S_ISDIR(sb.st_mode) ) if ( S_ISDIR(sb.st_mode) )
@ -623,6 +657,7 @@ int FFileDialog::readDir()
} }
} }
} }
if ( entry.type == DT_DIR ) if ( entry.type == DT_DIR )
dir_entries.push_back (entry); dir_entries.push_back (entry);
else if ( pattern_match(filter, entry.name) ) else if ( pattern_match(filter, entry.name) )
@ -633,11 +668,13 @@ int FFileDialog::readDir()
else if (errno != 0) else if (errno != 0)
{ {
FMessageBox::error (this, "Reading directory\n" + directory); FMessageBox::error (this, "Reading directory\n" + directory);
if ( errno != EOVERFLOW ) if ( errno != EOVERFLOW )
break; break;
} }
else else
break; break;
} // end while } // end while
if ( closedir (directory_stream) != 0 ) if ( closedir (directory_stream) != 0 )
@ -646,24 +683,21 @@ int FFileDialog::readDir()
return -2; return -2;
} }
int start;
if ( strcmp((*dir_entries.begin()).name, "..") == 0 ) if ( strcmp((*dir_entries.begin()).name, "..") == 0 )
start=1; start=1;
else else
start=0; start=0;
int dir_num = numOfDirs();
dir_num = numOfDirs();
// directories first // directories first
std::sort(dir_entries.begin()+start, dir_entries.end(), sortDirFirst); std::sort(dir_entries.begin()+start, dir_entries.end(), sortDirFirst);
// sort directories by name // sort directories by name
std::sort(dir_entries.begin()+start, dir_entries.begin()+dir_num, sortByName); std::sort(dir_entries.begin()+start, dir_entries.begin()+dir_num, sortByName);
// sort files by name // sort files by name
std::sort(dir_entries.begin()+dir_num, dir_entries.end(), sortByName); std::sort(dir_entries.begin()+dir_num, dir_entries.end(), sortByName);
// fill list with directory entries // fill list with directory entries
filebrowser->clear(); filebrowser->clear();
if ( ! dir_entries.empty() ) if ( ! dir_entries.empty() )
{ {
std::vector<dir_entry>::const_iterator iter, end; std::vector<dir_entry>::const_iterator iter, end;
@ -676,9 +710,11 @@ int FFileDialog::readDir()
filebrowser->insert(FString((*iter).name), fc::SquareBrackets); filebrowser->insert(FString((*iter).name), fc::SquareBrackets);
else else
filebrowser->insert(FString((*iter).name)); filebrowser->insert(FString((*iter).name));
++iter; ++iter;
} }
} }
return 0; return 0;
} }
@ -699,17 +735,22 @@ FString FFileDialog::fileOpenChooser ( FWidget* parent
, const FString& dirname , const FString& dirname
, const FString& filter ) , const FString& filter )
{ {
FFileDialog* fileopen;
FString ret; FString ret;
FString path = dirname; FString path = dirname;
FString file_filter = filter; FString file_filter = filter;
if ( path.isNull() ) if ( path.isNull() )
path = getHomeDir(); path = getHomeDir();
if ( file_filter.isNull() ) if ( file_filter.isNull() )
file_filter = FString("*"); file_filter = FString("*");
FFileDialog* fileopen = new FFileDialog ( path
, file_filter fileopen = new FFileDialog ( path
, FFileDialog::Open , file_filter
, parent ); , FFileDialog::Open
, parent );
if ( fileopen->exec() == FDialog::Accept ) if ( fileopen->exec() == FDialog::Accept )
ret = fileopen->getPath() + fileopen->getSelectedFile(); ret = fileopen->getPath() + fileopen->getSelectedFile();
else else
@ -724,21 +765,27 @@ FString FFileDialog::fileSaveChooser ( FWidget* parent
, const FString& dirname , const FString& dirname
, const FString& filter ) , const FString& filter )
{ {
FFileDialog* fileopen;
FString ret; FString ret;
FString path = dirname; FString path = dirname;
FString file_filter = filter; FString file_filter = filter;
if ( path.isNull() ) if ( path.isNull() )
path = getHomeDir(); path = getHomeDir();
if ( file_filter.isNull() ) if ( file_filter.isNull() )
file_filter = FString("*"); file_filter = FString("*");
FFileDialog* fileopen = new FFileDialog ( path
, file_filter fileopen = new FFileDialog ( path
, FFileDialog::Save , file_filter
, parent ); , FFileDialog::Save
, parent );
if ( fileopen->exec() == FDialog::Accept ) if ( fileopen->exec() == FDialog::Accept )
ret = fileopen->getPath() + fileopen->getSelectedFile(); ret = fileopen->getPath() + fileopen->getSelectedFile();
else else
ret = FString(); ret = FString();
delete fileopen; delete fileopen;
return ret; return ret;
} }

View File

@ -59,7 +59,6 @@ void FLabel::init()
flags |= fc::active; flags |= fc::active;
unsetFocusable(); unsetFocusable();
foregroundColor = getParentWidget()->getForegroundColor(); foregroundColor = getParentWidget()->getForegroundColor();
backgroundColor = getParentWidget()->getBackgroundColor(); backgroundColor = getParentWidget()->getBackgroundColor();
} }
@ -86,6 +85,7 @@ uChar FLabel::getHotkey()
return 0;; return 0;;
} }
} }
return 0; return 0;
} }
@ -105,8 +105,10 @@ int FLabel::getHotkeyPos (wchar_t*& src, wchar_t*& dest, uInt length)
i++; i++;
src++; src++;
} }
*dest++ = *src++; *dest++ = *src++;
} }
return hotkeypos; return hotkeypos;
} }
@ -114,6 +116,7 @@ int FLabel::getHotkeyPos (wchar_t*& src, wchar_t*& dest, uInt length)
void FLabel::setHotkeyAccelerator() void FLabel::setHotkeyAccelerator()
{ {
int hotkey = getHotkey(); int hotkey = getHotkey();
if ( hotkey ) if ( hotkey )
{ {
if ( isalpha(hotkey) || isdigit(hotkey) ) if ( isalpha(hotkey) || isdigit(hotkey) )
@ -163,7 +166,6 @@ void FLabel::printLine ( wchar_t*& line
{ {
int to_char; int to_char;
bool isActive, isNoUnderline; bool isActive, isNoUnderline;
isActive = ((flags & fc::active) != 0); isActive = ((flags & fc::active) != 0);
isNoUnderline = ((flags & fc::no_underline) != 0); isNoUnderline = ((flags & fc::no_underline) != 0);
@ -191,11 +193,15 @@ void FLabel::printLine ( wchar_t*& line
if ( (z == hotkeypos) && isActive ) if ( (z == hotkeypos) && isActive )
{ {
setColor (wc.label_hotkey_fg, wc.label_hotkey_bg); setColor (wc.label_hotkey_fg, wc.label_hotkey_bg);
if ( ! isNoUnderline ) if ( ! isNoUnderline )
setUnderline(); setUnderline();
print ( line[z] ); print ( line[z] );
if ( ! isNoUnderline ) if ( ! isNoUnderline )
unsetUnderline(); unsetUnderline();
if ( hasEmphasis() ) if ( hasEmphasis() )
setColor (emphasis_color, backgroundColor); setColor (emphasis_color, backgroundColor);
else else
@ -281,6 +287,7 @@ void FLabel::draw()
xoffset = getXOffset (int(length)); xoffset = getXOffset (int(length));
printLine (LabelText, length, -1, xoffset); printLine (LabelText, length, -1, xoffset);
} }
y++; y++;
delete[] LabelText; delete[] LabelText;
} }
@ -291,7 +298,6 @@ void FLabel::draw()
LabelText = new wchar_t[length+1](); LabelText = new wchar_t[length+1]();
src = const_cast<wchar_t*>(text.wc_str()); src = const_cast<wchar_t*>(text.wc_str());
dest = const_cast<wchar_t*>(LabelText); dest = const_cast<wchar_t*>(LabelText);
hotkeypos = getHotkeyPos (src, dest, length); hotkeypos = getHotkeyPos (src, dest, length);
if ( hotkeypos != -1 ) if ( hotkeypos != -1 )
@ -302,12 +308,15 @@ void FLabel::draw()
printLine (LabelText, length, hotkeypos, xoffset); printLine (LabelText, length, hotkeypos, xoffset);
delete[] LabelText; delete[] LabelText;
} }
if ( isMonochron() ) if ( isMonochron() )
{ {
setReverse(false); setReverse(false);
if ( hasEmphasis() ) if ( hasEmphasis() )
setBold(false); setBold(false);
} }
setUpdateVTerm(true); setUpdateVTerm(true);
} }
@ -320,11 +329,9 @@ void FLabel::hide()
char* blank; char* blank;
FWidget::hide(); FWidget::hide();
fg = getParentWidget()->getForegroundColor(); fg = getParentWidget()->getForegroundColor();
bg = getParentWidget()->getBackgroundColor(); bg = getParentWidget()->getBackgroundColor();
setColor (fg, bg); setColor (fg, bg);
blank = new char[width+1]; blank = new char[width+1];
memset(blank, ' ', uLong(width)); memset(blank, ' ', uLong(width));
blank[width] = '\0'; blank[width] = '\0';
@ -347,9 +354,12 @@ void FLabel::onMouseDown (FMouseEvent* ev)
FFocusEvent out (fc::FocusOut_Event); FFocusEvent out (fc::FocusOut_Event);
FApplication::queueEvent(focused_widget, &out); FApplication::queueEvent(focused_widget, &out);
accel_widget->setFocus(); accel_widget->setFocus();
if ( focused_widget ) if ( focused_widget )
focused_widget->redraw(); focused_widget->redraw();
accel_widget->redraw(); accel_widget->redraw();
if ( statusBar() ) if ( statusBar() )
{ {
accel_widget->statusBar()->drawMessage(); accel_widget->statusBar()->drawMessage();
@ -371,9 +381,12 @@ void FLabel::onAccel (FAccelEvent* ev)
FFocusEvent out (fc::FocusOut_Event); FFocusEvent out (fc::FocusOut_Event);
FApplication::queueEvent(focused_widget, &out); FApplication::queueEvent(focused_widget, &out);
accel_widget->setFocus(); accel_widget->setFocus();
if ( focused_widget ) if ( focused_widget )
focused_widget->redraw(); focused_widget->redraw();
accel_widget->redraw(); accel_widget->redraw();
if ( statusBar() ) if ( statusBar() )
{ {
accel_widget->statusBar()->drawMessage(); accel_widget->statusBar()->drawMessage();
@ -381,6 +394,7 @@ void FLabel::onAccel (FAccelEvent* ev)
flush_out(); flush_out();
} }
} }
ev->accept(); ev->accept();
} }
@ -420,6 +434,7 @@ bool FLabel::setEmphasis (bool on)
{ {
if ( emphasis != on ) if ( emphasis != on )
emphasis = on; emphasis = on;
return on; return on;
} }
@ -428,6 +443,7 @@ bool FLabel::setReverseMode (bool on)
{ {
if ( reverse_mode != on ) if ( reverse_mode != on )
reverse_mode = on; reverse_mode = on;
return on; return on;
} }
@ -446,6 +462,7 @@ bool FLabel::setEnable (bool on)
flags &= ~fc::active; flags &= ~fc::active;
delAccelerator(); delAccelerator();
} }
return on; return on;
} }
@ -460,6 +477,7 @@ void FLabel::setText (const FString& txt)
{ {
text = txt; text = txt;
multiline_text = text.split("\r\n"); multiline_text = text.split("\r\n");
if ( int(multiline_text.size()) > 1 ) if ( int(multiline_text.size()) > 1 )
multiline = true; multiline = true;
else else

View File

@ -54,9 +54,11 @@ FLineEdit::~FLineEdit() // destructor
setXTermCursorStyle(fc::blinking_underline); setXTermCursorStyle(fc::blinking_underline);
setKDECursor(fc::UnderlineCursor); setKDECursor(fc::UnderlineCursor);
setConsoleCursor(fc::underscore_cursor); setConsoleCursor(fc::underscore_cursor);
if ( isUrxvtTerminal() ) if ( isUrxvtTerminal() )
setXTermCursorColor("rgb:ffff/ffff/ffff"); setXTermCursorColor("rgb:ffff/ffff/ffff");
} }
if ( hasFocus() ) if ( hasFocus() )
hideCursor(); hideCursor();
} }
@ -98,6 +100,7 @@ bool FLineEdit::hasHotkey()
{ {
if ( label_text.isEmpty() ) if ( label_text.isEmpty() )
return 0; return 0;
return label_text.includes('&'); return label_text.includes('&');
} }
@ -105,14 +108,14 @@ bool FLineEdit::hasHotkey()
void FLineEdit::draw() void FLineEdit::draw()
{ {
bool isFocus; bool isFocus;
drawInputField(); drawInputField();
isFocus = ((flags & fc::focus) != 0); isFocus = ((flags & fc::focus) != 0);
if ( isFocus && statusBar() ) if ( isFocus && statusBar() )
{ {
FString msg = getStatusbarMessage(); FString msg = getStatusbarMessage();
FString curMsg = statusBar()->getMessage(); FString curMsg = statusBar()->getMessage();
if ( curMsg != msg ) if ( curMsg != msg )
{ {
statusBar()->setMessage(msg); statusBar()->setMessage(msg);
@ -134,10 +137,12 @@ void FLineEdit::drawInputField()
setUpdateVTerm(false); setUpdateVTerm(false);
gotoxy (xpos+xmin-1, ypos+ymin-1); gotoxy (xpos+xmin-1, ypos+ymin-1);
if ( isMonochron() ) if ( isMonochron() )
{ {
setReverse(true); setReverse(true);
print (' '); print (' ');
if ( isActiveFocus ) if ( isActiveFocus )
setReverse(false); setReverse(false);
else else
@ -146,6 +151,7 @@ void FLineEdit::drawInputField()
else if ( isActiveFocus ) else if ( isActiveFocus )
{ {
setColor (wc.inputfield_active_focus_bg, wc.dialog_bg); setColor (wc.inputfield_active_focus_bg, wc.dialog_bg);
if ( isCygwinTerminal() ) // IBM Codepage 850 if ( isCygwinTerminal() ) // IBM Codepage 850
print (fc::FullBlock); // █ print (fc::FullBlock); // █
else if ( isTeraTerm() ) else if ( isTeraTerm() )
@ -156,6 +162,7 @@ void FLineEdit::drawInputField()
else if ( isActive ) else if ( isActive )
{ {
setColor (wc.inputfield_active_bg, wc.dialog_bg); setColor (wc.inputfield_active_bg, wc.dialog_bg);
if ( isCygwinTerminal() ) // IBM Codepage 850 if ( isCygwinTerminal() ) // IBM Codepage 850
print (fc::FullBlock); // █ print (fc::FullBlock); // █
else if ( isTeraTerm() ) else if ( isTeraTerm() )
@ -166,6 +173,7 @@ void FLineEdit::drawInputField()
else // isInactive else // isInactive
{ {
setColor (wc.inputfield_inactive_bg, wc.dialog_bg); setColor (wc.inputfield_inactive_bg, wc.dialog_bg);
if ( isCygwinTerminal() ) // IBM Codepage 850 if ( isCygwinTerminal() ) // IBM Codepage 850
print (fc::FullBlock); // █ print (fc::FullBlock); // █
else if ( isTeraTerm() ) else if ( isTeraTerm() )
@ -183,14 +191,17 @@ void FLineEdit::drawInputField()
if ( isUTF8_linux_terminal() ) if ( isUTF8_linux_terminal() )
{ {
setUTF8(true); setUTF8(true);
if ( show_text ) if ( show_text )
print (show_text); print (show_text);
setUTF8(false); setUTF8(false);
} }
else if ( show_text ) else if ( show_text )
print (show_text); print (show_text);
x = int(show_text.getLength()); x = int(show_text.getLength());
while ( x < width-1 ) while ( x < width-1 )
{ {
print (' '); print (' ');
@ -228,6 +239,7 @@ void FLineEdit::processActivate()
setFocus(); setFocus();
redraw(); redraw();
} }
emitCallback("activate"); emitCallback("activate");
} }
@ -279,7 +291,6 @@ void FLineEdit::hide()
char* blank; char* blank;
FWidget::hide(); FWidget::hide();
fg = getParentWidget()->getForegroundColor(); fg = getParentWidget()->getForegroundColor();
bg = getParentWidget()->getBackgroundColor(); bg = getParentWidget()->getBackgroundColor();
setColor (fg, bg); setColor (fg, bg);
@ -294,8 +305,8 @@ void FLineEdit::hide()
gotoxy (xpos+xmin-1, ypos+ymin-1+y); gotoxy (xpos+xmin-1, ypos+ymin-1+y);
print (blank); print (blank);
} }
delete[] blank;
delete[] blank;
lable_Length = int(label_text.getLength()); lable_Length = int(label_text.getLength());
if ( lable_Length > 0 ) if ( lable_Length > 0 )
@ -313,6 +324,7 @@ void FLineEdit::hide()
gotoxy (xpos+xmin-int(lable_Length)-1, ypos+ymin-1); gotoxy (xpos+xmin-int(lable_Length)-1, ypos+ymin-1);
break; break;
} }
blank = new char[lable_Length+1]; blank = new char[lable_Length+1];
memset(blank, ' ', uLong(size)); memset(blank, ' ', uLong(size));
blank[lable_Length] = '\0'; blank[lable_Length] = '\0';
@ -329,6 +341,7 @@ bool FLineEdit::setEnable (bool on)
if ( on ) if ( on )
{ {
flags |= fc::active; flags |= fc::active;
if ( hasFocus() ) if ( hasFocus() )
{ {
foregroundColor = wc.inputfield_active_focus_fg; foregroundColor = wc.inputfield_active_focus_fg;
@ -346,6 +359,7 @@ bool FLineEdit::setEnable (bool on)
foregroundColor = wc.inputfield_inactive_fg; foregroundColor = wc.inputfield_inactive_fg;
backgroundColor = wc.inputfield_inactive_bg; backgroundColor = wc.inputfield_inactive_bg;
} }
return on; return on;
} }
@ -367,6 +381,7 @@ bool FLineEdit::setFocus (bool on)
{ {
FString msg = getStatusbarMessage(); FString msg = getStatusbarMessage();
FString curMsg = statusBar()->getMessage(); FString curMsg = statusBar()->getMessage();
if ( curMsg != msg ) if ( curMsg != msg )
statusBar()->setMessage(msg); statusBar()->setMessage(msg);
} }
@ -380,10 +395,12 @@ bool FLineEdit::setFocus (bool on)
{ {
foregroundColor = wc.inputfield_active_fg; foregroundColor = wc.inputfield_active_fg;
backgroundColor = wc.inputfield_active_bg; backgroundColor = wc.inputfield_active_bg;
if ( statusBar() ) if ( statusBar() )
statusBar()->clearMessage(); statusBar()->clearMessage();
} }
} }
return on; return on;
} }
@ -396,6 +413,7 @@ bool FLineEdit::setShadow (bool on)
flags |= fc::shadow; flags |= fc::shadow;
else else
flags &= ~fc::shadow; flags &= ~fc::shadow;
return on; return on;
} }
@ -409,19 +427,25 @@ void FLineEdit::onKeyPress (FKeyEvent* ev)
{ {
case fc::Fkey_left: case fc::Fkey_left:
cursor_pos--; cursor_pos--;
if ( cursor_pos < 0 ) if ( cursor_pos < 0 )
cursor_pos=0; cursor_pos=0;
if ( cursor_pos < offset ) if ( cursor_pos < offset )
offset--; offset--;
ev->accept(); ev->accept();
break; break;
case fc::Fkey_right: case fc::Fkey_right:
cursor_pos++; cursor_pos++;
if ( cursor_pos >= len ) if ( cursor_pos >= len )
cursor_pos=len; cursor_pos=len;
if ( cursor_pos-offset >= width-2 && offset <= len-width+1 ) if ( cursor_pos-offset >= width-2 && offset <= len-width+1 )
offset++; offset++;
ev->accept(); ev->accept();
break; break;
@ -444,12 +468,16 @@ void FLineEdit::onKeyPress (FKeyEvent* ev)
text.remove(uInt(cursor_pos), 1); text.remove(uInt(cursor_pos), 1);
processChanged(); processChanged();
} }
if ( cursor_pos >= len ) if ( cursor_pos >= len )
cursor_pos=len; cursor_pos=len;
if ( cursor_pos < 0 ) if ( cursor_pos < 0 )
cursor_pos=0; cursor_pos=0;
if ( offset > 0 && len-offset < width-1 ) if ( offset > 0 && len-offset < width-1 )
offset--; offset--;
ev->accept(); ev->accept();
break; break;
@ -460,19 +488,23 @@ void FLineEdit::onKeyPress (FKeyEvent* ev)
text.remove(uInt(cursor_pos-1), 1); text.remove(uInt(cursor_pos-1), 1);
processChanged(); processChanged();
cursor_pos--; cursor_pos--;
if ( offset > 0 ) if ( offset > 0 )
offset--; offset--;
} }
ev->accept(); ev->accept();
break; break;
case fc::Fkey_ic: // insert key case fc::Fkey_ic: // insert key
insert_mode = not insert_mode; insert_mode = not insert_mode;
if ( insert_mode ) if ( insert_mode )
{ {
setXTermCursorStyle(fc::blinking_underline); setXTermCursorStyle(fc::blinking_underline);
setKDECursor(fc::UnderlineCursor); setKDECursor(fc::UnderlineCursor);
setConsoleCursor(fc::underscore_cursor); setConsoleCursor(fc::underscore_cursor);
if ( isUrxvtTerminal() ) if ( isUrxvtTerminal() )
setXTermCursorColor("rgb:ffff/ffff/ffff"); setXTermCursorColor("rgb:ffff/ffff/ffff");
} }
@ -481,9 +513,11 @@ void FLineEdit::onKeyPress (FKeyEvent* ev)
setXTermCursorStyle(fc::steady_block); setXTermCursorStyle(fc::steady_block);
setKDECursor(fc::BlockCursor); setKDECursor(fc::BlockCursor);
setConsoleCursor(fc::full_block_cursor); setConsoleCursor(fc::full_block_cursor);
if ( isUrxvtTerminal() ) if ( isUrxvtTerminal() )
setXTermCursorColor("rgb:eeee/0000/0000"); setXTermCursorColor("rgb:eeee/0000/0000");
} }
ev->accept(); ev->accept();
break; break;
@ -511,6 +545,7 @@ void FLineEdit::onKeyPress (FKeyEvent* ev)
text.insert(wchar_t(key), uInt(cursor_pos)); text.insert(wchar_t(key), uInt(cursor_pos));
else else
text.overwrite(wchar_t(key), uInt(cursor_pos)); text.overwrite(wchar_t(key), uInt(cursor_pos));
processChanged(); processChanged();
} }
else else
@ -519,8 +554,10 @@ void FLineEdit::onKeyPress (FKeyEvent* ev)
processChanged(); processChanged();
} }
cursor_pos++; cursor_pos++;
if ( cursor_pos >= width-1 ) if ( cursor_pos >= width-1 )
offset++; offset++;
ev->accept(); ev->accept();
} }
else else
@ -551,9 +588,12 @@ void FLineEdit::onMouseDown (FMouseEvent* ev)
FFocusEvent out (fc::FocusOut_Event); FFocusEvent out (fc::FocusOut_Event);
FApplication::queueEvent(focused_widget, &out); FApplication::queueEvent(focused_widget, &out);
setFocus(); setFocus();
if ( focused_widget ) if ( focused_widget )
focused_widget->redraw(); focused_widget->redraw();
redraw(); redraw();
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
} }
@ -565,8 +605,10 @@ void FLineEdit::onMouseDown (FMouseEvent* ev)
{ {
int len = int(text.getLength()); int len = int(text.getLength());
cursor_pos = offset + mouse_x - 2; cursor_pos = offset + mouse_x - 2;
if ( cursor_pos >= len ) if ( cursor_pos >= len )
cursor_pos = len; cursor_pos = len;
drawInputField(); drawInputField();
updateTerminal(); updateTerminal();
} }
@ -597,10 +639,11 @@ void FLineEdit::onMouseMove (FMouseEvent* ev)
if ( mouse_x >= 2 && mouse_x <= width && mouse_y == 1 ) if ( mouse_x >= 2 && mouse_x <= width && mouse_y == 1 )
{ {
cursor_pos = offset + mouse_x - 2; cursor_pos = offset + mouse_x - 2;
if ( cursor_pos >= len ) if ( cursor_pos >= len )
cursor_pos=len; cursor_pos=len;
drawInputField(); drawInputField();
updateTerminal(); updateTerminal();
} }
@ -615,6 +658,7 @@ void FLineEdit::onMouseMove (FMouseEvent* ev)
addTimer(scrollRepeat); addTimer(scrollRepeat);
dragScroll = FLineEdit::scrollLeft; dragScroll = FLineEdit::scrollLeft;
} }
if ( offset == 0 ) if ( offset == 0 )
{ {
delOwnTimer(); delOwnTimer();
@ -630,6 +674,7 @@ void FLineEdit::onMouseMove (FMouseEvent* ev)
addTimer(scrollRepeat); addTimer(scrollRepeat);
dragScroll = FLineEdit::scrollRight; dragScroll = FLineEdit::scrollRight;
} }
if ( offset == len-width+2 ) if ( offset == len-width+2 )
{ {
delOwnTimer(); delOwnTimer();
@ -656,18 +701,22 @@ void FLineEdit::onTimer (FTimerEvent*)
return; return;
case FLineEdit::scrollLeft: case FLineEdit::scrollLeft:
if ( offset == 0) if ( offset == 0)
{ {
dragScroll = FLineEdit::noScroll; dragScroll = FLineEdit::noScroll;
return; return;
} }
offset--; offset--;
if ( offset < 0 ) if ( offset < 0 )
offset = 0; offset = 0;
cursor_pos--; cursor_pos--;
if ( cursor_pos < 0 ) if ( cursor_pos < 0 )
cursor_pos = 0; cursor_pos = 0;
break; break;
case FLineEdit::scrollRight: case FLineEdit::scrollRight:
@ -676,10 +725,14 @@ void FLineEdit::onTimer (FTimerEvent*)
dragScroll = FLineEdit::noScroll; dragScroll = FLineEdit::noScroll;
return; return;
} }
offset++; offset++;
if ( offset > len-width+2 ) if ( offset > len-width+2 )
offset = len-width+2; offset = len-width+2;
cursor_pos++; cursor_pos++;
if ( cursor_pos > len ) if ( cursor_pos > len )
cursor_pos = len; cursor_pos = len;
@ -702,9 +755,12 @@ void FLineEdit::onAccel (FAccelEvent* ev)
FFocusEvent out (fc::FocusOut_Event); FFocusEvent out (fc::FocusOut_Event);
FApplication::queueEvent(focused_widget, &out); FApplication::queueEvent(focused_widget, &out);
setFocus(); setFocus();
if ( focused_widget ) if ( focused_widget )
focused_widget->redraw(); focused_widget->redraw();
redraw(); redraw();
if ( statusBar() ) if ( statusBar() )
{ {
statusBar()->drawMessage(); statusBar()->drawMessage();
@ -712,6 +768,7 @@ void FLineEdit::onAccel (FAccelEvent* ev)
flush_out(); flush_out();
} }
} }
ev->accept(); ev->accept();
} }
} }
@ -727,6 +784,7 @@ void FLineEdit::onHide (FHideEvent*)
if ( isUrxvtTerminal() ) if ( isUrxvtTerminal() )
setXTermCursorColor("rgb:ffff/ffff/ffff"); setXTermCursorColor("rgb:ffff/ffff/ffff");
} }
if ( hasFocus() ) if ( hasFocus() )
hideCursor(); hideCursor();
} }
@ -753,6 +811,7 @@ void FLineEdit::onFocusIn (FFocusEvent*)
if ( isUrxvtTerminal() ) if ( isUrxvtTerminal() )
setXTermCursorColor("rgb:0000/0000/0000"); setXTermCursorColor("rgb:0000/0000/0000");
} }
if ( statusBar() ) if ( statusBar() )
{ {
statusBar()->drawMessage(); statusBar()->drawMessage();
@ -775,6 +834,7 @@ void FLineEdit::onFocusOut (FFocusEvent*)
setXTermCursorStyle(fc::blinking_underline); setXTermCursorStyle(fc::blinking_underline);
setKDECursor(fc::UnderlineCursor); setKDECursor(fc::UnderlineCursor);
setConsoleCursor(fc::underscore_cursor); setConsoleCursor(fc::underscore_cursor);
if ( isUrxvtTerminal() ) if ( isUrxvtTerminal() )
setXTermCursorColor("rgb:ffff/ffff/ffff"); setXTermCursorColor("rgb:ffff/ffff/ffff");
} }
@ -795,6 +855,7 @@ void FLineEdit::setText (FString txt)
{ {
offset = 0; offset = 0;
cursor_pos = 0; cursor_pos = 0;
if ( txt ) if ( txt )
text = txt; text = txt;
else else

File diff suppressed because it is too large Load Diff

View File

@ -79,8 +79,10 @@ FMenu::~FMenu()
{ {
if ( vwin->changes != 0 ) if ( vwin->changes != 0 )
delete[] vwin->changes; delete[] vwin->changes;
if ( vwin->text != 0 ) if ( vwin->text != 0 )
delete[] vwin->text; delete[] vwin->text;
delete vwin; delete vwin;
} }
} }
@ -124,17 +126,21 @@ void FMenu::init(FWidget* parent)
if ( isMenuBar(parent) ) if ( isMenuBar(parent) )
{ {
FMenuBar* mbar = dynamic_cast<FMenuBar*>(parent); FMenuBar* mbar = dynamic_cast<FMenuBar*>(parent);
if ( mbar ) if ( mbar )
mbar->menu_dimension(); mbar->menu_dimension();
} }
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->menu_dimension();
} }
setSuperMenu(parent); setSuperMenu(parent);
} }
menu_dimension(); menu_dimension();
} }
@ -194,8 +200,8 @@ void FMenu::menu_dimension()
// set sub-menu position // set sub-menu position
(*iter)->getMenu()->setPos (menu_X, menu_Y, false); (*iter)->getMenu()->setPos (menu_X, menu_Y, false);
} }
item_Y++;
item_Y++;
++iter; ++iter;
} }
} }
@ -225,6 +231,7 @@ void FMenu::adjustItems()
if ( menu->count() > 0 ) if ( menu->count() > 0 )
menu->adjustItems(); menu->adjustItems();
} }
++iter; ++iter;
} }
} }
@ -240,19 +247,10 @@ int FMenu::adjustX (int x_pos)
if ( x_pos < 1 ) if ( x_pos < 1 )
x_pos = 1; x_pos = 1;
} }
return x_pos; return x_pos;
} }
//----------------------------------------------------------------------
void FMenu::adjustSize()
{
//int adjust_X = adjustX(xpos);
FWidget::adjustSize();
//move (adjust_X, ypos);
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMenu::isWindowsMenu (FWidget* w) const bool FMenu::isWindowsMenu (FWidget* w) const
{ {
@ -284,6 +282,7 @@ bool FMenu::isRadioMenuItem (FWidget* w) const
bool FMenu::isSubMenu() const bool FMenu::isSubMenu() const
{ {
FWidget* super = getSuperMenu(); FWidget* super = getSuperMenu();
if ( super && isMenu(super) ) if ( super && isMenu(super) )
return true; return true;
else else
@ -298,15 +297,19 @@ void FMenu::openSubMenu (FMenu* sub_menu)
// open sub menu // open sub menu
sub_menu->selectFirstItem(); sub_menu->selectFirstItem();
if ( sub_menu->hasSelectedItem() ) if ( sub_menu->hasSelectedItem() )
sub_menu->getSelectedItem()->setFocus(); sub_menu->getSelectedItem()->setFocus();
sub_menu->setVisible(); sub_menu->setVisible();
sub_menu->show(); sub_menu->show();
open_sub_menu = sub_menu; open_sub_menu = sub_menu;
raiseWindow (sub_menu); raiseWindow (sub_menu);
sub_menu->redraw(); sub_menu->redraw();
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
updateTerminal(); updateTerminal();
flush_out(); flush_out();
} }
@ -321,6 +324,7 @@ void FMenu::hideSubMenus()
open_sub_menu->hide(); open_sub_menu->hide();
open_sub_menu = 0; open_sub_menu = 0;
} }
unselectItem(); unselectItem();
} }
@ -329,6 +333,7 @@ void FMenu::hideSuperMenus()
{ {
// hide all menus to the top // hide all menus to the top
FWidget* super = getSuperMenu(); FWidget* super = getSuperMenu();
if ( super ) if ( super )
{ {
if ( isMenuBar(super) ) if ( isMenuBar(super) )
@ -374,7 +379,9 @@ FMenu* FMenu::superMenuAt (int x, int y) const
// Check mouse click position for super menu // Check mouse click position for super menu
if ( getGeometryGlobal().contains(x,y) ) if ( getGeometryGlobal().contains(x,y) )
return 0; return 0;
FWidget* super = getSuperMenu(); FWidget* super = getSuperMenu();
if ( super && isMenu(super) ) if ( super && isMenu(super) )
{ {
if ( super->getGeometryGlobal().contains(x,y) ) if ( super->getGeometryGlobal().contains(x,y) )
@ -385,6 +392,7 @@ FMenu* FMenu::superMenuAt (int x, int y) const
return smenu->superMenuAt(x,y); return smenu->superMenuAt(x,y);
} }
} }
return 0; return 0;
} }
@ -401,33 +409,40 @@ bool FMenu::selectNextItem()
{ {
FMenuItem* next; FMenuItem* next;
std::vector<FMenuItem*>::const_iterator next_element; std::vector<FMenuItem*>::const_iterator next_element;
next_element = iter; next_element = iter;
do do
{ {
++next_element; ++next_element;
if ( next_element == itemlist.end() ) if ( next_element == itemlist.end() )
next_element = itemlist.begin(); next_element = itemlist.begin();
next = static_cast<FMenuItem*>(*next_element); next = static_cast<FMenuItem*>(*next_element);
} while ( ! next->isEnabled() }
|| ! next->acceptFocus() while ( ! next->isEnabled()
|| ! next->isVisible() || ! next->acceptFocus()
|| next->isSeparator() ); || ! next->isVisible()
|| next->isSeparator() );
if ( next == *iter ) if ( next == *iter )
return false; return false;
unselectItem(); unselectItem();
next->setSelected(); next->setSelected();
setSelectedItem(next); setSelectedItem(next);
redraw(); redraw();
next->setFocus(); next->setFocus();
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
updateTerminal(); updateTerminal();
flush_out(); flush_out();
break; break;
} }
++iter; ++iter;
} }
return true; return true;
} }
@ -441,36 +456,43 @@ bool FMenu::selectPrevItem()
do do
{ {
--iter; --iter;
if ( (*iter)->isSelected() ) if ( (*iter)->isSelected() )
{ {
FMenuItem* prev; FMenuItem* prev;
std::vector<FMenuItem*>::const_iterator prev_element; std::vector<FMenuItem*>::const_iterator prev_element;
prev_element = iter; prev_element = iter;
do do
{ {
if ( prev_element == itemlist.begin() ) if ( prev_element == itemlist.begin() )
prev_element = itemlist.end(); prev_element = itemlist.end();
--prev_element; --prev_element;
prev = static_cast<FMenuItem*>(*prev_element); prev = static_cast<FMenuItem*>(*prev_element);
} while ( ! prev->isEnabled() }
|| ! prev->acceptFocus() while ( ! prev->isEnabled()
|| ! prev->isVisible() || ! prev->acceptFocus()
|| prev->isSeparator() ); || ! prev->isVisible()
|| prev->isSeparator() );
if ( prev == *iter ) if ( prev == *iter )
return false; return false;
unselectItem(); unselectItem();
prev->setSelected(); prev->setSelected();
setSelectedItem(prev); setSelectedItem(prev);
prev->setFocus(); prev->setFocus();
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
redraw(); redraw();
updateTerminal(); updateTerminal();
flush_out(); flush_out();
break; break;
} }
} while ( iter != begin ); }
while ( iter != begin );
return true; return true;
} }
@ -530,11 +552,14 @@ bool FMenu::hotkeyMenu (FKeyEvent*& ev)
ev->accept(); ev->accept();
(*iter)->processClicked(); (*iter)->processClicked();
} }
return true; return true;
} }
} }
++iter; ++iter;
} }
return false; return false;
} }
@ -554,8 +579,10 @@ int FMenu::getHotkeyPos (wchar_t*& src, wchar_t*& dest, uInt length)
i++; i++;
src++; src++;
} }
*dest++ = *src++; *dest++ = *src++;
} }
return hotkeypos; return hotkeypos;
} }
@ -565,15 +592,20 @@ void FMenu::draw()
// fill the background // fill the background
setColor (wc.menu_active_fg, wc.menu_active_bg); setColor (wc.menu_active_fg, wc.menu_active_bg);
setUpdateVTerm(false); setUpdateVTerm(false);
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
clrscr(); clrscr();
drawBorder(); drawBorder();
drawItems(); drawItems();
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
if ( (flags & fc::shadow) != 0 ) if ( (flags & fc::shadow) != 0 )
drawMenuShadow(); drawMenuShadow();
setUpdateVTerm(true); setUpdateVTerm(true);
} }
@ -590,8 +622,10 @@ void FMenu::drawBorder()
{ {
gotoxy (x1, y1); gotoxy (x1, y1);
print (fc::NF_border_corner_upper_left); // ⎡ print (fc::NF_border_corner_upper_left); // ⎡
for (int x=x1+1; x < x2; x++) for (int x=x1+1; x < x2; x++)
print (fc::NF_border_line_upper); // ¯ print (fc::NF_border_line_upper); // ¯
print (fc::NF_rev_border_corner_upper_right); // ⎤ print (fc::NF_rev_border_corner_upper_right); // ⎤
for (int y=y1+1; y <= y2; y++) for (int y=y1+1; y <= y2; y++)
@ -603,11 +637,14 @@ void FMenu::drawBorder()
// border right⎹ // border right⎹
print (fc::NF_rev_border_line_right); print (fc::NF_rev_border_line_right);
} }
gotoxy (x1, y2); gotoxy (x1, y2);
// lower left corner border ⎣ // lower left corner border ⎣
print (fc::NF_border_corner_lower_left); print (fc::NF_border_corner_lower_left);
for (int x=1; x < width-1; x++) // low line _ for (int x=1; x < width-1; x++) // low line _
print (fc::NF_border_line_bottom); print (fc::NF_border_line_bottom);
gotoxy (x2, y2); gotoxy (x2, y2);
// lower right corner border ⎦ // lower right corner border ⎦
print (fc::NF_rev_border_corner_lower_right); print (fc::NF_rev_border_corner_lower_right);
@ -616,14 +653,17 @@ void FMenu::drawBorder()
{ {
gotoxy (x1, y1); gotoxy (x1, y1);
print (fc::BoxDrawingsDownAndRight); // ┌ print (fc::BoxDrawingsDownAndRight); // ┌
for (int x=x1+1; x < x2; x++) for (int x=x1+1; x < x2; x++)
print (fc::BoxDrawingsHorizontal); // ─ print (fc::BoxDrawingsHorizontal); // ─
print (fc::BoxDrawingsDownAndLeft); // ┐
print (fc::BoxDrawingsDownAndLeft); // ┐
gotoxy (x1, y2); gotoxy (x1, y2);
print (fc::BoxDrawingsUpAndRight); // └ print (fc::BoxDrawingsUpAndRight); // └
for (int x=x1+1; x < x2; x++) for (int x=x1+1; x < x2; x++)
print (fc::BoxDrawingsHorizontal); // ─ print (fc::BoxDrawingsHorizontal); // ─
print (fc::BoxDrawingsUpAndLeft); // ┘ print (fc::BoxDrawingsUpAndLeft); // ┘
for (int y=y1+1; y < y2; y++) for (int y=y1+1; y < y2; y++)
@ -684,6 +724,7 @@ void FMenu::drawItems()
{ {
foregroundColor = wc.menu_active_focus_fg; foregroundColor = wc.menu_active_focus_fg;
backgroundColor = wc.menu_active_focus_bg; backgroundColor = wc.menu_active_focus_bg;
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
} }
@ -691,6 +732,7 @@ void FMenu::drawItems()
{ {
foregroundColor = wc.menu_active_fg; foregroundColor = wc.menu_active_fg;
backgroundColor = wc.menu_active_bg; backgroundColor = wc.menu_active_bg;
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
} }
@ -699,11 +741,14 @@ void FMenu::drawItems()
{ {
foregroundColor = wc.menu_inactive_fg; foregroundColor = wc.menu_inactive_fg;
backgroundColor = wc.menu_inactive_bg; backgroundColor = wc.menu_inactive_bg;
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
} }
gotoxy (xpos+xmin, ypos+ymin+y); gotoxy (xpos+xmin, ypos+ymin+y);
setColor (foregroundColor, backgroundColor); setColor (foregroundColor, backgroundColor);
if ( has_checkable_items ) if ( has_checkable_items )
{ {
if ( is_checkable ) if ( is_checkable )
@ -730,18 +775,20 @@ void FMenu::drawItems()
else else
{ {
setColor (wc.menu_inactive_fg, backgroundColor); setColor (wc.menu_inactive_fg, backgroundColor);
if ( getEncoding() == "ASCII" ) if ( getEncoding() == "ASCII" )
print ('-'); print ('-');
else else
print (fc::SmallBullet); print (fc::SmallBullet);
setColor (foregroundColor, backgroundColor); setColor (foregroundColor, backgroundColor);
} }
} }
else else
print (' '); print (' ');
} }
print (' ');
print (' ');
txt = (*iter)->getText(); txt = (*iter)->getText();
txt_length = uInt(txt.getLength()); txt_length = uInt(txt.getLength());
item_text = new wchar_t[txt_length+1](); item_text = new wchar_t[txt_length+1]();
@ -761,6 +808,7 @@ void FMenu::drawItems()
if ( is_selected ) if ( is_selected )
setCursorPos ( xpos+xmin+1+hotkeypos setCursorPos ( xpos+xmin+1+hotkeypos
, ypos+ymin+y ); // hotkey , ypos+ymin+y ); // hotkey
txt_length--; txt_length--;
to_char--; to_char--;
} }
@ -777,22 +825,29 @@ void FMenu::drawItems()
item_text[z] = L' '; item_text[z] = L' ';
} }
} }
if ( (z == hotkeypos) && is_enabled && ! is_selected ) if ( (z == hotkeypos) && is_enabled && ! is_selected )
{ {
setColor (wc.menu_hotkey_fg, wc.menu_hotkey_bg); setColor (wc.menu_hotkey_fg, wc.menu_hotkey_bg);
if ( ! is_noUnderline ) if ( ! is_noUnderline )
setUnderline(); setUnderline();
print (item_text[z]); print (item_text[z]);
if ( ! is_noUnderline ) if ( ! is_noUnderline )
unsetUnderline(); unsetUnderline();
setColor (foregroundColor, backgroundColor); setColor (foregroundColor, backgroundColor);
} }
else else
print (item_text[z]); print (item_text[z]);
} }
if ( has_menu ) if ( has_menu )
{ {
int len = int(maxItemWidth) - (to_char + c + 3); int len = int(maxItemWidth) - (to_char + c + 3);
if ( len > 0 ) if ( len > 0 )
{ {
print (FString(len, wchar_t(' '))); print (FString(len, wchar_t(' ')));
@ -806,6 +861,7 @@ void FMenu::drawItems()
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(maxItemWidth) - (to_char + accel_len + c + 2);
if ( len > 0 ) if ( len > 0 )
{ {
FString spaces (len, wchar_t(' ')); FString spaces (len, wchar_t(' '));
@ -822,11 +878,14 @@ void FMenu::drawItems()
if ( isMonochron() && is_enabled && is_selected ) if ( isMonochron() && is_enabled && is_selected )
setReverse(true); setReverse(true);
delete[] item_text; delete[] item_text;
} }
++iter; ++iter;
y++; y++;
} }
if ( hasFocus() ) if ( hasFocus() )
setCursor(); setCursor();
} }
@ -836,8 +895,10 @@ inline void FMenu::drawSeparator(int y)
{ {
gotoxy (xpos+xmin-1, ypos+ymin+y); gotoxy (xpos+xmin-1, ypos+ymin+y);
setColor (wc.menu_active_fg, wc.menu_active_bg); setColor (wc.menu_active_fg, wc.menu_active_bg);
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
if ( isNewFont() ) if ( isNewFont() )
{ {
print (fc::NF_border_line_vertical_right); print (fc::NF_border_line_vertical_right);
@ -852,6 +913,7 @@ inline void FMenu::drawSeparator(int y)
print (line); print (line);
print (fc::BoxDrawingsVerticalAndLeft); print (fc::BoxDrawingsVerticalAndLeft);
} }
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
} }
@ -867,15 +929,19 @@ void FMenu::processActivate()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenu::onKeyPress (FKeyEvent* ev) void FMenu::onKeyPress (FKeyEvent* ev)
{ {
FWidget* menubar;
// looking for menu hotkey // looking for menu hotkey
if ( hotkeyMenu(ev) ) if ( hotkeyMenu(ev) )
return; return;
// looking for menu bar hotkey // looking for menu bar hotkey
FWidget* menubar = menuBar(); menubar = menuBar();
if ( menubar ) if ( menubar )
{ {
FMenuBar* mbar = reinterpret_cast<FMenuBar*>(menubar); FMenuBar* mbar = reinterpret_cast<FMenuBar*>(menubar);
if ( mbar->hotkeyMenu(ev) ) if ( mbar->hotkeyMenu(ev) )
return; return;
} }
@ -916,8 +982,10 @@ void FMenu::onKeyPress (FKeyEvent* ev)
hide(); hide();
smenu->getSelectedItem()->setFocus(); smenu->getSelectedItem()->setFocus();
smenu->redraw(); smenu->redraw();
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
updateTerminal(); updateTerminal();
flush_out(); flush_out();
} }
@ -929,6 +997,7 @@ void FMenu::onKeyPress (FKeyEvent* ev)
if ( hasSelectedItem() && getSelectedItem()->hasMenu() ) if ( hasSelectedItem() && getSelectedItem()->hasMenu() )
{ {
FMenu* sub_menu = getSelectedItem()->getMenu(); FMenu* sub_menu = getSelectedItem()->getMenu();
if ( ! sub_menu->isVisible() ) if ( ! sub_menu->isVisible() )
openSubMenu (sub_menu); openSubMenu (sub_menu);
else else
@ -943,6 +1012,7 @@ void FMenu::onKeyPress (FKeyEvent* ev)
unselectItem(); unselectItem();
hideSubMenus(); hideSubMenus();
hide(); hide();
if ( isSubMenu() ) if ( isSubMenu() )
{ {
FMenu* smenu = reinterpret_cast<FMenu*>(getSuperMenu()); FMenu* smenu = reinterpret_cast<FMenu*>(getSuperMenu());
@ -952,15 +1022,19 @@ void FMenu::onKeyPress (FKeyEvent* ev)
else else
{ {
hideSuperMenus(); hideSuperMenus();
if ( statusBar() ) if ( statusBar() )
statusBar()->clearMessage(); statusBar()->clearMessage();
activatePrevWindow(); activatePrevWindow();
raiseWindow (getActiveWindow()); raiseWindow (getActiveWindow());
getActiveWindow()->getFocusWidget()->setFocus(); getActiveWindow()->getFocusWidget()->setFocus();
getActiveWindow()->redraw(); getActiveWindow()->redraw();
} }
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
updateTerminal(); updateTerminal();
flush_out(); flush_out();
break; break;
@ -986,11 +1060,14 @@ void FMenu::onMouseDown (FMouseEvent* ev)
open_sub_menu = 0; open_sub_menu = 0;
getSelectedItem()->setFocus(); getSelectedItem()->setFocus();
redraw(); redraw();
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
updateTerminal(); updateTerminal();
flush_out(); flush_out();
} }
return; return;
} }
@ -1017,7 +1094,6 @@ void FMenu::onMouseDown (FMouseEvent* ev)
while ( iter != end ) while ( iter != end )
{ {
int x1, x2, y, mouse_x, mouse_y; int x1, x2, y, mouse_x, mouse_y;
x1 = (*iter)->getX(); x1 = (*iter)->getX();
x2 = (*iter)->getX() + (*iter)->getWidth(); x2 = (*iter)->getX() + (*iter)->getWidth();
y = (*iter)->getY(); y = (*iter)->getY();
@ -1051,6 +1127,7 @@ void FMenu::onMouseDown (FMouseEvent* ev)
} }
} }
} }
if ( ! (*iter)->isSelected() ) if ( ! (*iter)->isSelected() )
{ {
unselectItem(); unselectItem();
@ -1060,19 +1137,24 @@ void FMenu::onMouseDown (FMouseEvent* ev)
(*iter)->setSelected(); (*iter)->setSelected();
setSelectedItem(*iter); setSelectedItem(*iter);
(*iter)->setFocus(); (*iter)->setFocus();
if ( focused_widget ) if ( focused_widget )
focused_widget->redraw(); focused_widget->redraw();
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
if ( (*iter)->hasMenu() ) if ( (*iter)->hasMenu() )
{ {
FMenu* sub_menu = (*iter)->getMenu(); FMenu* sub_menu = (*iter)->getMenu();
if ( ! sub_menu->isVisible() ) if ( ! sub_menu->isVisible() )
show_sub_menu = sub_menu; show_sub_menu = sub_menu;
} }
focus_changed = true; focus_changed = true;
} }
} }
++iter; ++iter;
} }
@ -1102,11 +1184,11 @@ void FMenu::onMouseUp (FMouseEvent* ev)
if ( mouse_down ) if ( mouse_down )
{ {
mouse_down = false; mouse_down = false;
if ( ! itemlist.empty() ) if ( ! itemlist.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 = itemlist.begin();
end = itemlist.end(); end = itemlist.end();
mouse_pos = ev->getPos(); mouse_pos = ev->getPos();
@ -1115,7 +1197,6 @@ void FMenu::onMouseUp (FMouseEvent* ev)
while ( iter != end ) while ( iter != end )
{ {
int x1, x2, y; int x1, x2, y;
x1 = (*iter)->getX(); x1 = (*iter)->getX();
x2 = (*iter)->getX() + (*iter)->getWidth(); x2 = (*iter)->getX() + (*iter)->getWidth();
y = (*iter)->getY(); y = (*iter)->getY();
@ -1138,14 +1219,19 @@ void FMenu::onMouseUp (FMouseEvent* ev)
else if ( open_sub_menu ) else if ( open_sub_menu )
{ {
open_sub_menu->selectFirstItem(); open_sub_menu->selectFirstItem();
if ( open_sub_menu->hasSelectedItem() ) if ( open_sub_menu->hasSelectedItem() )
open_sub_menu->getSelectedItem()->setFocus(); open_sub_menu->getSelectedItem()->setFocus();
open_sub_menu->redraw(); open_sub_menu->redraw();
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
updateTerminal(); updateTerminal();
flush_out(); flush_out();
} }
return; return;
} }
else else
@ -1157,8 +1243,10 @@ void FMenu::onMouseUp (FMouseEvent* ev)
} }
} }
} }
++iter; ++iter;
} }
// Click on a non-FMenuItem (border or separator line) // Click on a non-FMenuItem (border or separator line)
unselectItem(); unselectItem();
hide(); hide();
@ -1207,6 +1295,7 @@ void FMenu::onMouseMove (FMouseEvent* ev)
if ( isSubMenu() ) if ( isSubMenu() )
{ {
smenu = superMenuAt (ev->getGlobalPos()); smenu = superMenuAt (ev->getGlobalPos());
if ( smenu ) if ( smenu )
mouse_over_supermenu = true; mouse_over_supermenu = true;
} }
@ -1221,7 +1310,6 @@ void FMenu::onMouseMove (FMouseEvent* ev)
while ( iter != end ) while ( iter != end )
{ {
int x1, x2, y, mouse_x, mouse_y; int x1, x2, y, mouse_x, mouse_y;
x1 = (*iter)->getX(); x1 = (*iter)->getX();
x2 = (*iter)->getX() + (*iter)->getWidth(); x2 = (*iter)->getX() + (*iter)->getWidth();
y = (*iter)->getY(); y = (*iter)->getY();
@ -1243,19 +1331,24 @@ void FMenu::onMouseMove (FMouseEvent* ev)
(*iter)->setSelected(); (*iter)->setSelected();
setSelectedItem(*iter); setSelectedItem(*iter);
(*iter)->setFocus(); (*iter)->setFocus();
if ( focused_widget ) if ( focused_widget )
focused_widget->redraw(); focused_widget->redraw();
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
// sub menu handling // sub menu handling
if ( (*iter)->hasMenu() ) if ( (*iter)->hasMenu() )
{ {
FMenu* sub_menu = (*iter)->getMenu(); FMenu* sub_menu = (*iter)->getMenu();
if ( ! sub_menu->isVisible() ) if ( ! sub_menu->isVisible() )
show_sub_menu = sub_menu; show_sub_menu = sub_menu;
} }
else if ( open_sub_menu ) else if ( open_sub_menu )
hide_sub_menu = true; hide_sub_menu = true;
focus_changed = true; focus_changed = true;
} }
} }
@ -1268,11 +1361,14 @@ void FMenu::onMouseMove (FMouseEvent* ev)
{ {
// Unselect selected item without mouse focus // Unselect selected item without mouse focus
(*iter)->unsetSelected(); (*iter)->unsetSelected();
if ( getSelectedItem() == *iter ) if ( getSelectedItem() == *iter )
setSelectedItem(0); setSelectedItem(0);
focus_changed = true; focus_changed = true;
} }
} }
++iter; ++iter;
} }
@ -1324,12 +1420,15 @@ void FMenu::onMouseMove (FMouseEvent* ev)
{ {
FString msg = getStatusbarMessage(); FString msg = getStatusbarMessage();
FString curMsg = statusBar()->getMessage(); FString curMsg = statusBar()->getMessage();
if ( curMsg != msg )
if ( curMsg != msg ) if ( curMsg != msg )
{ {
statusBar()->setMessage(msg); statusBar()->setMessage(msg);
statusBar()->drawMessage(); statusBar()->drawMessage();
} }
} }
if ( open_sub_menu ) if ( open_sub_menu )
hide_sub_menu = true; hide_sub_menu = true;
} }
@ -1345,6 +1444,7 @@ void FMenu::onMouseMove (FMouseEvent* ev)
open_sub_menu->hideSubMenus(); open_sub_menu->hideSubMenus();
open_sub_menu->hide(); open_sub_menu->hide();
} }
// open sub menu // open sub menu
show_sub_menu->setVisible(); show_sub_menu->setVisible();
show_sub_menu->show(); show_sub_menu->show();
@ -1398,10 +1498,13 @@ void FMenu::hide()
if ( ! isSubMenu() ) if ( ! isSubMenu() )
{ {
FMenu* open_menu = static_cast<FMenu*>(getOpenMenu()); FMenu* open_menu = static_cast<FMenu*>(getOpenMenu());
if ( open_menu && open_menu != this ) if ( open_menu && open_menu != this )
open_menu->hide(); open_menu->hide();
setOpenMenu(0); setOpenMenu(0);
} }
mouse_down = false; mouse_down = false;
} }
} }
@ -1412,6 +1515,7 @@ void FMenu::setGeometry (int xx, int yy, int ww, int hh, bool adjust)
int old_width = width; int old_width = width;
int old_height = height; int old_height = height;
FWidget::setGeometry (xx, yy, ww, hh, adjust); FWidget::setGeometry (xx, yy, ww, hh, adjust);
if ( vwin && (width != old_width || height != old_height) ) if ( vwin && (width != old_width || height != old_height) )
resizeArea (vwin); resizeArea (vwin);
} }
@ -1420,6 +1524,7 @@ void FMenu::setGeometry (int xx, int yy, int ww, int hh, bool adjust)
void FMenu::setStatusbarMessage(FString msg) void FMenu::setStatusbarMessage(FString msg)
{ {
FWidget::setStatusbarMessage(msg); FWidget::setStatusbarMessage(msg);
if ( item ) if ( item )
item->setStatusbarMessage(msg); item->setStatusbarMessage(msg);
} }
@ -1432,8 +1537,10 @@ void FMenu::cb_menuitem_toggled (FWidget* widget, void*)
if ( ! has_checkable_items ) if ( ! has_checkable_items )
return; return;
if ( ! menuitem->isChecked() ) if ( ! menuitem->isChecked() )
return; return;
if ( itemlist.empty() ) if ( itemlist.empty() )
return; return;
@ -1448,6 +1555,7 @@ void FMenu::cb_menuitem_toggled (FWidget* widget, void*)
{ {
(*iter)->unsetChecked(); (*iter)->unsetChecked();
} }
++iter; ++iter;
} }
} }
@ -1471,7 +1579,7 @@ bool FMenu::setTransparentShadow (bool on)
adjustWidgetSizeShadow = getGeometry() + getShadow(); adjustWidgetSizeShadow = getGeometry() + getShadow();
adjustWidgetSizeGlobalShadow = getGeometryGlobal() + getShadow(); adjustWidgetSizeGlobalShadow = getGeometryGlobal() + getShadow();
} }
resizeArea (vwin); resizeArea (vwin);
return on; return on;
} }

View File

@ -60,7 +60,6 @@ class FMenu : public FWindow, public FMenuList
void menu_dimension(); void menu_dimension();
void adjustItems(); void adjustItems();
int adjustX(int); int adjustX(int);
void adjustSize();
bool isWindowsMenu (FWidget*) const; bool isWindowsMenu (FWidget*) const;
bool isMenuBar (FWidget*) const; bool isMenuBar (FWidget*) const;
bool isMenu (FWidget*) const; bool isMenu (FWidget*) const;

View File

@ -26,10 +26,13 @@ FMenuBar::~FMenuBar()
{ {
if ( vmenubar->changes != 0 ) if ( vmenubar->changes != 0 )
delete[] vmenubar->changes; delete[] vmenubar->changes;
if ( vmenubar->text != 0 ) if ( vmenubar->text != 0 )
delete[] vmenubar->text; delete[] vmenubar->text;
delete vmenubar; delete vmenubar;
} }
vmenubar = 0; vmenubar = 0;
} }
@ -45,7 +48,6 @@ void FMenuBar::init()
vmenubar->visible = true; vmenubar->visible = true;
window_object = true; window_object = true;
ignore_padding = true; ignore_padding = true;
// initialize geometry values // initialize geometry values
setGeometry (1, 1, getColumnNumber(), 1, false); setGeometry (1, 1, getColumnNumber(), 1, false);
setMenuBar(this); setMenuBar(this);
@ -104,42 +106,53 @@ bool FMenuBar::selectNextItem()
{ {
FMenuItem* next; FMenuItem* next;
std::vector<FMenuItem*>::const_iterator next_element; std::vector<FMenuItem*>::const_iterator next_element;
next_element = iter; next_element = iter;
do do
{ {
++next_element; ++next_element;
if ( next_element == itemlist.end() ) if ( next_element == itemlist.end() )
next_element = itemlist.begin(); next_element = itemlist.begin();
next = static_cast<FMenuItem*>(*next_element); next = static_cast<FMenuItem*>(*next_element);
} while ( ! next->isEnabled() } while ( ! next->isEnabled()
|| ! next->acceptFocus() || ! next->acceptFocus()
|| ! next->isVisible() || ! next->isVisible()
|| next->isSeparator() ); || next->isSeparator() );
if ( next == *iter ) if ( next == *iter )
return false; return false;
unselectItem(); unselectItem();
next->setSelected(); next->setSelected();
setSelectedItem(next); setSelectedItem(next);
next->setFocus(); next->setFocus();
if ( drop_down && next->hasMenu() ) if ( drop_down && next->hasMenu() )
{ {
FMenuItem* first_item; FMenuItem* first_item;
FMenu* menu = next->getMenu(); FMenu* menu = next->getMenu();
next->openMenu(); next->openMenu();
menu->selectFirstItem(); menu->selectFirstItem();
first_item = menu->getSelectedItem(); first_item = menu->getSelectedItem();
if ( first_item )
first_item->setFocus(); if ( first_item )
menu->redraw(); first_item->setFocus();
menu->redraw();
} }
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
redraw(); redraw();
break; break;
} }
++iter; ++iter;
} }
return true; return true;
} }
@ -153,27 +166,33 @@ bool FMenuBar::selectPrevItem()
do do
{ {
--iter; --iter;
if ( (*iter)->isSelected() ) if ( (*iter)->isSelected() )
{ {
FMenuItem* prev; FMenuItem* prev;
std::vector<FMenuItem*>::const_iterator prev_element; std::vector<FMenuItem*>::const_iterator prev_element;
prev_element = iter; prev_element = iter;
do do
{ {
if ( prev_element == itemlist.begin() ) if ( prev_element == itemlist.begin() )
prev_element = itemlist.end(); prev_element = itemlist.end();
--prev_element; --prev_element;
prev = static_cast<FMenuItem*>(*prev_element); prev = static_cast<FMenuItem*>(*prev_element);
} while ( ! prev->isEnabled() }
|| ! prev->acceptFocus() while ( ! prev->isEnabled()
|| ! prev->isVisible() || ! prev->acceptFocus()
|| prev->isSeparator() ); || ! prev->isVisible()
|| prev->isSeparator() );
if ( prev == *iter ) if ( prev == *iter )
return false; return false;
unselectItem(); unselectItem();
prev->setSelected(); prev->setSelected();
prev->setFocus(); prev->setFocus();
if ( drop_down && prev->hasMenu() ) if ( drop_down && prev->hasMenu() )
{ {
FMenuItem* first_item; FMenuItem* first_item;
@ -181,17 +200,22 @@ bool FMenuBar::selectPrevItem()
prev->openMenu(); prev->openMenu();
menu->selectFirstItem(); menu->selectFirstItem();
first_item = menu->getSelectedItem(); first_item = menu->getSelectedItem();
if ( first_item ) if ( first_item )
first_item->setFocus(); first_item->setFocus();
menu->redraw(); menu->redraw();
} }
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
setSelectedItem(prev); setSelectedItem(prev);
redraw(); redraw();
break; break;
} }
} while ( iter != begin ); }
while ( iter != begin );
return true; return true;
} }
@ -229,11 +253,15 @@ bool FMenuBar::hotkeyMenu (FKeyEvent*& ev)
(*iter)->openMenu(); (*iter)->openMenu();
menu->selectFirstItem(); menu->selectFirstItem();
first_item = menu->getSelectedItem(); first_item = menu->getSelectedItem();
if ( first_item ) if ( first_item )
first_item->setFocus(); first_item->setFocus();
menu->redraw(); menu->redraw();
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
redraw(); redraw();
drop_down = true; drop_down = true;
} }
@ -244,12 +272,15 @@ bool FMenuBar::hotkeyMenu (FKeyEvent*& ev)
drop_down = false; drop_down = false;
(*iter)->processClicked(); (*iter)->processClicked();
} }
ev->accept(); ev->accept();
return true; return true;
} }
} }
++iter; ++iter;
} }
return false; return false;
} }
@ -269,8 +300,10 @@ int FMenuBar::getHotkeyPos (wchar_t*& src, wchar_t*& dest, uInt length)
i++; i++;
src++; src++;
} }
*dest++ = *src++; *dest++ = *src++;
} }
return hotkeypos; return hotkeypos;
} }
@ -288,7 +321,6 @@ void FMenuBar::drawItems()
{ {
std::vector<FMenuItem*>::const_iterator iter, end; std::vector<FMenuItem*>::const_iterator iter, end;
int screenWidth; int screenWidth;
int x = 1; int x = 1;
screenWidth = getColumnNumber(); screenWidth = getColumnNumber();
width = screenWidth; width = screenWidth;
@ -341,6 +373,7 @@ void FMenuBar::drawItems()
foregroundColor = wc.menu_inactive_fg; foregroundColor = wc.menu_inactive_fg;
backgroundColor = wc.menu_inactive_bg; backgroundColor = wc.menu_inactive_bg;
} }
setColor (foregroundColor, backgroundColor); setColor (foregroundColor, backgroundColor);
if ( x < screenWidth ) if ( x < screenWidth )
@ -374,6 +407,7 @@ void FMenuBar::drawItems()
{ {
if ( startpos > screenWidth-z ) if ( startpos > screenWidth-z )
break; break;
if ( ! iswprint(wint_t(item_text[z])) ) if ( ! iswprint(wint_t(item_text[z])) )
{ {
if ( ! isNewFont() && ( int(item_text[z]) < fc::NF_rev_left_arrow2 if ( ! isNewFont() && ( int(item_text[z]) < fc::NF_rev_left_arrow2
@ -382,14 +416,19 @@ void FMenuBar::drawItems()
item_text[z] = L' '; item_text[z] = L' ';
} }
} }
if ( (z == hotkeypos) && is_active && ! is_selected ) if ( (z == hotkeypos) && is_active && ! is_selected )
{ {
setColor (wc.menu_hotkey_fg, wc.menu_hotkey_bg); setColor (wc.menu_hotkey_fg, wc.menu_hotkey_bg);
if ( ! is_noUnderline ) if ( ! is_noUnderline )
setUnderline(); setUnderline();
print (vmenubar, item_text[z]); print (vmenubar, item_text[z]);
if ( ! is_noUnderline ) if ( ! is_noUnderline )
unsetUnderline(); unsetUnderline();
setColor (foregroundColor, backgroundColor); setColor (foregroundColor, backgroundColor);
} }
else else
@ -417,10 +456,11 @@ void FMenuBar::drawItems()
} }
setColor (wc.menu_active_fg, wc.menu_active_bg); setColor (wc.menu_active_fg, wc.menu_active_bg);
if ( isMonochron() && is_active && is_selected ) if ( isMonochron() && is_active && is_selected )
setReverse(true); setReverse(true);
delete[] item_text;
delete[] item_text;
++iter; ++iter;
} }
@ -457,8 +497,8 @@ void FMenuBar::adjustItems()
// call menu adjustItems() // call menu adjustItems()
menu->adjustItems(); menu->adjustItems();
} }
item_X += item_width;
item_X += item_width;
++iter; ++iter;
} }
} }
@ -468,11 +508,15 @@ void FMenuBar::leaveMenuBar()
{ {
resetMenu(); resetMenu();
redraw(); redraw();
if ( statusBar() ) if ( statusBar() )
statusBar()->clearMessage(); statusBar()->clearMessage();
switchToPrevWindow(); switchToPrevWindow();
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
updateTerminal(); updateTerminal();
flush_out(); flush_out();
mouse_down = false; mouse_down = false;
@ -499,11 +543,15 @@ void FMenuBar::onKeyPress (FKeyEvent* ev)
sel_item->openMenu(); sel_item->openMenu();
menu->selectFirstItem(); menu->selectFirstItem();
first_item = menu->getSelectedItem(); first_item = menu->getSelectedItem();
if ( first_item ) if ( first_item )
first_item->setFocus(); first_item->setFocus();
menu->redraw(); menu->redraw();
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
redraw(); redraw();
drop_down = true; drop_down = true;
} }
@ -515,6 +563,7 @@ void FMenuBar::onKeyPress (FKeyEvent* ev)
sel_item->processClicked(); sel_item->processClicked();
} }
} }
ev->accept(); ev->accept();
break; break;
@ -552,7 +601,8 @@ void FMenuBar::onMouseDown (FMouseEvent* ev)
return; return;
if ( statusBar() ) if ( statusBar() )
statusBar()->clearMessage(); statusBar()->clearMessage();
return; return;
} }
@ -593,8 +643,10 @@ void FMenuBar::onMouseDown (FMouseEvent* ev)
FApplication::queueEvent(focused_widget, &out); FApplication::queueEvent(focused_widget, &out);
(*iter)->setSelected(); (*iter)->setSelected();
(*iter)->setFocus(); (*iter)->setFocus();
if ( focused_widget ) if ( focused_widget )
focused_widget->redraw(); focused_widget->redraw();
(*iter)->openMenu(); (*iter)->openMenu();
setSelectedItem(*iter); setSelectedItem(*iter);
focus_changed = true; focus_changed = true;
@ -602,6 +654,7 @@ void FMenuBar::onMouseDown (FMouseEvent* ev)
if ( (*iter)->hasMenu() ) if ( (*iter)->hasMenu() )
{ {
FMenu* menu = (*iter)->getMenu(); FMenu* menu = (*iter)->getMenu();
if ( menu->hasSelectedItem() ) if ( menu->hasSelectedItem() )
{ {
menu->unselectItem(); menu->unselectItem();
@ -614,11 +667,14 @@ void FMenuBar::onMouseDown (FMouseEvent* ev)
else if ( (*iter)->isEnabled() && (*iter)->isSelected() ) else if ( (*iter)->isEnabled() && (*iter)->isSelected() )
{ {
(*iter)->unsetSelected(); (*iter)->unsetSelected();
if ( getSelectedItem() == *iter ) if ( getSelectedItem() == *iter )
setSelectedItem(0); setSelectedItem(0);
focus_changed = true; focus_changed = true;
} }
} }
++iter; ++iter;
} }
@ -642,11 +698,11 @@ void FMenuBar::onMouseUp (FMouseEvent* ev)
if ( mouse_down ) if ( mouse_down )
{ {
mouse_down = false; mouse_down = false;
if ( ! itemlist.empty() ) if ( ! itemlist.empty() )
{ {
std::vector<FMenuItem*>::const_iterator iter, end;
int mouse_x, mouse_y; int mouse_x, mouse_y;
std::vector<FMenuItem*>::const_iterator iter, end;
iter = itemlist.begin(); iter = itemlist.begin();
end = itemlist.end(); end = itemlist.end();
mouse_x = ev->getX(); mouse_x = ev->getX();
@ -655,7 +711,6 @@ void FMenuBar::onMouseUp (FMouseEvent* ev)
while ( iter != end ) while ( iter != end )
{ {
int x1, x2; int x1, x2;
x1 = (*iter)->getX(); x1 = (*iter)->getX();
x2 = (*iter)->getX() + (*iter)->getWidth(); x2 = (*iter)->getX() + (*iter)->getWidth();
@ -669,16 +724,21 @@ void FMenuBar::onMouseUp (FMouseEvent* ev)
if ( (*iter)->hasMenu() ) if ( (*iter)->hasMenu() )
{ {
FMenu* menu = (*iter)->getMenu(); FMenu* menu = (*iter)->getMenu();
if ( ! menu->hasSelectedItem() ) if ( ! menu->hasSelectedItem() )
{ {
FMenuItem* first_item; FMenuItem* first_item;
menu->selectFirstItem(); menu->selectFirstItem();
first_item = menu->getSelectedItem(); first_item = menu->getSelectedItem();
if ( first_item ) if ( first_item )
first_item->setFocus(); first_item->setFocus();
menu->redraw(); menu->redraw();
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
redraw(); redraw();
drop_down = true; drop_down = true;
} }
@ -686,6 +746,7 @@ void FMenuBar::onMouseUp (FMouseEvent* ev)
else else
{ {
(*iter)->unsetSelected(); (*iter)->unsetSelected();
if ( getSelectedItem() == *iter ) if ( getSelectedItem() == *iter )
{ {
setSelectedItem(0); setSelectedItem(0);
@ -699,14 +760,18 @@ void FMenuBar::onMouseUp (FMouseEvent* ev)
else else
{ {
(*iter)->unsetSelected(); (*iter)->unsetSelected();
if ( getSelectedItem() == *iter ) if ( getSelectedItem() == *iter )
setSelectedItem(0); setSelectedItem(0);
redraw(); redraw();
} }
} }
++iter; ++iter;
} }
} }
if ( ! hasSelectedItem() ) if ( ! hasSelectedItem() )
leaveMenuBar(); leaveMenuBar();
} }
@ -728,7 +793,6 @@ void FMenuBar::onMouseMove (FMouseEvent* ev)
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 = itemlist.begin();
end = itemlist.end(); end = itemlist.end();
mouse_x = ev->getX(); mouse_x = ev->getX();
@ -740,7 +804,6 @@ void FMenuBar::onMouseMove (FMouseEvent* ev)
while ( iter != end ) while ( iter != end )
{ {
int x1, x2; int x1, x2;
x1 = (*iter)->getX(); x1 = (*iter)->getX();
x2 = (*iter)->getX() + (*iter)->getWidth(); x2 = (*iter)->getX() + (*iter)->getWidth();
@ -756,21 +819,24 @@ void FMenuBar::onMouseMove (FMouseEvent* ev)
FApplication::queueEvent(focused_widget, &out); FApplication::queueEvent(focused_widget, &out);
(*iter)->setSelected(); (*iter)->setSelected();
(*iter)->setFocus(); (*iter)->setFocus();
if ( focused_widget ) if ( focused_widget )
focused_widget->redraw(); focused_widget->redraw();
(*iter)->openMenu(); (*iter)->openMenu();
setSelectedItem(*iter); setSelectedItem(*iter);
focus_changed = true; focus_changed = true;
if ( (*iter)->hasMenu() ) if ( (*iter)->hasMenu() )
{ {
FMenu* menu = (*iter)->getMenu(); FMenu* menu = (*iter)->getMenu();
if ( menu->hasSelectedItem() )
{ if ( menu->hasSelectedItem() )
menu->unselectItem(); {
menu->redraw(); menu->unselectItem();
drop_down = true; menu->redraw();
} drop_down = true;
}
} }
} }
else if ( statusBar() ) else if ( statusBar() )
@ -784,8 +850,10 @@ void FMenuBar::onMouseMove (FMouseEvent* ev)
{ {
// Unselect selected item without mouse focus // Unselect selected item without mouse focus
(*iter)->unsetSelected(); (*iter)->unsetSelected();
if ( getSelectedItem() == *iter ) if ( getSelectedItem() == *iter )
setSelectedItem(0); setSelectedItem(0);
focus_changed = true; focus_changed = true;
drop_down = false; drop_down = false;
} }
@ -798,10 +866,11 @@ void FMenuBar::onMouseMove (FMouseEvent* ev)
if ( menu->count() > 0 if ( menu->count() > 0
&& menu_geometry.contains(ev->getGlobalPos()) ) && menu_geometry.contains(ev->getGlobalPos()) )
{ {
FMouseEvent* _ev;
const FPoint& g = ev->getGlobalPos(); const FPoint& g = ev->getGlobalPos();
const FPoint& p = menu->globalToLocalPos(g); const FPoint& p = menu->globalToLocalPos(g);
int b = ev->getButton(); int b = ev->getButton();
FMouseEvent* _ev = new FMouseEvent (fc::MouseMove_Event, p, g, b); _ev = new FMouseEvent (fc::MouseMove_Event, p, g, b);
menu->mouse_down = true; menu->mouse_down = true;
setClickedWidget(menu); setClickedWidget(menu);
menu->onMouseMove(_ev); menu->onMouseMove(_ev);
@ -809,10 +878,13 @@ void FMenuBar::onMouseMove (FMouseEvent* ev)
} }
} }
} }
++iter; ++iter;
} }
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
if ( focus_changed ) if ( focus_changed )
{ {
redraw(); redraw();
@ -827,8 +899,10 @@ void FMenuBar::onAccel (FAccelEvent* ev)
unselectItem(); unselectItem();
selectFirstItem(); selectFirstItem();
getSelectedItem()->setFocus(); getSelectedItem()->setFocus();
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
redraw(); redraw();
ev->accept(); ev->accept();
} }
@ -841,16 +915,13 @@ void FMenuBar::hide()
char* blank; char* blank;
FWindow::hide(); FWindow::hide();
fg = wc.term_fg; fg = wc.term_fg;
bg = wc.term_bg; bg = wc.term_bg;
setColor (fg, bg); setColor (fg, bg);
screenWidth = getColumnNumber(); screenWidth = getColumnNumber();
blank = new char[screenWidth+1]; blank = new char[screenWidth+1];
memset(blank, ' ', uLong(screenWidth)); memset(blank, ' ', uLong(screenWidth));
blank[screenWidth] = '\0'; blank[screenWidth] = '\0';
gotoxy (1,1); gotoxy (1,1);
print (vmenubar, blank); print (vmenubar, blank);
delete[] blank; delete[] blank;
@ -880,6 +951,7 @@ void FMenuBar::setGeometry (int xx, int yy, int ww, int hh, bool adjust)
int old_width = width; int old_width = width;
int old_height = height; int old_height = height;
FWidget::setGeometry (xx, yy, ww, hh, adjust); FWidget::setGeometry (xx, yy, ww, hh, adjust);
if ( vmenubar && (width != old_width || height != old_height) ) if ( vmenubar && (width != old_width || height != old_height) )
resizeArea (vmenubar); resizeArea (vmenubar);
} }

View File

@ -175,12 +175,14 @@ void FMenuItem::init (FWidget* parent)
addAccelerator (accel_key); addAccelerator (accel_key);
menu_list = dynamic_cast<FMenuList*>(parent); menu_list = dynamic_cast<FMenuList*>(parent);
if ( menu_list ) if ( menu_list )
menu_list->insert(this); menu_list->insert(this);
if ( isMenuBar(parent) ) // Parent is menubar if ( isMenuBar(parent) ) // Parent is menubar
{ {
FMenuBar* menubar_ptr = dynamic_cast<FMenuBar*>(parent); FMenuBar* menubar_ptr = dynamic_cast<FMenuBar*>(parent);
if ( menubar_ptr ) if ( menubar_ptr )
{ {
menubar_ptr->menu_dimension(); menubar_ptr->menu_dimension();
@ -198,10 +200,12 @@ void FMenuItem::init (FWidget* parent)
else if ( isMenu(parent) ) // Parent is menu else if ( isMenu(parent) ) // Parent is menu
{ {
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->menu_dimension();
} }
} }
if ( hasFocus() ) if ( hasFocus() )
flags = fc::focus; flags = fc::focus;
@ -231,6 +235,7 @@ uChar FMenuItem::hotKey()
return 0;; return 0;;
} }
} }
return 0; return 0;
} }
@ -260,13 +265,16 @@ void FMenuItem::createDialogList (FMenu* winmenu)
do do
{ {
--iter; --iter;
if ( (*iter)->isDialog() ) if ( (*iter)->isDialog() )
{ {
FDialog* win = dynamic_cast<FDialog*>(*iter); FDialog* win = dynamic_cast<FDialog*>(*iter);
if ( win ) if ( win )
{ {
FString win_title = win->getText(); FString win_title = win->getText();
FMenuItem* win_item = new FMenuItem (win_title, winmenu); FMenuItem* win_item = new FMenuItem (win_title, winmenu);
win_item->addCallback win_item->addCallback
( (
"clicked", "clicked",
@ -278,6 +286,7 @@ void FMenuItem::createDialogList (FMenu* winmenu)
} }
while ( iter != begin ); while ( iter != begin );
} }
winmenu->menu_dimension(); winmenu->menu_dimension();
} }
@ -285,13 +294,16 @@ void FMenuItem::createDialogList (FMenu* winmenu)
void FMenuItem::cb_switchToDialog (FWidget*, void* data_ptr) void FMenuItem::cb_switchToDialog (FWidget*, void* data_ptr)
{ {
FDialog* win = static_cast<FDialog*>(data_ptr); FDialog* win = static_cast<FDialog*>(data_ptr);
if ( win && ! win->isHiddenWindow() && ! win->isActiveWindow() ) if ( win && ! win->isHiddenWindow() && ! win->isActiveWindow() )
{ {
FWindow::setActiveWindow(win); FWindow::setActiveWindow(win);
FWidget* focus_widget = win->getFocusWidget(); FWidget* focus_widget = win->getFocusWidget();
FWindow::raiseWindow (win); FWindow::raiseWindow (win);
if ( focus_widget ) if ( focus_widget )
focus_widget->setFocus(); focus_widget->setFocus();
win->redraw(); win->redraw();
} }
} }
@ -333,6 +345,7 @@ bool FMenuItem::isMenu (FWidget* w) const
void FMenuItem::addAccelerator (int key, FWidget* obj) void FMenuItem::addAccelerator (int key, FWidget* obj)
{ {
FWidget* super = super_menu; FWidget* super = super_menu;
if ( ! super ) if ( ! super )
return; return;
@ -349,6 +362,7 @@ void FMenuItem::addAccelerator (int key, FWidget* obj)
if ( ! window ) if ( ! window )
window = getRootWidget(); window = getRootWidget();
if ( window && window->accelerator_list ) if ( window && window->accelerator_list )
{ {
accel_key = key; accel_key = key;
@ -359,6 +373,7 @@ void FMenuItem::addAccelerator (int key, FWidget* obj)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
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->menu_dimension();
} }
@ -368,6 +383,7 @@ void FMenuItem::addAccelerator (int key, FWidget* obj)
void FMenuItem::delAccelerator (FWidget* obj) void FMenuItem::delAccelerator (FWidget* obj)
{ {
FWidget* super = super_menu; FWidget* super = super_menu;
if ( ! super ) if ( ! super )
return; return;
@ -383,6 +399,7 @@ void FMenuItem::delAccelerator (FWidget* obj)
if ( ! window ) if ( ! window )
window = getRootWidget(); window = getRootWidget();
if ( window if ( window
&& window->accelerator_list && window->accelerator_list
&& ! window->accelerator_list->empty() ) && ! window->accelerator_list->empty() )
@ -406,6 +423,7 @@ void FMenuItem::delAccelerator (FWidget* obj)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
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->menu_dimension();
} }
@ -419,6 +437,7 @@ void FMenuItem::onKeyPress (FKeyEvent* ev)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
FMenu* smenu = dynamic_cast<FMenu*>(super_menu); FMenu* smenu = dynamic_cast<FMenu*>(super_menu);
if ( smenu ) if ( smenu )
smenu->onKeyPress(ev); smenu->onKeyPress(ev);
} }
@ -426,10 +445,12 @@ void FMenuItem::onKeyPress (FKeyEvent* ev)
if ( isMenuBar(super_menu) ) if ( isMenuBar(super_menu) )
{ {
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu); FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu);
if ( mbar ) if ( mbar )
{ {
if ( mbar->hotkeyMenu(ev) ) if ( mbar->hotkeyMenu(ev) )
return; return;
mbar->onKeyPress(ev); mbar->onKeyPress(ev);
} }
} }
@ -447,6 +468,7 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
FMenu* smenu = dynamic_cast<FMenu*>(super_menu); FMenu* smenu = dynamic_cast<FMenu*>(super_menu);
if ( smenu ) if ( smenu )
{ {
const FPoint& p2 = smenu->globalToLocalPos(g); const FPoint& p2 = smenu->globalToLocalPos(g);
@ -459,6 +481,7 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
if ( isMenuBar(super_menu) ) if ( isMenuBar(super_menu) )
{ {
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu); FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu);
if ( mbar ) if ( mbar )
{ {
const FPoint& p2 = mbar->globalToLocalPos(g); const FPoint& p2 = mbar->globalToLocalPos(g);
@ -471,6 +494,7 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
if ( isWindowsMenu(super_menu) ) if ( isWindowsMenu(super_menu) )
{ {
FDialog* dgl = dynamic_cast<FDialog*>(super_menu); FDialog* dgl = dynamic_cast<FDialog*>(super_menu);
if ( dgl ) if ( dgl )
{ {
const FPoint& p2 = dgl->globalToLocalPos(g); const FPoint& p2 = dgl->globalToLocalPos(g);
@ -493,6 +517,7 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
FMenu* smenu = dynamic_cast<FMenu*>(super_menu); FMenu* smenu = dynamic_cast<FMenu*>(super_menu);
if ( smenu ) if ( smenu )
{ {
const FPoint& p2 = smenu->globalToLocalPos(g); const FPoint& p2 = smenu->globalToLocalPos(g);
@ -505,6 +530,7 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
if ( isMenuBar(super_menu) ) if ( isMenuBar(super_menu) )
{ {
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu); FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu);
if ( mbar ) if ( mbar )
{ {
const FPoint& p2 = mbar->globalToLocalPos(g); const FPoint& p2 = mbar->globalToLocalPos(g);
@ -517,6 +543,7 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
if ( isWindowsMenu(super_menu) ) if ( isWindowsMenu(super_menu) )
{ {
FDialog* dgl = dynamic_cast<FDialog*>(super_menu); FDialog* dgl = dynamic_cast<FDialog*>(super_menu);
if ( dgl ) if ( dgl )
{ {
const FPoint& p2 = dgl->globalToLocalPos(g); const FPoint& p2 = dgl->globalToLocalPos(g);
@ -539,6 +566,7 @@ void FMenuItem::onMouseUp (FMouseEvent* ev)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
FMenu* smenu = dynamic_cast<FMenu*>(super_menu); FMenu* smenu = dynamic_cast<FMenu*>(super_menu);
if ( smenu ) if ( smenu )
{ {
const FPoint& p2 = smenu->globalToLocalPos(g); const FPoint& p2 = smenu->globalToLocalPos(g);
@ -551,6 +579,7 @@ void FMenuItem::onMouseUp (FMouseEvent* ev)
if ( isMenuBar(super_menu) ) if ( isMenuBar(super_menu) )
{ {
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu); FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu);
if ( mbar ) if ( mbar )
{ {
const FPoint& p2 = mbar->globalToLocalPos(g); const FPoint& p2 = mbar->globalToLocalPos(g);
@ -563,6 +592,7 @@ void FMenuItem::onMouseUp (FMouseEvent* ev)
if ( isWindowsMenu(super_menu) ) if ( isWindowsMenu(super_menu) )
{ {
FDialog* dgl = dynamic_cast<FDialog*>(super_menu); FDialog* dgl = dynamic_cast<FDialog*>(super_menu);
if ( dgl ) if ( dgl )
{ {
const FPoint& p2 = dgl->globalToLocalPos(g); const FPoint& p2 = dgl->globalToLocalPos(g);
@ -585,6 +615,7 @@ void FMenuItem::onMouseMove (FMouseEvent* ev)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
FMenu* smenu = dynamic_cast<FMenu*>(super_menu); FMenu* smenu = dynamic_cast<FMenu*>(super_menu);
if ( smenu ) if ( smenu )
{ {
const FPoint& p2 = smenu->globalToLocalPos(g); const FPoint& p2 = smenu->globalToLocalPos(g);
@ -597,6 +628,7 @@ void FMenuItem::onMouseMove (FMouseEvent* ev)
if ( isMenuBar(super_menu) ) if ( isMenuBar(super_menu) )
{ {
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu); FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu);
if ( mbar ) if ( mbar )
{ {
const FPoint& p2 = mbar->globalToLocalPos(g); const FPoint& p2 = mbar->globalToLocalPos(g);
@ -609,6 +641,7 @@ void FMenuItem::onMouseMove (FMouseEvent* ev)
if ( isWindowsMenu(super_menu) ) if ( isWindowsMenu(super_menu) )
{ {
FDialog* dgl = dynamic_cast<FDialog*>(super_menu); FDialog* dgl = dynamic_cast<FDialog*>(super_menu);
if ( dgl ) if ( dgl )
{ {
const FPoint& p2 = dgl->globalToLocalPos(g); const FPoint& p2 = dgl->globalToLocalPos(g);
@ -628,6 +661,7 @@ void FMenuItem::onAccel (FAccelEvent* ev)
if ( super_menu && isMenuBar(super_menu) ) if ( super_menu && isMenuBar(super_menu) )
{ {
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu); FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu);
if ( mbar ) if ( mbar )
{ {
if ( menu ) if ( menu )
@ -636,6 +670,7 @@ void FMenuItem::onAccel (FAccelEvent* ev)
if ( mbar->getSelectedItem() ) if ( mbar->getSelectedItem() )
mbar->getSelectedItem()->unsetSelected(); mbar->getSelectedItem()->unsetSelected();
setSelected(); setSelected();
mbar->selectedItem = this; mbar->selectedItem = this;
openMenu(); openMenu();
@ -646,11 +681,15 @@ void FMenuItem::onAccel (FAccelEvent* ev)
menu->unselectItem(); menu->unselectItem();
menu->selectFirstItem(); menu->selectFirstItem();
menu->getSelectedItem()->setFocus(); menu->getSelectedItem()->setFocus();
if ( focused_widget ) if ( focused_widget )
focused_widget->redraw(); focused_widget->redraw();
menu->redraw(); menu->redraw();
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
mbar->redraw(); mbar->redraw();
mbar->drop_down = true; mbar->drop_down = true;
} }
@ -681,12 +720,15 @@ void FMenuItem::onFocusIn (FFocusEvent*)
void FMenuItem::onFocusOut (FFocusEvent*) void FMenuItem::onFocusOut (FFocusEvent*)
{ {
unsetSelected(); unsetSelected();
if ( super_menu && isMenuBar(super_menu) ) if ( super_menu && isMenuBar(super_menu) )
{ {
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu); FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu);
if ( mbar ) if ( mbar )
mbar->redraw(); mbar->redraw();
} }
if ( statusBar() ) if ( statusBar() )
{ {
statusBar()->clearMessage(); statusBar()->clearMessage();
@ -698,7 +740,6 @@ void FMenuItem::onFocusOut (FFocusEvent*)
bool FMenuItem::setEnable (bool on) bool FMenuItem::setEnable (bool on)
{ {
FWidget::setEnable(on); FWidget::setEnable(on);
FWidget* super = getSuperMenu(); FWidget* super = getSuperMenu();
if ( on ) if ( on )
@ -718,6 +759,7 @@ bool FMenuItem::setEnable (bool on)
if ( super && isMenuBar(super) ) if ( super && isMenuBar(super) )
super->delAccelerator (this); super->delAccelerator (this);
} }
return on; return on;
} }
@ -736,6 +778,7 @@ bool FMenuItem::setFocus (bool on)
{ {
FMenuList* menu_list = dynamic_cast<FMenuList*>(getSuperMenu()); FMenuList* menu_list = dynamic_cast<FMenuList*>(getSuperMenu());
setSelected(); setSelected();
if ( menu_list ) if ( menu_list )
{ {
menu_list->unselectItem(); menu_list->unselectItem();
@ -746,15 +789,18 @@ bool FMenuItem::setFocus (bool on)
statusBar()->drawMessage(); statusBar()->drawMessage();
FWidget* parent = getSuperMenu(); FWidget* parent = getSuperMenu();
if ( isMenuBar(parent) ) if ( isMenuBar(parent) )
{ {
FMenuBar* menubar_ptr = dynamic_cast<FMenuBar*>(parent); FMenuBar* menubar_ptr = dynamic_cast<FMenuBar*>(parent);
if ( menubar_ptr ) if ( menubar_ptr )
menubar_ptr->redraw(); menubar_ptr->redraw();
} }
else if ( isMenu(parent) ) else if ( isMenu(parent) )
{ {
FMenu* menu_ptr = dynamic_cast<FMenu*>(parent); FMenu* menu_ptr = dynamic_cast<FMenu*>(parent);
if ( menu_ptr ) if ( menu_ptr )
menu_ptr->redraw(); menu_ptr->redraw();
} }
@ -764,6 +810,7 @@ bool FMenuItem::setFocus (bool on)
{ {
FString msg = getStatusbarMessage(); FString msg = getStatusbarMessage();
FString curMsg = statusBar()->getMessage(); FString curMsg = statusBar()->getMessage();
if ( curMsg != msg ) if ( curMsg != msg )
statusBar()->setMessage(msg); statusBar()->setMessage(msg);
} }
@ -776,6 +823,7 @@ bool FMenuItem::setFocus (bool on)
if ( isEnabled() && statusBar() ) if ( isEnabled() && statusBar() )
statusBar()->clearMessage(); statusBar()->clearMessage();
} }
return on; return on;
} }
@ -805,19 +853,22 @@ void FMenuItem::openMenu()
if ( hasMenu() ) if ( hasMenu() )
{ {
dd_menu = getMenu(); dd_menu = getMenu();
if ( dd_menu->isVisible() ) if ( dd_menu->isVisible() )
return; return;
open_menu = static_cast<FMenu*>(getOpenMenu()); open_menu = static_cast<FMenu*>(getOpenMenu());
if ( open_menu && open_menu != dd_menu ) if ( open_menu && open_menu != dd_menu )
{ {
open_menu->hide(); open_menu->hide();
open_menu->hideSubMenus(); open_menu->hideSubMenus();
} }
if ( dialog_list ) if ( dialog_list )
createDialogList (dd_menu); createDialogList (dd_menu);
setOpenMenu(dd_menu);
setOpenMenu(dd_menu);
dd_menu->setVisible(); dd_menu->setVisible();
dd_menu->show(); dd_menu->show();
dd_menu->raiseWindow(dd_menu); dd_menu->raiseWindow(dd_menu);
@ -833,8 +884,10 @@ void FMenuItem::setText (FString& txt)
text = txt; text = txt;
text_length = text.getLength(); text_length = text.getLength();
hotkey = hotKey(); hotkey = hotKey();
if ( hotkey ) if ( hotkey )
text_length--; text_length--;
setWidth(int(text_length)); setWidth(int(text_length));
} }

View File

@ -55,6 +55,7 @@ void FMenuList::selectFirstItem()
setSelectedItem(*iter); setSelectedItem(*iter);
break; break;
} }
++iter; ++iter;
} }
} }
@ -64,6 +65,7 @@ void FMenuList::unselectItem()
{ {
if ( hasSelectedItem() ) if ( hasSelectedItem() )
getSelectedItem()->unsetSelected(); getSelectedItem()->unsetSelected();
setSelectedItem(0); setSelectedItem(0);
} }
@ -82,6 +84,7 @@ void FMenuList::remove (FMenuItem* i)
return; return;
iter = itemlist.begin(); iter = itemlist.begin();
while ( iter != itemlist.end() ) while ( iter != itemlist.end() )
{ {
if ( (*iter) == i ) if ( (*iter) == i )
@ -109,4 +112,3 @@ void FMenuList::clear()
{ {
itemlist.clear(); itemlist.clear();
} }

View File

@ -109,8 +109,10 @@ void FMessageBox::init(int button0, int button1, int button2)
{ {
button0 = button1 = button2 = 0; button0 = button1 = button2 = 0;
} }
if ( button0 == 0 ) if ( button0 == 0 )
button0 = FMessageBox::Ok; button0 = FMessageBox::Ok;
if ( button1 == 0 && button2 == 0 ) if ( button1 == 0 && button2 == 0 )
numButtons = 1; numButtons = 1;
else if ( button2 == 0 ) else if ( button2 == 0 )
@ -157,29 +159,34 @@ void FMessageBox::init(int button0, int button1, int button2)
adjustButtons(); adjustButtons();
if ( *button_digit[0] != 0 ) if ( *button_digit[0] != 0 )
{
button[0]->addCallback button[0]->addCallback
( (
"clicked", "clicked",
_METHOD_CALLBACK (this, &FMessageBox::cb_processClick), _METHOD_CALLBACK (this, &FMessageBox::cb_processClick),
static_cast<FWidget::data_ptr>(button_digit[0]) static_cast<FWidget::data_ptr>(button_digit[0])
); );
}
if ( *button_digit[1] != 0 ) if ( *button_digit[1] != 0 )
{
button[1]->addCallback button[1]->addCallback
( (
"clicked", "clicked",
_METHOD_CALLBACK (this, &FMessageBox::cb_processClick), _METHOD_CALLBACK (this, &FMessageBox::cb_processClick),
static_cast<FWidget::data_ptr>(button_digit[1]) static_cast<FWidget::data_ptr>(button_digit[1])
); );
}
if ( *button_digit[2] != 0 ) if ( *button_digit[2] != 0 )
{
button[2]->addCallback button[2]->addCallback
( (
"clicked", "clicked",
_METHOD_CALLBACK (this, &FMessageBox::cb_processClick), _METHOD_CALLBACK (this, &FMessageBox::cb_processClick),
static_cast<FWidget::data_ptr>(button_digit[2]) static_cast<FWidget::data_ptr>(button_digit[2])
); );
}
setModal(); setModal();
setTransparentShadow(); setTransparentShadow();
@ -201,13 +208,17 @@ void FMessageBox::msg_dimension()
for (uInt i=0; i < text_num_lines; i++) for (uInt i=0; i < text_num_lines; i++)
{ {
uInt len = text_components[i].getLength(); uInt len = text_components[i].getLength();
if ( len > maxLineWidth ) if ( len > maxLineWidth )
maxLineWidth = len; maxLineWidth = len;
} }
h = int(text_num_lines) + 8 + headline_height; h = int(text_num_lines) + 8 + headline_height;
w = int(maxLineWidth + 4); w = int(maxLineWidth + 4);
if ( w < 20 ) if ( w < 20 )
w = 20; w = 20;
x = 1 + int((getParentWidget()->getWidth()-w)/2); x = 1 + int((getParentWidget()->getWidth()-w)/2);
y = 1 + int((getParentWidget()->getHeight()-h)/3); y = 1 + int((getParentWidget()->getHeight()-h)/3);
setGeometry (x, y, w, h); setGeometry (x, y, w, h);
@ -221,7 +232,6 @@ void FMessageBox::draw()
int head_offset = 0; int head_offset = 0;
int center_x = 0; int center_x = 0;
int msg_x = int((width - int(maxLineWidth)) / 2); // center the whole block int msg_x = int((width - int(maxLineWidth)) / 2); // center the whole block
setUpdateVTerm(false); setUpdateVTerm(false);
if ( isMonochron() ) if ( isMonochron() )
@ -231,8 +241,10 @@ void FMessageBox::draw()
{ {
setColor(emphasis_color, backgroundColor); setColor(emphasis_color, backgroundColor);
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((maxLineWidth - headline_length) / 2);
gotoxy (xpos+xmin-1+msg_x+center_x, ypos+ymin+2); gotoxy (xpos+xmin-1+msg_x+center_x, ypos+ymin+2);
print (headline_text); print (headline_text);
head_offset = 2; head_offset = 2;
@ -243,8 +255,10 @@ void FMessageBox::draw()
for (int i=0; i < int(text_num_lines); i++) for (int i=0; i < int(text_num_lines); i++)
{ {
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((maxLineWidth - line_length) / 2);
gotoxy (xpos+xmin-1+msg_x+center_x, ypos+ymin+2+head_offset+i); gotoxy (xpos+xmin-1+msg_x+center_x, ypos+ymin+2+head_offset+i);
print(text_components[i]); print(text_components[i]);
} }
@ -259,9 +273,11 @@ void FMessageBox::draw()
void FMessageBox::resizeButtons() 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 < numButtons; n++)
{ {
len[n] = button[n]->getText().getLength(); len[n] = button[n]->getText().getLength();
if ( button[n]->getText().includes('&') ) if ( button[n]->getText().includes('&') )
len[n]--; len[n]--;
} }
@ -272,9 +288,11 @@ void FMessageBox::resizeButtons()
{ {
assert ( numButtons > 1 ); assert ( numButtons > 1 );
max_size = std::max(len[0], len[1]); max_size = std::max(len[0], len[1]);
if ( numButtons == 3 ) if ( numButtons == 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;
@ -287,6 +305,7 @@ 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 < numButtons; n++)
{ {
if ( n == numButtons-1 ) if ( n == numButtons-1 )
@ -381,11 +400,15 @@ void FMessageBox::setHeadline (const FString& headline)
int old_height = height; int old_height = height;
headline_text = headline; headline_text = headline;
setHeight(height + 2, true); setHeight(height + 2, true);
for (uInt n=0; n < numButtons; n++) for (uInt n=0; n < numButtons; n++)
button[n]->setY(height-4, false); button[n]->setY(height-4, false);
uInt len = headline_text.getLength(); uInt len = headline_text.getLength();
if ( len > maxLineWidth ) if ( len > maxLineWidth )
maxLineWidth = len; maxLineWidth = len;
if ( vwin && height != old_height ) if ( vwin && height != old_height )
resizeArea (vwin); resizeArea (vwin);
} }
@ -410,10 +433,13 @@ void FMessageBox::setText (const FString& txt)
text = txt; text = txt;
msg_dimension(); msg_dimension();
button[0]->setY(height-4, false); button[0]->setY(height-4, false);
if ( *button_digit[1] != 0 ) if ( *button_digit[1] != 0 )
button[1]->setY(height-4, false); button[1]->setY(height-4, false);
if ( *button_digit[2] != 0 ) if ( *button_digit[2] != 0 )
button[2]->setY(height-4, false); button[2]->setY(height-4, false);
adjustButtons(); adjustButtons();
} }

View File

@ -49,6 +49,7 @@ FObject::~FObject() // destructor
// delete children objects // delete children objects
FObject::object_list children = this->getChildren(); FObject::object_list children = this->getChildren();
if ( ! children.empty() ) if ( ! children.empty() )
{ {
FObject::object_list::const_iterator iter; FObject::object_list::const_iterator iter;
@ -92,6 +93,7 @@ bool FObject::event (FEvent* ev)
onTimer ( static_cast<FTimerEvent*>(ev) ); onTimer ( static_cast<FTimerEvent*>(ev) );
return true; return true;
} }
return false; return false;
} }
@ -106,6 +108,7 @@ void FObject::getCurrentTime (timeval &time)
time.tv_usec -= 1000000; time.tv_usec -= 1000000;
time.tv_sec++; time.tv_sec++;
} }
while ( time.tv_usec < 0 ) while ( time.tv_usec < 0 )
{ {
if ( time.tv_sec > 0 ) if ( time.tv_sec > 0 )
@ -196,8 +199,8 @@ bool FObject::delTimer (int id)
modify_timer = false; modify_timer = false;
return true; return true;
} }
modify_timer = false;
modify_timer = false;
return false; return false;
} }
@ -208,6 +211,7 @@ bool FObject::delOwnTimer()
if ( ! timer_list ) if ( ! timer_list )
return false; return false;
if ( timer_list->empty() ) if ( timer_list->empty() )
return false; return false;
@ -221,8 +225,8 @@ bool FObject::delOwnTimer()
else else
++iter; ++iter;
} }
modify_timer = false;
modify_timer = false;
return true; return true;
} }
@ -231,13 +235,13 @@ bool FObject::delAllTimer()
{ {
if ( ! timer_list ) if ( ! timer_list )
return false; return false;
if ( timer_list->empty() ) if ( timer_list->empty() )
return false; return false;
modify_timer = true; modify_timer = true;
timer_list->clear(); timer_list->clear();
modify_timer = false; modify_timer = false;
return true; return true;
} }

View File

@ -134,11 +134,13 @@ static inline timeval operator + (const timeval& t1, const timeval& t2)
{ {
timeval tmp; timeval tmp;
tmp.tv_sec = t1.tv_sec + t2.tv_sec; tmp.tv_sec = t1.tv_sec + t2.tv_sec;
if ( (tmp.tv_usec = t1.tv_usec + t2.tv_usec) >= 1000000 ) if ( (tmp.tv_usec = t1.tv_usec + t2.tv_usec) >= 1000000 )
{ {
tmp.tv_sec++; tmp.tv_sec++;
tmp.tv_usec -= 1000000; tmp.tv_usec -= 1000000;
} }
return tmp; return tmp;
} }
@ -147,11 +149,13 @@ static inline timeval operator - (const timeval& t1, const timeval& t2)
{ {
timeval tmp; timeval tmp;
tmp.tv_sec = t1.tv_sec - t2.tv_sec; tmp.tv_sec = t1.tv_sec - t2.tv_sec;
if ( (tmp.tv_usec = t1.tv_usec - t2.tv_usec) < 0 ) if ( (tmp.tv_usec = t1.tv_usec - t2.tv_usec) < 0 )
{ {
tmp.tv_sec--; tmp.tv_sec--;
tmp.tv_usec += 1000000; tmp.tv_usec += 1000000;
} }
return tmp; return tmp;
} }
@ -159,11 +163,13 @@ static inline timeval operator - (const timeval& t1, const timeval& t2)
static inline timeval& operator += (timeval& t1, const timeval& t2) static inline timeval& operator += (timeval& t1, const timeval& t2)
{ {
t1.tv_sec += t2.tv_sec; t1.tv_sec += t2.tv_sec;
if ( (t1.tv_usec += t2.tv_usec) >= 1000000 ) if ( (t1.tv_usec += t2.tv_usec) >= 1000000 )
{ {
t1.tv_sec++; t1.tv_sec++;
t1.tv_usec -= 1000000; t1.tv_usec -= 1000000;
} }
return t1; return t1;
} }

View File

@ -135,6 +135,7 @@ inline void FOptiAttr::prevent_no_color_video_attributes (char_data*& attr)
if ( attr->reverse ) if ( attr->reverse )
{ {
attr->reverse = false; attr->reverse = false;
if ( attr->fg_color != attr->bg_color ) if ( attr->fg_color != attr->bg_color )
fake_reverse = true; fake_reverse = true;
} }
@ -216,10 +217,12 @@ void FOptiAttr::change_color (char_data*& term, char_data*& next)
{ {
char* sgr_49; char* sgr_49;
char* op = F_orig_pair.cap; char* op = F_orig_pair.cap;
if ( op && strncmp (op, CSI "39;49;25m", 11) == 0 ) if ( op && strncmp (op, CSI "39;49;25m", 11) == 0 )
sgr_49 = const_cast<char*>(CSI "49;25m"); sgr_49 = const_cast<char*>(CSI "49;25m");
else else
sgr_49 = const_cast<char*>(CSI "49m"); sgr_49 = const_cast<char*>(CSI "49m");
append_sequence (sgr_49); append_sequence (sgr_49);
term->bg_color = Default; term->bg_color = Default;
} }
@ -238,6 +241,7 @@ void FOptiAttr::change_color (char_data*& term, char_data*& next)
if ( fake_reverse ) if ( fake_reverse )
{ {
std::swap (fg, bg); std::swap (fg, bg);
if ( fg == Default || bg == Default ) if ( fg == Default || bg == Default )
setTermDefaultColor(term); setTermDefaultColor(term);
} }
@ -257,9 +261,11 @@ void FOptiAttr::change_color (char_data*& term, char_data*& next)
if ( ansi_fg != Default ) if ( ansi_fg != Default )
{ {
color_str = tparm(AF, ansi_fg); color_str = tparm(AF, ansi_fg);
if ( color_str ) if ( color_str )
append_sequence (color_str); append_sequence (color_str);
} }
if ( ansi_bg != Default ) if ( ansi_bg != Default )
{ {
color_str = tparm(AB, ansi_bg); color_str = tparm(AB, ansi_bg);
@ -352,15 +358,20 @@ bool FOptiAttr::caused_reset_attributes (char*& cap, uChar test)
{ {
if ( (test & test_ansi_reset) && strncmp (cap, CSI "m", 3) == 0 ) if ( (test & test_ansi_reset) && strncmp (cap, CSI "m", 3) == 0 )
return true; return true;
if ( (test & test_adm3_reset) && strncmp (cap, ESC "G0", 3) == 0 ) if ( (test & test_adm3_reset) && strncmp (cap, ESC "G0", 3) == 0 )
return true; return true;
if ( (test & same_like_ue) && ue && strcmp (cap, ue) == 0 ) if ( (test & same_like_ue) && ue && strcmp (cap, ue) == 0 )
return true; return true;
if ( (test & same_like_se) && se && strcmp (cap, se) == 0 ) if ( (test & same_like_se) && se && strcmp (cap, se) == 0 )
return true; return true;
if ( (test & same_like_me) && me && strcmp (cap, me) == 0 ) if ( (test & same_like_me) && me && strcmp (cap, me) == 0 )
return true; return true;
} }
return false; return false;
} }
@ -460,6 +471,7 @@ inline bool FOptiAttr::unsetTermBold (char_data*& term)
term->bold = false; term->bold = false;
term->dim = false; term->dim = false;
} }
return true; return true;
} }
else else
@ -488,6 +500,7 @@ inline bool FOptiAttr::unsetTermDim (char_data*& term)
term->bold = false; term->bold = false;
term->dim = false; term->dim = false;
} }
return true; return true;
} }
else else
@ -512,6 +525,7 @@ inline bool FOptiAttr::unsetTermItalic (char_data*& term)
reset(term); reset(term);
else else
term->italic = false; term->italic = false;
return true; return true;
} }
else else
@ -540,6 +554,7 @@ inline bool FOptiAttr::unsetTermUnderline (char_data*& term)
term->underline = false; term->underline = false;
term->dbl_underline = false; term->dbl_underline = false;
} }
return true; return true;
} }
else else
@ -564,6 +579,7 @@ inline bool FOptiAttr::unsetTermBlink (char_data*& term)
reset(term); reset(term);
else else
term->blink = false; term->blink = false;
return true; return true;
} }
else else
@ -588,6 +604,7 @@ inline bool FOptiAttr::unsetTermReverse (char_data*& term)
reset(term); reset(term);
else else
term->reverse = false; term->reverse = false;
return true; return true;
} }
else else
@ -612,6 +629,7 @@ inline bool FOptiAttr::unsetTermStandout (char_data*& term)
reset(term); reset(term);
else else
term->standout = false; term->standout = false;
return true; return true;
} }
else else
@ -636,6 +654,7 @@ inline bool FOptiAttr::unsetTermInvisible (char_data*& term)
reset(term); reset(term);
else else
term->invisible = false; term->invisible = false;
return true; return true;
} }
else else
@ -660,6 +679,7 @@ inline bool FOptiAttr::unsetTermProtected (char_data*& term)
reset(term); reset(term);
else else
term->protect = false; term->protect = false;
return true; return true;
} }
else else
@ -684,6 +704,7 @@ inline bool FOptiAttr::unsetTermCrossedOut (char_data*& term)
reset(term); reset(term);
else else
term->crossed_out = false; term->crossed_out = false;
return true; return true;
} }
else else
@ -712,6 +733,7 @@ inline bool FOptiAttr::unsetTermDoubleUnderline (char_data*& term)
term->underline = false; term->underline = false;
term->dbl_underline = false; term->dbl_underline = false;
} }
return true; return true;
} }
else else
@ -1289,6 +1311,7 @@ char* FOptiAttr::change_attribute (char_data*& term, char_data*& next)
{ {
if ( off.pc_charset ) if ( off.pc_charset )
unsetTermPCcharset(term); unsetTermPCcharset(term);
if ( off.alt_charset ) if ( off.alt_charset )
unsetTermAltCharset(term); unsetTermAltCharset(term);
@ -1300,28 +1323,39 @@ char* FOptiAttr::change_attribute (char_data*& term, char_data*& next)
{ {
if ( off.bold ) if ( off.bold )
unsetTermBold(term); unsetTermBold(term);
if ( off.dim ) if ( off.dim )
unsetTermDim(term); unsetTermDim(term);
if ( off.italic ) if ( off.italic )
unsetTermItalic(term); unsetTermItalic(term);
if ( off.underline ) if ( off.underline )
unsetTermUnderline(term); unsetTermUnderline(term);
if ( off.blink ) if ( off.blink )
unsetTermBlink(term); unsetTermBlink(term);
if ( off.reverse ) if ( off.reverse )
unsetTermReverse(term); unsetTermReverse(term);
if ( off.standout ) if ( off.standout )
unsetTermStandout(term); unsetTermStandout(term);
if ( off.invisible ) if ( off.invisible )
unsetTermInvisible(term); unsetTermInvisible(term);
if ( off.protect ) if ( off.protect )
unsetTermProtected(term); unsetTermProtected(term);
if ( off.crossed_out ) if ( off.crossed_out )
unsetTermCrossedOut(term); unsetTermCrossedOut(term);
if ( off.dbl_underline ) if ( off.dbl_underline )
unsetTermDoubleUnderline(term); unsetTermDoubleUnderline(term);
} }
} }
if ( colorChange(term, next) ) if ( colorChange(term, next) )
change_color (term, next); change_color (term, next);
} }
@ -1341,24 +1375,31 @@ char* FOptiAttr::change_attribute (char_data*& term, char_data*& next)
, next->invisible , next->invisible
, next->protect , next->protect
, next->alt_charset ); , next->alt_charset );
if ( next->italic ) if ( next->italic )
setTermItalic(term); setTermItalic(term);
if ( next->crossed_out ) if ( next->crossed_out )
setTermCrossedOut(term); setTermCrossedOut(term);
if ( next->dbl_underline ) if ( next->dbl_underline )
setTermDoubleUnderline(term); setTermDoubleUnderline(term);
if ( next->pc_charset ) if ( next->pc_charset )
setTermPCcharset(term); setTermPCcharset(term);
if ( colorChange(term, next) ) if ( colorChange(term, next) )
{ {
change_color (term, next); change_color (term, next);
if ( cygwin_terminal ) if ( cygwin_terminal )
{ {
if ( next->bold ) if ( next->bold )
setTermBold(term); setTermBold(term);
if ( next->reverse ) if ( next->reverse )
setTermReverse(term); setTermReverse(term);
if ( next->standout ) if ( next->standout )
setTermStandout(term); setTermStandout(term);
} }
@ -1368,28 +1409,40 @@ char* FOptiAttr::change_attribute (char_data*& term, char_data*& next)
{ {
if ( off.pc_charset ) if ( off.pc_charset )
unsetTermPCcharset(term); unsetTermPCcharset(term);
if ( off.alt_charset ) if ( off.alt_charset )
unsetTermAltCharset(term); unsetTermAltCharset(term);
if ( off.bold ) if ( off.bold )
unsetTermBold(term); unsetTermBold(term);
if ( off.dim ) if ( off.dim )
unsetTermDim(term); unsetTermDim(term);
if ( off.italic ) if ( off.italic )
unsetTermItalic(term); unsetTermItalic(term);
if ( off.underline ) if ( off.underline )
unsetTermUnderline(term); unsetTermUnderline(term);
if ( off.blink ) if ( off.blink )
unsetTermBlink(term); unsetTermBlink(term);
if ( off.reverse ) if ( off.reverse )
unsetTermReverse(term); unsetTermReverse(term);
if ( off.standout ) if ( off.standout )
unsetTermStandout(term); unsetTermStandout(term);
if ( off.invisible ) if ( off.invisible )
unsetTermInvisible(term); unsetTermInvisible(term);
if ( off.protect ) if ( off.protect )
unsetTermProtected(term); unsetTermProtected(term);
if ( off.crossed_out ) if ( off.crossed_out )
unsetTermCrossedOut(term); unsetTermCrossedOut(term);
if ( off.dbl_underline ) if ( off.dbl_underline )
unsetTermDoubleUnderline(term); unsetTermDoubleUnderline(term);
@ -1402,30 +1455,43 @@ char* FOptiAttr::change_attribute (char_data*& term, char_data*& next)
change_color (term, next); change_color (term, next);
detectSwitchOn (term, next); detectSwitchOn (term, next);
if ( on.pc_charset ) if ( on.pc_charset )
setTermPCcharset(term); setTermPCcharset(term);
if ( on.alt_charset ) if ( on.alt_charset )
setTermAltCharset(term); setTermAltCharset(term);
if ( on.bold ) if ( on.bold )
setTermBold(term); setTermBold(term);
if ( on.dim ) if ( on.dim )
setTermDim(term); setTermDim(term);
if ( on.italic ) if ( on.italic )
setTermItalic(term); setTermItalic(term);
if ( on.underline ) if ( on.underline )
setTermUnderline(term); setTermUnderline(term);
if ( on.blink ) if ( on.blink )
setTermBlink(term); setTermBlink(term);
if ( on.reverse ) if ( on.reverse )
setTermReverse(term); setTermReverse(term);
if ( on.standout ) if ( on.standout )
setTermStandout(term); setTermStandout(term);
if ( on.invisible ) if ( on.invisible )
setTermInvisible(term); setTermInvisible(term);
if ( on.protect ) if ( on.protect )
setTermProtected(term); setTermProtected(term);
if ( on.crossed_out ) if ( on.crossed_out )
setTermCrossedOut(term); setTermCrossedOut(term);
if ( on.dbl_underline ) if ( on.dbl_underline )
setTermDoubleUnderline(term); setTermDoubleUnderline(term);
} }

View File

@ -54,6 +54,7 @@ void FOptiMove::calculateCharDuration()
const int baudbyte = 9; // = 7 bit + 1 parity + 1 stop const int baudbyte = 9; // = 7 bit + 1 parity + 1 stop
char_duration = (baudbyte * 1000 * 10) char_duration = (baudbyte * 1000 * 10)
/ (baudrate > 0 ? baudrate : 9600); // milliseconds / (baudrate > 0 ? baudrate : 9600); // milliseconds
if ( char_duration <= 0 ) if ( char_duration <= 0 )
char_duration = 1; char_duration = 1;
} }
@ -89,11 +90,13 @@ int FOptiMove::cap_duration (char*& cap, int affcnt)
else if ( *p == '.' && *++p != '>' && isdigit(uChar(*p)) ) else if ( *p == '.' && *++p != '>' && isdigit(uChar(*p)) )
num += float((*p - '0') / 10.0); num += float((*p - '0') / 10.0);
} }
ms += num * 10; ms += num * 10;
} }
else else
ms += float(char_duration); ms += float(char_duration);
} }
return int(ms); return int(ms);
} }
else else
@ -324,9 +327,11 @@ int FOptiMove::repeated_append (capability& o, int count, char* dst)
if ( (dst_len + uInt(count) * src_len) < sizeof(move_buf)-1 ) if ( (dst_len + uInt(count) * src_len) < sizeof(move_buf)-1 )
{ {
total += count * o.duration; total += count * o.duration;
if ( dst ) if ( dst )
{ {
dst += dst_len; dst += dst_len;
while ( count-- > 0 ) while ( count-- > 0 )
{ {
strcpy (dst, o.cap); strcpy (dst, o.cap);
@ -360,6 +365,7 @@ int FOptiMove::relative_move ( char*& move
{ {
if ( move ) if ( move )
strcpy (move, tparm(F_row_address.cap, to_y)); strcpy (move, tparm(F_row_address.cap, to_y));
vtime = F_row_address.duration; vtime = F_row_address.duration;
} }
@ -371,6 +377,7 @@ int FOptiMove::relative_move ( char*& move
{ {
if ( move ) if ( move )
strcpy (move, tparm(F_parm_down_cursor.cap, num)); strcpy (move, tparm(F_parm_down_cursor.cap, num));
vtime = F_parm_down_cursor.duration; vtime = F_parm_down_cursor.duration;
} }
@ -378,6 +385,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 = repeated_append (F_cursor_down, num, move);
} }
} }
@ -389,6 +397,7 @@ int FOptiMove::relative_move ( char*& move
{ {
if ( move ) if ( move )
strcpy (move, tparm(F_parm_up_cursor.cap, num)); strcpy (move, tparm(F_parm_up_cursor.cap, num));
vtime = F_parm_up_cursor.duration; vtime = F_parm_up_cursor.duration;
} }
@ -396,6 +405,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 = repeated_append (F_cursor_up, num, move);
} }
} }
@ -446,11 +456,15 @@ 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 += repeated_append (F_tab, 1, str);
if ( htime_r >= LONG_DURATION ) if ( htime_r >= LONG_DURATION )
break; break;
pos = tab_pos; pos = tab_pos;
} }
num = to_x - pos; num = to_x - pos;
} }
@ -461,6 +475,7 @@ int FOptiMove::relative_move ( char*& move
strcpy (hmove, str); strcpy (hmove, str);
htime = htime_r; htime = htime_r;
} }
} }
} }
else // to_x < from_x else // to_x < from_x
@ -484,17 +499,22 @@ int FOptiMove::relative_move ( char*& move
if ( tabstop > 0 && F_back_tab.cap ) if ( tabstop > 0 && F_back_tab.cap )
{ {
int pos = from_x; int pos = from_x;
while ( true ) while ( true )
{ {
int tab_pos = ( pos > 0 ) ? ((pos-1)/tabstop)*tabstop : -1; int tab_pos = ( pos > 0 ) ? ((pos-1)/tabstop)*tabstop : -1;
if ( tab_pos < to_x ) if ( tab_pos < to_x )
break; break;
htime_l += repeated_append (F_back_tab, 1, str); htime_l += repeated_append (F_back_tab, 1, str);
if ( htime_l >= LONG_DURATION ) if ( htime_l >= LONG_DURATION )
break; break;
pos = tab_pos; pos = tab_pos;
} }
num = pos - to_x; num = pos - to_x;
} }
@ -505,6 +525,7 @@ int FOptiMove::relative_move ( char*& move
strcpy (hmove, str); strcpy (hmove, str);
htime = htime_l; htime = htime_l;
} }
} }
} }
@ -572,6 +593,7 @@ char* FOptiMove::cursor_move (int xold, int yold, int xnew, int ynew)
if ( xold >= 0 && yold >= 0 ) if ( xold >= 0 && yold >= 0 )
{ {
new_time = relative_move (null_ptr, xold, yold, xnew, ynew); new_time = relative_move (null_ptr, xold, yold, xnew, ynew);
if ( new_time < LONG_DURATION && new_time < move_time ) if ( new_time < LONG_DURATION && new_time < move_time )
{ {
method = 1; method = 1;
@ -583,6 +605,7 @@ char* FOptiMove::cursor_move (int xold, int yold, int xnew, int ynew)
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 = relative_move (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 )
{ {
@ -595,6 +618,7 @@ char* FOptiMove::cursor_move (int xold, int yold, int xnew, int ynew)
if ( F_cursor_home.cap ) if ( F_cursor_home.cap )
{ {
new_time = relative_move (null_ptr, 0, 0, xnew, ynew); new_time = relative_move (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 )
{ {
@ -607,6 +631,7 @@ char* FOptiMove::cursor_move (int xold, int yold, int xnew, int ynew)
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 = relative_move (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 )
{ {
@ -622,6 +647,7 @@ char* FOptiMove::cursor_move (int xold, int yold, int xnew, int ynew)
&& F_cursor_left.cap ) && F_cursor_left.cap )
{ {
new_time = relative_move (null_ptr, screen_width-1, yold-1, xnew, ynew); new_time = relative_move (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
&& F_carriage_return.duration && F_carriage_return.duration
@ -664,10 +690,12 @@ char* FOptiMove::cursor_move (int xold, int yold, int xnew, int ynew)
case 5: case 5:
move_buf[0] = '\0'; move_buf[0] = '\0';
if ( xold >= 0 ) if ( xold >= 0 )
strncat ( move_ptr strncat ( move_ptr
, F_carriage_return.cap , F_carriage_return.cap
, sizeof(move_buf) - strlen(move_ptr) - 1 ); , sizeof(move_buf) - strlen(move_ptr) - 1 );
strncat ( move_ptr strncat ( move_ptr
, F_cursor_left.cap , F_cursor_left.cap
, sizeof(move_buf) - strlen(move_ptr) - 1 ); , sizeof(move_buf) - strlen(move_ptr) - 1 );
@ -679,6 +707,7 @@ char* FOptiMove::cursor_move (int xold, int yold, int xnew, int ynew)
break; break;
} }
} }
if ( move_time < LONG_DURATION ) if ( move_time < LONG_DURATION )
return move_buf; return move_buf;
else else

View File

@ -27,13 +27,17 @@ void FProgressbar::drawPercentage()
{ {
setColor ( getParentWidget()->getForegroundColor() setColor ( getParentWidget()->getForegroundColor()
, getParentWidget()->getBackgroundColor() ); , getParentWidget()->getBackgroundColor() );
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
gotoxy (xpos+xmin+width-5, ypos+ymin-2); gotoxy (xpos+xmin+width-5, ypos+ymin-2);
if ( percentage < 0 || percentage > 100 ) if ( percentage < 0 || percentage > 100 )
print ("--- %"); print ("--- %");
else else
printf ("%3d %%", percentage); printf ("%3d %%", percentage);
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
} }
@ -43,8 +47,8 @@ void FProgressbar::drawBar()
{ {
int i = 1; int i = 1;
float length = float(BarLength*percentage)/100; float length = float(BarLength*percentage)/100;
gotoxy (xpos+xmin-1, ypos+ymin-1); gotoxy (xpos+xmin-1, ypos+ymin-1);
if ( isMonochron() ) if ( isMonochron() )
{ {
if ( round(length) >= 1) if ( round(length) >= 1)
@ -60,6 +64,7 @@ void FProgressbar::drawBar()
{ {
setColor ( wc.progressbar_bg setColor ( wc.progressbar_bg
, wc.progressbar_fg ); , wc.progressbar_fg );
if ( round(length) >= 1) if ( round(length) >= 1)
print (' '); print (' ');
else else
@ -86,10 +91,13 @@ void FProgressbar::drawBar()
setColor ( wc.progressbar_bg setColor ( wc.progressbar_bg
, wc.progressbar_fg ); , wc.progressbar_fg );
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
for (; i < trunc(length); i++) for (; i < trunc(length); i++)
print (' '); print (' ');
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
@ -113,10 +121,12 @@ void FProgressbar::drawBar()
setColor (wc.progressbar_fg, wc.progressbar_bg); setColor (wc.progressbar_fg, wc.progressbar_bg);
print (fc::LeftHalfBlock); // ▌ print (fc::LeftHalfBlock); // ▌
} }
i++; i++;
} }
setColor (wc.progressbar_fg, wc.progressbar_bg); setColor (wc.progressbar_fg, wc.progressbar_bg);
if ( getMaxColor() < 16 ) if ( getMaxColor() < 16 )
{ {
for (; i < BarLength; i++) for (; i < BarLength; i++)
@ -127,6 +137,7 @@ void FProgressbar::drawBar()
for (; i < BarLength; i++) for (; i < BarLength; i++)
print (' '); print (' ');
} }
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
@ -145,6 +156,7 @@ void FProgressbar::draw()
if ( (flags & fc::shadow) != 0 ) if ( (flags & fc::shadow) != 0 )
drawShadow (); drawShadow ();
setUpdateVTerm(true); setUpdateVTerm(true);
flush_out(); flush_out();
} }
@ -159,11 +171,9 @@ void FProgressbar::hide()
char* blank; char* blank;
FWidget::hide(); FWidget::hide();
fg = getParentWidget()->getForegroundColor(); fg = getParentWidget()->getForegroundColor();
bg = getParentWidget()->getBackgroundColor(); bg = getParentWidget()->getBackgroundColor();
setColor (fg, bg); setColor (fg, bg);
s = hasShadow() ? 1 : 0; s = hasShadow() ? 1 : 0;
size = width + s; size = width + s;
blank = new char[size+1]; blank = new char[size+1];
@ -175,8 +185,8 @@ void FProgressbar::hide()
gotoxy (xpos+xmin-1, ypos+ymin-1+y); gotoxy (xpos+xmin-1, ypos+ymin-1+y);
print (blank); print (blank);
} }
delete[] blank;
delete[] blank;
gotoxy (xpos+xmin+width-5, ypos+ymin-2); gotoxy (xpos+xmin+width-5, ypos+ymin-2);
print (" "); // hide percentage print (" "); // hide percentage
} }
@ -195,11 +205,13 @@ void FProgressbar::setPercentage (int percentage_value)
percentage = percentage_value; percentage = percentage_value;
setUpdateVTerm(false); setUpdateVTerm(false);
if ( isVisible() ) if ( isVisible() )
{ {
drawPercentage(); drawPercentage();
drawBar(); drawBar();
} }
setUpdateVTerm(true); setUpdateVTerm(true);
updateTerminal(); updateTerminal();
} }
@ -209,11 +221,13 @@ void FProgressbar::reset()
{ {
setUpdateVTerm(false); setUpdateVTerm(false);
percentage = -1; percentage = -1;
if ( isVisible() ) if ( isVisible() )
{ {
drawPercentage(); drawPercentage();
drawBar(); drawBar();
} }
setUpdateVTerm(true); setUpdateVTerm(true);
updateTerminal(); updateTerminal();
} }
@ -234,6 +248,7 @@ bool FProgressbar::setEnable (bool on)
flags |= fc::active; flags |= fc::active;
else else
flags &= ~fc::active; flags &= ~fc::active;
return on; return on;
} }
@ -246,5 +261,6 @@ bool FProgressbar::setShadow (bool on)
flags |= fc::shadow; flags |= fc::shadow;
else else
flags &= ~fc::shadow; flags &= ~fc::shadow;
return on; return on;
} }

View File

@ -45,7 +45,6 @@ void FRadioButton::draw()
drawRadioButton(); drawRadioButton();
drawLabel(); drawLabel();
setUpdateVTerm(true); setUpdateVTerm(true);
FToggleButton::draw(); FToggleButton::draw();
} }
@ -65,6 +64,7 @@ void FRadioButton::drawRadioButton()
else else
setReverse(true); setReverse(true);
} }
if ( checked ) if ( checked )
{ {
if ( isNewFont() ) if ( isNewFont() )
@ -87,7 +87,7 @@ void FRadioButton::drawRadioButton()
print (')'); print (')');
} }
} }
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
} }

View File

@ -54,6 +54,7 @@ void FRadioMenuItem::init (FWidget* parent)
if ( isMenu(parent) ) // Parent is menu if ( isMenu(parent) ) // Parent is menu
{ {
FMenu* menu_ptr = dynamic_cast<FMenu*>(parent); FMenu* menu_ptr = dynamic_cast<FMenu*>(parent);
if ( menu_ptr ) if ( menu_ptr )
menu_ptr->has_checkable_items = true; menu_ptr->has_checkable_items = true;

View File

@ -91,6 +91,7 @@ void FScrollbar::draw()
int FScrollbar::getClickedScrollType (int x, int y) int FScrollbar::getClickedScrollType (int x, int y)
{ {
int stype; int stype;
if ( bar_orientation == fc::vertical ) if ( bar_orientation == fc::vertical )
{ {
if ( y == 1 ) if ( y == 1 )
@ -157,6 +158,7 @@ int FScrollbar::getClickedScrollType (int x, int y)
stype = FScrollbar::noScroll; stype = FScrollbar::noScroll;
} }
} }
return stype; return stype;
} }
@ -164,6 +166,7 @@ int FScrollbar::getClickedScrollType (int x, int y)
void FScrollbar::processMiddleButton (int x, int y) void FScrollbar::processMiddleButton (int x, int y)
{ {
int new_val; int new_val;
if ( bar_orientation == fc::vertical ) if ( bar_orientation == fc::vertical )
{ {
if ( y >1 && y < height ) if ( y >1 && y < height )
@ -177,6 +180,7 @@ void FScrollbar::processMiddleButton (int x, int y)
else // horizontal else // horizontal
{ {
int nf = isNewFont() ? 1 : 0; int nf = isNewFont() ? 1 : 0;
if ( x > 1+nf && x < width-nf ) if ( x > 1+nf && x < width-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-(SliderLength/2))
@ -185,6 +189,7 @@ void FScrollbar::processMiddleButton (int x, int y)
else else
return; return;
} }
if ( new_val != val ) if ( new_val != val )
{ {
setValue(new_val); setValue(new_val);
@ -313,11 +318,11 @@ void FScrollbar::onMouseMove (FMouseEvent* ev)
if ( scrollType == FScrollbar::scrollJump ) if ( scrollType == 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 - SliderClickPos;
SliderClickPos = mouse_y; SliderClickPos = mouse_y;
new_val = int( round ( float((max-min) * (SliderPos + dy)) new_val = int( round ( float((max-min) * (SliderPos + dy))
/ float(BarLength-SliderLength) ) ); / float(BarLength-SliderLength) ) );
} }
@ -325,10 +330,10 @@ void FScrollbar::onMouseMove (FMouseEvent* ev)
{ {
int dx = mouse_x - SliderClickPos; int dx = mouse_x - SliderClickPos;
SliderClickPos = mouse_x; SliderClickPos = mouse_x;
new_val = int( round ( float((max-min) * (SliderPos + dx)) new_val = int( round ( float((max-min) * (SliderPos + dx))
/ float(BarLength-SliderLength) ) ); / float(BarLength-SliderLength) ) );
} }
if ( new_val != val ) if ( new_val != val )
{ {
setValue(new_val); setValue(new_val);
@ -449,6 +454,7 @@ void FScrollbar::setSteps (float st)
steps = 1; steps = 1;
else else
steps = st; steps = st;
if ( pageSize == 0 ) if ( pageSize == 0 )
pageSize = int(float(max)/steps); pageSize = int(float(max)/steps);
} }
@ -475,6 +481,7 @@ void FScrollbar::calculateSliderValues()
BarLength = length - 4; BarLength = length - 4;
else else
BarLength = length - 2; BarLength = length - 2;
SliderLength = int(float(BarLength) / steps); SliderLength = int(float(BarLength) / steps);
if ( SliderLength < 1 ) if ( SliderLength < 1 )
@ -487,6 +494,7 @@ void FScrollbar::calculateSliderValues()
SliderPos = 0; SliderPos = 0;
return; return;
} }
if ( val == max ) if ( val == max )
{ {
SliderPos = BarLength - SliderLength; SliderPos = BarLength - SliderLength;
@ -517,6 +525,7 @@ void FScrollbar::setOrientation (int o)
{ {
height = 1; height = 1;
width = length; width = length;
if ( isNewFont() ) if ( isNewFont() )
nf = 2; nf = 2;
} }
@ -541,6 +550,7 @@ void FScrollbar::setGeometry (int x, int y, int w, int h, bool adjust)
{ {
height = 1; height = 1;
width = length; width = length;
if ( isNewFont() ) if ( isNewFont() )
nf = 2; nf = 2;
} }
@ -558,19 +568,25 @@ void FScrollbar::drawBar()
if ( bar_orientation == fc::vertical ) if ( bar_orientation == fc::vertical )
{ {
setColor (wc.scrollbar_fg, wc.scrollbar_bg); setColor (wc.scrollbar_fg, wc.scrollbar_bg);
for (z=1; z <= SliderPos; z++) for (z=1; z <= SliderPos; z++)
{ {
gotoxy (xpos+xmin-1, ypos+ymin-1+z); gotoxy (xpos+xmin-1, ypos+ymin-1+z);
if ( isNewFont() ) if ( isNewFont() )
print (fc::NF_border_line_left); // ⎸ print (fc::NF_border_line_left); // ⎸
if ( isMonochron() || max_color < 16 ) if ( isMonochron() || max_color < 16 )
print (fc::MediumShade); // ▒ print (fc::MediumShade); // ▒
else else
print (' '); print (' ');
} }
setColor (wc.scrollbar_bg, wc.scrollbar_fg); setColor (wc.scrollbar_bg, wc.scrollbar_fg);
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
for (z=1; z <= SliderLength; z++) for (z=1; z <= SliderLength; z++)
{ {
gotoxy (xpos+xmin-1, ypos+ymin-1+SliderPos+z); gotoxy (xpos+xmin-1, ypos+ymin-1+SliderPos+z);
@ -578,14 +594,19 @@ void FScrollbar::drawBar()
print (' '); print (' ');
print (' '); print (' ');
} }
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
setColor (wc.scrollbar_fg, wc.scrollbar_bg); setColor (wc.scrollbar_fg, wc.scrollbar_bg);
for (z=SliderPos+SliderLength+1; z <= BarLength; z++) for (z=SliderPos+SliderLength+1; z <= BarLength; z++)
{ {
gotoxy (xpos+xmin-1, ypos+ymin-1+z); gotoxy (xpos+xmin-1, ypos+ymin-1+z);
if ( isNewFont() ) if ( isNewFont() )
print (fc::NF_border_line_left); // ⎸ print (fc::NF_border_line_left); // ⎸
if ( isMonochron() || max_color < 16 ) if ( isMonochron() || max_color < 16 )
print (fc::MediumShade); print (fc::MediumShade);
else else
@ -595,8 +616,8 @@ void FScrollbar::drawBar()
else // horizontal else // horizontal
{ {
setColor (wc.scrollbar_fg, wc.scrollbar_bg); setColor (wc.scrollbar_fg, wc.scrollbar_bg);
z = 0; z = 0;
if ( isNewFont() ) if ( isNewFont() )
gotoxy (xpos+xmin+1+z, ypos+ymin-1); gotoxy (xpos+xmin+1+z, ypos+ymin-1);
else else
@ -611,17 +632,23 @@ void FScrollbar::drawBar()
else else
print (' '); print (' ');
} }
setColor (wc.scrollbar_bg, wc.scrollbar_fg); setColor (wc.scrollbar_bg, wc.scrollbar_fg);
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
z = 0; z = 0;
for (; z < SliderLength; z++) for (; z < SliderLength; 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 = SliderPos + SliderLength + 1;
for (; z <= BarLength; z++) for (; z <= BarLength; z++)
{ {
if ( isNewFont() ) if ( isNewFont() )
@ -632,6 +659,7 @@ void FScrollbar::drawBar()
print (' '); print (' ');
} }
} }
currentSliderPos = SliderPos; currentSliderPos = SliderPos;
if ( isMonochron() ) if ( isMonochron() )
@ -680,7 +708,9 @@ void FScrollbar::drawButtons()
print ('^'); print ('^');
else else
print (fc::BlackUpPointingTriangle); // ▲ print (fc::BlackUpPointingTriangle); // ▲
gotoxy (xpos+xmin-1, ypos+ymin+length-2); gotoxy (xpos+xmin-1, ypos+ymin+length-2);
if ( isCygwinTerminal() ) if ( isCygwinTerminal() )
print ('v'); print ('v');
else else
@ -693,6 +723,7 @@ void FScrollbar::drawButtons()
print (fc::BlackRightPointingPointer); // ► print (fc::BlackRightPointingPointer); // ►
} }
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
} }

View File

@ -62,6 +62,7 @@ FStatusKey::~FStatusKey() // destructor
{ {
if ( statusbar() ) if ( statusbar() )
statusbar()->remove(this); statusbar()->remove(this);
delAccelerator(); delAccelerator();
} }
@ -154,10 +155,13 @@ FStatusBar::~FStatusBar()
{ {
if ( vstatusbar->changes != 0 ) if ( vstatusbar->changes != 0 )
delete[] vstatusbar->changes; delete[] vstatusbar->changes;
if ( vstatusbar->text != 0 ) if ( vstatusbar->text != 0 )
delete[] vstatusbar->text; delete[] vstatusbar->text;
delete vstatusbar; delete vstatusbar;
} }
vstatusbar = 0; vstatusbar = 0;
// delete all keys // delete all keys
@ -213,7 +217,6 @@ void FStatusBar::drawKeys()
{ {
std::vector<FStatusKey*>::const_iterator iter, end; std::vector<FStatusKey*>::const_iterator iter, end;
int screenWidth, lastLine; int screenWidth, lastLine;
x = 1; x = 1;
screenWidth = getColumnNumber(); screenWidth = getColumnNumber();
lastLine = getLineNumber(); lastLine = getLineNumber();
@ -238,25 +241,27 @@ void FStatusBar::drawKeys()
while ( iter != end ) while ( iter != end )
{ {
int kname_len = int(getKeyName((*iter)->getKey()).getLength()); int kname_len = int(getKeyName((*iter)->getKey()).getLength());
if ( x+kname_len+2 < screenWidth ) if ( x+kname_len+2 < screenWidth )
{ {
if ( (*iter)->isActivated() || (*iter)->hasMouseFocus() ) if ( (*iter)->isActivated() || (*iter)->hasMouseFocus() )
{ {
int txt_length;
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
setColor ( wc.statusbar_active_hotkey_fg setColor ( wc.statusbar_active_hotkey_fg
, wc.statusbar_active_hotkey_bg ); , wc.statusbar_active_hotkey_bg );
x++; x++;
print (vstatusbar, ' '); print (vstatusbar, ' ');
x += kname_len; x += kname_len;
print (vstatusbar, getKeyName((*iter)->getKey())); print (vstatusbar, getKeyName((*iter)->getKey()));
setColor (wc.statusbar_active_fg, wc.statusbar_active_bg); setColor (wc.statusbar_active_fg, wc.statusbar_active_bg);
x++; x++;
print (vstatusbar, '-'); print (vstatusbar, '-');
txt_length = int((*iter)->getText().getLength());
int txt_length = int((*iter)->getText().getLength());
x += txt_length; x += txt_length;
if ( x <= screenWidth ) if ( x <= screenWidth )
{ {
print (vstatusbar, (*iter)->getText()); print (vstatusbar, (*iter)->getText());
@ -270,6 +275,7 @@ void FStatusBar::drawKeys()
.left(uInt(txt_length+screenWidth-x-1)) ); .left(uInt(txt_length+screenWidth-x-1)) );
print (vstatusbar, ".."); print (vstatusbar, "..");
} }
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
} }
@ -281,16 +287,14 @@ void FStatusBar::drawKeys()
setColor (wc.statusbar_hotkey_fg, wc.statusbar_hotkey_bg); setColor (wc.statusbar_hotkey_fg, wc.statusbar_hotkey_bg);
x++; x++;
print (vstatusbar, ' '); print (vstatusbar, ' ');
x += kname_len; x += kname_len;
print (vstatusbar, getKeyName((*iter)->getKey())); print (vstatusbar, getKeyName((*iter)->getKey()));
setColor (wc.statusbar_fg, wc.statusbar_bg); setColor (wc.statusbar_fg, wc.statusbar_bg);
x++; x++;
print (vstatusbar, '-'); print (vstatusbar, '-');
txt_length = int((*iter)->getText().getLength()); txt_length = int((*iter)->getText().getLength());
x += txt_length; x += txt_length;
if ( x-1 <= screenWidth ) if ( x-1 <= screenWidth )
print (vstatusbar, (*iter)->getText()); print (vstatusbar, (*iter)->getText());
else else
@ -300,6 +304,7 @@ void FStatusBar::drawKeys()
.left(uInt(txt_length+screenWidth-x-1)) ); .left(uInt(txt_length+screenWidth-x-1)) );
print ( vstatusbar, ".." ); print ( vstatusbar, ".." );
} }
if ( iter+1 != keylist.end() if ( iter+1 != keylist.end()
&& ( (*(iter+1))->isActivated() || (*(iter+1))->hasMouseFocus() ) && ( (*(iter+1))->isActivated() || (*(iter+1))->hasMouseFocus() )
&& x + int(getKeyName((*(iter+1))->getKey()).getLength()) + 3 && x + int(getKeyName((*(iter+1))->getKey()).getLength()) + 3
@ -308,9 +313,11 @@ void FStatusBar::drawKeys()
// next element is active // next element is active
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
setColor (wc.statusbar_active_fg, wc.statusbar_active_bg); setColor (wc.statusbar_active_fg, wc.statusbar_active_bg);
x++; x++;
print (vstatusbar, fc::LeftHalfBlock); // ▐ print (vstatusbar, fc::LeftHalfBlock); // ▐
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
} }
@ -326,6 +333,7 @@ void FStatusBar::drawKeys()
else else
{ {
setColor (wc.statusbar_fg, wc.statusbar_bg); setColor (wc.statusbar_fg, wc.statusbar_bg);
for (; x <= screenWidth; x++) for (; x <= screenWidth; x++)
print (vstatusbar, ' '); print (vstatusbar, ' ');
} }
@ -345,9 +353,11 @@ void FStatusBar::onMouseDown (FMouseEvent* ev)
{ {
if ( hasActivatedKey() ) if ( hasActivatedKey() )
return; return;
if ( ev->getButton() != fc::LeftButton ) if ( ev->getButton() != fc::LeftButton )
{ {
mouse_down = false; mouse_down = false;
if ( ! keylist.empty() ) if ( ! keylist.empty() )
{ {
std::vector<FStatusKey*>::const_iterator iter, end; std::vector<FStatusKey*>::const_iterator iter, end;
@ -360,18 +370,20 @@ void FStatusBar::onMouseDown (FMouseEvent* ev)
++iter; ++iter;
} }
} }
redraw(); redraw();
return; return;
} }
if ( mouse_down ) if ( mouse_down )
return; return;
mouse_down = true; mouse_down = true;
if ( ! keylist.empty() ) if ( ! keylist.empty() )
{ {
std::vector<FStatusKey*>::const_iterator iter, end; std::vector<FStatusKey*>::const_iterator iter, end;
int X = 1; int X = 1;
iter = keylist.begin(); iter = keylist.begin();
end = keylist.end(); end = keylist.end();
@ -394,6 +406,7 @@ void FStatusBar::onMouseDown (FMouseEvent* ev)
(*iter)->setMouseFocus(); (*iter)->setMouseFocus();
redraw(); redraw();
} }
X = x2 + 2; X = x2 + 2;
++iter; ++iter;
} }
@ -405,24 +418,24 @@ void FStatusBar::onMouseUp (FMouseEvent* ev)
{ {
if ( hasActivatedKey() ) if ( hasActivatedKey() )
return; return;
if ( ev->getButton() != fc::LeftButton ) if ( ev->getButton() != fc::LeftButton )
return; return;
if ( mouse_down ) if ( mouse_down )
{ {
mouse_down = false; mouse_down = false;
if ( ! keylist.empty() ) if ( ! keylist.empty() )
{ {
std::vector<FStatusKey*>::const_iterator iter, end; std::vector<FStatusKey*>::const_iterator iter, end;
int X = 1; int X = 1;
iter = keylist.begin(); iter = keylist.begin();
end = keylist.end(); end = keylist.end();
while ( iter != end ) while ( iter != end )
{ {
int x1, x2, kname_len, txt_length; int x1, x2, kname_len, txt_length;
x1 = X; x1 = X;
kname_len = int(getKeyName((*iter)->getKey()).getLength()); kname_len = int(getKeyName((*iter)->getKey()).getLength());
txt_length = int((*iter)->getText().getLength()); txt_length = int((*iter)->getText().getLength());
@ -434,12 +447,15 @@ void FStatusBar::onMouseUp (FMouseEvent* ev)
(*iter)->unsetMouseFocus(); (*iter)->unsetMouseFocus();
mouse_x = ev->getX(); mouse_x = ev->getX();
mouse_y = ev->getY(); mouse_y = ev->getY();
if ( mouse_x >= x1 && mouse_x <= x2 && mouse_y == 1 ) if ( mouse_x >= x1 && mouse_x <= x2 && mouse_y == 1 )
(*iter)->setActive(); (*iter)->setActive();
// unset after get back from callback // unset after get back from callback
(*iter)->unsetActive(); (*iter)->unsetActive();
redraw(); redraw();
} }
X = x2 + 2; X = x2 + 2;
++iter; ++iter;
} }
@ -452,6 +468,7 @@ void FStatusBar::onMouseMove (FMouseEvent* ev)
{ {
if ( hasActivatedKey() ) if ( hasActivatedKey() )
return; return;
if ( ev->getButton() != fc::LeftButton ) if ( ev->getButton() != fc::LeftButton )
return; return;
@ -460,21 +477,19 @@ void FStatusBar::onMouseMove (FMouseEvent* ev)
std::vector<FStatusKey*>::const_iterator iter, end; std::vector<FStatusKey*>::const_iterator iter, end;
bool focus_changed = false; bool focus_changed = false;
int X=1; int X=1;
iter = keylist.begin(); iter = keylist.begin();
end = keylist.end(); end = keylist.end();
while ( iter != end ) while ( iter != end )
{ {
int x1, x2, mouse_x, mouse_y, kname_len, txt_length; int x1, x2, mouse_x, mouse_y, kname_len, txt_length;
x1 = X; x1 = X;
kname_len = int(getKeyName((*iter)->getKey()).getLength()); kname_len = int(getKeyName((*iter)->getKey()).getLength());
txt_length = int((*iter)->getText().getLength()); txt_length = int((*iter)->getText().getLength());
x2 = x1 + kname_len + txt_length + 1; x2 = x1 + kname_len + txt_length + 1;
mouse_x = ev->getX(); mouse_x = ev->getX();
mouse_y = ev->getY(); mouse_y = ev->getY();
if ( mouse_x >= x1 if ( mouse_x >= x1
&& mouse_x <= x2 && mouse_x <= x2
&& mouse_y == 1 ) && mouse_y == 1 )
@ -493,9 +508,11 @@ void FStatusBar::onMouseMove (FMouseEvent* ev)
focus_changed = true; focus_changed = true;
} }
} }
X = x2 + 2; X = x2 + 2;
++iter; ++iter;
} }
if ( focus_changed ) if ( focus_changed )
redraw(); redraw();
} }
@ -509,17 +526,14 @@ void FStatusBar::hide()
char* blank; char* blank;
FWindow::hide(); FWindow::hide();
fg = wc.term_fg; fg = wc.term_fg;
bg = wc.term_bg; bg = wc.term_bg;
setColor (fg, bg); setColor (fg, bg);
lastLine = getLineNumber(); lastLine = getLineNumber();
screenWidth = getColumnNumber(); screenWidth = getColumnNumber();
blank = new char[screenWidth+1]; blank = new char[screenWidth+1];
memset(blank, ' ', uLong(screenWidth)); memset(blank, ' ', uLong(screenWidth));
blank[screenWidth] = '\0'; blank[screenWidth] = '\0';
gotoxy (1, lastLine); gotoxy (1, lastLine);
print (vstatusbar, blank); print (vstatusbar, blank);
delete[] blank; delete[] blank;
@ -531,6 +545,7 @@ void FStatusBar::setGeometry (int xx, int yy, int ww, int hh, bool adjust)
int old_width = width; int old_width = width;
int old_height = height; int old_height = height;
FWidget::setGeometry (xx, yy, ww, hh, adjust); FWidget::setGeometry (xx, yy, ww, hh, adjust);
if ( vstatusbar && (width != old_width || height != old_height) ) if ( vstatusbar && (width != old_width || height != old_height) )
resizeArea (vstatusbar); resizeArea (vstatusbar);
} }
@ -548,9 +563,11 @@ bool FStatusBar::hasActivatedKey()
{ {
if ( (*iter)->isActivated() ) if ( (*iter)->isActivated() )
return true; return true;
++iter; ++iter;
} }
} }
return false; return false;
} }
@ -562,6 +579,7 @@ void FStatusBar::drawMessage()
if ( ! isVisible() ) if ( ! isVisible() )
return; return;
if ( x < 0 || x_msg < 0 ) if ( x < 0 || x_msg < 0 )
return; return;
@ -586,8 +604,10 @@ void FStatusBar::drawMessage()
setUpdateVTerm(false); setUpdateVTerm(false);
setColor (wc.statusbar_fg, wc.statusbar_bg); setColor (wc.statusbar_fg, wc.statusbar_bg);
gotoxy (x, lastLine); gotoxy (x, lastLine);
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
if ( x+space_offset+3 < termWidth ) if ( x+space_offset+3 < termWidth )
{ {
if ( text ) if ( text )
@ -597,6 +617,7 @@ void FStatusBar::drawMessage()
x++; x++;
print (vstatusbar, ' '); print (vstatusbar, ' ');
} }
if ( hasKeys ) if ( hasKeys )
{ {
x += 2; x += 2;
@ -606,6 +627,7 @@ void FStatusBar::drawMessage()
int msg_length = int(getMessage().getLength()); int msg_length = int(getMessage().getLength());
x += msg_length; x += msg_length;
if ( x-1 <= termWidth ) if ( x-1 <= termWidth )
print (vstatusbar, getMessage()); print (vstatusbar, getMessage());
else else
@ -616,6 +638,7 @@ void FStatusBar::drawMessage()
} }
} }
} }
for (int i=x; i <= termWidth; i++) for (int i=x; i <= termWidth; i++)
print (vstatusbar, ' '); print (vstatusbar, ' ');
@ -670,6 +693,7 @@ void FStatusBar::remove (FStatusKey* skey)
return; return;
iter = keylist.begin(); iter = keylist.begin();
while ( iter != keylist.end() ) while ( iter != keylist.end() )
{ {
if ( (*iter) == skey ) if ( (*iter) == skey )
@ -726,8 +750,10 @@ void FStatusBar::cb_statuskey_activated (FWidget* widget, void*)
++iter; ++iter;
} }
} }
if ( isVisible() && isShown() ) if ( isVisible() && isShown() )
redraw(); redraw();
if ( ! isHiddenCursor() ) if ( ! isHiddenCursor() )
hideCursor(); hideCursor();
} }

View File

@ -207,6 +207,7 @@ FString::~FString() // destructor
{ {
if ( string ) if ( string )
delete[](string); delete[](string);
if ( c_string ) if ( c_string )
delete[](c_string); delete[](c_string);
} }
@ -260,6 +261,7 @@ inline void FString::_insert (uInt pos, uInt len, const wchar_t* s)
// string is null // string is null
length = len; length = len;
bufsize = FWDBUFFER + length + 1; bufsize = FWDBUFFER + length + 1;
try try
{ {
string = new wchar_t[bufsize](); string = new wchar_t[bufsize]();
@ -269,6 +271,7 @@ inline void FString::_insert (uInt pos, uInt len, const wchar_t* s)
std::cerr << bad_alloc_str << " " << ex.what() << std::endl; std::cerr << bad_alloc_str << " " << ex.what() << std::endl;
return; return;
} }
wcscpy (string, s); wcscpy (string, s);
return; return;
} }
@ -281,8 +284,10 @@ inline void FString::_insert (uInt pos, uInt len, const wchar_t* s)
// output string <= bufsize // output string <= bufsize
for (x = length; x > pos-1; x--) // shifting right side + '\0' for (x = length; x > pos-1; x--) // shifting right side + '\0'
string[x+len] = string[x]; string[x+len] = string[x];
for (x=0; x < len; x++) // insert string for (x=0; x < len; x++) // insert string
string[x+pos] = s[x]; string[x+pos] = s[x];
length += len; length += len;
} }
else else
@ -300,13 +305,18 @@ inline void FString::_insert (uInt pos, uInt len, const wchar_t* s)
std::cerr << bad_alloc_str << " " << ex.what() << std::endl; std::cerr << bad_alloc_str << " " << ex.what() << std::endl;
return; return;
} }
uInt y = 0; uInt y = 0;
for (x=0; x < pos; x++) // left side for (x=0; x < pos; x++) // left side
sptr[y++] = string[x]; sptr[y++] = string[x];
for (x=0; x < len; x++) // insert string for (x=0; x < len; x++) // insert string
sptr[y++] = s[x]; sptr[y++] = s[x];
for (x=pos; x < length+1; x++) // right side + '\0' for (x=pos; x < length+1; x++) // right side + '\0'
sptr[y++] = string[x]; sptr[y++] = string[x];
length += len; length += len;
delete[](string); // delete old string delete[](string); // delete old string
string = sptr; string = sptr;
@ -322,6 +332,7 @@ inline void FString::_remove (uInt pos, uInt len)
// shifting left side to pos // shifting left side to pos
for (uInt i=pos; (i+len) < length+1; i++) for (uInt i=pos; (i+len) < length+1; i++)
string[i] = string[i+len]; string[i] = string[i+len];
length -= len; length -= len;
} }
else else
@ -338,11 +349,15 @@ inline void FString::_remove (uInt pos, uInt len)
std::cerr << bad_alloc_str << " " << ex.what() << std::endl; std::cerr << bad_alloc_str << " " << ex.what() << std::endl;
return; return;
} }
uInt x, y = 0; uInt x, y = 0;
for (x=0; x < pos; x++) // left side for (x=0; x < pos; x++) // left side
sptr[y++] = string[x]; sptr[y++] = string[x];
for (x=pos+len; x < length+1; x++) // right side + '\0' for (x=pos+len; x < length+1; x++) // right side + '\0'
sptr[y++] = string[x]; sptr[y++] = string[x];
delete[](string); // delete old string delete[](string); // delete old string
string = sptr; string = sptr;
length -= len; length -= len;
@ -357,6 +372,7 @@ inline char* FString::wc_to_c_str (const wchar_t* s) const
if ( ! s ) // handle NULL string if ( ! s ) // handle NULL string
return 0; return 0;
if ( ! *s ) // handle empty string if ( ! *s ) // handle empty string
{ {
try try
@ -369,8 +385,10 @@ inline char* FString::wc_to_c_str (const wchar_t* s) const
std::cerr << bad_alloc_str << " " << ex.what() << std::endl; std::cerr << bad_alloc_str << " " << ex.what() << std::endl;
return 0; return 0;
} }
return c_string; return c_string;
} }
if ( c_string ) if ( c_string )
delete[](c_string); delete[](c_string);
@ -401,6 +419,7 @@ inline char* FString::wc_to_c_str (const wchar_t* s) const
c_string = 0; c_string = 0;
return const_cast<char*>(""); return const_cast<char*>("");
} }
return c_string; return c_string;
} }
@ -413,6 +432,7 @@ inline wchar_t* FString::c_to_wc_str (const char* s) const
if ( ! s ) // handle NULL string if ( ! s ) // handle NULL string
return 0; return 0;
if ( ! *s ) // handle empty string if ( ! *s ) // handle empty string
{ {
try try
@ -457,8 +477,10 @@ inline wchar_t* FString::c_to_wc_str (const char* s) const
return 0; return 0;
} }
} }
if ( wclength == size ) if ( wclength == size )
dest[size-1] = '\0'; dest[size-1] = '\0';
if ( wclength ) if ( wclength )
return dest; return dest;
else else
@ -495,6 +517,7 @@ std::ostream& operator << (std::ostream& outstr, const FString& s)
{ {
if ( s.length ) if ( s.length )
outstr << s.wc_to_c_str( s.string ); outstr << s.wc_to_c_str( s.string );
return (outstr); return (outstr);
} }
@ -512,6 +535,7 @@ std::istream& operator >> (std::istream& instr, FString& s)
s._replace (wc_str); s._replace (wc_str);
delete[] wc_str; delete[] wc_str;
} }
return (instr); return (instr);
} }
@ -520,6 +544,7 @@ std::wostream& operator << (std::wostream& outstr, const FString& s)
{ {
if ( s.length ) if ( s.length )
outstr << s.string; outstr << s.string;
return (outstr); return (outstr);
} }
@ -539,6 +564,7 @@ FString& FString::operator = (const FString& s)
_replace (s.string); _replace (s.string);
else else
clear(); clear();
return (*this); return (*this);
} }
@ -549,6 +575,7 @@ FString& FString::operator = (const std::wstring& s)
_replace (s.c_str()); _replace (s.c_str());
else else
clear(); clear();
return (*this); return (*this);
} }
@ -559,6 +586,7 @@ const FString& FString::operator = (const wchar_t* s)
_replace (s); _replace (s);
else else
clear(); clear();
return (*this); return (*this);
} }
@ -566,6 +594,7 @@ const FString& FString::operator = (const wchar_t* s)
FString& FString::operator = (const std::string& s) FString& FString::operator = (const std::string& s)
{ {
const wchar_t* wc_string = c_to_wc_str(s.c_str()); const wchar_t* wc_string = c_to_wc_str(s.c_str());
if ( wc_string ) if ( wc_string )
{ {
_replace( wc_string ); _replace( wc_string );
@ -573,6 +602,7 @@ FString& FString::operator = (const std::string& s)
} }
else else
clear(); clear();
return (*this); return (*this);
} }
@ -580,6 +610,7 @@ FString& FString::operator = (const std::string& s)
const FString& FString::operator = (const char* s) const FString& FString::operator = (const char* s)
{ {
const wchar_t* wc_string = c_to_wc_str(s); const wchar_t* wc_string = c_to_wc_str(s);
if ( wc_string ) if ( wc_string )
{ {
_replace( wc_string ); _replace( wc_string );
@ -587,6 +618,7 @@ const FString& FString::operator = (const char* s)
} }
else else
clear(); clear();
return (*this); return (*this);
} }
@ -635,11 +667,13 @@ const FString& FString::operator += (const wchar_t* s)
const FString& FString::operator += (const std::string& s) const FString& FString::operator += (const std::string& s)
{ {
const wchar_t* wc_string = c_to_wc_str(s.c_str()); const wchar_t* wc_string = c_to_wc_str(s.c_str());
if ( wc_string ) if ( wc_string )
{ {
_insert (length, uInt(s.length()), wc_string); _insert (length, uInt(s.length()), wc_string);
delete[] wc_string; delete[] wc_string;
} }
return (*this); return (*this);
} }
@ -647,11 +681,13 @@ const FString& FString::operator += (const std::string& s)
const FString& FString::operator += (const char* s) const FString& FString::operator += (const char* s)
{ {
const wchar_t* wc_string = c_to_wc_str(s); const wchar_t* wc_string = c_to_wc_str(s);
if ( wc_string ) if ( wc_string )
{ {
_insert (length, uInt(strlen(s)), wc_string); _insert (length, uInt(strlen(s)), wc_string);
delete[] wc_string; delete[] wc_string;
} }
return (*this); return (*this);
} }
@ -704,11 +740,12 @@ const FString FString::operator + (const std::string& s)
{ {
FString tmp(string); FString tmp(string);
wchar_t* wc_string = c_to_wc_str(s.c_str()); wchar_t* wc_string = c_to_wc_str(s.c_str());
if ( ! wc_string ) if ( ! wc_string )
return (tmp); return (tmp);
tmp._insert (length, uInt(wcslen(wc_string)), wc_string); tmp._insert (length, uInt(wcslen(wc_string)), wc_string);
delete[] wc_string; delete[] wc_string;
return (tmp); return (tmp);
} }
@ -717,11 +754,12 @@ const FString FString::operator + (const char* s)
{ {
FString tmp(string); FString tmp(string);
wchar_t* wc_string = c_to_wc_str(s); wchar_t* wc_string = c_to_wc_str(s);
if ( ! wc_string ) if ( ! wc_string )
return (tmp); return (tmp);
tmp._insert (length, uInt(wcslen(wc_string)), wc_string); tmp._insert (length, uInt(wcslen(wc_string)), wc_string);
delete[] wc_string; delete[] wc_string;
return (tmp); return (tmp);
} }
@ -841,8 +879,10 @@ wchar_t& FString::operator [] (int pos)
wchar_t& FString::operator [] (uInt pos) wchar_t& FString::operator [] (uInt pos)
{ {
assert ( (pos < length) && "Invalid index position!" ); assert ( (pos < length) && "Invalid index position!" );
if (pos >= length) if (pos >= length)
throw std::out_of_range(""); throw std::out_of_range("");
return string[pos]; return string[pos];
} }
@ -910,11 +950,13 @@ FString& FString::sprintf (const char* format, ...)
} }
wc_string = c_to_wc_str(buffer); wc_string = c_to_wc_str(buffer);
if ( wc_string ) if ( wc_string )
{ {
_replace(wc_string); _replace(wc_string);
delete[] wc_string; delete[] wc_string;
} }
if ( buffer != buf ) if ( buffer != buf )
delete[] buffer; delete[] buffer;
@ -926,10 +968,10 @@ FString FString::clear()
{ {
if ( string ) if ( string )
delete[](string); delete[](string);
length = 0; length = 0;
bufsize = 0; bufsize = 0;
string = 0; string = 0;
return (*this); return (*this);
} }
@ -966,6 +1008,7 @@ FString FString::toLower() const
p++; p++;
} }
} }
return s; return s;
} }
@ -984,6 +1027,7 @@ FString FString::toUpper() const
p++; p++;
} }
} }
return s; return s;
} }
@ -1070,11 +1114,13 @@ long FString::toLong() const
while ( isdigit(*p) ) while ( isdigit(*p) )
{ {
register uChar d = uChar((*p) - L'0'); register uChar d = uChar((*p) - L'0');
if ( num > tenth_limit if ( num > tenth_limit
|| (num == tenth_limit && d > tenth_limit_digit) ) || (num == tenth_limit && d > tenth_limit_digit) )
{ {
throw std::overflow_error ("overflow"); throw std::overflow_error ("overflow");
} }
num = (num<<3)+(num<<1) + d; // (10 * num) + d num = (num<<3)+(num<<1) + d; // (10 * num) + d
p++; p++;
} }
@ -1114,11 +1160,13 @@ uLong FString::toULong() const
while ( isdigit(*p) ) while ( isdigit(*p) )
{ {
register uChar d = uChar((*p) - L'0'); register uChar d = uChar((*p) - L'0');
if ( num > tenth_limit if ( num > tenth_limit
|| (num == tenth_limit && d > tenth_limit_digit) ) || (num == tenth_limit && d > tenth_limit_digit) )
{ {
throw std::overflow_error ("overflow"); throw std::overflow_error ("overflow");
} }
num = (num<<3)+(num<<1) + d; // (10 * num) + d num = (num<<3)+(num<<1) + d; // (10 * num) + d
p++; p++;
} }
@ -1162,9 +1210,11 @@ double FString::toDouble() const
{ {
if ( ret >= HUGE_VAL || ret <= -HUGE_VAL ) if ( ret >= HUGE_VAL || ret <= -HUGE_VAL )
throw std::overflow_error ("overflow"); throw std::overflow_error ("overflow");
if ( fabs(ret) < DBL_EPSILON ) // ret == 0.0l if ( fabs(ret) < DBL_EPSILON ) // ret == 0.0l
throw std::underflow_error ("underflow"); throw std::underflow_error ("underflow");
} }
return ret; return ret;
} }
@ -1177,9 +1227,12 @@ FString FString::ltrim() const
// handle NULL and empty string // handle NULL and empty string
if ( ! string || ! *string ) if ( ! string || ! *string )
return s; return s;
p = s.string; p = s.string;
while ( iswspace(uInt(*p)) ) while ( iswspace(uInt(*p)) )
p++; p++;
return FString(p); return FString(p);
} }
@ -1193,9 +1246,12 @@ FString FString::rtrim() const
// handle NULL and empty string // handle NULL and empty string
if ( ! string || ! *string ) if ( ! string || ! *string )
return s; return s;
p = s.string; p = s.string;
last = p + length; last = p + length;
while ( iswspace(uInt(*--last)) && last > p ); while ( iswspace(uInt(*--last)) && last > p );
if ( last == p && iswspace(uInt(*last)) ) if ( last == p && iswspace(uInt(*last)) )
s.clear(); s.clear();
else else
@ -1210,6 +1266,7 @@ FString FString::trim() const
// handle NULL and empty string // handle NULL and empty string
if ( ! string || ! *string ) if ( ! string || ! *string )
return (*this); return (*this);
FString s(ltrim()); FString s(ltrim());
return s.rtrim(); return s.rtrim();
} }
@ -1223,8 +1280,10 @@ FString FString::left(uInt len) const
// handle NULL and empty string // handle NULL and empty string
if ( ! string || ! *string ) if ( ! string || ! *string )
return s; return s;
if ( len > length ) if ( len > length )
return s; return s;
p = s.string; p = s.string;
*(p+len) = '\0'; *(p+len) = '\0';
return s; return s;
@ -1239,8 +1298,10 @@ FString FString::right(uInt len) const
// handle NULL and empty string // handle NULL and empty string
if ( ! string || ! *string ) if ( ! string || ! *string )
return s; return s;
if ( len > length ) if ( len > length )
return s; return s;
p = s.string; p = s.string;
p += (length-len); p += (length-len);
return FString(p); return FString(p);
@ -1256,10 +1317,13 @@ FString FString::mid(uInt pos, uInt len) const
// handle NULL and empty string // handle NULL and empty string
if ( ! string || ! *string ) if ( ! string || ! *string )
return s; return s;
if ( pos == 0 ) if ( pos == 0 )
pos = 1; pos = 1;
if ( pos <= length && pos+len > length ) if ( pos <= length && pos+len > length )
len = length - pos + 1; len = length - pos + 1;
if ( pos > length || pos+len-1 > length || len == 0 ) if ( pos > length || pos+len-1 > length || len == 0 )
return FString(L""); return FString(L"");
@ -1289,6 +1353,7 @@ std::vector<FString> FString::split (const FString& delimiter)
stringList.push_back (FString(token)); stringList.push_back (FString(token));
token = extractToken (&rest, 0, delimiter.wc_str()); token = extractToken (&rest, 0, delimiter.wc_str());
} }
return stringList; return stringList;
} }
@ -1303,11 +1368,13 @@ FString& FString::setString (const wchar_t* s)
FString& FString::setString (const char* s) FString& FString::setString (const char* s)
{ {
const wchar_t* wc_string = c_to_wc_str(s); const wchar_t* wc_string = c_to_wc_str(s);
if ( wc_string ) if ( wc_string )
{ {
_replace (wc_string); _replace (wc_string);
delete[] wc_string; delete[] wc_string;
} }
return (*this); return (*this);
} }
@ -1329,15 +1396,19 @@ FString& FString::setNumber (long num)
{ {
neg = false; neg = false;
} }
*s = '\0'; *s = '\0';
do do
{ {
*--s = wchar_t(int(num%10) + '0'); *--s = wchar_t(int(num%10) + '0');
num /= 10; num /= 10;
} while ( num ); }
while ( num );
if ( neg ) if ( neg )
*--s = '-'; *--s = '-';
_replace (s); _replace (s);
return *this; return *this;
} }
@ -1355,10 +1426,10 @@ FString& FString::setNumber (uLong num)
{ {
*--s = wchar_t(int(num%10) + '0'); *--s = wchar_t(int(num%10) + '0');
num /= 10; num /= 10;
} while ( num ); }
while ( num );
_replace (s); _replace (s);
return *this; return *this;
} }
@ -1386,7 +1457,6 @@ FString& FString::setNumber (lDouble num, int precision)
*s++ = L'L'; *s++ = L'L';
*s++ = L'g'; *s++ = L'g';
*s = L'\0'; *s = L'\0';
return sprintf(format, num); return sprintf(format, num);
} }
@ -1413,17 +1483,22 @@ FString& FString::setFormatedNumber (long num, char separator)
{ {
neg = false; neg = false;
} }
*s = L'\0'; *s = L'\0';
do do
{ {
*--s = wchar_t(int(num%10) + '0'); *--s = wchar_t(int(num%10) + '0');
num /= 10; num /= 10;
if ( num && ++n % 3 == 0 ) if ( num && ++n % 3 == 0 )
*--s = separator; *--s = separator;
} while ( num ); }
while ( num );
if ( neg ) if ( neg )
*--s = '-'; *--s = '-';
_replace (s); _replace (s);
return *this; return *this;
} }
@ -1446,13 +1521,14 @@ FString& FString::setFormatedNumber (uLong num, char separator)
{ {
*--s = wchar_t(int(num%10) + '0'); *--s = wchar_t(int(num%10) + '0');
num /= 10; num /= 10;
if ( num && ++n % 3 == 0 ) if ( num && ++n % 3 == 0 )
*--s = separator; *--s = separator;
} while ( num ); }
while ( num );
_replace (s); _replace (s);
return *this; return *this;
} }
@ -1462,12 +1538,16 @@ bool FString::operator < (const FString& s) const
{ {
if ( ! s ) if ( ! s )
return false; return false;
if ( string && ! s.string ) if ( string && ! s.string )
return false; return false;
if ( ! string && s.string ) if ( ! string && s.string )
return true; return true;
if ( ! string && ! s.string ) if ( ! string && ! s.string )
return false; return false;
return (wcscmp(string, s.string) < 0); return (wcscmp(string, s.string) < 0);
} }
@ -1518,12 +1598,16 @@ bool FString::operator <= (const FString& s) const
{ {
if ( ! s ) if ( ! s )
return false; return false;
if ( string && ! s.string ) if ( string && ! s.string )
return false; return false;
if ( ! string && s.string ) if ( ! string && s.string )
return true; return true;
if ( ! string && ! s.string ) if ( ! string && ! s.string )
return true; return true;
return (wcscmp(string, s.string) <= 0); return (wcscmp(string, s.string) <= 0);
} }
@ -1574,10 +1658,13 @@ bool FString::operator == (const FString& s) const
{ {
if ( ! s ) if ( ! s )
return false; return false;
if ( (string && ! s.string ) || (! string && s.string) ) if ( (string && ! s.string ) || (! string && s.string) )
return false; return false;
if ( ! string && ! s.string ) if ( ! string && ! s.string )
return true; return true;
return (wcscmp(string, s.string) == 0); return (wcscmp(string, s.string) == 0);
} }
@ -1628,10 +1715,13 @@ bool FString::operator != (const FString& s) const
{ {
if ( ! s ) if ( ! s )
return true; return true;
if ( (string && ! s.string ) || (! string && s.string) ) if ( (string && ! s.string ) || (! string && s.string) )
return true; return true;
if ( ! string && ! s.string ) if ( ! string && ! s.string )
return false; return false;
return (wcscmp(string, s.string) != 0); return (wcscmp(string, s.string) != 0);
} }
@ -1682,12 +1772,16 @@ bool FString::operator >= (const FString& s) const
{ {
if ( ! s ) if ( ! s )
return true; return true;
if ( string && ! s.string ) if ( string && ! s.string )
return true; return true;
if ( ! string && s.string ) if ( ! string && s.string )
return false; return false;
if ( ! string && ! s.string ) if ( ! string && ! s.string )
return true; return true;
return (wcscmp(string, s.string) >= 0); return (wcscmp(string, s.string) >= 0);
} }
@ -1738,12 +1832,16 @@ bool FString::operator > (const FString& s) const
{ {
if ( ! s ) if ( ! s )
return true; return true;
if ( string && ! s.string ) if ( string && ! s.string )
return true; return true;
if ( ! string && s.string ) if ( ! string && s.string )
return false; return false;
if ( ! string && ! s.string ) if ( ! string && ! s.string )
return false; return false;
return (wcscmp(string, s.string) > 0); return (wcscmp(string, s.string) > 0);
} }
@ -1795,6 +1893,7 @@ const FString& FString::insert (const FString& s, uInt pos)
// assert (pos <= length); // assert (pos <= length);
if ( pos >= length ) if ( pos >= length )
throw std::out_of_range(""); throw std::out_of_range("");
_insert (pos, s.length, s.string); _insert (pos, s.length, s.string);
return (*this); return (*this);
} }
@ -1805,6 +1904,7 @@ const FString& FString::insert (const wchar_t* s, uInt pos)
// assert (pos <= length); // assert (pos <= length);
if ( pos >= length ) if ( pos >= length )
throw std::out_of_range(""); throw std::out_of_range("");
_insert (pos, uInt(wcslen(s)), s); _insert (pos, uInt(wcslen(s)), s);
return (*this); return (*this);
} }
@ -1837,12 +1937,15 @@ FString FString::replace (const FString& from, const FString& to)
// handle NULL and empty string // handle NULL and empty string
if ( ! string || ! *string ) if ( ! string || ! *string )
return s; return s;
if ( from.isNull() || to.isNull() ) if ( from.isNull() || to.isNull() )
return s; return s;
p = s.string; p = s.string;
from_length = from.getLength(); from_length = from.getLength();
to_length = to.getLength(); to_length = to.getLength();
pos = 0; pos = 0;
while ( *p ) while ( *p )
{ {
if ( wcsncmp(p, from.string, from_length) == 0 ) if ( wcsncmp(p, from.string, from_length) == 0 )
@ -2118,11 +2221,14 @@ FString FString::replace (const wchar_t from, const FString& to)
// handle NULL and empty string // handle NULL and empty string
if ( ! string || ! *string ) if ( ! string || ! *string )
return s; return s;
if ( to.isNull() ) if ( to.isNull() )
return s; return s;
p = s.string; p = s.string;
uInt to_length = to.getLength(); uInt to_length = to.getLength();
uInt pos = 0; uInt pos = 0;
while ( *p ) while ( *p )
{ {
if ( wchar_t(*p) == from ) if ( wchar_t(*p) == from )
@ -2138,6 +2244,7 @@ FString FString::replace (const wchar_t from, const FString& to)
p++; p++;
} }
} }
return s; return s;
} }
@ -2234,12 +2341,15 @@ FString FString::replace (const char from, const char to)
return s; return s;
p = s.string; p = s.string;
while ( *p ) while ( *p )
{ {
if ( char(*p) == from ) if ( char(*p) == from )
*p = to; *p = to;
p++; p++;
} }
return s; return s;
} }
@ -2269,9 +2379,11 @@ FString FString::replaceControlCodes() const
} }
else if ( ! iswprint(wint_t(*p)) ) else if ( ! iswprint(wint_t(*p)) )
*p = L' '; *p = L' ';
p++; p++;
} }
} }
return s; return s;
} }
@ -2285,11 +2397,13 @@ FString FString::expandTabs (uInt tabstop) const
tab_split = instr.split("\t"); tab_split = instr.split("\t");
last = tab_split.size(); last = tab_split.size();
for (uInt i=0; i < last; i++) for (uInt i=0; i < last; i++)
{ {
uInt len = tab_split[i].getLength(); uInt len = tab_split[i].getLength();
outstr += tab_split[i] + FString(tabstop - len % tabstop, L' '); outstr += tab_split[i] + FString(tabstop - len % tabstop, L' ');
} }
return outstr; return outstr;
} }
@ -2304,7 +2418,8 @@ FString FString::removeDel() const
if ( p ) if ( p )
{ {
uInt i=0; uInt i=0;
uInt d=0; uInt d=0;
while ( *p ) while ( *p )
{ {
if ( *p == 0x7f ) if ( *p == 0x7f )
@ -2320,11 +2435,14 @@ FString FString::removeDel() const
s.string[i] = *p; s.string[i] = *p;
i++; i++;
} }
p++; p++;
} }
s.string[i] = L'\0'; s.string[i] = L'\0';
s.length = i; s.length = i;
} }
return s; return s;
} }
@ -2340,6 +2458,7 @@ FString FString::removeBackspaces() const
if ( p ) if ( p )
{ {
uInt i=0; uInt i=0;
while ( *p ) while ( *p )
{ {
if ( *p != L'\b' ) if ( *p != L'\b' )
@ -2351,11 +2470,14 @@ FString FString::removeBackspaces() const
{ {
i--; i--;
} }
p++; p++;
} }
s.string[i] = L'\0'; s.string[i] = L'\0';
s.length = i; s.length = i;
} }
return s; return s;
} }
@ -2371,6 +2493,7 @@ const FString& FString::overwrite (const FString& s, uInt pos)
wcsncpy (string + pos, s.string, length - pos); wcsncpy (string + pos, s.string, length - pos);
_insert (length, pos + s.length - length, s.string + length - pos); _insert (length, pos + s.length - length, s.string + length - pos);
} }
return (*this); return (*this);
} }
@ -2378,6 +2501,7 @@ const FString& FString::overwrite (const FString& s, uInt pos)
const FString& FString::overwrite (const wchar_t* s, uInt pos) const FString& FString::overwrite (const wchar_t* s, uInt pos)
{ {
uInt len = uInt(wcslen(s)); uInt len = uInt(wcslen(s));
if (length >= (pos+len) ) if (length >= (pos+len) )
{ {
wcsncpy (string + pos, s, len); wcsncpy (string + pos, s, len);
@ -2387,6 +2511,7 @@ const FString& FString::overwrite (const wchar_t* s, uInt pos)
wcsncpy (string + pos, s, length - pos); wcsncpy (string + pos, s, length - pos);
_insert (length, pos + len - length, s + length - pos); _insert (length, pos + len - length, s + length - pos);
} }
return (*this); return (*this);
} }
@ -2397,6 +2522,7 @@ const FString& FString::overwrite (const wchar_t c, uInt pos)
{ {
string[pos] = c; string[pos] = c;
} }
return (*this); return (*this);
} }
@ -2405,6 +2531,7 @@ const FString& FString::remove (uInt pos, uInt len)
{ {
assert ((pos < length) && ((pos + len) <= length)); assert ((pos < length) && ((pos + len) <= length));
_remove (pos, len); _remove (pos, len);
return (*this); return (*this);
} }
@ -2425,8 +2552,10 @@ bool FString::includes (const char* s)
{ {
bool ret; bool ret;
const wchar_t* wc_string = c_to_wc_str(s); const wchar_t* wc_string = c_to_wc_str(s);
if ( ! wc_string ) if ( ! wc_string )
return false; return false;
ret = bool(wcsstr(string, wc_string) != 0); ret = bool(wcsstr(string, wc_string) != 0);
delete[] wc_string; delete[] wc_string;
return (ret); return (ret);

View File

@ -41,7 +41,6 @@ void FSwitch::draw()
drawLabel(); drawLabel();
drawCheckButton(); drawCheckButton();
setUpdateVTerm(true); setUpdateVTerm(true);
FToggleButton::draw(); FToggleButton::draw();
updateTerminal(); updateTerminal();
flush_out(); flush_out();
@ -75,10 +74,12 @@ void FSwitch::drawCheckButton()
setColor (wc.button_hotkey_fg, wc.button_active_focus_bg); setColor (wc.button_hotkey_fg, wc.button_active_focus_bg);
} }
else else
{
if ( isMonochron() || getMaxColor() < 16 ) if ( isMonochron() || getMaxColor() < 16 )
setColor (wc.button_active_focus_fg, wc.button_active_bg); setColor (wc.button_active_focus_fg, wc.button_active_bg);
else else
setColor (wc.button_hotkey_fg, wc.button_active_bg); setColor (wc.button_hotkey_fg, wc.button_active_bg);
}
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
@ -93,8 +94,10 @@ void FSwitch::drawCheckButton()
setColor (wc.button_inactive_fg, wc.button_inactive_bg); setColor (wc.button_inactive_fg, wc.button_inactive_bg);
print (off); print (off);
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
setCursorPos ( xpos + xmin + 1 + switch_offset_pos setCursorPos ( xpos + xmin + 1 + switch_offset_pos
, ypos + ymin - 1 ); , ypos + ymin - 1 );
} }
@ -123,10 +126,12 @@ void FSwitch::drawCheckButton()
setColor (wc.button_hotkey_fg, wc.button_active_focus_bg); setColor (wc.button_hotkey_fg, wc.button_active_focus_bg);
} }
else else
{
if ( isMonochron() || getMaxColor() < 16 ) if ( isMonochron() || getMaxColor() < 16 )
setColor (wc.button_active_focus_fg, wc.button_active_bg); setColor (wc.button_active_focus_fg, wc.button_active_bg);
else else
setColor (wc.button_hotkey_fg, wc.button_active_bg); setColor (wc.button_hotkey_fg, wc.button_active_bg);
}
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);

File diff suppressed because it is too large Load Diff

View File

@ -461,6 +461,7 @@ inline int FTerm::getLineNumber()
{ {
if ( term->getHeight() == 0 ) if ( term->getHeight() == 0 )
getTermSize(); getTermSize();
return term->getHeight(); return term->getHeight();
} }
@ -469,6 +470,7 @@ inline int FTerm::getColumnNumber()
{ {
if ( term->getWidth() == 0 ) if ( term->getWidth() == 0 )
getTermSize(); getTermSize();
return term->getWidth(); return term->getWidth();
} }

View File

@ -67,24 +67,30 @@ void FTextView::draw()
{ {
setUpdateVTerm(false); setUpdateVTerm(false);
setColor (foregroundColor, backgroundColor); setColor (foregroundColor, backgroundColor);
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
if ( ! isNewFont() ) if ( ! isNewFont() )
drawBorder(); drawBorder();
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();
setUpdateVTerm(true);
setUpdateVTerm(true);
drawText(); drawText();
if ( hasFocus() && statusBar() ) if ( hasFocus() && statusBar() )
{ {
FString msg = getStatusbarMessage(); FString msg = getStatusbarMessage();
FString curMsg = statusBar()->getMessage(); FString curMsg = statusBar()->getMessage();
if ( curMsg != msg ) if ( curMsg != msg )
{ {
setUpdateVTerm(false); setUpdateVTerm(false);
@ -93,6 +99,7 @@ void FTextView::draw()
setUpdateVTerm(true); setUpdateVTerm(true);
} }
} }
setCursorPos(1,1); setCursorPos(1,1);
updateTerminal(); updateTerminal();
flush_out(); flush_out();
@ -105,8 +112,10 @@ void FTextView::drawText()
if ( data.empty() || height < 4 || width < 5 ) if ( data.empty() || height < 4 || width < 5 )
return; return;
start = 0; start = 0;
end = uInt(height+nf_offset-2); end = uInt(height+nf_offset-2);
if ( end > getRows() ) if ( end > getRows() )
end = getRows(); end = getRows();
@ -118,12 +127,14 @@ void FTextView::drawText()
for (uInt y=start; y < end; y++) for (uInt y=start; y < end; y++)
{ {
uInt i, len;
FString line;
const wchar_t* line_str;
gotoxy (xpos+xmin, ypos+ymin-nf_offset+int(y)); gotoxy (xpos+xmin, ypos+ymin-nf_offset+int(y));
uInt i; line = data[y+uInt(yoffset)].mid ( uInt(1 + xoffset)
FString line = data[y+uInt(yoffset)].mid ( uInt(1 + xoffset) , uInt(width - nf_offset - 2) );
, uInt(width - nf_offset - 2) ); line_str = line.wc_str();
const wchar_t* line_str = line.wc_str(); len = line.getLength();
uInt len = line.getLength();
for (i=0; i < len; i++) for (i=0; i < len; i++)
{ {
@ -140,6 +151,7 @@ void FTextView::drawText()
else else
print ('.'); print ('.');
} }
for (; i < uInt(width - nf_offset - 2); i++) for (; i < uInt(width - nf_offset - 2); i++)
print (' '); print (' ');
} }
@ -195,11 +207,9 @@ void FTextView::hide()
char* blank; char* blank;
FWidget::hide(); FWidget::hide();
fg = getParentWidget()->getForegroundColor(); fg = getParentWidget()->getForegroundColor();
bg = getParentWidget()->getBackgroundColor(); bg = getParentWidget()->getBackgroundColor();
setColor (fg, bg); setColor (fg, bg);
n = isNewFont() ? 1 : 0; n = isNewFont() ? 1 : 0;
size = width + n; size = width + n;
blank = new char[size+1]; blank = new char[size+1];
@ -211,6 +221,7 @@ void FTextView::hide()
gotoxy (xpos+xmin-1, ypos+ymin-1+y); gotoxy (xpos+xmin-1, ypos+ymin-1+y);
print (blank); print (blank);
} }
delete[] blank; delete[] blank;
flush_out(); flush_out();
} }
@ -226,41 +237,50 @@ void FTextView::onKeyPress (FKeyEvent* ev)
case fc::Fkey_up: case fc::Fkey_up:
if ( yoffset > 0 ) if ( yoffset > 0 )
yoffset--; yoffset--;
ev->accept(); ev->accept();
break; break;
case fc::Fkey_down: case fc::Fkey_down:
if ( yoffset + height + nf_offset <= last_line + 1 ) if ( yoffset + height + nf_offset <= last_line + 1 )
yoffset++; yoffset++;
ev->accept(); ev->accept();
break; break;
case fc::Fkey_right: case fc::Fkey_right:
if ( xoffset + width - nf_offset <= int(maxLineWidth) + 1 ) if ( xoffset + width - nf_offset <= int(maxLineWidth) + 1 )
xoffset++; xoffset++;
ev->accept(); ev->accept();
break; break;
case fc::Fkey_left: case fc::Fkey_left:
if ( xoffset > 0 ) if ( xoffset > 0 )
xoffset--; xoffset--;
ev->accept(); ev->accept();
break; break;
case fc::Fkey_ppage: case fc::Fkey_ppage:
yoffset -= height-2; yoffset -= height-2;
if ( yoffset < 0 ) if ( yoffset < 0 )
yoffset = 0; yoffset = 0;
ev->accept(); ev->accept();
break; break;
case fc::Fkey_npage: case fc::Fkey_npage:
if ( last_line >= height ) if ( last_line >= height )
yoffset += height-2; yoffset += height-2;
if ( yoffset > last_line - height - nf_offset + 2 ) if ( yoffset > last_line - height - nf_offset + 2 )
yoffset = last_line - height - nf_offset + 2; yoffset = last_line - height - nf_offset + 2;
if ( yoffset < 0 ) if ( yoffset < 0 )
yoffset = 0; yoffset = 0;
ev->accept(); ev->accept();
break; break;
@ -272,6 +292,7 @@ void FTextView::onKeyPress (FKeyEvent* ev)
case fc::Fkey_end: case fc::Fkey_end:
if ( last_line >= height ) if ( last_line >= height )
yoffset = last_line - height - nf_offset + 2; yoffset = last_line - height - nf_offset + 2;
ev->accept(); ev->accept();
break; break;
@ -285,11 +306,15 @@ void FTextView::onKeyPress (FKeyEvent* ev)
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();
} }
@ -307,8 +332,10 @@ void FTextView::onMouseDown (FMouseEvent* ev)
FFocusEvent out (fc::FocusOut_Event); FFocusEvent out (fc::FocusOut_Event);
FApplication::queueEvent(focused_widget, &out); FApplication::queueEvent(focused_widget, &out);
setFocus(); setFocus();
if ( focused_widget ) if ( focused_widget )
focused_widget->redraw(); focused_widget->redraw();
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
} }
@ -325,19 +352,26 @@ void FTextView::onWheel (FWheelEvent* ev)
case fc::WheelUp: case fc::WheelUp:
if ( yoffset == 0 ) if ( yoffset == 0 )
break; break;
yoffset -= 4; yoffset -= 4;
if ( yoffset < 0 ) if ( yoffset < 0 )
yoffset=0; yoffset=0;
break; break;
case fc::WheelDown: case fc::WheelDown:
{ {
int yoffset_end = last_line - height - nf_offset + 2; int yoffset_end = last_line - height - nf_offset + 2;
if ( yoffset_end < 0 ) if ( yoffset_end < 0 )
yoffset_end = 0; yoffset_end = 0;
if ( yoffset == yoffset_end ) if ( yoffset == yoffset_end )
break; break;
yoffset += 4; yoffset += 4;
if ( yoffset > yoffset_end ) if ( yoffset > yoffset_end )
yoffset = yoffset_end; yoffset = yoffset_end;
} }
@ -351,11 +385,15 @@ void FTextView::onWheel (FWheelEvent* ev)
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();
} }
@ -391,8 +429,10 @@ void FTextView::cb_VBarChange (FWidget*, void*)
// fall through // fall through
case FScrollbar::scrollStepBackward: case FScrollbar::scrollStepBackward:
yoffset -= distance; yoffset -= distance;
if ( yoffset < 0 ) if ( yoffset < 0 )
yoffset = 0; yoffset = 0;
break; break;
case FScrollbar::scrollPageForward: case FScrollbar::scrollPageForward:
@ -400,20 +440,27 @@ void FTextView::cb_VBarChange (FWidget*, void*)
// fall through // fall through
case FScrollbar::scrollStepForward: case FScrollbar::scrollStepForward:
yoffset += distance; yoffset += distance;
if ( yoffset > last_line - height - nf_offset + 2 ) if ( yoffset > last_line - height - nf_offset + 2 )
yoffset = last_line - height - nf_offset + 2; yoffset = last_line - height - nf_offset + 2;
break; break;
case FScrollbar::scrollJump: case FScrollbar::scrollJump:
{ {
int val = VBar->getValue(); int val = VBar->getValue();
if ( yoffset == val ) if ( yoffset == val )
break; break;
yoffset = val; yoffset = val;
if ( yoffset > last_line - height - nf_offset + 2 ) if ( yoffset > last_line - height - nf_offset + 2 )
yoffset = last_line - height - nf_offset + 2; yoffset = last_line - height - nf_offset + 2;
if ( yoffset < 0 ) if ( yoffset < 0 )
yoffset = 0; yoffset = 0;
break; break;
} }
@ -445,8 +492,10 @@ void FTextView::cb_VBarChange (FWidget*, void*)
&& 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();
} }
} }
@ -466,8 +515,10 @@ void FTextView::cb_HBarChange (FWidget*, void*)
// fall through // fall through
case FScrollbar::scrollStepBackward: case FScrollbar::scrollStepBackward:
xoffset -= distance; xoffset -= distance;
if ( xoffset < 0 ) if ( xoffset < 0 )
xoffset = 0; xoffset = 0;
break; break;
case FScrollbar::scrollPageForward: case FScrollbar::scrollPageForward:
@ -475,39 +526,53 @@ void FTextView::cb_HBarChange (FWidget*, void*)
// fall through // fall through
case FScrollbar::scrollStepForward: case FScrollbar::scrollStepForward:
xoffset += distance; xoffset += distance;
if ( xoffset > int(maxLineWidth) - width + nf_offset + 4 ) if ( xoffset > int(maxLineWidth) - width + nf_offset + 4 )
xoffset = int(maxLineWidth) - width + nf_offset + 4; xoffset = int(maxLineWidth) - width + nf_offset + 4;
if ( xoffset < 0 ) if ( xoffset < 0 )
xoffset = 0; xoffset = 0;
break; break;
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 > int(maxLineWidth) - width + nf_offset + 4 ) if ( xoffset > int(maxLineWidth) - width + nf_offset + 4 )
xoffset = int(maxLineWidth) - width + nf_offset + 4; xoffset = int(maxLineWidth) - width + nf_offset + 4;
if ( xoffset < 0 ) if ( xoffset < 0 )
xoffset = 0; xoffset = 0;
break; break;
} }
case FScrollbar::scrollWheelUp: case FScrollbar::scrollWheelUp:
if ( xoffset == 0 ) if ( xoffset == 0 )
break; break;
xoffset -= 4; xoffset -= 4;
if ( xoffset < 0 ) if ( xoffset < 0 )
xoffset=0; xoffset=0;
break; break;
case FScrollbar::scrollWheelDown: case FScrollbar::scrollWheelDown:
if ( xoffset == xoffset_end ) if ( xoffset == xoffset_end )
break; break;
xoffset += 4; xoffset += 4;
if ( xoffset > xoffset_end ) if ( xoffset > xoffset_end )
xoffset = xoffset_end; xoffset = xoffset_end;
break; break;
default: default:
@ -524,8 +589,10 @@ void FTextView::cb_HBarChange (FWidget*, void*)
&& 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();
} }
} }
@ -551,6 +618,7 @@ void FTextView::setGeometry (int x, int y, int w, int h, bool adjust)
void FTextView::setPosition (int pos) void FTextView::setPosition (int pos)
{ {
int last_line = int(getRows()); int last_line = int(getRows());
if ( pos < 0 || pos > last_line - height + 2 ) if ( pos < 0 || pos > last_line - height + 2 )
return; return;
@ -560,6 +628,7 @@ void FTextView::setPosition (int pos)
drawText(); drawText();
VBar->setValue (yoffset); VBar->setValue (yoffset);
if ( VBar->isVisible() ) if ( VBar->isVisible() )
VBar->drawBar(); VBar->drawBar();
@ -583,14 +652,17 @@ FString FTextView::getText() const
len = 0; len = 0;
rows = getRows(); rows = getRows();
for (uInt i=0 ; i < rows; i++) for (uInt i=0 ; i < rows; i++)
len += data[i].getLength() + 1; len += data[i].getLength() + 1;
FString s(len + 1); FString s(len + 1);
idx = 0; idx = 0;
for (uInt i=0 ; i < rows; i++) for (uInt i=0 ; i < rows; i++)
{ {
const wchar_t* p = data[i].wc_str(); const wchar_t* p = data[i].wc_str();
if ( p ) if ( p )
{ {
while ( (s[idx++] = *p++) != 0 ); while ( (s[idx++] = *p++) != 0 );
@ -601,6 +673,7 @@ FString FTextView::getText() const
s[idx++] = '\n'; s[idx++] = '\n';
} }
} }
s[idx-1] = 0; s[idx-1] = 0;
return s; return s;
} }
@ -639,28 +712,34 @@ void FTextView::insert (const FString& str, int pos)
.replaceControlCodes() .replaceControlCodes()
.rtrim(); .rtrim();
len = text_split[i].getLength(); len = text_split[i].getLength();
if ( len > maxLineWidth ) if ( len > maxLineWidth )
{ {
maxLineWidth = len; maxLineWidth = len;
if ( len > uInt(width-nf_offset-2) ) if ( len > uInt(width-nf_offset-2) )
{ {
HBar->setMaximum (int(maxLineWidth) - width + nf_offset + 2); HBar->setMaximum (int(maxLineWidth) - width + nf_offset + 2);
HBar->setPageSize (int(maxLineWidth), width - nf_offset - 2); HBar->setPageSize (int(maxLineWidth), width - 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()) - height + 2 - nf_offset); VBar->setMaximum (int(getRows()) - height + 2 - nf_offset);
VBar->setPageSize (int(getRows()), height - 2 + nf_offset); VBar->setPageSize (int(getRows()), height - 2 + nf_offset);
VBar->calculateSliderValues(); VBar->calculateSliderValues();
if ( ! VBar->isVisible() && int(getRows()) >= height + nf_offset - 1 ) if ( ! VBar->isVisible() && int(getRows()) >= height + nf_offset - 1 )
VBar->setVisible(); VBar->setVisible();
if ( VBar->isVisible() && int(getRows()) < height + nf_offset - 1 ) if ( VBar->isVisible() && int(getRows()) < height + nf_offset - 1 )
VBar->hide(); VBar->hide();
processChanged(); processChanged();
} }
@ -671,8 +750,10 @@ void FTextView::replaceRange (const FString& str, int start, int end)
if ( start > end ) if ( start > end )
return; return;
if ( start < 0 || start >= int(getRows()) ) if ( start < 0 || start >= int(getRows()) )
return; return;
if ( end < 0 || end >= int(getRows()) ) if ( end < 0 || end >= int(getRows()) )
return; return;
@ -690,7 +771,6 @@ void FTextView::clear()
char* blank; char* blank;
data.clear(); data.clear();
xoffset = 0; xoffset = 0;
yoffset = 0; yoffset = 0;
maxLineWidth = 0; maxLineWidth = 0;
@ -715,6 +795,7 @@ void FTextView::clear()
gotoxy (xpos+xmin, ypos+ymin-nf_offset+y); gotoxy (xpos+xmin, ypos+ymin-nf_offset+y);
print (blank); print (blank);
} }
delete[] blank; delete[] blank;
processChanged(); processChanged();
} }

View File

@ -57,8 +57,10 @@ FToggleButton::FToggleButton (const FString& txt, FWidget* parent)
FToggleButton::~FToggleButton() // destructor FToggleButton::~FToggleButton() // destructor
{ {
delAccelerator(); delAccelerator();
if ( group() ) if ( group() )
group()->remove(this); group()->remove(this);
if ( hasFocus() ) if ( hasFocus() )
hideCursor(); hideCursor();
} }
@ -125,6 +127,7 @@ uChar FToggleButton::getHotkey()
return 0;; return 0;;
} }
} }
return 0; return 0;
} }
@ -153,10 +156,12 @@ void FToggleButton::setHotkeyAccelerator()
void FToggleButton::draw() void FToggleButton::draw()
{ {
bool isFocus = ((flags & fc::focus) != 0); bool isFocus = ((flags & fc::focus) != 0);
if ( isFocus && statusBar() ) if ( isFocus && statusBar() )
{ {
FString msg = getStatusbarMessage(); FString msg = getStatusbarMessage();
FString curMsg = statusBar()->getMessage(); FString curMsg = statusBar()->getMessage();
if ( curMsg != msg ) if ( curMsg != msg )
{ {
statusBar()->setMessage(msg); statusBar()->setMessage(msg);
@ -192,6 +197,7 @@ void FToggleButton::drawLabel()
if ( ! isVisible() ) if ( ! isVisible() )
return; return;
if ( text.isNull() || text.isEmpty() ) if ( text.isNull() || text.isEmpty() )
return; return;
@ -215,8 +221,10 @@ void FToggleButton::drawLabel()
i++; i++;
src++; src++;
} }
*dest++ = *src++; *dest++ = *src++;
} }
if ( hotkeypos != -1 ) if ( hotkeypos != -1 )
length--; length--;
@ -235,11 +243,15 @@ void FToggleButton::drawLabel()
if ( (z == hotkeypos) && isActive ) if ( (z == hotkeypos) && isActive )
{ {
setColor (wc.label_hotkey_fg, wc.label_hotkey_bg); setColor (wc.label_hotkey_fg, wc.label_hotkey_bg);
if ( ! isNoUnderline ) if ( ! isNoUnderline )
setUnderline(); setUnderline();
print ( LabelText[z] ); print ( LabelText[z] );
if ( ! isNoUnderline ) if ( ! isNoUnderline )
unsetUnderline(); unsetUnderline();
setColor (wc.label_fg, wc.label_bg); setColor (wc.label_fg, wc.label_bg);
} }
else else
@ -351,7 +363,6 @@ void FToggleButton::hide()
char* blank; char* blank;
FWidget::hide(); FWidget::hide();
fg = getParentWidget()->getForegroundColor(); fg = getParentWidget()->getForegroundColor();
bg = getParentWidget()->getBackgroundColor(); bg = getParentWidget()->getBackgroundColor();
setColor (fg, bg); setColor (fg, bg);
@ -369,8 +380,10 @@ void FToggleButton::hide()
void FToggleButton::setGeometry (int x, int y, int w, int h, bool adjust) void FToggleButton::setGeometry (int x, int y, int w, int h, bool adjust)
{ {
int min_width = button_width + int(text.getLength()); int min_width = button_width + int(text.getLength());
if ( w < min_width ) if ( w < min_width )
w = min_width; w = min_width;
FWidget::setGeometry(x, y, w, h, adjust); FWidget::setGeometry(x, y, w, h, adjust);
} }
@ -381,6 +394,7 @@ bool FToggleButton::setNoUnderline (bool on)
flags |= fc::no_underline; flags |= fc::no_underline;
else else
flags &= ~fc::no_underline; flags &= ~fc::no_underline;
return on; return on;
} }
@ -393,6 +407,7 @@ bool FToggleButton::setEnable (bool on)
{ {
flags |= fc::active; flags |= fc::active;
setHotkeyAccelerator(); setHotkeyAccelerator();
if ( hasFocus() ) if ( hasFocus() )
{ {
foregroundColor = wc.toggle_button_active_focus_fg; foregroundColor = wc.toggle_button_active_focus_fg;
@ -411,6 +426,7 @@ bool FToggleButton::setEnable (bool on)
foregroundColor = wc.toggle_button_inactive_fg; foregroundColor = wc.toggle_button_inactive_fg;
backgroundColor = wc.toggle_button_inactive_bg; backgroundColor = wc.toggle_button_inactive_bg;
} }
return on; return on;
} }
@ -431,7 +447,6 @@ bool FToggleButton::setFocus (bool on)
foregroundColor = wc.toggle_button_active_focus_fg; foregroundColor = wc.toggle_button_active_focus_fg;
backgroundColor = wc.toggle_button_active_focus_bg; backgroundColor = wc.toggle_button_active_focus_bg;
if ( isCursorInside() && (isRadioButton() || isCheckboxButton()) ) if ( isCursorInside() && (isRadioButton() || isCheckboxButton()) )
showCursor(); showCursor();
@ -439,6 +454,7 @@ bool FToggleButton::setFocus (bool on)
{ {
FString msg = getStatusbarMessage(); FString msg = getStatusbarMessage();
FString curMsg = statusBar()->getMessage(); FString curMsg = statusBar()->getMessage();
if ( curMsg != msg ) if ( curMsg != msg )
statusBar()->setMessage(msg); statusBar()->setMessage(msg);
} }
@ -458,6 +474,7 @@ bool FToggleButton::setFocus (bool on)
statusBar()->clearMessage(); statusBar()->clearMessage();
} }
} }
return on; return on;
} }
@ -473,9 +490,12 @@ void FToggleButton::onMouseDown (FMouseEvent* ev)
FFocusEvent out (fc::FocusOut_Event); FFocusEvent out (fc::FocusOut_Event);
FApplication::queueEvent(focused_widget, &out); FApplication::queueEvent(focused_widget, &out);
setFocus(); setFocus();
if ( focused_widget ) if ( focused_widget )
focused_widget->redraw(); focused_widget->redraw();
redraw(); redraw();
if ( statusBar() ) if ( statusBar() )
{ {
statusBar()->drawMessage(); statusBar()->drawMessage();
@ -522,6 +542,7 @@ void FToggleButton::onAccel (FAccelEvent* ev)
FFocusEvent out (fc::FocusOut_Event); FFocusEvent out (fc::FocusOut_Event);
FApplication::queueEvent(focused_widget, &out); FApplication::queueEvent(focused_widget, &out);
setFocus(); setFocus();
if ( focused_widget ) if ( focused_widget )
focused_widget->redraw(); focused_widget->redraw();
} }
@ -539,13 +560,16 @@ void FToggleButton::onAccel (FAccelEvent* ev)
checked = not checked; checked = not checked;
processToggle(); processToggle();
} }
redraw(); redraw();
if ( statusBar() ) if ( statusBar() )
{ {
statusBar()->drawMessage(); statusBar()->drawMessage();
updateTerminal(); updateTerminal();
flush_out(); flush_out();
} }
processClick(); processClick();
ev->accept(); ev->accept();
} }
@ -585,10 +609,13 @@ void FToggleButton::onFocusOut (FFocusEvent* out_ev)
{ {
focus_inside_group = true; focus_inside_group = true;
out_ev->ignore(); out_ev->ignore();
if ( out_ev->getFocusType() == fc::FocusNextWidget ) if ( out_ev->getFocusType() == fc::FocusNextWidget )
group()->focusNextChild(); group()->focusNextChild();
if ( out_ev->getFocusType() == fc::FocusPreviousWidget ) if ( out_ev->getFocusType() == fc::FocusPreviousWidget )
group()->focusPrevChild(); group()->focusPrevChild();
redraw(); redraw();
} }
else if ( this == group()->getLastButton() else if ( this == group()->getLastButton()
@ -616,6 +643,7 @@ bool FToggleButton::setChecked (bool on)
checked = on; checked = on;
processToggle(); processToggle();
} }
return checked; return checked;
} }
@ -624,6 +652,7 @@ void FToggleButton::setText (FString txt)
{ {
text = txt; text = txt;
setWidth(button_width + int(text.getLength())); setWidth(button_width + int(text.getLength()));
if ( isEnabled() ) if ( isEnabled() )
{ {
delAccelerator(); delAccelerator();

View File

@ -177,6 +177,7 @@ void FWidget::finish()
delete close_widget; delete close_widget;
close_widget = 0; close_widget = 0;
} }
if ( window_list ) if ( window_list )
{ {
delete window_list; delete window_list;
@ -416,6 +417,7 @@ void FWidget::adjustSize()
xmax = getParentWidget()->client_xmax; xmax = getParentWidget()->client_xmax;
ymax = getParentWidget()->client_ymax; ymax = getParentWidget()->client_ymax;
} }
xpos = widgetSize.getX(); xpos = widgetSize.getX();
ypos = widgetSize.getY(); ypos = widgetSize.getY();
width = widgetSize.getWidth(); width = widgetSize.getWidth();
@ -427,6 +429,7 @@ void FWidget::adjustSize()
while ( xpos+xmin-1+width > xmax+1 ) while ( xpos+xmin-1+width > xmax+1 )
{ {
xpos--; xpos--;
if ( xpos < 1 ) if ( xpos < 1 )
{ {
xpos = 1; xpos = 1;
@ -437,6 +440,7 @@ void FWidget::adjustSize()
while ( ypos+ymin-1+height > ymax+1 ) while ( ypos+ymin-1+height > ymax+1 )
{ {
ypos--; ypos--;
if ( ypos < 1 ) if ( ypos < 1 )
{ {
ypos = 1; ypos = 1;
@ -446,18 +450,19 @@ void FWidget::adjustSize()
while ( xmin+width-1 > xmax ) while ( xmin+width-1 > xmax )
width--; width--;
while ( ymin+height-1 > ymax ) while ( ymin+height-1 > ymax )
height--; height--;
if ( width < 1 ) if ( width < 1 )
width = 1; width = 1;
if ( height < 1 ) if ( height < 1 )
height = 1; height = 1;
} }
adjustWidgetSize.setRect(xpos, ypos, width, height); adjustWidgetSize.setRect(xpos, ypos, width, height);
adjustWidgetSizeShadow = adjustWidgetSize + shadow; adjustWidgetSizeShadow = adjustWidgetSize + shadow;
adjustWidgetSizeGlobal.setRect ( xpos + xmin - 1 adjustWidgetSizeGlobal.setRect ( xpos + xmin - 1
, ypos + ymin - 1 , ypos + ymin - 1
, width, height ); , width, height );
@ -480,8 +485,10 @@ void FWidget::adjustSize()
while ( iter != end ) while ( iter != end )
{ {
FWidget* widget = static_cast<FWidget*>(*iter); FWidget* widget = static_cast<FWidget*>(*iter);
if ( ! widget->isWindow() ) if ( ! widget->isWindow() )
widget->adjustSize(); widget->adjustSize();
++iter; ++iter;
} }
} }
@ -521,6 +528,7 @@ void FWidget::setStatusBar (FStatusBar* sbar)
{ {
if ( ! sbar || statusbar == sbar ) if ( ! sbar || statusbar == sbar )
return; return;
if ( statusbar ) if ( statusbar )
delete statusbar; delete statusbar;
@ -532,6 +540,7 @@ void FWidget::setMenuBar (FMenuBar* mbar)
{ {
if ( ! mbar || menubar == mbar ) if ( ! mbar || menubar == mbar )
return; return;
if ( menubar ) if ( menubar )
delete menubar; delete menubar;
@ -547,16 +556,21 @@ bool FWidget::event (FEvent* ev)
{ {
FKeyEvent* kev = static_cast<FKeyEvent*>(ev); FKeyEvent* kev = static_cast<FKeyEvent*>(ev);
bool accpt_focus = false; bool accpt_focus = false;
if ( kev->key() == fc::Fkey_tab ) if ( kev->key() == fc::Fkey_tab )
accpt_focus = focusNextChild(); accpt_focus = focusNextChild();
else if ( kev->key() == fc::Fkey_btab ) else if ( kev->key() == fc::Fkey_btab )
accpt_focus = focusPrevChild(); accpt_focus = focusPrevChild();
if ( accpt_focus ) if ( accpt_focus )
break; break;
FWidget* widget = this; FWidget* widget = this;
while ( widget ) while ( widget )
{ {
widget->onKeyPress(kev); widget->onKeyPress(kev);
if ( ! kev->isAccepted() ) if ( ! kev->isAccepted() )
{ {
if ( kev->key() == fc::Fkey_right if ( kev->key() == fc::Fkey_right
@ -565,11 +579,14 @@ bool FWidget::event (FEvent* ev)
else if ( kev->key() == fc::Fkey_left else if ( kev->key() == fc::Fkey_left
|| kev->key() == fc::Fkey_up ) || kev->key() == fc::Fkey_up )
accpt_focus = focusPrevChild(); accpt_focus = focusPrevChild();
if ( accpt_focus ) if ( accpt_focus )
break; break;
} }
if ( kev->isAccepted() || widget->isRootWidget() ) if ( kev->isAccepted() || widget->isRootWidget() )
break; break;
widget = widget->getParentWidget(); widget = widget->getParentWidget();
} }
} }
@ -583,11 +600,14 @@ bool FWidget::event (FEvent* ev)
{ {
FKeyEvent* kev = static_cast<FKeyEvent*>(ev); FKeyEvent* kev = static_cast<FKeyEvent*>(ev);
FWidget* widget = this; FWidget* widget = this;
while ( widget ) while ( widget )
{ {
widget->onKeyDown(kev); widget->onKeyDown(kev);
if ( kev->isAccepted() || widget->isRootWidget() ) if ( kev->isAccepted() || widget->isRootWidget() )
break; break;
widget = widget->getParentWidget(); widget = widget->getParentWidget();
} }
} }
@ -723,6 +743,7 @@ bool FWidget::focusNextChild()
if ( hasParent() ) if ( hasParent() )
{ {
FWidget* parent = static_cast<FWidget*>(getParent()); FWidget* parent = static_cast<FWidget*>(getParent());
if ( parent->hasChildren() && parent->numOfFocusableChildren() > 1 ) if ( parent->hasChildren() && parent->numOfFocusableChildren() > 1 )
{ {
FObject::object_list children; FObject::object_list children;
@ -735,33 +756,40 @@ bool FWidget::focusNextChild()
while ( iter != end ) while ( iter != end )
{ {
FWidget* w = static_cast<FWidget*>(*iter); FWidget* w = static_cast<FWidget*>(*iter);
if ( w == this ) if ( w == this )
{ {
FWidget* next; FWidget* next;
FObject::object_list::const_iterator next_element; FObject::object_list::const_iterator next_element;
next_element = iter; next_element = iter;
do do
{ {
++next_element; ++next_element;
if ( next_element == children.end() ) if ( next_element == children.end() )
next_element = children.begin(); next_element = children.begin();
next = static_cast<FWidget*>(*next_element); next = static_cast<FWidget*>(*next_element);
} while ( ! next->isEnabled() } while ( ! next->isEnabled()
|| ! next->acceptFocus() || ! next->acceptFocus()
|| ! next->isVisible() || ! next->isVisible()
|| next->isWindow() ); || next->isWindow() );
FFocusEvent out (fc::FocusOut_Event); FFocusEvent out (fc::FocusOut_Event);
out.setFocusType(fc::FocusNextWidget); out.setFocusType(fc::FocusNextWidget);
FApplication::sendEvent(this, &out); FApplication::sendEvent(this, &out);
if ( out.isAccepted() ) if ( out.isAccepted() )
{ {
if ( next == this ) if ( next == this )
return false; return false;
next->setFocus(); next->setFocus();
FFocusEvent in (fc::FocusIn_Event); FFocusEvent in (fc::FocusIn_Event);
in.setFocusType(fc::FocusNextWidget); in.setFocusType(fc::FocusNextWidget);
FApplication::sendEvent(next, &in); FApplication::sendEvent(next, &in);
if ( in.isAccepted() ) if ( in.isAccepted() )
{ {
this->draw(); this->draw();
@ -785,6 +813,7 @@ bool FWidget::focusPrevChild()
if ( hasParent() ) if ( hasParent() )
{ {
FWidget* parent = static_cast<FWidget*>(getParent()); FWidget* parent = static_cast<FWidget*>(getParent());
if ( parent->hasChildren() && parent->numOfFocusableChildren() > 1 ) if ( parent->hasChildren() && parent->numOfFocusableChildren() > 1 )
{ {
FObject::object_list children; FObject::object_list children;
@ -793,29 +822,34 @@ bool FWidget::focusPrevChild()
children = getParent()->getChildren(); children = getParent()->getChildren();
iter = children.end(); iter = children.end();
begin = children.begin(); begin = children.begin();
do do
{ {
--iter; --iter;
FWidget* w = static_cast<FWidget*>(*iter); FWidget* w = static_cast<FWidget*>(*iter);
if ( w == this ) if ( w == this )
{ {
FWidget* prev; FWidget* prev;
FObject::object_list::const_iterator prev_element; FObject::object_list::const_iterator prev_element;
prev_element = iter; prev_element = iter;
do do
{ {
if ( prev_element == children.begin() ) if ( prev_element == children.begin() )
prev_element = children.end(); prev_element = children.end();
--prev_element; --prev_element;
prev = static_cast<FWidget*>(*prev_element); prev = static_cast<FWidget*>(*prev_element);
} while ( ! prev->isEnabled() } while ( ! prev->isEnabled()
|| ! prev->acceptFocus() || ! prev->acceptFocus()
|| ! prev->isVisible() || ! prev->isVisible()
|| prev->isWindow() ); || prev->isWindow() );
FFocusEvent out (fc::FocusOut_Event); FFocusEvent out (fc::FocusOut_Event);
out.setFocusType(fc::FocusPreviousWidget); out.setFocusType(fc::FocusPreviousWidget);
FApplication::sendEvent(this, &out); FApplication::sendEvent(this, &out);
if ( out.isAccepted() ) if ( out.isAccepted() )
{ {
if ( prev == this ) if ( prev == this )
@ -832,11 +866,14 @@ bool FWidget::focusPrevChild()
flush_out(); flush_out();
} }
} }
break; break;
} }
} while ( iter != begin ); }
while ( iter != begin );
} }
} }
return true; return true;
} }
@ -885,6 +922,7 @@ FWidget* FWidget::childWidgetAt (FWidget* p, int x, int y)
while ( iter != end ) while ( iter != end )
{ {
FWidget* widget = static_cast<FWidget*>(*iter); FWidget* widget = static_cast<FWidget*>(*iter);
if ( widget->isEnabled() if ( widget->isEnabled()
&& widget->isVisible() && widget->isVisible()
&& ! widget->isWindow() && ! widget->isWindow()
@ -893,9 +931,11 @@ FWidget* FWidget::childWidgetAt (FWidget* p, int x, int y)
FWidget* child = childWidgetAt(widget, x, y); FWidget* child = childWidgetAt(widget, x, y);
return (child != 0) ? child : widget; return (child != 0) ? child : widget;
} }
++iter; ++iter;
} }
} }
return 0; return 0;
} }
@ -948,7 +988,6 @@ int FWidget::numOfFocusableChildren()
return 0; return 0;
int num = 0; int num = 0;
children = this->getChildren(); children = this->getChildren();
iter = children.begin(); iter = children.begin();
end = children.end(); end = children.end();
@ -956,10 +995,13 @@ int FWidget::numOfFocusableChildren()
while ( iter != end ) while ( iter != end )
{ {
FWidget* widget = static_cast<FWidget*>(*iter); FWidget* widget = static_cast<FWidget*>(*iter);
if ( widget->acceptFocus() ) if ( widget->acceptFocus() )
num++; num++;
++iter; ++iter;
} }
return num; return num;
} }
@ -976,6 +1018,7 @@ bool FWidget::close()
else else
{ {
hide(); hide();
if ( (flags & fc::modal) == 0 ) if ( (flags & fc::modal) == 0 )
close_widget->push_back(this); close_widget->push_back(this);
} }
@ -1088,9 +1131,11 @@ void FWidget::emitCallback (FString emit_signal)
// call the member function pointer // call the member function pointer
(m_iter->cb_instance->*callback)(this, m_iter->data); (m_iter->cb_instance->*callback)(this, m_iter->data);
} }
++m_iter; ++m_iter;
} }
} }
// function pointer // function pointer
if ( ! callbackObjects.empty() ) if ( ! callbackObjects.empty() )
{ {
@ -1106,6 +1151,7 @@ void FWidget::emitCallback (FString emit_signal)
// call the function pointer // call the function pointer
callback(this, iter->data); callback(this, iter->data);
} }
++iter; ++iter;
} }
} }
@ -1119,8 +1165,10 @@ void FWidget::addAccelerator (int key, FWidget* obj)
if ( ! window ) if ( ! window )
window = getRootWidget(); window = getRootWidget();
if ( window == statusbar || window == menubar ) if ( window == statusbar || window == menubar )
window = FWindow::getWindowWidget(getParentWidget()); window = FWindow::getWindowWidget(getParentWidget());
if ( window && window->accelerator_list ) if ( window && window->accelerator_list )
window->accelerator_list->push_back(accel); window->accelerator_list->push_back(accel);
} }
@ -1132,8 +1180,10 @@ void FWidget::delAccelerator (FWidget* obj)
if ( ! window ) if ( ! window )
window = getRootWidget(); window = getRootWidget();
if ( window == statusbar || window == menubar ) if ( window == statusbar || window == menubar )
window = FWindow::getWindowWidget(getParentWidget()); window = FWindow::getWindowWidget(getParentWidget());
if ( window if ( window
&& window->accelerator_list && window->accelerator_list
&& ! window->accelerator_list->empty() ) && ! window->accelerator_list->empty() )
@ -1206,9 +1256,11 @@ void FWidget::redraw()
(*iter)->redraw(); (*iter)->redraw();
} }
++iter; ++iter;
} }
} }
if ( menubar && vmenubar ) if ( menubar && vmenubar )
{ {
int w = vmenubar->width; int w = vmenubar->width;
@ -1216,6 +1268,7 @@ void FWidget::redraw()
std::fill_n (vmenubar->text, w * h, default_char); std::fill_n (vmenubar->text, w * h, default_char);
menubar->redraw(); menubar->redraw();
} }
if ( statusbar && vstatusbar ) if ( statusbar && vstatusbar )
{ {
int w = vstatusbar->width; int w = vstatusbar->width;
@ -1239,8 +1292,10 @@ void FWidget::redraw()
while ( iter != end ) while ( iter != end )
{ {
FWidget* widget = static_cast<FWidget*>(*iter); FWidget* widget = static_cast<FWidget*>(*iter);
if ( widget->isVisible() && ! widget->isWindow() ) if ( widget->isVisible() && ! widget->isWindow() )
widget->redraw(); widget->redraw();
++iter; ++iter;
} }
} }
@ -1270,6 +1325,7 @@ void FWidget::resize()
if ( menubar ) if ( menubar )
{ {
menubar->setGeometry(1, 1, width, 1, false); menubar->setGeometry(1, 1, width, 1, false);
if ( vmenubar ) if ( vmenubar )
resizeArea(vmenubar); resizeArea(vmenubar);
} }
@ -1277,9 +1333,11 @@ void FWidget::resize()
if ( statusbar ) if ( statusbar )
{ {
statusbar->setGeometry(1, height, width, 1, false); statusbar->setGeometry(1, height, width, 1, false);
if ( vstatusbar ) if ( vstatusbar )
resizeArea(vstatusbar); resizeArea(vstatusbar);
} }
adjustSizeGlobal(); adjustSizeGlobal();
} }
else else
@ -1355,6 +1413,7 @@ void FWidget::hide()
FWidget::setFocusWidget(getParentWidget()); FWidget::setFocusWidget(getParentWidget());
} }
} }
FHideEvent hide_ev (fc::Hide_Event); FHideEvent hide_ev (fc::Hide_Event);
FApplication::sendEvent(this, &hide_ev); FApplication::sendEvent(this, &hide_ev);
} }
@ -1406,6 +1465,7 @@ bool FWidget::focusFirstChild()
&& ! widget->isMenu() ) && ! widget->isMenu() )
{ {
widget->setFocus(); widget->setFocus();
if ( widget->numOfChildren() >= 1 ) if ( widget->numOfChildren() >= 1 )
{ {
if ( ! widget->focusFirstChild() && widget->isWindow() ) if ( ! widget->focusFirstChild() && widget->isWindow() )
@ -1414,8 +1474,10 @@ bool FWidget::focusFirstChild()
continue; continue;
} }
} }
return true; return true;
} }
// prefix increment (++) is faster // prefix increment (++) is faster
// than postfix for non primitive type // than postfix for non primitive type
++iter; ++iter;
@ -1446,11 +1508,13 @@ bool FWidget::focusLastChild()
&& ! widget->isMenu() ) && ! widget->isMenu() )
{ {
widget->setFocus(); widget->setFocus();
if ( widget->numOfChildren() >= 1 ) if ( widget->numOfChildren() >= 1 )
{ {
if ( ! widget->focusLastChild() && widget->isWindow() ) if ( ! widget->focusLastChild() && widget->isWindow() )
continue; continue;
} }
return true; return true;
} }
} }
@ -1466,6 +1530,7 @@ bool FWidget::setFocus (bool on)
if ( ! enable ) if ( ! enable )
return false; return false;
if ( on == focus ) if ( on == focus )
return true; return true;
@ -1493,6 +1558,7 @@ bool FWidget::setFocus (bool on)
{ {
bool has_raised = window->raiseWindow(); bool has_raised = window->raiseWindow();
FWindow::setActiveWindow(window); FWindow::setActiveWindow(window);
if ( has_raised && window->isVisible() && window->isShown() ) if ( has_raised && window->isVisible() && window->isShown() )
window->redraw(); window->redraw();
} }
@ -1799,6 +1865,7 @@ void FWidget::move (int x, int y)
{ {
if ( x == xpos && y == ypos ) if ( x == xpos && y == ypos )
return; return;
// Avoid to move widget completely outside the terminal // Avoid to move widget completely outside the terminal
if ( x+width < 1 || x > term->getWidth() || y < 1 || y > term->getHeight() ) if ( x+width < 1 || x > term->getWidth() || y < 1 || y > term->getHeight() )
return; return;
@ -1870,6 +1937,7 @@ void FWidget::clrscr()
area = area_widget->getVWin(); area = area_widget->getVWin();
else else
area = vdesktop; area = vdesktop;
if ( ! area ) if ( ! area )
return; return;
@ -1892,6 +1960,7 @@ void FWidget::clrscr()
area->changes[i].xmin = 0; area->changes[i].xmin = 0;
area->changes[i].xmax = uInt(area->width + area->right_shadow - 1); area->changes[i].xmax = uInt(area->width + area->right_shadow - 1);
} }
putArea (xpos+xmin-1, ypos+ymin-1, area); putArea (xpos+xmin-1, ypos+ymin-1, area);
} }
@ -1931,28 +2000,40 @@ void FWidget::drawShadow()
if ( ch.bold ) if ( ch.bold )
setBold (true); setBold (true);
if ( ch.dim ) if ( ch.dim )
setDim (true); setDim (true);
if ( ch.italic ) if ( ch.italic )
setItalic (true); setItalic (true);
if ( ch.underline ) if ( ch.underline )
setUnderline (true); setUnderline (true);
if ( ch.blink ) if ( ch.blink )
setBlink (true); setBlink (true);
if ( ch.reverse ) if ( ch.reverse )
setReverse (true); setReverse (true);
if ( ch.standout ) if ( ch.standout )
setStandout (true); setStandout (true);
if ( ch.invisible ) if ( ch.invisible )
setInvisible (true); setInvisible (true);
if ( ch.protect ) if ( ch.protect )
setProtected (true); setProtected (true);
if ( ch.crossed_out ) if ( ch.crossed_out )
setCrossedOut (true); setCrossedOut (true);
if ( ch.dbl_underline ) if ( ch.dbl_underline )
setDoubleUnderline (true); setDoubleUnderline (true);
if ( ch.alt_charset ) if ( ch.alt_charset )
setAltCharset (true); setAltCharset (true);
if ( ch.pc_charset ) if ( ch.pc_charset )
setPCcharset (true); setPCcharset (true);
@ -1962,12 +2043,15 @@ void FWidget::drawShadow()
} }
setColor (wc.shadow_bg, wc.shadow_fg); setColor (wc.shadow_bg, wc.shadow_fg);
for (int i=1; i < height && y1+i <= ymax; i++) for (int i=1; i < height && y1+i <= ymax; i++)
{ {
gotoxy (x2+1, y1+i); gotoxy (x2+1, y1+i);
for (int x=1; x <= 2; x++) for (int x=1; x <= 2; x++)
{ {
ch = getCoveredCharacter (x2+x, y1+i, this); ch = getCoveredCharacter (x2+x, y1+i, this);
if ( ch.code == fc::LowerHalfBlock if ( ch.code == fc::LowerHalfBlock
|| ch.code == fc::UpperHalfBlock || ch.code == fc::UpperHalfBlock
|| ch.code == fc::LeftHalfBlock || ch.code == fc::LeftHalfBlock
@ -1979,6 +2063,7 @@ void FWidget::drawShadow()
} }
} }
} }
if ( y2 < ymax ) if ( y2 < ymax )
{ {
gotoxy (x1, y2+1); gotoxy (x1, y2+1);
@ -1990,40 +2075,53 @@ void FWidget::drawShadow()
if ( ch.bold ) if ( ch.bold )
setBold (true); setBold (true);
if ( ch.dim ) if ( ch.dim )
setDim (true); setDim (true);
if ( ch.italic ) if ( ch.italic )
setItalic (true); setItalic (true);
if ( ch.underline ) if ( ch.underline )
setUnderline (true); setUnderline (true);
if ( ch.blink ) if ( ch.blink )
setBlink (true); setBlink (true);
if ( ch.reverse ) if ( ch.reverse )
setReverse (true); setReverse (true);
if ( ch.standout ) if ( ch.standout )
setStandout (true); setStandout (true);
if ( ch.invisible ) if ( ch.invisible )
setInvisible (true); setInvisible (true);
if ( ch.protect ) if ( ch.protect )
setProtected (true); setProtected (true);
if ( ch.crossed_out ) if ( ch.crossed_out )
setCrossedOut (true); setCrossedOut (true);
if ( ch.dbl_underline ) if ( ch.dbl_underline )
setDoubleUnderline (true); setDoubleUnderline (true);
if ( ch.alt_charset ) if ( ch.alt_charset )
setAltCharset (true); setAltCharset (true);
if ( ch.pc_charset ) if ( ch.pc_charset )
setPCcharset (true); setPCcharset (true);
print (ch.code); print (ch.code);
setNormal(); setNormal();
} }
setColor (wc.shadow_bg, wc.shadow_fg); setColor (wc.shadow_bg, wc.shadow_fg);
for (int i=2; i <= width+1 && x1+i <= xmax; i++) for (int i=2; i <= width+1 && x1+i <= xmax; i++)
{ {
ch = getCoveredCharacter (x1+i, y2+1, this); ch = getCoveredCharacter (x1+i, y2+1, this);
if ( ch.code == fc::LowerHalfBlock if ( ch.code == fc::LowerHalfBlock
|| ch.code == fc::UpperHalfBlock || ch.code == fc::UpperHalfBlock
|| ch.code == fc::LeftHalfBlock || ch.code == fc::LeftHalfBlock
@ -2034,6 +2132,7 @@ void FWidget::drawShadow()
print (ch.code); print (ch.code);
} }
} }
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
} }
@ -2067,10 +2166,12 @@ void FWidget::drawShadow()
if ( y2 < ymax ) if ( y2 < ymax )
{ {
gotoxy (x1+1, y2+1); gotoxy (x1+1, y2+1);
for (int i=1; i <= width && x1+i <= xmax; i++) for (int i=1; i <= width && x1+i <= xmax; i++)
{ {
ch = getCoveredCharacter (x1+i, y2+1, this); ch = getCoveredCharacter (x1+i, y2+1, this);
setColor (wc.shadow_fg, ch.bg_color); setColor (wc.shadow_fg, ch.bg_color);
if ( isTeraTerm() ) if ( isTeraTerm() )
print (0xdf); // ▀ print (0xdf); // ▀
else else
@ -2104,9 +2205,11 @@ void FWidget::clearShadow()
print (' '); // clear █ print (' '); // clear █
} }
} }
if ( y2 < ymax ) if ( y2 < ymax )
{ {
gotoxy (x1+1, y2+1); gotoxy (x1+1, y2+1);
for (int i=1; i <= width && x1+i <= xmax; i++) for (int i=1; i <= width && x1+i <= xmax; i++)
{ {
ch = getCoveredCharacter (x1+i, y2+1, this); ch = getCoveredCharacter (x1+i, y2+1, this);
@ -2130,9 +2233,11 @@ void FWidget::drawFlatBorder()
y2 = ypos+ymin-1+height; y2 = ypos+ymin-1+height;
setColor (wc.dialog_fg, wc.dialog_bg); setColor (wc.dialog_fg, wc.dialog_bg);
for (int y=0; y < height; y++) for (int y=0; y < height; y++)
{ {
gotoxy (x1-1, y1+y+1); gotoxy (x1-1, y1+y+1);
if ( double_flatline_mask.left[uLong(y)] ) if ( double_flatline_mask.left[uLong(y)] )
print (fc::NF_rev_border_line_right_and_left); // left+right line (on left side) print (fc::NF_rev_border_line_right_and_left); // left+right line (on left side)
else else
@ -2140,16 +2245,19 @@ void FWidget::drawFlatBorder()
} }
gotoxy (x2, y1+1); gotoxy (x2, y1+1);
for (int y=0; y < height; y++) for (int y=0; y < height; y++)
{ {
if ( double_flatline_mask.right[uLong(y)] ) if ( double_flatline_mask.right[uLong(y)] )
print (fc::NF_rev_border_line_right_and_left); // left+right line (on right side) print (fc::NF_rev_border_line_right_and_left); // left+right line (on right side)
else else
print (fc::NF_border_line_left); // left line (on right side) print (fc::NF_border_line_left); // left line (on right side)
gotoxy (x2, y1+y+2); gotoxy (x2, y1+y+2);
} }
gotoxy (x1, y1); gotoxy (x1, y1);
for (int x=0; x < width; x++) for (int x=0; x < width; x++)
{ {
if ( double_flatline_mask.top[uLong(x)] ) if ( double_flatline_mask.top[uLong(x)] )
@ -2159,6 +2267,7 @@ void FWidget::drawFlatBorder()
} }
gotoxy (x1, y2); gotoxy (x1, y2);
for (int x=0; x < width; x++) for (int x=0; x < width; x++)
{ {
if ( double_flatline_mask.bottom[uLong(x)] ) if ( double_flatline_mask.bottom[uLong(x)] )
@ -2278,10 +2387,13 @@ void FWidget::drawBorder()
if ( x1 < xmin ) if ( x1 < xmin )
x1 = xmin; x1 = xmin;
if ( y1 < ymin ) if ( y1 < ymin )
y1 = ymin; y1 = ymin;
if ( x2 > xmax ) if ( x2 > xmax )
x2 = xmax; x2 = xmax;
if ( y2 > ymax ) if ( y2 > ymax )
y2 = ymax; y2 = ymax;
@ -2290,9 +2402,12 @@ void FWidget::drawBorder()
setColor (wc.dialog_fg, wc.dialog_bg); setColor (wc.dialog_fg, wc.dialog_bg);
gotoxy (x1, y1); gotoxy (x1, y1);
print (fc::NF_border_corner_middle_upper_left); // ┌ print (fc::NF_border_corner_middle_upper_left); // ┌
for (int x=x1+1; x < x2; x++) for (int x=x1+1; x < x2; x++)
print (fc::BoxDrawingsHorizontal); // ─ print (fc::BoxDrawingsHorizontal); // ─
print (fc::NF_border_corner_middle_upper_right); // ┐ print (fc::NF_border_corner_middle_upper_right); // ┐
for (int y=y1+1; y <= y2; y++) for (int y=y1+1; y <= y2; y++)
{ {
gotoxy (x1, y); gotoxy (x1, y);
@ -2300,10 +2415,13 @@ void FWidget::drawBorder()
gotoxy (x2, y); gotoxy (x2, y);
print (fc::NF_rev_border_line_right); // border right⎹ print (fc::NF_rev_border_line_right); // border right⎹
} }
gotoxy (x1, y2); gotoxy (x1, y2);
print (fc::NF_border_corner_middle_lower_left); // └ print (fc::NF_border_corner_middle_lower_left); // └
for (int x=x1+1; x < x2; x++) for (int x=x1+1; x < x2; x++)
print (fc::BoxDrawingsHorizontal); // ─ print (fc::BoxDrawingsHorizontal); // ─
print (fc::NF_border_corner_middle_lower_right); // ┘ print (fc::NF_border_corner_middle_lower_right); // ┘
} }
else else
@ -2313,7 +2431,9 @@ void FWidget::drawBorder()
for (int x=x1+1; x < x2; x++) for (int x=x1+1; x < x2; x++)
print (fc::BoxDrawingsHorizontal); // ─ print (fc::BoxDrawingsHorizontal); // ─
print (fc::BoxDrawingsDownAndLeft); // ┐ print (fc::BoxDrawingsDownAndLeft); // ┐
for (int y=y1+1; y < y2; y++) for (int y=y1+1; y < y2; y++)
{ {
gotoxy (x1, y); gotoxy (x1, y);
@ -2321,10 +2441,13 @@ void FWidget::drawBorder()
gotoxy (x2, y); gotoxy (x2, y);
print (fc::BoxDrawingsVertical); // │ print (fc::BoxDrawingsVertical); // │
} }
gotoxy (x1, y2); gotoxy (x1, y2);
print (fc::BoxDrawingsUpAndRight); // └ print (fc::BoxDrawingsUpAndRight); // └
for (int x=x1+1; x < x2; x++) for (int x=x1+1; x < x2; x++)
print (fc::BoxDrawingsHorizontal); // ─ print (fc::BoxDrawingsHorizontal); // ─
print (fc::BoxDrawingsUpAndLeft); // ┘ print (fc::BoxDrawingsUpAndLeft); // ┘
for (int x=x1+1; x < x2; x++) for (int x=x1+1; x < x2; x++)

View File

@ -78,8 +78,10 @@ void FWindow::onWindowLowered (FEvent*)
void FWindow::show() void FWindow::show()
{ {
term_area* area = getVWin(); term_area* area = getVWin();
if ( area ) if ( area )
area->visible = true; area->visible = true;
FWidget::show(); FWidget::show();
} }
@ -87,8 +89,10 @@ void FWindow::show()
void FWindow::hide() void FWindow::hide()
{ {
term_area* area = getVWin(); term_area* area = getVWin();
if ( area ) if ( area )
area->visible = false; area->visible = false;
FWidget::hide(); FWidget::hide();
} }
@ -114,13 +118,16 @@ FWindow* FWindow::getWindowWidgetAt (int x, int y)
if ( *iter ) if ( *iter )
{ {
FWindow* w = static_cast<FWindow*>(*iter); FWindow* w = static_cast<FWindow*>(*iter);
if ( ! w->isHiddenWindow() if ( ! w->isHiddenWindow()
&& w->getGeometryGlobal().contains(x,y) ) && w->getGeometryGlobal().contains(x,y) )
return w; return w;
} }
} }
while ( iter != begin ); while ( iter != begin );
} }
return 0; return 0;
} }
@ -148,6 +155,7 @@ void FWindow::delWindow (FWidget* obj)
window_list->erase(iter); window_list->erase(iter);
return; return;
} }
++iter; ++iter;
} }
} }
@ -158,11 +166,13 @@ FWindow* FWindow::getWindowWidget (FWidget* obj)
{ {
// returns the window object to the given widget obj // returns the window object to the given widget obj
FWidget* p_obj = obj->getParentWidget(); FWidget* p_obj = obj->getParentWidget();
while ( ! obj->isWindow() && p_obj ) while ( ! obj->isWindow() && p_obj )
{ {
obj = p_obj; obj = p_obj;
p_obj = p_obj->getParentWidget(); p_obj = p_obj->getParentWidget();
} }
if ( obj->isWindow() ) if ( obj->isWindow() )
return static_cast<FWindow*>(obj); return static_cast<FWindow*>(obj);
else else
@ -178,6 +188,7 @@ int FWindow::getWindowLayer (FWidget* obj)
if ( ! window_list ) if ( ! window_list )
return -1; return -1;
if ( window_list->empty() ) if ( window_list->empty() )
return -1; return -1;
@ -196,6 +207,7 @@ int FWindow::getWindowLayer (FWidget* obj)
{ {
if ( *iter == window ) if ( *iter == window )
break; break;
++iter; ++iter;
} }
@ -210,10 +222,13 @@ void FWindow::swapWindow (FWidget* obj1, FWidget* obj2)
if ( ! window_list ) if ( ! window_list )
return; return;
if ( window_list->empty() ) if ( window_list->empty() )
return; return;
if ( (obj1->getFlags() & fc::modal) != 0 ) if ( (obj1->getFlags() & fc::modal) != 0 )
return; return;
if ( (obj2->getFlags() & fc::modal) != 0 ) if ( (obj2->getFlags() & fc::modal) != 0 )
return; return;
@ -228,6 +243,7 @@ void FWindow::swapWindow (FWidget* obj1, FWidget* obj2)
iter1 = iter; iter1 = iter;
else if ( (*iter) == obj2 ) else if ( (*iter) == obj2 )
iter2 = iter; iter2 = iter;
++iter; ++iter;
} }
@ -243,12 +259,16 @@ bool FWindow::raiseWindow (FWidget* obj)
if ( ! window_list ) if ( ! window_list )
return false; return false;
if ( window_list->empty() ) if ( window_list->empty() )
return false; return false;
if ( ! obj->isWindow() ) if ( ! obj->isWindow() )
return false; return false;
if ( window_list->back() == obj ) if ( window_list->back() == obj )
return false; return false;
if ( (window_list->back()->getFlags() & fc::modal) != 0 if ( (window_list->back()->getFlags() & fc::modal) != 0
&& ! obj->isMenu() ) && ! obj->isMenu() )
return false; return false;
@ -265,8 +285,10 @@ bool FWindow::raiseWindow (FWidget* obj)
FApplication::sendEvent(obj, &ev); FApplication::sendEvent(obj, &ev);
return true; return true;
} }
++iter; ++iter;
} }
return false; return false;
} }
@ -278,12 +300,16 @@ bool FWindow::lowerWindow (FWidget* obj)
if ( ! window_list ) if ( ! window_list )
return false; return false;
if ( window_list->empty() ) if ( window_list->empty() )
return false; return false;
if ( ! obj->isWindow() ) if ( ! obj->isWindow() )
return false; return false;
if ( window_list->front() == obj ) if ( window_list->front() == obj )
return false; return false;
if ( (obj->getFlags() & fc::modal) != 0 ) if ( (obj->getFlags() & fc::modal) != 0 )
return false; return false;
@ -299,8 +325,10 @@ bool FWindow::lowerWindow (FWidget* obj)
FApplication::sendEvent(obj, &ev); FApplication::sendEvent(obj, &ev);
return true; return true;
} }
++iter; ++iter;
} }
return false; return false;
} }
@ -312,6 +340,7 @@ void FWindow::setActiveWindow (FWindow* window)
if ( ! window_list ) if ( ! window_list )
return; return;
if ( window_list->empty() ) if ( window_list->empty() )
return; return;
@ -332,6 +361,7 @@ void FWindow::setActiveWindow (FWindow* window)
else else
{ {
FWindow* w = static_cast<FWindow*>(*iter); FWindow* w = static_cast<FWindow*>(*iter);
if ( w->isActiveWindow() ) if ( w->isActiveWindow() )
{ {
w->deactivateWindow(); w->deactivateWindow();
@ -339,6 +369,7 @@ void FWindow::setActiveWindow (FWindow* window)
FApplication::sendEvent(*iter, &ev); FApplication::sendEvent(*iter, &ev);
} }
} }
++iter; ++iter;
} }
} }
@ -356,16 +387,20 @@ void FWindow::switchToPrevWindow()
{ {
// switch to previous window // switch to previous window
activatePrevWindow(); activatePrevWindow();
FWindow* active_window = getActiveWindow(); FWindow* active_window = getActiveWindow();
if ( active_window ) if ( active_window )
{ {
FWidget* focus_widget = active_window->getFocusWidget(); FWidget* focus_widget = active_window->getFocusWidget();
if ( ! active_window->isActiveWindow() ) if ( ! active_window->isActiveWindow() )
setActiveWindow(active_window); setActiveWindow(active_window);
raiseWindow (active_window); raiseWindow (active_window);
if ( focus_widget ) if ( focus_widget )
focus_widget->setFocus(); focus_widget->setFocus();
active_window->redraw(); active_window->redraw();
} }
} }
@ -400,6 +435,7 @@ bool FWindow::isHiddenWindow() const
{ {
// returns the window hidden state // returns the window hidden state
term_area* area = getVWin(); term_area* area = getVWin();
if ( area ) if ( area )
return ! area->visible; return ! area->visible;
else else

View File

@ -59,6 +59,7 @@ void Button::setChecked (bool on)
setFocusForegroundColor(wc.button_active_focus_fg); setFocusForegroundColor(wc.button_active_focus_fg);
setFocusBackgroundColor(wc.button_active_focus_bg); setFocusBackgroundColor(wc.button_active_focus_bg);
} }
redraw(); redraw();
} }
} }
@ -224,7 +225,6 @@ Calc::Calc (FWidget* parent)
}; };
setlocale(LC_NUMERIC, "C"); setlocale(LC_NUMERIC, "C");
setText ("calculator"); setText ("calculator");
setGeometry (19, 6, 37, 18); setGeometry (19, 6, 37, 18);
addAccelerator('q'); // press 'q' to quit addAccelerator('q'); // press 'q' to quit
@ -245,12 +245,15 @@ Calc::Calc (FWidget* parent)
y = (key+n)/5*2 + 3; y = (key+n)/5*2 + 3;
btn->setGeometry(x, y, 5, 1); btn->setGeometry(x, y, 5, 1);
} }
btn->setFlat(); btn->setFlat();
btn->setNoUnderline(); btn->setNoUnderline();
btn->setText(button_text[key]); btn->setText(button_text[key]);
btn->setDoubleFlatLine(fc::top); btn->setDoubleFlatLine(fc::top);
if ( isNewFont() ) if ( isNewFont() )
btn->unsetClickAnimation(); btn->unsetClickAnimation();
if ( key <= Three ) if ( key <= Three )
btn->setDoubleFlatLine(fc::bottom); btn->setDoubleFlatLine(fc::bottom);
@ -311,15 +314,18 @@ void Calc::drawDispay()
display = " Error "; display = " Error ";
setColor(fc::Black, fc::LightGray); setColor(fc::Black, fc::LightGray);
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
gotoxy (xpos+xmin+1, ypos+ymin+1); gotoxy (xpos+xmin+1, ypos+ymin+1);
print(display); print(display);
print(L' '); print(L' ');
setColor(wc.dialog_fg, wc.dialog_bg); setColor(wc.dialog_fg, wc.dialog_bg);
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
if ( isNewFont() ) if ( isNewFont() )
{ {
FString bottom_line(33, wchar_t(fc::NF_border_line_bottom)); FString bottom_line(33, wchar_t(fc::NF_border_line_bottom));
@ -346,6 +352,7 @@ void Calc::drawDispay()
gotoxy (xpos+xmin-1, ypos+ymin+2); gotoxy (xpos+xmin-1, ypos+ymin+2);
print(separator); print(separator);
} }
setUpdateVTerm(true); setUpdateVTerm(true);
} }
@ -479,6 +486,7 @@ void Calc::calcInfixOperator()
case '^': case '^':
a = pow(a, b); a = pow(a, b);
if ( errno == EDOM || errno == ERANGE ) if ( errno == EDOM || errno == ERANGE )
error = true; error = true;
break; break;
@ -505,10 +513,12 @@ void Calc::onKeyPress (FKeyEvent* ev)
input = ""; input = "";
else else
input = input.left(input.getLength() - 1); input = input.left(input.getLength() - 1);
a = atof(input.c_str()); a = atof(input.c_str());
drawDispay(); drawDispay();
updateTerminal(); updateTerminal();
} }
ev->accept(); ev->accept();
break; break;
@ -568,8 +578,10 @@ void Calc::cb_buttonClicked (FWidget*, void* data_ptr)
if ( arcus_mode ) if ( arcus_mode )
{ {
*x = log(*x + sqrt((*x) * (*x) + 1)); *x = log(*x + sqrt((*x) * (*x) + 1));
if ( errno == EDOM || errno == ERANGE ) if ( errno == EDOM || errno == ERANGE )
error = true; error = true;
if ( *x == INFINITY ) if ( *x == INFINITY )
error = true; error = true;
} }
@ -585,8 +597,10 @@ void Calc::cb_buttonClicked (FWidget*, void* data_ptr)
else else
*x = sin(*x * PI/180.0L); *x = sin(*x * PI/180.0L);
} }
if ( errno == EDOM ) if ( errno == EDOM )
error = true; error = true;
setDisplay(*x); setDisplay(*x);
arcus_mode = false; arcus_mode = false;
hyperbolic_mode = false; hyperbolic_mode = false;
@ -600,8 +614,10 @@ void Calc::cb_buttonClicked (FWidget*, void* data_ptr)
if ( arcus_mode ) if ( arcus_mode )
{ {
*x = log(*x + sqrt((*x) * (*x) - 1)); *x = log(*x + sqrt((*x) * (*x) - 1));
if ( errno == EDOM || errno == ERANGE ) if ( errno == EDOM || errno == ERANGE )
error = true; error = true;
if ( *x == INFINITY ) if ( *x == INFINITY )
error = true; error = true;
} }
@ -617,8 +633,10 @@ void Calc::cb_buttonClicked (FWidget*, void* data_ptr)
else else
*x = cos(*x * PI/180.0L); *x = cos(*x * PI/180.0L);
} }
if ( errno == EDOM ) if ( errno == EDOM )
error = true; error = true;
setDisplay(*x); setDisplay(*x);
arcus_mode = false; arcus_mode = false;
hyperbolic_mode = false; hyperbolic_mode = false;
@ -633,6 +651,7 @@ void Calc::cb_buttonClicked (FWidget*, void* data_ptr)
if ( *x < 1 ) if ( *x < 1 )
{ {
*x = 0.5L * log((1+(*x))/(1-(*x))); *x = 0.5L * log((1+(*x))/(1-(*x)));
if ( errno == EDOM || errno == ERANGE ) if ( errno == EDOM || errno == ERANGE )
error = true; error = true;
} }
@ -655,8 +674,10 @@ void Calc::cb_buttonClicked (FWidget*, void* data_ptr)
else else
*x = tan(*x * PI/180.0L); *x = tan(*x * PI/180.0L);
} }
if ( errno == EDOM ) if ( errno == EDOM )
error = true; error = true;
setDisplay(*x); setDisplay(*x);
arcus_mode = false; arcus_mode = false;
hyperbolic_mode = false; hyperbolic_mode = false;
@ -688,50 +709,62 @@ void Calc::cb_buttonClicked (FWidget*, void* data_ptr)
case Natural_logarithm: // ln case Natural_logarithm: // ln
*x = log(*x); *x = log(*x);
if ( errno == EDOM || errno == ERANGE ) if ( errno == EDOM || errno == ERANGE )
error = true; error = true;
setDisplay(*x); setDisplay(*x);
break; break;
case Powers_of_e: // eˣ case Powers_of_e: // eˣ
*x = exp(*x); *x = exp(*x);
if ( errno == ERANGE ) if ( errno == ERANGE )
error = true; error = true;
setDisplay(*x); setDisplay(*x);
break; break;
case Power: // yˣ case Power: // yˣ
if ( ! isOperatorKey(last_key) ) if ( ! isOperatorKey(last_key) )
calcInfixOperator(); calcInfixOperator();
setDisplay(*x); setDisplay(*x);
setInfixOperator('^'); setInfixOperator('^');
break; break;
case Square_root: // sqrt case Square_root: // sqrt
*x = sqrt(*x); *x = sqrt(*x);
if ( errno == EDOM || errno == ERANGE ) if ( errno == EDOM || errno == ERANGE )
error = true; error = true;
setDisplay(*x); setDisplay(*x);
break; break;
case Divide: // ÷ case Divide: // ÷
if ( ! isOperatorKey(last_key) ) if ( ! isOperatorKey(last_key) )
calcInfixOperator(); calcInfixOperator();
setDisplay(a); setDisplay(a);
setInfixOperator('/'); setInfixOperator('/');
break; break;
case Common_logarithm: // lg case Common_logarithm: // lg
*x = log10(*x); *x = log10(*x);
if ( errno == EDOM || errno == ERANGE ) if ( errno == EDOM || errno == ERANGE )
error = true; error = true;
setDisplay(*x); setDisplay(*x);
break; break;
case Powers_of_ten: // 10ˣ case Powers_of_ten: // 10ˣ
*x = pow(10,*x); *x = pow(10,*x);
if ( errno == EDOM || errno == ERANGE ) if ( errno == EDOM || errno == ERANGE )
error = true; error = true;
setDisplay(*x); setDisplay(*x);
break; break;
@ -762,6 +795,7 @@ void Calc::cb_buttonClicked (FWidget*, void* data_ptr)
case Multiply: // * case Multiply: // *
if ( ! isOperatorKey(last_key) ) if ( ! isOperatorKey(last_key) )
calcInfixOperator(); calcInfixOperator();
setDisplay(a); setDisplay(a);
setInfixOperator('*'); setInfixOperator('*');
break; break;
@ -805,6 +839,7 @@ void Calc::cb_buttonClicked (FWidget*, void* data_ptr)
case Subtract: // - case Subtract: // -
if ( ! isOperatorKey(last_key) ) if ( ! isOperatorKey(last_key) )
calcInfixOperator(); calcInfixOperator();
setDisplay(a); setDisplay(a);
setInfixOperator('-'); setInfixOperator('-');
break; break;
@ -848,6 +883,7 @@ void Calc::cb_buttonClicked (FWidget*, void* data_ptr)
case Add: // + case Add: // +
if ( ! isOperatorKey(last_key) ) if ( ! isOperatorKey(last_key) )
calcInfixOperator(); calcInfixOperator();
setDisplay(a); setDisplay(a);
setInfixOperator('+'); setInfixOperator('+');
break; break;
@ -942,6 +978,7 @@ void Calc::cb_buttonClicked (FWidget*, void* data_ptr)
if ( infix_operator && ! isDataEntryKey(key) ) if ( infix_operator && ! isDataEntryKey(key) )
input = ""; input = "";
last_key = key; last_key = key;
} }

View File

@ -78,12 +78,15 @@ void Mandelbrot::draw()
x = xtemp; x = xtemp;
iter++; iter++;
} }
if ( iter < max_iter ) if ( iter < max_iter )
setColor(fc::Black, iter%16); setColor(fc::Black, iter%16);
else else
setColor(fc::Black, 0); setColor(fc::Black, 0);
print(' '); print(' ');
} }
current_line++; current_line++;
} }
@ -105,6 +108,7 @@ void Mandelbrot::onClose (FCloseEvent* ev)
"to quit the program ?" "to quit the program ?"
, FMessageBox::Yes , FMessageBox::Yes
, FMessageBox::No ); , FMessageBox::No );
if ( ret == FMessageBox::Yes ) if ( ret == FMessageBox::Yes )
ev->accept(); ev->accept();
else else

View File

@ -227,6 +227,7 @@ void Menu::onClose (FCloseEvent* ev)
"to quit the program ?" "to quit the program ?"
, FMessageBox::Yes , FMessageBox::Yes
, FMessageBox::No ); , FMessageBox::No );
if ( ret == FMessageBox::Yes ) if ( ret == FMessageBox::Yes )
ev->accept(); ev->accept();
else else

View File

@ -15,11 +15,13 @@ int main (int, char**)
// init current locale // init current locale
printf (" Locale: %s\n", setlocale(LC_CTYPE, "") ); printf (" Locale: %s\n", setlocale(LC_CTYPE, "") );
if ( isatty(1) && ! strcmp(nl_langinfo(CODESET), "ANSI_X3.4-1968") ) if ( isatty(1) && ! strcmp(nl_langinfo(CODESET), "ANSI_X3.4-1968") )
{ {
// locale C -> switch from 7bit ascii -> latin1 // locale C -> switch from 7bit ascii -> latin1
setlocale(LC_ALL, "en_US"); setlocale(LC_ALL, "en_US");
} }
printf (" Codeset: %s\n", nl_langinfo(CODESET)); printf (" Codeset: %s\n", nl_langinfo(CODESET));
std::cout << "--------------[ FString test ]-----------------" std::cout << "--------------[ FString test ]-----------------"
@ -78,26 +80,32 @@ int main (int, char**)
std::cout << " add: " << add13 << std::endl; std::cout << " add: " << add13 << std::endl;
FString cmp = "compare"; FString cmp = "compare";
if ( cmp == FString("compare") ) if ( cmp == FString("compare") )
std::cout << " cmp: == Ok" << std::endl; std::cout << " cmp: == Ok" << std::endl;
else else
std::cout << " cmp: == Not Ok" << std::endl; std::cout << " cmp: == Not Ok" << std::endl;
if ( cmp <= FString("d_compare") ) if ( cmp <= FString("d_compare") )
std::cout << " cmp: <= Ok" << std::endl; std::cout << " cmp: <= Ok" << std::endl;
else else
std::cout << " cmp: <= Not Ok" << std::endl; std::cout << " cmp: <= Not Ok" << std::endl;
if ( cmp < FString("e_compare") ) if ( cmp < FString("e_compare") )
std::cout << " cmp: < Ok" << std::endl; std::cout << " cmp: < Ok" << std::endl;
else else
std::cout << " cmp: < Not Ok" << std::endl; std::cout << " cmp: < Not Ok" << std::endl;
if ( cmp >= FString("b_compare") ) if ( cmp >= FString("b_compare") )
std::cout << " cmp: >= Ok" << std::endl; std::cout << " cmp: >= Ok" << std::endl;
else else
std::cout << " cmp: >= Not Ok" << std::endl; std::cout << " cmp: >= Not Ok" << std::endl;
if ( cmp > FString("a_compare") ) if ( cmp > FString("a_compare") )
std::cout << " cmp: > Ok" << std::endl; std::cout << " cmp: > Ok" << std::endl;
else else
std::cout << " cmp: > Not Ok" << std::endl; std::cout << " cmp: > Not Ok" << std::endl;
if ( cmp != FString("equal") ) if ( cmp != FString("equal") )
std::cout << " cmp: != Ok" << std::endl; std::cout << " cmp: != Ok" << std::endl;
else else
@ -109,8 +117,10 @@ int main (int, char**)
std::vector <FString> parts = split_str.split(","); std::vector <FString> parts = split_str.split(",");
std::vector<FString>::iterator it, end; std::vector<FString>::iterator it, end;
end = parts.end(); end = parts.end();
for (it = parts.begin(); it != end; ++it) for (it = parts.begin(); it != end; ++it)
std::cout << " \"" << (*it) << "\""; std::cout << " \"" << (*it) << "\"";
std::cout << std::endl; std::cout << std::endl;
FString formatStr = ""; FString formatStr = "";
@ -146,6 +156,7 @@ int main (int, char**)
} }
setlocale(LC_NUMERIC, "C"); setlocale(LC_NUMERIC, "C");
try try
{ {
double double_num = FString("2.7182818284590452353").toDouble(); double double_num = FString("2.7182818284590452353").toDouble();
@ -207,6 +218,7 @@ int main (int, char**)
<< alphabet.right(11) << "\"" << std::endl; << alphabet.right(11) << "\"" << std::endl;
FString insert_str = "I am a string"; FString insert_str = "I am a string";
try try
{ {
std::cout << " insert: " std::cout << " insert: "
@ -219,6 +231,7 @@ int main (int, char**)
FString index(5); // a string with five characters FString index(5); // a string with five characters
index = "index"; index = "index";
try try
{ {
index[0] = L'I'; // write a wide character at position 0 index[0] = L'I'; // write a wide character at position 0
@ -235,11 +248,13 @@ int main (int, char**)
FString::iterator iter; FString::iterator iter;
iter = stringIterator.begin(); iter = stringIterator.begin();
std::cout << " " << stringIterator << ": "; std::cout << " " << stringIterator << ": ";
while ( iter != stringIterator.end() ) while ( iter != stringIterator.end() )
{ {
std::cout << char(*iter) << "|"; std::cout << char(*iter) << "|";
++iter; ++iter;
} }
std::cout << " (front='" << char(stringIterator.front()) std::cout << " (front='" << char(stringIterator.front())
<< "', back='" << char(stringIterator.back()) << "', back='" << char(stringIterator.back())
<< "')" << std::endl; << "')" << std::endl;
@ -253,6 +268,7 @@ int main (int, char**)
<< remove_std.remove(7,2) << std::endl; << remove_std.remove(7,2) << std::endl;
FString include_std = "string"; FString include_std = "string";
if ( include_std.includes("ring") ) if ( include_std.includes("ring") )
std::cout << " includes: \"" std::cout << " includes: \""
<< include_std << "\" includes \"ring\" " << include_std << "\" includes \"ring\" "
@ -261,6 +277,7 @@ int main (int, char**)
std::cout << " includes: \"" std::cout << " includes: \""
<< include_std << "\" includes no \"ring\" " << include_std << "\" includes no \"ring\" "
<< std::endl; << std::endl;
if ( include_std.includes("data") ) if ( include_std.includes("data") )
std::cout << " includes: \"" std::cout << " includes: \""
<< include_std << "\" includes \"data\" " << include_std << "\" includes \"data\" "

View File

@ -65,6 +65,7 @@ AttribDlg::AttribDlg (FWidget* parent)
"clicked", "clicked",
_METHOD_CALLBACK (this, &AttribDlg::cb_next) _METHOD_CALLBACK (this, &AttribDlg::cb_next)
); );
back_button->addCallback back_button->addCallback
( (
"clicked", "clicked",
@ -102,6 +103,7 @@ void AttribDlg::onClose (FCloseEvent* ev)
"to quit the program ?" "to quit the program ?"
, FMessageBox::Yes , FMessageBox::Yes
, FMessageBox::No ); , FMessageBox::No );
if ( ret == FMessageBox::Yes ) if ( ret == FMessageBox::Yes )
ev->accept(); ev->accept();
else else
@ -113,9 +115,12 @@ void AttribDlg::cb_next (FWidget*, void*)
{ {
if ( isMonochron() ) if ( isMonochron() )
return; return;
bgcolor++; bgcolor++;
if ( bgcolor >= getMaxColor() ) if ( bgcolor >= getMaxColor() )
bgcolor = fc::Default; bgcolor = fc::Default;
redraw(); redraw();
} }
@ -124,9 +129,12 @@ void AttribDlg::cb_back (FWidget*, void*)
{ {
if ( isMonochron() ) if ( isMonochron() )
return; return;
bgcolor--; bgcolor--;
if ( bgcolor < fc::Default ) if ( bgcolor < fc::Default )
bgcolor = short(getMaxColor() - 1); bgcolor = short(getMaxColor() - 1);
redraw(); redraw();
} }
@ -135,8 +143,10 @@ void AttribDlg::adjustSize()
{ {
int x = ((getParentWidget()->getWidth() - getWidth()) / 2 ); int x = ((getParentWidget()->getWidth() - getWidth()) / 2 );
int y = ((getParentWidget()->getHeight() - getHeight()) / 2 ) + 1; int y = ((getParentWidget()->getHeight() - getHeight()) / 2 ) + 1;
if ( x < 1 ) if ( x < 1 )
x = 1; x = 1;
if ( y < 1 ) if ( y < 1 )
y = 1; y = 1;
@ -186,6 +196,7 @@ AttribDemo::AttribDemo (FWidget* parent)
colors = 1; colors = 1;
else if ( colors > 16 ) else if ( colors > 16 )
colors = 16; colors = 16;
unsetFocusable(); unsetFocusable();
} }
@ -211,6 +222,7 @@ void AttribDemo::printAltCharset()
gotoxy (xpos + xmin - 1, ypos + ymin - 1); gotoxy (xpos + xmin - 1, ypos + ymin - 1);
print("alternate charset: "); print("alternate charset: ");
if ( parent->bgcolor == fc::Default ) if ( parent->bgcolor == fc::Default )
{ {
setColor (fc::Default, fc::Default); setColor (fc::Default, fc::Default);
@ -222,6 +234,7 @@ void AttribDemo::printAltCharset()
else else
setColor (fc::Black, parent->bgcolor); setColor (fc::Black, parent->bgcolor);
} }
setAltCharset(); setAltCharset();
print("`abcdefghijklmnopqrstuvwxyz{|}~"); print("`abcdefghijklmnopqrstuvwxyz{|}~");
unsetAltCharset(); unsetAltCharset();
@ -342,16 +355,18 @@ void AttribDemo::draw()
if ( ! isMonochron() ) if ( ! isMonochron() )
setColor(wc.label_fg, wc.label_bg); setColor(wc.label_fg, wc.label_bg);
gotoxy (xpos + xmin - 1, ypos + ymin + 13); gotoxy (xpos + xmin - 1, ypos + ymin + 13);
short bg = static_cast<AttribDlg*>(getParent())->bgcolor; short bg = static_cast<AttribDlg*>(getParent())->bgcolor;
print (" Background color:"); print (" Background color:");
if ( bg == fc::Default ) if ( bg == fc::Default )
print (" default"); print (" default");
else else
printf ( " %d", bg); printf ( " %d", bg);
gotoxy (xpos + xmin + 14, ypos + ymin + 15); gotoxy (xpos + xmin + 14, ypos + ymin + 15);
print ("Change background color ->"); print ("Change background color ->");
setUpdateVTerm(true); setUpdateVTerm(true);
} }

View File

@ -130,8 +130,10 @@ void ProgressDialog::onTimer (FTimerEvent*)
more->setEnable(); more->setEnable();
quit->setEnable(); quit->setEnable();
redraw(); redraw();
if ( statusBar() ) if ( statusBar() )
statusBar()->drawMessage(); statusBar()->drawMessage();
updateTerminal(); updateTerminal();
flush_out(); flush_out();
} }
@ -621,6 +623,7 @@ void MyDialog::cb_drives (FWidget*, void*)
net.setGeometry (11, 4, 4, 1); net.setGeometry (11, 4, 4, 1);
FLabel cd (" CD ", &info2); FLabel cd (" CD ", &info2);
cd.setGeometry (11, 6, 4, 1); cd.setGeometry (11, 6, 4, 1);
if ( isMonochron() ) if ( isMonochron() )
{ {
net.setReverseMode(); net.setReverseMode();
@ -636,6 +639,7 @@ void MyDialog::cb_drives (FWidget*, void*)
cd.setForegroundColor (fc::White); cd.setForegroundColor (fc::White);
cd.setBackgroundColor (fc::DarkGray); cd.setBackgroundColor (fc::DarkGray);
} }
info2.exec(); info2.exec();
} }
} }
@ -645,6 +649,7 @@ void MyDialog::cb_cutClipboard (FWidget*, void*)
{ {
if ( ! myLineEdit ) if ( ! myLineEdit )
return; return;
clipboard = myLineEdit->getText(); clipboard = myLineEdit->getText();
myLineEdit->clearText(); myLineEdit->clearText();
myLineEdit->redraw(); myLineEdit->redraw();
@ -655,6 +660,7 @@ void MyDialog::cb_copyClipboard (FWidget*, void*)
{ {
if ( ! myLineEdit ) if ( ! myLineEdit )
return; return;
clipboard = myLineEdit->getText(); clipboard = myLineEdit->getText();
} }
@ -663,6 +669,7 @@ void MyDialog::cb_pasteClipboard (FWidget*, void*)
{ {
if ( ! myLineEdit ) if ( ! myLineEdit )
return; return;
myLineEdit->setText(clipboard); myLineEdit->setText(clipboard);
myLineEdit->redraw(); myLineEdit->redraw();
} }
@ -672,6 +679,7 @@ void MyDialog::cb_clearInput (FWidget*, void*)
{ {
if ( ! myLineEdit ) if ( ! myLineEdit )
return; return;
clipboard.clear(); clipboard.clear();
myLineEdit->clearText(); myLineEdit->clearText();
myLineEdit->redraw(); myLineEdit->redraw();
@ -709,9 +717,11 @@ void MyDialog::cb_updateNumber (FWidget* widget, void* data_ptr)
FLabel* num = static_cast<FLabel*>(data_ptr); FLabel* num = static_cast<FLabel*>(data_ptr);
int select_num = 0; int select_num = 0;
uInt end = list->count(); uInt end = list->count();
for (uInt n=1; n <= end; n++) for (uInt n=1; n <= end; n++)
if ( list->isSelected(int(n)) ) if ( list->isSelected(int(n)) )
select_num++; select_num++;
num->setNumber(select_num); num->setNumber(select_num);
num->redraw(); num->redraw();
} }
@ -721,10 +731,12 @@ void MyDialog::cb_activateButton (FWidget* widget, void* data_ptr)
{ {
FRadioButton* rb = static_cast<FRadioButton*>(widget); FRadioButton* rb = static_cast<FRadioButton*>(widget);
FButton* button = static_cast<FButton*>(data_ptr); FButton* button = static_cast<FButton*>(data_ptr);
if ( rb->isChecked() ) if ( rb->isChecked() )
button->setEnable(); button->setEnable();
else else
button->setDisable(); button->setDisable();
button->redraw(); button->redraw();
} }
@ -738,6 +750,7 @@ void MyDialog::cb_view (FWidget*, void* data_ptr)
file = item->getText(); file = item->getText();
else else
file = FFileDialog::fileOpenChooser (this); file = FFileDialog::fileOpenChooser (this);
if ( file.isNull() ) if ( file.isNull() )
return; return;
@ -765,13 +778,16 @@ void MyDialog::cb_view (FWidget*, void* data_ptr)
std::string line = ""; std::string line = "";
std::ifstream infile; std::ifstream infile;
infile.open(file); infile.open(file);
while ( ! infile.eof() && infile.good() ) while ( ! infile.eof() && infile.good() )
{ {
getline(infile, line); getline(infile, line);
scrollText->append(line); scrollText->append(line);
} }
if ( infile.is_open() ) if ( infile.is_open() )
infile.close(); infile.close();
view->show(); view->show();
} }
@ -796,11 +812,15 @@ void MyDialog::adjustSize()
int h = getParentWidget()->getHeight() - 4; int h = getParentWidget()->getHeight() - 4;
setHeight (h, false); setHeight (h, false);
int X = int((getParentWidget()->getWidth() - getWidth()) / 2); int X = int((getParentWidget()->getWidth() - getWidth()) / 2);
if ( X < 1 ) if ( X < 1 )
X = 1; X = 1;
setX (X, false); setX (X, false);
if ( myList ) if ( myList )
myList->setHeight (getHeight() - 3, false); myList->setHeight (getHeight() - 3, false);
FDialog::adjustSize(); FDialog::adjustSize();
} }