arch/cpu.resource: remove dead code
[AROS.git] / workbench / classes / zune / betterstring / mcc / private.h
blobdda6c34e8c4e6114ff69ca6071bb66224cd1225a
1 /***************************************************************************
3 BetterString.mcc - A better String gadget MUI Custom Class
4 Copyright (C) 1997-2000 Allan Odgaard
5 Copyright (C) 2005-2013 by BetterString.mcc Open Source Team
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 BetterString class Support Site: http://www.sf.net/projects/bstring-mcc/
19 $Id$
21 ***************************************************************************/
23 #ifndef BETTERSTRING_MCC_PRIV_H
24 #define BETTERSTRING_MCC_PRIV_H
26 #include <dos/exall.h>
27 #include <exec/types.h>
28 #include <proto/intuition.h>
29 #include <intuition/classusr.h>
30 #include <libraries/mui.h>
32 #include <muiextra.h>
33 #include <mcc_common.h>
35 #include <mui/BetterString_mcc.h>
36 #include "Debug.h"
38 struct FNCData
40 struct FNCData *next;
41 struct ExAllData buffer;
44 struct InstData
46 /* Normal stringgadget info */
47 char *Contents;
48 char *InactiveContents;
49 char *Original; /* Amiga-q (toggle) */
50 char *Undo; /* Amiga-z (toggle) */
51 char *Accept;
52 char *Reject;
53 Object *ForwardObject;
54 Object *Popup; /* ctrl-p popup object */
55 UWORD DisplayPos;
56 UWORD BufferPos;
57 UWORD BufferLastPos;
58 UWORD MaxLength;
59 WORD Alignment;
60 UWORD UndoPos;
61 UWORD Width;
63 /* Various system resources and data */
64 struct MUI_EventHandlerNode ehnode;
65 struct RastPort rport;
66 struct Locale *locale;
67 ULONG Flags;
69 Object *KeyUpFocus;
70 Object *KeyDownFocus;
72 // the selection pointer Object
73 Object *PointerObj;
74 BOOL activeSelectPointer;
76 /* Filename completion */
77 struct FNCData *FNCBuffer;
78 WORD FileNumber;
79 UWORD FileEntries;
80 UWORD FileNameStart;
82 /* For marking of text */
83 UWORD BlockStart;
84 WORD BlockStop;
86 /* For double/triple clicking */
87 ULONG StartSecs, StartMicros;
88 UBYTE ClickCount;
90 /* The hotkey which activates the stringgadget */
91 UBYTE CtrlChar;
93 /* Config */
94 STRPTR InactiveBackground;
95 ULONG InactiveText;
96 STRPTR ActiveBackground;
97 ULONG ActiveText;
98 ULONG CursorColor;
99 ULONG MarkedColor;
100 ULONG MarkedTextColor;
101 BOOL SelectOnActive;
102 BOOL SelectPointer;
104 char InactiveBackgroundBuffer[128];
105 char ActiveBackgroundBuffer[128];
107 /* Edit hook */
108 struct Hook *EditHook;
110 BOOL mui39;
111 BOOL mui4x;
112 STRPTR OwnBackground;
115 #define FLG_Secret (1L << 0)
116 #define FLG_AdvanceOnCr (1L << 1)
117 #define FLG_BlockEnabled (1L << 2)
118 #define FLG_Active (1L << 3)
119 #define FLG_Ghosted (1L << 4)
120 #define FLG_Shown (1L << 5)
121 #define FLG_Original (1L << 6)
122 #define FLG_RedoAvailable (1L << 7)
123 #define FLG_StayActive (1L << 8)
124 #define FLG_OwnBackground (1L << 11)
125 #define FLG_NoInput (1L << 12)
126 #define FLG_DragOutside (1L << 13)
127 #define FLG_NoShortcuts (1L << 14)
128 #define FLG_ForceSelectOn (1L << 15)
129 #define FLG_ForceSelectOff (1L << 16)
130 #define FLG_FreshActive (1L << 17)
131 #define FLG_MouseButtonDown (1L << 18)
132 #define FLG_NoNotify (1L << 19) // don't trigger notifications immediately but queue them instead
133 #define FLG_NotifyQueued (1L << 20) // there are notifications pending
134 #define FLG_Setup (1L << 21) // successful MUIM_Setup
135 #define FLG_WindowSleepNotifyAdded (1L << 22) // notify for MUIA_Window_Sleep was added
136 #define FLG_DummyNotifyAdded (1L << 23) // dummy notify was added
138 // private attributes
139 #define MUIA_BetterString_InternalSelectOnActive 0xad002000UL
140 #define MUIA_BetterString_Nop 0xad002001UL
142 // proper RAWKEY_ defines were first introduced in OS4 and MorphOS
143 // and unfortunately they are also a bit different, so lets
144 // prepare an alternate table for it
145 #if defined(__amigaos4__)
146 #include <proto/keymap.h>
148 #define RAWKEY_SCRLOCK RAWKEY_MENU
149 #define RAWKEY_NUMLOCK 0x79
151 #elif defined(__MORPHOS__)
152 #include <devices/rawkeycodes.h>
154 #define RAWKEY_CRSRUP RAWKEY_UP
155 #define RAWKEY_CRSRDOWN RAWKEY_DOWN
156 #define RAWKEY_CRSRRIGHT RAWKEY_RIGHT
157 #define RAWKEY_CRSRLEFT RAWKEY_LEFT
158 #define RAWKEY_PRINTSCR RAWKEY_PRTSCREEN
159 #define RAWKEY_BREAK RAWKEY_PAUSE
160 #define RAWKEY_DEL RAWKEY_DELETE
162 #define RAWKEY_AUD_STOP RAWKEY_CDTV_STOP
163 #define RAWKEY_AUD_PLAY_PAUSE RAWKEY_CDTV_PLAY
164 #define RAWKEY_AUD_PREV_TRACK RAWKEY_CDTV_PREV
165 #define RAWKEY_AUD_NEXT_TRACK RAWKEY_CDTV_NEXT
166 #define RAWKEY_AUD_SHUFFLE RAWKEY_CDTV_REW
167 #define RAWKEY_AUD_REPEAT RAWKEY_CDTV_FF
169 #else
171 #define RAWKEY_BACKSPACE 0x41
172 #define RAWKEY_TAB 0x42
173 #define RAWKEY_DEL 0x46
174 #define RAWKEY_INSERT 0x47 /* Not on classic keyboards */
175 #define RAWKEY_PAGEUP 0x48 /* Not on classic keyboards */
176 #define RAWKEY_PAGEDOWN 0x49 /* Not on classic keyboards */
177 #define RAWKEY_F11 0x4B /* Not on classic keyboards */
178 #define RAWKEY_CRSRUP 0x4C
179 #define RAWKEY_CRSRDOWN 0x4D
180 #define RAWKEY_CRSRRIGHT 0x4E
181 #define RAWKEY_CRSRLEFT 0x4F
182 #define RAWKEY_F1 0x50
183 #define RAWKEY_F2 0x51
184 #define RAWKEY_F3 0x52
185 #define RAWKEY_F4 0x53
186 #define RAWKEY_F5 0x54
187 #define RAWKEY_F6 0x55
188 #define RAWKEY_F7 0x56
189 #define RAWKEY_F8 0x57
190 #define RAWKEY_F9 0x58
191 #define RAWKEY_F10 0x59
192 #define RAWKEY_HELP 0x5F
193 #define RAWKEY_SCRLOCK 0x6B /* Not on classic keyboards */
194 #define RAWKEY_PRINTSCR 0x6D /* Not on classic keyboards */
195 #define RAWKEY_BREAK 0x6E /* Not on classic keyboards */
196 #define RAWKEY_F12 0x6F /* Not on classic keyboards */
197 #define RAWKEY_HOME 0x70 /* Not on classic keyboards */
198 #define RAWKEY_END 0x71 /* Not on classic keyboards */
200 #define RAWKEY_AUD_STOP 0x72
201 #define RAWKEY_AUD_PLAY_PAUSE 0x73
202 #define RAWKEY_AUD_PREV_TRACK 0x74
203 #define RAWKEY_AUD_NEXT_TRACK 0x75
204 #define RAWKEY_AUD_SHUFFLE 0x76
205 #define RAWKEY_AUD_REPEAT 0x77
207 #define RAWKEY_NUMLOCK 0x79
209 #endif
211 // our prototypes
212 VOID PrintString(struct IClass *, Object *);
213 void TriggerNotify(struct IClass *cl, Object *obj);
214 ULONG ConvertKey(struct IntuiMessage *);
215 VOID DeleteBlock(struct InstData *);
217 // HandleInput.c
218 IPTR mDoAction(struct IClass *, Object *, struct MUIP_BetterString_DoAction *);
219 IPTR mHandleInput(struct IClass *, Object *, struct MUIP_HandleEvent *);
220 IPTR mInsert(struct IClass *cl, Object *obj, struct MUIP_BetterString_Insert *msg);
222 // GetSetAttrs.c
223 IPTR mGet(struct IClass *, Object *, struct opGet *);
224 IPTR mSet(struct IClass *, Object *, struct opSet *);
226 // AllocFunctions.c
227 BOOL CreateSharedPool(void);
228 void DeleteSharedPool(void);
229 APTR SharedPoolAlloc(ULONG);
230 void SharedPoolFree(APTR);
231 char *AllocContentString(ULONG size);
232 void FreeContentString(char *str);
233 ULONG ContentStringSize(char *str);
234 BOOL ExpandContentString(char **str, ULONG extra);
236 BOOL Overwrite(STRPTR, UWORD, UWORD, struct InstData *);
237 BOOL OverwriteA(STRPTR, UWORD, UWORD, UWORD, struct InstData *);
238 BOOL FileNameComplete(Object *, BOOL, struct InstData *);
239 LONG mFileNameStart(struct MUIP_BetterString_FileNameStart *msg);
241 WORD CmpStrings(REG(a0, STRPTR), REG(a1, STRPTR));
243 VOID InitConfig(Object *, struct InstData *);
244 VOID FreeConfig(struct MUI_RenderInfo *, struct InstData *);
246 struct BitMap * SAVEDS ASM MUIG_AllocBitMap(REG(d0, LONG), REG(d1, LONG), REG(d2, LONG), REG(d3, LONG flags), REG(a0, struct BitMap *));
247 VOID SAVEDS ASM MUIG_FreeBitMap(REG(a0, struct BitMap *));
249 // Dispatcher.c
250 void AddWindowSleepNotify(struct IClass *cl, Object *obj);
251 void RemWindowSleepNotify(struct IClass *cl, Object *obj);
253 // Pointer.c
254 void SetupSelectPointer(struct InstData *data);
255 void CleanupSelectPointer(struct InstData *data);
256 void ShowSelectPointer(Object *obj, struct InstData *data);
257 void HideSelectPointer(Object *obj, struct InstData *data);
259 // ClipboardServer.c
260 BOOL StartClipboardServer(void);
261 void ShutdownClipboardServer(void);
262 void StringToClipboard(STRPTR str, LONG length);
263 BOOL ClipboardToString(STRPTR *str, LONG *length);
265 #define setFlag(mask, flag) (mask) |= (flag)
266 #define clearFlag(mask, flag) (mask) &= ~(flag)
267 #define isAnyFlagSet(mask, flag) (((mask) & (flag)) != 0)
268 #define isFlagSet(mask, flag) (((mask) & (flag)) == (flag))
269 #define isFlagClear(mask, flag) (((mask) & (flag)) == 0)
271 #define LIBVER(lib) ((struct Library *)lib)->lib_Version
272 #define LIBREV(lib) ((struct Library *)lib)->lib_Revision
273 #define VERSION_IS_AT_LEAST(ver, rev, minver, minrev) (((ver) > (minver)) || ((ver) == (minver) && (rev) == (minrev)) || ((ver) == (minver) && (rev) > (minrev)))
274 #define LIB_VERSION_IS_AT_LEAST(lib, minver, minrev) VERSION_IS_AT_LEAST(((struct Library *)(lib))->lib_Version, ((struct Library *)(lib))->lib_Revision, minver, minrev)
276 #if defined(__MORPHOS__)
277 #include <proto/exec.h>
278 #define IS_MORPHOS2 LIB_VERSION_IS_AT_LEAST(SysBase, 51, 0)
279 #endif
281 // some own usefull MUI-style macros to check mouse positions in objects
282 #define _between(a,x,b) ((x)>=(a) && (x)<=(b))
283 #define _isinobject(o,x,y) (_between(_mleft(o),(x),_mright (o)) && _between(_mtop(o) ,(y),_mbottom(o)))
284 #define _isinwholeobject(o,x,y) (_between(_left(o),(x),_right (o)) && _between(_top(o) ,(y),_bottom(o)))
286 /// xget()
287 // Gets an attribute value from a MUI object
288 IPTR xget(Object *obj, const IPTR attr);
289 #if defined(__GNUC__)
290 // please note that we do not evaluate the return value of GetAttr()
291 // as some attributes (e.g. MUIA_Selected) always return FALSE, even
292 // when they are supported by the object. But setting b=0 right before
293 // the GetAttr() should catch the case when attr doesn't exist at all
294 #define xget(OBJ, ATTR) ({IPTR b=0; GetAttr(ATTR, OBJ, &b); b;})
295 #endif
298 #ifndef MUIKEY_CUT
299 #define MUIKEY_CUT 22
300 #endif
302 #ifndef MUIKEY_COPY
303 #define MUIKEY_COPY 23
304 #endif
306 #ifndef MUIKEY_PASTE
307 #define MUIKEY_PASTE 24
308 #endif
310 #ifndef MUIKEY_UNDO
311 #define MUIKEY_UNDO 25
312 #endif
314 #ifndef MUIKEY_REDO
315 #define MUIKEY_REDO 26
316 #endif
318 #ifndef MUIA_String_Popup
319 #define MUIA_String_Popup 0x80420d71
320 #endif
322 #ifndef MUII_StringBack
323 #define MUII_StringBack 49
324 #endif
326 #ifndef MUII_StringActiveBack
327 #define MUII_StringActiveBack 50
328 #endif
330 #endif /* BETTERSTRING_MCC_PRIV_H */