1 #ifndef _SWELL_INTERNAL_H_
2 #define _SWELL_INTERNAL_H_
4 #include "../ptrlist.h"
6 class SWELL_ListView_Row
9 SWELL_ListView_Row() : m_param(0), m_imageidx(0), m_tmp(0) { }
10 ~SWELL_ListView_Row() { m_vals
.Empty(true,free
); }
11 WDL_PtrList
<char> m_vals
;
15 int m_tmp
; // Cocoa uses this temporarily, generic uses it as a mask (1= selected)
19 #ifdef SWELL_TARGET_OSX
22 // at some point we should enable this and use it in most SWELL APIs that call Cocoa code...
23 #define SWELL_BEGIN_TRY @try {
24 #define SWELL_END_TRY(x) } @catch (NSException *ex) { NSLog(@"SWELL exception in %s:%d :: %@:%@\n",__FILE__,__LINE__,[ex name], [ex reason]); x }
26 #define SWELL_BEGIN_TRY
27 #define SWELL_END_TRY(x)
30 #define __SWELL_PREFIX_CLASSNAME3(a,b) a##b
31 #define __SWELL_PREFIX_CLASSNAME2(a,b) __SWELL_PREFIX_CLASSNAME3(a,b)
32 #define __SWELL_PREFIX_CLASSNAME(cname) __SWELL_PREFIX_CLASSNAME2(SWELL_APP_PREFIX,cname)
34 // this defines interfaces to internal swell classes
35 #define SWELL_hwndChild __SWELL_PREFIX_CLASSNAME(_hwnd)
36 #define SWELL_hwndCarbonHost __SWELL_PREFIX_CLASSNAME(_hwndcarbonhost)
38 #define SWELL_ModelessWindow __SWELL_PREFIX_CLASSNAME(_modelesswindow)
39 #define SWELL_ModalDialog __SWELL_PREFIX_CLASSNAME(_dialogbox)
41 #define SWELL_TextField __SWELL_PREFIX_CLASSNAME(_textfield)
42 #define SWELL_ListView __SWELL_PREFIX_CLASSNAME(_listview)
43 #define SWELL_TreeView __SWELL_PREFIX_CLASSNAME(_treeview)
44 #define SWELL_TabView __SWELL_PREFIX_CLASSNAME(_tabview)
45 #define SWELL_ProgressView __SWELL_PREFIX_CLASSNAME(_progind)
46 #define SWELL_TextView __SWELL_PREFIX_CLASSNAME(_textview)
47 #define SWELL_BoxView __SWELL_PREFIX_CLASSNAME(_box)
48 #define SWELL_Button __SWELL_PREFIX_CLASSNAME(_button)
49 #define SWELL_PopUpButton __SWELL_PREFIX_CLASSNAME(_pub)
50 #define SWELL_ComboBox __SWELL_PREFIX_CLASSNAME(_cbox)
52 #define SWELL_StatusCell __SWELL_PREFIX_CLASSNAME(_statuscell)
53 #define SWELL_ListViewCell __SWELL_PREFIX_CLASSNAME(_listviewcell)
54 #define SWELL_ODListViewCell __SWELL_PREFIX_CLASSNAME(_ODlistviewcell)
55 #define SWELL_ODButtonCell __SWELL_PREFIX_CLASSNAME(_ODbuttoncell)
57 #define SWELL_FocusRectWnd __SWELL_PREFIX_CLASSNAME(_drawfocusrectwnd)
59 #define SWELL_DataHold __SWELL_PREFIX_CLASSNAME(_sdh)
60 #define SWELL_ThreadTmp __SWELL_PREFIX_CLASSNAME(_thread)
61 #define SWELL_PopupMenuRecv __SWELL_PREFIX_CLASSNAME(_trackpopupmenurecv)
63 #define SWELL_TimerFuncTarget __SWELL_PREFIX_CLASSNAME(_tft)
66 #define SWELL_Menu __SWELL_PREFIX_CLASSNAME(_menu)
71 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
72 typedef int NSInteger
;
73 typedef unsigned int NSUInteger
;
76 @interface SWELL_Menu
: NSMenu
80 - (id
)copyWithZone
:(NSZone
*)zone
;
83 @interface SWELL_DataHold
: NSObject
87 -(id
) initWithVal
:(void *)val
;
91 @interface SWELL_TimerFuncTarget
: NSObject
97 -(id
) initWithId
:(UINT_PTR
)tid hwnd
:(HWND
)h callback
:(TIMERPROC
)cb
;
98 -(void)SWELL_Timer
:(id
)sender
;
101 typedef struct OwnedWindowListRec
104 struct OwnedWindowListRec
*_next
;
105 } OwnedWindowListRec
;
107 typedef struct WindowPropRec
109 char *name
; // either <64k or a strdup'd name
111 struct WindowPropRec
*_next
;
120 bool FindItem(HTREEITEM it
, HTREEITEM__
**parOut
, int *idxOut
);
122 SWELL_DataHold
*m_dh
;
126 WDL_PtrList
<HTREEITEM__
> m_children
; // only used in tree mode
132 @interface SWELL_TextField
: NSTextField
133 - (void)setNeedsDisplay
:(BOOL
)flag
;
134 - (void)setNeedsDisplayInRect
:(NSRect
)rect
;
137 @interface SWELL_TabView
: NSTabView
144 @interface SWELL_ProgressView
: NSProgressIndicator
150 @interface SWELL_ListViewCell
: NSTextFieldCell
155 @interface SWELL_StatusCell
: NSTextFieldCell
161 @interface SWELL_TreeView
: NSOutlineView
164 bool m_fakerightmouse
;
166 WDL_PtrList
<HTREEITEM__
> *m_items
;
168 NSMutableArray
*m_selColors
;
172 @interface SWELL_ListView
: NSTableView
174 int m_leftmousemovecnt
;
175 bool m_fakerightmouse
;
181 int m_start_item_clickmode
;
183 WDL_PtrList
<SWELL_ListView_Row
> *m_items
;
184 WDL_PtrList
<NSTableColumn
> *m_cols
;
185 WDL_PtrList
<HGDIOBJ__
> *m_status_imagelist
;
186 int m_status_imagelist_type
;
189 NSMutableArray
*m_selColors
;
191 -(LONG
)getSwellStyle
;
192 -(void)setSwellStyle
:(LONG
)st
;
193 -(int)getSwellNotificationMode
;
194 -(void)setSwellNotificationMode
:(int)lbMode
;
195 -(int)columnAtPoint
:(NSPoint
)pt
;
196 -(int)getColumnPos
:(int)idx
; // get current position of column that was originally at idx
197 -(int)getColumnIdx
:(int)pos
; // get original index of column that is currently at position
200 @interface SWELL_ODButtonCell
: NSButtonCell
205 @interface SWELL_ODListViewCell
: NSCell
207 SWELL_ListView
*m_ownctl
;
210 -(void)setOwnerControl
:(SWELL_ListView
*)t
;
211 -(void)setItemIdx
:(int)idx
;
214 @interface SWELL_Button
: NSButton
216 void *m_swellGDIimage
;
220 -(int)swellGetRadioFlags
;
221 -(void)swellSetRadioFlags
:(int)f
;
222 -(LONG_PTR
)getSwellUserData
;
223 -(void)setSwellUserData
:(LONG_PTR
)val
;
224 -(void)setSwellGDIImage
:(void *)par
;
225 -(void *)getSwellGDIImage
;
228 @interface SWELL_TextView
: NSTextView
233 -(void) setTag
:(NSInteger
)tag
;
236 @interface SWELL_BoxView
: NSBox
241 -(void) setTag
:(NSInteger
)tag
;
244 @interface SWELL_FocusRectWnd
: NSView
249 @interface SWELL_ThreadTmp
: NSObject
259 @interface SWELL_hwndChild
: NSView
// <NSDraggingSource>
266 LONG_PTR m_extradata
[32];
268 int m_isfakerightmouse
;
269 char m_hashaddestroy
; // 2 = WM_DESTROY has finished completely
272 bool m_supports_ddrop
;
273 bool m_paintctx_used
;
275 WindowPropRec
*m_props
;
276 NSRect m_paintctx_rect
;
278 char m_titlestr
[1024];
279 unsigned int m_create_windowflags
;
280 NSOpenGLContext
*m_glctx
;
281 char m_isdirty
; // &1=self needs redraw, &2=children may need redraw
282 id m_lastTopLevelOwner
; // save a copy of the owner, if any
283 id m_access_cacheptrs
[6];
285 - (id
)initChild
:(SWELL_DialogResourceIndex
*)resstate Parent
:(NSView
*)parent dlgProc
:(DLGPROC
)dlgproc Param
:(LPARAM
)par
;
286 - (LRESULT
)onSwellMessage
:(UINT
)msg p1
:(WPARAM
)wParam p2
:(LPARAM
)lParam
;
287 -(HANDLE
)swellExtendedDragOp
:(id
<NSDraggingInfo
>)sender retGlob
:(BOOL
)retG
;
288 - (const char *)onSwellGetText
;
289 -(void)onSwellSetText
:(const char *)buf
;
290 -(LONG
)swellGetExtendedStyle
;
291 -(void)swellSetExtendedStyle
:(LONG
)st
;
292 -(HMENU
)swellGetMenu
;
293 -(BOOL
)swellHasBeenDestroyed
;
294 -(void)swellSetMenu
:(HMENU
)menu
;
295 -(LONG_PTR
)getSwellUserData
;
296 -(void)setSwellUserData
:(LONG_PTR
)val
;
297 -(void)setOpaque
:(bool)isOpaque
;
298 -(LPARAM
)getSwellExtraData
:(int)idx
;
299 -(void)setSwellExtraData
:(int)idx value
:(LPARAM
)val
;
300 -(void)setSwellWindowProc
:(WNDPROC
)val
;
301 -(WNDPROC
)getSwellWindowProc
;
302 -(void)setSwellDialogProc
:(DLGPROC
)val
;
303 -(DLGPROC
)getSwellDialogProc
;
305 - (NSArray
*) namesOfPromisedFilesDroppedAtDestination
:(NSURL
*)droplocation
;
307 -(void) getSwellPaintInfo
:(PAINTSTRUCT
*)ps
;
308 - (int)swellCapChangeNotify
;
309 -(unsigned int)swellCreateWindowFlags
;
311 -(bool)swellCanPostMessage
;
312 -(int)swellEnumProps
:(PROPENUMPROCEX
)proc lp
:(LPARAM
)lParam
;
313 -(void *)swellGetProp
:(const char *)name wantRemove
:(BOOL
)rem
;
314 -(int)swellSetProp
:(const char *)name value
:(void *)val
;
320 //- (NSArray *)accessibilityAttributeNames;
321 - (id
)accessibilityAttributeValue
:(NSString
*)attribute
;
322 //- (BOOL)accessibilityIsAttributeSettable:(NSString *)attribute;
323 //- (void)accessibilitySetValue:(id)value forAttribute:(NSString *)attribute;
325 // parameterized attribute methods
326 //- (NSArray *)accessibilityParameterizedAttributeNames;
327 //- (id)accessibilityAttributeValue:(NSString *)attribute forParameter:(id)parameter;
330 //- (NSArray *)accessibilityActionNames;
331 //- (NSString *)accessibilityActionDescription:(NSString *)action;
332 //- (void)accessibilityPerformAction:(NSString *)action;
334 // Return YES if the UIElement doesn't show up to the outside world - i.e. its parent should return the UIElement's children as its own - cutting the UIElement out. E.g. NSControls are ignored when they are single-celled.
335 - (BOOL
)accessibilityIsIgnored
;
337 // Returns the deepest descendant of the UIElement hierarchy that contains the point. You can assume the point has already been determined to lie within the receiver. Override this method to do deeper hit testing within a UIElement - e.g. a NSMatrix would test its cells. The point is bottom-left relative screen coordinates.
338 - (id
)accessibilityHitTest
:(NSPoint
)point
;
340 // Returns the UI Element that has the focus. You can assume that the search for the focus has already been narrowed down to the reciever. Override this method to do a deeper search with a UIElement - e.g. a NSMatrix would determine if one of its cells has the focus.
341 - (id
)accessibilityFocusedUIElement
;
348 @interface SWELL_ModelessWindow
: NSWindow
351 NSSize lastFrameSize
;
353 OwnedWindowListRec
*m_ownedwnds
;
356 bool m_wantInitialKeyWindowOnShow
;
358 - (id
)initModeless
:(SWELL_DialogResourceIndex
*)resstate Parent
:(HWND
)parent dlgProc
:(DLGPROC
)dlgproc Param
:(LPARAM
)par outputHwnd
:(HWND
*)hwndOut forceStyles
:(unsigned int)smask
;
359 - (id
)initModelessForChild
:(HWND
)child owner
:(HWND
)owner styleMask
:(unsigned int)smask
;
360 - (void)swellDestroyAllOwnedWindows
;
361 - (void)swellRemoveOwnedWindow
:(NSWindow
*)wnd
;
362 - (void)swellSetOwner
:(id
)owner
;
364 - (void **)swellGetOwnerWindowHead
;
365 -(void)swellDoDestroyStuff
;
366 -(void)swellResetOwnedWindowLevels
;
369 @interface SWELL_ModalDialog
: NSPanel
371 NSSize lastFrameSize
;
373 OwnedWindowListRec
*m_ownedwnds
;
379 - (id
)initDialogBox
:(SWELL_DialogResourceIndex
*)resstate Parent
:(HWND
)parent dlgProc
:(DLGPROC
)dlgproc Param
:(LPARAM
)par
;
380 - (void)swellDestroyAllOwnedWindows
;
381 - (void)swellRemoveOwnedWindow
:(NSWindow
*)wnd
;
382 - (void)swellSetOwner
:(id
)owner
;
384 - (void **)swellGetOwnerWindowHead
;
385 -(void)swellDoDestroyStuff
;
387 -(void)swellSetModalRetVal
:(int)r
;
388 -(int)swellGetModalRetVal
;
389 -(bool)swellHasModalRetVal
;
393 @interface SWELL_hwndCarbonHost
: SWELL_hwndChild
394 #ifdef MAC_OS_X_VERSION_10_7
401 bool m_whileresizing
;
402 void* m_wndhandler
; // won't compile if declared EventHandlerRef, wtf
403 void* m_ctlhandler
; // not sure if these need to be separate but cant hurt
406 -(BOOL
)swellIsCarbonHostingView
;
411 @interface SWELL_PopupMenuRecv
: NSObject
416 -(id
) initWithWnd
:(HWND
)wnd
;
417 -(void) onSwellCommand
:(id
)sender
;
419 - (void)menuNeedsUpdate
:(NSMenu
*)menu
;
423 @interface SWELL_PopUpButton
: NSPopUpButton
427 -(void)setSwellStyle
:(LONG
)style
;
428 -(LONG
)getSwellStyle
;
431 @interface SWELL_ComboBox
: NSComboBox
435 WDL_PtrList
<char> *m_ids
;
439 -(void)setSwellStyle
:(LONG
)style
;
440 -(LONG
)getSwellStyle
;
447 #ifndef __AVAILABILITYMACROS__
448 #error __AVAILABILITYMACROS__ not defined, include AvailabilityMacros.h!
451 // 10.4 doesn't support CoreText, so allow ATSUI if targetting 10.4 SDK
452 #ifndef MAC_OS_X_VERSION_10_5
454 #define SWELL_NO_CORETEXT
455 #define SWELL_ATSUI_TEXT_SUPPORT
458 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
460 #define SWELL_ATSUI_TEXT_SUPPORT
470 int additional_refcnt
; // refcnt of 0 means one owner (if >0, additional owners)
477 NSMutableDictionary
*__old_fontdict
; // unused, for ABI compat
479 // if ATSUI used, meaning IsCoreTextSupported() returned false
480 ATSUStyle atsui_font_style
;
485 struct HGDIOBJ__
*_next
;
487 // if using CoreText to draw text
494 void *ownedData
; // always use via SWELL_GetContextFrameBuffer() (which performs necessary alignment)
499 NSColor
*__old_nstextcol
; // provided for ABI compat, but unused
500 int cur_text_color_int
; // text color as int
504 float lastpos_x
,lastpos_y
;
506 void *GLgfxctx
; // optionally set
510 CGColorRef curtextcol
; // text color as CGColor
517 // some extras so we can call functions available only on some OSX versions without warnings, and with the correct types
518 #define SWELL_DelegateExtensions __SWELL_PREFIX_CLASSNAME(_delext)
519 #define SWELL_ViewExtensions __SWELL_PREFIX_CLASSNAME(_viewext)
520 #define SWELL_AppExtensions __SWELL_PREFIX_CLASSNAME(_appext)
521 #define SWELL_WindowExtensions __SWELL_PREFIX_CLASSNAME(_wndext)
522 #define SWELL_TableColumnExtensions __SWELL_PREFIX_CLASSNAME(_tcolext)
524 @interface SWELL_WindowExtensions
: NSWindow
525 -(void)setCollectionBehavior
:(NSUInteger
)a
;
527 @interface SWELL_ViewExtensions
: NSView
528 -(void)_recursiveDisplayRectIfNeededIgnoringOpacity
:(NSRect
)rect isVisibleRect
:(BOOL
)vr rectIsVisibleRectForView
:(NSView
*)v topView
:(NSView
*)v2
;
531 @interface SWELL_DelegateExtensions
: NSObject
532 -(bool)swellPostMessage
:(HWND
)dest msg
:(int)message wp
:(WPARAM
)wParam lp
:(LPARAM
)lParam
;
533 -(void)swellPostMessageClearQ
:(HWND
)dest
;
534 -(void)swellPostMessageTick
:(id
)sender
;
537 @interface SWELL_AppExtensions
: NSApplication
538 -(NSUInteger
)presentationOptions
;
539 -(void)setPresentationOptions
:(NSUInteger
)o
;
541 @interface SWELL_TableColumnExtensions
: NSTableColumn
543 -(void)setHidden
:(BOOL
)h
;
552 // 10.4 sdk just uses "float"
553 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
555 typedef double CGFloat
;
557 typedef float CGFloat
;
563 #elif defined(SWELL_TARGET_GDK)
566 #include <gdk/gdkkeysyms.h>
571 #endif // end generic
573 #ifndef SWELL_TARGET_OSX
575 #ifdef SWELL_LICE_GDI
576 #include "../lice/lice.h"
578 #include "../assocarray.h"
580 LRESULT
SwellDialogDefaultWindowProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
584 HWND__(HWND par
, int wID
=0, RECT
*wndr
=NULL
, const char *label
=NULL
, bool visible
=false, WNDPROC wndproc
=NULL
, DLGPROC dlgproc
=NULL
);
585 ~HWND__(); // DO NOT USE!!! We would make this private but it breaks PtrList using it on gcc.
587 // using this API prevents the HWND from being valid -- it'll still get its resources destroyed via DestroyWindow() though.
588 // DestroyWindow() does cleanup, then the final Release().
589 void Retain() { m_refcnt
++; }
590 void Release() { if (!--m_refcnt
) delete this; }
595 const char *m_classname
;
598 #ifdef SWELL_TARGET_GDK
599 GdkWindow
*m_oswindow
;
603 HWND__
*m_children
, *m_parent
, *m_next
, *m_prev
;
604 HWND__
*m_owner
, *m_owned
;
607 int m_style
, m_exstyle
;
612 INT_PTR m_private_data
; // used by internal controls
615 bool m_hashaddestroy
;
623 WDL_StringKeyedArray
<void *> m_props
;
625 #ifdef SWELL_LICE_GDI
626 void *m_paintctx
; // temporarily set for calls to WM_PAINT
629 bool m_child_invalidated
; // if a child is invalidated
630 bool m_invalidated
; // set to true on direct invalidate. todo RECT instead?
632 LICE_IBitmap
*m_backingstore
; // if NULL, unused (probably only should use on top level windows, but support caching?)
639 ~HMENU__() { items
.Empty(true,freeMenuItem
); }
641 WDL_PtrList
<MENUITEMINFO
> items
;
643 HMENU__
*Duplicate();
644 static void freeMenuItem(void *p
);
652 int additional_refcnt
; // refcnt of 0 means one owner (if >0, additional owners)
657 struct HGDIOBJ__
*_next
;
659 #ifdef SWELL_FREETYPE
660 void *fontface
; // FT_Face
667 #ifdef SWELL_LICE_GDI
668 LICE_IBitmap
*surface
; // owned by context. can be (and usually is, if clipping is desired) LICE_SubBitmap
669 POINT surface_offs
; // offset drawing into surface by this amount
671 RECT dirty_rect
; // in surface coordinates, used for GetWindowDC()/GetDC()/etc
672 bool dirty_rect_valid
;
674 void *ownedData
; // for mem contexts, support a null rendering
681 int cur_text_color_int
; // text color as int
685 float lastpos_x
,lastpos_y
;
693 HDC
SWELL_CreateGfxContext(void *);
699 #define TYPE_BITMAP 4
707 int (*SWELL_dllMain
)(HINSTANCE
, DWORD
,LPVOID
); //last parm=SWELLAPI_GetFunc
708 BOOL (*dllMain
)(HINSTANCE
, DWORD
, LPVOID
);
709 void *lastSymbolRequested
;
715 INTERNAL_OBJECT_START
= 0x1000001,
716 INTERNAL_OBJECT_THREAD
,
717 INTERNAL_OBJECT_EVENT
,
718 INTERNAL_OBJECT_FILE
,
719 INTERNAL_OBJECT_EXTERNALSOCKET
, // socket not owned by us
720 INTERNAL_OBJECT_SOCKETEVENT
,
721 INTERNAL_OBJECT_NSTASK
,
727 int type
; // INTERNAL_OBJECT_*
728 int count
; // reference count
729 } SWELL_InternalObjectHeader
;
733 SWELL_InternalObjectHeader hdr
;
734 DWORD (*threadProc
)(LPVOID
);
739 } SWELL_InternalObjectHeader_Thread
;
743 SWELL_InternalObjectHeader hdr
;
745 pthread_mutex_t mutex
;
751 } SWELL_InternalObjectHeader_Event
;
754 // used for both INTERNAL_OBJECT_EXTERNALSOCKET and INTERNAL_OBJECT_SOCKETEVENT.
755 // if EXTERNALSOCKET, socket[1] ignored and autoReset ignored.
758 SWELL_InternalObjectHeader hdr
;
761 } SWELL_InternalObjectHeader_SocketEvent
;
765 SWELL_InternalObjectHeader hdr
;
768 } SWELL_InternalObjectHeader_File
;
772 SWELL_InternalObjectHeader hdr
;
774 } SWELL_InternalObjectHeader_NSTask
;
777 bool IsRightClickEmulateEnabled();