-
Notifications
You must be signed in to change notification settings - Fork 0
/
llem_main.cpp
4801 lines (2945 loc) · 114 KB
/
llem_main.cpp
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
/*
Copyright (C) 2019 BrerDawg
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//llem_main.cpp
//v1.01 2021-dec-05 //
//mingw needs library -lmsvcp60 for mcrtomb type calls:
//from Makefile.win that dev-c++ uses, these params were used to compile and link:
//LIBS = -L"C:/Dev-Cpp/lib" -lmsvcp60 -lfltk_images -lfltk_jpeg -mwindows -lfltk -lole32 -luuid -lcomctl32 -lwsock32 -lm
//INCS = -I"C:/Dev-Cpp/include"
//CXXINCS = -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"
//CXXFLAGS = $(CXXINCS)
//CFLAGS = $(INCS) -DWIN32 -mms-bitfields
//#define compile_for_windows //!!!!!!!!!!! uncomment for a dos/windows compile
//use -mconsole in make's LIBS shown above for windows to use the dos console, rather a attaching a console
#include "llem_main.h"
#include "iconapp.xpm"
//asm("int3"); //useful to trigger debugger
//global objs
//dble_wnd *wndMain;
llem_wnd *wnd_llem = 0;
Fl_RGB_Image *theapp_icon0;
PrefWnd* pref_wnd2=0;
//global vars
int mains_font;
int mains_fontsize;
string csIniFilename;
int iBorderWidth;
int iBorderHeight;
int gi0,gi1,gi2,gi3,gi4;
double gd0,gd1,gd2,gd3,gd4;
string app_path; //path this app resides on
string dir_seperator="\\"; //assume dos\windows folder directory seperator
int mode;
int font_num = cnFontEditor;
int font_size = cnSizeEditor;
unsigned long long int ns_tim_start1; //a ns timer start val
double perf_period; //used for windows timings in timing_start( ), timing_stop( )
string fav_editor;
int pref_invert_mousewheel = 0;
int pref_allow_bounce_collision_det = 0;
int pref_audio_bounce_gain = 30;
int pref_audio_explosion_gain = 80;
int pref_audio_bass_boost = 1;
int pref_audio_gain = 100;
int pref_audio_reverb_on = 1;
int pref_audio_reverb_room_size = 30;
int pref_audio_reverb_damping = 70;
int pref_audio_reverb_width = 100;
int pref_audio_reverb_dry_wet = 30;
int pref_development_mode = 0;
int pref_audio_fryingpan_plosive_gain = 100;
int pref_distortion_gain = 100;
int pref_expertise0 = 0; //refer: 'landing_rating_speed_limit[]'
int pref_expertise1 = 1;
int pref_expertise2 = 0;
int pref_expertise3 = 0;
int pref_expertise4 = 0;
bool mute = 0;
int iAppExistDontRun = 1; //if set, app probably exist and user doesn't want to run another
//set it to assume we don't want to run another incase user closes
//wnd without pressing either 'Run Anyway' or 'Don't Run, Exit' buttons
string sdebug; //holds all cslpf output
bool my_verbose = 1;
float timer_period = 0.02f;
mystr tim1;
rtaud rta; //rtaudio
st_rtaud_arg_tag st_rta_arg; //this is used in audio proc callback to work out chan in/out counts
int srate = 48000;
int framecnt = 1024;
float time_per_sample;
bool audio_started = 0;
int audio_source = 2;
float audio_gain = 2.0f;
float audio_thrust_gain = 0.0f;
float audio_thrust_gain_slewed = audio_thrust_gain; //slew rate limited, adj'd by rt audio callback to match 'audio_thrust_gain'
//float audio_thrust_gain_slewed_zeroed = audio_thrust_gain_slewed;
float audio_explosion_gain = 1.5f;
float filt_freq0 = 1000;
float filt_q0 = 2;
float play_speed = 0.5;
st_iir_2nd_order_tag iir0; //thrust filter
st_iir_2nd_order_tag iir1; //
st_iir_2nd_order_tag iir2; //thrust subsonic filter
st_iir_2nd_order_tag iir20; //explosion filter
st_iir_2nd_order_tag iir30; //explosion filter
st_iir_2nd_order_tag iir40; //frying pan noise src filter
float gain_iir0 = 1.0f;
float gain_iir1 = 1.0f;
float gain_iir2 = 1.0f;
float gain_iir20 = 1.0f;
float gain_iir30 = 1.0f;
float gain_iir40 = 1.0f;
float *revb_bf0 = 0;
float *revb_bf1 = 0;
float *revb_bf10 = 0;
float *revb_bf11 = 0;
int revb_size0;
int revb_size1;
int revb_size10;
int revb_size11;
int revb_rd0 = 1;
int revb_wr0 = 0;
int revb_rd1 = 1;
int revb_wr1 = 0;
int revb_rd10 = 1;
int revb_wr10 = 0;
int revb_rd11 = 1;
int revb_wr11 = 0;
string slast_wave_fname;
string slast_ship_fname;
string slast_moonscape_fname;
string sship_state_fname;
audio_formats af0;
st_audio_formats_tag saf0;
bool aud_loaded = 0;
uint64_t audptr = 0;
double dfract_audptr = 0;
int iflag_nan = 0; //rt code debug
st_envlp_tag st_envlp0[10]; //used for explosion sound
st_envlp_tag st_envlp1[10];
st_envlp_tag st_envlp2[10]; //used for bounce sound
string slast_highscore_name;
//function prototypes
void LoadSettings(string csIniFilename);
void SaveSettings(string csIniFilename);
int CheckInstanceExists(string csAppName);
void open_editor( string fname );
int RunShell( string sin );
//callbacks
void cslpf( const char *fmt,... );
void cb_wndmain( Fl_Callback *, void* v);
void cb_btAbout(Fl_Widget *, void *);
void cb_btOpen(Fl_Widget *, void *);
void cb_btSave(Fl_Widget *, void *);
void cb_btQuit(Fl_Widget *, void *);
void cb_timer1(void *);
void cb_pref2(Fl_Widget*w, void* v);
void cb_show_mywnd(Fl_Widget*w, void* v);
//void cb_font_pref(Fl_Widget*w, void* v);
void cb_open_folder(Fl_Widget *, void *);
void cb_open_file(Fl_Widget *, void *);
void log_callback( string s );
void cb_user2( void *o, int row, int ctrl );
void cb_edit_undo(Fl_Widget *, void *);
void cb_edit_redo(Fl_Widget *, void *);
void cb_edit_cut(Fl_Widget *, void *);
void cb_edit_copy(Fl_Widget *, void *);
void cb_edit_paste(Fl_Widget *, void *);
bool start_audio();
void stop_audio();
bool open_audio_file( string sfname );
void graph_update( vector<float> &v0, vector<float> &v1, vector<float> &v2 );
void create_filter_iir( en_filter_pass_type_tag filt_type, float filt_freq_in, float filt_q_in, st_iir_2nd_order_tag &iir );
bool grph_bf_loaded = 0; //set when audio proc has loaded data
float grph_bf0[cn_grph_buf_size];
float grph_bf1[cn_grph_buf_size];
float grph_bf2[cn_grph_buf_size];
freeverb_reverb *fvb = 0;
//make sure 'picked' is not the same string as 'pathfilename'
//string 'picked' is loaded with selected path and filename, on 'OK'
//on 'Cancel' string 'picked' is set to a null string
//returns 1 if 'OK', else 0
//set 'type' to Fl_File_Chooser::CREATE to allow a new filename to be entered
//linux code
#ifndef compile_for_windows
bool my_file_chooser( string &picked, const char* title, const char* pat, const char* start_path_filename, int type, Fl_Font fnt = -1, int fntsze = -1 )
{
picked = "";
//show file chooser
Fl_File_Chooser fc ( start_path_filename, // directory
pat, // filter
Fl_File_Chooser::SINGLE | type, // chooser type
title // title
);
if ( fnt != -1 )fc.textfont( fnt );
if ( fntsze != -1 )fc.textsize( fntsze );
fc.show();
while( fc.shown() )
{
Fl::wait();
}
if( fc.value() == 0 ) return 0;
picked = fc.value();
//windows code
//#ifdef compile_for_windows
//make the slash suit Windows OS
//mystr m1;
//m1 = fc.value();
//m1.FindReplace( picked, "/", "\\",0);
//#endif
return 1;
}
#endif
//windows code
#ifdef compile_for_windows
bool my_file_chooser( string &picked, const char* title, const char* pat, const char* start_path_filename, int type, Fl_Font fnt = -1, int fntsze = -1 )
{
OPENFILENAME ofn;
char szFile[ 8192 ];
string fname;
mystr m1;
m1 = start_path_filename;
m1.ExtractFilename( dir_seperator[ 0 ], fname ); //remove path from filename
strncpy( szFile, fname.c_str(), sizeof( szFile ) ); //put supplied fname as default
memset( &ofn, 0, sizeof( ofn ) );
ofn.lStructSize = sizeof ( ofn );
ofn.hwndOwner = NULL ;
ofn.lpstrFile = szFile ;
//ofn.lpstrFile[ 0 ] = '\0';
ofn.nMaxFile = sizeof( szFile );
ofn.lpstrFilter = "All\0*.*\0Text\0*.TXT\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = 0;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = start_path_filename ;
ofn.lpstrTitle = title;
ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR ;
if( type == Fl_File_Chooser::CREATE )
{
if( GetSaveFileName( &ofn ) )
{
picked = szFile;
return 1;
}
}
else{
if( GetOpenFileName( &ofn ) )
{
picked = szFile;
return 1;
}
}
return 0;
}
#endif
//linux code
#ifndef compile_for_windows
//make sure 'picked' is not the same string as 'pathfilename'
//string 'picked' is loaded with selected dir, on 'OK'
//on 'Cancel' string 'picked' is set to a null string
//returns 1 if 'OK', else 0
//set 'type' to Fl_File_Chooser::CREATE to allow a new directory to be entered
bool my_dir_chooser( string &picked, const char* title, const char* pat, const char* start_path_filename, int type, Fl_Font fnt = -1, int fntsze = -1 )
{
picked = "";
mystr m1;
//show file chooser
Fl_File_Chooser fc ( start_path_filename, // directory
pat, // filter
Fl_File_Chooser::DIRECTORY | type, // chooser type
title // title
);
if ( fnt != -1 )fc.textfont( fnt );
if ( fntsze != -1 )fc.textsize( fntsze );
fc.show();
while( fc.shown() )
{
Fl::wait();
}
if( fc.value() == 0 ) return 0;
picked = fc.value();
//make the slash suit Windows OS
//m1 = fc.value();
//m1.FindReplace( picked, "/", "\\",0);
return 1;
}
#endif
//windows code
#ifdef compile_for_windows
int CALLBACK BrowseCallbackProc( HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData )
{
TCHAR szDir[MAX_PATH];
switch( uMsg )
{
case BFFM_INITIALIZED:
if ( GetCurrentDirectory( sizeof(szDir) / sizeof(TCHAR), szDir ) )
{
// WParam is TRUE since you are passing a path.
// It would be FALSE if you were passing a pidl.
SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)szDir);
}
break;
case BFFM_SELCHANGED:
// Set the status window to the currently selected path.
if (SHGetPathFromIDList((LPITEMIDLIST) lp ,szDir))
{
SendMessage(hwnd,BFFM_SETSTATUSTEXT,0,(LPARAM)szDir);
}
break;
}
return 0;
}
/*
//this returns the PIDL for a particular folder, can be use with GetFolderSelection(..) code further below,
//if used in 'bi.pidlRoot', it only shows folders below the 'path', you can't seem to navigate upward past 'path'
LPITEMIDLIST get_pidl_from_path( string path )
{
LPITEMIDLIST pidl = 0;
LPSHELLFOLDER pDesktopFolder;
char szPath[MAX_PATH];
OLECHAR olePath[MAX_PATH];
char szDisplayName[MAX_PATH];
ULONG chEaten;
ULONG dwAttributes;
HRESULT hr;
//
// Get a pointer to the Desktop's IShellFolder interface.
//
if ( SUCCEEDED( SHGetDesktopFolder( &pDesktopFolder ) ) )
{
//
// IShellFolder::ParseDisplayName requires the file name be in
// Unicode.
//
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, path.c_str(), -1, olePath, MAX_PATH );
//
// Convert the path to an ITEMIDLIST.
//
hr = pDesktopFolder->ParseDisplayName( NULL, NULL, olePath, &chEaten, &pidl, &dwAttributes );
if ( FAILED( hr ) )
{
pidl = 0;
printf( "grrr() - failed\n" );
// Handle error.
}
//
// pidl now contains a pointer to an ITEMIDLIST for .\readme.txt.
// This ITEMIDLIST needs to be freed using the IMalloc allocator
// returned from SHGetMalloc().
//
//release the desktop folder object
pDesktopFolder->Release();
}
return pidl;
}
*/
//Displays a directory selection dialog. CoInitialize must be called before calling this function.
//szBuf must be MAX_PATH characters in length. hWnd may be NULL.
//Note: the get_pidl_from_path(..) call is commented out
BOOL GetFolderSelection( HWND hWnd, LPTSTR szBuf, LPCTSTR szTitle, string starting_path )
{
LPITEMIDLIST pidl = NULL;
BROWSEINFO bi = { 0 };
BOOL bResult = FALSE;
bi.hwndOwner = hWnd;
bi.pszDisplayName = szBuf;
bi.pidlRoot = 0;// get_pidl_from_path( starting_path ); //get_pidl_from_path(..) is not used as it only shows folders below the path, you can't navigate upward past 'pidlRoot'
bi.lpszTitle = szTitle;
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_USENEWUI;
bi.lpfn = BrowseCallbackProc;
if ((pidl = SHBrowseForFolder(&bi)) != NULL)
{
bResult = SHGetPathFromIDList(pidl, szBuf);
CoTaskMemFree(pidl);
}
return bResult;
}
bool my_dir_chooser( string &picked, const char* title, const char* pat, const char* start_path_filename, int type, Fl_Font fnt = -1, int fntsze = -1 )
{
OPENFILENAME ofn;
char szFile[ 8192 ];
TCHAR szFolder[ MAX_PATH ];
CoInitialize( NULL );
if( GetFolderSelection( NULL, szFolder, title, start_path_filename ))
{
printf( "The folder selected was %s\n", szFolder );
picked = szFolder;
return 1;
}
return 0;
/*
memset( &ofn, 0, sizeof( ofn ) );
ofn.lStructSize = sizeof ( ofn );
ofn.hwndOwner = NULL ;
ofn.lpstrFile = szFile ;
ofn.lpstrFile[ 0 ] = '\0';
ofn.nMaxFile = sizeof( szFile );
ofn.lpstrFilter = "All\0*.*\0Text\0*.TXT\0";
ofn.nFilterIndex =1;
ofn.lpstrFileTitle = 0;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = start_path_filename ;
ofn.lpstrTitle = title;
ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST ;
GetOpenFileName( &ofn );
picked = szFile;
*/
}
#endif
void cb_file_open( Fl_Widget *w, void* v )
{
string s1, s2;
//linux code
#ifndef compile_for_windows
s1 = "/mnt/home/PuppyLinux/MyPrj/Skeleton Unicode fltk - George";
#endif
//windows code
#ifdef compile_for_windows
s1 = "c:\\gc\\MyPrj\\Skeleton Unicode fltk - George";
#endif
/*
if( my_file_chooser( s2, "Open File", "*", s1.c_str(), 0, font_num, font_size ) )
{
u_wnd->fi_filename->value( s2.c_str() );
}
u_wnd->fc = new ucde_file_chooser( s1.c_str(), 0, FL_SINGLE, "Open a file" );
u_wnd->fc->textfont( font_num );
u_wnd->fc->textsize( font_size );
u_wnd->fc->callback( cb_ucde_file_chooser, 0 );
//fc->redraw();
u_wnd->fc->show();
while( u_wnd->fc->shown() )
{
Fl::wait();
}
GCCol.o: GCCol.h
u_wnd->fi_filename->value( u_wnd->fc->value() );
//u_wnd->fi_filename->value("Help!");
*/
//fc->hide();
//fc->show();
//fc->fileName->show();
}
void cb_dir_open( Fl_Widget *w, void* v )
{
string s1, s2;
//linux code
#ifndef compile_for_windows
s1 = "/mnt/home/PuppyLinux/MyPrj/Skeleton Unicode fltk - George";
#endif
//windows code
#ifdef compile_for_windows
s1 = "c:\\gc\\MyPrj\\Skeleton Unicode fltk - George";
#endif
/*
if( my_dir_chooser( s2, "Open Dir", "*", s1.c_str(), 0, font_num, font_size ) )
{
u_wnd->fi_filename->value( s2.c_str() );
}
*/
return;
char *ptr;
ptr = fl_dir_chooser( "Open Dir", s1.c_str() );
/*
if( ptr )
{
u_wnd->fi_filename->value( ptr );
}
*/
}
/*
bool check_file_exists( string fname )
{
FILE *fp;
mystr m1;
FILE* wcfopen( wstring &wstr );
//linux code
#ifndef compile_for_windows
//cslpf("src file exists: %s \n", fname.c_str() );
fp = fopen( fname.c_str() ,"rb" ); //open file
#endif
//windows code
#ifdef compile_for_windows
wstring ws1;
mystr m1 = fname;
m1.mbcstr_wcstr( ws1 ); //convert utf8 string to windows wchar string array
fp = _wfsopen( ws1.c_str(), L"rb", _SH_DENYNO );
#endif
if( fp == 0 )
{
return 0;
}
fclose( fp );
return 1;
}
*/
//----------------------------------------------------------
mywnd::mywnd( int xx, int yy, int wid, int hei, const char *label ) : dble_wnd( xx, yy, wid ,hei, label )
{
buf = 0;
jpg = 0;
init();
jpg = new Fl_JPEG_Image( "earthmap.jpg" ); // load jpeg image into ram
printf("Image dimensions w=%d, h=%d, depth=%d\n", jpg->w(), jpg->h(), jpg->d() );
bx_image = new Fl_Box( 50, h() - 50, jpg->w(), jpg->h() );
bx_image->image( jpg );
}
mywnd::~mywnd()
{
if ( buf != 0 ) delete buf;
printf(" \nFreeing memory...\n ");
if ( jpg != 0 ) delete jpg;
}
void mywnd::init()
{
ctrl_key = 0;
mousewheel = 0;
if ( buf != 0 ) delete buf;
buf = new int [ 100 ];
printf(" \nAllocating memory...\n ");
}
void mywnd::setcolref( colref col )
{
fl_color( col.r , col.g , col.b );
}
void mywnd::draw()
{
int rght,bot;
string s1;
Fl_Double_Window::draw();
//clear wnd
setcolref( col_bkgd );
fl_rectf( 0 , 0 , w() , h() - 50 );
setcolref( col_yel );
strpf( s1, "Dropped something here: %s", dropped_str.c_str() );
fl_draw( s1.c_str(), 5, 14 );
if ( ctrl_key == 1 ) s1 ="ControlKey: down";
else s1 ="ControlKey: up";
fl_draw( s1.c_str(), 5, 42 );
if ( left_button == 1 ) s1 ="LeftButton: down";
else s1 ="LeftButton: up";
setcolref( col_yel );
fl_draw( s1.c_str(), 5, 56 );
strpf( s1,"MouseWheel Val = %d" , mousewheel );
fl_draw( s1.c_str(), 5, 70 );
strpf( s1,"You should see a map below... ");
fl_draw( s1.c_str(), 5, 98 );
setcolref( col_mag );
fl_line( 50, 70, 80 , h() );
//bx_image->draw( 0, 0 );
}
//int bDonePaste = 0; //need this to be 0 to make dragging from web browser in linux work
int mywnd::handle( int e )
{
bool need_redraw = 0;
bool dont_pass_on = 0;
#ifdef compile_for_windows
bDonePaste = 1; //does not seem to be required for Windows, so nullify by setting to 1
#endif
if ( e == FL_PASTE ) //needed below code because on drag release the first FL_PASTE call does not have valid text as yet,
{ //possibly because of a delay in X windows, so have used Fl:paste(..) to send another paste event and
// if( bDonePaste == 0) //this seems to work ok (does not seem to happen in Windows)
if( 0 )
{
Fl::paste( *this, 0 ); //passing second var as 0 uses currently selected text, (not prev cut text)
// printf("\nDropped1\n" );
// bDonePaste = 1;
}
else{
// bDonePaste = 0;
string s = Fl::event_text();
int len = Fl::event_length();
printf("\nDropped Len=%d, Str=%s\n", len, s.c_str() );
if( len ) //anything dropped/pasted?
{
dropped_str = s;
need_redraw = 1;
}
}
// return 1;
dont_pass_on = 1;
}
if (e == FL_DND_DRAG)
{
printf("\nDrag\n");
dont_pass_on = 1;
}
if (e == FL_DND_ENTER)
{
printf("\nDrag Enter\n");
dont_pass_on = 1;
}
if (e == FL_DND_RELEASE)
{
printf("\nDrag Release\n");
dont_pass_on = 1;
}
if ( e == FL_PUSH )
{
if(Fl::event_button()==1)
{
left_button = 1;
need_redraw = 1;
}
dont_pass_on = 1;
}
if ( e == FL_RELEASE )
{
if(Fl::event_button()==1)
{
left_button = 0;
need_redraw = 1;
}
dont_pass_on = 1;
}
if ( ( e == FL_KEYDOWN ) || ( e == FL_SHORTCUT ) ) //key pressed?