-
Notifications
You must be signed in to change notification settings - Fork 1
/
tinlib.ew
8762 lines (7538 loc) · 290 KB
/
tinlib.ew
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- strange bugs are marked with --CHECK
--without warning
--****
forward public procedure pb_SetStep(atom handle,atom step=1)
forward public procedure pb_SetRange(atom handle,atom minimum=1,atom maximum=100)
forward public function Window (sequence title="TinEwg Window",atom xpos=-1,atom ypos=-1,atom xsize=400, atom ysize=200)
forward public function GetImageHeight (atom handle)
forward public function GetImageWidth (atom handle)
forward public function GetWindowLong (atom hwnd,atom index)
forward public function SetWindowLong (atom hwnd,atom index,atom newlong)
forward public function SendMessage (atom hwnd,atom msg,atom wparam,atom lparam)
forward public function GetWindowRect (atom hwnd)
forward public function GetClientRect (atom hwnd)
forward public procedure InfoMsg ( object text, object title)
forward public procedure WarnMsg ( object text, object title)
forward public procedure ListSeek ( atom handle,atom pos)
forward public procedure DeleteImage (atom handle)
forward public function GetText ( atom handle)
forward public function FindWindow (object name,object classw=0)
forward public procedure MoveWindow ( atom handle, atom xpos, atom ypos, atom height, atom width, atom repaint)
forward public function WideCharSeq(sequence text)
forward public function AppendSeparator (atom menuhandle)
forward public function GetControlType(atom handle)
forward function ctlGetControlIndex(atom handle)
forward public procedure IPC_SendString (object target,sequence data)
-- more forwards line 980...
-- == tinEWG - A simple wrapper for the Win32 Api
-- <<TOC level=1
-- <<LEVELTOC level=2 depth=3>>
-- == Preample
--
-- This documentation is far from being completed or correct!
--
-- The name tinEWG means "this is not EuWinGui".
-- tinEWG was born as an extension for EuWinGui, as i tried to improve Designer for
-- EuWinGui.\\
-- tinEWG is still under construction and I'am really shure it will be forever.
-- I use it for my own small projects and expand it as i need it myself.\\
-- tinEWG is not a replacement for the fullfeatured frameworks like Win32lib or EuGTK or wxWindows,
-- but it is handy for simple Prgrams that don't need a complex GUI.
-- \\
-- tinewg is based on ideas of Andrea Cini and his EuWinGui library.
-- I use his documentation of EuWinGui as a starting point for the documentation of tinewg
-- and he kindly gave me the permission to use his work. \\
--
-- {{{
-- Hello Andreas
-- sure you can use the documentation as a starting base for your project. Thanks for keeping reference to my work.
-- Best wishes and good luck|
--
-- Andrea
-- }}}
--
-- ----
-- == License
-- As i think it is very Important to have a clear License for any kind of Software\\
-- i hereby put this Software under the MIT license.\\\\
--
-- Copyright (c) <2013> <Andreas Wagner andi@indonesianet.de>\\
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this
-- software and associated documentation files (the "Software"), to deal in the Software
-- without restriction, including without limitation the rights to use, copy, modify, merge,
-- publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
-- to whom the Software is furnished to do so, subject to the following conditions:\\
-- \\The above copyright notice and this permission notice shall be included in all copies or
-- substantial portions of the Software.\\
-- \\THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
-- INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-- IN THE SOFTWARE.
--
-- ----
-- == Basic usage
--
-- Also tinEWG is mostly compatible to EuWinGui, there are some differences\\
-- A simple tinEWG program may look like this\\
--
-- {{first.jpg|First}}\\
-- <eucode>
-- include tinewg.exw
-- Window ("EuWinGUI - The First Program",100,100,290,95)
-- constant button1=Control(Button,"Info",5,10,270,50)
-- SetIcon("T.ICO")
--
-- procedure clickbutton()
-- InfoMsg("Programmed in Euphoria with the EuWinGUI Library!!","EuWinGUI")
-- end procedure
--
-- SetHandler (button1,Click,routine_id("clickbutton"))
--
-- WinMain ()
--
-- </eucode>
-- But for sure, you can also write your code in the default EuWinGui style\\
-- <eucode>
-- include tinewg.exw
-- atom button1
--
-- procedure EventLoop()
-- while True do
-- WaitEvent()
-- if Event = Click then
-- if EventOwner = button1 then
-- InfoMsg("Programmed in Euphoria with the EuWinGUI Library!!","EuWinGUI")
-- end if
-- end if
-- end while
-- end procedure
--
-- procedure Main()
-- Window("EuWinGUI - The First Program",100,100,290,95)
-- button1 = Control(Button,"Info",5,10,270,50)
-- SetIcon("T.ICO")
-- EventLoop()
-- CloseApp(0)
-- end procedure
--
-- Main()
-- </eucode>
--
-- Or even mix both of the styles (sometimes you have to do this)
--
-- <eucode>
-- include tinewg.exw
-- Window("EuWinGUI - The First Program",100,100,290,95)
-- constant button1 = Control(Button,"Info",5,10,270,50)
--
-- procedure clickbutton()
-- InfoMsg("Programmed in Euphoria with the EuWinGUI Library!!","EuWinGUI")
-- end procedure
--
-- SetHandler (button1,Click,routine_id("clickbutton"))
--
-- procedure EventLoop()
-- while WaitEvent () do
-- ProcessHandlers ()
-- end while
-- end procedure
--
-- procedure Main()
-- SetIcon("T.ICO")
-- EventLoop()
-- CloseApp(0)
-- end procedure
--
-- Main()
-- </eucode>
--
-- tinEWG stands for "this is not" EWG (so do not wonder if it acts different)!
-- This is a first try to rewrite EuWinGui from Andrea Cini, basicly only to improve the Designer
-- started 8.7.2011 Andreas Wagner andi@indonesianet.de
-- if you read the remarks, EWG or EuWinGui is for the original EuWinGui from Andrea Cini
-- if it refers to tinEWG this is this file
-- All Editing is done with Edita (0.3.5) the best you can get for Euphoria
-- After 12.08.2011 i changed development to Eu4 (no testing for Eu3 anymore)
-- 16.07.2011 Controls are now implementet, Dialogs seems to work, Activate() still doesn't like expected.
-- 19.07.2011 Startet work on resizing windows
-- 23.07.2011 Added FileDlg
-- 26.07.2011 Startet work on Sub Classing the Controls (hooking their WndProc)
-- 04.08.2011 Startet Resizing Controls Support for the Designer (fits to the above task)
-- 06.08.2011 Startet Moving Controls Support for the Designer
-- 12.08.2011 Resizing mostly done, still lacking support for STATIC-Controls (maybe need to fake them in the Designer)
-- 15.08.2011 Startet GDI Functions (NewMB,DrawPolygon,SetPenColor needed for the Designer)
-- 17.08.2011 Added faked STatic-Controls to the Designer
-- 31.08.2011 Just a few marginal changes to tinEWG (to increase compatibility with the Designer)
-- 22.09.2011 Added ProcessEvent()
-- 11.01.2012 Added CopyMB,CopyMBtoControl,NewFont, etc.
--
-- since 13.01.2012
--
-- Thanks to Fred Mangan from Australia, becouse of his intensive testing, countless bugs could be fixed.
--
-- 21.02.2012 Added ChooseFont() the Standard Windows Dialog for choosing fonts
-- 24.03.2012 Added Printing support
-- 21.04.2012 New experimental SetHandler interface
-- 06.05.2012 Menu support
-- LoadPicFR (Load a Bitmap from Resource)
-- 06.08.2012 (very) Basic IPC via WM_COPYDATA
-- 11.2012 MCISendString
-- 29.12.2012 RichEdit with support for Syntax Color (only for use in the Designer)
-- without warning
-- without type_check
--
--****
-- ----
-- === Global Variables
-- ----
--
--**
-- Just a number, can be used to make sure that a specific Version is used, or the Version
-- is not to old for your Software. As of this writing the actual number is 78(hex)
-- I think a real Version 1.0.0 will follow the number FF(hex), if ever.
--
--
public constant TINVERSION=#09b
--include std\os.e
--include std\pretty.e
--include std\console.e
--include std\machine.e
--include std\dll.e
--include std\math.e
--include std\filesys.e
--include std\search.e
include cffi.e
include tinEWG_const.ew
include winapi.ew
-- Types used to make live easier
type flatsequence(object text)
if sequence(text) then
for i=1 to length(text) do
if not(atom(text[i])) then
return 0
end if
/*end*/
end for
/*end*/
else return 0
end if
/*end*/
return 1
end type
type bool(integer x)
return x=0 or x=1
end type
--global type byte(integer x)
-- return (x>-1) and (x<256)
--end type
atom INPROC
-- Maybe, someday we will need it
constant tPOINTER = 4,
tDWORD = 4
-- tUINT = 4,
-- tWORD = 2,
-- tBYTE = 1
atom myLoadIcon, myLoadCursor,mySetCursor, myGetStockObject, myRegisterClassEx,
myCreateWindow, myShowWindow, myUpdateWindow, myGetMessage,myPeekMessage,
myTranslateMessage, myDispatchMessage, myPlaySound, myBeginPaint,
myGetClientRect, myDrawText, myEndPaint, myPostQuitMessage, myDefWindowProc,mySetWindowText,
myGetWindowText,myGetDesktopWindow,myGetActiveWindow,mySetActiveWindow,myGetTopWindow,myGetNextWindow,
myMessageBox,mySetForegroundWindow,myGetVersionEx,mySetWindowsHookEx,myUnhookWindowsHookEx,myCallNextHookEx,
myExitWindowsEx,myGetClassName,myGetDC,myGetWindowDC,myReleaseDC,mySleep,mySetBkColor
global atom myCreateSolidBrush,myDeleteObject,myGetSysColorBrush,myInvalidateRect,myGetWindowRect,mySelectObject,myStretchBlt,
myBitBlt,mySetStretchBltMode,myDeleteDC,myCreateFont,myGetTextExtentPoint32,myChooseFont,myGetDeviceCaps,myGetObject
atom myEllipse
atom myMapVirtualKey,myPostMessage,mykeybd_event,myGetKeyState,mySetBkMode,mySetTextColor
atom myFindWindow1,myWinExec,myLoadImage,mySendMessage,myBringWindowToTop,mySetFocus
atom myIsZoomed,myIsIconic
atom myCloseClipboard,myOpenClipboard,myEmptyClipboard,mySetClipboardData
atom myCreateToolhelp32Snapshot,myCloseHandle,myModule32First,myModule32Next,myGetLastError,
myProcess32First,myProcess32Next
atom myGetWindowThreadProcessId,myGetCurrentThreadId,myAttachThreadInput,myGetForegroundWindow
atom mySetTimer,myKillTimer,myMoveWindow,myIsWindowVisible,myEnumWindows
atom myGetSystemMetrics,mySetWindowTheme,myInitCommonControlsEx,myEnableWindow,myRedrawWindow,myChildWindowFromPoint,
myAnimateWindow,myDestroyWindow
atom myAppendMenu,myCheckMenuItem,myCreateMenu,myDestroyMenu,myEnableMenuItem,mySetMenu,myCreatePopupMenu,myTrackPopupMenu,
myDrawMenuBar,mySetMenuItemBitmaps,myGetMenuItemInfo
atom myGetOpenFileName,myGetSaveFileName,myCommDlgExtendedError,myCallWindowProc,myGetWindowLong,mySetWindowLong,
myMultiByteToWideChar,myGetSysColor,myShellExecute
atom myCreateCompatibleDC,myCreateCompatibleBitmap,myRectangle,mySetDCBrushColor,mySetDCPenColor,myFillRect,
myMoveTo,myLineTo,myPolyLine,myPolygon,myCreatePen,myGetPixel,mySetPixel,myTextOut
atom myGetDefaultPrinter,myStartDoc,myEndDoc,myStartPage,myEndPage,myCreateDC,myPrintWindow,
myPrintDlg,
myFindExecutable,myAssocQueryString
atom mySetLayeredWindowAttributes
atom mymciSendString,myGetShortPathName
atom mySetProcessDefaultLayout
-- atom MSG,PID,lpWideCharStr
atom lpWideCharStr
atom myBrowseFolder,mySHGetPathFromIDList
--sequence th_modulname,th_pathname,th_procname
atom myGetCurrentProcess,iswow64
atom mygdiplusStartup,mygdiplusShutdown,myRtlGetNtVersionNumbers
atom mygdipCreateBitmapFromFile,mygdipDisposeImage,mygdipCreateHBITMAPFromBitmap
atom gdipToken=allocate(4)
atom myaddfont,myremovefont
poke4(gdipToken,0) -- The handle (token) for GDI+ Startup und Shutdown,free on exit
constant WideCharMax=16384
public sequence PosRect,LPRECT
--
-- MSG is the container(buffer) for the Windows Messages, used all the time
--
-- now in winapi.ew
--MSG = allocate(SIZE_OF_MESSAGE) -- The buffer for the WindowMessages, free it on Exit
lpWideCharStr = allocate(WideCharMax) -- Buffer for WideChars, free on Exit
--
-- Buffer for Rect-Struct (Window-Coordinates)
-- Used in the resizepart of WM-SIZE in WndProc
--
LPRECT = {0,0,0,0}
PosRect={0,0,0,0}
--
-- Buffer for whatever a POINT STructure is needed, free it on Exit
-- typedef struct tagPOINT {
-- LONG x;
-- LONG y;
-- } POINT, *PPOINT;
--
atom tPoint = allocate (8)
atom ButtonProcAdress,
EditProcAdress,
ListBoxProcAdress,
StaticProcAdress,
ProgressProcAdress,
ComboBoxProcAdress,
RichEditProcAdress,
ListViewProcAdress,
OldButtonProcAdress,
OldEditProcAdress,
OldListBoxProcAdress,
OldStaticProcAdress,
OldProgressProcAdress,
OldComboBoxProcAdress,
OldRichEditProcAdress,
OldListViewProcAdress
-- EWG VARS
--public constant True = 1
--public constant False = 0
public constant Null = 0
public object Void
constant WinTimer =1
global atom EWG = 1
--**
-- initially set to False; if set to True before running the event loop allows the
-- generation of a Close event if the user clicks on a window's default close button;
-- process this Event to perform some actions before the application is finished
-- (and remember to finish it with a call to the [[:CloseApp]]() procedure to free the resources
-- created by EuWinGUI) or to make a Dialog control invisible in a multiple-windows
-- application
-- See also:
-- Event [[:Close]],[[:CloseApp]]
--
public integer CloseEventEnabled
--**
-- (initially set to False; if set to True before using the SetPic() procedure,
-- tells Windows to use the color of the leftmost/topmost pixel of a bitmap loaded from a file
-- as "transparent color": all the occurences of that color inside the image are automatically
-- replaced with the color of the window's surface, so that is possible to load into
-- Picture/ClickPicture/PictureButton controls images with a "transparent" background);
-- Note that this flag has no effect if the bitmap has been created in memory using NewMB()
--
public integer UseTransparentPics
--**
-- (initially set to False; set this variable to True before using the Window() procedure
-- if you need to create an always-on-top Main Window)
--
public integer WinOnTop
--**
-- initially set to True; by default, the Main Window and all controls are shown
-- immediately after their creation. By setting this variable to False BEFORE the creation
-- of the main window or any control it is possible to create them initially hidden.
-- To make them visible it will be necessary to call the [[:SetVisible]]() EuWinGUI procedure.
-- For example if an application uses many controls the interface's creation could take
-- some time and cause some noisy "flickerings". By setting this variable to False BEFORE
-- using the [[:Window]]() procedure and resetting it to True BEFORE the creation of the controls,
-- the main window is not shown after its creation and remains hidden until a call to
-- SetVisible(WinHwnd,True) make it visible. This way it is possible to add all the needed
-- controls to the window while it is still hidden and then make it visible only after the
-- interface is completely created and all the settings have been made (i.e. before entering
-- the event loop); this way, no flickerings occur
-- See also:
-- [[:SetVisible]],[[:AnimateWindow]],[[:ShowWindow]]
--
public integer ShowFlag
public integer AutoResize=1
public integer UserTrap
-- This should contain the routine_id for the GameLoop in WinGame()
public atom GameLoop = 0
--**
-- stores the handle of the Main Window, after it has been created using the Window()
-- procedure, for use with any EuWinGUI function which need a control's handle to work
--
public atom WinHwnd
--**
-- stores the last Event type recorded after returning from the WaitEvent() function
--
public atom Event
atom intEvent=0
--**
-- stores the handle of the control to which the last Event recorded after returning
-- from the WaitEvent() function belongs
--
public atom EventOwner
atom intEventOwner=0
--**
-- stores an additional value associated with certain Event types, after returning from
-- the WaitEvent() funtion; for instance stores the char code of the key pressed,
-- once a Key Event has occurred
--
public atom EventItem
atom intEventItem=0
-- **
-- stores the handle of the last bitmap loaded after a call to the [[:SetPicture]]() procedure
-- (so it can be NULL if the latter function fails). The handle of a bitmap can be used
-- with the [[:SetPic]]() to load it multiple times into a same or different controls without
-- using additional memory, or with the [[:DeleteImage]]() procedure to free up the used memory
-- if the bitmap is no more needed
-- See also:
-- [[:SetPicture]],[[:SetPic]],[[:DeleteImage]]
public atom PictureHandle = 0
--**
-- initially set to NoMaxWin; use this variable to set the appearance (style) of the Main Window or of a Dialog control before using the Window()
-- procedure or the Control(Dialog,...) function.
-- Note:
-- # windows created with either NoTitleWin or NoBorderWin styles, lacking the titlebar,
-- cannot be moved on the screen by the program's User (but it is still possible to move
-- them at run-time)
-- # program which uses a Main Window created with one the latter styles or the NoSysWin
-- one, lacking the default close ("X") button, MUST provide an alternative way to close
-- the program.
-- Six different styles are available:
--
public atom WindowType
--**
-- default; window with titlebar, minimize+close buttons and solid frame
--
public constant NoMaxWin = 3001
--**
-- window with titlebar, close button only and solid frame
--
public constant NoMaxMinWin = 3002
--**
-- window with titlebar, no active buttons and solid frame
--
public constant NoSysWin = 3003
--**
-- window without titlebar and solid frame
--
public constant NoTitleWin = 3004
--**
-- flat window without titlebar and border
--
public constant NoBorderWin = 3005
--**
-- Resizeable Window with titlebar
--
public constant StandardWin = 3006
WindowType = NoMaxWin
--**
-- (store the pointer's coordinates, relative to the upper-left corner of the control's client
-- area, after the occurrence of a recognized mouse event (i.e. Click, Release, RClick, RRelease,
-- Move if the issuing control is the Main Window or a Dialog, or the Move event only if the
-- control is another type)
-- Note: The Move events generated while one of the mouse buttons is pressed (as well as the
-- Release and RRelease events) and recognized by the Main Window or by a Dialog can be issued
-- when the mouse pointer is phisically out of the owner window's boundaries. Since the values
-- stored into MouseX/Y can range from 0 to 65535 (e.g. no negative values are returned by Windows)
-- and are relative to the upper-left corner of the window's client area, it is not directly possible
-- to know if the mouse has generated the events inside or outside the window's boundaries.
-- However it is possible to know that with a simple check: if MouseX (MouseY) is bigger than
-- the width (height) of the owner's window, it means that the event was surely generated while
-- the mouse was outside the right (bottom) boundary of the window, BUT if MouseX (MouseY) is ALSO
-- greater than the screen's width (height) it means that the event was generated while the mouse
-- pointer was outside the left (top) boundary of the window's client area. Practically,
-- if MouseX (MouseY) returns a value of 65535, it means that the event was generated when the
-- pointer was located 1 pixel left (up) of the beginning of the window's client area,
-- 65534 means it was 2 pixels left (top) and so on.)
--
public atom MouseX=0 , MouseY=0
public atom Ticks
public atom FN_DEFAULT, FN_FIXED
--****
-- == The tinewg Events
-- <<TOC level=1
-- <<LEVELTOC level=2 depth=3>>
--
public constant event_names={"Click","Move","RClick","Time","Close","HotKey","Restore","Key",
"DClick","Release","RRelease","PosChanged","CurChange","Paint",
"Menu","Default","Ipc","Mci","ReSize"}
public constant
--**
-- An Event:
-- generated by leftclicking a Control/Window\\
-- recognized/generated by: ALL windows and controls BUT Group,Picture,Framed/Text,Label\\
-- when: one of the specified controls is clicked with the left mouse button;
-- if the control is a window, the Event is generated when the mouse button is pressed,
-- otherwise it is generated when the button is released
--
Click = 1001,
--**
-- An Event:
-- recognized/generated by: ALL windows and controls BUT Group,Picture,Framed/Text,Label\\
-- when: the mouse pointer is moved over the client area
-- of one of the specified controls not covered by others
--
Move = 1002,
--**
-- An Event:
-- recognized/generated by: ALL windows and controls BUT Group,Picture,Framed/Text,Label\\
-- when: the right mouse button is pressed over a window. Note: by handling this Event it
-- is possible to incidentally break the normal handling procedure of the same event
-- (if any) made by Windows. For example, by intercepting the RClick Event of an Edit field
-- it is possible to prevent the default Cut/Copy/Paste Windows popup menu to be shown.
-- For this reason, particular care must be made if intercepting this Event while the owner
-- control already has an associated default Windows action to perform
--
RClick = 1003,
--**
-- An Event:
--
Time = 1004,
--**
-- An Event:
-- recognized/generated by: Main Window,Dialog
-- when: CloseEventEnabled is set to True, and the user clicks on the window's default
-- close ("X") button
-- See also:
-- [[:CloseEventEnabled]]
--
Close = 1005,
--**
-- An Event:
--
HotKey = 1006,
--**
-- An Event:
--
Restore = 1007,
--**
-- An Event:
--
Key = 1008,
--**
-- An Event:
--
DClick = 1009,
--**
-- An Event:
-- recognized/generated by: Main Window,Dialog
-- when: the left mouse button is released after it was pressed over a window
--
Release = 1010,
--**
-- An Event:
--
RRelease = 1011,
--**
-- An Event:
--
PosChanged = 1012,
--**
-- An Event:
--
CurChange = 1013,
--**
-- An Event:
--
Paint = 1014,
--**
-- An Event:
--
Menu = 1015,
--**
-- All Events:
--
Default=1016,
--**
-- An Event:
--
Ipc=1017,
--**
-- An Event:
--
Mci=1018,
--**
-- An Event:
--
ReSize=1019
--****
-- == The tinewg Controls
-- <<TOC level=1
-- <<LEVELTOC level=2 depth=3>>
--
--**
-- Simple button with a caption
-- <eucode>
-- atom button1=Control(Button,"Button",0,0,80,30)
-- </eucode>
-- {{button.jpg|Button}}
--
public constant Button = 1
--**
-- Button showing a custom BMP picture instead of a caption
--
public constant PictureButton = 2
--**
-- Editable field with horizontal scrollable text
--
public constant Edit = 3
--**
-- Simple editable field with fixed width text
--
public constant SimEdit = 4
--**
-- Multiline editable field with horizontal scrollable text
--
public constant MultiEdit = 5
--**
-- Simple multiline editable field with fixed width text and word wrapping
--
public constant SimMultiEdit = 6,
Text = 7,
FramedText = 8,
ClickText = 9,
Label = 10,
ClickLabel = 11,
Group = 12,
Check = 13,
SimCheck = 14,
Radio = 15,
SimRadio = 16,
Picture = 17,
ClickPicture = 18
--**
-- Simple list box
-- <eucode>
-- atom lbox=Control(List,"",0,0,80,80)
-- ListAdd(lbox,"ListItem 1")
-- ListAdd(lbox,"ListItem 2")
-- [...]
-- ListAdd(lbox,"ListItem n")
-- </eucode>
-- {{listbox.jpg|Listbox}}
--
public constant List = 19
--**
-- Sorted list box. The Items are automaticlly sorted in this ListBox.
--
public constant SortedList = 20,
SimMultiList = 21,
PushButton = 22,
PicturePushButton = 23,
Dialog = 24,
SelecList = 25,
SortedSelecList = 26,
IconButton = 27,
ProgressBar = 28,
DropDown = 29,
StatusBar = 30,
ListView = 31,
ClickImage = 35,
Image = 36,
ComboBox = 37,
TabControl = 38
global atom Calendar = 32,
IpEdit = 33
public atom RichEdit = 34
global atom Fake = 49,
UserDefControl = 50,
MainWin =51
public atom ToolTip = 52
atom SSaver = 3007
public constant CR_WE = 4001,
CR_NS = 4002,
CR_SIZE = 4003,
CR_VARROW = 4004,
CR_WAIT = 4005,
CR_NULL = 4006,
CR_HELP = 4007,
X_DIM = 5001,
Y_DIM = 5002,
KEY_ENTER = 13,
KEY_BACKSPACE = 8,
KEY_ESCAPE = 27,
KEY_DOWN = 40,
KEY_UP = 38,
KEY_LEFT = 37,
KEY_RIGHT = 39,
KEY_CLEAR = 12,
KEY_PAUSE = 19,
KEY_CAPSLOCK = 20,
KEY_PGUP = 33,
KEY_PGDN = 34,
KEY_END = 35,
KEY_HOME = 36,
KEY_INS = 45,
KEY_DEL = 46,
KEY_FUNC01 = 112,
Save = 2001,
Open = 2002,
CL_WHITE = #FFFFFF,
CL_GRAY = #C0C0C0,
CL_DKGRAY = #808080,
CL_BLACK = #000000,
CL_YELLOW = #00FFFF,
CL_DKYELLOW = #008080,
CL_RED = #0000FF,
CL_DKRED = #000080,
CL_GREEN = #00FF00,
CL_DKGREEN = #008000,
CL_CYAN = #FFFF00,
CL_DKCYAN = #808000,
CL_BLUE = #FF0000,
CL_DKBLUE = #800000,
CL_PURPLE = #FF00FF,
CL_DKPURPLE = #800080,
CL_DEFAULT = #FFFFFFFF
CloseEventEnabled = False
UseTransparentPics = False
WinOnTop = False
ShowFlag = True
UserTrap = False
-- Extensions for tinEWG
public atom PressedKey=-1
public atom EraseBkg=True
public sequence TrappedMsgList={0}
public sequence TrappedMsg={0,0,0,0}
public atom MessageBoxReturnValue
public atom WinBackGround
atom DC_BrushColor -- This is a Brush not a color
atom DC_PenColor -- This is a Pen not a color
--atom DC_BkColor=CL_DEFAULT -- Backgroundcolor for Drawstring
atom DC_DefaultControl -- the default drawing control (same as the default memorybitmap in tinEWG)
atom DC_ActColor -- This is the actual Color (in EuWinGui for both Pen and Brush)
atom DC_ActPenSize -- Size of the Pen
atom DC_ActPenStyle -- Style of the Pen (remember not every style works with every size)
atom DC_ActFont -- The default drawing font
atom DC_HOLLOWBRUSH
public atom ParentWnd
public atom SpecialMode -- Could be for now Designer or NoDesigner
public sequence DefaultPrinter= "none" -- The Printer after calling selectprinter
atom Print_ActFont -- The dafault drawing Font for the Printer
atom Print_ActColor -- The actual Printing color
atom Printhdc=0
public constant Designer=1
public constant NoDesigner=0
public constant gDesigner=#FFFF -- The Special-Group for the Designer
public atom ctlEvent,
ctlEventOwner,
ctlEventItem -- needed for moving/resizing controls in the Designer
public bool NoVisualStyles=False -- If set, it disables Themes for CheckBox Controls
public atom CopyMode=SRCCOPY -- For the CopyMB and the CopyMBToControl functions
-- Internally for making the Events work
atom XEventOwner=False
atom XRestore=False
atom IsMiniMized=False -- !!!remove after testing!!!???
-- Internally for making the Events work
--**
-- Sets the Color of the Window and Dialog Backgrounds, must be between 0 to 31
-- must be set before the main Window is created
-- You can also set WinBackGround to any other Brush.
-- e.g. WinBackGround=c_func(myCreateSolidBrush,{#00F0F0F0})
--
WinBackGround = 16
ParentWnd = Null
WinHwnd = Null
DC_BrushColor=0
DC_PenColor=0
DC_DefaultControl=0
DC_ActPenSize=1
DC_ActPenStyle=PS_SOLID
--**
-- Set the creation behavior of Dialog Windows. Dialog as Child is the standardway in the original EWG
--
public bool DialogIsChild
DialogIsChild = True
public bool DialogIsRealChild
DialogIsRealChild=False
--**
-- The Classname of the Main Window. You can change this as you like it
--
public sequence tinEWGApp
tinEWGApp = "tinEWGApp"
--
-- Sequence and constants needed to store the coordinates for Autoresizing the controls
--
constant rs_handle = 1, -- handel of the control
rs_xcoord = 2, -- x Position
rs_ycoord = 3, -- y Position
rs_xsize = 4, -- x Size (Width)
rs_ysize = 5, -- y Size (Height)
rs_parent = 6, -- handle of Parent
rs_mode = 7, -- set resizing mode, see below
rs_backcolor =8, --
rs_textcolor =9, --
rs_backbrush =10, --
rs_controltype = 11, -- type of control
rs_group=12, -- Group of Control (if any) #FFFF is used for the Designer
rs_tooltip=13 -- The assosciated ToolTip-Control
sequence resize_controls
resize_controls = {{rs_handle,rs_xcoord,rs_ycoord,rs_xsize,rs_ysize,rs_parent,rs_mode,rs_backcolor,
rs_textcolor,rs_backbrush,rs_controltype,rs_group}}
public constant rs_mode_non = 0, -- no resizing
rs_mode_full = 1, -- resizes both, size and position
rs_mode_size = 2, -- only size
rs_mode_pos = 3 -- only position
sequence PaintProcs={{Null,Null}}
sequence GDIBrushes,GDIBitmaps
GDIBrushes = {{Null,Null}}
GDIBitmaps = {{Null,Null}}
-- Variables for the new experimental SetHandler interface
object Click_Event=0
object RClick_Event=0
object Release_Event=0
object Move_Event=0
object RRelease_Event=0
object DClick_Event=0
object Key_Event=0
object HotKey_Event=0
object Restore_Event=0
object Close_Event=0
object Time_Event=0
object Menu_Event=0
object Default_Event=0 -- The Default Event is "every" Event
object Data_Event=0 -- This holds the Ipc Event
object Mci_Event=0 --
object Paint_Event=0
--object ReSize_Event=0
--
-- END EWG VARS --
procedure init_ewg()
FN_FIXED=c_func(myGetStockObject,{SYSTEM_FIXED_FONT})
FN_DEFAULT=c_func(myGetStockObject,{ANSI_VAR_FONT})
DC_HOLLOWBRUSH=c_func(myGetStockObject,{HOLLOW_BRUSH})
DC_ActFont=FN_DEFAULT
Print_ActFont=FN_DEFAULT
EventOwner =0
EventItem =0
Event =0
-- only needed for resizing in the Designer
ctlEventOwner=0
ctlEventItem=0
ctlEvent=0
--
INPROC=0
SpecialMode=NoDesigner
end procedure
forward public procedure SetPic ( atom handle, atom controltype=0, object imagehandle=DC_DefaultControl)
forward public procedure SetText ( atom handle, flatsequence text, atom part=0)
public function LoWord(atom dword)
return and_bits(#0000FFFF,dword)
end function
public function HiWord(atom dword)
return floor(and_bits(#FFFF0000,dword)/#10000)
end function
procedure not_found(sequence name)