event.h 157 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: event.h
  3. // Purpose: interface of wxEvtHandler, wxEventBlocker and many
  4. // wxEvent-derived classes
  5. // Author: wxWidgets team
  6. // Licence: wxWindows licence
  7. /////////////////////////////////////////////////////////////////////////////
  8. #if wxUSE_BASE
  9. /**
  10. The predefined constants for the number of times we propagate event
  11. upwards window child-parent chain.
  12. */
  13. enum wxEventPropagation
  14. {
  15. /// don't propagate it at all
  16. wxEVENT_PROPAGATE_NONE = 0,
  17. /// propagate it until it is processed
  18. wxEVENT_PROPAGATE_MAX = INT_MAX
  19. };
  20. /**
  21. The different categories for a wxEvent; see wxEvent::GetEventCategory.
  22. @note They are used as OR-combinable flags by wxEventLoopBase::YieldFor.
  23. */
  24. enum wxEventCategory
  25. {
  26. /**
  27. This is the category for those events which are generated to update
  28. the appearance of the GUI but which (usually) do not comport data
  29. processing, i.e. which do not provide input or output data
  30. (e.g. size events, scroll events, etc).
  31. They are events NOT directly generated by the user's input devices.
  32. */
  33. wxEVT_CATEGORY_UI = 1,
  34. /**
  35. This category groups those events which are generated directly from the
  36. user through input devices like mouse and keyboard and usually result in
  37. data to be processed from the application
  38. (e.g. mouse clicks, key presses, etc).
  39. */
  40. wxEVT_CATEGORY_USER_INPUT = 2,
  41. /// This category is for wxSocketEvent
  42. wxEVT_CATEGORY_SOCKET = 4,
  43. /// This category is for wxTimerEvent
  44. wxEVT_CATEGORY_TIMER = 8,
  45. /**
  46. This category is for any event used to send notifications from the
  47. secondary threads to the main one or in general for notifications among
  48. different threads (which may or may not be user-generated).
  49. See e.g. wxThreadEvent.
  50. */
  51. wxEVT_CATEGORY_THREAD = 16,
  52. /**
  53. This mask is used in wxEventLoopBase::YieldFor to specify that all event
  54. categories should be processed.
  55. */
  56. wxEVT_CATEGORY_ALL =
  57. wxEVT_CATEGORY_UI|wxEVT_CATEGORY_USER_INPUT|wxEVT_CATEGORY_SOCKET| \
  58. wxEVT_CATEGORY_TIMER|wxEVT_CATEGORY_THREAD
  59. };
  60. /**
  61. @class wxEvent
  62. An event is a structure holding information about an event passed to a
  63. callback or member function.
  64. wxEvent used to be a multipurpose event object, and is an abstract base class
  65. for other event classes (see below).
  66. For more information about events, see the @ref overview_events overview.
  67. @beginWxPerlOnly
  68. In wxPerl custom event classes should be derived from
  69. @c Wx::PlEvent and @c Wx::PlCommandEvent.
  70. @endWxPerlOnly
  71. @library{wxbase}
  72. @category{events}
  73. @see wxCommandEvent, wxMouseEvent
  74. */
  75. class wxEvent : public wxObject
  76. {
  77. public:
  78. /**
  79. Constructor.
  80. Notice that events are usually created by wxWidgets itself and creating
  81. e.g. a wxPaintEvent in your code and sending it to e.g. a wxTextCtrl
  82. will not usually affect it at all as native controls have no specific
  83. knowledge about wxWidgets events. However you may construct objects of
  84. specific types and pass them to wxEvtHandler::ProcessEvent() if you
  85. want to create your own custom control and want to process its events
  86. in the same manner as the standard ones.
  87. Also please notice that the order of parameters in this constructor is
  88. different from almost all the derived classes which specify the event
  89. type as the first argument.
  90. @param id
  91. The identifier of the object (window, timer, ...) which generated
  92. this event.
  93. @param eventType
  94. The unique type of event, e.g. @c wxEVT_PAINT, @c wxEVT_SIZE or
  95. @c wxEVT_BUTTON.
  96. */
  97. wxEvent(int id = 0, wxEventType eventType = wxEVT_NULL);
  98. /**
  99. Returns a copy of the event.
  100. Any event that is posted to the wxWidgets event system for later action
  101. (via wxEvtHandler::AddPendingEvent, wxEvtHandler::QueueEvent or wxPostEvent())
  102. must implement this method.
  103. All wxWidgets events fully implement this method, but any derived events
  104. implemented by the user should also implement this method just in case they
  105. (or some event derived from them) are ever posted.
  106. All wxWidgets events implement a copy constructor, so the easiest way of
  107. implementing the Clone function is to implement a copy constructor for
  108. a new event (call it MyEvent) and then define the Clone function like this:
  109. @code
  110. wxEvent *Clone() const { return new MyEvent(*this); }
  111. @endcode
  112. */
  113. virtual wxEvent* Clone() const = 0;
  114. /**
  115. Returns the object (usually a window) associated with the event, if any.
  116. */
  117. wxObject* GetEventObject() const;
  118. /**
  119. Returns the identifier of the given event type, such as @c wxEVT_BUTTON.
  120. */
  121. wxEventType GetEventType() const;
  122. /**
  123. Returns a generic category for this event.
  124. wxEvent implementation returns @c wxEVT_CATEGORY_UI by default.
  125. This function is used to selectively process events in wxEventLoopBase::YieldFor.
  126. */
  127. virtual wxEventCategory GetEventCategory() const;
  128. /**
  129. Returns the identifier associated with this event, such as a button command id.
  130. */
  131. int GetId() const;
  132. /**
  133. Return the user data associated with a dynamically connected event handler.
  134. wxEvtHandler::Connect() and wxEvtHandler::Bind() allow associating
  135. optional @c userData pointer with the handler and this method returns
  136. the value of this pointer.
  137. The returned pointer is owned by wxWidgets and must not be deleted.
  138. @since 2.9.5
  139. */
  140. wxObject *GetEventUserData() const;
  141. /**
  142. Returns @true if the event handler should be skipped, @false otherwise.
  143. */
  144. bool GetSkipped() const;
  145. /**
  146. Gets the timestamp for the event. The timestamp is the time in milliseconds
  147. since some fixed moment (not necessarily the standard Unix Epoch, so only
  148. differences between the timestamps and not their absolute values usually make sense).
  149. @warning
  150. wxWidgets returns a non-NULL timestamp only for mouse and key events
  151. (see wxMouseEvent and wxKeyEvent).
  152. */
  153. long GetTimestamp() const;
  154. /**
  155. Returns @true if the event is or is derived from wxCommandEvent else it returns @false.
  156. @note exists only for optimization purposes.
  157. */
  158. bool IsCommandEvent() const;
  159. /**
  160. Sets the propagation level to the given value (for example returned from an
  161. earlier call to wxEvent::StopPropagation).
  162. */
  163. void ResumePropagation(int propagationLevel);
  164. /**
  165. Sets the originating object.
  166. */
  167. void SetEventObject(wxObject* object);
  168. /**
  169. Sets the event type.
  170. */
  171. void SetEventType(wxEventType type);
  172. /**
  173. Sets the identifier associated with this event, such as a button command id.
  174. */
  175. void SetId(int id);
  176. /**
  177. Sets the timestamp for the event.
  178. */
  179. void SetTimestamp(long timeStamp = 0);
  180. /**
  181. Test if this event should be propagated or not, i.e.\ if the propagation level
  182. is currently greater than 0.
  183. */
  184. bool ShouldPropagate() const;
  185. /**
  186. This method can be used inside an event handler to control whether further
  187. event handlers bound to this event will be called after the current one returns.
  188. Without Skip() (or equivalently if Skip(@false) is used), the event will not
  189. be processed any more. If Skip(@true) is called, the event processing system
  190. continues searching for a further handler function for this event, even though
  191. it has been processed already in the current handler.
  192. In general, it is recommended to skip all non-command events to allow the
  193. default handling to take place. The command events are, however, normally not
  194. skipped as usually a single command such as a button click or menu item
  195. selection must only be processed by one handler.
  196. */
  197. void Skip(bool skip = true);
  198. /**
  199. Stop the event from propagating to its parent window.
  200. Returns the old propagation level value which may be later passed to
  201. ResumePropagation() to allow propagating the event again.
  202. */
  203. int StopPropagation();
  204. protected:
  205. /**
  206. Indicates how many levels the event can propagate.
  207. This member is protected and should typically only be set in the constructors
  208. of the derived classes. It may be temporarily changed by StopPropagation()
  209. and ResumePropagation() and tested with ShouldPropagate().
  210. The initial value is set to either @c wxEVENT_PROPAGATE_NONE (by default)
  211. meaning that the event shouldn't be propagated at all or to
  212. @c wxEVENT_PROPAGATE_MAX (for command events) meaning that it should be
  213. propagated as much as necessary.
  214. Any positive number means that the event should be propagated but no more than
  215. the given number of times. E.g. the propagation level may be set to 1 to
  216. propagate the event to its parent only, but not to its grandparent.
  217. */
  218. int m_propagationLevel;
  219. };
  220. #endif // wxUSE_BASE
  221. #if wxUSE_GUI
  222. /**
  223. @class wxEventBlocker
  224. This class is a special event handler which allows to discard
  225. any event (or a set of event types) directed to a specific window.
  226. Example:
  227. @code
  228. void MyWindow::DoSomething()
  229. {
  230. {
  231. // block all events directed to this window while
  232. // we do the 1000 FunctionWhichSendsEvents() calls
  233. wxEventBlocker blocker(this);
  234. for ( int i = 0; i 1000; i++ )
  235. FunctionWhichSendsEvents(i);
  236. } // ~wxEventBlocker called, old event handler is restored
  237. // the event generated by this call will be processed:
  238. FunctionWhichSendsEvents(0)
  239. }
  240. @endcode
  241. @library{wxcore}
  242. @category{events}
  243. @see @ref overview_events_processing, wxEvtHandler
  244. */
  245. class wxEventBlocker : public wxEvtHandler
  246. {
  247. public:
  248. /**
  249. Constructs the blocker for the given window and for the given event type.
  250. If @a type is @c wxEVT_ANY, then all events for that window are blocked.
  251. You can call Block() after creation to add other event types to the list
  252. of events to block.
  253. Note that the @a win window @b must remain alive until the
  254. wxEventBlocker object destruction.
  255. */
  256. wxEventBlocker(wxWindow* win, wxEventType type = -1);
  257. /**
  258. Destructor. The blocker will remove itself from the chain of event handlers for
  259. the window provided in the constructor, thus restoring normal processing of events.
  260. */
  261. virtual ~wxEventBlocker();
  262. /**
  263. Adds to the list of event types which should be blocked the given @a eventType.
  264. */
  265. void Block(wxEventType eventType);
  266. };
  267. /**
  268. Helper class to temporarily change an event to not propagate.
  269. */
  270. class wxPropagationDisabler
  271. {
  272. public:
  273. wxPropagationDisabler(wxEvent& event);
  274. ~wxPropagationDisabler();
  275. };
  276. /**
  277. Helper class to temporarily lower propagation level.
  278. */
  279. class wxPropagateOnce
  280. {
  281. public:
  282. wxPropagateOnce(wxEvent& event);
  283. ~wxPropagateOnce();
  284. };
  285. #endif // wxUSE_GUI
  286. #if wxUSE_BASE
  287. /**
  288. @class wxEvtHandler
  289. A class that can handle events from the windowing system.
  290. wxWindow is (and therefore all window classes are) derived from this class.
  291. When events are received, wxEvtHandler invokes the method listed in the
  292. event table using itself as the object. When using multiple inheritance
  293. <b>it is imperative that the wxEvtHandler(-derived) class is the first
  294. class inherited</b> such that the @c this pointer for the overall object
  295. will be identical to the @c this pointer of the wxEvtHandler portion.
  296. @library{wxbase}
  297. @category{events}
  298. @see @ref overview_events_processing, wxEventBlocker, wxEventLoopBase
  299. */
  300. class wxEvtHandler : public wxObject, public wxTrackable
  301. {
  302. public:
  303. /**
  304. Constructor.
  305. */
  306. wxEvtHandler();
  307. /**
  308. Destructor.
  309. If the handler is part of a chain, the destructor will unlink itself
  310. (see Unlink()).
  311. */
  312. virtual ~wxEvtHandler();
  313. /**
  314. @name Event queuing and processing
  315. */
  316. //@{
  317. /**
  318. Queue event for a later processing.
  319. This method is similar to ProcessEvent() but while the latter is
  320. synchronous, i.e. the event is processed immediately, before the
  321. function returns, this one is asynchronous and returns immediately
  322. while the event will be processed at some later time (usually during
  323. the next event loop iteration).
  324. Another important difference is that this method takes ownership of the
  325. @a event parameter, i.e. it will delete it itself. This implies that
  326. the event should be allocated on the heap and that the pointer can't be
  327. used any more after the function returns (as it can be deleted at any
  328. moment).
  329. QueueEvent() can be used for inter-thread communication from the worker
  330. threads to the main thread, it is safe in the sense that it uses
  331. locking internally and avoids the problem mentioned in AddPendingEvent()
  332. documentation by ensuring that the @a event object is not used by the
  333. calling thread any more. Care should still be taken to avoid that some
  334. fields of this object are used by it, notably any wxString members of
  335. the event object must not be shallow copies of another wxString object
  336. as this would result in them still using the same string buffer behind
  337. the scenes. For example:
  338. @code
  339. void FunctionInAWorkerThread(const wxString& str)
  340. {
  341. wxCommandEvent* evt = new wxCommandEvent;
  342. // NOT evt->SetString(str) as this would be a shallow copy
  343. evt->SetString(str.c_str()); // make a deep copy
  344. wxTheApp->QueueEvent( evt );
  345. }
  346. @endcode
  347. Note that you can use wxThreadEvent instead of wxCommandEvent
  348. to avoid this problem:
  349. @code
  350. void FunctionInAWorkerThread(const wxString& str)
  351. {
  352. wxThreadEvent evt;
  353. evt->SetString(str);
  354. // wxThreadEvent::Clone() makes sure that the internal wxString
  355. // member is not shared by other wxString instances:
  356. wxTheApp->QueueEvent( evt.Clone() );
  357. }
  358. @endcode
  359. Finally notice that this method automatically wakes up the event loop
  360. if it is currently idle by calling ::wxWakeUpIdle() so there is no need
  361. to do it manually when using it.
  362. @since 2.9.0
  363. @param event
  364. A heap-allocated event to be queued, QueueEvent() takes ownership
  365. of it. This parameter shouldn't be @c NULL.
  366. */
  367. virtual void QueueEvent(wxEvent *event);
  368. /**
  369. Post an event to be processed later.
  370. This function is similar to QueueEvent() but can't be used to post
  371. events from worker threads for the event objects with wxString fields
  372. (i.e. in practice most of them) because of an unsafe use of the same
  373. wxString object which happens because the wxString field in the
  374. original @a event object and its copy made internally by this function
  375. share the same string buffer internally. Use QueueEvent() to avoid
  376. this.
  377. A copy of @a event is made by the function, so the original can be deleted
  378. as soon as function returns (it is common that the original is created
  379. on the stack). This requires that the wxEvent::Clone() method be
  380. implemented by event so that it can be duplicated and stored until it
  381. gets processed.
  382. @param event
  383. Event to add to the pending events queue.
  384. */
  385. virtual void AddPendingEvent(const wxEvent& event);
  386. /**
  387. Asynchronously call the given method.
  388. Calling this function on an object schedules an asynchronous call to
  389. the method specified as CallAfter() argument at a (slightly) later
  390. time. This is useful when processing some events as certain actions
  391. typically can't be performed inside their handlers, e.g. you shouldn't
  392. show a modal dialog from a mouse click event handler as this would
  393. break the mouse capture state -- but you can call a method showing
  394. this message dialog after the current event handler completes.
  395. The method being called must be the method of the object on which
  396. CallAfter() itself is called.
  397. Notice that it is safe to use CallAfter() from other, non-GUI,
  398. threads, but that the method will be always called in the main, GUI,
  399. thread context.
  400. Example of use:
  401. @code
  402. class MyFrame : public wxFrame {
  403. void OnClick(wxMouseEvent& event) {
  404. CallAfter(&MyFrame::ShowPosition, event.GetPosition());
  405. }
  406. void ShowPosition(const wxPoint& pos) {
  407. if ( wxMessageBox(
  408. wxString::Format("Perform click at (%d, %d)?",
  409. pos.x, pos.y), "", wxYES_NO) == wxYES )
  410. {
  411. ... do take this click into account ...
  412. }
  413. }
  414. };
  415. @endcode
  416. @param method The method to call.
  417. @param x1 The (optional) first parameter to pass to the method.
  418. Currently, 0, 1 or 2 parameters can be passed. If you need to pass
  419. more than 2 arguments, you can use the CallAfter<T>(const T& fn)
  420. overload that can call any functor.
  421. @note This method is not available with Visual C++ before version 8
  422. (Visual Studio 2005) as earlier versions of the compiler don't
  423. have the required support for C++ templates to implement it.
  424. @since 2.9.5
  425. */
  426. template<typename T, typename T1, ...>
  427. void CallAfter(void (T::*method)(T1, ...), T1 x1, ...);
  428. /**
  429. Asynchronously call the given functor.
  430. Calling this function on an object schedules an asynchronous call to
  431. the functor specified as CallAfter() argument at a (slightly) later
  432. time. This is useful when processing some events as certain actions
  433. typically can't be performed inside their handlers, e.g. you shouldn't
  434. show a modal dialog from a mouse click event handler as this would
  435. break the mouse capture state -- but you can call a function showing
  436. this message dialog after the current event handler completes.
  437. Notice that it is safe to use CallAfter() from other, non-GUI,
  438. threads, but that the method will be always called in the main, GUI,
  439. thread context.
  440. This overload is particularly useful in combination with C++11 lambdas:
  441. @code
  442. wxGetApp().CallAfter([]{
  443. wxBell();
  444. });
  445. @endcode
  446. @param functor The functor to call.
  447. @note This method is not available with Visual C++ before version 8
  448. (Visual Studio 2005) as earlier versions of the compiler don't
  449. have the required support for C++ templates to implement it.
  450. @since 3.0
  451. */
  452. template<typename T>
  453. void CallAfter(const T& functor);
  454. /**
  455. Processes an event, searching event tables and calling zero or more suitable
  456. event handler function(s).
  457. Normally, your application would not call this function: it is called in the
  458. wxWidgets implementation to dispatch incoming user interface events to the
  459. framework (and application).
  460. However, you might need to call it if implementing new functionality
  461. (such as a new control) where you define new event types, as opposed to
  462. allowing the user to override virtual functions.
  463. Notice that you don't usually need to override ProcessEvent() to
  464. customize the event handling, overriding the specially provided
  465. TryBefore() and TryAfter() functions is usually enough. For example,
  466. wxMDIParentFrame may override TryBefore() to ensure that the menu
  467. events are processed in the active child frame before being processed
  468. in the parent frame itself.
  469. The normal order of event table searching is as follows:
  470. -# wxApp::FilterEvent() is called. If it returns anything but @c -1
  471. (default) the processing stops here.
  472. -# TryBefore() is called (this is where wxValidator are taken into
  473. account for wxWindow objects). If this returns @true, the function exits.
  474. -# If the object is disabled (via a call to wxEvtHandler::SetEvtHandlerEnabled)
  475. the function skips to step (7).
  476. -# Dynamic event table of the handlers bound using Bind<>() is
  477. searched. If a handler is found, it is executed and the function
  478. returns @true unless the handler used wxEvent::Skip() to indicate
  479. that it didn't handle the event in which case the search continues.
  480. -# Static events table of the handlers bound using event table
  481. macros is searched for this event handler. If this fails, the base
  482. class event table is tried, and so on until no more tables
  483. exist or an appropriate function was found. If a handler is found,
  484. the same logic as in the previous step applies.
  485. -# The search is applied down the entire chain of event handlers (usually the
  486. chain has a length of one). This chain can be formed using wxEvtHandler::SetNextHandler():
  487. @image html overview_events_chain.png
  488. (referring to the image, if @c A->ProcessEvent is called and it doesn't handle
  489. the event, @c B->ProcessEvent will be called and so on...).
  490. Note that in the case of wxWindow you can build a stack of event handlers
  491. (see wxWindow::PushEventHandler() for more info).
  492. If any of the handlers of the chain return @true, the function exits.
  493. -# TryAfter() is called: for the wxWindow object this may propagate the
  494. event to the window parent (recursively). If the event is still not
  495. processed, ProcessEvent() on wxTheApp object is called as the last
  496. step.
  497. Notice that steps (2)-(6) are performed in ProcessEventLocally()
  498. which is called by this function.
  499. @param event
  500. Event to process.
  501. @return
  502. @true if a suitable event handler function was found and executed,
  503. and the function did not call wxEvent::Skip.
  504. @see SearchEventTable()
  505. */
  506. virtual bool ProcessEvent(wxEvent& event);
  507. /**
  508. Try to process the event in this handler and all those chained to it.
  509. As explained in ProcessEvent() documentation, the event handlers may be
  510. chained in a doubly-linked list. This function tries to process the
  511. event in this handler (including performing any pre-processing done in
  512. TryBefore(), e.g. applying validators) and all those following it in
  513. the chain until the event is processed or the chain is exhausted.
  514. This function is called from ProcessEvent() and, in turn, calls
  515. TryBefore() and TryAfter(). It is not virtual and so cannot be
  516. overridden but can, and should, be called to forward an event to
  517. another handler instead of ProcessEvent() which would result in a
  518. duplicate call to TryAfter(), e.g. resulting in all unprocessed events
  519. being sent to the application object multiple times.
  520. @since 2.9.1
  521. @param event
  522. Event to process.
  523. @return
  524. @true if this handler of one of those chained to it processed the
  525. event.
  526. */
  527. bool ProcessEventLocally(wxEvent& event);
  528. /**
  529. Processes an event by calling ProcessEvent() and handles any exceptions
  530. that occur in the process.
  531. If an exception is thrown in event handler, wxApp::OnExceptionInMainLoop is called.
  532. @param event
  533. Event to process.
  534. @return @true if the event was processed, @false if no handler was found
  535. or an exception was thrown.
  536. @see wxWindow::HandleWindowEvent
  537. */
  538. bool SafelyProcessEvent(wxEvent& event);
  539. /**
  540. Processes the pending events previously queued using QueueEvent() or
  541. AddPendingEvent(); you must call this function only if you are sure
  542. there are pending events for this handler, otherwise a @c wxCHECK
  543. will fail.
  544. The real processing still happens in ProcessEvent() which is called by this
  545. function.
  546. Note that this function needs a valid application object (see
  547. wxAppConsole::GetInstance()) because wxApp holds the list of the event
  548. handlers with pending events and this function manipulates that list.
  549. */
  550. void ProcessPendingEvents();
  551. /**
  552. Deletes all events queued on this event handler using QueueEvent() or
  553. AddPendingEvent().
  554. Use with care because the events which are deleted are (obviously) not
  555. processed and this may have unwanted consequences (e.g. user actions events
  556. will be lost).
  557. */
  558. void DeletePendingEvents();
  559. /**
  560. Searches the event table, executing an event handler function if an appropriate
  561. one is found.
  562. @param table
  563. Event table to be searched.
  564. @param event
  565. Event to be matched against an event table entry.
  566. @return @true if a suitable event handler function was found and
  567. executed, and the function did not call wxEvent::Skip.
  568. @remarks This function looks through the object's event table and tries
  569. to find an entry that will match the event.
  570. An entry will match if:
  571. @li The event type matches, and
  572. @li the identifier or identifier range matches, or the event table
  573. entry's identifier is zero.
  574. If a suitable function is called but calls wxEvent::Skip, this
  575. function will fail, and searching will continue.
  576. @todo this function in the header is listed as an "implementation only" function;
  577. are we sure we want to document it?
  578. @see ProcessEvent()
  579. */
  580. virtual bool SearchEventTable(wxEventTable& table,
  581. wxEvent& event);
  582. //@}
  583. /**
  584. @name Connecting and disconnecting
  585. */
  586. //@{
  587. /**
  588. Connects the given function dynamically with the event handler, id and
  589. event type.
  590. Notice that Bind() provides a more flexible and safer way to do the
  591. same thing as Connect(), please use it in any new code -- while
  592. Connect() is not formally deprecated due to its existing widespread
  593. usage, it has no advantages compared to Bind().
  594. This is an alternative to the use of static event tables. It is more
  595. flexible as it allows to connect events generated by some object to an
  596. event handler defined in a different object of a different class (which
  597. is impossible to do directly with the event tables -- the events can be
  598. only handled in another object if they are propagated upwards to it).
  599. Do make sure to specify the correct @a eventSink when connecting to an
  600. event of a different object.
  601. See @ref overview_events_bind for more detailed explanation
  602. of this function and the @ref page_samples_event sample for usage
  603. examples.
  604. This specific overload allows you to connect an event handler to a @e range
  605. of @e source IDs.
  606. Do not confuse @e source IDs with event @e types: source IDs identify the
  607. event generator objects (typically wxMenuItem or wxWindow objects) while the
  608. event @e type identify which type of events should be handled by the
  609. given @e function (an event generator object may generate many different
  610. types of events!).
  611. @param id
  612. The first ID of the identifier range to be associated with the event
  613. handler function.
  614. @param lastId
  615. The last ID of the identifier range to be associated with the event
  616. handler function.
  617. @param eventType
  618. The event type to be associated with this event handler.
  619. @param function
  620. The event handler function. Note that this function should
  621. be explicitly converted to the correct type which can be done using a macro
  622. called @c wxFooEventHandler for the handler for any @c wxFooEvent.
  623. @param userData
  624. Optional data to be associated with the event table entry.
  625. wxWidgets will take ownership of this pointer, i.e. it will be
  626. destroyed when the event handler is disconnected or at the program
  627. termination. This pointer can be retrieved using
  628. wxEvent::GetEventUserData() later.
  629. @param eventSink
  630. Object whose member function should be called. It must be specified
  631. when connecting an event generated by one object to a member
  632. function of a different object. If it is omitted, @c this is used.
  633. @beginWxPerlOnly
  634. In wxPerl this function takes 4 arguments: @a id, @a lastid,
  635. @a type, @a method; if @a method is undef, the handler is
  636. disconnected.}
  637. @endWxPerlOnly
  638. @see Bind<>()
  639. */
  640. void Connect(int id, int lastId, wxEventType eventType,
  641. wxObjectEventFunction function,
  642. wxObject* userData = NULL,
  643. wxEvtHandler* eventSink = NULL);
  644. /**
  645. See the Connect(int, int, wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*)
  646. overload for more info.
  647. This overload can be used to attach an event handler to a single source ID:
  648. Example:
  649. @code
  650. frame->Connect( wxID_EXIT,
  651. wxEVT_MENU,
  652. wxCommandEventHandler(MyFrame::OnQuit) );
  653. @endcode
  654. @beginWxPerlOnly
  655. Not supported by wxPerl.
  656. @endWxPerlOnly
  657. */
  658. void Connect(int id, wxEventType eventType,
  659. wxObjectEventFunction function,
  660. wxObject* userData = NULL,
  661. wxEvtHandler* eventSink = NULL);
  662. /**
  663. See the Connect(int, int, wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*)
  664. overload for more info.
  665. This overload will connect the given event handler so that regardless of the
  666. ID of the event source, the handler will be called.
  667. @beginWxPerlOnly
  668. Not supported by wxPerl.
  669. @endWxPerlOnly
  670. */
  671. void Connect(wxEventType eventType,
  672. wxObjectEventFunction function,
  673. wxObject* userData = NULL,
  674. wxEvtHandler* eventSink = NULL);
  675. /**
  676. Disconnects the given function dynamically from the event handler, using the
  677. specified parameters as search criteria and returning @true if a matching
  678. function has been found and removed.
  679. This method can only disconnect functions which have been added using the
  680. Connect() method. There is no way to disconnect functions connected using
  681. the (static) event tables.
  682. @param eventType
  683. The event type associated with this event handler.
  684. @param function
  685. The event handler function.
  686. @param userData
  687. Data associated with the event table entry.
  688. @param eventSink
  689. Object whose member function should be called.
  690. @beginWxPerlOnly
  691. Not supported by wxPerl.
  692. @endWxPerlOnly
  693. */
  694. bool Disconnect(wxEventType eventType,
  695. wxObjectEventFunction function,
  696. wxObject* userData = NULL,
  697. wxEvtHandler* eventSink = NULL);
  698. /**
  699. See the Disconnect(wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*)
  700. overload for more info.
  701. This overload takes the additional @a id parameter.
  702. @beginWxPerlOnly
  703. Not supported by wxPerl.
  704. @endWxPerlOnly
  705. */
  706. bool Disconnect(int id = wxID_ANY,
  707. wxEventType eventType = wxEVT_NULL,
  708. wxObjectEventFunction function = NULL,
  709. wxObject* userData = NULL,
  710. wxEvtHandler* eventSink = NULL);
  711. /**
  712. See the Disconnect(wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*)
  713. overload for more info.
  714. This overload takes an additional range of source IDs.
  715. @beginWxPerlOnly
  716. In wxPerl this function takes 3 arguments: @a id,
  717. @a lastid, @a type.
  718. @endWxPerlOnly
  719. */
  720. bool Disconnect(int id, int lastId,
  721. wxEventType eventType,
  722. wxObjectEventFunction function = NULL,
  723. wxObject* userData = NULL,
  724. wxEvtHandler* eventSink = NULL);
  725. //@}
  726. /**
  727. @name Binding and Unbinding
  728. */
  729. //@{
  730. /**
  731. Binds the given function, functor or method dynamically with the event.
  732. This offers basically the same functionality as Connect(), but it is
  733. more flexible as it also allows you to use ordinary functions and
  734. arbitrary functors as event handlers. It is also less restrictive then
  735. Connect() because you can use an arbitrary method as an event handler,
  736. whereas Connect() requires a wxEvtHandler derived handler.
  737. See @ref overview_events_bind for more detailed explanation
  738. of this function and the @ref page_samples_event sample for usage
  739. examples.
  740. @param eventType
  741. The event type to be associated with this event handler.
  742. @param functor
  743. The event handler functor. This can be an ordinary function but also
  744. an arbitrary functor like boost::function<>.
  745. @param id
  746. The first ID of the identifier range to be associated with the event
  747. handler.
  748. @param lastId
  749. The last ID of the identifier range to be associated with the event
  750. handler.
  751. @param userData
  752. Optional data to be associated with the event table entry.
  753. wxWidgets will take ownership of this pointer, i.e. it will be
  754. destroyed when the event handler is disconnected or at the program
  755. termination. This pointer can be retrieved using
  756. wxEvent::GetEventUserData() later.
  757. @see @ref overview_cpp_rtti_disabled
  758. @since 2.9.0
  759. */
  760. template <typename EventTag, typename Functor>
  761. void Bind(const EventTag& eventType,
  762. Functor functor,
  763. int id = wxID_ANY,
  764. int lastId = wxID_ANY,
  765. wxObject *userData = NULL);
  766. /**
  767. See the Bind<>(const EventTag&, Functor, int, int, wxObject*) overload for
  768. more info.
  769. This overload will bind the given method as the event handler.
  770. @param eventType
  771. The event type to be associated with this event handler.
  772. @param method
  773. The event handler method. This can be an arbitrary method (doesn't need
  774. to be from a wxEvtHandler derived class).
  775. @param handler
  776. Object whose method should be called. It must always be specified
  777. so it can be checked at compile time whether the given method is an
  778. actual member of the given handler.
  779. @param id
  780. The first ID of the identifier range to be associated with the event
  781. handler.
  782. @param lastId
  783. The last ID of the identifier range to be associated with the event
  784. handler.
  785. @param userData
  786. Optional data to be associated with the event table entry.
  787. wxWidgets will take ownership of this pointer, i.e. it will be
  788. destroyed when the event handler is disconnected or at the program
  789. termination. This pointer can be retrieved using
  790. wxEvent::GetEventUserData() later.
  791. @see @ref overview_cpp_rtti_disabled
  792. @since 2.9.0
  793. */
  794. template <typename EventTag, typename Class, typename EventArg, typename EventHandler>
  795. void Bind(const EventTag &eventType,
  796. void (Class::*method)(EventArg &),
  797. EventHandler *handler,
  798. int id = wxID_ANY,
  799. int lastId = wxID_ANY,
  800. wxObject *userData = NULL);
  801. /**
  802. Unbinds the given function, functor or method dynamically from the
  803. event handler, using the specified parameters as search criteria and
  804. returning @true if a matching function has been found and removed.
  805. This method can only unbind functions, functors or methods which have
  806. been added using the Bind<>() method. There is no way to unbind
  807. functions bound using the (static) event tables.
  808. @param eventType
  809. The event type associated with this event handler.
  810. @param functor
  811. The event handler functor. This can be an ordinary function but also
  812. an arbitrary functor like boost::function<>.
  813. @param id
  814. The first ID of the identifier range associated with the event
  815. handler.
  816. @param lastId
  817. The last ID of the identifier range associated with the event
  818. handler.
  819. @param userData
  820. Data associated with the event table entry.
  821. @see @ref overview_cpp_rtti_disabled
  822. @since 2.9.0
  823. */
  824. template <typename EventTag, typename Functor>
  825. bool Unbind(const EventTag& eventType,
  826. Functor functor,
  827. int id = wxID_ANY,
  828. int lastId = wxID_ANY,
  829. wxObject *userData = NULL);
  830. /**
  831. See the Unbind<>(const EventTag&, Functor, int, int, wxObject*)
  832. overload for more info.
  833. This overload unbinds the given method from the event..
  834. @param eventType
  835. The event type associated with this event handler.
  836. @param method
  837. The event handler method associated with this event.
  838. @param handler
  839. Object whose method was called.
  840. @param id
  841. The first ID of the identifier range associated with the event
  842. handler.
  843. @param lastId
  844. The last ID of the identifier range associated with the event
  845. handler.
  846. @param userData
  847. Data associated with the event table entry.
  848. @see @ref overview_cpp_rtti_disabled
  849. @since 2.9.0
  850. */
  851. template <typename EventTag, typename Class, typename EventArg, typename EventHandler>
  852. bool Unbind(const EventTag &eventType,
  853. void (Class::*method)(EventArg&),
  854. EventHandler *handler,
  855. int id = wxID_ANY,
  856. int lastId = wxID_ANY,
  857. wxObject *userData = NULL );
  858. //@}
  859. /**
  860. @name User-supplied data
  861. */
  862. //@{
  863. /**
  864. Returns user-supplied client data.
  865. @remarks Normally, any extra data the programmer wishes to associate with
  866. the object should be made available by deriving a new class with
  867. new data members.
  868. @see SetClientData()
  869. */
  870. void* GetClientData() const;
  871. /**
  872. Returns a pointer to the user-supplied client data object.
  873. @see SetClientObject(), wxClientData
  874. */
  875. wxClientData* GetClientObject() const;
  876. /**
  877. Sets user-supplied client data.
  878. @param data
  879. Data to be associated with the event handler.
  880. @remarks Normally, any extra data the programmer wishes to associate
  881. with the object should be made available by deriving a new
  882. class with new data members. You must not call this method
  883. and SetClientObject on the same class - only one of them.
  884. @see GetClientData()
  885. */
  886. void SetClientData(void* data);
  887. /**
  888. Set the client data object. Any previous object will be deleted.
  889. @see GetClientObject(), wxClientData
  890. */
  891. void SetClientObject(wxClientData* data);
  892. //@}
  893. /**
  894. @name Event handler chaining
  895. wxEvtHandler can be arranged in a double-linked list of handlers
  896. which is automatically iterated by ProcessEvent() if needed.
  897. */
  898. //@{
  899. /**
  900. Returns @true if the event handler is enabled, @false otherwise.
  901. @see SetEvtHandlerEnabled()
  902. */
  903. bool GetEvtHandlerEnabled() const;
  904. /**
  905. Returns the pointer to the next handler in the chain.
  906. @see SetNextHandler(), GetPreviousHandler(), SetPreviousHandler(),
  907. wxWindow::PushEventHandler, wxWindow::PopEventHandler
  908. */
  909. wxEvtHandler* GetNextHandler() const;
  910. /**
  911. Returns the pointer to the previous handler in the chain.
  912. @see SetPreviousHandler(), GetNextHandler(), SetNextHandler(),
  913. wxWindow::PushEventHandler, wxWindow::PopEventHandler
  914. */
  915. wxEvtHandler* GetPreviousHandler() const;
  916. /**
  917. Enables or disables the event handler.
  918. @param enabled
  919. @true if the event handler is to be enabled, @false if it is to be disabled.
  920. @remarks You can use this function to avoid having to remove the event
  921. handler from the chain, for example when implementing a
  922. dialog editor and changing from edit to test mode.
  923. @see GetEvtHandlerEnabled()
  924. */
  925. void SetEvtHandlerEnabled(bool enabled);
  926. /**
  927. Sets the pointer to the next handler.
  928. @remarks
  929. See ProcessEvent() for more info about how the chains of event handlers
  930. are internally used.
  931. Also remember that wxEvtHandler uses double-linked lists and thus if you
  932. use this function, you should also call SetPreviousHandler() on the
  933. argument passed to this function:
  934. @code
  935. handlerA->SetNextHandler(handlerB);
  936. handlerB->SetPreviousHandler(handlerA);
  937. @endcode
  938. @param handler
  939. The event handler to be set as the next handler.
  940. Cannot be @NULL.
  941. @see @ref overview_events_processing
  942. */
  943. virtual void SetNextHandler(wxEvtHandler* handler);
  944. /**
  945. Sets the pointer to the previous handler.
  946. All remarks about SetNextHandler() apply to this function as well.
  947. @param handler
  948. The event handler to be set as the previous handler.
  949. Cannot be @NULL.
  950. @see @ref overview_events_processing
  951. */
  952. virtual void SetPreviousHandler(wxEvtHandler* handler);
  953. /**
  954. Unlinks this event handler from the chain it's part of (if any);
  955. then links the "previous" event handler to the "next" one
  956. (so that the chain won't be interrupted).
  957. E.g. if before calling Unlink() you have the following chain:
  958. @image html evthandler_unlink_before.png
  959. then after calling @c B->Unlink() you'll have:
  960. @image html evthandler_unlink_after.png
  961. @since 2.9.0
  962. */
  963. void Unlink();
  964. /**
  965. Returns @true if the next and the previous handler pointers of this
  966. event handler instance are @NULL.
  967. @since 2.9.0
  968. @see SetPreviousHandler(), SetNextHandler()
  969. */
  970. bool IsUnlinked() const;
  971. //@}
  972. /**
  973. @name Global event filters.
  974. Methods for working with the global list of event filters.
  975. Event filters can be defined to pre-process all the events that happen
  976. in an application, see wxEventFilter documentation for more information.
  977. */
  978. //@{
  979. /**
  980. Add an event filter whose FilterEvent() method will be called for each
  981. and every event processed by wxWidgets.
  982. The filters are called in LIFO order and wxApp is registered as an
  983. event filter by default. The pointer must remain valid until it's
  984. removed with RemoveFilter() and is not deleted by wxEvtHandler.
  985. @since 2.9.3
  986. */
  987. static void AddFilter(wxEventFilter* filter);
  988. /**
  989. Remove a filter previously installed with AddFilter().
  990. It's an error to remove a filter that hadn't been previously added or
  991. was already removed.
  992. @since 2.9.3
  993. */
  994. static void RemoveFilter(wxEventFilter* filter);
  995. //@}
  996. protected:
  997. /**
  998. Method called by ProcessEvent() before examining this object event
  999. tables.
  1000. This method can be overridden to hook into the event processing logic
  1001. as early as possible. You should usually call the base class version
  1002. when overriding this method, even if wxEvtHandler itself does nothing
  1003. here, some derived classes do use this method, e.g. wxWindow implements
  1004. support for wxValidator in it.
  1005. Example:
  1006. @code
  1007. class MyClass : public BaseClass // inheriting from wxEvtHandler
  1008. {
  1009. ...
  1010. protected:
  1011. virtual bool TryBefore(wxEvent& event)
  1012. {
  1013. if ( MyPreProcess(event) )
  1014. return true;
  1015. return BaseClass::TryBefore(event);
  1016. }
  1017. };
  1018. @endcode
  1019. @see ProcessEvent()
  1020. */
  1021. virtual bool TryBefore(wxEvent& event);
  1022. /**
  1023. Method called by ProcessEvent() as last resort.
  1024. This method can be overridden to implement post-processing for the
  1025. events which were not processed anywhere else.
  1026. The base class version handles forwarding the unprocessed events to
  1027. wxApp at wxEvtHandler level and propagating them upwards the window
  1028. child-parent chain at wxWindow level and so should usually be called
  1029. when overriding this method:
  1030. @code
  1031. class MyClass : public BaseClass // inheriting from wxEvtHandler
  1032. {
  1033. ...
  1034. protected:
  1035. virtual bool TryAfter(wxEvent& event)
  1036. {
  1037. if ( BaseClass::TryAfter(event) )
  1038. return true;
  1039. return MyPostProcess(event);
  1040. }
  1041. };
  1042. @endcode
  1043. @see ProcessEvent()
  1044. */
  1045. virtual bool TryAfter(wxEvent& event);
  1046. };
  1047. #endif // wxUSE_BASE
  1048. #if wxUSE_GUI
  1049. /**
  1050. Flags for categories of keys.
  1051. These values are used by wxKeyEvent::IsKeyInCategory(). They may be
  1052. combined via the bitwise operators |, &, and ~.
  1053. @since 2.9.1
  1054. */
  1055. enum wxKeyCategoryFlags
  1056. {
  1057. /// arrow keys, on and off numeric keypads
  1058. WXK_CATEGORY_ARROW,
  1059. /// page up and page down keys, on and off numeric keypads
  1060. WXK_CATEGORY_PAGING,
  1061. /// home and end keys, on and off numeric keypads
  1062. WXK_CATEGORY_JUMP,
  1063. /// tab key, on and off numeric keypads
  1064. WXK_CATEGORY_TAB,
  1065. /// backspace and delete keys, on and off numeric keypads
  1066. WXK_CATEGORY_CUT,
  1067. /// union of WXK_CATEGORY_ARROW, WXK_CATEGORY_PAGING, and WXK_CATEGORY_JUMP categories
  1068. WXK_CATEGORY_NAVIGATION
  1069. };
  1070. /**
  1071. @class wxKeyEvent
  1072. This event class contains information about key press and release events.
  1073. The main information carried by this event is the key being pressed or
  1074. released. It can be accessed using either GetKeyCode() function or
  1075. GetUnicodeKey(). For the printable characters, the latter should be used as
  1076. it works for any keys, including non-Latin-1 characters that can be entered
  1077. when using national keyboard layouts. GetKeyCode() should be used to handle
  1078. special characters (such as cursor arrows keys or @c HOME or @c INS and so
  1079. on) which correspond to ::wxKeyCode enum elements above the @c WXK_START
  1080. constant. While GetKeyCode() also returns the character code for Latin-1
  1081. keys for compatibility, it doesn't work for Unicode characters in general
  1082. and will return @c WXK_NONE for any non-Latin-1 ones. For this reason, it's
  1083. recommended to always use GetUnicodeKey() and only fall back to GetKeyCode()
  1084. if GetUnicodeKey() returned @c WXK_NONE meaning that the event corresponds
  1085. to a non-printable special keys.
  1086. While both of these functions can be used with the events of @c
  1087. wxEVT_KEY_DOWN, @c wxEVT_KEY_UP and @c wxEVT_CHAR types, the values
  1088. returned by them are different for the first two events and the last one.
  1089. For the latter, the key returned corresponds to the character that would
  1090. appear in e.g. a text zone if the user pressed the key in it. As such, its
  1091. value depends on the current state of the Shift key and, for the letters,
  1092. on the state of Caps Lock modifier. For example, if @c A key is pressed
  1093. without Shift being held down, wxKeyEvent of type @c wxEVT_CHAR generated
  1094. for this key press will return (from either GetKeyCode() or GetUnicodeKey()
  1095. as their meanings coincide for ASCII characters) key code of 97
  1096. corresponding the ASCII value of @c a. And if the same key is pressed but
  1097. with Shift being held (or Caps Lock being active), then the key could would
  1098. be 65, i.e. ASCII value of capital @c A.
  1099. However for the key down and up events the returned key code will instead
  1100. be @c A independently of the state of the modifier keys i.e. it depends
  1101. only on physical key being pressed and is not translated to its logical
  1102. representation using the current keyboard state. Such untranslated key
  1103. codes are defined as follows:
  1104. - For the letters they correspond to the @e upper case value of the
  1105. letter.
  1106. - For the other alphanumeric keys (e.g. @c 7 or @c +), the untranslated
  1107. key code corresponds to the character produced by the key when it is
  1108. pressed without Shift. E.g. in standard US keyboard layout the
  1109. untranslated key code for the key @c =/+ in the upper right corner of
  1110. the keyboard is 61 which is the ASCII value of @c =.
  1111. - For the rest of the keys (i.e. special non-printable keys) it is the
  1112. same as the normal key code as no translation is used anyhow.
  1113. Notice that the first rule applies to all Unicode letters, not just the
  1114. usual Latin-1 ones. However for non-Latin-1 letters only GetUnicodeKey()
  1115. can be used to retrieve the key code as GetKeyCode() just returns @c
  1116. WXK_NONE in this case.
  1117. To summarize: you should handle @c wxEVT_CHAR if you need the translated
  1118. key and @c wxEVT_KEY_DOWN if you only need the value of the key itself,
  1119. independent of the current keyboard state.
  1120. @note Not all key down events may be generated by the user. As an example,
  1121. @c wxEVT_KEY_DOWN with @c = key code can be generated using the
  1122. standard US keyboard layout but not using the German one because the @c
  1123. = key corresponds to Shift-0 key combination in this layout and the key
  1124. code for it is @c 0, not @c =. Because of this you should avoid
  1125. requiring your users to type key events that might be impossible to
  1126. enter on their keyboard.
  1127. Another difference between key and char events is that another kind of
  1128. translation is done for the latter ones when the Control key is pressed:
  1129. char events for ASCII letters in this case carry codes corresponding to the
  1130. ASCII value of Ctrl-Latter, i.e. 1 for Ctrl-A, 2 for Ctrl-B and so on until
  1131. 26 for Ctrl-Z. This is convenient for terminal-like applications and can be
  1132. completely ignored by all the other ones (if you need to handle Ctrl-A it
  1133. is probably a better idea to use the key event rather than the char one).
  1134. Notice that currently no translation is done for the presses of @c [, @c
  1135. \\, @c ], @c ^ and @c _ keys which might be mapped to ASCII values from 27
  1136. to 31.
  1137. Since version 2.9.2, the enum values @c WXK_CONTROL_A - @c WXK_CONTROL_Z
  1138. can be used instead of the non-descriptive constant values 1-26.
  1139. Finally, modifier keys only generate key events but no char events at all.
  1140. The modifiers keys are @c WXK_SHIFT, @c WXK_CONTROL, @c WXK_ALT and various
  1141. @c WXK_WINDOWS_XXX from ::wxKeyCode enum.
  1142. Modifier keys events are special in one additional aspect: usually the
  1143. keyboard state associated with a key press is well defined, e.g.
  1144. wxKeyboardState::ShiftDown() returns @c true only if the Shift key was held
  1145. pressed when the key that generated this event itself was pressed. There is
  1146. an ambiguity for the key press events for Shift key itself however. By
  1147. convention, it is considered to be already pressed when it is pressed and
  1148. already released when it is released. In other words, @c wxEVT_KEY_DOWN
  1149. event for the Shift key itself will have @c wxMOD_SHIFT in GetModifiers()
  1150. and ShiftDown() will return true while the @c wxEVT_KEY_UP event for Shift
  1151. itself will not have @c wxMOD_SHIFT in its modifiers and ShiftDown() will
  1152. return false.
  1153. @b Tip: You may discover the key codes and modifiers generated by all the
  1154. keys on your system interactively by running the @ref
  1155. page_samples_keyboard wxWidgets sample and pressing some keys in it.
  1156. @note If a key down (@c EVT_KEY_DOWN) event is caught and the event handler
  1157. does not call @c event.Skip() then the corresponding char event
  1158. (@c EVT_CHAR) will not happen. This is by design and enables the
  1159. programs that handle both types of events to avoid processing the
  1160. same key twice. As a consequence, if you do not want to suppress the
  1161. @c wxEVT_CHAR events for the keys you handle, always call @c
  1162. event.Skip() in your @c wxEVT_KEY_DOWN handler. Not doing may also
  1163. prevent accelerators defined using this key from working.
  1164. @note If a key is maintained in a pressed state, you will typically get a
  1165. lot of (automatically generated) key down events but only one key up
  1166. one at the end when the key is released so it is wrong to assume that
  1167. there is one up event corresponding to each down one.
  1168. @note For Windows programmers: The key and char events in wxWidgets are
  1169. similar to but slightly different from Windows @c WM_KEYDOWN and
  1170. @c WM_CHAR events. In particular, Alt-x combination will generate a
  1171. char event in wxWidgets (unless it is used as an accelerator) and
  1172. almost all keys, including ones without ASCII equivalents, generate
  1173. char events too.
  1174. @beginEventTable{wxKeyEvent}
  1175. @event{EVT_KEY_DOWN(func)}
  1176. Process a @c wxEVT_KEY_DOWN event (any key has been pressed). If this
  1177. event is handled and not skipped, @c wxEVT_CHAR will not be generated
  1178. at all for this key press (but @c wxEVT_KEY_UP will be).
  1179. @event{EVT_KEY_UP(func)}
  1180. Process a @c wxEVT_KEY_UP event (any key has been released).
  1181. @event{EVT_CHAR(func)}
  1182. Process a @c wxEVT_CHAR event.
  1183. @event{EVT_CHAR_HOOK(func)}
  1184. Process a @c wxEVT_CHAR_HOOK event. Unlike all the other key events,
  1185. this event is propagated upwards the window hierarchy which allows
  1186. intercepting it in the parent window of the focused window to which it
  1187. is sent initially (if there is no focused window, this event is sent to
  1188. the wxApp global object). It is also generated before any other key
  1189. events and so gives the parent window an opportunity to modify the
  1190. keyboard handling of its children, e.g. it is used internally by
  1191. wxWidgets in some ports to intercept pressing Esc key in any child of a
  1192. dialog to close the dialog itself when it's pressed. By default, if
  1193. this event is handled, i.e. the handler doesn't call wxEvent::Skip(),
  1194. neither @c wxEVT_KEY_DOWN nor @c wxEVT_CHAR events will be generated
  1195. (although @c wxEVT_KEY_UP still will be), i.e. it replaces the normal
  1196. key events. However by calling the special DoAllowNextEvent() method
  1197. you can handle @c wxEVT_CHAR_HOOK and still allow normal events
  1198. generation. This is something that is rarely useful but can be required
  1199. if you need to prevent a parent @c wxEVT_CHAR_HOOK handler from running
  1200. without suppressing the normal key events. Finally notice that this
  1201. event is not generated when the mouse is captured as it is considered
  1202. that the window which has the capture should receive all the keyboard
  1203. events too without allowing its parent wxTopLevelWindow to interfere
  1204. with their processing.
  1205. @endEventTable
  1206. @see wxKeyboardState
  1207. @library{wxcore}
  1208. @category{events}
  1209. */
  1210. class wxKeyEvent : public wxEvent,
  1211. public wxKeyboardState
  1212. {
  1213. public:
  1214. /**
  1215. Constructor.
  1216. Currently, the only valid event types are @c wxEVT_CHAR and @c wxEVT_CHAR_HOOK.
  1217. */
  1218. wxKeyEvent(wxEventType keyEventType = wxEVT_NULL);
  1219. /**
  1220. Returns the key code of the key that generated this event.
  1221. ASCII symbols return normal ASCII values, while events from special
  1222. keys such as "left cursor arrow" (@c WXK_LEFT) return values outside of
  1223. the ASCII range. See ::wxKeyCode for a full list of the virtual key
  1224. codes.
  1225. Note that this method returns a meaningful value only for special
  1226. non-alphanumeric keys or if the user entered a Latin-1 character (this
  1227. includes ASCII and the accented letters found in Western European
  1228. languages but not letters of other alphabets such as e.g. Cyrillic).
  1229. Otherwise it simply method returns @c WXK_NONE and GetUnicodeKey()
  1230. should be used to obtain the corresponding Unicode character.
  1231. Using GetUnicodeKey() is in general the right thing to do if you are
  1232. interested in the characters typed by the user, GetKeyCode() should be
  1233. only used for special keys (for which GetUnicodeKey() returns @c
  1234. WXK_NONE). To handle both kinds of keys you might write:
  1235. @code
  1236. void MyHandler::OnChar(wxKeyEvent& event)
  1237. {
  1238. wxChar uc = event.GetUnicodeKey();
  1239. if ( uc != WXK_NONE )
  1240. {
  1241. // It's a "normal" character. Notice that this includes
  1242. // control characters in 1..31 range, e.g. WXK_RETURN or
  1243. // WXK_BACK, so check for them explicitly.
  1244. if ( uc >= 32 )
  1245. {
  1246. wxLogMessage("You pressed '%c'", uc);
  1247. }
  1248. else
  1249. {
  1250. // It's a control character
  1251. ...
  1252. }
  1253. }
  1254. else // No Unicode equivalent.
  1255. {
  1256. // It's a special key, deal with all the known ones:
  1257. switch ( event.GetKeyCode() )
  1258. {
  1259. case WXK_LEFT:
  1260. case WXK_RIGHT:
  1261. ... move cursor ...
  1262. break;
  1263. case WXK_F1:
  1264. ... give help ...
  1265. break;
  1266. }
  1267. }
  1268. }
  1269. @endcode
  1270. */
  1271. int GetKeyCode() const;
  1272. /**
  1273. Returns true if the key is in the given key category.
  1274. @param category
  1275. A bitwise combination of named ::wxKeyCategoryFlags constants.
  1276. @since 2.9.1
  1277. */
  1278. bool IsKeyInCategory(int category) const;
  1279. //@{
  1280. /**
  1281. Obtains the position (in client coordinates) at which the key was pressed.
  1282. Notice that under most platforms this position is simply the current
  1283. mouse pointer position and has no special relationship to the key event
  1284. itself.
  1285. @a x and @a y may be @NULL if the corresponding coordinate is not
  1286. needed.
  1287. */
  1288. wxPoint GetPosition() const;
  1289. void GetPosition(wxCoord* x, wxCoord* y) const;
  1290. //@}
  1291. /**
  1292. Returns the raw key code for this event.
  1293. The flags are platform-dependent and should only be used if the
  1294. functionality provided by other wxKeyEvent methods is insufficient.
  1295. Under MSW, the raw key code is the value of @c wParam parameter of the
  1296. corresponding message.
  1297. Under GTK, the raw key code is the @c keyval field of the corresponding
  1298. GDK event.
  1299. Under OS X, the raw key code is the @c keyCode field of the
  1300. corresponding NSEvent.
  1301. @note Currently the raw key codes are not supported by all ports, use
  1302. @ifdef_ wxHAS_RAW_KEY_CODES to determine if this feature is available.
  1303. */
  1304. wxUint32 GetRawKeyCode() const;
  1305. /**
  1306. Returns the low level key flags for this event.
  1307. The flags are platform-dependent and should only be used if the
  1308. functionality provided by other wxKeyEvent methods is insufficient.
  1309. Under MSW, the raw flags are just the value of @c lParam parameter of
  1310. the corresponding message.
  1311. Under GTK, the raw flags contain the @c hardware_keycode field of the
  1312. corresponding GDK event.
  1313. Under OS X, the raw flags contain the modifiers state.
  1314. @note Currently the raw key flags are not supported by all ports, use
  1315. @ifdef_ wxHAS_RAW_KEY_CODES to determine if this feature is available.
  1316. */
  1317. wxUint32 GetRawKeyFlags() const;
  1318. /**
  1319. Returns the Unicode character corresponding to this key event.
  1320. If the key pressed doesn't have any character value (e.g. a cursor key)
  1321. this method will return @c WXK_NONE. In this case you should use
  1322. GetKeyCode() to retrieve the value of the key.
  1323. This function is only available in Unicode build, i.e. when
  1324. @c wxUSE_UNICODE is 1.
  1325. */
  1326. wxChar GetUnicodeKey() const;
  1327. /**
  1328. Returns the X position (in client coordinates) of the event.
  1329. @see GetPosition()
  1330. */
  1331. wxCoord GetX() const;
  1332. /**
  1333. Returns the Y position (in client coordinates) of the event.
  1334. @see GetPosition()
  1335. */
  1336. wxCoord GetY() const;
  1337. /**
  1338. Allow normal key events generation.
  1339. Can be called from @c wxEVT_CHAR_HOOK handler to indicate that the
  1340. generation of normal events should @em not be suppressed, as it happens
  1341. by default when this event is handled.
  1342. The intended use of this method is to allow some window object to
  1343. prevent @c wxEVT_CHAR_HOOK handler in its parent window from running by
  1344. defining its own handler for this event. Without calling this method,
  1345. this would result in not generating @c wxEVT_KEY_DOWN nor @c wxEVT_CHAR
  1346. events at all but by calling it you can ensure that these events would
  1347. still be generated, even if @c wxEVT_CHAR_HOOK event was handled.
  1348. @since 2.9.3
  1349. */
  1350. void DoAllowNextEvent();
  1351. /**
  1352. Returns @true if DoAllowNextEvent() had been called, @false by default.
  1353. This method is used by wxWidgets itself to determine whether the normal
  1354. key events should be generated after @c wxEVT_CHAR_HOOK processing.
  1355. @since 2.9.3
  1356. */
  1357. bool IsNextEventAllowed() const;
  1358. };
  1359. enum
  1360. {
  1361. wxJOYSTICK1,
  1362. wxJOYSTICK2
  1363. };
  1364. // Which button is down?
  1365. enum
  1366. {
  1367. wxJOY_BUTTON_ANY = -1,
  1368. wxJOY_BUTTON1 = 1,
  1369. wxJOY_BUTTON2 = 2,
  1370. wxJOY_BUTTON3 = 4,
  1371. wxJOY_BUTTON4 = 8
  1372. };
  1373. /**
  1374. @class wxJoystickEvent
  1375. This event class contains information about joystick events, particularly
  1376. events received by windows.
  1377. @beginEventTable{wxJoystickEvent}
  1378. @event{EVT_JOY_BUTTON_DOWN(func)}
  1379. Process a @c wxEVT_JOY_BUTTON_DOWN event.
  1380. @event{EVT_JOY_BUTTON_UP(func)}
  1381. Process a @c wxEVT_JOY_BUTTON_UP event.
  1382. @event{EVT_JOY_MOVE(func)}
  1383. Process a @c wxEVT_JOY_MOVE event.
  1384. @event{EVT_JOY_ZMOVE(func)}
  1385. Process a @c wxEVT_JOY_ZMOVE event.
  1386. @event{EVT_JOYSTICK_EVENTS(func)}
  1387. Processes all joystick events.
  1388. @endEventTable
  1389. @library{wxcore}
  1390. @category{events}
  1391. @see wxJoystick
  1392. */
  1393. class wxJoystickEvent : public wxEvent
  1394. {
  1395. public:
  1396. /**
  1397. Constructor.
  1398. */
  1399. wxJoystickEvent(wxEventType eventType = wxEVT_NULL, int state = 0,
  1400. int joystick = wxJOYSTICK1,
  1401. int change = 0);
  1402. /**
  1403. Returns @true if the event was a down event from the specified button
  1404. (or any button).
  1405. @param button
  1406. Can be @c wxJOY_BUTTONn where @c n is 1, 2, 3 or 4; or @c wxJOY_BUTTON_ANY to
  1407. indicate any button down event.
  1408. */
  1409. bool ButtonDown(int button = wxJOY_BUTTON_ANY) const;
  1410. /**
  1411. Returns @true if the specified button (or any button) was in a down state.
  1412. @param button
  1413. Can be @c wxJOY_BUTTONn where @c n is 1, 2, 3 or 4; or @c wxJOY_BUTTON_ANY to
  1414. indicate any button down event.
  1415. */
  1416. bool ButtonIsDown(int button = wxJOY_BUTTON_ANY) const;
  1417. /**
  1418. Returns @true if the event was an up event from the specified button
  1419. (or any button).
  1420. @param button
  1421. Can be @c wxJOY_BUTTONn where @c n is 1, 2, 3 or 4; or @c wxJOY_BUTTON_ANY to
  1422. indicate any button down event.
  1423. */
  1424. bool ButtonUp(int button = wxJOY_BUTTON_ANY) const;
  1425. /**
  1426. Returns the identifier of the button changing state.
  1427. This is a @c wxJOY_BUTTONn identifier, where @c n is one of 1, 2, 3, 4.
  1428. */
  1429. int GetButtonChange() const;
  1430. /**
  1431. Returns the down state of the buttons.
  1432. This is a @c wxJOY_BUTTONn identifier, where @c n is one of 1, 2, 3, 4.
  1433. */
  1434. int GetButtonState() const;
  1435. /**
  1436. Returns the identifier of the joystick generating the event - one of
  1437. wxJOYSTICK1 and wxJOYSTICK2.
  1438. */
  1439. int GetJoystick() const;
  1440. /**
  1441. Returns the x, y position of the joystick event.
  1442. These coordinates are valid for all the events except wxEVT_JOY_ZMOVE.
  1443. */
  1444. wxPoint GetPosition() const;
  1445. /**
  1446. Returns the z position of the joystick event.
  1447. This method can only be used for wxEVT_JOY_ZMOVE events.
  1448. */
  1449. int GetZPosition() const;
  1450. /**
  1451. Returns @true if this was a button up or down event
  1452. (@e not 'is any button down?').
  1453. */
  1454. bool IsButton() const;
  1455. /**
  1456. Returns @true if this was an x, y move event.
  1457. */
  1458. bool IsMove() const;
  1459. /**
  1460. Returns @true if this was a z move event.
  1461. */
  1462. bool IsZMove() const;
  1463. };
  1464. /**
  1465. @class wxScrollWinEvent
  1466. A scroll event holds information about events sent from scrolling windows.
  1467. Note that you can use the EVT_SCROLLWIN* macros for intercepting scroll window events
  1468. from the receiving window.
  1469. @beginEventTable{wxScrollWinEvent}
  1470. @event{EVT_SCROLLWIN(func)}
  1471. Process all scroll events.
  1472. @event{EVT_SCROLLWIN_TOP(func)}
  1473. Process @c wxEVT_SCROLLWIN_TOP scroll-to-top events.
  1474. @event{EVT_SCROLLWIN_BOTTOM(func)}
  1475. Process @c wxEVT_SCROLLWIN_BOTTOM scroll-to-bottom events.
  1476. @event{EVT_SCROLLWIN_LINEUP(func)}
  1477. Process @c wxEVT_SCROLLWIN_LINEUP line up events.
  1478. @event{EVT_SCROLLWIN_LINEDOWN(func)}
  1479. Process @c wxEVT_SCROLLWIN_LINEDOWN line down events.
  1480. @event{EVT_SCROLLWIN_PAGEUP(func)}
  1481. Process @c wxEVT_SCROLLWIN_PAGEUP page up events.
  1482. @event{EVT_SCROLLWIN_PAGEDOWN(func)}
  1483. Process @c wxEVT_SCROLLWIN_PAGEDOWN page down events.
  1484. @event{EVT_SCROLLWIN_THUMBTRACK(func)}
  1485. Process @c wxEVT_SCROLLWIN_THUMBTRACK thumbtrack events
  1486. (frequent events sent as the user drags the thumbtrack).
  1487. @event{EVT_SCROLLWIN_THUMBRELEASE(func)}
  1488. Process @c wxEVT_SCROLLWIN_THUMBRELEASE thumb release events.
  1489. @endEventTable
  1490. @library{wxcore}
  1491. @category{events}
  1492. @see wxScrollEvent, @ref overview_events
  1493. */
  1494. class wxScrollWinEvent : public wxEvent
  1495. {
  1496. public:
  1497. /**
  1498. Constructor.
  1499. */
  1500. wxScrollWinEvent(wxEventType commandType = wxEVT_NULL, int pos = 0,
  1501. int orientation = 0);
  1502. /**
  1503. Returns wxHORIZONTAL or wxVERTICAL, depending on the orientation of the
  1504. scrollbar.
  1505. @todo wxHORIZONTAL and wxVERTICAL should go in their own enum
  1506. */
  1507. int GetOrientation() const;
  1508. /**
  1509. Returns the position of the scrollbar for the thumb track and release events.
  1510. Note that this field can't be used for the other events, you need to query
  1511. the window itself for the current position in that case.
  1512. */
  1513. int GetPosition() const;
  1514. void SetOrientation(int orient);
  1515. void SetPosition(int pos);
  1516. };
  1517. /**
  1518. @class wxSysColourChangedEvent
  1519. This class is used for system colour change events, which are generated
  1520. when the user changes the colour settings using the control panel.
  1521. This is only appropriate under Windows.
  1522. @remarks
  1523. The default event handler for this event propagates the event to child windows,
  1524. since Windows only sends the events to top-level windows.
  1525. If intercepting this event for a top-level window, remember to call the base
  1526. class handler, or to pass the event on to the window's children explicitly.
  1527. @beginEventTable{wxSysColourChangedEvent}
  1528. @event{EVT_SYS_COLOUR_CHANGED(func)}
  1529. Process a @c wxEVT_SYS_COLOUR_CHANGED event.
  1530. @endEventTable
  1531. @library{wxcore}
  1532. @category{events}
  1533. @see @ref overview_events
  1534. */
  1535. class wxSysColourChangedEvent : public wxEvent
  1536. {
  1537. public:
  1538. /**
  1539. Constructor.
  1540. */
  1541. wxSysColourChangedEvent();
  1542. };
  1543. /**
  1544. @class wxCommandEvent
  1545. This event class contains information about command events, which originate
  1546. from a variety of simple controls.
  1547. Note that wxCommandEvents and wxCommandEvent-derived event classes by default
  1548. and unlike other wxEvent-derived classes propagate upward from the source
  1549. window (the window which emits the event) up to the first parent which processes
  1550. the event. Be sure to read @ref overview_events_propagation.
  1551. More complex controls, such as wxTreeCtrl, have separate command event classes.
  1552. @beginEventTable{wxCommandEvent}
  1553. @event{EVT_COMMAND(id, event, func)}
  1554. Process a command, supplying the window identifier, command event identifier,
  1555. and member function.
  1556. @event{EVT_COMMAND_RANGE(id1, id2, event, func)}
  1557. Process a command for a range of window identifiers, supplying the minimum and
  1558. maximum window identifiers, command event identifier, and member function.
  1559. @event{EVT_BUTTON(id, func)}
  1560. Process a @c wxEVT_BUTTON command, which is generated by a wxButton control.
  1561. @event{EVT_CHECKBOX(id, func)}
  1562. Process a @c wxEVT_CHECKBOX command, which is generated by a wxCheckBox control.
  1563. @event{EVT_CHOICE(id, func)}
  1564. Process a @c wxEVT_CHOICE command, which is generated by a wxChoice control.
  1565. @event{EVT_COMBOBOX(id, func)}
  1566. Process a @c wxEVT_COMBOBOX command, which is generated by a wxComboBox control.
  1567. @event{EVT_LISTBOX(id, func)}
  1568. Process a @c wxEVT_LISTBOX command, which is generated by a wxListBox control.
  1569. @event{EVT_LISTBOX_DCLICK(id, func)}
  1570. Process a @c wxEVT_LISTBOX_DCLICK command, which is generated by a wxListBox control.
  1571. @event{EVT_CHECKLISTBOX(id, func)}
  1572. Process a @c wxEVT_CHECKLISTBOX command, which is generated by a wxCheckListBox control.
  1573. @event{EVT_MENU(id, func)}
  1574. Process a @c wxEVT_MENU command, which is generated by a menu item.
  1575. @event{EVT_MENU_RANGE(id1, id2, func)}
  1576. Process a @c wxEVT_MENU command, which is generated by a range of menu items.
  1577. @event{EVT_CONTEXT_MENU(func)}
  1578. Process the event generated when the user has requested a popup menu to appear by
  1579. pressing a special keyboard key (under Windows) or by right clicking the mouse.
  1580. @event{EVT_RADIOBOX(id, func)}
  1581. Process a @c wxEVT_RADIOBOX command, which is generated by a wxRadioBox control.
  1582. @event{EVT_RADIOBUTTON(id, func)}
  1583. Process a @c wxEVT_RADIOBUTTON command, which is generated by a wxRadioButton control.
  1584. @event{EVT_SCROLLBAR(id, func)}
  1585. Process a @c wxEVT_SCROLLBAR command, which is generated by a wxScrollBar
  1586. control. This is provided for compatibility only; more specific scrollbar event macros
  1587. should be used instead (see wxScrollEvent).
  1588. @event{EVT_SLIDER(id, func)}
  1589. Process a @c wxEVT_SLIDER command, which is generated by a wxSlider control.
  1590. @event{EVT_TEXT(id, func)}
  1591. Process a @c wxEVT_TEXT command, which is generated by a wxTextCtrl control.
  1592. @event{EVT_TEXT_ENTER(id, func)}
  1593. Process a @c wxEVT_TEXT_ENTER command, which is generated by a wxTextCtrl control.
  1594. Note that you must use wxTE_PROCESS_ENTER flag when creating the control if you want it
  1595. to generate such events.
  1596. @event{EVT_TEXT_MAXLEN(id, func)}
  1597. Process a @c wxEVT_TEXT_MAXLEN command, which is generated by a wxTextCtrl control
  1598. when the user tries to enter more characters into it than the limit previously set
  1599. with SetMaxLength().
  1600. @event{EVT_TOGGLEBUTTON(id, func)}
  1601. Process a @c wxEVT_TOGGLEBUTTON event.
  1602. @event{EVT_TOOL(id, func)}
  1603. Process a @c wxEVT_TOOL event (a synonym for @c wxEVT_MENU).
  1604. Pass the id of the tool.
  1605. @event{EVT_TOOL_RANGE(id1, id2, func)}
  1606. Process a @c wxEVT_TOOL event for a range of identifiers. Pass the ids of the tools.
  1607. @event{EVT_TOOL_RCLICKED(id, func)}
  1608. Process a @c wxEVT_TOOL_RCLICKED event. Pass the id of the tool. (Not available on wxOSX.)
  1609. @event{EVT_TOOL_RCLICKED_RANGE(id1, id2, func)}
  1610. Process a @c wxEVT_TOOL_RCLICKED event for a range of ids. Pass the ids of the tools. (Not available on wxOSX.)
  1611. @event{EVT_TOOL_ENTER(id, func)}
  1612. Process a @c wxEVT_TOOL_ENTER event. Pass the id of the toolbar itself.
  1613. The value of wxCommandEvent::GetSelection() is the tool id, or -1 if the mouse cursor
  1614. has moved off a tool. (Not available on wxOSX.)
  1615. @event{EVT_COMMAND_LEFT_CLICK(id, func)}
  1616. Process a @c wxEVT_COMMAND_LEFT_CLICK command, which is generated by a control (wxMSW only).
  1617. @event{EVT_COMMAND_LEFT_DCLICK(id, func)}
  1618. Process a @c wxEVT_COMMAND_LEFT_DCLICK command, which is generated by a control (wxMSW only).
  1619. @event{EVT_COMMAND_RIGHT_CLICK(id, func)}
  1620. Process a @c wxEVT_COMMAND_RIGHT_CLICK command, which is generated by a control (wxMSW only).
  1621. @event{EVT_COMMAND_SET_FOCUS(id, func)}
  1622. Process a @c wxEVT_COMMAND_SET_FOCUS command, which is generated by a control (wxMSW only).
  1623. @event{EVT_COMMAND_KILL_FOCUS(id, func)}
  1624. Process a @c wxEVT_COMMAND_KILL_FOCUS command, which is generated by a control (wxMSW only).
  1625. @event{EVT_COMMAND_ENTER(id, func)}
  1626. Process a @c wxEVT_COMMAND_ENTER command, which is generated by a control.
  1627. @endEventTable
  1628. @library{wxcore}
  1629. @category{events}
  1630. */
  1631. class wxCommandEvent : public wxEvent
  1632. {
  1633. public:
  1634. /**
  1635. Constructor.
  1636. */
  1637. wxCommandEvent(wxEventType commandEventType = wxEVT_NULL, int id = 0);
  1638. /**
  1639. Returns client data pointer for a listbox or choice selection event
  1640. (not valid for a deselection).
  1641. */
  1642. void* GetClientData() const;
  1643. /**
  1644. Returns client object pointer for a listbox or choice selection event
  1645. (not valid for a deselection).
  1646. */
  1647. wxClientData* GetClientObject() const;
  1648. /**
  1649. Returns extra information dependent on the event objects type.
  1650. If the event comes from a listbox selection, it is a boolean
  1651. determining whether the event was a selection (@true) or a
  1652. deselection (@false). A listbox deselection only occurs for
  1653. multiple-selection boxes, and in this case the index and string values
  1654. are indeterminate and the listbox must be examined by the application.
  1655. */
  1656. long GetExtraLong() const;
  1657. /**
  1658. Returns the integer identifier corresponding to a listbox, choice or
  1659. radiobox selection (only if the event was a selection, not a deselection),
  1660. or a boolean value representing the value of a checkbox.
  1661. For a menu item, this method returns -1 if the item is not checkable or
  1662. a boolean value (true or false) for checkable items indicating the new
  1663. state of the item.
  1664. */
  1665. int GetInt() const;
  1666. /**
  1667. Returns item index for a listbox or choice selection event (not valid for
  1668. a deselection).
  1669. */
  1670. int GetSelection() const;
  1671. /**
  1672. Returns item string for a listbox or choice selection event. If one
  1673. or several items have been deselected, returns the index of the first
  1674. deselected item. If some items have been selected and others deselected
  1675. at the same time, it will return the index of the first selected item.
  1676. */
  1677. wxString GetString() const;
  1678. /**
  1679. This method can be used with checkbox and menu events: for the checkboxes, the
  1680. method returns @true for a selection event and @false for a deselection one.
  1681. For the menu events, this method indicates if the menu item just has become
  1682. checked or unchecked (and thus only makes sense for checkable menu items).
  1683. Notice that this method cannot be used with wxCheckListBox currently.
  1684. */
  1685. bool IsChecked() const;
  1686. /**
  1687. For a listbox or similar event, returns @true if it is a selection, @false
  1688. if it is a deselection. If some items have been selected and others deselected
  1689. at the same time, it will return @true.
  1690. */
  1691. bool IsSelection() const;
  1692. /**
  1693. Sets the client data for this event.
  1694. */
  1695. void SetClientData(void* clientData);
  1696. /**
  1697. Sets the client object for this event. The client object is not owned by the
  1698. event object and the event object will not delete the client object in its destructor.
  1699. The client object must be owned and deleted by another object (e.g. a control)
  1700. that has longer life time than the event object.
  1701. */
  1702. void SetClientObject(wxClientData* clientObject);
  1703. /**
  1704. Sets the @b m_extraLong member.
  1705. */
  1706. void SetExtraLong(long extraLong);
  1707. /**
  1708. Sets the @b m_commandInt member.
  1709. */
  1710. void SetInt(int intCommand);
  1711. /**
  1712. Sets the @b m_commandString member.
  1713. */
  1714. void SetString(const wxString& string);
  1715. };
  1716. /**
  1717. @class wxWindowCreateEvent
  1718. This event is sent just after the actual window associated with a wxWindow
  1719. object has been created.
  1720. Since it is derived from wxCommandEvent, the event propagates up
  1721. the window hierarchy.
  1722. @beginEventTable{wxWindowCreateEvent}
  1723. @event{EVT_WINDOW_CREATE(func)}
  1724. Process a @c wxEVT_CREATE event.
  1725. @endEventTable
  1726. @library{wxcore}
  1727. @category{events}
  1728. @see @ref overview_events, wxWindowDestroyEvent
  1729. */
  1730. class wxWindowCreateEvent : public wxCommandEvent
  1731. {
  1732. public:
  1733. /**
  1734. Constructor.
  1735. */
  1736. wxWindowCreateEvent(wxWindow* win = NULL);
  1737. /// Return the window being created.
  1738. wxWindow *GetWindow() const;
  1739. };
  1740. /**
  1741. @class wxPaintEvent
  1742. A paint event is sent when a window's contents needs to be repainted.
  1743. The handler of this event must create a wxPaintDC object and use it for
  1744. painting the window contents. For example:
  1745. @code
  1746. void MyWindow::OnPaint(wxPaintEvent& event)
  1747. {
  1748. wxPaintDC dc(this);
  1749. DrawMyDocument(dc);
  1750. }
  1751. @endcode
  1752. Notice that you must @e not create other kinds of wxDC (e.g. wxClientDC or
  1753. wxWindowDC) in EVT_PAINT handlers and also don't create wxPaintDC outside
  1754. of this event handlers.
  1755. You can optimize painting by retrieving the rectangles that have been damaged
  1756. and only repainting these. The rectangles are in terms of the client area,
  1757. and are unscrolled, so you will need to do some calculations using the current
  1758. view position to obtain logical, scrolled units.
  1759. Here is an example of using the wxRegionIterator class:
  1760. @code
  1761. // Called when window needs to be repainted.
  1762. void MyWindow::OnPaint(wxPaintEvent& event)
  1763. {
  1764. wxPaintDC dc(this);
  1765. // Find Out where the window is scrolled to
  1766. int vbX,vbY; // Top left corner of client
  1767. GetViewStart(&vbX,&vbY);
  1768. int vX,vY,vW,vH; // Dimensions of client area in pixels
  1769. wxRegionIterator upd(GetUpdateRegion()); // get the update rect list
  1770. while (upd)
  1771. {
  1772. vX = upd.GetX();
  1773. vY = upd.GetY();
  1774. vW = upd.GetW();
  1775. vH = upd.GetH();
  1776. // Alternatively we can do this:
  1777. // wxRect rect(upd.GetRect());
  1778. // Repaint this rectangle
  1779. ...some code...
  1780. upd ++ ;
  1781. }
  1782. }
  1783. @endcode
  1784. @remarks
  1785. Please notice that in general it is impossible to change the drawing of a
  1786. standard control (such as wxButton) and so you shouldn't attempt to handle
  1787. paint events for them as even if it might work on some platforms, this is
  1788. inherently not portable and won't work everywhere.
  1789. @beginEventTable{wxPaintEvent}
  1790. @event{EVT_PAINT(func)}
  1791. Process a @c wxEVT_PAINT event.
  1792. @endEventTable
  1793. @library{wxcore}
  1794. @category{events}
  1795. @see @ref overview_events
  1796. */
  1797. class wxPaintEvent : public wxEvent
  1798. {
  1799. public:
  1800. /**
  1801. Constructor.
  1802. */
  1803. wxPaintEvent(int id = 0);
  1804. };
  1805. /**
  1806. @class wxMaximizeEvent
  1807. An event being sent when a top level window is maximized. Notice that it is
  1808. not sent when the window is restored to its original size after it had been
  1809. maximized, only a normal wxSizeEvent is generated in this case.
  1810. Currently this event is only generated in wxMSW, wxGTK, wxOSX/Cocoa and wxOS2
  1811. ports so portable programs should only rely on receiving @c wxEVT_SIZE and
  1812. not necessarily this event when the window is maximized.
  1813. @beginEventTable{wxMaximizeEvent}
  1814. @event{EVT_MAXIMIZE(func)}
  1815. Process a @c wxEVT_MAXIMIZE event.
  1816. @endEventTable
  1817. @library{wxcore}
  1818. @category{events}
  1819. @see @ref overview_events, wxTopLevelWindow::Maximize,
  1820. wxTopLevelWindow::IsMaximized
  1821. */
  1822. class wxMaximizeEvent : public wxEvent
  1823. {
  1824. public:
  1825. /**
  1826. Constructor. Only used by wxWidgets internally.
  1827. */
  1828. wxMaximizeEvent(int id = 0);
  1829. };
  1830. /**
  1831. The possibles modes to pass to wxUpdateUIEvent::SetMode().
  1832. */
  1833. enum wxUpdateUIMode
  1834. {
  1835. /** Send UI update events to all windows. */
  1836. wxUPDATE_UI_PROCESS_ALL,
  1837. /** Send UI update events to windows that have
  1838. the wxWS_EX_PROCESS_UI_UPDATES flag specified. */
  1839. wxUPDATE_UI_PROCESS_SPECIFIED
  1840. };
  1841. /**
  1842. @class wxUpdateUIEvent
  1843. This class is used for pseudo-events which are called by wxWidgets
  1844. to give an application the chance to update various user interface elements.
  1845. Without update UI events, an application has to work hard to check/uncheck,
  1846. enable/disable, show/hide, and set the text for elements such as menu items
  1847. and toolbar buttons. The code for doing this has to be mixed up with the code
  1848. that is invoked when an action is invoked for a menu item or button.
  1849. With update UI events, you define an event handler to look at the state of the
  1850. application and change UI elements accordingly. wxWidgets will call your member
  1851. functions in idle time, so you don't have to worry where to call this code.
  1852. In addition to being a clearer and more declarative method, it also means you don't
  1853. have to worry whether you're updating a toolbar or menubar identifier. The same
  1854. handler can update a menu item and toolbar button, if the identifier is the same.
  1855. Instead of directly manipulating the menu or button, you call functions in the event
  1856. object, such as wxUpdateUIEvent::Check. wxWidgets will determine whether such a
  1857. call has been made, and which UI element to update.
  1858. These events will work for popup menus as well as menubars. Just before a menu is
  1859. popped up, wxMenu::UpdateUI is called to process any UI events for the window that
  1860. owns the menu.
  1861. If you find that the overhead of UI update processing is affecting your application,
  1862. you can do one or both of the following:
  1863. @li Call wxUpdateUIEvent::SetMode with a value of wxUPDATE_UI_PROCESS_SPECIFIED,
  1864. and set the extra style wxWS_EX_PROCESS_UI_UPDATES for every window that should
  1865. receive update events. No other windows will receive update events.
  1866. @li Call wxUpdateUIEvent::SetUpdateInterval with a millisecond value to set the delay
  1867. between updates. You may need to call wxWindow::UpdateWindowUI at critical points,
  1868. for example when a dialog is about to be shown, in case the user sees a slight
  1869. delay before windows are updated.
  1870. Note that although events are sent in idle time, defining a wxIdleEvent handler
  1871. for a window does not affect this because the events are sent from wxWindow::OnInternalIdle
  1872. which is always called in idle time.
  1873. wxWidgets tries to optimize update events on some platforms.
  1874. On Windows and GTK+, events for menubar items are only sent when the menu is about
  1875. to be shown, and not in idle time.
  1876. @beginEventTable{wxUpdateUIEvent}
  1877. @event{EVT_UPDATE_UI(id, func)}
  1878. Process a @c wxEVT_UPDATE_UI event for the command with the given id.
  1879. @event{EVT_UPDATE_UI_RANGE(id1, id2, func)}
  1880. Process a @c wxEVT_UPDATE_UI event for any command with id included in the given range.
  1881. @endEventTable
  1882. @library{wxcore}
  1883. @category{events}
  1884. @see @ref overview_events
  1885. */
  1886. class wxUpdateUIEvent : public wxCommandEvent
  1887. {
  1888. public:
  1889. /**
  1890. Constructor.
  1891. */
  1892. wxUpdateUIEvent(wxWindowID commandId = 0);
  1893. /**
  1894. Returns @true if it is appropriate to update (send UI update events to)
  1895. this window.
  1896. This function looks at the mode used (see wxUpdateUIEvent::SetMode),
  1897. the wxWS_EX_PROCESS_UI_UPDATES flag in @a window, the time update events
  1898. were last sent in idle time, and the update interval, to determine whether
  1899. events should be sent to this window now. By default this will always
  1900. return @true because the update mode is initially wxUPDATE_UI_PROCESS_ALL
  1901. and the interval is set to 0; so update events will be sent as often as
  1902. possible. You can reduce the frequency that events are sent by changing the
  1903. mode and/or setting an update interval.
  1904. @see ResetUpdateTime(), SetUpdateInterval(), SetMode()
  1905. */
  1906. static bool CanUpdate(wxWindow* window);
  1907. /**
  1908. Check or uncheck the UI element.
  1909. */
  1910. void Check(bool check);
  1911. /**
  1912. Enable or disable the UI element.
  1913. */
  1914. void Enable(bool enable);
  1915. /**
  1916. Returns @true if the UI element should be checked.
  1917. */
  1918. bool GetChecked() const;
  1919. /**
  1920. Returns @true if the UI element should be enabled.
  1921. */
  1922. bool GetEnabled() const;
  1923. /**
  1924. Static function returning a value specifying how wxWidgets will send update
  1925. events: to all windows, or only to those which specify that they will process
  1926. the events.
  1927. @see SetMode()
  1928. */
  1929. static wxUpdateUIMode GetMode();
  1930. /**
  1931. Returns @true if the application has called Check().
  1932. For wxWidgets internal use only.
  1933. */
  1934. bool GetSetChecked() const;
  1935. /**
  1936. Returns @true if the application has called Enable().
  1937. For wxWidgets internal use only.
  1938. */
  1939. bool GetSetEnabled() const;
  1940. /**
  1941. Returns @true if the application has called Show().
  1942. For wxWidgets internal use only.
  1943. */
  1944. bool GetSetShown() const;
  1945. /**
  1946. Returns @true if the application has called SetText().
  1947. For wxWidgets internal use only.
  1948. */
  1949. bool GetSetText() const;
  1950. /**
  1951. Returns @true if the UI element should be shown.
  1952. */
  1953. bool GetShown() const;
  1954. /**
  1955. Returns the text that should be set for the UI element.
  1956. */
  1957. wxString GetText() const;
  1958. /**
  1959. Returns the current interval between updates in milliseconds.
  1960. The value -1 disables updates, 0 updates as frequently as possible.
  1961. @see SetUpdateInterval().
  1962. */
  1963. static long GetUpdateInterval();
  1964. /**
  1965. Used internally to reset the last-updated time to the current time.
  1966. It is assumed that update events are normally sent in idle time, so this
  1967. is called at the end of idle processing.
  1968. @see CanUpdate(), SetUpdateInterval(), SetMode()
  1969. */
  1970. static void ResetUpdateTime();
  1971. /**
  1972. Specify how wxWidgets will send update events: to all windows, or only to
  1973. those which specify that they will process the events.
  1974. @param mode
  1975. this parameter may be one of the ::wxUpdateUIMode enumeration values.
  1976. The default mode is wxUPDATE_UI_PROCESS_ALL.
  1977. */
  1978. static void SetMode(wxUpdateUIMode mode);
  1979. /**
  1980. Sets the text for this UI element.
  1981. */
  1982. void SetText(const wxString& text);
  1983. /**
  1984. Sets the interval between updates in milliseconds.
  1985. Set to -1 to disable updates, or to 0 to update as frequently as possible.
  1986. The default is 0.
  1987. Use this to reduce the overhead of UI update events if your application
  1988. has a lot of windows. If you set the value to -1 or greater than 0,
  1989. you may also need to call wxWindow::UpdateWindowUI at appropriate points
  1990. in your application, such as when a dialog is about to be shown.
  1991. */
  1992. static void SetUpdateInterval(long updateInterval);
  1993. /**
  1994. Show or hide the UI element.
  1995. */
  1996. void Show(bool show);
  1997. };
  1998. /**
  1999. @class wxClipboardTextEvent
  2000. This class represents the events generated by a control (typically a
  2001. wxTextCtrl but other windows can generate these events as well) when its
  2002. content gets copied or cut to, or pasted from the clipboard.
  2003. There are three types of corresponding events @c wxEVT_TEXT_COPY,
  2004. @c wxEVT_TEXT_CUT and @c wxEVT_TEXT_PASTE.
  2005. If any of these events is processed (without being skipped) by an event
  2006. handler, the corresponding operation doesn't take place which allows to
  2007. prevent the text from being copied from or pasted to a control. It is also
  2008. possible to examine the clipboard contents in the PASTE event handler and
  2009. transform it in some way before inserting in a control -- for example,
  2010. changing its case or removing invalid characters.
  2011. Finally notice that a CUT event is always preceded by the COPY event which
  2012. makes it possible to only process the latter if it doesn't matter if the
  2013. text was copied or cut.
  2014. @note
  2015. These events are currently only generated by wxTextCtrl in wxGTK and wxOSX
  2016. but are also generated by wxComboBox without wxCB_READONLY style in wxMSW.
  2017. @beginEventTable{wxClipboardTextEvent}
  2018. @event{EVT_TEXT_COPY(id, func)}
  2019. Some or all of the controls content was copied to the clipboard.
  2020. @event{EVT_TEXT_CUT(id, func)}
  2021. Some or all of the controls content was cut (i.e. copied and
  2022. deleted).
  2023. @event{EVT_TEXT_PASTE(id, func)}
  2024. Clipboard content was pasted into the control.
  2025. @endEventTable
  2026. @library{wxcore}
  2027. @category{events}
  2028. @see wxClipboard
  2029. */
  2030. class wxClipboardTextEvent : public wxCommandEvent
  2031. {
  2032. public:
  2033. /**
  2034. Constructor.
  2035. */
  2036. wxClipboardTextEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
  2037. };
  2038. /**
  2039. Possible axis values for mouse wheel scroll events.
  2040. @since 2.9.4
  2041. */
  2042. enum wxMouseWheelAxis
  2043. {
  2044. wxMOUSE_WHEEL_VERTICAL, ///< Vertical scroll event.
  2045. wxMOUSE_WHEEL_HORIZONTAL ///< Horizontal scroll event.
  2046. };
  2047. /**
  2048. @class wxMouseEvent
  2049. This event class contains information about the events generated by the mouse:
  2050. they include mouse buttons press and release events and mouse move events.
  2051. All mouse events involving the buttons use @c wxMOUSE_BTN_LEFT for the
  2052. left mouse button, @c wxMOUSE_BTN_MIDDLE for the middle one and
  2053. @c wxMOUSE_BTN_RIGHT for the right one. And if the system supports more
  2054. buttons, the @c wxMOUSE_BTN_AUX1 and @c wxMOUSE_BTN_AUX2 events
  2055. can also be generated. Note that not all mice have even a middle button so a
  2056. portable application should avoid relying on the events from it (but the right
  2057. button click can be emulated using the left mouse button with the control key
  2058. under Mac platforms with a single button mouse).
  2059. For the @c wxEVT_ENTER_WINDOW and @c wxEVT_LEAVE_WINDOW events
  2060. purposes, the mouse is considered to be inside the window if it is in the
  2061. window client area and not inside one of its children. In other words, the
  2062. parent window receives @c wxEVT_LEAVE_WINDOW event not only when the
  2063. mouse leaves the window entirely but also when it enters one of its children.
  2064. The position associated with a mouse event is expressed in the window
  2065. coordinates of the window which generated the event, you can use
  2066. wxWindow::ClientToScreen() to convert it to screen coordinates and possibly
  2067. call wxWindow::ScreenToClient() next to convert it to window coordinates of
  2068. another window.
  2069. @note Note that under Windows CE mouse enter and leave events are not natively
  2070. supported by the system but are generated by wxWidgets itself. This has several
  2071. drawbacks: the LEAVE_WINDOW event might be received some time after the mouse
  2072. left the window and the state variables for it may have changed during this time.
  2073. @note Note the difference between methods like wxMouseEvent::LeftDown and
  2074. the inherited wxMouseState::LeftIsDown: the former returns @true when
  2075. the event corresponds to the left mouse button click while the latter
  2076. returns @true if the left mouse button is currently being pressed.
  2077. For example, when the user is dragging the mouse you can use
  2078. wxMouseEvent::LeftIsDown to test whether the left mouse button is
  2079. (still) depressed. Also, by convention, if wxMouseEvent::LeftDown
  2080. returns @true, wxMouseEvent::LeftIsDown will also return @true in
  2081. wxWidgets whatever the underlying GUI behaviour is (which is
  2082. platform-dependent). The same applies, of course, to other mouse
  2083. buttons as well.
  2084. @beginEventTable{wxMouseEvent}
  2085. @event{EVT_LEFT_DOWN(func)}
  2086. Process a @c wxEVT_LEFT_DOWN event. The handler of this event should normally
  2087. call event.Skip() to allow the default processing to take place as otherwise
  2088. the window under mouse wouldn't get the focus.
  2089. @event{EVT_LEFT_UP(func)}
  2090. Process a @c wxEVT_LEFT_UP event.
  2091. @event{EVT_LEFT_DCLICK(func)}
  2092. Process a @c wxEVT_LEFT_DCLICK event.
  2093. @event{EVT_MIDDLE_DOWN(func)}
  2094. Process a @c wxEVT_MIDDLE_DOWN event.
  2095. @event{EVT_MIDDLE_UP(func)}
  2096. Process a @c wxEVT_MIDDLE_UP event.
  2097. @event{EVT_MIDDLE_DCLICK(func)}
  2098. Process a @c wxEVT_MIDDLE_DCLICK event.
  2099. @event{EVT_RIGHT_DOWN(func)}
  2100. Process a @c wxEVT_RIGHT_DOWN event.
  2101. @event{EVT_RIGHT_UP(func)}
  2102. Process a @c wxEVT_RIGHT_UP event.
  2103. @event{EVT_RIGHT_DCLICK(func)}
  2104. Process a @c wxEVT_RIGHT_DCLICK event.
  2105. @event{EVT_MOUSE_AUX1_DOWN(func)}
  2106. Process a @c wxEVT_AUX1_DOWN event.
  2107. @event{EVT_MOUSE_AUX1_UP(func)}
  2108. Process a @c wxEVT_AUX1_UP event.
  2109. @event{EVT_MOUSE_AUX1_DCLICK(func)}
  2110. Process a @c wxEVT_AUX1_DCLICK event.
  2111. @event{EVT_MOUSE_AUX2_DOWN(func)}
  2112. Process a @c wxEVT_AUX2_DOWN event.
  2113. @event{EVT_MOUSE_AUX2_UP(func)}
  2114. Process a @c wxEVT_AUX2_UP event.
  2115. @event{EVT_MOUSE_AUX2_DCLICK(func)}
  2116. Process a @c wxEVT_AUX2_DCLICK event.
  2117. @event{EVT_MOTION(func)}
  2118. Process a @c wxEVT_MOTION event.
  2119. @event{EVT_ENTER_WINDOW(func)}
  2120. Process a @c wxEVT_ENTER_WINDOW event.
  2121. @event{EVT_LEAVE_WINDOW(func)}
  2122. Process a @c wxEVT_LEAVE_WINDOW event.
  2123. @event{EVT_MOUSEWHEEL(func)}
  2124. Process a @c wxEVT_MOUSEWHEEL event.
  2125. @event{EVT_MOUSE_EVENTS(func)}
  2126. Process all mouse events.
  2127. @endEventTable
  2128. @library{wxcore}
  2129. @category{events}
  2130. @see wxKeyEvent
  2131. */
  2132. class wxMouseEvent : public wxEvent,
  2133. public wxMouseState
  2134. {
  2135. public:
  2136. /**
  2137. Constructor. Valid event types are:
  2138. @li @c wxEVT_ENTER_WINDOW
  2139. @li @c wxEVT_LEAVE_WINDOW
  2140. @li @c wxEVT_LEFT_DOWN
  2141. @li @c wxEVT_LEFT_UP
  2142. @li @c wxEVT_LEFT_DCLICK
  2143. @li @c wxEVT_MIDDLE_DOWN
  2144. @li @c wxEVT_MIDDLE_UP
  2145. @li @c wxEVT_MIDDLE_DCLICK
  2146. @li @c wxEVT_RIGHT_DOWN
  2147. @li @c wxEVT_RIGHT_UP
  2148. @li @c wxEVT_RIGHT_DCLICK
  2149. @li @c wxEVT_AUX1_DOWN
  2150. @li @c wxEVT_AUX1_UP
  2151. @li @c wxEVT_AUX1_DCLICK
  2152. @li @c wxEVT_AUX2_DOWN
  2153. @li @c wxEVT_AUX2_UP
  2154. @li @c wxEVT_AUX2_DCLICK
  2155. @li @c wxEVT_MOTION
  2156. @li @c wxEVT_MOUSEWHEEL
  2157. */
  2158. wxMouseEvent(wxEventType mouseEventType = wxEVT_NULL);
  2159. /**
  2160. Returns @true if the event was a first extra button double click.
  2161. */
  2162. bool Aux1DClick() const;
  2163. /**
  2164. Returns @true if the first extra button mouse button changed to down.
  2165. */
  2166. bool Aux1Down() const;
  2167. /**
  2168. Returns @true if the first extra button mouse button changed to up.
  2169. */
  2170. bool Aux1Up() const;
  2171. /**
  2172. Returns @true if the event was a second extra button double click.
  2173. */
  2174. bool Aux2DClick() const;
  2175. /**
  2176. Returns @true if the second extra button mouse button changed to down.
  2177. */
  2178. bool Aux2Down() const;
  2179. /**
  2180. Returns @true if the second extra button mouse button changed to up.
  2181. */
  2182. bool Aux2Up() const;
  2183. /**
  2184. Returns @true if the event was generated by the specified button.
  2185. @see wxMouseState::ButtoinIsDown()
  2186. */
  2187. bool Button(wxMouseButton but) const;
  2188. /**
  2189. If the argument is omitted, this returns @true if the event was a mouse
  2190. double click event. Otherwise the argument specifies which double click event
  2191. was generated (see Button() for the possible values).
  2192. */
  2193. bool ButtonDClick(wxMouseButton but = wxMOUSE_BTN_ANY) const;
  2194. /**
  2195. If the argument is omitted, this returns @true if the event was a mouse
  2196. button down event. Otherwise the argument specifies which button-down event
  2197. was generated (see Button() for the possible values).
  2198. */
  2199. bool ButtonDown(wxMouseButton but = wxMOUSE_BTN_ANY) const;
  2200. /**
  2201. If the argument is omitted, this returns @true if the event was a mouse
  2202. button up event. Otherwise the argument specifies which button-up event
  2203. was generated (see Button() for the possible values).
  2204. */
  2205. bool ButtonUp(wxMouseButton but = wxMOUSE_BTN_ANY) const;
  2206. /**
  2207. Returns @true if this was a dragging event (motion while a button is depressed).
  2208. @see Moving()
  2209. */
  2210. bool Dragging() const;
  2211. /**
  2212. Returns @true if the mouse was entering the window.
  2213. @see Leaving()
  2214. */
  2215. bool Entering() const;
  2216. /**
  2217. Returns the mouse button which generated this event or @c wxMOUSE_BTN_NONE
  2218. if no button is involved (for mouse move, enter or leave event, for example).
  2219. Otherwise @c wxMOUSE_BTN_LEFT is returned for the left button down, up and
  2220. double click events, @c wxMOUSE_BTN_MIDDLE and @c wxMOUSE_BTN_RIGHT
  2221. for the same events for the middle and the right buttons respectively.
  2222. */
  2223. int GetButton() const;
  2224. /**
  2225. Returns the number of mouse clicks for this event: 1 for a simple click, 2
  2226. for a double-click, 3 for a triple-click and so on.
  2227. Currently this function is implemented only in wxMac and returns -1 for the
  2228. other platforms (you can still distinguish simple clicks from double-clicks as
  2229. they generate different kinds of events however).
  2230. @since 2.9.0
  2231. */
  2232. int GetClickCount() const;
  2233. /**
  2234. Returns the configured number of lines (or whatever) to be scrolled per
  2235. wheel action.
  2236. Default value under most platforms is three.
  2237. @see GetColumnsPerAction()
  2238. */
  2239. int GetLinesPerAction() const;
  2240. /**
  2241. Returns the configured number of columns (or whatever) to be scrolled per
  2242. wheel action.
  2243. Default value under most platforms is three.
  2244. @see GetLinesPerAction()
  2245. @since 2.9.5
  2246. */
  2247. int GetColumnsPerAction() const;
  2248. /**
  2249. Returns the logical mouse position in pixels (i.e.\ translated according to the
  2250. translation set for the DC, which usually indicates that the window has been
  2251. scrolled).
  2252. */
  2253. wxPoint GetLogicalPosition(const wxDC& dc) const;
  2254. /**
  2255. Get wheel delta, normally 120.
  2256. This is the threshold for action to be taken, and one such action
  2257. (for example, scrolling one increment) should occur for each delta.
  2258. */
  2259. int GetWheelDelta() const;
  2260. /**
  2261. Get wheel rotation, positive or negative indicates direction of rotation.
  2262. Current devices all send an event when rotation is at least +/-WheelDelta, but
  2263. finer resolution devices can be created in the future.
  2264. Because of this you shouldn't assume that one event is equal to 1 line, but you
  2265. should be able to either do partial line scrolling or wait until several
  2266. events accumulate before scrolling.
  2267. */
  2268. int GetWheelRotation() const;
  2269. /**
  2270. Gets the axis the wheel operation concerns.
  2271. Usually the mouse wheel is used to scroll vertically so @c
  2272. wxMOUSE_WHEEL_VERTICAL is returned but some mice (and most trackpads)
  2273. also allow to use the wheel to scroll horizontally in which case
  2274. @c wxMOUSE_WHEEL_HORIZONTAL is returned.
  2275. Notice that before wxWidgets 2.9.4 this method returned @c int.
  2276. */
  2277. wxMouseWheelAxis GetWheelAxis() const;
  2278. /**
  2279. Returns @true if the event was a mouse button event (not necessarily a button
  2280. down event - that may be tested using ButtonDown()).
  2281. */
  2282. bool IsButton() const;
  2283. /**
  2284. Returns @true if the system has been setup to do page scrolling with
  2285. the mouse wheel instead of line scrolling.
  2286. */
  2287. bool IsPageScroll() const;
  2288. /**
  2289. Returns @true if the mouse was leaving the window.
  2290. @see Entering().
  2291. */
  2292. bool Leaving() const;
  2293. /**
  2294. Returns @true if the event was a left double click.
  2295. */
  2296. bool LeftDClick() const;
  2297. /**
  2298. Returns @true if the left mouse button changed to down.
  2299. */
  2300. bool LeftDown() const;
  2301. /**
  2302. Returns @true if the left mouse button changed to up.
  2303. */
  2304. bool LeftUp() const;
  2305. /**
  2306. Returns @true if the Meta key was down at the time of the event.
  2307. */
  2308. bool MetaDown() const;
  2309. /**
  2310. Returns @true if the event was a middle double click.
  2311. */
  2312. bool MiddleDClick() const;
  2313. /**
  2314. Returns @true if the middle mouse button changed to down.
  2315. */
  2316. bool MiddleDown() const;
  2317. /**
  2318. Returns @true if the middle mouse button changed to up.
  2319. */
  2320. bool MiddleUp() const;
  2321. /**
  2322. Returns @true if this was a motion event and no mouse buttons were pressed.
  2323. If any mouse button is held pressed, then this method returns @false and
  2324. Dragging() returns @true.
  2325. */
  2326. bool Moving() const;
  2327. /**
  2328. Returns @true if the event was a right double click.
  2329. */
  2330. bool RightDClick() const;
  2331. /**
  2332. Returns @true if the right mouse button changed to down.
  2333. */
  2334. bool RightDown() const;
  2335. /**
  2336. Returns @true if the right mouse button changed to up.
  2337. */
  2338. bool RightUp() const;
  2339. };
  2340. /**
  2341. @class wxDropFilesEvent
  2342. This class is used for drop files events, that is, when files have been dropped
  2343. onto the window. This functionality is currently only available under Windows.
  2344. The window must have previously been enabled for dropping by calling
  2345. wxWindow::DragAcceptFiles().
  2346. Important note: this is a separate implementation to the more general drag and drop
  2347. implementation documented in the @ref overview_dnd. It uses the older, Windows
  2348. message-based approach of dropping files.
  2349. @beginEventTable{wxDropFilesEvent}
  2350. @event{EVT_DROP_FILES(func)}
  2351. Process a @c wxEVT_DROP_FILES event.
  2352. @endEventTable
  2353. @onlyfor{wxmsw}
  2354. @library{wxcore}
  2355. @category{events}
  2356. @see @ref overview_events
  2357. */
  2358. class wxDropFilesEvent : public wxEvent
  2359. {
  2360. public:
  2361. /**
  2362. Constructor.
  2363. */
  2364. wxDropFilesEvent(wxEventType id = 0, int noFiles = 0,
  2365. wxString* files = NULL);
  2366. /**
  2367. Returns an array of filenames.
  2368. */
  2369. wxString* GetFiles() const;
  2370. /**
  2371. Returns the number of files dropped.
  2372. */
  2373. int GetNumberOfFiles() const;
  2374. /**
  2375. Returns the position at which the files were dropped.
  2376. Returns an array of filenames.
  2377. */
  2378. wxPoint GetPosition() const;
  2379. };
  2380. /**
  2381. @class wxActivateEvent
  2382. An activate event is sent when a window or application is being activated
  2383. or deactivated.
  2384. @beginEventTable{wxActivateEvent}
  2385. @event{EVT_ACTIVATE(func)}
  2386. Process a @c wxEVT_ACTIVATE event.
  2387. @event{EVT_ACTIVATE_APP(func)}
  2388. Process a @c wxEVT_ACTIVATE_APP event.
  2389. This event is received by the wxApp-derived instance only.
  2390. @event{EVT_HIBERNATE(func)}
  2391. Process a hibernate event, supplying the member function. This event applies
  2392. to wxApp only, and only on Windows SmartPhone and PocketPC.
  2393. It is generated when the system is low on memory; the application should free
  2394. up as much memory as possible, and restore full working state when it receives
  2395. a @c wxEVT_ACTIVATE or @c wxEVT_ACTIVATE_APP event.
  2396. @endEventTable
  2397. @library{wxcore}
  2398. @category{events}
  2399. @see @ref overview_events, wxApp::IsActive
  2400. */
  2401. class wxActivateEvent : public wxEvent
  2402. {
  2403. public:
  2404. /**
  2405. Specifies the reason for the generation of this event.
  2406. See GetActivationReason().
  2407. @since 3.0
  2408. */
  2409. enum Reason
  2410. {
  2411. /// Window activated by mouse click.
  2412. Reason_Mouse,
  2413. /// Window was activated with some other method than mouse click.
  2414. Reason_Unknown
  2415. };
  2416. /**
  2417. Constructor.
  2418. */
  2419. wxActivateEvent(wxEventType eventType = wxEVT_NULL, bool active = true,
  2420. int id = 0, Reason ActivationReason = Reason_Unknown);
  2421. /**
  2422. Returns @true if the application or window is being activated, @false otherwise.
  2423. */
  2424. bool GetActive() const;
  2425. /**
  2426. Allows to check if the window was activated by clicking it with the
  2427. mouse or in some other way.
  2428. This method is currently only implemented in wxMSW and returns @c
  2429. Reason_Mouse there if the window was activated by a mouse click and @c
  2430. Reason_Unknown if it was activated in any other way (e.g. from
  2431. keyboard or programmatically).
  2432. Under all the other platforms, @c Reason_Unknown is always returned.
  2433. @since 3.0
  2434. */
  2435. Reason GetActivationReason() const;
  2436. };
  2437. /**
  2438. @class wxContextMenuEvent
  2439. This class is used for context menu events, sent to give
  2440. the application a chance to show a context (popup) menu for a wxWindow.
  2441. Note that if wxContextMenuEvent::GetPosition returns wxDefaultPosition, this
  2442. means that the event originated from a keyboard context button event, and you
  2443. should compute a suitable position yourself, for example by calling wxGetMousePosition().
  2444. Notice that the exact sequence of mouse events is different across the
  2445. platforms. For example, under MSW the context menu event is generated after
  2446. @c EVT_RIGHT_UP event and only if it was not handled but under GTK the
  2447. context menu event is generated after @c EVT_RIGHT_DOWN event. This is
  2448. correct in the sense that it ensures that the context menu is shown
  2449. according to the current platform UI conventions and also means that you
  2450. must not handle (or call wxEvent::Skip() in your handler if you do have
  2451. one) neither right mouse down nor right mouse up event if you plan on
  2452. handling @c EVT_CONTEXT_MENU event.
  2453. @beginEventTable{wxContextMenuEvent}
  2454. @event{EVT_CONTEXT_MENU(func)}
  2455. A right click (or other context menu command depending on platform) has been detected.
  2456. @endEventTable
  2457. @library{wxcore}
  2458. @category{events}
  2459. @see wxCommandEvent, @ref overview_events
  2460. */
  2461. class wxContextMenuEvent : public wxCommandEvent
  2462. {
  2463. public:
  2464. /**
  2465. Constructor.
  2466. */
  2467. wxContextMenuEvent(wxEventType type = wxEVT_NULL, int id = 0,
  2468. const wxPoint& pos = wxDefaultPosition);
  2469. /**
  2470. Returns the position in screen coordinates at which the menu should be shown.
  2471. Use wxWindow::ScreenToClient to convert to client coordinates.
  2472. You can also omit a position from wxWindow::PopupMenu in order to use
  2473. the current mouse pointer position.
  2474. If the event originated from a keyboard event, the value returned from this
  2475. function will be wxDefaultPosition.
  2476. */
  2477. const wxPoint& GetPosition() const;
  2478. /**
  2479. Sets the position at which the menu should be shown.
  2480. */
  2481. void SetPosition(const wxPoint& point);
  2482. };
  2483. /**
  2484. @class wxEraseEvent
  2485. An erase event is sent when a window's background needs to be repainted.
  2486. On some platforms, such as GTK+, this event is simulated (simply generated just
  2487. before the paint event) and may cause flicker. It is therefore recommended that
  2488. you set the text background colour explicitly in order to prevent flicker.
  2489. The default background colour under GTK+ is grey.
  2490. To intercept this event, use the EVT_ERASE_BACKGROUND macro in an event table
  2491. definition.
  2492. You must use the device context returned by GetDC() to draw on, don't create
  2493. a wxPaintDC in the event handler.
  2494. @beginEventTable{wxEraseEvent}
  2495. @event{EVT_ERASE_BACKGROUND(func)}
  2496. Process a @c wxEVT_ERASE_BACKGROUND event.
  2497. @endEventTable
  2498. @library{wxcore}
  2499. @category{events}
  2500. @see @ref overview_events
  2501. */
  2502. class wxEraseEvent : public wxEvent
  2503. {
  2504. public:
  2505. /**
  2506. Constructor.
  2507. */
  2508. wxEraseEvent(int id = 0, wxDC* dc = NULL);
  2509. /**
  2510. Returns the device context associated with the erase event to draw on.
  2511. The returned pointer is never @NULL.
  2512. */
  2513. wxDC* GetDC() const;
  2514. };
  2515. /**
  2516. @class wxFocusEvent
  2517. A focus event is sent when a window's focus changes. The window losing focus
  2518. receives a "kill focus" event while the window gaining it gets a "set focus" one.
  2519. Notice that the set focus event happens both when the user gives focus to the
  2520. window (whether using the mouse or keyboard) and when it is done from the
  2521. program itself using wxWindow::SetFocus.
  2522. The focus event handlers should almost invariably call wxEvent::Skip() on
  2523. their event argument to allow the default handling to take place. Failure
  2524. to do this may result in incorrect behaviour of the native controls. Also
  2525. note that wxEVT_KILL_FOCUS handler must not call wxWindow::SetFocus() as
  2526. this, again, is not supported by all native controls. If you need to do
  2527. this, consider using the @ref sec_delayed_action described in wxIdleEvent
  2528. documentation.
  2529. @beginEventTable{wxFocusEvent}
  2530. @event{EVT_SET_FOCUS(func)}
  2531. Process a @c wxEVT_SET_FOCUS event.
  2532. @event{EVT_KILL_FOCUS(func)}
  2533. Process a @c wxEVT_KILL_FOCUS event.
  2534. @endEventTable
  2535. @library{wxcore}
  2536. @category{events}
  2537. @see @ref overview_events
  2538. */
  2539. class wxFocusEvent : public wxEvent
  2540. {
  2541. public:
  2542. /**
  2543. Constructor.
  2544. */
  2545. wxFocusEvent(wxEventType eventType = wxEVT_NULL, int id = 0);
  2546. /**
  2547. Returns the window associated with this event, that is the window which had the
  2548. focus before for the @c wxEVT_SET_FOCUS event and the window which is
  2549. going to receive focus for the @c wxEVT_KILL_FOCUS one.
  2550. Warning: the window pointer may be @NULL!
  2551. */
  2552. wxWindow *GetWindow() const;
  2553. void SetWindow(wxWindow *win);
  2554. };
  2555. /**
  2556. @class wxChildFocusEvent
  2557. A child focus event is sent to a (parent-)window when one of its child windows
  2558. gains focus, so that the window could restore the focus back to its corresponding
  2559. child if it loses it now and regains later.
  2560. Notice that child window is the direct child of the window receiving event.
  2561. Use wxWindow::FindFocus() to retrieve the window which is actually getting focus.
  2562. @beginEventTable{wxChildFocusEvent}
  2563. @event{EVT_CHILD_FOCUS(func)}
  2564. Process a @c wxEVT_CHILD_FOCUS event.
  2565. @endEventTable
  2566. @library{wxcore}
  2567. @category{events}
  2568. @see @ref overview_events
  2569. */
  2570. class wxChildFocusEvent : public wxCommandEvent
  2571. {
  2572. public:
  2573. /**
  2574. Constructor.
  2575. @param win
  2576. The direct child which is (or which contains the window which is) receiving
  2577. the focus.
  2578. */
  2579. wxChildFocusEvent(wxWindow* win = NULL);
  2580. /**
  2581. Returns the direct child which receives the focus, or a (grand-)parent of the
  2582. control receiving the focus.
  2583. To get the actually focused control use wxWindow::FindFocus.
  2584. */
  2585. wxWindow *GetWindow() const;
  2586. };
  2587. /**
  2588. @class wxMouseCaptureLostEvent
  2589. A mouse capture lost event is sent to a window that had obtained mouse capture,
  2590. which was subsequently lost due to an "external" event (for example, when a dialog
  2591. box is shown or if another application captures the mouse).
  2592. If this happens, this event is sent to all windows that are on the capture stack
  2593. (i.e. called CaptureMouse, but didn't call ReleaseMouse yet). The event is
  2594. not sent if the capture changes because of a call to CaptureMouse or
  2595. ReleaseMouse.
  2596. This event is currently emitted under Windows only.
  2597. @beginEventTable{wxMouseCaptureLostEvent}
  2598. @event{EVT_MOUSE_CAPTURE_LOST(func)}
  2599. Process a @c wxEVT_MOUSE_CAPTURE_LOST event.
  2600. @endEventTable
  2601. @onlyfor{wxmsw}
  2602. @library{wxcore}
  2603. @category{events}
  2604. @see wxMouseCaptureChangedEvent, @ref overview_events,
  2605. wxWindow::CaptureMouse, wxWindow::ReleaseMouse, wxWindow::GetCapture
  2606. */
  2607. class wxMouseCaptureLostEvent : public wxEvent
  2608. {
  2609. public:
  2610. /**
  2611. Constructor.
  2612. */
  2613. wxMouseCaptureLostEvent(wxWindowID windowId = 0);
  2614. };
  2615. class wxDisplayChangedEvent : public wxEvent
  2616. {
  2617. public:
  2618. wxDisplayChangedEvent();
  2619. };
  2620. class wxPaletteChangedEvent : public wxEvent
  2621. {
  2622. public:
  2623. wxPaletteChangedEvent(wxWindowID winid = 0);
  2624. void SetChangedWindow(wxWindow* win);
  2625. wxWindow* GetChangedWindow() const;
  2626. };
  2627. class wxQueryNewPaletteEvent : public wxEvent
  2628. {
  2629. public:
  2630. wxQueryNewPaletteEvent(wxWindowID winid = 0);
  2631. void SetPaletteRealized(bool realized);
  2632. bool GetPaletteRealized();
  2633. };
  2634. /**
  2635. @class wxNotifyEvent
  2636. This class is not used by the event handlers by itself, but is a base class
  2637. for other event classes (such as wxBookCtrlEvent).
  2638. It (or an object of a derived class) is sent when the controls state is being
  2639. changed and allows the program to wxNotifyEvent::Veto() this change if it wants
  2640. to prevent it from happening.
  2641. @library{wxcore}
  2642. @category{events}
  2643. @see wxBookCtrlEvent
  2644. */
  2645. class wxNotifyEvent : public wxCommandEvent
  2646. {
  2647. public:
  2648. /**
  2649. Constructor (used internally by wxWidgets only).
  2650. */
  2651. wxNotifyEvent(wxEventType eventType = wxEVT_NULL, int id = 0);
  2652. /**
  2653. This is the opposite of Veto(): it explicitly allows the event to be processed.
  2654. For most events it is not necessary to call this method as the events are allowed
  2655. anyhow but some are forbidden by default (this will be mentioned in the corresponding
  2656. event description).
  2657. */
  2658. void Allow();
  2659. /**
  2660. Returns @true if the change is allowed (Veto() hasn't been called) or @false
  2661. otherwise (if it was).
  2662. */
  2663. bool IsAllowed() const;
  2664. /**
  2665. Prevents the change announced by this event from happening.
  2666. It is in general a good idea to notify the user about the reasons for vetoing
  2667. the change because otherwise the applications behaviour (which just refuses to
  2668. do what the user wants) might be quite surprising.
  2669. */
  2670. void Veto();
  2671. };
  2672. /**
  2673. @class wxThreadEvent
  2674. This class adds some simple functionality to wxEvent to facilitate
  2675. inter-thread communication.
  2676. This event is not natively emitted by any control/class: it is just
  2677. a helper class for the user.
  2678. Its most important feature is the GetEventCategory() implementation which
  2679. allows thread events @b NOT to be processed by wxEventLoopBase::YieldFor calls
  2680. (unless the @c wxEVT_CATEGORY_THREAD is specified - which is never in wx code).
  2681. @library{wxcore}
  2682. @category{events,threading}
  2683. @see @ref overview_thread, wxEventLoopBase::YieldFor
  2684. @since 2.9.0
  2685. */
  2686. class wxThreadEvent : public wxEvent
  2687. {
  2688. public:
  2689. /**
  2690. Constructor.
  2691. */
  2692. wxThreadEvent(wxEventType eventType = wxEVT_THREAD, int id = wxID_ANY);
  2693. /**
  2694. Clones this event making sure that all internal members which use
  2695. COW (only @c m_commandString for now; see @ref overview_refcount)
  2696. are unshared (see wxObject::UnShare).
  2697. */
  2698. virtual wxEvent *Clone() const;
  2699. /**
  2700. Returns @c wxEVT_CATEGORY_THREAD.
  2701. This is important to avoid unwanted processing of thread events
  2702. when calling wxEventLoopBase::YieldFor().
  2703. */
  2704. virtual wxEventCategory GetEventCategory() const;
  2705. /**
  2706. Sets custom data payload.
  2707. The @a payload argument may be of any type that wxAny can handle
  2708. (i.e. pretty much anything). Note that T's copy constructor must be
  2709. thread-safe, i.e. create a copy that doesn't share anything with
  2710. the original (see Clone()).
  2711. @note This method is not available with Visual C++ 6.
  2712. @since 2.9.1
  2713. @see GetPayload(), wxAny
  2714. */
  2715. template<typename T>
  2716. void SetPayload(const T& payload);
  2717. /**
  2718. Get custom data payload.
  2719. Correct type is checked in debug builds.
  2720. @note This method is not available with Visual C++ 6.
  2721. @since 2.9.1
  2722. @see SetPayload(), wxAny
  2723. */
  2724. template<typename T>
  2725. T GetPayload() const;
  2726. /**
  2727. Returns extra information integer value.
  2728. */
  2729. long GetExtraLong() const;
  2730. /**
  2731. Returns stored integer value.
  2732. */
  2733. int GetInt() const;
  2734. /**
  2735. Returns stored string value.
  2736. */
  2737. wxString GetString() const;
  2738. /**
  2739. Sets the extra information value.
  2740. */
  2741. void SetExtraLong(long extraLong);
  2742. /**
  2743. Sets the integer value.
  2744. */
  2745. void SetInt(int intCommand);
  2746. /**
  2747. Sets the string value.
  2748. */
  2749. void SetString(const wxString& string);
  2750. };
  2751. /**
  2752. @class wxHelpEvent
  2753. A help event is sent when the user has requested context-sensitive help.
  2754. This can either be caused by the application requesting context-sensitive help mode
  2755. via wxContextHelp, or (on MS Windows) by the system generating a WM_HELP message when
  2756. the user pressed F1 or clicked on the query button in a dialog caption.
  2757. A help event is sent to the window that the user clicked on, and is propagated
  2758. up the window hierarchy until the event is processed or there are no more event
  2759. handlers.
  2760. The application should call wxEvent::GetId to check the identity of the
  2761. clicked-on window, and then either show some suitable help or call wxEvent::Skip()
  2762. if the identifier is unrecognised.
  2763. Calling Skip is important because it allows wxWidgets to generate further
  2764. events for ancestors of the clicked-on window. Otherwise it would be impossible to
  2765. show help for container windows, since processing would stop after the first window
  2766. found.
  2767. @beginEventTable{wxHelpEvent}
  2768. @event{EVT_HELP(id, func)}
  2769. Process a @c wxEVT_HELP event.
  2770. @event{EVT_HELP_RANGE(id1, id2, func)}
  2771. Process a @c wxEVT_HELP event for a range of ids.
  2772. @endEventTable
  2773. @library{wxcore}
  2774. @category{events}
  2775. @see wxContextHelp, wxDialog, @ref overview_events
  2776. */
  2777. class wxHelpEvent : public wxCommandEvent
  2778. {
  2779. public:
  2780. /**
  2781. Indicates how a wxHelpEvent was generated.
  2782. */
  2783. enum Origin
  2784. {
  2785. Origin_Unknown, /**< unrecognized event source. */
  2786. Origin_Keyboard, /**< event generated from F1 key press. */
  2787. /** event generated by wxContextHelp or from the [?] button on
  2788. the title bar (Windows). */
  2789. Origin_HelpButton
  2790. };
  2791. /**
  2792. Constructor.
  2793. */
  2794. wxHelpEvent(wxEventType type = wxEVT_NULL,
  2795. wxWindowID winid = 0,
  2796. const wxPoint& pt = wxDefaultPosition,
  2797. wxHelpEvent::Origin origin = Origin_Unknown);
  2798. /**
  2799. Returns the origin of the help event which is one of the wxHelpEvent::Origin
  2800. values.
  2801. The application may handle events generated using the keyboard or mouse
  2802. differently, e.g. by using wxGetMousePosition() for the mouse events.
  2803. @see SetOrigin()
  2804. */
  2805. wxHelpEvent::Origin GetOrigin() const;
  2806. /**
  2807. Returns the left-click position of the mouse, in screen coordinates.
  2808. This allows the application to position the help appropriately.
  2809. */
  2810. const wxPoint& GetPosition() const;
  2811. /**
  2812. Set the help event origin, only used internally by wxWidgets normally.
  2813. @see GetOrigin()
  2814. */
  2815. void SetOrigin(wxHelpEvent::Origin origin);
  2816. /**
  2817. Sets the left-click position of the mouse, in screen coordinates.
  2818. */
  2819. void SetPosition(const wxPoint& pt);
  2820. };
  2821. /**
  2822. @class wxScrollEvent
  2823. A scroll event holds information about events sent from stand-alone
  2824. scrollbars (see wxScrollBar) and sliders (see wxSlider).
  2825. Note that scrolled windows send the wxScrollWinEvent which does not derive from
  2826. wxCommandEvent, but from wxEvent directly - don't confuse these two kinds of
  2827. events and use the event table macros mentioned below only for the scrollbar-like
  2828. controls.
  2829. @section scrollevent_diff The difference between EVT_SCROLL_THUMBRELEASE and EVT_SCROLL_CHANGED
  2830. The EVT_SCROLL_THUMBRELEASE event is only emitted when actually dragging the thumb
  2831. using the mouse and releasing it (This EVT_SCROLL_THUMBRELEASE event is also followed
  2832. by an EVT_SCROLL_CHANGED event).
  2833. The EVT_SCROLL_CHANGED event also occurs when using the keyboard to change the thumb
  2834. position, and when clicking next to the thumb (In all these cases the EVT_SCROLL_THUMBRELEASE
  2835. event does not happen).
  2836. In short, the EVT_SCROLL_CHANGED event is triggered when scrolling/ moving has finished
  2837. independently of the way it had started. Please see the widgets sample ("Slider" page)
  2838. to see the difference between EVT_SCROLL_THUMBRELEASE and EVT_SCROLL_CHANGED in action.
  2839. @remarks
  2840. Note that unless specifying a scroll control identifier, you will need to test for scrollbar
  2841. orientation with wxScrollEvent::GetOrientation, since horizontal and vertical scroll events
  2842. are processed using the same event handler.
  2843. @beginEventTable{wxScrollEvent}
  2844. You can use EVT_COMMAND_SCROLL... macros with window IDs for when intercepting
  2845. scroll events from controls, or EVT_SCROLL... macros without window IDs for
  2846. intercepting scroll events from the receiving window -- except for this, the
  2847. macros behave exactly the same.
  2848. @event{EVT_SCROLL(func)}
  2849. Process all scroll events.
  2850. @event{EVT_SCROLL_TOP(func)}
  2851. Process @c wxEVT_SCROLL_TOP scroll-to-top events (minimum position).
  2852. @event{EVT_SCROLL_BOTTOM(func)}
  2853. Process @c wxEVT_SCROLL_BOTTOM scroll-to-bottom events (maximum position).
  2854. @event{EVT_SCROLL_LINEUP(func)}
  2855. Process @c wxEVT_SCROLL_LINEUP line up events.
  2856. @event{EVT_SCROLL_LINEDOWN(func)}
  2857. Process @c wxEVT_SCROLL_LINEDOWN line down events.
  2858. @event{EVT_SCROLL_PAGEUP(func)}
  2859. Process @c wxEVT_SCROLL_PAGEUP page up events.
  2860. @event{EVT_SCROLL_PAGEDOWN(func)}
  2861. Process @c wxEVT_SCROLL_PAGEDOWN page down events.
  2862. @event{EVT_SCROLL_THUMBTRACK(func)}
  2863. Process @c wxEVT_SCROLL_THUMBTRACK thumbtrack events (frequent events sent as the
  2864. user drags the thumbtrack).
  2865. @event{EVT_SCROLL_THUMBRELEASE(func)}
  2866. Process @c wxEVT_SCROLL_THUMBRELEASE thumb release events.
  2867. @event{EVT_SCROLL_CHANGED(func)}
  2868. Process @c wxEVT_SCROLL_CHANGED end of scrolling events (MSW only).
  2869. @event{EVT_COMMAND_SCROLL(id, func)}
  2870. Process all scroll events.
  2871. @event{EVT_COMMAND_SCROLL_TOP(id, func)}
  2872. Process @c wxEVT_SCROLL_TOP scroll-to-top events (minimum position).
  2873. @event{EVT_COMMAND_SCROLL_BOTTOM(id, func)}
  2874. Process @c wxEVT_SCROLL_BOTTOM scroll-to-bottom events (maximum position).
  2875. @event{EVT_COMMAND_SCROLL_LINEUP(id, func)}
  2876. Process @c wxEVT_SCROLL_LINEUP line up events.
  2877. @event{EVT_COMMAND_SCROLL_LINEDOWN(id, func)}
  2878. Process @c wxEVT_SCROLL_LINEDOWN line down events.
  2879. @event{EVT_COMMAND_SCROLL_PAGEUP(id, func)}
  2880. Process @c wxEVT_SCROLL_PAGEUP page up events.
  2881. @event{EVT_COMMAND_SCROLL_PAGEDOWN(id, func)}
  2882. Process @c wxEVT_SCROLL_PAGEDOWN page down events.
  2883. @event{EVT_COMMAND_SCROLL_THUMBTRACK(id, func)}
  2884. Process @c wxEVT_SCROLL_THUMBTRACK thumbtrack events (frequent events sent
  2885. as the user drags the thumbtrack).
  2886. @event{EVT_COMMAND_SCROLL_THUMBRELEASE(func)}
  2887. Process @c wxEVT_SCROLL_THUMBRELEASE thumb release events.
  2888. @event{EVT_COMMAND_SCROLL_CHANGED(func)}
  2889. Process @c wxEVT_SCROLL_CHANGED end of scrolling events (MSW only).
  2890. @endEventTable
  2891. @library{wxcore}
  2892. @category{events}
  2893. @see wxScrollBar, wxSlider, wxSpinButton, wxScrollWinEvent, @ref overview_events
  2894. */
  2895. class wxScrollEvent : public wxCommandEvent
  2896. {
  2897. public:
  2898. /**
  2899. Constructor.
  2900. */
  2901. wxScrollEvent(wxEventType commandType = wxEVT_NULL, int id = 0, int pos = 0,
  2902. int orientation = 0);
  2903. /**
  2904. Returns wxHORIZONTAL or wxVERTICAL, depending on the orientation of the
  2905. scrollbar.
  2906. */
  2907. int GetOrientation() const;
  2908. /**
  2909. Returns the position of the scrollbar.
  2910. */
  2911. int GetPosition() const;
  2912. void SetOrientation(int orient);
  2913. void SetPosition(int pos);
  2914. };
  2915. #endif // wxUSE_GUI
  2916. #if wxUSE_BASE
  2917. /**
  2918. See wxIdleEvent::SetMode() for more info.
  2919. */
  2920. enum wxIdleMode
  2921. {
  2922. /** Send idle events to all windows */
  2923. wxIDLE_PROCESS_ALL,
  2924. /** Send idle events to windows that have the wxWS_EX_PROCESS_IDLE flag specified */
  2925. wxIDLE_PROCESS_SPECIFIED
  2926. };
  2927. /**
  2928. @class wxIdleEvent
  2929. This class is used for idle events, which are generated when the system becomes
  2930. idle. Note that, unless you do something specifically, the idle events are not
  2931. sent if the system remains idle once it has become it, e.g. only a single idle
  2932. event will be generated until something else resulting in more normal events
  2933. happens and only then is the next idle event sent again.
  2934. If you need to ensure a continuous stream of idle events, you can either use
  2935. wxIdleEvent::RequestMore method in your handler or call wxWakeUpIdle() periodically
  2936. (for example from a timer event handler), but note that both of these approaches
  2937. (and especially the first one) increase the system load and so should be avoided
  2938. if possible.
  2939. By default, idle events are sent to all windows, including even the hidden
  2940. ones because they may be shown if some condition is met from their @c
  2941. wxEVT_IDLE (or related @c wxEVT_UPDATE_UI) handler. The children of hidden
  2942. windows do not receive idle events however as they can't change their state
  2943. in any way noticeable by the user. Finally, the global wxApp object also
  2944. receives these events, as usual, so it can be used for any global idle time
  2945. processing.
  2946. If sending idle events to all windows is causing a significant overhead in
  2947. your application, you can call wxIdleEvent::SetMode with the value
  2948. wxIDLE_PROCESS_SPECIFIED, and set the wxWS_EX_PROCESS_IDLE extra window
  2949. style for every window which should receive idle events, all the other ones
  2950. will not receive them in this case.
  2951. @beginEventTable{wxIdleEvent}
  2952. @event{EVT_IDLE(func)}
  2953. Process a @c wxEVT_IDLE event.
  2954. @endEventTable
  2955. @library{wxbase}
  2956. @category{events}
  2957. @section sec_delayed_action Delayed Action Mechanism
  2958. wxIdleEvent can be used to perform some action "at slightly later time".
  2959. This can be necessary in several circumstances when, for whatever reason,
  2960. something can't be done in the current event handler. For example, if a
  2961. mouse event handler is called with the mouse button pressed, the mouse can
  2962. be currently captured and some operations with it -- notably capturing it
  2963. again -- might be impossible or lead to undesirable results. If you still
  2964. want to capture it, you can do it from @c wxEVT_IDLE handler when it is
  2965. called the next time instead of doing it immediately.
  2966. This can be achieved in two different ways: when using static event tables,
  2967. you will need a flag indicating to the (always connected) idle event
  2968. handler whether the desired action should be performed. The originally
  2969. called handler would then set it to indicate that it should indeed be done
  2970. and the idle handler itself would reset it to prevent it from doing the
  2971. same action again.
  2972. Using dynamically connected event handlers things are even simpler as the
  2973. original event handler can simply wxEvtHandler::Connect() or
  2974. wxEvtHandler::Bind() the idle event handler which would only be executed
  2975. then and could wxEvtHandler::Disconnect() or wxEvtHandler::Unbind() itself.
  2976. @see @ref overview_events, wxUpdateUIEvent, wxWindow::OnInternalIdle
  2977. */
  2978. class wxIdleEvent : public wxEvent
  2979. {
  2980. public:
  2981. /**
  2982. Constructor.
  2983. */
  2984. wxIdleEvent();
  2985. /**
  2986. Static function returning a value specifying how wxWidgets will send idle
  2987. events: to all windows, or only to those which specify that they
  2988. will process the events.
  2989. @see SetMode().
  2990. */
  2991. static wxIdleMode GetMode();
  2992. /**
  2993. Returns @true if the OnIdle function processing this event requested more
  2994. processing time.
  2995. @see RequestMore()
  2996. */
  2997. bool MoreRequested() const;
  2998. /**
  2999. Tells wxWidgets that more processing is required.
  3000. This function can be called by an OnIdle handler for a window or window event
  3001. handler to indicate that wxApp::OnIdle should forward the OnIdle event once
  3002. more to the application windows.
  3003. If no window calls this function during OnIdle, then the application will
  3004. remain in a passive event loop (not calling OnIdle) until a new event is
  3005. posted to the application by the windowing system.
  3006. @see MoreRequested()
  3007. */
  3008. void RequestMore(bool needMore = true);
  3009. /**
  3010. Static function for specifying how wxWidgets will send idle events: to
  3011. all windows, or only to those which specify that they will process the events.
  3012. @param mode
  3013. Can be one of the ::wxIdleMode values.
  3014. The default is wxIDLE_PROCESS_ALL.
  3015. */
  3016. static void SetMode(wxIdleMode mode);
  3017. };
  3018. #endif // wxUSE_BASE
  3019. #if wxUSE_GUI
  3020. /**
  3021. @class wxInitDialogEvent
  3022. A wxInitDialogEvent is sent as a dialog or panel is being initialised.
  3023. Handlers for this event can transfer data to the window.
  3024. The default handler calls wxWindow::TransferDataToWindow.
  3025. @beginEventTable{wxInitDialogEvent}
  3026. @event{EVT_INIT_DIALOG(func)}
  3027. Process a @c wxEVT_INIT_DIALOG event.
  3028. @endEventTable
  3029. @library{wxcore}
  3030. @category{events}
  3031. @see @ref overview_events
  3032. */
  3033. class wxInitDialogEvent : public wxEvent
  3034. {
  3035. public:
  3036. /**
  3037. Constructor.
  3038. */
  3039. wxInitDialogEvent(int id = 0);
  3040. };
  3041. /**
  3042. @class wxWindowDestroyEvent
  3043. This event is sent as early as possible during the window destruction
  3044. process.
  3045. For the top level windows, as early as possible means that this is done by
  3046. wxFrame or wxDialog destructor, i.e. after the destructor of the derived
  3047. class was executed and so any methods specific to the derived class can't
  3048. be called any more from this event handler. If you need to do this, you
  3049. must call wxWindow::SendDestroyEvent() from your derived class destructor.
  3050. For the child windows, this event is generated just before deleting the
  3051. window from wxWindow::Destroy() (which is also called when the parent
  3052. window is deleted) or from the window destructor if operator @c delete was
  3053. used directly (which is not recommended for this very reason).
  3054. It is usually pointless to handle this event in the window itself but it ca
  3055. be very useful to receive notifications about the window destruction in the
  3056. parent window or in any other object interested in this window.
  3057. @library{wxcore}
  3058. @category{events}
  3059. @see @ref overview_events, wxWindowCreateEvent
  3060. */
  3061. class wxWindowDestroyEvent : public wxCommandEvent
  3062. {
  3063. public:
  3064. /**
  3065. Constructor.
  3066. */
  3067. wxWindowDestroyEvent(wxWindow* win = NULL);
  3068. /// Return the window being destroyed.
  3069. wxWindow *GetWindow() const;
  3070. };
  3071. /**
  3072. @class wxNavigationKeyEvent
  3073. This event class contains information about navigation events,
  3074. generated by navigation keys such as tab and page down.
  3075. This event is mainly used by wxWidgets implementations.
  3076. A wxNavigationKeyEvent handler is automatically provided by wxWidgets
  3077. when you enable keyboard navigation inside a window by inheriting it from
  3078. wxNavigationEnabled<>.
  3079. @beginEventTable{wxNavigationKeyEvent}
  3080. @event{EVT_NAVIGATION_KEY(func)}
  3081. Process a navigation key event.
  3082. @endEventTable
  3083. @library{wxcore}
  3084. @category{events}
  3085. @see wxWindow::Navigate, wxWindow::NavigateIn
  3086. */
  3087. class wxNavigationKeyEvent : public wxEvent
  3088. {
  3089. public:
  3090. /**
  3091. Flags which can be used with wxNavigationKeyEvent.
  3092. */
  3093. enum wxNavigationKeyEventFlags
  3094. {
  3095. IsBackward = 0x0000,
  3096. IsForward = 0x0001,
  3097. WinChange = 0x0002,
  3098. FromTab = 0x0004
  3099. };
  3100. wxNavigationKeyEvent();
  3101. wxNavigationKeyEvent(const wxNavigationKeyEvent& event);
  3102. /**
  3103. Returns the child that has the focus, or @NULL.
  3104. */
  3105. wxWindow* GetCurrentFocus() const;
  3106. /**
  3107. Returns @true if the navigation was in the forward direction.
  3108. */
  3109. bool GetDirection() const;
  3110. /**
  3111. Returns @true if the navigation event was from a tab key.
  3112. This is required for proper navigation over radio buttons.
  3113. */
  3114. bool IsFromTab() const;
  3115. /**
  3116. Returns @true if the navigation event represents a window change
  3117. (for example, from Ctrl-Page Down in a notebook).
  3118. */
  3119. bool IsWindowChange() const;
  3120. /**
  3121. Sets the current focus window member.
  3122. */
  3123. void SetCurrentFocus(wxWindow* currentFocus);
  3124. /**
  3125. Sets the direction to forward if @a direction is @true, or backward
  3126. if @false.
  3127. */
  3128. void SetDirection(bool direction);
  3129. /**
  3130. Sets the flags for this event.
  3131. The @a flags can be a combination of the
  3132. wxNavigationKeyEvent::wxNavigationKeyEventFlags values.
  3133. */
  3134. void SetFlags(long flags);
  3135. /**
  3136. Marks the navigation event as from a tab key.
  3137. */
  3138. void SetFromTab(bool fromTab);
  3139. /**
  3140. Marks the event as a window change event.
  3141. */
  3142. void SetWindowChange(bool windowChange);
  3143. };
  3144. /**
  3145. @class wxMouseCaptureChangedEvent
  3146. An mouse capture changed event is sent to a window that loses its
  3147. mouse capture. This is called even if wxWindow::ReleaseMouse
  3148. was called by the application code. Handling this event allows
  3149. an application to cater for unexpected capture releases which
  3150. might otherwise confuse mouse handling code.
  3151. @onlyfor{wxmsw}
  3152. @beginEventTable{wxMouseCaptureChangedEvent}
  3153. @event{EVT_MOUSE_CAPTURE_CHANGED(func)}
  3154. Process a @c wxEVT_MOUSE_CAPTURE_CHANGED event.
  3155. @endEventTable
  3156. @library{wxcore}
  3157. @category{events}
  3158. @see wxMouseCaptureLostEvent, @ref overview_events,
  3159. wxWindow::CaptureMouse, wxWindow::ReleaseMouse, wxWindow::GetCapture
  3160. */
  3161. class wxMouseCaptureChangedEvent : public wxEvent
  3162. {
  3163. public:
  3164. /**
  3165. Constructor.
  3166. */
  3167. wxMouseCaptureChangedEvent(wxWindowID windowId = 0,
  3168. wxWindow* gainedCapture = NULL);
  3169. /**
  3170. Returns the window that gained the capture, or @NULL if it was a
  3171. non-wxWidgets window.
  3172. */
  3173. wxWindow* GetCapturedWindow() const;
  3174. };
  3175. /**
  3176. @class wxCloseEvent
  3177. This event class contains information about window and session close events.
  3178. The handler function for EVT_CLOSE is called when the user has tried to close a
  3179. a frame or dialog box using the window manager (X) or system menu (Windows).
  3180. It can also be invoked by the application itself programmatically, for example by
  3181. calling the wxWindow::Close function.
  3182. You should check whether the application is forcing the deletion of the window
  3183. using wxCloseEvent::CanVeto. If this is @false, you @e must destroy the window
  3184. using wxWindow::Destroy.
  3185. If the return value is @true, it is up to you whether you respond by destroying
  3186. the window.
  3187. If you don't destroy the window, you should call wxCloseEvent::Veto to
  3188. let the calling code know that you did not destroy the window.
  3189. This allows the wxWindow::Close function to return @true or @false depending
  3190. on whether the close instruction was honoured or not.
  3191. Example of a wxCloseEvent handler:
  3192. @code
  3193. void MyFrame::OnClose(wxCloseEvent& event)
  3194. {
  3195. if ( event.CanVeto() && m_bFileNotSaved )
  3196. {
  3197. if ( wxMessageBox("The file has not been saved... continue closing?",
  3198. "Please confirm",
  3199. wxICON_QUESTION | wxYES_NO) != wxYES )
  3200. {
  3201. event.Veto();
  3202. return;
  3203. }
  3204. }
  3205. Destroy(); // you may also do: event.Skip();
  3206. // since the default event handler does call Destroy(), too
  3207. }
  3208. @endcode
  3209. The EVT_END_SESSION event is slightly different as it is sent by the system
  3210. when the user session is ending (e.g. because of log out or shutdown) and
  3211. so all windows are being forcefully closed. At least under MSW, after the
  3212. handler for this event is executed the program is simply killed by the
  3213. system. Because of this, the default handler for this event provided by
  3214. wxWidgets calls all the usual cleanup code (including wxApp::OnExit()) so
  3215. that it could still be executed and exit()s the process itself, without
  3216. waiting for being killed. If this behaviour is for some reason undesirable,
  3217. make sure that you define a handler for this event in your wxApp-derived
  3218. class and do not call @c event.Skip() in it (but be aware that the system
  3219. will still kill your application).
  3220. @beginEventTable{wxCloseEvent}
  3221. @event{EVT_CLOSE(func)}
  3222. Process a @c wxEVT_CLOSE_WINDOW command event, supplying the member function.
  3223. This event applies to wxFrame and wxDialog classes.
  3224. @event{EVT_QUERY_END_SESSION(func)}
  3225. Process a @c wxEVT_QUERY_END_SESSION session event, supplying the member function.
  3226. This event can be handled in wxApp-derived class only.
  3227. @event{EVT_END_SESSION(func)}
  3228. Process a @c wxEVT_END_SESSION session event, supplying the member function.
  3229. This event can be handled in wxApp-derived class only.
  3230. @endEventTable
  3231. @library{wxcore}
  3232. @category{events}
  3233. @see wxWindow::Close, @ref overview_windowdeletion
  3234. */
  3235. class wxCloseEvent : public wxEvent
  3236. {
  3237. public:
  3238. /**
  3239. Constructor.
  3240. */
  3241. wxCloseEvent(wxEventType commandEventType = wxEVT_NULL, int id = 0);
  3242. /**
  3243. Returns @true if you can veto a system shutdown or a window close event.
  3244. Vetoing a window close event is not possible if the calling code wishes to
  3245. force the application to exit, and so this function must be called to check this.
  3246. */
  3247. bool CanVeto() const;
  3248. /**
  3249. Returns @true if the user is just logging off or @false if the system is
  3250. shutting down. This method can only be called for end session and query end
  3251. session events, it doesn't make sense for close window event.
  3252. */
  3253. bool GetLoggingOff() const;
  3254. /**
  3255. Sets the 'can veto' flag.
  3256. */
  3257. void SetCanVeto(bool canVeto);
  3258. /**
  3259. Sets the 'logging off' flag.
  3260. */
  3261. void SetLoggingOff(bool loggingOff);
  3262. /**
  3263. Call this from your event handler to veto a system shutdown or to signal
  3264. to the calling application that a window close did not happen.
  3265. You can only veto a shutdown if CanVeto() returns @true.
  3266. */
  3267. void Veto(bool veto = true);
  3268. /**
  3269. Returns whether the Veto flag was set.
  3270. */
  3271. bool GetVeto() const;
  3272. };
  3273. /**
  3274. @class wxMenuEvent
  3275. This class is used for a variety of menu-related events. Note that
  3276. these do not include menu command events, which are
  3277. handled using wxCommandEvent objects.
  3278. The default handler for @c wxEVT_MENU_HIGHLIGHT displays help
  3279. text in the first field of the status bar.
  3280. @beginEventTable{wxMenuEvent}
  3281. @event{EVT_MENU_OPEN(func)}
  3282. A menu is about to be opened. On Windows, this is only sent once for each
  3283. navigation of the menubar (up until all menus have closed).
  3284. @event{EVT_MENU_CLOSE(func)}
  3285. A menu has been just closed. Notice that this event is currently being
  3286. sent before the menu selection (@c wxEVT_MENU) event, if any.
  3287. @event{EVT_MENU_HIGHLIGHT(id, func)}
  3288. The menu item with the specified id has been highlighted: used to show
  3289. help prompts in the status bar by wxFrame
  3290. @event{EVT_MENU_HIGHLIGHT_ALL(func)}
  3291. A menu item has been highlighted, i.e. the currently selected menu item has changed.
  3292. @endEventTable
  3293. @library{wxcore}
  3294. @category{events}
  3295. @see wxCommandEvent, @ref overview_events
  3296. */
  3297. class wxMenuEvent : public wxEvent
  3298. {
  3299. public:
  3300. /**
  3301. Constructor.
  3302. */
  3303. wxMenuEvent(wxEventType type = wxEVT_NULL, int id = 0, wxMenu* menu = NULL);
  3304. /**
  3305. Returns the menu which is being opened or closed.
  3306. This method can only be used with the @c OPEN and @c CLOSE events.
  3307. The returned value is never @NULL in the ports implementing this
  3308. function, which currently includes all the major ones.
  3309. */
  3310. wxMenu* GetMenu() const;
  3311. /**
  3312. Returns the menu identifier associated with the event.
  3313. This method should be only used with the @c HIGHLIGHT events.
  3314. */
  3315. int GetMenuId() const;
  3316. /**
  3317. Returns @true if the menu which is being opened or closed is a popup menu,
  3318. @false if it is a normal one.
  3319. This method should only be used with the @c OPEN and @c CLOSE events.
  3320. */
  3321. bool IsPopup() const;
  3322. };
  3323. /**
  3324. @class wxShowEvent
  3325. An event being sent when the window is shown or hidden.
  3326. The event is triggered by calls to wxWindow::Show(), and any user
  3327. action showing a previously hidden window or vice versa (if allowed by
  3328. the current platform and/or window manager).
  3329. Notice that the event is not triggered when the application is iconized
  3330. (minimized) or restored under wxMSW.
  3331. @onlyfor{wxmsw,wxgtk,wxos2}
  3332. @beginEventTable{wxShowEvent}
  3333. @event{EVT_SHOW(func)}
  3334. Process a @c wxEVT_SHOW event.
  3335. @endEventTable
  3336. @library{wxcore}
  3337. @category{events}
  3338. @see @ref overview_events, wxWindow::Show,
  3339. wxWindow::IsShown
  3340. */
  3341. class wxShowEvent : public wxEvent
  3342. {
  3343. public:
  3344. /**
  3345. Constructor.
  3346. */
  3347. wxShowEvent(int winid = 0, bool show = false);
  3348. /**
  3349. Set whether the windows was shown or hidden.
  3350. */
  3351. void SetShow(bool show);
  3352. /**
  3353. Return @true if the window has been shown, @false if it has been
  3354. hidden.
  3355. */
  3356. bool IsShown() const;
  3357. /**
  3358. @deprecated This function is deprecated in favour of IsShown().
  3359. */
  3360. bool GetShow() const;
  3361. };
  3362. /**
  3363. @class wxIconizeEvent
  3364. An event being sent when the frame is iconized (minimized) or restored.
  3365. Currently only wxMSW and wxGTK generate such events.
  3366. @onlyfor{wxmsw,wxgtk}
  3367. @beginEventTable{wxIconizeEvent}
  3368. @event{EVT_ICONIZE(func)}
  3369. Process a @c wxEVT_ICONIZE event.
  3370. @endEventTable
  3371. @library{wxcore}
  3372. @category{events}
  3373. @see @ref overview_events, wxTopLevelWindow::Iconize,
  3374. wxTopLevelWindow::IsIconized
  3375. */
  3376. class wxIconizeEvent : public wxEvent
  3377. {
  3378. public:
  3379. /**
  3380. Constructor.
  3381. */
  3382. wxIconizeEvent(int id = 0, bool iconized = true);
  3383. /**
  3384. Returns @true if the frame has been iconized, @false if it has been
  3385. restored.
  3386. */
  3387. bool IsIconized() const;
  3388. /**
  3389. @deprecated This function is deprecated in favour of IsIconized().
  3390. */
  3391. bool Iconized() const;
  3392. };
  3393. /**
  3394. @class wxMoveEvent
  3395. A move event holds information about wxTopLevelWindow move change events.
  3396. These events are currently only generated by wxMSW port.
  3397. @beginEventTable{wxMoveEvent}
  3398. @event{EVT_MOVE(func)}
  3399. Process a @c wxEVT_MOVE event, which is generated when a window is moved.
  3400. @event{EVT_MOVE_START(func)}
  3401. Process a @c wxEVT_MOVE_START event, which is generated when the user starts
  3402. to move or size a window. wxMSW only.
  3403. @event{EVT_MOVING(func)}
  3404. Process a @c wxEVT_MOVING event, which is generated while the user is
  3405. moving the window. wxMSW only.
  3406. @event{EVT_MOVE_END(func)}
  3407. Process a @c wxEVT_MOVE_END event, which is generated when the user stops
  3408. moving or sizing a window. wxMSW only.
  3409. @endEventTable
  3410. @library{wxcore}
  3411. @category{events}
  3412. @see wxPoint, @ref overview_events
  3413. */
  3414. class wxMoveEvent : public wxEvent
  3415. {
  3416. public:
  3417. /**
  3418. Constructor.
  3419. */
  3420. wxMoveEvent(const wxPoint& pt, int id = 0);
  3421. /**
  3422. Returns the position of the window generating the move change event.
  3423. */
  3424. wxPoint GetPosition() const;
  3425. wxRect GetRect() const;
  3426. void SetRect(const wxRect& rect);
  3427. void SetPosition(const wxPoint& pos);
  3428. };
  3429. /**
  3430. @class wxSizeEvent
  3431. A size event holds information about size change events of wxWindow.
  3432. The EVT_SIZE handler function will be called when the window has been resized.
  3433. You may wish to use this for frames to resize their child windows as appropriate.
  3434. Note that the size passed is of the whole window: call wxWindow::GetClientSize()
  3435. for the area which may be used by the application.
  3436. When a window is resized, usually only a small part of the window is damaged
  3437. and you may only need to repaint that area. However, if your drawing depends on the
  3438. size of the window, you may need to clear the DC explicitly and repaint the whole window.
  3439. In which case, you may need to call wxWindow::Refresh to invalidate the entire window.
  3440. @b Important : Sizers ( see @ref overview_sizer ) rely on size events to function
  3441. correctly. Therefore, in a sizer-based layout, do not forget to call Skip on all
  3442. size events you catch (and don't catch size events at all when you don't need to).
  3443. @beginEventTable{wxSizeEvent}
  3444. @event{EVT_SIZE(func)}
  3445. Process a @c wxEVT_SIZE event.
  3446. @endEventTable
  3447. @library{wxcore}
  3448. @category{events}
  3449. @see wxSize, @ref overview_events
  3450. */
  3451. class wxSizeEvent : public wxEvent
  3452. {
  3453. public:
  3454. /**
  3455. Constructor.
  3456. */
  3457. wxSizeEvent(const wxSize& sz, int id = 0);
  3458. /**
  3459. Returns the entire size of the window generating the size change event.
  3460. This is the new total size of the window, i.e. the same size as would
  3461. be returned by wxWindow::GetSize() if it were called now. Use
  3462. wxWindow::GetClientSize() if you catch this event in a top level window
  3463. such as wxFrame to find the size available for the window contents.
  3464. */
  3465. wxSize GetSize() const;
  3466. void SetSize(wxSize size);
  3467. wxRect GetRect() const;
  3468. void SetRect(wxRect rect);
  3469. };
  3470. /**
  3471. @class wxSetCursorEvent
  3472. A wxSetCursorEvent is generated from wxWindow when the mouse cursor is about
  3473. to be set as a result of mouse motion.
  3474. This event gives the application the chance to perform specific mouse cursor
  3475. processing based on the current position of the mouse within the window.
  3476. Use wxSetCursorEvent::SetCursor to specify the cursor you want to be displayed.
  3477. @beginEventTable{wxSetCursorEvent}
  3478. @event{EVT_SET_CURSOR(func)}
  3479. Process a @c wxEVT_SET_CURSOR event.
  3480. @endEventTable
  3481. @library{wxcore}
  3482. @category{events}
  3483. @see ::wxSetCursor, wxWindow::SetCursor
  3484. */
  3485. class wxSetCursorEvent : public wxEvent
  3486. {
  3487. public:
  3488. /**
  3489. Constructor, used by the library itself internally to initialize the event
  3490. object.
  3491. */
  3492. wxSetCursorEvent(wxCoord x = 0, wxCoord y = 0);
  3493. /**
  3494. Returns a reference to the cursor specified by this event.
  3495. */
  3496. const wxCursor& GetCursor() const;
  3497. /**
  3498. Returns the X coordinate of the mouse in client coordinates.
  3499. */
  3500. wxCoord GetX() const;
  3501. /**
  3502. Returns the Y coordinate of the mouse in client coordinates.
  3503. */
  3504. wxCoord GetY() const;
  3505. /**
  3506. Returns @true if the cursor specified by this event is a valid cursor.
  3507. @remarks You cannot specify wxNullCursor with this event, as it is not
  3508. considered a valid cursor.
  3509. */
  3510. bool HasCursor() const;
  3511. /**
  3512. Sets the cursor associated with this event.
  3513. */
  3514. void SetCursor(const wxCursor& cursor);
  3515. };
  3516. #endif // wxUSE_GUI
  3517. // ============================================================================
  3518. // Global functions/macros
  3519. // ============================================================================
  3520. /** @addtogroup group_funcmacro_events */
  3521. //@{
  3522. #if wxUSE_BASE
  3523. /**
  3524. A value uniquely identifying the type of the event.
  3525. The values of this type should only be created using wxNewEventType().
  3526. See the macro DEFINE_EVENT_TYPE() for more info.
  3527. @see @ref overview_events
  3528. */
  3529. typedef int wxEventType;
  3530. /**
  3531. A special event type usually used to indicate that some wxEvent has yet
  3532. no type assigned.
  3533. */
  3534. wxEventType wxEVT_NULL;
  3535. wxEventType wxEVT_ANY;
  3536. /**
  3537. Generates a new unique event type.
  3538. Usually this function is only used by wxDEFINE_EVENT() and not called
  3539. directly.
  3540. */
  3541. wxEventType wxNewEventType();
  3542. /**
  3543. Define a new event type associated with the specified event class.
  3544. This macro defines a new unique event type @a name associated with the
  3545. event class @a cls.
  3546. For example:
  3547. @code
  3548. wxDEFINE_EVENT(MY_COMMAND_EVENT, wxCommandEvent);
  3549. class MyCustomEvent : public wxEvent { ... };
  3550. wxDEFINE_EVENT(MY_CUSTOM_EVENT, MyCustomEvent);
  3551. @endcode
  3552. @see wxDECLARE_EVENT(), @ref overview_events_custom
  3553. */
  3554. #define wxDEFINE_EVENT(name, cls) \
  3555. const wxEventTypeTag< cls > name(wxNewEventType())
  3556. /**
  3557. Declares a custom event type.
  3558. This macro declares a variable called @a name which must be defined
  3559. elsewhere using wxDEFINE_EVENT().
  3560. The class @a cls must be the wxEvent-derived class associated with the
  3561. events of this type and its full declaration must be visible from the point
  3562. of use of this macro.
  3563. For example:
  3564. @code
  3565. wxDECLARE_EVENT(MY_COMMAND_EVENT, wxCommandEvent);
  3566. class MyCustomEvent : public wxEvent { ... };
  3567. wxDECLARE_EVENT(MY_CUSTOM_EVENT, MyCustomEvent);
  3568. @endcode
  3569. */
  3570. #define wxDECLARE_EVENT(name, cls) \
  3571. wxDECLARE_EXPORTED_EVENT(wxEMPTY_PARAMETER_VALUE, name, cls)
  3572. /**
  3573. Variant of wxDECLARE_EVENT() used for event types defined inside a shared
  3574. library.
  3575. This is mostly used by wxWidgets internally, e.g.
  3576. @code
  3577. wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_BUTTON, wxCommandEvent)
  3578. @endcode
  3579. */
  3580. #define wxDECLARE_EXPORTED_EVENT( expdecl, name, cls ) \
  3581. extern const expdecl wxEventTypeTag< cls > name;
  3582. /**
  3583. Helper macro for definition of custom event table macros.
  3584. This macro must only be used if wxEVENTS_COMPATIBILITY_2_8 is 1, otherwise
  3585. it is better and more clear to just use the address of the function
  3586. directly as this is all this macro does in this case. However it needs to
  3587. explicitly cast @a func to @a functype, which is the type of wxEvtHandler
  3588. member function taking the custom event argument when
  3589. wxEVENTS_COMPATIBILITY_2_8 is 0.
  3590. See wx__DECLARE_EVT0 for an example of use.
  3591. @see @ref overview_events_custom_ownclass
  3592. */
  3593. #define wxEVENT_HANDLER_CAST(functype, func) (&func)
  3594. /**
  3595. This macro is used to define event table macros for handling custom
  3596. events.
  3597. Example of use:
  3598. @code
  3599. class MyEvent : public wxEvent { ... };
  3600. // note that this is not necessary unless using old compilers: for the
  3601. // reasonably new ones just use &func instead of MyEventHandler(func)
  3602. typedef void (wxEvtHandler::*MyEventFunction)(MyEvent&);
  3603. #define MyEventHandler(func) wxEVENT_HANDLER_CAST(MyEventFunction, func)
  3604. wxDEFINE_EVENT(MY_EVENT_TYPE, MyEvent);
  3605. #define EVT_MY(id, func) \
  3606. wx__DECLARE_EVT1(MY_EVENT_TYPE, id, MyEventHandler(func))
  3607. ...
  3608. wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
  3609. EVT_MY(wxID_ANY, MyFrame::OnMyEvent)
  3610. wxEND_EVENT_TABLE()
  3611. @endcode
  3612. @param evt
  3613. The event type to handle.
  3614. @param id
  3615. The identifier of events to handle.
  3616. @param fn
  3617. The event handler method.
  3618. */
  3619. #define wx__DECLARE_EVT1(evt, id, fn) \
  3620. wx__DECLARE_EVT2(evt, id, wxID_ANY, fn)
  3621. /**
  3622. Generalized version of the wx__DECLARE_EVT1() macro taking a range of
  3623. IDs instead of a single one.
  3624. Argument @a id1 is the first identifier of the range, @a id2 is the
  3625. second identifier of the range.
  3626. */
  3627. #define wx__DECLARE_EVT2(evt, id1, id2, fn) \
  3628. DECLARE_EVENT_TABLE_ENTRY(evt, id1, id2, fn, NULL),
  3629. /**
  3630. Simplified version of the wx__DECLARE_EVT1() macro, to be used when the
  3631. event type must be handled regardless of the ID associated with the
  3632. specific event instances.
  3633. */
  3634. #define wx__DECLARE_EVT0(evt, fn) \
  3635. wx__DECLARE_EVT1(evt, wxID_ANY, fn)
  3636. /**
  3637. Use this macro inside a class declaration to declare a @e static event table
  3638. for that class.
  3639. In the implementation file you'll need to use the wxBEGIN_EVENT_TABLE()
  3640. and the wxEND_EVENT_TABLE() macros, plus some additional @c EVT_xxx macro
  3641. to capture events.
  3642. Note that this macro requires a final semicolon.
  3643. @see @ref overview_events_eventtables
  3644. */
  3645. #define wxDECLARE_EVENT_TABLE()
  3646. /**
  3647. Use this macro in a source file to start listing @e static event handlers
  3648. for a specific class.
  3649. Use wxEND_EVENT_TABLE() to terminate the event-declaration block.
  3650. @see @ref overview_events_eventtables
  3651. */
  3652. #define wxBEGIN_EVENT_TABLE(theClass, baseClass)
  3653. /**
  3654. Use this macro in a source file to end listing @e static event handlers
  3655. for a specific class.
  3656. Use wxBEGIN_EVENT_TABLE() to start the event-declaration block.
  3657. @see @ref overview_events_eventtables
  3658. */
  3659. #define wxEND_EVENT_TABLE()
  3660. /**
  3661. In a GUI application, this function posts @a event to the specified @e dest
  3662. object using wxEvtHandler::AddPendingEvent().
  3663. Otherwise, it dispatches @a event immediately using
  3664. wxEvtHandler::ProcessEvent(). See the respective documentation for details
  3665. (and caveats). Because of limitation of wxEvtHandler::AddPendingEvent()
  3666. this function is not thread-safe for event objects having wxString fields,
  3667. use wxQueueEvent() instead.
  3668. @header{wx/event.h}
  3669. */
  3670. void wxPostEvent(wxEvtHandler* dest, const wxEvent& event);
  3671. /**
  3672. Queue an event for processing on the given object.
  3673. This is a wrapper around wxEvtHandler::QueueEvent(), see its documentation
  3674. for more details.
  3675. @header{wx/event.h}
  3676. @param dest
  3677. The object to queue the event on, can't be @c NULL.
  3678. @param event
  3679. The heap-allocated and non-@c NULL event to queue, the function takes
  3680. ownership of it.
  3681. */
  3682. void wxQueueEvent(wxEvtHandler* dest, wxEvent *event);
  3683. #endif // wxUSE_BASE
  3684. #if wxUSE_GUI
  3685. wxEventType wxEVT_BUTTON;
  3686. wxEventType wxEVT_CHECKBOX;
  3687. wxEventType wxEVT_CHOICE;
  3688. wxEventType wxEVT_LISTBOX;
  3689. wxEventType wxEVT_LISTBOX_DCLICK;
  3690. wxEventType wxEVT_CHECKLISTBOX;
  3691. wxEventType wxEVT_MENU;
  3692. wxEventType wxEVT_SLIDER;
  3693. wxEventType wxEVT_RADIOBOX;
  3694. wxEventType wxEVT_RADIOBUTTON;
  3695. wxEventType wxEVT_SCROLLBAR;
  3696. wxEventType wxEVT_VLBOX;
  3697. wxEventType wxEVT_COMBOBOX;
  3698. wxEventType wxEVT_TOOL_RCLICKED;
  3699. wxEventType wxEVT_TOOL_DROPDOWN;
  3700. wxEventType wxEVT_TOOL_ENTER;
  3701. wxEventType wxEVT_COMBOBOX_DROPDOWN;
  3702. wxEventType wxEVT_COMBOBOX_CLOSEUP;
  3703. wxEventType wxEVT_THREAD;
  3704. wxEventType wxEVT_LEFT_DOWN;
  3705. wxEventType wxEVT_LEFT_UP;
  3706. wxEventType wxEVT_MIDDLE_DOWN;
  3707. wxEventType wxEVT_MIDDLE_UP;
  3708. wxEventType wxEVT_RIGHT_DOWN;
  3709. wxEventType wxEVT_RIGHT_UP;
  3710. wxEventType wxEVT_MOTION;
  3711. wxEventType wxEVT_ENTER_WINDOW;
  3712. wxEventType wxEVT_LEAVE_WINDOW;
  3713. wxEventType wxEVT_LEFT_DCLICK;
  3714. wxEventType wxEVT_MIDDLE_DCLICK;
  3715. wxEventType wxEVT_RIGHT_DCLICK;
  3716. wxEventType wxEVT_SET_FOCUS;
  3717. wxEventType wxEVT_KILL_FOCUS;
  3718. wxEventType wxEVT_CHILD_FOCUS;
  3719. wxEventType wxEVT_MOUSEWHEEL;
  3720. wxEventType wxEVT_AUX1_DOWN;
  3721. wxEventType wxEVT_AUX1_UP;
  3722. wxEventType wxEVT_AUX1_DCLICK;
  3723. wxEventType wxEVT_AUX2_DOWN;
  3724. wxEventType wxEVT_AUX2_UP;
  3725. wxEventType wxEVT_AUX2_DCLICK;
  3726. wxEventType wxEVT_CHAR;
  3727. wxEventType wxEVT_CHAR_HOOK;
  3728. wxEventType wxEVT_NAVIGATION_KEY;
  3729. wxEventType wxEVT_KEY_DOWN;
  3730. wxEventType wxEVT_KEY_UP;
  3731. wxEventType wxEVT_HOTKEY;
  3732. wxEventType wxEVT_SET_CURSOR;
  3733. wxEventType wxEVT_SCROLL_TOP;
  3734. wxEventType wxEVT_SCROLL_BOTTOM;
  3735. wxEventType wxEVT_SCROLL_LINEUP;
  3736. wxEventType wxEVT_SCROLL_LINEDOWN;
  3737. wxEventType wxEVT_SCROLL_PAGEUP;
  3738. wxEventType wxEVT_SCROLL_PAGEDOWN;
  3739. wxEventType wxEVT_SCROLL_THUMBTRACK;
  3740. wxEventType wxEVT_SCROLL_THUMBRELEASE;
  3741. wxEventType wxEVT_SCROLL_CHANGED;
  3742. wxEventType wxEVT_SPIN_UP;
  3743. wxEventType wxEVT_SPIN_DOWN;
  3744. wxEventType wxEVT_SPIN;
  3745. wxEventType wxEVT_SCROLLWIN_TOP;
  3746. wxEventType wxEVT_SCROLLWIN_BOTTOM;
  3747. wxEventType wxEVT_SCROLLWIN_LINEUP;
  3748. wxEventType wxEVT_SCROLLWIN_LINEDOWN;
  3749. wxEventType wxEVT_SCROLLWIN_PAGEUP;
  3750. wxEventType wxEVT_SCROLLWIN_PAGEDOWN;
  3751. wxEventType wxEVT_SCROLLWIN_THUMBTRACK;
  3752. wxEventType wxEVT_SCROLLWIN_THUMBRELEASE;
  3753. wxEventType wxEVT_SIZE;
  3754. wxEventType wxEVT_MOVE;
  3755. wxEventType wxEVT_CLOSE_WINDOW;
  3756. wxEventType wxEVT_END_SESSION;
  3757. wxEventType wxEVT_QUERY_END_SESSION;
  3758. wxEventType wxEVT_ACTIVATE_APP;
  3759. wxEventType wxEVT_ACTIVATE;
  3760. wxEventType wxEVT_CREATE;
  3761. wxEventType wxEVT_DESTROY;
  3762. wxEventType wxEVT_SHOW;
  3763. wxEventType wxEVT_ICONIZE;
  3764. wxEventType wxEVT_MAXIMIZE;
  3765. wxEventType wxEVT_MOUSE_CAPTURE_CHANGED;
  3766. wxEventType wxEVT_MOUSE_CAPTURE_LOST;
  3767. wxEventType wxEVT_PAINT;
  3768. wxEventType wxEVT_ERASE_BACKGROUND;
  3769. wxEventType wxEVT_NC_PAINT;
  3770. wxEventType wxEVT_MENU_OPEN;
  3771. wxEventType wxEVT_MENU_CLOSE;
  3772. wxEventType wxEVT_MENU_HIGHLIGHT;
  3773. wxEventType wxEVT_CONTEXT_MENU;
  3774. wxEventType wxEVT_SYS_COLOUR_CHANGED;
  3775. wxEventType wxEVT_DISPLAY_CHANGED;
  3776. wxEventType wxEVT_QUERY_NEW_PALETTE;
  3777. wxEventType wxEVT_PALETTE_CHANGED;
  3778. wxEventType wxEVT_JOY_BUTTON_DOWN;
  3779. wxEventType wxEVT_JOY_BUTTON_UP;
  3780. wxEventType wxEVT_JOY_MOVE;
  3781. wxEventType wxEVT_JOY_ZMOVE;
  3782. wxEventType wxEVT_DROP_FILES;
  3783. wxEventType wxEVT_INIT_DIALOG;
  3784. wxEventType wxEVT_IDLE;
  3785. wxEventType wxEVT_UPDATE_UI;
  3786. wxEventType wxEVT_SIZING;
  3787. wxEventType wxEVT_MOVING;
  3788. wxEventType wxEVT_MOVE_START;
  3789. wxEventType wxEVT_MOVE_END;
  3790. wxEventType wxEVT_HIBERNATE;
  3791. wxEventType wxEVT_TEXT_COPY;
  3792. wxEventType wxEVT_TEXT_CUT;
  3793. wxEventType wxEVT_TEXT_PASTE;
  3794. wxEventType wxEVT_COMMAND_LEFT_CLICK;
  3795. wxEventType wxEVT_COMMAND_LEFT_DCLICK;
  3796. wxEventType wxEVT_COMMAND_RIGHT_CLICK;
  3797. wxEventType wxEVT_COMMAND_RIGHT_DCLICK;
  3798. wxEventType wxEVT_COMMAND_SET_FOCUS;
  3799. wxEventType wxEVT_COMMAND_KILL_FOCUS;
  3800. wxEventType wxEVT_COMMAND_ENTER;
  3801. wxEventType wxEVT_HELP;
  3802. wxEventType wxEVT_DETAILED_HELP;
  3803. wxEventType wxEVT_TOOL;
  3804. wxEventType wxEVT_WINDOW_MODAL_DIALOG_CLOSED;
  3805. #endif // wxUSE_GUI
  3806. //@}