TListBox,several columns,insert row #198
Replies: 4 comments 3 replies
-
|
Use TListView |
Beta Was this translation helpful? Give feedback.
-
|
listView = new TListViewer(TRect(10,3,maxLx + 12,20),3,0,0); I have replaced TListBox for TListViewer. But how i could fill the columns of each row? |
Beta Was this translation helpful? Give feedback.
-
|
Hi! The There is no standard view that does what you are trying to achieve. However, I found an old spreadsheet example in http://www.sigala.it/sergio/tvision/resources.html: Although it is a bit rudimentary (e.g., it does not support adding rows or columns dynamically), you may find it helpful. You can download it here: spread.zip. Related discussion: #54 Cheers. |
Beta Was this translation helpful? Give feedback.
-
This must be done in the --- a/sprdview.cpp
+++ b/sprdview.cpp
@@ -100,7 +100,7 @@ void TMatrixViewer::draw()
scOff = 0;
}
else if (column < numColumns && row < numRows &&
- isSelected(column, row))
+ focusedRow == row)
{
color = selectedColor;
scOff = 2;That change will cause the whole row to be drawn with a different color. Although that would pervert the intended palette usage, since the --- a/sprdview.cpp
+++ b/sprdview.cpp
@@ -26,7 +26,21 @@
const int cmUpdateItemNumber = 901;
-#define cpMatrixViewer "\x1A\x1A\x1B\x1C\x1D\x06"
+/* ---------------------------------------------------------------------- */
+/* class TMatrixViewer */
+/* */
+/* Palette layout */
+/* 1 = Normal (view focused) */
+/* 2 = Normal (view unfocused) */
+/* 3 = Selected cell (view focused) */
+/* 4 = Selected cell (view unfocused) */
+/* 5 = Column separator */
+/* 6 = Header */
+/* 7 = Selected row (view focused) */
+/* 8 = Selected row (view unfocused) */
+/* ---------------------------------------------------------------------- */
+
+#define cpMatrixViewer "\x1A\x1A\x1B\x1C\x1D\x06\x0A\x1A"
const char * const _NEAR TMatrixViewer::name = "TMatrixViewer";
@@ -61,19 +75,25 @@ TMatrixViewer::TMatrixViewer(const TRect& bounds, TScrollBar *aHScrollBar,
void TMatrixViewer::draw()
{
short i, row, column;
- ushort normalColor, selectedColor, focusedColor, color;
+ TColorAttr normalColor, selectedCellColor, selectedRowColor, color;
TDrawBuffer b;
uchar scOff;
ushort thisWidth;
- focusedColor = getColor(3);
- selectedColor = getColor(4);
if (headingMode)
normalColor = getColor(6);
else if ((state & (sfSelected | sfActive)) == (sfSelected | sfActive))
+ {
normalColor = getColor(1);
+ selectedCellColor = getColor(3);
+ selectedRowColor = getColor(7);
+ }
else
+ {
normalColor = getColor(2);
+ selectedCellColor = getColor(4);
+ selectedRowColor = getColor(8);
+ }
short posColumn = 0;
for (column = leftColumn; posColumn <= size.x; column++)
@@ -95,14 +115,19 @@ void TMatrixViewer::draw()
focusedRow == row && focusedColumn == column &&
numRows > 0)
{
- color = focusedColor;
+ color = selectedCellColor;
setCursor(posColumn + 1, i); // Move the hardware cursor.
scOff = 0;
}
else if (column < numColumns && row < numRows &&
isSelected(column, row))
{
- color = selectedColor;
+ color = selectedCellColor;
scOff = 2;
}
+ else if (focusedRow == row)
+ {
+ color = selectedRowColor;
+ scOff = 4;
+ }
elseDefining palette indices is cumbersome and confusing, so instead of using a custom palette ( |
Beta Was this translation helpful? Give feedback.



Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to fill a TListBox with 3 columns, i am doing:
Here only the first column in the TListBox is filled.
How shall i do to insert the col1, col2 and col3 of each row?
Beta Was this translation helpful? Give feedback.
All reactions