Merge branch 'master' of http://www-dev.cockos.com/wdl/WDL into updatewdl
[wdl/wdl-ol.git] / WDL / swell / swell-functions.h
blobd9c4f9e50ddba30696556859eabf19fee2949521
1 /* Cockos SWELL (Simple/Small Win32 Emulation Layer for L****)
2 Copyright (C) 2006-2010, 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 SWELL provides _EXTREMELY BASIC_ win32 wrapping for OS X and maybe other platforms.
25 #ifndef _WDL_SWELL_H_API_DEFINED_
26 #define _WDL_SWELL_H_API_DEFINED_
28 ////////////////////////////////////////////
29 /////////// FUNCTIONS
30 ////////////////////////////////////////////
32 #ifndef SWELL_API_DEFINE
35 #ifdef SWELL_PROVIDED_BY_APP
36 #ifdef __cplusplus
37 #define SWELL_API_DEFINE(ret,func,parms) extern "C" ret (*func)parms;
38 #else
39 #define SWELL_API_DEFINE(ret,func,parms) extern ret (*func)parms;
40 #endif
41 #else
42 #define SWELL_API_DEFINE(ret,func,parms) ret func parms ;
43 #endif
44 #endif
46 // when adding APIs, add it using:
47 // SWELL_API_DEFINE(void, function_name, (int parm, int parm2))
48 // rather than:
49 // void function_name(int parm, int parm2);
51 /*
52 ** lstrcpyn: this is provided because strncpy is braindead (filling with zeroes, and not
53 ** NULL terminating if the destination buffer is too short? ASKING for trouble..)
54 ** lstrpcyn always null terminates the string and doesnt fill anything extra.
56 SWELL_API_DEFINE(char *, lstrcpyn, (char *dest, const char *src, int l))
60 ** MulDiv(): (parm1*parm2)/parm3
61 ** Implemented using long longs.
63 SWELL_API_DEFINE(int, MulDiv, (int, int, int))
67 ** Sleep() sleeps for specified milliseconds. This maps to usleep, with a ms value of 0
68 ** usleeping for 100 microseconds.
70 SWELL_API_DEFINE(void, Sleep,(int ms))
73 ** GetTickCount() and timeGetTime() give you ms level timings via gettimeofday().
74 **
75 ** NOTE: This doesn't map to time since system start (like in win32), so a wrap around
76 ** is slightly more likely (i.e. even if you booted your system an hour ago it could happen).
78 SWELL_API_DEFINE(DWORD, GetTickCount,())
79 #ifndef timeGetTime
80 #define timeGetTime() GetTickCount()
81 #endif
84 ** GetFileTime() gets the file time of a file (FILE *), and converts it to the Windows time.
86 ** NOTE: while it returns a 64 bit time value, it is only accurate to the second since thats
87 ** what fstat() returns. Takes an int filedes rather than a HANDLE.
89 SWELL_API_DEFINE(BOOL, GetFileTime,(int filedes, FILETIME *lpCreationTime, FILETIME *lpLastAccessTime, FILETIME *lpLastWriteTime))
92 ** *PrivateProfileString/Int():
93 ** These are mostly thread-safe, mostly inter-process safe, and mostly module safe
94 ** (i.e. writes from other modules) should be synchronized).
96 ** NOTES:
97 ** the filename used MUST be the full filename, unlike on Windows where files without paths go to
98 ** C:/Windows, here they will be opened in the current directory.
100 ** It's probably not a good idea to push your luck with simultaneous writes from multiple
101 ** modules in different threads/processes, but in theory it should work.
103 SWELL_API_DEFINE(BOOL, WritePrivateProfileString, (const char *appname, const char *keyname, const char *val, const char *fn))
104 SWELL_API_DEFINE(DWORD, GetPrivateProfileString, (const char *appname, const char *keyname, const char *def, char *ret, int retsize, const char *fn))
105 SWELL_API_DEFINE(int, GetPrivateProfileInt,(const char *appname, const char *keyname, int def, const char *fn))
106 SWELL_API_DEFINE(BOOL, GetPrivateProfileStruct,(const char *appname, const char *keyname, void *buf, int bufsz, const char *fn))
107 SWELL_API_DEFINE(BOOL, WritePrivateProfileStruct,(const char *appname, const char *keyname, const void *buf, int bufsz, const char *fn))
108 SWELL_API_DEFINE(BOOL, WritePrivateProfileSection, (const char *appname, const char *strings, const char *fn))
109 SWELL_API_DEFINE(DWORD, GetPrivateProfileSection, (const char *appname, char *strout, DWORD strout_len, const char *fn))
112 ** GetModuleFileName()
113 ** Can pass NULL (exe filename) or a hInstance from DllMain or LoadLibrary
115 SWELL_API_DEFINE(DWORD, GetModuleFileName,(HINSTANCE hInst, char *fn, DWORD nSize))
117 #ifdef SWELL_TARGET_OSX
119 ** SWELL_CStringToCFString(): Creates a CFString/NSString * from a C string. This is mostly
120 ** used internally but you may wish to use it as well (though none of the SWELL APIs take
121 ** CFString/NSString.
123 SWELL_API_DEFINE(void *,SWELL_CStringToCFString,(const char *str))
124 SWELL_API_DEFINE(void, SWELL_CFStringToCString, (const void *str, char *buf, int buflen))
125 #endif
129 ** PtInRect() should hopefully function just like it's win32 equivelent.
130 ** there is #define funkiness because some Mac system headers define PtInRect as well.
132 #ifdef PtInRect
133 #undef PtInRect
134 #endif
135 #define PtInRect(r,p) SWELL_PtInRect(r,p)
136 SWELL_API_DEFINE(BOOL, SWELL_PtInRect,(const RECT *r, POINT p))
139 ** ShellExecute():
140 ** NOTE: currently action is ignored, and it only works on content1 being an app, an URL beginning with http://,
141 ** "notepad.exe" (content2=file to open), or "explorer.exe" (content2=folder to open, or content2=/select,"file_to_reveal_if_10.6+")
142 ** TODO: finish implementation
144 SWELL_API_DEFINE(BOOL, ShellExecute,(HWND hwndDlg, const char *action, const char *content1, const char *content2, const char *content3, int blah))
147 ** MessageBox().
149 SWELL_API_DEFINE(int, MessageBox,(HWND hwndParent, const char *text, const char *caption, int type))
153 ** GetOpenFileName() / GetSaveFileName()
154 ** These are a different API because we didnt feel like reeimplimenting the full API.
155 ** Extlist is something similar you'd pass getopenfilename,
156 ** initialdir and initialfile are optional (and NULL means not set).
159 // free() the result of this, if non-NULL.
160 // if allowmul is set, the multiple files are specified the same way GetOpenFileName() returns.
161 SWELL_API_DEFINE(char *,BrowseForFiles,(const char *text, const char *initialdir,
162 const char *initialfile, bool allowmul, const char *extlist))
164 // returns TRUE if file was chosen.
165 SWELL_API_DEFINE(bool, BrowseForSaveFile,(const char *text, const char *initialdir, const char *initialfile, const char *extlist,
166 char *fn, int fnsize))
168 // returns TRUE if path was chosen.
169 SWELL_API_DEFINE(bool, BrowseForDirectory,(const char *text, const char *initialdir, char *fn, int fnsize))
171 // can use this before calling BrowseForFiles or BrowseForSaveFile to use a template dialog
172 SWELL_API_DEFINE(void,BrowseFile_SetTemplate,(const char *dlgid, DLGPROC dlgProc, struct SWELL_DialogResourceIndex *reshead))
175 // Note that window functions are generally NOT threadsafe.
176 // all of these treat HWND as NSView and/or NSWindow (usually smartish about it)
180 ** GetDlgItem(hwnd,0) returns hwnd if hwnd is a NSView, or the contentview if hwnd is a NSWindow.
181 ** Note that this GetDlgItem will actually search a view hierarchy for the tagged view,
182 ** unlike Win32 where it will only look at immediate children.
184 SWELL_API_DEFINE(HWND, GetDlgItem,(HWND, int))
187 ** ShowWindow() works for hwnds that represent NSView and/or NSWindow.
188 ** SW_SHOW, SW_SHOWNA, and SW_HIDE are defined, and some of the other common uses
189 ** alias to these.
191 SWELL_API_DEFINE(void, ShowWindow,(HWND, int))
195 ** DestroyWindow() works for both a NSWindow or NSView.
196 ** Note that if the window is a fake window with a procedure
197 ** (created via CreateDialog or DialogBox below) then WM_DESTROY
198 ** will be called immediately, though the window/view may be freed
199 ** sometime later via the autorelease pool.
201 SWELL_API_DEFINE(void, DestroyWindow,(HWND hwnd))
203 SWELL_API_DEFINE(BOOL, SWELL_GetGestureInfo, (LPARAM lParam, GESTUREINFO* gi))
205 SWELL_API_DEFINE(void, SWELL_HideApp,())
208 ** These should all work like their Win32 versions, though if idx=0 it gets/sets the
209 ** value for the window. Note that SetDlgItemText() for an edit control does NOT send
210 ** a WM_COMMAND notification like on win32, so you will have to do this yourself.
212 SWELL_API_DEFINE(BOOL, SetDlgItemText,(HWND, int idx, const char *text))
213 SWELL_API_DEFINE(BOOL, SetDlgItemInt,(HWND, int idx, int val, int issigned))
214 SWELL_API_DEFINE(int, GetDlgItemInt,(HWND, int idx, BOOL *translated, int issigned))
215 SWELL_API_DEFINE(BOOL, GetDlgItemText,(HWND, int idx, char *text, int textlen))
217 #ifndef GetWindowText
218 #define GetWindowText(hwnd,text,textlen) GetDlgItemText(hwnd,0,text,textlen)
219 #define SetWindowText(hwnd,text) SetDlgItemText(hwnd,0,text)
220 #endif
223 SWELL_API_DEFINE(void, CheckDlgButton,(HWND hwnd, int idx, int check))
224 SWELL_API_DEFINE(int, IsDlgButtonChecked,(HWND hwnd, int idx))
225 SWELL_API_DEFINE(void, EnableWindow,(HWND hwnd, int enable))
226 SWELL_API_DEFINE(void, SetFocus,(HWND hwnd)) // these take NSWindow/NSView, and return NSView *
227 SWELL_API_DEFINE(HWND, GetFocus,())
228 SWELL_API_DEFINE(void, SetForegroundWindow,(HWND hwnd)) // these take NSWindow/NSView, and return NSView *
229 SWELL_API_DEFINE(HWND, GetForegroundWindow,())
230 #ifndef GetActiveWindow
231 #define GetActiveWindow() GetForegroundWindow()
232 #endif
233 #ifndef SetActiveWindow
234 #define SetActiveWindow(x) SetForegroundWindow(x)
235 #endif
238 ** GetCapture/SetCapture/ReleaseCapture are completely faked, with just an internal state.
239 ** Mouse click+drag automatically captures the focus sending mouseDrag events in OSX, so
240 ** these are as a porting aid.
242 ** Updated: they actually send WM_CAPTURECHANGED messages now, if the window supports
243 ** onSwellMessage:p1:p2: and swellCapChangeNotify (and swellCapChangeNotify returns YES).
245 ** Note that any HWND that returns YES to swellCapChangeNotify should do the following on
246 ** destroy or dealloc: if (GetCapture()==(HWND)self) ReleaseCapture(); Failure to do so
247 ** can cause a dealloc'd window to get messages sent to it.
249 SWELL_API_DEFINE(HWND, SetCapture,(HWND hwnd))
250 SWELL_API_DEFINE(HWND, GetCapture,())
251 SWELL_API_DEFINE(void, ReleaseCapture,())
254 ** IsChild()
255 ** Notes: hwndChild must be a NSView (if not then false is returned)
256 ** hwndParent can be a NSWindow or NSView.
257 ** NSWindow level ownership/children are not detected.
259 SWELL_API_DEFINE(int, IsChild,(HWND hwndParent, HWND hwndChild))
263 ** GetParent()
264 ** Notes: if hwnd is a NSView, then gets the parent view (or NSWindow
265 ** if the parent view is the window's contentview). If hwnd is a NSWindow,
266 ** then GetParent returns the owner window, if any. Note that the owner
267 ** window system is not part of OSX, but rather part of SWELL.
269 SWELL_API_DEFINE(HWND, GetParent,(HWND hwnd))
272 ** SetParent()
273 ** Notes: hwnd must be a NSView, newPar can be either NSView or NSWindow.
275 SWELL_API_DEFINE(HWND, SetParent,(HWND hwnd, HWND newPar))
278 ** GetWindow()
279 ** Most of the standard GW_CHILD etc work. Does not do anything to prevent you from
280 ** getting into infinite loops if you go changing the order on the fly etc.
282 SWELL_API_DEFINE(HWND, GetWindow,(HWND hwnd, int what))
284 SWELL_API_DEFINE(BOOL, EnumWindows, (BOOL (*proc)(HWND, LPARAM), LPARAM lp))
286 SWELL_API_DEFINE(HWND,FindWindowEx,(HWND par, HWND lastw, const char *classname, const char *title))
290 ** Notes: common win32 code like this:
291 ** RECT r;
292 ** GetWindowRect(hwnd,&r);
293 ** ScreenToClient(otherhwnd,(LPPOINT)&r);
294 ** ScreenToClient(otherhwnd,((LPPOINT)&r)+1);
295 ** does work, however be aware that in certain instances r.bottom may be less
296 ** than r.top, due to flipped coordinates. SetWindowPos and other functions
297 ** handle negative heights gracefully, and you should too.
299 ** Note: GetWindowContentViewRect gets the rectangle of the content view (pre-NCCALCSIZE etc)
301 SWELL_API_DEFINE(void, ClientToScreen,(HWND hwnd, POINT *p))
302 SWELL_API_DEFINE(void, ScreenToClient,(HWND hwnd, POINT *p))
303 SWELL_API_DEFINE(bool, GetWindowRect,(HWND hwnd, RECT *r))
304 SWELL_API_DEFINE(void, GetWindowContentViewRect, (HWND hwnd, RECT *r))
305 SWELL_API_DEFINE(void, GetClientRect,(HWND hwnd, RECT *r))
306 SWELL_API_DEFINE(HWND, WindowFromPoint,(POINT p))
307 SWELL_API_DEFINE(BOOL, WinOffsetRect, (LPRECT lprc, int dx, int dy))
308 SWELL_API_DEFINE(BOOL, WinSetRect, (LPRECT lprc, int xLeft, int yTop, int xRight, int yBottom))
309 SWELL_API_DEFINE(void,WinUnionRect,(RECT *out, const RECT *in1, const RECT *in2))
310 SWELL_API_DEFINE(int,WinIntersectRect,(RECT *out, const RECT *in1, const RECT *in2))
314 ** SetWindowPos():
315 ** Notes: Z ordering stuff is ignored, as are most flags.
316 ** SWP_NOMOVE and SWP_NOSIZE are the only flags used.
318 SWELL_API_DEFINE(void, SetWindowPos,(HWND hwnd, HWND unused, int x, int y, int cx, int cy, int flags))
320 SWELL_API_DEFINE(int, SWELL_SetWindowLevel, (HWND hwnd, int newlevel))
323 ** InvalidateRect()
324 ** Notes: eraseBk is ignored, probably not threadsafe! hwnd can be NSWindow or NSView
326 SWELL_API_DEFINE(BOOL,InvalidateRect,(HWND hwnd, const RECT *r, int eraseBk))
329 ** UpdateWindow()
330 ** Notes: not currently implemented but provided here in case someday it is necessary
332 SWELL_API_DEFINE(void,UpdateWindow,(HWND hwnd))
336 ** GetWindowLong()/SetWindowLong()
338 ** GWL_ID is supported for all objects that support the 'tag'/'setTag' methods,
339 ** which would be controls and SWELL created windows/dialogs/controls.
341 ** GWL_USERDATA is supported by SWELL created windows/dialogs/controls, using
342 ** (int)getSwellUserData and setSwellUserData:(int).
344 ** GWL_WNDPROC is supported by SWELL created windows/dialogs/controls, using
345 ** (int)getSwellWindowProc and setSwellWindowProc:(int).
347 ** DWL_DLGPROC is supported by SWELL created dialogs now (it might work in windows/controls but isnt recommended)
349 ** GWL_STYLE is only supported for NSButton. Currently the only flags supported are
350 ** BS_AUTO3STATE (BS_AUTOCHECKBOX is returned but also ignored).
352 ** indices of >= 0 and < 128 (32 integers) are supported for SWELL created
353 ** windows/dialogs/controls, via (int)getSwellExtraData:(int)idx and
354 ** setSwellExtraData:(int)idx value:(int)val .
356 SWELL_API_DEFINE(LONG_PTR, GetWindowLong,(HWND hwnd, int idx))
357 SWELL_API_DEFINE(LONG_PTR, SetWindowLong,(HWND hwnd, int idx, LONG_PTR val))
360 SWELL_API_DEFINE(BOOL, ScrollWindow, (HWND hwnd, int xamt, int yamt, const RECT *lpRect, const RECT *lpClipRect))
363 ** GetProp() SetProp() RemoveProp() EnumPropsEx()
364 ** These should work like in win32. Free your props otherwise they will leak.
365 ** Restriction on what you can do in the PROPENUMPROCEX is similar to win32
366 ** (you can remove only the called prop, and can't add props within it).
367 ** if the prop name is < (void *)65536 then it is treated as a short identifier.
369 SWELL_API_DEFINE(int, EnumPropsEx,(HWND, PROPENUMPROCEX, LPARAM))
370 SWELL_API_DEFINE(HANDLE, GetProp, (HWND, const char *))
371 SWELL_API_DEFINE(BOOL, SetProp, (HWND, const char *, HANDLE))
372 SWELL_API_DEFINE(HANDLE, RemoveProp, (HWND, const char *))
376 ** IsWindowVisible()
377 ** if hwnd is a NSView, returns !isHiddenOrHasHiddenAncestor
378 ** if hwnd is a NSWindow returns isVisible
379 ** otherwise returns TRUE if non-null hwnd
381 SWELL_API_DEFINE(bool, IsWindowVisible,(HWND hwnd))
383 SWELL_API_DEFINE(bool, IsWindow, (HWND hwnd)) // very costly (compared to win32) -- enumerates all windows, searches for hwnd
384 SWELL_API_DEFINE(void, CenterWindow, (HWND hwnd))
388 ** SetTimer/KillTimer():
389 ** Notes:
390 ** The timer API may be threadsafe though it is highly untested.
391 ** Note also that the mechanism for sending timers is SWELL_Timer:(id).
392 ** The fourth parameter to SetTimer() is not supported and will be ignored, so you must
393 ** receive your timers via a WM_TIMER (or SWELL_Timer:(id))
395 ** You can kill all timers for a window using KillTimer(hwnd,-1);
396 ** You MUST kill all timers for a window before destroying it. Note that SWELL created
397 ** windows/dialogs/controls automatically do this, but if you use SetTimer() on a NSView *
398 ** or NSWindow * directly, then you should kill all timers in -dealloc.
400 SWELL_API_DEFINE(UINT_PTR, SetTimer,(HWND hwnd, UINT_PTR timerid, UINT rate, TIMERPROC tProc))
401 SWELL_API_DEFINE(BOOL, KillTimer,(HWND hwnd, UINT_PTR timerid))
403 #ifdef SWELL_TARGET_OSX
405 ** These provide the interfaces for directly updating a combo box control. This is no longer
406 ** required as SendMessage can now be used with CB_* etc.
407 ** Combo boxes may be implemented using a NSComboBox or NSPopUpButton depending on the style.
409 ** Notes: CB_SetItemData/CB_GetItemData only work for the non-user-editable version (using NSPopUpbutotn).
411 SWELL_API_DEFINE(int, SWELL_CB_AddString,(HWND hwnd, int idx, const char *str))
412 SWELL_API_DEFINE(void, SWELL_CB_SetCurSel,(HWND hwnd, int idx, int sel))
413 SWELL_API_DEFINE(int, SWELL_CB_GetCurSel,(HWND hwnd, int idx))
414 SWELL_API_DEFINE(int, SWELL_CB_GetNumItems,(HWND hwnd, int idx))
415 SWELL_API_DEFINE(void, SWELL_CB_SetItemData,(HWND hwnd, int idx, int item, LONG_PTR data)) // these two only work for the combo list version for now
416 SWELL_API_DEFINE(LONG_PTR, SWELL_CB_GetItemData,(HWND hwnd, int idx, int item))
417 SWELL_API_DEFINE(void, SWELL_CB_Empty,(HWND hwnd, int idx))
418 SWELL_API_DEFINE(int, SWELL_CB_InsertString,(HWND hwnd, int idx, int pos, const char *str))
419 SWELL_API_DEFINE(int, SWELL_CB_GetItemText,(HWND hwnd, int idx, int item, char *buf, int bufsz))
420 SWELL_API_DEFINE(void, SWELL_CB_DeleteString,(HWND hwnd, int idx, int wh))
421 SWELL_API_DEFINE(int, SWELL_CB_FindString,(HWND hwnd, int idx, int startAfter, const char *str, bool exact))
425 ** Trackbar API
426 ** These provide the interfaces for directly updating a trackbar (implemented using NSSlider).
427 ** Note that you can now use SendMessage with TBM_* instead.
429 SWELL_API_DEFINE(void, SWELL_TB_SetPos,(HWND hwnd, int idx, int pos))
430 SWELL_API_DEFINE(void, SWELL_TB_SetRange,(HWND hwnd, int idx, int low, int hi))
431 SWELL_API_DEFINE(int, SWELL_TB_GetPos,(HWND hwnd, int idx))
432 SWELL_API_DEFINE(void, SWELL_TB_SetTic,(HWND hwnd, int idx, int pos))
435 #endif
438 ** ListView API. In owner data mode only LVN_GETDISPINFO is used (not ODFINDITEM etc).
439 ** LVN_BEGINDRAG also should work as on windows. Imagelists state icons work as well.
441 SWELL_API_DEFINE(void, ListView_SetExtendedListViewStyleEx,(HWND h, int mask, int style))
442 SWELL_API_DEFINE(void, ListView_InsertColumn,(HWND h, int pos, const LVCOLUMN *lvc))
443 SWELL_API_DEFINE(bool, ListView_DeleteColumn,(HWND h, int pos))
444 SWELL_API_DEFINE(void, ListView_SetColumn,(HWND h, int pos, const LVCOLUMN *lvc))
445 SWELL_API_DEFINE(int, ListView_GetColumnWidth,(HWND h, int pos))
446 SWELL_API_DEFINE(int, ListView_InsertItem,(HWND h, const LVITEM *item))
447 SWELL_API_DEFINE(void, ListView_SetItemText,(HWND h, int ipos, int cpos, const char *txt))
448 SWELL_API_DEFINE(bool, ListView_SetItem,(HWND h, LVITEM *item))
449 SWELL_API_DEFINE(int, ListView_GetNextItem,(HWND h, int istart, int flags))
450 SWELL_API_DEFINE(bool, ListView_GetItem,(HWND h, LVITEM *item))
451 SWELL_API_DEFINE(int, ListView_GetItemState,(HWND h, int ipos, UINT mask))
452 SWELL_API_DEFINE(void, ListView_DeleteItem,(HWND h, int ipos))
453 SWELL_API_DEFINE(void, ListView_DeleteAllItems,(HWND h))
454 SWELL_API_DEFINE(int, ListView_GetSelectedCount,(HWND h))
455 SWELL_API_DEFINE(int, ListView_GetItemCount,(HWND h))
456 SWELL_API_DEFINE(int, ListView_GetSelectionMark,(HWND h))
457 SWELL_API_DEFINE(void, ListView_SetColumnWidth,(HWND h, int colpos, int wid))
458 SWELL_API_DEFINE(bool, ListView_SetItemState,(HWND h, int item, UINT state, UINT statemask))
459 SWELL_API_DEFINE(void, ListView_RedrawItems,(HWND h, int startitem, int enditem))
460 SWELL_API_DEFINE(void, ListView_SetItemCount,(HWND h, int cnt))
461 #ifdef ListView_SetItemCountEx
462 #undef ListView_SetItemCountEx
463 #endif
464 #define ListView_SetItemCountEx(list,cnt,flags) ListView_SetItemCount(list,cnt)
466 SWELL_API_DEFINE(void, ListView_EnsureVisible,(HWND h, int i, BOOL pok))
467 SWELL_API_DEFINE(bool, ListView_GetSubItemRect,(HWND h, int item, int subitem, int code, RECT *r))
468 SWELL_API_DEFINE(void, ListView_SetImageList,(HWND h, HIMAGELIST imagelist, int which))
469 SWELL_API_DEFINE(int, ListView_HitTest,(HWND h, LVHITTESTINFO *pinf))
470 SWELL_API_DEFINE(int, ListView_SubItemHitTest,(HWND h, LVHITTESTINFO *pinf))
471 SWELL_API_DEFINE(void, ListView_GetItemText,(HWND hwnd, int item, int subitem, char *text, int textmax))
472 SWELL_API_DEFINE(void, ListView_SortItems,(HWND hwnd, PFNLVCOMPARE compf, LPARAM parm))
473 SWELL_API_DEFINE(bool, ListView_GetItemRect,(HWND h, int item, RECT *r, int code))
474 SWELL_API_DEFINE(bool, ListView_Scroll,(HWND h, int xscroll, int yscroll))
475 SWELL_API_DEFINE(int, ListView_GetTopIndex,(HWND h))
476 SWELL_API_DEFINE(int, ListView_GetCountPerPage,(HWND h))
477 SWELL_API_DEFINE(BOOL, ListView_SetColumnOrderArray,(HWND h, int cnt, int* arr))
478 SWELL_API_DEFINE(BOOL, ListView_GetColumnOrderArray,(HWND h, int cnt, int* arr))
479 SWELL_API_DEFINE(HWND, ListView_GetHeader,(HWND h))
480 SWELL_API_DEFINE(int, Header_GetItemCount,(HWND h))
481 SWELL_API_DEFINE(BOOL, Header_GetItem,(HWND h, int col, HDITEM* hi))
482 SWELL_API_DEFINE(BOOL, Header_SetItem,(HWND h, int col, HDITEM* hi))
484 SWELL_API_DEFINE(int, SWELL_GetListViewHeaderHeight, (HWND h))
486 #ifndef ImageList_Create
487 #define ImageList_Create(x,y,a,b,c) ImageList_CreateEx();
488 #endif
489 SWELL_API_DEFINE(HIMAGELIST, ImageList_CreateEx,())
490 SWELL_API_DEFINE(BOOL, ImageList_Remove, (HIMAGELIST list, int idx))
491 SWELL_API_DEFINE(int, ImageList_ReplaceIcon,(HIMAGELIST list, int offset, HICON image))
492 SWELL_API_DEFINE(void, ImageList_Destroy, (HIMAGELIST))
494 ** TabCtrl api.
496 SWELL_API_DEFINE(int, TabCtrl_GetItemCount,(HWND hwnd))
497 SWELL_API_DEFINE(BOOL, TabCtrl_DeleteItem,(HWND hwnd, int idx))
498 SWELL_API_DEFINE(int, TabCtrl_InsertItem,(HWND hwnd, int idx, TCITEM *item))
499 SWELL_API_DEFINE(int, TabCtrl_SetCurSel,(HWND hwnd, int idx))
500 SWELL_API_DEFINE(int, TabCtrl_GetCurSel,(HWND hwnd))
501 SWELL_API_DEFINE(BOOL, TabCtrl_AdjustRect, (HWND hwnd, BOOL fLarger, RECT *r))
504 ** TreeView
507 SWELL_API_DEFINE(HTREEITEM, TreeView_InsertItem, (HWND hwnd, TV_INSERTSTRUCT *ins))
508 SWELL_API_DEFINE(BOOL, TreeView_Expand,(HWND hwnd, HTREEITEM item, UINT flag))
509 SWELL_API_DEFINE(HTREEITEM, TreeView_GetSelection,(HWND hwnd))
510 SWELL_API_DEFINE(void, TreeView_DeleteItem,(HWND hwnd, HTREEITEM item))
511 SWELL_API_DEFINE(void, TreeView_DeleteAllItems,(HWND hwnd))
512 SWELL_API_DEFINE(void, TreeView_SelectItem,(HWND hwnd, HTREEITEM item))
513 SWELL_API_DEFINE(BOOL, TreeView_GetItem,(HWND hwnd, LPTVITEM pitem))
514 SWELL_API_DEFINE(BOOL, TreeView_SetItem,(HWND hwnd, LPTVITEM pitem))
515 SWELL_API_DEFINE(HTREEITEM, TreeView_HitTest, (HWND hwnd, TVHITTESTINFO *hti))
516 SWELL_API_DEFINE(BOOL, TreeView_SetIndent,(HWND hwnd, int indent))
518 SWELL_API_DEFINE(HTREEITEM, TreeView_GetChild, (HWND hwnd, HTREEITEM item))
519 SWELL_API_DEFINE(HTREEITEM, TreeView_GetNextSibling, (HWND hwnd, HTREEITEM item))
520 SWELL_API_DEFINE(HTREEITEM, TreeView_GetRoot, (HWND hwnd))
522 SWELL_API_DEFINE(void,TreeView_SetBkColor,(HWND hwnd, int color))
523 SWELL_API_DEFINE(void,TreeView_SetTextColor,(HWND hwnd, int color))
524 SWELL_API_DEFINE(void,ListView_SetBkColor,(HWND hwnd, int color))
525 SWELL_API_DEFINE(void,ListView_SetTextBkColor,(HWND hwnd, int color))
526 SWELL_API_DEFINE(void,ListView_SetTextColor,(HWND hwnd, int color))
527 SWELL_API_DEFINE(void,ListView_SetGridColor,(HWND hwnd, int color))
528 SWELL_API_DEFINE(void,ListView_SetSelColors,(HWND hwnd, int *colors, int ncolors))
531 ** These are deprecated functions for launching a modal window but still running
532 ** your own code. In general use DialogBox with a timer if needed instead.
534 SWELL_API_DEFINE(void *, SWELL_ModalWindowStart,(HWND hwnd))
535 SWELL_API_DEFINE(bool, SWELL_ModalWindowRun,(void *ctx, int *ret)) // returns false and puts retval in *ret when done
536 SWELL_API_DEFINE(void, SWELL_ModalWindowEnd,(void *ctx))
537 SWELL_API_DEFINE(void, SWELL_CloseWindow,(HWND hwnd))
541 ** Menu functions
542 ** HMENU is a NSMenu *.
544 SWELL_API_DEFINE(HMENU, CreatePopupMenu,())
545 SWELL_API_DEFINE(HMENU, CreatePopupMenuEx,(const char *title))
546 SWELL_API_DEFINE(void, DestroyMenu,(HMENU hMenu))
547 SWELL_API_DEFINE(int, AddMenuItem,(HMENU hMenu, int pos, const char *name, int tagid))
548 SWELL_API_DEFINE(HMENU, GetSubMenu,(HMENU hMenu, int pos))
549 SWELL_API_DEFINE(int, GetMenuItemCount,(HMENU hMenu))
550 SWELL_API_DEFINE(int, GetMenuItemID,(HMENU hMenu, int pos))
551 SWELL_API_DEFINE(bool, SetMenuItemModifier,(HMENU hMenu, int idx, int flag, int code, unsigned int mask))
552 SWELL_API_DEFINE(bool, SetMenuItemText,(HMENU hMenu, int idx, int flag, const char *text))
553 SWELL_API_DEFINE(bool, EnableMenuItem,(HMENU hMenu, int idx, int en))
554 SWELL_API_DEFINE(bool, DeleteMenu,(HMENU hMenu, int idx, int flag))
555 SWELL_API_DEFINE(bool, CheckMenuItem,(HMENU hMenu, int idx, int chk))
556 SWELL_API_DEFINE(void, InsertMenuItem,(HMENU hMenu, int pos, BOOL byPos, MENUITEMINFO *mi))
557 SWELL_API_DEFINE(void,SWELL_InsertMenu,(HMENU menu, int pos, unsigned int flag, UINT_PTR idx, const char *str))
558 #ifdef InsertMenu
559 #undef InsertMenu
560 #endif
561 #define InsertMenu SWELL_InsertMenu
563 SWELL_API_DEFINE(BOOL, GetMenuItemInfo,(HMENU hMenu, int pos, BOOL byPos, MENUITEMINFO *mi))
564 SWELL_API_DEFINE(BOOL, SetMenuItemInfo,(HMENU hMenu, int pos, BOOL byPos, MENUITEMINFO *mi))
565 SWELL_API_DEFINE(void, DrawMenuBar,(HWND))
570 ** LoadMenu()
571 ** Loads a menu created with SWELL_DEFINE_MENU_RESOURCE_BEGIN(), see swell-menugen.h
572 ** Notes: the hinst parameter is ignored, the menu must have been defined in the same
573 ** APP or DYLIB as the LoadMenu call. If you wish to load a menu from another module,
574 ** you should somehow get its SWELL_curmodule_menuresource_head and pass it to SWELL_LoadMenu
575 ** directly.
577 #ifndef LoadMenu
578 #define LoadMenu(hinst,resid) SWELL_LoadMenu(SWELL_curmodule_menuresource_head,(resid))
579 #endif
580 SWELL_API_DEFINE(HMENU, SWELL_LoadMenu,(struct SWELL_MenuResourceIndex *head, const char *resid))
583 ** TrackPopupMenu
584 ** Notes: the rectangle and many flags are ignored, but TPM_NONOTIFY is used.
585 ** It always returns the command selected, even if TPM_RETURNCMD is not specified.
587 SWELL_API_DEFINE(int, TrackPopupMenu,(HMENU hMenu, int flags, int xpos, int ypos, int resvd, HWND hwnd, const RECT *r))
590 ** SWELL_SetMenuDestination: set the action destination for all items in a menu
591 ** Notes:
592 ** TrackPopupMenu and SetMenu use this internally, but it may be useful.
594 SWELL_API_DEFINE(void, SWELL_SetMenuDestination,(HMENU menu, HWND hwnd))
597 ** SWELL_DuplicateMenu:
598 ** Copies an entire menu.
600 SWELL_API_DEFINE(HMENU, SWELL_DuplicateMenu,(HMENU menu))
603 ** SetMenu()/GetMenu()
604 ** Notes: These work on SWELL created NSWindows, or objective C objects that respond to
605 ** swellSetMenu:(HMENU) and swellGetMenu.
606 ** Setting these values doesnt mean anything, except that the SWELL windows will automatically
607 ** set the application menu via NSApp setMainMenu: when activated.
610 SWELL_API_DEFINE(BOOL, SetMenu,(HWND hwnd, HMENU menu))
611 SWELL_API_DEFINE(HMENU, GetMenu,(HWND hwnd))
614 ** SWELL_SetDefaultWindowMenu()/SWELL_GetDefaultWindowMenu()
615 ** these set an internal flag for the default window menu, which will be set
616 ** when switching to a window that has no menu set. Set this to your application's
617 ** main menu.
619 SWELL_API_DEFINE(HMENU, SWELL_GetDefaultWindowMenu,())
620 SWELL_API_DEFINE(void, SWELL_SetDefaultWindowMenu,(HMENU))
621 SWELL_API_DEFINE(HMENU, SWELL_GetDefaultModalWindowMenu,())
622 SWELL_API_DEFINE(void, SWELL_SetDefaultModalWindowMenu,(HMENU))
623 SWELL_API_DEFINE(HMENU, SWELL_GetCurrentMenu,())
624 SWELL_API_DEFINE(void, SWELL_SetCurrentMenu,(HMENU))
629 ** SWELL dialog box/control/window/child dialog/etc creation
630 ** DialogBox(), DialogBoxParam(), CreateDialog(), and CreateDialogParam()
632 ** Notes:
633 ** hInstance parameters are ignored. If you wish to load a dialog resource from another
634 ** module (DYLIB), you should get its SWELL_curmodule_dialogresource_head via your own
635 ** mechanism and pass it as the first parameter of SWELL_DialogBox or whichever API.
637 ** If you are using CreateDialog() and creating a child window, you can use a resource ID of
638 ** 0, which creates an opaque child window. Instead of passing a DLGPROC, you should pass a
639 ** routine that retuns LRESULT (and cast it to DLGPROC).
643 #ifndef DialogBox
644 #define DialogBox(hinst, resid, par, dlgproc) SWELL_DialogBox(SWELL_curmodule_dialogresource_head,(resid),par,dlgproc,0)
645 #define DialogBoxParam(hinst, resid, par, dlgproc, param) SWELL_DialogBox(SWELL_curmodule_dialogresource_head,(resid),par,dlgproc,param)
646 #define CreateDialog(hinst,resid,par,dlgproc) SWELL_CreateDialog(SWELL_curmodule_dialogresource_head,(resid),par,dlgproc,0)
647 #define CreateDialogParam(hinst,resid,par,dlgproc,param) SWELL_CreateDialog(SWELL_curmodule_dialogresource_head,(resid),par,dlgproc,param)
648 #endif
649 SWELL_API_DEFINE(int, SWELL_DialogBox,(struct SWELL_DialogResourceIndex *reshead, const char *resid, HWND parent, DLGPROC dlgproc, LPARAM param))
650 SWELL_API_DEFINE(HWND, SWELL_CreateDialog,(struct SWELL_DialogResourceIndex *reshead, const char *resid, HWND parent, DLGPROC dlgproc, LPARAM param))
654 ** SWELL_RegisterCustomControlCreator(), SWELL_UnregisterCustomControlCreator()
655 ** Notes:
656 ** Pass these a callback function that can create custom controls based on classname.
657 ** Todo: document.
660 SWELL_API_DEFINE(void, SWELL_RegisterCustomControlCreator,(SWELL_ControlCreatorProc proc))
661 SWELL_API_DEFINE(void, SWELL_UnregisterCustomControlCreator,(SWELL_ControlCreatorProc proc))
664 ** DefWindowProc().
665 ** Notes: Doesnt do much but call it anyway from any child windows created with CreateDialog
666 ** and a 0 resource-id window proc.
668 SWELL_API_DEFINE(LRESULT, DefWindowProc,(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam))
671 ** EndDialog():
672 ** Notes: _ONLY_ use on a dialog created with DialogBox(). Will do nothing on other dialogs.
674 SWELL_API_DEFINE(void, EndDialog,(HWND, int))
677 SWELL_API_DEFINE(int,SWELL_GetDefaultButtonID,(HWND hwndDlg, bool onlyIfEnabled))
681 ** SendMessage()
682 ** Notes:
683 ** LIMITATION - SendMessage should only be used from the same thread that the window/view
684 ** was created in. Cross-thread use SHOULD BE AVOIDED. It may work, but it may blow up.
685 ** PostMessage (below) can be used in certain instances for asynchronous notifications.
687 ** If the hwnd supports onSwellMessage:p1:p2: then the message is sent via this.
688 ** Alternatively, buttons created via the dialog interface support BM_GETIMAGE/BM_SETIMAGE
689 ** NSPopUpButton and NSComboBox controls support CB_*
690 ** NSSlider controls support TBM_*
691 ** If the receiver is a view and none of these work, the message goes to the window's onSwellMessage, if any
692 ** If the receiver is a window and none of these work, the message goes to the window's contentview's onSwellMessage, if any
695 SWELL_API_DEFINE(LRESULT, SendMessage,(HWND, UINT, WPARAM, LPARAM))
696 #ifndef SendDlgItemMessage
697 #define SendDlgItemMessage(hwnd,idx,msg,wparam,lparam) SendMessage(GetDlgItem(hwnd,idx),msg,wparam,lparam)
698 #endif
700 SWELL_API_DEFINE(void,SWELL_BroadcastMessage,(UINT, WPARAM, LPARAM))
703 ** PostMessage()
704 ** Notes:
705 ** Queues a message into the application message queue. Note that you should only ever
706 ** send messages to destinations that were created from the main thread. They will be
707 ** processed later from a timer (in the main thread).
708 ** When a window is destroyed any outstanding messages will be discarded for it.
710 SWELL_API_DEFINE(BOOL, PostMessage,(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam))
713 ** SWELL_MessageQueue_Flush():
714 ** Notes:
715 ** Processes all messages in the message queue. ONLY call from the main thread.
717 SWELL_API_DEFINE(void, SWELL_MessageQueue_Flush,())
720 ** SWELL_MessageQueue_Clear():
721 ** Notes:
722 ** Discards all messages from the message queue if h is NULL, otherwise discards all messages
723 ** to h.
725 SWELL_API_DEFINE(void, SWELL_MessageQueue_Clear,(HWND h))
730 ** keyboard/mouse support
734 ** SWELL_MacKeyToWindowsKey()
735 ** Pass a keyboard NSEvent *, and it will return a windows VK_ keycode (or ascii), and set flags,
736 ** including (possibly) FSHIFT, FCONTROL (apple key), FALT, and FVIRTKEY. The ctrl key is not checked,
737 ** as SWELL generally encourages this to be used soley for a right mouse button (as modifier).
739 #ifdef SWELL_TARGET_OSX
740 SWELL_API_DEFINE(int, SWELL_MacKeyToWindowsKey,(void *nsevent, int *flags))
742 // ex is the same as normal, except if mode=1 it does more processing of raw keys w/ modifiers
743 // and also if nsevent==NULL current event is used
744 SWELL_API_DEFINE(int, SWELL_MacKeyToWindowsKeyEx,(void *nsevent, int *flags, int mode))
745 #endif
746 SWELL_API_DEFINE(int,SWELL_KeyToASCII,(int wParam, int lParam, int *newflags))
750 ** GetAsyncKeyState()
751 ** Notes: only supports MK_LBUTTON, MK_RBUTTON, MK_MBUTTON, VK_SHIFT, VK_MENU, and VK_CONTROL (apple key) for now.
753 SWELL_API_DEFINE(WORD, GetAsyncKeyState,(int key))
756 ** GetCursorPos(), GetMessagePos()
757 ** Notes: GetMessagePos() currently returns the same coordinates as GetCursorPos(),
758 ** this needs to be fixed.
760 SWELL_API_DEFINE(void, GetCursorPos,(POINT *pt))
761 SWELL_API_DEFINE(DWORD, GetMessagePos,())
764 ** LoadCursor().
765 ** Notes: hinstance parameter ignored, currently only supports loading some of the predefined values.
766 ** (IDC_SIZEALL etc). If it succeeds value is a NSCursor *
768 SWELL_API_DEFINE(HCURSOR, SWELL_LoadCursor,(const char *idx))
769 #ifndef LoadCursor
770 #define LoadCursor(a,x) SWELL_LoadCursor(x)
771 #endif
774 ** SetCursor()
775 ** Sets a cursor as active (can be HCURSOR or NSCursor * cast as such).
777 #ifdef SetCursor
778 #undef SetCursor
779 #endif
780 #define SetCursor(x) SWELL_SetCursor(x)
781 SWELL_API_DEFINE(void, SWELL_SetCursor,(HCURSOR curs))
784 #ifdef GetCursor
785 #undef GetCursor
786 #endif
787 #define GetCursor SWELL_GetCursor
789 #ifdef ShowCursor
790 #undef ShowCursor
791 #endif
792 #define ShowCursor SWELL_ShowCursor
794 #ifdef SetCursorPos
795 #undef SetCursorPos
796 #endif
797 #define SetCursorPos SWELL_SetCursorPos
799 #ifdef ScrollWindowEx
800 #undef ScrollWindowEx
801 #endif
802 #define ScrollWindowEx(a,b,c,d,e,f,g,h) ScrollWindow(a,b,c,d,e)
806 ** Globally enable or disable emulating mouse right-click using control+left-click
808 SWELL_API_DEFINE(void, SWELL_EnableRightClickEmulate, (BOOL enable))
812 ** GetCursor() gets the actual system cursor,
813 ** SWELL_GetLastSetCursor() gets the last cursor set via SWELL (if they differ than some other window must have changed the cursor)
815 SWELL_API_DEFINE(HCURSOR, SWELL_GetCursor,())
816 SWELL_API_DEFINE(HCURSOR, SWELL_GetLastSetCursor,())
818 SWELL_API_DEFINE(bool, SWELL_IsCursorVisible, ())
819 SWELL_API_DEFINE(int, SWELL_ShowCursor, (BOOL bShow))
820 SWELL_API_DEFINE(BOOL, SWELL_SetCursorPos, (int X, int Y))
823 ** SWELL_GetViewPort
824 ** Gets screen information, for the screen that contains sourcerect. if wantWork is set
825 ** it excluses the menu bar etc.
827 SWELL_API_DEFINE(void, SWELL_GetViewPort,(RECT *r, const RECT *sourcerect, bool wantWork))
830 ** Clipboard API emulation
831 ** Notes: setting multiple types may not work right
834 SWELL_API_DEFINE(bool, OpenClipboard,(HWND hwndDlg))
835 SWELL_API_DEFINE(void, CloseClipboard,())
836 SWELL_API_DEFINE(HANDLE, GetClipboardData,(UINT type))
838 SWELL_API_DEFINE(void, EmptyClipboard,())
839 SWELL_API_DEFINE(void, SetClipboardData,(UINT type, HANDLE h))
840 SWELL_API_DEFINE(UINT, RegisterClipboardFormat,(const char *desc))
841 SWELL_API_DEFINE(UINT, EnumClipboardFormats,(UINT lastfmt))
843 #ifndef CF_TEXT
844 #define CF_TEXT (RegisterClipboardFormat("SWELL__CF_TEXT"))
845 #endif
848 ** GlobalAlloc*()
849 ** These are only currently used by the clipboard system,
850 ** but should work normally.
853 SWELL_API_DEFINE(HANDLE, GlobalAlloc,(int flags, int sz))
854 SWELL_API_DEFINE(void *, GlobalLock,(HANDLE h))
855 SWELL_API_DEFINE(int, GlobalSize,(HANDLE h))
856 SWELL_API_DEFINE(void, GlobalUnlock,(HANDLE h))
857 SWELL_API_DEFINE(void, GlobalFree,(HANDLE h))
860 SWELL_API_DEFINE(HANDLE,CreateThread,(void *TA, DWORD stackSize, DWORD (*ThreadProc)(LPVOID), LPVOID parm, DWORD cf, DWORD *tidOut))
861 SWELL_API_DEFINE(HANDLE,CreateEvent,(void *SA, BOOL manualReset, BOOL initialSig, const char *ignored))
862 SWELL_API_DEFINE(HANDLE,CreateEventAsSocket,(void *SA, BOOL manualReset, BOOL initialSig, const char *ignored))
865 #ifdef _beginthreadex
866 #undef _beginthreadex
867 #endif
868 #define _beginthreadex(a,b,c,d,e,f) ((UINT_PTR)CreateThread(a,b,(unsigned (*)(LPVOID))(c),d,e,(DWORD*)(f)))
870 SWELL_API_DEFINE(DWORD,GetCurrentThreadId,())
871 SWELL_API_DEFINE(DWORD,WaitForSingleObject,(HANDLE hand, DWORD msTO))
872 SWELL_API_DEFINE(DWORD,WaitForAnySocketObject,(int numObjs, HANDLE *objs, DWORD msTO)) // waits for any number of socket objects
873 SWELL_API_DEFINE(BOOL,CloseHandle,(HANDLE hand))
874 SWELL_API_DEFINE(BOOL,SetThreadPriority,(HANDLE evt, int prio))
875 SWELL_API_DEFINE(BOOL,SetEvent,(HANDLE evt))
876 SWELL_API_DEFINE(BOOL,ResetEvent,(HANDLE evt))
878 #ifdef SWELL_TARGET_OSX
879 SWELL_API_DEFINE(void,SWELL_EnsureMultithreadedCocoa,())
880 SWELL_API_DEFINE(void *, SWELL_InitAutoRelease,())
881 SWELL_API_DEFINE(void, SWELL_QuitAutoRelease,(void *p))
882 #endif
884 SWELL_API_DEFINE(HANDLE,SWELL_CreateProcess,(const char *exe, int nparams, const char **params))
887 SWELL_API_DEFINE(HINSTANCE,LoadLibraryGlobals,(const char *fileName, bool symbolsAsGlobals))
888 SWELL_API_DEFINE(HINSTANCE,LoadLibrary,(const char *fileName))
889 SWELL_API_DEFINE(void *,GetProcAddress,(HINSTANCE hInst, const char *procName))
890 SWELL_API_DEFINE(BOOL,FreeLibrary,(HINSTANCE hInst))
892 SWELL_API_DEFINE(void*,SWELL_GetBundle,(HINSTANCE hInst))
895 ** GDI functions.
896 ** Everything should be all hunky dory, your windows may get WM_PAINT, call
897 ** GetDC()/ReleaseDC(), etc.
899 ** Or, there are these helper functions:
904 ** SWELL_CreateMemContext()
905 ** Creates a memory context (that you can get the bits for, below)
906 ** hdc is currently ignored.
908 SWELL_API_DEFINE(HDC, SWELL_CreateMemContext,(HDC hdc, int w, int h))
911 ** SWELL_DeleteGfxContext()
912 ** Deletes a context created with SWELL_CreateMemContext() (or the internal SWELL_CreateGfxContext)
914 SWELL_API_DEFINE(void, SWELL_DeleteGfxContext,(HDC))
917 ** SWELL_GetCtxGC()
918 ** Returns the CGContextRef of a HDC
920 SWELL_API_DEFINE(void *, SWELL_GetCtxGC,(HDC ctx))
924 ** SWELL_GetCtxFrameBuffer()
925 ** Gets the framebuffer of a memory context. NULL if none available.
927 SWELL_API_DEFINE(void *, SWELL_GetCtxFrameBuffer,(HDC ctx))
932 ** Some utility functions for pushing, setting, and popping the clip region.
934 SWELL_API_DEFINE(void, SWELL_PushClipRegion,(HDC ctx))
935 SWELL_API_DEFINE(void, SWELL_SetClipRegion,(HDC ctx, const RECT *r))
936 SWELL_API_DEFINE(void, SWELL_PopClipRegion,(HDC ctx))
941 ** GDI emulation functions
942 ** todo: document
945 SWELL_API_DEFINE(HFONT, CreateFontIndirect,(LOGFONT *))
946 SWELL_API_DEFINE(HFONT, CreateFont,(int lfHeight, int lfWidth, int lfEscapement, int lfOrientation, int lfWeight, char lfItalic,
947 char lfUnderline, char lfStrikeOut, char lfCharSet, char lfOutPrecision, char lfClipPrecision,
948 char lfQuality, char lfPitchAndFamily, const char *lfFaceName))
950 SWELL_API_DEFINE(HPEN, CreatePen,(int attr, int wid, int col))
951 SWELL_API_DEFINE(HBRUSH, CreateSolidBrush,(int col))
952 SWELL_API_DEFINE(HPEN, CreatePenAlpha,(int attr, int wid, int col, float alpha))
953 SWELL_API_DEFINE(HBRUSH, CreateSolidBrushAlpha,(int col, float alpha))
954 SWELL_API_DEFINE(HGDIOBJ, SelectObject,(HDC ctx, HGDIOBJ pen))
955 SWELL_API_DEFINE(HGDIOBJ, GetStockObject,(int wh))
956 SWELL_API_DEFINE(void, DeleteObject,(HGDIOBJ))
957 #ifndef DestroyIcon
958 #define DestroyIcon(x) DeleteObject(x)
959 #endif
961 #ifdef LineTo
962 #undef LineTo
963 #endif
964 #ifdef SetPixel
965 #undef SetPixel
966 #endif
967 #ifdef FillRect
968 #undef FillRect
969 #endif
970 #ifdef DrawText
971 #undef DrawText
972 #endif
973 #ifdef Polygon
974 #undef Polygon
975 #endif
977 #define DrawText SWELL_DrawText
978 #define FillRect SWELL_FillRect
979 #define LineTo SWELL_LineTo
980 #define SetPixel SWELL_SetPixel
981 #define Polygon(a,b,c) SWELL_Polygon(a,b,c)
983 SWELL_API_DEFINE(void, SWELL_FillRect,(HDC ctx, const RECT *r, HBRUSH br))
984 SWELL_API_DEFINE(void, Rectangle,(HDC ctx, int l, int t, int r, int b))
985 SWELL_API_DEFINE(void, Ellipse,(HDC ctx, int l, int t, int r, int b))
986 SWELL_API_DEFINE(void, SWELL_Polygon,(HDC ctx, POINT *pts, int npts))
987 SWELL_API_DEFINE(void, MoveToEx,(HDC ctx, int x, int y, POINT *op))
988 SWELL_API_DEFINE(void, LineTo,(HDC ctx, int x, int y))
989 SWELL_API_DEFINE(void, SetPixel,(HDC ctx, int x, int y, int c))
990 SWELL_API_DEFINE(void, PolyBezierTo,(HDC ctx, POINT *pts, int np))
991 SWELL_API_DEFINE(int, SWELL_DrawText,(HDC ctx, const char *buf, int len, RECT *r, int align))
992 SWELL_API_DEFINE(void, SetTextColor,(HDC ctx, int col))
993 SWELL_API_DEFINE(int, GetTextColor,(HDC ctx))
994 SWELL_API_DEFINE(void, SetBkColor,(HDC ctx, int col))
995 SWELL_API_DEFINE(void, SetBkMode,(HDC ctx, int col))
997 SWELL_API_DEFINE(void, RoundRect,(HDC ctx, int x, int y, int x2, int y2, int xrnd, int yrnd))
998 SWELL_API_DEFINE(void, PolyPolyline,(HDC ctx, POINT *pts, DWORD *cnts, int nseg))
999 SWELL_API_DEFINE(BOOL, GetTextMetrics,(HDC ctx, TEXTMETRIC *tm))
1000 SWELL_API_DEFINE(int, GetTextFace,(HDC ctx, int nCount, LPTSTR lpFaceName))
1001 #ifdef SWELL_TARGET_OSX
1002 SWELL_API_DEFINE(void *, GetNSImageFromHICON,(HICON))
1003 #endif
1004 SWELL_API_DEFINE(BOOL, GetObject, (HICON icon, int bmsz, void *_bm))
1005 SWELL_API_DEFINE(HICON, CreateIconIndirect, (ICONINFO* iconinfo))
1006 SWELL_API_DEFINE(HICON, LoadNamedImage,(const char *name, bool alphaFromMask))
1007 SWELL_API_DEFINE(void, DrawImageInRect,(HDC ctx, HICON img, const RECT *r))
1008 SWELL_API_DEFINE(void, BitBlt,(HDC hdcOut, int x, int y, int w, int h, HDC hdcIn, int xin, int yin, int mode))
1009 SWELL_API_DEFINE(void, StretchBlt,(HDC hdcOut, int x, int y, int w, int h, HDC hdcIn, int xin, int yin, int srcw, int srch, int mode))
1010 SWELL_API_DEFINE(int, GetSysColor,(int idx))
1011 SWELL_API_DEFINE(HBITMAP, CreateBitmap,(int width, int height, int numplanes, int bitsperpixel, unsigned char* bits))
1013 SWELL_API_DEFINE(void, SetOpaque, (HWND h, bool isopaque))
1014 #ifdef SWELL_TARGET_OSX
1015 SWELL_API_DEFINE(int, SWELL_IsRetinaDC, (HDC hdc)) // returns 1 if DC is a retina DC (2x res possible)
1016 SWELL_API_DEFINE(int, SWELL_IsRetinaHWND, (HWND h)) // returns 1 if HWND is a retina HWND
1017 SWELL_API_DEFINE(void, SWELL_SetViewGL, (HWND h, bool wantGL))
1018 SWELL_API_DEFINE(bool, SWELL_GetViewGL, (HWND h))
1019 SWELL_API_DEFINE(bool, SWELL_SetGLContextToView, (HWND h)) // sets GL context to that view, returns TRUE if successs (use NULL to clear GL context)
1020 #endif
1022 SWELL_API_DEFINE(HDC, BeginPaint,(HWND, PAINTSTRUCT *))
1023 SWELL_API_DEFINE(BOOL, EndPaint,(HWND, PAINTSTRUCT *))
1025 SWELL_API_DEFINE(HDC, GetDC,(HWND)) // use these sparingly! they kinda work but shouldnt be overused!!
1026 SWELL_API_DEFINE(HDC, GetWindowDC,(HWND))
1027 SWELL_API_DEFINE(void, ReleaseDC,(HWND, HDC))
1029 #ifdef __APPLE__
1030 SWELL_API_DEFINE(void, SWELL_FlushWindow,(HWND))
1031 #endif
1033 SWELL_API_DEFINE(void, SWELL_FillDialogBackground,(HDC hdc, const RECT *r, int level))
1035 SWELL_API_DEFINE(HGDIOBJ,SWELL_CloneGDIObject,(HGDIOBJ a))
1037 SWELL_API_DEFINE(int, GetSystemMetrics, (int))
1039 SWELL_API_DEFINE(BOOL, DragQueryPoint,(HDROP,LPPOINT))
1040 SWELL_API_DEFINE(void, DragFinish,(HDROP))
1041 SWELL_API_DEFINE(UINT, DragQueryFile,(HDROP,UINT,char *,UINT))
1043 // source drag/drop - callback is source implementing "create dropped files at droppath"
1044 SWELL_API_DEFINE(void, SWELL_InitiateDragDrop, (HWND, RECT* srcrect, const char* srcfn, void (*callback)(const char* droppath)))
1045 SWELL_API_DEFINE(void,SWELL_InitiateDragDropOfFileList,(HWND, RECT *srcrect, const char **srclist, int srccount, HICON icon))
1046 SWELL_API_DEFINE(void, SWELL_FinishDragDrop, ()) // cancels any outstanding InitiateDragDrop
1050 // r=NULL to "free" handle
1051 // otherwise r is in hwndPar coordinates
1052 SWELL_API_DEFINE(void,SWELL_DrawFocusRect,(HWND hwndPar, RECT *rct, void **handle))
1055 #ifdef SWELL_TARGET_OSX
1056 SWELL_API_DEFINE(void,SWELL_SetWindowRepre,(HWND hwnd, const char *fn, bool isDirty)) // sets the represented file and edited state
1057 SWELL_API_DEFINE(void,SWELL_PostQuitMessage,(void *sender))
1058 #endif
1061 ** Functions used by swell-dlggen.h and swell-menugen.h
1062 ** No need to really dig into these unless you're working on swell or debugging..
1065 SWELL_API_DEFINE(void, SWELL_MakeSetCurParms,(float xscale, float yscale, float xtrans, float ytrans, HWND parent, bool doauto, bool dosizetofit))
1067 SWELL_API_DEFINE(HWND, SWELL_MakeButton,(int def, const char *label, int idx, int x, int y, int w, int h, int flags))
1068 SWELL_API_DEFINE(HWND, SWELL_MakeEditField,(int idx, int x, int y, int w, int h, int flags))
1069 SWELL_API_DEFINE(HWND, SWELL_MakeLabel,(int align, const char *label, int idx, int x, int y, int w, int h, int flags))
1070 SWELL_API_DEFINE(HWND, SWELL_MakeControl,(const char *cname, int idx, const char *classname, int style, int x, int y, int w, int h, int exstyle))
1071 SWELL_API_DEFINE(HWND, SWELL_MakeCombo,(int idx, int x, int y, int w, int h, int flags))
1072 SWELL_API_DEFINE(HWND, SWELL_MakeGroupBox,(const char *name, int idx, int x, int y, int w, int h, int style))
1073 SWELL_API_DEFINE(HWND, SWELL_MakeCheckBox,(const char *name, int idx, int x, int y, int w, int h, int flags))
1074 SWELL_API_DEFINE(HWND, SWELL_MakeListBox,(int idx, int x, int y, int w, int h, int styles))
1076 SWELL_API_DEFINE(void, SWELL_Menu_AddMenuItem,(HMENU hMenu, const char *name, int idx, unsigned int flags))
1077 SWELL_API_DEFINE(int, SWELL_GenerateMenuFromList,(HMENU hMenu, const void *list, int listsz)) // list is SWELL_MenuGen_Entry
1079 SWELL_API_DEFINE(void, SWELL_GenerateDialogFromList, (const void *list, int listsz))
1082 SWELL_API_DEFINE(unsigned int, _controlfp,(unsigned int flag, unsigned int mask))
1084 SWELL_API_DEFINE(void,SWELL_Internal_PostMessage_Init,())
1087 SWELL_API_DEFINE(HCURSOR,SWELL_LoadCursorFromFile,(const char *fn))
1088 SWELL_API_DEFINE(void,SWELL_SetWindowWantRaiseAmt,(HWND h, int amt))
1089 SWELL_API_DEFINE(int,SWELL_GetWindowWantRaiseAmt,(HWND))
1091 SWELL_API_DEFINE(void,SWELL_SetListViewFastClickMask,(HWND hList, int mask))
1094 SWELL_API_DEFINE(void,GetTempPath,(int sz, char *buf))
1096 #ifndef __APPLE__
1097 SWELL_API_DEFINE(void,SWELL_initargs,(int *argc, char ***argv))
1098 SWELL_API_DEFINE(void,SWELL_RunMessageLoop,())
1099 #endif
1101 #ifdef __APPLE__
1102 SWELL_API_DEFINE(void,SWELL_GenerateGUID,(void *g))
1103 #endif
1105 SWELL_API_DEFINE(BOOL,EnumChildWindows,(HWND hwnd, BOOL (*cwEnumFunc)(HWND,LPARAM),LPARAM lParam))
1108 SWELL_API_DEFINE(BOOL,SWELL_IsGroupBox,(HWND))
1109 SWELL_API_DEFINE(BOOL,SWELL_IsButton,(HWND))
1110 SWELL_API_DEFINE(BOOL,SWELL_IsStaticText,(HWND))
1111 SWELL_API_DEFINE(void,SWELL_GetDesiredControlSize,(HWND hwnd, RECT *r))
1113 #ifdef __APPLE__
1114 SWELL_API_DEFINE(void,SWELL_DisableAppNap,(int disable))
1115 SWELL_API_DEFINE(int,SWELL_GetOSXVersion,())
1116 #endif
1119 #endif // _WDL_SWELL_H_API_DEFINED_