Initial commit.
[amiga/xmodule.git] / Gui.h
1 /*
2 **      Gui.h
3 **
4 **      Copyright (C) 1993,94,95,96,98 by Bernardo Innocenti
5 **
6 **      Various definitions for the user interface.
7 */
8
9 #ifndef INTUITION_INTUITION_H
10 #include <intuition/intuition.h>
11 #endif
12
13 #ifndef XMODULE_PRIV_H
14 #include <XModulePriv.h>
15 #endif
16
17
18 /***************/
19 /* WinUserData */
20 /***************/
21
22 /* This structure holds data needed to handle windows
23  * in a nice Object oriented way (no more endless switches :-)
24  */
25 struct WinUserData
26 {
27         struct MinNode           Link;  /* Used to mantain a list of all open windows. */
28
29         struct Window           *Win;
30         ULONG                            GCount;
31         struct Gadget           **Gadgets;
32         struct GInfo            *GInfo;
33         UBYTE                           *Keys;
34         struct TextAttr         *Attr;
35         struct TextFont         *Font;
36         struct NewMenu          *NewMenu;
37         struct Menu                     *MenuStrip;
38         struct Gadget           *GList;
39         ULONG                           *LayoutArgs;
40         struct WindowBorder     *Borders;
41         struct AppWindow        *AppWin;
42         ULONG                            Flags;
43         ULONG                            IDCMPFlags;
44         STRPTR                           Title;
45
46         ULONG                            WindowID;
47         struct IBox                      WindowSize;
48         struct IBox                      WindowZoom;
49         LONG                             WUDFlags;
50         APTR                             UserData;
51         STRPTR                           HelpNode;
52
53         /* Window specific user functions */
54         LONG (*PreOpenFunc)(struct WinUserData *);
55         void (*PostOpenFunc)(struct WinUserData *);
56         LONG (*PreCloseFunc)(struct WinUserData *);
57         void (*PostCloseFunc)(struct WinUserData *);
58         void (*IDCMPFunc)(struct WinUserData *);
59         void (*DropIcon)(struct AppMessage *);
60         void (*LayoutCleanupFunc)(struct WinUserData *);
61 };
62
63
64 /* Flags for WinUserData->WUDFlags */
65
66 #define WUDF_REOPENME           (1<<0)  /* Open this window again later                         */
67 #define WUDF_LOCALEDONE         (1<<1)  /* Set when menustrip has been localized        */
68 #define WUDF_JUSTRESIZED        (1<<3)  /* Set just after an IDCMP_NEWSIZE                      */
69
70 #define WUDF_CUSTOMLAYOUT       (1<<2)
71 /* Do not use the standard layout routines for
72  * this window.  If not NULL, wud->LayoutArgs must point to
73  * a user function which should create and position the gadgets.
74  *
75  *      struct Gadget *CustomLayoutFunc (struct WinUserData *wud);
76  */
77
78
79
80 struct WDescr
81 {
82         struct WinUserData      *Wud;                   /* Pointer to WinUserData                               */
83         UWORD                            UseCnt;                /* Number of WUDs of this kind                  */
84         UWORD                            Flags;                 /* Some flags, see below                                */
85         struct TagItem          *CreationTags;  /* See <gui.h> for possible tags                */
86 };
87
88
89
90 /* Flags for WDescr->Flags */
91 #define XMWINF_OPENMULTI        (1<<0)  /* Allow opening multiple times                         */
92 #define XMWINF_LOCALEDONE       (1<<1)  /* Set when menustrip has been localized        */
93
94
95 /* Window IDs */
96
97 enum
98 {
99         WID_TOOLBOX,
100         WID_PREFS,
101         WID_SONGINFO,
102         WID_INSTRUMENTS,
103         WID_SEQUENCE,
104         WID_PATTERN,
105         WID_PLAY,
106         WID_SAMPLE,
107         WID_OPTIMIZATION,
108         WID_SAVERS,
109         WID_PATTPREFS,
110         WID_PATTSIZE,
111         WID_CLEAR,
112         WID_LOG,
113         WID_PROGRESS,
114
115         WID_COUNT
116 };
117
118
119
120 /* Tags for MyOpenWindow() */
121 #define XMWIN_Dummy                     (TAG_USER + 'WN' << 8)
122 #define XMWIN_NewMenu           (XMWIN_Dummy + 1)       /* Pointer to NewMenu array                     */
123 #define XMWIN_LayoutArgs        (XMWIN_Dummy + 2)       /* Pointer to layout args array         */
124 #define XMWIN_GCount            (XMWIN_Dummy + 3)       /* Number of gadgets in window          */
125 #define XMWIN_Title                     (XMWIN_Dummy + 4)       /* Window title                                         */
126 #define XMWIN_WindowFlags       (XMWIN_Dummy + 5)       /* Window flags for WA_Flags            */
127 #define XMWIN_IDCMPFlags        (XMWIN_Dummy + 6)       /* Flags for WA_IDCMPFlags                      */
128 #define XMWIN_IDCMPFunc         (XMWIN_Dummy + 7)       /* Custom IDCMP handler                         */
129 #define XMWIN_DropIconFunc      (XMWIN_Dummy + 8)       /* AppWindow handler                            */
130 #define XMWIN_LayoutFunc        (XMWIN_Dummy + 9)       /* Your custom layout function          */
131 #define XMWIN_PreOpenFunc       (XMWIN_Dummy + 10)      /* Called just before opening win       */
132 #define XMWIN_PostOpenFunc      (XMWIN_Dummy + 11)      /* Called just after opening win        */
133 #define XMWIN_PreCloseFunc      (XMWIN_Dummy + 12)      /* Called just before closing win       */
134 #define XMWIN_PostCloseFunc     (XMWIN_Dummy + 13)      /* Called just after closing win        */
135 #define XMWIN_HelpNode          (XMWIN_Dummy + 14)      /* Name of AmigaGuide node for help     */
136 #define XMWIN_UserData          (XMWIN_Dummy + 15)      /* Whatever you want...                         */
137 #define XMWIN_LayoutCleanup     (XMWIN_Dummy + 16)      /* Cleanup for custom layout func       */
138
139 /* You can also use standard OpenWindow() tags */
140
141
142
143 /* This structure is used by LockWindows() to
144  * track modifications made to the windows.
145  */
146 struct WindowLock
147 {
148         struct Requester        Req;
149         ULONG                           OldIDCMPFlags;
150         UWORD                           OldMinWidth,
151                                                 OldMinHeight,
152                                                 OldMaxWidth,
153                                                 OldMaxHeight;
154 };
155
156
157
158 /****************/
159 /* WindowBorder */
160 /****************/
161
162 /* A linked list of these structures is attached to all
163  * WUDs to keep track of the bevel boxes inside the window.
164  */
165 struct WindowBorder
166 {
167         struct WindowBorder     *NextBorder;
168         ULONG                            Type;
169         struct IBox                      Size;
170 };
171
172
173
174 /*********/
175 /* GInfo */
176 /*********/
177
178 /* Each WUD gets an array of GInfo structures to store
179  * some precalculated layout data. Each gadget and group
180  * has a GInfo structure in the array.
181  */
182 struct GInfo
183 {
184         WORD    GKind;                                  /* Object kind (#?_KIND)                */
185         UWORD   MinWidth, MinHeight;    /* Minimum size                                 */
186         UWORD   LabelWidth;                             /* Label width for this object  */
187         UWORD   Flags;                                  /* See below                                    */
188         UWORD   Dummy;                                  /* Keep structure long aligned  */
189         union {
190                 APTR    SpecialStorage;         /* For gadget objects                   */
191                 struct {
192                         UWORD Width, Height;    /* For group objects                    */
193                 } Fixed;
194         };
195 };
196
197 /* Flags for GInfo->Flags */
198 #define GIF_FIXEDWIDTH  (1<<0)
199 #define GIF_FIXEDHEIGHT (1<<1)
200 #define GIF_HASBORDER   (1<<4)
201
202
203
204 /*********************/
205 /* LayoutGadgetsArgs */
206 /*********************/
207
208 /* LayoutGadgetsArgs is used to pass arguments to LayoutGadgets()
209  * and CreateGadgets().
210  */
211 struct LayoutGadgetsArgs
212 {
213         ULONG                           *Args;                  /* Arguments array                                                      */
214         ULONG                            Count;                 /* GInfo array counter                                          */
215         struct GInfo            *GInfo;                 /* GInfo array                                                          */
216         struct WinUserData      *Wud;                   /* The window we are working for                        */
217         struct RastPort         *DummyRast;             /* RastPort initialzied for TextLength()        */
218         void                            *VInfo;                 /* VisualInfo for GadTools gadgets                      */
219         struct Gadget           *PrevGad;               /* Used to link gadgets together                        */
220         ULONG                           *SpecialTags;   /* Storage for additional tags for gadgets      */
221 };
222
223
224 /* Layout modes for LayoutGadgets and CreateGadgets() */
225 #define LAYOUTMODE_V    0
226 #define LAYOUTMODE_H    1
227
228 #define VSPACING                1               /* Vertical spacing between GUI elements        */
229 #define HSPACING                2               /* Horizontal spacing between GUI elements      */
230 #define LABELSPACING    8               /* Extra horizontal spacing for labels          */
231
232
233
234 /***********/
235 /* ScrInfo */
236 /***********/
237
238 struct ScrInfo
239 {
240     ULONG       DisplayID;              /* Display mode ID                              */
241     ULONG       Width;                  /* Width of display in pixels   */
242     ULONG       Height;                 /* Height of display in pixels  */
243     UWORD       Depth;                  /* Number of bit-planes                 */
244     UWORD       OverscanType;   /* Type of overscan of display  */
245     BOOL        AutoScroll;             /* Display should auto-scroll?  */
246         BOOL    OwnPalette;
247         UWORD   Colors[32];
248         UBYTE   PubScreenName[32];
249 };
250
251
252
253 /*******************/
254 /* File requesters */
255 /*******************/
256
257 /* This structure is used to reference all the file requesters.
258  */
259 struct XMFileReq
260 {
261         APTR    FReq;           /* Real file requester (ASL or ReqTools)                                */
262         ULONG   Title;          /* Message number for title                                                             */
263         ULONG   Flags;          /* FRF_DOSAVEMODE, FRF_DOPATTERNS, FRF_DOMULTISELECT... */
264 };
265
266 enum
267 {
268         FREQ_LOADMOD,
269         FREQ_SAVEMOD,
270         FREQ_LOADINST,
271         FREQ_SAVEINST,
272         FREQ_LOADPATT,
273         FREQ_SAVEPATT,
274         FREQ_LOADMISC,
275         FREQ_SAVEMISC,
276
277         FREQ_COUNT
278 };
279
280
281
282 /************/
283 /* Switches */
284 /************/
285
286
287 struct ClearSwitches
288 {
289         BOOL    ClearPatt,
290                         ClearSeq,
291                         ClearInstr;
292 };
293
294 struct SaveSwitches
295 {
296         BOOL    SavePatt,
297                         SaveSeq,
298                         SaveInstr,
299                         SaveNames,
300                         SaveIcons;
301 };
302
303 struct OptSwitches
304 {
305         BOOL    RemPatts,
306                         RemDupPatts,
307                         RemInstr,
308                         RemDupInstr,
309                         CutAfterLoop,
310                         CutZeroTail,
311                         CutPatts,
312                         RemapInstr;
313 };
314
315 struct GuiSwitches
316 {
317         BOOL    SaveIcons,
318                         AskOverwrite,
319                         AskExit,
320                         ShowAppIcon,
321                         UseReqTools,
322                         SmartRefresh,
323                         UseDataTypes,
324                         InstrSaveIcons,
325                         AskAutosave,
326                         DoBackups,
327                         LogToFile;
328         UWORD   InstrSaveMode,
329                         SampDrawMode,
330                         LogLevel,
331                         AutosaveTime,
332                         BackupVersions;
333         UBYTE   BackupTemplate[64];
334         UBYTE   LogFile[128];
335 };
336
337 struct PattSwitches
338 {
339         WORD    AdvanceTracks,  AdvanceLines;
340         ULONG   MaxUndoLevels,  MaxUndoMem;
341         ULONG   Flags;                                                  /* See <patteditclass.h> for possible flags */
342         WORD    VScrollerPlace, HScrollerPlace;
343         UBYTE   ClipboardUnit,  Pad0;
344         UWORD   TrackChars, Backdrop;
345         ULONG   BGPen, TextPen, LinesPen, TinyLinesPen;
346 };
347
348
349
350 /* Possible values for (H|V)ScrollerPlace */
351 #define SCROLLERPLACE_NONE              0
352 #define SCROLLERPLACE_RIGHT             1
353 #define SCROLLERPLACE_BOTTOM    1
354 #define SCROLLERPLACE_LEFT              2
355
356
357
358 /* Instrument save modes */
359 enum {
360         INST_8SVX,
361         INST_8SVX_FIB,
362         INST_RAW,
363         INST_XPK
364 };
365
366
367 /* Handy macros to get a gadget string/number */
368
369 #define GetString(g)      (((struct StringInfo *)g->SpecialInfo)->Buffer)
370 #define GetNumber(g)      (((struct StringInfo *)g->SpecialInfo)->LongInt)
371
372
373 /* Some handy definitions missing in <devices/inputevent.h> */
374
375 #define IEQUALIFIER_SHIFT       (IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT)
376 #define IEQUALIFIER_ALT         (IEQUALIFIER_LALT | IEQUALIFIER_RALT)
377 #define IEQUALIFIER_COMMAND     (IEQUALIFIER_LCOMMAND | IEQUALIFIER_RCOMMAND)
378
379
380 /* Any break flag */
381
382 #define SIGBREAKFLAGS (SIGBREAKF_CTRL_C | SIGBREAKF_CTRL_D | SIGBREAKF_CTRL_E | SIGBREAKF_CTRL_F)
383
384
385 /**************************/
386 /* XModule custom gadgets */
387 /**************************/
388
389
390 #define ENDGROUP_KIND   -1      /* End of group                                         */
391 #define VGROUP_KIND             -2      /* Vertical group                                       */
392 #define HGROUP_KIND             -3      /* Horizontal group                                     */
393 #define IMAGEBUTTON_KIND 20 /* button with vector image label   */
394 #define BOOPSI_KIND              21     /* BOOPSI gadget                                        */
395
396
397 /* ti_Data is a pointer to a setup function for custom gadgets.
398  * It receives the newly allocated Gadget structure and should customize
399  * all fields it is interested in, as well as doing all the allocations
400  * and precalculations which are needed for the custom gadget.
401  *
402  * When the XMGAD_BOOPSI tag is specified, SetupFunc() receves the
403  * tag array pointer and the NewGadget structure associated with the
404  * gadget.  SetupFunc() should then return a pointer to the BOOPSI
405  * Gadget it has allocated.
406  */
407 #define XMGAD_SetupFunc (TAG_USER+1)
408
409
410 /* If ti_Data is TRUE, the layout routines will let the SetupFunc()
411  * allocate a BOOPSI gadget itself, So the gadget is _not_ allocated with
412  * the GadTools function CreateGadget(). When the window is closed with
413  * MyCloseWindow(), or when MyOpenWindow() fails after creating the object,
414  * it is your duty to DisposeObject() on these gadgets.
415  */
416 //#define XMGAD_BOOPSI  (TAG_USER+2)
417
418
419
420 /********************/
421 /* External symbols */
422 /********************/
423
424 XREF struct Screen              *Scr;
425 XREF struct DrawInfo    *DrawInfo;
426 XREF APTR                                VisualInfo;
427 XREF struct ScrInfo              ScrInfo;
428 XREF struct WDescr               WDescr[];
429 XREF CxObj                              *MyBroker;
430 XREF UWORD __chip               *BlockPointer;  /* for OS2.0 only */
431 XREF Class                              *ScrollButtonClass;
432 XREF UWORD                               OffX, OffY;
433 XREF WORD                                SizeWidth, SizeHeight;
434 XREF ULONG                               UniqueID;
435
436 XREF struct IntuiMessage IntuiMsg;
437
438 XREF struct MsgPort
439         *PubPort,
440         *CxPort;
441
442 XREF struct TextAttr
443         TopazAttr,
444         ScreenAttr,
445         WindowAttr,
446         ListAttr,
447         EditorAttr;
448
449 XREF struct TextFont *TopazFont;
450
451 XREF ULONG
452         FileReqSig,
453         AppSig,
454         AudioSig,
455         CxSig,
456         AmigaGuideSig,
457         PubPortSig,
458         Signals;                // Global Wait() signals
459
460
461 XREF struct XMFileReq FileReqs[FREQ_COUNT];
462
463
464 XREF struct List
465         WindowList,
466         InstrList,
467         PatternsList,
468         SequenceList,
469         LogList;
470
471
472 XREF struct SaveSwitches        SaveSwitches;
473 XREF struct ClearSwitches       ClearSwitches;
474 XREF struct OptSwitches         OptSwitches;
475 XREF struct GuiSwitches         GuiSwitches;
476 XREF struct PattSwitches        PattSwitches;
477
478 XREF BOOL DoNextSelect;
479 XREF BOOL ShowRequesters;
480 XREF BOOL Iconified;
481 XREF BOOL Quit;
482
483 XREF LONG
484         ToolBoxWinTags[],
485         PrefsWinTags[],
486         SongInfoWinTags[],
487         InstrumentsWinTags[],
488         SequenceWinTags[],
489         PatternWinTags[],
490         PlayWinTags[],
491         SampleWinTags[],
492         OptimizationWinTags[],
493         SaversWinTags[],
494         PattPrefsWinTags[],
495         PattSizeWinTags[],
496         ClearWinTags[],
497         LogWinTags[],
498         ProgressWinTags[];
499
500
501
502 /***********************/
503 /* Function prototypes */
504 /***********************/
505
506 GLOBALCALL void OpenProgressWindow      (void);
507 GLOBALCALL void CloseProgressWindow     (void);
508
509 GLOBALCALL void UpdateInstrList         (void);
510 GLOBALCALL void UpdateInstrInfo         (void);
511 GLOBALCALL void DetatchSongInfoList (void);
512 GLOBALCALL void UpdateSongInfoList      (void);
513 GLOBALCALL void UpdateSongInfo          (void);
514 GLOBALCALL void UpdatePatternList       (void);
515 GLOBALCALL void UpdateSequenceList      (void);
516 /*
517 GLOBALCALL void UpdateSample            (void);
518 GLOBALCALL void UpdateSampInfo          (void);
519 GLOBALCALL void UpdateSampGraph         (void);
520 */
521 GLOBALCALL void UpdateSampleMenu        (void);
522 GLOBALCALL void UpdateGuiSwitches       (void);
523 GLOBALCALL void UpdateInstrSwitches (void);
524 GLOBALCALL void UpdateClearSwitches     (void);
525 GLOBALCALL void UpdateSaveSwitches      (void);
526 GLOBALCALL void UpdateOptSwitches       (void);
527 GLOBALCALL void UpdatePrefsWindow       (void);
528 GLOBALCALL void UpdatePattern           (void);
529 GLOBALCALL void UpdateEditorInst        (void);
530 //GLOBALCALL void       UpdatePlay                      (void);
531
532 GLOBALCALL void UpdatePattSize          (void);
533 GLOBALCALL void UpdatePattPrefs         (void);
534
535 GLOBALCALL void ToolBoxDropIcon         (struct AppMessage *msg);
536
537 GLOBALCALL void HandleIDCMP                     (void);
538 GLOBALCALL void LockWindows                     (void);
539 GLOBALCALL void UnlockWindows           (void);
540 GLOBALCALL void RevealWindow            (struct WinUserData *wud);
541 GLOBALCALL void SetGadgets                      (struct WinUserData *wud, LONG arg, ...);
542
543 GLOBALCALL LONG AddListViewNodeA        (struct List *lv, CONST_STRPTR label, LONG *args);
544 GLOBALCALL LONG AddListViewNode         (struct List *lv, CONST_STRPTR label, ...);
545 GLOBALCALL void RemListViewNode         (struct Node *n);
546 GLOBALCALL struct Image *NewImageObject (ULONG which);
547 GLOBALCALL struct Window *NewWindow     (ULONG id);
548 GLOBALCALL struct Window *MyOpenWindow (struct WinUserData *wud);
549 GLOBALCALL void MyCloseWindow           (struct WinUserData *wud);
550 GLOBALCALL struct WinUserData *CreateWUD (ULONG id);
551 GLOBALCALL void DeleteLayoutInfo        (struct WinUserData     *wud);
552
553 GLOBALCALL void ReopenWindows           (void);
554 GLOBALCALL LONG SetupScreen                     (void);
555 GLOBALCALL void CloseDownScreen         (void);
556
557 GLOBALCALL struct Gadget *CreateUpButton (ULONG id, struct Gadget *target, LONG *map, LONG Place);
558 GLOBALCALL struct Gadget *CreateDnButton (ULONG id, struct Gadget *target, LONG *map, LONG Place);
559 GLOBALCALL struct Gadget *CreateSxButton (ULONG id, struct Gadget *target, LONG *map);
560 GLOBALCALL struct Gadget *CreateDxButton (ULONG id, struct Gadget *target, LONG *map);
561 GLOBALCALL struct Gadget *CreateVSlider (ULONG id, struct Gadget *target, LONG *map, LONG ButtonsSpacing, LONG Place);
562 GLOBALCALL struct Gadget *CreateHSlider (ULONG id, struct Gadget *target, LONG *map, LONG ButtonsSpacing);