window.h 131 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: window.h
  3. // Purpose: interface of wxWindow
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. Valid values for wxWindow::ShowWithEffect() and wxWindow::HideWithEffect().
  9. */
  10. enum wxShowEffect
  11. {
  12. /**
  13. No effect, equivalent to normal wxWindow::Show() or Hide() call.
  14. @since 2.9.1
  15. */
  16. wxSHOW_EFFECT_NONE,
  17. /// Roll window to the left
  18. wxSHOW_EFFECT_ROLL_TO_LEFT,
  19. /// Roll window to the right
  20. wxSHOW_EFFECT_ROLL_TO_RIGHT,
  21. /// Roll window to the top
  22. wxSHOW_EFFECT_ROLL_TO_TOP,
  23. /// Roll window to the bottom
  24. wxSHOW_EFFECT_ROLL_TO_BOTTOM,
  25. /// Slide window to the left
  26. wxSHOW_EFFECT_SLIDE_TO_LEFT,
  27. /// Slide window to the right
  28. wxSHOW_EFFECT_SLIDE_TO_RIGHT,
  29. /// Slide window to the top
  30. wxSHOW_EFFECT_SLIDE_TO_TOP,
  31. /// Slide window to the bottom
  32. wxSHOW_EFFECT_SLIDE_TO_BOTTOM,
  33. /// Fade in or out effect
  34. wxSHOW_EFFECT_BLEND,
  35. /// Expanding or collapsing effect
  36. wxSHOW_EFFECT_EXPAND,
  37. wxSHOW_EFFECT_MAX
  38. };
  39. /**
  40. flags for SendSizeEvent()
  41. */
  42. enum
  43. {
  44. wxSEND_EVENT_POST = 1
  45. };
  46. /**
  47. Struct containing all the visual attributes of a control.
  48. */
  49. struct wxVisualAttributes
  50. {
  51. /// The font used for control label/text inside it.
  52. wxFont font;
  53. /// The foreground colour.
  54. wxColour colFg;
  55. /**
  56. The background colour.
  57. May be wxNullColour if the controls background colour is not solid.
  58. */
  59. wxColour colBg;
  60. };
  61. /**
  62. Different window variants, on platforms like eg mac uses different
  63. rendering sizes.
  64. */
  65. enum wxWindowVariant
  66. {
  67. wxWINDOW_VARIANT_NORMAL, //!< Normal size
  68. wxWINDOW_VARIANT_SMALL, //!< Smaller size (about 25 % smaller than normal)
  69. wxWINDOW_VARIANT_MINI, //!< Mini size (about 33 % smaller than normal)
  70. wxWINDOW_VARIANT_LARGE, //!< Large size (about 25 % larger than normal)
  71. wxWINDOW_VARIANT_MAX
  72. };
  73. /**
  74. @class wxWindow
  75. wxWindow is the base class for all windows and represents any visible object
  76. on screen. All controls, top level windows and so on are windows. Sizers and
  77. device contexts are not, however, as they don't appear on screen themselves.
  78. Please note that all children of the window will be deleted automatically by
  79. the destructor before the window itself is deleted which means that you don't
  80. have to worry about deleting them manually. Please see the @ref
  81. overview_windowdeletion "window deletion overview" for more information.
  82. Also note that in this, and many others, wxWidgets classes some
  83. @c GetXXX() methods may be overloaded (as, for example,
  84. wxWindow::GetSize or wxWindow::GetClientSize). In this case, the overloads
  85. are non-virtual because having multiple virtual functions with the same name
  86. results in a virtual function name hiding at the derived class level (in
  87. English, this means that the derived class has to override all overloaded
  88. variants if it overrides any of them). To allow overriding them in the derived
  89. class, wxWidgets uses a unique protected virtual @c DoGetXXX() method
  90. and all @c GetXXX() ones are forwarded to it, so overriding the former
  91. changes the behaviour of the latter.
  92. @beginStyleTable
  93. @style{wxBORDER_DEFAULT}
  94. The window class will decide the kind of border to show, if any.
  95. @style{wxBORDER_SIMPLE}
  96. Displays a thin border around the window. wxSIMPLE_BORDER is the
  97. old name for this style.
  98. @style{wxBORDER_SUNKEN}
  99. Displays a sunken border. wxSUNKEN_BORDER is the old name for this
  100. style.
  101. @style{wxBORDER_RAISED}
  102. Displays a raised border. wxRAISED_BORDER is the old name for this
  103. style.
  104. @style{wxBORDER_STATIC}
  105. Displays a border suitable for a static control. wxSTATIC_BORDER
  106. is the old name for this style. Windows only.
  107. @style{wxBORDER_THEME}
  108. Displays a native border suitable for a control, on the current
  109. platform. On Windows XP or Vista, this will be a themed border; on
  110. most other platforms a sunken border will be used. For more
  111. information for themed borders on Windows, please see Themed
  112. borders on Windows.
  113. @style{wxBORDER_NONE}
  114. Displays no border, overriding the default border style for the
  115. window. wxNO_BORDER is the old name for this style.
  116. @style{wxBORDER_DOUBLE}
  117. This style is obsolete and should not be used.
  118. @style{wxTRANSPARENT_WINDOW}
  119. The window is transparent, that is, it will not receive paint
  120. events. Windows only.
  121. @style{wxTAB_TRAVERSAL}
  122. Use this to enable tab traversal for non-dialog windows.
  123. @style{wxWANTS_CHARS}
  124. Use this to indicate that the window wants to get all char/key
  125. events for all keys - even for keys like TAB or ENTER which are
  126. usually used for dialog navigation and which wouldn't be generated
  127. without this style. If you need to use this style in order to get
  128. the arrows or etc., but would still like to have normal keyboard
  129. navigation take place, you should call Navigate in response to the
  130. key events for Tab and Shift-Tab.
  131. @style{wxNO_FULL_REPAINT_ON_RESIZE}
  132. On Windows, this style used to disable repainting the window
  133. completely when its size is changed. Since this behaviour is now
  134. the default, the style is now obsolete and no longer has an effect.
  135. @style{wxVSCROLL}
  136. Use this style to enable a vertical scrollbar. Notice that this
  137. style cannot be used with native controls which don't support
  138. scrollbars nor with top-level windows in most ports.
  139. @style{wxHSCROLL}
  140. Use this style to enable a horizontal scrollbar. The same
  141. limitations as for wxVSCROLL apply to this style.
  142. @style{wxALWAYS_SHOW_SB}
  143. If a window has scrollbars, disable them instead of hiding them
  144. when they are not needed (i.e. when the size of the window is big
  145. enough to not require the scrollbars to navigate it). This style is
  146. currently implemented for wxMSW, wxGTK and wxUniversal and does
  147. nothing on the other platforms.
  148. @style{wxCLIP_CHILDREN}
  149. Use this style to eliminate flicker caused by the background being
  150. repainted, then children being painted over them. Windows only.
  151. @style{wxFULL_REPAINT_ON_RESIZE}
  152. Use this style to force a complete redraw of the window whenever it
  153. is resized instead of redrawing just the part of the window
  154. affected by resizing. Note that this was the behaviour by default
  155. before 2.5.1 release and that if you experience redraw problems
  156. with code which previously used to work you may want to try this.
  157. Currently this style applies on GTK+ 2 and Windows only, and full
  158. repainting is always done on other platforms.
  159. @endStyleTable
  160. @beginExtraStyleTable
  161. @style{wxWS_EX_VALIDATE_RECURSIVELY}
  162. By default, wxWindow::Validate(), wxWindow::TransferDataTo() and
  163. wxWindow::TransferDataFromWindow() only work on
  164. direct children of the window (compatible behaviour).
  165. Set this flag to make them recursively descend into all subwindows.
  166. @style{wxWS_EX_BLOCK_EVENTS}
  167. wxCommandEvents and the objects of the derived classes are
  168. forwarded to the parent window and so on recursively by default.
  169. Using this flag for the given window allows to block this
  170. propagation at this window, i.e. prevent the events from being
  171. propagated further upwards. Dialogs have this flag on by default
  172. for the reasons explained in the @ref overview_events.
  173. @style{wxWS_EX_TRANSIENT}
  174. Don't use this window as an implicit parent for the other windows:
  175. this must be used with transient windows as otherwise there is the
  176. risk of creating a dialog/frame with this window as a parent, which
  177. would lead to a crash if the parent were destroyed before the child.
  178. @style{wxWS_EX_CONTEXTHELP}
  179. Under Windows, puts a query button on the caption. When pressed,
  180. Windows will go into a context-sensitive help mode and wxWidgets
  181. will send a @c wxEVT_HELP event if the user clicked on an application window.
  182. This style cannot be used (because of the underlying native behaviour)
  183. together with @c wxMAXIMIZE_BOX or @c wxMINIMIZE_BOX, so these two styles
  184. are automatically turned off if this one is used.
  185. @style{wxWS_EX_PROCESS_IDLE}
  186. This window should always process idle events, even if the mode set
  187. by wxIdleEvent::SetMode is @c wxIDLE_PROCESS_SPECIFIED.
  188. @style{wxWS_EX_PROCESS_UI_UPDATES}
  189. This window should always process UI update events, even if the
  190. mode set by wxUpdateUIEvent::SetMode is @c wxUPDATE_UI_PROCESS_SPECIFIED.
  191. @endExtraStyleTable
  192. @beginEventEmissionTable
  193. @event{EVT_ACTIVATE(id, func)}
  194. Process a @c wxEVT_ACTIVATE event. See wxActivateEvent.
  195. @event{EVT_CHILD_FOCUS(func)}
  196. Process a @c wxEVT_CHILD_FOCUS event. See wxChildFocusEvent.
  197. @event{EVT_CONTEXT_MENU(func)}
  198. A right click (or other context menu command depending on platform) has been detected.
  199. See wxContextMenuEvent.
  200. @event{EVT_HELP(id, func)}
  201. Process a @c wxEVT_HELP event. See wxHelpEvent.
  202. @event{EVT_HELP_RANGE(id1, id2, func)}
  203. Process a @c wxEVT_HELP event for a range of ids. See wxHelpEvent.
  204. @event{EVT_DROP_FILES(func)}
  205. Process a @c wxEVT_DROP_FILES event. See wxDropFilesEvent.
  206. @event{EVT_ERASE_BACKGROUND(func)}
  207. Process a @c wxEVT_ERASE_BACKGROUND event. See wxEraseEvent.
  208. @event{EVT_SET_FOCUS(func)}
  209. Process a @c wxEVT_SET_FOCUS event. See wxFocusEvent.
  210. @event{EVT_KILL_FOCUS(func)}
  211. Process a @c wxEVT_KILL_FOCUS event. See wxFocusEvent.
  212. @event{EVT_IDLE(func)}
  213. Process a @c wxEVT_IDLE event. See wxIdleEvent.
  214. @event{EVT_JOY_*(func)}
  215. Processes joystick events. See wxJoystickEvent.
  216. @event{EVT_KEY_DOWN(func)}
  217. Process a @c wxEVT_KEY_DOWN event (any key has been pressed).
  218. See wxKeyEvent.
  219. @event{EVT_KEY_UP(func)}
  220. Process a @c wxEVT_KEY_UP event (any key has been released).
  221. See wxKeyEvent.
  222. @event{EVT_CHAR(func)}
  223. Process a @c wxEVT_CHAR event.
  224. See wxKeyEvent.
  225. @event{EVT_CHAR_HOOK(func)}
  226. Process a @c wxEVT_CHAR_HOOK event.
  227. See wxKeyEvent.
  228. @event{EVT_MOUSE_CAPTURE_LOST(func)}
  229. Process a @c wxEVT_MOUSE_CAPTURE_LOST event. See wxMouseCaptureLostEvent.
  230. @event{EVT_MOUSE_CAPTURE_CHANGED(func)}
  231. Process a @c wxEVT_MOUSE_CAPTURE_CHANGED event. See wxMouseCaptureChangedEvent.
  232. @event{EVT_MOUSE_*(func)}
  233. See wxMouseEvent.
  234. @event{EVT_PAINT(func)}
  235. Process a @c wxEVT_PAINT event. See wxPaintEvent.
  236. @event{EVT_POWER_*(func)}
  237. The system power state changed. See wxPowerEvent.
  238. @event{EVT_SCROLLWIN_*(func)}
  239. Process scroll events. See wxScrollWinEvent.
  240. @event{EVT_SET_CURSOR(func)}
  241. Process a @c wxEVT_SET_CURSOR event. See wxSetCursorEvent.
  242. @event{EVT_SIZE(func)}
  243. Process a @c wxEVT_SIZE event. See wxSizeEvent.
  244. @event{EVT_SYS_COLOUR_CHANGED(func)}
  245. Process a @c wxEVT_SYS_COLOUR_CHANGED event. See wxSysColourChangedEvent.
  246. @endEventTable
  247. @library{wxcore}
  248. @category{miscwnd}
  249. @see @ref overview_events, @ref overview_windowsizing
  250. */
  251. class wxWindow : public wxEvtHandler
  252. {
  253. public:
  254. /**
  255. Default constructor
  256. */
  257. wxWindow();
  258. /**
  259. Constructs a window, which can be a child of a frame, dialog or any other
  260. non-control window.
  261. @param parent
  262. Pointer to a parent window.
  263. @param id
  264. Window identifier. If wxID_ANY, will automatically create an identifier.
  265. @param pos
  266. Window position. wxDefaultPosition indicates that wxWidgets
  267. should generate a default position for the window.
  268. If using the wxWindow class directly, supply an actual position.
  269. @param size
  270. Window size. wxDefaultSize indicates that wxWidgets should generate
  271. a default size for the window. If no suitable size can be found, the
  272. window will be sized to 20x20 pixels so that the window is visible but
  273. obviously not correctly sized.
  274. @param style
  275. Window style. For generic window styles, please see wxWindow.
  276. @param name
  277. Window name.
  278. */
  279. wxWindow(wxWindow* parent, wxWindowID id,
  280. const wxPoint& pos = wxDefaultPosition,
  281. const wxSize& size = wxDefaultSize,
  282. long style = 0,
  283. const wxString& name = wxPanelNameStr);
  284. /**
  285. Destructor.
  286. Deletes all sub-windows, then deletes itself. Instead of using
  287. the @b delete operator explicitly, you should normally use Destroy()
  288. so that wxWidgets can delete a window only when it is safe to do so, in idle time.
  289. @see @ref overview_windowdeletion "Window Deletion Overview",
  290. Destroy(), wxCloseEvent
  291. */
  292. virtual ~wxWindow();
  293. bool Create(wxWindow *parent,
  294. wxWindowID id,
  295. const wxPoint& pos = wxDefaultPosition,
  296. const wxSize& size = wxDefaultSize,
  297. long style = 0,
  298. const wxString& name = wxPanelNameStr);
  299. /**
  300. @name Focus functions
  301. See also the static function FindFocus().
  302. */
  303. //@{
  304. /**
  305. This method may be overridden in the derived classes to return @false to
  306. indicate that this control doesn't accept input at all (i.e.\ behaves like
  307. e.g.\ wxStaticText) and so doesn't need focus.
  308. @see AcceptsFocusFromKeyboard()
  309. */
  310. virtual bool AcceptsFocus() const;
  311. /**
  312. This method may be overridden in the derived classes to return @false to
  313. indicate that while this control can, in principle, have focus if the user
  314. clicks it with the mouse, it shouldn't be included in the TAB traversal chain
  315. when using the keyboard.
  316. */
  317. virtual bool AcceptsFocusFromKeyboard() const;
  318. /**
  319. Overridden to indicate whether this window or one of its children accepts
  320. focus. Usually it's the same as AcceptsFocus() but is overridden for
  321. container windows.
  322. */
  323. virtual bool AcceptsFocusRecursively() const;
  324. /**
  325. Can this window itself have focus?
  326. */
  327. bool IsFocusable() const;
  328. /**
  329. Can this window have focus right now?
  330. If this method returns true, it means that calling SetFocus() will
  331. put focus either to this window or one of its children, if you need
  332. to know whether this window accepts focus itself, use IsFocusable()
  333. */
  334. bool CanAcceptFocus() const;
  335. /**
  336. Can this window be assigned focus from keyboard right now?
  337. */
  338. bool CanAcceptFocusFromKeyboard() const;
  339. /**
  340. Returns @true if the window (or in case of composite controls, its main
  341. child window) has focus.
  342. @since 2.9.0
  343. @see FindFocus()
  344. */
  345. virtual bool HasFocus() const;
  346. /**
  347. This method is only implemented by ports which have support for
  348. native TAB traversal (such as GTK+ 2.0).
  349. It is called by wxWidgets' container control code to give the native
  350. system a hint when doing TAB traversal. A call to this does not disable
  351. or change the effect of programmatically calling SetFocus().
  352. @see wxFocusEvent, wxPanel::SetFocus, wxPanel::SetFocusIgnoringChildren
  353. */
  354. virtual void SetCanFocus(bool canFocus);
  355. /**
  356. This sets the window to receive keyboard input.
  357. @see HasFocus(), wxFocusEvent, wxPanel::SetFocus,
  358. wxPanel::SetFocusIgnoringChildren
  359. */
  360. virtual void SetFocus();
  361. /**
  362. This function is called by wxWidgets keyboard navigation code when the user
  363. gives the focus to this window from keyboard (e.g. using @c TAB key).
  364. By default this method simply calls SetFocus() but
  365. can be overridden to do something in addition to this in the derived classes.
  366. */
  367. virtual void SetFocusFromKbd();
  368. //@}
  369. /**
  370. @name Child management functions
  371. */
  372. //@{
  373. /**
  374. Adds a child window. This is called automatically by window creation
  375. functions so should not be required by the application programmer.
  376. Notice that this function is mostly internal to wxWidgets and shouldn't be
  377. called by the user code.
  378. @param child
  379. Child window to add.
  380. */
  381. virtual void AddChild(wxWindow* child);
  382. /**
  383. Destroys all children of a window. Called automatically by the destructor.
  384. */
  385. bool DestroyChildren();
  386. /**
  387. Find a child of this window, by @a id.
  388. May return @a this if it matches itself.
  389. Notice that only real children, not top level windows using this window
  390. as parent, are searched by this function.
  391. */
  392. wxWindow* FindWindow(long id) const;
  393. /**
  394. Find a child of this window, by name.
  395. May return @a this if it matches itself.
  396. Notice that only real children, not top level windows using this window
  397. as parent, are searched by this function.
  398. */
  399. wxWindow* FindWindow(const wxString& name) const;
  400. /**
  401. Returns a reference to the list of the window's children. @c wxWindowList
  402. is a type-safe wxList-like class whose elements are of type @c wxWindow*.
  403. */
  404. wxWindowList& GetChildren();
  405. /**
  406. @overload
  407. */
  408. const wxWindowList& GetChildren() const;
  409. /**
  410. Removes a child window.
  411. This is called automatically by window deletion functions so should not
  412. be required by the application programmer.
  413. Notice that this function is mostly internal to wxWidgets and shouldn't be
  414. called by the user code.
  415. @param child
  416. Child window to remove.
  417. */
  418. virtual void RemoveChild(wxWindow* child);
  419. //@}
  420. /**
  421. @name Sibling and parent management functions
  422. */
  423. //@{
  424. /**
  425. Returns the grandparent of a window, or @NULL if there isn't one.
  426. */
  427. wxWindow* GetGrandParent() const;
  428. /**
  429. Returns the next window after this one among the parent's children or @NULL
  430. if this window is the last child.
  431. @since 2.8.8
  432. @see GetPrevSibling()
  433. */
  434. wxWindow* GetNextSibling() const;
  435. /**
  436. Returns the parent of the window, or @NULL if there is no parent.
  437. */
  438. wxWindow* GetParent() const;
  439. /**
  440. Returns the previous window before this one among the parent's children or @c
  441. @NULL if this window is the first child.
  442. @since 2.8.8
  443. @see GetNextSibling()
  444. */
  445. wxWindow* GetPrevSibling() const;
  446. /**
  447. Check if the specified window is a descendant of this one.
  448. Returns @true if the window is a descendant (i.e. a child or
  449. grand-child or grand-grand-child or ...) of this one.
  450. Notice that a window can never be a descendant of another one if they
  451. are in different top level windows, i.e. a child of a wxDialog is not
  452. considered to be a descendant of dialogs parent wxFrame.
  453. @param win Any window, possible @NULL (@false is always returned then).
  454. @since 2.9.4
  455. */
  456. bool IsDescendant(wxWindowBase* win) const;
  457. /**
  458. Reparents the window, i.e.\ the window will be removed from its
  459. current parent window (e.g. a non-standard toolbar in a wxFrame)
  460. and then re-inserted into another.
  461. Notice that currently you need to explicitly call
  462. wxNotebook::RemovePage() before reparenting a notebook page.
  463. @param newParent
  464. New parent.
  465. */
  466. virtual bool Reparent(wxWindow* newParent);
  467. //@}
  468. /**
  469. @name Scrolling and scrollbars functions
  470. Note that these methods don't work with native controls which don't use
  471. wxWidgets scrolling framework (i.e. don't derive from wxScrolledWindow).
  472. */
  473. //@{
  474. /**
  475. Call this function to force one or both scrollbars to be always shown, even if
  476. the window is big enough to show its entire contents without scrolling.
  477. @since 2.9.0
  478. @param hflag
  479. Whether the horizontal scroll bar should always be visible.
  480. @param vflag
  481. Whether the vertical scroll bar should always be visible.
  482. @remarks This function is currently only implemented under Mac/Carbon.
  483. */
  484. virtual void AlwaysShowScrollbars(bool hflag = true, bool vflag = true);
  485. /**
  486. Returns the built-in scrollbar position.
  487. @see SetScrollbar()
  488. */
  489. virtual int GetScrollPos(int orientation) const;
  490. /**
  491. Returns the built-in scrollbar range.
  492. @see SetScrollbar()
  493. */
  494. virtual int GetScrollRange(int orientation) const;
  495. /**
  496. Returns the built-in scrollbar thumb size.
  497. @see SetScrollbar()
  498. */
  499. virtual int GetScrollThumb(int orientation) const;
  500. /**
  501. Returns @true if this window can have a scroll bar in this orientation.
  502. @param orient
  503. Orientation to check, either wxHORIZONTAL or wxVERTICAL.
  504. @since 2.9.1
  505. */
  506. bool CanScroll(int orient) const;
  507. /**
  508. Returns @true if this window currently has a scroll bar for this
  509. orientation.
  510. This method may return @false even when CanScroll() for the same
  511. orientation returns @true, but if CanScroll() returns @false, i.e.
  512. scrolling in this direction is not enabled at all, HasScrollbar()
  513. always returns @false as well.
  514. @param orient
  515. Orientation to check, either wxHORIZONTAL or wxVERTICAL.
  516. */
  517. bool HasScrollbar(int orient) const;
  518. /**
  519. Return whether a scrollbar is always shown.
  520. @param orient
  521. Orientation to check, either wxHORIZONTAL or wxVERTICAL.
  522. @see AlwaysShowScrollbars()
  523. */
  524. virtual bool IsScrollbarAlwaysShown(int orient) const;
  525. /**
  526. Scrolls the window by the given number of lines down (if @a lines is
  527. positive) or up.
  528. @return Returns @true if the window was scrolled, @false if it was already
  529. on top/bottom and nothing was done.
  530. @remarks This function is currently only implemented under MSW and
  531. wxTextCtrl under wxGTK (it also works for wxScrolled classes
  532. under all platforms).
  533. @see ScrollPages()
  534. */
  535. virtual bool ScrollLines(int lines);
  536. /**
  537. Scrolls the window by the given number of pages down (if @a pages is
  538. positive) or up.
  539. @return Returns @true if the window was scrolled, @false if it was already
  540. on top/bottom and nothing was done.
  541. @remarks This function is currently only implemented under MSW and wxGTK.
  542. @see ScrollLines()
  543. */
  544. virtual bool ScrollPages(int pages);
  545. /**
  546. Physically scrolls the pixels in the window and move child windows accordingly.
  547. @param dx
  548. Amount to scroll horizontally.
  549. @param dy
  550. Amount to scroll vertically.
  551. @param rect
  552. Rectangle to scroll, if it is @NULL, the whole window is
  553. scrolled (this is always the case under wxGTK which doesn't support this
  554. parameter)
  555. @remarks Note that you can often use wxScrolled instead of using this
  556. function directly.
  557. */
  558. virtual void ScrollWindow(int dx, int dy,
  559. const wxRect* rect = NULL);
  560. /**
  561. Same as #ScrollLines (-1).
  562. */
  563. bool LineUp();
  564. /**
  565. Same as #ScrollLines (1).
  566. */
  567. bool LineDown();
  568. /**
  569. Same as #ScrollPages (-1).
  570. */
  571. bool PageUp();
  572. /**
  573. Same as #ScrollPages (1).
  574. */
  575. bool PageDown();
  576. /**
  577. Sets the position of one of the built-in scrollbars.
  578. @param orientation
  579. Determines the scrollbar whose position is to be set.
  580. May be wxHORIZONTAL or wxVERTICAL.
  581. @param pos
  582. Position in scroll units.
  583. @param refresh
  584. @true to redraw the scrollbar, @false otherwise.
  585. @remarks This function does not directly affect the contents of the
  586. window: it is up to the application to take note of
  587. scrollbar attributes and redraw contents accordingly.
  588. @see SetScrollbar(), GetScrollPos(), GetScrollThumb(), wxScrollBar,
  589. wxScrolled
  590. */
  591. virtual void SetScrollPos(int orientation, int pos,
  592. bool refresh = true);
  593. /**
  594. Sets the scrollbar properties of a built-in scrollbar.
  595. @param orientation
  596. Determines the scrollbar whose page size is to be set.
  597. May be wxHORIZONTAL or wxVERTICAL.
  598. @param position
  599. The position of the scrollbar in scroll units.
  600. @param thumbSize
  601. The size of the thumb, or visible portion of the scrollbar, in scroll units.
  602. @param range
  603. The maximum position of the scrollbar. Value of -1 can be used to
  604. ask for the scrollbar to be shown but in the disabled state: this
  605. can be used to avoid removing the scrollbar even when it is not
  606. needed (currently this is only implemented in wxMSW port).
  607. @param refresh
  608. @true to redraw the scrollbar, @false otherwise.
  609. @remarks
  610. Let's say you wish to display 50 lines of text, using the same font.
  611. The window is sized so that you can only see 16 lines at a time.
  612. You would use:
  613. @code
  614. SetScrollbar(wxVERTICAL, 0, 16, 50);
  615. @endcode
  616. Note that with the window at this size, the thumb position can never
  617. go above 50 minus 16, or 34. You can determine how many lines are
  618. currently visible by dividing the current view size by the character
  619. height in pixels.
  620. When defining your own scrollbar behaviour, you will always need
  621. to recalculate the scrollbar settings when the window size changes.
  622. You could therefore put your scrollbar calculations and SetScrollbar
  623. call into a function named AdjustScrollbars, which can be called
  624. initially and also from your wxSizeEvent handler function.
  625. @see @ref overview_scrolling, wxScrollBar, wxScrolled, wxScrollWinEvent
  626. */
  627. virtual void SetScrollbar(int orientation, int position,
  628. int thumbSize, int range,
  629. bool refresh = true);
  630. //@}
  631. /**
  632. @name Sizing functions
  633. See also the protected functions DoGetBestSize() and
  634. DoGetBestClientSize().
  635. */
  636. //@{
  637. /**
  638. Helper for ensuring EndRepositioningChildren() is called correctly.
  639. This class wraps the calls to BeginRepositioningChildren() and
  640. EndRepositioningChildren() by performing the former in its constructor
  641. and the latter in its destructor if, and only if, the first call
  642. returned @true. This is the simplest way to call these methods and if
  643. this class is created as a local variable, it also ensures that
  644. EndRepositioningChildren() is correctly called (or not) on scope exit,
  645. so its use instead of calling these methods manually is highly
  646. recommended.
  647. @since 2.9.5
  648. */
  649. class ChildrenRepositioningGuard
  650. {
  651. public:
  652. /**
  653. Constructor calls wxWindow::BeginRepositioningChildren().
  654. @param win The window to call BeginRepositioningChildren() on. If
  655. it is @NULL, nothing is done.
  656. */
  657. explicit ChildrenRepositioningGuard(wxWindow* win);
  658. /**
  659. Destructor calls wxWindow::EndRepositioningChildren() if necessary.
  660. EndRepositioningChildren() is called only if a valid window was
  661. passed to the constructor and if BeginRepositioningChildren()
  662. returned @true.
  663. */
  664. ~ChildrenRepositioningGuard();
  665. };
  666. /**
  667. Prepare for changing positions of multiple child windows.
  668. This method should be called before changing positions of multiple
  669. child windows to reduce flicker and, in MSW case, even avoid display
  670. corruption in some cases. It is used internally by wxWidgets and called
  671. automatically when the window size changes but it can also be useful to
  672. call it from outside of the library if a repositioning involving
  673. multiple children is done without changing the window size.
  674. If this method returns @true, then EndRepositioningChildren() must be
  675. called after setting all children positions. Use
  676. ChildrenRepositioningGuard class to ensure that this requirement is
  677. satisfied.
  678. @since 2.9.5
  679. */
  680. bool BeginRepositioningChildren();
  681. /**
  682. Fix child window positions after setting all of them at once.
  683. This method must be called if and only if the previous call to
  684. BeginRepositioningChildren() returned @true.
  685. @since 2.9.5
  686. */
  687. void EndRepositioningChildren();
  688. /**
  689. Sets the cached best size value.
  690. @see GetBestSize()
  691. */
  692. void CacheBestSize(const wxSize& size) const;
  693. /**
  694. Converts client area size @a size to corresponding window size.
  695. In other words, the returned value is what would GetSize() return if this
  696. window had client area of given size. Components with wxDefaultCoord
  697. value are left unchanged. Note that the conversion is not always
  698. exact, it assumes that non-client area doesn't change and so doesn't
  699. take into account things like menu bar (un)wrapping or (dis)appearance
  700. of the scrollbars.
  701. @since 2.8.8
  702. @see WindowToClientSize()
  703. */
  704. virtual wxSize ClientToWindowSize(const wxSize& size) const;
  705. /**
  706. Converts window size @a size to corresponding client area size
  707. In other words, the returned value is what would GetClientSize() return if
  708. this window had given window size. Components with wxDefaultCoord value
  709. are left unchanged.
  710. Note that the conversion is not always exact, it assumes that
  711. non-client area doesn't change and so doesn't take into account things
  712. like menu bar (un)wrapping or (dis)appearance of the scrollbars.
  713. @since 2.8.8
  714. @see ClientToWindowSize()
  715. */
  716. virtual wxSize WindowToClientSize(const wxSize& size) const;
  717. /**
  718. Sizes the window so that it fits around its subwindows.
  719. This function won't do anything if there are no subwindows and will only really
  720. work correctly if sizers are used for the subwindows layout.
  721. Also, if the window has exactly one subwindow it is better (faster and the result
  722. is more precise as Fit() adds some margin to account for fuzziness of its calculations)
  723. to call:
  724. @code
  725. window->SetClientSize(child->GetSize());
  726. @endcode
  727. instead of calling Fit().
  728. @see @ref overview_windowsizing
  729. */
  730. virtual void Fit();
  731. /**
  732. Similar to Fit(), but sizes the interior (virtual) size of a window.
  733. Mainly useful with scrolled windows to reset scrollbars after sizing
  734. changes that do not trigger a size event, and/or scrolled windows without
  735. an interior sizer. This function similarly won't do anything if there are
  736. no subwindows.
  737. */
  738. virtual void FitInside();
  739. /**
  740. This functions returns the best acceptable minimal size for the window.
  741. For example, for a static control, it will be the minimal size such that the
  742. control label is not truncated. For windows containing subwindows (typically
  743. wxPanel), the size returned by this function will be the same as the size
  744. the window would have had after calling Fit().
  745. Override virtual DoGetBestSize() or, better, because it's usually more
  746. convenient, DoGetBestClientSize() when writing your own custom window
  747. class to change the value returned by this public non-virtual method.
  748. Notice that the best size respects the minimal and maximal size
  749. explicitly set for the window, if any. So even if some window believes
  750. that it needs 200 pixels horizontally, calling SetMaxSize() with a
  751. width of 100 would ensure that GetBestSize() returns the width of at
  752. most 100 pixels.
  753. @see CacheBestSize(), @ref overview_windowsizing
  754. */
  755. wxSize GetBestSize() const;
  756. /**
  757. Returns the best height needed by this window if it had the given width.
  758. @see DoGetBestClientHeight()
  759. @since 2.9.4
  760. */
  761. int GetBestHeight(int width) const;
  762. /**
  763. Returns the best width needed by this window if it had the given height.
  764. @see DoGetBestClientWidth()
  765. @since 2.9.4
  766. */
  767. int GetBestWidth(int height) const;
  768. /**
  769. Returns the size of the window 'client area' in pixels.
  770. The client area is the area which may be drawn on by the programmer,
  771. excluding title bar, border, scrollbars, etc.
  772. Note that if this window is a top-level one and it is currently minimized, the
  773. return size is empty (both width and height are 0).
  774. @beginWxPerlOnly
  775. In wxPerl this method takes no parameters and returns
  776. a 2-element list (width, height).
  777. @endWxPerlOnly
  778. @see GetSize(), GetVirtualSize()
  779. */
  780. void GetClientSize(int* width, int* height) const;
  781. /**
  782. @overload
  783. */
  784. wxSize GetClientSize() const;
  785. /**
  786. Merges the window's best size into the min size and returns the result.
  787. This is the value used by sizers to determine the appropriate
  788. amount of space to allocate for the widget.
  789. This is the method called by a wxSizer when it queries the size
  790. of a window or control.
  791. @see GetBestSize(), SetInitialSize(), @ref overview_windowsizing
  792. */
  793. virtual wxSize GetEffectiveMinSize() const;
  794. /**
  795. Returns the maximum size of window's client area.
  796. This is an indication to the sizer layout mechanism that this is the maximum
  797. possible size as well as the upper bound on window's size settable using
  798. SetClientSize().
  799. @see GetMaxSize(), @ref overview_windowsizing
  800. */
  801. virtual wxSize GetMaxClientSize() const;
  802. /**
  803. Returns the maximum size of the window.
  804. This is an indication to the sizer layout mechanism that this is the maximum
  805. possible size as well as the upper bound on window's size settable using SetSize().
  806. @see GetMaxClientSize(), @ref overview_windowsizing
  807. */
  808. virtual wxSize GetMaxSize() const;
  809. /**
  810. Returns the minimum size of window's client area, an indication to the sizer
  811. layout mechanism that this is the minimum required size of its client area.
  812. It normally just returns the value set by SetMinClientSize(), but it can be
  813. overridden to do the calculation on demand.
  814. @see GetMinSize(), @ref overview_windowsizing
  815. */
  816. virtual wxSize GetMinClientSize() const;
  817. /**
  818. Returns the minimum size of the window, an indication to the sizer layout
  819. mechanism that this is the minimum required size.
  820. This method normally just returns the value set by SetMinSize(), but it
  821. can be overridden to do the calculation on demand.
  822. @see GetMinClientSize(), @ref overview_windowsizing
  823. */
  824. virtual wxSize GetMinSize() const;
  825. /**
  826. Returns the horizontal component of window minimal size.
  827. The returned value is wxDefaultCoord if the minimal width was not set.
  828. @see GetMinSize()
  829. */
  830. int GetMinWidth() const;
  831. /**
  832. Returns the vertical component of window minimal size.
  833. The returned value is wxDefaultCoord if the minimal height was not set.
  834. @see GetMinSize()
  835. */
  836. int GetMinHeight() const;
  837. /**
  838. Returns the horizontal component of window maximal size.
  839. The returned value is wxDefaultCoord if the maximal width was not set.
  840. @see GetMaxSize()
  841. */
  842. int GetMaxWidth() const;
  843. /**
  844. Returns the vertical component of window maximal size.
  845. The returned value is wxDefaultCoord if the maximal width was not set.
  846. @see GetMaxSize()
  847. */
  848. int GetMaxHeight() const;
  849. /**
  850. Returns the size of the entire window in pixels, including title bar, border,
  851. scrollbars, etc.
  852. Note that if this window is a top-level one and it is currently minimized, the
  853. returned size is the restored window size, not the size of the window icon.
  854. @param width
  855. Receives the window width.
  856. @param height
  857. Receives the window height.
  858. @beginWxPerlOnly
  859. In wxPerl this method is implemented as GetSizeWH() returning
  860. a 2-element list (width, height).
  861. @endWxPerlOnly
  862. @see GetClientSize(), GetVirtualSize(), @ref overview_windowsizing
  863. */
  864. void GetSize(int* width, int* height) const;
  865. /**
  866. See the GetSize(int*,int*) overload for more info.
  867. */
  868. wxSize GetSize() const;
  869. /**
  870. This gets the virtual size of the window in pixels.
  871. By default it returns the client size of the window, but after a call to
  872. SetVirtualSize() it will return the size set with that method.
  873. @see @ref overview_windowsizing
  874. */
  875. wxSize GetVirtualSize() const;
  876. /**
  877. Like the other GetVirtualSize() overload but uses pointers instead.
  878. @param width
  879. Receives the window virtual width.
  880. @param height
  881. Receives the window virtual height.
  882. */
  883. void GetVirtualSize(int* width, int* height) const;
  884. /**
  885. Return the largest of ClientSize and BestSize (as determined
  886. by a sizer, interior children, or other means)
  887. */
  888. virtual wxSize GetBestVirtualSize() const;
  889. /**
  890. Returns the magnification of the backing store of this window, eg 2.0
  891. for a window on a retina screen.
  892. @since 2.9.5
  893. */
  894. virtual double GetContentScaleFactor() const;
  895. /**
  896. Returns the size of the left/right and top/bottom borders of this window in x
  897. and y components of the result respectively.
  898. */
  899. virtual wxSize GetWindowBorderSize() const;
  900. /**
  901. wxSizer and friends use this to give a chance to a component to recalc
  902. its min size once one of the final size components is known. Override
  903. this function when that is useful (such as for wxStaticText which can
  904. stretch over several lines). Parameter availableOtherDir
  905. tells the item how much more space there is available in the opposite
  906. direction (-1 if unknown).
  907. */
  908. virtual bool
  909. InformFirstDirection(int direction,
  910. int size,
  911. int availableOtherDir);
  912. /**
  913. Resets the cached best size value so it will be recalculated the next time it
  914. is needed.
  915. @see CacheBestSize()
  916. */
  917. void InvalidateBestSize();
  918. /**
  919. Posts a size event to the window.
  920. This is the same as SendSizeEvent() with @c wxSEND_EVENT_POST argument.
  921. */
  922. void PostSizeEvent();
  923. /**
  924. Posts a size event to the parent of this window.
  925. This is the same as SendSizeEventToParent() with @c wxSEND_EVENT_POST
  926. argument.
  927. */
  928. void PostSizeEventToParent();
  929. /**
  930. This function sends a dummy @ref wxSizeEvent "size event" to
  931. the window allowing it to re-layout its children positions.
  932. It is sometimes useful to call this function after adding or deleting a
  933. children after the frame creation or if a child size changes. Note that
  934. if the frame is using either sizers or constraints for the children
  935. layout, it is enough to call wxWindow::Layout() directly and this
  936. function should not be used in this case.
  937. If @a flags includes @c wxSEND_EVENT_POST value, this function posts
  938. the event, i.e. schedules it for later processing, instead of
  939. dispatching it directly. You can also use PostSizeEvent() as a more
  940. readable equivalent of calling this function with this flag.
  941. @param flags
  942. May include @c wxSEND_EVENT_POST. Default value is 0.
  943. */
  944. virtual void SendSizeEvent(int flags = 0);
  945. /**
  946. Safe wrapper for GetParent()->SendSizeEvent().
  947. This function simply checks that the window has a valid parent which is
  948. not in process of being deleted and calls SendSizeEvent() on it. It is
  949. used internally by windows such as toolbars changes to whose state
  950. should result in parent re-layout (e.g. when a toolbar is added to the
  951. top of the window, all the other windows must be shifted down).
  952. @see PostSizeEventToParent()
  953. @param flags
  954. See description of this parameter in SendSizeEvent() documentation.
  955. */
  956. void SendSizeEventToParent(int flags = 0);
  957. /**
  958. This sets the size of the window client area in pixels.
  959. Using this function to size a window tends to be more device-independent
  960. than SetSize(), since the application need not worry about what dimensions
  961. the border or title bar have when trying to fit the window around panel
  962. items, for example.
  963. @see @ref overview_windowsizing
  964. */
  965. void SetClientSize(int width, int height);
  966. /**
  967. @overload
  968. */
  969. void SetClientSize(const wxSize& size);
  970. /**
  971. @overload
  972. */
  973. void SetClientSize(const wxRect& rect);
  974. /**
  975. This normally does not need to be called by user code.
  976. It is called when a window is added to a sizer, and is used so the window
  977. can remove itself from the sizer when it is destroyed.
  978. */
  979. void SetContainingSizer(wxSizer* sizer);
  980. /**
  981. A @e smart SetSize that will fill in default size components with the
  982. window's @e best size values.
  983. Also sets the window's minsize to the value passed in for use with sizers.
  984. This means that if a full or partial size is passed to this function then
  985. the sizers will use that size instead of the results of GetBestSize() to
  986. determine the minimum needs of the window for layout.
  987. Most controls will use this to set their initial size, and their min
  988. size to the passed in value (if any.)
  989. @see SetSize(), GetBestSize(), GetEffectiveMinSize(),
  990. @ref overview_windowsizing
  991. */
  992. void SetInitialSize(const wxSize& size = wxDefaultSize);
  993. /**
  994. Sets the maximum client size of the window, to indicate to the sizer
  995. layout mechanism that this is the maximum possible size of its client area.
  996. Note that this method is just a shortcut for:
  997. @code
  998. SetMaxSize(ClientToWindowSize(size));
  999. @endcode
  1000. @see SetMaxSize(), @ref overview_windowsizing
  1001. */
  1002. virtual void SetMaxClientSize(const wxSize& size);
  1003. /**
  1004. Sets the maximum size of the window, to indicate to the sizer layout mechanism
  1005. that this is the maximum possible size.
  1006. @see SetMaxClientSize(), @ref overview_windowsizing
  1007. */
  1008. virtual void SetMaxSize(const wxSize& size);
  1009. /**
  1010. Sets the minimum client size of the window, to indicate to the sizer
  1011. layout mechanism that this is the minimum required size of window's client
  1012. area.
  1013. You may need to call this if you change the window size after
  1014. construction and before adding to its parent sizer.
  1015. Note, that just as with SetMinSize(), calling this method doesn't
  1016. prevent the program from explicitly making the window smaller than the
  1017. specified size.
  1018. Note that this method is just a shortcut for:
  1019. @code
  1020. SetMinSize(ClientToWindowSize(size));
  1021. @endcode
  1022. @see SetMinSize(), @ref overview_windowsizing
  1023. */
  1024. virtual void SetMinClientSize(const wxSize& size);
  1025. /**
  1026. Sets the minimum size of the window, to indicate to the sizer layout
  1027. mechanism that this is the minimum required size.
  1028. You may need to call this if you change the window size after
  1029. construction and before adding to its parent sizer.
  1030. Notice that calling this method doesn't prevent the program from making
  1031. the window explicitly smaller than the specified size by calling
  1032. SetSize(), it just ensures that it won't become smaller than this size
  1033. during the automatic layout.
  1034. @see SetMinClientSize(), @ref overview_windowsizing
  1035. */
  1036. virtual void SetMinSize(const wxSize& size);
  1037. /**
  1038. Sets the size of the window in pixels.
  1039. @param x
  1040. Required x position in pixels, or wxDefaultCoord to indicate that the
  1041. existing value should be used.
  1042. @param y
  1043. Required y position in pixels, or wxDefaultCoord to indicate that the
  1044. existing value should be used.
  1045. @param width
  1046. Required width in pixels, or wxDefaultCoord to indicate that the existing
  1047. value should be used.
  1048. @param height
  1049. Required height position in pixels, or wxDefaultCoord to indicate that the
  1050. existing value should be used.
  1051. @param sizeFlags
  1052. Indicates the interpretation of other parameters.
  1053. It is a bit list of the following:
  1054. - @c wxSIZE_AUTO_WIDTH: a wxDefaultCoord width value is taken to indicate
  1055. a wxWidgets-supplied default width.
  1056. - @c wxSIZE_AUTO_HEIGHT: a wxDefaultCoord height value is taken to indicate
  1057. a wxWidgets-supplied default height.
  1058. - @c wxSIZE_AUTO: wxDefaultCoord size values are taken to indicate
  1059. a wxWidgets-supplied default size.
  1060. - @c wxSIZE_USE_EXISTING: existing dimensions should be used
  1061. if wxDefaultCoord values are supplied.
  1062. - @c wxSIZE_ALLOW_MINUS_ONE: allow negative dimensions (i.e. value of
  1063. wxDefaultCoord) to be interpreted as real
  1064. dimensions, not default values.
  1065. - @c wxSIZE_FORCE: normally, if the position and the size of the window are
  1066. already the same as the parameters of this function,
  1067. nothing is done. but with this flag a window resize may
  1068. be forced even in this case (supported in wx 2.6.2 and
  1069. later and only implemented for MSW and ignored elsewhere
  1070. currently).
  1071. @remarks This overload sets the position and optionally size, of the window.
  1072. Parameters may be wxDefaultCoord to indicate either that a default
  1073. should be supplied by wxWidgets, or that the current value of the
  1074. dimension should be used.
  1075. @see Move(), @ref overview_windowsizing
  1076. */
  1077. void SetSize(int x, int y, int width, int height,
  1078. int sizeFlags = wxSIZE_AUTO);
  1079. /**
  1080. Sets the size of the window in pixels.
  1081. The size is specified using a wxRect, wxSize or by a couple of @c int objects.
  1082. @remarks This form must be used with non-default width and height values.
  1083. @see Move(), @ref overview_windowsizing
  1084. */
  1085. void SetSize(const wxRect& rect);
  1086. /**
  1087. @overload
  1088. */
  1089. void SetSize(const wxSize& size);
  1090. /**
  1091. @overload
  1092. */
  1093. void SetSize(int width, int height);
  1094. /**
  1095. Use of this function for windows which are not toplevel windows
  1096. (such as wxDialog or wxFrame) is discouraged.
  1097. Please use SetMinSize() and SetMaxSize() instead.
  1098. @see wxTopLevelWindow::SetSizeHints, @ref overview_windowsizing
  1099. */
  1100. virtual void SetSizeHints( const wxSize& minSize,
  1101. const wxSize& maxSize=wxDefaultSize,
  1102. const wxSize& incSize=wxDefaultSize);
  1103. /**
  1104. @overload
  1105. */
  1106. virtual void SetSizeHints( int minW, int minH,
  1107. int maxW = -1, int maxH = -1,
  1108. int incW = -1, int incH = -1 );
  1109. /**
  1110. Sets the virtual size of the window in pixels.
  1111. @see @ref overview_windowsizing
  1112. */
  1113. void SetVirtualSize(int width, int height);
  1114. /**
  1115. @overload
  1116. */
  1117. void SetVirtualSize(const wxSize& size);
  1118. //@}
  1119. /**
  1120. @name Positioning functions
  1121. */
  1122. //@{
  1123. /**
  1124. A synonym for Centre().
  1125. */
  1126. void Center(int dir = wxBOTH);
  1127. /**
  1128. A synonym for CentreOnParent().
  1129. */
  1130. void CenterOnParent(int dir = wxBOTH);
  1131. /**
  1132. Centres the window.
  1133. @param direction
  1134. Specifies the direction for the centring. May be wxHORIZONTAL, wxVERTICAL
  1135. or wxBOTH. It may also include the wxCENTRE_ON_SCREEN flag
  1136. if you want to centre the window on the entire screen and not on its
  1137. parent window.
  1138. @remarks If the window is a top level one (i.e. doesn't have a parent),
  1139. it will be centred relative to the screen anyhow.
  1140. @see Center()
  1141. */
  1142. void Centre(int direction = wxBOTH);
  1143. /**
  1144. Centres the window on its parent. This is a more readable synonym for Centre().
  1145. @param direction
  1146. Specifies the direction for the centring. May be wxHORIZONTAL, wxVERTICAL
  1147. or wxBOTH.
  1148. @remarks This methods provides for a way to centre top level windows over
  1149. their parents instead of the entire screen. If there
  1150. is no parent or if the window is not a top level
  1151. window, then behaviour is the same as Centre().
  1152. @see wxTopLevelWindow::CentreOnScreen
  1153. */
  1154. void CentreOnParent(int direction = wxBOTH);
  1155. /**
  1156. This gets the position of the window in pixels, relative to the parent window
  1157. for the child windows or relative to the display origin for the top level windows.
  1158. @param x
  1159. Receives the x position of the window if non-@NULL.
  1160. @param y
  1161. Receives the y position of the window if non-@NULL.
  1162. @beginWxPerlOnly
  1163. In wxPerl this method is implemented as GetPositionXY() returning
  1164. a 2-element list (x, y).
  1165. @endWxPerlOnly
  1166. @see GetScreenPosition()
  1167. */
  1168. void GetPosition(int* x, int* y) const;
  1169. /**
  1170. This gets the position of the window in pixels, relative to the parent window
  1171. for the child windows or relative to the display origin for the top level windows.
  1172. @see GetScreenPosition()
  1173. */
  1174. wxPoint GetPosition() const;
  1175. /**
  1176. Returns the position and size of the window as a wxRect object.
  1177. @see GetScreenRect()
  1178. */
  1179. wxRect GetRect() const;
  1180. /**
  1181. Returns the window position in screen coordinates, whether the window is a
  1182. child window or a top level one.
  1183. @param x
  1184. Receives the x position of the window on the screen if non-@NULL.
  1185. @param y
  1186. Receives the y position of the window on the screen if non-@NULL.
  1187. @see GetPosition()
  1188. */
  1189. void GetScreenPosition(int* x, int* y) const;
  1190. /**
  1191. Returns the window position in screen coordinates, whether the window is a
  1192. child window or a top level one.
  1193. @see GetPosition()
  1194. */
  1195. wxPoint GetScreenPosition() const;
  1196. /**
  1197. Returns the position and size of the window on the screen as a wxRect object.
  1198. @see GetRect()
  1199. */
  1200. wxRect GetScreenRect() const;
  1201. /**
  1202. Get the origin of the client area of the window relative to the
  1203. window top left corner (the client area may be shifted because of
  1204. the borders, scrollbars, other decorations...)
  1205. */
  1206. virtual wxPoint GetClientAreaOrigin() const;
  1207. /**
  1208. Get the client rectangle in window (i.e.\ client) coordinates
  1209. */
  1210. wxRect GetClientRect() const;
  1211. /**
  1212. Moves the window to the given position.
  1213. @param x
  1214. Required x position.
  1215. @param y
  1216. Required y position.
  1217. @param flags
  1218. See SetSize() for more info about this parameter.
  1219. @remarks Implementations of SetSize can also implicitly implement the
  1220. Move() function, which is defined in the base wxWindow class as the call:
  1221. @code
  1222. SetSize(x, y, wxDefaultCoord, wxDefaultCoord, wxSIZE_USE_EXISTING);
  1223. @endcode
  1224. @see SetSize()
  1225. */
  1226. void Move(int x, int y, int flags = wxSIZE_USE_EXISTING);
  1227. /**
  1228. Moves the window to the given position.
  1229. @param pt
  1230. wxPoint object representing the position.
  1231. @param flags
  1232. See SetSize() for more info about this parameter.
  1233. @remarks Implementations of SetSize() can also implicitly implement the
  1234. Move() function, which is defined in the base wxWindow class as the call:
  1235. @code
  1236. SetSize(x, y, wxDefaultCoord, wxDefaultCoord, wxSIZE_USE_EXISTING);
  1237. @endcode
  1238. @see SetSize()
  1239. */
  1240. void Move(const wxPoint& pt, int flags = wxSIZE_USE_EXISTING);
  1241. void SetPosition(const wxPoint& pt);
  1242. //@}
  1243. /**
  1244. @name Coordinate conversion functions
  1245. */
  1246. //@{
  1247. /**
  1248. Converts to screen coordinates from coordinates relative to this window.
  1249. @param x
  1250. A pointer to a integer value for the x coordinate. Pass the client
  1251. coordinate in, and a screen coordinate will be passed out.
  1252. @param y
  1253. A pointer to a integer value for the y coordinate. Pass the client
  1254. coordinate in, and a screen coordinate will be passed out.
  1255. @beginWxPerlOnly
  1256. In wxPerl this method returns a 2-element list instead of
  1257. modifying its parameters.
  1258. @endWxPerlOnly
  1259. */
  1260. void ClientToScreen(int* x, int* y) const;
  1261. /**
  1262. Converts to screen coordinates from coordinates relative to this window.
  1263. @param pt
  1264. The client position for the second form of the function.
  1265. */
  1266. wxPoint ClientToScreen(const wxPoint& pt) const;
  1267. /**
  1268. Converts a point or size from dialog units to pixels.
  1269. For the x dimension, the dialog units are multiplied by the average character
  1270. width and then divided by 4.
  1271. For the y dimension, the dialog units are multiplied by the average character
  1272. height and then divided by 8.
  1273. @remarks Dialog units are used for maintaining a dialog's proportions
  1274. even if the font changes.
  1275. You can also use these functions programmatically.
  1276. A convenience macro is defined:
  1277. @code
  1278. #define wxDLG_UNIT(parent, pt) parent->ConvertDialogToPixels(pt)
  1279. @endcode
  1280. @see ConvertPixelsToDialog()
  1281. */
  1282. wxPoint ConvertDialogToPixels(const wxPoint& pt) const;
  1283. /**
  1284. @overload
  1285. */
  1286. wxSize ConvertDialogToPixels(const wxSize& sz) const;
  1287. /**
  1288. Converts a point or size from pixels to dialog units.
  1289. For the x dimension, the pixels are multiplied by 4 and then divided by the
  1290. average character width.
  1291. For the y dimension, the pixels are multiplied by 8 and then divided by the
  1292. average character height.
  1293. @remarks Dialog units are used for maintaining a dialog's proportions
  1294. even if the font changes.
  1295. @see ConvertDialogToPixels()
  1296. */
  1297. wxPoint ConvertPixelsToDialog(const wxPoint& pt) const;
  1298. /**
  1299. @overload
  1300. */
  1301. wxSize ConvertPixelsToDialog(const wxSize& sz) const;
  1302. /**
  1303. Converts from screen to client window coordinates.
  1304. @param x
  1305. Stores the screen x coordinate and receives the client x coordinate.
  1306. @param y
  1307. Stores the screen x coordinate and receives the client x coordinate.
  1308. */
  1309. void ScreenToClient(int* x, int* y) const;
  1310. /**
  1311. Converts from screen to client window coordinates.
  1312. @param pt
  1313. The screen position.
  1314. */
  1315. wxPoint ScreenToClient(const wxPoint& pt) const;
  1316. //@}
  1317. /**
  1318. @name Drawing-related functions
  1319. */
  1320. //@{
  1321. /**
  1322. Clears the window by filling it with the current background colour.
  1323. Does not cause an erase background event to be generated.
  1324. Notice that this uses wxClientDC to draw on the window and the results
  1325. of doing it while also drawing on wxPaintDC for this window are
  1326. undefined. Hence this method shouldn't be used from EVT_PAINT handlers,
  1327. just use wxDC::Clear() on the wxPaintDC you already use there instead.
  1328. */
  1329. virtual void ClearBackground();
  1330. /**
  1331. Freezes the window or, in other words, prevents any updates from taking
  1332. place on screen, the window is not redrawn at all.
  1333. Thaw() must be called to reenable window redrawing. Calls to these two
  1334. functions may be nested but to ensure that the window is properly
  1335. repainted again, you must thaw it exactly as many times as you froze it.
  1336. If the window has any children, they are recursively frozen too.
  1337. This method is useful for visual appearance optimization (for example,
  1338. it is a good idea to use it before doing many large text insertions in
  1339. a row into a wxTextCtrl under wxGTK) but is not implemented on all
  1340. platforms nor for all controls so it is mostly just a hint to wxWidgets
  1341. and not a mandatory directive.
  1342. @see wxWindowUpdateLocker, Thaw(), IsFrozen()
  1343. */
  1344. void Freeze();
  1345. /**
  1346. Re-enables window updating after a previous call to Freeze().
  1347. To really thaw the control, it must be called exactly the same number
  1348. of times as Freeze().
  1349. If the window has any children, they are recursively thawed too.
  1350. @see wxWindowUpdateLocker, Freeze(), IsFrozen()
  1351. */
  1352. void Thaw();
  1353. /**
  1354. Returns @true if the window is currently frozen by a call to Freeze().
  1355. @see Freeze(), Thaw()
  1356. */
  1357. bool IsFrozen() const;
  1358. /**
  1359. Returns the background colour of the window.
  1360. @see SetBackgroundColour(), SetForegroundColour(), GetForegroundColour()
  1361. */
  1362. wxColour GetBackgroundColour() const;
  1363. /**
  1364. Returns the background style of the window.
  1365. @see SetBackgroundColour(), GetForegroundColour(),
  1366. SetBackgroundStyle(), SetTransparent()
  1367. */
  1368. virtual wxBackgroundStyle GetBackgroundStyle() const;
  1369. /**
  1370. Returns the character height for this window.
  1371. */
  1372. virtual int GetCharHeight() const;
  1373. /**
  1374. Returns the average character width for this window.
  1375. */
  1376. virtual int GetCharWidth() const;
  1377. /**
  1378. Currently this is the same as calling
  1379. wxWindow::GetClassDefaultAttributes(wxWindow::GetWindowVariant()).
  1380. One advantage of using this function compared to the static version is that
  1381. the call is automatically dispatched to the correct class (as usual with
  1382. virtual functions) and you don't have to specify the class name explicitly.
  1383. The other one is that in the future this function could return different
  1384. results, for example it might return a different font for an "Ok" button
  1385. than for a generic button if the users GUI is configured to show such buttons
  1386. in bold font. Of course, the down side is that it is impossible to call this
  1387. function without actually having an object to apply it to whereas the static
  1388. version can be used without having to create an object first.
  1389. */
  1390. virtual wxVisualAttributes GetDefaultAttributes() const;
  1391. /**
  1392. Returns the font for this window.
  1393. @see SetFont()
  1394. */
  1395. wxFont GetFont() const;
  1396. /**
  1397. Returns the foreground colour of the window.
  1398. @remarks The meaning of foreground colour varies according to the window class;
  1399. it may be the text colour or other colour, or it may not be used at all.
  1400. @see SetForegroundColour(), SetBackgroundColour(),
  1401. GetBackgroundColour()
  1402. */
  1403. wxColour GetForegroundColour() const;
  1404. /**
  1405. Gets the dimensions of the string as it would be drawn on the
  1406. window with the currently selected font.
  1407. The text extent is returned in the @a w and @a h pointers.
  1408. @param string
  1409. String whose extent is to be measured.
  1410. @param w
  1411. Return value for width.
  1412. @param h
  1413. Return value for height.
  1414. @param descent
  1415. Return value for descent (optional).
  1416. @param externalLeading
  1417. Return value for external leading (optional).
  1418. @param font
  1419. Font to use instead of the current window font (optional).
  1420. @beginWxPerlOnly
  1421. In wxPerl this method takes only the @a string and optionally
  1422. @a font parameters, and returns a 4-element list
  1423. (x, y, descent, externalLeading).
  1424. @endWxPerlOnly
  1425. */
  1426. void GetTextExtent(const wxString& string,
  1427. int* w, int* h,
  1428. int* descent = NULL,
  1429. int* externalLeading = NULL,
  1430. const wxFont* font = NULL) const;
  1431. /**
  1432. Gets the dimensions of the string as it would be drawn on the
  1433. window with the currently selected font.
  1434. */
  1435. wxSize GetTextExtent(const wxString& string) const;
  1436. /**
  1437. Returns the region specifying which parts of the window have been damaged.
  1438. Should only be called within an wxPaintEvent handler.
  1439. @see wxRegion, wxRegionIterator
  1440. */
  1441. const wxRegion& GetUpdateRegion() const;
  1442. /**
  1443. Get the update rectangle bounding box in client coords
  1444. */
  1445. wxRect GetUpdateClientRect() const;
  1446. /**
  1447. Returns @true if this window background is transparent (as, for example,
  1448. for wxStaticText) and should show the parent window background.
  1449. This method is mostly used internally by the library itself and you normally
  1450. shouldn't have to call it. You may, however, have to override it in your
  1451. wxWindow-derived class to ensure that background is painted correctly.
  1452. */
  1453. virtual bool HasTransparentBackground();
  1454. /**
  1455. Causes this window, and all of its children recursively (except under wxGTK1
  1456. where this is not implemented), to be repainted. Note that repainting doesn't
  1457. happen immediately but only during the next event loop iteration, if you need
  1458. to update the window immediately you should use Update() instead.
  1459. @param eraseBackground
  1460. If @true, the background will be erased.
  1461. @param rect
  1462. If non-@NULL, only the given rectangle will be treated as damaged.
  1463. @see RefreshRect()
  1464. */
  1465. virtual void Refresh(bool eraseBackground = true,
  1466. const wxRect* rect = NULL);
  1467. /**
  1468. Redraws the contents of the given rectangle: only the area inside it will be
  1469. repainted.
  1470. This is the same as Refresh() but has a nicer syntax as it can be called
  1471. with a temporary wxRect object as argument like this @c RefreshRect(wxRect(x, y, w, h)).
  1472. */
  1473. void RefreshRect(const wxRect& rect, bool eraseBackground = true);
  1474. /**
  1475. Calling this method immediately repaints the invalidated area of the window and
  1476. all of its children recursively (this normally only happens when the
  1477. flow of control returns to the event loop).
  1478. Notice that this function doesn't invalidate any area of the window so
  1479. nothing happens if nothing has been invalidated (i.e. marked as requiring
  1480. a redraw). Use Refresh() first if you want to immediately redraw the
  1481. window unconditionally.
  1482. */
  1483. virtual void Update();
  1484. /**
  1485. Sets the background colour of the window.
  1486. Notice that as with SetForegroundColour(), setting the background
  1487. colour of a native control may not affect the entire control and could
  1488. be not supported at all depending on the control and platform.
  1489. Please see InheritAttributes() for explanation of the difference between
  1490. this method and SetOwnBackgroundColour().
  1491. @param colour
  1492. The colour to be used as the background colour; pass
  1493. wxNullColour to reset to the default colour.
  1494. Note that you may want to use wxSystemSettings::GetColour() to retrieve
  1495. a suitable colour to use rather than setting an hard-coded one.
  1496. @remarks The background colour is usually painted by the default
  1497. wxEraseEvent event handler function under Windows and
  1498. automatically under GTK.
  1499. Note that setting the background colour does not cause an
  1500. immediate refresh, so you may wish to call wxWindow::ClearBackground
  1501. or wxWindow::Refresh after calling this function.
  1502. Using this function will disable attempts to use themes for
  1503. this window, if the system supports them. Use with care since
  1504. usually the themes represent the appearance chosen by the user
  1505. to be used for all applications on the system.
  1506. @return @true if the colour was really changed, @false if it was already set
  1507. to this colour and nothing was done.
  1508. @see GetBackgroundColour(), SetForegroundColour(),
  1509. GetForegroundColour(), ClearBackground(),
  1510. Refresh(), wxEraseEvent, wxSystemSettings
  1511. */
  1512. virtual bool SetBackgroundColour(const wxColour& colour);
  1513. /**
  1514. Sets the background style of the window.
  1515. The default background style is @c wxBG_STYLE_ERASE which indicates that
  1516. the window background may be erased in @c EVT_ERASE_BACKGROUND handler.
  1517. This is a safe, compatibility default; however you may want to change it
  1518. to @c wxBG_STYLE_SYSTEM if you don't define any erase background event
  1519. handlers at all, to avoid unnecessary generation of erase background
  1520. events and always let system erase the background. And you should
  1521. change the background style to @c wxBG_STYLE_PAINT if you define an
  1522. @c EVT_PAINT handler which completely overwrites the window background as
  1523. in this case erasing it previously, either in @c EVT_ERASE_BACKGROUND
  1524. handler or in the system default handler, would result in flicker as
  1525. the background pixels will be repainted twice every time the window is
  1526. redrawn. Do ensure that the background is entirely erased by your
  1527. @c EVT_PAINT handler in this case however as otherwise garbage may be left
  1528. on screen.
  1529. Notice that in previous versions of wxWidgets a common way to work
  1530. around the above mentioned flickering problem was to define an empty
  1531. @c EVT_ERASE_BACKGROUND handler. Setting background style to
  1532. @c wxBG_STYLE_PAINT is a simpler and more efficient solution to the same
  1533. problem.
  1534. Under wxGTK and wxOSX, you can use ::wxBG_STYLE_TRANSPARENT to obtain
  1535. full transparency of the window background. Note that wxGTK supports
  1536. this only since GTK 2.12 with a compositing manager enabled, call
  1537. IsTransparentBackgroundSupported() to check whether this is the case.
  1538. Also, on order for @c SetBackgroundStyle(wxBG_STYLE_TRANSPARENT) to
  1539. work, it must be called before Create(). If you're using your own
  1540. wxWindow-derived class you should write your code in the following way:
  1541. @code
  1542. class MyWidget : public wxWindow
  1543. {
  1544. public:
  1545. MyWidget(wxWindow* parent, ...)
  1546. : wxWindow() // Use default ctor here!
  1547. {
  1548. // Do this first:
  1549. SetBackgroundStyle(wxBG_STYLE_TRANSPARENT);
  1550. // And really create the window afterwards:
  1551. Create(parent, ...);
  1552. }
  1553. };
  1554. @endcode
  1555. @see SetBackgroundColour(), GetForegroundColour(),
  1556. SetTransparent(), IsTransparentBackgroundSupported()
  1557. */
  1558. virtual bool SetBackgroundStyle(wxBackgroundStyle style);
  1559. /**
  1560. Checks whether using transparent background might work.
  1561. If this function returns @false, calling SetBackgroundStyle() with
  1562. ::wxBG_STYLE_TRANSPARENT is not going to work. If it returns @true,
  1563. setting transparent style should normally succeed.
  1564. Notice that this function would typically be called on the parent of a
  1565. window you want to set transparent background style for as the window
  1566. for which this method is called must be fully created.
  1567. @param reason
  1568. If not @NULL, a reason message is provided if transparency is not
  1569. supported.
  1570. @return @true if background transparency is supported.
  1571. @since 2.9.4
  1572. */
  1573. virtual bool IsTransparentBackgroundSupported(wxString *reason = NULL) const;
  1574. /**
  1575. Sets the font for this window. This function should not be called for the
  1576. parent window if you don't want its font to be inherited by its children,
  1577. use SetOwnFont() instead in this case and see InheritAttributes() for more
  1578. explanations.
  1579. Please notice that the given font is not automatically used for
  1580. wxPaintDC objects associated with this window, you need to
  1581. call wxDC::SetFont too. However this font is used by
  1582. any standard controls for drawing their text as well as by
  1583. GetTextExtent().
  1584. @param font
  1585. Font to associate with this window, pass
  1586. wxNullFont to reset to the default font.
  1587. @return @true if the font was really changed, @false if it was already set
  1588. to this font and nothing was done.
  1589. @see GetFont(), InheritAttributes()
  1590. */
  1591. virtual bool SetFont(const wxFont& font);
  1592. /**
  1593. Sets the foreground colour of the window.
  1594. The meaning of foreground colour varies according to the window class;
  1595. it may be the text colour or other colour, or it may not be used at
  1596. all. Additionally, not all native controls support changing their
  1597. foreground colour so this method may change their colour only partially
  1598. or even not at all.
  1599. Please see InheritAttributes() for explanation of the difference between
  1600. this method and SetOwnForegroundColour().
  1601. @param colour
  1602. The colour to be used as the foreground colour; pass
  1603. wxNullColour to reset to the default colour.
  1604. @return @true if the colour was really changed, @false if it was already set
  1605. to this colour and nothing was done.
  1606. @see GetForegroundColour(), SetBackgroundColour(),
  1607. GetBackgroundColour(), ShouldInheritColours()
  1608. */
  1609. virtual bool SetForegroundColour(const wxColour& colour);
  1610. /**
  1611. Sets the background colour of the window but prevents it from being inherited
  1612. by the children of this window.
  1613. @see SetBackgroundColour(), InheritAttributes()
  1614. */
  1615. void SetOwnBackgroundColour(const wxColour& colour);
  1616. /**
  1617. Return @true if this window inherits the background colour from its parent.
  1618. @see SetOwnBackgroundColour(), InheritAttributes()
  1619. */
  1620. bool InheritsBackgroundColour() const;
  1621. /**
  1622. Return @true if a background colour has been set for this window.
  1623. */
  1624. bool UseBgCol() const;
  1625. /**
  1626. Sets the font of the window but prevents it from being inherited by the
  1627. children of this window.
  1628. @see SetFont(), InheritAttributes()
  1629. */
  1630. void SetOwnFont(const wxFont& font);
  1631. /**
  1632. Sets the foreground colour of the window but prevents it from being inherited
  1633. by the children of this window.
  1634. @see SetForegroundColour(), InheritAttributes()
  1635. */
  1636. void SetOwnForegroundColour(const wxColour& colour);
  1637. /**
  1638. @deprecated use wxDC::SetPalette instead.
  1639. */
  1640. void SetPalette(const wxPalette& pal);
  1641. /**
  1642. Return @true from here to allow the colours of this window to be changed by
  1643. InheritAttributes(). Returning @false forbids inheriting them from the parent window.
  1644. The base class version returns @false, but this method is overridden in
  1645. wxControl where it returns @true.
  1646. */
  1647. virtual bool ShouldInheritColours() const;
  1648. /**
  1649. This function tells a window if it should use the system's "theme" code
  1650. to draw the windows' background instead of its own background drawing
  1651. code. This does not always have any effect since the underlying platform
  1652. obviously needs to support the notion of themes in user defined windows.
  1653. One such platform is GTK+ where windows can have (very colourful) backgrounds
  1654. defined by a user's selected theme.
  1655. Dialogs, notebook pages and the status bar have this flag set to @true
  1656. by default so that the default look and feel is simulated best.
  1657. */
  1658. virtual void SetThemeEnabled(bool enable);
  1659. /**
  1660. */
  1661. virtual bool GetThemeEnabled() const;
  1662. /**
  1663. Returns @true if the system supports transparent windows and calling
  1664. SetTransparent() may succeed. If this function returns @false, transparent
  1665. windows are definitely not supported by the current system.
  1666. */
  1667. virtual bool CanSetTransparent();
  1668. /**
  1669. Set the transparency of the window. If the system supports transparent windows,
  1670. returns @true, otherwise returns @false and the window remains fully opaque.
  1671. See also CanSetTransparent().
  1672. The parameter @a alpha is in the range 0..255 where 0 corresponds to a
  1673. fully transparent window and 255 to the fully opaque one. The constants
  1674. @c wxIMAGE_ALPHA_TRANSPARENT and @c wxIMAGE_ALPHA_OPAQUE can be used.
  1675. */
  1676. virtual bool SetTransparent(wxByte alpha);
  1677. //@}
  1678. /**
  1679. @name Event-handling functions
  1680. wxWindow allows you to build a (sort of) stack of event handlers which
  1681. can be used to override the window's own event handling.
  1682. */
  1683. //@{
  1684. /**
  1685. Returns the event handler for this window.
  1686. By default, the window is its own event handler.
  1687. @see SetEventHandler(), PushEventHandler(),
  1688. PopEventHandler(), wxEvtHandler::ProcessEvent, wxEvtHandler
  1689. */
  1690. wxEvtHandler* GetEventHandler() const;
  1691. /**
  1692. This function will generate the appropriate call to Navigate() if the key
  1693. event is one normally used for keyboard navigation and return @true in this case.
  1694. @return Returns @true if the key pressed was for navigation and was
  1695. handled, @false otherwise.
  1696. @see Navigate()
  1697. */
  1698. bool HandleAsNavigationKey(const wxKeyEvent& event);
  1699. /**
  1700. Shorthand for:
  1701. @code
  1702. GetEventHandler()->SafelyProcessEvent(event);
  1703. @endcode
  1704. @see ProcessWindowEvent()
  1705. */
  1706. bool HandleWindowEvent(wxEvent& event) const;
  1707. /**
  1708. Convenient wrapper for ProcessEvent().
  1709. This is the same as writing @code GetEventHandler()->ProcessEvent(event);
  1710. @endcode but more convenient. Notice that ProcessEvent() itself can't
  1711. be called for wxWindow objects as it ignores the event handlers
  1712. associated with the window; use this function instead.
  1713. */
  1714. bool ProcessWindowEvent(wxEvent& event);
  1715. /**
  1716. Wrapper for wxEvtHandler::ProcessEventLocally().
  1717. This method is similar to ProcessWindowEvent() but can be used to
  1718. search for the event handler only in this window and any event handlers
  1719. pushed on top of it. Unlike ProcessWindowEvent() it won't propagate the
  1720. event upwards. But it will use the validator and event handlers
  1721. associated with this window, if any.
  1722. @since 2.9.1
  1723. */
  1724. bool ProcessWindowEventLocally(wxEvent& event);
  1725. /**
  1726. Removes and returns the top-most event handler on the event handler stack.
  1727. E.g. in the case of:
  1728. @image html overview_events_winstack.png
  1729. when calling @c W->PopEventHandler(), the event handler @c A will be
  1730. removed and @c B will be the first handler of the stack.
  1731. Note that it's an error to call this function when no event handlers
  1732. were pushed on this window (i.e. when the window itself is its only
  1733. event handler).
  1734. @param deleteHandler
  1735. If this is @true, the handler will be deleted after it is removed
  1736. (and the returned value will be @NULL).
  1737. @see @ref overview_events_processing
  1738. */
  1739. wxEvtHandler* PopEventHandler(bool deleteHandler = false);
  1740. /**
  1741. Pushes this event handler onto the event stack for the window.
  1742. An event handler is an object that is capable of processing the events sent
  1743. to a window. By default, the window is its own event handler, but an application
  1744. may wish to substitute another, for example to allow central implementation
  1745. of event-handling for a variety of different window classes.
  1746. wxWindow::PushEventHandler allows an application to set up a @e stack
  1747. of event handlers, where an event not handled by one event handler is
  1748. handed to the next one in the chain.
  1749. E.g. if you have two event handlers @c A and @c B and a wxWindow instance
  1750. @c W and you call:
  1751. @code
  1752. W->PushEventHandler(A);
  1753. W->PushEventHandler(B);
  1754. @endcode
  1755. you will end up with the following situation:
  1756. @image html overview_events_winstack.png
  1757. Note that you can use wxWindow::PopEventHandler to remove the event handler.
  1758. @param handler
  1759. Specifies the handler to be pushed.
  1760. It must not be part of a wxEvtHandler chain; an assert will fail
  1761. if it's not unlinked (see wxEvtHandler::IsUnlinked).
  1762. @see @ref overview_events_processing
  1763. */
  1764. void PushEventHandler(wxEvtHandler* handler);
  1765. /**
  1766. Find the given @a handler in the windows event handler stack and
  1767. removes (but does not delete) it from the stack.
  1768. See wxEvtHandler::Unlink() for more info.
  1769. @param handler
  1770. The event handler to remove, must be non-@NULL and
  1771. must be present in this windows event handlers stack.
  1772. @return Returns @true if it was found and @false otherwise (this also
  1773. results in an assert failure so this function should
  1774. only be called when the handler is supposed to be there).
  1775. @see PushEventHandler(), PopEventHandler()
  1776. */
  1777. bool RemoveEventHandler(wxEvtHandler* handler);
  1778. /**
  1779. Sets the event handler for this window.
  1780. Note that if you use this function you may want to use as the "next" handler
  1781. of @a handler the window itself; in this way when @a handler doesn't process
  1782. an event, the window itself will have a chance to do it.
  1783. @param handler
  1784. Specifies the handler to be set. Cannot be @NULL.
  1785. @see @ref overview_events_processing
  1786. */
  1787. void SetEventHandler(wxEvtHandler* handler);
  1788. /**
  1789. wxWindows cannot be used to form event handler chains; this function
  1790. thus will assert when called.
  1791. Note that instead you can use PushEventHandler() or SetEventHandler() to
  1792. implement a stack of event handlers to override wxWindow's own
  1793. event handling mechanism.
  1794. */
  1795. virtual void SetNextHandler(wxEvtHandler* handler);
  1796. /**
  1797. wxWindows cannot be used to form event handler chains; this function
  1798. thus will assert when called.
  1799. Note that instead you can use PushEventHandler() or SetEventHandler() to
  1800. implement a stack of event handlers to override wxWindow's own
  1801. event handling mechanism.
  1802. */
  1803. virtual void SetPreviousHandler(wxEvtHandler* handler);
  1804. //@}
  1805. /**
  1806. @name Window styles functions
  1807. */
  1808. //@{
  1809. /**
  1810. Returns the extra style bits for the window.
  1811. */
  1812. long GetExtraStyle() const;
  1813. /**
  1814. Gets the window style that was passed to the constructor or Create()
  1815. method. GetWindowStyle() is another name for the same function.
  1816. */
  1817. virtual long GetWindowStyleFlag() const;
  1818. /**
  1819. See GetWindowStyleFlag() for more info.
  1820. */
  1821. long GetWindowStyle() const;
  1822. /**
  1823. Returns @true if the window has the given @a exFlag bit set in its
  1824. extra styles.
  1825. @see SetExtraStyle()
  1826. */
  1827. bool HasExtraStyle(int exFlag) const;
  1828. /**
  1829. Returns @true if the window has the given @a flag bit set.
  1830. */
  1831. bool HasFlag(int flag) const;
  1832. /**
  1833. Sets the extra style bits for the window.
  1834. The currently defined extra style bits are reported in the class
  1835. description.
  1836. */
  1837. virtual void SetExtraStyle(long exStyle);
  1838. /**
  1839. Sets the style of the window. Please note that some styles cannot be changed
  1840. after the window creation and that Refresh() might need to be called
  1841. after changing the others for the change to take place immediately.
  1842. See @ref overview_windowstyles "Window styles" for more information about flags.
  1843. @see GetWindowStyleFlag()
  1844. */
  1845. virtual void SetWindowStyleFlag(long style);
  1846. /**
  1847. See SetWindowStyleFlag() for more info.
  1848. */
  1849. void SetWindowStyle(long style);
  1850. /**
  1851. Turns the given @a flag on if it's currently turned off and vice versa.
  1852. This function cannot be used if the value of the flag is 0 (which is often
  1853. the case for default flags).
  1854. Also, please notice that not all styles can be changed after the control
  1855. creation.
  1856. @return Returns @true if the style was turned on by this function, @false
  1857. if it was switched off.
  1858. @see SetWindowStyleFlag(), HasFlag()
  1859. */
  1860. bool ToggleWindowStyle(int flag);
  1861. //@}
  1862. /**
  1863. @name Tab order functions
  1864. */
  1865. //@{
  1866. /**
  1867. Moves this window in the tab navigation order after the specified @e win.
  1868. This means that when the user presses @c TAB key on that other window,
  1869. the focus switches to this window.
  1870. Default tab order is the same as creation order, this function and
  1871. MoveBeforeInTabOrder() allow to change
  1872. it after creating all the windows.
  1873. @param win
  1874. A sibling of this window which should precede it in tab order,
  1875. must not be @NULL
  1876. */
  1877. void MoveAfterInTabOrder(wxWindow* win);
  1878. /**
  1879. Same as MoveAfterInTabOrder() except that it inserts this window just
  1880. before @a win instead of putting it right after it.
  1881. */
  1882. void MoveBeforeInTabOrder(wxWindow* win);
  1883. /**
  1884. Performs a keyboard navigation action starting from this window.
  1885. This method is equivalent to calling NavigateIn() method on the
  1886. parent window.
  1887. @param flags
  1888. A combination of wxNavigationKeyEvent::IsForward and
  1889. wxNavigationKeyEvent::WinChange.
  1890. @return Returns @true if the focus was moved to another window or @false
  1891. if nothing changed.
  1892. @remarks You may wish to call this from a text control custom keypress
  1893. handler to do the default navigation behaviour for the
  1894. tab key, since the standard default behaviour for a
  1895. multiline text control with the wxTE_PROCESS_TAB style
  1896. is to insert a tab and not navigate to the next
  1897. control. See also wxNavigationKeyEvent and
  1898. HandleAsNavigationKey.
  1899. */
  1900. bool Navigate(int flags = wxNavigationKeyEvent::IsForward);
  1901. /**
  1902. Performs a keyboard navigation action inside this window.
  1903. See Navigate() for more information.
  1904. */
  1905. bool NavigateIn(int flags = wxNavigationKeyEvent::IsForward);
  1906. //@}
  1907. /**
  1908. @name Z order functions
  1909. */
  1910. //@{
  1911. /**
  1912. Lowers the window to the bottom of the window hierarchy (Z-order).
  1913. @remarks
  1914. This function only works for wxTopLevelWindow-derived classes.
  1915. @see Raise()
  1916. */
  1917. virtual void Lower();
  1918. /**
  1919. Raises the window to the top of the window hierarchy (Z-order).
  1920. Notice that this function only requests the window manager to raise
  1921. this window to the top of Z-order. Depending on its configuration, the
  1922. window manager may raise the window, not do it at all or indicate that
  1923. a window requested to be raised in some other way, e.g. by flashing its
  1924. icon if it is minimized.
  1925. @remarks
  1926. This function only works for wxTopLevelWindow-derived classes.
  1927. @see Lower()
  1928. */
  1929. virtual void Raise();
  1930. //@}
  1931. /**
  1932. @name Window status functions
  1933. */
  1934. //@{
  1935. /**
  1936. Equivalent to calling wxWindow::Show(@false).
  1937. */
  1938. bool Hide();
  1939. /**
  1940. This function hides a window, like Hide(), but using a special visual
  1941. effect if possible.
  1942. The parameters of this function are the same as for ShowWithEffect(),
  1943. please see their description there.
  1944. @since 2.9.0
  1945. */
  1946. virtual bool HideWithEffect(wxShowEffect effect,
  1947. unsigned int timeout = 0);
  1948. /**
  1949. Returns @true if the window is enabled, i.e.\ if it accepts user input,
  1950. @false otherwise.
  1951. Notice that this method can return @false even if this window itself hadn't
  1952. been explicitly disabled when one of its parent windows is disabled.
  1953. To get the intrinsic status of this window, use IsThisEnabled()
  1954. @see Enable()
  1955. */
  1956. bool IsEnabled() const;
  1957. /**
  1958. Returns @true if the given point or rectangle area has been exposed since the
  1959. last repaint. Call this in an paint event handler to optimize redrawing by
  1960. only redrawing those areas, which have been exposed.
  1961. */
  1962. bool IsExposed(int x, int y) const;
  1963. /**
  1964. @overload
  1965. */
  1966. bool IsExposed(wxPoint& pt) const;
  1967. /**
  1968. @overload
  1969. */
  1970. bool IsExposed(int x, int y, int w, int h) const;
  1971. /**
  1972. @overload
  1973. */
  1974. bool IsExposed(wxRect& rect) const;
  1975. /**
  1976. Returns @true if the window is shown, @false if it has been hidden.
  1977. @see IsShownOnScreen()
  1978. */
  1979. virtual bool IsShown() const;
  1980. /**
  1981. Returns @true if the window is physically visible on the screen, i.e.\ it
  1982. is shown and all its parents up to the toplevel window are shown as well.
  1983. @see IsShown()
  1984. */
  1985. virtual bool IsShownOnScreen() const;
  1986. /**
  1987. Disables the window. Same as @ref Enable() Enable(@false).
  1988. @return Returns @true if the window has been disabled, @false if it had
  1989. been already disabled before the call to this function.
  1990. */
  1991. bool Disable();
  1992. /**
  1993. Enable or disable the window for user input. Note that when a parent window is
  1994. disabled, all of its children are disabled as well and they are reenabled again
  1995. when the parent is.
  1996. @param enable
  1997. If @true, enables the window for input. If @false, disables the window.
  1998. @return Returns @true if the window has been enabled or disabled, @false
  1999. if nothing was done, i.e. if the window had already
  2000. been in the specified state.
  2001. @see IsEnabled(), Disable(), wxRadioBox::Enable
  2002. */
  2003. virtual bool Enable(bool enable = true);
  2004. /**
  2005. Shows or hides the window. You may need to call Raise()
  2006. for a top level window if you want to bring it to top, although this is not
  2007. needed if Show() is called immediately after the frame creation.
  2008. Notice that the default state of newly created top level windows is hidden
  2009. (to allow you to create their contents without flicker) unlike for
  2010. all the other, not derived from wxTopLevelWindow, windows that
  2011. are by default created in the shown state.
  2012. @param show
  2013. If @true displays the window. Otherwise, hides it.
  2014. @return @true if the window has been shown or hidden or @false if nothing
  2015. was done because it already was in the requested state.
  2016. @see IsShown(), Hide(), wxRadioBox::Show, wxShowEvent.
  2017. */
  2018. virtual bool Show(bool show = true);
  2019. /**
  2020. This function shows a window, like Show(), but using a special visual
  2021. effect if possible.
  2022. @param effect
  2023. The effect to use.
  2024. @param timeout
  2025. The @a timeout parameter specifies the time of the animation, in
  2026. milliseconds. If the default value of 0 is used, the default
  2027. animation time for the current platform is used.
  2028. @note Currently this function is only implemented in wxMSW and wxOSX
  2029. (for wxTopLevelWindows only in Carbon version and for any kind of
  2030. windows in Cocoa) and does the same thing as Show() in the other
  2031. ports.
  2032. @since 2.9.0
  2033. @see HideWithEffect()
  2034. */
  2035. virtual bool ShowWithEffect(wxShowEffect effect,
  2036. unsigned int timeout = 0);
  2037. //@}
  2038. /**
  2039. @name Context-sensitive help functions
  2040. */
  2041. //@{
  2042. /**
  2043. Gets the help text to be used as context-sensitive help for this window.
  2044. Note that the text is actually stored by the current wxHelpProvider
  2045. implementation, and not in the window object itself.
  2046. @see SetHelpText(), GetHelpTextAtPoint(), wxHelpProvider
  2047. */
  2048. wxString GetHelpText() const;
  2049. /**
  2050. Sets the help text to be used as context-sensitive help for this window.
  2051. Note that the text is actually stored by the current wxHelpProvider
  2052. implementation, and not in the window object itself.
  2053. @see GetHelpText(), wxHelpProvider::AddHelp()
  2054. */
  2055. void SetHelpText(const wxString& helpText);
  2056. /**
  2057. Gets the help text to be used as context-sensitive help for this window.
  2058. This method should be overridden if the help message depends on the position
  2059. inside the window, otherwise GetHelpText() can be used.
  2060. @param point
  2061. Coordinates of the mouse at the moment of help event emission.
  2062. @param origin
  2063. Help event origin, see also wxHelpEvent::GetOrigin.
  2064. */
  2065. virtual wxString GetHelpTextAtPoint(const wxPoint& point,
  2066. wxHelpEvent::Origin origin) const;
  2067. /**
  2068. Get the associated tooltip or @NULL if none.
  2069. */
  2070. wxToolTip* GetToolTip() const;
  2071. /**
  2072. Get the text of the associated tooltip or empty string if none.
  2073. */
  2074. wxString GetToolTipText() const;
  2075. /**
  2076. Attach a tooltip to the window.
  2077. wxToolTip pointer can be @NULL in the overload taking the pointer,
  2078. meaning to unset any existing tooltips; however UnsetToolTip() provides
  2079. a more readable alternative to this operation.
  2080. Notice that these methods are always available, even if wxWidgets was
  2081. compiled with @c wxUSE_TOOLTIPS set to 0, but don't do anything in this
  2082. case.
  2083. @see GetToolTip(), wxToolTip
  2084. */
  2085. void SetToolTip(const wxString& tipString);
  2086. /**
  2087. @overload
  2088. */
  2089. void SetToolTip(wxToolTip* tip);
  2090. /**
  2091. Unset any existing tooltip.
  2092. @since 2.9.0
  2093. @see SetToolTip()
  2094. */
  2095. void UnsetToolTip();
  2096. //@}
  2097. /**
  2098. @name Popup/context menu functions
  2099. */
  2100. //@{
  2101. /**
  2102. This function shows a popup menu at the given position in this window and
  2103. returns the selected id.
  2104. It can be more convenient than the general purpose PopupMenu() function
  2105. for simple menus proposing a choice in a list of strings to the user.
  2106. Notice that to avoid unexpected conflicts between the (usually
  2107. consecutive range of) ids used by the menu passed to this function and
  2108. the existing EVT_UPDATE_UI() handlers, this function temporarily
  2109. disables UI updates for the window, so you need to manually disable
  2110. (or toggle or ...) any items which should be disabled in the menu
  2111. before showing it.
  2112. The parameter @a menu is the menu to show.
  2113. The parameter @a pos (or the parameters @a x and @a y) is the
  2114. position at which to show the menu in client coordinates.
  2115. It is recommended to not explicitly specify coordinates when
  2116. calling this method in response to mouse click, because some of
  2117. the ports (namely, wxGTK) can do a better job of positioning
  2118. the menu in that case.
  2119. @return
  2120. The selected menu item id or @c wxID_NONE if none selected or an
  2121. error occurred.
  2122. @since 2.9.0
  2123. */
  2124. int GetPopupMenuSelectionFromUser(wxMenu& menu,
  2125. const wxPoint& pos = wxDefaultPosition);
  2126. /**
  2127. @overload
  2128. */
  2129. int GetPopupMenuSelectionFromUser(wxMenu& menu, int x, int y);
  2130. /**
  2131. Pops up the given menu at the specified coordinates, relative to this
  2132. window, and returns control when the user has dismissed the menu.
  2133. If a menu item is selected, the corresponding menu event is generated and will be
  2134. processed as usual. If coordinates are not specified, the current mouse
  2135. cursor position is used.
  2136. @a menu is the menu to pop up.
  2137. The position where the menu will appear can be specified either as a
  2138. wxPoint @a pos or by two integers (@a x and @a y).
  2139. @remarks Just before the menu is popped up, wxMenu::UpdateUI is called to
  2140. ensure that the menu items are in the correct state.
  2141. The menu does not get deleted by the window.
  2142. It is recommended to not explicitly specify coordinates when
  2143. calling PopupMenu in response to mouse click, because some of
  2144. the ports (namely, wxGTK) can do a better job of positioning
  2145. the menu in that case.
  2146. @see wxMenu
  2147. */
  2148. bool PopupMenu(wxMenu* menu,
  2149. const wxPoint& pos = wxDefaultPosition);
  2150. /**
  2151. @overload
  2152. */
  2153. bool PopupMenu(wxMenu* menu, int x, int y);
  2154. //@}
  2155. /**
  2156. Validator functions
  2157. */
  2158. //@{
  2159. /**
  2160. Returns a pointer to the current validator for the window, or @NULL if
  2161. there is none.
  2162. */
  2163. virtual wxValidator* GetValidator();
  2164. /**
  2165. Deletes the current validator (if any) and sets the window validator, having
  2166. called wxValidator::Clone to create a new validator of this type.
  2167. */
  2168. virtual void SetValidator(const wxValidator& validator);
  2169. /**
  2170. Transfers values from child controls to data areas specified by their
  2171. validators. Returns @false if a transfer failed.
  2172. If the window has @c wxWS_EX_VALIDATE_RECURSIVELY extra style flag set,
  2173. the method will also call TransferDataFromWindow() of all child windows.
  2174. @see TransferDataToWindow(), wxValidator, Validate()
  2175. */
  2176. virtual bool TransferDataFromWindow();
  2177. /**
  2178. Transfers values to child controls from data areas specified by their
  2179. validators.
  2180. If the window has @c wxWS_EX_VALIDATE_RECURSIVELY extra style flag set,
  2181. the method will also call TransferDataToWindow() of all child windows.
  2182. @return Returns @false if a transfer failed.
  2183. @see TransferDataFromWindow(), wxValidator, Validate()
  2184. */
  2185. virtual bool TransferDataToWindow();
  2186. /**
  2187. Validates the current values of the child controls using their validators.
  2188. If the window has @c wxWS_EX_VALIDATE_RECURSIVELY extra style flag set,
  2189. the method will also call Validate() of all child windows.
  2190. @return Returns @false if any of the validations failed.
  2191. @see TransferDataFromWindow(), TransferDataToWindow(),
  2192. wxValidator
  2193. */
  2194. virtual bool Validate();
  2195. //@}
  2196. /**
  2197. @name wxWindow properties functions
  2198. */
  2199. //@{
  2200. /**
  2201. Returns the identifier of the window.
  2202. @remarks Each window has an integer identifier. If the application
  2203. has not provided one (or the default wxID_ANY) a unique
  2204. identifier with a negative value will be generated.
  2205. @see SetId(), @ref overview_windowids
  2206. */
  2207. wxWindowID GetId() const;
  2208. /**
  2209. Generic way of getting a label from any window, for
  2210. identification purposes.
  2211. @remarks The interpretation of this function differs from class to class.
  2212. For frames and dialogs, the value returned is the
  2213. title. For buttons or static text controls, it is the
  2214. button text. This function can be useful for
  2215. meta-programs (such as testing tools or special-needs
  2216. access programs) which need to identify windows by name.
  2217. */
  2218. virtual wxString GetLabel() const;
  2219. /**
  2220. Returns the layout direction for this window,
  2221. Note that @c wxLayout_Default is returned if layout direction is not supported.
  2222. */
  2223. virtual wxLayoutDirection GetLayoutDirection() const;
  2224. /**
  2225. Mirror coordinates for RTL layout if this window uses it and if the
  2226. mirroring is not done automatically like Win32.
  2227. */
  2228. virtual wxCoord AdjustForLayoutDirection(wxCoord x,
  2229. wxCoord width,
  2230. wxCoord widthTotal) const;
  2231. /**
  2232. Returns the window's name.
  2233. @remarks This name is not guaranteed to be unique; it is up to the
  2234. programmer to supply an appropriate name in the window
  2235. constructor or via SetName().
  2236. @see SetName()
  2237. */
  2238. virtual wxString GetName() const;
  2239. /**
  2240. Returns the value previously passed to SetWindowVariant().
  2241. */
  2242. wxWindowVariant GetWindowVariant() const;
  2243. /**
  2244. Sets the identifier of the window.
  2245. @remarks Each window has an integer identifier. If the application has
  2246. not provided one, an identifier will be generated.
  2247. Normally, the identifier should be provided on creation
  2248. and should not be modified subsequently.
  2249. @see GetId(), @ref overview_windowids
  2250. */
  2251. void SetId(wxWindowID winid);
  2252. /**
  2253. Sets the window's label.
  2254. @param label
  2255. The window label.
  2256. @see GetLabel()
  2257. */
  2258. virtual void SetLabel(const wxString& label);
  2259. /**
  2260. Sets the layout direction for this window.
  2261. */
  2262. virtual void SetLayoutDirection(wxLayoutDirection dir);
  2263. /**
  2264. Sets the window's name.
  2265. @param name
  2266. A name to set for the window.
  2267. @see GetName()
  2268. */
  2269. virtual void SetName(const wxString& name);
  2270. /**
  2271. Chooses a different variant of the window display to use.
  2272. Window variants currently just differ in size, as can be seen from
  2273. ::wxWindowVariant documentation. Under all platforms but OS X, this
  2274. function does nothing more than change the font used by the window.
  2275. However under OS X it is implemented natively and selects the
  2276. appropriate variant of the native widget, which has better appearance
  2277. than just scaled down or up version of the normal variant, so it should
  2278. be preferred to directly tweaking the font size.
  2279. By default the controls naturally use the normal variant.
  2280. */
  2281. void SetWindowVariant(wxWindowVariant variant);
  2282. /**
  2283. Gets the accelerator table for this window. See wxAcceleratorTable.
  2284. */
  2285. wxAcceleratorTable* GetAcceleratorTable();
  2286. /**
  2287. Returns the accessible object for this window, if any.
  2288. See also wxAccessible.
  2289. */
  2290. wxAccessible* GetAccessible();
  2291. /**
  2292. Sets the accelerator table for this window. See wxAcceleratorTable.
  2293. */
  2294. virtual void SetAcceleratorTable(const wxAcceleratorTable& accel);
  2295. /**
  2296. Sets the accessible for this window. Any existing accessible for this window
  2297. will be deleted first, if not identical to @e accessible.
  2298. See also wxAccessible.
  2299. */
  2300. void SetAccessible(wxAccessible* accessible);
  2301. //@}
  2302. /**
  2303. @name Window deletion functions
  2304. */
  2305. //@{
  2306. /**
  2307. This function simply generates a wxCloseEvent whose handler usually tries
  2308. to close the window. It doesn't close the window itself, however.
  2309. @param force
  2310. @false if the window's close handler should be able to veto the destruction
  2311. of this window, @true if it cannot.
  2312. @return @true if the event was handled and not vetoed, @false otherwise.
  2313. @remarks Close calls the close handler for the window, providing an
  2314. opportunity for the window to choose whether to destroy
  2315. the window. Usually it is only used with the top level
  2316. windows (wxFrame and wxDialog classes) as the others
  2317. are not supposed to have any special OnClose() logic.
  2318. The close handler should check whether the window is being deleted
  2319. forcibly, using wxCloseEvent::CanVeto, in which case it should
  2320. destroy the window using wxWindow::Destroy.
  2321. Note that calling Close does not guarantee that the window will
  2322. be destroyed; but it provides a way to simulate a manual close
  2323. of a window, which may or may not be implemented by destroying
  2324. the window. The default implementation of wxDialog::OnCloseWindow
  2325. does not necessarily delete the dialog, since it will simply
  2326. simulate an wxID_CANCEL event which is handled by the appropriate
  2327. button event handler and may do anything at all.
  2328. To guarantee that the window will be destroyed, call
  2329. wxWindow::Destroy instead
  2330. @see @ref overview_windowdeletion "Window Deletion Overview",
  2331. Destroy(), wxCloseEvent
  2332. */
  2333. bool Close(bool force = false);
  2334. /**
  2335. Destroys the window safely. Use this function instead of the delete operator,
  2336. since different window classes can be destroyed differently. Frames and dialogs
  2337. are not destroyed immediately when this function is called -- they are added
  2338. to a list of windows to be deleted on idle time, when all the window's events
  2339. have been processed. This prevents problems with events being sent to
  2340. non-existent windows.
  2341. @return @true if the window has either been successfully deleted, or it
  2342. has been added to the list of windows pending real deletion.
  2343. */
  2344. virtual bool Destroy();
  2345. /**
  2346. Returns true if this window is in process of being destroyed.
  2347. Top level windows are not deleted immediately but are rather
  2348. scheduled for later destruction to give them time to process any
  2349. pending messages; see Destroy() description.
  2350. This function returns @true if this window, or one of its parent
  2351. windows, is scheduled for destruction and can be useful to avoid
  2352. manipulating it as it's usually useless to do something with a window
  2353. which is on the point of disappearing anyhow.
  2354. */
  2355. bool IsBeingDeleted() const;
  2356. //@}
  2357. /**
  2358. @name Drag and drop functions
  2359. */
  2360. //@{
  2361. /**
  2362. Returns the associated drop target, which may be @NULL.
  2363. @see SetDropTarget(), @ref overview_dnd
  2364. */
  2365. virtual wxDropTarget* GetDropTarget() const;
  2366. /**
  2367. Associates a drop target with this window.
  2368. If the window already has a drop target, it is deleted.
  2369. @see GetDropTarget(), @ref overview_dnd
  2370. */
  2371. virtual void SetDropTarget(wxDropTarget* target);
  2372. /**
  2373. Enables or disables eligibility for drop file events (OnDropFiles).
  2374. @param accept
  2375. If @true, the window is eligible for drop file events.
  2376. If @false, the window will not accept drop file events.
  2377. @remarks Windows only until version 2.8.9, available on all platforms
  2378. since 2.8.10. Cannot be used together with SetDropTarget() on
  2379. non-Windows platforms.
  2380. @see SetDropTarget()
  2381. */
  2382. virtual void DragAcceptFiles(bool accept);
  2383. //@}
  2384. /**
  2385. @name Constraints, sizers and window layout functions
  2386. */
  2387. //@{
  2388. /**
  2389. Returns the sizer of which this window is a member, if any, otherwise @NULL.
  2390. */
  2391. wxSizer* GetContainingSizer() const;
  2392. /**
  2393. Returns the sizer associated with the window by a previous call to
  2394. SetSizer(), or @NULL.
  2395. */
  2396. wxSizer* GetSizer() const;
  2397. /**
  2398. Sets the window to have the given layout sizer.
  2399. The window will then own the object, and will take care of its deletion.
  2400. If an existing layout constraints object is already owned by the
  2401. window, it will be deleted if the @a deleteOld parameter is @true.
  2402. Note that this function will also call SetAutoLayout() implicitly with @true
  2403. parameter if the @a sizer is non-@NULL and @false otherwise so that the
  2404. sizer will be effectively used to layout the window children whenever
  2405. it is resized.
  2406. @param sizer
  2407. The sizer to set. Pass @NULL to disassociate and conditionally delete
  2408. the window's sizer. See below.
  2409. @param deleteOld
  2410. If @true (the default), this will delete any pre-existing sizer.
  2411. Pass @false if you wish to handle deleting the old sizer yourself
  2412. but remember to do it yourself in this case to avoid memory leaks.
  2413. @remarks SetSizer enables and disables Layout automatically.
  2414. */
  2415. void SetSizer(wxSizer* sizer, bool deleteOld = true);
  2416. /**
  2417. This method calls SetSizer() and then wxSizer::SetSizeHints which sets the initial
  2418. window size to the size needed to accommodate all sizer elements and sets the
  2419. size hints which, if this window is a top level one, prevent the user from
  2420. resizing it to be less than this minimal size.
  2421. */
  2422. void SetSizerAndFit(wxSizer* sizer, bool deleteOld = true);
  2423. /**
  2424. Returns a pointer to the window's layout constraints, or @NULL if there are none.
  2425. */
  2426. wxLayoutConstraints* GetConstraints() const;
  2427. /**
  2428. Sets the window to have the given layout constraints. The window
  2429. will then own the object, and will take care of its deletion.
  2430. If an existing layout constraints object is already owned by the
  2431. window, it will be deleted.
  2432. @param constraints
  2433. The constraints to set. Pass @NULL to disassociate and delete the window's
  2434. constraints.
  2435. @remarks You must call SetAutoLayout() to tell a window to use
  2436. the constraints automatically in OnSize; otherwise, you
  2437. must override OnSize and call Layout() explicitly. When
  2438. setting both a wxLayoutConstraints and a wxSizer, only
  2439. the sizer will have effect.
  2440. */
  2441. void SetConstraints(wxLayoutConstraints* constraints);
  2442. /**
  2443. Invokes the constraint-based layout algorithm or the sizer-based algorithm
  2444. for this window.
  2445. This function does not get called automatically when the window is resized
  2446. because lots of windows deriving from wxWindow does not need this functionality.
  2447. If you want to have Layout() called automatically, you should derive
  2448. from wxPanel (see wxPanel::Layout).
  2449. @see @ref overview_windowsizing
  2450. */
  2451. virtual bool Layout();
  2452. /**
  2453. Determines whether the Layout() function will be called automatically
  2454. when the window is resized.
  2455. This method is called implicitly by SetSizer() but if you use SetConstraints()
  2456. you should call it manually or otherwise the window layout won't be correctly
  2457. updated when its size changes.
  2458. @param autoLayout
  2459. Set this to @true if you wish the Layout() function to be called
  2460. automatically when the window is resized.
  2461. @see SetSizer(), SetConstraints()
  2462. */
  2463. void SetAutoLayout(bool autoLayout);
  2464. bool GetAutoLayout() const;
  2465. //@}
  2466. /**
  2467. @name Mouse functions
  2468. */
  2469. //@{
  2470. /**
  2471. Directs all mouse input to this window.
  2472. Call ReleaseMouse() to release the capture.
  2473. Note that wxWidgets maintains the stack of windows having captured the mouse
  2474. and when the mouse is released the capture returns to the window which had had
  2475. captured it previously and it is only really released if there were no previous
  2476. window. In particular, this means that you must release the mouse as many times
  2477. as you capture it, unless the window receives the wxMouseCaptureLostEvent event.
  2478. Any application which captures the mouse in the beginning of some operation
  2479. must handle wxMouseCaptureLostEvent and cancel this operation when it receives
  2480. the event. The event handler must not recapture mouse.
  2481. @see ReleaseMouse(), wxMouseCaptureLostEvent
  2482. */
  2483. void CaptureMouse();
  2484. /**
  2485. Returns the caret() associated with the window.
  2486. */
  2487. wxCaret* GetCaret() const;
  2488. /**
  2489. Return the cursor associated with this window.
  2490. @see SetCursor()
  2491. */
  2492. const wxCursor& GetCursor() const;
  2493. /**
  2494. Returns @true if this window has the current mouse capture.
  2495. @see CaptureMouse(), ReleaseMouse(), wxMouseCaptureLostEvent,
  2496. wxMouseCaptureChangedEvent
  2497. */
  2498. virtual bool HasCapture() const;
  2499. /**
  2500. Releases mouse input captured with CaptureMouse().
  2501. @see CaptureMouse(), HasCapture(), ReleaseMouse(),
  2502. wxMouseCaptureLostEvent, wxMouseCaptureChangedEvent
  2503. */
  2504. void ReleaseMouse();
  2505. /**
  2506. Sets the caret() associated with the window.
  2507. */
  2508. void SetCaret(wxCaret* caret);
  2509. /**
  2510. Sets the window's cursor. Notice that the window cursor also sets it for the
  2511. children of the window implicitly.
  2512. The @a cursor may be @c wxNullCursor in which case the window cursor will
  2513. be reset back to default.
  2514. @param cursor
  2515. Specifies the cursor that the window should normally display.
  2516. @see ::wxSetCursor, wxCursor
  2517. */
  2518. virtual bool SetCursor(const wxCursor& cursor);
  2519. /**
  2520. Moves the pointer to the given position on the window.
  2521. @note Apple Human Interface Guidelines forbid moving the mouse cursor
  2522. programmatically so you should avoid using this function in Mac
  2523. applications (and probably avoid using it under the other
  2524. platforms without good reason as well).
  2525. @param x
  2526. The new x position for the cursor.
  2527. @param y
  2528. The new y position for the cursor.
  2529. */
  2530. virtual void WarpPointer(int x, int y);
  2531. //@}
  2532. /**
  2533. @name Miscellaneous functions
  2534. */
  2535. //@{
  2536. wxHitTest HitTest(wxCoord x, wxCoord y) const;
  2537. wxHitTest HitTest(const wxPoint& pt) const;
  2538. /**
  2539. Get the window border style from the given flags: this is different from
  2540. simply doing flags & wxBORDER_MASK because it uses GetDefaultBorder() to
  2541. translate wxBORDER_DEFAULT to something reasonable
  2542. */
  2543. wxBorder GetBorder(long flags) const;
  2544. /**
  2545. Get border for the flags of this window
  2546. */
  2547. wxBorder GetBorder() const;
  2548. /**
  2549. Does the window-specific updating after processing the update event.
  2550. This function is called by UpdateWindowUI() in order to check return
  2551. values in the wxUpdateUIEvent and act appropriately.
  2552. For example, to allow frame and dialog title updating, wxWidgets
  2553. implements this function as follows:
  2554. @code
  2555. // do the window-specific processing after processing the update event
  2556. void wxTopLevelWindowBase::DoUpdateWindowUI(wxUpdateUIEvent& event)
  2557. {
  2558. if ( event.GetSetEnabled() )
  2559. Enable(event.GetEnabled());
  2560. if ( event.GetSetText() )
  2561. {
  2562. if ( event.GetText() != GetTitle() )
  2563. SetTitle(event.GetText());
  2564. }
  2565. }
  2566. @endcode
  2567. */
  2568. virtual void DoUpdateWindowUI(wxUpdateUIEvent& event);
  2569. /**
  2570. Returns the platform-specific handle of the physical window.
  2571. Cast it to an appropriate handle, such as @b HWND for Windows,
  2572. @b Widget for Motif or @b GtkWidget for GTK.
  2573. @beginWxPerlOnly
  2574. This method will return an integer in wxPerl.
  2575. @endWxPerlOnly
  2576. */
  2577. virtual WXWidget GetHandle() const;
  2578. /**
  2579. This method should be overridden to return @true if this window has
  2580. multiple pages. All standard class with multiple pages such as
  2581. wxNotebook, wxListbook and wxTreebook already override it to return @true
  2582. and user-defined classes with similar behaviour should also do so, to
  2583. allow the library to handle such windows appropriately.
  2584. */
  2585. virtual bool HasMultiplePages() const;
  2586. /**
  2587. This function is (or should be, in case of custom controls) called during
  2588. window creation to intelligently set up the window visual attributes, that is
  2589. the font and the foreground and background colours.
  2590. By "intelligently" the following is meant: by default, all windows use their
  2591. own @ref GetClassDefaultAttributes() default attributes.
  2592. However if some of the parents attributes are explicitly (that is, using
  2593. SetFont() and not wxWindow::SetOwnFont) changed and if the corresponding
  2594. attribute hadn't been explicitly set for this window itself, then this
  2595. window takes the same value as used by the parent.
  2596. In addition, if the window overrides ShouldInheritColours() to return @false,
  2597. the colours will not be changed no matter what and only the font might.
  2598. This rather complicated logic is necessary in order to accommodate the
  2599. different usage scenarios. The most common one is when all default attributes
  2600. are used and in this case, nothing should be inherited as in modern GUIs
  2601. different controls use different fonts (and colours) than their siblings so
  2602. they can't inherit the same value from the parent. However it was also deemed
  2603. desirable to allow to simply change the attributes of all children at once by
  2604. just changing the font or colour of their common parent, hence in this case we
  2605. do inherit the parents attributes.
  2606. */
  2607. virtual void InheritAttributes();
  2608. /**
  2609. Sends an @c wxEVT_INIT_DIALOG event, whose handler usually transfers data
  2610. to the dialog via validators.
  2611. */
  2612. virtual void InitDialog();
  2613. /**
  2614. Returns @true if the window contents is double-buffered by the system, i.e.\ if
  2615. any drawing done on the window is really done on a temporary backing surface
  2616. and transferred to the screen all at once later.
  2617. @see wxBufferedDC
  2618. */
  2619. virtual bool IsDoubleBuffered() const;
  2620. /**
  2621. Turn on or off double buffering of the window if the system supports it.
  2622. */
  2623. void SetDoubleBuffered(bool on);
  2624. /**
  2625. Returns @true if the window is retained, @false otherwise.
  2626. @remarks Retained windows are only available on X platforms.
  2627. */
  2628. virtual bool IsRetained() const;
  2629. /**
  2630. Returns @true if this window is intrinsically enabled, @false otherwise,
  2631. i.e.\ if @ref Enable() Enable(@false) had been called. This method is
  2632. mostly used for wxWidgets itself, user code should normally use
  2633. IsEnabled() instead.
  2634. */
  2635. bool IsThisEnabled() const;
  2636. /**
  2637. Returns @true if the given window is a top-level one. Currently all frames and
  2638. dialogs are considered to be top-level windows (even if they have a parent
  2639. window).
  2640. */
  2641. virtual bool IsTopLevel() const;
  2642. /**
  2643. This virtual function is normally only used internally, but
  2644. sometimes an application may need it to implement functionality
  2645. that should not be disabled by an application defining an OnIdle
  2646. handler in a derived class.
  2647. This function may be used to do delayed painting, for example,
  2648. and most implementations call UpdateWindowUI()
  2649. in order to send update events to the window in idle time.
  2650. */
  2651. virtual void OnInternalIdle();
  2652. /**
  2653. Send idle event to window and all subwindows. Returns true if more idle
  2654. time is requested.
  2655. */
  2656. virtual bool SendIdleEvents(wxIdleEvent& event);
  2657. /**
  2658. Registers a system wide hotkey. Every time the user presses the hotkey
  2659. registered here, this window will receive a hotkey event.
  2660. It will receive the event even if the application is in the background
  2661. and does not have the input focus because the user is working with some
  2662. other application.
  2663. @param hotkeyId
  2664. Numeric identifier of the hotkey. For applications this must be between 0
  2665. and 0xBFFF. If this function is called from a shared DLL, it must be a
  2666. system wide unique identifier between 0xC000 and 0xFFFF.
  2667. This is a MSW specific detail.
  2668. @param modifiers
  2669. A bitwise combination of wxMOD_SHIFT, wxMOD_CONTROL, wxMOD_ALT
  2670. or wxMOD_WIN specifying the modifier keys that have to be pressed along
  2671. with the key.
  2672. @param virtualKeyCode
  2673. The virtual key code of the hotkey.
  2674. @return @true if the hotkey was registered successfully. @false if some
  2675. other application already registered a hotkey with this
  2676. modifier/virtualKeyCode combination.
  2677. @remarks Use EVT_HOTKEY(hotkeyId, fnc) in the event table to capture the
  2678. event. This function is currently only implemented
  2679. under Windows. It is used in the Windows CE port for
  2680. detecting hardware button presses.
  2681. @see UnregisterHotKey()
  2682. */
  2683. virtual bool RegisterHotKey(int hotkeyId, int modifiers,
  2684. int virtualKeyCode);
  2685. /**
  2686. Unregisters a system wide hotkey.
  2687. @param hotkeyId
  2688. Numeric identifier of the hotkey. Must be the same id that was passed to
  2689. RegisterHotKey().
  2690. @return @true if the hotkey was unregistered successfully, @false if the
  2691. id was invalid.
  2692. @remarks This function is currently only implemented under MSW.
  2693. @see RegisterHotKey()
  2694. */
  2695. virtual bool UnregisterHotKey(int hotkeyId);
  2696. /**
  2697. This function sends one or more wxUpdateUIEvent to the window.
  2698. The particular implementation depends on the window; for example a
  2699. wxToolBar will send an update UI event for each toolbar button,
  2700. and a wxFrame will send an update UI event for each menubar menu item.
  2701. You can call this function from your application to ensure that your
  2702. UI is up-to-date at this point (as far as your wxUpdateUIEvent handlers
  2703. are concerned). This may be necessary if you have called
  2704. wxUpdateUIEvent::SetMode() or wxUpdateUIEvent::SetUpdateInterval() to limit
  2705. the overhead that wxWidgets incurs by sending update UI events in idle time.
  2706. @a flags should be a bitlist of one or more of the ::wxUpdateUI enumeration.
  2707. If you are calling this function from an OnInternalIdle or OnIdle
  2708. function, make sure you pass the wxUPDATE_UI_FROMIDLE flag, since
  2709. this tells the window to only update the UI elements that need
  2710. to be updated in idle time. Some windows update their elements
  2711. only when necessary, for example when a menu is about to be shown.
  2712. The following is an example of how to call UpdateWindowUI from
  2713. an idle function.
  2714. @code
  2715. void MyWindow::OnInternalIdle()
  2716. {
  2717. if (wxUpdateUIEvent::CanUpdate(this))
  2718. UpdateWindowUI(wxUPDATE_UI_FROMIDLE);
  2719. }
  2720. @endcode
  2721. @see wxUpdateUIEvent, DoUpdateWindowUI(), OnInternalIdle()
  2722. */
  2723. virtual void UpdateWindowUI(long flags = wxUPDATE_UI_NONE);
  2724. //@}
  2725. // NOTE: static functions must have their own group or Doxygen will screw
  2726. // up the ordering of the member groups
  2727. /**
  2728. @name Miscellaneous static functions
  2729. */
  2730. //@{
  2731. /**
  2732. Returns the default font and colours which are used by the control.
  2733. This is useful if you want to use the same font or colour in your own control
  2734. as in a standard control -- which is a much better idea than hard coding specific
  2735. colours or fonts which might look completely out of place on the users
  2736. system, especially if it uses themes.
  2737. The @a variant parameter is only relevant under Mac currently and is
  2738. ignore under other platforms. Under Mac, it will change the size of the
  2739. returned font. See SetWindowVariant() for more about this.
  2740. This static method is "overridden" in many derived classes and so calling,
  2741. for example, wxButton::GetClassDefaultAttributes() will typically
  2742. return the values appropriate for a button which will be normally different
  2743. from those returned by, say, wxListCtrl::GetClassDefaultAttributes().
  2744. The @c wxVisualAttributes structure has at least the fields
  2745. @c font, @c colFg and @c colBg. All of them may be invalid
  2746. if it was not possible to determine the default control appearance or,
  2747. especially for the background colour, if the field doesn't make sense as is
  2748. the case for @c colBg for the controls with themed background.
  2749. @see InheritAttributes()
  2750. */
  2751. static wxVisualAttributes GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
  2752. /**
  2753. Finds the window or control which currently has the keyboard focus.
  2754. @remarks Note that this is a static function, so it can be called without
  2755. needing a wxWindow pointer.
  2756. @see SetFocus(), HasFocus()
  2757. */
  2758. static wxWindow* FindFocus();
  2759. /**
  2760. Find the first window with the given @e id.
  2761. If @a parent is @NULL, the search will start from all top-level frames
  2762. and dialog boxes; if non-@NULL, the search will be limited to the given
  2763. window hierarchy.
  2764. The search is recursive in both cases.
  2765. @see FindWindow()
  2766. @return Window with the given @a id or @NULL if not found.
  2767. */
  2768. static wxWindow* FindWindowById(long id, const wxWindow* parent = 0);
  2769. /**
  2770. Find a window by its label.
  2771. Depending on the type of window, the label may be a window title
  2772. or panel item label. If @a parent is @NULL, the search will start from all
  2773. top-level frames and dialog boxes; if non-@NULL, the search will be
  2774. limited to the given window hierarchy.
  2775. The search is recursive in both cases.
  2776. @see FindWindow()
  2777. @return Window with the given @a label or @NULL if not found.
  2778. */
  2779. static wxWindow* FindWindowByLabel(const wxString& label,
  2780. const wxWindow* parent = 0);
  2781. /**
  2782. Find a window by its name (as given in a window constructor or Create()
  2783. function call).
  2784. If @a parent is @NULL, the search will start from all top-level frames
  2785. and dialog boxes; if non-@NULL, the search will be limited to the given
  2786. window hierarchy.
  2787. The search is recursive in both cases. If no window with such name is found,
  2788. FindWindowByLabel() is called.
  2789. @see FindWindow()
  2790. @return Window with the given @a name or @NULL if not found.
  2791. */
  2792. static wxWindow* FindWindowByName(const wxString& name,
  2793. const wxWindow* parent = 0);
  2794. /**
  2795. Returns the currently captured window.
  2796. @see HasCapture(), CaptureMouse(), ReleaseMouse(),
  2797. wxMouseCaptureLostEvent, wxMouseCaptureChangedEvent
  2798. */
  2799. static wxWindow* GetCapture();
  2800. /**
  2801. Create a new ID or range of IDs that are not currently in use.
  2802. The IDs will be reserved until assigned to a wxWindow ID
  2803. or unreserved with UnreserveControlId().
  2804. See @ref overview_windowids for more information.
  2805. @param count
  2806. The number of sequential IDs to reserve.
  2807. @return Returns the ID or the first ID of the range (i.e. the most negative),
  2808. or wxID_NONE if the specified number of identifiers couldn't be allocated.
  2809. @see UnreserveControlId(), wxIdManager,
  2810. @ref overview_windowids
  2811. */
  2812. static wxWindowID NewControlId(int count = 1);
  2813. /**
  2814. Unreserve an ID or range of IDs that was reserved by NewControlId().
  2815. See @ref overview_windowids for more information.
  2816. @param id
  2817. The starting ID of the range of IDs to unreserve.
  2818. @param count
  2819. The number of sequential IDs to unreserve.
  2820. @see NewControlId(), wxIdManager, @ref overview_windowids
  2821. */
  2822. static void UnreserveControlId(wxWindowID id, int count = 1);
  2823. //@}
  2824. protected:
  2825. /**
  2826. Centres the window.
  2827. @param direction
  2828. Specifies the direction for the centring. May be wxHORIZONTAL,
  2829. wxVERTICAL or wxBOTH. It may also include the wxCENTRE_ON_SCREEN
  2830. flag.
  2831. @remarks This function is not meant to be called directly by user code,
  2832. but via Centre, Center, CentreOnParent, or CenterOnParent.
  2833. This function can be overridden to fine-tune centring behaviour.
  2834. */
  2835. virtual void DoCentre(int direction);
  2836. /**
  2837. Implementation of GetBestSize() that can be overridden.
  2838. Notice that it is usually more convenient to override
  2839. DoGetBestClientSize() rather than this method itself as you need to
  2840. explicitly account for the window borders size if you do the latter.
  2841. The default implementation of this function is designed for use in container
  2842. windows, such as wxPanel, and works something like this:
  2843. -# If the window has a sizer then it is used to calculate the best size.
  2844. -# Otherwise if the window has layout constraints then those are used to
  2845. calculate the best size.
  2846. -# Otherwise if the window has children then the best size is set to be large
  2847. enough to show all the children.
  2848. -# Otherwise if there are no children then the window's minimal size will be
  2849. used as its best size.
  2850. -# Otherwise if there is no minimal size set, then the current size is used
  2851. for the best size.
  2852. @see @ref overview_windowsizing
  2853. */
  2854. virtual wxSize DoGetBestSize() const;
  2855. /**
  2856. Override this method to return the best size for a custom control.
  2857. A typical implementation of this method should compute the minimal size
  2858. needed to fully display the control contents taking into account the
  2859. current font size.
  2860. The default implementation simply returns ::wxDefaultSize and
  2861. GetBestSize() returns an arbitrary hardcoded size for the window, so
  2862. you must override it when implementing a custom window class.
  2863. Notice that the best size returned by this function is cached
  2864. internally, so if anything that results in the best size changing (e.g.
  2865. change to the control contents) happens, you need to call
  2866. InvalidateBestSize() to notify wxWidgets about it.
  2867. @see @ref overview_windowsizing
  2868. @since 2.9.0
  2869. */
  2870. virtual wxSize DoGetBestClientSize() const;
  2871. /**
  2872. Override this method to implement height-for-width best size
  2873. calculation.
  2874. Return the height needed to fully display the control contents if its
  2875. width is fixed to the given value. Custom classes implementing
  2876. wrapping should override this method and return the height
  2877. corresponding to the number of lines needed to lay out the control
  2878. contents at this width.
  2879. Currently this method is not used by wxWidgets yet, however it is
  2880. planned that it will be used by the new sizer classes implementing
  2881. height-for-width layout strategy in the future.
  2882. Notice that implementing this method or even implementing both it and
  2883. DoGetBestClientWidth() doesn't replace overriding DoGetBestClientSize(),
  2884. i.e. you still need to implement the latter as well in order to provide
  2885. the best size when neither width nor height are constrained.
  2886. By default returns ::wxDefaultCoord meaning that the vertical component
  2887. of DoGetBestClientSize() return value should be used.
  2888. @since 2.9.4
  2889. */
  2890. virtual int DoGetBestClientHeight(int width) const;
  2891. /**
  2892. Override this method to implement width-for-height best size
  2893. calculation.
  2894. This method is exactly the same as DoGetBestClientHeight() except that
  2895. it determines the width assuming the height is fixed instead of vice
  2896. versa.
  2897. @since 2.9.4
  2898. */
  2899. virtual int DoGetBestClientWidth(int height) const;
  2900. /**
  2901. Sets the initial window size if none is given (i.e.\ at least one of the
  2902. components of the size passed to ctor/Create() is wxDefaultCoord).
  2903. @deprecated Use SetInitialSize() instead.
  2904. */
  2905. virtual void SetInitialBestSize(const wxSize& size);
  2906. /**
  2907. Generate wxWindowDestroyEvent for this window.
  2908. This is called by the window itself when it is being destroyed and
  2909. usually there is no need to call it but see wxWindowDestroyEvent for
  2910. explanations of when you might want to do it.
  2911. */
  2912. void SendDestroyEvent();
  2913. /**
  2914. This function is public in wxEvtHandler but protected in wxWindow
  2915. because for wxWindows you should always call ProcessEvent() on the
  2916. pointer returned by GetEventHandler() and not on the wxWindow object
  2917. itself.
  2918. For convenience, a ProcessWindowEvent() method is provided as a synonym
  2919. for @code GetEventHandler()->ProcessEvent() @endcode
  2920. Note that it's still possible to call these functions directly on the
  2921. wxWindow object (e.g. casting it to wxEvtHandler) but doing that will
  2922. create subtle bugs when windows with event handlers pushed on them are
  2923. involved.
  2924. This holds also for all other wxEvtHandler functions.
  2925. */
  2926. virtual bool ProcessEvent(wxEvent& event);
  2927. //@{
  2928. /**
  2929. See ProcessEvent() for more info about why you shouldn't use this function
  2930. and the reason for making this function protected in wxWindow.
  2931. */
  2932. bool SafelyProcessEvent(wxEvent& event);
  2933. virtual void QueueEvent(wxEvent *event);
  2934. virtual void AddPendingEvent(const wxEvent& event);
  2935. void ProcessPendingEvents();
  2936. bool ProcessThreadEvent(const wxEvent& event);
  2937. //@}
  2938. };
  2939. // ============================================================================
  2940. // Global functions/macros
  2941. // ============================================================================
  2942. /** @addtogroup group_funcmacro_misc */
  2943. //@{
  2944. /**
  2945. Find the deepest window at the mouse pointer position, returning the window
  2946. and current pointer position in screen coordinates.
  2947. @header{wx/window.h}
  2948. */
  2949. wxWindow* wxFindWindowAtPointer(wxPoint& pt);
  2950. /**
  2951. Gets the currently active window (implemented for MSW and GTK only
  2952. currently, always returns @NULL in the other ports).
  2953. @header{wx/window.h}
  2954. */
  2955. wxWindow* wxGetActiveWindow();
  2956. /**
  2957. Returns the first top level parent of the given window, or in other words,
  2958. the frame or dialog containing it, or @NULL.
  2959. @header{wx/window.h}
  2960. */
  2961. wxWindow* wxGetTopLevelParent(wxWindow* window);
  2962. //@}