Merge pull request #110 from tesselode/fixes
[wdl/wdl-ol.git] / WDL / swell / swell-generic-headless.cpp
blob859c07bc7697531723d1226efa25807f9b759373
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.
24 #ifndef SWELL_PROVIDED_BY_APP
26 #include "swell.h"
28 #ifndef SWELL_TARGET_GDK
30 #include "swell-internal.h"
31 #include "swell-dlggen.h"
32 #include "../wdlcstring.h"
34 void swell_oswindow_destroy(HWND hwnd)
36 if (hwnd && hwnd->m_oswindow)
38 if (SWELL_focused_oswindow == hwnd->m_oswindow) SWELL_focused_oswindow = NULL;
39 hwnd->m_oswindow=NULL;
40 #ifdef SWELL_LICE_GDI
41 delete hwnd->m_backingstore;
42 hwnd->m_backingstore=0;
43 #endif
46 void swell_oswindow_update_text(HWND hwnd)
48 if (hwnd) printf("SWELL: swt '%s'\n",hwnd->m_title.Get());
52 void swell_oswindow_focus(HWND hwnd)
54 if (!hwnd)
56 SWELL_focused_oswindow = NULL;
58 while (hwnd && !hwnd->m_oswindow) hwnd=hwnd->m_parent;
59 if (hwnd && hwnd->m_oswindow != SWELL_focused_oswindow)
61 SWELL_focused_oswindow = hwnd->m_oswindow;
65 void swell_recalcMinMaxInfo(HWND hwnd)
70 void SWELL_initargs(int *argc, char ***argv)
74 void swell_oswindow_updatetoscreen(HWND hwnd, RECT *rect)
78 void swell_oswindow_manage(HWND hwnd, bool wantfocus)
80 if (!hwnd) return;
82 bool isVis = !!hwnd->m_oswindow;
83 bool wantVis = !hwnd->m_parent && hwnd->m_visible;
85 if (isVis != wantVis)
87 if (!wantVis) swell_oswindow_destroy(hwnd);
88 else
90 // generic implementation
91 hwnd->m_oswindow = hwnd;
92 if (wantfocus) swell_oswindow_focus(hwnd);
95 if (wantVis) swell_oswindow_update_text(hwnd);
98 void SWELL_RunEvents()
103 void swell_oswindow_update_style(HWND hwnd, LONG oldstyle)
107 void swell_oswindow_update_enable(HWND hwnd)
111 int SWELL_SetWindowLevel(HWND hwnd, int newlevel)
113 int rv=0;
114 if (hwnd)
116 rv = hwnd->m_israised ? 1 : 0;
117 hwnd->m_israised = newlevel>0;
119 return rv;
122 void SWELL_GetViewPort(RECT *r, const RECT *sourcerect, bool wantWork)
124 r->left=r->top=0;
125 r->right=1024;
126 r->bottom=768;
130 bool GetWindowRect(HWND hwnd, RECT *r)
132 if (!hwnd) return false;
133 if (hwnd->m_oswindow)
135 *r = hwnd->m_position;
136 return true;
139 r->left=r->top=0;
140 ClientToScreen(hwnd,(LPPOINT)r);
141 r->right = r->left + hwnd->m_position.right - hwnd->m_position.left;
142 r->bottom = r->top + hwnd->m_position.bottom - hwnd->m_position.top;
143 return true;
146 void swell_oswindow_begin_resize(SWELL_OSWINDOW wnd) { }
147 void swell_oswindow_resize(SWELL_OSWINDOW wnd, int reposflag, RECT f) { }
148 void swell_oswindow_postresize(HWND hwnd, RECT f) { }
149 void swell_oswindow_invalidate(HWND hwnd, const RECT *r) { }
151 void UpdateWindow(HWND hwnd) { }
153 static WDL_IntKeyedArray<HANDLE> m_clip_recs(GlobalFree);
154 static WDL_PtrList<char> m_clip_curfmts;
156 bool OpenClipboard(HWND hwndDlg) { return true; }
158 void CloseClipboard() { }
160 UINT EnumClipboardFormats(UINT lastfmt)
162 int x=0;
163 for (;;)
165 int fmt=0;
166 if (!m_clip_recs.Enumerate(x++,&fmt)) return 0;
167 if (lastfmt == 0) return fmt;
169 if ((UINT)fmt == lastfmt) return m_clip_recs.Enumerate(x++,&fmt) ? fmt : 0;
173 HANDLE GetClipboardData(UINT type)
175 return m_clip_recs.Get(type);
179 void EmptyClipboard()
181 m_clip_recs.DeleteAll();
184 void SetClipboardData(UINT type, HANDLE h)
186 if (h) m_clip_recs.Insert(type,h);
187 else m_clip_recs.Delete(type);
190 UINT RegisterClipboardFormat(const char *desc)
192 if (!desc || !*desc) return 0;
193 int x;
194 const int n = m_clip_curfmts.GetSize();
195 for(x=0;x<n;x++)
196 if (!strcmp(m_clip_curfmts.Get(x),desc)) return x + 1;
197 m_clip_curfmts.Add(strdup(desc));
198 return n+1;
202 void GetCursorPos(POINT *pt)
204 pt->x=0;
205 pt->y=0;
209 WORD GetAsyncKeyState(int key)
211 return 0;
215 DWORD GetMessagePos()
217 return 0;
220 HWND SWELL_CreateXBridgeWindow(HWND viewpar, void **wref, RECT *r)
222 *wref = NULL;
223 return NULL;
228 void SWELL_InitiateDragDrop(HWND hwnd, RECT* srcrect, const char* srcfn, void (*callback)(const char* dropfn))
232 // owner owns srclist, make copies here etc
233 void SWELL_InitiateDragDropOfFileList(HWND hwnd, RECT *srcrect, const char **srclist, int srccount, HICON icon)
237 void SWELL_FinishDragDrop() { }
239 static HCURSOR m_last_setcursor;
241 void SWELL_SetCursor(HCURSOR curs)
243 m_last_setcursor=curs;
246 HCURSOR SWELL_GetCursor()
248 return m_last_setcursor;
250 HCURSOR SWELL_GetLastSetCursor()
252 return m_last_setcursor;
255 static int m_curvis_cnt;
256 bool SWELL_IsCursorVisible()
258 return m_curvis_cnt>=0;
261 int SWELL_ShowCursor(BOOL bShow)
263 m_curvis_cnt += (bShow?1:-1);
264 return m_curvis_cnt;
267 BOOL SWELL_SetCursorPos(int X, int Y)
269 return false;
272 HCURSOR SWELL_LoadCursorFromFile(const char *fn)
274 return NULL;
278 static SWELL_CursorResourceIndex *SWELL_curmodule_cursorresource_head;
280 HCURSOR SWELL_LoadCursor(const char *_idx)
282 return NULL;
287 void SWELL_Register_Cursor_Resource(const char *idx, const char *name, int hotspot_x, int hotspot_y)
289 SWELL_CursorResourceIndex *ri = (SWELL_CursorResourceIndex*)malloc(sizeof(SWELL_CursorResourceIndex));
290 ri->hotspot.x = hotspot_x;
291 ri->hotspot.y = hotspot_y;
292 ri->resname=name;
293 ri->cachedCursor=0;
294 ri->resid = idx;
295 ri->_next = SWELL_curmodule_cursorresource_head;
296 SWELL_curmodule_cursorresource_head = ri;
299 int SWELL_KeyToASCII(int wParam, int lParam, int *newflags)
301 return 0;
305 #endif
306 #endif