ToolMap
|
Manage a report list. More...
#include <listgenreport.h>
Public Member Functions | |
void | SortListItem (int x_col, int low, int high, int typecol, bool bAscending=TRUE) |
Sort columns. | |
void | SwapRow (int x_row1, int x_row2) |
Swap two items value. | |
virtual int | Compare (int iColumnCompareType, const wxString &x_strValue1, const wxString &x_strValue2, bool bAscending) |
Compare two values for sorting data. | |
ListGenReport (wxWindow *parent, wxWindowID id, wxSize size=wxDefaultSize) | |
Constructor for derived class. | |
ListGenReport (wxWindow *parent, wxWindowID id, wxArrayString *pColsName, wxArrayInt *pColsSize=nullptr, wxSize size=wxDefaultSize, long style=wxLC_REPORT) | |
Constructor. | |
~ListGenReport () | |
Desctructor. | |
void | AddItemToList (wxString myValue, int iPosition=-1) |
Add an item to the list. | |
wxString | GetItemColText (int iItem, int iCol) |
Get the text of a specified column for a specified item. | |
bool | SetItemText (int iItem, int iCol, wxString text) |
Set the text of a specified column for a specified item. | |
long | GetSelectedItem () |
Get the first item selected. | |
void | SetSelectedItem (long index) |
int | GetAllSelectedItem (wxArrayLong &results) |
Get all selected item. | |
void | MoveItem (int iItem, int iNewPos=0) |
Move item in the list. | |
bool | DataToList (ListGenDialog *pdialog, wxArrayString &myValues) |
Change list values using a ListGenDialog. | |
bool | DeleteSelectedItem () |
Delete the selected item. | |
virtual int | GetAllDataAsStringArray (wxArrayString &myStringArray, long index) |
Get all data from a row into an array of string. | |
bool | ItemExist (long index) |
Check for an item existence. | |
virtual bool | EditDataToList (const wxArrayString &myValue, int index=-1) |
Fill list using a string array. | |
virtual int | ImportParsedFileToListCtrl (const wxString &filename, const int &FilterIndex) |
Import and parse file to a list. | |
int | ExportListParsedToFile (const wxString &filename, const int &FilterIndex) |
Export values of a list to a parsed file. | |
int | GetColumnClicked (wxWindow *parent, int iIndex, int iBorderMargin) |
Get the column in wich user has clicked. | |
DECLARE_EVENT_TABLE () | |
Static Public Attributes | |
static const int | ID_LIST = wxID_ANY |
Protected Member Functions | |
void | CreateColumns (wxArrayString *pColsName, wxArrayInt *pColsSize=nullptr) |
virtual void | OnDoubleClickItem (wxListEvent &event) |
virtual void | OnPressBackSpace (wxListEvent &event) |
virtual void | OnContextMenu (wxListEvent &event) |
void | OnMoveItemInList (wxCommandEvent &event) |
virtual void | OnSortColumns (wxListEvent &event) |
Called when user click on the column header. | |
void | OnInit () |
Protected Attributes | |
ListGenMenu * | m_ListContextMenu |
TextParser * | m_ImportParser |
Manage a report list.
This class is derived from wxListCtrl and is mainly used for managing all sort of report list. This class is intended to be derivated This is a graphical class
ListGenReport::ListGenReport | ( | wxWindow * | parent, |
wxWindowID | id, | ||
wxSize | size = wxDefaultSize |
||
) |
Constructor for derived class.
This is the basic constructor mainly used for derivated class. This constructor dosen't invoke the CreateColumns() method and therfore the created list will not contain any columns.
parent | Parent of the list |
id | Id of the List control |
size | Size of the listctrl |
ListGenReport::ListGenReport | ( | wxWindow * | parent, |
wxWindowID | id, | ||
wxArrayString * | pColsName, | ||
wxArrayInt * | pColsSize = nullptr , |
||
wxSize | size = wxDefaultSize , |
||
long | style = wxLC_REPORT |
||
) |
Constructor.
This constructor invoke the CreateColumns() method and therfore the created list will contain columns passed as parameters (see pColsName and pColsSize)
parent | Parent of the list |
id | Id of the List Control |
pColsName | pointer to an String array containing columns header. The number of constructed columns is dependant of the number of items in this array |
pColsSize | pointer to an array of integer containing the width for each columns. If no values are specified then a default size of 100 will be used |
size | the size of the listctrl |
ListGenReport::~ListGenReport | ( | ) |
Desctructor.
Do nothing for the moment
void ListGenReport::AddItemToList | ( | wxString | myValue, |
int | iPosition = -1 |
||
) |
Add an item to the list.
This function adds an item to the list and set the value of this item to the string value specified in parameter myValue.
myValue | The string value of the new item |
iPosition | The position where we should insert item in the list, default is -1, it means at the end of the list |
|
virtual |
Compare two values for sorting data.
This function compare values of two items based on the column type wich could be one of the LIST_FIELD_TYPE
iColumnCompareType | One of the LIST_FIELD_TYPE value indicating wich sort of column we are trying to sort |
x_strValue1 | The string value of item 1 (may be converted internally based on column type) |
x_strValue2 | The string value of item 2 (may be converted internally based on column type) |
bAscending | a TRUE value indicate an ascending sort and a FALSE one indicate a descending sort |
Reimplemented in ScaleList.
bool ListGenReport::DataToList | ( | ListGenDialog * | pdialog, |
wxArrayString & | myValues | ||
) |
Change list values using a ListGenDialog.
For simple list, we can use a ListGenDialog derived dialog. This dialog should implement the SetDlgData() and GetDlgData virtual function for modification of items in response of a double click for exemple.
pdialog | The adress of a ListGenDialog |
myValues | The string used to pass data to the dialog for modification |
bool ListGenReport::DeleteSelectedItem | ( | ) |
Delete the selected item.
|
virtual |
Fill list using a string array.
This function could be used to set values into a list using a String array. This generic function may be used without knowledge of the list, it simply fill the number of cols according to the number of items in the string array. If both numbers are different, then only the first n items of the string array are used or only the first n columns are filled. Some internal checks are done to ensure that the passed array is not empty.
myValue | a string array containing the values in the same order as the columns |
index | the zero based index of the item to set the text for. default is -1 meaning that we want to add a new item |
int ListGenReport::ExportListParsedToFile | ( | const wxString & | filename, |
const int & | FilterIndex | ||
) |
Export values of a list to a parsed file.
This uses the TextParser class for parsing all the list values into a file. Supported parser are managed by the TextParser class.
filename | string containing the full path and extension of the destination file |
FilterIndex | Zero index based value of the filter selected in the "Save file dialog" see also TEXTPARSER_TYPE |
|
virtual |
Get all data from a row into an array of string.
This function does some aditionnal checks, first of all it checks that some columns exists in the list control and also that the specified item exist (calling the ItemExist() function). A wxFAIL signal is sent in debug mode if thoses conditions aren't fullfiled.
myStringArray | reference to a wxArrayString for storing the list data as wxString. |
index | Zero based index of the list item to get |
int ListGenReport::GetAllSelectedItem | ( | wxArrayLong & | results | ) |
Get all selected item.
Return an array of long containing all selected items in the list (only usefull if list style isn't wxLC_SINGLE_SEL)
results | an Array of long wich will be filled with selected items |
int ListGenReport::GetColumnClicked | ( | wxWindow * | parent, |
int | iIndex, | ||
int | iBorderMargin | ||
) |
Get the column in wich user has clicked.
parent | Adress of a wxWindow Parent. Used to get the position of the window in screen coordinates |
iIndex | zero based index of item clicked |
iBorderMargin | the left space between window and the control |
wxString ListGenReport::GetItemColText | ( | int | iItem, |
int | iCol | ||
) |
Get the text of a specified column for a specified item.
Retrive the text of a specified item (iItem) for a specified column (iCol)
iItem | the zero based index of the item in the list |
iCol | the zero based column |
long ListGenReport::GetSelectedItem | ( | ) |
Get the first item selected.
|
virtual |
Import and parse file to a list.
Uses the TextParser class for importing and parsing file into a list.
filename | string containing the filename (with path and extension) |
FilterIndex | Zero index based value of the filter selected in the Open file dialog. This value could be for exemple : TXTFILE_COMMA or TXTFILE_TAB. See description of class TextParser for more details. |
Reimplemented in ListGenReportWithDialog.
bool ListGenReport::ItemExist | ( | long | index | ) |
Check for an item existence.
index | the zero based item index of the searched item |
void ListGenReport::MoveItem | ( | int | iItem, |
int | iNewPos = 0 |
||
) |
Move item in the list.
This function is intended to move item between two position in the list. This function could be used for exemple in response to a DnD event or to a popup menu
iItem | the zero based index of the item to move |
iNewPos | The new position for the object iItem (default is 0, top of the list) |
|
protectedvirtual |
Called when user click on the column header.
bool ListGenReport::SetItemText | ( | int | iItem, |
int | iCol, | ||
wxString | text | ||
) |
Set the text of a specified column for a specified item.
Allow to change the text of a specified item in an easy way
iItem | the item to change |
iCol | the zero based column |
text | the new text to set |
void ListGenReport::SortListItem | ( | int | x_col, |
int | low, | ||
int | high, | ||
int | typecol, | ||
bool | bAscending = TRUE |
||
) |
Sort columns.
This functions sort columns based on type in ascending or descending order
x_col | zero based index of column used for sorting |
low | zero based index of first item to sort (pass 0 for sorting since the begining) |
high | zero based top index of item to sort (pass -1 for sorting to the end) |
typecol | One of the col type described in LIST_FIELD_TYPE |
bAscending | TRUE for sorting ascending, FALSE for descending order |
void ListGenReport::SwapRow | ( | int | x_row1, |
int | x_row2 | ||
) |
Swap two items value.
Swap the values of items (color, item data, even icon) between two items. A verification is made and nothing is done if two items are similar
x_row1 | zero based index of item one |
x_row2 | zero based index of item two |