1 /* Cockos SWELL (Simple/Small Win32 Emulation Layer for Linux/OSX)
2 Copyright (C) 2006 and later, Cockos, Inc.
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
21 #ifndef _SWELL_INTERNAL_H_
22 #define _SWELL_INTERNAL_H_
24 #include "../ptrlist.h"
26 class SWELL_ListView_Row
29 SWELL_ListView_Row() : m_param(0), m_imageidx(0), m_tmp(0) { }
30 ~SWELL_ListView_Row() { m_vals
.Empty(true,free
); }
31 WDL_PtrList
<char> m_vals
;
35 int m_tmp
; // Cocoa uses this temporarily, generic uses it as a mask (1= selected)
40 #ifdef SWELL_TARGET_OSX
43 // at some point we should enable this and use it in most SWELL APIs that call Cocoa code...
44 #define SWELL_BEGIN_TRY @try {
45 #define SWELL_END_TRY(x) } @catch (NSException *ex) { NSLog(@"SWELL exception in %s:%d :: %@:%@\n",__FILE__,__LINE__,[ex name], [ex reason]); x }
47 #define SWELL_BEGIN_TRY
48 #define SWELL_END_TRY(x)
51 #define __SWELL_PREFIX_CLASSNAME3(a,b) a##b
52 #define __SWELL_PREFIX_CLASSNAME2(a,b) __SWELL_PREFIX_CLASSNAME3(a,b)
53 #define __SWELL_PREFIX_CLASSNAME(cname) __SWELL_PREFIX_CLASSNAME2(SWELL_APP_PREFIX,cname)
55 // this defines interfaces to internal swell classes
56 #define SWELL_hwndChild __SWELL_PREFIX_CLASSNAME(_hwnd)
57 #define SWELL_hwndCarbonHost __SWELL_PREFIX_CLASSNAME(_hwndcarbonhost)
59 #define SWELL_ModelessWindow __SWELL_PREFIX_CLASSNAME(_modelesswindow)
60 #define SWELL_ModalDialog __SWELL_PREFIX_CLASSNAME(_dialogbox)
62 #define SWELL_TextField __SWELL_PREFIX_CLASSNAME(_textfield)
63 #define SWELL_ListView __SWELL_PREFIX_CLASSNAME(_listview)
64 #define SWELL_TreeView __SWELL_PREFIX_CLASSNAME(_treeview)
65 #define SWELL_TabView __SWELL_PREFIX_CLASSNAME(_tabview)
66 #define SWELL_ProgressView __SWELL_PREFIX_CLASSNAME(_progind)
67 #define SWELL_TextView __SWELL_PREFIX_CLASSNAME(_textview)
68 #define SWELL_BoxView __SWELL_PREFIX_CLASSNAME(_box)
69 #define SWELL_Button __SWELL_PREFIX_CLASSNAME(_button)
70 #define SWELL_PopUpButton __SWELL_PREFIX_CLASSNAME(_pub)
71 #define SWELL_ComboBox __SWELL_PREFIX_CLASSNAME(_cbox)
73 #define SWELL_StatusCell __SWELL_PREFIX_CLASSNAME(_statuscell)
74 #define SWELL_ListViewCell __SWELL_PREFIX_CLASSNAME(_listviewcell)
75 #define SWELL_ODListViewCell __SWELL_PREFIX_CLASSNAME(_ODlistviewcell)
76 #define SWELL_ODButtonCell __SWELL_PREFIX_CLASSNAME(_ODbuttoncell)
77 #define SWELL_ImageButtonCell __SWELL_PREFIX_CLASSNAME(_imgbuttoncell)
79 #define SWELL_FocusRectWnd __SWELL_PREFIX_CLASSNAME(_drawfocusrectwnd)
81 #define SWELL_DataHold __SWELL_PREFIX_CLASSNAME(_sdh)
82 #define SWELL_ThreadTmp __SWELL_PREFIX_CLASSNAME(_thread)
83 #define SWELL_PopupMenuRecv __SWELL_PREFIX_CLASSNAME(_trackpopupmenurecv)
85 #define SWELL_TimerFuncTarget __SWELL_PREFIX_CLASSNAME(_tft)
88 #define SWELL_Menu __SWELL_PREFIX_CLASSNAME(_menu)
93 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
94 typedef int NSInteger
;
95 typedef unsigned int NSUInteger
;
98 @interface SWELL_Menu
: NSMenu
102 - (id
)copyWithZone
:(NSZone
*)zone
;
105 @interface SWELL_DataHold
: NSObject
109 -(id
) initWithVal
:(void *)val
;
113 @interface SWELL_TimerFuncTarget
: NSObject
119 -(id
) initWithId
:(UINT_PTR
)tid hwnd
:(HWND
)h callback
:(TIMERPROC
)cb
;
120 -(void)SWELL_Timer
:(id
)sender
;
123 typedef struct OwnedWindowListRec
126 struct OwnedWindowListRec
*_next
;
127 } OwnedWindowListRec
;
129 typedef struct WindowPropRec
131 char *name
; // either <64k or a strdup'd name
133 struct WindowPropRec
*_next
;
138 @interface SWELL_TextField
: NSTextField
139 - (void)setNeedsDisplay
:(BOOL
)flag
;
140 - (void)setNeedsDisplayInRect
:(NSRect
)rect
;
143 @interface SWELL_TabView
: NSTabView
150 @interface SWELL_ProgressView
: NSProgressIndicator
156 @interface SWELL_ListViewCell
: NSTextFieldCell
161 @interface SWELL_StatusCell
: NSTextFieldCell
167 @interface SWELL_TreeView
: NSOutlineView
170 bool m_fakerightmouse
;
172 WDL_PtrList
<HTREEITEM__
> *m_items
;
174 NSMutableArray
*m_selColors
;
178 @interface SWELL_ListView
: NSTableView
180 int m_leftmousemovecnt
;
181 bool m_fakerightmouse
;
187 int m_start_item_clickmode
;
190 WDL_PtrList
<SWELL_ListView_Row
> *m_items
;
191 WDL_PtrList
<NSTableColumn
> *m_cols
;
192 WDL_PtrList
<HGDIOBJ__
> *m_status_imagelist
;
193 int m_status_imagelist_type
;
196 NSMutableArray
*m_selColors
;
198 // these are for the new yosemite mouse handling code
199 int m_last_plainly_clicked_item
, m_last_shift_clicked_item
;
202 -(LONG
)getSwellStyle
;
203 -(void)setSwellStyle
:(LONG
)st
;
204 -(int)getSwellNotificationMode
;
205 -(void)setSwellNotificationMode
:(int)lbMode
;
206 -(NSInteger
)columnAtPoint
:(NSPoint
)pt
;
207 -(int)getColumnPos
:(int)idx
; // get current position of column that was originally at idx
208 -(int)getColumnIdx
:(int)pos
; // get original index of column that is currently at position
211 @interface SWELL_ImageButtonCell
: NSButtonCell
214 - (NSRect
)drawTitle
:(NSAttributedString
*)title withFrame
:(NSRect
)frame inView
:(NSView
*)controlView
;
217 @interface SWELL_ODButtonCell
: NSButtonCell
222 @interface SWELL_ODListViewCell
: NSCell
224 SWELL_ListView
*m_ownctl
;
227 -(void)setOwnerControl
:(SWELL_ListView
*)t
;
228 -(void)setItemIdx
:(int)idx
;
231 @interface SWELL_Button
: NSButton
233 void *m_swellGDIimage
;
237 -(int)swellGetRadioFlags
;
238 -(void)swellSetRadioFlags
:(int)f
;
239 -(LONG_PTR
)getSwellUserData
;
240 -(void)setSwellUserData
:(LONG_PTR
)val
;
241 -(void)setSwellGDIImage
:(void *)par
;
242 -(void *)getSwellGDIImage
;
245 @interface SWELL_TextView
: NSTextView
250 -(void) setTag
:(NSInteger
)tag
;
253 @interface SWELL_BoxView
: NSBox
258 -(void) setTag
:(NSInteger
)tag
;
261 @interface SWELL_FocusRectWnd
: NSView
266 @interface SWELL_ThreadTmp
: NSObject
276 @interface SWELL_hwndChild
: NSView
// <NSDraggingSource>
279 int m_enabled
; // -1 if preventing focus
283 LONG_PTR m_extradata
[32];
285 int m_isfakerightmouse
;
286 char m_hashaddestroy
; // 2 = WM_DESTROY has finished completely
289 bool m_supports_ddrop
;
290 bool m_paintctx_used
;
292 WindowPropRec
*m_props
;
293 NSRect m_paintctx_rect
;
295 char m_titlestr
[1024];
296 unsigned int m_create_windowflags
;
297 NSOpenGLContext
*m_glctx
;
298 char m_isdirty
; // &1=self needs redraw, &2=children may need redraw
299 char m_allow_nomiddleman
;
300 id m_lastTopLevelOwner
; // save a copy of the owner, if any
301 id m_access_cacheptrs
[6];
303 - (id
)initChild
:(SWELL_DialogResourceIndex
*)resstate Parent
:(NSView
*)parent dlgProc
:(DLGPROC
)dlgproc Param
:(LPARAM
)par
;
304 - (LRESULT
)onSwellMessage
:(UINT
)msg p1
:(WPARAM
)wParam p2
:(LPARAM
)lParam
;
305 -(HANDLE
)swellExtendedDragOp
:(id
<NSDraggingInfo
>)sender retGlob
:(BOOL
)retG
;
306 - (const char *)onSwellGetText
;
307 -(void)onSwellSetText
:(const char *)buf
;
308 -(LONG
)swellGetExtendedStyle
;
309 -(void)swellSetExtendedStyle
:(LONG
)st
;
310 -(HMENU
)swellGetMenu
;
311 -(BOOL
)swellHasBeenDestroyed
;
312 -(void)swellSetMenu
:(HMENU
)menu
;
313 -(LONG_PTR
)getSwellUserData
;
314 -(void)setSwellUserData
:(LONG_PTR
)val
;
315 -(void)setOpaque
:(bool)isOpaque
;
316 -(LPARAM
)getSwellExtraData
:(int)idx
;
317 -(void)setSwellExtraData
:(int)idx value
:(LPARAM
)val
;
318 -(void)setSwellWindowProc
:(WNDPROC
)val
;
319 -(WNDPROC
)getSwellWindowProc
;
320 -(void)setSwellDialogProc
:(DLGPROC
)val
;
321 -(DLGPROC
)getSwellDialogProc
;
323 - (NSArray
*) namesOfPromisedFilesDroppedAtDestination
:(NSURL
*)droplocation
;
325 -(void) getSwellPaintInfo
:(PAINTSTRUCT
*)ps
;
326 - (int)swellCapChangeNotify
;
327 -(unsigned int)swellCreateWindowFlags
;
329 -(bool)swellCanPostMessage
;
330 -(int)swellEnumProps
:(PROPENUMPROCEX
)proc lp
:(LPARAM
)lParam
;
331 -(void *)swellGetProp
:(const char *)name wantRemove
:(BOOL
)rem
;
332 -(int)swellSetProp
:(const char *)name value
:(void *)val
;
333 -(NSOpenGLContext
*)swellGetGLContext
;
338 //- (NSArray *)accessibilityAttributeNames;
339 - (id
)accessibilityAttributeValue
:(NSString
*)attribute
;
340 //- (BOOL)accessibilityIsAttributeSettable:(NSString *)attribute;
341 //- (void)accessibilitySetValue:(id)value forAttribute:(NSString *)attribute;
343 // parameterized attribute methods
344 //- (NSArray *)accessibilityParameterizedAttributeNames;
345 //- (id)accessibilityAttributeValue:(NSString *)attribute forParameter:(id)parameter;
348 //- (NSArray *)accessibilityActionNames;
349 //- (NSString *)accessibilityActionDescription:(NSString *)action;
350 //- (void)accessibilityPerformAction:(NSString *)action;
352 // 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.
353 - (BOOL
)accessibilityIsIgnored
;
355 // 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.
356 - (id
)accessibilityHitTest
:(NSPoint
)point
;
358 // 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.
359 - (id
)accessibilityFocusedUIElement
;
366 @interface SWELL_ModelessWindow
: NSWindow
369 NSSize lastFrameSize
;
371 OwnedWindowListRec
*m_ownedwnds
;
374 bool m_wantInitialKeyWindowOnShow
;
376 - (id
)initModeless
:(SWELL_DialogResourceIndex
*)resstate Parent
:(HWND
)parent dlgProc
:(DLGPROC
)dlgproc Param
:(LPARAM
)par outputHwnd
:(HWND
*)hwndOut forceStyles
:(unsigned int)smask
;
377 - (id
)initModelessForChild
:(HWND
)child owner
:(HWND
)owner styleMask
:(unsigned int)smask
;
378 - (void)swellDestroyAllOwnedWindows
;
379 - (void)swellRemoveOwnedWindow
:(NSWindow
*)wnd
;
380 - (void)swellSetOwner
:(id
)owner
;
382 - (void **)swellGetOwnerWindowHead
;
383 -(void)swellDoDestroyStuff
;
384 -(void)swellResetOwnedWindowLevels
;
387 @interface SWELL_ModalDialog
: NSPanel
389 NSSize lastFrameSize
;
391 OwnedWindowListRec
*m_ownedwnds
;
397 - (id
)initDialogBox
:(SWELL_DialogResourceIndex
*)resstate Parent
:(HWND
)parent dlgProc
:(DLGPROC
)dlgproc Param
:(LPARAM
)par
;
398 - (void)swellDestroyAllOwnedWindows
;
399 - (void)swellRemoveOwnedWindow
:(NSWindow
*)wnd
;
400 - (void)swellSetOwner
:(id
)owner
;
402 - (void **)swellGetOwnerWindowHead
;
403 -(void)swellDoDestroyStuff
;
405 -(void)swellSetModalRetVal
:(int)r
;
406 -(int)swellGetModalRetVal
;
407 -(bool)swellHasModalRetVal
;
411 @interface SWELL_hwndCarbonHost
: SWELL_hwndChild
412 #ifdef MAC_OS_X_VERSION_10_7
419 bool m_whileresizing
;
420 void* m_wndhandler
; // won't compile if declared EventHandlerRef, wtf
421 void* m_ctlhandler
; // not sure if these need to be separate but cant hurt
424 -(BOOL
)swellIsCarbonHostingView
;
429 @interface SWELL_PopupMenuRecv
: NSObject
434 -(id
) initWithWnd
:(HWND
)wnd
;
435 -(void) onSwellCommand
:(id
)sender
;
437 - (void)menuNeedsUpdate
:(NSMenu
*)menu
;
441 @interface SWELL_PopUpButton
: NSPopUpButton
445 -(void)setSwellStyle
:(LONG
)style
;
446 -(LONG
)getSwellStyle
;
449 @interface SWELL_ComboBox
: NSComboBox
453 WDL_PtrList
<char> *m_ids
;
457 -(void)setSwellStyle
:(LONG
)style
;
458 -(LONG
)getSwellStyle
;
465 #ifndef __AVAILABILITYMACROS__
466 #error __AVAILABILITYMACROS__ not defined, include AvailabilityMacros.h!
469 // 10.4 doesn't support CoreText, so allow ATSUI if targetting 10.4 SDK
470 #ifndef MAC_OS_X_VERSION_10_5
472 #define SWELL_NO_CORETEXT
473 #define SWELL_ATSUI_TEXT_SUPPORT
476 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
478 #define SWELL_ATSUI_TEXT_SUPPORT
488 int additional_refcnt
; // refcnt of 0 means one owner (if >0, additional owners)
495 NSMutableDictionary
*__old_fontdict
; // unused, for ABI compat
497 // if ATSUI used, meaning IsCoreTextSupported() returned false
498 ATSUStyle atsui_font_style
;
503 struct HGDIOBJ__
*_next
;
505 // if using CoreText to draw text
512 void *ownedData
; // always use via SWELL_GetContextFrameBuffer() (which performs necessary alignment)
517 NSColor
*__old_nstextcol
; // provided for ABI compat, but unused
518 int cur_text_color_int
; // text color as int
522 float lastpos_x
,lastpos_y
;
524 void *GLgfxctx
; // optionally set
528 CGColorRef curtextcol
; // text color as CGColor
535 // some extras so we can call functions available only on some OSX versions without warnings, and with the correct types
536 #define SWELL_DelegateExtensions __SWELL_PREFIX_CLASSNAME(_delext)
537 #define SWELL_ViewExtensions __SWELL_PREFIX_CLASSNAME(_viewext)
538 #define SWELL_AppExtensions __SWELL_PREFIX_CLASSNAME(_appext)
539 #define SWELL_WindowExtensions __SWELL_PREFIX_CLASSNAME(_wndext)
540 #define SWELL_TableColumnExtensions __SWELL_PREFIX_CLASSNAME(_tcolext)
542 @interface SWELL_WindowExtensions
: NSWindow
543 -(void)setCollectionBehavior
:(NSUInteger
)a
;
545 @interface SWELL_ViewExtensions
: NSView
546 -(void)_recursiveDisplayRectIfNeededIgnoringOpacity
:(NSRect
)rect isVisibleRect
:(BOOL
)vr rectIsVisibleRectForView
:(NSView
*)v topView
:(NSView
*)v2
;
549 @interface SWELL_DelegateExtensions
: NSObject
550 -(bool)swellPostMessage
:(HWND
)dest msg
:(int)message wp
:(WPARAM
)wParam lp
:(LPARAM
)lParam
;
551 -(void)swellPostMessageClearQ
:(HWND
)dest
;
552 -(void)swellPostMessageTick
:(id
)sender
;
555 @interface SWELL_AppExtensions
: NSApplication
556 -(NSUInteger
)presentationOptions
;
557 -(void)setPresentationOptions
:(NSUInteger
)o
;
559 @interface SWELL_TableColumnExtensions
: NSTableColumn
561 -(void)setHidden
:(BOOL
)h
;
568 // compat when compiling targetting OSX but not in objectiveC mode
569 struct SWELL_DataHold
;
572 // 10.4 sdk just uses "float"
573 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
575 typedef double CGFloat
;
577 typedef float CGFloat
;
583 #elif defined(SWELL_TARGET_GDK)
586 #include <gdk/gdkkeysyms.h>
587 #include <gdk/gdkx.h>
593 #endif // end generic
599 bool FindItem(HTREEITEM it
, HTREEITEM__
**parOut
, int *idxOut
);
601 #ifdef SWELL_TARGET_OSX
602 SWELL_DataHold
*m_dh
;
604 int m_state
; // TVIS_EXPANDED, for ex
609 WDL_PtrList
<HTREEITEM__
> m_children
; // only used in tree mode
615 #ifndef SWELL_TARGET_OSX
617 #include "../wdlstring.h"
619 #ifdef SWELL_LICE_GDI
620 #include "../lice/lice.h"
622 #include "../assocarray.h"
624 LRESULT
SwellDialogDefaultWindowProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
627 #ifdef SWELL_TARGET_GDK
628 typedef GdkWindow
*SWELL_OSWINDOW
;
630 typedef void *SWELL_OSWINDOW
; // maps to the HWND__ itself on visible, non-GDK, top level windows
635 HWND__(HWND par
, int wID
=0, RECT
*wndr
=NULL
, const char *label
=NULL
, bool visible
=false, WNDPROC wndproc
=NULL
, DLGPROC dlgproc
=NULL
, HWND ownerWindow
=NULL
);
636 ~HWND__(); // DO NOT USE!!! We would make this private but it breaks PtrList using it on gcc.
638 // using this API prevents the HWND from being valid -- it'll still get its resources destroyed via DestroyWindow() though.
639 // DestroyWindow() does cleanup, then the final Release().
640 void Retain() { m_refcnt
++; }
641 void Release() { if (!--m_refcnt
) delete this; }
643 const char *m_classname
;
645 SWELL_OSWINDOW m_oswindow
;
647 WDL_FastString m_title
;
649 HWND__
*m_children
, *m_parent
, *m_next
, *m_prev
;
650 HWND__
*m_owner
, *m_owned_list
, *m_owned_next
, *m_owned_prev
;
651 HWND__
*m_focused_child
; // only valid if hwnd itself is in focus chain, and must be validated before accessed
654 int m_style
, m_exstyle
;
659 INT_PTR m_private_data
; // used by internal controls
662 char m_hashaddestroy
; // 1 in destroy, 2 full destroy
667 bool m_has_had_position
;
668 bool m_oswindow_fullscreen
;
671 int m_oswindow_private
; // private state for generic-gtk or whatever
676 WDL_StringKeyedArray
<void *> m_props
;
678 #ifdef SWELL_LICE_GDI
679 void *m_paintctx
; // temporarily set for calls to WM_PAINT
681 bool m_child_invalidated
; // if a child is invalidated
682 bool m_invalidated
; // set to true on direct invalidate. todo RECT instead?
684 LICE_IBitmap
*m_backingstore
; // if NULL, unused (probably only should use on top level windows, but support caching?)
690 HMENU__() { m_refcnt
=1; sel_vis
= -1; }
692 void Retain() { m_refcnt
++; }
693 void Release() { if (!--m_refcnt
) delete this; }
695 WDL_PtrList
<MENUITEMINFO
> items
;
696 int sel_vis
; // for mouse/keyboard nav
699 HMENU__
*Duplicate();
700 static void freeMenuItem(void *p
);
703 ~HMENU__() { items
.Empty(true,freeMenuItem
); }
710 int additional_refcnt
; // refcnt of 0 means one owner (if >0, additional owners)
717 struct HGDIOBJ__
*_next
;
719 void *typedata
; // font: FT_Face, bitmap: LICE_IBitmap
724 #ifdef SWELL_LICE_GDI
725 LICE_IBitmap
*surface
; // owned by context. can be (and usually is, if clipping is desired) LICE_SubBitmap
726 POINT surface_offs
; // offset drawing into surface by this amount
728 RECT dirty_rect
; // in surface coordinates, used for GetWindowDC()/GetDC()/etc
729 bool dirty_rect_valid
;
731 void *ownedData
; // for mem contexts, support a null rendering
738 int cur_text_color_int
; // text color as int
742 float lastpos_x
,lastpos_y
;
748 HWND
DialogBoxIsActive(void);
749 void DestroyPopupMenus(void);
750 HWND
ChildWindowFromPoint(HWND h
, POINT p
);
751 bool IsWindowEnabled(HWND hwnd
);
752 HWND
GetFocusIncludeMenus();
754 void SWELL_RunEvents();
756 bool swell_isOSwindowmenu(SWELL_OSWINDOW osw
);
758 bool swell_is_virtkey_char(int c
);
760 void swell_on_toplevel_raise(SWELL_OSWINDOW wnd
); // called by swell-generic-gdk when a window is focused
762 HWND
swell_oswindow_to_hwnd(SWELL_OSWINDOW w
);
763 void swell_oswindow_focus(HWND hwnd
);
764 void swell_oswindow_update_style(HWND hwnd
, LONG oldstyle
);
765 void swell_oswindow_update_enable(HWND hwnd
);
766 void swell_oswindow_update_text(HWND hwnd
);
767 void swell_oswindow_begin_resize(SWELL_OSWINDOW wnd
);
768 void swell_oswindow_resize(SWELL_OSWINDOW wnd
, int reposflag
, RECT f
);
769 void swell_oswindow_postresize(HWND hwnd
, RECT f
);
770 void swell_oswindow_invalidate(HWND hwnd
, const RECT
*r
);
771 void swell_oswindow_destroy(HWND hwnd
);
772 void swell_oswindow_manage(HWND hwnd
, bool wantfocus
);
773 void swell_oswindow_updatetoscreen(HWND hwnd
, RECT
*rect
);
774 void swell_dlg_destroyspare();
776 extern bool swell_is_likely_capslock
; // only used when processing dit events for a-zA-Z
777 extern const char *g_swell_appname
;
778 extern SWELL_OSWINDOW SWELL_focused_oswindow
; // top level window which has focus (might not map to a HWND__!)
779 extern HWND swell_captured_window
;
780 extern HWND SWELL_topwindows
; // front of list = most recently active
781 extern bool swell_app_is_inactive
;
784 void VALIDATE_HWND_LIST(HWND list
, HWND par
);
786 #define VALIDATE_HWND_LIST(list, par) do { } while (0)
792 HDC
SWELL_CreateGfxContext(void *);
798 #define TYPE_BITMAP 4
808 int (*SWELL_dllMain
)(HINSTANCE
, DWORD
,LPVOID
); //last parm=SWELLAPI_GetFunc
809 BOOL (*dllMain
)(HINSTANCE
, DWORD
, LPVOID
);
810 void *lastSymbolRequested
;
816 INTERNAL_OBJECT_START
= 0x1000001,
817 INTERNAL_OBJECT_THREAD
,
818 INTERNAL_OBJECT_EVENT
,
819 INTERNAL_OBJECT_FILE
,
820 INTERNAL_OBJECT_EXTERNALSOCKET
, // socket not owned by us
821 INTERNAL_OBJECT_SOCKETEVENT
,
822 INTERNAL_OBJECT_NSTASK
,
828 int type
; // INTERNAL_OBJECT_*
829 int count
; // reference count
830 } SWELL_InternalObjectHeader
;
834 SWELL_InternalObjectHeader hdr
;
835 DWORD (*threadProc
)(LPVOID
);
840 } SWELL_InternalObjectHeader_Thread
;
844 SWELL_InternalObjectHeader hdr
;
846 pthread_mutex_t mutex
;
852 } SWELL_InternalObjectHeader_Event
;
855 // used for both INTERNAL_OBJECT_EXTERNALSOCKET and INTERNAL_OBJECT_SOCKETEVENT.
856 // if EXTERNALSOCKET, socket[1] ignored and autoReset ignored.
859 SWELL_InternalObjectHeader hdr
;
862 } SWELL_InternalObjectHeader_SocketEvent
;
866 SWELL_InternalObjectHeader hdr
;
869 } SWELL_InternalObjectHeader_File
;
873 SWELL_InternalObjectHeader hdr
;
875 } SWELL_InternalObjectHeader_NSTask
;
878 bool IsRightClickEmulateEnabled();
880 #ifdef SWELL_INTERNAL_HTREEITEM_IMPL
882 HTREEITEM__::HTREEITEM__()
887 #ifdef SWELL_TARGET_OSX
888 m_dh
= [[SWELL_DataHold alloc
] initWithVal
:this];
893 HTREEITEM__::~HTREEITEM__()
896 m_children
.Empty(true);
897 #ifdef SWELL_TARGET_OSX
903 bool HTREEITEM__::FindItem(HTREEITEM it
, HTREEITEM__
**parOut
, int *idxOut
)
905 int a
=m_children
.Find((HTREEITEM__
*)it
);
908 if (parOut
) *parOut
=this;
909 if (idxOut
) *idxOut
=a
;
913 const int n
=m_children
.GetSize();
914 for (x
= 0; x
< n
; x
++)
916 if (m_children
.Get(x
)->FindItem(it
,parOut
,idxOut
)) return true;
923 #ifdef SWELL_INTERNAL_MERGESORT_IMPL
925 static int __listview_sortfunc(void *p1
, void *p2
, int (*compar
)(LPARAM val1
, LPARAM val2
, LPARAM userval
), LPARAM userval
)
927 SWELL_ListView_Row
*a
= *(SWELL_ListView_Row
**)p1
;
928 SWELL_ListView_Row
*b
= *(SWELL_ListView_Row
**)p2
;
929 return compar(a
->m_param
,b
->m_param
,userval
);
933 static void __listview_mergesort_internal(void *base
, size_t nmemb
, size_t size
,
934 int (*compar
)(LPARAM val1
, LPARAM val2
, LPARAM userval
),
941 if (nmemb
< 2) return;
946 b2
= b1
+ (n1
* size
);
950 __listview_mergesort_internal(b1
, n1
, size
, compar
, parm
, tmpspace
);
951 __listview_mergesort_internal(b2
, n2
, size
, compar
, parm
, tmpspace
);
958 if (__listview_sortfunc(b1
, b2
, compar
,parm
) > 0)
972 while (n1
> 0 && n2
> 0);
974 if (n1
> 0) memcpy(p
, b1
, n1
* size
);
975 memcpy(base
, tmpspace
, (nmemb
- n2
) * size
);
981 #ifndef SWELL_TARGET_OSX
983 #define SWELL_GENERIC_THEMESIZEDEFS(f,fd) \
984 f(default_font_size, 12) \
985 f(menubar_height, 17) \
986 f(menubar_font_size, 13) \
987 f(menubar_spacing_width, 8) \
988 f(menubar_margin_width, 6) \
989 f(scrollbar_width, 14) \
990 f(scrollbar_min_thumb_height, 4) \
991 f(combo_height, 20) \
994 #define SWELL_GENERIC_THEMEDEFS(f,fd) \
995 SWELL_GENERIC_THEMESIZEDEFS(f,fd) \
996 f(_3dface,RGB(192,192,192)) \
997 f(_3dshadow,RGB(96,96,96)) \
998 f(_3dhilight,RGB(224,224,224)) \
999 f(_3ddkshadow,RGB(48,48,48)) \
1000 fd(button_bg,RGB(192,192,192),_3dface) \
1001 f(button_text,RGB(0,0,0)) \
1002 f(button_text_disabled, RGB(128,128,128)) \
1003 fd(button_shadow, RGB(96,96,96), _3dshadow) \
1004 fd(button_hilight, RGB(224,224,224), _3dhilight) \
1005 f(checkbox_text,RGB(0,0,0)) \
1006 f(checkbox_text_disabled, RGB(128,128,128)) \
1007 f(checkbox_fg, RGB(0,0,0)) \
1008 f(checkbox_inter, RGB(192,192,192)) \
1009 f(checkbox_bg, RGB(255,255,255)) \
1010 f(scrollbar,RGB(32,32,32)) \
1011 f(scrollbar_fg, RGB(160,160,160)) \
1012 f(scrollbar_bg, RGB(224,224,224)) \
1013 f(edit_cursor,RGB(0,128,255)) \
1014 f(edit_bg,RGB(255,255,255)) \
1015 f(edit_bg_disabled,RGB(224,224,224)) \
1016 f(edit_text,RGB(0,0,0)) \
1017 f(edit_text_disabled, RGB(128,128,128)) \
1018 f(edit_bg_sel,RGB(128,192,255)) \
1019 f(edit_text_sel,RGB(255,255,255)) \
1020 fd(edit_hilight, RGB(224,224,224), _3dhilight) \
1021 fd(edit_shadow, RGB(96,96,96), _3dshadow) \
1022 f(info_bk,RGB(255,240,200)) \
1023 f(info_text,RGB(0,0,0)) \
1024 fd(menu_bg, RGB(192,192,192), _3dface) \
1025 fd(menu_shadow, RGB(96,96,96), _3dshadow) \
1026 fd(menu_hilight, RGB(224,224,224), _3dhilight) \
1027 fd(menu_text, RGB(0,0,0), button_text) \
1028 fd(menu_text_disabled, RGB(224,224,224), _3dhilight) \
1029 fd(menu_bg_sel, RGB(0,0,0), menu_text) \
1030 fd(menu_text_sel, RGB(224,224,224), menu_bg) \
1031 f(menu_scroll, RGB(64,64,64)) \
1032 fd(menu_scroll_arrow, RGB(96,96,96), _3dshadow) \
1033 fd(menu_submenu_arrow, RGB(96,96,96), _3dshadow) \
1034 fd(menubar_bg, RGB(192,192,192), menu_bg) \
1035 fd(menubar_text, RGB(0,0,0), menu_text) \
1036 fd(menubar_text_disabled, RGB(224,224,224), menu_text_disabled) \
1037 fd(menubar_bg_sel, RGB(0,0,0), menu_bg_sel) \
1038 fd(menubar_text_sel, RGB(224,224,224), menu_text_sel) \
1039 f(trackbar_track, RGB(224,224,224)) \
1040 f(trackbar_mark, RGB(96,96,96)) \
1041 f(trackbar_knob, RGB(48,48,48)) \
1042 f(progress,RGB(0,128,255)) \
1043 fd(label_text, RGB(0,0,0), button_text) \
1044 fd(label_text_disabled, RGB(128,128,128), button_text_disabled) \
1045 fd(combo_text, RGB(0,0,0), button_text) \
1046 fd(combo_text_disabled, RGB(128,128,128), button_text_disabled) \
1047 fd(combo_bg, RGB(192,192,192), _3dface) \
1048 f(combo_bg2, RGB(255,255,255)) \
1049 fd(combo_shadow, RGB(96,96,96), _3dshadow) \
1050 fd(combo_hilight, RGB(224,224,224), _3dhilight) \
1051 fd(combo_arrow, RGB(96,96,96), _3dshadow) \
1052 fd(combo_arrow_press, RGB(224,224,224), _3dhilight) \
1053 f(listview_bg, RGB(255,255,255)) \
1054 f(listview_bg_sel, RGB(128,128, 255)) \
1055 f(listview_text, RGB(0,0,0)) \
1056 fd(listview_text_sel, RGB(0,0,0), listview_text) \
1057 fd(listview_grid, RGB(224,224,224), _3dhilight) \
1058 f(listview_hdr_arrow,RGB(96,96,96)) \
1059 fd(listview_hdr_shadow, RGB(96,96,96), _3dshadow) \
1060 fd(listview_hdr_hilight, RGB(224,224,224), _3dhilight) \
1061 fd(listview_hdr_bg, RGB(192,192,192), _3dface) \
1062 fd(listview_hdr_text, RGB(0,0,0), button_text) \
1063 f(treeview_text,RGB( 0,0,0)) \
1064 f(treeview_bg, RGB(255,255,255)) \
1065 f(treeview_bg_sel, RGB(128,128,255)) \
1066 f(treeview_text_sel, RGB(0,0,0)) \
1067 f(treeview_arrow, RGB(96,96,96)) \
1068 fd(tab_shadow, RGB(96,96,96), _3dshadow) \
1069 fd(tab_hilight, RGB(224,224,224), _3dhilight) \
1070 fd(tab_text, RGB(0,0,0), button_text) \
1071 f(focusrect,RGB(255,0,0)) \
1072 f(group_text,RGB(0,0,0)) \
1073 fd(group_shadow, RGB(96,96,96), _3dshadow) \
1074 fd(group_hilight, RGB(224,224,224), _3dhilight) \
1075 f(focus_hilight, RGB(192,192,255)) \
1079 struct swell_colortheme
{
1080 #define __def_theme_ent(x,c) int x;
1081 #define __def_theme_ent_fb(x,c,fb) int x;
1082 SWELL_GENERIC_THEMEDEFS(__def_theme_ent
,__def_theme_ent_fb
)
1083 #undef __def_theme_ent
1084 #undef __def_theme_ent_fb
1087 #define SWELL_UI_SCALE(x) (((x)*g_swell_ui_scale)/256)
1088 extern int g_swell_ui_scale
;
1089 extern swell_colortheme g_swell_ctheme
;
1090 extern const char *g_swell_deffont_face
;