forked from fkhannouf/BGUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbaseclass.c
More file actions
1895 lines (1705 loc) · 49.4 KB
/
Copy pathbaseclass.c
File metadata and controls
1895 lines (1705 loc) · 49.4 KB
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
/*
* @(#) $Header$
*
* BGUI library
* baseclass.c
*
* (C) Copyright 1998 Manuel Lemos.
* (C) Copyright 1996-1997 Ian J. Einman.
* (C) Copyright 1993-1996 Jaba Development.
* (C) Copyright 1993-1996 Jan van den Baard.
* All Rights Reserved.
*
* $Log$
* Revision 42.9 2004/06/16 20:16:48 verhaegs
* Use METHODPROTO, METHOD_END and REGFUNCPROTOn where needed.
*
* Revision 42.8 2003/01/18 19:09:55 chodorowski
* Instead of using the _AROS or __AROS preprocessor symbols, use __AROS__.
*
* Revision 42.7 2000/08/17 15:09:18 chodorowski
* Fixed compiler warnings.
*
* Revision 42.6 2000/08/10 17:52:47 stegerg
* temp fix for relayout refresh bug which only happens in AROS. temp. solved
* by doing a RefreshGList in windowclass.c/WindowClassRelease method.
*
* Revision 42.5 2000/08/09 11:45:57 chodorowski
* Removed a lot of #ifdefs that disabled the AROS_LIB* macros when not building on AROS. This is now handled in contrib/bgui/include/bgui_compilerspecific.h.
*
* Revision 42.4 2000/07/07 17:07:49 stegerg
* fixed PACKW #define, which must be different on AROS, because
* I changed all methods to use STACKULONG/STACKUWORD/??? types.
*
* Revision 42.3 2000/05/29 00:40:23 bergers
* Update to compile with AROS now. Should also still compile with SASC etc since I only made changes that test the define __AROS__. The compilation is still very noisy but it does the trick for the main directory. Maybe members of the BGUI team should also have a look at the compiler warnings because some could also cause problems on other systems... (Comparison always TRUE due to datatype (or something like that)). And please compile it on an Amiga to see whether it still works... Thanks.
*
* Revision 42.2 2000/05/15 19:27:00 stegerg
* another hundreds of REG() macro replacements in func headers/protos.
*
* Revision 42.1 2000/05/14 23:32:46 stegerg
* changed over 200 function headers which all use register
* parameters (oh boy ...), because the simple REG() macro
* doesn't work with AROS. And there are still hundreds
* of headers left to be fixed :(
*
* Many of these functions would also work with stack
* params, but since i have fixed every single one
* I encountered up to now, I guess will have to do
* the same for the rest.
*
* Revision 42.0 2000/05/09 22:08:19 mlemos
* Bumped to revision 42.0 before handing BGUI to AROS team
*
* Revision 41.11 2000/05/09 19:53:49 mlemos
* Merged with the branch Manuel_Lemos_fixes.
*
* Revision 41.10.2.15 1999/08/30 00:46:12 mlemos
* Fixed rendering a object in BASE_RELAYOUT when the minimum dimensions did
* not change.
*
* Revision 41.10.2.14 1999/08/30 00:20:01 mlemos
* Assured that the object is not rendered in BASE_RELAYOUT if it is inhibited.
*
* Revision 41.10.2.13 1999/08/29 20:21:55 mlemos
* Renamed the GRM_RELAYOUT to BASE_RELAYOUT.
*
* Revision 41.10.2.12 1999/08/01 04:15:28 mlemos
* Avoided trying to copy invisible rendered portions of an object in a view.
*
* Revision 41.10.2.11 1999/07/26 22:17:33 mlemos
* Re-enabled drag token conversion into a window while stopped.
*
* Revision 41.10.2.10 1999/07/03 15:17:31 mlemos
* Replaced the calls to CallHookPkt to BGUI_CallHookPkt.
*
* Revision 41.10.2.9 1998/12/08 03:28:20 mlemos
* Ensured that whenever the gadget border activation flags are changed the
* the IMAGE_Border attribute of the frame and the label will reflect the
* current gadget position.
* Corrected the choice of background color for erasing the area of a gadget
* in the border without any parents with frames.
*
* Revision 41.10.2.8 1998/12/07 14:46:15 mlemos
* Ensured that any previously opened font is closed when setting BT_TextAttr.
*
* Revision 41.10.2.7 1998/12/07 03:36:59 mlemos
* Fixed potential text font leak.
*
* Revision 41.10.2.6 1998/12/07 03:06:54 mlemos
* Replaced OpenFont and CloseFont calls by the respective BGUI debug macros.
*
* Revision 41.10.2.5 1998/11/13 16:44:18 mlemos
* Fixed missing Rastport assignment in GM_RENDER that was preventing view
* class to work.
*
* Revision 41.10.2.4 1998/07/05 19:34:11 mlemos
* Made calls to AllocBaseInfo in BaseClassDragActive and BaseClassDragUpdate
* ensure that the rastport is properly obtained.
*
* Revision 41.10.2.3 1998/03/01 17:26:15 mlemos
* Fixed BaseInfo memory leak.
*
* Revision 41.10.2.2 1998/03/01 15:36:46 mlemos
* Removed tracing debugging statements.
*
* Revision 41.10.2.1 1998/03/01 15:33:31 mlemos
* Added support to track BaseInfo memory leaks.
*
* Revision 41.10 1998/02/25 21:11:33 mlemos
* Bumping to 41.10
*
* Revision 1.1 1998/02/25 17:07:27 mlemos
* Ian sources
*
*
*/
#define WW(x)
/* Get the prototype for kprintf() */
#ifdef __AROS__
#include <clib/arossupport_protos.h>
#else
#include <clib/debug_protos.h>
#endif
/// Class definitions.
#include "include/classdefs.h"
#define bd_Flags bd_BC.bc_Flags /* See below. */
#define bd_OuterBox bd_BC.bc_OuterBox /* Domain of object. */
#define bd_InnerBox bd_BC.bc_InnerBox /* Internal area. */
#define bd_HitBox bd_BC.bc_HitBox /* Object hitbox. */
#define bd_Extentions bd_BC.bc_Extensions /* Label extensions. */
#define bd_Frame bd_BC.bc_Frame /* Frame for this object. */
#define bd_Label bd_BC.bc_Label /* Label for this object. */
#define bd_Parent bd_BC.bc_Window /* Parent window object. */
#define bd_View bd_BC.bc_View /* Parent view object. */
#define bd_RPort bd_BC.bc_RPort /* RastPort that is rendered to. */
#define bd_TextAttr bd_BC.bc_TextAttr /* Font to use. */
#define bd_TextFont bd_BC.bc_TextFont /* Font to use (opened). */
#define bd_Group bd_BC.bc_Group
#define bd_Window bd_BC.bc_Window
#define bd_Member bd_BC.bc_GroupNode /* Associated group member data. */
/*
* Object instance data.
*/
typedef struct bd_ {
BC bd_BC; /* Shared data. */
struct Hook *bd_HelpHook; /* Hook for help function. */
UBYTE *bd_HelpFile; /* File name for help. */
UBYTE *bd_HelpNode; /* Node name for AmigaGuide file. */
ULONG bd_HelpLine; /* Line number in help file. */
UBYTE *bd_HelpText; /* Text for requester help. */
LONG bd_HelpTextID; /* Text for requester help. */
UBYTE *bd_ToolTip; /* ToolTip text. */
LONG bd_ToolTipID; /* ToolTip text ID. */
struct RastPort *bd_PreBuffer; /* Render beforehand for later use. */
BMO *bd_BMO; /* Drag bitmap information. */
UWORD bd_Thresh; /* Drag Threshold. */
UWORD bd_DragQual; /* Drag qualifier. */
struct Window *bd_DragWindow; /* Window of drag bitmap. */
UWORD bd_MouseAct; /* Mouse button activation. */
UWORD bd_Qual; /* Input qualifier. */
UBYTE *bd_Key, bd_RawKey; /* Key equivalent. */
WORD bd_LeftOffset; /* Left offset. */
WORD bd_RightOffset; /* Right offset. */
WORD bd_TopOffset; /* Top offset. */
WORD bd_BottomOffset; /* Bottom offset. */
} BD;
#define BDF_DRAGGABLE (1 << 0) /* The object can be dragged. */
#define BDF_DROPPABLE (1 << 1) /* The object can be dropped on. */
#define BDF_LABEL_CLICK (1 << 2) /* Count label-clicks as a hit. */
#define BDF_REPORT_ID (1 << 3) /* Report ID if RMB/MMB */
#define BDF_NORECESSED (1 << 4) /* Dont recess frame when selected. */
#define BDF_ISACTIVE (1 << 5) /* Object active? */
#define BDF_MOVING (1 << 6) /* We're moving... */
#define BDF_MOVE_DROPBOX (1 << 10) /* Standard moving dropbox */
#define BDF_BUFFER (1 << 11) /* Buffer this object? */
#define BDF_INHIBITED (1 << 12) /* Located on a invisible page. */
#define BDF_GOT_LABEL_EXT (1 << 13) /* Got label extentions. */
#define BDF_FIXED_FONT (1 << 14) /* Font set during create. */
#define BDF_CACHE_NOTIFY (1 << 15) /* Notify upon window opening. */
///
/// CalcDimensions
makeproto ULONG CalcDimensions(Class *cl, Object *obj, struct bmDimensions *bmd, UWORD mx, UWORD my)
{
ULONG rc;
if ((rc = AsmDoSuperMethodA(cl, obj, (Msg)bmd)))
{
bmd->bmd_Extent->be_Min.Width += mx;
bmd->bmd_Extent->be_Min.Height += my;
bmd->bmd_Extent->be_Nom.Width += mx;
bmd->bmd_Extent->be_Nom.Height += my;
};
return rc;
}
///
#ifdef __AROS__
makearosproto
AROS_LH3(VOID, BGUI_PostRender,
AROS_LHA(Class *, cl, A0),
AROS_LHA(Object *, obj, A2),
AROS_LHA(struct gpRender *, gpr, A1),
struct Library *, BGUIBase, 23, BGUI)
#else
makeproto SAVEDS ASM VOID BGUI_PostRender(REG(a0) Class *cl, REG(a2) Object *obj, REG(a1) struct gpRender *gpr)
#endif
{
AROS_LIBFUNC_INIT
AROS_LIBFUNC_EXIT
}
/// RM_REFRESH
/*
* Refresh after a set.
*/
METHOD(BaseClassRefresh, struct rmRefresh *, rr)
{
ULONG rc = rr->rr_Flags;
if (rc & (RAF_RESIZE|RAF_REDRAW))
{
DoRenderMethod(obj, (struct GadgetInfo *)rr->rr_Context, GREDRAW_REDRAW);
rc &= ~(RAF_RESIZE|RAF_REDRAW);
};
return rc;
}
METHOD_END
///
/// OM_NEW
/*
* Create a shiny new object.
*/
METHOD(BaseClassNew, struct opSet *, ops)
{
BD *bd;
IPTR rc;
struct TagItem *tags = ops->ops_AttrList;
/*
* We let the superclass setup an object
* for us.
*/
if ((rc = NewSuperObject(cl, obj, tags)))
{
/*
* Get the instance data.
*/
bd = INST_DATA(cl, rc);
/*
* Try to create a label
* and a frame.
*/
bd->bd_DragQual = (UWORD)~0;
bd->bd_RawKey = (UBYTE)~0;
bd->bd_Qual = (UWORD)~0;
bd->bd_Thresh = 3;
AsmCoerceMethod(cl, (Object *)rc, RM_SETM, ops->ops_AttrList, RAF_INITIAL);
}
return rc;
}
METHOD_END
///
/// RM_GET
/*
* Get an attribute.
*/
METHOD(BaseClassGet, struct rmAttr *, ra)
{
ULONG rc;
rc = BGUI_GetAttrChart(cl, obj, ra);
return rc;
}
METHOD_END
///
/// RM_GETCUSTOM
/*
* Get custom attributes.
*/
METHOD(BaseClassGetCustom, struct rmAttr *, ra)
{
BD *bd = (BD *)INST_DATA(cl, obj);
ULONG attr = ra->ra_Attr->ti_Tag;
ULONG *store = (ULONG *)ra->ra_Attr->ti_Data;
switch (attr)
{
case BT_ToolTip:
if (bd->bd_Flags & BDF_ISACTIVE)
STORE NULL;
break;
};
return 1;
}
METHOD_END
///
/// RM_GETATTRFLAGS
/*
* Get the flags of an attribute.
*/
METHOD(BaseClassGetAttrFlags, struct rmAttr *, ra)
{
static struct TagItem chart[] =
{
{ BT_LabelClick, CHART_FLAG(bd_, bd_Flags, BDF_LABEL_CLICK), },
{ BT_NoRecessed, CHART_FLAG(bd_, bd_Flags, BDF_NORECESSED), },
{ BT_DragObject, CHART_FLAG(bd_, bd_Flags, BDF_DRAGGABLE), },
{ BT_DropObject, CHART_FLAG(bd_, bd_Flags, BDF_DROPPABLE), },
{ BT_Buffer, CHART_FLAG(bd_, bd_Flags, BDF_BUFFER), },
{ BT_IsActive, CHART_FLAG(bd_, bd_Flags, BDF_ISACTIVE), },
{ BT_ReportID, CHART_FLAG(bd_, bd_Flags, BDF_REPORT_ID), },
{ BT_Inhibit, CHART_FLAG(bd_, bd_Flags, BDF_INHIBITED) | RAF_NOSET, },
{ BT_LabelObject, CHART_ATTR(bd_, bd_Label) | RAF_CUSTOM | RAF_NOSET, },
{ BT_FrameObject, CHART_ATTR(bd_, bd_Frame) | RAF_CUSTOM | RAF_NOSET, },
{ BT_TextAttr, CHART_ATTR(bd_, bd_TextAttr) | RAF_CUSTOM | RAF_NOSET, },
{ BT_TextFont, CHART_ATTR(bd_, bd_TextFont) | RAF_NOSET, },
{ BT_HelpHook, CHART_ATTR(bd_, bd_HelpHook), },
{ BT_HelpFile, CHART_ATTR(bd_, bd_HelpFile), },
{ BT_HelpNode, CHART_ATTR(bd_, bd_HelpNode), },
{ BT_HelpLine, CHART_ATTR(bd_, bd_HelpLine), },
{ BT_HelpText, CHART_ATTR(bd_, bd_HelpText), },
{ BT_HelpTextID, CHART_ATTR(bd_, bd_HelpTextID), },
{ BT_ToolTip, CHART_ATTR(bd_, bd_ToolTip) | RAF_CUSTOM, },
{ BT_ToolTipID, CHART_ATTR(bd_, bd_ToolTipID), },
{ BT_DragThreshold, CHART_ATTR(bd_, bd_Thresh), },
{ BT_DragQualifier, CHART_ATTR(bd_, bd_DragQual), },
{ BT_MouseActivation, CHART_ATTR(bd_, bd_MouseAct), },
{ BT_Key, CHART_ATTR(bd_, bd_Key) | RAF_CUSTOM, },
{ BT_RawKey, CHART_ATTR(bd_, bd_RawKey) | RAF_CUSTOM, },
{ BT_Qualifier, CHART_ATTR(bd_, bd_Qual), },
{ BT_HitBox, CHART_ATTR(bd_, bd_HitBox) | RAF_ADDRESS, },
{ BT_OuterBox, CHART_ATTR(bd_, bd_OuterBox) | RAF_ADDRESS, },
{ BT_InnerBox, CHART_ATTR(bd_, bd_InnerBox) | RAF_ADDRESS, },
{ BT_LeftOffset, CHART_ATTR(bd_, bd_LeftOffset) | RAF_SIGNED, },
{ BT_RightOffset, CHART_ATTR(bd_, bd_RightOffset) | RAF_SIGNED, },
{ BT_TopOffset, CHART_ATTR(bd_, bd_TopOffset) | RAF_SIGNED, },
{ BT_BottomOffset, CHART_ATTR(bd_, bd_BottomOffset) | RAF_SIGNED, },
{ BT_ParentWindow, CHART_ATTR(bd_, bd_Window) | RAF_CUSTOM, },
{ BT_ParentView, CHART_ATTR(bd_, bd_View), },
{ BT_ParentGroup, CHART_ATTR(bd_, bd_Group) | RAF_CUSTOM, },
{ BT_GroupMember, CHART_ATTR(bd_, bd_Member), },
{ GA_ID, RAF_SUPER | RAF_NOUPDATE | RAF_NOP, },
{ TAG_DONE },
};
return GetTagData(ra->ra_Attr->ti_Tag, 0, chart);
}
METHOD_END
///
/// RM_SET
/*
* Set standard attributes.
*/
METHOD(BaseClassSet, struct rmAttr *, ra)
{
BD *bd;
ULONG attr, data, rc;
rc = BGUI_SetAttrChart(cl, obj, ra);
if (!(rc & RAF_UNDERSTOOD))
{
bd = (BD *)INST_DATA(cl, obj);
attr = ra->ra_Attr->ti_Tag;
data = ra->ra_Attr->ti_Data;
if (!bd->bd_Label && LAB_TAG(attr))
{
bd->bd_Label = BGUI_NewObject(BGUI_LABEL_IMAGE, IMAGE_InBorder, GADGET(obj)->Activation & BORDERMASK, TAG_DONE);
rc = RAF_RESIZE;
};
if (bd->bd_Label) rc |= AsmDoMethodA(bd->bd_Label, (Msg)ra);
if (rc & RAF_UNDERSTOOD) return rc;
if (LGO_TAG(attr))
{
rc = RAF_UNDERSTOOD|RAF_RESIZE;
if (bd->bd_Member) DoSetMethodNG(bd->bd_Member, attr, data, TAG_DONE);
}
else if (FRM_TAG(attr))
{
rc = RAF_UNDERSTOOD|RAF_REDRAW;
if (attr == FRM_Type) rc |= RAF_RESIZE;
if (bd->bd_Frame)
{
DoSetMethodNG(bd->bd_Frame, attr, data, TAG_DONE);
}
else
{
if (attr != FRM_ThinFrame)
{
bd->bd_Frame = BGUI_NewObject(BGUI_FRAME_IMAGE, attr, data, IMAGE_InBorder,
GADGET(obj)->Activation & BORDERMASK, TAG_DONE);
rc |= RAF_RESIZE;
};
};
};
}
else
{
switch(ra->ra_Attr->ti_Tag)
{
case GA_TopBorder:
case GA_BottomBorder:
case GA_LeftBorder:
case GA_RightBorder:
bd = (BD *)INST_DATA(cl, obj);
if (bd->bd_Frame)
{
DoSetMethodNG(bd->bd_Frame, IMAGE_InBorder, GADGET(obj)->Activation & BORDERMASK, TAG_END);
rc |= RAF_REDRAW;
};
if (bd->bd_Label)
{
DoSetMethodNG(bd->bd_Label, IMAGE_InBorder, GADGET(obj)->Activation & BORDERMASK, TAG_END);
rc |= RAF_REDRAW;
};
break;
}
}
return rc;
}
METHOD_END
///
/// RM_SETCUSTOM
/*
* Set custom attributes.
*/
METHOD(BaseClassSetCustom, struct rmAttr *, ra)
{
BD *bd = (BD *)INST_DATA(cl, obj);
struct TextAttr *ta;
struct TextFont *tf;
Tag attr = ra->ra_Attr->ti_Tag;
IPTR data = ra->ra_Attr->ti_Data;
switch (attr)
{
case BT_LabelObject:
if (bd->bd_Label) DisposeObject(bd->bd_Label);
if ((bd->bd_Label = (Object *)data))
{
bd->bd_Flags &= ~BDF_GOT_LABEL_EXT;
DoSetMethodNG(bd->bd_Label, IMAGE_InBorder, GADGET(obj)->Activation & BORDERMASK, TAG_END);
};
break;
case BT_FrameObject:
if (bd->bd_Frame) DisposeObject(bd->bd_Frame);
if ((bd->bd_Frame = (Object *)data))
{
DoSetMethodNG(bd->bd_Frame, IMAGE_InBorder, GADGET(obj)->Activation & BORDERMASK, TAG_END);
};
break;
case BT_TextAttr:
/*
* Only change the font if it was not defined yet and if it was
* not set at create time.
*/
if (bd->bd_Flags & BDF_FIXED_FONT)
break;
/*
* We only change the font when it opens ok.
*/
if ((ta = (struct TextAttr *)data))
{
if ((tf = BGUI_OpenFont(ta)))
{
bd->bd_TextAttr = ta;
if(bd->bd_TextFont)
BGUI_CloseFont(bd->bd_TextFont);
bd->bd_TextFont = tf;
bd->bd_Flags &= ~BDF_GOT_LABEL_EXT;
if (ra->ra_Flags & RAF_INITIAL) bd->bd_Flags |= BDF_FIXED_FONT;
/*
* Change the font settings on the images.
*/
if (bd->bd_Label) DoSetMethodNG(bd->bd_Label, IMAGE_TextFont, tf, TAG_END);
if (bd->bd_Frame) DoSetMethodNG(bd->bd_Frame, IMAGE_TextFont, tf, TAG_END);
};
};
break;
case BT_Key:
bd->bd_RawKey = (UBYTE)~0;
break;
case BT_RawKey:
bd->bd_Key = NULL;
break;
case BT_ParentGroup:
if (bd->bd_Frame) DoSetMethodNG(bd->bd_Frame, BT_ParentGroup, data, TAG_DONE);
break;
case BT_ParentWindow:
if (bd->bd_Flags & BDF_CACHE_NOTIFY)
{
//DoNotifyMethod(obj, ops->ops_GInfo, 0, GA_ID, GADGET(obj)->GadgetID, TAG_END);
bd->bd_Flags &= ~BDF_CACHE_NOTIFY;
};
break;
};
return 1;
}
METHOD_END
///
/// OM_NOTIFY
METHOD(BaseClassNotify, struct opUpdate *, opu)
{
BD *bd = INST_DATA(cl, obj);
AsmDoSuperMethodA(cl, obj, (Msg)opu);
if (!opu->opu_GInfo || !opu->opu_GInfo->gi_Window)
{
bd->bd_Flags |= BDF_CACHE_NOTIFY;
};
return 1;
}
METHOD_END
///
/// OM_DISPOSE
/*
* They do not need us anymore.
*/
METHOD(BaseClassDispose, Msg, msg)
{
BD *bd = (BD *)INST_DATA(cl, obj);
/*
* Delete frame and label.
*/
if (bd->bd_Frame)
DisposeObject(bd->bd_Frame);
if (bd->bd_Label)
DisposeObject(bd->bd_Label);
if (bd->bd_PreBuffer)
BGUI_FreeRPortBitMap(bd->bd_PreBuffer);
if (bd->bd_TextFont)
BGUI_CloseFont(bd->bd_TextFont);
/*
* Let the superclass dispose
* of us.
*/
return AsmDoSuperMethodA(cl, obj, msg);
}
METHOD_END
///
/// GM_HITTEST
/*
* Are we hit?
*/
METHOD(BaseClassHitTest, struct gpHitTest *, gpht)
{
BD *bd = INST_DATA(cl, obj);
struct IBox *ibox = (bd->bd_Flags & BDF_LABEL_CLICK) ? &bd->bd_OuterBox : &bd->bd_HitBox;
/*
* Get absolute click position.
*/
WORD x = GADGET(obj)->LeftEdge + gpht->gpht_Mouse.X;
WORD y = GADGET(obj)->TopEdge + gpht->gpht_Mouse.Y;
return (ULONG)(PointInBox(ibox, x, y) ? GMR_GADGETHIT : 0);
}
METHOD_END
///
/// GM_HELPTEST
/*
* Are we hit?
*/
METHOD(BaseClassHelpTest, struct gpHitTest *, gpht)
{
BD *bd = INST_DATA(cl, obj);
struct IBox *ibox = &bd->bd_OuterBox;
/*
* Get absolute click position.
*/
WORD x = GADGET(obj)->LeftEdge + gpht->gpht_Mouse.X;
WORD y = GADGET(obj)->TopEdge + gpht->gpht_Mouse.Y;
return (ULONG)(PointInBox(ibox, x, y) ? GMR_HELPHIT : GMR_NOHELPHIT);
}
METHOD_END
///
/// GM_RENDER
/*
* Render the object.
*/
METHOD(BaseClassRenderX, struct gpRender *, gpr)
{
BD *bd = INST_DATA(cl, obj);
struct RastPort *rp = NULL;
struct BaseInfo *bi;
int x, y, from_x, from_y, to_x, to_y;
struct IBox *box, to;
ULONG rc = 0;
IPTR gok = TRUE;
/*
* Are we inhibited? If so we do not render ourselves.
*/
if (bd->bd_Window)
Get_Attr(bd->bd_Window, WINDOW_GadgetOK, &gok);
if ((bd->bd_Flags & BDF_INHIBITED) || (!gok))
return 0;
if (bd->bd_Flags & BDF_BUFFER)
{
/*
* Use buffer?
*/
if (bd->bd_Window)
{
Get_Attr(bd->bd_Window, WINDOW_BufferRP, (IPTR *)&rp);
}
};
if (!rp) rp = gpr->gpr_RPort;
/*
* Handle virtual groups.
*/
if (bd->bd_View)
{
Get_Attr(bd->bd_View, VIEW_ObjectBuffer, (IPTR *)&rp);
};
if ((bd->bd_RPort = rp))
{
#ifdef DEBUG_BGUI
if (bi = AllocBaseInfoDebug(__FILE__,__LINE__,BI_GadgetInfo, gpr->gpr_GInfo, BI_RastPort, rp, TAG_DONE))
#else
if ((bi = AllocBaseInfo(BI_GadgetInfo, gpr->gpr_GInfo, BI_RastPort, rp, TAG_DONE)))
#endif
{
bi->bi_Window = bd->bd_Parent;
/*
* Layout the object.
*/
if ((rc = AsmDoMethod(obj, BASE_LAYOUT, bi, GADGETBOX(obj), 0)))
{
/*
* Remove layer from buffer if not needed.
*/
//if (bd->bd_Parent) AsmDoMethod(bd->bd_Parent, WM_CLIP, NULL, CLIPACTION_NONE);
rc = AsmDoMethod(obj, BASE_RENDER, bi, gpr->gpr_Redraw);
};
FreeBaseInfo(bi);
};
};
if (rc)
{
if (bd->bd_View)
{
if (rp != gpr->gpr_RPort)
{
IPTR tmp;
Get_Attr(bd->bd_View, VIEW_AbsoluteX, &tmp);
x = (int)tmp;
Get_Attr(bd->bd_View, VIEW_AbsoluteY, &tmp);
y = (int)tmp;
from_x = bd->bd_OuterBox.Left;
from_y = bd->bd_OuterBox.Top;
to.Left = to_x = x + from_x;
to.Top = to_y = y + from_y;
to.Width = bd->bd_OuterBox.Width;
to.Height = bd->bd_OuterBox.Height;
/*
* Convert from ibox to rectangle.
*/
to.Width += to.Left - 1;
to.Height += to.Top - 1;
AsmDoMethod(bd->bd_View, VIEW_CLIP, &to, TRUE);
/*
* Convert from rectangle to ibox.
*/
to.Width -= to.Left - 1;
to.Height -= to.Top - 1;
/*
* Get clipping offsets.
*/
from_x += to.Left - to_x;
from_y += to.Top - to_y;
/*
* Copy the object to the window.
*/
if(to.Width>0
&& to.Height>0)
ClipBlit(rp, from_x, from_y, gpr->gpr_RPort, to.Left, to.Top, to.Width, to.Height, 0xC0);
//if (BASE_DATA(bd->bd_View)->bc_View)
//{
// DoSetMethodNG(BASE_DATA(bd->bd_View)->bc_View, VIEW_ObjectBuffer, NULL, TAG_DONE);
//};
};
}
else
{
if (rp && (rp != gpr->gpr_RPort))
{
/*
* Remove layer from buffer.
*/
if (bd->bd_Window)
{
AsmDoMethod(bd->bd_Window, WM_CLIP, NULL, CLIPACTION_NONE);
};
box = (gpr->gpr_Redraw == GREDRAW_REDRAW) ? &bd->bd_OuterBox : &bd->bd_InnerBox;
/*
* Blast the GUI to the window.
*/
if(box->Width>0
&& box->Height>0)
ClipBlit(rp, box->Left, box->Top, gpr->gpr_RPort, box->Left, box->Top, box->Width, box->Height, 0xC0);
};
};
};
return rc;
}
METHOD_END
///
/// BASE_LAYOUT
/*
* Render the baseclass imagery.
*/
METHOD(BaseClassLayout, struct bmLayout *, bml)
{
BD *bd = INST_DATA(cl, obj);
int dw, dh;
UWORD gflags = GADGET(obj)->Flags;
struct BaseInfo *bi = bml->bml_BInfo;
/*
* Get gadget bounds.
*/
bd->bd_OuterBox = *(bml->bml_Bounds);
/*
* Don't bother with this if we are completely absolute.
*/
if (gflags & (GFLG_RELRIGHT|GFLG_RELBOTTOM|GFLG_RELWIDTH|GFLG_RELHEIGHT))
{
/*
* Get domain width and height.
*/
dw = bi->bi_Domain.Width;
dh = bi->bi_Domain.Height;
/*
* Adjust for any relativity.
*/
if (gflags & GFLG_RELRIGHT) bd->bd_OuterBox.Left += dw - 1;
if (gflags & GFLG_RELBOTTOM) bd->bd_OuterBox.Top += dh - 1;
if (gflags & GFLG_RELWIDTH) bd->bd_OuterBox.Width += dw;
if (gflags & GFLG_RELHEIGHT) bd->bd_OuterBox.Height += dh;
};
bd->bd_HitBox = bd->bd_OuterBox;
/*
* Do we have a label?
*/
if (bd->bd_Label && bi->bi_RPort)
{
/*
* If the extentions are already known we
* we do not bother getting them again.
*/
if (!(bd->bd_Flags & BDF_GOT_LABEL_EXT))
{
/*
* Setup label extentions.
*/
DoExtentMethod(bd->bd_Label, bi->bi_RPort, &bd->bd_Extentions, NULL, NULL, EXTF_MAXIMUM);
/*
* We got the extentions.
*/
bd->bd_Flags |= BDF_GOT_LABEL_EXT;
};
/*
* Adjust hitbox accordingly.
*/
bd->bd_HitBox.Left += -bd->bd_Extentions.Left;
bd->bd_HitBox.Top += -bd->bd_Extentions.Top;
bd->bd_HitBox.Width -= -bd->bd_Extentions.Left + bd->bd_Extentions.Width;
bd->bd_HitBox.Height -= -bd->bd_Extentions.Top + bd->bd_Extentions.Height;
/*
* Setup label bounds.
*/
SetImageBounds(bd->bd_Label, &bd->bd_HitBox);
};
bd->bd_InnerBox = bd->bd_HitBox;
bd->bd_InnerBox.Left += bd->bd_LeftOffset;
bd->bd_InnerBox.Top += bd->bd_TopOffset;
bd->bd_InnerBox.Width -= bd->bd_LeftOffset + bd->bd_RightOffset;
bd->bd_InnerBox.Height -= bd->bd_TopOffset + bd->bd_BottomOffset;
/*
* Setup frame bounds.
*/
if (bd->bd_Frame)
{
AsmDoMethod(bd->bd_Frame, FRAMEM_SETUPBOUNDS, &bd->bd_HitBox, &bd->bd_InnerBox);
};
return 1;
}
METHOD_END
///
/// BASE_RENDER
/*
* Render the baseclass imagery.
*/
METHOD(BaseClassRender, struct bmRender *, bmr)
{
BD *bd = INST_DATA(cl, obj), *bd2;
struct BaseInfo *bi = bmr->bmr_BInfo;
ULONG state;
Object *parent, *frame;
struct Rectangle rect;
/*
* Complete redraw?
*/
if (bmr->bmr_Flags == GREDRAW_REDRAW)
{
/*
* What state do we render?
*/
state = GadgetState(bi, obj, bd->bd_Flags & BDF_NORECESSED);
if (bd->bd_Frame)
{
BDrawImageState(bi, bd->bd_Frame, 0, 0, state);
}
else
{
bd2 = bd;
while ((parent = bd2->bd_Group))
{
bd2 = INST_DATA(cl, parent);
if ((frame = bd2->bd_Frame))
{
/*
* Use the frame for our backfill.
*/
rect.MinX = bd->bd_InnerBox.Left;
rect.MinY = bd->bd_InnerBox.Top;
rect.MaxX = bd->bd_InnerBox.Width + rect.MinX - 1;
rect.MaxY = bd->bd_InnerBox.Height + rect.MinY - 1;
AsmDoMethod(frame, FRAMEM_BACKFILL, bi, &rect, state);
break;
};
};
if (!parent)
{
UWORD apen;
/*
* If we do not have a frame, we need to clear the area ourselves.
*/
switch (state)
{
case IDS_SELECTED:
apen = FILLPEN;
break;
case IDS_INACTIVESELECTED:
case IDS_INACTIVENORMAL:
apen = BACKGROUNDPEN;
break;
default:
/*
* And BACKGROUNDPEN for normal frames.
*/
apen = (GADGET(obj)->Activation & BORDERMASK) ? FILLPEN : BACKGROUNDPEN;
break;
};
BSetDPenA(bi, apen);
BSetDrMd(bi, JAM1);
BClearAfPt(bi);
BBoxFillA(bi, &bd->bd_InnerBox);
};
};
/*
* Render the label.
*/
if (bd->bd_Label) BDrawImageState(bi, bd->bd_Label, 0, 0, state);
/*
if (bd->bd_Frame)
{
rect.MinX = bd->bd_InnerBox.Left + 2;
rect.MinY = bd->bd_InnerBox.Top + 2;
rect.MaxX = bd->bd_InnerBox.Width + rect.MinX - 5;
rect.MaxY = bd->bd_InnerBox.Height + rect.MinY - 5;
BSetDrPt(bi, 0xAAAA);
BSetDrMd(bi, JAM1);
BSetDPenA(bi, SHADOWPEN);
Move(bi->bi_RPort, rect.MaxX, rect.MinY);
Draw(bi->bi_RPort, rect.MinX, rect.MinY);
Draw(bi->bi_RPort, rect.MinX, rect.MaxY);
Draw(bi->bi_RPort, rect.MaxX, rect.MaxY);
Draw(bi->bi_RPort, rect.MaxX, rect.MinY);
};
*/
};
return 1;
}
METHOD_END
///
/// BASE_HELP
/*
* Show help.
*/
METHOD(BaseClassHelp, struct bmShowHelp *, bsh)
{
BD *bd = INST_DATA(cl, obj);
struct NewAmigaGuide nag = { };
ULONG rc = BMHELP_NOT_ME;
struct gpHitTest gph;
/*
* We only show help when
* necessary or possible.
*/
if (bd->bd_HelpFile || bd->bd_HelpText || bd->bd_HelpHook)
{
#if 0
WORD l, t, w, h, dw, dh;
/*
* Setup the gadget bounds.
*/
l = GADGET(obj)->LeftEdge;
t = GADGET(obj)->TopEdge;
w = GADGET(obj)->Width;
h = GADGET(obj)->Height;
/*
* When one of the GFLGREL... flags
* is set adjust the appropiate value.
*/
if (!(GADGET(obj)->GadgetType & GTYP_REQGADGET))
{
dw = bsh->bsh_Window->Width;