diff --git a/ChangeLog b/ChangeLog index 6b7eb35d..33ed2fb1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,11 @@ -2017-10-02 Markus Gans +2017-02-11 Markus Gans + * Refactoring FWidget::focusNextChild and FWidget::focusPrevChild + * Refactoring FListView::onWheel + * Refactoring FListView::drawColumnLabels + * Refactoring FTerm::getSystemTermType + * Rename getTermName() to getTermFileName() + +2017-02-10 Markus Gans * Refactoring FOptiMove::verticalMove and FOptiMove::horizontalMove * Refactoring FVTerm::getCharacter * Refactoring FWidget::drawBorder diff --git a/examples/ui.cpp b/examples/ui.cpp index c5b956fa..ca6d7563 100644 --- a/examples/ui.cpp +++ b/examples/ui.cpp @@ -828,7 +828,7 @@ void MyDialog::cb_terminfo (FWidget*, data_ptr) FMessageBox info1 ( "Environment" , FString() << " Type: " << getTermType() << "\n" - << " Name: " << getTermName() << "\n" + << " Name: " << getTermFileName() << "\n" << " Mode: " << getEncodingString() << "\n" << " Size: " << x << wchar_t(fc::Times) << y << "\n" diff --git a/include/final/flistview.h b/include/final/flistview.h index 82378e63..e8926e24 100644 --- a/include/final/flistview.h +++ b/include/final/flistview.h @@ -323,9 +323,16 @@ class FListView : public FWidget void drawListLine (const FListViewItem*, bool, bool); void setLineAttributes (bool, bool); FString getLinePrefix (const FListViewItem*, uInt); + void drawColumnText (headerItems::const_iterator&); + void drawColumnEllipsis ( headerItems::const_iterator& + , const FString& ); void updateDrawing (bool, bool); void recalculateHorizontalBar (int); void recalculateVerticalBar (int); + void wheelUp (int); + void wheelDown (int); + bool dragScrollUp (int); + bool dragScrollDown (int); FObjectIterator appendItem (FListViewItem*); void processClick(); void processChanged(); diff --git a/include/final/fterm.h b/include/final/fterm.h index fe78a481..08f235dc 100644 --- a/include/final/fterm.h +++ b/include/final/fterm.h @@ -173,7 +173,7 @@ class FTerm #endif static char* getTermType(); - static char* getTermName(); + static char* getTermFileName(); static int getTabstop(); static int getMaxColor(); @@ -437,6 +437,10 @@ class FTerm static int openConsole(); static int closeConsole(); static void getSystemTermType(); + static void getTTYtype(); +#if F_HAVE_GETTTYNAM + static bool getTTYSFileEntry(); +#endif static void storeTTYsettings(); static void restoreTTYsettings(); @@ -576,7 +580,7 @@ class FTerm static bool screen_terminal; static bool tmux_terminal; static char termtype[256]; - static char term_name[256]; + static char termfilename[256]; static char* locale_name; static char* locale_xterm; static FRect* term; // current terminal geometry @@ -662,8 +666,8 @@ inline char* FTerm::getTermType() { return termtype; } //---------------------------------------------------------------------- -inline char* FTerm::getTermName() -{ return term_name; } +inline char* FTerm::getTermFileName() +{ return termfilename; } //---------------------------------------------------------------------- inline int FTerm::getTabstop() diff --git a/include/final/fwidget.h b/include/final/fwidget.h index 7cf90c4b..ae9ca1a8 100644 --- a/include/final/fwidget.h +++ b/include/final/fwidget.h @@ -342,8 +342,8 @@ class FWidget : public FVTerm, public FObject // Methods virtual void adjustSize(); void adjustSizeGlobal(); - virtual bool focusNextChild(); // Change child - virtual bool focusPrevChild(); // focus + virtual bool focusNextChild(); // Change child... + virtual bool focusPrevChild(); // ...focus // Event handlers bool event (FEvent*); @@ -388,6 +388,7 @@ class FWidget : public FVTerm, public FObject void insufficientSpaceAdjust(); void KeyPressEvent (FKeyEvent*); void KeyDownEvent (FKeyEvent*); + bool changeFocus (FWidget*, FWidget*, fc::FocusTypes); void processDestroy(); virtual void draw(); void drawWindows(); diff --git a/src/flistview.cpp b/src/flistview.cpp index 917c2543..a19b1a89 100644 --- a/src/flistview.cpp +++ b/src/flistview.cpp @@ -1020,8 +1020,7 @@ void FListView::onMouseDoubleClick (FMouseEvent* ev) //---------------------------------------------------------------------- void FListView::onTimer (FTimerEvent*) { - int element_count = int(getCount()) - , position_before = current_iter.getPosition() + int position_before = current_iter.getPosition() , first_line_position_before = first_visible_line.getPosition(); switch ( int(drag_scroll) ) @@ -1031,24 +1030,14 @@ void FListView::onTimer (FTimerEvent*) case fc::scrollUp: case fc::scrollUpSelect: - if ( position_before == 0 ) - { - drag_scroll = fc::noScroll; + if ( ! dragScrollUp(position_before) ) return; - } - - stepBackward(scroll_distance); break; case fc::scrollDown: case fc::scrollDownSelect: - if ( position_before + 1 == element_count ) - { - drag_scroll = fc::noScroll; + if ( ! dragScrollDown(position_before) ) return; - } - - stepForward(scroll_distance); break; default: @@ -1071,14 +1060,10 @@ void FListView::onTimer (FTimerEvent*) //---------------------------------------------------------------------- void FListView::onWheel (FWheelEvent* ev) { - int wheel - , element_count = int(getCount()) - , position_before = current_iter.getPosition() + int position_before = current_iter.getPosition() , first_line_position_before = first_visible_line.getPosition() , pagesize = 4; - wheel = ev->getWheel(); - if ( drag_scroll != fc::noScroll ) { delOwnTimer(); @@ -1087,52 +1072,14 @@ void FListView::onWheel (FWheelEvent* ev) drag_scroll = fc::noScroll; } - switch ( wheel ) + switch ( ev->getWheel() ) { case fc::WheelUp: - if ( current_iter.getPosition() == 0 ) - 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); - } - + wheelUp (pagesize); break; case fc::WheelDown: - if ( current_iter.getPosition() + 1 == element_count ) - 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); - } - + wheelDown (pagesize); break; default: @@ -1384,13 +1331,8 @@ void FListView::draw() //---------------------------------------------------------------------- void FListView::drawColumnLabels() { - static const int leading_space = 1; - static const int trailing_space = 1; - static const int ellipsis_length = 2; std::vector::const_iterator first, last; headerItems::const_iterator iter; - FString txt; - uInt txt_length; if ( header.empty() || getHeight() <= 2 @@ -1404,8 +1346,6 @@ void FListView::drawColumnLabels() while ( iter != header.end() ) { const FString& text = (*iter).name; - int width = (*iter).width; - int column_width; if ( text.isNull() || text.isEmpty() ) { @@ -1413,42 +1353,7 @@ void FListView::drawColumnLabels() continue; } - txt = " " + text; - 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 << ' '; - } - + drawColumnText(iter); ++iter; } @@ -1660,6 +1565,59 @@ inline FString FListView::getLinePrefix ( const FListViewItem* item 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) { @@ -1710,6 +1668,84 @@ void FListView::recalculateVerticalBar (int element_count) 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) { diff --git a/src/foptimove.cpp b/src/foptimove.cpp index 4af6b39f..0c17934a 100644 --- a/src/foptimove.cpp +++ b/src/foptimove.cpp @@ -810,7 +810,6 @@ inline int FOptiMove::horizontalMove (char hmove[], int from_x, int to_x) inline void FOptiMove::rightMove ( char hmove[], int& htime , int from_x, int to_x ) { - char str[BUF_SIZE] = {}; int num = to_x - from_x; 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 ) { + char str[BUF_SIZE] = {}; int htime_r = 0; str[0] = '\0'; diff --git a/src/fterm.cpp b/src/fterm.cpp index 5a1ba2e8..e1664dc5 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -101,7 +101,7 @@ bool FTerm::xterm_default_colors; bool FTerm::use_alternate_screen = true; termios FTerm::term_init; char FTerm::termtype[256] = {}; -char FTerm::term_name[256] = {}; +char FTerm::termfilename[256] = {}; #if DEBUG char FTerm::termtype_256color[256] = {}; @@ -1989,7 +1989,7 @@ int FTerm::openConsole() if ( fd_tty >= 0 ) // console is already opened return 0; - if ( ! *term_name ) + if ( ! *termfilename ) return 0; for (int i = 0; terminal_devices[i] != 0; i++) @@ -2022,92 +2022,118 @@ void FTerm::getSystemTermType() if ( term_env ) { + // Save name in termtype std::strncpy (termtype, term_env, sizeof(termtype) - 1); 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 - const char* term_basename = std::strrchr(term_name, '/'); - - if ( term_basename == 0 ) - term_basename = term_name; - else - term_basename++; - - // Analyse /etc/ttytype - // -------------------- - // file format: - // - // - // Example: - // linux tty1 - // vt100 ttys0 - - std::FILE *fp; - - if ( (fp = std::fopen("/etc/ttytype", "r")) != 0 ) - { - char* p; - char str[BUFSIZ]; - - // read and parse the file - while ( fgets(str, sizeof(str) - 1, fp) != 0 ) - { - char* name; - char* type; - type = name = 0; // 0 == not found - p = str; - - while ( *p ) - { - if ( std::isspace(uChar(*p)) ) - *p = '\0'; - else if ( type == 0 ) - type = p; - else if ( name == 0 && p != str && p[-1] == '\0' ) - name = p; - - p++; - } - - if ( type != 0 && name != 0 && ! std::strcmp(name, term_basename) ) - { - std::strncpy (termtype, type, sizeof(termtype) - 1); - std::fclose(fp); - return; - } - } - - std::fclose(fp); - } + getTTYtype(); // Look into /etc/ttytype #if F_HAVE_GETTTYNAM + if ( getTTYSFileEntry() ) // Look into /etc/ttys + return; +#endif + } - // Analyse /etc/ttys - // -------------------- - struct ttyent* ttys_entryt; - ttys_entryt = getttynam(term_basename); + // 2nd fallback: use vt100 if not found + std::strncpy (termtype, C_STR("vt100"), 6); +} - if ( ttys_entryt ) +//---------------------------------------------------------------------- +void FTerm::getTTYtype() +{ + // Analyse /etc/ttytype and get the term name + // ------------------------------------------ + // file format: + // + // + // Example: + // linux tty1 + // 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; + + if ( (fp = std::fopen("/etc/ttytype", "r")) != 0 ) + { + char* p; + char str[BUFSIZ]; + + // Read and parse the file + while ( fgets(str, sizeof(str) - 1, fp) != 0 ) { - char* type = ttys_entryt->ty_type; + char* name; + char* type; + type = name = 0; // 0 == not found + p = str; - if ( type != 0 ) + while ( *p ) { + if ( std::isspace(uChar(*p)) ) + *p = '\0'; + else if ( type == 0 ) + type = p; + else if ( name == 0 && p != str && p[-1] == '\0' ) + name = p; + + p++; + } + + if ( type != 0 && name != 0 && ! std::strcmp(name, term_basename) ) + { + // Save name in termtype std::strncpy (termtype, type, sizeof(termtype) - 1); - endttyent(); + std::fclose(fp); return; } } - endttyent(); -#endif + std::fclose(fp); + } +} + +#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++; + + struct ttyent* ttys_entryt; + ttys_entryt = getttynam(term_basename); + + if ( ttys_entryt ) + { + char* type = ttys_entryt->ty_type; + + if ( type != 0 ) + { + // Save name in termtype + std::strncpy (termtype, type, sizeof(termtype) - 1); + endttyent(); + return true; + } } - // use vt100 if not found - std::strncpy (termtype, C_STR("vt100"), 6); + endttyent(); + return false; } +#endif //---------------------------------------------------------------------- void FTerm::storeTTYsettings() @@ -4420,8 +4446,8 @@ void FTerm::init() std::abort(); // Get pathname of the terminal device - if ( ttyname_r(stdout_no, term_name, sizeof(term_name)) ) - term_name[0] = '\0'; + if ( ttyname_r(stdout_no, termfilename, sizeof(termfilename)) ) + termfilename[0] = '\0'; initOSspecifics(); diff --git a/src/fwidget.cpp b/src/fwidget.cpp index e66931f7..d435dddb 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -1761,184 +1761,124 @@ void FWidget::adjustSizeGlobal() //---------------------------------------------------------------------- bool FWidget::focusNextChild() { - if ( isDialogWidget() ) + if ( isDialogWidget() || ! hasParent() ) return false; - if ( hasParent() ) + FWidget* parent = getParentWidget(); + + if ( ! parent->hasChildren() || parent->numOfFocusableChildren() <= 1 ) + return false; + + FObjectIterator iter, last; + iter = parent->begin(); + last = parent->end(); + + while ( iter != last ) { - FWidget* parent = getParentWidget(); - - if ( parent->hasChildren() && parent->numOfFocusableChildren() > 1 ) + if ( ! (*iter)->isWidget() ) { - FObjectIterator iter, last; - iter = parent->begin(); - last = parent->end(); - - while ( iter != last ) - { - if ( ! (*iter)->isWidget() ) - { - ++iter; - continue; - } - - FWidget* w = static_cast(*iter); - - if ( w == this ) - { - FWidget* next = 0; - constFObjectIterator next_element; - next_element = iter; - - do - { - ++next_element; - - if ( next_element == parent->end() ) - next_element = parent->begin(); - - if ( ! (*next_element)->isWidget() ) - continue; - - next = static_cast(*next_element); - } while ( ! next - || ! next->isEnabled() - || ! next->acceptFocus() - || ! next->isVisible() - || next->isWindowWidget() ); - - FFocusEvent out (fc::FocusOut_Event); - out.setFocusType(fc::FocusNextWidget); - FApplication::sendEvent(this, &out); - - FFocusEvent cfo (fc::ChildFocusOut_Event); - cfo.setFocusType(fc::FocusNextWidget); - cfo.ignore(); - FApplication::sendEvent(parent, &cfo); - - if ( cfo.isAccepted() ) - out.ignore(); - - if ( out.isAccepted() ) - { - if ( next == this ) - return false; - - next->setFocus(); - 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; - } + ++iter; + continue; } + + FWidget* w = static_cast(*iter); + + if ( w != this ) + { + ++iter; + continue; + } + + FWidget* next = 0; + constFObjectIterator next_element; + next_element = iter; + + do + { + ++next_element; + + if ( next_element == parent->end() ) + next_element = parent->begin(); + + if ( ! (*next_element)->isWidget() ) + continue; + + next = static_cast(*next_element); + } while ( ! next + || ! next->isEnabled() + || ! next->acceptFocus() + || ! next->isVisible() + || next->isWindowWidget() ); + + bool accpt = changeFocus (next, parent, fc::FocusNextWidget); + + if ( ! accpt ) + return false; + + break; // The focus has been changed } + return true; } //---------------------------------------------------------------------- bool FWidget::focusPrevChild() { - if ( isDialogWidget() ) + if ( isDialogWidget() || ! hasParent() ) return false; - if ( hasParent() ) + FWidget* parent = getParentWidget(); + + if ( ! parent->hasChildren() || parent->numOfFocusableChildren() <= 1 ) + return false; + + FObjectIterator iter, first; + iter = parent->end(); + first = parent->begin(); + + do { - FWidget* parent = getParentWidget(); + --iter; - if ( parent->hasChildren() && parent->numOfFocusableChildren() > 1 ) + if ( ! (*iter)->isWidget() ) + continue; + + FWidget* w = static_cast(*iter); + + if ( w != this ) + continue; + + FWidget* prev = 0; + constFObjectIterator prev_element; + prev_element = iter; + + do { - FObjectIterator iter, first; - iter = parent->end(); - first = parent->begin(); - - do + if ( ! (*prev_element)->isWidget() ) { - --iter; - - if ( ! (*iter)->isWidget() ) - continue; - - FWidget* w = static_cast(*iter); - - if ( w == this ) - { - FWidget* prev = 0; - constFObjectIterator prev_element; - prev_element = iter; - - do - { - if ( ! (*prev_element)->isWidget() ) - { - --prev_element; - continue; - } - - if ( prev_element == parent->begin() ) - prev_element = parent->end(); - - --prev_element; - prev = static_cast(*prev_element); - } while ( ! prev - || ! prev->isEnabled() - || ! prev->acceptFocus() - || ! prev->isVisible() - || prev->isWindowWidget() ); - - FFocusEvent out (fc::FocusOut_Event); - out.setFocusType(fc::FocusPreviousWidget); - FApplication::sendEvent(this, &out); - - FFocusEvent cfo (fc::ChildFocusOut_Event); - cfo.setFocusType(fc::FocusPreviousWidget); - cfo.ignore(); - FApplication::sendEvent(parent, &cfo); - - if ( cfo.isAccepted() ) - out.ignore(); - - if ( out.isAccepted() ) - { - if ( prev == this ) - return false; - - prev->setFocus(); - 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; - } + --prev_element; + continue; } - while ( iter != first ); - } + + if ( prev_element == parent->begin() ) + prev_element = parent->end(); + + --prev_element; + prev = static_cast(*prev_element); + } while ( ! prev + || ! prev->isEnabled() + || ! prev->acceptFocus() + || ! prev->isVisible() + || prev->isWindowWidget() ); + + bool accpt = changeFocus (prev, parent, fc::FocusPreviousWidget); + + if ( ! accpt ) + return false; + + break; // The focus has been changed } + while ( iter != first ); 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() { }