GadTools STRING_kind problem

A forum for general AmigaOS 4.x support questions that are not platform-specific
Post Reply
JosDuchIt
Posts: 291
Joined: Sun Jun 26, 2011 5:47 pm
Contact:

GadTools STRING_kind problem

Post by JosDuchIt »

Code: Select all

/* Gadget example 

*/
# define __USE_INLINE__
# include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/gadtools.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <intuition/intuition.h>
#include <libraries/gadtools.h>
#include <stdio.h>
#include <stdlib.h> // exit instead of Exit obsolete

char name[30] = "Joseph";
APTR visual;
/* Type of gadgets to display */
   ULONG Gadgetkinds[3] = {STRING_KIND, INTEGER_KIND, BUTTON_KIND }; /// text entry  not TEXT or NUMBERKIND
struct TextAttr topaz8 = {
   (STRPTR)"topaz.font", 8, 0, 1
   };
/* Data for gadget structures */
   struct NewGadget Gadgetdata[3] = {
   63, 36, 172, 17, (UBYTE *)"Name", &topaz8, 1, PLACETEXT_LEFT, NULL, NULL, 
   62, 60, 175, 17, (UBYTE *)"Age", &topaz8, 2, PLACETEXT_LEFT, NULL,    NULL,
   111, 105, 54, 31, (UBYTE *)"Calc", &topaz8, 3, PLACETEXT_IN, NULL,    NULL 
   };
/* Extra information for gadgets using Tags */
   ULONG GadgetTags[] = {
   (GTST_MaxChars), 256, (GTST_String), name, (STRINGA_Justification), STRINGCENTER , (TAG_DONE),
   (GTNM_Border), TRUE,(GTIN_Number), 3,  (TAG_DONE),   
   (TAG_DONE)
   };
int main() {
      struct Screen *pubScreen;
      struct Window *myWindow;
      struct Gadget *myGadgets[3], *glist=NULL, *gad1;
      int closewin = FALSE, i;
      struct IntuiMessage *msg;
      ULONG msgClass;

      /* Lock screen and get visual info for gadtools */
      if (pubScreen = LockPubScreen(NULL)) {
         if (!(visual = GetVisualInfo(pubScreen,    TAG_DONE))) {
            printf("Failed to get visual info.\n");
            exit(5);
         }
      }
      else {
         printf("Failed to lock screen.\n");
         exit(5);
      }
    /* Create the gadget list */
      if (!(gad1 = CreateContext(&glist))) {
         printf("Failed to create gadtools context.\n");
         exit(5);
      }
      /* Create gadgets specify gadget kind, a Gadget, NewGadget data and extra tag info */
      for (i=0; i<3; i++) {
         Gadgetdata[i].ng_VisualInfo = visual;
         if (myGadgets[i] = gad1 = CreateGadgetA(Gadgetkinds[i], gad1, &Gadgetdata[i], (struct TagItem *)&GadgetTags[i])) {
            printf("Gadget %d created.\n", i);
         }
         else
            printf("Failed to create gadget %d.\n",i);
      }
   
      /* Open window and specify gadget list (glist) */
      myWindow = OpenWindowTags(NULL,
         WA_Left, 10, WA_Top, 15,
         WA_Width, 280, WA_Height, 180,
         WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_GADGETUP,
         WA_Flags, WFLG_SIZEGADGET | WFLG_DRAGBAR    | WFLG_DEPTHGADGET | WFLG_CLOSEGADGET | WFLG_ACTIVATE | WFLG_SMART_REFRESH,
         WA_Gadgets, glist,
         WA_Title, "My Window",
         WA_PubScreenName, "Workbench",
         TAG_DONE);
      GT_RefreshWindow(myWindow, NULL); /* Update window */
   
      while (closewin == FALSE) {
         Wait(1L << myWindow->UserPort->mp_SigBit);
         msg = GT_GetIMsg(myWindow->UserPort);
         msgClass = msg->Class;
         GT_ReplyIMsg(msg);
         if (msgClass == IDCMP_CLOSEWINDOW) {
            closewin = TRUE;
         }
      }
    if (myWindow) CloseWindow(myWindow);
    /* Free gadgets */
    if (glist) FreeGadgets(glist);
   
    if (visual) FreeVisualInfo(visual);
    if (pubScreen) UnlockPubScreen(NULL, pubScreen);
    return(0);
 }

How do i have to make the string center in the STRING_kind gadget ?
(STRINGA_Justification), STRINGCENTER, is not accepted
I followed the gadtools.doc i think?

Solved it:
with
#include <intuition/iobsolete.h>
(STRINGA_Justification), GACT_STRINGCENTER,
Post Reply