Refactoring of some functions

This commit is contained in:
Markus Gans 2018-02-11 23:41:23 +01:00
parent 2af1b1d0d4
commit d8a6c25ce0
9 changed files with 403 additions and 341 deletions

View File

@ -1,4 +1,11 @@
2017-10-02 Markus Gans <guru.mail@muenster.de> 2017-02-11 Markus Gans <guru.mail@muenster.de>
* Refactoring FWidget::focusNextChild and FWidget::focusPrevChild
* Refactoring FListView::onWheel
* Refactoring FListView::drawColumnLabels
* Refactoring FTerm::getSystemTermType
* Rename getTermName() to getTermFileName()
2017-02-10 Markus Gans <guru.mail@muenster.de>
* Refactoring FOptiMove::verticalMove and FOptiMove::horizontalMove * Refactoring FOptiMove::verticalMove and FOptiMove::horizontalMove
* Refactoring FVTerm::getCharacter * Refactoring FVTerm::getCharacter
* Refactoring FWidget::drawBorder * Refactoring FWidget::drawBorder

View File

@ -828,7 +828,7 @@ void MyDialog::cb_terminfo (FWidget*, data_ptr)
FMessageBox info1 ( "Environment" FMessageBox info1 ( "Environment"
, FString() , FString()
<< " Type: " << getTermType() << "\n" << " Type: " << getTermType() << "\n"
<< " Name: " << getTermName() << "\n" << " Name: " << getTermFileName() << "\n"
<< " Mode: " << getEncodingString() << "\n" << " Mode: " << getEncodingString() << "\n"
<< " Size: " << x << wchar_t(fc::Times) << " Size: " << x << wchar_t(fc::Times)
<< y << "\n" << y << "\n"

View File

@ -323,9 +323,16 @@ class FListView : public FWidget
void drawListLine (const FListViewItem*, bool, bool); void drawListLine (const FListViewItem*, bool, bool);
void setLineAttributes (bool, bool); void setLineAttributes (bool, bool);
FString getLinePrefix (const FListViewItem*, uInt); FString getLinePrefix (const FListViewItem*, uInt);
void drawColumnText (headerItems::const_iterator&);
void drawColumnEllipsis ( headerItems::const_iterator&
, const FString& );
void updateDrawing (bool, bool); void updateDrawing (bool, bool);
void recalculateHorizontalBar (int); void recalculateHorizontalBar (int);
void recalculateVerticalBar (int); void recalculateVerticalBar (int);
void wheelUp (int);
void wheelDown (int);
bool dragScrollUp (int);
bool dragScrollDown (int);
FObjectIterator appendItem (FListViewItem*); FObjectIterator appendItem (FListViewItem*);
void processClick(); void processClick();
void processChanged(); void processChanged();

View File

@ -173,7 +173,7 @@ class FTerm
#endif #endif
static char* getTermType(); static char* getTermType();
static char* getTermName(); static char* getTermFileName();
static int getTabstop(); static int getTabstop();
static int getMaxColor(); static int getMaxColor();
@ -437,6 +437,10 @@ class FTerm
static int openConsole(); static int openConsole();
static int closeConsole(); static int closeConsole();
static void getSystemTermType(); static void getSystemTermType();
static void getTTYtype();
#if F_HAVE_GETTTYNAM
static bool getTTYSFileEntry();
#endif
static void storeTTYsettings(); static void storeTTYsettings();
static void restoreTTYsettings(); static void restoreTTYsettings();
@ -576,7 +580,7 @@ class FTerm
static bool screen_terminal; static bool screen_terminal;
static bool tmux_terminal; static bool tmux_terminal;
static char termtype[256]; static char termtype[256];
static char term_name[256]; static char termfilename[256];
static char* locale_name; static char* locale_name;
static char* locale_xterm; static char* locale_xterm;
static FRect* term; // current terminal geometry static FRect* term; // current terminal geometry
@ -662,8 +666,8 @@ inline char* FTerm::getTermType()
{ return termtype; } { return termtype; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline char* FTerm::getTermName() inline char* FTerm::getTermFileName()
{ return term_name; } { return termfilename; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline int FTerm::getTabstop() inline int FTerm::getTabstop()

View File

@ -342,8 +342,8 @@ class FWidget : public FVTerm, public FObject
// Methods // Methods
virtual void adjustSize(); virtual void adjustSize();
void adjustSizeGlobal(); void adjustSizeGlobal();
virtual bool focusNextChild(); // Change child virtual bool focusNextChild(); // Change child...
virtual bool focusPrevChild(); // focus virtual bool focusPrevChild(); // ...focus
// Event handlers // Event handlers
bool event (FEvent*); bool event (FEvent*);
@ -388,6 +388,7 @@ class FWidget : public FVTerm, public FObject
void insufficientSpaceAdjust(); void insufficientSpaceAdjust();
void KeyPressEvent (FKeyEvent*); void KeyPressEvent (FKeyEvent*);
void KeyDownEvent (FKeyEvent*); void KeyDownEvent (FKeyEvent*);
bool changeFocus (FWidget*, FWidget*, fc::FocusTypes);
void processDestroy(); void processDestroy();
virtual void draw(); virtual void draw();
void drawWindows(); void drawWindows();

View File

@ -1020,8 +1020,7 @@ void FListView::onMouseDoubleClick (FMouseEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::onTimer (FTimerEvent*) void FListView::onTimer (FTimerEvent*)
{ {
int element_count = int(getCount()) int position_before = current_iter.getPosition()
, position_before = current_iter.getPosition()
, first_line_position_before = first_visible_line.getPosition(); , first_line_position_before = first_visible_line.getPosition();
switch ( int(drag_scroll) ) switch ( int(drag_scroll) )
@ -1031,24 +1030,14 @@ void FListView::onTimer (FTimerEvent*)
case fc::scrollUp: case fc::scrollUp:
case fc::scrollUpSelect: case fc::scrollUpSelect:
if ( position_before == 0 ) if ( ! dragScrollUp(position_before) )
{
drag_scroll = fc::noScroll;
return; return;
}
stepBackward(scroll_distance);
break; break;
case fc::scrollDown: case fc::scrollDown:
case fc::scrollDownSelect: case fc::scrollDownSelect:
if ( position_before + 1 == element_count ) if ( ! dragScrollDown(position_before) )
{
drag_scroll = fc::noScroll;
return; return;
}
stepForward(scroll_distance);
break; break;
default: default:
@ -1071,14 +1060,10 @@ void FListView::onTimer (FTimerEvent*)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::onWheel (FWheelEvent* ev) void FListView::onWheel (FWheelEvent* ev)
{ {
int wheel int position_before = current_iter.getPosition()
, element_count = int(getCount())
, position_before = current_iter.getPosition()
, first_line_position_before = first_visible_line.getPosition() , first_line_position_before = first_visible_line.getPosition()
, pagesize = 4; , pagesize = 4;
wheel = ev->getWheel();
if ( drag_scroll != fc::noScroll ) if ( drag_scroll != fc::noScroll )
{ {
delOwnTimer(); delOwnTimer();
@ -1087,52 +1072,14 @@ void FListView::onWheel (FWheelEvent* ev)
drag_scroll = fc::noScroll; drag_scroll = fc::noScroll;
} }
switch ( wheel ) switch ( ev->getWheel() )
{ {
case fc::WheelUp: case fc::WheelUp:
if ( current_iter.getPosition() == 0 ) wheelUp (pagesize);
break;
if ( first_visible_line.getPosition() >= pagesize )
{
current_iter -= pagesize;
first_visible_line -= pagesize;
last_visible_line -= pagesize;
}
else
{
// Save relative position from the first line
int ry = current_iter.getPosition() - first_visible_line.getPosition();
// Save difference from top
int difference = first_visible_line.getPosition();
first_visible_line -= difference;
last_visible_line -= difference;
setRelativePosition(ry);
}
break; break;
case fc::WheelDown: case fc::WheelDown:
if ( current_iter.getPosition() + 1 == element_count ) wheelDown (pagesize);
break;
if ( last_visible_line.getPosition() < element_count - pagesize )
{
current_iter += pagesize;
first_visible_line += pagesize;
last_visible_line += pagesize;
}
else
{
// Save relative position from the first line
int ry = current_iter.getPosition() - first_visible_line.getPosition();
// Save difference from bottom
int differenz = element_count - last_visible_line.getPosition() - 1;
first_visible_line += differenz;
last_visible_line += differenz;
setRelativePosition(ry);
}
break; break;
default: default:
@ -1384,13 +1331,8 @@ void FListView::draw()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::drawColumnLabels() void FListView::drawColumnLabels()
{ {
static const int leading_space = 1;
static const int trailing_space = 1;
static const int ellipsis_length = 2;
std::vector<char_data>::const_iterator first, last; std::vector<char_data>::const_iterator first, last;
headerItems::const_iterator iter; headerItems::const_iterator iter;
FString txt;
uInt txt_length;
if ( header.empty() if ( header.empty()
|| getHeight() <= 2 || getHeight() <= 2
@ -1404,8 +1346,6 @@ void FListView::drawColumnLabels()
while ( iter != header.end() ) while ( iter != header.end() )
{ {
const FString& text = (*iter).name; const FString& text = (*iter).name;
int width = (*iter).width;
int column_width;
if ( text.isNull() || text.isEmpty() ) if ( text.isNull() || text.isEmpty() )
{ {
@ -1413,42 +1353,7 @@ void FListView::drawColumnLabels()
continue; continue;
} }
txt = " " + text; drawColumnText(iter);
txt_length = txt.getLength();
column_width = leading_space + width;
if ( isEnabled() )
setColor (wc.label_emphasis_fg, wc.label_bg);
else
setColor (wc.label_inactive_fg, wc.label_inactive_bg);
if ( txt_length <= uInt(column_width) )
{
headerline << txt;
if ( txt_length < uInt(column_width) )
headerline << ' '; // trailing space
if ( txt_length + trailing_space < uInt(column_width) )
{
setColor();
const FString line ( uInt(column_width) - trailing_space - txt_length
, wchar_t(fc::BoxDrawingsHorizontal) );
headerline << line; // horizontal line
}
}
else
{
// Print ellipsis
headerline << ' ';
headerline << text.left(uInt(width - ellipsis_length));
setColor (wc.label_ellipsis_fg, wc.label_bg);
headerline << "..";
if ( iter == header.end() - 1 ) // Last element
headerline << ' ';
}
++iter; ++iter;
} }
@ -1660,6 +1565,59 @@ inline FString FListView::getLinePrefix ( const FListViewItem* item
return line; return line;
} }
//----------------------------------------------------------------------
void FListView::drawColumnText (headerItems::const_iterator& iter)
{
// Print lable text
static const int leading_space = 1;
static const int trailing_space = 1;
const FString& text = (*iter).name;
int width = (*iter).width;
FString txt = " " + text;
uInt txt_length = txt.getLength();
int column_width = leading_space + width;
if ( isEnabled() )
setColor (wc.label_emphasis_fg, wc.label_bg);
else
setColor (wc.label_inactive_fg, wc.label_inactive_bg);
if ( txt_length <= uInt(column_width) )
{
headerline << txt;
if ( txt_length < uInt(column_width) )
headerline << ' '; // trailing space
if ( txt_length + trailing_space < uInt(column_width) )
{
setColor();
const FString line ( uInt(column_width) - trailing_space - txt_length
, wchar_t(fc::BoxDrawingsHorizontal) );
headerline << line; // horizontal line
}
}
else
drawColumnEllipsis (iter, text); // Print ellipsis
}
//----------------------------------------------------------------------
void FListView::drawColumnEllipsis ( headerItems::const_iterator& iter
, const FString& text )
{
// Print lable ellipsis
static const int ellipsis_length = 2;
int width = (*iter).width;
headerline << ' ';
headerline << text.left(uInt(width - ellipsis_length));
setColor (wc.label_ellipsis_fg, wc.label_bg);
headerline << "..";
if ( iter == header.end() - 1 ) // Last element
headerline << ' ';
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::updateDrawing (bool draw_vbar, bool draw_hbar) void FListView::updateDrawing (bool draw_vbar, bool draw_hbar)
{ {
@ -1710,6 +1668,84 @@ void FListView::recalculateVerticalBar (int element_count)
vbar->setVisible(); vbar->setVisible();
} }
//----------------------------------------------------------------------
void FListView::wheelUp (int pagesize)
{
if ( current_iter.getPosition() == 0 )
return;
if ( first_visible_line.getPosition() >= pagesize )
{
current_iter -= pagesize;
first_visible_line -= pagesize;
last_visible_line -= pagesize;
}
else
{
// Save relative position from the first line
int ry = current_iter.getPosition() - first_visible_line.getPosition();
// Save difference from top
int difference = first_visible_line.getPosition();
first_visible_line -= difference;
last_visible_line -= difference;
setRelativePosition(ry);
}
}
//----------------------------------------------------------------------
void FListView::wheelDown (int pagesize)
{
int element_count = int(getCount());
if ( current_iter.getPosition() + 1 == element_count )
return;
if ( last_visible_line.getPosition() < element_count - pagesize )
{
current_iter += pagesize;
first_visible_line += pagesize;
last_visible_line += pagesize;
}
else
{
// Save relative position from the first line
int ry = current_iter.getPosition() - first_visible_line.getPosition();
// Save difference from bottom
int differenz = element_count - last_visible_line.getPosition() - 1;
first_visible_line += differenz;
last_visible_line += differenz;
setRelativePosition(ry);
}
}
//----------------------------------------------------------------------
bool FListView::dragScrollUp (int position_before)
{
if ( position_before == 0 )
{
drag_scroll = fc::noScroll;
return false;
}
stepBackward(scroll_distance);
return true;
}
//----------------------------------------------------------------------
bool FListView::dragScrollDown (int position_before)
{
int element_count = int(getCount());
if ( position_before + 1 == element_count )
{
drag_scroll = fc::noScroll;
return false;
}
stepForward(scroll_distance);
return true;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FObject::FObjectIterator FListView::appendItem (FListViewItem* item) FObject::FObjectIterator FListView::appendItem (FListViewItem* item)
{ {

View File

@ -810,7 +810,6 @@ inline int FOptiMove::horizontalMove (char hmove[], int from_x, int to_x)
inline void FOptiMove::rightMove ( char hmove[], int& htime inline void FOptiMove::rightMove ( char hmove[], int& htime
, int from_x, int to_x ) , int from_x, int to_x )
{ {
char str[BUF_SIZE] = {};
int num = to_x - from_x; int num = to_x - from_x;
if ( F_parm_right_cursor.cap && F_parm_right_cursor.duration < htime ) if ( F_parm_right_cursor.cap && F_parm_right_cursor.duration < htime )
@ -823,6 +822,7 @@ inline void FOptiMove::rightMove ( char hmove[], int& htime
if ( F_cursor_right.cap ) if ( F_cursor_right.cap )
{ {
char str[BUF_SIZE] = {};
int htime_r = 0; int htime_r = 0;
str[0] = '\0'; str[0] = '\0';

View File

@ -101,7 +101,7 @@ bool FTerm::xterm_default_colors;
bool FTerm::use_alternate_screen = true; bool FTerm::use_alternate_screen = true;
termios FTerm::term_init; termios FTerm::term_init;
char FTerm::termtype[256] = {}; char FTerm::termtype[256] = {};
char FTerm::term_name[256] = {}; char FTerm::termfilename[256] = {};
#if DEBUG #if DEBUG
char FTerm::termtype_256color[256] = {}; char FTerm::termtype_256color[256] = {};
@ -1989,7 +1989,7 @@ int FTerm::openConsole()
if ( fd_tty >= 0 ) // console is already opened if ( fd_tty >= 0 ) // console is already opened
return 0; return 0;
if ( ! *term_name ) if ( ! *termfilename )
return 0; return 0;
for (int i = 0; terminal_devices[i] != 0; i++) for (int i = 0; terminal_devices[i] != 0; i++)
@ -2022,21 +2022,29 @@ void FTerm::getSystemTermType()
if ( term_env ) if ( term_env )
{ {
// Save name in termtype
std::strncpy (termtype, term_env, sizeof(termtype) - 1); std::strncpy (termtype, term_env, sizeof(termtype) - 1);
return; return;
} }
else if ( *term_name ) // fallback: look into /etc/ttytype or /etc/ttys else if ( *termfilename ) // 1st fallback: use the teminal file name
{ {
// get term basename getTTYtype(); // Look into /etc/ttytype
const char* term_basename = std::strrchr(term_name, '/');
if ( term_basename == 0 ) #if F_HAVE_GETTTYNAM
term_basename = term_name; if ( getTTYSFileEntry() ) // Look into /etc/ttys
else return;
term_basename++; #endif
}
// Analyse /etc/ttytype // 2nd fallback: use vt100 if not found
// -------------------- std::strncpy (termtype, C_STR("vt100"), 6);
}
//----------------------------------------------------------------------
void FTerm::getTTYtype()
{
// Analyse /etc/ttytype and get the term name
// ------------------------------------------
// file format: // file format:
// <terminal type> <whitespace> <tty name> // <terminal type> <whitespace> <tty name>
// //
@ -2044,6 +2052,14 @@ void FTerm::getSystemTermType()
// linux tty1 // linux tty1
// vt100 ttys0 // vt100 ttys0
// Get term basename
const char* term_basename = std::strrchr(termfilename, '/');
if ( term_basename == 0 )
term_basename = termfilename;
else
term_basename++;
std::FILE *fp; std::FILE *fp;
if ( (fp = std::fopen("/etc/ttytype", "r")) != 0 ) if ( (fp = std::fopen("/etc/ttytype", "r")) != 0 )
@ -2051,7 +2067,7 @@ void FTerm::getSystemTermType()
char* p; char* p;
char str[BUFSIZ]; char str[BUFSIZ];
// read and parse the file // Read and parse the file
while ( fgets(str, sizeof(str) - 1, fp) != 0 ) while ( fgets(str, sizeof(str) - 1, fp) != 0 )
{ {
char* name; char* name;
@ -2073,6 +2089,7 @@ void FTerm::getSystemTermType()
if ( type != 0 && name != 0 && ! std::strcmp(name, term_basename) ) if ( type != 0 && name != 0 && ! std::strcmp(name, term_basename) )
{ {
// Save name in termtype
std::strncpy (termtype, type, sizeof(termtype) - 1); std::strncpy (termtype, type, sizeof(termtype) - 1);
std::fclose(fp); std::fclose(fp);
return; return;
@ -2081,11 +2098,22 @@ void FTerm::getSystemTermType()
std::fclose(fp); std::fclose(fp);
} }
}
#if F_HAVE_GETTTYNAM #if F_HAVE_GETTTYNAM
//----------------------------------------------------------------------
bool FTerm::getTTYSFileEntry()
{
// Analyse /etc/ttys and get the term name
// get term basename
const char* term_basename = std::strrchr(termfilename, '/');
if ( term_basename == 0 )
term_basename = termfilename;
else
term_basename++;
// Analyse /etc/ttys
// --------------------
struct ttyent* ttys_entryt; struct ttyent* ttys_entryt;
ttys_entryt = getttynam(term_basename); ttys_entryt = getttynam(term_basename);
@ -2095,19 +2123,17 @@ void FTerm::getSystemTermType()
if ( type != 0 ) if ( type != 0 )
{ {
// Save name in termtype
std::strncpy (termtype, type, sizeof(termtype) - 1); std::strncpy (termtype, type, sizeof(termtype) - 1);
endttyent(); endttyent();
return; return true;
} }
} }
endttyent(); endttyent();
return false;
}
#endif #endif
}
// use vt100 if not found
std::strncpy (termtype, C_STR("vt100"), 6);
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::storeTTYsettings() void FTerm::storeTTYsettings()
@ -4420,8 +4446,8 @@ void FTerm::init()
std::abort(); std::abort();
// Get pathname of the terminal device // Get pathname of the terminal device
if ( ttyname_r(stdout_no, term_name, sizeof(term_name)) ) if ( ttyname_r(stdout_no, termfilename, sizeof(termfilename)) )
term_name[0] = '\0'; termfilename[0] = '\0';
initOSspecifics(); initOSspecifics();

View File

@ -1761,15 +1761,14 @@ void FWidget::adjustSizeGlobal()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FWidget::focusNextChild() bool FWidget::focusNextChild()
{ {
if ( isDialogWidget() ) if ( isDialogWidget() || ! hasParent() )
return false; return false;
if ( hasParent() )
{
FWidget* parent = getParentWidget(); FWidget* parent = getParentWidget();
if ( parent->hasChildren() && parent->numOfFocusableChildren() > 1 ) if ( ! parent->hasChildren() || parent->numOfFocusableChildren() <= 1 )
{ return false;
FObjectIterator iter, last; FObjectIterator iter, last;
iter = parent->begin(); iter = parent->begin();
last = parent->end(); last = parent->end();
@ -1784,8 +1783,12 @@ bool FWidget::focusNextChild()
FWidget* w = static_cast<FWidget*>(*iter); FWidget* w = static_cast<FWidget*>(*iter);
if ( w == this ) if ( w != this )
{ {
++iter;
continue;
}
FWidget* next = 0; FWidget* next = 0;
constFObjectIterator next_element; constFObjectIterator next_element;
next_element = iter; next_element = iter;
@ -1807,60 +1810,28 @@ bool FWidget::focusNextChild()
|| ! next->isVisible() || ! next->isVisible()
|| next->isWindowWidget() ); || next->isWindowWidget() );
FFocusEvent out (fc::FocusOut_Event); bool accpt = changeFocus (next, parent, fc::FocusNextWidget);
out.setFocusType(fc::FocusNextWidget);
FApplication::sendEvent(this, &out);
FFocusEvent cfo (fc::ChildFocusOut_Event); if ( ! accpt )
cfo.setFocusType(fc::FocusNextWidget);
cfo.ignore();
FApplication::sendEvent(parent, &cfo);
if ( cfo.isAccepted() )
out.ignore();
if ( out.isAccepted() )
{
if ( next == this )
return false; return false;
next->setFocus(); break; // The focus has been changed
FFocusEvent cfi (fc::ChildFocusIn_Event); }
FApplication::sendEvent(parent, &cfi);
FFocusEvent in (fc::FocusIn_Event);
in.setFocusType(fc::FocusNextWidget);
FApplication::sendEvent(next, &in);
if ( in.isAccepted() )
{
redraw();
next->redraw();
updateTerminal();
flush_out();
}
}
break;
}
++iter;
}
}
}
return true; return true;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FWidget::focusPrevChild() bool FWidget::focusPrevChild()
{ {
if ( isDialogWidget() ) if ( isDialogWidget() || ! hasParent() )
return false; return false;
if ( hasParent() )
{
FWidget* parent = getParentWidget(); FWidget* parent = getParentWidget();
if ( parent->hasChildren() && parent->numOfFocusableChildren() > 1 ) if ( ! parent->hasChildren() || parent->numOfFocusableChildren() <= 1 )
{ return false;
FObjectIterator iter, first; FObjectIterator iter, first;
iter = parent->end(); iter = parent->end();
first = parent->begin(); first = parent->begin();
@ -1874,8 +1845,9 @@ bool FWidget::focusPrevChild()
FWidget* w = static_cast<FWidget*>(*iter); FWidget* w = static_cast<FWidget*>(*iter);
if ( w == this ) if ( w != this )
{ continue;
FWidget* prev = 0; FWidget* prev = 0;
constFObjectIterator prev_element; constFObjectIterator prev_element;
prev_element = iter; prev_element = iter;
@ -1899,46 +1871,14 @@ bool FWidget::focusPrevChild()
|| ! prev->isVisible() || ! prev->isVisible()
|| prev->isWindowWidget() ); || prev->isWindowWidget() );
FFocusEvent out (fc::FocusOut_Event); bool accpt = changeFocus (prev, parent, fc::FocusPreviousWidget);
out.setFocusType(fc::FocusPreviousWidget);
FApplication::sendEvent(this, &out);
FFocusEvent cfo (fc::ChildFocusOut_Event); if ( ! accpt )
cfo.setFocusType(fc::FocusPreviousWidget);
cfo.ignore();
FApplication::sendEvent(parent, &cfo);
if ( cfo.isAccepted() )
out.ignore();
if ( out.isAccepted() )
{
if ( prev == this )
return false; return false;
prev->setFocus(); break; // The focus has been changed
FFocusEvent cfi (fc::ChildFocusIn_Event);
FApplication::sendEvent(parent, &cfi);
FFocusEvent in (fc::FocusIn_Event);
in.setFocusType(fc::FocusPreviousWidget);
FApplication::sendEvent(prev, &in);
if ( in.isAccepted() )
{
redraw();
prev->redraw();
updateTerminal();
flush_out();
}
}
break;
}
} }
while ( iter != first ); while ( iter != first );
}
}
return true; return true;
} }
@ -2294,6 +2234,47 @@ void FWidget::KeyDownEvent (FKeyEvent* kev)
} }
} }
//----------------------------------------------------------------------
bool FWidget::changeFocus ( FWidget* follower, FWidget* parent
, fc::FocusTypes ft )
{
FFocusEvent out (fc::FocusOut_Event);
out.setFocusType(ft);
FApplication::sendEvent(this, &out);
FFocusEvent cfo (fc::ChildFocusOut_Event);
cfo.setFocusType(ft);
cfo.ignore();
FApplication::sendEvent(parent, &cfo);
if ( cfo.isAccepted() )
out.ignore();
if ( out.isAccepted() )
{
if ( follower == this )
return false;
follower->setFocus();
FFocusEvent cfi (fc::ChildFocusIn_Event);
FApplication::sendEvent(parent, &cfi);
FFocusEvent in (fc::FocusIn_Event);
in.setFocusType(ft);
FApplication::sendEvent(follower, &in);
if ( in.isAccepted() )
{
redraw();
follower->redraw();
updateTerminal();
flush_out();
}
}
return true;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::draw() void FWidget::draw()
{ } { }