-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathhwWind.c
2918 lines (2656 loc) · 80.7 KB
/
hwWind.c
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
/*
**
**
** Changes
** Author Date Desription
** P Slegg 14-Aug-2009 Remove the limit on paste buffer size by dynamically allocating space.
** P Slegg 18-Dec-2009 vTab_evKeybrd Utilise NKCC from cflib to handle the various control keys in text fields.
**
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <gem.h>
#include <cflib.h>
#include <gemx.h>
#ifdef __PUREC__
# define CONTAINR struct s_containr *
# define HISTORY struct s_history *
#endif
#include "global.h"
#include "Containr.h"
#include "Loader.h"
#include "Location.h"
#include "Form.h"
#include "cache.h"
#include "Logging.h"
#include "dragdrop.h"
#include "bookmark.h"
#include "strtools.h"
#include "clipbrd.h"
#define WINDOW_t HwWIND
#include "hwWind.h"
static WINDOW vTab_destruct(HwWIND);
static BOOL vTab_evMessage (HwWIND, WORD msg[], PXY mouse, UWORD kstate);
static void vTab_evButton (HwWIND, WORD bmask, PXY mouse, UWORD kstate, WORD);
static void vTab_evKeybrd (HwWIND, WORD scan, WORD ascii, UWORD kstate);
static void vTab_drawWork (HwWIND, const GRECT *);
static void vTab_drawIcon (HwWIND, const GRECT *);
static BOOL vTab_close (HwWIND, UWORD kstate);
static void vTab_raised (HwWIND, BOOL topNbot);
static void vTab_moved (HwWIND);
static BOOL vTab_sized (HwWIND);
static void vTab_iconified (HwWIND);
#define Curr Base.Curr
#define HISTORY_LAST 20
typedef struct s_url_hist * URLHIST;
struct s_url_hist {
URLHIST Next;
char Menu[40];
char Link[1];
};
static URLHIST url_hist = NULL;
#define URL_HIST_MAX 10
#define MAX_CLIPBOARD_LENGTH 4096
static WORD info_fgnd = G_BLACK, info_bgnd = G_WHITE;
static WORD inc_xy = 0;
static WORD widget_b, widget_w, widget_h;
static GRECT desk_area;
static GRECT brws_curr = { -1, -1, 0, 0 };
static GRECT bmrk_curr = { -1, -1, 0, 0 };
static UWORD brws_gmsk = 0x0000u;
static UWORD bmrk_gmsk = 0x0000u;
#define GEO_CFG_XY 0xF000u /* XY read from config */
#define GEO_USR_XY 0x00F0u /* XY modified by user */
#define GEO_CFG_WH 0x0F00u /* WH read from config */
#define GEO_USR_WH 0x000Fu /* WH modified by user */
static WORD tbar_set = +21;
#if (_HIGHWIRE_INFOLINE_ == 0)
static WORD wind_kind = NAME|CLOSER|FULLER|MOVER|SMALLER|SIZER;
#else
static WORD wind_kind = NAME|CLOSER|FULLER|MOVER|SMALLER/*|SIZER|INFO|LFARROW*/;
#endif
WORD hwWind_Mshape = ARROW;
HwWIND hwWind_Focus = NULL;
static void draw_infobar (HwWIND This, const GRECT * p_clip, const char * info);
static void draw_toolbar (HwWIND This, const GRECT * p_clip, BOOL all);
static BOOL chng_toolbar (HwWIND, UWORD, UWORD, WORD);
static void wnd_hdlr (HW_EVENT, long, CONTAINR, const void *);
typedef struct {
WORD Offset;
WORD Fgnd, Bgnd;
WORD Data[15], Fill[15];
} TOOLBTN;
static TOOLBTN hw_buttons[] = {
#define TBAR_LEFT 0
{ -1, G_BLACK, G_GREEN,
{ 0x0400, 0x0C00, 0x1400, 0x27E0, 0x4090, 0x8048, 0x8044, 0x4042,
0x27C2, 0x1442, 0x0C42, 0x0442, 0x0042, 0x005A, 0x0066 },
{ 0x0000, 0x0000, 0x0800, 0x1800, 0x3F60, 0x7FB0, 0x7FB8, 0x3FBC,
0x183C, 0x083C, 0x003C, 0x003C, 0x003C, 0x0025, 0x0000 } },
#define TBAR_RGHT 1
{ 20, G_BLACK, G_GREEN,
{ 0x0040, 0x0060, 0x0050, 0x0FC8, 0x1204, 0x2402, 0x4402, 0x8404,
0x87C8, 0x8450, 0x8460, 0x8440, 0x8400, 0xB400, 0xCC00 },
{ 0x0000, 0x0000, 0x0020, 0x0030, 0x0DF8, 0x1BFC, 0x3BFC, 0x7BF8,
0x7830, 0x7820, 0x7800, 0x7800, 0x7800, 0x4800, 0x0000 } },
#define TBAR_HOME 2
{ 41, G_BLACK, G_WHITE,
{ 0x0100, 0x3280, 0x3540, 0x3AA0, 0x3550, 0x2AA8, 0x5554, 0xC006,
0x5EF4, 0x5294, 0x5294, 0x5EB4, 0x4094, 0x4094, 0x7FFC },
{ 0x0000, 0x0100, 0x0280, 0x0540, 0x0AA0, 0x1550, 0x2AA8, 0x3FF8,
0x2108, 0x2D68, 0x2D68, 0x2148, 0x3F68, 0x3F68, 0x0000 } },
#define TBAR_REDO 3
{ 72, G_BLACK, G_YELLOW,
{ 0x03E0, 0x0C10, 0x1F08, 0x2084, 0x0044, 0x10C6, 0x2882, 0x4444,
0x8228, 0xC610, 0x4400, 0x4208, 0x21F0, 0x1060, 0x0F80 },
{ 0x0000, 0x03E0, 0x00F0, 0x0078, 0x0038, 0x0038, 0x107C, 0x3838,
0x7C10, 0x3800, 0x3800, 0x3C00, 0x1E00, 0x0F80, 0x0000 } },
#define TBAR_OPEN 4
{ 93, G_BLACK, G_CYAN,
{ 0x0780, 0x1fe8, 0x3078, 0x4038, 0x0078, 0x3800, 0x47c0, 0x8020,
0x8ffe, 0x9002, 0x9004, 0xa004, 0xa008, 0xc008, 0xfff0 },
{ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3800, 0x7fc0,
0x7000, 0x6ffc, 0x6ff8, 0x5ff8, 0x5ff0, 0x3ff0, 0x0000 } },
#define TBAR_STOP 5
{114, G_WHITE, G_RED,
{ 0x0FE0, 0x1010, 0x2008, 0x4004, 0x975A, 0xA2DA, 0xA2DA, 0x92DA,
0x8AD2, 0x8AD2, 0xB292, 0x4004, 0x2008, 0x1010, 0x0FE0 },
{ 0x0000, 0x0FE0, 0x1FF0, 0x3FF8, 0x68A4, 0x5D24, 0x5D24, 0x6D24,
0x752D, 0x752D, 0x4D6C, 0x3FF8, 0x1FF0, 0x0FE0, 0x0000 } },
#define TBAR_EDIT 6
#define TBAR_HIST 7
/* {150, G_BLACK, G_GREEN,
{ 0x0000, 0x7FFC, 0x4004, 0x2008, 0x2008, 0x1010, 0x1010, 0x0820,
0x0820, 0x0440, 0x0440, 0x0280, 0x0280, 0x0100, 0x0100 },
{ 0x0000, 0x0000, 0x3FF8, 0x1FF0, 0x1FF0, 0x0FE0, 0x0FE0, 0x07C0,
0x07C0, 0x0380, 0x0380, 0x0100, 0x0100, 0x0000, 0x0000 } }
*/
/* {150, G_LBLACK, G_WHITE,
{ 0x0000, 0x7FFC, 0x4004, 0x2008, 0x2008, 0x1010, 0x1010, 0x0820,
0x0820, 0x0440, 0x0440, 0x0280, 0x0280, 0x0100, 0x0100 },
{ 0x0000, 0x0001, 0x0004, 0x0008, 0x0008, 0x0010, 0x0010, 0x0020,
0x0020, 0x0040, 0x0040, 0x0080, 0x0080, 0x0100, 0x0100 } }
*/
{150, G_LBLACK, G_WHITE,
{ 0x0000, 0x7FFC, 0x4004, 0x27C8, 0x2448, 0x1290, 0x1290, 0x0920,
0x0920, 0x0440, 0x0440, 0x0280, 0x0280, 0x0100, 0x0100 },
{ 0x0000, 0x0001, 0x0004, 0x07C8, 0x0408, 0x0210, 0x0210, 0x0120,
0x0120, 0x0040, 0x0040, 0x0080, 0x0080, 0x0100, 0x0100 } }
};
#define TBAR_LEFT_MASK (1 << TBAR_LEFT)
#define TBAR_RGHT_MASK (1 << TBAR_RGHT)
#define TBAR_HOME_MASK (1 << TBAR_HOME)
#define TBAR_REDO_MASK (1 << TBAR_REDO)
#define TBAR_OPEN_MASK (1 << TBAR_OPEN)
#define TBAR_STOP_MASK (1 << TBAR_STOP)
#define TBAR_HIST_MASK (1 << TBAR_HIST)
typedef struct {
WORD Visible;
WORD Shift;
WORD Cursor;
WORD Length;
char Text[1024];
} TBAREDIT;
#define TbarEdit(w) ((TBAREDIT*)(w->History + HISTORY_LAST +2))
/*----------------------------------------------------------------------------*/
static BOOL
wgeo_read (char * buff, GRECT * rect)
{
BOOL ret = FALSE;
char * str = buff;
if (*str != '+') {
WORD w = (WORD)strtol (str, &str, 16);
if (*str == 'x' && str > buff) {
WORD h = (WORD)strtol (++str, &str, 16);
if (str > buff) {
rect->g_w = w;
rect->g_h = h;
buff = str;
ret = TRUE;
}
}
}
if (*str == '+') {
WORD x = (WORD)strtol (++str, &str, 16);
if (*str == '+' && str > buff +1) {
WORD y = (WORD)strtol (++str, &str, 16);
if (str > buff +2) {
rect->g_x = x;
rect->g_y = y;
buff = str;
ret = TRUE;
}
}
}
return ret;
}
/*----------------------------------------------------------------------------*/
static UWORD
wgeo_calc (GRECT * rect, GRECT * curr)
{
UWORD mask = 0x0000u;
if (rect->g_w > 0 && rect->g_h > 0) {
WORD w = (WORD)(((long)rect->g_w * desk_area.g_w) / 0x7FFFu);
WORD h = (WORD)(((long)rect->g_h * desk_area.g_h) / 0x7FFFu);
if ((curr->g_w = max (w, inc_xy *7)) > desk_area.g_w) {
curr->g_w = desk_area.g_w;
}
if ((curr->g_h = max (h, inc_xy *6)) > desk_area.g_h) {
curr->g_h = desk_area.g_h;
}
mask |= GEO_CFG_WH;
if (curr->g_w != w || curr->g_h != h) {
mask |= GEO_USR_WH;
}
}
if (rect->g_x >= 0 && rect->g_y >= 0) {
curr->g_x = (WORD)(((long)rect->g_x * (desk_area.g_w - desk_area.g_x))
/ 0x7FFFu + desk_area.g_x);
curr->g_y = (WORD)(((long)rect->g_y * (desk_area.g_h - desk_area.g_y))
/ 0x7FFFu + desk_area.g_y);
mask |= GEO_CFG_XY;
if (curr->g_x + curr->g_w > desk_area.g_x + desk_area.g_w) {
curr->g_x = desk_area.g_x + desk_area.g_w - curr->g_w;
if (curr->g_x < desk_area.g_x) curr->g_x = desk_area.g_x;
mask |= GEO_USR_XY;
}
if (curr->g_y + curr->g_h > desk_area.g_y + desk_area.g_h) {
curr->g_y = desk_area.g_y + desk_area.g_h - curr->g_h;
if (curr->g_y < desk_area.g_y) curr->g_y = desk_area.g_y;
mask |= GEO_USR_XY;
}
}
*rect = *curr;
return mask;
}
/*----------------------------------------------------------------------------*/
static BOOL
wgeo_write (const GRECT * rect, UWORD mask, char * buff)
{
char * p = buff;
if ((mask & GEO_USR_WH) || ((mask & GEO_CFG_WH) && (mask & GEO_USR_XY))) {
WORD w = (WORD)(((long)rect->g_w * 0x7FFF) / desk_area.g_w);
WORD h = (WORD)(((long)rect->g_h * 0x7FFF) / desk_area.g_h);
sprintf (p, "%04hXx%04hX", w, h);
p = strchr (p, '\0');
}
if ((mask & GEO_USR_XY) || ((mask & GEO_CFG_XY) && (mask & GEO_USR_WH))) {
WORD x = (WORD)(((long)(rect->g_x - desk_area.g_x) * 0x7FFF)
/ (desk_area.g_w - desk_area.g_x));
WORD y = (WORD)(((long)(rect->g_y - desk_area.g_y) * 0x7FFF)
/ (desk_area.g_h - desk_area.g_y));
sprintf (p, "+%04hX+%04hX", x, y);
p = strchr (p, '\0');
}
return (p > buff);
}
/*============================================================================*/
void
hwWind_setup (HWWIND_SET set, long arg)
{
switch (set) {
case HWWS_INFOBAR:
if (arg & 1) wind_kind |= INFO;
else wind_kind &= ~INFO;
if (arg & 4) {
wind_kind &= ~(SIZER|LFARROW|HSLIDE);
} else {
wind_kind |= SIZER;
if (arg & 2) wind_kind |= LFARROW;
else wind_kind &= ~LFARROW;
}
break;
case HWWS_TOOLBAR:
if (arg > 0) tbar_set = +21;
else if (arg < 0) tbar_set = -21;
else tbar_set = 0;
break;
case HWWS_GEOMETRY:
wgeo_read ((char*)arg, &brws_curr);
break;
case HWWS_BOOKMGEO:
wgeo_read ((char*)arg, &bmrk_curr);
break;
}
}
/*============================================================================*/
void
hwWind_store (HWWIND_SET set)
{
switch (set) {
case HWWS_INFOBAR:
case HWWS_TOOLBAR:
break; /* not in use yet */
case HWWS_GEOMETRY: {
char buff[30];
if (wgeo_write (&brws_curr, brws_gmsk, buff)) {
save_config ("BRWSR_GEO", buff);
}
} break;
case HWWS_BOOKMGEO: {
char buff[30];
if (wgeo_write (&bmrk_curr, bmrk_gmsk, buff)) {
save_config ("BOOKM_GEO", buff);
}
} break;
}
}
/*============================================================================*/
HwWIND
new_hwWind (const char * name, const char * url, BOOL topNbot)
{
HwWIND This = malloc (sizeof (struct hw_window) +
sizeof (HISTORY) * HISTORY_LAST +
sizeof (TBAREDIT) +1);
TBAREDIT * edit;
short i;
GRECT curr;
ULONG ident = (url && url == bkm_File ? WIDENT_BMRK : WIDENT_BRWS);
/* special case for bookmark window */
if (!inc_xy) {
wind_get_grect (DESKTOP_HANDLE, WF_WORKXYWH, &desk_area);
wind_calc_grect (WC_BORDER, VSLIDE|HSLIDE, &desk_area, &curr);
widget_b = desk_area.g_x - curr.g_x;
widget_w = curr.g_w - desk_area.g_w;
widget_h = curr.g_h - desk_area.g_h;
inc_xy = max (widget_w, widget_h) - widget_b;
if (desk_area.g_w < 800) {
curr = desk_area;
curr.g_w = (desk_area.g_w *2) /3;
} else {
curr.g_x = desk_area.g_x + inc_xy;
curr.g_y = desk_area.g_y + inc_xy;
curr.g_w = (desk_area.g_w *3) /4;
curr.g_h = (desk_area.g_h *3) /4;
}
brws_gmsk = wgeo_calc (&brws_curr, &curr);
if (!ignore_colours) {
#if 0 /* this doesn't work with MagiC yet */
u = W_HELEV;
out = 0;
if (wind_get (0, WF_DCOLOR, &u, &out, &u, &u) && out) {
info_bgnd = out | 0x00F0;
if ((info_bgnd & 0x000F) == G_BLACK) {
info_fgnd = G_WHITE;
}
} else {
info_bgnd = G_LWHITE;
}
#else
info_bgnd = G_LWHITE;
#endif
}
} else if (ident == WIDENT_BMRK) {
static BOOL __once = TRUE;
if (__once) {
__once = FALSE;
curr.g_h = desk_area.g_h;
curr.g_y = desk_area.g_y;
curr.g_w = max (curr.g_h /2, 200);
curr.g_x = desk_area.g_x + desk_area.g_w - curr.g_w;
bmrk_gmsk = wgeo_calc (&bmrk_curr, &curr);
} else {
curr = bmrk_curr;
}
} else {
brws_curr.g_x += inc_xy;
if (brws_curr.g_x + brws_curr.g_w > desk_area.g_x + desk_area.g_w) {
brws_curr.g_x = desk_area.g_x;
}
brws_curr.g_y += inc_xy;
if (brws_curr.g_y + brws_curr.g_h > desk_area.g_y + desk_area.g_h) {
brws_curr.g_y = desk_area.g_y;
}
curr = brws_curr;
}
window_ctor (This, wind_kind, ident,
(name && *name ? name : url), NULL, FALSE);
This->Base.destruct = vTab_destruct;
This->Base.evMessage = vTab_evMessage;
This->Base.evButton = vTab_evButton;
This->Base.evKeybrd = vTab_evKeybrd;
This->Base.drawWork = vTab_drawWork;
This->Base.drawIcon = vTab_drawIcon;
This->Base.close = vTab_close;
This->Base.raised = vTab_raised;
This->Base.moved = vTab_moved;
This->Base.sized = vTab_sized;
This->Base.iconified = vTab_iconified;
This->shaded = FALSE;
This->isBusy = 0;
This->isDone = 0;
This->loading = 0;
This->Location = NULL;
This->Pane = new_containr (NULL);
This->Active = NULL;
This->Input = NULL;
containr_register (This->Pane, wnd_hdlr, (long)This);
This->HistUsed = 0;
This->HistMenu = 0;
for (i = 0; i <= HISTORY_LAST; This->History[i++] = NULL);
This->Stat[0] = '\0';
This->Info[0] = '\0';
if (wind_kind & (HSLIDE|LFARROW|SIZER)) {
if (wind_kind & HSLIDE) {
wind_set (This->Base.Handle, WF_HSLIDE, 0, 0,0,0);
wind_set (This->Base.Handle, WF_HSLSIZE, -1, 0,0,0);
}
This->IbarH = 0;
} else {
This->IbarH = widget_h - widget_b -1;
}
This->TbarH = (tbar_set > 0 && ident == WIDENT_BRWS ? tbar_set : 0);
This->TbarMask = (url_hist ? TBAR_HIST_MASK : 0) | TBAR_OPEN_MASK;
This->TbarActv = (This->TbarH && !url ? TBAR_EDIT : -1);
for (i = 0; i < numberof(hw_buttons)-1; i++) {
This->TbarElem[i].Offset = hw_buttons[i].Offset;
This->TbarElem[i].Width = 21;
}
This->TbarElem[TBAR_EDIT].Offset = This->TbarElem[TBAR_EDIT -1].Offset
+ This->TbarElem[TBAR_EDIT -1].Width *3 /2;
This->TbarElem[TBAR_HIST].Width = 21;
edit = TbarEdit (This);
edit->Text[0] = '\0';
edit->Length = 0;
edit->Shift = 0;
edit->Cursor = 0;
window_setBevent (&This->Base);
if (info_bgnd & 0x0080) {
wind_set(This->Base.Handle, WF_COLOR, W_HBAR, info_bgnd, info_bgnd, -1);
wind_set(This->Base.Handle, WF_COLOR, W_HSLIDE, info_bgnd, info_bgnd, -1);
}
This->Work.g_w = This->Work.g_h = 0; /* mark for inital resize */
window_raise (&This->Base, topNbot, &curr);
hwWind_redraw (This, NULL);
if (url && *url) {
start_page_load (This->Pane, url, NULL, TRUE, NULL);
}
#ifdef GEM_MENU
menu_history (NULL,0,0);
#endif
if (cfg_AVWindow) {
send_avwinopen(This->Base.Handle);
}
return This;
}
/*============================================================================*/
static WINDOW
vTab_destruct (HwWIND This)
{
short i;
if (hwWind_Focus == This) {
hwWind_Focus = NULL;
}
#ifdef GEM_MENU
if (This == hwWind_Top) {
HwWIND next = hwWind_Next (This);
if (next) {
menu_history (next->History, next->HistUsed, next->HistMenu);
} else {
menu_history (NULL,0,0);
}
}
#endif
for (i = 0; i < This->HistUsed; history_destroy (&This->History[i++]));
free_location (&This->Location);
delete_containr ((CONTAINR*)&This->Pane);
return window_dtor(This);
}
/*----------------------------------------------------------------------------*/
static void
draw_busybar (HwWIND This, const GRECT * area, const GRECT * clip)
{
GRECT rect;
PXY p[3];
WORD width = area->g_w -4 - This->IbarH;
p[2].p_x = 128 +2;
p[2].p_y = area->g_h -4;
p[1].p_x = area->g_x +2 + width - (p[2].p_x -1);
p[1].p_y = area->g_y +2;
rect = *(GRECT*)(p +1);
if (rc_intersect (clip, &rect)) {
p[0].p_x = p[1].p_x;
p[0].p_y = p[1].p_y + p[2].p_y -2;
p[2].p_x = p[1].p_x + p[2].p_x -2;
p[2].p_y = p[1].p_y;
vsl_color (vdi_handle, G_LBLACK);
v_pline (vdi_handle, 3, &p[0].p_x);
p[1].p_x = ++p[2].p_x; p[0].p_x++;
p[1].p_y = ++p[0].p_y; p[2].p_y++;
vsl_color (vdi_handle, G_WHITE);
v_pline (vdi_handle, 3, &p[0].p_x);
if (This->isBusy > 1) {
width = ((This->isDone +1) *128) / This->isBusy;
if (width >128) width = 128;
else if (width < 1) width = 1;
p[1].p_x--;
p[1].p_y--;
p[0].p_x = p[1].p_x - width +1;
p[0].p_y = p[2].p_y;
vsf_color (vdi_handle, G_BLUE);
v_bar (vdi_handle, &p[0].p_x);
}
}
}
/*----------------------------------------------------------------------------*/
static void
draw_infobar (HwWIND This, const GRECT * p_clip, const char * info)
{
GRECT area, clip, rect;
WORD x_btn, dmy, fnt, pnt;
if (This->Base.isIcon || This->shaded) return;
area = This->Work;
area.g_y += area.g_h - This->IbarH +1;
area.g_h = This->IbarH -1;
clip = area;
x_btn = area.g_x + area.g_w - This->IbarH;
if (p_clip) {
clip.g_y--;
clip.g_h++;
if (clip.g_y >= p_clip->g_y + p_clip->g_h) {
return;
}
rect = *p_clip;
} else {
clip.g_w -= This->IbarH +1;
if (!rc_intersect (&desk_area, &clip)) {
return;
}
wind_update (BEG_UPDATE);
wind_get_grect (This->Base.Handle, WF_FIRSTXYWH, &rect);
}
vsf_interior (vdi_handle, FIS_SOLID);
vsf_color (vdi_handle, info_bgnd & 0x000F);
fnt = (inc_xy < 16 ? 1 : fonts[header_font][0][0]);
if ((fnt = vst_font (vdi_handle, fnt)) == 1) {
pnt = (inc_xy < 16 ? 11 : 12);
vst_point (vdi_handle, pnt, &dmy,&dmy,&dmy,&dmy);
} else {
pnt = 14;
vst_height (vdi_handle, pnt, &dmy,&dmy,&dmy,&dmy);
}
vst_color (vdi_handle, info_fgnd);
vst_map_mode (vdi_handle, MAP_UNICODE);
vst_effects (vdi_handle, TXT_NORMAL);
v_hide_c (vdi_handle);
while (rect.g_w > 0 && rect.g_h > 0) {
if (rc_intersect (&clip, &rect)) {
PXY p[2];
p[1].p_x = (p[0].p_x = rect.g_x) + rect.g_w -1;
p[1].p_y = (p[0].p_y = rect.g_y) + rect.g_h -1;
v_bar (vdi_handle, &p[0].p_x);
if (This->isBusy) {
vs_clip_pxy (vdi_handle, p);
draw_busybar (This, &area, &rect);
vsf_color (vdi_handle, info_bgnd & 0x000F);
}
if (*info && p[0].p_x < x_btn) {
short rgt = p[1].p_x;
if (p[1].p_x >= x_btn){
p[1].p_x = x_btn -1;
}
vs_clip_pxy (vdi_handle, p);
vst_alignment (vdi_handle, TA_LEFT, TA_TOP, &dmy, &dmy);
v_ftext (vdi_handle, area.g_x +1, area.g_y -1, info);
if (!p_clip) {
vs_clip_off (vdi_handle);
}
p[1].p_x = rgt;
}
if (p_clip) {
vs_clip_pxy (vdi_handle, p);
vsl_color (vdi_handle, info_fgnd & 0x000F);
if (p[0].p_y < area.g_y) {
PXY l[2];
l[1].p_x = (l[0].p_x = area.g_x) + area.g_w -1;
l[1].p_y = l[0].p_y = area.g_y -1;
v_pline (vdi_handle, 2, &l[0].p_x);
}
if (p[1].p_x >= x_btn) {
p[0].p_x = p[1].p_x = x_btn;
v_pline (vdi_handle, 2, &p[0].p_x);
p[0].p_x++;
p[0].p_y = area.g_y;
p[1].p_x = p[1].p_y = This->IbarH -1;
draw_border ((GRECT*)p, G_WHITE, G_LBLACK, 1);
if (fnt != 1) {
vst_font (vdi_handle, 1);
vst_point (vdi_handle, (inc_xy < 16 ? 11 : 12),
&dmy,&dmy,&dmy,&dmy);
}
vst_alignment (vdi_handle, TA_CENTER, TA_TOP, &dmy, &dmy);
v_gtext (vdi_handle,
p[0].p_x + This->IbarH /2, p[0].p_y +1, "\006");
}
vs_clip_off (vdi_handle);
break;
}
}
wind_get_grect (This->Base.Handle, WF_NEXTXYWH, &rect);
}
v_show_c (vdi_handle, 1);
vst_alignment (vdi_handle, TA_LEFT, TA_BASE, &dmy, &dmy);
if (!p_clip) {
wind_update (END_UPDATE);
}
}
/*------------------------------------------------------------------------------
* Set Horizontal scroller space text - only works on top windows
*/
static void
hwWind_setHSInfo (HwWIND This, const char * info)
{
WORD dmy;
PXY p[2], clip[2];
if (This != hwWind_Top || This->Base.isIcon || This->shaded) {
return;
} else {
WORD top;
wind_get (0, WF_TOP, &top, &dmy, &dmy, &dmy);
if (top != This->Base.Handle) {
return;
}
}
p[0].p_y = This->Work.g_y + This->Work.g_h +1;
p[1].p_y = This->Curr.g_y + This->Curr.g_h - widget_b -1;
p[0].p_x = This->Curr.g_x + widget_w - widget_b +1;
p[1].p_x = This->Curr.g_x + This->Curr.g_w - widget_w + widget_b -2;
clip[0].p_x = max (p[0].p_x, desk_area.g_x);
clip[0].p_y = max (p[0].p_y, desk_area.g_y);
clip[1].p_x = min (p[1].p_x, desk_area.g_x + desk_area.g_w -1);
clip[1].p_y = min (p[1].p_y, desk_area.g_y + desk_area.g_h -1);
if (clip[0].p_x > clip[1].p_x || clip[0].p_y > clip[1].p_y) {
return;
}
vs_clip_pxy (vdi_handle, clip);
vswr_mode (vdi_handle, MD_REPLACE);
vsf_interior (vdi_handle, FIS_SOLID);
vsf_style (vdi_handle, 4);
vsf_color (vdi_handle, info_bgnd & 0x000F);
dmy = (inc_xy < 16 ? 1 : fonts[header_font][0][0]);
if (vst_font (vdi_handle, dmy) == 1) {
vst_point (vdi_handle, (inc_xy < 16 ? 11 : 12), &dmy, &dmy, &dmy, &dmy);
} else {
vst_height (vdi_handle, 14, &dmy, &dmy, &dmy, &dmy);
}
vst_color (vdi_handle, info_fgnd);
vst_map_mode (vdi_handle, MAP_UNICODE);
vst_effects (vdi_handle, TXT_NORMAL);
vst_alignment (vdi_handle, TA_LEFT, TA_DESCENT, &dmy, &dmy);
v_hide_c (vdi_handle);
v_bar (vdi_handle, &p[0].p_x);
vswr_mode (vdi_handle, MD_TRANS);
if (This->isBusy) {
GRECT area;
area.g_x = p[0].p_x;
area.g_y = p[0].p_y;
area.g_w = p[1].p_x - area.g_x + 1;
area.g_h = p[1].p_y - area.g_y + 1;
clip[1].p_x -= clip[0].p_x -1;
clip[1].p_y -= clip[0].p_y -1;
draw_busybar (This, &area, (GRECT*)clip);
}
v_ftext (vdi_handle, p[0].p_x +1, p[1].p_y -1, info);
v_show_c (vdi_handle, 1);
vst_alignment (vdi_handle, TA_LEFT, TA_BASE, &dmy, &dmy);
vs_clip_off (vdi_handle);
}
/*============================================================================*/
void
hwWind_setInfo (HwWIND This, const char * info, BOOL statNinfo)
{
if (statNinfo) {
if (info && *info) {
strncpy (This->Stat, info, sizeof(This->Stat));
This->Stat[sizeof(This->Stat)-1] = '\0';
info = This->Stat;
} else if (This->Stat[0]) {
This->Stat[0] = '\0';
info = This->Info;
} else {
info = (This->Info[0] ? This->Info : NULL);
}
} else {
if (info && *info) {
strncpy (This->Info, info, sizeof(This->Info));
This->Info[sizeof(This->Info)-1] = '\0';
info = This->Info;
} else if (This->Info[0]) {
This->Info[0] = '\0';
info = This->Stat;
} else {
info = (This->Stat[0] ? This->Stat : NULL);
}
}
if (info && !(This->Base.isScrn && This->Base.isFull)) {
if (wind_kind & INFO) {
wind_set_str (This->Base.Handle, WF_INFO, info);
}
if (wind_kind & (LFARROW|HSLIDE)) {
hwWind_setHSInfo(This, info);
} else if (This->IbarH) {
draw_infobar (This, NULL, info);
}
}
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
static void
vTab_raised (HwWIND This, BOOL topNbot)
{
HwWIND new_top = hwWind_Top;
WORD mx, my, u;
if (topNbot && !This->Base.isScrn && (wind_kind & (LFARROW|HSLIDE))) {
hwWind_setHSInfo (This, (This->Info[0] ? This->Info : This->Stat));
}
graf_mkstate (&mx, &my, &u,&u);
check_mouse_position (mx, my);
#ifdef GEM_MENU
if (new_top) {
menu_history (new_top->History, new_top->HistUsed, new_top->HistMenu);
}
#endif
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
static void
vTab_moved (HwWIND This)
{
wind_get_grect (This->Base.Handle, WF_WORKXYWH, &This->Work);
containr_relocate (This->Pane, This->Work.g_x, This->Work.g_y + This->TbarH);
if (This->Base.Ident == WIDENT_BRWS) {
brws_curr.g_x = This->Curr.g_x;
brws_curr.g_y = This->Curr.g_y;
brws_gmsk |= GEO_USR_XY;
} else { /* WIDENT_BMRK */
bmrk_curr.g_x = This->Curr.g_x;
bmrk_curr.g_y = This->Curr.g_y;
bmrk_gmsk |= GEO_USR_XY;
}
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
static BOOL
vTab_sized (HwWIND This)
{
TBAREDIT * edit = TbarEdit (This);
GRECT work;
if (This->Base.isScrn) {
if (This->Base.isFull) { /* set to mode */
This->IbarH = 0;
} else { /* back to normal mode */
char * info = (This->Info[0] ? This->Info : This->Stat);
if (wind_kind & INFO) {
wind_set_str (This->Base.Handle, WF_INFO, info);
}
if (wind_kind & (LFARROW|HSLIDE)) {
hwWind_setHSInfo(This, info);
} else {
This->IbarH = widget_h - widget_b -1;
}
wind_set_str (This->Base.Handle, WF_NAME, This->Base.Name);
window_setBevent (&This->Base);
}
} else if (!This->Base.isFull) {
BOOL mask = (This->Work.g_w > 0 && This->Work.g_h > 0 ? GEO_USR_WH : 0);
if (This->Base.Ident == WIDENT_BRWS) {
brws_curr.g_w = This->Curr.g_w;
brws_curr.g_h = This->Curr.g_h;
brws_gmsk |= mask;
} else if (This->Base.Ident == WIDENT_BMRK) {
bmrk_curr.g_w = This->Curr.g_w;
bmrk_curr.g_h = This->Curr.g_h;
bmrk_gmsk |= mask;
}
}
wind_get_grect (This->Base.Handle, WF_WORKXYWH, &This->Work);
work = This->Work;
work.g_y += This->TbarH;
work.g_h -= This->TbarH + This->IbarH;
containr_calculate (This->Pane, &work);
work.g_w -= This->TbarElem[TBAR_EDIT].Offset +6
+ This->TbarElem[TBAR_HIST].Width;
if ((edit->Visible = work.g_w /8) < 7) {
edit->Visible = 7;
}
This->TbarElem[TBAR_EDIT].Width = edit->Visible *8 +6;
This->TbarElem[TBAR_HIST].Offset = This->TbarElem[TBAR_EDIT].Offset
+ This->TbarElem[TBAR_EDIT].Width -1;
if (edit->Length <= edit->Visible) {
edit->Shift = 0;
} else if (edit->Shift > edit->Length - edit->Visible) {
edit->Shift = edit->Length - edit->Visible;
} else if (edit->Shift < edit->Cursor - edit->Visible) {
edit->Shift = edit->Cursor - edit->Visible;
}
return TRUE;
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
static void
vTab_iconified (HwWIND This)
{
WORD mx, my, u;
if (This->Base.isIcon) {
if (This->TbarActv == TBAR_EDIT) {
TBAREDIT * edit = TbarEdit (This);
edit->Cursor = 0;
edit->Shift = 0;
chng_toolbar (This, 0, 0, -1);
}
} else {
if (wind_kind & (LFARROW|HSLIDE)) {
hwWind_setHSInfo (This, (This->Info[0] ? This->Info : This->Stat));
}
}
graf_mkstate (&mx, &my, &u,&u);
check_mouse_position (mx, my);
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
static BOOL
vTab_close (HwWIND This, UWORD state)
{
if (!(state & K_ALT) || This->Base.Ident != WIDENT_BRWS) {
return TRUE; /* to be deleted */
} else if (tbar_set) {
GRECT work = This->Work;
TBAREDIT * edit = TbarEdit (This);
edit->Text[0] = '\0';
edit->Length = 0;
edit->Shift = 0;
edit->Cursor = 0;
This->TbarActv = -1;
if (This->TbarH) {
if (tbar_set > 0) tbar_set = -tbar_set;
This->TbarH = 0;
} else {
if (tbar_set < 0) tbar_set = -tbar_set;
This->TbarH = tbar_set;
}
work.g_y += This->TbarH;
work.g_h -= This->TbarH + This->IbarH;
containr_calculate (This->Pane, &work);
work.g_y -= This->TbarH;
work.g_h += This->TbarH;
hwWind_redraw (This, &work);
}
return FALSE;
}
/*============================================================================*/
void
hwWind_scroll (HwWIND This, CONTAINR cont, long dx, long dy)
{
GRECT work = This->Work;
if (cont->Base != This->Pane) {
printf ("hwWind_scroll() ERROR: container not in window!\n");
return;
}
if (containr_shift (cont, &dx, &dy)
&& rc_intersect (&desk_area, &work)
&& rc_intersect (&cont->Area, &work)) {
GRECT clip;
wind_update (BEG_UPDATE);
wind_get_grect (This->Base.Handle, WF_FIRSTXYWH, &clip);
while (clip.g_w > 0 && clip.g_h > 0) {
if (rc_intersect (&work, &clip)) {
containr_scroll (cont, &clip, dx, dy);
}
wind_get_grect (This->Base.Handle, WF_NEXTXYWH, &clip);
}
wind_update (END_UPDATE);
}
}
/*----------------------------------------------------------------------------*/
static void
hist_append (HwWIND This, CONTAINR sub)
{
WORD prev = This->HistMenu;
WORD menu = prev +1;
if (!This->HistUsed) {
prev = -1;
menu = 0;
} else if (menu < This->HistUsed) {
do {
history_destroy (&This->History[--This->HistUsed]);
} while (menu < This->HistUsed);
if (prev > menu) {
prev = -1;
}
} else if (menu > HISTORY_LAST) {
short i;
history_destroy (&This->History[0]);
for (i = 0; i < HISTORY_LAST; i++) {
This->History[i] = This->History[i +1];
}
menu = This->HistUsed = HISTORY_LAST;
prev--;
}
if (sub) {
This->History[menu] = history_create (sub, This->Stat,
(prev < 0 ? NULL : This->History[prev]));
} else {
This->History[menu] = history_create (This->Pane, This->Base.Name, NULL);
}
if (prev >= 0) {
This->History[prev]->Text[0] = ' ';
}