LMMS
Loading...
Searching...
No Matches
eel_lice.h
Go to the documentation of this file.
1#ifndef _EEL_LICE_H_
2#define _EEL_LICE_H_
3
4// #define EEL_LICE_GET_FILENAME_FOR_STRING(idx, fs, p) (((sInst*)opaque)->GetFilenameForParameter(idx,fs,p))
5// #define EEL_LICE_GET_CONTEXT(opaque) (((opaque) ? (((sInst *)opaque)->m_gfx_state) : NULL)
6
7
9
10#ifdef DYNAMIC_LICE
11 #define LICE_IBitmap LICE_IBitmap_disabledAPI
12 #include "../lice/lice.h"
13
14 #undef LICE_IBitmap
15 typedef void LICE_IBitmap; // prevent us from using LICE api directly, in case it ever changes
16
17class LICE_IFont;
18
19#ifdef EEL_LICE_API_ONLY
20#define EEL_LICE_FUNCDEF extern
21#else
22#define EEL_LICE_FUNCDEF
23#endif
24
25#define LICE_FUNCTION_VALID(x) (x)
26
27EEL_LICE_FUNCDEF LICE_IBitmap *(*__LICE_CreateBitmap)(int, int, int);
28EEL_LICE_FUNCDEF void (*__LICE_Clear)(LICE_IBitmap *dest, LICE_pixel color);
29EEL_LICE_FUNCDEF void (*__LICE_Line)(LICE_IBitmap *dest, int x1, int y1, int x2, int y2, LICE_pixel color, float alpha, int mode, bool aa);
30EEL_LICE_FUNCDEF bool (*__LICE_ClipLine)(int* pX1, int* pY1, int* pX2, int* pY2, int xLo, int yLo, int xHi, int yHi);
31EEL_LICE_FUNCDEF void (*__LICE_DrawText)(LICE_IBitmap *bm, int x, int y, const char *string,
32 LICE_pixel color, float alpha, int mode);
33EEL_LICE_FUNCDEF void (*__LICE_DrawChar)(LICE_IBitmap *bm, int x, int y, char c,
34 LICE_pixel color, float alpha, int mode);
35EEL_LICE_FUNCDEF void (*__LICE_MeasureText)(const char *string, int *w, int *h);
36EEL_LICE_FUNCDEF void (*__LICE_PutPixel)(LICE_IBitmap *bm, int x, int y, LICE_pixel color, float alpha, int mode);
37EEL_LICE_FUNCDEF LICE_pixel (*__LICE_GetPixel)(LICE_IBitmap *bm, int x, int y);
38EEL_LICE_FUNCDEF void (*__LICE_FillRect)(LICE_IBitmap *dest, int x, int y, int w, int h, LICE_pixel color, float alpha, int mode);
39EEL_LICE_FUNCDEF void (*__LICE_DrawRect)(LICE_IBitmap *dest, int x, int y, int w, int h, LICE_pixel color, float alpha, int mode);
40EEL_LICE_FUNCDEF LICE_IBitmap *(*__LICE_LoadImage)(const char* filename, LICE_IBitmap* bmp, bool tryIgnoreExtension);
41EEL_LICE_FUNCDEF void (*__LICE_Blur)(LICE_IBitmap *dest, LICE_IBitmap *src, int dstx, int dsty, int srcx, int srcy, int srcw, int srch); // src and dest can overlap, however it may look fudgy if they do
42EEL_LICE_FUNCDEF void (*__LICE_ScaledBlit)(LICE_IBitmap *dest, LICE_IBitmap *src, int dstx, int dsty, int dstw, int dsth,
43 float srcx, float srcy, float srcw, float srch, float alpha, int mode);
44EEL_LICE_FUNCDEF void (*__LICE_Circle)(LICE_IBitmap* dest, float cx, float cy, float r, LICE_pixel color, float alpha, int mode, bool aa);
45EEL_LICE_FUNCDEF void (*__LICE_FillCircle)(LICE_IBitmap* dest, float cx, float cy, float r, LICE_pixel color, float alpha, int mode, bool aa);
46EEL_LICE_FUNCDEF void (*__LICE_FillTriangle)(LICE_IBitmap* dest, int x1, int y1, int x2, int y2, int x3, int y3, LICE_pixel color, float alpha, int mode);
47EEL_LICE_FUNCDEF void (*__LICE_FillConvexPolygon)(LICE_IBitmap* dest, const int* x, const int* y, int npoints, LICE_pixel color, float alpha, int mode);
48EEL_LICE_FUNCDEF void (*__LICE_RoundRect)(LICE_IBitmap *drawbm, float xpos, float ypos, float w, float h, int cornerradius, LICE_pixel col, float alpha, int mode, bool aa);
49EEL_LICE_FUNCDEF void (*__LICE_Arc)(LICE_IBitmap* dest, float cx, float cy, float r, float minAngle, float maxAngle, LICE_pixel color, float alpha, int mode, bool aa);
50
51// if cliptosourcerect is false, then areas outside the source rect can get in (otherwise they are not drawn)
52EEL_LICE_FUNCDEF void (*__LICE_RotatedBlit)(LICE_IBitmap *dest, LICE_IBitmap *src,
53 int dstx, int dsty, int dstw, int dsth,
54 float srcx, float srcy, float srcw, float srch,
55 float angle,
56 bool cliptosourcerect, float alpha, int mode,
57 float rotxcent, float rotycent); // these coordinates are offset from the center of the image, in source pixel coordinates
58
59
60EEL_LICE_FUNCDEF void (*__LICE_MultiplyAddRect)(LICE_IBitmap *dest, int x, int y, int w, int h,
61 float rsc, float gsc, float bsc, float asc, // 0-1, or -100 .. +100 if you really are insane
62 float radd, float gadd, float badd, float aadd); // 0-255 is the normal range on these.. of course its clamped
63
64EEL_LICE_FUNCDEF void (*__LICE_GradRect)(LICE_IBitmap *dest, int dstx, int dsty, int dstw, int dsth,
65 float ir, float ig, float ib, float ia,
66 float drdx, float dgdx, float dbdx, float dadx,
67 float drdy, float dgdy, float dbdy, float dady,
68 int mode);
69
70EEL_LICE_FUNCDEF void (*__LICE_TransformBlit2)(LICE_IBitmap *dest, LICE_IBitmap *src,
71 int dstx, int dsty, int dstw, int dsth,
72 double *srcpoints, int div_w, int div_h, // srcpoints coords should be div_w*div_h*2 long, and be in source image coordinates
73 float alpha, int mode);
74
75EEL_LICE_FUNCDEF void (*__LICE_DeltaBlit)(LICE_IBitmap *dest, LICE_IBitmap *src,
76 int dstx, int dsty, int dstw, int dsth,
77 float srcx, float srcy, float srcw, float srch,
78 double dsdx, double dtdx, double dsdy, double dtdy,
79 double dsdxdy, double dtdxdy,
80 bool cliptosourcerect, float alpha, int mode);
81
82
83#define LICE_Blur __LICE_Blur
84#define LICE_Clear __LICE_Clear
85#define LICE_Line __LICE_Line
86#define LICE_ClipLine __LICE_ClipLine
87#define LICE_FillRect __LICE_FillRect
88#define LICE_DrawRect __LICE_DrawRect
89#define LICE_PutPixel __LICE_PutPixel
90#define LICE_GetPixel __LICE_GetPixel
91#define LICE_DrawText __LICE_DrawText
92#define LICE_DrawChar __LICE_DrawChar
93#define LICE_MeasureText __LICE_MeasureText
94#define LICE_LoadImage __LICE_LoadImage
95#define LICE_RotatedBlit __LICE_RotatedBlit
96#define LICE_ScaledBlit __LICE_ScaledBlit
97#define LICE_MultiplyAddRect __LICE_MultiplyAddRect
98#define LICE_GradRect __LICE_GradRect
99#define LICE_TransformBlit2 __LICE_TransformBlit2
100#define LICE_DeltaBlit __LICE_DeltaBlit
101#define LICE_Circle __LICE_Circle
102#define LICE_FillCircle __LICE_FillCircle
103#define LICE_FillTriangle __LICE_FillTriangle
104#define LICE_FillConvexPolygon __LICE_FillConvexPolygon
105#define LICE_RoundRect __LICE_RoundRect
106#define LICE_Arc __LICE_Arc
107
108EEL_LICE_FUNCDEF HDC (*LICE__GetDC)(LICE_IBitmap *bm);
109EEL_LICE_FUNCDEF int (*LICE__GetWidth)(LICE_IBitmap *bm);
110EEL_LICE_FUNCDEF int (*LICE__GetHeight)(LICE_IBitmap *bm);
111EEL_LICE_FUNCDEF void (*LICE__Destroy)(LICE_IBitmap *bm);
112EEL_LICE_FUNCDEF bool (*LICE__resize)(LICE_IBitmap *bm, int w, int h);
113
114EEL_LICE_FUNCDEF void (*LICE__DestroyFont)(LICE_IFont* font);
115EEL_LICE_FUNCDEF LICE_IFont *(*LICE_CreateFont)();
116EEL_LICE_FUNCDEF void (*LICE__SetFromHFont)(LICE_IFont* ifont, HFONT font, int flags);
117EEL_LICE_FUNCDEF LICE_pixel (*LICE__SetTextColor)(LICE_IFont* ifont, LICE_pixel color);
118EEL_LICE_FUNCDEF void (*LICE__SetTextCombineMode)(LICE_IFont* ifont, int mode, float alpha);
119EEL_LICE_FUNCDEF int (*LICE__DrawText)(LICE_IFont* ifont, LICE_IBitmap *bm, const char *str, int strcnt, RECT *rect, UINT dtFlags);
120
121#else
122
123#include "../lice/lice.h"
124#include "../lice/lice_text.h"
125
126#define LICE_FUNCTION_VALID(x) (sizeof(int) > 0)
127
129{
130 return bm->getDC();
131}
133{
134 return bm->getWidth();
135}
137{
138 return bm->getHeight();
139}
141{
142 delete bm;
143}
144static void LICE__SetFromHFont(LICE_IFont * ifont, HFONT font, int flags)
145{
146 if (ifont) ifont->SetFromHFont(font,flags);
147}
149{
150 if (ifont) return ifont->SetTextColor(color);
151 return 0;
152}
153static void LICE__SetTextCombineMode(LICE_IFont* ifont, int mode, float alpha)
154{
155 if (ifont) ifont->SetCombineMode(mode, alpha);
156}
157static int LICE__DrawText(LICE_IFont* ifont, LICE_IBitmap *bm, const char *str, int strcnt, RECT *rect, UINT dtFlags)
158{
159 if (ifont) return ifont->DrawText(bm, str, strcnt, rect, dtFlags);
160 return 0;
161}
162
163
165{
166 return new LICE_CachedFont();
167}
169{
170 delete bm;
171}
172static bool LICE__resize(LICE_IBitmap *bm, int w, int h)
173{
174 return bm->resize(w,h);
175}
176
178{
179 if (mode==1) return new LICE_SysBitmap(w,h);
180 return new LICE_MemBitmap(w,h);
181}
182
183
184#endif
185
186#include "../wdlutf8.h"
187
188
190{
191public:
192
193 eel_lice_state(NSEEL_VMCTX vm, void *ctx, int image_slots, int font_slots);
195
197 {
199 if (m_gfx_a2) *m_gfx_a2=1.0;
200 if (m_gfx_dest) *m_gfx_dest=-1.0;
203 // todo: reset others?
204 }
205
219 enum {
224 };
225
226 int m_gfx_font_active; // -1 for default, otherwise index into gfx_fonts (NOTE: this differs from the exposed API, which defines 0 as default, 1-n)
228
229 LICE_IBitmap *GetImageForIndex(EEL_F idx, const char *callername)
230 {
231 if (idx>-2.0)
232 {
233 if (idx < 0.0) return m_framebuffer;
234
235 const int a = (int)idx;
236 if (a >= 0 && a < m_gfx_images.GetSize()) return m_gfx_images.Get()[a];
237 }
238 return NULL;
239 };
240
242 {
244 {
245 if (m_gfx_clear && *m_gfx_clear > -1.0)
246 {
247 const int a=(int)*m_gfx_clear;
248 if (LICE_FUNCTION_VALID(LICE_Clear)) LICE_Clear(m_framebuffer,LICE_RGBA((a&0xff),((a>>8)&0xff),((a>>16)&0xff),0));
249 }
251 }
252 }
253
254 // R, G, B, A, w, h, x, y, mode(1=add,0=copy)
258
261
262 int setup_frame(HWND hwnd, RECT r, int _mouse_x=0, int _mouse_y=0, int has_dpi=0); // mouse_x/y used only if hwnd is NULL
263 void finish_draw();
264
265 void gfx_lineto(EEL_F xpos, EEL_F ypos, EEL_F aaflag);
266 void gfx_rectto(EEL_F xpos, EEL_F ypos);
267 void gfx_line(int np, EEL_F **parms);
268 void gfx_rect(int np, EEL_F **parms);
269 void gfx_roundrect(int np, EEL_F **parms);
270 void gfx_arc(int np, EEL_F **parms);
271 void gfx_set(int np, EEL_F **parms);
272 void gfx_grad_or_muladd_rect(int mode, int np, EEL_F **parms);
273 void gfx_setpixel(EEL_F r, EEL_F g, EEL_F b);
274 void gfx_getpixel(EEL_F *r, EEL_F *g, EEL_F *b);
275 void gfx_drawnumber(EEL_F n, EEL_F ndigits);
276 void gfx_drawchar(EEL_F ch);
277 void gfx_getimgdim(EEL_F img, EEL_F *w, EEL_F *h);
278 EEL_F gfx_setimgdim(int img, EEL_F *w, EEL_F *h);
279 void gfx_blurto(EEL_F x, EEL_F y);
280 void gfx_blitext(EEL_F img, EEL_F *coords, EEL_F angle);
281 void gfx_blitext2(int np, EEL_F **parms, int mode); // 0=blit, 1=deltablit
282 void gfx_transformblit(EEL_F **parms, int div_w, int div_h, EEL_F *tab); // parms[0]=src, 1-4=x,y,w,h
283 void gfx_circle(float x, float y, float r, bool fill, bool aaflag);
284 void gfx_triangle(EEL_F** parms, int nparms);
285 void gfx_drawstr(void *opaque, EEL_F **parms, int nparms, int formatmode); // formatmode=1 for format, 2 for purely measure no format, 3 for measure char
286 EEL_F gfx_loadimg(void *opaque, int img, EEL_F loadFrom);
287 EEL_F gfx_setfont(void *opaque, int np, EEL_F **parms);
288 EEL_F gfx_getfont(void *opaque, int np, EEL_F **parms);
289 EEL_F gfx_getdropfile(void *opaque, int np, EEL_F **parms);
290
292 int getCurMode();
293 int getCurModeForBlit(bool isFBsrc);
294
295#ifdef EEL_LICE_WANT_STANDALONE
296 HWND create_wnd(HWND par, int isChild);
297 HWND hwnd_standalone;
298 int hwnd_standalone_kb_state[32]; // pressed keys, if any
299
300 // these have to be **parms because of the hack for getting string from parm index
301 EEL_F gfx_showmenu(void* opaque, EEL_F** parms, int nparms);
302 EEL_F gfx_setcursor(void* opaque, EEL_F** parms, int nparms);
303
304 int m_kb_queue[64];
305 unsigned char m_kb_queue_valid;
306 unsigned char m_kb_queue_pos;
307 HCURSOR m_cursor;
308 int m_cursor_resid;
309#ifdef EEL_LICE_LOADTHEMECURSOR
310 char m_cursor_name[128];
311#endif
312
313#ifndef EEL_LICE_STANDALONE_NOINITQUIT
314 RECT m_last_undocked_r;
315#endif
316
317#endif
318 int m_has_cap; // high 16 bits are current capture state, low 16 bits are temporary flags from mousedown
319 bool m_has_had_getch; // set on first gfx_getchar(), makes mouse_cap updated with modifiers even when no mouse click is down
320
322};
323
324
325#ifndef EEL_LICE_API_ONLY
326
327eel_lice_state::eel_lice_state(NSEEL_VMCTX vm, void *ctx, int image_slots, int font_slots)
328{
329#ifdef EEL_LICE_WANT_STANDALONE
330 hwnd_standalone=NULL;
331 memset(hwnd_standalone_kb_state,0,sizeof(hwnd_standalone_kb_state));
332 m_kb_queue_valid=0;
333 m_cursor_resid=0;
334 m_cursor = NULL;
335#ifndef EEL_LICE_STANDALONE_NOINITQUIT
336 memset(&m_last_undocked_r,0,sizeof(m_last_undocked_r));
337#endif
338
339#ifdef EEL_LICE_LOADTHEMECURSOR
340 m_cursor_name[0]=0;
341#endif
342#endif
343 m_user_ctx=ctx;
344 m_vmref= vm;
346 m_gfx_fonts.Resize(font_slots);
347 memset(m_gfx_fonts.Get(),0,m_gfx_fonts.GetSize()*sizeof(m_gfx_fonts.Get()[0]));
348
349 m_gfx_images.Resize(image_slots);
350 memset(m_gfx_images.Get(),0,m_gfx_images.GetSize()*sizeof(m_gfx_images.Get()[0]));
353
354 m_gfx_r = NSEEL_VM_regvar(vm,"gfx_r");
355 m_gfx_g = NSEEL_VM_regvar(vm,"gfx_g");
356 m_gfx_b = NSEEL_VM_regvar(vm,"gfx_b");
357 m_gfx_a = NSEEL_VM_regvar(vm,"gfx_a");
358 m_gfx_a2 = NSEEL_VM_regvar(vm,"gfx_a2");
359
360 m_gfx_w = NSEEL_VM_regvar(vm,"gfx_w");
361 m_gfx_h = NSEEL_VM_regvar(vm,"gfx_h");
362 m_gfx_x = NSEEL_VM_regvar(vm,"gfx_x");
363 m_gfx_y = NSEEL_VM_regvar(vm,"gfx_y");
364 m_gfx_mode = NSEEL_VM_regvar(vm,"gfx_mode");
365 m_gfx_clear = NSEEL_VM_regvar(vm,"gfx_clear");
366 m_gfx_texth = NSEEL_VM_regvar(vm,"gfx_texth");
367 m_gfx_dest = NSEEL_VM_regvar(vm,"gfx_dest");
368 m_gfx_ext_retina = NSEEL_VM_regvar(vm,"gfx_ext_retina");
369
370 m_mouse_x = NSEEL_VM_regvar(vm,"mouse_x");
371 m_mouse_y = NSEEL_VM_regvar(vm,"mouse_y");
372 m_mouse_cap = NSEEL_VM_regvar(vm,"mouse_cap");
373 m_mouse_wheel=NSEEL_VM_regvar(vm,"mouse_wheel");
374 m_mouse_hwheel=NSEEL_VM_regvar(vm,"mouse_hwheel");
375
376 if (m_gfx_texth) *m_gfx_texth=8;
377
378 m_has_cap=0;
379 m_has_had_getch=false;
380}
382{
383#ifdef EEL_LICE_WANT_STANDALONE
384 if (hwnd_standalone) DestroyWindow(hwnd_standalone);
385#endif
387 {
390 int x;
391 for (x=0;x<m_gfx_images.GetSize();x++)
392 {
394 }
395 }
397 {
398 int x;
399 for (x=0;x<m_gfx_fonts.GetSize();x++)
400 {
401 if (m_gfx_fonts.Get()[x].font) LICE__DestroyFont(m_gfx_fonts.Get()[x].font);
402 }
403 }
404 m_ddrop_files.Empty(true,free);
405}
406
408{
409 const int gmode = (int) (*m_gfx_mode);
410 const int sm=(gmode>>4)&0xf;
411 if (sm > LICE_BLIT_MODE_COPY && sm <= LICE_BLIT_MODE_HSVADJ) return sm;
412
413 return (gmode&1) ? LICE_BLIT_MODE_ADD : LICE_BLIT_MODE_COPY;
414}
416{
417 const int gmode = (int) (*m_gfx_mode);
418
419 const int sm=(gmode>>4)&0xf;
420
421 int mode;
422 if (sm > LICE_BLIT_MODE_COPY && sm <= LICE_BLIT_MODE_HSVADJ) mode=sm;
423 else mode=((gmode&1) ? LICE_BLIT_MODE_ADD : LICE_BLIT_MODE_COPY);
424
425
426 if (!isFBsrc && !(gmode&2)) mode|=LICE_BLIT_USE_ALPHA;
427 if (!(gmode&4)) mode|=LICE_BLIT_FILTER_BILINEAR;
428
429 return mode;
430}
432{
433 int red=(int) (*m_gfx_r*255.0);
434 int green=(int) (*m_gfx_g*255.0);
435 int blue=(int) (*m_gfx_b*255.0);
436 int a2=(int) (*m_gfx_a2*255.0);
437 if (red<0) red=0;else if (red>255)red=255;
438 if (green<0) green=0;else if (green>255)green=255;
439 if (blue<0) blue=0; else if (blue>255) blue=255;
440 if (a2<0) a2=0; else if (a2>255) a2=255;
441 return LICE_RGBA(red,green,blue,a2);
442}
443
444
445static EEL_F * NSEEL_CGEN_CALL _gfx_lineto(void *opaque, EEL_F *xpos, EEL_F *ypos, EEL_F *useaa)
446{
448 if (ctx) ctx->gfx_lineto(*xpos, *ypos, *useaa);
449 return xpos;
450}
451static EEL_F * NSEEL_CGEN_CALL _gfx_lineto2(void *opaque, EEL_F *xpos, EEL_F *ypos)
452{
454 if (ctx) ctx->gfx_lineto(*xpos, *ypos, 1.0f);
455 return xpos;
456}
457
458static EEL_F * NSEEL_CGEN_CALL _gfx_rectto(void *opaque, EEL_F *xpos, EEL_F *ypos)
459{
461 if (ctx) ctx->gfx_rectto(*xpos, *ypos);
462 return xpos;
463}
464
465static EEL_F NSEEL_CGEN_CALL _gfx_line(void *opaque, INT_PTR np, EEL_F **parms)
466{
468 if (ctx) ctx->gfx_line((int)np,parms);
469 return 0.0;
470}
471
472static EEL_F NSEEL_CGEN_CALL _gfx_rect(void *opaque, INT_PTR np, EEL_F **parms)
473{
475 if (ctx) ctx->gfx_rect((int)np,parms);
476 return 0.0;
477}
478static EEL_F NSEEL_CGEN_CALL _gfx_roundrect(void *opaque, INT_PTR np, EEL_F **parms)
479{
481 if (ctx) ctx->gfx_roundrect((int)np,parms);
482 return 0.0;
483}
484static EEL_F NSEEL_CGEN_CALL _gfx_arc(void *opaque, INT_PTR np, EEL_F **parms)
485{
487 if (ctx) ctx->gfx_arc((int)np,parms);
488 return 0.0;
489}
490static EEL_F NSEEL_CGEN_CALL _gfx_set(void *opaque, INT_PTR np, EEL_F **parms)
491{
493 if (ctx) ctx->gfx_set((int)np,parms);
494 return 0.0;
495}
496static EEL_F NSEEL_CGEN_CALL _gfx_gradrect(void *opaque, INT_PTR np, EEL_F **parms)
497{
499 if (ctx) ctx->gfx_grad_or_muladd_rect(0,(int)np,parms);
500 return 0.0;
501}
502
503static EEL_F NSEEL_CGEN_CALL _gfx_muladdrect(void *opaque, INT_PTR np, EEL_F **parms)
504{
506 if (ctx) ctx->gfx_grad_or_muladd_rect(1,(int)np,parms);
507 return 0.0;
508}
509
510static EEL_F NSEEL_CGEN_CALL _gfx_deltablit(void *opaque, INT_PTR np, EEL_F **parms)
511{
513 if (ctx) ctx->gfx_blitext2((int)np,parms,1);
514 return 0.0;
515}
516
517static EEL_F NSEEL_CGEN_CALL _gfx_transformblit(void *opaque, INT_PTR np, EEL_F **parms)
518{
520 if (ctx)
521 {
522#ifndef EEL_LICE_NO_RAM
523 const int divw = (int) (parms[5][0]+0.5);
524 const int divh = (int) (parms[6][0]+0.5);
525 if (divw < 1 || divh < 1) return 0.0;
526 const int sz = divw*divh*2;
527
528#ifdef EEL_LICE_RAMFUNC
529 EEL_F *d = EEL_LICE_RAMFUNC(opaque,7,sz);
530 if (!d) return 0.0;
531#else
532 EEL_F **blocks = ctx->m_vmref ? ((compileContext*)ctx->m_vmref)->ram_state->blocks : 0;
533 if (!blocks || np < 8) return 0.0;
534
535 const int addr1= (int) (parms[7][0]+0.5);
536 EEL_F *d=__NSEEL_RAMAlloc(blocks,addr1);
538 {
539 int x;
541 if (__NSEEL_RAMAlloc(blocks,addr1+x) != d+x) return 0.0;
542 }
543 EEL_F *end=__NSEEL_RAMAlloc(blocks,addr1+sz-1);
544 if (end != d+sz-1) return 0.0; // buffer not contiguous
545#endif
546
547 ctx->gfx_transformblit(parms,divw,divh,d);
548#endif
549 }
550 return 0.0;
551}
552
553static EEL_F NSEEL_CGEN_CALL _gfx_circle(void *opaque, INT_PTR np, EEL_F **parms)
554{
556 bool aa = true, fill = false;
557 if (np>3) fill = parms[3][0] > 0.5;
558 if (np>4) aa = parms[4][0] > 0.5;
559 if (ctx) ctx->gfx_circle((float)parms[0][0], (float)parms[1][0], (float)parms[2][0], fill, aa);
560 return 0.0;
561}
562
563static EEL_F NSEEL_CGEN_CALL _gfx_triangle(void* opaque, INT_PTR np, EEL_F **parms)
564{
566 if (ctx) ctx->gfx_triangle(parms, (int)np);
567 return 0.0;
568}
569
570static EEL_F * NSEEL_CGEN_CALL _gfx_drawnumber(void *opaque, EEL_F *n, EEL_F *nd)
571{
573 if (ctx) ctx->gfx_drawnumber(*n, *nd);
574 return n;
575}
576
577static EEL_F * NSEEL_CGEN_CALL _gfx_drawchar(void *opaque, EEL_F *n)
578{
580 if (ctx) ctx->gfx_drawchar(*n);
581 return n;
582}
583
584static EEL_F * NSEEL_CGEN_CALL _gfx_measurestr(void *opaque, EEL_F *str, EEL_F *xOut, EEL_F *yOut)
585{
587 if (ctx)
588 {
589 EEL_F *p[3]={str,xOut,yOut};
590 ctx->gfx_drawstr(opaque,p,3,2);
591 }
592 return str;
593}
594static EEL_F * NSEEL_CGEN_CALL _gfx_measurechar(void *opaque, EEL_F *str, EEL_F *xOut, EEL_F *yOut)
595{
597 if (ctx)
598 {
599 EEL_F *p[3]={str,xOut,yOut};
600 ctx->gfx_drawstr(opaque,p,3,3);
601 }
602 return str;
603}
604
605static EEL_F NSEEL_CGEN_CALL _gfx_drawstr(void *opaque, INT_PTR nparms, EEL_F **parms)
606{
608 if (ctx) ctx->gfx_drawstr(opaque,parms,(int)nparms,0);
609 return parms[0][0];
610}
611
612static EEL_F NSEEL_CGEN_CALL _gfx_printf(void *opaque, INT_PTR nparms, EEL_F **parms)
613{
615 if (ctx && nparms>0)
616 {
617 EEL_F v= **parms;
618 ctx->gfx_drawstr(opaque,parms,(int)nparms,1);
619 return v;
620 }
621 return 0.0;
622}
623
624static EEL_F NSEEL_CGEN_CALL _gfx_showmenu(void* opaque, INT_PTR nparms, EEL_F **parms)
625{
627 if (ctx) return ctx->gfx_showmenu(opaque, parms, (int)nparms);
628 return 0.0;
629}
630
631static EEL_F NSEEL_CGEN_CALL _gfx_setcursor(void* opaque, INT_PTR nparms, EEL_F **parms)
632{
634 if (ctx) return ctx->gfx_setcursor(opaque, parms, (int)nparms);
635 return 0.0;
636}
637
638static EEL_F * NSEEL_CGEN_CALL _gfx_setpixel(void *opaque, EEL_F *r, EEL_F *g, EEL_F *b)
639{
641 if (ctx) ctx->gfx_setpixel(*r, *g, *b);
642 return r;
643}
644
645static EEL_F * NSEEL_CGEN_CALL _gfx_getpixel(void *opaque, EEL_F *r, EEL_F *g, EEL_F *b)
646{
648 if (ctx) ctx->gfx_getpixel(r, g, b);
649 return r;
650}
651
652static EEL_F NSEEL_CGEN_CALL _gfx_setfont(void *opaque, INT_PTR np, EEL_F **parms)
653{
655 if (ctx) return ctx->gfx_setfont(opaque,(int)np,parms);
656 return 0.0;
657}
658
659static EEL_F NSEEL_CGEN_CALL _gfx_getfont(void *opaque, INT_PTR np, EEL_F **parms)
660{
662 if (ctx)
663 {
664 const int idx=ctx->m_gfx_font_active;
665 if (idx>=0 && idx < ctx->m_gfx_fonts.GetSize())
666 {
668
670
671#ifdef NOT_EEL_STRING_UPDATE_STRING
672 NOT_EEL_STRING_UPDATE_STRING(parms[0][0],f->actual_fontname);
673#else
674 WDL_FastString *fs=NULL;
675 EEL_STRING_GET_FOR_WRITE(parms[0][0],&fs);
676 if (fs) fs->Set(f->actual_fontname);
677#endif
678 }
679 return idx;
680 }
681 return 0.0;
682}
683
684static EEL_F NSEEL_CGEN_CALL _gfx_blit2(void *opaque, INT_PTR np, EEL_F **parms)
685{
687 if (ctx && np>=3)
688 {
689 ctx->gfx_blitext2((int)np,parms,0);
690 return *(parms[0]);
691 }
692 return 0.0;
693}
694
695static EEL_F * NSEEL_CGEN_CALL _gfx_blitext(void *opaque, EEL_F *img, EEL_F *coordidx, EEL_F *rotate)
696{
698 if (ctx)
699 {
700#ifndef EEL_LICE_NO_RAM
701#ifdef EEL_LICE_RAMFUNC
702 EEL_F *buf = EEL_LICE_RAMFUNC(opaque,1,10);
703 if (!buf) return img;
704#else
705 EEL_F fc = *coordidx;
706 if (fc < -0.5 || fc >= NSEEL_RAM_BLOCKS*NSEEL_RAM_ITEMSPERBLOCK) return img;
707 int a=(int)fc;
708 if (a<0) return img;
709
710 EEL_F buf[10];
711 int x;
712 EEL_F **blocks = ctx->m_vmref ? ((compileContext*)ctx->m_vmref)->ram_state->blocks : 0;
713 if (!blocks) return img;
714 for (x = 0;x < 10; x ++)
715 {
716 EEL_F *d=__NSEEL_RAMAlloc(blocks,a++);
717 if (!d || d==&nseel_ramalloc_onfail) return img;
718 buf[x]=*d;
719 }
720#endif
721 // read megabuf
722 ctx->gfx_blitext(*img,buf,*rotate);
723#endif
724 }
725 return img;
726}
727
728
729static EEL_F * NSEEL_CGEN_CALL _gfx_blurto(void *opaque, EEL_F *x, EEL_F *y)
730{
732 if (ctx) ctx->gfx_blurto(*x,*y);
733 return x;
734}
735
736static EEL_F * NSEEL_CGEN_CALL _gfx_getimgdim(void *opaque, EEL_F *img, EEL_F *w, EEL_F *h)
737{
739 if (ctx) ctx->gfx_getimgdim(*img,w,h);
740 return img;
741}
742
743static EEL_F NSEEL_CGEN_CALL _gfx_loadimg(void *opaque, EEL_F *img, EEL_F *fr)
744{
746 if (ctx) return ctx->gfx_loadimg(opaque,(int)*img,*fr);
747 return 0.0;
748}
749
750static EEL_F NSEEL_CGEN_CALL _gfx_getdropfile(void *opaque, INT_PTR np, EEL_F **parms)
751{
753 if (ctx) return ctx->gfx_getdropfile(opaque,(int) np, parms);
754 return 0.0;
755}
756static EEL_F NSEEL_CGEN_CALL _gfx_setimgdim(void *opaque, EEL_F *img, EEL_F *w, EEL_F *h)
757{
759 if (ctx) return ctx->gfx_setimgdim((int)*img,w,h);
760 return 0.0;
761}
762
763static EEL_F NSEEL_CGEN_CALL _gfx_getsyscol(void* ctxe, INT_PTR np, EEL_F **parms)
764{
766}
767
768void eel_lice_state::gfx_lineto(EEL_F xpos, EEL_F ypos, EEL_F aaflag)
769{
770 LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_lineto");
771 if (!dest) return;
772
773 int x1=(int)floor(xpos),y1=(int)floor(ypos),x2=(int)floor(*m_gfx_x), y2=(int)floor(*m_gfx_y);
776 LICE_ClipLine(&x1,&y1,&x2,&y2,0,0,LICE__GetWidth(dest),LICE__GetHeight(dest)))
777 {
778 SetImageDirty(dest);
779 LICE_Line(dest,x1,y1,x2,y2,getCurColor(),(float) *m_gfx_a,getCurMode(),aaflag > 0.5);
780 }
781 *m_gfx_x = xpos;
782 *m_gfx_y = ypos;
783
784}
785
786void eel_lice_state::gfx_circle(float x, float y, float r, bool fill, bool aaflag)
787{
788 LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_circle");
789 if (!dest) return;
790
792 {
793 SetImageDirty(dest);
794 if(fill)
795 LICE_FillCircle(dest, x, y, r, getCurColor(), (float) *m_gfx_a, getCurMode(), aaflag);
796 else
797 LICE_Circle(dest, x, y, r, getCurColor(), (float) *m_gfx_a, getCurMode(), aaflag);
798 }
799}
800
801void eel_lice_state::gfx_triangle(EEL_F** parms, int np)
802{
803 LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest, "gfx_triangle");
804 if (np >= 6)
805 {
806 np &= ~1;
807 SetImageDirty(dest);
808 if (np == 6)
809 {
811
812 LICE_FillTriangle(dest, (int)parms[0][0], (int)parms[1][0], (int)parms[2][0], (int)parms[3][0],
813 (int)parms[4][0], (int)parms[5][0], getCurColor(), (float)*m_gfx_a, getCurMode());
814 }
815 else
816 {
818
819 const int maxpt = 512;
820 const int n = wdl_min(np/2, maxpt);
821 int i, rdi=0;
822 int x[maxpt], y[maxpt];
823 for (i=0; i < n; i++)
824 {
825 x[i]=(int)parms[rdi++][0];
826 y[i]=(int)parms[rdi++][0];
827 }
828
829 LICE_FillConvexPolygon(dest, x, y, n, getCurColor(), (float)*m_gfx_a, getCurMode());
830 }
831 }
832}
833
834void eel_lice_state::gfx_rectto(EEL_F xpos, EEL_F ypos)
835{
836 LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_rectto");
837 if (!dest) return;
838
839 EEL_F x1=xpos,y1=ypos,x2=*m_gfx_x, y2=*m_gfx_y;
840 if (x2<x1) { x1=x2; x2=xpos; }
841 if (y2<y1) { y1=y2; y2=ypos; }
842
843 if (LICE_FUNCTION_VALID(LICE_FillRect) && x2-x1 > 0.5 && y2-y1 > 0.5)
844 {
845 SetImageDirty(dest);
846 LICE_FillRect(dest,(int)x1,(int)y1,(int)(x2-x1),(int)(y2-y1),getCurColor(),(float)*m_gfx_a,getCurMode());
847 }
848 *m_gfx_x = xpos;
849 *m_gfx_y = ypos;
850}
851
852
853void eel_lice_state::gfx_line(int np, EEL_F **parms)
854{
855 LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_line");
856 if (!dest) return;
857
858 int x1=(int)floor(parms[0][0]),y1=(int)floor(parms[1][0]),x2=(int)floor(parms[2][0]), y2=(int)floor(parms[3][0]);
863 {
864 SetImageDirty(dest);
865 LICE_Line(dest,x1,y1,x2,y2,getCurColor(),(float)*m_gfx_a,getCurMode(),np< 5 || parms[4][0] > 0.5);
866 }
867}
868
869void eel_lice_state::gfx_rect(int np, EEL_F **parms)
870{
871 LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_rect");
872 if (!dest) return;
873
874 int x1=(int)floor(parms[0][0]),y1=(int)floor(parms[1][0]),w=(int)floor(parms[2][0]),h=(int)floor(parms[3][0]);
875 int filled=(np < 5 || parms[4][0] > 0.5);
876
878 {
879 SetImageDirty(dest);
880 if (filled) LICE_FillRect(dest,x1,y1,w,h,getCurColor(),(float)*m_gfx_a,getCurMode());
881 else LICE_DrawRect(dest, x1, y1, w-1, h-1, getCurColor(), (float)*m_gfx_a, getCurMode());
882 }
883}
884
885void eel_lice_state::gfx_roundrect(int np, EEL_F **parms)
886{
887 LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_roundrect");
888 if (!dest) return;
889
890 const bool aa = np <= 5 || parms[5][0]>0.5;
891
892 if (LICE_FUNCTION_VALID(LICE_RoundRect) && parms[2][0]>0 && parms[3][0]>0)
893 {
894 SetImageDirty(dest);
895 LICE_RoundRect(dest, (float)parms[0][0], (float)parms[1][0], (float)parms[2][0], (float)parms[3][0], (int)parms[4][0], getCurColor(), (float)*m_gfx_a, getCurMode(), aa);
896 }
897}
898
899void eel_lice_state::gfx_arc(int np, EEL_F **parms)
900{
901 LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_arc");
902 if (!dest) return;
903
904 const bool aa = np <= 5 || parms[5][0]>0.5;
905
907 {
908 SetImageDirty(dest);
909 LICE_Arc(dest, (float)parms[0][0], (float)parms[1][0], (float)parms[2][0], (float)parms[3][0], (float)parms[4][0], getCurColor(), (float)*m_gfx_a, getCurMode(), aa);
910 }
911}
912
913void eel_lice_state::gfx_grad_or_muladd_rect(int whichmode, int np, EEL_F **parms)
914{
915 LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,whichmode==0?"gfx_gradrect":"gfx_muladdrect");
916 if (!dest) return;
917
918 const int x1=(int)floor(parms[0][0]),y1=(int)floor(parms[1][0]),w=(int)floor(parms[2][0]), h=(int)floor(parms[3][0]);
919
920 if (w>0 && h>0)
921 {
922 SetImageDirty(dest);
923 if (whichmode==0 && LICE_FUNCTION_VALID(LICE_GradRect) && np > 7)
924 {
925 LICE_GradRect(dest,x1,y1,w,h,(float)parms[4][0],(float)parms[5][0],(float)parms[6][0],(float)parms[7][0],
926 np > 8 ? (float)parms[8][0]:0.0f, np > 9 ? (float)parms[9][0]:0.0f, np > 10 ? (float)parms[10][0]:0.0f, np > 11 ? (float)parms[11][0]:0.0f,
927 np > 12 ? (float)parms[12][0]:0.0f, np > 13 ? (float)parms[13][0]:0.0f, np > 14 ? (float)parms[14][0]:0.0f, np > 15 ? (float)parms[15][0]:0.0f,
928 getCurMode());
929 }
930 else if (whichmode==1 && LICE_FUNCTION_VALID(LICE_MultiplyAddRect) && np > 6)
931 {
932 const double sc = 255.0;
933 LICE_MultiplyAddRect(dest,x1,y1,w,h,(float)parms[4][0],(float)parms[5][0],(float)parms[6][0],np>7 ? (float)parms[7][0]:1.0f,
934 (float)(np > 8 ? sc*parms[8][0]:0.0), (float)(np > 9 ? sc*parms[9][0]:0.0), (float)(np > 10 ? sc*parms[10][0]:0.0), (float)(np > 11 ? sc*parms[11][0]:0.0));
935 }
936 }
937}
938
939
940
941void eel_lice_state::gfx_setpixel(EEL_F r, EEL_F g, EEL_F b)
942{
943 LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_setpixel");
944 if (!dest) return;
945
946 int red=(int) (r*255.0);
947 int green=(int) (g*255.0);
948 int blue=(int) (b*255.0);
949 if (red<0) red=0;else if (red>255)red=255;
950 if (green<0) green=0;else if (green>255)green=255;
951 if (blue<0) blue=0; else if (blue>255) blue=255;
952
954 {
955 SetImageDirty(dest);
956 LICE_PutPixel(dest,(int)*m_gfx_x, (int)*m_gfx_y,LICE_RGBA(red,green,blue,255), (float)*m_gfx_a,getCurMode());
957 }
958}
959
960void eel_lice_state::gfx_getimgdim(EEL_F img, EEL_F *w, EEL_F *h)
961{
962 *w=*h=0;
963#ifdef DYNAMIC_LICE
964 if (!LICE__GetWidth || !LICE__GetHeight) return;
965#endif
966
967 LICE_IBitmap *bm=GetImageForIndex(img,"gfx_getimgdim");
968 if (bm)
969 {
970 *w=LICE__GetWidth(bm);
971 *h=LICE__GetHeight(bm);
972 }
973}
974
975EEL_F eel_lice_state::gfx_getdropfile(void *opaque, int np, EEL_F **parms)
976{
977 const int idx = (int) parms[0][0];
978 if (idx<0) m_ddrop_files.Empty(true,free);
979 if (idx < 0 || idx >= m_ddrop_files.GetSize()) return 0.0;
980
981#ifdef NOT_EEL_STRING_UPDATE_STRING
982 NOT_EEL_STRING_UPDATE_STRING(parms[1][0],m_ddrop_files.Get(idx));
983#else
984 if (np > 1)
985 {
987 WDL_FastString *fs=NULL;
988 EEL_STRING_GET_FOR_WRITE(parms[1][0], &fs);
989 if (fs) fs->Set(m_ddrop_files.Get(idx));
990 }
991#endif
992 return 1.0;
993}
994
995EEL_F eel_lice_state::gfx_loadimg(void *opaque, int img, EEL_F loadFrom)
996{
997#ifdef DYNAMIC_LICE
998 if (!__LICE_LoadImage || !LICE__Destroy) return 0.0;
999#endif
1000
1001 if (img >= 0 && img < m_gfx_images.GetSize())
1002 {
1003 WDL_FastString fs;
1004 bool ok = EEL_LICE_GET_FILENAME_FOR_STRING(loadFrom,&fs,0);
1005
1006 if (ok && fs.GetLength())
1007 {
1008 LICE_IBitmap *bm = LICE_LoadImage(fs.Get(),NULL,false);
1009 if (bm)
1010 {
1011 LICE__Destroy(m_gfx_images.Get()[img]);
1012 m_gfx_images.Get()[img]=bm;
1013 return img;
1014 }
1015 }
1016 }
1017 return -1.0;
1018
1019}
1020
1021EEL_F eel_lice_state::gfx_setimgdim(int img, EEL_F *w, EEL_F *h)
1022{
1023 int rv=0;
1024#ifdef DYNAMIC_LICE
1026#endif
1027
1028 int use_w = (int)*w;
1029 int use_h = (int)*h;
1030 if (use_w<1 || use_h < 1) use_w=use_h=0;
1031 if (use_w > 8192) use_w=8192;
1032 if (use_h > 8192) use_h=8192;
1033
1034 LICE_IBitmap *bm=NULL;
1035 if (img >= 0 && img < m_gfx_images.GetSize())
1036 {
1037 bm=m_gfx_images.Get()[img];
1038 if (!bm)
1039 {
1040 m_gfx_images.Get()[img] = bm = __LICE_CreateBitmap(1,use_w,use_h);
1041 rv=!!bm;
1042 }
1043 else
1044 {
1045 rv=LICE__resize(bm,use_w,use_h);
1046 }
1047 }
1048
1049 return rv?1.0:0.0;
1050}
1051
1053{
1054 LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_blurto");
1055 if (!dest
1056#ifdef DYNAMIC_LICE
1057 ||!LICE_Blur
1058#endif
1059 ) return;
1060
1061 SetImageDirty(dest);
1062
1063 int srcx = (int)x;
1064 int srcy = (int)y;
1065 int srcw=(int) (*m_gfx_x-x);
1066 int srch=(int) (*m_gfx_y-y);
1067 if (srch < 0) { srch=-srch; srcy = (int)*m_gfx_y; }
1068 if (srcw < 0) { srcw=-srcw; srcx = (int)*m_gfx_x; }
1069 LICE_Blur(dest,dest,srcx,srcy,srcx,srcy,srcw,srch);
1070 *m_gfx_x = x;
1071 *m_gfx_y = y;
1072}
1073
1074static bool CoordsSrcDestOverlap(EEL_F *coords)
1075{
1076 if (coords[0]+coords[2] < coords[4]) return false;
1077 if (coords[0] > coords[4] + coords[6]) return false;
1078 if (coords[1]+coords[3] < coords[5]) return false;
1079 if (coords[1] > coords[5] + coords[7]) return false;
1080 return true;
1081}
1082
1083void eel_lice_state::gfx_transformblit(EEL_F **parms, int div_w, int div_h, EEL_F *tab)
1084{
1085 LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_transformblit");
1086
1087 if (!dest
1088#ifdef DYNAMIC_LICE
1090#endif
1091 ) return;
1092
1093 LICE_IBitmap *bm=GetImageForIndex(parms[0][0],"gfx_transformblit:src");
1094 if (!bm) return;
1095
1096 const int bmw=LICE__GetWidth(bm);
1097 const int bmh=LICE__GetHeight(bm);
1098
1099 const bool isFromFB = bm==m_framebuffer;
1100
1101 SetImageDirty(dest);
1102
1103 if (bm == dest)
1104 {
1107 {
1108
1110 LICE_ScaledBlit(bm,dest, // copy the entire image
1111 0,0,bmw,bmh,
1112 0.0f,0.0f,(float)bmw,(float)bmh,
1113 1.0f,LICE_BLIT_MODE_COPY);
1114 }
1115 }
1116 LICE_TransformBlit2(dest,bm,(int)floor(parms[1][0]),(int)floor(parms[2][0]),(int)floor(parms[3][0]),(int)floor(parms[4][0]),tab,div_w,div_h, (float)*m_gfx_a,getCurModeForBlit(isFromFB));
1117}
1118
1119EEL_F eel_lice_state::gfx_setfont(void *opaque, int np, EEL_F **parms)
1120{
1121 int a = np>0 ? ((int)floor(parms[0][0]))-1 : -1;
1122
1123 if (a>=0 && a < m_gfx_fonts.GetSize())
1124 {
1125 gfxFontStruct *s = m_gfx_fonts.Get()+a;
1127 {
1128 const int sz=np>2 ? (int)parms[2][0] : 10;
1129
1130 bool doCreate=false;
1131 int fontflag=0;
1132 if (!s->font) s->actual_fontname[0]=0;
1133
1134 {
1136
1137 const char *face=EEL_STRING_GET_FOR_INDEX(parms[1][0],NULL);
1138 #ifdef EEL_STRING_DEBUGOUT
1139 if (!face) EEL_STRING_DEBUGOUT("gfx_setfont: invalid string identifier %f",parms[1][0]);
1140 #endif
1141 if (!face || !*face) face="Arial";
1142
1143 {
1144 unsigned int c = np > 3 ? (unsigned int) parms[3][0] : 0;
1145 while (c)
1146 {
1147 switch (toupper(c&0xff))
1148 {
1149 case 'B': fontflag|=EELFONT_FLAG_BOLD; break;
1150 case 'I': fontflag|=EELFONT_FLAG_ITALIC; break;
1151 case 'U': fontflag|=EELFONT_FLAG_UNDERLINE; break;
1152 case 'R': fontflag|=16; break; //LICE_FONT_FLAG_FX_BLUR
1153 case 'V': fontflag|=32; break; //LICE_FONT_FLAG_FX_INVERT
1154 case 'M': fontflag|=64; break; //LICE_FONT_FLAG_FX_MONO
1155 case 'S': fontflag|=128; break; //LICE_FONT_FLAG_FX_SHADOW
1156 case 'O': fontflag|=256; break; //LICE_FONT_FLAG_FX_OUTLINE
1157 case 'Z': fontflag|=1; break; //LICE_FONT_FLAG_VERTICAL
1158 case 'Y': fontflag|=1|2; break; //LICE_FONT_FLAG_VERTICAL|LICE_FONT_FLAG_VERTICAL_BOTTOMUP
1159 }
1160 c>>=8;
1161 }
1162 }
1163
1164
1165 if (fontflag != s->last_fontflag || sz!=s->last_fontsize || strncmp(s->last_fontname,face,sizeof(s->last_fontname)-1))
1166 {
1167 lstrcpyn_safe(s->last_fontname,face,sizeof(s->last_fontname));
1168 s->last_fontsize=sz;
1169 s->last_fontflag=fontflag;
1170 doCreate=1;
1171 }
1172 }
1173
1174 if (doCreate)
1175 {
1176 s->actual_fontname[0]=0;
1177 if (!s->font) s->font=LICE_CreateFont();
1178 if (s->font)
1179 {
1180 const int fw = (fontflag&EELFONT_FLAG_BOLD) ? FW_BOLD : FW_NORMAL;
1181 const bool italic = !!(fontflag&EELFONT_FLAG_ITALIC);
1182 const bool underline = !!(fontflag&EELFONT_FLAG_UNDERLINE);
1183 HFONT hf=NULL;
1184#if defined(_WIN32) && !defined(WDL_NO_SUPPORT_UTF8)
1185 WCHAR wf[256];
1186 if (WDL_DetectUTF8(s->last_fontname)>0 &&
1187 GetVersion()<0x80000000 &&
1188 MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,s->last_fontname,-1,wf,256))
1189 {
1190 hf = CreateFontW(sz,0,0,0,fw,italic,underline,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH,wf);
1191 }
1192#endif
1193 if (!hf) hf = CreateFont(sz,0,0,0,fw,italic,underline,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH,s->last_fontname);
1194
1195 if (!hf)
1196 {
1197 s->use_fonth=0; // disable this font
1198 }
1199 else
1200 {
1201 TEXTMETRIC tm;
1202 tm.tmHeight = sz;
1203
1205
1207 {
1208 HGDIOBJ oldFont = 0;
1210 if (hdc)
1211 {
1212 oldFont = SelectObject(hdc,hf);
1213 GetTextMetrics(hdc,&tm);
1214
1215#if defined(_WIN32) && !defined(WDL_NO_SUPPORT_UTF8)
1216 if (GetVersion()<0x80000000 &&
1217 GetTextFaceW(hdc,sizeof(wf)/sizeof(wf[0]),wf) &&
1218 WideCharToMultiByte(CP_UTF8,0,wf,-1,s->actual_fontname,sizeof(s->actual_fontname),NULL,NULL))
1219 {
1220 s->actual_fontname[sizeof(s->actual_fontname)-1]=0;
1221 }
1222 else
1223#endif
1224 GetTextFace(hdc, sizeof(s->actual_fontname), s->actual_fontname);
1225 SelectObject(hdc,oldFont);
1226 }
1227 }
1228
1229 s->use_fonth=wdl_max(tm.tmHeight,1);
1230 LICE__SetFromHFont(s->font,hf, (fontflag & ~EELFONT_FLAG_MASK) | 512 /*LICE_FONT_FLAG_OWNS_HFONT*/);
1231 }
1232 }
1233 }
1234 }
1235
1236
1237 if (s->font && s->use_fonth)
1238 {
1240 if (m_gfx_texth) *m_gfx_texth=s->use_fonth;
1241 return 1.0;
1242 }
1243 // try to init this font
1244 }
1245 #ifdef EEL_STRING_DEBUGOUT
1246 if (a >= m_gfx_fonts.GetSize()) EEL_STRING_DEBUGOUT("gfx_setfont: invalid font %d specified",a);
1247 #endif
1248
1249 if (a<0||a>=m_gfx_fonts.GetSize()||!m_gfx_fonts.Get()[a].font)
1250 {
1252 if (m_gfx_texth) *m_gfx_texth=8;
1253 return 1.0;
1254 }
1255 return 0.0;
1256}
1257
1258void eel_lice_state::gfx_blitext2(int np, EEL_F **parms, int blitmode)
1259{
1260 LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_blitext2");
1261
1262 if (!dest
1263#ifdef DYNAMIC_LICE
1265#endif
1266 ) return;
1267
1268 LICE_IBitmap *bm=GetImageForIndex(parms[0][0],"gfx_blitext2:src");
1269 if (!bm) return;
1270
1271 const int bmw=LICE__GetWidth(bm);
1272 const int bmh=LICE__GetHeight(bm);
1273
1274 // 0=img, 1=scale, 2=rotate
1275 double coords[8];
1276 const double sc = blitmode==0 && np > 1 ? parms[1][0] : 1.0,
1277 angle = blitmode==0 && np > 2 ? parms[2][0] : 0.0;
1278 if (blitmode==0)
1279 {
1280 parms+=2;
1281 np -= 2;
1282 }
1283
1284 coords[0]=np > 1 ? parms[1][0] : 0.0f;
1285 coords[1]=np > 2 ? parms[2][0] : 0.0f;
1286 coords[2]=np > 3 ? parms[3][0] : bmw;
1287 coords[3]=np > 4 ? parms[4][0] : bmh;
1288 coords[4]=np > 5 ? parms[5][0] : *m_gfx_x;
1289 coords[5]=np > 6 ? parms[6][0] : *m_gfx_y;
1290 coords[6]=np > 7 ? parms[7][0] : coords[2]*sc;
1291 coords[7]=np > 8 ? parms[8][0] : coords[3]*sc;
1292
1293 const bool isFromFB = bm == m_framebuffer;
1294 SetImageDirty(dest);
1295
1296 if (bm == dest &&
1297 (blitmode != 0 || np > 1) && // legacy behavior to matech previous gfx_blit(3parm), do not use temp buffer
1298 CoordsSrcDestOverlap(coords))
1299 {
1302 {
1303
1305 LICE_ScaledBlit(bm,dest, // copy the source portion
1306 (int)coords[0],(int)coords[1],(int)coords[2],(int)coords[3],
1307 (float)coords[0],(float)coords[1],(float)coords[2],(float)coords[3],
1308 1.0f,LICE_BLIT_MODE_COPY);
1309 }
1310 }
1311
1312 if (blitmode==1)
1313 {
1315 LICE_DeltaBlit(dest,bm,(int)coords[4],(int)coords[5],(int)coords[6],(int)coords[7],
1316 (float)coords[0],(float)coords[1],(float)coords[2],(float)coords[3],
1317 np > 9 ? (float)parms[9][0]:1.0f, // dsdx
1318 np > 10 ? (float)parms[10][0]:0.0f, // dtdx
1319 np > 11 ? (float)parms[11][0]:0.0f, // dsdy
1320 np > 12 ? (float)parms[12][0]:1.0f, // dtdy
1321 np > 13 ? (float)parms[13][0]:0.0f, // dsdxdy
1322 np > 14 ? (float)parms[14][0]:0.0f, // dtdxdy
1323 np <= 15 || parms[15][0] > 0.5, (float)*m_gfx_a,getCurModeForBlit(isFromFB));
1324 }
1325 else if (fabs(angle)>0.000000001)
1326 {
1327 LICE_RotatedBlit(dest,bm,(int)coords[4],(int)coords[5],(int)coords[6],(int)coords[7],
1328 (float)coords[0],(float)coords[1],(float)coords[2],(float)coords[3],
1329 (float)angle,true, (float)*m_gfx_a,getCurModeForBlit(isFromFB),
1330 np > 9 ? (float)parms[9][0] : 0.0f,
1331 np > 10 ? (float)parms[10][0] : 0.0f);
1332 }
1333 else
1334 {
1335 LICE_ScaledBlit(dest,bm,(int)coords[4],(int)coords[5],(int)coords[6],(int)coords[7],
1336 (float)coords[0],(float)coords[1],(float)coords[2],(float)coords[3], (float)*m_gfx_a,getCurModeForBlit(isFromFB));
1337 }
1338}
1339
1340void eel_lice_state::gfx_blitext(EEL_F img, EEL_F *coords, EEL_F angle)
1341{
1342 LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_blitext");
1343
1344 if (!dest
1345#ifdef DYNAMIC_LICE
1347#endif
1348 ) return;
1349
1350 LICE_IBitmap *bm=GetImageForIndex(img,"gfx_blitext:src");
1351 if (!bm) return;
1352
1353 SetImageDirty(dest);
1354 const bool isFromFB = bm == m_framebuffer;
1355
1356 int bmw=LICE__GetWidth(bm);
1357 int bmh=LICE__GetHeight(bm);
1358
1359 if (bm == dest && CoordsSrcDestOverlap(coords))
1360 {
1363 {
1364
1366 LICE_ScaledBlit(bm,dest, // copy the source portion
1367 (int)coords[0],(int)coords[1],(int)coords[2],(int)coords[3],
1368 (float)coords[0],(float)coords[1],(float)coords[2],(float)coords[3],
1369 1.0f,LICE_BLIT_MODE_COPY);
1370 }
1371 }
1372
1373 if (fabs(angle)>0.000000001)
1374 {
1375 LICE_RotatedBlit(dest,bm,(int)coords[4],(int)coords[5],(int)coords[6],(int)coords[7],
1376 (float)coords[0],(float)coords[1],(float)coords[2],(float)coords[3],(float)angle,
1377 true, (float)*m_gfx_a,getCurModeForBlit(isFromFB),
1378 (float)coords[8],(float)coords[9]);
1379 }
1380 else
1381 {
1382 LICE_ScaledBlit(dest,bm,(int)coords[4],(int)coords[5],(int)coords[6],(int)coords[7],
1383 (float)coords[0],(float)coords[1],(float)coords[2],(float)coords[3], (float)*m_gfx_a,getCurModeForBlit(isFromFB));
1384 }
1385}
1386
1387void eel_lice_state::gfx_set(int np, EEL_F **parms)
1388{
1389 if (np < 1) return;
1390 if (m_gfx_r) *m_gfx_r = parms[0][0];
1391 if (m_gfx_g) *m_gfx_g = np > 1 ? parms[1][0] : parms[0][0];
1392 if (m_gfx_b) *m_gfx_b = np > 2 ? parms[2][0] : parms[0][0];
1393 if (m_gfx_a) *m_gfx_a = np > 3 ? parms[3][0] : 1.0;
1394 if (m_gfx_mode) *m_gfx_mode = np > 4 ? parms[4][0] : 0;
1395 if (np > 5 && m_gfx_dest) *m_gfx_dest = parms[5][0];
1396 if (m_gfx_a2) *m_gfx_a2 = np > 6 ? parms[6][0] : 1.0;
1397}
1398
1399void eel_lice_state::gfx_getpixel(EEL_F *r, EEL_F *g, EEL_F *b)
1400{
1401 LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_getpixel");
1402 if (!dest) return;
1403
1404 int ret=LICE_FUNCTION_VALID(LICE_GetPixel)?LICE_GetPixel(dest,(int)*m_gfx_x, (int)*m_gfx_y):0;
1405
1406 *r=LICE_GETR(ret)/255.0;
1407 *g=LICE_GETG(ret)/255.0;
1408 *b=LICE_GETB(ret)/255.0;
1409
1410}
1411
1412
1413static int __drawTextWithFont(LICE_IBitmap *dest, const RECT *rect, LICE_IFont *font, const char *buf, int buflen,
1414 int fg, int mode, float alpha, int flags, EEL_F *wantYoutput, EEL_F **measureOnly)
1415{
1417 {
1418 RECT tr=*rect;
1419 LICE__SetTextColor(font,fg);
1420 LICE__SetTextCombineMode(font,mode,alpha);
1421
1422 int maxx=0;
1423 RECT r={0,0,tr.left,0};
1424 while (buflen>0)
1425 {
1426 int thislen = 0;
1427 while (thislen < buflen && buf[thislen] != '\n') thislen++;
1428 memset(&r,0,sizeof(r));
1429 int lineh = LICE__DrawText(font,dest,buf,thislen?thislen:1,&r,DT_SINGLELINE|DT_NOPREFIX|DT_CALCRECT);
1430 if (!measureOnly)
1431 {
1432 r.right += tr.left;
1433 lineh = LICE__DrawText(font,dest,buf,thislen?thislen:1,&tr,DT_SINGLELINE|DT_NOPREFIX|flags);
1434 if (wantYoutput) *wantYoutput = tr.top;
1435 }
1436 else
1437 {
1438 if (r.right > maxx) maxx=r.right;
1439 }
1440 tr.top += lineh;
1441
1442 buflen -= thislen+1;
1443 buf += thislen+1;
1444 }
1445 if (measureOnly)
1446 {
1447 measureOnly[0][0] = maxx;
1448 measureOnly[1][0] = tr.top;
1449 }
1450 return r.right;
1451 }
1452 else
1453 {
1454 int xpos=rect->left, ypos=rect->top;
1455 int x;
1456 int maxx=0,maxy=0;
1457
1458 LICE_SubBitmap sbm(
1459#ifdef DYNAMIC_LICE
1460 (LICE_IBitmap_disabledAPI*)
1461#endif
1462 dest,rect->left,rect->top,rect->right-rect->left,rect->bottom-rect->top);
1463
1464 if (!measureOnly)
1465 {
1466 if (!(flags & DT_NOCLIP))
1467 {
1468 if (rect->right <= rect->left || rect->bottom <= rect->top) return 0; // invalid clip rect hm
1469
1470 xpos = ypos = 0;
1471 dest = &sbm;
1472 }
1473 if (flags & (DT_RIGHT|DT_BOTTOM|DT_CENTER|DT_VCENTER))
1474 {
1475 EEL_F w=0.0,h=0.0;
1476 EEL_F *mo[2] = { &w,&h};
1477 RECT tr={0,};
1478 __drawTextWithFont(dest,&tr,NULL,buf,buflen,0,0,0.0f,0,NULL,mo);
1479
1480 if (flags & DT_RIGHT) xpos += (rect->right-rect->left) - (int)floor(w);
1481 else if (flags & DT_CENTER) xpos += (rect->right-rect->left)/2 - (int)floor(w*.5);
1482
1483 if (flags & DT_BOTTOM) ypos += (rect->bottom-rect->top) - (int)floor(h);
1484 else if (flags & DT_VCENTER) ypos += (rect->bottom-rect->top)/2 - (int)floor(h*.5);
1485 }
1486 }
1487 const int sxpos = xpos;
1488
1489 if (LICE_FUNCTION_VALID(LICE_DrawChar)) for(x=0;x<buflen;x++)
1490 {
1491 switch (buf[x])
1492 {
1493 case '\n':
1494 ypos += 8;
1495 case '\r':
1496 xpos = sxpos;
1497 break;
1498 case ' ': xpos += 8; break;
1499 case '\t': xpos += 8*5; break;
1500 default:
1501 if (!measureOnly) LICE_DrawChar(dest,xpos,ypos,buf[x], fg,alpha,mode);
1502 xpos += 8;
1503 if (xpos > maxx) maxx=xpos;
1504 maxy = ypos + 8;
1505 break;
1506 }
1507 }
1508 if (measureOnly)
1509 {
1510 measureOnly[0][0]=maxx;
1511 measureOnly[1][0]=maxy;
1512 }
1513 else
1514 {
1515 if (wantYoutput) *wantYoutput=ypos;
1516 }
1517 return xpos;
1518 }
1519}
1520
1521static HMENU PopulateMenuFromStr(const char** str, int* startid)
1522{
1524 int pos=0;
1525 int id=*startid;
1526
1527 char buf[1024];
1528 const char* p=*str;
1529 const char* sep=strchr(p, '|');
1530 while (sep || *p)
1531 {
1532 int len = (int)(sep ? sep-p : strlen(p));
1533 int destlen=wdl_min(len, (int)sizeof(buf)-1);
1534 lstrcpyn(buf, p, destlen+1);
1535 p += len;
1536 if (sep) sep=strchr(++p, '|');
1537
1538 const char* q=buf;
1539 HMENU subm=NULL;
1540 bool done=false;
1541 int flags=MF_BYPOSITION|MF_STRING;
1542 while (strspn(q, ">#!<"))
1543 {
1544 if (*q == '>' && !subm)
1545 {
1546 subm=PopulateMenuFromStr(&p, &id);
1547 sep=strchr(p, '|');
1548 }
1549 if (*q == '#') flags |= MF_GRAYED;
1550 if (*q == '!') flags |= MF_CHECKED;
1551 if (*q == '<') done=true;
1552 ++q;
1553 }
1554 if (subm) flags |= MF_POPUP;
1555 if (*q) InsertMenu(hm, pos++, flags, (subm ? (INT_PTR)subm : (INT_PTR)id++), q);
1556 else if (!done) InsertMenu(hm, pos++, MF_BYPOSITION|MF_SEPARATOR, 0, NULL);
1557 if (done) break;
1558 }
1559
1560 *str=p;
1561 *startid=id;
1562
1563 if (!pos)
1564 {
1565 DestroyMenu(hm);
1566 return NULL;
1567 }
1568 return hm;
1569}
1570
1571EEL_F eel_lice_state::gfx_showmenu(void* opaque, EEL_F** parms, int nparms)
1572{
1573 const char* p=EEL_STRING_GET_FOR_INDEX(parms[0][0], NULL);
1574 if (!p || !p[0]) return 0.0;
1575
1576 int id=1;
1577 HMENU hm=PopulateMenuFromStr(&p, &id);
1578
1579 int ret=0;
1580 if (hm)
1581 {
1582 POINT pt;
1583 if (hwnd_standalone)
1584 {
1585#ifdef __APPLE__
1586 if (*m_gfx_ext_retina > 1.0)
1587 {
1588 pt.x = (short)(*m_gfx_x * .5);
1589 pt.y = (short)(*m_gfx_y * .5);
1590 }
1591 else
1592#endif
1593 {
1594 pt.x = (short)*m_gfx_x;
1595 pt.y = (short)*m_gfx_y;
1596 }
1597 ClientToScreen(hwnd_standalone, &pt);
1598 }
1599 else
1600 GetCursorPos(&pt);
1601 ret=TrackPopupMenu(hm, TPM_NONOTIFY|TPM_RETURNCMD, pt.x, pt.y, 0, hwnd_standalone, NULL);
1602 DestroyMenu(hm);
1603 }
1604 return (EEL_F)ret;
1605}
1606
1607EEL_F eel_lice_state::gfx_setcursor(void* opaque, EEL_F** parms, int nparms)
1608{
1609 if (!hwnd_standalone) return 0.0;
1610
1611 bool chg = false;
1612 const int nc = (int)parms[0][0];
1613 if (m_cursor_resid != nc)
1614 {
1615 m_cursor_resid = nc;
1616 chg = true;
1617 }
1618
1619 const char *p = NULL;
1620#ifdef EEL_LICE_LOADTHEMECURSOR
1621 if (nparms > 1) p=EEL_STRING_GET_FOR_INDEX(parms[1][0], NULL);
1622
1623 if (strncmp(p?p:"",m_cursor_name,sizeof(m_cursor_name)-1))
1624 {
1625 lstrcpyn(m_cursor_name, p?p:"", sizeof(m_cursor_name));
1626 chg = true;
1627 }
1628#endif
1629
1630 if (chg)
1631 {
1632 m_cursor = NULL;
1633 if (m_cursor_resid > 0)
1634 {
1635 if (!p || !*p) m_cursor = LoadCursor(NULL, MAKEINTRESOURCE(m_cursor_resid));
1636#ifdef EEL_LICE_LOADTHEMECURSOR
1637 else m_cursor = EEL_LICE_LOADTHEMECURSOR(m_cursor_resid, p);
1638#endif
1639 }
1640
1641 bool do_set = GetCapture() == hwnd_standalone;
1642 if (!do_set && GetFocus() == hwnd_standalone)
1643 {
1644 POINT pt;
1645 RECT r;
1646 GetCursorPos(&pt);
1647 ScreenToClient(hwnd_standalone,&pt);
1648 GetClientRect(hwnd_standalone,&r);
1649 do_set = PtInRect(&r,pt)!=0;
1650 }
1651
1652 if (do_set)
1653 {
1654 SetCursor(m_cursor ? m_cursor : LoadCursor(NULL,IDC_ARROW));
1655 }
1656 }
1657
1658 return 1.0;
1659}
1660
1661
1662void eel_lice_state::gfx_drawstr(void *opaque, EEL_F **parms, int nparms, int formatmode)// formatmode=1 for format, 2 for purely measure no format
1663{
1664 int nfmtparms = nparms-1;
1665 EEL_F **fmtparms = parms+1;
1666 const char *funcname = formatmode==1?"gfx_printf":
1667 formatmode==2?"gfx_measurestr":
1668 formatmode==3?"gfx_measurechar" : "gfx_drawstr";
1669
1670 LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,funcname);
1671 if (!dest) return;
1672
1673#ifdef DYNAMIC_LICE
1674 if (!LICE__GetWidth || !LICE__GetHeight) return;
1675#endif
1676
1678
1679 WDL_FastString *fs=NULL;
1680 char buf[4096];
1681 int s_len=0;
1682
1683 const char *s;
1684 if (formatmode==3)
1685 {
1686 s_len = WDL_MakeUTFChar(buf, (int)parms[0][0], sizeof(buf));
1687 s=buf;
1688 }
1689 else
1690 {
1691 s=EEL_STRING_GET_FOR_INDEX(parms[0][0],&fs);
1692 #ifdef EEL_STRING_DEBUGOUT
1693 if (!s) EEL_STRING_DEBUGOUT("gfx_%s: invalid string identifier %f",funcname,parms[0][0]);
1694 #endif
1695 if (!s)
1696 {
1697 s="<bad string>";
1698 s_len = 12;
1699 }
1700 else if (formatmode==1)
1701 {
1702 extern int eel_format_strings(void *, const char *s, const char *ep, char *, int, int, EEL_F **);
1703 s_len = eel_format_strings(opaque,s,fs?(s+fs->GetLength()):NULL,buf,sizeof(buf),nfmtparms,fmtparms);
1704 if (s_len<1) return;
1705 s=buf;
1706 }
1707 else
1708 {
1709 s_len = fs?fs->GetLength():(int)strlen(s);
1710 }
1711 }
1712
1713 if (s_len)
1714 {
1715 SetImageDirty(dest);
1716 if (formatmode>=2)
1717 {
1718 if (nfmtparms==2)
1719 {
1720 RECT r={0,0,0,0};
1721 __drawTextWithFont(dest,&r,GetActiveFont(),s,s_len,
1722 getCurColor(),getCurMode(),(float)*m_gfx_a,0,NULL,fmtparms);
1723 }
1724 }
1725 else
1726 {
1727 RECT r={(int)floor(*m_gfx_x),(int)floor(*m_gfx_y),0,0};
1728 int flags=DT_NOCLIP;
1729 if (formatmode == 0 && nparms >= 4)
1730 {
1731 flags=(int)*parms[1];
1733 r.right=(int)*parms[2];
1734 r.bottom=(int)*parms[3];
1735 }
1737 getCurColor(),getCurMode(),(float)*m_gfx_a,flags,m_gfx_y,NULL);
1738 }
1739 }
1740}
1741
1743{
1744 LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_drawchar");
1745 if (!dest) return;
1746
1747 SetImageDirty(dest);
1748
1749 int a=(int)(ch+0.5);
1750 if (a == '\r' || a=='\n') a=' ';
1751
1752 char buf[32];
1753 const int buflen = WDL_MakeUTFChar(buf, a, sizeof(buf));
1754
1755 RECT r={(int)floor(*m_gfx_x),(int)floor(*m_gfx_y),0,0};
1756 *m_gfx_x = __drawTextWithFont(dest,&r,
1757 GetActiveFont(),buf,buflen,
1759
1760}
1761
1762
1763void eel_lice_state::gfx_drawnumber(EEL_F n, EEL_F ndigits)
1764{
1765 LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_drawnumber");
1766 if (!dest) return;
1767
1768 SetImageDirty(dest);
1769
1770 char buf[512];
1771 int a=(int)(ndigits+0.5);
1772 if (a <0)a=0;
1773 else if (a > 16) a=16;
1774 snprintf(buf,sizeof(buf),"%.*f",a,n);
1775
1776 RECT r={(int)floor(*m_gfx_x),(int)floor(*m_gfx_y),0,0};
1777 *m_gfx_x = __drawTextWithFont(dest,&r,
1778 GetActiveFont(),buf,(int)strlen(buf),
1780}
1781
1782int eel_lice_state::setup_frame(HWND hwnd, RECT r, int _mouse_x, int _mouse_y, int has_dpi)
1783{
1784 int use_w = r.right - r.left;
1785 int use_h = r.bottom - r.top;
1786
1787 POINT pt = { _mouse_x, _mouse_y };
1788 if (hwnd)
1789 {
1790 GetCursorPos(&pt);
1791 ScreenToClient(hwnd,&pt);
1792 }
1793
1794 *m_mouse_x=pt.x-r.left;
1795 *m_mouse_y=pt.y-r.top;
1796
1797 if (has_dpi>0 && *m_gfx_ext_retina > 0.0)
1798 {
1799 *m_gfx_ext_retina = has_dpi/256.0;
1800 }
1801 else if (*m_gfx_ext_retina > 0.0)
1802 {
1803#ifdef __APPLE__
1804 *m_gfx_ext_retina = (hwnd && SWELL_IsRetinaHWND(hwnd)) ? 2.0 : 1.0;
1805 if (*m_gfx_ext_retina > 1.0)
1806 {
1807 *m_mouse_x *= 2.0;
1808 *m_mouse_y *= 2.0;
1809 use_w*=2;
1810 use_h*=2;
1811 }
1812#else
1813 *m_gfx_ext_retina = 1.0;
1814 #ifdef _WIN32
1815 static UINT (WINAPI *__GetDpiForWindow)(HWND);
1816 if (!__GetDpiForWindow)
1817 {
1818 HINSTANCE h = LoadLibrary("user32.dll");
1819 if (h) *(void **)&__GetDpiForWindow = GetProcAddress(h,"GetDpiForWindow");
1820 if (!__GetDpiForWindow)
1821 *(void **)&__GetDpiForWindow = (void*)(INT_PTR)1;
1822 }
1823 if (hwnd && (UINT_PTR)__GetDpiForWindow > (UINT_PTR)1)
1824 {
1825 int dpi = __GetDpiForWindow(hwnd);
1826 if (dpi != 96)
1827 *m_gfx_ext_retina = dpi / 96.0;
1828 }
1829 #else
1830 const int rsc = SWELL_GetScaling256();
1831 if (rsc > 256) *m_gfx_ext_retina = rsc/256.0;
1832 #endif
1833#endif
1834 }
1835 int dr=0;
1837 {
1838 m_framebuffer=__LICE_CreateBitmap(1,use_w,use_h);
1839 dr=1;
1840 }
1841
1843
1844 if (use_w != LICE__GetWidth(m_framebuffer) || use_h != LICE__GetHeight(m_framebuffer))
1845 {
1846 LICE__resize(m_framebuffer,use_w,use_h);
1847 dr=1;
1848 }
1849 *m_gfx_w = use_w;
1850 *m_gfx_h = use_h;
1851
1852 if (*m_gfx_clear > -1.0 && dr)
1853 {
1854 const int a=(int)*m_gfx_clear;
1855 if (LICE_FUNCTION_VALID(LICE_Clear)) LICE_Clear(m_framebuffer,LICE_RGBA((a&0xff),((a>>8)&0xff),((a>>16)&0xff),0));
1856 }
1858
1859 int vflags=0;
1860
1861 if (m_has_cap)
1862 {
1863 bool swap = false;
1864#ifdef _WIN32
1865 swap = !!GetSystemMetrics(SM_SWAPBUTTON);
1866#endif
1867 vflags|=m_has_cap&0xffff;
1868 if (GetAsyncKeyState(VK_LBUTTON)&0x8000) vflags|=swap?2:1;
1869 if (GetAsyncKeyState(VK_RBUTTON)&0x8000) vflags|=swap?1:2;
1870 if (GetAsyncKeyState(VK_MBUTTON)&0x8000) vflags|=64;
1871 }
1872 if (m_has_cap || (m_has_had_getch && hwnd && GetFocus()==hwnd))
1873 {
1874 if (GetAsyncKeyState(VK_CONTROL)&0x8000) vflags|=4;
1875 if (GetAsyncKeyState(VK_SHIFT)&0x8000) vflags|=8;
1876 if (GetAsyncKeyState(VK_MENU)&0x8000) vflags|=16;
1877 if (GetAsyncKeyState(VK_LWIN)&0x8000) vflags|=32;
1878 }
1879 m_has_cap &= 0xf0000;
1880
1881 *m_mouse_cap=(EEL_F)vflags;
1882
1883 *m_gfx_dest = -1.0; // m_framebuffer
1884 *m_gfx_a2 = *m_gfx_a = 1.0; // default to full alpha every call
1885 int fh;
1886 if (m_gfx_font_active>=0&&m_gfx_font_active<m_gfx_fonts.GetSize() && (fh=m_gfx_fonts.Get()[m_gfx_font_active].use_fonth)>0)
1887 *m_gfx_texth=fh;
1888 else
1889 *m_gfx_texth = 8;
1890
1891 return dr;
1892}
1893
1895{
1896 if (hwnd_standalone && m_framebuffer_dirty)
1897 {
1898#ifdef __APPLE__
1899 void *p = SWELL_InitAutoRelease();
1900#endif
1901
1902 InvalidateRect(hwnd_standalone,NULL,FALSE);
1903 UpdateWindow(hwnd_standalone);
1904
1905#ifdef __APPLE__
1906 SWELL_QuitAutoRelease(p);
1907#endif
1909 }
1910}
1911
1912#ifndef EEL_LICE_NO_REGISTER
1914{
1919 NSEEL_addfunc_varparm("gfx_line",4,NSEEL_PProc_THIS,&_gfx_line); // 5th param is optionally AA
1949}
1950#endif
1951
1952#ifdef EEL_LICE_WANT_STANDALONE
1953
1954#ifdef _WIN32
1955static HINSTANCE eel_lice_hinstance;
1956#endif
1957static const char *eel_lice_standalone_classname;
1958
1959#ifdef EEL_LICE_WANT_STANDALONE_UPDATE
1960static EEL_F * NSEEL_CGEN_CALL _gfx_update(void *opaque, EEL_F *n)
1961{
1963 if (ctx)
1964 {
1965 ctx->m_ddrop_files.Empty(true,free);
1966 if (ctx->hwnd_standalone)
1967 {
1968#ifndef EEL_LICE_WANT_STANDALONE_UPDATE_NO_SETUPFRAME
1969 ctx->finish_draw();
1970#endif
1971
1972 // run message pump
1973#ifndef EEL_LICE_WANT_STANDALONE_UPDATE_NO_MSGPUMP
1974
1975#ifdef _WIN32
1976 MSG msg;
1977 while (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
1978 {
1979 TranslateMessage(&msg);
1980 DispatchMessage(&msg);
1981 }
1982#else
1983 void SWELL_RunEvents();
1985#endif
1986#endif
1987#ifndef EEL_LICE_WANT_STANDALONE_UPDATE_NO_SETUPFRAME
1988 RECT r;
1989 GetClientRect(ctx->hwnd_standalone,&r);
1990 ctx->setup_frame(ctx->hwnd_standalone,r);
1991#endif
1992 }
1993 }
1994 return n;
1995}
1996#endif
1997
1998
1999
2000static EEL_F NSEEL_CGEN_CALL _gfx_getchar(void *opaque, EEL_F *p)
2001{
2003 if (ctx)
2004 {
2005 ctx->m_has_had_getch=true;
2006 if (*p >= 2.0)
2007 {
2008 if (*p == 65536.0)
2009 {
2010 int rv = 1;
2011 if (ctx->hwnd_standalone)
2012 {
2013 if (ctx->hwnd_standalone==GetFocus()) rv|=2;
2014 if (IsWindowVisible(ctx->hwnd_standalone)) rv|=4;
2015 }
2016 return rv;
2017 }
2018 int x;
2019 const int n = sizeof(ctx->hwnd_standalone_kb_state) / sizeof(ctx->hwnd_standalone_kb_state[0]);
2020 int *st = ctx->hwnd_standalone_kb_state;
2021 int a = (int)*p;
2022 for (x=0;x<n && st[x] != a;x++);
2023 return x<n ? 1.0 : 0.0;
2024 }
2025
2026 if (!ctx->hwnd_standalone) return -1.0;
2027
2028 if (ctx->m_kb_queue_valid)
2029 {
2030 const int qsize = sizeof(ctx->m_kb_queue)/sizeof(ctx->m_kb_queue[0]);
2031 const int a = ctx->m_kb_queue[ctx->m_kb_queue_pos & (qsize-1)];
2032 ctx->m_kb_queue_pos++;
2033 ctx->m_kb_queue_valid--;
2034 return a;
2035 }
2036 }
2037 return 0.0;
2038}
2039
2040static int eel_lice_key_xlate(int msg, int wParam, int lParam, bool *isAltOut)
2041{
2042#define EEL_MB_C(a) (sizeof(a)<=2 ? a[0] : \
2043 sizeof(a)==3 ? (((a[0])<<8)+(a[1])) : \
2044 sizeof(a)==4 ? (((a[0])<<16)+((a[1])<<8)+(a[2])) : \
2045 (((a[0])<<24)+((a[1])<<16)+((a[2])<<8)+(a[3])))
2046
2047 if (msg != WM_CHAR)
2048 {
2049#ifndef _WIN32
2050 if (lParam & FVIRTKEY)
2051#endif
2052 switch (wParam)
2053 {
2054 case VK_HOME: return EEL_MB_C("home");
2055 case VK_UP: return EEL_MB_C("up");
2056 case VK_PRIOR: return EEL_MB_C("pgup");
2057 case VK_LEFT: return EEL_MB_C("left");
2058 case VK_RIGHT: return EEL_MB_C("rght");
2059 case VK_END: return EEL_MB_C("end");
2060 case VK_DOWN: return EEL_MB_C("down");
2061 case VK_NEXT: return EEL_MB_C("pgdn");
2062 case VK_INSERT: return EEL_MB_C("ins");
2063 case VK_DELETE: return EEL_MB_C("del");
2064 case VK_F1: return EEL_MB_C("f1");
2065 case VK_F2: return EEL_MB_C("f2");
2066 case VK_F3: return EEL_MB_C("f3");
2067 case VK_F4: return EEL_MB_C("f4");
2068 case VK_F5: return EEL_MB_C("f5");
2069 case VK_F6: return EEL_MB_C("f6");
2070 case VK_F7: return EEL_MB_C("f7");
2071 case VK_F8: return EEL_MB_C("f8");
2072 case VK_F9: return EEL_MB_C("f9");
2073 case VK_F10: return EEL_MB_C("f10");
2074 case VK_F11: return EEL_MB_C("f11");
2075 case VK_F12: return EEL_MB_C("f12");
2076#ifndef _WIN32
2077 case VK_SUBTRACT: return '-'; // numpad -
2078 case VK_ADD: return '+';
2079 case VK_MULTIPLY: return '*';
2080 case VK_DIVIDE: return '/';
2081 case VK_DECIMAL: return '.';
2082 case VK_NUMPAD0: return '0';
2083 case VK_NUMPAD1: return '1';
2084 case VK_NUMPAD2: return '2';
2085 case VK_NUMPAD3: return '3';
2086 case VK_NUMPAD4: return '4';
2087 case VK_NUMPAD5: return '5';
2088 case VK_NUMPAD6: return '6';
2089 case VK_NUMPAD7: return '7';
2090 case VK_NUMPAD8: return '8';
2091 case VK_NUMPAD9: return '9';
2092 case (32768|VK_RETURN): return VK_RETURN;
2093#endif
2094 }
2095
2096 switch (wParam)
2097 {
2098 case VK_RETURN:
2099 case VK_BACK:
2100 case VK_TAB:
2101 case VK_ESCAPE:
2102 return wParam;
2103
2104 case VK_CONTROL: break;
2105
2106 default:
2107 {
2108 const bool isctrl = !!(GetAsyncKeyState(VK_CONTROL)&0x8000);
2109 const bool isalt = !!(GetAsyncKeyState(VK_MENU)&0x8000);
2110 if(isctrl || isalt)
2111 {
2112 if (wParam>='a' && wParam<='z')
2113 {
2114 if (isctrl) wParam += 1-'a';
2115 if (isalt) wParam += 256;
2116 *isAltOut=isalt;
2117 return wParam;
2118 }
2119 if (wParam>='A' && wParam<='Z')
2120 {
2121 if (isctrl) wParam += 1-'A';
2122 if (isalt) wParam += 256;
2123 *isAltOut=isalt;
2124 return wParam;
2125 }
2126 }
2127
2128 if (isctrl)
2129 {
2130 if ((wParam&~0x80) == '[') return 27;
2131 if ((wParam&~0x80) == ']') return 29;
2132 }
2133 }
2134 break;
2135 }
2136 }
2137
2138 if(wParam>=32)
2139 {
2140 #ifdef _WIN32
2141 if (msg == WM_CHAR) return wParam;
2142 #else
2143 if (!(GetAsyncKeyState(VK_SHIFT)&0x8000))
2144 {
2145 if (wParam>='A' && wParam<='Z')
2146 {
2147 if ((GetAsyncKeyState(VK_LWIN)&0x8000)) wParam -= 'A'-1;
2148 else
2149 wParam += 'a'-'A';
2150 }
2151 }
2152 return wParam;
2153 #endif
2154 }
2155 return 0;
2156}
2157#undef EEL_MB_C
2158
2159static LRESULT WINAPI eel_lice_wndproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
2160#ifdef __APPLE__
2161extern "C"
2162{
2163 void *objc_getClass(const char *p);
2164#ifndef _OBJC_OBJC_H_
2165 void *sel_getUid(const char *p);
2166#endif
2167 void objc_msgSend(void);
2168};
2169#endif
2170
2171
2172HWND eel_lice_state::create_wnd(HWND par, int isChild)
2173{
2174 if (hwnd_standalone) return hwnd_standalone;
2175#ifdef _WIN32
2176 return CreateWindowEx(WS_EX_ACCEPTFILES,eel_lice_standalone_classname,"",
2177 isChild ? (WS_CHILD|WS_TABSTOP) : (WS_POPUP|WS_CAPTION|WS_THICKFRAME|WS_SYSMENU),CW_USEDEFAULT,CW_USEDEFAULT,100,100,par,NULL,eel_lice_hinstance,this);
2178#else
2179 HWND h = SWELL_CreateDialog(NULL,isChild ? NULL : ((const char *)(INT_PTR)0x400001),par,(DLGPROC)eel_lice_wndproc,(LPARAM)this);
2180 if (h)
2181 {
2182 SWELL_SetClassName(h,eel_lice_standalone_classname);
2184 }
2185 return h;
2186#endif
2187}
2188
2189#ifdef EEL_LICE_WANTDOCK
2190#ifndef ID_DOCKWINDOW
2191#define ID_DOCKWINDOW 40269
2192#endif
2193
2194static EEL_F NSEEL_CGEN_CALL _gfx_dock(void *opaque, INT_PTR np, EEL_F **parms)
2195{
2197 if (ctx)
2198 {
2199 if (np > 0 && parms[0][0] >= 0.0 && ctx->hwnd_standalone) EEL_LICE_WANTDOCK(ctx,(int)parms[0][0]);
2200
2201 if (np > 1 && parms[1]) parms[1][0] = ctx->m_last_undocked_r.left;
2202 if (np > 2 && parms[2]) parms[2][0] = ctx->m_last_undocked_r.top;
2203 if (np > 3 && parms[3]) parms[3][0] = ctx->m_last_undocked_r.right;
2204 if (np > 4 && parms[4]) parms[4][0] = ctx->m_last_undocked_r.bottom;
2205
2206#ifdef EEL_LICE_ISDOCKED
2207 return EEL_LICE_ISDOCKED(ctx);
2208#endif
2209 }
2210 return 0.0;
2211}
2212
2213#endif //EEL_LICE_WANTDOCK
2214
2215
2216#ifndef EEL_LICE_STANDALONE_NOINITQUIT
2217
2218static EEL_F * NSEEL_CGEN_CALL _gfx_quit(void *opaque, EEL_F *n)
2219{
2221 if (ctx)
2222 {
2223 if (ctx->hwnd_standalone)
2224 {
2225 DestroyWindow(ctx->hwnd_standalone);
2226 }
2227 ctx->hwnd_standalone=0;
2228 }
2229 return n;
2230}
2231
2232static EEL_F NSEEL_CGEN_CALL _gfx_init(void *opaque, INT_PTR np, EEL_F **parms)
2233{
2234#ifdef EEL_LICE_GET_CONTEXT_INIT
2235 eel_lice_state *ctx=EEL_LICE_GET_CONTEXT_INIT(opaque);
2236#else
2238#endif
2239 if (ctx)
2240 {
2241 bool wantShow=false, wantResize=true;
2242 int sug_w = np > 1 ? (int)parms[1][0] : 640;
2243 int sug_h = np > 2 ? (int)parms[2][0] : 480;
2244 if (sug_w <1 && sug_h < 1 && ctx->hwnd_standalone)
2245 {
2246 RECT r;
2247 GetClientRect(ctx->hwnd_standalone,&r);
2248 sug_w = r.right;
2249 sug_h = r.bottom;
2250 }
2251 #ifdef EEL_LICE_WANTDOCK
2252 const int pos_offs = 4;
2253 #else
2254 const int pos_offs = 3;
2255 #endif
2256
2257 if (sug_w < 16) sug_w=16;
2258 else if (sug_w > 8192) sug_w=8192;
2259 if (sug_h < 16) sug_h=16;
2260 else if (sug_h > 8192) sug_h=8192;
2261
2262 if (!ctx->hwnd_standalone)
2263 {
2264 #ifdef __APPLE__
2265 void *(*send_msg)(void *, void *) = (void *(*)(void *, void *))objc_msgSend;
2266 void (*send_msg_longparm)(void *, void *, long) = (void (*)(void *, void *, long))objc_msgSend; // long = NSInteger
2267
2268 void *nsapp=send_msg( objc_getClass("NSApplication"), sel_getUid("sharedApplication"));
2269 send_msg_longparm(nsapp,sel_getUid("setActivationPolicy:"), 0);
2270 send_msg_longparm(nsapp,sel_getUid("activateIgnoringOtherApps:"), 1);
2271
2272 #endif
2273
2274 #ifdef EEL_LICE_STANDALONE_PARENT
2275 HWND par = EEL_LICE_STANDALONE_PARENT(opaque);
2276 #elif defined(_WIN32)
2277 HWND par=GetDesktopWindow();
2278 #else
2279 HWND par=NULL;
2280 #endif
2281
2282 ctx->create_wnd(par,0);
2283 // resize client
2284
2285 if (ctx->hwnd_standalone)
2286 {
2287 int px=0,py=0;
2288 if (np >= pos_offs+2)
2289 {
2290 px = (int) floor(parms[pos_offs][0] + 0.5);
2291 py = (int) floor(parms[pos_offs+1][0] + 0.5);
2292#ifdef EEL_LICE_VALIDATE_RECT_ON_SCREEN
2293 RECT r = {px,py,px+sug_w,py+sug_h};
2294 EEL_LICE_VALIDATE_RECT_ON_SCREEN(r);
2295 px=r.left; py=r.top; sug_w = r.right-r.left; sug_h = r.bottom-r.top;
2296#endif
2297 ctx->m_last_undocked_r.left = px;
2298 ctx->m_last_undocked_r.top = py;
2299 ctx->m_last_undocked_r.right = sug_w;
2300 ctx->m_last_undocked_r.bottom = sug_h;
2301 }
2302
2303 RECT r1,r2;
2304 GetWindowRect(ctx->hwnd_standalone,&r1);
2305 GetClientRect(ctx->hwnd_standalone,&r2);
2306 sug_w += (r1.right-r1.left) - r2.right;
2307 sug_h += abs(r1.bottom-r1.top) - r2.bottom;
2308
2309 SetWindowPos(ctx->hwnd_standalone,NULL,px,py,sug_w,sug_h,(np >= pos_offs+2 ? 0:SWP_NOMOVE)|SWP_NOZORDER|SWP_NOACTIVATE);
2310
2311 wantShow=true;
2312 #ifdef EEL_LICE_WANTDOCK
2313 if (np > 3) EEL_LICE_WANTDOCK(ctx,parms[3][0]);
2314 #endif
2315 #ifdef EEL_LICE_WANT_STANDALONE_UPDATE
2316 {
2317 RECT r;
2318 GetClientRect(ctx->hwnd_standalone,&r);
2319 ctx->setup_frame(ctx->hwnd_standalone,r);
2320 }
2321 #endif
2322 }
2323 wantResize=false;
2324 }
2325 if (!ctx->hwnd_standalone) return 0;
2326
2327 if (np>0)
2328 {
2330 const char *title=EEL_STRING_GET_FOR_INDEX(parms[0][0],NULL);
2331 #ifdef EEL_STRING_DEBUGOUT
2332 if (!title) EEL_STRING_DEBUGOUT("gfx_init: invalid string identifier %f",parms[0][0]);
2333 #endif
2334 if (title&&*title)
2335 {
2336 SetWindowText(ctx->hwnd_standalone,title);
2337 wantResize=false; // ignore resize if we're setting title
2338 }
2339 }
2340 if (wantShow)
2341 ShowWindow(ctx->hwnd_standalone,SW_SHOW);
2342 if (wantResize && np>2 && !(GetWindowLong(ctx->hwnd_standalone,GWL_STYLE)&WS_CHILD))
2343 {
2344 RECT r1,r2;
2345 GetWindowRect(ctx->hwnd_standalone,&r1);
2346 GetClientRect(ctx->hwnd_standalone,&r2);
2347 const bool do_size = sug_w != r2.right || sug_h != r2.bottom;
2348
2349 sug_w += (r1.right-r1.left) - r2.right;
2350 sug_h += abs(r1.bottom-r1.top) - r2.bottom;
2351
2352 int px=0,py=0;
2353 const bool do_move=(np >= pos_offs+2);
2354 if (do_move)
2355 {
2356 px = (int) floor(parms[pos_offs][0] + 0.5);
2357 py = (int) floor(parms[pos_offs+1][0] + 0.5);
2358#ifdef EEL_LICE_VALIDATE_RECT_ON_SCREEN
2359 RECT r = {px,py,px+sug_w,py+sug_h};
2360 EEL_LICE_VALIDATE_RECT_ON_SCREEN(r);
2361 px=r.left; py=r.top; sug_w = r.right-r.left; sug_h = r.bottom-r.top;
2362#endif
2363 }
2364 if (do_size || do_move)
2365 SetWindowPos(ctx->hwnd_standalone,NULL,px,py,sug_w,sug_h,
2366 (do_size ? 0 : SWP_NOSIZE)|(do_move? 0:SWP_NOMOVE)|SWP_NOZORDER|SWP_NOACTIVATE);
2367 }
2368 return 1;
2369 }
2370 return 0;
2371}
2372
2373static EEL_F NSEEL_CGEN_CALL _gfx_screentoclient(void *opaque, EEL_F *x, EEL_F *y)
2374{
2376 if (ctx && ctx->hwnd_standalone)
2377 {
2378 POINT pt={(int) *x, (int) *y};
2379 ScreenToClient(ctx->hwnd_standalone,&pt);
2380 *x = pt.x;
2381 *y = pt.y;
2382 return 1.0;
2383 }
2384 return 0.0;
2385}
2386
2387static EEL_F NSEEL_CGEN_CALL _gfx_clienttoscreen(void *opaque, EEL_F *x, EEL_F *y)
2388{
2390 if (ctx && ctx->hwnd_standalone)
2391 {
2392 POINT pt={(int) *x, (int) *y};
2393 ClientToScreen(ctx->hwnd_standalone,&pt);
2394 *x = pt.x;
2395 *y = pt.y;
2396 return 1.0;
2397 }
2398 return 0.0;
2399}
2400
2401#endif // !EEL_LICE_STANDALONE_NOINITQUIT
2402
2403
2404#ifndef WM_MOUSEWHEEL
2405#define WM_MOUSEWHEEL 0x20A
2406#endif
2407#ifndef WM_MOUSEHWHEEL
2408#define WM_MOUSEHWHEEL 0x20E
2409#endif
2410
2411LRESULT WINAPI eel_lice_wndproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2412{
2413#ifdef WIN32
2414 static UINT Scroll_Message;
2415 static bool sm_init;
2416 if (!sm_init)
2417 {
2418 sm_init=true;
2419 Scroll_Message = RegisterWindowMessage("MSWHEEL_ROLLMSG");
2420 }
2421 if (Scroll_Message && uMsg == Scroll_Message)
2422 {
2423 uMsg=WM_MOUSEWHEEL;
2424 wParam<<=16;
2425 }
2426#endif
2427
2428 switch (uMsg)
2429 {
2430 case WM_CREATE:
2431 {
2432#ifdef _WIN32
2433 LPCREATESTRUCT lpcs= (LPCREATESTRUCT )lParam;
2434 eel_lice_state *ctx=(eel_lice_state*)lpcs->lpCreateParams;
2435 SetWindowLongPtr(hwnd,GWLP_USERDATA,(LPARAM)lpcs->lpCreateParams);
2436#else
2437 eel_lice_state *ctx=(eel_lice_state*)lParam;
2440#endif
2441 ctx->m_kb_queue_valid=0;
2442 ctx->hwnd_standalone=hwnd;
2443 }
2444 return 0;
2445#ifndef _WIN32
2446 case WM_CLOSE:
2448 return 0;
2449#endif
2450 case WM_DESTROY:
2451 {
2453 if (ctx)
2454 {
2455#ifdef EEL_LICE_WANTDOCK
2456 EEL_LICE_WANTDOCK(ctx,0);
2457#endif
2458 ctx->hwnd_standalone=NULL;
2459 }
2460 }
2461 return 0;
2462 case WM_ACTIVATE:
2463 {
2465 if (ctx) memset(&ctx->hwnd_standalone_kb_state,0,sizeof(ctx->hwnd_standalone_kb_state));
2466 }
2467 break;
2468 case WM_SETCURSOR:
2469 {
2471 if (ctx && ctx->m_cursor)
2472 {
2473 POINT p;
2474 GetCursorPos(&p);
2476 RECT r;
2477 GetClientRect(hwnd, &r);
2478 if (PtInRect(&r,p))
2479 {
2480 SetCursor(ctx->m_cursor);
2481 return TRUE;
2482 }
2483 }
2484 }
2485 break;
2486#ifdef EEL_LICE_WANTDOCK
2487 case WM_CONTEXTMENU:
2488 {
2490 if (ctx)
2491 {
2492 char title[512], buf[1024];
2493 GetWindowText(hwnd, title, sizeof(title)-1);
2494 if (!title[0]) strcpy(title, "ReaScript");
2495
2497 int pos=0;
2498
2499 int flag=((EEL_LICE_ISDOCKED(ctx)&1) ? MF_CHECKED : 0);
2500 snprintf(buf, sizeof(buf), "Dock %s window in Docker", title);
2501 InsertMenu(hm, pos++, MF_BYPOSITION|MF_STRING|flag, ID_DOCKWINDOW, buf);
2502 snprintf(buf, sizeof(buf), "Close %s window", title);
2503 InsertMenu(hm, pos++, MF_BYPOSITION|MF_STRING, IDCANCEL, buf);
2504
2505 POINT pt;
2506 GetCursorPos(&pt);
2507 TrackPopupMenu(hm, 0, pt.x, pt.y, 0, hwnd, NULL);
2508 DestroyMenu(hm);
2509 }
2510 }
2511 return 0;
2512#endif
2513 case WM_COMMAND:
2514 switch (LOWORD(wParam))
2515 {
2516#ifdef EEL_LICE_WANTDOCK
2517 case ID_DOCKWINDOW:
2518 {
2520 if (ctx) EEL_LICE_WANTDOCK(ctx, EEL_LICE_ISDOCKED(ctx)^1);
2521 }
2522 return 0;
2523#endif
2524 case IDCANCEL:
2526 return 0;
2527 }
2528 break;
2529 case WM_DROPFILES:
2530 {
2532 if (ctx && wParam)
2533 {
2534 ctx->m_ddrop_files.Empty(true,free);
2535
2536 HDROP hDrop = (HDROP) wParam;
2537 const int n=DragQueryFile(hDrop,-1,NULL,0);
2538 for (int x=0;x<n;x++)
2539 {
2540 char buf[4096];
2541 buf[0]=0;
2542 DragQueryFile(hDrop,x,buf,sizeof(buf));
2543 if (buf[0]) ctx->m_ddrop_files.Add(strdup(buf));
2544 }
2545 DragFinish(hDrop);
2546 }
2547 }
2548 return 0;
2549 case WM_MOUSEHWHEEL:
2550 case WM_MOUSEWHEEL:
2551 {
2553 if (ctx)
2554 {
2555 EEL_F *p= uMsg==WM_MOUSEHWHEEL ? ctx->m_mouse_hwheel : ctx->m_mouse_wheel;
2556 if (p) *p += (EEL_F) (short)HIWORD(wParam);
2557 }
2558 }
2559 return -1;
2560#ifdef _WIN32
2561 case WM_SYSKEYDOWN:
2562 case WM_SYSKEYUP:
2563#endif
2564 case WM_KEYDOWN:
2565 case WM_KEYUP:
2566 case WM_CHAR:
2567 {
2569
2570 bool hadAltAdj=false;
2571 int a=eel_lice_key_xlate(uMsg,(int)wParam,(int)lParam, &hadAltAdj);
2572#ifdef _WIN32
2573 if (!a && (uMsg == WM_KEYUP || uMsg == WM_SYSKEYUP) && wParam >= 'A' && wParam <= 'Z') a=(int)wParam + 'a' - 'A';
2574#endif
2575 const int mask = hadAltAdj ? ~256 : ~0;
2576
2577#ifdef _WIN32
2578 if (!a && (uMsg == WM_KEYUP || uMsg == WM_SYSKEYUP))
2579 {
2580 // not ideal, doesn't properly support all modifiers but better than nothing
2581 a = (int)MapVirtualKey((UINT)wParam,2/*MAPVK_VK_TO_CHAR*/);
2582 }
2583#endif
2584
2585 if (a & mask)
2586 {
2587 int a_no_alt = (a&mask);
2588 const int lowera = a_no_alt >= 1 && a_no_alt < 27 ? (a_no_alt+'a'-1) : a_no_alt >= 'A' && a_no_alt <= 'Z' ? a_no_alt+'a'-'A' : a_no_alt;
2589
2590 int *st = ctx->hwnd_standalone_kb_state;
2591
2592 const int n = sizeof(ctx->hwnd_standalone_kb_state) / sizeof(ctx->hwnd_standalone_kb_state[0]);
2593 int zp=n-1,x;
2594
2595 for (x=0;x<n && st[x] != lowera;x++) if (x < zp && !st[x]) zp=x;
2596
2597 if (uMsg==WM_KEYUP
2598#ifdef _WIN32
2599 ||uMsg == WM_SYSKEYUP
2600#endif
2601 )
2602 {
2603 if (x<n) st[x]=0;
2604 }
2605 else if (x==n) // key not already down
2606 {
2607 st[zp]=lowera;
2608 }
2609 }
2610#ifdef _WIN32
2611 if (!a && (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN) && ((GetAsyncKeyState(VK_CONTROL)&0x8000)||(GetAsyncKeyState(VK_MENU)&0x8000)))
2612 {
2613 a = (int)MapVirtualKey((UINT)wParam,2/*MAPVK_VK_TO_CHAR*/);
2614 }
2615#endif
2616
2617 if (a && uMsg != WM_KEYUP
2618#ifdef _WIN32
2619 && uMsg != WM_SYSKEYUP
2620#endif
2621 )
2622 {
2623 // add to queue
2624 const int qsize = sizeof(ctx->m_kb_queue)/sizeof(ctx->m_kb_queue[0]);
2625 if (ctx->m_kb_queue_valid>=qsize) // queue full, dump an old event!
2626 {
2627 ctx->m_kb_queue_valid--;
2628 ctx->m_kb_queue_pos++;
2629 }
2630 ctx->m_kb_queue[(ctx->m_kb_queue_pos + ctx->m_kb_queue_valid++) & (qsize-1)] = a;
2631 }
2632
2633 }
2634 return 0;
2635 case WM_LBUTTONDBLCLK:
2636 case WM_RBUTTONDBLCLK:
2637 case WM_MBUTTONDBLCLK:
2638 case WM_RBUTTONDOWN:
2639 case WM_MBUTTONDOWN:
2640 case WM_LBUTTONDOWN:
2641 {
2642 POINT p = { (short)LOWORD(lParam), (short)HIWORD(lParam) };
2643 RECT r;
2644 GetClientRect(hwnd, &r);
2645 if (p.x >= r.left && p.x < r.right && p.y >= r.top && p.y < r.bottom)
2646 {
2647 if (GetCapture()!=hwnd) SetFocus(hwnd);
2649 if (ctx)
2650 {
2651 if (GetCapture()!=hwnd) SetCapture(hwnd);
2652 int f = 0;
2653 if (uMsg == WM_LBUTTONDBLCLK || uMsg == WM_LBUTTONDOWN) f=0x10001;
2654 else if (uMsg == WM_RBUTTONDBLCLK || uMsg == WM_RBUTTONDOWN) f=0x20002;
2655 else if (uMsg == WM_MBUTTONDBLCLK || uMsg == WM_MBUTTONDOWN) f=0x40040;
2656
2657 if (GetAsyncKeyState(VK_CONTROL)&0x8000) f|=4;
2658 if (GetAsyncKeyState(VK_SHIFT)&0x8000) f|=8;
2659 if (GetAsyncKeyState(VK_MENU)&0x8000) f|=16;
2660 if (GetAsyncKeyState(VK_LWIN)&0x8000) f|=32;
2661
2662 ctx->m_has_cap|=f;
2663 }
2664 }
2665 }
2666 return 1;
2667 case WM_LBUTTONUP:
2668 case WM_RBUTTONUP:
2669 case WM_MBUTTONUP:
2670 case WM_CAPTURECHANGED:
2671 {
2673 if (ctx)
2674 {
2675 if (uMsg == WM_CAPTURECHANGED)
2676 {
2677 ctx->m_has_cap &= 0xffff;
2678 }
2679 else
2680 {
2681 if (uMsg == WM_LBUTTONUP) ctx->m_has_cap &= ~0x10000;
2682 else if (uMsg == WM_RBUTTONUP) ctx->m_has_cap &= ~0x20000;
2683 else if (uMsg == WM_MBUTTONUP) ctx->m_has_cap &= ~0x40000;
2684
2685 if (!(ctx->m_has_cap & 0xf0000))
2686 {
2688 }
2689 }
2690 }
2691 }
2692 return 1;
2693#ifdef _WIN32
2694 case WM_GETDLGCODE:
2695 if (GetWindowLong(hwnd,GWL_STYLE)&WS_CHILD) return DLGC_WANTALLKEYS;
2696 break;
2697 case 0x02E0: //WM_DPICHANGED
2699 {
2700 RECT *prcNewWindow = (RECT*)lParam;
2702 NULL,
2703 prcNewWindow ->left,
2704 prcNewWindow ->top,
2705 prcNewWindow->right - prcNewWindow->left,
2706 prcNewWindow->bottom - prcNewWindow->top,
2708 }
2709 break;
2710#endif
2711 case WM_SIZE:
2712 // fall through
2713#ifndef EEL_LICE_STANDALONE_NOINITQUIT
2714 case WM_MOVE:
2715 if (uMsg != WM_SIZE || wParam != SIZE_MINIMIZED)
2716 {
2718 if (ctx
2719#ifdef EEL_LICE_ISDOCKED
2721#endif
2722 )
2723 {
2724 RECT r;
2725 GetWindowRect(hwnd,&ctx->m_last_undocked_r);
2727 if (ctx->m_last_undocked_r.bottom < ctx->m_last_undocked_r.top) ctx->m_last_undocked_r.top = ctx->m_last_undocked_r.bottom;
2728 ctx->m_last_undocked_r.right = r.right;
2729 ctx->m_last_undocked_r.bottom = r.bottom;
2730 }
2731
2732 }
2733#endif
2734
2735 break;
2736
2737 case WM_PAINT:
2738 {
2739 PAINTSTRUCT ps;
2740 if (BeginPaint(hwnd,&ps))
2741 {
2743 if (ctx && ctx->m_framebuffer &&
2745 {
2746 int w = LICE__GetWidth(ctx->m_framebuffer);
2747 int h = LICE__GetHeight(ctx->m_framebuffer);
2748#ifdef __APPLE__
2749 if (*ctx->m_gfx_ext_retina > 1.0)
2750 {
2751 StretchBlt(ps.hdc,0,0,w/2,h/2,LICE__GetDC(ctx->m_framebuffer),0,0,w,h,SRCCOPY);
2752 }
2753 else
2754#endif
2755 BitBlt(ps.hdc,0,0,w,h,LICE__GetDC(ctx->m_framebuffer),0,0,SRCCOPY);
2756 }
2757 EndPaint(hwnd,&ps);
2758 }
2759 }
2760 return 0;
2761 case WM_GETMINMAXINFO:
2762 {
2763 LPMINMAXINFO p=(LPMINMAXINFO)lParam;
2764 if (p->ptMinTrackSize.x > 10) p->ptMinTrackSize.x = 10;
2765 if (p->ptMinTrackSize.y > 10) p->ptMinTrackSize.y = 10;
2766 }
2767 return 0;
2768 }
2769
2770 return DefWindowProc(hwnd,uMsg,wParam,lParam);
2771}
2772
2773
2774
2775void eel_lice_register_standalone(HINSTANCE hInstance, const char *classname, HWND hwndPar, HICON icon)
2776{
2777 eel_lice_standalone_classname=classname && *classname ? classname : "EEL_LICE_gfx_standalone";
2778#ifdef _WIN32
2779 static bool reg;
2780 if (!reg)
2781 {
2782 eel_lice_hinstance=hInstance;
2783 WNDCLASS wc={CS_DBLCLKS,eel_lice_wndproc,0,0,hInstance,icon,LoadCursor(NULL,IDC_ARROW), NULL, NULL,eel_lice_standalone_classname};
2784 RegisterClass(&wc);
2785 reg = true;
2786 }
2787#endif
2788
2789#ifndef EEL_LICE_NO_REGISTER
2790 // gfx_init(title[, w,h, flags])
2791#ifndef EEL_LICE_STANDALONE_NOINITQUIT
2792 NSEEL_addfunc_varparm("gfx_init",1,NSEEL_PProc_THIS,&_gfx_init);
2793 NSEEL_addfunc_retptr("gfx_quit",1,NSEEL_PProc_THIS,&_gfx_quit);
2794
2795 NSEEL_addfunc_retval("gfx_screentoclient",2,NSEEL_PProc_THIS,&_gfx_screentoclient);
2796 NSEEL_addfunc_retval("gfx_clienttoscreen",2,NSEEL_PProc_THIS,&_gfx_clienttoscreen);
2797
2798#endif
2799#ifdef EEL_LICE_WANTDOCK
2800 NSEEL_addfunc_varparm("gfx_dock",1,NSEEL_PProc_THIS,&_gfx_dock);
2801#endif
2802
2803#ifdef EEL_LICE_WANT_STANDALONE_UPDATE
2804 NSEEL_addfunc_retptr("gfx_update",1,NSEEL_PProc_THIS,&_gfx_update);
2805#endif
2806
2807 NSEEL_addfunc_retval("gfx_getchar",1,NSEEL_PProc_THIS,&_gfx_getchar);
2808#endif
2809}
2810
2811
2812#endif
2813
2814#endif
2815
2816
2817
2818
2819#ifdef DYNAMIC_LICE
2820static WDL_STATICFUNC_UNUSED void eel_lice_initfuncs(void *(*getFunc)(const char *name))
2821{
2822 if (!getFunc) return;
2823
2824 *(void **)&__LICE_CreateBitmap = getFunc("LICE_CreateBitmap");
2825 *(void **)&LICE_Clear = getFunc("LICE_Clear");
2826 *(void **)&LICE_Line = getFunc("LICE_LineInt");
2827 *(void **)&LICE_ClipLine = getFunc("LICE_ClipLine");
2828 *(void **)&LICE_FillRect = getFunc("LICE_FillRect");
2829 *(void **)&LICE_DrawRect = getFunc("LICE_DrawRect");
2830 *(void **)&LICE_PutPixel = getFunc("LICE_PutPixel");
2831 *(void **)&LICE_GetPixel = getFunc("LICE_GetPixel");
2832 *(void **)&LICE_DrawText = getFunc("LICE_DrawText");
2833 *(void **)&LICE_DrawChar = getFunc("LICE_DrawChar");
2834 *(void **)&LICE_MeasureText = getFunc("LICE_MeasureText");
2835 *(void **)&LICE_LoadImage = getFunc("LICE_LoadImage");
2836 *(void **)&LICE__GetDC = getFunc("LICE__GetDC");
2837 *(void **)&LICE__Destroy = getFunc("LICE__Destroy");
2838 *(void **)&LICE__GetWidth = getFunc("LICE__GetWidth");
2839 *(void **)&LICE__GetHeight = getFunc("LICE__GetHeight");
2840 *(void **)&LICE__resize = getFunc("LICE__resize");
2841 *(void **)&LICE_Blur = getFunc("LICE_Blur");
2842 *(void **)&LICE_RotatedBlit = getFunc("LICE_RotatedBlit");
2843 *(void **)&LICE_ScaledBlit = getFunc("LICE_ScaledBlit");
2844 *(void **)&LICE_Circle = getFunc("LICE_Circle");
2845 *(void **)&LICE_FillCircle = getFunc("LICE_FillCircle");
2846 *(void **)&LICE_FillTriangle=getFunc("LICE_FillTriangle");
2847 *(void **)&LICE_FillConvexPolygon=getFunc("LICE_FillConvexPolygon");
2848 *(void **)&LICE_RoundRect = getFunc("LICE_RoundRect");
2849 *(void **)&LICE_Arc = getFunc("LICE_Arc");
2850
2851 *(void **)&LICE_MultiplyAddRect = getFunc("LICE_MultiplyAddRect");
2852 *(void **)&LICE_GradRect = getFunc("LICE_GradRect");
2853 *(void **)&LICE_TransformBlit2 = getFunc("LICE_TransformBlit2");
2854 *(void **)&LICE_DeltaBlit = getFunc("LICE_DeltaBlit");
2855
2856 *(void **)&LICE__DestroyFont = getFunc("LICE__DestroyFont");
2857 *(void **)&LICE_CreateFont = getFunc("LICE_CreateFont");
2858 *(void **)&LICE__SetFromHFont = getFunc("LICE__SetFromHFont2");
2859
2860 *(void **)&LICE__SetTextColor = getFunc("LICE__SetTextColor");
2861 *(void **)&LICE__SetTextCombineMode = getFunc("LICE__SetTextCombineMode");
2862 *(void **)&LICE__DrawText = getFunc("LICE__DrawText");
2863}
2864#endif
2865
2866#ifdef EEL_WANT_DOCUMENTATION
2867
2868#ifdef EELSCRIPT_LICE_MAX_IMAGES
2869#define MKSTR2(x) #x
2870#define MKSTR(x) MKSTR2(x)
2871#define EEL_LICE_DOC_MAXHANDLE MKSTR(EELSCRIPT_LICE_MAX_IMAGES-1)
2872#else
2873#define EEL_LICE_DOC_MAXHANDLE "127"
2874#endif
2875
2876
2877static const char *eel_lice_function_reference =
2878#ifdef EEL_LICE_WANT_STANDALONE
2879#ifndef EEL_LICE_STANDALONE_NOINITQUIT
2880#ifdef EEL_LICE_WANTDOCK
2881 "gfx_init\t\"name\"[,width,height,dockstate,xpos,ypos]\tInitializes the graphics window with title name. Suggested width and height can be specified. If window is already open, a non-empty name will re-title window, or an empty title will resize window. \n\n"
2882#else
2883 "gfx_init\t\"name\"[,width,height,xpos,ypos]\tInitializes the graphics window with title name. Suggested width and height can be specified. If window is already open, a non-empty name will re-title window, or an empty title will resize window.\n\n"
2884#endif
2885 "Once the graphics window is open, gfx_update() should be called periodically. \0"
2886 "gfx_quit\t\tCloses the graphics window.\0"
2887#endif
2888#ifdef EEL_LICE_WANT_STANDALONE_UPDATE
2889 "gfx_update\t\tUpdates the graphics display, if opened\0"
2890#endif
2891#endif
2892#ifdef EEL_LICE_WANTDOCK
2893 "gfx_dock\tv[,wx,wy,ww,wh]\tCall with v=-1 to query docked state, otherwise v>=0 to set docked state. State is &1 if docked, second byte is docker index (or last docker index if undocked). If wx-wh are specified, they will be filled with the undocked window position/size\0"
2894#endif
2895 "gfx_aaaaa\t\t"
2896 "The following global variables are special and will be used by the graphics system:\n\n\3"
2897 // we depend on the formatting here -- following gfx_aaaaa, search for \4[gfx_*|mouse_*]- for syntax highlight etc
2898 "\4gfx_r - current red component (0..1) used by drawing operations.\n"
2899 "\4gfx_g - current green component (0..1) used by drawing operations.\n"
2900 "\4gfx_b - current blue component (0..1) used by drawing operations.\n"
2901 "\4gfx_a2 - current alpha component (0..1) used by drawing operations when writing solid colors (normally ignored but useful when creating transparent images).\n"
2902 "\4gfx_a - alpha for drawing (1=normal).\n"
2903 "\4gfx_mode - blend mode for drawing. Set mode to 0 for default options. Add 1.0 for additive blend mode (if you wish to do subtractive, set gfx_a to negative and use gfx_mode as additive). Add 2.0 to disable source alpha for gfx_blit(). Add 4.0 to disable filtering for gfx_blit(). \n"
2904 "\4gfx_w - width of the UI framebuffer. \n"
2905 "\4gfx_h - height of the UI framebuffer. \n"
2906 "\4gfx_x - current graphics position X. Some drawing functions use as start position and update. \n"
2907 "\4gfx_y - current graphics position Y. Some drawing functions use as start position and update. \n"
2908 "\4gfx_clear - if greater than -1.0, framebuffer will be cleared to that color. the color for this one is packed RGB (0..255), i.e. red+green*256+blue*65536. The default is 0 (black). \n"
2909 "\4gfx_dest - destination for drawing operations, -1 is main framebuffer, set to 0.." EEL_LICE_DOC_MAXHANDLE " to have drawing operations go to an offscreen buffer (or loaded image).\n"
2910 "\4gfx_texth - the (READ-ONLY) height of a line of text in the current font. Do not modify this variable.\n"
2911 "\4gfx_ext_retina - to support hidpi/retina, callers should set to 1.0 on initialization, this value will be updated to value greater than 1.0 (such as 2.0) if retina/hidpi. On macOS gfx_w/gfx_h/etc will be doubled, but on other systems gfx_w/gfx_h will remain the same and gfx_ext_retina is a scaling hint for drawing.\n"
2912 "\4mouse_x - current X coordinate of the mouse relative to the graphics window.\n"
2913 "\4mouse_y - current Y coordinate of the mouse relative to the graphics window.\n"
2914 "\4mouse_wheel - wheel position, will change typically by 120 or a multiple thereof, the caller should clear the state to 0 after reading it.\n"
2915 "\4mouse_hwheel - horizontal wheel positions, will change typically by 120 or a multiple thereof, the caller should clear the state to 0 after reading it.\n"
2916 "\4mouse_cap - a bitfield of mouse and keyboard modifier state. Note that a script must call gfx_getchar() at least once in order to get modifier state when the mouse is not captured by the window. Bitfield bits:\3"
2917 "\4" "1: left mouse button\n"
2918 "\4" "2: right mouse button\n"
2919#ifdef __APPLE__
2920 "\4" "4: Command key\n"
2921 "\4" "8: Shift key\n"
2922 "\4" "16: Option key\n"
2923 "\4" "32: Control key\n"
2924#else
2925 "\4" "4: Control key\n"
2926 "\4" "8: Shift key\n"
2927 "\4" "16: Alt key\n"
2928 "\4" "32: Windows key\n"
2929#endif
2930 "\4" "64: middle mouse button\n"
2931 "\2"
2932 "\2\0"
2933
2934"gfx_getchar\t[char]\tIf char is 0 or omitted, returns a character from the keyboard queue, or 0 if no character is available, or -1 if the graphics window is not open. "
2935 "If char is specified and nonzero, that character's status will be checked, and the function will return greater than 0 if it is pressed. Note that calling gfx_getchar() at least once causes mouse_cap to reflect keyboard modifiers even when the mouse is not captured.\n\n"
2936 "Common values are standard ASCII, such as 'a', 'A', '=' and '1', but for many keys multi-byte values are used, including 'home', 'up', 'down', 'left', 'rght', 'f1'.. 'f12', 'pgup', 'pgdn', 'ins', and 'del'. \n\n"
2937 "Modified and special keys can also be returned, including:\3\n"
2938 "\4Ctrl/Cmd+A..Ctrl+Z as 1..26\n"
2939 "\4Ctrl/Cmd+Alt+A..Z as 257..282\n"
2940 "\4Alt+A..Z as 'A'+256..'Z'+256\n"
2941 "\4" "27 for ESC\n"
2942 "\4" "13 for Enter\n"
2943 "\4' ' for space\n"
2944 "\4" "65536 for query of special flags, returns: &1 (supported), &2=window has focus, &4=window is visible\n"
2945 "\2\0"
2946
2947 "gfx_showmenu\t\"str\"\tShows a popup menu at gfx_x,gfx_y. str is a list of fields separated by | characters. "
2948 "Each field represents a menu item.\nFields can start with special characters:\n\n"
2949 "# : grayed out\n"
2950 "! : checked\n"
2951 "> : this menu item shows a submenu\n"
2952 "< : last item in the current submenu\n\n"
2953 "An empty field will appear as a separator in the menu. "
2954 "gfx_showmenu returns 0 if the user selected nothing from the menu, 1 if the first field is selected, etc.\nExample:\n\n"
2955 "gfx_showmenu(\"first item, followed by separator||!second item, checked|>third item which spawns a submenu|#first item in submenu, grayed out|<second and last item in submenu|fourth item in top menu\")\0"
2956
2957#ifdef EEL_LICE_LOADTHEMECURSOR
2958 "gfx_setcursor\tresource_id,custom_cursor_name\tSets the mouse cursor. resource_id is a value like 32512 (for an arrow cursor), custom_cursor_name is a string description (such as \"arrow\") that will be override the resource_id, if available. In either case resource_id should be nonzero.\0"
2959#else
2960 "gfx_setcursor\tresource_id\tSets the mouse cursor. resource_id is a value like 32512 (for an arrow cursor).\0"
2961#endif
2962 "gfx_lineto\tx,y[,aa]\tDraws a line from gfx_x,gfx_y to x,y. If aa is 0.5 or greater, then antialiasing is used. Updates gfx_x and gfx_y to x,y.\0"
2963 "gfx_line\tx,y,x2,y2[,aa]\tDraws a line from x,y to x2,y2, and if aa is not specified or 0.5 or greater, it will be antialiased. \0"
2964 "gfx_rectto\tx,y\tFills a rectangle from gfx_x,gfx_y to x,y. Updates gfx_x,gfx_y to x,y. \0"
2965 "gfx_rect\tx,y,w,h[,filled]\tFills a rectangle at x,y, w,h pixels in dimension, filled by default. \0"
2966 "gfx_setpixel\tr,g,b\tWrites a pixel of r,g,b to gfx_x,gfx_y.\0"
2967 "gfx_getpixel\tr,g,b\tGets the value of the pixel at gfx_x,gfx_y into r,g,b. \0"
2968 "gfx_drawnumber\tn,ndigits\tDraws the number n with ndigits of precision to gfx_x, gfx_y, and updates gfx_x to the right side of the drawing. The text height is gfx_texth.\0"
2969 "gfx_drawchar\tchar\tDraws the character (can be a numeric ASCII code as well), to gfx_x, gfx_y, and moves gfx_x over by the size of the character.\0"
2970 "gfx_drawstr\t\"str\"[,flags,right,bottom]\tDraws a string at gfx_x, gfx_y, and updates gfx_x/gfx_y so that subsequent draws will occur in a similar place.\n\n"
2971 "If flags, right ,bottom passed in:\n"
2972 "\4flags&1: center horizontally\n"
2973 "\4flags&2: right justify\n"
2974 "\4flags&4: center vertically\n"
2975 "\4flags&8: bottom justify\n"
2976 "\4flags&256: ignore right/bottom, otherwise text is clipped to (gfx_x, gfx_y, right, bottom)\0"
2977 "gfx_measurestr\t\"str\",&w,&h\tMeasures the drawing dimensions of a string with the current font (as set by gfx_setfont). \0"
2978 "gfx_measurechar\tcharacter,&w,&h\tMeasures the drawing dimensions of a character with the current font (as set by gfx_setfont). \0"
2979 "gfx_setfont\tidx[,\"fontface\", sz, flags]\tCan select a font and optionally configure it. idx=0 for default bitmapped font, no configuration is possible for this font. idx=1..16 for a configurable font, specify fontface such as \"Arial\", sz of 8-100, and optionally specify flags, which is a multibyte character, which can include 'i' for italics, 'u' for underline, or 'b' for bold. These flags may or may not be supported depending on the font and OS. After calling gfx_setfont(), gfx_texth may be updated to reflect the new average line height.\0"
2980 "gfx_getfont\t[#str]\tReturns current font index. If a string is passed, it will receive the actual font face used by this font, if available.\0"
2981 "gfx_printf\t\"format\"[, ...]\tFormats and draws a string at gfx_x, gfx_y, and updates gfx_x/gfx_y accordingly (the latter only if the formatted string contains newline). For more information on format strings, see sprintf()\0"
2982 "gfx_blurto\tx,y\tBlurs the region of the screen between gfx_x,gfx_y and x,y, and updates gfx_x,gfx_y to x,y.\0"
2983 "gfx_blit\tsource[, scale, rotation, srcx, srcy, srcw, srch, destx, desty, destw, desth, rotxoffs, rotyoffs]\t"
2984 "Copies from source (-1 = main framebuffer, or an image from gfx_loadimg() etc), using current opacity and copy mode (set with gfx_a, gfx_mode).\n"
2985 "If destx/desty are not specified, gfx_x/gfx_y will be used as the destination position.\n"
2986 "scale (1.0 is unscaled) will be used only if destw/desth are not specified.\n"
2987 "rotation is an angle in radians\n"
2988 "srcx/srcy/srcw/srch specify the source rectangle (if omitted srcw/srch default to image size)\n"
2989 "destx/desty/destw/desth specify destination rectangle (if not specified destw/desth default to srcw/srch * scale). \0"
2990 "gfx_blitext\tsource,coordinatelist,rotation\tDeprecated, use gfx_blit instead.\0"
2991 "gfx_getimgdim\timage,w,h\tRetreives the dimensions of image (representing a filename: index number) into w and h. Sets these values to 0 if an image failed loading (or if the filename index is invalid).\0"
2992 "gfx_setimgdim\timage,w,h\tResize image referenced by index 0.." EEL_LICE_DOC_MAXHANDLE ", width and height must be 0-8192. The contents of the image will be undefined after the resize.\0"
2993 "gfx_loadimg\timage,\"filename\"\tLoad image from filename into slot 0.." EEL_LICE_DOC_MAXHANDLE " specified by image. Returns the image index if success, otherwise -1 if failure. The image will be resized to the dimensions of the image file. \0"
2994 "gfx_gradrect\tx,y,w,h, r,g,b,a[, drdx, dgdx, dbdx, dadx, drdy, dgdy, dbdy, dady]\tFills a gradient rectangle with the color and alpha specified. drdx-dadx reflect the adjustment (per-pixel) applied for each pixel moved to the right, drdy-dady are the adjustment applied for each pixel moved toward the bottom. Normally drdx=adjustamount/w, drdy=adjustamount/h, etc.\0"
2995 "gfx_muladdrect\tx,y,w,h,mul_r,mul_g,mul_b[,mul_a,add_r,add_g,add_b,add_a]\tMultiplies each pixel by mul_* and adds add_*, and updates in-place. Useful for changing brightness/contrast, or other effects.\0"
2996 "gfx_deltablit\tsrcimg,srcs,srct,srcw,srch,destx,desty,destw,desth,dsdx,dtdx,dsdy,dtdy,dsdxdy,dtdxdy[,usecliprect=1]\tBlits from srcimg(srcx,srcy,srcw,srch) "
2997 "to destination (destx,desty,destw,desth). Source texture coordinates are s/t, dsdx represents the change in s coordinate for each x pixel"
2998 ", dtdy represents the change in t coordinate for each y pixel, etc. dsdxdy represents the change in dsdx for each line. If usecliprect is specified and 0, then srcw/srch are ignored.\0"
2999 "gfx_transformblit\tsrcimg,destx,desty,destw,desth,div_w,div_h,table\tBlits to destination at (destx,desty), size (destw,desth). "
3000 "div_w and div_h should be 2..64, and table should point to a table of 2*div_w*div_h values (this table must not cross a "
3001 "65536 item boundary). Each pair in the table represents a S,T coordinate in the source image, and the table is treated as "
3002 "a left-right, top-bottom list of texture coordinates, which will then be rendered to the destination.\0"
3003 "gfx_circle\tx,y,r[,fill,antialias]\tDraws a circle, optionally filling/antialiasing. \0"
3004 "gfx_triangle\tx1,y1,x2,y2,x3,y3[x4,y4...]\tDraws a filled triangle, or any convex polygon. \0"
3005 "gfx_roundrect\tx,y,w,h,radius[,antialias]\tDraws a rectangle with rounded corners. \0"
3006 "gfx_arc\tx,y,r,ang1,ang2[,antialias]\tDraws an arc of the circle centered at x,y, with ang1/ang2 being specified in radians.\0"
3007 "gfx_set\tr[,g,b,a,mode,dest,a2]\tSets gfx_r/gfx_g/gfx_b/gfx_a/gfx_mode/gfx_a2, sets gfx_dest if final parameter specified\0"
3008 "gfx_getdropfile\tidx[,#str]\tEnumerates any drag/dropped files. call gfx_dropfile(-1) to clear the list when finished. Returns 1 if idx is valid, 0 if idx is out of range.\0"
3009
3010#ifdef EEL_LICE_WANT_STANDALONE
3011#ifndef EEL_LICE_STANDALONE_NOINITQUIT
3012 "gfx_clienttoscreen\tx,y\tConverts client coordinates x,y to screen coordinates.\0"
3013 "gfx_screentoclient\tx,y\tConverts screen coordinates x,y to client coordinates.\0"
3014#endif
3015#endif
3016;
3017#ifdef EELSCRIPT_LICE_MAX_IMAGES
3018#undef MKSTR2
3019#undef MKSTR
3020#endif
3021#endif
3022
3023#endif//_EEL_LICE_H_
#define NULL
Definition CarlaBridgeFormat.cpp:30
uint8_t a
Definition Spc_Cpu.h:141
float abs(const fft_t *freqs, off_t x)
Definition OscilGen.cpp:52
static const unsigned long mask[]
Definition bitwise.c:31
Definition lice_text.h:61
Definition lice.h:84
virtual int getHeight()=0
virtual int getWidth()=0
virtual bool resize(int w, int h)=0
virtual HDC getDC()
Definition lice.h:95
Definition lice_text.h:37
virtual void SetFromHFont(HFONT font, int flags=0)=0
virtual LICE_pixel SetTextColor(LICE_pixel color)=0
virtual int DrawText(LICE_IBitmap *bm, const char *str, int strcnt, RECT *rect, UINT dtFlags)=0
virtual void SetCombineMode(int combine, float alpha=1.0f)=0
Definition lice.h:110
Definition lice.h:238
Definition lice.h:138
Definition ptrlist.h:40
PTRTYPE * Add(PTRTYPE *item)
Definition ptrlist.h:82
void Empty()
Definition ptrlist.h:166
Definition heapbuf.h:259
int GetSize() const
Definition heapbuf.h:263
Definition eel_lice.h:190
EEL_F gfx_loadimg(void *opaque, int img, EEL_F loadFrom)
Definition eel_lice.h:995
bool m_has_had_getch
Definition eel_lice.h:319
eel_lice_state(NSEEL_VMCTX vm, void *ctx, int image_slots, int font_slots)
Definition eel_lice.h:327
EEL_F * m_gfx_r
Definition eel_lice.h:255
void gfx_rect(int np, EEL_F **parms)
Definition eel_lice.h:869
EEL_F * m_gfx_a2
Definition eel_lice.h:255
void gfx_circle(float x, float y, float r, bool fill, bool aaflag)
Definition eel_lice.h:786
LICE_pixel getCurColor()
Definition eel_lice.h:431
void gfx_rectto(EEL_F xpos, EEL_F ypos)
Definition eel_lice.h:834
LICE_IFont * GetActiveFont()
Definition eel_lice.h:227
void gfx_blitext2(int np, EEL_F **parms, int mode)
Definition eel_lice.h:1258
void gfx_blurto(EEL_F x, EEL_F y)
Definition eel_lice.h:1052
EEL_F * m_gfx_h
Definition eel_lice.h:255
EEL_F gfx_getdropfile(void *opaque, int np, EEL_F **parms)
Definition eel_lice.h:975
void * m_user_ctx
Definition eel_lice.h:260
void gfx_drawnumber(EEL_F n, EEL_F ndigits)
Definition eel_lice.h:1763
void gfx_arc(int np, EEL_F **parms)
Definition eel_lice.h:899
void resetVarsToStock()
Definition eel_lice.h:196
EEL_F * m_gfx_y
Definition eel_lice.h:255
EEL_F * m_gfx_a
Definition eel_lice.h:255
void gfx_drawstr(void *opaque, EEL_F **parms, int nparms, int formatmode)
Definition eel_lice.h:1662
EEL_F * m_mouse_hwheel
Definition eel_lice.h:256
@ EELFONT_FLAG_BOLD
Definition eel_lice.h:220
@ EELFONT_FLAG_MASK
Definition eel_lice.h:223
@ EELFONT_FLAG_ITALIC
Definition eel_lice.h:221
@ EELFONT_FLAG_UNDERLINE
Definition eel_lice.h:222
void gfx_line(int np, EEL_F **parms)
Definition eel_lice.h:853
void gfx_triangle(EEL_F **parms, int nparms)
Definition eel_lice.h:801
EEL_F * m_mouse_wheel
Definition eel_lice.h:256
int m_has_cap
Definition eel_lice.h:318
void gfx_grad_or_muladd_rect(int mode, int np, EEL_F **parms)
Definition eel_lice.h:913
int getCurModeForBlit(bool isFBsrc)
Definition eel_lice.h:415
void finish_draw()
Definition eel_lice.h:1894
EEL_F gfx_setfont(void *opaque, int np, EEL_F **parms)
Definition eel_lice.h:1119
EEL_F * m_gfx_x
Definition eel_lice.h:255
LICE_IBitmap * m_framebuffer
Definition eel_lice.h:206
void gfx_getpixel(EEL_F *r, EEL_F *g, EEL_F *b)
Definition eel_lice.h:1399
EEL_F * m_gfx_clear
Definition eel_lice.h:255
EEL_F * m_gfx_g
Definition eel_lice.h:255
void gfx_drawchar(EEL_F ch)
Definition eel_lice.h:1742
void SetImageDirty(LICE_IBitmap *bm)
Definition eel_lice.h:241
WDL_TypedBuf< LICE_IBitmap * > m_gfx_images
Definition eel_lice.h:208
void gfx_blitext(EEL_F img, EEL_F *coords, EEL_F angle)
Definition eel_lice.h:1340
LICE_IBitmap * GetImageForIndex(EEL_F idx, const char *callername)
Definition eel_lice.h:229
void gfx_transformblit(EEL_F **parms, int div_w, int div_h, EEL_F *tab)
Definition eel_lice.h:1083
WDL_TypedBuf< gfxFontStruct > m_gfx_fonts
Definition eel_lice.h:218
NSEEL_VMCTX m_vmref
Definition eel_lice.h:259
EEL_F * m_gfx_w
Definition eel_lice.h:255
~eel_lice_state()
Definition eel_lice.h:381
int getCurMode()
Definition eel_lice.h:407
int setup_frame(HWND hwnd, RECT r, int _mouse_x=0, int _mouse_y=0, int has_dpi=0)
Definition eel_lice.h:1782
void gfx_setpixel(EEL_F r, EEL_F g, EEL_F b)
Definition eel_lice.h:941
void gfx_lineto(EEL_F xpos, EEL_F ypos, EEL_F aaflag)
Definition eel_lice.h:768
void gfx_getimgdim(EEL_F img, EEL_F *w, EEL_F *h)
Definition eel_lice.h:960
EEL_F gfx_getfont(void *opaque, int np, EEL_F **parms)
EEL_F * m_gfx_ext_retina
Definition eel_lice.h:257
EEL_F * m_mouse_x
Definition eel_lice.h:256
EEL_F gfx_setimgdim(int img, EEL_F *w, EEL_F *h)
Definition eel_lice.h:1021
EEL_F * m_gfx_b
Definition eel_lice.h:255
EEL_F * m_gfx_dest
Definition eel_lice.h:255
WDL_PtrList< char > m_ddrop_files
Definition eel_lice.h:321
void gfx_roundrect(int np, EEL_F **parms)
Definition eel_lice.h:885
EEL_F * m_gfx_mode
Definition eel_lice.h:255
LICE_IBitmap * m_framebuffer_extra
Definition eel_lice.h:206
EEL_F * m_gfx_texth
Definition eel_lice.h:255
EEL_F * m_mouse_y
Definition eel_lice.h:256
int m_gfx_font_active
Definition eel_lice.h:226
EEL_F * m_mouse_cap
Definition eel_lice.h:256
void gfx_set(int np, EEL_F **parms)
Definition eel_lice.h:1387
int m_framebuffer_dirty
Definition eel_lice.h:207
UINT_D64 w
Definition inflate.c:942
int y
Definition inflate.c:1588
unsigned v[N_MAX]
Definition inflate.c:1584
unsigned d
Definition inflate.c:940
int g
Definition inflate.c:1573
register unsigned i
Definition inflate.c:1575
unsigned s
Definition inflate.c:1555
unsigned x[BMAX+1]
Definition inflate.c:1586
unsigned f
Definition inflate.c:1572
EEL_F *(* NSEEL_VM_regvar)(NSEEL_VMCTX ctx, const char *name)
Definition eel_import.h:13
#define NSEEL_addfunc_varparm(name, min_np, pproc, fptr)
Definition eel_import.h:63
#define NSEEL_addfunc_exparms(name, np, pproc, fptr)
Definition eel_import.h:67
#define NSEEL_addfunc_retptr(name, np, pproc, fptr)
Definition eel_import.h:55
#define NSEEL_addfunc_retval(name, np, pproc, fptr)
Definition eel_import.h:51
void *(* NSEEL_PProc_THIS)(void *data, int data_size, struct _compileContext *ctx)
Definition eel_import.h:40
void eel_lice_register()
Definition eel_lice.h:1913
static EEL_F *NSEEL_CGEN_CALL _gfx_lineto2(void *opaque, EEL_F *xpos, EEL_F *ypos)
Definition eel_lice.h:451
static void LICE__SetTextCombineMode(LICE_IFont *ifont, int mode, float alpha)
Definition eel_lice.h:153
static HDC LICE__GetDC(LICE_IBitmap *bm)
Definition eel_lice.h:128
static EEL_F NSEEL_CGEN_CALL _gfx_drawstr(void *opaque, INT_PTR nparms, EEL_F **parms)
Definition eel_lice.h:605
static int LICE__GetWidth(LICE_IBitmap *bm)
Definition eel_lice.h:132
static void LICE__Destroy(LICE_IBitmap *bm)
Definition eel_lice.h:140
static EEL_F NSEEL_CGEN_CALL _gfx_triangle(void *opaque, INT_PTR np, EEL_F **parms)
Definition eel_lice.h:563
static EEL_F NSEEL_CGEN_CALL _gfx_loadimg(void *opaque, EEL_F *img, EEL_F *fr)
Definition eel_lice.h:743
static LICE_IBitmap * __LICE_CreateBitmap(int mode, int w, int h)
Definition eel_lice.h:177
static bool LICE__resize(LICE_IBitmap *bm, int w, int h)
Definition eel_lice.h:172
static EEL_F NSEEL_CGEN_CALL _gfx_rect(void *opaque, INT_PTR np, EEL_F **parms)
Definition eel_lice.h:472
static EEL_F NSEEL_CGEN_CALL _gfx_set(void *opaque, INT_PTR np, EEL_F **parms)
Definition eel_lice.h:490
static EEL_F NSEEL_CGEN_CALL _gfx_roundrect(void *opaque, INT_PTR np, EEL_F **parms)
Definition eel_lice.h:478
static EEL_F *NSEEL_CGEN_CALL _gfx_lineto(void *opaque, EEL_F *xpos, EEL_F *ypos, EEL_F *useaa)
Definition eel_lice.h:445
static HMENU PopulateMenuFromStr(const char **str, int *startid)
Definition eel_lice.h:1521
static EEL_F NSEEL_CGEN_CALL _gfx_blit2(void *opaque, INT_PTR np, EEL_F **parms)
Definition eel_lice.h:684
static int LICE__DrawText(LICE_IFont *ifont, LICE_IBitmap *bm, const char *str, int strcnt, RECT *rect, UINT dtFlags)
Definition eel_lice.h:157
static EEL_F NSEEL_CGEN_CALL _gfx_setfont(void *opaque, INT_PTR np, EEL_F **parms)
Definition eel_lice.h:652
static EEL_F *NSEEL_CGEN_CALL _gfx_blurto(void *opaque, EEL_F *x, EEL_F *y)
Definition eel_lice.h:729
static EEL_F *NSEEL_CGEN_CALL _gfx_rectto(void *opaque, EEL_F *xpos, EEL_F *ypos)
Definition eel_lice.h:458
static EEL_F NSEEL_CGEN_CALL _gfx_deltablit(void *opaque, INT_PTR np, EEL_F **parms)
Definition eel_lice.h:510
static EEL_F *NSEEL_CGEN_CALL _gfx_measurechar(void *opaque, EEL_F *str, EEL_F *xOut, EEL_F *yOut)
Definition eel_lice.h:594
static int LICE__GetHeight(LICE_IBitmap *bm)
Definition eel_lice.h:136
static EEL_F NSEEL_CGEN_CALL _gfx_arc(void *opaque, INT_PTR np, EEL_F **parms)
Definition eel_lice.h:484
static EEL_F *NSEEL_CGEN_CALL _gfx_drawchar(void *opaque, EEL_F *n)
Definition eel_lice.h:577
static EEL_F NSEEL_CGEN_CALL _gfx_setimgdim(void *opaque, EEL_F *img, EEL_F *w, EEL_F *h)
Definition eel_lice.h:756
static EEL_F *NSEEL_CGEN_CALL _gfx_blitext(void *opaque, EEL_F *img, EEL_F *coordidx, EEL_F *rotate)
Definition eel_lice.h:695
#define LICE_FUNCTION_VALID(x)
Definition eel_lice.h:126
static bool CoordsSrcDestOverlap(EEL_F *coords)
Definition eel_lice.h:1074
static void LICE__DestroyFont(LICE_IFont *bm)
Definition eel_lice.h:168
static EEL_F *NSEEL_CGEN_CALL _gfx_measurestr(void *opaque, EEL_F *str, EEL_F *xOut, EEL_F *yOut)
Definition eel_lice.h:584
static EEL_F NSEEL_CGEN_CALL _gfx_setcursor(void *opaque, INT_PTR nparms, EEL_F **parms)
Definition eel_lice.h:631
static int __drawTextWithFont(LICE_IBitmap *dest, const RECT *rect, LICE_IFont *font, const char *buf, int buflen, int fg, int mode, float alpha, int flags, EEL_F *wantYoutput, EEL_F **measureOnly)
Definition eel_lice.h:1413
static EEL_F *NSEEL_CGEN_CALL _gfx_getimgdim(void *opaque, EEL_F *img, EEL_F *w, EEL_F *h)
Definition eel_lice.h:736
static EEL_F NSEEL_CGEN_CALL _gfx_muladdrect(void *opaque, INT_PTR np, EEL_F **parms)
Definition eel_lice.h:503
static EEL_F *NSEEL_CGEN_CALL _gfx_drawnumber(void *opaque, EEL_F *n, EEL_F *nd)
Definition eel_lice.h:570
static EEL_F NSEEL_CGEN_CALL _gfx_getfont(void *opaque, INT_PTR np, EEL_F **parms)
Definition eel_lice.h:659
static LICE_IFont * LICE_CreateFont()
Definition eel_lice.h:164
static EEL_F NSEEL_CGEN_CALL _gfx_printf(void *opaque, INT_PTR nparms, EEL_F **parms)
Definition eel_lice.h:612
static EEL_F NSEEL_CGEN_CALL _gfx_showmenu(void *opaque, INT_PTR nparms, EEL_F **parms)
Definition eel_lice.h:624
static EEL_F *NSEEL_CGEN_CALL _gfx_getpixel(void *opaque, EEL_F *r, EEL_F *g, EEL_F *b)
Definition eel_lice.h:645
static EEL_F NSEEL_CGEN_CALL _gfx_line(void *opaque, INT_PTR np, EEL_F **parms)
Definition eel_lice.h:465
static void LICE__SetFromHFont(LICE_IFont *ifont, HFONT font, int flags)
Definition eel_lice.h:144
static EEL_F NSEEL_CGEN_CALL _gfx_circle(void *opaque, INT_PTR np, EEL_F **parms)
Definition eel_lice.h:553
static EEL_F NSEEL_CGEN_CALL _gfx_getdropfile(void *opaque, INT_PTR np, EEL_F **parms)
Definition eel_lice.h:750
static LICE_pixel LICE__SetTextColor(LICE_IFont *ifont, LICE_pixel color)
Definition eel_lice.h:148
static EEL_F *NSEEL_CGEN_CALL _gfx_setpixel(void *opaque, EEL_F *r, EEL_F *g, EEL_F *b)
Definition eel_lice.h:638
static EEL_F NSEEL_CGEN_CALL _gfx_getsyscol(void *ctxe, INT_PTR np, EEL_F **parms)
Definition eel_lice.h:763
static EEL_F NSEEL_CGEN_CALL _gfx_gradrect(void *opaque, INT_PTR np, EEL_F **parms)
Definition eel_lice.h:496
static EEL_F NSEEL_CGEN_CALL _gfx_transformblit(void *opaque, INT_PTR np, EEL_F **parms)
Definition eel_lice.h:517
#define EEL_STRING_GET_FOR_WRITE(x, wr)
Definition eel_strings.h:100
#define EEL_STRING_GET_FOR_INDEX(x, wr)
Definition eel_strings.h:96
#define EEL_STRING_MUTEXLOCK_SCOPE
Definition eel_strings.h:90
int eel_format_strings(void *opaque, const char *fmt, const char *fmt_end, char *buf, int buf_sz, int num_fmt_parms, EEL_F **fmt_parms)
Definition eel_strings.h:402
#define opaque
Definition eelscript.h:281
#define EEL_LICE_GET_CONTEXT(opaque)
Definition eelscript.h:209
struct @113205115357366127300225113341150224053346037032::@137033172036070230260373056156374243321245367362 left
static char filename[]
Definition features.c:5
static void r2(register WDL_FFT_REAL *a)
Definition fft.c:1089
static const char * title
Definition pugl.h:1747
static const char * name
Definition pugl.h:1582
static void rotate(ZixTreeNode *p, ZixTreeNode *q)
Definition tree.c:113
LICE_pixel LICE_GetPixel(LICE_IBitmap *bm, int x, int y)
Definition lice.cpp:2220
void LICE_MultiplyAddRect(LICE_IBitmap *dest, int x, int y, int w, int h, float rsc, float gsc, float bsc, float asc, float radd, float gadd, float badd, float aadd)
Definition lice.cpp:2006
void LICE_Blur(LICE_IBitmap *dest, LICE_IBitmap *src, int dstx, int dsty, int srcx, int srcy, int srcw, int srch)
Definition lice.cpp:1103
void LICE_DeltaBlit(LICE_IBitmap *dest, LICE_IBitmap *src, int dstx, int dsty, int dstw, int dsth, float srcx, float srcy, float srcw, float srch, double dsdx, double dtdx, double dsdy, double dtdy, double dsdxdy, double dtdxdy, bool cliptosourcerect, float alpha, int mode)
Definition lice.cpp:1485
void LICE_TransformBlit2(LICE_IBitmap *dest, LICE_IBitmap *src, int dstx, int dsty, int dstw, int dsth, const double *srcpoints, int div_w, int div_h, float alpha, int mode)
Definition lice.cpp:2464
void LICE_GradRect(LICE_IBitmap *dest, int dstx, int dsty, int dstw, int dsth, float ir, float ig, float ib, float ia, float drdx, float dgdx, float dbdx, float dadx, float drdy, float dgdy, float dbdy, float dady, int mode)
Definition lice.cpp:835
LICE_IBitmap * LICE_LoadImage(const char *filename, LICE_IBitmap *bmp=NULL, bool tryIgnoreExtension=false)
Definition lice_image.cpp:5
#define LICE_GETG(v)
Definition lice.h:59
#define LICE_BLIT_USE_ALPHA
Definition lice.h:331
#define LICE_GETB(v)
Definition lice.h:58
#define LICE_RGBA(r, g, b, a)
Definition lice.h:57
static LICE_pixel LICE_RGBA_FROMNATIVE(LICE_pixel col, int alpha=0)
Definition lice.h:76
#define LICE_BLIT_FILTER_BILINEAR
Definition lice.h:327
#define LICE_GETR(v)
Definition lice.h:60
#define LICE_BLIT_MODE_COPY
Definition lice.h:316
unsigned int LICE_pixel
Definition lice.h:54
#define LICE_BLIT_MODE_ADD
Definition lice.h:317
void LICE_DrawChar(LICE_IBitmap *bm, int x, int y, char c, LICE_pixel color, float alpha, int mode)
Definition lice_text.cpp:1283
bool LICE_ClipLine(int *pX1, int *pY1, int *pX2, int *pY2, int xLo, int yLo, int xHi, int yHi)
Definition lice_line.cpp:980
#define LICE_BLIT_MODE_HSVADJ
Definition lice.h:321
void LICE_RoundRect(LICE_IBitmap *drawbm, float xpos, float ypos, float w, float h, int cornerradius, LICE_pixel col, float alpha, int mode, bool aa)
Definition lice_arc.cpp:684
LICE_FUNC_DEF_DECL void(* __LICE_DrawRect)(LICE_IBitmap *dest, int x, int y, int w, int h, LICE_pixel color, float alpha, int mode)
Definition lice_import.h:16
#define LICE_PutPixel
Definition lice_import.h:34
#define LICE_MeasureText
Definition lice_import.h:53
LICE_FUNC_DEF_DECL void(* __LICE_PutPixel)(LICE_IBitmap *dest, int x, int y, LICE_pixel color, float alpha, int mode)
Definition lice_import.h:11
LICE_FUNC_DEF_DECL void(* __LICE_Arc)(LICE_IBitmap *dest, float cx, float cy, float r, float alo, float ahi, LICE_pixel color, float alpha, int mode, bool aa)
Definition lice_import.h:25
#define LICE_Arc
Definition lice_import.h:48
#define LICE_DrawText
Definition lice_import.h:52
LICE_FUNC_DEF_DECL void(* __LICE_FillConvexPolygon)(LICE_IBitmap *dest, int *x, int *y, int npoints, LICE_pixel color, float alpha, int mode)
Definition lice_import.h:27
#define LICE_DrawRect
Definition lice_import.h:39
#define LICE_Circle
Definition lice_import.h:40
#define LICE_FillRect
Definition lice_import.h:38
LICE_FUNC_DEF_DECL void(* __LICE_RotatedBlit)(LICE_IBitmap *dest, LICE_IBitmap *src, int dstx, int dsty, int dstw, int dsth, float srcx, float srcy, float srcw, float srch, float angle, bool cliptosourcerect, float alpha, int mode, float rotxcent, float rotycent)
Definition lice_import.h:22
LICE_FUNC_DEF_DECL void(* __LICE_ScaledBlit)(LICE_IBitmap *dest, LICE_IBitmap *src, int dstx, int dsty, int dstw, int dsth, float srcx, float srcy, float srcw, float srch, float alpha, int mode)
Definition lice_import.h:31
LICE_FUNC_DEF_DECL void *(* LICE_CreateFont)()
Definition lice_import.h:33
#define LICE_Clear
Definition lice_import.h:41
LICE_FUNC_DEF_DECL void(* __LICE_FillTriangle)(LICE_IBitmap *dest, int x1, int y1, int x2, int y2, int x3, int y3, LICE_pixel color, float alpha, int mode)
Definition lice_import.h:24
#define LICE_FillTriangle
Definition lice_import.h:47
LICE_FUNC_DEF_DECL void(* __LICE_Line)(LICE_IBitmap *dest, int x1, int y1, int x2, int y2, LICE_pixel color, float alpha, int mode, bool aa)
Definition lice_import.h:12
#define LICE_FillConvexPolygon
Definition lice_import.h:50
LICE_FUNC_DEF_DECL void(* __LICE_DrawText)(LICE_IBitmap *bm, int x, int y, const char *string, LICE_pixel color, float alpha, int mode)
Definition lice_import.h:29
LICE_FUNC_DEF_DECL void(* __LICE_Clear)(LICE_IBitmap *dest, LICE_pixel color)
Definition lice_import.h:20
#define LICE_Line
Definition lice_import.h:35
LICE_FUNC_DEF_DECL void(* __LICE_FillCircle)(LICE_IBitmap *dest, float cx, float cy, float r, LICE_pixel color, float alpha, int mode, bool aa)
Definition lice_import.h:19
LICE_FUNC_DEF_DECL LICE_IBitmap *(* __LICE_CreateBitmap)(int, int, int)
Definition lice_import.h:10
#define LICE_ScaledBlit
Definition lice_import.h:54
LICE_FUNC_DEF_DECL void(* __LICE_MeasureText)(const char *string, int *w, int *h)
Definition lice_import.h:30
#define LICE_RotatedBlit
Definition lice_import.h:43
LICE_FUNC_DEF_DECL void(* __LICE_Circle)(LICE_IBitmap *dest, float cx, float cy, float r, LICE_pixel color, float alpha, int mode, bool aa)
Definition lice_import.h:18
#define LICE_FillCircle
Definition lice_import.h:45
LICE_FUNC_DEF_DECL void(* __LICE_FillRect)(LICE_IBitmap *dest, int x, int y, int w, int h, LICE_pixel color, float alpha, int mode)
Definition lice_import.h:15
const char * msg
Definition missing_descriptor.c:20
jack_client_t client jack_client_t client jack_client_t client jack_client_t JackInfoShutdownCallback void arg jack_client_t jack_port_t port void func jack_client_t const char const char unsigned long flags
Definition juce_linux_JackAudio.cpp:69
struct _compileContext compileContext
EEL_F *NSEEL_CGEN_CALL __NSEEL_RAMAlloc(EEL_F **blocks, unsigned int w)
Definition nseel-ram.c:139
EEL_F nseel_ramalloc_onfail
Definition nseel-ram.c:92
#define NSEEL_CGEN_CALL
Definition ns-eel.h:44
void * NSEEL_VMCTX
Definition ns-eel.h:117
#define NSEEL_RAM_ITEMSPERBLOCK
Definition ns-eel.h:235
#define NSEEL_RAM_BLOCKS
Definition ns-eel.h:234
png_structrp int mode
Definition png.h:1139
png_structrp int png_fixed_point red
Definition png.h:1083
Definition swell-types.h:254
Definition swell-types.h:535
HDC hdc
Definition swell-types.h:536
Definition swell-types.h:218
LONG x
Definition swell-types.h:219
LONG y
Definition swell-types.h:219
Definition swell-types.h:231
LONG bottom
Definition swell-types.h:232
LONG left
Definition swell-types.h:232
LONG top
Definition swell-types.h:232
LONG right
Definition swell-types.h:232
Definition swell-types.h:526
LONG tmHeight
Definition swell-types.h:527
Definition eel_lice.h:209
int last_fontsize
Definition eel_lice.h:213
int use_fonth
Definition eel_lice.h:216
char actual_fontname[128]
Definition eel_lice.h:212
char last_fontname[128]
Definition eel_lice.h:211
LICE_IFont * font
Definition eel_lice.h:210
int last_fontflag
Definition eel_lice.h:214
#define WM_PAINT
#define DEFAULT_PITCH
#define WS_CHILD
#define WS_CAPTION
#define VK_NUMPAD3
#define WM_CLOSE
#define SWP_NOACTIVATE
#define DT_NOPREFIX
#define VK_F12
#define VK_TAB
#define VK_F9
#define WM_KEYUP
#define DT_CENTER
#define VK_MULTIPLY
#define VK_NUMPAD1
#define IDCANCEL
#define VK_F10
#define WM_CAPTURECHANGED
#define WS_EX_ACCEPTFILES
#define WM_CREATE
#define VK_NUMPAD2
#define DEFAULT_QUALITY
#define WM_SIZE
#define FW_BOLD
#define WM_DROPFILES
#define DT_SINGLELINE
#define WM_LBUTTONDBLCLK
#define SWP_NOMOVE
#define WM_COMMAND
#define MF_STRING
#define VK_NUMPAD4
#define VK_RBUTTON
#define IDC_ARROW
#define VK_CONTROL
#define WM_RBUTTONUP
#define VK_UP
#define WM_RBUTTONDBLCLK
#define WS_TABSTOP
#define WS_SYSMENU
#define MF_CHECKED
#define SWP_NOSIZE
#define VK_MBUTTON
#define DT_NOCLIP
#define SIZE_MINIMIZED
#define TPM_NONOTIFY
#define WM_LBUTTONDOWN
#define DEFAULT_CHARSET
#define WM_CONTEXTMENU
#define VK_NUMPAD0
#define VK_F1
#define FVIRTKEY
#define VK_F6
#define MF_POPUP
#define VK_NUMPAD6
#define SRCCOPY
#define VK_NEXT
#define WM_ACTIVATE
#define WM_RBUTTONDOWN
#define VK_RETURN
#define WM_GETMINMAXINFO
#define VK_F5
#define MF_SEPARATOR
#define VK_F11
#define VK_F8
#define PtInRect(r, p)
#define OUT_DEFAULT_PRECIS
#define VK_NUMPAD9
#define VK_END
#define VK_HOME
#define MF_BYPOSITION
#define VK_ADD
#define WM_MBUTTONDBLCLK
#define WM_SYSKEYUP
#define VK_BACK
#define CLIP_DEFAULT_PRECIS
#define VK_F3
#define VK_LWIN
#define FW_NORMAL
#define VK_F4
#define WM_LBUTTONUP
#define WM_CHAR
#define DT_VCENTER
#define DT_BOTTOM
#define VK_NUMPAD5
#define SetCursor(x)
#define WM_MOVE
#define VK_LEFT
#define VK_NUMPAD7
#define VK_RIGHT
#define VK_DOWN
#define WM_SETCURSOR
#define VK_SHIFT
#define SW_SHOW
#define VK_PRIOR
#define VK_DELETE
#define WM_DESTROY
#define WM_KEYDOWN
#define DT_RIGHT
#define VK_DIVIDE
#define VK_NUMPAD8
#define TPM_RETURNCMD
#define SWP_NOZORDER
#define DT_CALCRECT
#define VK_DECIMAL
#define WM_MBUTTONUP
#define GWL_STYLE
#define InsertMenu
#define VK_ESCAPE
#define WM_SYSKEYDOWN
#define VK_F7
#define WS_THICKFRAME
#define VK_INSERT
#define WM_MBUTTONDOWN
#define VK_SUBTRACT
#define VK_MENU
#define GWL_EXSTYLE
#define MF_GRAYED
#define COLOR_3DFACE
#define VK_LBUTTON
#define VK_F2
HWND SWELL_CreateDialog(SWELL_DialogResourceIndex *reshead, const char *resid, HWND parent, DLGPROC dlgproc, LPARAM param)
Definition swell-dlg-generic.cpp:272
#define SetWindowText(hwnd, text)
Definition swell-functions.h:210
#define SWELL_EnableMetal(hwnd, x)
#define LoadCursor(a, x)
#define GetWindowText(hwnd, text, textlen)
Definition swell-functions.h:209
RECT const char void HWND hwnd
Definition swell-functions.h:1066
void StretchBlt(HDC hdcOut, int x, int y, int w, int h, HDC hdcIn, int xin, int yin, int srcw, int srch, int mode)
Definition swell-gdi-generic.cpp:502
HGDIOBJ SelectObject(HDC ctx, HGDIOBJ pen)
Definition swell-gdi-generic.cpp:193
void BitBlt(HDC hdcOut, int x, int y, int w, int h, HDC hdcIn, int xin, int yin, int mode)
Definition swell-gdi-generic.cpp:498
BOOL GetTextMetrics(HDC ctx, TEXTMETRIC *tm)
Definition swell-gdi-generic.cpp:398
int SWELL_GetScaling256(void)
Definition swell-gdi-generic.cpp:62
HFONT CreateFont(int lfHeight, int lfWidth, int lfEscapement, int lfOrientation, int lfWeight, char lfItalic, char lfUnderline, char lfStrikeOut, char lfCharSet, char lfOutPrecision, char lfClipPrecision, char lfQuality, char lfPitchAndFamily, const char *lfFaceName)
Definition swell-gdi-generic.cpp:137
HDC BeginPaint(HWND hwnd, PAINTSTRUCT *ps)
Definition swell-gdi-generic.cpp:562
int GetTextFace(HDC ctx, int nCount, LPTSTR lpFaceName)
Definition swell-gdi-generic.cpp:167
int GetSysColor(int idx)
Definition swell-gdi-generic.cpp:42
WORD GetAsyncKeyState(int key)
Definition swell-generic-headless.cpp:218
bool GetWindowRect(HWND hwnd, RECT *r)
Definition swell-generic-headless.cpp:130
void SWELL_RunEvents()
Definition swell-generic-headless.cpp:98
void GetCursorPos(POINT *pt)
Definition swell-generic-headless.cpp:211
void UpdateWindow(HWND hwnd)
Definition swell-generic-headless.cpp:151
int TrackPopupMenu(HMENU hMenu, int flags, int xpos, int ypos, int resvd, HWND hwnd, const RECT *r)
Definition swell-menu-generic.cpp:1203
HMENU CreatePopupMenu()
Definition swell-menu-generic.cpp:159
void DestroyMenu(HMENU hMenu)
Definition swell-menu-generic.cpp:168
#define LOWORD(l)
Definition swell-types.h:90
void * HINSTANCE
Definition swell-types.h:212
uintptr_t UINT_PTR
Definition swell-types.h:43
LONG_PTR LRESULT
Definition swell-types.h:171
unsigned int UINT
Definition swell-types.h:166
LONG_PTR LPARAM
Definition swell-types.h:170
intptr_t INT_PTR
Definition swell-types.h:42
struct MINMAXINFO * LPMINMAXINFO
void * HDROP
Definition swell-types.h:212
ULONG_PTR WPARAM
Definition swell-types.h:169
struct HGDIOBJ__ * HFONT
Definition swell-types.h:272
struct HMENU__ * HMENU
Definition swell-types.h:211
#define WINAPI
Definition swell-types.h:631
struct HGDIOBJ__ * HGDIOBJ
Definition swell-types.h:269
struct HCURSOR__ * HCURSOR
Definition swell-types.h:264
struct HWND__ * HWND
Definition swell-types.h:210
struct HGDIOBJ__ * HICON
Definition swell-types.h:268
struct HDC__ * HDC
Definition swell-types.h:263
INT_PTR(* DLGPROC)(HWND, UINT, WPARAM, LPARAM)
Definition swell-types.h:586
#define HIWORD(l)
Definition swell-types.h:91
#define MAKEINTRESOURCE(x)
Definition swell-types.h:1157
HWND SetCapture(HWND hwnd)
Definition swell-wnd-generic.cpp:6934
LONG_PTR GetWindowLong(HWND hwnd, int idx)
Definition swell-wnd-generic.cpp:235
void DragFinish(HDROP hDrop)
Definition swell-wnd-generic.cpp:7516
UINT DragQueryFile(HDROP hDrop, UINT wf, char *buf, UINT bufsz)
Definition swell-wnd-generic.cpp:7521
LRESULT DefWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition swell-wnd-generic.cpp:7223
int GetSystemMetrics(int p)
Definition swell-wnd-generic.cpp:7734
void SWELL_SetClassName(HWND hwnd, const char *p)
Definition swell-wnd-generic.cpp:8421
HWND GetCapture()
Definition swell-wnd-generic.cpp:6929
void DestroyWindow(HWND hwnd)
Definition swell-wnd-generic.cpp:449
HWND GetFocus()
Definition swell-wnd-generic.cpp:572
void SetWindowPos(HWND hwnd, HWND zorder, int x, int y, int cx, int cy, int flags)
Definition swell-wnd-generic.cpp:637
bool IsWindowVisible(HWND hwnd)
Definition swell-wnd-generic.cpp:302
void ScreenToClient(HWND hwnd, POINT *pt)
Definition swell-wnd-generic.cpp:580
void SetFocus(HWND hwnd)
Definition swell-wnd-generic.cpp:506
LONG_PTR SetWindowLong(HWND hwnd, int idx, LONG_PTR val)
Definition swell-wnd-generic.cpp:163
BOOL EndPaint(HWND hwnd, PAINTSTRUCT *ps)
Definition swell-wnd-generic.cpp:7082
void ClientToScreen(HWND hwnd, POINT *pt)
Definition swell-wnd-generic.cpp:596
void ReleaseCapture()
Definition swell-wnd-generic.cpp:6946
BOOL InvalidateRect(HWND hwnd, const RECT *r, int eraseBk)
Definition swell-wnd-generic.cpp:6848
void GetClientRect(HWND hwnd, RECT *r)
Definition swell-wnd-generic.cpp:621
void ShowWindow(HWND hwnd, int cmd)
Definition swell-wnd-generic.cpp:1034
HINSTANCE LoadLibrary(const char *fn)
Definition swell.cpp:793
void * GetProcAddress(HINSTANCE hInst, const char *procName)
Definition swell.cpp:902
char * lstrcpyn(char *dest, const char *src, int l)
Definition swell.cpp:767
int n
Definition crypt.c:458
uch * p
Definition crypt.c:594
return c
Definition crypt.c:175
int r
Definition crypt.c:458
uch h[RAND_HEAD_LEN]
Definition crypt.c:459
b
Definition crypt.c:628
register uch * q
Definition fileio.c:817
int flag
Definition unix.c:754
typedef int(UZ_EXP MsgFn)()
#define void
Definition unzip.h:396
#define TRUE
Definition unzpriv.h:1295
#define FALSE
Definition unzpriv.h:1298
mo
Definition zipinfo.c:2287
_WDL_CSTRING_PREFIX void lstrcpyn_safe(char *o, const char *in, INT_PTR count)
Definition wdlcstring.h:129
#define GetWindowLongPtr(a, b)
Definition wdltypes.h:63
#define WDL_STATICFUNC_UNUSED
Definition wdltypes.h:87
#define SetWindowLongPtr(a, b, c)
Definition wdltypes.h:62
#define wdl_max(x, y)
Definition wdltypes.h:106
#define wdl_min(x, y)
Definition wdltypes.h:107
static int WDL_STATICFUNC_UNUSED WDL_MakeUTFChar(char *dest, int c, int destlen)
Definition wdlutf8.h:162
static int WDL_STATICFUNC_UNUSED WDL_DetectUTF8(const char *str)
Definition wdlutf8.h:202
#define GWLP_USERDATA
Definition win.c:30
#define WM_MOUSEHWHEEL
Definition win.c:24
#define WM_MOUSEWHEEL
Definition win.c:21
#define EEL_LICE_GET_FILENAME_FOR_STRING(idx, fs, p)
Definition ysfx_api_gfx.cpp:80