The data structure loaded into the wxDataViewListCtrl is an array of structures: one array structure (element) per wxDataViewListCtrl row. Here is the a snippet from file MainFrame.cpp defining the database.
Code: Select all
// ...
// =============================================================================
// Constants Global Within This File
// =============================================================================
#define QTY_CHANNELS 4 // quantity of rows = QTY_CHANNELS + 1 (1 for a header row)
#define QTY_COLUMNS 4
#define COL_OF_CH 0 // column 0 = channel
#define COL_OF_SHUNT 1 // column 1 = shunt on/off
#define COL_OF_PGA 2 // column 2 = PGA value
#define COL_OF_ADC_DF 3 // column 3 = ADC DF value
// =============================================================================
// Types Public Within This File
// =============================================================================
enum t_CH_Type
{ // Each one of these defines a single channel.
ch_Type_01, // Notice number starts at 1, not 0.
ch_Type_02,
ch_Type_03,
ch_Type_04
}; // Each one of these defines a single channel.
enum t_Shunt_Type
{
Shunt_Off,
Shunt_On
};
#define QTY_PGAS 8
enum t_PGA_Type
{
PGA_000, // 0
PGA_001, // 1
PGA_002, // 2
PGA_005, // 3
PGA_010, // 4
PGA_020, // 5
PGA_050, // 6
PGA_100 // 7
};
#define QTY_ADC_DFS 4
enum t_ADC_DF_Type
{
ADC_DF_00, // 0
ADC_DF_01, // 1
ADC_DF_02, // 2
ADC_DF_03 // 3
};
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Example of the wxDataViewListCtrl display:
//
// +------------------------------------+
// | Channel Shunt PGA ADC DF |
// | ------- ----- --- ------ |
// | 1 off 50 3 |
// | 2 on 100 1 |
// | 3 off 2 2 |
// | 4 off 20 0 |
// +------------------------------------+
//
// The following values appear as the COLUMN HEADERS for the
// wxDataViewListCtrl.
//
// Column # Identifier Data Type
// -------- ---------- ---------
// 0 Channel # choice: UInt16, [1..4]
// 1 Shunt choice: 1 binary digit: [0b0..0b1]
// 2 PGA choice: 3 binary digits: [0b000..0b111]
// 3 ADC_DF choice: 2 binary digits: [0b00..0b11]
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
typedef struct t_Channel_Data
{
t_CH_Type Ch_Number; // 0
t_Shunt_Type Shunt; // 1
t_PGA_Type PGA; // 2
t_ADC_DF_Type ADC_DF; // 3
} t_Channel_Record; // structure_type_Channel_Data
// =============================================================================
// Variables Local to This File
// =============================================================================
static t_Channel_Record Orig_Ch_Data [QTY_CHANNELS];
static t_Channel_Record Edited_Ch_Data [QTY_CHANNELS];
static bool A_Value_Changed;
static MainFrame* Local_MF_Ptr;
// ...
I need both the row and column values in order to update my array of structures. I.e. Edited_Ch_Data [row].<correct column> = newvalue;
So, let's say my user changes the value in Row 3, Column 2 (which would be channel 3, PGA). I know I can use GetValue to get the new value:
Code: Select all
void wxDataViewListCtrl::GetValue ( wxVariant & value,
unsigned int row,
unsigned int col
)
What I DON'T know is, how do I get the value for the "col" argument for GetValue?
To figure this out on my own:
* I looked at the sample wxDataViewListCtrl code, but it does not cover changing values in the fields. It features display-only information.
* I read and re-read the wxWidgets wxDataViewListCtrl page http://docs.wxwidgets.org/trunk/classwx ... _ctrl.html. I'm sure the right function is there, but I'm just not seeing it.
* I experimented with different values for "col" hardcoded into the GetValue call. The values I tried certainly worked correctly. But how do I know which column was the one that the user just edited?
Suggestions:
1. A GetSelectedCol function would be very handy, and its name would match the format of the GetSelectedRow function that already exists.
2. A GetSelectedPosition function to return both row and column of an edited field would be wonderfully handy, too.
Thanks in advance!!!
Colleen
Versions:
CodeLite 10.0.7
MinGW hard to tell, but I downloaded it on July 10, 2017
Windows 10 Pro, 64-bit, currently running in Test Mode
wxWidgets 3.0.2
wxCrafter 2.6