1 /***************************************************************************
3 BetterString.mcc - A better String gadget MUI Custom Class
4 Copyright (C) 1997-2000 Allan Odgaard
5 Copyright (C) 2005-2009 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/
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>
33 #include <mcc_common.h>
35 #include <mui/BetterString_mcc.h>
41 struct ExAllData buffer
;
46 /* Normal stringgadget info */
48 STRPTR InactiveContents
;
49 STRPTR Original
; /* Amiga-q (toggle) */
50 STRPTR Undo
; /* Amiga-z (toggle) */
53 Object
*ForwardObject
;
54 Object
*Popup
; /* ctrl-p popup object */
63 /* Various system resources and data */
64 struct MUI_EventHandlerNode ehnode
;
65 struct RastPort rport
;
66 struct Locale
*locale
;
70 Object
*KeyUpFocus
, *KeyDownFocus
;
72 // the selection pointer Object
74 BOOL activeSelectPointer
;
76 /* Filename completion */
77 struct FNCData
*FNCBuffer
;
82 /* For marking of text */
86 /* For double/triple clicking */
87 ULONG StartSecs
, StartMicros
;
90 /* The hotkey which activates the stringgadget */
94 STRPTR InactiveBackground
;
96 STRPTR ActiveBackground
;
100 ULONG MarkedTextColor
;
101 struct TextFont
*Font
;
106 struct Hook
*EditHook
;
109 #define FLG_Secret (1L << 0)
110 #define FLG_AdvanceOnCr (1L << 1)
111 #define FLG_BlockEnabled (1L << 2)
112 #define FLG_Active (1L << 3)
113 #define FLG_Ghosted (1L << 4)
114 #define FLG_Shown (1L << 5)
115 #define FLG_Original (1L << 6)
116 #define FLG_RedoAvailable (1L << 7)
117 #define FLG_StayActive (1L << 8)
118 #define FLG_SetFrame (1L << 9)
119 #define FLG_OwnFont (1L << 10)
120 #define FLG_OwnBackground (1L << 11)
121 #define FLG_NoInput (1L << 12)
122 #define FLG_DragOutside (1L << 13)
123 #define FLG_NoShortcuts (1L << 14)
124 #define FLG_ForceSelectOn (1L << 15)
125 #define FLG_ForceSelectOff (1L << 16)
126 #define FLG_FreshActive (1L << 17)
127 #define FLG_MouseButtonDown (1L << 18)
129 // proper RAWKEY_ defines were first introduced in OS4 and MorphOS
130 // and unfortunately they are also a bit different, so lets
131 // prepare an alternate table for it
132 #if defined(__amigaos4__)
133 #include <proto/keymap.h>
135 #define RAWKEY_SCRLOCK RAWKEY_MENU
136 #define RAWKEY_NUMLOCK 0x79
138 #elif defined(__MORPHOS__)
139 #include <devices/rawkeycodes.h>
141 #define RAWKEY_CRSRUP RAWKEY_UP
142 #define RAWKEY_CRSRDOWN RAWKEY_DOWN
143 #define RAWKEY_CRSRRIGHT RAWKEY_RIGHT
144 #define RAWKEY_CRSRLEFT RAWKEY_LEFT
145 #define RAWKEY_PRINTSCR RAWKEY_PRTSCREEN
146 #define RAWKEY_BREAK RAWKEY_PAUSE
147 #define RAWKEY_DEL RAWKEY_DELETE
149 #define RAWKEY_AUD_STOP RAWKEY_CDTV_STOP
150 #define RAWKEY_AUD_PLAY_PAUSE RAWKEY_CDTV_PLAY
151 #define RAWKEY_AUD_PREV_TRACK RAWKEY_CDTV_PREV
152 #define RAWKEY_AUD_NEXT_TRACK RAWKEY_CDTV_NEXT
153 #define RAWKEY_AUD_SHUFFLE RAWKEY_CDTV_REW
154 #define RAWKEY_AUD_REPEAT RAWKEY_CDTV_FF
158 #define RAWKEY_BACKSPACE 0x41
159 #define RAWKEY_TAB 0x42
160 #define RAWKEY_DEL 0x46
161 #define RAWKEY_INSERT 0x47 /* Not on classic keyboards */
162 #define RAWKEY_PAGEUP 0x48 /* Not on classic keyboards */
163 #define RAWKEY_PAGEDOWN 0x49 /* Not on classic keyboards */
164 #define RAWKEY_F11 0x4B /* Not on classic keyboards */
165 #define RAWKEY_CRSRUP 0x4C
166 #define RAWKEY_CRSRDOWN 0x4D
167 #define RAWKEY_CRSRRIGHT 0x4E
168 #define RAWKEY_CRSRLEFT 0x4F
169 #define RAWKEY_F1 0x50
170 #define RAWKEY_F2 0x51
171 #define RAWKEY_F3 0x52
172 #define RAWKEY_F4 0x53
173 #define RAWKEY_F5 0x54
174 #define RAWKEY_F6 0x55
175 #define RAWKEY_F7 0x56
176 #define RAWKEY_F8 0x57
177 #define RAWKEY_F9 0x58
178 #define RAWKEY_F10 0x59
179 #define RAWKEY_HELP 0x5F
180 #define RAWKEY_SCRLOCK 0x6B /* Not on classic keyboards */
181 #define RAWKEY_PRINTSCR 0x6D /* Not on classic keyboards */
182 #define RAWKEY_BREAK 0x6E /* Not on classic keyboards */
183 #define RAWKEY_F12 0x6F /* Not on classic keyboards */
184 #define RAWKEY_HOME 0x70 /* Not on classic keyboards */
185 #define RAWKEY_END 0x71 /* Not on classic keyboards */
187 #define RAWKEY_AUD_STOP 0x72
188 #define RAWKEY_AUD_PLAY_PAUSE 0x73
189 #define RAWKEY_AUD_PREV_TRACK 0x74
190 #define RAWKEY_AUD_NEXT_TRACK 0x75
191 #define RAWKEY_AUD_SHUFFLE 0x76
192 #define RAWKEY_AUD_REPEAT 0x77
194 #define RAWKEY_NUMLOCK 0x79
199 VOID
PrintString(struct IClass
*, Object
*);
200 IPTR
HandleInput(struct IClass
*, Object
*, struct MUIP_HandleEvent
*);
201 ULONG
ConvertKey(struct IntuiMessage
*);
202 VOID
DeleteBlock(struct InstData
*);
204 IPTR
Get(struct IClass
*, Object
*, struct opGet
*);
205 IPTR
Set(struct IClass
*, Object
*, struct opSet
*);
206 IPTR
mDoAction(struct IClass
*, Object
*, struct MUIP_BetterString_DoAction
*);
208 BOOL
CreateSharedPool(void);
209 void DeleteSharedPool(void);
210 APTR
SharedPoolAlloc(ULONG
);
211 VOID
SharedPoolFree(APTR
);
212 APTR
SharedPoolExpand(APTR
, ULONG
);
214 VOID
strcpyback(STRPTR
, STRPTR
);
216 BOOL
Overwrite(STRPTR
, UWORD
, UWORD
, struct InstData
*);
217 BOOL
OverwriteA(STRPTR
, UWORD
, UWORD
, UWORD
, struct InstData
*);
218 BOOL
FileNameComplete(Object
*, BOOL
, struct InstData
*);
219 LONG
FileNameStart(struct MUIP_BetterString_FileNameStart
*msg
);
221 WORD
CmpStrings(REG(a0
, STRPTR
), REG(a1
, STRPTR
));
223 VOID
InitConfig(Object
*, struct InstData
*);
224 VOID
FreeConfig(struct MUI_RenderInfo
*, struct InstData
*);
226 struct BitMap
* SAVEDS ASM
MUIG_AllocBitMap(REG(d0
, LONG
), REG(d1
, LONG
), REG(d2
, LONG
), REG(d3
, LONG flags
), REG(a0
, struct BitMap
*));
227 VOID SAVEDS ASM
MUIG_FreeBitMap(REG(a0
, struct BitMap
*));
230 void SetupSelectPointer(struct InstData
*data
);
231 void CleanupSelectPointer(struct InstData
*data
);
232 void ShowSelectPointer(Object
*obj
, struct InstData
*data
);
233 void HideSelectPointer(Object
*obj
, struct InstData
*data
);
236 BOOL
StartClipboardServer(void);
237 void ShutdownClipboardServer(void);
238 void StringToClipboard(STRPTR str
, LONG length
);
239 void ClipboardToString(STRPTR
*str
, LONG
*length
);
241 #define setFlag(mask, flag) (mask) |= (flag)
242 #define clearFlag(mask, flag) (mask) &= ~(flag)
243 #define isAnyFlagSet(mask, flag) (((mask) & (flag)) != 0)
244 #define isFlagSet(mask, flag) (((mask) & (flag)) == (flag))
245 #define isFlagClear(mask, flag) (((mask) & (flag)) == 0)
247 #if defined(__MORPHOS__)
248 #include <proto/exec.h>
249 #define IS_MORPHOS2 (((struct Library *)SysBase)->lib_Version >= 51)
252 // some own usefull MUI-style macros to check mouse positions in objects
253 #define _between(a,x,b) ((x)>=(a) && (x)<=(b))
254 #define _isinobject(o,x,y) (_between(_mleft(o),(x),_mright (o)) && _between(_mtop(o) ,(y),_mbottom(o)))
255 #define _isinwholeobject(o,x,y) (_between(_left(o),(x),_right (o)) && _between(_top(o) ,(y),_bottom(o)))
258 // Gets an attribute value from a MUI object
259 IPTR
xget(Object
*obj
, const IPTR attr
);
260 #if defined(__GNUC__)
261 // please note that we do not evaluate the return value of GetAttr()
262 // as some attributes (e.g. MUIA_Selected) always return FALSE, even
263 // when they are supported by the object. But setting b=0 right before
264 // the GetAttr() should catch the case when attr doesn't exist at all
265 #define xget(OBJ, ATTR) ({IPTR b=0; GetAttr(ATTR, OBJ, &b); b;})
269 #endif /* BETTERSTRING_MCC_PRIV_H */