ToolMap
Loading...
Searching...
No Matches
ListGenReport Class Reference

Manage a report list. More...

#include <listgenreport.h>

Inheritance diagram for ListGenReport:
ListGenReportWithDialog QueriesLayerList ListGenReportWithStatus ProjectDefFieldList ProjectDefLayersFieldsList ProjectDefLayersObjectList QueriesList ScaleList ShortcutList ObjectDefinitionList ProjectDefList

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

ListGenMenum_ListContextMenu
 
TextParserm_ImportParser
 

Detailed Description

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

Author
Lucien Schreiber (c) CREALP 2007
Date
15 November 2007

Constructor & Destructor Documentation

◆ ListGenReport() [1/2]

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.

Parameters
parentParent of the list
idId of the List control
sizeSize of the listctrl
Author
Lucien Schreiber (c) CREALP
Date
19 November 2007

◆ ListGenReport() [2/2]

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)

Parameters
parentParent of the list
idId of the List Control
pColsNamepointer to an String array containing columns header. The number of constructed columns is dependant of the number of items in this array
pColsSizepointer 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
sizethe size of the listctrl
Author
Lucien Schreiber (c) CREALP
Date
19 November 2007

◆ ~ListGenReport()

ListGenReport::~ListGenReport ( )

Desctructor.

Do nothing for the moment

Author
Lucien Schreiber (c) CREALP
Date
19 November 2007

Member Function Documentation

◆ AddItemToList()

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.

Parameters
myValueThe string value of the new item
iPositionThe position where we should insert item in the list, default is -1, it means at the end of the list
Author
Lucien Schreiber (c) CREALP 2007
Date
18 December 2007

◆ Compare()

int ListGenReport::Compare ( int  iColumnCompareType,
const wxString &  x_strValue1,
const wxString &  x_strValue2,
bool  bAscending 
)
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

Parameters
iColumnCompareTypeOne of the LIST_FIELD_TYPE value indicating wich sort of column we are trying to sort
x_strValue1The string value of item 1 (may be converted internally based on column type)
x_strValue2The string value of item 2 (may be converted internally based on column type)
bAscendinga TRUE value indicate an ascending sort and a FALSE one indicate a descending sort
Returns
if value 1 is greater than value 2 return 1, if equal return 0 and finaly if value 1 is smaller than value 2 return -1
Author
Lucien Schreiber (c) CREALP 2007
Date
03 April 2008

Reimplemented in ScaleList.

◆ DataToList()

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.

Parameters
pdialogThe adress of a ListGenDialog
myValuesThe string used to pass data to the dialog for modification
Returns
return true if the dialog was closed with the wxID_OK code, FALSE otherwise.
Author
Lucien Schreiber (c) CREALP 2007
Date
18 December 2007

◆ DeleteSelectedItem()

bool ListGenReport::DeleteSelectedItem ( )

Delete the selected item.

Returns
TRUE if an item was selected and is now deleted, otherwise FALSE.
Author
Lucien Schreiber (c) CREALP 2007
Date
18 December 2007

◆ EditDataToList()

bool ListGenReport::EditDataToList ( const wxArrayString &  myValue,
int  index = -1 
)
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.

Parameters
myValuea string array containing the values in the same order as the columns
indexthe zero based index of the item to set the text for. default is -1 meaning that we want to add a new item
Returns
return TRUE if the array contain data false otherwise
Author
Lucien Schreiber (c) CREALP 2007
Date
18 December 2007

◆ ExportListParsedToFile()

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.

Parameters
filenamestring containing the full path and extension of the destination file
FilterIndexZero index based value of the filter selected in the "Save file dialog" see also TEXTPARSER_TYPE
Returns
number of lines written to the file or 0 if nothing was written.
Author
Lucien Schreiber (c) CREALP 2007
Date
18 December 2007

◆ GetAllDataAsStringArray()

int ListGenReport::GetAllDataAsStringArray ( wxArrayString &  myStringArray,
long  index 
)
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.

Parameters
myStringArrayreference to a wxArrayString for storing the list data as wxString.
indexZero based index of the list item to get
Returns
the number of columns of the list control, -1 if all checks fails (see detailled description)
Author
Lucien Schreiber (c) CREALP 2007
Date
18 December 2007

◆ GetAllSelectedItem()

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)

Parameters
resultsan Array of long wich will be filled with selected items
Returns
the number of items selected
Author
Lucien Schreiber (c) CREALP 2007
Date
14 March 2008

◆ GetColumnClicked()

int ListGenReport::GetColumnClicked ( wxWindow *  parent,
int  iIndex,
int  iBorderMargin 
)

Get the column in wich user has clicked.

Parameters
parentAdress of a wxWindow Parent. Used to get the position of the window in screen coordinates
iIndexzero based index of item clicked
iBorderMarginthe left space between window and the control
Returns
return the zero based index of the selected column or -1 if not found
Author
Lucien Schreiber (c) CREALP 2009
Date
21 January 2009

◆ GetItemColText()

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)

Returns
The string contained in the specified position (empty string if null)
Parameters
iItemthe zero based index of the item in the list
iColthe zero based column
Author
Lucien Schreiber (c) CREALP
Date
19 November 2007

◆ GetSelectedItem()

long ListGenReport::GetSelectedItem ( )

Get the first item selected.

Returns
the zero based index of the first item selected
Author
Lucien Schreiber (c) CREALP 2007
Date
20 November 2007

◆ ImportParsedFileToListCtrl()

int ListGenReport::ImportParsedFileToListCtrl ( const wxString &  filename,
const int &  FilterIndex 
)
virtual

Import and parse file to a list.

Uses the TextParser class for importing and parsing file into a list.

Parameters
filenamestring containing the filename (with path and extension)
FilterIndexZero 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.
Returns
number of line parsed
Author
Lucien Schreiber (c) CREALP 2007
Date
14 December 2007

Reimplemented in ListGenReportWithDialog.

◆ ItemExist()

bool ListGenReport::ItemExist ( long  index)

Check for an item existence.

Parameters
indexthe zero based item index of the searched item
Returns
return TRUE if the item exist, in Debug mode, a WXFAIL event will be sent if the item dosen't exist.
Author
Lucien Schreiber (c) CREALP 2007
Date
18 December 2007

◆ MoveItem()

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

Parameters
iItemthe zero based index of the item to move
iNewPosThe new position for the object iItem (default is 0, top of the list)
Author
Lucien Schreiber (c) CREALP 2007
Date
23 November 2007

◆ OnSortColumns()

void ListGenReport::OnSortColumns ( wxListEvent &  event)
protectedvirtual

Called when user click on the column header.

Author
Lucien Schreiber (c) CREALP 2008
Date
24 June 2008

◆ SetItemText()

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

Returns
return true if the item exist
Parameters
iItemthe item to change
iColthe zero based column
textthe new text to set
Author
Lucien Schreiber (c) CREALP
Date
19 November 2007

◆ SortListItem()

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

Parameters
x_colzero based index of column used for sorting
lowzero based index of first item to sort (pass 0 for sorting since the begining)
highzero based top index of item to sort (pass -1 for sorting to the end)
typecolOne of the col type described in LIST_FIELD_TYPE
bAscendingTRUE for sorting ascending, FALSE for descending order
Author
Lucien Schreiber (c) CREALP 2008
Date
24 June 2008

◆ SwapRow()

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

Parameters
x_row1zero based index of item one
x_row2zero based index of item two
Author
Lucien Schreiber (c) CREALP 2007
Date
03 April 2008

The documentation for this class was generated from the following files: