]>
Commit | Line | Data |
---|---|---|
1 | //----------------------------------------------------------------------------- | |
2 | // Name: custclas.h | |
3 | // Purpose: XML resources sample: A custom class to insert into a XRC file | |
4 | // Author: Robert O'Connor (rob@medicalmnemonics.com), Vaclav Slavik | |
5 | // Copyright: (c) Robert O'Connor and Vaclav Slavik | |
6 | // Licence: wxWindows licence | |
7 | //----------------------------------------------------------------------------- | |
8 | ||
9 | //---------------------------------------------------------------------------------------- | |
10 | // Begin single inclusion of this .h file condition | |
11 | //---------------------------------------------------------------------------------------- | |
12 | ||
13 | #ifndef _CUSTCLAS_H_ | |
14 | #define _CUSTCLAS_H_ | |
15 | ||
16 | //---------------------------------------------------------------------------------------- | |
17 | // Headers | |
18 | //---------------------------------------------------------------------------------------- | |
19 | ||
20 | #include "wx/listctrl.h" | |
21 | ||
22 | //---------------------------------------------------------------------------------------- | |
23 | // Class definition: MyResizableListCtrl | |
24 | //---------------------------------------------------------------------------------------- | |
25 | ||
26 | //! A custom listctrl that resizes itself and pops up a context-sensitive menu. | |
27 | class MyResizableListCtrl : public wxListCtrl | |
28 | { | |
29 | // Very helpful wxWidgets macro required for wxWidgets-RTTI tracing: By using this | |
30 | // you will see "Leaked one object of type myResizableListCtrl" in the debug log, | |
31 | // along with which line you if was created, but you forget to free the memory. | |
32 | // NOTE: Using this REQUIRES a default constructor: that means either: giving a | |
33 | // default value for all parameters in your constructor, or else having a dummy | |
34 | // MyResizableListCtrl(){} constructor in addition to your regular one. | |
35 | DECLARE_DYNAMIC_CLASS( MyResizableListCtrl ) | |
36 | ||
37 | public: | |
38 | ||
39 | // Constructor. | |
40 | /* | |
41 | These parameters are the same as a wxWidgets constructor. | |
42 | \param parent The parent window. | |
43 | \param id The id of the progress_listbox. Will usually be -1 unless multiple | |
44 | of them on the same dialog. | |
45 | \param pos The pixel position of the listctrl on its parent window | |
46 | \param size The pixel size of the listctrl | |
47 | \param style Style of the listbox. See wxWidgets wxListBox docs for details. | |
48 | \param validator Window validator. See wxWidgets docs for details. | |
49 | \param name Windows name (rarely used). | |
50 | \param exclusion_column_caption The label of header of listctrl's exclusion | |
51 | column. | |
52 | */ | |
53 | MyResizableListCtrl( wxWindow *parent = NULL, | |
54 | wxWindowID id = wxID_ANY, | |
55 | const wxPoint &pos = wxDefaultPosition, | |
56 | const wxSize &size = wxDefaultSize, | |
57 | long style = wxLC_REPORT, | |
58 | const wxValidator& validator = wxDefaultValidator, | |
59 | const wxString &name = wxT("myResizableListCtrl") | |
60 | ); | |
61 | ||
62 | // Destructor. | |
63 | ~MyResizableListCtrl(){}; | |
64 | ||
65 | protected: | |
66 | ||
67 | // A custom function for a context sensitive menu. | |
68 | void ContextSensitiveMenu( wxMouseEvent& event ); | |
69 | ||
70 | // This is a wxWidgets function that we are going to override with our own behaviour. | |
71 | void OnSize( wxSizeEvent &event ); | |
72 | ||
73 | // A custom function. What is called in the constructor, and in an OnSize() | |
74 | void SetColumnWidths(); | |
75 | ||
76 | private: | |
77 | ||
78 | // wxWidgets macro, required to be able to use Event tables in the .cpp file. | |
79 | DECLARE_EVENT_TABLE() | |
80 | ||
81 | }; | |
82 | ||
83 | //---------------------------------------------------------------------------------------- | |
84 | // End single inclusion of this .h file condition | |
85 | //---------------------------------------------------------------------------------------- | |
86 | ||
87 | #endif //_CUSTCLAS_H_ | |
88 |