#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <exec/exec.h>
#include <exec/types.h>
#include <intuition/intuition.h>
#include <libraries/mui.h>
#include <mui/TextEditor_mcc.h>
#include <proto/dos.h>
#include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/muimaster.h>
#include <proto/utility.h>
struct Library *MUIMasterBase = NULL;
struct IntuitionBase *IntuitionBase = NULL;
#define REG(x) register __ ## x
#define ASM __asm
#define SAVEDS __saveds
SAVEDS ASM LONG AppMsgFunc(REG(a2) APTR obj, REG(a1) int *x)
{
int y = -1;
get(obj, MUIA_TextEditor_UndoAvailable, &y);
printf("Undo available: %d %d\n", *x, y);
return(0);
}
SAVEDS ASM LONG AppMsgFunc2(REG(a2) APTR obj, REG(a1) int *x)
{
int y = -1;
get(obj, MUIA_TextEditor_RedoAvailable, &y);
printf("Redo available: %d %d\n", *x, y);
return(0);
}
int main(int argc, char *argv[])
{
Object *win, *app, *bt, *editor;
ULONG sigs = 0;
ULONG id;
int flag = 0;
Object *subwin, *parent, *reg;
static const struct Hook AppMsgHook = { { NULL,NULL },(VOID *)AppMsgFunc,NULL,NULL };
static const struct Hook AppMsgHook2 = { { NULL,NULL },(VOID *)AppMsgFunc2,NULL,NULL };
IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 0);
MUIMasterBase = OpenLibrary("muimaster.library", 0);
app = ApplicationObject,
MUIA_Application_Title, "Foo",
MUIA_Application_Base, "xxxxx",
SubWindow, win = WindowObject,
MUIA_Window_Title, "Bar",
WindowContents, VGroup,
Child, VGroup,
Child, editor = TextEditorObject,
MUIA_CycleChain, 1,
End,
Child, bt = SimpleButton("Click"),
End,
End,
End,
End;
DoMethod(bt,MUIM_Notify,MUIA_Pressed,FALSE,app,2,MUIM_Application_ReturnID,1000);
DoMethod(editor, MUIM_Notify, MUIA_TextEditor_UndoAvailable, MUIV_EveryTime, editor, 3, MUIM_CallHook,&AppMsgHook,MUIV_TriggerValue);
DoMethod(editor, MUIM_Notify, MUIA_TextEditor_RedoAvailable, MUIV_EveryTime, editor, 3, MUIM_CallHook,&AppMsgHook2,MUIV_TriggerValue);
DoMethod(win, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
set(win, MUIA_Window_Open, TRUE);
while((id = DoMethod(app,MUIM_Application_NewInput,&sigs)) != MUIV_Application_ReturnID_Quit) {
switch(id) {
case 1000:
DoMethod(editor, MUIM_TextEditor_ARexxCmd, "UNDO");
break;
}
if(sigs) {
sigs = Wait(sigs | SIGBREAKF_CTRL_C);
if (sigs & SIGBREAKF_CTRL_C) break;
}
}
MUI_DisposeObject(app);
if(MUIMasterBase) CloseLibrary(MUIMasterBase);
if(IntuitionBase) CloseLibrary((struct Library *) IntuitionBase);
return 0;
}