diff --git a/README.md b/README.md index bd5b1d6c..d51259b5 100644 --- a/README.md +++ b/README.md @@ -19,22 +19,22 @@ The Final Cut ============= -The Final Cut is a class library and widget toolkit with full mouse support for creating a [text-based user interface](https://en.wikipedia.org/wiki/Text-based_user_interface). The library supports the programmer to develop an application for the text console. It allows the simultaneous handling of multiple windows on the screen. +The Final Cut is a class library and widget toolkit with full mouse support for creating a [text-based user interface](https://en.wikipedia.org/wiki/Text-based_user_interface). The library supports the programmer to develop an application for the text console. It allows the simultaneous handling of multiple windows on the screen. The C++ class design was inspired by the Qt framework. It provides common controls like dialog windows, push buttons, check boxes, radio buttons, input lines, list boxes, status bars and so on. -![](doc/fileopen-dialog.png) +![](doc/fileopen-dialog.png) -![](doc/progress-bar.png) +![](doc/progress-bar.png) -![](doc/textview.png) +![](doc/textview.png) -![](doc/Mandelbrot.png) +![](doc/Mandelbrot.png) newfont ------- A new text font for X11 and the Linux console. -![](doc/newfont1.png) +![](doc/newfont1.png) ![](doc/newfont2.png) @@ -43,8 +43,8 @@ A new text font for X11 and the Linux console. Virtual terminal ---------------- -It uses a virtual terminal to print the character via an update method on the screen. -The virtual windows are an overlying layer to realizing window movements. +It uses a virtual terminal to print the character via an update method on the screen. +The virtual windows are an overlying layer to realizing window movements. The update method transmits only the changes to the virtual terminal or the screen.
@@ -87,7 +87,7 @@ printf(...)
                                          │ output_buffer │
                                          └───────────────┘
                                                  │
-                                                 │ flush_out() 
+                                                 │ flush_out()
                                                  │     +
                                                  │ Fputchar(char)
                                                  │
@@ -122,90 +122,85 @@ Class digramm
                                            │    ┌─────────────┐
                                ┌────────┐  ├────┤ FAccelEvent │
                                │ FEvent │◄─┤    └─────────────┘
-                               └────┬───┘  │    ┌──────────────┐
-                                    :1     ├────┤ FResizeEvent │
-                                    :      │    └──────────────┘
-                                    :      │    ┌────────────┐
-                                    :      ├────┤ FShowEvent │
-                                    :      │    └────────────┘
-                                    :      │    ┌────────────┐
-                                    :      ├────┤ FHideEvent │
-                                    :      │    └────────────┘
-                                    :      │    ┌─────────────┐
-                                    :      ├────┤ FCloseEvent │
-                                    :      │    └─────────────┘
-                                    :      │    ┌─────────────┐
-                                    :      └────┤ FTimerEvent │
-                                    :           └─────────────┘
-                                    :
-                                    :           ┌──────────────┐
-                                    :      ┌────┤ FApplication │
-                                    :      │    └──────────────┘
-                                    :      │    ┌─────────┐1
-                                    :      ├────┤ FButton ├-----------------------------┐
-                                    :      │    └─────────┘                             :
-                                    :      │    ┌────────┐1                             :
-                                    :      ├────┤ FLabel ├------------------------------┐
-                                    :      │    └────────┘                              :
-                                    :      │    ┌───────────┐1                          :
-                                    :      ├────┤ FLineEdit ├---------------------------┐
-                                    :      │    └───────────┘                           :
-                                    :      │    ┌──────────────┐      ┌──────────────┐1 :
-                                    :1     ├────┤ FButtonGroup │   ┌──┤ FRadioButton ├--┐
- ┌─────────┐    ┌────────┐    ┌─────┴───┐  │    └──────────────┘   │  └──────────────┘  :
- │ FObject │◄─┬─┤ FVTerm │◄───┤ FWidget │◄─┤    ┌───────────────┐  │  ┌───────────┐1    :
- └─────────┘  │ └────┬───┘    └───┬─┬───┘  ├────┤ FToggleButton │◄─┼──┤ FCheckBox ├-----┐
-              │      :1           :1:1     │    └───────────────┘  │  └───────────┘     :
-   ┌───────┐  │      :            : :      │    ┌──────────────┐   │  ┌─────────┐1      :
-   │ FTerm │◄─┘      └------------┐ :      ├────┤ FProgressbar │   └──┤ FSwitch ├-------┐
-   └─┬───┬─┘                      : :      │    └──────────────┘      └─────────┘       :
-     :1  :1                       : :      │    ┌────────────┐                          :  *┌─────────┐
-     :   └------------------------┐ :      ├────┤ FScrollbar │                          ├---┤ FString │
-     :                            : :      │    └────────────┘                          :   └─────────┘
-     :  1┌───────────┐            : :      │    ┌───────────┐1                          :
-     └---┤ FOptiAttr │            : :      ├────┤ FTextView ├---------------------------┘
-     :   └───────────┘            : :      │    └───────────┘                           :
-     :  1┌───────────┐            : :      │    ┌──────────┐1     *┌──────────────┐1    :
-     └---┤ FOptiMove │            : :      ├────┤ FListBox ├-------┤ FListBoxItem ├-----┘
-         └───────────┘            : :      │    └──────────┘       └──────────────┘     :
-                                  : :      │    ┌─────────────┐                         :
-                                  : :      ├────┤ FScrollView │                         :
-                                  : :      │    └─────────────┘                         :
-                                  : :      │    ┌────────────┐1   *┌────────────┐1      :
-                                  : :      │ ┌──┤ FStatusBar ├-----┤ FStatusKey ├-------┘
-                                  : :      │ │  └────┬───────┘     └────────────┘       :
-                                  : :      │ │      1└----------------------------------┘
-                                  : :      │ ▼                       ┌─────────────┐1   :
-                                  : :  ┌───┴─┴───┐  ┌─────────┐   ┌──┤ FFileDialog ├----┘
-                                  : :  │ FWindow │◄─┤ FDialog │◄──┤  └─────────────┘    :
-                                  : :  └──┬──┬───┘  └────┬────┘   │  ┌─────────────┐1   :
-                                  : :     ▲  ▲          1:        └──┤ FMessageBox ├----┘
-                                  : :     │  │           :           └─────────────┘    :
-                                  : :     │  │           └------------------------------┘
-                                  : :     │  │      ┌──────────┐                        :
-                                  : :     │  └──────┤ FToolTip ├------------------------┘
-                                  : :     │         └──────────┘                        :
-                                  : :     └───────────────┐          ┌──────────┐       :
-                                  : :                     │      ┌───┤ FMenuBar │       :
-                                  : :    ┌───────────┐    └──────┤   └──────────┘       :
-                                  : :    │ FMenuList │◄──────────┤   ┌───────┐          :
-                                  : :    └────┬──────┘           └───┤ FMenu │◄──┐      :
-                                  : :        1:                      └───────┘   │      :
-                                  : :         :            ┌─────────────────┐   │      :
-                                  : :         :            │ FDialogListMenu ├───┘      :
-                                  : :         :            └─────────────────┘          :
-                                  : :         :                    ┌────────────────┐*  :
-                                  : :         : *┌───────────┐  ┌──┤ FCheckMenuItem ├-┐ :
-                                  : :         ├--┤ FMenuItem │◄─┤  └────────────────┘ : :
-                                  : :         :  └───────────┘  │  ┌────────────────┐*: :
-                                  : :         :                 └──┤ FRadioMenuItem ├-┤ :
-                                  : :         :                    └────────────────┘ : :
-                                  : :         └---------------------------------------┘ :
-                                  : └---------------------------------------------------┘
-                                  :  *┌────────┐
-                                  └---┤ FPoint │
-                                  :   └────────┘
-                                  :  *┌───────┐
-                                  └---┤ FRect │
-                                      └───────┘
+                               └───┬────┘  │    ┌──────────────┐
+                                   :1      ├────┤ FResizeEvent │
+                                   :       │    └──────────────┘
+                                   :       │    ┌────────────┐
+                                   :       ├────┤ FShowEvent │
+                                   :       │    └────────────┘
+                                   :       │    ┌────────────┐
+                                   :       ├────┤ FHideEvent │
+                                   :       │    └────────────┘
+                                   :       │    ┌─────────────┐
+                                   :       ├────┤ FCloseEvent │
+                                   :       │    └─────────────┘
+              1┌───────────┐       :       │    ┌─────────────┐
+   ┌-----------┤ FOptiMove │       :       └────┤ FTimerEvent │
+   :           └───────────┘       :            └─────────────┘
+   :          1┌───────────┐       :
+   ┌-----------┤ FOptiAttr │       :            ┌──────────────┐
+   :           └───────────┘       :       ┌────┤ FApplication │
+   :          *┌─────────┐         :       │    └──────────────┘
+   :  ┌--------┤ FString │         :       │    ┌─────────┐
+   :  :        └─────────┘         :       ├────┤ FButton │
+   :  :       *┌────────┐          :       │    └─────────┘
+   :  ┌--------┤ FPoint │          :       │    ┌────────┐
+   :  :        └────────┘          :       ├────┤ FLabel │
+   :  :       *┌───────┐           :       │    └────────┘
+   :  ┌--------┤ FRect │           :       │    ┌───────────┐
+   :  :        └───────┘           :       ├────┤ FLineEdit │
+   :1 :1                           :       │    └───────────┘
+ ┌─┴──┴──┐                         :       │    ┌──────────────┐      ┌──────────────┐
+ │ FTerm │◄────┐                   :1      ├────┤ FButtonGroup │   ┌──┤ FRadioButton │
+ └───────┘     │ ┌────────┐   ┌────┴────┐  │    └──────────────┘   │  └──────────────┘
+               ├─┤ FVTerm │◄──┤ FWidget │◄─┤    ┌───────────────┐  │  ┌───────────┐
+ ┌─────────┐   │ └────────┘   └─────────┘  ├────┤ FToggleButton │◄─┼──┤ FCheckBox │
+ │ FObject │◄──┘                           │    └───────────────┘  │  └───────────┘
+ └─────────┘                               │    ┌──────────────┐   │  ┌─────────┐
+                                           ├────┤ FProgressbar │   └──┤ FSwitch │
+                                           │    └──────────────┘      └─────────┘
+                                           │    ┌────────────┐
+                                           ├────┤ FScrollbar │
+                                           │    └────────────┘
+                                           │    ┌───────────┐
+                                           ├────┤ FTextView │
+                                           │    └───────────┘
+                                           │    ┌──────────┐1     *┌──────────────┐
+                                           ├────┤ FListBox ├-------┤ FListBoxItem │
+                                           │    └──────────┘       └──────────────┘
+ ┌─────────────┐1                          │   1┌───────────┐1    *┌───────────────┐
+ │ FTermBuffer ├---------------------------├────┤ FListView ├------┤ FListViewItem │
+ └─────────────┘                           │    └───────────┘      └───────────────┘
+                                           │    ┌─────────────┐
+                                           ├────┤ FScrollView │
+                                           │    └─────────────┘
+                                           │    ┌────────────┐1   *┌────────────┐
+                                           │ ┌──┤ FStatusBar ├-----┤ FStatusKey │
+                                           │ │  └────────────┘     └────────────┘
+                                           │ │
+                                           │ ▼                       ┌─────────────┐
+                                       ┌───┴─┴───┐  ┌─────────┐   ┌──┤ FFileDialog │
+                                       │ FWindow │◄─┤ FDialog │◄──┤  └─────────────┘
+                                       └──┬──┬───┘  └─────────┘   │  ┌─────────────┐
+                                          ▲  ▲                    └──┤ FMessageBox │
+                                          │  │                       └─────────────┘
+                                          │  │      ┌──────────┐
+                                          │  └──────┤ FToolTip │
+                                          │         └──────────┘
+                                          └───────────────┐          ┌──────────┐
+                                                          │      ┌───┤ FMenuBar │
+                                         ┌───────────┐    └──────┤   └──────────┘
+                                         │ FMenuList │◄──────────┤   ┌───────┐
+                                         └────┬──────┘           └───┤ FMenu │◄──┐
+                                             1:                      └───────┘   │
+                                              :            ┌─────────────────┐   │
+                                              :            │ FDialogListMenu ├───┘
+                                              :            └─────────────────┘
+                                              :                    ┌────────────────┐*
+                                              : *┌───────────┐  ┌──┤ FCheckMenuItem ├-┐
+                                              ├--┤ FMenuItem │◄─┤  └────────────────┘ :
+                                              :  └───────────┘  │  ┌────────────────┐*:
+                                              :                 └──┤ FRadioMenuItem ├-┤
+                                              :                    └────────────────┘ :
+                                              └---------------------------------------┘
 
diff --git a/doc/class-diagram.txt b/doc/class-diagram.txt index 209aedb2..33f02897 100644 --- a/doc/class-diagram.txt +++ b/doc/class-diagram.txt @@ -17,89 +17,85 @@ │ ┌─────────────┐ ┌────────┐ ├────┤ FAccelEvent │ │ FEvent │◄─┤ └─────────────┘ - └────┬───┘ │ ┌──────────────┐ - :1 ├────┤ FResizeEvent │ - : │ └──────────────┘ - : │ ┌────────────┐ - : ├────┤ FShowEvent │ - : │ └────────────┘ - : │ ┌────────────┐ - : ├────┤ FHideEvent │ - : │ └────────────┘ - : │ ┌─────────────┐ - : ├────┤ FCloseEvent │ - : │ └─────────────┘ - : │ ┌─────────────┐ - : └────┤ FTimerEvent │ - : └─────────────┘ - : - : ┌──────────────┐ - : ┌────┤ FApplication │ - : │ └──────────────┘ - : │ ┌─────────┐1 - : ├────┤ FButton ├-----------------------------┐ - : │ └─────────┘ : - : │ ┌────────┐1 : - : ├────┤ FLabel ├------------------------------┐ - : │ └────────┘ : - : │ ┌───────────┐1 : - : ├────┤ FLineEdit ├---------------------------┐ - : │ └───────────┘ : - : │ ┌──────────────┐ ┌──────────────┐1 : - :1 ├────┤ FButtonGroup │ ┌──┤ FRadioButton ├--┐ - ┌─────────┐ ┌────────┐ ┌─────┴───┐ │ └──────────────┘ │ └──────────────┘ : - │ FObject │◄─┬─┤ FVTerm │◄───┤ FWidget │◄─┤ ┌───────────────┐ │ ┌───────────┐1 : - └─────────┘ │ └────┬───┘ └───┬─┬───┘ ├────┤ FToggleButton │◄─┼──┤ FCheckBox ├-----┐ - │ :1 :1:1 │ └───────────────┘ │ └───────────┘ : - ┌───────┐ │ : : : │ ┌──────────────┐ │ ┌─────────┐1 : - │ FTerm │◄─┘ └------------┐ : ├────┤ FProgressbar │ └──┤ FSwitch ├-------┐ - └─┬───┬─┘ : : │ └──────────────┘ └─────────┘ : - :1 :1 : : │ ┌────────────┐ : *┌─────────┐ - : └------------------------┐ : ├────┤ FScrollbar │ ├---┤ FString │ - : : : │ └────────────┘ : └─────────┘ - : 1┌───────────┐ : : │ ┌───────────┐1 : - └---┤ FOptiAttr │ : : ├────┤ FTextView ├---------------------------┘ - : └───────────┘ : : │ └───────────┘ : - : 1┌───────────┐ : : │ ┌──────────┐1 *┌──────────────┐1 : - └---┤ FOptiMove │ : : ├────┤ FListBox ├-------┤ FListBoxItem ├-----┘ - └───────────┘ : : │ └──────────┘ └──────────────┘ : - : : │ ┌─────────────┐ : - : : ├────┤ FScrollView │ : - : : │ └─────────────┘ : - : : │ ┌────────────┐1 *┌────────────┐1 : - : : │ ┌──┤ FStatusBar ├-----┤ FStatusKey ├-------┘ - : : │ │ └────┬───────┘ └────────────┘ : - : : │ │ 1└----------------------------------┘ - : : │ ▼ ┌─────────────┐1 : - : : ┌───┴─┴───┐ ┌─────────┐ ┌──┤ FFileDialog ├----┘ - : : │ FWindow │◄─┤ FDialog │◄──┤ └─────────────┘ : - : : └──┬──┬───┘ └────┬────┘ │ ┌─────────────┐1 : - : : ▲ ▲ 1: └──┤ FMessageBox ├----┘ - : : │ │ : └─────────────┘ : - : : │ │ └------------------------------┘ - : : │ │ ┌──────────┐ : - : : │ └──────┤ FToolTip ├------------------------┘ - : : │ └──────────┘ : - : : └───────────────┐ ┌──────────┐ : - : : │ ┌───┤ FMenuBar │ : - : : ┌───────────┐ └──────┤ └──────────┘ : - : : │ FMenuList │◄──────────┤ ┌───────┐ : - : : └────┬──────┘ └───┤ FMenu │◄──┐ : - : : 1: └───────┘ │ : - : : : ┌─────────────────┐ │ : - : : : │ FDialogListMenu ├───┘ : - : : : └─────────────────┘ : - : : : ┌────────────────┐* : - : : : *┌───────────┐ ┌──┤ FCheckMenuItem ├-┐ : - : : ├--┤ FMenuItem │◄─┤ └────────────────┘ : : - : : : └───────────┘ │ ┌────────────────┐*: : - : : : └──┤ FRadioMenuItem ├-┤ : - : : : └────────────────┘ : : - : : └---------------------------------------┘ : - : └---------------------------------------------------┘ - : *┌────────┐ - └---┤ FPoint │ - : └────────┘ - : *┌───────┐ - └---┤ FRect │ - └───────┘ + └───┬────┘ │ ┌──────────────┐ + :1 ├────┤ FResizeEvent │ + : │ └──────────────┘ + : │ ┌────────────┐ + : ├────┤ FShowEvent │ + : │ └────────────┘ + : │ ┌────────────┐ + : ├────┤ FHideEvent │ + : │ └────────────┘ + : │ ┌─────────────┐ + : ├────┤ FCloseEvent │ + : │ └─────────────┘ + 1┌───────────┐ : │ ┌─────────────┐ + ┌-----------┤ FOptiMove │ : └────┤ FTimerEvent │ + : └───────────┘ : └─────────────┘ + : 1┌───────────┐ : + ┌-----------┤ FOptiAttr │ : ┌──────────────┐ + : └───────────┘ : ┌────┤ FApplication │ + : *┌─────────┐ : │ └──────────────┘ + : ┌--------┤ FString │ : │ ┌─────────┐ + : : └─────────┘ : ├────┤ FButton │ + : : *┌────────┐ : │ └─────────┘ + : ┌--------┤ FPoint │ : │ ┌────────┐ + : : └────────┘ : ├────┤ FLabel │ + : : *┌───────┐ : │ └────────┘ + : ┌--------┤ FRect │ : │ ┌───────────┐ + : : └───────┘ : ├────┤ FLineEdit │ + :1 :1 : │ └───────────┘ + ┌─┴──┴──┐ : │ ┌──────────────┐ ┌──────────────┐ + │ FTerm │◄────┐ :1 ├────┤ FButtonGroup │ ┌──┤ FRadioButton │ + └───────┘ │ ┌────────┐ ┌────┴────┐ │ └──────────────┘ │ └──────────────┘ + ├─┤ FVTerm │◄──┤ FWidget │◄─┤ ┌───────────────┐ │ ┌───────────┐ + ┌─────────┐ │ └────────┘ └─────────┘ ├────┤ FToggleButton │◄─┼──┤ FCheckBox │ + │ FObject │◄──┘ │ └───────────────┘ │ └───────────┘ + └─────────┘ │ ┌──────────────┐ │ ┌─────────┐ + ├────┤ FProgressbar │ └──┤ FSwitch │ + │ └──────────────┘ └─────────┘ + │ ┌────────────┐ + ├────┤ FScrollbar │ + │ └────────────┘ + │ ┌───────────┐ + ├────┤ FTextView │ + │ └───────────┘ + │ ┌──────────┐1 *┌──────────────┐ + ├────┤ FListBox ├-------┤ FListBoxItem │ + │ └──────────┘ └──────────────┘ + ┌─────────────┐1 │ 1┌───────────┐1 *┌───────────────┐ + │ FTermBuffer ├---------------------------├────┤ FListView ├------┤ FListViewItem │ + └─────────────┘ │ └───────────┘ └───────────────┘ + │ ┌─────────────┐ + ├────┤ FScrollView │ + │ └─────────────┘ + │ ┌────────────┐1 *┌────────────┐ + │ ┌──┤ FStatusBar ├-----┤ FStatusKey │ + │ │ └────────────┘ └────────────┘ + │ │ + │ ▼ ┌─────────────┐ + ┌───┴─┴───┐ ┌─────────┐ ┌──┤ FFileDialog │ + │ FWindow │◄─┤ FDialog │◄──┤ └─────────────┘ + └──┬──┬───┘ └─────────┘ │ ┌─────────────┐ + ▲ ▲ └──┤ FMessageBox │ + │ │ └─────────────┘ + │ │ ┌──────────┐ + │ └──────┤ FToolTip │ + │ └──────────┘ + └───────────────┐ ┌──────────┐ + │ ┌───┤ FMenuBar │ + ┌───────────┐ └──────┤ └──────────┘ + │ FMenuList │◄──────────┤ ┌───────┐ + └────┬──────┘ └───┤ FMenu │◄──┐ + 1: └───────┘ │ + : ┌─────────────────┐ │ + : │ FDialogListMenu ├───┘ + : └─────────────────┘ + : ┌────────────────┐* + : *┌───────────┐ ┌──┤ FCheckMenuItem ├-┐ + ├--┤ FMenuItem │◄─┤ └────────────────┘ : + : └───────────┘ │ ┌────────────────┐*: + : └──┤ FRadioMenuItem ├-┤ + : └────────────────┘ : + └---------------------------------------┘ + diff --git a/src/flistview.cpp b/src/flistview.cpp index c8040615..973b5c33 100644 --- a/src/flistview.cpp +++ b/src/flistview.cpp @@ -122,7 +122,8 @@ FString FListViewItem::getText (int column) const || column > int(column_value.size()) ) return *fc::empty_string; - return column_value[uInt(column - 1)]; + column--; // Convert column position to address offset (index) + return column_value[uInt(column)]; } //---------------------------------------------------------------------- @@ -134,21 +135,22 @@ void FListViewItem::setText (int column, const FString& text) return; FObject* parent = getParent(); + column--; // Convert column position to address offset (index) if ( parent && parent->isInstanceOf("FListView") ) { FListView* listview = static_cast(parent); - if ( ! listview->header[uInt(column - 1)].fixed_width ) + if ( ! listview->header[uInt(column)].fixed_width ) { int length = int(text.getLength()); - if ( length > listview->header[uInt(column - 1)].width ) - listview->header[uInt(column - 1)].width = length; + if ( length > listview->header[uInt(column)].width ) + listview->header[uInt(column)].width = length; } } - column_value[uInt(column - 1)] = text; + column_value[uInt(column)] = text; } //---------------------------------------------------------------------- @@ -250,7 +252,8 @@ fc::text_alignment FListView::getColumnAlignment (int column) const if ( column < 1 || header.empty() || column > int(header.size()) ) return fc::alignLeft; - return header[uInt(column - 1)].alignment; + column--; // Convert column position to address offset (index) + return header[uInt(column)].alignment; } //---------------------------------------------------------------------- @@ -261,7 +264,8 @@ FString FListView::getColumnText (int column) const if ( column < 1 || header.empty() || column > int(header.size()) ) return *fc::empty_string; - return header[uInt(column - 1)].name; + column--; // Convert column position to address offset (index) + return header[uInt(column)].name; } //---------------------------------------------------------------------- @@ -291,7 +295,8 @@ void FListView::setColumnAlignment (int column, fc::text_alignment align) if ( column < 1 || header.empty() || column > int(header.size()) ) {beep();return;} - header[uInt(column - 1)].alignment = align; + column--; // Convert column position to address offset (index) + header[uInt(column)].alignment = align; } //---------------------------------------------------------------------- @@ -302,15 +307,17 @@ void FListView::setColumnText (int column, const FString& label) if ( column < 1 || header.empty() || column > int(header.size()) ) return; - if ( ! header[uInt(column - 1)].fixed_width ) + column--; // Convert column position to address offset (index) + + if ( ! header[uInt(column)].fixed_width ) { int length = int(label.getLength()); - if ( length > header[uInt(column - 1)].width ) - header[uInt(column - 1)].width = length; + if ( length > header[uInt(column)].width ) + header[uInt(column)].width = length; } - header[uInt(column - 1)].name = label; + header[uInt(column)].name = label; } //---------------------------------------------------------------------- @@ -337,7 +344,7 @@ void FListView::insert (FListViewItem* item) { static const int padding_space = 1; int line_width = padding_space; // leading space - uInt column = 1; + uInt column_idx = 0; uInt entries = uInt(item->column_value.size()); headerItems::iterator iter; @@ -353,8 +360,8 @@ void FListView::insert (FListViewItem* item) { int len; - if ( column <= entries ) - len = int(item->column_value[column - 1].getLength()); + if ( column_idx < entries ) + len = int(item->column_value[column_idx].getLength()); else len = 0; @@ -363,7 +370,7 @@ void FListView::insert (FListViewItem* item) } line_width += (*iter).width + padding_space; // width + tailing space - column++; + column_idx++; ++iter; } @@ -1211,7 +1218,7 @@ void FListView::drawList() for (uInt y = start; y < end; y++) { - bool isCurrentLine = bool(y + uInt(yoffset) + 1 == uInt(current)); + bool isCurrentLine = bool( y + uInt(yoffset) + 1 == uInt(current) ); setPrintPos (2, 2 + int(y)); setColor (wc.list_fg, wc.list_bg); @@ -1250,14 +1257,17 @@ void FListView::drawList() // print columns if ( ! (*iter)->column_value.empty() ) { - for (uInt i = 0; i < (*iter)->column_value.size(); i++) + for (uInt i = 0; i < (*iter)->column_value.size(); ) { static const int leading_space = 1; static const int ellipsis_length = 2; FString text = (*iter)->column_value[i]; int width = header[i].width; uInt txt_length = text.getLength(); - fc::text_alignment align = getColumnAlignment(int(i + 1)); + // Increment the value of i for the column position + // and the next iteration + i++; + fc::text_alignment align = getColumnAlignment(int(i)); uInt align_offset = getAlignOffset (align, txt_length, uInt(width)); if ( align_offset > 0 ) @@ -1266,7 +1276,8 @@ void FListView::drawList() if ( align_offset + txt_length <= uInt(width) ) { line += text.left(width); - line += FString (leading_space + width - int(align_offset + txt_length), ' '); + line += FString ( leading_space + width + - int(align_offset + txt_length), ' '); } else if ( align == fc::alignRight ) {