ToolMap
Loading...
Searching...
No Matches
listgenreport.h
1/*******************************************************/
15#ifndef LISTGENREPORT_H
16#define LISTGENREPORT_H
17
18// For compilers that support precompilation, includes "wx/wx.h".
19#include <wx/wxprec.h>
20
21// Include wxWidgets' headers
22#ifndef WX_PRECOMP
23#include <wx/wx.h>
24#endif
25
26#include <wx/arrstr.h>
27#include <wx/dnd.h>
28#include <wx/listctrl.h>
29#include <wx/menu.h>
30#include <wx/textdlg.h>
31
32#include "../core/textparser.h"
33
39#define ID_MENU_MOVE_TOP 20000
40#define ID_MENU_MOVE_UP 20001
41#define ID_MENU_MOVE_DOWN 20002
42#define ID_MENU_MOVE_BOTTOM 20003
44
45class ListGenMenu; // forward declaration
46class ListGenDialog; // forward declaration
47
48enum LIST_FIELD_TYPE {
49 FIELD_STRING = 0,
50 FIELD_NUMBER = 1,
51 FIELD_DATE = 2
52};
53
54/*******************************************************/
63class ListGenReport : public wxListCtrl {
64 protected:
65 ListGenMenu* m_ListContextMenu;
66 TextParser* m_ImportParser;
67
68 void CreateColumns(wxArrayString* pColsName, wxArrayInt* pColsSize = nullptr);
69
70 // events
71 virtual void OnDoubleClickItem(wxListEvent& event);
72
73 virtual void OnPressBackSpace(wxListEvent& event);
74
75 virtual void OnContextMenu(wxListEvent& event);
76
77 void OnMoveItemInList(wxCommandEvent& event);
78
79 virtual void OnSortColumns(wxListEvent& event);
80
81 // void OnStartDrag (wxListEvent & event); // not implemented now maybe layer...
82 void OnInit();
83
84 public:
85 void SortListItem(int x_col, int low, int high, int typecol, bool bAscending = TRUE);
86
87 void SwapRow(int x_row1, int x_row2);
88
89 virtual int Compare(int iColumnCompareType, const wxString& x_strValue1, const wxString& x_strValue2,
90 bool bAscending);
91
92 /*********************************************/
105 ListGenReport(wxWindow* parent, wxWindowID id, wxSize size = wxDefaultSize);
106
107 /*********************************************/
129 ListGenReport(wxWindow* parent, wxWindowID id, wxArrayString* pColsName, wxArrayInt* pColsSize = nullptr,
130 wxSize size = wxDefaultSize, long style = wxLC_REPORT);
131
132 /*********************************************/
139
140 static const int ID_LIST;
141
142 /***************************************************************************/
152 void AddItemToList(wxString myValue, int iPosition = -1);
153
154 /*********************************************/
168 wxString GetItemColText(int iItem, int iCol);
169
170 /*********************************************/
182 bool SetItemText(int iItem, int iCol, wxString text);
183
184 /*********************************************/
191 long GetSelectedItem();
192
193 void SetSelectedItem(long index);
194
195 /***************************************************************************/
204 int GetAllSelectedItem(wxArrayLong& results);
205
206 /*****************************************************************/
217 void MoveItem(int iItem, int iNewPos = 0);
218
219 /***************************************************************************/
231 bool DataToList(ListGenDialog* pdialog, wxArrayString& myValues);
232
233 /***************************************************************************/
240 bool DeleteSelectedItem();
241
242 /***************************************************************************/
256 virtual int GetAllDataAsStringArray(wxArrayString& myStringArray, long index);
257
258 /***************************************************************************/
267 bool ItemExist(long index);
268
269 /***************************************************************************/
285 virtual bool EditDataToList(const wxArrayString& myValue, int index = -1);
286
287 /***************************************************************************/
298 virtual int ImportParsedFileToListCtrl(const wxString& filename, const int& FilterIndex);
299
300 /***************************************************************************/
312 int ExportListParsedToFile(const wxString& filename, const int& FilterIndex);
313
314 int GetColumnClicked(wxWindow* parent, int iIndex, int iBorderMargin);
315
316 DECLARE_EVENT_TABLE();
317};
318
320 protected:
321 wxDialog* m_pDialog;
322
323 void InitMembers();
324
325 virtual void BeforeAdding() {
326 ;
327 }
328
329 virtual void BeforeDeleting() {
330 ;
331 }
332
333 virtual void AfterAdding(bool bRealyAddItem) {
334 ;
335 }
336
337 virtual void BeforeEditing() {
338 ;
339 }
340
341 virtual void AfterEditing(bool bRealyEdited) {
342 ;
343 }
344
345 virtual void AddingValueToArray(wxArrayString& myImportedValues) {
346 ;
347 }
348
349 virtual void OnDoubleClickItem(wxListEvent& event);
350
351 virtual void OnPressBackSpace(wxListEvent& event);
352
353 public:
354 ListGenReportWithDialog(wxWindow* parent, wxWindowID id, wxSize size = wxDefaultSize);
355
356 ListGenReportWithDialog(wxWindow* parent, wxWindowID id, wxArrayString* pColsName, wxArrayInt* pColsSize = nullptr,
357 wxSize size = wxDefaultSize, long style = wxLC_REPORT);
358
360
361 virtual int ImportParsedFileToListCtrl(const wxString& filename, const int& FilterIndex);
362
363 void SetDialog(wxDialog* pDialog) {
364 m_pDialog = pDialog;
365 }
366
367 virtual void AddItem();
368
369 virtual void DeleteItem();
370
371 void EditItem();
372};
373
374// enum for disabling menu based on position
375enum MENU_DISABLE {
376 MENU_DISABLE_TOP = 1,
377 MENU_DISABLE_BOTTOM = 2
378};
379
380/*****************************************************************/
391class ListGenMenu : public wxMenu {
392 protected:
393 void MenuInit();
394
395 virtual wxMenu* CreateContextMenu();
396
397 wxMenu* m_ContextMenu;
398
399 public:
400 ListGenMenu();
401
402 ListGenMenu(const wxString& title, long style = 0);
403
404 ~ListGenMenu() {
405 delete m_ContextMenu;
406 }
407
408 // disable portion of menu
409 void DisableMenuMove(int flags);
410
411 wxMenu* GetTheMenu() {
412 return m_ContextMenu;
413 }
414};
415
416class ListGenDialog : public wxDialog {
417 protected:
418 // virtual void Init(){;}
419 // virtual void CreateDlgControls() {;}
420 public:
421 ListGenDialog() {
422 ;
423 }
424 // ListGenDialog( wxWindow* parent,
425 // wxWindowID id ,
426 // const wxString& caption,
427 // const wxPoint& pos,
428 // const wxSize& size,
429 // long style);
430
432 ;
433 }
434
435 virtual void GetDlgData(wxArrayString& myStringArray) = 0;
436
437 virtual void SetDlgData(wxArrayString& myStringArray) = 0;
438};
439
440#endif
Definition listgenreport.h:416
contextual menu for ListGenReport
Definition listgenreport.h:391
Definition listgenreport.h:319
virtual int ImportParsedFileToListCtrl(const wxString &filename, const int &FilterIndex)
Import file data to list.
Definition listgenreport.cpp:841
Manage a report list.
Definition listgenreport.h:63
bool SetItemText(int iItem, int iCol, wxString text)
Set the text of a specified column for a specified item.
Definition listgenreport.cpp:324
~ListGenReport()
Desctructor.
Definition listgenreport.cpp:177
int GetAllSelectedItem(wxArrayLong &results)
Get all selected item.
Definition listgenreport.cpp:308
void SwapRow(int x_row1, int x_row2)
Swap two items value.
Definition listgenreport.cpp:613
bool DataToList(ListGenDialog *pdialog, wxArrayString &myValues)
Change list values using a ListGenDialog.
Definition listgenreport.cpp:372
virtual int Compare(int iColumnCompareType, const wxString &x_strValue1, const wxString &x_strValue2, bool bAscending)
Compare two values for sorting data.
Definition listgenreport.cpp:684
bool ItemExist(long index)
Check for an item existence.
Definition listgenreport.cpp:429
void MoveItem(int iItem, int iNewPos=0)
Move item in the list.
Definition listgenreport.cpp:343
bool DeleteSelectedItem()
Delete the selected item.
Definition listgenreport.cpp:394
long GetSelectedItem()
Get the first item selected.
Definition listgenreport.cpp:292
void SortListItem(int x_col, int low, int high, int typecol, bool bAscending=TRUE)
Sort columns.
Definition listgenreport.cpp:559
virtual bool EditDataToList(const wxArrayString &myValue, int index=-1)
Fill list using a string array.
Definition listgenreport.cpp:45
virtual int ImportParsedFileToListCtrl(const wxString &filename, const int &FilterIndex)
Import and parse file to a list.
Definition listgenreport.cpp:72
virtual void OnSortColumns(wxListEvent &event)
Called when user click on the column header.
Definition listgenreport.cpp:278
int GetColumnClicked(wxWindow *parent, int iIndex, int iBorderMargin)
Get the column in wich user has clicked.
Definition listgenreport.cpp:449
wxString GetItemColText(int iItem, int iCol)
Get the text of a specified column for a specified item.
Definition listgenreport.cpp:282
virtual int GetAllDataAsStringArray(wxArrayString &myStringArray, long index)
Get all data from a row into an array of string.
Definition listgenreport.cpp:409
void AddItemToList(wxString myValue, int iPosition=-1)
Add an item to the list.
Definition listgenreport.cpp:181
int ExportListParsedToFile(const wxString &filename, const int &FilterIndex)
Export values of a list to a parsed file.
Definition listgenreport.cpp:115
Super-class for parsing different file.
Definition textparser.h:64