dataview.h 110 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: dataview.h
  3. // Purpose: interface of wxDataView* classes
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. @class wxDataViewModel
  9. wxDataViewModel is the base class for all data model to be displayed by a
  10. wxDataViewCtrl.
  11. All other models derive from it and must implement its pure virtual functions
  12. in order to define a complete data model. In detail, you need to override
  13. wxDataViewModel::IsContainer, wxDataViewModel::GetParent, wxDataViewModel::GetChildren,
  14. wxDataViewModel::GetColumnCount, wxDataViewModel::GetColumnType and
  15. wxDataViewModel::GetValue in order to define the data model which acts as an
  16. interface between your actual data and the wxDataViewCtrl.
  17. Note that wxDataViewModel does not define the position or index of any item
  18. in the control because different controls might display the same data differently.
  19. wxDataViewModel does provide a wxDataViewModel::Compare method which the
  20. wxDataViewCtrl may use to sort the data either in conjunction with a column
  21. header or without (see wxDataViewModel::HasDefaultCompare).
  22. wxDataViewModel (as indeed the entire wxDataViewCtrl code) is using wxVariant
  23. to store data and its type in a generic way. wxVariant can be extended to contain
  24. almost any data without changes to the original class. To a certain extent,
  25. you can use (the somewhat more elegant) wxAny instead of wxVariant as there
  26. is code to convert between the two, but it is unclear what impact this will
  27. have on performance.
  28. Since you will usually allow the wxDataViewCtrl to change your data
  29. through its graphical interface, you will also have to override
  30. wxDataViewModel::SetValue which the wxDataViewCtrl will call when a change
  31. to some data has been committed.
  32. If the data represented by the model is changed by something else than its
  33. associated wxDataViewCtrl, the control has to be notified about the change.
  34. Depending on what happened you need to call one of the following methods:
  35. - wxDataViewModel::ValueChanged,
  36. - wxDataViewModel::ItemAdded,
  37. - wxDataViewModel::ItemDeleted,
  38. - wxDataViewModel::ItemChanged,
  39. - wxDataViewModel::Cleared.
  40. There are plural forms for notification of addition, change or removal of
  41. several item at once. See:
  42. - wxDataViewModel::ItemsAdded,
  43. - wxDataViewModel::ItemsDeleted,
  44. - wxDataViewModel::ItemsChanged.
  45. This class maintains a list of wxDataViewModelNotifier which link this class
  46. to the specific implementations on the supported platforms so that e.g. calling
  47. wxDataViewModel::ValueChanged on this model will just call
  48. wxDataViewModelNotifier::ValueChanged for each notifier that has been added.
  49. You can also add your own notifier in order to get informed about any changes
  50. to the data in the list model.
  51. Currently wxWidgets provides the following models apart from the base model:
  52. wxDataViewIndexListModel, wxDataViewVirtualListModel, wxDataViewTreeStore,
  53. wxDataViewListStore.
  54. Note that wxDataViewModel is reference counted, derives from wxRefCounter
  55. and cannot be deleted directly as it can be shared by several wxDataViewCtrls.
  56. This implies that you need to decrease the reference count after
  57. associating the model with a control like this:
  58. @code
  59. wxDataViewCtrl *musicCtrl = new wxDataViewCtrl( this, wxID_ANY );
  60. wxDataViewModel *musicModel = new MyMusicModel;
  61. m_musicCtrl->AssociateModel( musicModel );
  62. musicModel->DecRef(); // avoid memory leak !!
  63. // add columns now
  64. @endcode
  65. A potentially better way to avoid memory leaks is to use wxObjectDataPtr
  66. @code
  67. wxObjectDataPtr<MyMusicModel> musicModel;
  68. wxDataViewCtrl *musicCtrl = new wxDataViewCtrl( this, wxID_ANY );
  69. musicModel = new MyMusicModel;
  70. m_musicCtrl->AssociateModel( musicModel.get() );
  71. // add columns now
  72. @endcode
  73. @library{wxadv}
  74. @category{dvc}
  75. */
  76. class wxDataViewModel : public wxRefCounter
  77. {
  78. public:
  79. /**
  80. Constructor.
  81. */
  82. wxDataViewModel();
  83. /**
  84. Adds a wxDataViewModelNotifier to the model.
  85. */
  86. void AddNotifier(wxDataViewModelNotifier* notifier);
  87. /**
  88. Change the value of the given item and update the control to reflect
  89. it.
  90. This function simply calls SetValue() and, if it succeeded,
  91. ValueChanged().
  92. @since 2.9.1
  93. @param variant
  94. The new value.
  95. @param item
  96. The item (row) to update.
  97. @param col
  98. The column to update.
  99. @return
  100. @true if both SetValue() and ValueChanged() returned @true.
  101. */
  102. bool ChangeValue(const wxVariant& variant,
  103. const wxDataViewItem& item,
  104. unsigned int col);
  105. /**
  106. Called to inform the model that all data has been cleared.
  107. The control will reread the data from the model again.
  108. */
  109. virtual bool Cleared();
  110. /**
  111. The compare function to be used by control. The default compare function
  112. sorts by container and other items separately and in ascending order.
  113. Override this for a different sorting behaviour.
  114. @see HasDefaultCompare().
  115. */
  116. virtual int Compare(const wxDataViewItem& item1,
  117. const wxDataViewItem& item2,
  118. unsigned int column,
  119. bool ascending) const;
  120. /**
  121. Override this to indicate that the item has special font attributes.
  122. This only affects the wxDataViewTextRendererText renderer.
  123. The base class version always simply returns @false.
  124. @see wxDataViewItemAttr.
  125. @param item
  126. The item for which the attribute is requested.
  127. @param col
  128. The column of the item for which the attribute is requested.
  129. @param attr
  130. The attribute to be filled in if the function returns @true.
  131. @return
  132. @true if this item has an attribute or @false otherwise.
  133. */
  134. virtual bool GetAttr(const wxDataViewItem& item, unsigned int col,
  135. wxDataViewItemAttr& attr) const;
  136. /**
  137. Override this to indicate that the item should be disabled.
  138. Disabled items are displayed differently (e.g. grayed out) and cannot
  139. be interacted with.
  140. The base class version always returns @true, thus making all items
  141. enabled by default.
  142. @param item
  143. The item whose enabled status is requested.
  144. @param col
  145. The column of the item whose enabled status is requested.
  146. @return
  147. @true if this item should be enabled, @false otherwise.
  148. @note Currently disabling items is not supported by the wxOSX/Carbon
  149. implementation.
  150. @since 2.9.2
  151. */
  152. virtual bool IsEnabled(const wxDataViewItem &item,
  153. unsigned int col) const;
  154. /**
  155. Override this so the control can query the child items of an item.
  156. Returns the number of items.
  157. */
  158. virtual unsigned int GetChildren(const wxDataViewItem& item,
  159. wxDataViewItemArray& children) const = 0;
  160. /**
  161. Override this to indicate the number of columns in the model.
  162. */
  163. virtual unsigned int GetColumnCount() const = 0;
  164. /**
  165. Override this to indicate what type of data is stored in the
  166. column specified by @a col.
  167. This should return a string indicating the type of data as reported by wxVariant.
  168. */
  169. virtual wxString GetColumnType(unsigned int col) const = 0;
  170. /**
  171. Override this to indicate which wxDataViewItem representing the parent
  172. of @a item or an invalid wxDataViewItem if the root item is
  173. the parent item.
  174. */
  175. virtual wxDataViewItem GetParent(const wxDataViewItem& item) const = 0;
  176. /**
  177. Override this to indicate the value of @a item.
  178. A wxVariant is used to store the data.
  179. */
  180. virtual void GetValue(wxVariant& variant, const wxDataViewItem& item,
  181. unsigned int col) const = 0;
  182. /**
  183. Override this method to indicate if a container item merely acts as a
  184. headline (or for categorisation) or if it also acts a normal item with
  185. entries for further columns. By default returns @false.
  186. */
  187. virtual bool HasContainerColumns(const wxDataViewItem& item) const;
  188. /**
  189. Override this to indicate that the model provides a default compare
  190. function that the control should use if no wxDataViewColumn has been
  191. chosen for sorting. Usually, the user clicks on a column header for
  192. sorting, the data will be sorted alphanumerically.
  193. If any other order (e.g. by index or order of appearance) is required,
  194. then this should be used.
  195. See wxDataViewIndexListModel for a model which makes use of this.
  196. */
  197. virtual bool HasDefaultCompare() const;
  198. /**
  199. Return true if there is a value in the given column of this item.
  200. All normal items have values in all columns but the container items
  201. only show their label in the first column (@a col == 0) by default (but
  202. see HasContainerColumns()). So this function always returns true for
  203. the first column while for the other ones it returns true only if the
  204. item is not a container or HasContainerColumns() was overridden to
  205. return true for it.
  206. @since 2.9.1
  207. */
  208. bool HasValue(const wxDataViewItem& item, unsigned col) const;
  209. /**
  210. Override this to indicate of @a item is a container, i.e.\ if
  211. it can have child items.
  212. */
  213. virtual bool IsContainer(const wxDataViewItem& item) const = 0;
  214. /**
  215. Call this to inform the model that an item has been added to the data.
  216. */
  217. bool ItemAdded(const wxDataViewItem& parent,
  218. const wxDataViewItem& item);
  219. /**
  220. Call this to inform the model that an item has changed.
  221. This will eventually emit a @c wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
  222. event (in which the column fields will not be set) to the user.
  223. */
  224. bool ItemChanged(const wxDataViewItem& item);
  225. /**
  226. Call this to inform the model that an item has been deleted from the data.
  227. */
  228. bool ItemDeleted(const wxDataViewItem& parent,
  229. const wxDataViewItem& item);
  230. /**
  231. Call this to inform the model that several items have been added to the data.
  232. */
  233. bool ItemsAdded(const wxDataViewItem& parent,
  234. const wxDataViewItemArray& items);
  235. /**
  236. Call this to inform the model that several items have changed.
  237. This will eventually emit @c wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
  238. events (in which the column fields will not be set) to the user.
  239. */
  240. bool ItemsChanged(const wxDataViewItemArray& items);
  241. /**
  242. Call this to inform the model that several items have been deleted.
  243. */
  244. bool ItemsDeleted(const wxDataViewItem& parent,
  245. const wxDataViewItemArray& items);
  246. /**
  247. Remove the @a notifier from the list of notifiers.
  248. */
  249. void RemoveNotifier(wxDataViewModelNotifier* notifier);
  250. /**
  251. Call this to initiate a resort after the sort function has been changed.
  252. */
  253. virtual void Resort();
  254. /**
  255. This gets called in order to set a value in the data model.
  256. The most common scenario is that the wxDataViewCtrl calls this method
  257. after the user changed some data in the view.
  258. This is the function you need to override in your derived class but if
  259. you want to call it, ChangeValue() is usually more convenient as
  260. otherwise you need to manually call ValueChanged() to update the
  261. control itself.
  262. */
  263. virtual bool SetValue(const wxVariant& variant,
  264. const wxDataViewItem& item,
  265. unsigned int col) = 0;
  266. /**
  267. Call this to inform this model that a value in the model has been changed.
  268. This is also called from wxDataViewCtrl's internal editing code, e.g. when
  269. editing a text field in the control.
  270. This will eventually emit a @c wxEVT_DATAVIEW_ITEM_VALUE_CHANGED
  271. event to the user.
  272. */
  273. virtual bool ValueChanged(const wxDataViewItem& item,
  274. unsigned int col);
  275. virtual bool IsListModel() const;
  276. virtual bool IsVirtualListModel() const;
  277. protected:
  278. /**
  279. Destructor. This should not be called directly. Use DecRef() instead.
  280. */
  281. virtual ~wxDataViewModel();
  282. };
  283. /**
  284. @class wxDataViewListModel
  285. Base class with abstract API for wxDataViewIndexListModel and
  286. wxDataViewVirtualListModel.
  287. @library{wxadv}
  288. @category{dvc}
  289. */
  290. class wxDataViewListModel : public wxDataViewModel
  291. {
  292. public:
  293. /**
  294. Destructor.
  295. */
  296. virtual ~wxDataViewListModel();
  297. /**
  298. Compare method that sorts the items by their index.
  299. */
  300. int Compare(const wxDataViewItem& item1,
  301. const wxDataViewItem& item2,
  302. unsigned int column, bool ascending) const;
  303. /**
  304. Override this to indicate that the row has special font attributes.
  305. This only affects the wxDataViewTextRendererText() renderer.
  306. The base class version always simply returns @false.
  307. @see wxDataViewItemAttr.
  308. @param row
  309. The row for which the attribute is requested.
  310. @param col
  311. The column for which the attribute is requested.
  312. @param attr
  313. The attribute to be filled in if the function returns @true.
  314. @return
  315. @true if this item has an attribute or @false otherwise.
  316. */
  317. virtual bool GetAttrByRow(unsigned int row, unsigned int col,
  318. wxDataViewItemAttr& attr) const;
  319. /**
  320. Override this if you want to disable specific items.
  321. The base class version always returns @true, thus making all items
  322. enabled by default.
  323. @param row
  324. The row of the item whose enabled status is requested.
  325. @param col
  326. The column of the item whose enabled status is requested.
  327. @return
  328. @true if the item at this row and column should be enabled,
  329. @false otherwise.
  330. @note See wxDataViewModel::IsEnabled() for the current status of
  331. support for disabling the items under different platforms.
  332. @since 2.9.2
  333. */
  334. virtual bool IsEnabledByRow(unsigned int row,
  335. unsigned int col) const;
  336. /**
  337. Returns the number of items (or rows) in the list.
  338. */
  339. unsigned int GetCount() const = 0;
  340. /**
  341. Returns the position of given @e item.
  342. */
  343. unsigned int GetRow(const wxDataViewItem& item) const = 0;
  344. /**
  345. Override this to allow getting values from the model.
  346. */
  347. virtual void GetValueByRow(wxVariant& variant, unsigned int row,
  348. unsigned int col) const = 0;
  349. /**
  350. Called in order to set a value in the model.
  351. */
  352. virtual bool SetValueByRow(const wxVariant& variant, unsigned int row,
  353. unsigned int col) = 0;
  354. };
  355. /**
  356. @class wxDataViewIndexListModel
  357. wxDataViewIndexListModel is a specialized data model which lets you address
  358. an item by its position (row) rather than its wxDataViewItem (which you can
  359. obtain from this class).
  360. This model also provides its own wxDataViewIndexListModel::Compare
  361. method which sorts the model's data by the index.
  362. This model is not a virtual model since the control stores each wxDataViewItem.
  363. Use wxDataViewVirtualListModel if you need to display millions of items or
  364. have other reason to use a virtual control.
  365. @see wxDataViewListModel for the API.
  366. @library{wxadv}
  367. @category{dvc}
  368. */
  369. class wxDataViewIndexListModel : public wxDataViewListModel
  370. {
  371. public:
  372. /**
  373. Constructor.
  374. */
  375. wxDataViewIndexListModel(unsigned int initial_size = 0);
  376. /**
  377. Returns the wxDataViewItem at the given @e row.
  378. */
  379. wxDataViewItem GetItem(unsigned int row) const;
  380. /**
  381. Call this after if the data has to be read again from the model.
  382. This is useful after major changes when calling the methods below
  383. (possibly thousands of times) doesn't make sense.
  384. */
  385. void Reset(unsigned int new_size);
  386. /**
  387. Call this after a row has been appended to the model.
  388. */
  389. void RowAppended();
  390. /**
  391. Call this after a row has been changed.
  392. */
  393. void RowChanged(unsigned int row);
  394. /**
  395. Call this after a row has been deleted.
  396. */
  397. void RowDeleted(unsigned int row);
  398. /**
  399. Call this after a row has been inserted at the given position.
  400. */
  401. void RowInserted(unsigned int before);
  402. /**
  403. Call this after a row has been prepended to the model.
  404. */
  405. void RowPrepended();
  406. /**
  407. Call this after a value has been changed.
  408. */
  409. void RowValueChanged(unsigned int row, unsigned int col);
  410. /**
  411. Call this after rows have been deleted.
  412. The array will internally get copied and sorted in descending order so
  413. that the rows with the highest position will be deleted first.
  414. */
  415. void RowsDeleted(const wxArrayInt& rows);
  416. };
  417. /**
  418. @class wxDataViewVirtualListModel
  419. wxDataViewVirtualListModel is a specialized data model which lets you address
  420. an item by its position (row) rather than its wxDataViewItem and as such offers
  421. the exact same interface as wxDataViewIndexListModel.
  422. The important difference is that under platforms other than OS X, using this
  423. model will result in a truly virtual control able to handle millions of items
  424. as the control doesn't store any item (a feature not supported by OS X).
  425. @see wxDataViewListModel for the API.
  426. @library{wxadv}
  427. @category{dvc}
  428. */
  429. class wxDataViewVirtualListModel : public wxDataViewListModel
  430. {
  431. public:
  432. /**
  433. Constructor.
  434. */
  435. wxDataViewVirtualListModel(unsigned int initial_size = 0);
  436. /**
  437. Returns the wxDataViewItem at the given @e row.
  438. */
  439. wxDataViewItem GetItem(unsigned int row) const;
  440. /**
  441. Call this after if the data has to be read again from the model.
  442. This is useful after major changes when calling the methods below
  443. (possibly thousands of times) doesn't make sense.
  444. */
  445. void Reset(unsigned int new_size);
  446. /**
  447. Call this after a row has been appended to the model.
  448. */
  449. void RowAppended();
  450. /**
  451. Call this after a row has been changed.
  452. */
  453. void RowChanged(unsigned int row);
  454. /**
  455. Call this after a row has been deleted.
  456. */
  457. void RowDeleted(unsigned int row);
  458. /**
  459. Call this after a row has been inserted at the given position.
  460. */
  461. void RowInserted(unsigned int before);
  462. /**
  463. Call this after a row has been prepended to the model.
  464. */
  465. void RowPrepended();
  466. /**
  467. Call this after a value has been changed.
  468. */
  469. void RowValueChanged(unsigned int row, unsigned int col);
  470. /**
  471. Call this after rows have been deleted.
  472. The array will internally get copied and sorted in descending order so
  473. that the rows with the highest position will be deleted first.
  474. */
  475. void RowsDeleted(const wxArrayInt& rows);
  476. };
  477. /**
  478. @class wxDataViewItemAttr
  479. This class is used to indicate to a wxDataViewCtrl that a certain item
  480. (see wxDataViewItem) has extra font attributes for its renderer.
  481. For this, it is required to override wxDataViewModel::GetAttr.
  482. Attributes are currently only supported by wxDataViewTextRendererText.
  483. @library{wxadv}
  484. @category{dvc}
  485. */
  486. class wxDataViewItemAttr
  487. {
  488. public:
  489. /**
  490. Constructor.
  491. */
  492. wxDataViewItemAttr();
  493. /**
  494. Call this to indicate that the item shall be displayed in bold text.
  495. */
  496. void SetBold(bool set);
  497. /**
  498. Call this to indicate that the item shall be displayed with that colour.
  499. */
  500. void SetColour(const wxColour& colour);
  501. /**
  502. Call this to set the background colour to use.
  503. Currently this attribute is only supported in the generic version of
  504. wxDataViewCtrl and ignored by the native GTK+ and OS X implementations.
  505. @since 2.9.4
  506. */
  507. void SetBackgroundColour(const wxColour& colour);
  508. /**
  509. Call this to indicate that the item shall be displayed in italic text.
  510. */
  511. void SetItalic(bool set);
  512. /**
  513. Returns true if the colour property has been set.
  514. */
  515. bool HasColour() const;
  516. /**
  517. Returns this attribute's colour.
  518. */
  519. const wxColour& GetColour() const;
  520. /**
  521. Returns true if any property affecting the font has been set.
  522. */
  523. bool HasFont() const;
  524. /**
  525. Returns value of the bold property.
  526. */
  527. bool GetBold() const;
  528. /**
  529. Returns value of the italics property.
  530. */
  531. bool GetItalic() const;
  532. /**
  533. Returns true if the background colour property has been set.
  534. */
  535. bool HasBackgroundColour() const;
  536. /**
  537. Returns the colour to be used for the background.
  538. */
  539. const wxColour& GetBackgroundColour() const;
  540. /**
  541. Returns true if none of the properties have been set.
  542. */
  543. bool IsDefault() const;
  544. /**
  545. Return the font based on the given one with this attribute applied to it.
  546. */
  547. wxFont GetEffectiveFont(const wxFont& font) const;
  548. };
  549. /**
  550. @class wxDataViewItem
  551. wxDataViewItem is a small opaque class that represents an item in a wxDataViewCtrl
  552. in a persistent way, i.e. independent of the position of the item in the control
  553. or changes to its contents.
  554. It must hold a unique ID of type @e void* in its only field and can be converted
  555. to and from it.
  556. If the ID is @NULL the wxDataViewItem is invalid and wxDataViewItem::IsOk will
  557. return @false which used in many places in the API of wxDataViewCtrl to
  558. indicate that e.g. no item was found. An ID of @NULL is also used to indicate
  559. the invisible root. Examples for this are wxDataViewModel::GetParent and
  560. wxDataViewModel::GetChildren.
  561. @library{wxadv}
  562. @category{dvc}
  563. */
  564. class wxDataViewItem
  565. {
  566. public:
  567. //@{
  568. /**
  569. Constructor.
  570. */
  571. wxDataViewItem();
  572. wxDataViewItem(const wxDataViewItem& item);
  573. explicit wxDataViewItem(void* id);
  574. //@}
  575. /**
  576. Returns the ID.
  577. */
  578. void* GetID() const;
  579. /**
  580. Returns @true if the ID is not @NULL.
  581. */
  582. bool IsOk() const;
  583. };
  584. // ----------------------------------------------------------------------------
  585. // wxDataViewCtrl flags
  586. // ----------------------------------------------------------------------------
  587. // size of a wxDataViewRenderer without contents:
  588. #define wxDVC_DEFAULT_RENDERER_SIZE 20
  589. // the default width of new (text) columns:
  590. #define wxDVC_DEFAULT_WIDTH 80
  591. // the default width of new toggle columns:
  592. #define wxDVC_TOGGLE_DEFAULT_WIDTH 30
  593. // the default minimal width of the columns:
  594. #define wxDVC_DEFAULT_MINWIDTH 30
  595. // The default alignment of wxDataViewRenderers is to take
  596. // the alignment from the column it owns.
  597. #define wxDVR_DEFAULT_ALIGNMENT -1
  598. #define wxDV_SINGLE 0x0000 // for convenience
  599. #define wxDV_MULTIPLE 0x0001 // can select multiple items
  600. #define wxDV_NO_HEADER 0x0002 // column titles not visible
  601. #define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows
  602. #define wxDV_VERT_RULES 0x0008 // light vertical rules between columns
  603. #define wxDV_ROW_LINES 0x0010 // alternating colour in rows
  604. #define wxDV_VARIABLE_LINE_HEIGHT 0x0020 // variable line height
  605. // events
  606. wxEventType wxEVT_DATAVIEW_SELECTION_CHANGED;
  607. wxEventType wxEVT_DATAVIEW_ITEM_ACTIVATED;
  608. wxEventType wxEVT_DATAVIEW_ITEM_COLLAPSING;
  609. wxEventType wxEVT_DATAVIEW_ITEM_COLLAPSED;
  610. wxEventType wxEVT_DATAVIEW_ITEM_EXPANDING;
  611. wxEventType wxEVT_DATAVIEW_ITEM_EXPANDED;
  612. wxEventType wxEVT_DATAVIEW_ITEM_START_EDITING;
  613. wxEventType wxEVT_DATAVIEW_ITEM_EDITING_STARTED;
  614. wxEventType wxEVT_DATAVIEW_ITEM_EDITING_DONE;
  615. wxEventType wxEVT_DATAVIEW_ITEM_VALUE_CHANGED;
  616. wxEventType wxEVT_DATAVIEW_ITEM_CONTEXT_MENU;
  617. wxEventType wxEVT_DATAVIEW_COLUMN_HEADER_CLICK;
  618. wxEventType wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK;
  619. wxEventType wxEVT_DATAVIEW_COLUMN_SORTED;
  620. wxEventType wxEVT_DATAVIEW_COLUMN_REORDERED;
  621. wxEventType wxEVT_DATAVIEW_CACHE_HINT;
  622. wxEventType wxEVT_DATAVIEW_ITEM_BEGIN_DRAG;
  623. wxEventType wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE;
  624. wxEventType wxEVT_DATAVIEW_ITEM_DROP;
  625. /**
  626. @class wxDataViewCtrl
  627. wxDataViewCtrl is a control to display data either in a tree like fashion or
  628. in a tabular form or both.
  629. If you only need to display a simple tree structure with an API more like the
  630. older wxTreeCtrl class, then the specialized wxDataViewTreeCtrl can be used.
  631. Likewise, if you only want to display simple table structure you can use
  632. the specialized wxDataViewListCtrl class. Both wxDataViewTreeCtrl and
  633. wxDataViewListCtrl can be used without defining your own wxDataViewModel.
  634. A wxDataViewItem is used to represent a (visible) item in the control.
  635. Unlike wxListCtrl, wxDataViewCtrl doesn't get its data from the user through
  636. virtual functions or by setting it directly. Instead you need to write your own
  637. wxDataViewModel and associate it with this control.
  638. Then you need to add a number of wxDataViewColumn to this control to define
  639. what each column shall display. Each wxDataViewColumn in turn owns 1 instance
  640. of a wxDataViewRenderer to render its cells.
  641. A number of standard renderers for rendering text, dates, images, toggle,
  642. a progress bar etc. are provided. Additionally, the user can write custom
  643. renderers deriving from wxDataViewCustomRenderer for displaying anything.
  644. All data transfer from the control to the model and the user code is done
  645. through wxVariant which can be extended to support more data formats as necessary.
  646. Accordingly, all type information uses the strings returned from wxVariant::GetType.
  647. @beginStyleTable
  648. @style{wxDV_SINGLE}
  649. Single selection mode. This is the default.
  650. @style{wxDV_MULTIPLE}
  651. Multiple selection mode.
  652. @style{wxDV_ROW_LINES}
  653. Use alternating colours for rows if supported by platform and theme.
  654. Currently only supported by the native GTK and OS X implementations
  655. but not by the generic one.
  656. @style{wxDV_HORIZ_RULES}
  657. Display the separator lines between rows.
  658. @style{wxDV_VERT_RULES}
  659. Display the separator lines between columns.
  660. @style{wxDV_VARIABLE_LINE_HEIGHT}
  661. Allow variable line heights.
  662. This can be inefficient when displaying large number of items.
  663. @style{wxDV_NO_HEADER}
  664. Do not show column headers (which are shown by default).
  665. @endStyleTable
  666. @beginEventEmissionTable{wxDataViewEvent}
  667. @event{EVT_DATAVIEW_SELECTION_CHANGED(id, func)}
  668. Process a @c wxEVT_DATAVIEW_SELECTION_CHANGED event.
  669. @event{EVT_DATAVIEW_ITEM_ACTIVATED(id, func)}
  670. Process a @c wxEVT_DATAVIEW_ITEM_ACTIVATED event. This event
  671. is triggered by double clicking an item or pressing some special key
  672. (usually "Enter") when it is focused.
  673. @event{EVT_DATAVIEW_ITEM_START_EDITING(id, func)}
  674. Process a @c wxEVT_DATAVIEW_ITEM_START_EDITING event. This
  675. event can be vetoed in order to prevent editing on an item by item
  676. basis.
  677. @event{EVT_DATAVIEW_ITEM_EDITING_STARTED(id, func)}
  678. Process a @c wxEVT_DATAVIEW_ITEM_EDITING_STARTED event.
  679. @event{EVT_DATAVIEW_ITEM_EDITING_DONE(id, func)}
  680. Process a @c wxEVT_DATAVIEW_ITEM_EDITING_DONE event.
  681. @event{EVT_DATAVIEW_ITEM_COLLAPSING(id, func)}
  682. Process a @c wxEVT_DATAVIEW_ITEM_COLLAPSING event.
  683. @event{EVT_DATAVIEW_ITEM_COLLAPSED(id, func)}
  684. Process a @c wxEVT_DATAVIEW_ITEM_COLLAPSED event.
  685. @event{EVT_DATAVIEW_ITEM_EXPANDING(id, func)}
  686. Process a @c wxEVT_DATAVIEW_ITEM_EXPANDING event.
  687. @event{EVT_DATAVIEW_ITEM_EXPANDED(id, func)}
  688. Process a @c wxEVT_DATAVIEW_ITEM_EXPANDED event.
  689. @event{EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, func)}
  690. Process a @c wxEVT_DATAVIEW_ITEM_VALUE_CHANGED event.
  691. @event{EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, func)}
  692. Process a @c wxEVT_DATAVIEW_ITEM_CONTEXT_MENU event
  693. generated when the user right clicks inside the control. Notice that
  694. this menu is generated even if the click didn't occur on any valid
  695. item, in this case wxDataViewEvent::GetItem() simply returns an
  696. invalid item.
  697. @event{EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, func)}
  698. Process a @c wxEVT_DATAVIEW_COLUMN_HEADER_CLICK event.
  699. @event{EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, func)}
  700. Process a @c wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK event.
  701. Notice that currently this event is not generated in the native OS X
  702. versions of the control.
  703. @event{EVT_DATAVIEW_COLUMN_SORTED(id, func)}
  704. Process a @c wxEVT_DATAVIEW_COLUMN_SORTED event.
  705. @event{EVT_DATAVIEW_COLUMN_REORDERED(id, func)}
  706. Process a @c wxEVT_DATAVIEW_COLUMN_REORDERED event.
  707. @event{EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, func)}
  708. Process a @c wxEVT_DATAVIEW_ITEM_BEGIN_DRAG event.
  709. @event{EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, func)}
  710. Process a @c wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE event.
  711. @event{EVT_DATAVIEW_ITEM_DROP(id, func)}
  712. Process a @c wxEVT_DATAVIEW_ITEM_DROP event.
  713. @endEventTable
  714. Notice that this control doesn't allow to process generic mouse events such
  715. as @c wxEVT_LEFT_DOWN in all ports (notably it doesn't work in wxGTK). If
  716. you need to handle any mouse events not covered by the ones above, consider
  717. using a custom renderer for the cells that must handle them.
  718. @library{wxadv}
  719. @category{ctrl,dvc}
  720. @appearance{dataviewctrl}
  721. */
  722. class wxDataViewCtrl : public wxControl
  723. {
  724. public:
  725. /**
  726. Default Constructor.
  727. */
  728. wxDataViewCtrl();
  729. /**
  730. Constructor. Calls Create().
  731. */
  732. wxDataViewCtrl(wxWindow* parent, wxWindowID id,
  733. const wxPoint& pos = wxDefaultPosition,
  734. const wxSize& size = wxDefaultSize,
  735. long style = 0,
  736. const wxValidator& validator = wxDefaultValidator,
  737. const wxString& name = wxDataViewCtrlNameStr);
  738. /**
  739. Destructor.
  740. */
  741. virtual ~wxDataViewCtrl();
  742. /**
  743. Create the control. Useful for two step creation.
  744. */
  745. bool Create(wxWindow* parent, wxWindowID id,
  746. const wxPoint& pos = wxDefaultPosition,
  747. const wxSize& size = wxDefaultSize,
  748. long style = 0,
  749. const wxValidator& validator = wxDefaultValidator,
  750. const wxString& name = wxDataViewCtrlNameStr);
  751. /**
  752. Appends a wxDataViewColumn to the control. Returns @true on success.
  753. Note that there is a number of short cut methods which implicitly create
  754. a wxDataViewColumn and a wxDataViewRenderer for it (see below).
  755. */
  756. virtual bool AppendColumn(wxDataViewColumn* col);
  757. /**
  758. Prepends a wxDataViewColumn to the control. Returns @true on success.
  759. Note that there is a number of short cut methods which implicitly create
  760. a wxDataViewColumn and a wxDataViewRenderer for it.
  761. */
  762. virtual bool PrependColumn(wxDataViewColumn* col);
  763. /**
  764. Inserts a wxDataViewColumn to the control. Returns @true on success.
  765. */
  766. virtual bool InsertColumn(unsigned int pos, wxDataViewColumn* col);
  767. //@{
  768. /**
  769. Appends a column for rendering a bitmap. Returns the wxDataViewColumn
  770. created in the function or @NULL on failure.
  771. */
  772. wxDataViewColumn* AppendBitmapColumn(const wxString& label,
  773. unsigned int model_column,
  774. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  775. int width = -1,
  776. wxAlignment align = wxALIGN_CENTER,
  777. int flags = wxDATAVIEW_COL_RESIZABLE);
  778. wxDataViewColumn* AppendBitmapColumn(const wxBitmap& label,
  779. unsigned int model_column,
  780. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  781. int width = -1,
  782. wxAlignment align = wxALIGN_CENTER,
  783. int flags = wxDATAVIEW_COL_RESIZABLE);
  784. //@}
  785. //@{
  786. /**
  787. Prepends a column for rendering a bitmap. Returns the wxDataViewColumn
  788. created in the function or @NULL on failure.
  789. */
  790. wxDataViewColumn* PrependBitmapColumn(const wxString& label,
  791. unsigned int model_column,
  792. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  793. int width = -1,
  794. wxAlignment align = wxALIGN_CENTER,
  795. int flags = wxDATAVIEW_COL_RESIZABLE);
  796. wxDataViewColumn* PrependBitmapColumn(const wxBitmap& label,
  797. unsigned int model_column,
  798. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  799. int width = -1,
  800. wxAlignment align = wxALIGN_CENTER,
  801. int flags = wxDATAVIEW_COL_RESIZABLE);
  802. //@}
  803. //@{
  804. /**
  805. Appends a column for rendering a date. Returns the wxDataViewColumn
  806. created in the function or @NULL on failure.
  807. @note The @a align parameter is applied to both the column header and
  808. the column renderer.
  809. */
  810. wxDataViewColumn* AppendDateColumn(const wxString& label,
  811. unsigned int model_column,
  812. wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
  813. int width = -1,
  814. wxAlignment align = wxALIGN_NOT,
  815. int flags = wxDATAVIEW_COL_RESIZABLE);
  816. wxDataViewColumn* AppendDateColumn(const wxBitmap& label,
  817. unsigned int model_column,
  818. wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
  819. int width = -1,
  820. wxAlignment align = wxALIGN_NOT,
  821. int flags = wxDATAVIEW_COL_RESIZABLE);
  822. //@}
  823. //@{
  824. /**
  825. Prepends a column for rendering a date. Returns the wxDataViewColumn
  826. created in the function or @NULL on failure.
  827. @note The @a align parameter is applied to both the column header and
  828. the column renderer.
  829. */
  830. wxDataViewColumn* PrependDateColumn(const wxString& label,
  831. unsigned int model_column,
  832. wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
  833. int width = -1,
  834. wxAlignment align = wxALIGN_NOT,
  835. int flags = wxDATAVIEW_COL_RESIZABLE);
  836. wxDataViewColumn* PrependDateColumn(const wxBitmap& label,
  837. unsigned int model_column,
  838. wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
  839. int width = -1,
  840. wxAlignment align = wxALIGN_NOT,
  841. int flags = wxDATAVIEW_COL_RESIZABLE);
  842. //@}
  843. //@{
  844. /**
  845. Appends a column for rendering text with an icon. Returns the wxDataViewColumn
  846. created in the function or @NULL on failure.
  847. This method uses the wxDataViewIconTextRenderer class.
  848. @note The @a align parameter is applied to both the column header and
  849. the column renderer.
  850. */
  851. wxDataViewColumn* AppendIconTextColumn(const wxString& label,
  852. unsigned int model_column,
  853. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  854. int width = -1,
  855. wxAlignment align = wxALIGN_NOT,
  856. int flags = wxDATAVIEW_COL_RESIZABLE);
  857. wxDataViewColumn* AppendIconTextColumn(const wxBitmap& label,
  858. unsigned int model_column,
  859. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  860. int width = -1,
  861. wxAlignment align = wxALIGN_NOT,
  862. int flags = wxDATAVIEW_COL_RESIZABLE);
  863. //@}
  864. //@{
  865. /**
  866. Prepends a column for rendering text with an icon. Returns the wxDataViewColumn
  867. created in the function or @NULL on failure.
  868. This method uses the wxDataViewIconTextRenderer class.
  869. @note The @a align parameter is applied to both the column header and
  870. the column renderer.
  871. */
  872. wxDataViewColumn* PrependIconTextColumn(const wxString& label,
  873. unsigned int model_column,
  874. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  875. int width = -1,
  876. wxAlignment align = wxALIGN_NOT,
  877. int flags = wxDATAVIEW_COL_RESIZABLE);
  878. wxDataViewColumn* PrependIconTextColumn(const wxBitmap& label,
  879. unsigned int model_column,
  880. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  881. int width = -1,
  882. wxAlignment align = wxALIGN_NOT,
  883. int flags = wxDATAVIEW_COL_RESIZABLE);
  884. //@}
  885. //@{
  886. /**
  887. Appends a column for rendering a progress indicator. Returns the
  888. wxDataViewColumn created in the function or @NULL on failure.
  889. @note The @a align parameter is applied to both the column header and
  890. the column renderer.
  891. */
  892. wxDataViewColumn* AppendProgressColumn(const wxString& label,
  893. unsigned int model_column,
  894. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  895. int width = 80,
  896. wxAlignment align = wxALIGN_CENTER,
  897. int flags = wxDATAVIEW_COL_RESIZABLE);
  898. wxDataViewColumn* AppendProgressColumn(const wxBitmap& label,
  899. unsigned int model_column,
  900. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  901. int width = 80,
  902. wxAlignment align = wxALIGN_CENTER,
  903. int flags = wxDATAVIEW_COL_RESIZABLE);
  904. //@}
  905. //@{
  906. /**
  907. Prepends a column for rendering a progress indicator. Returns the
  908. wxDataViewColumn created in the function or @NULL on failure.
  909. @note The @a align parameter is applied to both the column header and
  910. the column renderer.
  911. */
  912. wxDataViewColumn* PrependProgressColumn(const wxString& label,
  913. unsigned int model_column,
  914. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  915. int width = 80,
  916. wxAlignment align = wxALIGN_CENTER,
  917. int flags = wxDATAVIEW_COL_RESIZABLE);
  918. wxDataViewColumn* PrependProgressColumn(const wxBitmap& label,
  919. unsigned int model_column,
  920. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  921. int width = 80,
  922. wxAlignment align = wxALIGN_CENTER,
  923. int flags = wxDATAVIEW_COL_RESIZABLE);
  924. //@}
  925. //@{
  926. /**
  927. Appends a column for rendering text. Returns the wxDataViewColumn
  928. created in the function or @NULL on failure.
  929. @note The @a align parameter is applied to both the column header and
  930. the column renderer.
  931. */
  932. wxDataViewColumn* AppendTextColumn(const wxString& label,
  933. unsigned int model_column,
  934. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  935. int width = -1,
  936. wxAlignment align = wxALIGN_NOT,
  937. int flags = wxDATAVIEW_COL_RESIZABLE);
  938. wxDataViewColumn* AppendTextColumn(const wxBitmap& label,
  939. unsigned int model_column,
  940. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  941. int width = -1,
  942. wxAlignment align = wxALIGN_NOT,
  943. int flags = wxDATAVIEW_COL_RESIZABLE);
  944. //@}
  945. //@{
  946. /**
  947. Prepends a column for rendering text. Returns the wxDataViewColumn
  948. created in the function or @NULL on failure.
  949. @note The @a align parameter is applied to both the column header and
  950. the column renderer.
  951. */
  952. wxDataViewColumn* PrependTextColumn(const wxString& label,
  953. unsigned int model_column,
  954. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  955. int width = -1,
  956. wxAlignment align = wxALIGN_NOT,
  957. int flags = wxDATAVIEW_COL_RESIZABLE);
  958. wxDataViewColumn* PrependTextColumn(const wxBitmap& label,
  959. unsigned int model_column,
  960. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  961. int width = -1,
  962. wxAlignment align = wxALIGN_NOT,
  963. int flags = wxDATAVIEW_COL_RESIZABLE);
  964. //@}
  965. //@{
  966. /**
  967. Appends a column for rendering a toggle. Returns the wxDataViewColumn
  968. created in the function or @NULL on failure.
  969. @note The @a align parameter is applied to both the column header and
  970. the column renderer.
  971. */
  972. wxDataViewColumn* AppendToggleColumn(const wxString& label,
  973. unsigned int model_column,
  974. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  975. int width = 30,
  976. wxAlignment align = wxALIGN_CENTER,
  977. int flags = wxDATAVIEW_COL_RESIZABLE);
  978. wxDataViewColumn* AppendToggleColumn(const wxBitmap& label,
  979. unsigned int model_column,
  980. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  981. int width = 30,
  982. wxAlignment align = wxALIGN_CENTER,
  983. int flags = wxDATAVIEW_COL_RESIZABLE);
  984. //@}
  985. //@{
  986. /**
  987. Prepends a column for rendering a toggle. Returns the wxDataViewColumn
  988. created in the function or @NULL on failure.
  989. @note The @a align parameter is applied to both the column header and
  990. the column renderer.
  991. */
  992. wxDataViewColumn* PrependToggleColumn(const wxString& label,
  993. unsigned int model_column,
  994. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  995. int width = 30,
  996. wxAlignment align = wxALIGN_CENTER,
  997. int flags = wxDATAVIEW_COL_RESIZABLE);
  998. wxDataViewColumn* PrependToggleColumn(const wxBitmap& label,
  999. unsigned int model_column,
  1000. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  1001. int width = 30,
  1002. wxAlignment align = wxALIGN_CENTER,
  1003. int flags = wxDATAVIEW_COL_RESIZABLE);
  1004. //@}
  1005. /**
  1006. Associates a wxDataViewModel with the control.
  1007. This increases the reference count of the model by 1.
  1008. */
  1009. virtual bool AssociateModel(wxDataViewModel* model);
  1010. /**
  1011. Removes all columns.
  1012. */
  1013. virtual bool ClearColumns();
  1014. /**
  1015. Collapses the item.
  1016. */
  1017. virtual void Collapse(const wxDataViewItem& item);
  1018. /**
  1019. Deletes given column.
  1020. */
  1021. virtual bool DeleteColumn(wxDataViewColumn* column);
  1022. /**
  1023. Programmatically starts editing given cell of @a item.
  1024. Doesn't do anything if the item or this column is not editable.
  1025. @note Currently not implemented in wxOSX/Carbon.
  1026. @since 2.9.4
  1027. */
  1028. virtual void EditItem(const wxDataViewItem& item, const wxDataViewColumn *column);
  1029. /**
  1030. Enable drag operations using the given @a format.
  1031. */
  1032. virtual bool EnableDragSource( const wxDataFormat &format );
  1033. /**
  1034. Enable drop operations using the given @a format.
  1035. */
  1036. virtual bool EnableDropTarget( const wxDataFormat &format );
  1037. /**
  1038. Call this to ensure that the given item is visible.
  1039. */
  1040. virtual void EnsureVisible(const wxDataViewItem& item,
  1041. const wxDataViewColumn* column = NULL);
  1042. /**
  1043. Expands the item.
  1044. */
  1045. virtual void Expand(const wxDataViewItem& item);
  1046. /**
  1047. Expands all ancestors of the @a item. This method also
  1048. ensures that the item itself as well as all ancestor
  1049. items have been read from the model by the control.
  1050. */
  1051. virtual void ExpandAncestors( const wxDataViewItem & item );
  1052. /**
  1053. Returns pointer to the column. @a pos refers to the position in the
  1054. control which may change after reordering columns by the user.
  1055. */
  1056. virtual wxDataViewColumn* GetColumn(unsigned int pos) const;
  1057. /**
  1058. Returns the number of columns.
  1059. */
  1060. virtual unsigned int GetColumnCount() const;
  1061. /**
  1062. Returns the position of the column or -1 if not found in the control.
  1063. */
  1064. virtual int GetColumnPosition(const wxDataViewColumn* column) const;
  1065. /**
  1066. Returns column containing the expanders.
  1067. */
  1068. wxDataViewColumn* GetExpanderColumn() const;
  1069. /**
  1070. Returns the currently focused item.
  1071. This is the item that the keyboard commands apply to. It may be invalid
  1072. if there is no focus currently.
  1073. This method is mostly useful for the controls with @c wxDV_MULTIPLE
  1074. style as in the case of single selection it returns the same thing as
  1075. GetSelection().
  1076. Notice that under all platforms except Mac OS X the currently focused
  1077. item may be selected or not but under OS X the current item is always
  1078. selected.
  1079. @see SetCurrentItem(), GetCurrentColumn()
  1080. @since 2.9.2
  1081. */
  1082. wxDataViewItem GetCurrentItem() const;
  1083. /**
  1084. Returns the column that currently has focus.
  1085. If the focus is set to individual cell within the currently focused
  1086. item (as opposed to being on the item as a whole), then this is the
  1087. column that the focus is on.
  1088. Returns NULL if no column currently has focus.
  1089. @see GetCurrentItem()
  1090. @since 2.9.4
  1091. */
  1092. wxDataViewColumn *GetCurrentColumn() const;
  1093. /**
  1094. Returns indentation.
  1095. */
  1096. int GetIndent() const;
  1097. /**
  1098. Returns item rectangle.
  1099. This method is currently not implemented at all in wxGTK and only
  1100. implemented for non-@NULL @a col argument in wxOSX. It is fully
  1101. implemented in the generic version of the control.
  1102. @param item
  1103. A valid item.
  1104. @param col
  1105. If non-@NULL, the rectangle returned corresponds to the
  1106. intersection of the item with the specified column. If @NULL, the
  1107. rectangle spans all the columns.
  1108. */
  1109. virtual wxRect GetItemRect(const wxDataViewItem& item,
  1110. const wxDataViewColumn* col = NULL) const;
  1111. /**
  1112. Returns pointer to the data model associated with the control (if any).
  1113. */
  1114. wxDataViewModel* GetModel();
  1115. /**
  1116. Returns the number of currently selected items.
  1117. This method may be called for both the controls with single and
  1118. multiple selections and returns the number of selected item, possibly
  1119. 0, in any case.
  1120. @since 2.9.3
  1121. */
  1122. virtual int GetSelectedItemsCount() const;
  1123. /**
  1124. Returns first selected item or an invalid item if none is selected.
  1125. This method may be called for both the controls with single and
  1126. multiple selections but returns an invalid item if more than one item
  1127. is selected in the latter case, use HasSelection() to determine if
  1128. there are any selected items when using multiple selection.
  1129. */
  1130. virtual wxDataViewItem GetSelection() const;
  1131. /**
  1132. Fills @a sel with currently selected items and returns their number.
  1133. This method may be called for both the controls with single and
  1134. multiple selections. In the single selection case it returns the array
  1135. with at most one element in it.
  1136. @see GetSelectedItemsCount()
  1137. */
  1138. virtual int GetSelections(wxDataViewItemArray& sel) const;
  1139. /**
  1140. Returns the wxDataViewColumn currently responsible for sorting
  1141. or @NULL if none has been selected.
  1142. */
  1143. virtual wxDataViewColumn* GetSortingColumn() const;
  1144. /**
  1145. Returns true if any items are currently selected.
  1146. This method may be called for both the controls with single and
  1147. multiple selections.
  1148. Calling this method is equivalent to calling GetSelectedItemsCount()
  1149. and comparing its result with 0 but is more clear and might also be
  1150. implemented more efficiently in the future.
  1151. @since 2.9.3
  1152. */
  1153. bool HasSelection() const;
  1154. /**
  1155. Hittest.
  1156. */
  1157. virtual void HitTest(const wxPoint& point, wxDataViewItem& item,
  1158. wxDataViewColumn*& col) const;
  1159. /**
  1160. Return @true if the item is expanded.
  1161. */
  1162. virtual bool IsExpanded(const wxDataViewItem& item) const;
  1163. /**
  1164. Return @true if the item is selected.
  1165. */
  1166. virtual bool IsSelected(const wxDataViewItem& item) const;
  1167. /**
  1168. Select the given item.
  1169. In single selection mode this changes the (unique) currently selected
  1170. item. In multi selection mode, the @a item is selected and the
  1171. previously selected items remain selected.
  1172. */
  1173. virtual void Select(const wxDataViewItem& item);
  1174. /**
  1175. Select all items.
  1176. */
  1177. virtual void SelectAll();
  1178. /**
  1179. Set which column shall contain the tree-like expanders.
  1180. */
  1181. void SetExpanderColumn(wxDataViewColumn* col);
  1182. /**
  1183. Changes the currently focused item.
  1184. The @a item parameter must be valid, there is no way to remove the
  1185. current item from the control.
  1186. In single selection mode, calling this method is the same as calling
  1187. Select() and is thus not very useful. In multiple selection mode this
  1188. method only moves the current item however without changing the
  1189. selection except under OS X where the current item is always selected,
  1190. so calling SetCurrentItem() selects @a item if it hadn't been selected
  1191. before.
  1192. @see GetCurrentItem()
  1193. @since 2.9.2
  1194. */
  1195. void SetCurrentItem(const wxDataViewItem& item);
  1196. /**
  1197. Sets the indentation.
  1198. */
  1199. void SetIndent(int indent);
  1200. /**
  1201. Sets the selection to the array of wxDataViewItems.
  1202. */
  1203. virtual void SetSelections(const wxDataViewItemArray& sel);
  1204. /**
  1205. Unselect the given item.
  1206. */
  1207. virtual void Unselect(const wxDataViewItem& item);
  1208. /**
  1209. Unselect all item.
  1210. This method only has effect if multiple selections are allowed.
  1211. */
  1212. virtual void UnselectAll();
  1213. /**
  1214. Sets the row height.
  1215. This function can only be used when all rows have the same height, i.e.
  1216. when wxDV_VARIABLE_LINE_HEIGHT flag is not used.
  1217. Currently this is implemented in the generic and native GTK versions
  1218. only and nothing is done (and @false returned) when using OS X port.
  1219. Also notice that this method can only be used to increase the row
  1220. height compared with the default one (as determined by the return value
  1221. of wxDataViewRenderer::GetSize()), if it is set to a too small value
  1222. then the minimum required by the renderers will be used.
  1223. @return @true if the line height was changed or @false otherwise.
  1224. @since 2.9.2
  1225. */
  1226. virtual bool SetRowHeight(int rowHeight);
  1227. };
  1228. /**
  1229. @class wxDataViewModelNotifier
  1230. A wxDataViewModelNotifier instance is owned by a wxDataViewModel and mirrors
  1231. its notification interface.
  1232. See the documentation of that class for further information.
  1233. @library{wxadv}
  1234. @category{dvc}
  1235. */
  1236. class wxDataViewModelNotifier
  1237. {
  1238. public:
  1239. /**
  1240. Constructor.
  1241. */
  1242. wxDataViewModelNotifier();
  1243. /**
  1244. Destructor.
  1245. */
  1246. virtual ~wxDataViewModelNotifier();
  1247. /**
  1248. Called by owning model.
  1249. */
  1250. virtual bool Cleared() = 0;
  1251. /**
  1252. Get owning wxDataViewModel.
  1253. */
  1254. wxDataViewModel* GetOwner() const;
  1255. /**
  1256. Called by owning model.
  1257. @return Always return @true from this function in derived classes.
  1258. */
  1259. virtual bool ItemAdded(const wxDataViewItem& parent,
  1260. const wxDataViewItem& item) = 0;
  1261. /**
  1262. Called by owning model.
  1263. @return Always return @true from this function in derived classes.
  1264. */
  1265. virtual bool ItemChanged(const wxDataViewItem& item) = 0;
  1266. /**
  1267. Called by owning model.
  1268. @return Always return @true from this function in derived classes.
  1269. */
  1270. virtual bool ItemDeleted(const wxDataViewItem& parent,
  1271. const wxDataViewItem& item) = 0;
  1272. /**
  1273. Called by owning model.
  1274. @return Always return @true from this function in derived classes.
  1275. */
  1276. virtual bool ItemsAdded(const wxDataViewItem& parent,
  1277. const wxDataViewItemArray& items);
  1278. /**
  1279. Called by owning model.
  1280. @return Always return @true from this function in derived classes.
  1281. */
  1282. virtual bool ItemsChanged(const wxDataViewItemArray& items);
  1283. /**
  1284. Called by owning model.
  1285. @return Always return @true from this function in derived classes.
  1286. */
  1287. virtual bool ItemsDeleted(const wxDataViewItem& parent,
  1288. const wxDataViewItemArray& items);
  1289. /**
  1290. Called by owning model.
  1291. */
  1292. virtual void Resort() = 0;
  1293. /**
  1294. Set owner of this notifier. Used internally.
  1295. */
  1296. void SetOwner(wxDataViewModel* owner);
  1297. /**
  1298. Called by owning model.
  1299. @return Always return @true from this function in derived classes.
  1300. */
  1301. virtual bool ValueChanged(const wxDataViewItem& item, unsigned int col) = 0;
  1302. };
  1303. /**
  1304. The mode of a data-view cell; see wxDataViewRenderer for more info.
  1305. */
  1306. enum wxDataViewCellMode
  1307. {
  1308. /**
  1309. The cell only displays information and cannot be manipulated or
  1310. otherwise interacted with in any way.
  1311. Note that this doesn't mean that the row being drawn can't be selected,
  1312. just that a particular element of it cannot be individually modified.
  1313. */
  1314. wxDATAVIEW_CELL_INERT,
  1315. /**
  1316. Indicates that the cell can be @em activated by clicking it or using
  1317. keyboard.
  1318. Activating a cell is an alternative to showing inline editor when the
  1319. value can be edited in a simple way that doesn't warrant full editor
  1320. control. The most typical use of cell activation is toggling the
  1321. checkbox in wxDataViewToggleRenderer; others would be e.g. an embedded
  1322. volume slider or a five-star rating column.
  1323. The exact means of activating a cell are platform-dependent, but they
  1324. are usually similar to those used for inline editing of values.
  1325. Typically, a cell would be activated by Space or Enter keys or by left
  1326. mouse click.
  1327. @note Do not confuse this with item activation in wxDataViewCtrl
  1328. and the wxEVT_DATAVIEW_ITEM_ACTIVATED event. That one is
  1329. used for activating the item (or, to put it differently, the
  1330. entire row) similarly to analogous messages in wxTreeCtrl and
  1331. wxListCtrl, and the effect differs (play a song, open a file
  1332. etc.). Cell activation, on the other hand, is all about
  1333. interacting with the individual cell.
  1334. @see wxDataViewCustomRenderer::ActivateCell()
  1335. */
  1336. wxDATAVIEW_CELL_ACTIVATABLE,
  1337. /**
  1338. Indicates that the user can edit the data in-place in an inline editor
  1339. control that will show up when the user wants to edit the cell.
  1340. A typical example of this behaviour is changing the filename in a file
  1341. managers.
  1342. Editing is typically triggered by slowly double-clicking the cell or by
  1343. a platform-dependent keyboard shortcut (F2 is typical on Windows, Space
  1344. and/or Enter is common elsewhere and supported on Windows too).
  1345. @see wxDataViewCustomRenderer::CreateEditorCtrl()
  1346. */
  1347. wxDATAVIEW_CELL_EDITABLE
  1348. };
  1349. /**
  1350. The values of this enum controls how a wxDataViewRenderer should display
  1351. its contents in a cell.
  1352. */
  1353. enum wxDataViewCellRenderState
  1354. {
  1355. wxDATAVIEW_CELL_SELECTED = 1,
  1356. wxDATAVIEW_CELL_PRELIT = 2,
  1357. wxDATAVIEW_CELL_INSENSITIVE = 4,
  1358. wxDATAVIEW_CELL_FOCUSED = 8
  1359. };
  1360. /**
  1361. @class wxDataViewRenderer
  1362. This class is used by wxDataViewCtrl to render the individual cells.
  1363. One instance of a renderer class is owned by a wxDataViewColumn.
  1364. There is a number of ready-to-use renderers provided:
  1365. - wxDataViewTextRenderer,
  1366. - wxDataViewIconTextRenderer,
  1367. - wxDataViewToggleRenderer,
  1368. - wxDataViewProgressRenderer,
  1369. - wxDataViewBitmapRenderer,
  1370. - wxDataViewDateRenderer,
  1371. - wxDataViewSpinRenderer.
  1372. - wxDataViewChoiceRenderer.
  1373. Additionally, the user can write their own renderers by deriving from
  1374. wxDataViewCustomRenderer.
  1375. The ::wxDataViewCellMode and ::wxDataViewCellRenderState flags accepted
  1376. by the constructors respectively controls what actions the cell data allows
  1377. and how the renderer should display its contents in a cell.
  1378. @library{wxadv}
  1379. @category{dvc}
  1380. */
  1381. class wxDataViewRenderer : public wxObject
  1382. {
  1383. public:
  1384. /**
  1385. Constructor.
  1386. */
  1387. wxDataViewRenderer(const wxString& varianttype,
  1388. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  1389. int align = wxDVR_DEFAULT_ALIGNMENT );
  1390. /**
  1391. Enable or disable replacing parts of the item text with ellipsis to
  1392. make it fit the column width.
  1393. This method only makes sense for the renderers working with text, such
  1394. as wxDataViewTextRenderer or wxDataViewIconTextRenderer.
  1395. By default wxELLIPSIZE_MIDDLE is used.
  1396. @param mode
  1397. Ellipsization mode, use wxELLIPSIZE_NONE to disable.
  1398. @since 2.9.1
  1399. */
  1400. void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE);
  1401. /**
  1402. Disable replacing parts of the item text with ellipsis.
  1403. If ellipsizing is disabled, the string will be truncated if it doesn't
  1404. fit.
  1405. This is the same as @code EnableEllipsize(wxELLIPSIZE_NONE) @endcode.
  1406. @since 2.9.1
  1407. */
  1408. void DisableEllipsize();
  1409. /**
  1410. Returns the alignment. See SetAlignment()
  1411. */
  1412. virtual int GetAlignment() const;
  1413. /**
  1414. Returns the ellipsize mode used by the renderer.
  1415. If the return value is wxELLIPSIZE_NONE, the text is simply truncated
  1416. if it doesn't fit.
  1417. @see EnableEllipsize()
  1418. */
  1419. wxEllipsizeMode GetEllipsizeMode() const;
  1420. /**
  1421. Returns the cell mode.
  1422. */
  1423. virtual wxDataViewCellMode GetMode() const;
  1424. /**
  1425. Returns pointer to the owning wxDataViewColumn.
  1426. */
  1427. wxDataViewColumn* GetOwner() const;
  1428. /**
  1429. This methods retrieves the value from the renderer in order to
  1430. transfer the value back to the data model.
  1431. Returns @false on failure.
  1432. */
  1433. virtual bool GetValue(wxVariant& value) const = 0;
  1434. /**
  1435. Returns a string with the type of the wxVariant supported by this renderer.
  1436. */
  1437. wxString GetVariantType() const;
  1438. /**
  1439. Sets the alignment of the renderer's content.
  1440. The default value of @c wxDVR_DEFAULT_ALIGMENT indicates that the content
  1441. should have the same alignment as the column header.
  1442. The method is not implemented under OS X and the renderer always aligns
  1443. its contents as the column header on that platform. The other platforms
  1444. support both vertical and horizontal alignment.
  1445. */
  1446. virtual void SetAlignment( int align );
  1447. /**
  1448. Sets the owning wxDataViewColumn.
  1449. This is usually called from within wxDataViewColumn.
  1450. */
  1451. void SetOwner(wxDataViewColumn* owner);
  1452. /**
  1453. Set the value of the renderer (and thus its cell) to @a value.
  1454. The internal code will then render this cell with this data.
  1455. */
  1456. virtual bool SetValue(const wxVariant& value) = 0;
  1457. /**
  1458. Before data is committed to the data model, it is passed to this
  1459. method where it can be checked for validity. This can also be
  1460. used for checking a valid range or limiting the user input in
  1461. a certain aspect (e.g. max number of characters or only alphanumeric
  1462. input, ASCII only etc.). Return @false if the value is not valid.
  1463. Please note that due to implementation limitations, this validation
  1464. is done after the editing control already is destroyed and the
  1465. editing process finished.
  1466. */
  1467. virtual bool Validate(wxVariant& value);
  1468. virtual bool HasEditorCtrl() const;
  1469. virtual wxWindow* CreateEditorCtrl(wxWindow * parent,
  1470. wxRect labelRect,
  1471. const wxVariant& value);
  1472. virtual bool GetValueFromEditorCtrl(wxWindow * editor,
  1473. wxVariant& value);
  1474. virtual bool StartEditing( const wxDataViewItem &item, wxRect labelRect );
  1475. virtual void CancelEditing();
  1476. virtual bool FinishEditing();
  1477. wxWindow *GetEditorCtrl();
  1478. protected:
  1479. wxDataViewCtrl* GetView() const;
  1480. };
  1481. /**
  1482. @class wxDataViewTextRenderer
  1483. wxDataViewTextRenderer is used for rendering text.
  1484. It supports in-place editing if desired.
  1485. @library{wxadv}
  1486. @category{dvc}
  1487. */
  1488. class wxDataViewTextRenderer : public wxDataViewRenderer
  1489. {
  1490. public:
  1491. /**
  1492. The ctor.
  1493. */
  1494. wxDataViewTextRenderer(const wxString& varianttype = "string",
  1495. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  1496. int align = wxDVR_DEFAULT_ALIGNMENT );
  1497. };
  1498. /**
  1499. @class wxDataViewIconTextRenderer
  1500. The wxDataViewIconTextRenderer class is used to display text with
  1501. a small icon next to it as it is typically done in a file manager.
  1502. This classes uses the wxDataViewIconText helper class to store its data.
  1503. wxDataViewIconText can be converted to and from a wxVariant using the left
  1504. shift operator.
  1505. @library{wxadv}
  1506. @category{dvc}
  1507. */
  1508. class wxDataViewIconTextRenderer : public wxDataViewRenderer
  1509. {
  1510. public:
  1511. /**
  1512. The ctor.
  1513. */
  1514. wxDataViewIconTextRenderer(const wxString& varianttype = "wxDataViewIconText",
  1515. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  1516. int align = wxDVR_DEFAULT_ALIGNMENT );
  1517. };
  1518. /**
  1519. @class wxDataViewProgressRenderer
  1520. This class is used by wxDataViewCtrl to render progress bars.
  1521. @library{wxadv}
  1522. @category{dvc}
  1523. */
  1524. class wxDataViewProgressRenderer : public wxDataViewRenderer
  1525. {
  1526. public:
  1527. /**
  1528. The ctor.
  1529. */
  1530. wxDataViewProgressRenderer(const wxString& label = wxEmptyString,
  1531. const wxString& varianttype = "long",
  1532. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  1533. int align = wxDVR_DEFAULT_ALIGNMENT );
  1534. };
  1535. /**
  1536. @class wxDataViewSpinRenderer
  1537. This is a specialized renderer for rendering integer values.
  1538. It supports modifying the values in-place by using a wxSpinCtrl.
  1539. The renderer only support variants of type @e long.
  1540. @library{wxadv}
  1541. @category{dvc}
  1542. */
  1543. class wxDataViewSpinRenderer : public wxDataViewCustomRenderer
  1544. {
  1545. public:
  1546. /**
  1547. Constructor.
  1548. @a min and @a max indicate the minimum and maximum values for the wxSpinCtrl.
  1549. */
  1550. wxDataViewSpinRenderer(int min, int max,
  1551. wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
  1552. int align = wxDVR_DEFAULT_ALIGNMENT);
  1553. };
  1554. /**
  1555. @class wxDataViewToggleRenderer
  1556. This class is used by wxDataViewCtrl to render toggle controls.
  1557. @library{wxadv}
  1558. @category{dvc}
  1559. */
  1560. class wxDataViewToggleRenderer : public wxDataViewRenderer
  1561. {
  1562. public:
  1563. /**
  1564. The ctor.
  1565. */
  1566. wxDataViewToggleRenderer(const wxString& varianttype = "bool",
  1567. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  1568. int align = wxDVR_DEFAULT_ALIGNMENT);
  1569. };
  1570. /**
  1571. A wxDataViewCtrl renderer using wxChoice control and values of strings in
  1572. it.
  1573. This class is used by wxDataViewCtrl to render choice controls.
  1574. It stores a string so that SetValue() and GetValue() operate
  1575. on a variant holding a string.
  1576. @see wxDataViewChoiceByIndexRenderer
  1577. @library{wxadv}
  1578. @category{dvc}
  1579. */
  1580. class wxDataViewChoiceRenderer: public wxDataViewRenderer
  1581. {
  1582. public:
  1583. /**
  1584. The ctor.
  1585. */
  1586. wxDataViewChoiceRenderer( const wxArrayString &choices,
  1587. wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
  1588. int alignment = wxDVR_DEFAULT_ALIGNMENT );
  1589. /**
  1590. Returns the choice referred to by index.
  1591. */
  1592. wxString GetChoice(size_t index) const;
  1593. /**
  1594. Returns all choices.
  1595. */
  1596. const wxArrayString& GetChoices() const;
  1597. };
  1598. /**
  1599. A wxDataViewCtrl renderer using wxChoice control and indexes into it.
  1600. Unlike its base wxDataViewChoiceRenderer class, this one stores the choice
  1601. index, i.e. an @c int, in the variant used by its SetValue() and
  1602. GetValue().
  1603. @library{wxadv}
  1604. @category{dvc}
  1605. */
  1606. class wxDataViewChoiceByIndexRenderer : public wxDataViewChoiceRenderer
  1607. {
  1608. public:
  1609. /**
  1610. The ctor.
  1611. */
  1612. wxDataViewChoiceByIndexRenderer( const wxArrayString &choices,
  1613. wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
  1614. int alignment = wxDVR_DEFAULT_ALIGNMENT );
  1615. };
  1616. /**
  1617. @class wxDataViewDateRenderer
  1618. This class is used by wxDataViewCtrl to render calendar controls.
  1619. @library{wxadv}
  1620. @category{dvc}
  1621. */
  1622. class wxDataViewDateRenderer : public wxDataViewRenderer
  1623. {
  1624. public:
  1625. /**
  1626. The ctor.
  1627. */
  1628. wxDataViewDateRenderer(const wxString& varianttype = "datetime",
  1629. wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
  1630. int align = wxDVR_DEFAULT_ALIGNMENT);
  1631. };
  1632. /**
  1633. @class wxDataViewCustomRenderer
  1634. You need to derive a new class from wxDataViewCustomRenderer in
  1635. order to write a new renderer.
  1636. You need to override at least wxDataViewRenderer::SetValue, wxDataViewRenderer::GetValue,
  1637. wxDataViewCustomRenderer::GetSize and wxDataViewCustomRenderer::Render.
  1638. If you want your renderer to support in-place editing then you also need to override
  1639. wxDataViewCustomRenderer::HasEditorCtrl, wxDataViewCustomRenderer::CreateEditorCtrl
  1640. and wxDataViewCustomRenderer::GetValueFromEditorCtrl.
  1641. Note that a special event handler will be pushed onto that editor control
  1642. which handles @e \<ENTER\> and focus out events in order to end the editing.
  1643. @library{wxadv}
  1644. @category{dvc}
  1645. */
  1646. class wxDataViewCustomRenderer : public wxDataViewRenderer
  1647. {
  1648. public:
  1649. /**
  1650. Constructor.
  1651. */
  1652. wxDataViewCustomRenderer(const wxString& varianttype = "string",
  1653. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  1654. int align = wxDVR_DEFAULT_ALIGNMENT);
  1655. /**
  1656. Destructor.
  1657. */
  1658. virtual ~wxDataViewCustomRenderer();
  1659. /**
  1660. Override this to react to cell @em activation. Activating a cell is an
  1661. alternative to showing inline editor when the value can be edited in a
  1662. simple way that doesn't warrant full editor control. The most typical
  1663. use of cell activation is toggling the checkbox in
  1664. wxDataViewToggleRenderer; others would be e.g. an embedded volume
  1665. slider or a five-star rating column.
  1666. The exact means of activating a cell are platform-dependent, but they
  1667. are usually similar to those used for inline editing of values.
  1668. Typically, a cell would be activated by Space or Enter keys or by left
  1669. mouse click.
  1670. This method will only be called if the cell has the
  1671. wxDATAVIEW_CELL_ACTIVATABLE mode.
  1672. @param cell
  1673. Coordinates of the activated cell's area.
  1674. @param model
  1675. The model to manipulate in response.
  1676. @param item
  1677. Activated item.
  1678. @param col
  1679. Activated column of @a item.
  1680. @param mouseEvent
  1681. If the activation was triggered by mouse click, contains the
  1682. corresponding event. Is @NULL otherwise (for keyboard activation).
  1683. Mouse coordinates are adjusted to be relative to the cell.
  1684. @since 2.9.3
  1685. @note Do not confuse this method with item activation in wxDataViewCtrl
  1686. and the wxEVT_DATAVIEW_ITEM_ACTIVATED event. That one is
  1687. used for activating the item (or, to put it differently, the
  1688. entire row) similarly to analogous messages in wxTreeCtrl and
  1689. wxListCtrl, and the effect differs (play a song, open a file
  1690. etc.). Cell activation, on the other hand, is all about
  1691. interacting with the individual cell.
  1692. @see CreateEditorCtrl()
  1693. */
  1694. virtual bool ActivateCell(const wxRect& cell,
  1695. wxDataViewModel* model,
  1696. const wxDataViewItem & item,
  1697. unsigned int col,
  1698. const wxMouseEvent *mouseEvent);
  1699. /**
  1700. Override this to create the actual editor control once editing
  1701. is about to start.
  1702. This method will only be called if the cell has the
  1703. wxDATAVIEW_CELL_EDITABLE mode. Editing is typically triggered by slowly
  1704. double-clicking the cell or by a platform-dependent keyboard shortcut
  1705. (F2 is typical on Windows, Space and/or Enter is common elsewhere and
  1706. supported on Windows too).
  1707. @param parent
  1708. The parent of the editor control.
  1709. @param labelRect
  1710. Indicates the position and size of the editor control. The control
  1711. should be created in place of the cell and @a labelRect should be
  1712. respected as much as possible.
  1713. @param value
  1714. Initial value of the editor.
  1715. An example:
  1716. @code
  1717. {
  1718. long l = value;
  1719. return new wxSpinCtrl( parent, wxID_ANY, wxEmptyString,
  1720. labelRect.GetTopLeft(), labelRect.GetSize(), 0, 0, 100, l );
  1721. }
  1722. @endcode
  1723. @see ActivateCell()
  1724. */
  1725. virtual wxWindow* CreateEditorCtrl(wxWindow* parent,
  1726. wxRect labelRect,
  1727. const wxVariant& value);
  1728. /**
  1729. Return the attribute to be used for rendering.
  1730. This function may be called from Render() implementation to use the
  1731. attributes defined for the item if the renderer supports them.
  1732. Notice that when Render() is called, the wxDC object passed to it is
  1733. already set up to use the correct attributes (e.g. its font is set to
  1734. bold or italic version if wxDataViewItemAttr::GetBold() or GetItalic()
  1735. returns true) so it may not be necessary to call it explicitly if you
  1736. only want to render text using the items attributes.
  1737. @since 2.9.1
  1738. */
  1739. const wxDataViewItemAttr& GetAttr() const;
  1740. /**
  1741. Return size required to show content.
  1742. */
  1743. virtual wxSize GetSize() const = 0;
  1744. /**
  1745. Override this so that the renderer can get the value from the editor
  1746. control (pointed to by @a editor):
  1747. @code
  1748. {
  1749. wxSpinCtrl *sc = (wxSpinCtrl*) editor;
  1750. long l = sc->GetValue();
  1751. value = l;
  1752. return true;
  1753. }
  1754. @endcode
  1755. */
  1756. virtual bool GetValueFromEditorCtrl(wxWindow* editor,
  1757. wxVariant& value);
  1758. /**
  1759. Override this and make it return @true in order to
  1760. indicate that this renderer supports in-place editing.
  1761. */
  1762. virtual bool HasEditorCtrl() const;
  1763. /**
  1764. Override this to react to a left click. This method will only be
  1765. called in @c wxDATAVIEW_CELL_ACTIVATABLE mode. This method is
  1766. deprecated, please use ActivateCell instead.
  1767. */
  1768. virtual bool LeftClick( wxPoint cursor,
  1769. wxRect cell,
  1770. wxDataViewModel * model,
  1771. const wxDataViewItem & item,
  1772. unsigned int col );
  1773. /**
  1774. Override this to react to the activation of a cell. This method is
  1775. deprecated, please use ActivateCell instead.
  1776. */
  1777. virtual bool Activate(wxRect cell,
  1778. wxDataViewModel * model,
  1779. const wxDataViewItem & item,
  1780. unsigned int col);
  1781. /**
  1782. Override this to render the cell.
  1783. Before this is called, wxDataViewRenderer::SetValue was called
  1784. so that this instance knows what to render.
  1785. */
  1786. virtual bool Render(wxRect cell, wxDC* dc, int state) = 0;
  1787. /**
  1788. This method should be called from within Render() whenever you need to
  1789. render simple text.
  1790. This will ensure that the correct colour, font and vertical alignment will
  1791. be chosen so the text will look the same as text drawn by native renderers.
  1792. */
  1793. void RenderText(const wxString& text, int xoffset, wxRect cell,
  1794. wxDC* dc, int state);
  1795. /**
  1796. Override this to start a drag operation. Not yet supported.
  1797. */
  1798. virtual bool StartDrag(const wxPoint& cursor,
  1799. const wxRect& cell,
  1800. wxDataViewModel* model,
  1801. const wxDataViewItem & item,
  1802. unsigned int col);
  1803. protected:
  1804. /**
  1805. Helper for GetSize() implementations, respects attributes.
  1806. */
  1807. wxSize GetTextExtent(const wxString& str) const;
  1808. };
  1809. /**
  1810. @class wxDataViewBitmapRenderer
  1811. This class is used by wxDataViewCtrl to render bitmap controls.
  1812. @library{wxadv}
  1813. @category{dvc}
  1814. */
  1815. class wxDataViewBitmapRenderer : public wxDataViewRenderer
  1816. {
  1817. public:
  1818. /**
  1819. The ctor.
  1820. */
  1821. wxDataViewBitmapRenderer(const wxString& varianttype = "wxBitmap",
  1822. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  1823. int align = wxDVR_DEFAULT_ALIGNMENT);
  1824. };
  1825. /**
  1826. The flags used by wxDataViewColumn.
  1827. Can be combined together.
  1828. */
  1829. enum wxDataViewColumnFlags
  1830. {
  1831. wxDATAVIEW_COL_RESIZABLE = 1,
  1832. wxDATAVIEW_COL_SORTABLE = 2,
  1833. wxDATAVIEW_COL_REORDERABLE = 4,
  1834. wxDATAVIEW_COL_HIDDEN = 8
  1835. };
  1836. /**
  1837. @class wxDataViewColumn
  1838. This class represents a column in a wxDataViewCtrl.
  1839. One wxDataViewColumn is bound to one column in the data model to which the
  1840. wxDataViewCtrl has been associated.
  1841. An instance of wxDataViewRenderer is used by this class to render its data.
  1842. @library{wxadv}
  1843. @category{dvc}
  1844. */
  1845. class wxDataViewColumn : public wxSettableHeaderColumn
  1846. {
  1847. public:
  1848. /**
  1849. Constructs a text column.
  1850. @param title
  1851. The title of the column.
  1852. @param renderer
  1853. The class which will render the contents of this column.
  1854. @param model_column
  1855. The index of the model's column which is associated with this object.
  1856. @param width
  1857. The width of the column.
  1858. The @c wxDVC_DEFAULT_WIDTH value is the fixed default value.
  1859. @param align
  1860. The alignment of the column title.
  1861. @param flags
  1862. One or more flags of the ::wxDataViewColumnFlags enumeration.
  1863. */
  1864. wxDataViewColumn(const wxString& title,
  1865. wxDataViewRenderer* renderer,
  1866. unsigned int model_column,
  1867. int width = wxDVC_DEFAULT_WIDTH,
  1868. wxAlignment align = wxALIGN_CENTER,
  1869. int flags = wxDATAVIEW_COL_RESIZABLE);
  1870. /**
  1871. Constructs a bitmap column.
  1872. @param bitmap
  1873. The bitmap of the column.
  1874. @param renderer
  1875. The class which will render the contents of this column.
  1876. @param model_column
  1877. The index of the model's column which is associated with this object.
  1878. @param width
  1879. The width of the column.
  1880. The @c wxDVC_DEFAULT_WIDTH value is the fixed default value.
  1881. @param align
  1882. The alignment of the column title.
  1883. @param flags
  1884. One or more flags of the ::wxDataViewColumnFlags enumeration.
  1885. */
  1886. wxDataViewColumn(const wxBitmap& bitmap,
  1887. wxDataViewRenderer* renderer,
  1888. unsigned int model_column,
  1889. int width = wxDVC_DEFAULT_WIDTH,
  1890. wxAlignment align = wxALIGN_CENTER,
  1891. int flags = wxDATAVIEW_COL_RESIZABLE);
  1892. /**
  1893. Returns the index of the column of the model, which this
  1894. wxDataViewColumn is displaying.
  1895. */
  1896. unsigned int GetModelColumn() const;
  1897. /**
  1898. Returns the owning wxDataViewCtrl.
  1899. */
  1900. wxDataViewCtrl* GetOwner() const;
  1901. /**
  1902. Returns the renderer of this wxDataViewColumn.
  1903. @see wxDataViewRenderer.
  1904. */
  1905. wxDataViewRenderer* GetRenderer() const;
  1906. };
  1907. /**
  1908. @class wxDataViewListCtrl
  1909. This class is a wxDataViewCtrl which internally uses a wxDataViewListStore
  1910. and forwards most of its API to that class.
  1911. The purpose of this class is to offer a simple way to display and
  1912. edit a small table of data without having to write your own wxDataViewModel.
  1913. @code
  1914. wxDataViewListCtrl *listctrl = new wxDataViewListCtrl( parent, wxID_ANY );
  1915. listctrl->AppendToggleColumn( "Toggle" );
  1916. listctrl->AppendTextColumn( "Text" );
  1917. wxVector<wxVariant> data;
  1918. data.push_back( wxVariant(true) );
  1919. data.push_back( wxVariant("row 1") );
  1920. listctrl->AppendItem( data );
  1921. data.clear();
  1922. data.push_back( wxVariant(false) );
  1923. data.push_back( wxVariant("row 3") );
  1924. listctrl->AppendItem( data );
  1925. @endcode
  1926. @beginStyleTable
  1927. See wxDataViewCtrl for the list of supported styles.
  1928. @endStyleTable
  1929. @beginEventEmissionTable
  1930. See wxDataViewCtrl for the list of events emitted by this class.
  1931. @endEventTable
  1932. @library{wxadv}
  1933. @category{ctrl,dvc}
  1934. @since 2.9.0
  1935. */
  1936. class wxDataViewListCtrl: public wxDataViewCtrl
  1937. {
  1938. public:
  1939. /**
  1940. Default ctor.
  1941. */
  1942. wxDataViewListCtrl();
  1943. /**
  1944. Constructor. Calls Create().
  1945. */
  1946. wxDataViewListCtrl( wxWindow *parent, wxWindowID id,
  1947. const wxPoint& pos = wxDefaultPosition,
  1948. const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES,
  1949. const wxValidator& validator = wxDefaultValidator );
  1950. /**
  1951. Destructor. Deletes the image list if any.
  1952. */
  1953. ~wxDataViewListCtrl();
  1954. /**
  1955. Creates the control and a wxDataViewListStore as its internal model.
  1956. */
  1957. bool Create( wxWindow *parent, wxWindowID id,
  1958. const wxPoint& pos = wxDefaultPosition,
  1959. const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES,
  1960. const wxValidator& validator = wxDefaultValidator );
  1961. //@{
  1962. /**
  1963. Returns the store.
  1964. */
  1965. wxDataViewListStore *GetStore();
  1966. const wxDataViewListStore *GetStore() const;
  1967. //@}
  1968. /**
  1969. Returns the position of given @e item or wxNOT_FOUND if it's
  1970. not a valid item.
  1971. @since 2.9.2
  1972. */
  1973. int ItemToRow(const wxDataViewItem &item) const;
  1974. /**
  1975. Returns the wxDataViewItem at the given @e row.
  1976. @since 2.9.2
  1977. */
  1978. wxDataViewItem RowToItem(int row) const;
  1979. //@{
  1980. /**
  1981. @name Selection handling functions
  1982. */
  1983. /**
  1984. Returns index of the selected row or wxNOT_FOUND.
  1985. @see wxDataViewCtrl::GetSelection()
  1986. @since 2.9.2
  1987. */
  1988. int GetSelectedRow() const;
  1989. /**
  1990. Selects given row.
  1991. @see wxDataViewCtrl::Select()
  1992. @since 2.9.2
  1993. */
  1994. void SelectRow(unsigned row);
  1995. /**
  1996. Unselects given row.
  1997. @see wxDataViewCtrl::Unselect()
  1998. @since 2.9.2
  1999. */
  2000. void UnselectRow(unsigned row);
  2001. /**
  2002. Returns true if @a row is selected.
  2003. @see wxDataViewCtrl::IsSelected()
  2004. @since 2.9.2
  2005. */
  2006. bool IsRowSelected(unsigned row) const;
  2007. //@}
  2008. /**
  2009. @name Column management functions
  2010. */
  2011. //@{
  2012. /**
  2013. Appends a column to the control and additionally appends a
  2014. column to the store with the type string.
  2015. */
  2016. virtual bool AppendColumn( wxDataViewColumn *column );
  2017. /**
  2018. Appends a column to the control and additionally appends a
  2019. column to the list store with the type @a varianttype.
  2020. */
  2021. void AppendColumn( wxDataViewColumn *column, const wxString &varianttype );
  2022. /**
  2023. Appends a text column to the control and the store.
  2024. See wxDataViewColumn::wxDataViewColumn for more info about
  2025. the parameters.
  2026. */
  2027. wxDataViewColumn *AppendTextColumn( const wxString &label,
  2028. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  2029. int width = -1, wxAlignment align = wxALIGN_LEFT,
  2030. int flags = wxDATAVIEW_COL_RESIZABLE );
  2031. /**
  2032. Appends a toggle column to the control and the store.
  2033. See wxDataViewColumn::wxDataViewColumn for more info about
  2034. the parameters.
  2035. */
  2036. wxDataViewColumn *AppendToggleColumn( const wxString &label,
  2037. wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
  2038. int width = -1, wxAlignment align = wxALIGN_LEFT,
  2039. int flags = wxDATAVIEW_COL_RESIZABLE );
  2040. /**
  2041. Appends a progress column to the control and the store.
  2042. See wxDataViewColumn::wxDataViewColumn for more info about
  2043. the parameters.
  2044. */
  2045. wxDataViewColumn *AppendProgressColumn( const wxString &label,
  2046. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  2047. int width = -1, wxAlignment align = wxALIGN_LEFT,
  2048. int flags = wxDATAVIEW_COL_RESIZABLE );
  2049. /**
  2050. Appends an icon-and-text column to the control and the store.
  2051. See wxDataViewColumn::wxDataViewColumn for more info about
  2052. the parameters.
  2053. */
  2054. wxDataViewColumn *AppendIconTextColumn( const wxString &label,
  2055. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  2056. int width = -1, wxAlignment align = wxALIGN_LEFT,
  2057. int flags = wxDATAVIEW_COL_RESIZABLE );
  2058. /**
  2059. Inserts a column to the control and additionally inserts a
  2060. column to the store with the type string.
  2061. */
  2062. virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *column );
  2063. /**
  2064. Inserts a column to the control and additionally inserts a
  2065. column to the list store with the type @a varianttype.
  2066. */
  2067. void InsertColumn( unsigned int pos, wxDataViewColumn *column,
  2068. const wxString &varianttype );
  2069. /**
  2070. Prepends a column to the control and additionally prepends a
  2071. column to the store with the type string.
  2072. */
  2073. virtual bool PrependColumn( wxDataViewColumn *column );
  2074. /**
  2075. Prepends a column to the control and additionally prepends a
  2076. column to the list store with the type @a varianttype.
  2077. */
  2078. void PrependColumn( wxDataViewColumn *column, const wxString &varianttype );
  2079. //@}
  2080. /**
  2081. @name Item management functions
  2082. */
  2083. //@{
  2084. /**
  2085. Appends an item (=row) to the control and store.
  2086. */
  2087. void AppendItem( const wxVector<wxVariant> &values, wxUIntPtr data = NULL );
  2088. /**
  2089. Prepends an item (=row) to the control and store.
  2090. */
  2091. void PrependItem( const wxVector<wxVariant> &values, wxUIntPtr data = NULL );
  2092. /**
  2093. Inserts an item (=row) to the control and store.
  2094. */
  2095. void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxUIntPtr data = NULL );
  2096. /**
  2097. Delete the row at position @a row.
  2098. */
  2099. void DeleteItem( unsigned row );
  2100. /**
  2101. Delete all items (= all rows).
  2102. */
  2103. void DeleteAllItems();
  2104. /**
  2105. Returns the number of items (=rows) in the control
  2106. @since 2.9.4
  2107. */
  2108. unsigned int GetItemCount() const;
  2109. /**
  2110. Returns the client data associated with the item.
  2111. @see SetItemData()
  2112. @since 2.9.4
  2113. */
  2114. wxUIntPtr GetItemData(const wxDataViewItem& item) const;
  2115. /**
  2116. Sets the value in the store and update the control.
  2117. */
  2118. void SetValue( const wxVariant &value, unsigned int row, unsigned int col );
  2119. /**
  2120. Returns the value from the store.
  2121. */
  2122. void GetValue( wxVariant &value, unsigned int row, unsigned int col );
  2123. /**
  2124. Sets the value in the store and update the control.
  2125. This method assumes that the string is stored in respective
  2126. column.
  2127. */
  2128. void SetTextValue( const wxString &value, unsigned int row, unsigned int col );
  2129. /**
  2130. Returns the value from the store.
  2131. This method assumes that the string is stored in respective
  2132. column.
  2133. */
  2134. wxString GetTextValue( unsigned int row, unsigned int col ) const;
  2135. /**
  2136. Sets the value in the store and update the control.
  2137. This method assumes that the boolean value is stored in
  2138. respective column.
  2139. */
  2140. void SetToggleValue( bool value, unsigned int row, unsigned int col );
  2141. /**
  2142. Returns the value from the store.
  2143. This method assumes that the boolean value is stored in
  2144. respective column.
  2145. */
  2146. bool GetToggleValue( unsigned int row, unsigned int col ) const;
  2147. /**
  2148. Associates a client data pointer with the given item.
  2149. Notice that the control does @e not take ownership of the pointer for
  2150. compatibility with wxListCtrl. I.e. it will @e not delete the pointer
  2151. (if it is a pointer and not a number) itself, it is up to you to do it.
  2152. @see GetItemData()
  2153. @since 2.9.4
  2154. */
  2155. void SetItemData(const wxDataViewItem& item, wxUIntPtr data);
  2156. //@}
  2157. };
  2158. /**
  2159. @class wxDataViewTreeCtrl
  2160. This class is a wxDataViewCtrl which internally uses a wxDataViewTreeStore
  2161. and forwards most of its API to that class.
  2162. Additionally, it uses a wxImageList to store a list of icons.
  2163. The main purpose of this class is to provide a simple upgrade path for code
  2164. using wxTreeCtrl.
  2165. @beginStyleTable
  2166. See wxDataViewCtrl for the list of supported styles.
  2167. @endStyleTable
  2168. @beginEventEmissionTable
  2169. See wxDataViewCtrl for the list of events emitted by this class.
  2170. @endEventTable
  2171. @library{wxadv}
  2172. @category{ctrl,dvc}
  2173. @since 2.9.0
  2174. @appearance{dataviewtreectrl}
  2175. */
  2176. class wxDataViewTreeCtrl : public wxDataViewCtrl
  2177. {
  2178. public:
  2179. /**
  2180. Default ctor.
  2181. */
  2182. wxDataViewTreeCtrl();
  2183. /**
  2184. Constructor.
  2185. Calls Create().
  2186. */
  2187. wxDataViewTreeCtrl(wxWindow* parent, wxWindowID id,
  2188. const wxPoint& pos = wxDefaultPosition,
  2189. const wxSize& size = wxDefaultSize,
  2190. long style = wxDV_NO_HEADER | wxDV_ROW_LINES,
  2191. const wxValidator& validator = wxDefaultValidator);
  2192. /**
  2193. Destructor. Deletes the image list if any.
  2194. */
  2195. virtual ~wxDataViewTreeCtrl();
  2196. /**
  2197. Appends a container to the given @a parent.
  2198. */
  2199. wxDataViewItem AppendContainer(const wxDataViewItem& parent,
  2200. const wxString& text,
  2201. int icon = -1,
  2202. int expanded = -1,
  2203. wxClientData* data = NULL);
  2204. /**
  2205. Appends an item to the given @a parent.
  2206. */
  2207. wxDataViewItem AppendItem(const wxDataViewItem& parent,
  2208. const wxString& text,
  2209. int icon = -1,
  2210. wxClientData* data = NULL);
  2211. /**
  2212. Creates the control and a wxDataViewTreeStore as its internal model.
  2213. The default tree column created by this method is an editable column
  2214. using wxDataViewIconTextRenderer as its renderer.
  2215. */
  2216. bool Create(wxWindow* parent, wxWindowID id,
  2217. const wxPoint& pos = wxDefaultPosition,
  2218. const wxSize& size = wxDefaultSize,
  2219. long style = wxDV_NO_HEADER | wxDV_ROW_LINES,
  2220. const wxValidator& validator = wxDefaultValidator);
  2221. /**
  2222. Calls the identical method from wxDataViewTreeStore.
  2223. */
  2224. void DeleteAllItems();
  2225. /**
  2226. Calls the identical method from wxDataViewTreeStore.
  2227. */
  2228. void DeleteChildren(const wxDataViewItem& item);
  2229. /**
  2230. Calls the identical method from wxDataViewTreeStore.
  2231. */
  2232. void DeleteItem(const wxDataViewItem& item);
  2233. /**
  2234. Calls the identical method from wxDataViewTreeStore.
  2235. */
  2236. int GetChildCount(const wxDataViewItem& parent) const;
  2237. /**
  2238. Returns the image list.
  2239. */
  2240. wxImageList* GetImageList();
  2241. /**
  2242. Calls the identical method from wxDataViewTreeStore.
  2243. */
  2244. wxClientData* GetItemData(const wxDataViewItem& item) const;
  2245. /**
  2246. Calls the identical method from wxDataViewTreeStore.
  2247. */
  2248. const wxIcon& GetItemExpandedIcon(const wxDataViewItem& item) const;
  2249. /**
  2250. Calls the identical method from wxDataViewTreeStore.
  2251. */
  2252. const wxIcon& GetItemIcon(const wxDataViewItem& item) const;
  2253. /**
  2254. Calls the identical method from wxDataViewTreeStore.
  2255. */
  2256. wxString GetItemText(const wxDataViewItem& item) const;
  2257. /**
  2258. Calls the identical method from wxDataViewTreeStore.
  2259. */
  2260. wxDataViewItem GetNthChild(const wxDataViewItem& parent,
  2261. unsigned int pos) const;
  2262. //@{
  2263. /**
  2264. Returns the store.
  2265. */
  2266. wxDataViewTreeStore* GetStore();
  2267. const wxDataViewTreeStore* GetStore() const;
  2268. //@}
  2269. /**
  2270. Calls the same method from wxDataViewTreeStore but uses
  2271. an index position in the image list instead of a wxIcon.
  2272. */
  2273. wxDataViewItem InsertContainer(const wxDataViewItem& parent,
  2274. const wxDataViewItem& previous,
  2275. const wxString& text,
  2276. int icon = -1,
  2277. int expanded = -1,
  2278. wxClientData* data = NULL);
  2279. /**
  2280. Calls the same method from wxDataViewTreeStore but uses
  2281. an index position in the image list instead of a wxIcon.
  2282. */
  2283. wxDataViewItem InsertItem(const wxDataViewItem& parent,
  2284. const wxDataViewItem& previous,
  2285. const wxString& text,
  2286. int icon = -1,
  2287. wxClientData* data = NULL);
  2288. /**
  2289. Returns true if item is a container.
  2290. */
  2291. bool IsContainer( const wxDataViewItem& item );
  2292. /**
  2293. Calls the same method from wxDataViewTreeStore but uses
  2294. an index position in the image list instead of a wxIcon.
  2295. */
  2296. wxDataViewItem PrependContainer(const wxDataViewItem& parent,
  2297. const wxString& text,
  2298. int icon = -1,
  2299. int expanded = -1,
  2300. wxClientData* data = NULL);
  2301. /**
  2302. Calls the same method from wxDataViewTreeStore but uses
  2303. an index position in the image list instead of a wxIcon.
  2304. */
  2305. wxDataViewItem PrependItem(const wxDataViewItem& parent,
  2306. const wxString& text,
  2307. int icon = -1,
  2308. wxClientData* data = NULL);
  2309. /**
  2310. Sets the image list.
  2311. */
  2312. void SetImageList(wxImageList* imagelist);
  2313. /**
  2314. Calls the identical method from wxDataViewTreeStore.
  2315. */
  2316. void SetItemData(const wxDataViewItem& item, wxClientData* data);
  2317. /**
  2318. Calls the identical method from wxDataViewTreeStore.
  2319. */
  2320. void SetItemExpandedIcon(const wxDataViewItem& item,
  2321. const wxIcon& icon);
  2322. /**
  2323. Calls the identical method from wxDataViewTreeStore.
  2324. */
  2325. void SetItemIcon(const wxDataViewItem& item, const wxIcon& icon);
  2326. /**
  2327. Calls the identical method from wxDataViewTreeStore.
  2328. */
  2329. void SetItemText(const wxDataViewItem& item,
  2330. const wxString& text);
  2331. };
  2332. /**
  2333. @class wxDataViewListStore
  2334. wxDataViewListStore is a specialised wxDataViewModel for storing
  2335. a simple table of data. Since it derives from wxDataViewIndexListModel
  2336. its data is be accessed by row (i.e. by index) instead of only
  2337. by wxDataViewItem.
  2338. This class actually stores the values (therefore its name)
  2339. and implements all virtual methods from the base classes so it can be
  2340. used directly without having to derive any class from it, but it is
  2341. mostly used from within wxDataViewListCtrl.
  2342. @library{wxadv}
  2343. @category{dvc}
  2344. */
  2345. class wxDataViewListStore: public wxDataViewIndexListModel
  2346. {
  2347. public:
  2348. /**
  2349. Constructor
  2350. */
  2351. wxDataViewListStore();
  2352. /**
  2353. Destructor
  2354. */
  2355. ~wxDataViewListStore();
  2356. /**
  2357. Prepends a data column.
  2358. @a variantype indicates the type of values store in the column.
  2359. This does not automatically fill in any (default) values in
  2360. rows which exist in the store already.
  2361. */
  2362. void PrependColumn( const wxString &varianttype );
  2363. /**
  2364. Inserts a data column before @a pos.
  2365. @a variantype indicates the type of values store in the column.
  2366. This does not automatically fill in any (default) values in
  2367. rows which exist in the store already.
  2368. */
  2369. void InsertColumn( unsigned int pos, const wxString &varianttype );
  2370. /**
  2371. Appends a data column.
  2372. @a variantype indicates the type of values store in the column.
  2373. This does not automatically fill in any (default) values in
  2374. rows which exist in the store already.
  2375. */
  2376. void AppendColumn( const wxString &varianttype );
  2377. /**
  2378. Appends an item (=row) and fills it with @a values.
  2379. The values must match the values specifies in the column
  2380. in number and type. No (default) values are filled in
  2381. automatically.
  2382. */
  2383. void AppendItem( const wxVector<wxVariant> &values, wxUIntPtr data = NULL );
  2384. /**
  2385. Prepends an item (=row) and fills it with @a values.
  2386. The values must match the values specifies in the column
  2387. in number and type. No (default) values are filled in
  2388. automatically.
  2389. */
  2390. void PrependItem( const wxVector<wxVariant> &values, wxUIntPtr data = NULL );
  2391. /**
  2392. Inserts an item (=row) and fills it with @a values.
  2393. The values must match the values specifies in the column
  2394. in number and type. No (default) values are filled in
  2395. automatically.
  2396. */
  2397. void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxUIntPtr data = NULL );
  2398. /**
  2399. Delete the item (=row) at position @a pos.
  2400. */
  2401. void DeleteItem( unsigned pos );
  2402. /**
  2403. Delete all item (=all rows) in the store.
  2404. */
  2405. void DeleteAllItems();
  2406. /**
  2407. Returns the number of items (=rows) in the control
  2408. @since 2.9.4
  2409. */
  2410. unsigned int GetItemCount() const;
  2411. /**
  2412. Returns the client data associated with the item.
  2413. @see SetItemData()
  2414. @since 2.9.4
  2415. */
  2416. wxUIntPtr GetItemData(const wxDataViewItem& item) const;
  2417. /**
  2418. Overridden from wxDataViewModel
  2419. */
  2420. virtual unsigned int GetColumnCount() const;
  2421. /**
  2422. Overridden from wxDataViewModel
  2423. */
  2424. virtual wxString GetColumnType( unsigned int col ) const;
  2425. /**
  2426. Sets the client data associated with the item.
  2427. Notice that this class does @e not take ownership of the passed in
  2428. pointer and will not delete it.
  2429. @see GetItemData()
  2430. @since 2.9.4
  2431. */
  2432. void SetItemData(const wxDataViewItem& item, wxUIntPtr data);
  2433. /**
  2434. Overridden from wxDataViewIndexListModel
  2435. */
  2436. virtual void GetValueByRow( wxVariant &value,
  2437. unsigned int row, unsigned int col ) const;
  2438. /**
  2439. Overridden from wxDataViewIndexListModel
  2440. */
  2441. virtual bool SetValueByRow( const wxVariant &value,
  2442. unsigned int row, unsigned int col );
  2443. };
  2444. /**
  2445. @class wxDataViewTreeStore
  2446. wxDataViewTreeStore is a specialised wxDataViewModel for storing simple
  2447. trees very much like wxTreeCtrl does and it offers a similar API.
  2448. This class actually stores the entire tree and the values (therefore its name)
  2449. and implements all virtual methods from the base class so it can be used directly
  2450. without having to derive any class from it, but it is mostly used from within
  2451. wxDataViewTreeCtrl.
  2452. @library{wxadv}
  2453. @category{dvc}
  2454. */
  2455. class wxDataViewTreeStore : public wxDataViewModel
  2456. {
  2457. public:
  2458. /**
  2459. Constructor. Creates the invisible root node internally.
  2460. */
  2461. wxDataViewTreeStore();
  2462. /**
  2463. Destructor.
  2464. */
  2465. virtual ~wxDataViewTreeStore();
  2466. /**
  2467. Append a container.
  2468. */
  2469. wxDataViewItem AppendContainer(const wxDataViewItem& parent,
  2470. const wxString& text,
  2471. const wxIcon& icon = wxNullIcon,
  2472. const wxIcon& expanded = wxNullIcon,
  2473. wxClientData* data = NULL);
  2474. /**
  2475. Append an item.
  2476. */
  2477. wxDataViewItem AppendItem(const wxDataViewItem& parent,
  2478. const wxString& text,
  2479. const wxIcon& icon = wxNullIcon,
  2480. wxClientData* data = NULL);
  2481. /**
  2482. Delete all item in the model.
  2483. */
  2484. void DeleteAllItems();
  2485. /**
  2486. Delete all children of the item, but not the item itself.
  2487. */
  2488. void DeleteChildren(const wxDataViewItem& item);
  2489. /**
  2490. Delete this item.
  2491. */
  2492. void DeleteItem(const wxDataViewItem& item);
  2493. /**
  2494. Return the number of children of item.
  2495. */
  2496. int GetChildCount(const wxDataViewItem& parent) const;
  2497. /**
  2498. Returns the client data associated with the item.
  2499. */
  2500. wxClientData* GetItemData(const wxDataViewItem& item) const;
  2501. /**
  2502. Returns the icon to display in expanded containers.
  2503. */
  2504. const wxIcon& GetItemExpandedIcon(const wxDataViewItem& item) const;
  2505. /**
  2506. Returns the icon of the item.
  2507. */
  2508. const wxIcon& GetItemIcon(const wxDataViewItem& item) const;
  2509. /**
  2510. Returns the text of the item.
  2511. */
  2512. wxString GetItemText(const wxDataViewItem& item) const;
  2513. /**
  2514. Returns the nth child item of item.
  2515. */
  2516. wxDataViewItem GetNthChild(const wxDataViewItem& parent,
  2517. unsigned int pos) const;
  2518. /**
  2519. Inserts a container after @a previous.
  2520. */
  2521. wxDataViewItem InsertContainer(const wxDataViewItem& parent,
  2522. const wxDataViewItem& previous,
  2523. const wxString& text,
  2524. const wxIcon& icon = wxNullIcon,
  2525. const wxIcon& expanded = wxNullIcon,
  2526. wxClientData* data = NULL);
  2527. /**
  2528. Inserts an item after @a previous.
  2529. */
  2530. wxDataViewItem InsertItem(const wxDataViewItem& parent,
  2531. const wxDataViewItem& previous,
  2532. const wxString& text,
  2533. const wxIcon& icon = wxNullIcon,
  2534. wxClientData* data = NULL);
  2535. /**
  2536. Inserts a container before the first child item or @a parent.
  2537. */
  2538. wxDataViewItem PrependContainer(const wxDataViewItem& parent,
  2539. const wxString& text,
  2540. const wxIcon& icon = wxNullIcon,
  2541. const wxIcon& expanded = wxNullIcon,
  2542. wxClientData* data = NULL);
  2543. /**
  2544. Inserts an item before the first child item or @a parent.
  2545. */
  2546. wxDataViewItem PrependItem(const wxDataViewItem& parent,
  2547. const wxString& text,
  2548. const wxIcon& icon = wxNullIcon,
  2549. wxClientData* data = NULL);
  2550. /**
  2551. Sets the client data associated with the item.
  2552. */
  2553. void SetItemData(const wxDataViewItem& item, wxClientData* data);
  2554. /**
  2555. Sets the expanded icon for the item.
  2556. */
  2557. void SetItemExpandedIcon(const wxDataViewItem& item,
  2558. const wxIcon& icon);
  2559. /**
  2560. Sets the icon for the item.
  2561. */
  2562. void SetItemIcon(const wxDataViewItem& item, const wxIcon& icon);
  2563. };
  2564. /**
  2565. @class wxDataViewIconText
  2566. wxDataViewIconText is used by wxDataViewIconTextRenderer for data transfer.
  2567. This class can be converted to and from a wxVariant.
  2568. @library{wxadv}
  2569. @category{dvc}
  2570. */
  2571. class wxDataViewIconText : public wxObject
  2572. {
  2573. public:
  2574. //@{
  2575. /**
  2576. Constructor.
  2577. */
  2578. wxDataViewIconText(const wxString& text = wxEmptyString,
  2579. const wxIcon& icon = wxNullIcon);
  2580. wxDataViewIconText(const wxDataViewIconText& other);
  2581. //@}
  2582. /**
  2583. Gets the icon.
  2584. */
  2585. const wxIcon& GetIcon() const;
  2586. /**
  2587. Gets the text.
  2588. */
  2589. wxString GetText() const;
  2590. /**
  2591. Set the icon.
  2592. */
  2593. void SetIcon(const wxIcon& icon);
  2594. /**
  2595. Set the text.
  2596. */
  2597. void SetText(const wxString& text);
  2598. };
  2599. /**
  2600. @class wxDataViewEvent
  2601. This is the event class for the wxDataViewCtrl notifications.
  2602. @beginEventTable{wxDataViewEvent}
  2603. @event{EVT_DATAVIEW_SELECTION_CHANGED(id, func)}
  2604. Process a @c wxEVT_DATAVIEW_SELECTION_CHANGED event.
  2605. @event{EVT_DATAVIEW_ITEM_ACTIVATED(id, func)}
  2606. Process a @c wxEVT_DATAVIEW_ITEM_ACTIVATED event.
  2607. @event{EVT_DATAVIEW_ITEM_EDITING_STARTED(id, func)}
  2608. Process a @c wxEVT_DATAVIEW_ITEM_EDITING_STARTED event.
  2609. @event{EVT_DATAVIEW_ITEM_EDITING_DONE(id, func)}
  2610. Process a @c wxEVT_DATAVIEW_ITEM_EDITING_DONE event.
  2611. @event{EVT_DATAVIEW_ITEM_COLLAPSING(id, func)}
  2612. Process a @c wxEVT_DATAVIEW_ITEM_COLLAPSING event.
  2613. @event{EVT_DATAVIEW_ITEM_COLLAPSED(id, func)}
  2614. Process a @c wxEVT_DATAVIEW_ITEM_COLLAPSED event.
  2615. @event{EVT_DATAVIEW_ITEM_EXPANDING(id, func)}
  2616. Process a @c wxEVT_DATAVIEW_ITEM_EXPANDING event.
  2617. @event{EVT_DATAVIEW_ITEM_EXPANDED(id, func)}
  2618. Process a @c wxEVT_DATAVIEW_ITEM_EXPANDED event.
  2619. @event{EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, func)}
  2620. Process a @c wxEVT_DATAVIEW_ITEM_VALUE_CHANGED event.
  2621. @event{EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, func)}
  2622. Process a @c wxEVT_DATAVIEW_ITEM_CONTEXT_MENU event.
  2623. @event{EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, func)}
  2624. Process a @c wxEVT_DATAVIEW_COLUMN_HEADER_CLICK event.
  2625. @event{EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(id, func)}
  2626. Process a @c wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK event.
  2627. @event{EVT_DATAVIEW_COLUMN_SORTED(id, func)}
  2628. Process a @c wxEVT_DATAVIEW_COLUMN_SORTED event.
  2629. @event{EVT_DATAVIEW_COLUMN_REORDERED(id, func)}
  2630. Process a @c wxEVT_DATAVIEW_COLUMN_REORDERED event.
  2631. Currently this even is only generated when using the native OSX
  2632. version.
  2633. @event{EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, func)}
  2634. Process a @c wxEVT_DATAVIEW_ITEM_BEGIN_DRAG event.
  2635. @event{EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, func)}
  2636. Process a @c wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE event.
  2637. @event{EVT_DATAVIEW_ITEM_DROP(id, func)}
  2638. Process a @c wxEVT_DATAVIEW_ITEM_DROP event.
  2639. @event{EVT_DATAVIEW_CACHE_HINT(id, func)}
  2640. Process a @c wxEVT_DATAVIEW_CACHE_HINT event.
  2641. @endEventTable
  2642. @library{wxadv}
  2643. @category{events,dvc}
  2644. */
  2645. class wxDataViewEvent : public wxNotifyEvent
  2646. {
  2647. public:
  2648. /**
  2649. Constructor. Typically used by wxWidgets internals only.
  2650. */
  2651. wxDataViewEvent(wxEventType commandType = wxEVT_NULL,
  2652. int winid = 0);
  2653. /**
  2654. Returns the position of the column in the control or -1
  2655. if no column field was set by the event emitter.
  2656. */
  2657. int GetColumn() const;
  2658. /**
  2659. Returns a pointer to the wxDataViewColumn from which
  2660. the event was emitted or @NULL.
  2661. */
  2662. wxDataViewColumn* GetDataViewColumn() const;
  2663. /**
  2664. Returns the wxDataViewModel associated with the event.
  2665. */
  2666. wxDataViewModel* GetModel() const;
  2667. /**
  2668. Returns the position of a context menu event in screen coordinates.
  2669. */
  2670. wxPoint GetPosition() const;
  2671. /**
  2672. Returns a reference to a value.
  2673. */
  2674. const wxVariant& GetValue() const;
  2675. /**
  2676. Can be used to determine whether the new value is going to be accepted
  2677. in wxEVT_DATAVIEW_ITEM_EDITING_DONE handler.
  2678. Returns @true if editing the item was cancelled or if the user tried to
  2679. enter an invalid value (refused by wxDataViewRenderer::Validate()). If
  2680. this method returns @false, it means that the value in the model is
  2681. about to be changed to the new one.
  2682. Notice that wxEVT_DATAVIEW_ITEM_EDITING_DONE event handler can
  2683. call wxNotifyEvent::Veto() to prevent this from happening.
  2684. Currently support for setting this field and for vetoing the change is
  2685. only available in the generic version of wxDataViewCtrl, i.e. under MSW
  2686. but not GTK nor OS X.
  2687. @since 2.9.3
  2688. */
  2689. bool IsEditCancelled() const;
  2690. /**
  2691. Sets the column index associated with this event.
  2692. */
  2693. void SetColumn(int col);
  2694. /**
  2695. For @c wxEVT_DATAVIEW_COLUMN_HEADER_CLICK only.
  2696. */
  2697. void SetDataViewColumn(wxDataViewColumn* col);
  2698. /**
  2699. Sets the dataview model associated with this event.
  2700. */
  2701. void SetModel(wxDataViewModel* model);
  2702. /**
  2703. Sets the value associated with this event.
  2704. */
  2705. void SetValue(const wxVariant& value);
  2706. /**
  2707. Set wxDataObject for data transfer within a drag operation.
  2708. */
  2709. void SetDataObject( wxDataObject *obj );
  2710. /**
  2711. Gets the wxDataFormat during a drop operation.
  2712. */
  2713. wxDataFormat GetDataFormat() const;
  2714. /**
  2715. Gets the data size for a drop data transfer.
  2716. */
  2717. size_t GetDataSize() const;
  2718. /**
  2719. Gets the data buffer for a drop data transfer.
  2720. */
  2721. void *GetDataBuffer() const;
  2722. /**
  2723. Specify the kind of the drag operation to perform.
  2724. This method can be used inside a wxEVT_DATAVIEW_ITEM_BEGIN_DRAG
  2725. handler in order to configure the drag operation. Valid values are
  2726. ::wxDrag_CopyOnly (default), ::wxDrag_AllowMove (allow the data to be
  2727. moved) and ::wxDrag_DefaultMove.
  2728. Currently it is only honoured by the generic version of wxDataViewCtrl
  2729. (used e.g. under MSW) and not supported by the native GTK and OS X
  2730. versions.
  2731. @see GetDropEffect()
  2732. @since 2.9.4
  2733. */
  2734. void SetDragFlags(int flags);
  2735. /**
  2736. Returns the effect the user requested to happen to the dropped data.
  2737. This function can be used inside
  2738. wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE and
  2739. wxEVT_DATAVIEW_ITEM_DROP handlers and returns whether the user
  2740. is trying to copy (the return value is ::wxDragCopy) or move (if the
  2741. return value is ::wxDragMove) the data.
  2742. Currently this is only available when using the generic version of
  2743. wxDataViewCtrl (used e.g. under MSW) and always returns ::wxDragNone in
  2744. the GTK and OS X native versions.
  2745. @since 2.9.4
  2746. */
  2747. wxDragResult GetDropEffect() const;
  2748. /**
  2749. Return the first row that will be displayed.
  2750. */
  2751. int GetCacheFrom() const;
  2752. /**
  2753. Return the last row that will be displayed.
  2754. */
  2755. int GetCacheTo() const;
  2756. wxDataViewItem GetItem() const;
  2757. void SetItem( const wxDataViewItem &item );
  2758. void SetEditCanceled(bool editCancelled);
  2759. void SetPosition( int x, int y );
  2760. void SetCache(int from, int to);
  2761. wxDataObject *GetDataObject() const;
  2762. void SetDataFormat( const wxDataFormat &format );
  2763. void SetDataSize( size_t size );
  2764. void SetDataBuffer( void* buf );
  2765. int GetDragFlags() const;
  2766. void SetDropEffect( wxDragResult effect );
  2767. };