private.h 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/osx/carbon/private.h
  3. // Purpose: Private declarations: as this header is only included by
  4. // wxWidgets itself, it may contain identifiers which don't start
  5. // with "wx".
  6. // Author: Stefan Csomor
  7. // Modified by:
  8. // Created: 1998-01-01
  9. // Copyright: (c) Stefan Csomor
  10. // Licence: wxWindows licence
  11. /////////////////////////////////////////////////////////////////////////////
  12. #ifndef _WX_PRIVATE_H_
  13. #define _WX_PRIVATE_H_
  14. #if wxUSE_GUI
  15. #include "wx/osx/uma.h"
  16. #include "wx/listbox.h"
  17. #include "wx/osx/dc.h"
  18. #include "wx/osx/dcclient.h"
  19. #include "wx/osx/dcmemory.h"
  20. // app.h
  21. #endif // wxUSE_GUI
  22. // filefn.h
  23. WXDLLIMPEXP_BASE wxString wxMacFSSpec2MacFilename( const FSSpec *spec );
  24. WXDLLIMPEXP_BASE void wxMacFilename2FSSpec( const wxString &path , FSSpec *spec );
  25. // utils.h
  26. WXDLLIMPEXP_BASE wxString wxMacFindFolderNoSeparator(short vRefNum,
  27. OSType folderType,
  28. Boolean createFolder);
  29. WXDLLIMPEXP_BASE wxString wxMacFindFolder(short vRefNum,
  30. OSType folderType,
  31. Boolean createFolder);
  32. template<typename T> EventParamType wxMacGetEventParamType() { wxFAIL_MSG( wxT("Unknown Param Type") ); return 0; }
  33. template<> inline EventParamType wxMacGetEventParamType<HIShapeRef>() { return typeHIShapeRef; }
  34. template<> inline EventParamType wxMacGetEventParamType<RgnHandle>() { return typeQDRgnHandle; }
  35. template<> inline EventParamType wxMacGetEventParamType<ControlRef>() { return typeControlRef; }
  36. template<> inline EventParamType wxMacGetEventParamType<WindowRef>() { return typeWindowRef; }
  37. template<> inline EventParamType wxMacGetEventParamType<MenuRef>() { return typeMenuRef; }
  38. template<> inline EventParamType wxMacGetEventParamType<EventRef>() { return typeEventRef; }
  39. template<> inline EventParamType wxMacGetEventParamType<Point>() { return typeQDPoint; }
  40. template<> inline EventParamType wxMacGetEventParamType<Rect>() { return typeQDRectangle; }
  41. template<> inline EventParamType wxMacGetEventParamType<Boolean>() { return typeBoolean; }
  42. template<> inline EventParamType wxMacGetEventParamType<SInt16>() { return typeSInt16; }
  43. template<> inline EventParamType wxMacGetEventParamType<SInt32>() { return typeSInt32; }
  44. template<> inline EventParamType wxMacGetEventParamType<UInt32>() { return typeUInt32; }
  45. template<> inline EventParamType wxMacGetEventParamType<RGBColor>() { return typeRGBColor; }
  46. template<> inline EventParamType wxMacGetEventParamType<HICommand>() { return typeHICommand; }
  47. template<> inline EventParamType wxMacGetEventParamType<HIPoint>() { return typeHIPoint; }
  48. template<> inline EventParamType wxMacGetEventParamType<HISize>() { return typeHISize; }
  49. template<> inline EventParamType wxMacGetEventParamType<HIRect>() { return typeHIRect; }
  50. template<> inline EventParamType wxMacGetEventParamType<void*>() { return typeVoidPtr; }
  51. template<> inline EventParamType wxMacGetEventParamType<CFDictionaryRef>() { return typeCFDictionaryRef; }
  52. template<> inline EventParamType wxMacGetEventParamType<Collection>() { return typeCollection; }
  53. template<> inline EventParamType wxMacGetEventParamType<CGContextRef>() { return typeCGContextRef; }
  54. /*
  55. These are ambiguous
  56. template<> EventParamType wxMacGetEventParamType<GrafPtr>() { return typeGrafPtr; }
  57. template<> EventParamType wxMacGetEventParamType<OSStatus>() { return typeOSStatus; }
  58. template<> EventParamType wxMacGetEventParamType<CFIndex>() { return typeCFIndex; }
  59. template<> EventParamType wxMacGetEventParamType<GWorldPtr>() { return typeGWorldPtr; }
  60. */
  61. class WXDLLIMPEXP_CORE wxMacCarbonEvent
  62. {
  63. public :
  64. wxMacCarbonEvent()
  65. {
  66. m_eventRef = 0;
  67. m_release = false;
  68. }
  69. wxMacCarbonEvent( EventRef event , bool release = false )
  70. {
  71. m_eventRef = event;
  72. m_release = release;
  73. }
  74. wxMacCarbonEvent(UInt32 inClassID,UInt32 inKind,EventTime inWhen = 0 /*now*/,EventAttributes inAttributes=kEventAttributeNone)
  75. {
  76. m_eventRef = NULL;
  77. verify_noerr( MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef) );
  78. m_release = true;
  79. }
  80. ~wxMacCarbonEvent()
  81. {
  82. if ( m_release )
  83. ReleaseEvent( m_eventRef );
  84. }
  85. OSStatus Create(UInt32 inClassID,UInt32 inKind,EventTime inWhen = 0 /*now*/,EventAttributes inAttributes=kEventAttributeNone)
  86. {
  87. verify( (m_eventRef == NULL) || m_release );
  88. if ( m_eventRef && m_release )
  89. {
  90. ReleaseEvent( m_eventRef );
  91. m_release = false;
  92. m_eventRef = NULL;
  93. }
  94. OSStatus err = MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef);
  95. if ( err == noErr )
  96. m_release = true;
  97. return err;
  98. }
  99. OSStatus GetParameter( EventParamName inName, EventParamType inDesiredType, UInt32 inBufferSize, void * outData);
  100. template <typename T> OSStatus GetParameter( EventParamName inName, EventParamType type , T *data )
  101. {
  102. return GetParameter( inName, type , sizeof( T ) , data );
  103. }
  104. template <typename T> OSStatus GetParameter( EventParamName inName, T *data )
  105. {
  106. return GetParameter<T>( inName, wxMacGetEventParamType<T>() , data );
  107. }
  108. template <typename T> T GetParameter( EventParamName inName )
  109. {
  110. T value;
  111. verify_noerr( GetParameter<T>( inName, &value ) );
  112. return value;
  113. }
  114. template <typename T> T GetParameter( EventParamName inName, EventParamType inDesiredType )
  115. {
  116. T value;
  117. verify_noerr( GetParameter<T>( inName, inDesiredType , &value ) );
  118. return value;
  119. }
  120. OSStatus SetParameter( EventParamName inName, EventParamType inType, UInt32 inSize, const void * inData);
  121. template <typename T> OSStatus SetParameter( EventParamName inName, EventParamType inDesiredType , const T *data )
  122. {
  123. return SetParameter( inName, inDesiredType , sizeof( T ) , data );
  124. }
  125. template <typename T> OSStatus SetParameter( EventParamName inName, EventParamType inDesiredType , const T& data )
  126. {
  127. return SetParameter<T>( inName, inDesiredType , &data );
  128. }
  129. template <typename T> OSStatus SetParameter( EventParamName inName, const T *data )
  130. {
  131. return SetParameter<T>( inName, wxMacGetEventParamType<T>() , data );
  132. }
  133. template <typename T> OSStatus SetParameter( EventParamName inName, const T& data )
  134. {
  135. return SetParameter<T>( inName, wxMacGetEventParamType<T>() , &data );
  136. }
  137. UInt32 GetClass()
  138. {
  139. return ::GetEventClass( m_eventRef );
  140. }
  141. UInt32 GetKind()
  142. {
  143. return ::GetEventKind( m_eventRef );
  144. }
  145. EventTime GetTime()
  146. {
  147. return ::GetEventTime( m_eventRef );
  148. }
  149. UInt32 GetTicks()
  150. {
  151. return EventTimeToTicks( GetTime() );
  152. }
  153. OSStatus SetCurrentTime( )
  154. {
  155. return ::SetEventTime( m_eventRef , GetCurrentEventTime() );
  156. }
  157. OSStatus SetTime( EventTime when )
  158. {
  159. return ::SetEventTime( m_eventRef , when );
  160. }
  161. operator EventRef () { return m_eventRef; }
  162. bool IsValid() { return m_eventRef != 0; }
  163. protected :
  164. EventRef m_eventRef;
  165. bool m_release;
  166. };
  167. #if wxUSE_GUI
  168. class WXDLLIMPEXP_FWD_CORE wxMacToolTipTimer ;
  169. class WXDLLIMPEXP_CORE wxMacToolTip
  170. {
  171. public :
  172. wxMacToolTip() ;
  173. ~wxMacToolTip() ;
  174. void Setup( WindowRef window , const wxString& text , const wxPoint& localPosition ) ;
  175. void Draw() ;
  176. void Clear() ;
  177. long GetMark()
  178. { return m_mark ; }
  179. bool IsShown()
  180. { return m_shown ; }
  181. private :
  182. wxString m_label ;
  183. wxPoint m_position ;
  184. Rect m_rect ;
  185. WindowRef m_window ;
  186. PicHandle m_backpict ;
  187. bool m_shown ;
  188. long m_mark ;
  189. #if wxUSE_TIMER
  190. wxMacToolTipTimer* m_timer ;
  191. #endif
  192. wxCFStringRef m_helpTextRef ;
  193. } ;
  194. // Quartz
  195. WXDLLIMPEXP_CORE void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType = 0 );
  196. WXDLLIMPEXP_CORE void wxMacReleaseBitmapButton( ControlButtonContentInfo*info );
  197. #define MAC_WXHBITMAP(a) (GWorldPtr(a))
  198. #define MAC_WXHMETAFILE(a) (PicHandle(a))
  199. #define MAC_WXHICON(a) (IconRef(a))
  200. #define MAC_WXHCURSOR(a) (CursHandle(a))
  201. #define MAC_WXHRGN(a) (RgnHandle(a))
  202. #define MAC_WXHWND(a) (WindowPtr(a))
  203. #define MAC_WXRECPTR(a) ((Rect*)a)
  204. #define MAC_WXPOINTPTR(a) ((Point*)a)
  205. #define MAC_WXHMENU(a) ((MenuHandle)a)
  206. struct wxOpaqueWindowRef
  207. {
  208. wxOpaqueWindowRef( WindowRef ref ) { m_data = ref; }
  209. operator WindowRef() { return m_data; }
  210. private :
  211. WindowRef m_data;
  212. };
  213. WXDLLIMPEXP_CORE void wxMacRectToNative( const wxRect *wx , Rect *n );
  214. WXDLLIMPEXP_CORE void wxMacNativeToRect( const Rect *n , wxRect* wx );
  215. WXDLLIMPEXP_CORE void wxMacPointToNative( const wxPoint* wx , Point *n );
  216. WXDLLIMPEXP_CORE void wxMacNativeToPoint( const Point *n , wxPoint* wx );
  217. WXDLLIMPEXP_CORE wxMenu* wxFindMenuFromMacMenu(MenuRef inMenuRef);
  218. WXDLLIMPEXP_CORE int wxMacCommandToId( UInt32 macCommandId );
  219. WXDLLIMPEXP_CORE UInt32 wxIdToMacCommand( int wxId );
  220. WXDLLIMPEXP_CORE wxMenu* wxFindMenuFromMacCommand( const HICommand &macCommandId , wxMenuItem* &item );
  221. WXDLLIMPEXP_CORE pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , EventRef event , void *data );
  222. WXDLLIMPEXP_CORE Rect wxMacGetBoundsForControl( wxWindowMac* window , const wxPoint& pos , const wxSize &size , bool adjustForOrigin = true );
  223. ControlActionUPP GetwxMacLiveScrollbarActionProc();
  224. // additional optional event defines
  225. class WXDLLIMPEXP_CORE wxMacControl : public wxWidgetImpl
  226. {
  227. public :
  228. wxMacControl( wxWindowMac* peer , bool isRootControl = false, bool isUserPane = false );
  229. wxMacControl() ;
  230. virtual ~wxMacControl();
  231. void Init();
  232. void SetReferenceInNativeControl();
  233. static wxMacControl* GetReferenceFromNativeControl(ControlRef control);
  234. virtual ControlRef * GetControlRefAddr() { return &m_controlRef; }
  235. virtual ControlRef GetControlRef() const { return m_controlRef; }
  236. virtual WXWidget GetWXWidget() const { return (WXWidget) m_controlRef; }
  237. virtual bool IsVisible() const;
  238. virtual void Raise();
  239. virtual void Lower();
  240. virtual void ScrollRect( const wxRect *rect, int dx, int dy );
  241. virtual void GetContentArea( int &left , int &top , int &width , int &height ) const;
  242. virtual void Move(int x, int y, int width, int height);
  243. virtual void GetPosition( int &x, int &y ) const;
  244. virtual void GetSize( int &width, int &height ) const;
  245. virtual void SetControlSize( wxWindowVariant variant ) ;
  246. // where is in native window relative coordinates
  247. virtual void SetNeedsDisplay( const wxRect* where = NULL );
  248. virtual bool GetNeedsDisplay() const;
  249. virtual bool CanFocus() const;
  250. // return true if successful
  251. virtual bool SetFocus();
  252. virtual bool HasFocus() const;
  253. void RemoveFromParent();
  254. void Embed( wxWidgetImpl *parent );
  255. void SetDefaultButton( bool isDefault );
  256. void PerformClick();
  257. void SetLabel( const wxString& title, wxFontEncoding encoding );
  258. void SetCursor( const wxCursor & cursor );
  259. void CaptureMouse();
  260. void ReleaseMouse();
  261. wxInt32 GetValue() const;
  262. void SetValue( wxInt32 v );
  263. wxBitmap GetBitmap() const;
  264. void SetBitmap( const wxBitmap& bitmap );
  265. void SetBitmapPosition( wxDirection dir );
  266. void GetBestRect( wxRect *r ) const;
  267. bool IsEnabled() const;
  268. void Enable( bool enable );
  269. bool ButtonClickDidStateChange() { return false ;}
  270. void SetMinimum( wxInt32 v );
  271. void SetMaximum( wxInt32 v );
  272. void PulseGauge() ;
  273. void SetScrollThumb( wxInt32 value, wxInt32 thumbSize );
  274. // temp convenience methods
  275. void GetBestRect( Rect *r ) const;
  276. /*
  277. void operator= (ControlRef c) { m_controlRef = c; }
  278. operator ControlRef () { return m_controlRef; }
  279. operator ControlRef * () { return &m_controlRef; }
  280. */
  281. // accessing data and values
  282. virtual OSStatus SetData( ControlPartCode inPartCode , ResType inTag , Size inSize , const void * inData );
  283. virtual OSStatus GetData( ControlPartCode inPartCode , ResType inTag , Size inBufferSize , void * inOutBuffer , Size * outActualSize ) const;
  284. virtual OSStatus GetDataSize( ControlPartCode inPartCode , ResType inTag , Size * outActualSize ) const;
  285. virtual OSStatus SendEvent( EventRef ref , OptionBits inOptions = 0 );
  286. virtual OSStatus SendHICommand( HICommand &command , OptionBits inOptions = 0 );
  287. virtual OSStatus SendHICommand( UInt32 commandID , OptionBits inOptions = 0 );
  288. virtual wxInt32 GetMaximum() const;
  289. virtual wxInt32 GetMinimum() const;
  290. virtual void SetValueAndRange( SInt32 value , SInt32 minimum , SInt32 maximum );
  291. virtual void SetRange( SInt32 minimum , SInt32 maximum );
  292. // templated helpers
  293. Size GetDataSize( ControlPartCode inPartCode , ResType inTag ) const
  294. {
  295. Size sz;
  296. verify_noerr( GetDataSize( inPartCode , inTag , &sz ) );
  297. return sz;
  298. }
  299. template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T *data )
  300. {
  301. return SetData( inPartCode , inTag , sizeof( T ) , data );
  302. }
  303. template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T& data )
  304. {
  305. return SetData( inPartCode , inTag , sizeof( T ) , &data );
  306. }
  307. template <typename T> OSStatus SetData( ResType inTag , const T *data )
  308. {
  309. return SetData( kControlEntireControl , inTag , sizeof( T ) , data );
  310. }
  311. template <typename T> OSStatus SetData( ResType inTag , const T& data )
  312. {
  313. return SetData( kControlEntireControl , inTag , sizeof( T ) , &data );
  314. }
  315. template <typename T> OSStatus GetData( ControlPartCode inPartCode , ResType inTag , T *data ) const
  316. {
  317. Size dummy;
  318. return GetData( inPartCode , inTag , sizeof( T ) , data , &dummy );
  319. }
  320. template <typename T> T GetData( ControlPartCode inPartCode , ResType inTag ) const
  321. {
  322. T value;
  323. OSStatus err = GetData<T>( inPartCode , inTag , &value );
  324. if ( err != noErr )
  325. {
  326. wxFAIL_MSG( wxString::Format(wxT("GetData Failed for Part [%i] and Tag [%i]"),
  327. inPartCode, (int)inTag) );
  328. }
  329. return value;
  330. }
  331. template <typename T> OSStatus GetData( ResType inTag , T *data ) const
  332. {
  333. Size dummy;
  334. return GetData( kControlEntireControl , inTag , sizeof( T ) , data , &dummy );
  335. }
  336. template <typename T> T GetData( ResType inTag ) const
  337. {
  338. return GetData<T>( kControlEntireControl , inTag );
  339. }
  340. // Flash the control for the specified amount of time
  341. virtual void VisibilityChanged( bool shown );
  342. virtual void SuperChangedPosition();
  343. virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true );
  344. virtual void SetBackgroundColour( const wxColour& col );
  345. virtual bool SetBackgroundStyle(wxBackgroundStyle style);
  346. virtual ControlPartCode HandleKey( SInt16 keyCode, SInt16 charCode, EventModifiers modifiers );
  347. void SetActionProc( ControlActionUPP actionProc );
  348. SInt32 GetViewSize() const;
  349. virtual void SetVisibility( bool visible );
  350. virtual bool IsActive() const;
  351. // invalidates this control and all children
  352. virtual void InvalidateWithChildren();
  353. virtual void SetDrawingEnabled( bool enable );
  354. // in native parent window relative coordinates
  355. virtual void GetRectInWindowCoords( Rect *r );
  356. virtual void GetFeatures( UInt32 *features );
  357. // to be moved into a tab control class
  358. virtual OSStatus SetTabEnabled( SInt16 tabNo , bool enable );
  359. virtual void InstallEventHandler( WXWidget control = NULL );
  360. protected :
  361. WXEVENTHANDLERREF m_macControlEventHandler ;
  362. ControlRef m_controlRef;
  363. wxFont m_font;
  364. long m_windowStyle;
  365. DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacControl)
  366. };
  367. // ============================================================================
  368. // DataBrowser Wrapper
  369. // ============================================================================
  370. //
  371. // basing on DataBrowserItemIDs
  372. //
  373. class WXDLLIMPEXP_CORE wxMacDataBrowserControl : public wxMacControl
  374. {
  375. public :
  376. wxMacDataBrowserControl( wxWindow* peer, const wxPoint& pos, const wxSize& size, long style);
  377. wxMacDataBrowserControl() {}
  378. OSStatus SetCallbacks( const DataBrowserCallbacks *callbacks );
  379. OSStatus GetItemCount( DataBrowserItemID container,
  380. Boolean recurse,
  381. DataBrowserItemState state,
  382. ItemCount *numItems) const;
  383. OSStatus GetItems( DataBrowserItemID container,
  384. Boolean recurse,
  385. DataBrowserItemState state,
  386. Handle items) const;
  387. OSStatus AddColumn( DataBrowserListViewColumnDesc *columnDesc,
  388. DataBrowserTableViewColumnIndex position );
  389. OSStatus RemoveColumn( DataBrowserTableViewColumnIndex position );
  390. OSStatus AutoSizeColumns();
  391. OSStatus SetHasScrollBars( bool horiz, bool vert );
  392. OSStatus SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle );
  393. OSStatus SetHeaderButtonHeight( UInt16 height );
  394. OSStatus GetHeaderButtonHeight( UInt16 *height );
  395. OSStatus UpdateItems( DataBrowserItemID container, UInt32 numItems,
  396. const DataBrowserItemID *items,
  397. DataBrowserPropertyID preSortProperty,
  398. DataBrowserPropertyID propertyID ) const;
  399. OSStatus AddItems( DataBrowserItemID container, UInt32 numItems,
  400. const DataBrowserItemID *items,
  401. DataBrowserPropertyID preSortProperty );
  402. OSStatus RemoveItems( DataBrowserItemID container, UInt32 numItems,
  403. const DataBrowserItemID *items,
  404. DataBrowserPropertyID preSortProperty );
  405. OSStatus RevealItem( DataBrowserItemID item,
  406. DataBrowserPropertyID propertyID,
  407. DataBrowserRevealOptions options ) const;
  408. OSStatus SetSelectionFlags( DataBrowserSelectionFlags );
  409. OSStatus GetSelectionAnchor( DataBrowserItemID *first, DataBrowserItemID *last ) const;
  410. bool IsItemSelected( DataBrowserItemID item ) const;
  411. OSStatus SetSelectedItems( UInt32 numItems,
  412. const DataBrowserItemID *items,
  413. DataBrowserSetOption operation );
  414. OSStatus GetItemID( DataBrowserTableViewRowIndex row,
  415. DataBrowserItemID * item ) const;
  416. OSStatus GetItemRow( DataBrowserItemID item,
  417. DataBrowserTableViewRowIndex * row ) const;
  418. OSStatus SetDefaultRowHeight( UInt16 height );
  419. OSStatus GetDefaultRowHeight( UInt16 * height ) const;
  420. OSStatus SetRowHeight( DataBrowserItemID item , UInt16 height);
  421. OSStatus GetRowHeight( DataBrowserItemID item , UInt16 *height) const;
  422. OSStatus GetColumnWidth( DataBrowserPropertyID column , UInt16 *width ) const;
  423. OSStatus SetColumnWidth( DataBrowserPropertyID column , UInt16 width );
  424. OSStatus GetDefaultColumnWidth( UInt16 *width ) const;
  425. OSStatus SetDefaultColumnWidth( UInt16 width );
  426. OSStatus GetColumnCount( UInt32* numColumns) const;
  427. OSStatus GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position, DataBrowserTableViewColumnID* id );
  428. OSStatus GetColumnPosition( DataBrowserPropertyID column, DataBrowserTableViewColumnIndex *position) const;
  429. OSStatus SetColumnPosition( DataBrowserPropertyID column, DataBrowserTableViewColumnIndex position);
  430. OSStatus GetScrollPosition( UInt32 *top , UInt32 *left ) const;
  431. OSStatus SetScrollPosition( UInt32 top , UInt32 left );
  432. OSStatus GetSortProperty( DataBrowserPropertyID *column ) const;
  433. OSStatus SetSortProperty( DataBrowserPropertyID column );
  434. OSStatus GetSortOrder( DataBrowserSortOrder *order ) const;
  435. OSStatus SetSortOrder( DataBrowserSortOrder order );
  436. OSStatus GetPropertyFlags( DataBrowserPropertyID property, DataBrowserPropertyFlags *flags ) const;
  437. OSStatus SetPropertyFlags( DataBrowserPropertyID property, DataBrowserPropertyFlags flags );
  438. OSStatus GetHeaderDesc( DataBrowserPropertyID property, DataBrowserListViewHeaderDesc *desc ) const;
  439. OSStatus SetHeaderDesc( DataBrowserPropertyID property, DataBrowserListViewHeaderDesc *desc );
  440. OSStatus SetDisclosureColumn( DataBrowserPropertyID property , Boolean expandableRows );
  441. OSStatus GetItemPartBounds( DataBrowserItemID item, DataBrowserPropertyID property, DataBrowserPropertyPart part, Rect * bounds );
  442. protected :
  443. static pascal void DataBrowserItemNotificationProc(
  444. ControlRef browser,
  445. DataBrowserItemID itemID,
  446. DataBrowserItemNotification message,
  447. DataBrowserItemDataRef itemData );
  448. virtual void ItemNotification(
  449. DataBrowserItemID itemID,
  450. DataBrowserItemNotification message,
  451. DataBrowserItemDataRef itemData) = 0;
  452. static pascal OSStatus DataBrowserGetSetItemDataProc(
  453. ControlRef browser,
  454. DataBrowserItemID itemID,
  455. DataBrowserPropertyID property,
  456. DataBrowserItemDataRef itemData,
  457. Boolean changeValue );
  458. virtual OSStatus GetSetItemData(
  459. DataBrowserItemID itemID,
  460. DataBrowserPropertyID property,
  461. DataBrowserItemDataRef itemData,
  462. Boolean changeValue ) = 0;
  463. static pascal Boolean DataBrowserCompareProc(
  464. ControlRef browser,
  465. DataBrowserItemID itemOneID,
  466. DataBrowserItemID itemTwoID,
  467. DataBrowserPropertyID sortProperty);
  468. virtual Boolean CompareItems(DataBrowserItemID itemOneID,
  469. DataBrowserItemID itemTwoID,
  470. DataBrowserPropertyID sortProperty) = 0;
  471. DECLARE_ABSTRACT_CLASS(wxMacDataBrowserControl)
  472. };
  473. // ============================================================================
  474. // Higher-level Databrowser
  475. // ============================================================================
  476. //
  477. // basing on data item objects
  478. //
  479. // forward decl
  480. class wxMacDataItemBrowserControl;
  481. class wxMacListBoxItem;
  482. const DataBrowserPropertyID kTextColumnId = 1024;
  483. const DataBrowserPropertyID kNumericOrderColumnId = 1025;
  484. // for multi-column controls, we will use this + the column ID to identify the
  485. // column. We don't use kTextColumnId there, and ideally the two should merge.
  486. const DataBrowserPropertyID kMinColumnId = 1050;
  487. // base API for high-level databrowser operations
  488. // base class for databrowser items
  489. enum DataItemType {
  490. DataItem_Text
  491. };
  492. /*
  493. class WXDLLIMPEXP_CORE wxMacDataItem
  494. {
  495. public :
  496. wxMacDataItem();
  497. virtual ~wxMacDataItem();
  498. } ;
  499. */
  500. class WXDLLIMPEXP_CORE wxMacDataItem
  501. {
  502. public :
  503. wxMacDataItem();
  504. virtual ~wxMacDataItem();
  505. virtual bool IsLessThan(wxMacDataItemBrowserControl *owner ,
  506. const wxMacDataItem*,
  507. DataBrowserPropertyID property) const;
  508. // returns true if access was successful, otherwise false
  509. virtual OSStatus GetSetData(wxMacDataItemBrowserControl *owner ,
  510. DataBrowserPropertyID property,
  511. DataBrowserItemDataRef itemData,
  512. bool changeValue );
  513. virtual void Notification(wxMacDataItemBrowserControl *owner ,
  514. DataBrowserItemNotification message,
  515. DataBrowserItemDataRef itemData ) const;
  516. void SetOrder( SInt32 order );
  517. SInt32 GetOrder() const;
  518. protected :
  519. SInt32 m_order;
  520. };
  521. enum ListSortOrder {
  522. SortOrder_None,
  523. SortOrder_Text_Ascending,
  524. SortOrder_Text_Descending
  525. };
  526. typedef wxMacDataItem* wxMacDataItemPtr;
  527. const wxMacDataItemPtr wxMacDataBrowserRootContainer = NULL;
  528. typedef void * wxListColumnId ;
  529. WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxMacDataItemPtr, wxArrayMacDataItemPtr, class WXDLLIMPEXP_CORE);
  530. class WXDLLIMPEXP_CORE wxMacDataItemBrowserControl : public wxMacDataBrowserControl
  531. {
  532. public :
  533. wxMacDataItemBrowserControl( wxWindow* peer , const wxPoint& pos, const wxSize& size, long style);
  534. wxMacDataItemBrowserControl() {}
  535. // create a list item (can be a subclass of wxMacListBoxItem)
  536. unsigned int GetItemCount(const wxMacDataItem* container, bool recurse , DataBrowserItemState state) const;
  537. void GetItems(const wxMacDataItem* container, bool recurse ,
  538. DataBrowserItemState state, wxArrayMacDataItemPtr &items ) const;
  539. unsigned int GetSelectedItemCount( const wxMacDataItem* container, bool recurse ) const;
  540. unsigned int GetLineFromItem(const wxMacDataItem *item) const;
  541. wxMacDataItem * GetItemFromLine(unsigned int n) const;
  542. void UpdateItem(const wxMacDataItem *container, const wxMacDataItem *item,
  543. DataBrowserPropertyID property) const;
  544. void UpdateItems(const wxMacDataItem *container, wxArrayMacDataItemPtr &items,
  545. DataBrowserPropertyID property) const;
  546. void InsertColumn(int colId, DataBrowserPropertyType colType,
  547. const wxString& title, SInt16 just = teFlushDefault, int defaultWidth = -1);
  548. int GetColumnWidth(int colId);
  549. void SetColumnWidth(int colId, int width);
  550. void AddItem(wxMacDataItem *container, wxMacDataItem *item);
  551. void AddItems(wxMacDataItem *container, wxArrayMacDataItemPtr &items );
  552. void RemoveAllItems(wxMacDataItem *container);
  553. void RemoveItem(wxMacDataItem *container, wxMacDataItem* item);
  554. void RemoveItems(wxMacDataItem *container, wxArrayMacDataItemPtr &items);
  555. void SetSelectedItem( wxMacDataItem* item , DataBrowserSetOption option);
  556. void SetSelectedItems( wxArrayMacDataItemPtr &items , DataBrowserSetOption option);
  557. void SetSelectedAllItems( DataBrowserSetOption option);
  558. Boolean IsItemSelected( const wxMacDataItem* item) const;
  559. void RevealItem( wxMacDataItem* item, DataBrowserRevealOptions options);
  560. void GetSelectionAnchor( wxMacDataItemPtr* first , wxMacDataItemPtr* last) const;
  561. // add and remove
  562. virtual void MacDelete( unsigned int n );
  563. virtual void MacInsert( unsigned int n, wxMacDataItem* item);
  564. virtual void MacClear();
  565. // accessing content
  566. virtual unsigned int MacGetCount() const;
  567. public :
  568. // as we are getting the same events for human and API selection we have to suppress
  569. // events in the latter case, since this will be used from many subclasses we keep it here
  570. bool IsSelectionSuppressed() const { return m_suppressSelection; }
  571. bool SuppressSelection( bool suppress );
  572. // client data
  573. virtual wxClientDataType GetClientDataType() const;
  574. virtual void SetClientDataType(wxClientDataType clientDataItemsType);
  575. //virtual ListSortOrder GetSortOrder() const;
  576. //virtual void SetSortOrder(const ListSortOrder sort);
  577. protected:
  578. ListSortOrder m_sortOrder;
  579. wxClientDataType m_clientDataItemsType;
  580. // ID aware base methods, should be 'final' ie not changed in subclasses
  581. virtual Boolean CompareItems(DataBrowserItemID itemOneID,
  582. DataBrowserItemID itemTwoID,
  583. DataBrowserPropertyID sortProperty);
  584. virtual OSStatus GetSetItemData(DataBrowserItemID itemID,
  585. DataBrowserPropertyID property,
  586. DataBrowserItemDataRef itemData,
  587. Boolean changeValue );
  588. virtual void ItemNotification(
  589. DataBrowserItemID itemID,
  590. DataBrowserItemNotification message,
  591. DataBrowserItemDataRef itemData);
  592. private :
  593. bool m_suppressSelection;
  594. DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataItemBrowserControl)
  595. };
  596. class WXDLLIMPEXP_CORE wxMacDataItemBrowserSelectionSuppressor
  597. {
  598. public :
  599. wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl *browser);
  600. ~wxMacDataItemBrowserSelectionSuppressor();
  601. private :
  602. bool m_former;
  603. wxMacDataItemBrowserControl* m_browser;
  604. };
  605. // ============================================================================
  606. // platform listbox implementation
  607. // ============================================================================
  608. // exposed for reuse in wxCheckListBox
  609. class WXDLLIMPEXP_CORE wxMacListBoxItem : public wxMacDataItem
  610. {
  611. public :
  612. wxMacListBoxItem();
  613. virtual ~wxMacListBoxItem();
  614. virtual OSStatus GetSetData(wxMacDataItemBrowserControl *owner ,
  615. DataBrowserPropertyID property,
  616. DataBrowserItemDataRef itemData,
  617. bool changeValue );
  618. virtual void Notification(wxMacDataItemBrowserControl *owner ,
  619. DataBrowserItemNotification message,
  620. DataBrowserItemDataRef itemData ) const;
  621. protected :
  622. };
  623. class WXDLLIMPEXP_CORE wxMacDataBrowserColumn : public wxListWidgetColumn
  624. {
  625. public :
  626. wxMacDataBrowserColumn( DataBrowserPropertyID propertyId, DataBrowserPropertyType colType, bool editable )
  627. : m_property(propertyId), m_editable(editable), m_type( colType )
  628. {
  629. }
  630. ~wxMacDataBrowserColumn()
  631. {
  632. }
  633. DataBrowserPropertyID GetProperty() const { return m_property ; }
  634. bool IsEditable() const { return m_editable; }
  635. DataBrowserPropertyType GetType() const { return m_type; }
  636. protected :
  637. DataBrowserPropertyID m_property;
  638. bool m_editable;
  639. DataBrowserPropertyType m_type;
  640. } ;
  641. WX_DEFINE_ARRAY_PTR(wxMacDataBrowserColumn *, wxArrayMacDataBrowserColumns);
  642. class WXDLLIMPEXP_CORE wxMacDataBrowserCellValue : public wxListWidgetCellValue
  643. {
  644. public :
  645. wxMacDataBrowserCellValue(DataBrowserItemDataRef data) : m_data(data) {}
  646. virtual ~wxMacDataBrowserCellValue() {}
  647. virtual void Set( CFStringRef value );
  648. virtual void Set( const wxString& value );
  649. virtual void Set( int value ) ;
  650. virtual void Check( bool check );
  651. virtual int GetIntValue() const ;
  652. virtual wxString GetStringValue() const ;
  653. protected :
  654. DataBrowserItemDataRef m_data;
  655. } ;
  656. class WXDLLIMPEXP_CORE wxMacDataBrowserListControl : public wxMacDataItemBrowserControl, public wxListWidgetImpl
  657. {
  658. public:
  659. wxMacDataBrowserListControl( wxWindow *peer, const wxPoint& pos, const wxSize& size, long style );
  660. wxMacDataBrowserListControl() {}
  661. virtual ~wxMacDataBrowserListControl();
  662. // wxListWidgetImpl Methods
  663. wxListWidgetColumn* InsertTextColumn( unsigned int pos, const wxString& title, bool editable = false,
  664. wxAlignment just = wxALIGN_LEFT , int defaultWidth = -1) ;
  665. wxListWidgetColumn* InsertCheckColumn( unsigned int pos , const wxString& title, bool editable = false,
  666. wxAlignment just = wxALIGN_LEFT , int defaultWidth = -1) ;
  667. wxMacDataBrowserColumn* DoInsertColumn( unsigned int pos, DataBrowserPropertyID property,
  668. const wxString& title, bool editable,
  669. DataBrowserPropertyType colType, SInt16 just, int width );
  670. // add and remove
  671. virtual void ListDelete( unsigned int n );
  672. virtual void ListInsert( unsigned int n );
  673. virtual void ListClear();
  674. // selecting
  675. virtual void ListDeselectAll();
  676. virtual void ListSetSelection( unsigned int n, bool select, bool multi = false );
  677. virtual int ListGetSelection() const;
  678. virtual int ListGetSelections( wxArrayInt& aSelections ) const;
  679. virtual bool ListIsSelected( unsigned int n ) const;
  680. // display
  681. virtual void ListScrollTo( unsigned int n );
  682. // accessing content
  683. virtual unsigned int ListGetCount() const;
  684. virtual int DoListHitTest( const wxPoint& inpoint ) const;
  685. virtual void UpdateLine( unsigned int n, wxListWidgetColumn* col = NULL );
  686. virtual void UpdateLineToEnd( unsigned int n) ;
  687. // pointing back
  688. wxMacDataBrowserColumn* GetColumnFromProperty( DataBrowserPropertyID );
  689. protected:
  690. virtual void ItemNotification(
  691. DataBrowserItemID itemID,
  692. DataBrowserItemNotification message,
  693. DataBrowserItemDataRef itemData);
  694. private:
  695. wxArrayMacDataBrowserColumns m_columns;
  696. int m_nextColumnId ;
  697. DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataBrowserListControl)
  698. };
  699. // ============================================================================
  700. // graphics implementation
  701. // ============================================================================
  702. // draw the image 'upside down' corrected as HIViewDrawCGImage does
  703. OSStatus WXDLLIMPEXP_CORE wxMacDrawCGImage(
  704. CGContextRef inContext,
  705. const HIRect * inBounds,
  706. CGImageRef inImage) ;
  707. CGColorRef WXDLLIMPEXP_CORE wxMacCreateCGColorFromHITheme( ThemeBrush brush ) ;
  708. #endif // wxUSE_GUI
  709. #define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \
  710. UPP Get##x() \
  711. { \
  712. static UPP sHandler = NULL; \
  713. if ( sHandler == NULL ) \
  714. sHandler = New##UPP( x ); \
  715. return sHandler; \
  716. }
  717. //---------------------------------------------------------------------------
  718. // cocoa bridging utilities
  719. //---------------------------------------------------------------------------
  720. bool wxMacInitCocoa();
  721. typedef Cursor ClassicCursor;
  722. // -------------
  723. // Common to all
  724. // -------------
  725. // Cursor support
  726. const short kwxCursorBullseye = 0;
  727. const short kwxCursorBlank = 1;
  728. const short kwxCursorPencil = 2;
  729. const short kwxCursorMagnifier = 3;
  730. const short kwxCursorNoEntry = 4;
  731. const short kwxCursorPaintBrush = 5;
  732. const short kwxCursorPointRight = 6;
  733. const short kwxCursorPointLeft = 7;
  734. const short kwxCursorQuestionArrow = 8;
  735. const short kwxCursorRightArrow = 9;
  736. const short kwxCursorSizeNS = 10;
  737. const short kwxCursorSize = 11;
  738. const short kwxCursorSizeNESW = 12;
  739. const short kwxCursorSizeNWSE = 13;
  740. const short kwxCursorRoller = 14;
  741. const short kwxCursorWatch = 15;
  742. const short kwxCursorLast = kwxCursorWatch;
  743. // exposing our fallback cursor map
  744. extern ClassicCursor gMacCursors[];
  745. //
  746. //
  747. //
  748. #if wxUSE_GUI
  749. class wxNonOwnedWindowCarbonImpl : public wxNonOwnedWindowImpl
  750. {
  751. public :
  752. wxNonOwnedWindowCarbonImpl( wxNonOwnedWindow* nonownedwnd) ;
  753. wxNonOwnedWindowCarbonImpl();
  754. virtual ~wxNonOwnedWindowCarbonImpl();
  755. virtual void WillBeDestroyed() ;
  756. void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
  757. long style, long extraStyle, const wxString& name ) ;
  758. void Create( wxWindow* parent, WXWindow nativeWindow );
  759. WXWindow GetWXWindow() const;
  760. void Raise();
  761. void Lower();
  762. bool Show(bool show);
  763. bool ShowWithEffect(bool show, wxShowEffect effect, unsigned timeout);
  764. void Update();
  765. bool SetTransparent(wxByte alpha);
  766. bool SetBackgroundColour(const wxColour& col );
  767. void SetExtraStyle( long exStyle );
  768. bool SetBackgroundStyle(wxBackgroundStyle style);
  769. bool CanSetTransparent();
  770. void MoveWindow(int x, int y, int width, int height);
  771. void GetPosition( int &x, int &y ) const;
  772. void GetSize( int &width, int &height ) const;
  773. void GetContentArea( int &left , int &top , int &width , int &height ) const;
  774. bool SetShape(const wxRegion& region);
  775. virtual void SetTitle( const wxString& title, wxFontEncoding encoding ) ;
  776. virtual bool IsMaximized() const;
  777. virtual bool IsIconized() const;
  778. virtual void Iconize( bool iconize );
  779. virtual void Maximize(bool maximize);
  780. virtual bool IsFullScreen() const;
  781. virtual bool ShowFullScreen(bool show, long style);
  782. virtual void ShowWithoutActivating();
  783. virtual void RequestUserAttention(int flags);
  784. virtual void ScreenToWindow( int *x, int *y );
  785. virtual void WindowToScreen( int *x, int *y );
  786. virtual bool IsActive();
  787. bool MacGetUnifiedAppearance() const ;
  788. void MacChangeWindowAttributes( wxUint32 attributesToSet , wxUint32 attributesToClear ) ;
  789. wxUint32 MacGetWindowAttributes() const ;
  790. void MacSetMetalAppearance( bool set ) ;
  791. bool MacGetMetalAppearance() const ;
  792. void MacSetUnifiedAppearance( bool set );
  793. WXEVENTHANDLERREF MacGetEventHandler() { return m_macEventHandler ; }
  794. wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; }
  795. protected :
  796. void MacInstallTopLevelWindowEventHandler();
  797. WXEVENTHANDLERREF m_macEventHandler ;
  798. WindowRef m_macWindow;
  799. void * m_macFullScreenData ;
  800. DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCarbonImpl)
  801. };
  802. #endif // wxUSE_GUI
  803. #endif
  804. // _WX_PRIVATE_H_