[4fea5c]: libs / textedit / test / tedit.c Maximize Restore History

Download this file

tedit.c    152 lines (126 with data), 3.7 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
;/* tedit.c - Test for the TextEdit-class, 23.9.2000
;**
;** Copyright Š2000 pinc Software. All Rights Reserved.
;** Licensed under the terms of the MIT License.
;**
sc tedit.c link lib:debug.lib ign=73 nodbg data=near parm=b nochkabort nostkchk strmer streq to=ram:tedit
run ram:tedit
quit
*/
#define INTUI_V36_NAMES_ONLY
#include <exec/libraries.h>
#include <exec/nodes.h>
#include <exec/lists.h>
#include <exec/ports.h>
#include <exec/memory.h>
#include <intuition/intuition.h>
#include <intuition/gadgetclass.h>
#include <graphics/gfx.h>
#include <graphics/gfxmacros.h>
#include <libraries/gadtools.h>
#include <gadgets/TextEdit.h>
#include <libraries/asl.h>
#include <dos/dos.h>
#include <clib/alib_protos.h>
#include <proto/exec.h>
#include <proto/gadtools.h>
#include <proto/intuition.h>
#include <proto/graphics.h>
#include <proto/layers.h>
#include <proto/utility.h>
#include <proto/dos.h>
#if defined(__SASC)
# include <clib/alib_stdio_protos.h>
# include <clib/TextEdit_protos.h>
# include <pragmas/TextEdit_pragmas.h>
#else
# include <proto/pTextEdit.h>
#endif
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
extern void kprintf(STRPTR,...);
struct Screen *scr;
struct Window *win;
struct Gadget *gad,*glist;
APTR dri;
struct Library *TextEditBase;
struct Library *OpenClass(STRPTR name,LONG version)
{
struct Library *class;
char path[256];
strcpy(path,"gadgets/");
strcat(path,name);
if ((class = OpenLibrary(path,version)) != 0)
return(class);
if ((class = OpenLibrary(name,version)) != 0)
return(class);
return(NULL);
}
struct Window *CreateWindow(void)
{
if ((scr = LockPubScreen(NULL)) != 0)
dri = GetScreenDrawInfo(scr);
gad = CreateContext(&glist);
gad = NewObject(NULL,"pinc-editgadget",GA_Left, 8,
GA_Top, 20,
GA_Width, 284,
GA_Height, 270,
GA_DrawInfo, dri,
EGA_Scroller,TRUE,
EGA_AutoIndent,TRUE,
EGA_ShowControls,TRUE,
gad ? GA_Previous : TAG_IGNORE,gad,
GA_ID, 1,
TAG_END);
if (!(win = OpenWindowTags(NULL,WA_Title, "TextEdit - Test",
WA_Height, 300,
WA_Width, 300,
WA_Flags, WFLG_CLOSEGADGET | WFLG_DRAGBAR | WFLG_DEPTHGADGET,
WA_IDCMP, IDCMP_GADGETUP | IDCMP_CLOSEWINDOW,
WA_Gadgets, glist,
TAG_END)))
{
DisposeObject(gad);
FreeGadgets(glist);
}
FreeScreenDrawInfo(scr,dri);
UnlockPubScreen(NULL,scr);
return(win);
}
void HandleWindow(void)
{
struct IntuiMessage *msg;
BOOL done = FALSE;
while(!done)
{
WaitPort(win->UserPort);
while((msg = (struct IntuiMessage *)GetMsg(win->UserPort)) != 0)
{
switch(msg->Class)
{
case IDCMP_CLOSEWINDOW:
done = TRUE;
break;
}
ReplyMsg((struct Message *)msg);
}
}
}
int main(int argc, char **argv)
{
if ((TextEditBase = OpenClass("pTextEdit.gadget",0)) != 0)
{
kprintf("classbase: %lx\n",TextEditBase);
Text2Clipboard(0,"Hallo",5);
if ((win = CreateWindow()) != 0)
{
HandleWindow();
CloseWindow(win);
DisposeObject(gad);
FreeGadgets(glist);
}
CloseLibrary(TextEditBase);
}
return(0);
}