Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***************************************************
- * Source: raConvert.c *
- * Program: raConvert *
- * *
- * Tutorial App for AmigaOS 3.2.x *
- * ReAction C coding *
- * *
- * Author: Micha B. 2022 *
- * Web: http://amiga.mbergmann-sh.de *
- * *
- * sc NOSTACKCHECK raConvert.c LINK TO raConvert *
- ****************************************************/
- #define USE_BUILTIN_MATH
- #define USE_SYSBASE
- /* debugging memory */
- /*
- #include <exec/memory.h>
- #include <proto/exec.h>
- //#define MWDEBUG=1
- */
- //#define _DEBUG=1
- #include <memwatch.h> /* To enable memlib, you must #define MWDEBUG to 1 */
- #include <exec/types.h>
- #include <libraries/dos.h>
- #include <workbench/workbench.h>
- #include <workbench/startup.h>
- #include <intuition/classusr.h>
- #include <gadgets/layout.h>
- #include <gadgets/button.h>
- #include <gadgets/string.h>
- #include <classes/window.h>
- #include <classes/requester.h>
- #include <images/label.h>
- #include <images/bevel.h>
- #include <libraries/gadtools.h>
- //#include <clib/icon_protos.h>
- #define __CLIB_PRAGMA_LIBCALL
- #include <proto/alib.h>
- #include <proto/exec.h>
- #include <proto/dos.h>
- #include <proto/layout.h>
- #include <proto/window.h>
- #include <proto/requester.h>
- #include <proto/string.h>
- #include <proto/label.h>
- #include <proto/bevel.h>
- #include <proto/intuition.h>
- #include <proto/button.h>
- #include <proto/icon.h>
- #include <pragmas/requester_pragmas.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "version.h"
- /* --- Bases --- */
- struct IntuitionBase *IntuitionBase;
- struct Library *IconBase;
- struct Library *WindowBase;
- struct Library *LayoutBase;
- struct Library *ButtonBase;
- struct Library *LabelBase;
- struct Library *StringBase;
- struct Library *BevelBase;
- struct Library *RequesterBase;
- void __stdargs kprintf(const char *, ...);
- struct Hook IDCMPHook;
- /* --- ASL Hook function */
- void __saveds __asm processIDCMP(register __a0 struct Hook *hook,
- register __a2 Object * obj,
- register __a1 struct IntuiMessage *msg)
- {
- switch (msg->Class)
- {
- case IDCMP_GADGETDOWN:
- /* Do something about it */
- break;
- }
- }
- /* here we define a struct for our menu entries */
- struct NewMenu menu[] =
- {
- { NM_TITLE, "Project", 0, 0, 0, 0 }, /* first menu */
- { NM_ITEM, "About raConvert", "?", 0, 0, 0 },
- { NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL},
- { NM_ITEM, "GadgetHelp", "0", CHECKIT | CHECKED | MENUTOGGLE, 0, 0},
- { NM_ITEM, NM_BARLABEL, NULL, NULL, NULL, NULL},
- { NM_ITEM, "Quit", "Q", MIF_SHIFTCOMMSEQ, 0, 0 },
- /* --- more Menus might be constructed just the same way... --- */
- { NM_END, NULL, 0, 0, 0, 0 } /* MN_END finalizes Menu construction */
- };
- /* --- Window-related --- */
- struct Window *intuiwin = NULL; /* Window structure */
- Object *windowObject = NULL; /* our Window object */
- /* --- Layout Objects --- */
- Object *topLayout = NULL; /* holds first Label */
- Object *string1Layout = NULL; /* holds Label + first StringGadget */
- Object *string2Layout = NULL; /* holds Label + second StringGadget */
- Object *buttonLayout = NULL; /* holds two ButtonGadgets */
- Object *mainLayout = NULL; /* our main Layout Object */
- /* --- Requester Objects --- */
- Object *aboutReq = NULL;
- Object *quitReq = NULL;
- Object *emptyReq = NULL;
- Object *noasciiReq = NULL;
- /* --- Gadget Objects --- */
- Object *inString = NULL;
- Object *outString = NULL;
- Object *clearButton = NULL;
- Object *convertButton = NULL;
- Object *helpButton = NULL;
- /* --- Gadget IDs (for IDCMP handling) --- */
- #define GID_INSTRING 1
- #define GID_OUTSTRING 2
- #define GID_CLEARBUTTON 3
- #define GID_CONVERTBUTTON 4
- #define GID_HELPBUTTON 5
- /* --- define menu IDs --- */
- #define MN_ABOUT 63488
- #define MN_GADGETHELP 63552
- #define MN_QUIT 63616
- /* --- Function Prototypes --- */
- void cleanexit(Object * windowObject); /* exit gracefully */
- void processEvents(Object * windowObject); /* handle IDCMP events */
- void clearGadgets(void); /* empty StringGadgets */
- void doASCII(void); /* convert character to its ASCII Code */
- int main(void)
- {
- /* --- declare Titles for Screen and Window from Constants in "version.h" --- */
- char screentitle[32];
- char windowtitle[32];
- struct MsgPort *appPort; /* we need a message port for Intuition messages */
- /* --- Let´s open needed Libraries --- */
- if (!(IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 47)))
- cleanexit(NULL);
- if (!(IconBase = (struct Library *) OpenLibrary("icon.library", 47)))
- cleanexit(NULL);
- if (!(WindowBase = OpenLibrary("window.class", 47)))
- cleanexit(NULL);
- if (!(LayoutBase = OpenLibrary("gadgets/layout.gadget", 47)))
- cleanexit(NULL);
- if (!(ButtonBase = OpenLibrary("gadgets/button.gadget", 47)))
- cleanexit(NULL);
- if (!(StringBase = OpenLibrary("gadgets/string.gadget", 47)))
- cleanexit(NULL);
- if (!(LabelBase = OpenLibrary("images/label.image", 47)))
- cleanexit(NULL);
- if (!(BevelBase = OpenLibrary("images/bevel.image", 47)))
- cleanexit(NULL);
- if (!(RequesterBase = OpenLibrary("requester.class", 47)))
- cleanexit(NULL);
- /* --- Requesters --- */
- aboutReq = NewObject( REQUESTER_GetClass(), NULL,
- REQ_TitleText, "About raConvert",
- REQ_Type, REQTYPE_INFO,
- REQ_Image, REQIMAGE_INFO,
- REQ_BodyText, "raConvert is a ReAction-based graphical \ninterface for ASCII code conversion.\n\n AmigaOS 3.2.x is needed to run it.\n\nAuthor: Micha B. 2022\nWeb: www.amiga.mbergmann-sh.de ",
- REQ_GadgetText, "Understood",
- TAG_DONE);
- emptyReq = NewObject( REQUESTER_GetClass(), NULL,
- REQ_TitleText, "raConvert User Error",
- REQ_Type, REQTYPE_INFO,
- REQ_Image, REQIMAGE_WARNING,
- REQ_BodyText, "You did not enter a character.",
- REQ_GadgetText, "OK",
- TAG_DONE);
- noasciiReq = NewObject( REQUESTER_GetClass(), NULL,
- REQ_TitleText, "raConvert ASCII Error",
- REQ_Type, REQTYPE_INFO,
- REQ_Image, REQIMAGE_INFO,
- REQ_BodyText, "That does not look like an ASCII character.\n Maybe a german Umlaut or some other special\ncharacter? ",
- REQ_GadgetText, "OK",
- TAG_DONE);
- quitReq = NewObject( REQUESTER_GetClass(), NULL,
- REQ_TitleText, "Quit raConvert",
- REQ_Type, REQTYPE_INFO,
- REQ_Image, REQIMAGE_QUESTION,
- REQ_BodyText, " Really terminate the program? ",
- REQ_GadgetText, "OK|Cancel",
- REQ_EvenButtons, TRUE,
- TAG_DONE);
- /*
- * Define our Gadgets:
- --- This is our first StringGadget (takes character to convert) --- */
- inString = NewObject( STRING_GetClass(), NULL,
- GA_ID, GID_INSTRING,
- GA_RelVerify, TRUE,
- STRINGA_TextVal, "", /* this Tag holds the value of the Gadget! */
- STRINGA_MinVisible, 4, /* this determines Gadget´s size */
- STRINGA_MaxChars, 2, /* we want the user to input max. 1 charakter */
- STRINGA_Justification, GACT_STRINGCENTER, /* center text in Gadget */
- TAG_DONE);
- /* --- This is our second StringGadget (shows converted ASCII code) --- */
- outString = NewObject( STRING_GetClass(), NULL,
- GA_ID, GID_OUTSTRING,
- GA_RelVerify, TRUE,
- STRINGA_TextVal, "", /* this Tag holds the value of the Gadget! */
- STRINGA_MinVisible, 4,
- STRINGA_MaxChars, 4, /* we need 3 characters for an ASCII-Code to display */
- STRINGA_Justification, GACT_STRINGCENTER, /* center text in Gadget */
- TAG_DONE);
- /* --- define clearButton instance (first ButtoGadget) --- */
- clearButton = NewObject( BUTTON_GetClass(), NULL,
- GA_ID, GID_CLEARBUTTON,
- GA_RelVerify, TRUE,
- GA_Text, "C_lear",
- BUTTON_TextPadding, TRUE,
- GA_TabCycle, TRUE,
- TAG_DONE);
- /* --- define convertButton instance (second ButtonGadget) --- */
- convertButton = NewObject( BUTTON_GetClass(), NULL,
- GA_ID, GID_CONVERTBUTTON,
- GA_RelVerify, TRUE,
- GA_Text, "_Convert",
- BUTTON_TextPadding, TRUE,
- GA_TabCycle, TRUE,
- TAG_DONE);
- /* --- this is the Label that will show Help messages ---*/
- helpButton = NewObject( BUTTON_GetClass(), NULL,
- GA_ID, GID_HELPBUTTON,
- GA_ReadOnly, TRUE,
- GA_Text, "GadgetHelp is active",
- BUTTON_Justification, LJ_CENTRE,
- TAG_DONE);
- /*
- * Define our Layouts:
- --- This is our beveled horizontal Layout that shows up first --- */
- topLayout = NewObject(LAYOUT_GetClass(), NULL,
- LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
- //LAYOUT_DeferLayout, TRUE,
- LAYOUT_SpaceInner, TRUE,
- LAYOUT_SpaceOuter, TRUE,
- LAYOUT_BevelStyle, BVS_GROUP,
- /* --- Pseudo-Spacer! --- */
- LAYOUT_AddImage, NewObject( LABEL_GetClass(), NULL, LABEL_Text, "",
- TAG_END),
- CHILD_WeightedWidth, 98,
- /* --- Add Label --- */
- LAYOUT_AddImage, NewObject( LABEL_GetClass(), NULL,
- LABEL_Text, "Please enter a character\nand then press ´Convert´ or <Return>",
- LABEL_Justification, LJ_CENTRE,
- TAG_END),
- CHILD_WeightedWidth, 0,
- /* --- Pseudo-Spacer! --- */
- LAYOUT_AddImage, NewObject( LABEL_GetClass(), NULL, LABEL_Text, "",
- TAG_END),
- CHILD_WeightedWidth, 98,
- TAG_DONE);
- /* --- This is our 1. non-beveled horizontal Layout holds first Label/StringGadget pair --- */
- string1Layout = NewObject(LAYOUT_GetClass(), NULL,
- LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
- //LAYOUT_DeferLayout, TRUE,
- LAYOUT_SpaceInner, TRUE,
- LAYOUT_SpaceOuter, TRUE,
- LAYOUT_BevelStyle, BVS_NONE, /* you could as well leave this Tag out! */
- /* --- Add Label -- */
- LAYOUT_AddImage, NewObject( LABEL_GetClass(), NULL,
- LABEL_Text, "Enter character you wish to convert:",
- LABEL_Justification, LJ_LEFT,
- TAG_END),
- CHILD_WeightedWidth, 90,
- /* --- Add 1. StringGadget --- */
- LAYOUT_AddChild, inString,
- CHILD_WeightedHeight, 0,
- CHILD_WeightedWidth, 0, /* make 1. StringGadget non-expanding */
- TAG_DONE);
- /* --- This is our 2. non-beveled horizontal Layout holds second Label/StringGadget pair --- */
- string2Layout = NewObject(LAYOUT_GetClass(), NULL,
- LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
- //LAYOUT_DeferLayout, TRUE,
- LAYOUT_SpaceInner, TRUE,
- LAYOUT_SpaceOuter, TRUE,
- LAYOUT_BevelStyle, BVS_NONE, /* you could as well leave this Tag out! */
- /* --- Add Label -- */
- LAYOUT_AddImage, NewObject( LABEL_GetClass(), NULL,
- LABEL_Text, "The ASCII Code for this character is:",
- LABEL_Justification, LJ_LEFT,
- TAG_END),
- CHILD_WeightedWidth, 90,
- /* --- Add 2. StringGadget --- */
- LAYOUT_AddChild, outString,
- CHILD_WeightedHeight, 0,
- CHILD_WeightedWidth, 0, /* make 2. StringGadget non-expanding */
- TAG_DONE);
- /* --- This is our 2. non-beveled horizontal Layout holds second Label/StringGadget pair --- */
- buttonLayout = NewObject(LAYOUT_GetClass(), NULL,
- LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
- //LAYOUT_DeferLayout, TRUE,
- LAYOUT_SpaceInner, TRUE,
- LAYOUT_SpaceOuter, TRUE,
- LAYOUT_TopSpacing, 5, /* make some extra space! */
- LAYOUT_BottomSpacing, 7,
- LAYOUT_BevelStyle, BVS_SBAR_VERT, /* puts a thin bevel frame around the Layout */
- LAYOUT_Label, "Control Panel", /* Bevel Text... */
- LAYOUT_LabelPlace, BVJ_TOP_CENTER, /* ...placed on Top of Bevel, centered */
- /* --- Pseudo-Spacer! --- */
- LAYOUT_AddImage, NewObject( LABEL_GetClass(), NULL, LABEL_Text, "",
- TAG_END),
- CHILD_WeightedWidth, 6,
- /* --- Add 1. ButtonGadget --- */
- LAYOUT_AddChild, clearButton,
- CHILD_WeightedHeight, 0,
- CHILD_WeightedWidth, 42,
- /* --- Pseudo-Spacer! --- */
- LAYOUT_AddImage, NewObject( LABEL_GetClass(), NULL, LABEL_Text, "",
- TAG_END),
- CHILD_WeightedWidth, 6,
- /* --- Add 2. ButtonGadget --- */
- LAYOUT_AddChild, convertButton,
- CHILD_WeightedHeight, 0,
- CHILD_WeightedWidth, 42,
- /* --- Pseudo-Spacer! --- */
- LAYOUT_AddImage, NewObject( LABEL_GetClass(), NULL, LABEL_Text, "",
- TAG_END),
- CHILD_WeightedWidth, 6,
- TAG_DONE);
- /* --- This is our Main Layout. It holds all capsulated sub layouts --- */
- mainLayout = NewObject(LAYOUT_GetClass(), NULL,
- LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
- LAYOUT_DeferLayout, TRUE,
- LAYOUT_SpaceInner, TRUE,
- LAYOUT_SpaceOuter, TRUE,
- //LAYOUT_BevelStyle, BVS_BUTTON,
- /* -- Add titeling Label -- */
- LAYOUT_AddChild, topLayout,
- CHILD_WeightedHeight, 0,
- CHILD_WeightedWidth, 100,
- /* -- Add first Label/StringGadget pair --- */
- LAYOUT_AddChild, string1Layout,
- CHILD_WeightedHeight, 0,
- CHILD_WeightedWidth, 100,
- /* -- Add second Label/StringGadget pair -- */
- LAYOUT_AddChild, string2Layout,
- CHILD_WeightedHeight, 0,
- CHILD_WeightedWidth, 100,
- /* -- Add two-Button Layout -- */
- LAYOUT_AddChild, buttonLayout,
- CHILD_WeightedHeight, 0,
- CHILD_WeightedWidth, 100,
- /* -- finaly, add a "StatusBar" -- */
- LAYOUT_AddChild, helpButton,
- CHILD_WeightedHeight, 0,
- CHILD_WeightedWidth, 100,
- TAG_DONE);
- /* --- initialize IDCMPHook for listening to IDCMP Messages --- */
- IDCMPHook.h_Entry = (ULONG(*)())processIDCMP;
- IDCMPHook.h_SubEntry = NULL;
- IDCMPHook.h_Data = NULL;
- appPort = CreateMsgPort();
- /* --- Fill our window- and screen title with life... --- */
- sprintf(windowtitle, "%s v%s.%s", PROGRAMNAME, VERSION, SUBVERSION);
- sprintf(screentitle, "%s v%s.%s.%s %s", PROGRAMNAME, VERSION, SUBVERSION, REVISION, "by Micha B.");
- /* --- define our Window Object --- */
- windowObject = NewObject(WINDOW_GetClass(), NULL,
- WINDOW_Position, WPOS_CENTERSCREEN,
- WA_Activate, TRUE,
- WA_Title, (ULONG) windowtitle, /* here goes our constructed window title */
- WA_ScreenTitle, (ULONG) screentitle, /* here goes our constructed screen title */
- WA_DragBar, TRUE,
- WA_CloseGadget, TRUE,
- WA_DepthGadget, TRUE,
- WA_SizeGadget, TRUE,
- WA_InnerWidth, 250,
- WA_InnerHeight, 50,
- WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_GADGETUP | IDCMP_MENUPICK | IDCMP_RAWKEY | IDCMP_ACTIVEWINDOW,
- WINDOW_GadgetHelp, TRUE, /* enable Gadget help functionallity */
- WINDOW_Layout, mainLayout,
- WINDOW_IconifyGadget, TRUE,
- WINDOW_IDCMPHook, &IDCMPHook,
- WINDOW_IDCMPHookBits, IDCMP_GADGETDOWN | IDCMP_MENUPICK | IDCMP_RAWKEY | IDCMP_ACTIVEWINDOW,
- WINDOW_AppPort, appPort,
- WINDOW_AppWindow, TRUE,
- //WINDOW_Icon, GetDiskObject("PROGDIR:raConvert"), /* icon that is shown when app is iconified */
- WA_NewLookMenus, TRUE,
- WINDOW_NewMenu, menu, /* here we attach our formerly defined window menu */
- TAG_DONE);
- /* --- was our Window Object created correctly? --- */
- if (!windowObject)
- cleanexit(NULL);
- /* --- Try to open our Window! --- */
- if (!(intuiwin = (struct Window *) DoMethod(windowObject, WM_OPEN, NULL)))
- cleanexit(windowObject);
- /* --- let´s activate inString for user input (Focus) --- */
- ActivateLayoutGadget((struct Gadget *)mainLayout, intuiwin, NULL, (ULONG)inString);
- /* --- Handle IDCMP messages --- */
- processEvents(windowObject);
- /* --- After receiving a WMHI_CLOSEWINDOW message, close our Window --- */
- DoMethod(windowObject, WM_CLOSE);
- /* --- Finally, free Requester Objects ---- */
- /* IMPORTANT! You MUST free all declared */
- /* Requesters, even if you do not use them. */
- /* Otherwise your program will crash when */
- /* restarted! */
- DisposeObject( noasciiReq );
- DisposeObject( aboutReq );
- DisposeObject( quitReq );
- DisposeObject( emptyReq );
- /* --- clean up things and quit the program --- */
- cleanexit(windowObject);
- } /* main() END */
- /*
- * Function: clearGadgets()
- * empty the StringGadgets
- */
- void clearGadgets(void)
- {
- /* --- empty the StringGadgets... --- */
- SetGadgetAttrs( (struct Gadget *)inString, intuiwin, NULL, STRINGA_TextVal, "", TAG_END );
- SetGadgetAttrs( (struct Gadget *)outString, intuiwin, NULL, STRINGA_TextVal, "", TAG_END );
- /* --- ...and give the Focus back to our first StringGadget for input! --- */
- ActivateLayoutGadget((struct Gadget *)mainLayout, intuiwin, NULL, (ULONG)inString);
- }
- /*
- * Function: doASCII()
- * get inString content, convert to ASCII code, put result into outString
- */
- void doASCII(void)
- {
- char *inCharacter;
- char *outCharacter = " ";
- int i = 0;
- /* --- get character from inString StringGadget --- */
- GetAttr(STRINGA_TextVal, (APTR)inString, (ULONG *)&inCharacter);
- /* --- if not empty, convert and put into outString StringGadget --- */
- if(!(strcmp((char const *)inCharacter, "")))
- {
- OpenRequester(emptyReq, intuiwin);
- clearGadgets();
- }
- else
- {
- i = (int)inCharacter[0];
- /* --- convert! --- */
- sprintf(outCharacter, "%d", (int)inCharacter[0]);
- /* --- put result into outString --- */
- SetGadgetAttrs( (struct Gadget *)outString, intuiwin, NULL, STRINGA_TextVal, outCharacter, TAG_END );
- /* --- Umlaut or non-ASCII? ---*/
- if (i <= 0)
- {
- OpenRequester(noasciiReq, intuiwin);
- clearGadgets();
- }
- }
- } /* doASCII() END */
- /*
- * Function: processEvents()
- * here, all event handling is done
- */
- void processEvents(Object * windowObject)
- {
- ULONG windowsignal;
- ULONG receivedsignal;
- ULONG result;
- ULONG code;
- ULONG req_button;
- BOOL end = FALSE;
- GetAttr(WINDOW_SigMask, windowObject, &windowsignal);
- while (!end)
- {
- receivedsignal = Wait(windowsignal);
- while ((result = DoMethod(windowObject, WM_HANDLEINPUT, &code)) != WMHI_LASTMSG)
- {
- switch (result & WMHI_CLASSMASK)
- {
- /* --- Window IDCMP messages --- */
- case WMHI_CLOSEWINDOW:
- req_button = OpenRequester(quitReq, intuiwin);
- if(req_button)
- end = TRUE;
- break;
- case WMHI_ICONIFY:
- DoMethod(windowObject, WM_ICONIFY, NULL);
- #ifdef _DEBUG
- kprintf("WMHI_ICONIFY - WARNING: Crash expected.\n");
- #endif
- break;
- case WMHI_UNICONIFY:
- DoMethod(windowObject, WM_OPEN, NULL);
- /* --- ...and give the Focus back to our first StringGadget for input! --- */
- ActivateLayoutGadget((struct Gadget *)mainLayout, intuiwin, NULL, (ULONG)inString);
- #ifdef _DEBUG
- kprintf("WMHI_UNICONIFY - WARNING: Crash expected.\n");
- #endif
- break;
- case WMHI_ACTIVE:
- /* --- give the Focus back to our first StringGadget for input! --- */
- ActivateLayoutGadget((struct Gadget *)mainLayout, intuiwin, NULL, (ULONG)inString);
- break;
- /* --- Menu IDCMP messages --- */
- case WMHI_MENUPICK:
- /* Use this to find out menu entry addresses and put them in #defines: */
- #ifdef _DEBUG
- kprintf("\nSome Menu picked.\n");
- kprintf("Entry´s Adress: %ld\n",result & WMHI_MENUMASK);
- #endif
- switch (result & WMHI_MENUMASK)
- {
- case MN_ABOUT:
- /* --- display about message... --- */
- req_button = OpenRequester(aboutReq, intuiwin);
- /* --- ...and give the Focus back to our first StringGadget for input! --- */
- ActivateLayoutGadget((struct Gadget *)mainLayout, intuiwin, NULL, (ULONG)inString);
- break;
- case MN_GADGETHELP:
- /* --- find out if menu entry is checked --- */
- break;
- case MN_QUIT:
- /* --- ask if user wants to quit... --- */
- req_button = OpenRequester(quitReq, intuiwin);
- if(req_button)
- end = TRUE;
- break;
- } /* switch WMHI_MENUMASK */
- break;
- case WMHI_GADGETUP:
- #ifdef _DEBUG
- kprintf("GadgetUP!\n");
- #endif
- switch (result & WMHI_GADGETMASK)
- {
- case GID_INSTRING:
- doASCII();
- break;
- case GID_CLEARBUTTON:
- clearGadgets();
- break;
- case GID_CONVERTBUTTON:
- doASCII();
- break;
- } /* switch WMHI_GADGETMASK*/
- break;
- case WMHI_GADGETHELP:
- {
- STRPTR helptext;
- /* A gadget help message informs the application about the gadget
- * under the mouse pointer. The code WORD is set to the value the
- * gadget returned. Result code contains the ID of the gadget,
- * or NULL (not in the window) or WMHI_GADGETMASK (not over a gadget).
- */
- switch(result & WMHI_GADGETMASK)
- {
- case GID_INSTRING:
- helptext = "Insert here: Character to convert";
- break;
- case GID_OUTSTRING:
- helptext = "Show ASCII-Code";
- break;
- case GID_CLEARBUTTON:
- helptext = "Clear input and result";
- break;
- case GID_CONVERTBUTTON:
- helptext = "Start Conversion to ASCII-Code";
- break;
- default:
- helptext = "";
- break;
- }
- /*
- if (SetGadgetAttrs( GL[G_Help], Win, NULL, GA_Text, helptext, TAG_END ))
- RefreshGList(GL[G_Help], Win, NULL, 1); */
- if(SetGadgetAttrs( (struct Gadget *)helpButton, intuiwin, NULL, GA_Text, helptext, TAG_END ))
- RefreshGadgets((struct Gadget *)helpButton, intuiwin, NULL);
- }
- break;
- } /* switch WMHI_CLASSMASK */
- } /* while result */
- } /* while !end */
- } /* processEvent END */
- /*
- * Function: cleanexit()
- * here we clean up things before exiting
- */
- void cleanexit(Object * windowObject)
- {
- /* --- if theres a valid Window Object... --- */
- if (windowObject)
- DisposeObject(windowObject); /* ... we will dispose it.*/
- /* --- Afterwards, we´ll close all opened Libraries. --- */
- CloseLibrary((struct Library *) IconBase);
- CloseLibrary((struct Library *) IntuitionBase);
- CloseLibrary(RequesterBase);
- CloseLibrary(BevelBase);
- CloseLibrary(LabelBase);
- CloseLibrary(StringBase);
- CloseLibrary(ButtonBase);
- CloseLibrary(WindowBase);
- CloseLibrary(LayoutBase);
- exit(0);
- } /* cleanexit() END */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement