6 * (C) Copyright 1998 Manuel Lemos.
10 * Revision 42.0 2000/05/09 22:20:08 mlemos
11 * Bumped to revision 42.0 before handing BGUI to AROS team
13 * Revision 41.11 2000/05/09 20:33:57 mlemos
14 * Bumped to revision 41.11
16 * Revision 1.2 2000/05/09 19:59:12 mlemos
17 * Merged with the branch Manuel_Lemos_fixes.
19 * Revision 1.1.2.1 1999/07/30 22:11:47 mlemos
32 #include <intuition/icclass.h>
33 #include <gadgets/textfield.h>
34 #include <proto/textfield.h>
35 #include <proto/iffparse.h>
38 ** Library base pointers.
40 struct Library
*TextFieldBase
= NULL
;
45 #define ID_RIGHTPROP 1
46 #define ID_TEXTFIELD 2
51 VOID
StartDemo( void )
53 Object
*WN_Window
, *GO_Textfield
, *GO_Master
, *GO_RightProp
;
55 ULONG winsig
= 0L, sigrec
, rc
;
59 ** Open the libraries. Get display information etc...
61 if ( TextFieldBase
= OpenLibrary( TEXTFIELD_NAME
, TEXTFIELD_VER
)) {
63 struct ClipboardHandle
*clip_handle
, *undo_handle
;
64 struct IntuiText text1_title
;
66 text1_title
.FrontPen
= 0;
67 text1_title
.BackPen
= 1; /* don't really need to set for JAM1 */
68 text1_title
.DrawMode
= JAM1
;
69 text1_title
.LeftEdge
= 0;
70 text1_title
.TopEdge
= 0;
71 text1_title
.ITextFont
= NULL
;
72 text1_title
.IText
= NULL
;
73 text1_title
.NextText
= NULL
;
75 /* Open the clipboard; no need to verify */
76 clip_handle
= OpenClipboard(0);
77 undo_handle
= OpenClipboard(42);
80 ** Create a small window.
82 WN_Window
= WindowObject
,
83 WINDOW_Title
, "Text field",
85 WINDOW_ScaleWidth
, 20,
86 WINDOW_ScaleHeight
, 20,
87 WINDOW_AutoAspect
, TRUE
,
92 GO_RightProp
= PropObject
,
97 PGA_Freedom
, FREEVERT
,
105 GO_Master
= VGroupObject
, HOffset( 4 ), VOffset( 4 ), Spacing( 4 ),
107 GO_Textfield
= ExternalObject
,
110 EXT_Class
, TEXTFIELD_GetClass(),
113 FRM_Type
, FRTYPE_RIDGE
,
115 GA_FollowMouse
, TRUE
,
116 GA_IntuiText
, &text1_title
,
119 TEXTFIELD_Text
, (ULONG
)"Right Amiga C - Copy\nRight Amiga X - Cut\nRight Amiga V - Paste\n",
120 TEXTFIELD_UserAlign
, TRUE
,
121 TEXTFIELD_BlinkRate
, 500000,
122 TEXTFIELD_TabSpaces
, 4,
123 TEXTFIELD_NonPrintChars
,TRUE
,
124 TEXTFIELD_ClipStream
, clip_handle
,
125 TEXTFIELD_UndoStream
, undo_handle
,
135 ** Open up the window.
137 if ( win
= WindowOpen( WN_Window
)) {
139 ** Obtain window sigmask.
141 GetAttr( WINDOW_SigMask
, WN_Window
, &winsig
);
143 ** Wait for messages.
145 ActivateGadget((struct Gadget
*)GO_Textfield
,win
,NULL
);
147 sigrec
= Wait( winsig
);
152 if ( sigrec
& winsig
) {
153 while ( WN_Window
&& (( rc
= HandleEvent( WN_Window
)) != WMHI_NOMORE
)) {
156 case WMHI_CLOSEWINDOW
:
166 ULONG top
,visible
,total
;
168 GetAttr( EXT_Object
, GO_Textfield
, ( ULONG
* )&object
);
169 GetAttr( TEXTFIELD_Top
, object
, &top
);
170 GetAttr( PGA_Visible
, GO_RightProp
, &visible
);
171 GetAttr( PGA_Total
, GO_RightProp
, &total
);
174 SetGadgetAttrs((struct Gadget
*)object
,win
,NULL
,
176 TEXTFIELD_Visible
,visible
,
177 TEXTFIELD_Lines
,total
,
184 ULONG top
,visible
,total
;
186 GetAttr( EXT_Object
, GO_Textfield
, ( ULONG
* )&object
);
187 GetAttr( TEXTFIELD_Top
, object
, &top
);
188 GetAttr( TEXTFIELD_Visible
, object
, &visible
);
189 GetAttr( TEXTFIELD_Lines
, object
, &total
);
192 SetGadgetAttrs((struct Gadget
*)GO_RightProp
,win
,NULL
,
206 DisposeObject( WN_Window
);
209 /* Close the clipboard */
211 CloseClipboard(undo_handle
);
214 CloseClipboard(clip_handle
);
218 ** Close the textfield.gadget.
220 CloseLibrary( TextFieldBase
);
224 struct bguiRequest req
;
226 memset(&req
,'\0',sizeof(req
));
227 req
.br_GadgetFormat
= "_Ok";
228 req
.br_TextFormat
= ISEQ_C
"This program requires Mark Thomas' gadgets/textfield.gadget\ninstalled in your LIBS: directory.\n\n You may find it at: " ISEQ_U ISEQ_FILL
"aminet://dev/gui/textfield.lha" ISEQ_N
".";
229 req
.br_Flags
= BREQF_AUTO_ASPECT
|BREQF_FAST_KEYS
;
230 req
.br_ReqPos
= POS_CENTERMOUSE
;
231 req
.br_Underscore
= '_';
233 BGUI_RequestA( NULL
, &req
, NULL
);