]>
Commit | Line | Data |
---|---|---|
489468fe | 1 | ///////////////////////////////////////////////////////////////////////////// |
524c47aa | 2 | // Name: src/osx/carbon/utils.cpp |
489468fe SC |
3 | // Purpose: Various utilities |
4 | // Author: Stefan Csomor | |
5 | // Modified by: | |
6 | // Created: 1998-01-01 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Stefan Csomor | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
b2680ced | 12 | |
489468fe SC |
13 | #include "wx/wxprec.h" |
14 | ||
15 | #include "wx/utils.h" | |
16 | ||
17 | #ifndef WX_PRECOMP | |
18 | #include "wx/intl.h" | |
19 | #include "wx/app.h" | |
20 | #if wxUSE_GUI | |
21 | #include "wx/toplevel.h" | |
22 | #include "wx/font.h" | |
23 | #endif | |
24 | #endif | |
25 | ||
26 | #include "wx/apptrait.h" | |
27 | ||
489468fe SC |
28 | #include <ctype.h> |
29 | ||
30 | #include <stdio.h> | |
31 | #include <stdlib.h> | |
32 | #include <string.h> | |
33 | #include <stdarg.h> | |
34 | ||
35 | // #include "MoreFilesX.h" | |
36 | ||
37 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 | |
38 | #include <AudioToolbox/AudioServices.h> | |
39 | #endif | |
40 | ||
b2680ced | 41 | #include "wx/osx/private.h" |
489468fe | 42 | #if wxUSE_GUI |
1f0c8f31 | 43 | #include "wx/osx/private/timer.h" |
489468fe SC |
44 | #endif // wxUSE_GUI |
45 | ||
46 | #include "wx/evtloop.h" | |
489468fe SC |
47 | |
48 | #if defined(__MWERKS__) && wxUSE_UNICODE | |
49 | #if __MWERKS__ < 0x4100 | |
50 | #include <wtime.h> | |
51 | #endif | |
52 | #endif | |
53 | ||
b2680ced | 54 | #if wxUSE_BASE |
489468fe | 55 | |
b2680ced SC |
56 | // Emit a beeeeeep |
57 | void wxBell() | |
58 | { | |
59 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 | |
60 | if ( AudioServicesPlayAlertSound != NULL ) | |
61 | AudioServicesPlayAlertSound(kUserPreferredAlert); | |
62 | else | |
63 | #endif | |
64 | #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 | |
36eca861 | 65 | AlertSoundPlay(); |
b2680ced | 66 | #else |
489468fe | 67 | { |
489468fe | 68 | } |
b2680ced | 69 | #endif |
489468fe SC |
70 | } |
71 | ||
b2680ced | 72 | #endif // wxUSE_BASE |
489468fe | 73 | |
b2680ced | 74 | #if wxUSE_GUI |
489468fe | 75 | |
b2680ced | 76 | wxTimerImpl* wxGUIAppTraits::CreateTimerImpl(wxTimer *timer) |
489468fe | 77 | { |
fe2fa280 | 78 | return new wxOSXTimerImpl(timer); |
489468fe SC |
79 | } |
80 | ||
b2680ced SC |
81 | int gs_wxBusyCursorCount = 0; |
82 | extern wxCursor gMacCurrentCursor; | |
83 | wxCursor gMacStoredActiveCursor; | |
84 | ||
85 | // Set the cursor to the busy cursor for all windows | |
86 | void wxBeginBusyCursor(const wxCursor *cursor) | |
489468fe | 87 | { |
b2680ced SC |
88 | if (gs_wxBusyCursorCount++ == 0) |
89 | { | |
90 | gMacStoredActiveCursor = gMacCurrentCursor; | |
91 | cursor->MacInstall(); | |
92 | ||
93 | wxSetCursor(*cursor); | |
94 | } | |
95 | //else: nothing to do, already set | |
489468fe SC |
96 | } |
97 | ||
b2680ced SC |
98 | // Restore cursor to normal |
99 | void wxEndBusyCursor() | |
489468fe | 100 | { |
b2680ced SC |
101 | wxCHECK_RET( gs_wxBusyCursorCount > 0, |
102 | wxT("no matching wxBeginBusyCursor() for wxEndBusyCursor()") ); | |
489468fe | 103 | |
b2680ced | 104 | if (--gs_wxBusyCursorCount == 0) |
489468fe | 105 | { |
b2680ced SC |
106 | gMacStoredActiveCursor.MacInstall(); |
107 | gMacStoredActiveCursor = wxNullCursor; | |
108 | ||
109 | wxSetCursor(wxNullCursor); | |
489468fe SC |
110 | } |
111 | } | |
112 | ||
b2680ced SC |
113 | // true if we're between the above two calls |
114 | bool wxIsBusy() | |
489468fe | 115 | { |
b2680ced | 116 | return (gs_wxBusyCursorCount > 0); |
489468fe SC |
117 | } |
118 | ||
b2680ced SC |
119 | #endif // wxUSE_GUI |
120 | ||
121 | #if wxUSE_BASE | |
122 | ||
123 | wxString wxMacFindFolderNoSeparator( short vol, | |
124 | OSType folderType, | |
125 | Boolean createFolder) | |
489468fe | 126 | { |
b2680ced SC |
127 | FSRef fsRef; |
128 | wxString strDir; | |
489468fe | 129 | |
b2680ced SC |
130 | if ( FSFindFolder( vol, folderType, createFolder, &fsRef) == noErr) |
131 | { | |
132 | strDir = wxMacFSRefToPath( &fsRef ); | |
133 | } | |
489468fe | 134 | |
b2680ced | 135 | return strDir; |
489468fe SC |
136 | } |
137 | ||
b2680ced SC |
138 | wxString wxMacFindFolder( short vol, |
139 | OSType folderType, | |
140 | Boolean createFolder) | |
489468fe | 141 | { |
b2680ced | 142 | return wxMacFindFolderNoSeparator(vol, folderType, createFolder) + wxFILE_SEP_PATH; |
489468fe SC |
143 | } |
144 | ||
b2680ced SC |
145 | #endif // wxUSE_BASE |
146 | ||
50a2e26f FM |
147 | |
148 | // ============================================================================ | |
149 | // GUI-only functions from now on | |
150 | // ============================================================================ | |
151 | ||
b2680ced SC |
152 | #if wxUSE_GUI |
153 | ||
50a2e26f FM |
154 | // ---------------------------------------------------------------------------- |
155 | // Miscellaneous functions | |
156 | // ---------------------------------------------------------------------------- | |
157 | ||
b2680ced | 158 | void wxGetMousePosition( int* x, int* y ) |
489468fe | 159 | { |
b2680ced SC |
160 | Point pt; |
161 | GetGlobalMouse(&pt); | |
162 | if ( x ) | |
163 | *x = pt.h; | |
164 | if ( y ) | |
165 | *y = pt.v; | |
166 | }; | |
489468fe | 167 | |
b2680ced | 168 | void wxClientDisplayRect(int *x, int *y, int *width, int *height) |
489468fe | 169 | { |
b2680ced SC |
170 | #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 |
171 | HIRect bounds ; | |
172 | HIWindowGetAvailablePositioningBounds(kCGNullDirectDisplay,kHICoordSpace72DPIGlobal, | |
173 | &bounds); | |
174 | if ( x ) | |
175 | *x = bounds.origin.x; | |
176 | if ( y ) | |
177 | *y = bounds.origin.y; | |
178 | if ( width ) | |
179 | *width = bounds.size.width; | |
180 | if ( height ) | |
181 | *height = bounds.size.height; | |
182 | #else | |
183 | Rect r; | |
184 | GetAvailableWindowPositioningBounds( GetMainDevice() , &r ); | |
185 | if ( x ) | |
186 | *x = r.left; | |
187 | if ( y ) | |
188 | *y = r.top; | |
189 | if ( width ) | |
190 | *width = r.right - r.left; | |
191 | if ( height ) | |
192 | *height = r.bottom - r.top; | |
193 | #endif | |
489468fe SC |
194 | } |
195 | ||
b2680ced SC |
196 | #endif // wxUSE_GUI |
197 | ||
b2680ced SC |
198 | #if wxUSE_GUI |
199 | ||
200 | // ---------------------------------------------------------------------------- | |
201 | // Native Struct Conversions | |
202 | // ---------------------------------------------------------------------------- | |
203 | ||
204 | void wxMacRectToNative( const wxRect *wx , Rect *n ) | |
205 | { | |
206 | n->left = wx->x; | |
207 | n->top = wx->y; | |
208 | n->right = wx->x + wx->width; | |
209 | n->bottom = wx->y + wx->height; | |
489468fe SC |
210 | } |
211 | ||
b2680ced | 212 | void wxMacNativeToRect( const Rect *n , wxRect* wx ) |
489468fe | 213 | { |
b2680ced SC |
214 | wx->x = n->left; |
215 | wx->y = n->top; | |
216 | wx->width = n->right - n->left; | |
217 | wx->height = n->bottom - n->top; | |
489468fe SC |
218 | } |
219 | ||
b2680ced | 220 | void wxMacPointToNative( const wxPoint* wx , Point *n ) |
489468fe | 221 | { |
b2680ced SC |
222 | n->h = wx->x; |
223 | n->v = wx->y; | |
224 | } | |
489468fe | 225 | |
b2680ced SC |
226 | void wxMacNativeToPoint( const Point *n , wxPoint* wx ) |
227 | { | |
228 | wx->x = n->h; | |
229 | wx->y = n->v; | |
489468fe SC |
230 | } |
231 | ||
b2680ced SC |
232 | // ---------------------------------------------------------------------------- |
233 | // Carbon Event Support | |
234 | // ---------------------------------------------------------------------------- | |
489468fe | 235 | |
b2680ced | 236 | OSStatus wxMacCarbonEvent::GetParameter(EventParamName inName, EventParamType inDesiredType, UInt32 inBufferSize, void * outData) |
489468fe | 237 | { |
b2680ced | 238 | return ::GetEventParameter( m_eventRef , inName , inDesiredType , NULL , inBufferSize , NULL , outData ); |
489468fe SC |
239 | } |
240 | ||
b2680ced | 241 | OSStatus wxMacCarbonEvent::SetParameter(EventParamName inName, EventParamType inType, UInt32 inBufferSize, const void * inData) |
489468fe | 242 | { |
b2680ced | 243 | return ::SetEventParameter( m_eventRef , inName , inType , inBufferSize , inData ); |
489468fe SC |
244 | } |
245 | ||
b2680ced SC |
246 | // ---------------------------------------------------------------------------- |
247 | // Control Access Support | |
248 | // ---------------------------------------------------------------------------- | |
249 | ||
250 | ||
489468fe SC |
251 | // ============================================================================ |
252 | // DataBrowser Wrapper | |
253 | // ============================================================================ | |
254 | // | |
255 | // basing on DataBrowserItemIDs | |
256 | // | |
257 | ||
258 | IMPLEMENT_ABSTRACT_CLASS( wxMacDataBrowserControl , wxMacControl ) | |
259 | ||
260 | pascal void wxMacDataBrowserControl::DataBrowserItemNotificationProc( | |
261 | ControlRef browser, | |
262 | DataBrowserItemID itemID, | |
263 | DataBrowserItemNotification message, | |
264 | DataBrowserItemDataRef itemData ) | |
265 | { | |
266 | wxMacDataBrowserControl* ctl = wxDynamicCast(wxMacControl::GetReferenceFromNativeControl( browser ), wxMacDataBrowserControl); | |
267 | if ( ctl != 0 ) | |
268 | { | |
269 | ctl->ItemNotification(itemID, message, itemData); | |
270 | } | |
271 | } | |
272 | ||
273 | pascal OSStatus wxMacDataBrowserControl::DataBrowserGetSetItemDataProc( | |
274 | ControlRef browser, | |
275 | DataBrowserItemID itemID, | |
276 | DataBrowserPropertyID property, | |
277 | DataBrowserItemDataRef itemData, | |
278 | Boolean changeValue ) | |
279 | { | |
280 | OSStatus err = errDataBrowserPropertyNotSupported; | |
281 | wxMacDataBrowserControl* ctl = wxDynamicCast(wxMacControl::GetReferenceFromNativeControl( browser ), wxMacDataBrowserControl); | |
282 | if ( ctl != 0 ) | |
283 | { | |
284 | err = ctl->GetSetItemData(itemID, property, itemData, changeValue); | |
285 | } | |
286 | return err; | |
287 | } | |
288 | ||
289 | pascal Boolean wxMacDataBrowserControl::DataBrowserCompareProc( | |
290 | ControlRef browser, | |
291 | DataBrowserItemID itemOneID, | |
292 | DataBrowserItemID itemTwoID, | |
293 | DataBrowserPropertyID sortProperty) | |
294 | { | |
295 | wxMacDataBrowserControl* ctl = wxDynamicCast(wxMacControl::GetReferenceFromNativeControl( browser ), wxMacDataBrowserControl); | |
296 | if ( ctl != 0 ) | |
297 | { | |
298 | return ctl->CompareItems(itemOneID, itemTwoID, sortProperty); | |
299 | } | |
300 | return false; | |
301 | } | |
302 | ||
303 | DataBrowserItemDataUPP gDataBrowserItemDataUPP = NULL; | |
304 | DataBrowserItemNotificationUPP gDataBrowserItemNotificationUPP = NULL; | |
305 | DataBrowserItemCompareUPP gDataBrowserItemCompareUPP = NULL; | |
306 | ||
307 | wxMacDataBrowserControl::wxMacDataBrowserControl( wxWindow* peer, | |
308 | const wxPoint& pos, | |
309 | const wxSize& size, | |
310 | long WXUNUSED(style)) | |
311 | : wxMacControl( peer ) | |
312 | { | |
313 | Rect bounds = wxMacGetBoundsForControl( peer, pos, size ); | |
314 | OSStatus err = ::CreateDataBrowserControl( | |
315 | MAC_WXHWND(peer->MacGetTopLevelWindowRef()), | |
316 | &bounds, kDataBrowserListView, &m_controlRef ); | |
317 | SetReferenceInNativeControl(); | |
318 | verify_noerr( err ); | |
319 | if ( gDataBrowserItemCompareUPP == NULL ) | |
320 | gDataBrowserItemCompareUPP = NewDataBrowserItemCompareUPP(DataBrowserCompareProc); | |
321 | if ( gDataBrowserItemDataUPP == NULL ) | |
322 | gDataBrowserItemDataUPP = NewDataBrowserItemDataUPP(DataBrowserGetSetItemDataProc); | |
323 | if ( gDataBrowserItemNotificationUPP == NULL ) | |
324 | { | |
325 | gDataBrowserItemNotificationUPP = | |
326 | (DataBrowserItemNotificationUPP) NewDataBrowserItemNotificationWithItemUPP(DataBrowserItemNotificationProc); | |
327 | } | |
328 | ||
329 | DataBrowserCallbacks callbacks; | |
330 | InitializeDataBrowserCallbacks( &callbacks, kDataBrowserLatestCallbacks ); | |
331 | ||
332 | callbacks.u.v1.itemDataCallback = gDataBrowserItemDataUPP; | |
333 | callbacks.u.v1.itemCompareCallback = gDataBrowserItemCompareUPP; | |
334 | callbacks.u.v1.itemNotificationCallback = gDataBrowserItemNotificationUPP; | |
335 | SetCallbacks( &callbacks ); | |
336 | ||
337 | } | |
338 | ||
339 | OSStatus wxMacDataBrowserControl::GetItemCount( DataBrowserItemID container, | |
340 | Boolean recurse, | |
341 | DataBrowserItemState state, | |
342 | ItemCount *numItems) const | |
343 | { | |
344 | return GetDataBrowserItemCount( m_controlRef, container, recurse, state, numItems ); | |
345 | } | |
346 | ||
347 | OSStatus wxMacDataBrowserControl::GetItems( DataBrowserItemID container, | |
348 | Boolean recurse, | |
349 | DataBrowserItemState state, | |
350 | Handle items) const | |
351 | { | |
352 | return GetDataBrowserItems( m_controlRef, container, recurse, state, items ); | |
353 | } | |
354 | ||
355 | OSStatus wxMacDataBrowserControl::SetSelectionFlags( DataBrowserSelectionFlags options ) | |
356 | { | |
357 | return SetDataBrowserSelectionFlags( m_controlRef, options ); | |
358 | } | |
359 | ||
360 | OSStatus wxMacDataBrowserControl::AddColumn( DataBrowserListViewColumnDesc *columnDesc, | |
361 | DataBrowserTableViewColumnIndex position ) | |
362 | { | |
363 | return AddDataBrowserListViewColumn( m_controlRef, columnDesc, position ); | |
364 | } | |
365 | ||
89c33c48 RR |
366 | OSStatus wxMacDataBrowserControl::GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position, DataBrowserTableViewColumnID* id ) |
367 | { | |
489468fe SC |
368 | return GetDataBrowserTableViewColumnProperty( m_controlRef, position, id ); |
369 | } | |
370 | ||
371 | OSStatus wxMacDataBrowserControl::RemoveColumn( DataBrowserTableViewColumnIndex position ) | |
372 | { | |
373 | DataBrowserTableViewColumnID id; | |
374 | GetColumnIDFromIndex( position, &id ); | |
375 | return RemoveDataBrowserTableViewColumn( m_controlRef, id ); | |
376 | } | |
377 | ||
378 | OSStatus wxMacDataBrowserControl::AutoSizeColumns() | |
379 | { | |
380 | return AutoSizeDataBrowserListViewColumns(m_controlRef); | |
381 | } | |
382 | ||
383 | OSStatus wxMacDataBrowserControl::SetHasScrollBars( bool horiz, bool vert ) | |
384 | { | |
385 | return SetDataBrowserHasScrollBars( m_controlRef, horiz, vert ); | |
386 | } | |
387 | ||
388 | OSStatus wxMacDataBrowserControl::SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle ) | |
389 | { | |
390 | return SetDataBrowserTableViewHiliteStyle( m_controlRef, hiliteStyle ); | |
391 | } | |
392 | ||
393 | OSStatus wxMacDataBrowserControl::SetHeaderButtonHeight(UInt16 height) | |
394 | { | |
395 | return SetDataBrowserListViewHeaderBtnHeight( m_controlRef, height ); | |
396 | } | |
397 | ||
398 | OSStatus wxMacDataBrowserControl::GetHeaderButtonHeight(UInt16 *height) | |
399 | { | |
400 | return GetDataBrowserListViewHeaderBtnHeight( m_controlRef, height ); | |
401 | } | |
402 | ||
403 | OSStatus wxMacDataBrowserControl::SetCallbacks(const DataBrowserCallbacks *callbacks) | |
404 | { | |
405 | return SetDataBrowserCallbacks( m_controlRef, callbacks ); | |
406 | } | |
407 | ||
408 | OSStatus wxMacDataBrowserControl::UpdateItems( | |
409 | DataBrowserItemID container, | |
410 | UInt32 numItems, | |
411 | const DataBrowserItemID *items, | |
412 | DataBrowserPropertyID preSortProperty, | |
413 | DataBrowserPropertyID propertyID ) const | |
414 | { | |
415 | return UpdateDataBrowserItems( m_controlRef, container, numItems, items, preSortProperty, propertyID ); | |
416 | } | |
417 | ||
418 | bool wxMacDataBrowserControl::IsItemSelected( DataBrowserItemID item ) const | |
419 | { | |
420 | return IsDataBrowserItemSelected( m_controlRef, item ); | |
421 | } | |
422 | ||
423 | OSStatus wxMacDataBrowserControl::AddItems( | |
424 | DataBrowserItemID container, | |
425 | UInt32 numItems, | |
426 | const DataBrowserItemID *items, | |
427 | DataBrowserPropertyID preSortProperty ) | |
428 | { | |
429 | return AddDataBrowserItems( m_controlRef, container, numItems, items, preSortProperty ); | |
430 | } | |
431 | ||
432 | OSStatus wxMacDataBrowserControl::RemoveItems( | |
433 | DataBrowserItemID container, | |
434 | UInt32 numItems, | |
435 | const DataBrowserItemID *items, | |
436 | DataBrowserPropertyID preSortProperty ) | |
437 | { | |
438 | return RemoveDataBrowserItems( m_controlRef, container, numItems, items, preSortProperty ); | |
439 | } | |
440 | ||
441 | OSStatus wxMacDataBrowserControl::RevealItem( | |
442 | DataBrowserItemID item, | |
443 | DataBrowserPropertyID propertyID, | |
444 | DataBrowserRevealOptions options ) const | |
445 | { | |
446 | return RevealDataBrowserItem( m_controlRef, item, propertyID, options ); | |
447 | } | |
448 | ||
449 | OSStatus wxMacDataBrowserControl::SetSelectedItems( | |
450 | UInt32 numItems, | |
451 | const DataBrowserItemID *items, | |
452 | DataBrowserSetOption operation ) | |
453 | { | |
454 | return SetDataBrowserSelectedItems( m_controlRef, numItems, items, operation ); | |
455 | } | |
456 | ||
457 | OSStatus wxMacDataBrowserControl::GetSelectionAnchor( DataBrowserItemID *first, DataBrowserItemID *last ) const | |
458 | { | |
459 | return GetDataBrowserSelectionAnchor( m_controlRef, first, last ); | |
460 | } | |
461 | ||
462 | OSStatus wxMacDataBrowserControl::GetItemID( DataBrowserTableViewRowIndex row, DataBrowserItemID * item ) const | |
463 | { | |
464 | return GetDataBrowserTableViewItemID( m_controlRef, row, item ); | |
465 | } | |
466 | ||
467 | OSStatus wxMacDataBrowserControl::GetItemRow( DataBrowserItemID item, DataBrowserTableViewRowIndex * row ) const | |
468 | { | |
469 | return GetDataBrowserTableViewItemRow( m_controlRef, item, row ); | |
470 | } | |
471 | ||
472 | OSStatus wxMacDataBrowserControl::SetDefaultRowHeight( UInt16 height ) | |
473 | { | |
474 | return SetDataBrowserTableViewRowHeight( m_controlRef , height ); | |
475 | } | |
476 | ||
477 | OSStatus wxMacDataBrowserControl::GetDefaultRowHeight( UInt16 * height ) const | |
478 | { | |
479 | return GetDataBrowserTableViewRowHeight( m_controlRef, height ); | |
480 | } | |
481 | ||
482 | OSStatus wxMacDataBrowserControl::SetRowHeight( DataBrowserItemID item , UInt16 height) | |
483 | { | |
484 | return SetDataBrowserTableViewItemRowHeight( m_controlRef, item , height ); | |
485 | } | |
486 | ||
487 | OSStatus wxMacDataBrowserControl::GetRowHeight( DataBrowserItemID item , UInt16 *height) const | |
488 | { | |
489 | return GetDataBrowserTableViewItemRowHeight( m_controlRef, item , height); | |
490 | } | |
491 | ||
492 | OSStatus wxMacDataBrowserControl::GetColumnWidth( DataBrowserPropertyID column , UInt16 *width ) const | |
493 | { | |
494 | return GetDataBrowserTableViewNamedColumnWidth( m_controlRef , column , width ); | |
495 | } | |
496 | ||
497 | OSStatus wxMacDataBrowserControl::SetColumnWidth( DataBrowserPropertyID column , UInt16 width ) | |
498 | { | |
499 | return SetDataBrowserTableViewNamedColumnWidth( m_controlRef , column , width ); | |
500 | } | |
501 | ||
502 | OSStatus wxMacDataBrowserControl::GetDefaultColumnWidth( UInt16 *width ) const | |
503 | { | |
504 | return GetDataBrowserTableViewColumnWidth( m_controlRef , width ); | |
505 | } | |
506 | ||
507 | OSStatus wxMacDataBrowserControl::SetDefaultColumnWidth( UInt16 width ) | |
508 | { | |
509 | return SetDataBrowserTableViewColumnWidth( m_controlRef , width ); | |
510 | } | |
511 | ||
512 | OSStatus wxMacDataBrowserControl::GetColumnCount(UInt32* numColumns) const | |
513 | { | |
514 | return GetDataBrowserTableViewColumnCount( m_controlRef, numColumns); | |
515 | } | |
516 | ||
517 | OSStatus wxMacDataBrowserControl::GetColumnPosition( DataBrowserPropertyID column, | |
518 | DataBrowserTableViewColumnIndex *position) const | |
519 | { | |
520 | return GetDataBrowserTableViewColumnPosition( m_controlRef , column , position); | |
521 | } | |
522 | ||
523 | OSStatus wxMacDataBrowserControl::SetColumnPosition( DataBrowserPropertyID column, DataBrowserTableViewColumnIndex position) | |
524 | { | |
525 | return SetDataBrowserTableViewColumnPosition( m_controlRef , column , position); | |
526 | } | |
527 | ||
528 | OSStatus wxMacDataBrowserControl::GetScrollPosition( UInt32 *top , UInt32 *left ) const | |
529 | { | |
530 | return GetDataBrowserScrollPosition( m_controlRef , top , left ); | |
531 | } | |
532 | ||
533 | OSStatus wxMacDataBrowserControl::SetScrollPosition( UInt32 top , UInt32 left ) | |
534 | { | |
535 | return SetDataBrowserScrollPosition( m_controlRef , top , left ); | |
536 | } | |
537 | ||
538 | OSStatus wxMacDataBrowserControl::GetSortProperty( DataBrowserPropertyID *column ) const | |
539 | { | |
540 | return GetDataBrowserSortProperty( m_controlRef , column ); | |
541 | } | |
542 | ||
543 | OSStatus wxMacDataBrowserControl::SetSortProperty( DataBrowserPropertyID column ) | |
544 | { | |
545 | return SetDataBrowserSortProperty( m_controlRef , column ); | |
546 | } | |
547 | ||
548 | OSStatus wxMacDataBrowserControl::GetSortOrder( DataBrowserSortOrder *order ) const | |
549 | { | |
550 | return GetDataBrowserSortOrder( m_controlRef , order ); | |
551 | } | |
552 | ||
553 | OSStatus wxMacDataBrowserControl::SetSortOrder( DataBrowserSortOrder order ) | |
554 | { | |
555 | return SetDataBrowserSortOrder( m_controlRef , order ); | |
556 | } | |
557 | ||
558 | OSStatus wxMacDataBrowserControl::GetPropertyFlags( DataBrowserPropertyID property, | |
559 | DataBrowserPropertyFlags *flags ) const | |
560 | { | |
561 | return GetDataBrowserPropertyFlags( m_controlRef , property , flags ); | |
562 | } | |
563 | ||
564 | OSStatus wxMacDataBrowserControl::SetPropertyFlags( DataBrowserPropertyID property, | |
565 | DataBrowserPropertyFlags flags ) | |
566 | { | |
567 | return SetDataBrowserPropertyFlags( m_controlRef , property , flags ); | |
568 | } | |
569 | ||
570 | OSStatus wxMacDataBrowserControl::GetHeaderDesc( DataBrowserPropertyID property, | |
571 | DataBrowserListViewHeaderDesc *desc ) const | |
572 | { | |
573 | return GetDataBrowserListViewHeaderDesc( m_controlRef , property , desc ); | |
574 | } | |
575 | ||
576 | OSStatus wxMacDataBrowserControl::SetHeaderDesc( DataBrowserPropertyID property, | |
577 | DataBrowserListViewHeaderDesc *desc ) | |
578 | { | |
579 | return SetDataBrowserListViewHeaderDesc( m_controlRef , property , desc ); | |
580 | } | |
581 | ||
582 | OSStatus wxMacDataBrowserControl::SetDisclosureColumn( DataBrowserPropertyID property , | |
583 | Boolean expandableRows ) | |
584 | { | |
585 | return SetDataBrowserListViewDisclosureColumn( m_controlRef, property, expandableRows); | |
586 | } | |
587 | ||
51c72a7b JS |
588 | OSStatus wxMacDataBrowserControl::GetItemPartBounds( DataBrowserItemID item, DataBrowserPropertyID property, DataBrowserPropertyPart part, Rect * bounds ) |
589 | { | |
590 | return GetDataBrowserItemPartBounds( m_controlRef, item, property, part, bounds); | |
591 | } | |
592 | ||
489468fe SC |
593 | // ============================================================================ |
594 | // Higher-level Databrowser | |
595 | // ============================================================================ | |
596 | // | |
597 | // basing on data item objects | |
598 | // | |
599 | ||
600 | wxMacDataItem::wxMacDataItem() | |
601 | { | |
524c47aa | 602 | // m_data = NULL; |
489468fe SC |
603 | |
604 | m_order = 0; | |
524c47aa | 605 | // m_colId = kTextColumnId; // for compat with existing wx*ListBox impls. |
489468fe SC |
606 | } |
607 | ||
608 | wxMacDataItem::~wxMacDataItem() | |
609 | { | |
610 | } | |
611 | ||
612 | void wxMacDataItem::SetOrder( SInt32 order ) | |
613 | { | |
614 | m_order = order; | |
615 | } | |
616 | ||
617 | SInt32 wxMacDataItem::GetOrder() const | |
618 | { | |
619 | return m_order; | |
620 | } | |
524c47aa | 621 | /* |
489468fe SC |
622 | void wxMacDataItem::SetData( void* data) |
623 | { | |
624 | m_data = data; | |
625 | } | |
626 | ||
627 | void* wxMacDataItem::GetData() const | |
628 | { | |
629 | return m_data; | |
630 | } | |
631 | ||
632 | short wxMacDataItem::GetColumn() | |
633 | { | |
634 | return m_colId; | |
635 | } | |
636 | ||
637 | void wxMacDataItem::SetColumn( short col ) | |
638 | { | |
639 | m_colId = col; | |
640 | } | |
641 | ||
642 | void wxMacDataItem::SetLabel( const wxString& str) | |
643 | { | |
644 | m_label = str; | |
645 | m_cfLabel = wxCFStringRef( str , wxLocale::GetSystemEncoding()); | |
646 | } | |
647 | ||
648 | const wxString& wxMacDataItem::GetLabel() const | |
649 | { | |
650 | return m_label; | |
651 | } | |
524c47aa | 652 | */ |
489468fe SC |
653 | |
654 | bool wxMacDataItem::IsLessThan(wxMacDataItemBrowserControl *WXUNUSED(owner) , | |
655 | const wxMacDataItem* rhs, | |
656 | DataBrowserPropertyID sortProperty) const | |
657 | { | |
489468fe SC |
658 | bool retval = false; |
659 | ||
524c47aa | 660 | if ( sortProperty == kNumericOrderColumnId ) |
5c33522f | 661 | retval = m_order < rhs->m_order; |
489468fe SC |
662 | |
663 | return retval; | |
664 | } | |
665 | ||
666 | OSStatus wxMacDataItem::GetSetData( wxMacDataItemBrowserControl *WXUNUSED(owner) , | |
667 | DataBrowserPropertyID property, | |
668 | DataBrowserItemDataRef itemData, | |
669 | bool changeValue ) | |
670 | { | |
671 | OSStatus err = errDataBrowserPropertyNotSupported; | |
672 | if ( !changeValue ) | |
673 | { | |
524c47aa SC |
674 | if ( property == kNumericOrderColumnId ) |
675 | { | |
489468fe SC |
676 | err = ::SetDataBrowserItemDataValue( itemData, m_order ); |
677 | err = noErr; | |
678 | } | |
489468fe SC |
679 | } |
680 | ||
681 | return err; | |
682 | } | |
683 | ||
684 | void wxMacDataItem::Notification(wxMacDataItemBrowserControl *WXUNUSED(owner) , | |
685 | DataBrowserItemNotification WXUNUSED(message), | |
686 | DataBrowserItemDataRef WXUNUSED(itemData) ) const | |
687 | { | |
688 | } | |
689 | ||
690 | IMPLEMENT_DYNAMIC_CLASS( wxMacDataItemBrowserControl , wxMacDataBrowserControl ) | |
691 | ||
692 | wxMacDataItemBrowserControl::wxMacDataItemBrowserControl( wxWindow* peer , const wxPoint& pos, const wxSize& size, long style) : | |
693 | wxMacDataBrowserControl( peer, pos, size, style ) | |
694 | { | |
695 | m_suppressSelection = false; | |
696 | m_sortOrder = SortOrder_None; | |
697 | m_clientDataItemsType = wxClientData_None; | |
698 | } | |
699 | ||
489468fe SC |
700 | wxMacDataItemBrowserSelectionSuppressor::wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl *browser) |
701 | { | |
702 | m_former = browser->SuppressSelection(true); | |
703 | m_browser = browser; | |
704 | } | |
705 | ||
706 | wxMacDataItemBrowserSelectionSuppressor::~wxMacDataItemBrowserSelectionSuppressor() | |
707 | { | |
708 | m_browser->SuppressSelection(m_former); | |
709 | } | |
710 | ||
711 | bool wxMacDataItemBrowserControl::SuppressSelection( bool suppress ) | |
712 | { | |
713 | bool former = m_suppressSelection; | |
714 | m_suppressSelection = suppress; | |
715 | ||
716 | return former; | |
717 | } | |
718 | ||
719 | Boolean wxMacDataItemBrowserControl::CompareItems(DataBrowserItemID itemOneID, | |
720 | DataBrowserItemID itemTwoID, | |
721 | DataBrowserPropertyID sortProperty) | |
722 | { | |
723 | wxMacDataItem* itemOne = (wxMacDataItem*) itemOneID; | |
724 | wxMacDataItem* itemTwo = (wxMacDataItem*) itemTwoID; | |
489468fe | 725 | |
489468fe SC |
726 | Boolean retval = false; |
727 | if ( itemOne != NULL ) | |
728 | retval = itemOne->IsLessThan( this , itemTwo , sortProperty); | |
729 | return retval; | |
730 | } | |
731 | ||
732 | OSStatus wxMacDataItemBrowserControl::GetSetItemData( | |
733 | DataBrowserItemID itemID, | |
734 | DataBrowserPropertyID property, | |
735 | DataBrowserItemDataRef itemData, | |
736 | Boolean changeValue ) | |
737 | { | |
738 | wxMacDataItem* item = (wxMacDataItem*) itemID; | |
489468fe SC |
739 | OSStatus err = errDataBrowserPropertyNotSupported; |
740 | switch( property ) | |
741 | { | |
742 | case kDataBrowserContainerIsClosableProperty : | |
743 | case kDataBrowserContainerIsSortableProperty : | |
744 | case kDataBrowserContainerIsOpenableProperty : | |
745 | // right now default behaviour on these | |
746 | break; | |
747 | default : | |
748 | ||
749 | if ( item != NULL ){ | |
750 | err = item->GetSetData( this, property , itemData , changeValue ); | |
751 | } | |
752 | break; | |
753 | ||
754 | } | |
755 | return err; | |
756 | } | |
757 | ||
758 | void wxMacDataItemBrowserControl::ItemNotification( | |
759 | DataBrowserItemID itemID, | |
760 | DataBrowserItemNotification message, | |
761 | DataBrowserItemDataRef itemData) | |
762 | { | |
763 | wxMacDataItem* item = (wxMacDataItem*) itemID; | |
489468fe SC |
764 | if (item != NULL) |
765 | item->Notification( this, message, itemData); | |
766 | } | |
767 | ||
768 | unsigned int wxMacDataItemBrowserControl::GetItemCount(const wxMacDataItem* container, | |
769 | bool recurse , DataBrowserItemState state) const | |
770 | { | |
771 | ItemCount numItems = 0; | |
772 | verify_noerr( wxMacDataBrowserControl::GetItemCount( (DataBrowserItemID)container, | |
773 | recurse, state, &numItems ) ); | |
774 | return numItems; | |
775 | } | |
776 | ||
777 | unsigned int wxMacDataItemBrowserControl::GetSelectedItemCount( const wxMacDataItem* container, | |
778 | bool recurse ) const | |
779 | { | |
780 | return GetItemCount( container, recurse, kDataBrowserItemIsSelected ); | |
781 | ||
782 | } | |
783 | ||
784 | void wxMacDataItemBrowserControl::GetItems(const wxMacDataItem* container, | |
785 | bool recurse , DataBrowserItemState state, wxArrayMacDataItemPtr &items) const | |
786 | { | |
787 | Handle handle = NewHandle(0); | |
788 | verify_noerr( wxMacDataBrowserControl::GetItems( (DataBrowserItemID)container , | |
789 | recurse , state, handle) ); | |
790 | ||
791 | int itemCount = GetHandleSize(handle)/sizeof(DataBrowserItemID); | |
792 | HLock( handle ); | |
793 | wxMacDataItemPtr* itemsArray = (wxMacDataItemPtr*) *handle; | |
794 | for ( int i = 0; i < itemCount; ++i) | |
795 | { | |
796 | items.Add(itemsArray[i]); | |
797 | } | |
798 | HUnlock( handle ); | |
799 | DisposeHandle( handle ); | |
800 | } | |
801 | ||
802 | unsigned int wxMacDataItemBrowserControl::GetLineFromItem(const wxMacDataItem* item) const | |
803 | { | |
804 | DataBrowserTableViewRowIndex row; | |
805 | OSStatus err = GetItemRow( (DataBrowserItemID) item , &row); | |
806 | wxCHECK( err == noErr, (unsigned)-1 ); | |
807 | return row; | |
808 | } | |
809 | ||
810 | wxMacDataItem* wxMacDataItemBrowserControl::GetItemFromLine(unsigned int n) const | |
811 | { | |
812 | DataBrowserItemID id; | |
813 | OSStatus err = GetItemID( (DataBrowserTableViewRowIndex) n , &id); | |
814 | wxCHECK( err == noErr, NULL ); | |
815 | return (wxMacDataItem*) id; | |
816 | } | |
817 | ||
818 | void wxMacDataItemBrowserControl::UpdateItem(const wxMacDataItem *container, | |
819 | const wxMacDataItem *item , DataBrowserPropertyID property) const | |
820 | { | |
821 | verify_noerr( wxMacDataBrowserControl::UpdateItems((DataBrowserItemID)container, 1, | |
822 | (DataBrowserItemID*) &item, kDataBrowserItemNoProperty /* notSorted */, property ) ); | |
823 | } | |
824 | ||
825 | void wxMacDataItemBrowserControl::UpdateItems(const wxMacDataItem *container, | |
826 | wxArrayMacDataItemPtr &itemArray , DataBrowserPropertyID property) const | |
827 | { | |
828 | unsigned int noItems = itemArray.GetCount(); | |
829 | DataBrowserItemID *items = new DataBrowserItemID[noItems]; | |
830 | for ( unsigned int i = 0; i < noItems; ++i ) | |
831 | items[i] = (DataBrowserItemID) itemArray[i]; | |
832 | ||
833 | verify_noerr( wxMacDataBrowserControl::UpdateItems((DataBrowserItemID)container, noItems, | |
834 | items, kDataBrowserItemNoProperty /* notSorted */, property ) ); | |
835 | delete [] items; | |
836 | } | |
837 | ||
89c33c48 RR |
838 | static int column_id_counter = 0; |
839 | ||
840 | void wxMacDataItemBrowserControl::InsertColumn(int col, DataBrowserPropertyType colType, | |
489468fe SC |
841 | const wxString& title, SInt16 just, int defaultWidth) |
842 | { | |
843 | DataBrowserListViewColumnDesc columnDesc; | |
844 | columnDesc.headerBtnDesc.titleOffset = 0; | |
845 | columnDesc.headerBtnDesc.version = kDataBrowserListViewLatestHeaderDesc; | |
846 | ||
847 | columnDesc.headerBtnDesc.btnFontStyle.flags = | |
848 | kControlUseFontMask | kControlUseJustMask; | |
849 | ||
850 | columnDesc.headerBtnDesc.btnContentInfo.contentType = kControlContentTextOnly; | |
851 | columnDesc.headerBtnDesc.btnFontStyle.just = just; | |
852 | columnDesc.headerBtnDesc.btnFontStyle.font = kControlFontViewSystemFont; | |
853 | columnDesc.headerBtnDesc.btnFontStyle.style = normal; | |
854 | ||
855 | // TODO: Why is m_font not defined when we enter wxLC_LIST mode, but is | |
856 | // defined for other modes? | |
857 | wxFontEncoding enc; | |
858 | if ( m_font.Ok() ) | |
859 | enc = m_font.GetEncoding(); | |
860 | else | |
861 | enc = wxLocale::GetSystemEncoding(); | |
862 | wxCFStringRef cfTitle( title, enc ); | |
863 | columnDesc.headerBtnDesc.titleString = cfTitle; | |
864 | ||
865 | columnDesc.headerBtnDesc.minimumWidth = 0; | |
866 | columnDesc.headerBtnDesc.maximumWidth = 30000; | |
867 | ||
89c33c48 RR |
868 | DataBrowserPropertyID id = kMinColumnId + column_id_counter; |
869 | column_id_counter++; | |
870 | ||
871 | columnDesc.propertyDesc.propertyID = id; | |
489468fe SC |
872 | columnDesc.propertyDesc.propertyType = colType; |
873 | columnDesc.propertyDesc.propertyFlags = kDataBrowserListViewSortableColumn; | |
874 | columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewTypeSelectColumn; | |
875 | columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewNoGapForIconInHeaderButton; | |
876 | ||
89c33c48 | 877 | verify_noerr( AddColumn( &columnDesc, col ) ); |
489468fe SC |
878 | |
879 | if (defaultWidth > 0){ | |
89c33c48 | 880 | SetColumnWidth(col, defaultWidth); |
489468fe | 881 | } |
489468fe SC |
882 | } |
883 | ||
884 | void wxMacDataItemBrowserControl::SetColumnWidth(int colId, int width) | |
885 | { | |
886 | DataBrowserPropertyID id; | |
887 | GetColumnIDFromIndex(colId, &id); | |
888 | verify_noerr( wxMacDataBrowserControl::SetColumnWidth(id, width)); | |
889 | } | |
890 | ||
891 | int wxMacDataItemBrowserControl::GetColumnWidth(int colId) | |
892 | { | |
893 | DataBrowserPropertyID id; | |
894 | GetColumnIDFromIndex(colId, &id); | |
895 | UInt16 result; | |
896 | verify_noerr( wxMacDataBrowserControl::GetColumnWidth(id, &result)); | |
897 | return result; | |
898 | } | |
899 | ||
900 | void wxMacDataItemBrowserControl::AddItem(wxMacDataItem *container, wxMacDataItem *item) | |
901 | { | |
902 | verify_noerr( wxMacDataBrowserControl::AddItems( (DataBrowserItemID)container, 1, | |
903 | (DataBrowserItemID*) &item, kDataBrowserItemNoProperty ) ); | |
904 | } | |
905 | ||
906 | void wxMacDataItemBrowserControl::AddItems(wxMacDataItem *container, wxArrayMacDataItemPtr &itemArray ) | |
907 | { | |
908 | unsigned int noItems = itemArray.GetCount(); | |
909 | DataBrowserItemID *items = new DataBrowserItemID[noItems]; | |
910 | for ( unsigned int i = 0; i < noItems; ++i ) | |
911 | items[i] = (DataBrowserItemID) itemArray[i]; | |
912 | ||
913 | verify_noerr( wxMacDataBrowserControl::AddItems( (DataBrowserItemID)container, noItems, | |
914 | (DataBrowserItemID*) items, kDataBrowserItemNoProperty ) ); | |
915 | delete [] items; | |
916 | } | |
917 | ||
918 | void wxMacDataItemBrowserControl::RemoveItem(wxMacDataItem *container, wxMacDataItem* item) | |
919 | { | |
920 | OSStatus err = wxMacDataBrowserControl::RemoveItems( (DataBrowserItemID)container, 1, | |
921 | (DataBrowserItemID*) &item, kDataBrowserItemNoProperty ); | |
922 | verify_noerr( err ); | |
923 | } | |
924 | ||
925 | void wxMacDataItemBrowserControl::RemoveItems(wxMacDataItem *container, wxArrayMacDataItemPtr &itemArray) | |
926 | { | |
927 | unsigned int noItems = itemArray.GetCount(); | |
928 | DataBrowserItemID *items = new DataBrowserItemID[noItems]; | |
929 | for ( unsigned int i = 0; i < noItems; ++i ) | |
930 | items[i] = (DataBrowserItemID) itemArray[i]; | |
931 | ||
932 | OSStatus err = wxMacDataBrowserControl::RemoveItems( (DataBrowserItemID)container, noItems, | |
933 | (DataBrowserItemID*) items, kDataBrowserItemNoProperty ); | |
934 | verify_noerr( err ); | |
935 | delete [] items; | |
936 | } | |
937 | ||
938 | void wxMacDataItemBrowserControl::RemoveAllItems(wxMacDataItem *container) | |
939 | { | |
88b497c1 | 940 | SetScrollPosition(0, 0); |
489468fe SC |
941 | OSStatus err = wxMacDataBrowserControl::RemoveItems( (DataBrowserItemID)container, 0 , NULL , kDataBrowserItemNoProperty ); |
942 | verify_noerr( err ); | |
943 | } | |
944 | ||
945 | void wxMacDataItemBrowserControl::SetSelectedItem(wxMacDataItem* item , DataBrowserSetOption option) | |
946 | { | |
947 | verify_noerr(wxMacDataBrowserControl::SetSelectedItems( 1, (DataBrowserItemID*) &item, option )); | |
948 | } | |
949 | ||
950 | void wxMacDataItemBrowserControl::SetSelectedAllItems(DataBrowserSetOption option) | |
951 | { | |
952 | verify_noerr(wxMacDataBrowserControl::SetSelectedItems( 0 , NULL , option )); | |
953 | } | |
954 | ||
955 | void wxMacDataItemBrowserControl::SetSelectedItems(wxArrayMacDataItemPtr &itemArray , DataBrowserSetOption option) | |
956 | { | |
957 | unsigned int noItems = itemArray.GetCount(); | |
958 | DataBrowserItemID *items = new DataBrowserItemID[noItems]; | |
959 | for ( unsigned int i = 0; i < noItems; ++i ) | |
960 | items[i] = (DataBrowserItemID) itemArray[i]; | |
961 | ||
962 | verify_noerr(wxMacDataBrowserControl::SetSelectedItems( noItems, (DataBrowserItemID*) items, option )); | |
963 | delete [] items; | |
964 | } | |
965 | ||
966 | Boolean wxMacDataItemBrowserControl::IsItemSelected( const wxMacDataItem* item) const | |
967 | { | |
968 | return wxMacDataBrowserControl::IsItemSelected( (DataBrowserItemID) item); | |
969 | } | |
970 | ||
971 | void wxMacDataItemBrowserControl::RevealItem( wxMacDataItem* item, DataBrowserRevealOptions options) | |
972 | { | |
973 | verify_noerr(wxMacDataBrowserControl::RevealItem( (DataBrowserItemID) item, kDataBrowserNoItem , options ) ); | |
974 | } | |
975 | ||
976 | void wxMacDataItemBrowserControl::GetSelectionAnchor( wxMacDataItemPtr* first , wxMacDataItemPtr* last) const | |
977 | { | |
978 | verify_noerr(wxMacDataBrowserControl::GetSelectionAnchor( (DataBrowserItemID*) first, (DataBrowserItemID*) last) ); | |
979 | } | |
980 | ||
981 | wxClientDataType wxMacDataItemBrowserControl::GetClientDataType() const | |
982 | { | |
983 | return m_clientDataItemsType; | |
984 | } | |
985 | void wxMacDataItemBrowserControl::SetClientDataType(wxClientDataType clientDataItemsType) | |
986 | { | |
987 | m_clientDataItemsType = clientDataItemsType; | |
988 | } | |
989 | ||
489468fe SC |
990 | void wxMacDataItemBrowserControl::MacDelete( unsigned int n ) |
991 | { | |
992 | wxMacDataItem* item = (wxMacDataItem*)GetItemFromLine( n ); | |
993 | RemoveItem( wxMacDataBrowserRootContainer, item ); | |
994 | } | |
995 | ||
524c47aa | 996 | void wxMacDataItemBrowserControl::MacInsert( unsigned int n, wxMacDataItem* item) |
489468fe | 997 | { |
489468fe SC |
998 | if ( m_sortOrder == SortOrder_None ) |
999 | { | |
03647350 | 1000 | |
489468fe SC |
1001 | // increase the order of the lines to be shifted |
1002 | unsigned int lines = MacGetCount(); | |
1003 | for ( unsigned int i = n; i < lines; ++i) | |
1004 | { | |
1005 | wxMacDataItem* iter = (wxMacDataItem*) GetItemFromLine(i); | |
524c47aa | 1006 | iter->SetOrder( iter->GetOrder() + 1 ); |
489468fe | 1007 | } |
03647350 | 1008 | |
4ee5edc7 RR |
1009 | #if 0 |
1010 | // I don't understand what this code is supposed to do, RR. | |
1011 | SInt32 frontLineOrder = 0; | |
489468fe SC |
1012 | if ( n > 0 ) |
1013 | { | |
1014 | wxMacDataItem* iter = (wxMacDataItem*) GetItemFromLine(n-1); | |
4ee5edc7 | 1015 | frontLineOrder = iter->GetOrder()+1; |
489468fe | 1016 | } |
03647350 | 1017 | #else |
4ee5edc7 RR |
1018 | item->SetOrder( n ); |
1019 | #endif | |
489468fe SC |
1020 | } |
1021 | ||
4ee5edc7 | 1022 | AddItem( wxMacDataBrowserRootContainer, item ); |
489468fe SC |
1023 | } |
1024 | ||
489468fe SC |
1025 | void wxMacDataItemBrowserControl::MacClear() |
1026 | { | |
1027 | wxMacDataItemBrowserSelectionSuppressor suppressor(this); | |
1028 | RemoveAllItems(wxMacDataBrowserRootContainer); | |
1029 | } | |
1030 | ||
524c47aa | 1031 | unsigned int wxMacDataItemBrowserControl::MacGetCount() const |
489468fe | 1032 | { |
524c47aa | 1033 | return GetItemCount(wxMacDataBrowserRootContainer,false,kDataBrowserItemAnyState); |
489468fe SC |
1034 | } |
1035 | ||
489468fe SC |
1036 | #endif // wxUSE_GUI |
1037 |