#include <stdio.h> #include <string.h> #include <proto/intuition.h> /* Gadtools is needed for GetIMsg and ReplyIMsg */ #include <proto/gadtools.h> /* Exec is needed for Wait function */ #include <proto/exec.h> #include <proto/dos.h> #include <intuition/intuition.h> #include <dos/dostags.h> struct Window *myWindow; struct Gadget *myGadgets[5], *glist=NULL, *gad1; APTR visual; struct TextAttr topaz8 = {(STRPTR)"topaz.font", 8, 0, 1}; /* Data for gadget structures */ struct NewGadget Gadgetdata[] = { {25, 40, 60, 16, (UBYTE *)"1", &topaz8, 1, PLACETEXT_IN, NULL, NULL}, {95, 40, 60, 16, (UBYTE *)"2", &topaz8, 2, PLACETEXT_IN, NULL, NULL}, {165, 40, 60, 16, (UBYTE *)"3", &topaz8, 3, PLACETEXT_IN, NULL, NULL}, {235, 40, 60, 16, (UBYTE *)"4", &topaz8, 4, PLACETEXT_IN, NULL, NULL}, {25, 18, 270, 16, (UBYTE *)" ", &topaz8, 5, PLACETEXT_IN, NULL, NULL} }; int main(int argc, char *argv[]){ struct Screen *pubScreen; int i; struct IntuiMessage *msg; ULONG msgClass; /* Lock screen and get visual info for gadtools */ if(!(pubScreen = LockPubScreen(NULL))){ printf("Failed to lock screen.\n"); return(5); } if(!(visual = GetVisualInfo(pubScreen, TAG_END))){ printf("Failed to get visual info.\n"); return(5); } /* Create the gadget list */ if(!(gad1 = CreateContext(&glist))){ printf("Failed to create gadtools context.\n"); return(5); } /* Create gadgets specify gadget kind, a Gadget, NewGadget data and extra tag info */ for(i=0; i<5; i++) Gadgetdata[i].ng_VisualInfo = visual; myGadgets[0] = gad1 = CreateGadget(BUTTON_KIND, gad1, &Gadgetdata[0], TAG_END); myGadgets[1] = gad1 = CreateGadget(BUTTON_KIND, gad1, &Gadgetdata[1], TAG_END); myGadgets[2] = gad1 = CreateGadget(BUTTON_KIND, gad1, &Gadgetdata[2], TAG_END); myGadgets[3] = gad1 = CreateGadget(BUTTON_KIND, gad1, &Gadgetdata[3], TAG_END); myGadgets[4] = gad1 = CreateGadget(SCROLLER_KIND, gad1, &Gadgetdata[4], GTSC_Total, 255, GTSC_Top, 0, GA_RelVerify, 1, TAG_END); myWindow = OpenWindowTags(NULL, WA_Title, argv[1], WA_Gadgets, glist, WA_Left, 20, WA_Top, 20, WA_Width, 320, WA_Height, 64, WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_GADGETUP, WA_Flags, WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_CLOSEGADGET | WFLG_ACTIVATE, WA_PubScreen, pubScreen, TAG_END); GT_RefreshWindow(myWindow, NULL); /* Update window */ //===================================================== while(1){ /* Run program until window is closed */ Wait(1L << myWindow->UserPort->mp_SigBit); /* Wait for an event! */ msg = GT_GetIMsg(myWindow->UserPort); /* Get message data */ msgClass = msg->Class; /* What has been clicked? */ GT_ReplyIMsg(msg); /* Close message */ if(msgClass == IDCMP_CLOSEWINDOW){ /* Check here if Close Window selected */ break; } if(msgClass == GADGETUP){ struct Gadget *gadAddr; UWORD gadgetid; gadAddr = (struct Gadget *)msg->IAddress; gadgetid = gadAddr->GadgetID; if(gadgetid==1 || gadgetid==2 || gadgetid==3 || gadgetid==4){ printf("gadgetid=%i\n", gadgetid); ULONG position = 30; SetGadgetAttrs(myGadgets[4], myWindow, NULL, GTSC_Top, position, TAG_END); } if(gadgetid==5){ ULONG position = 30; //GetAttrs(myGadgets[4], GTSC_Top, &position, TAG_END); //GetGadgetAttrs(myGadgets[4], myWindow, NULL, GTSC_Top, &position, TAG_END); GetAttr(GTSC_Top, myGadgets[4], &position); printf("position=%i\n", position); } } } CloseWindow(myWindow); /* Close window */ UnlockPubScreen(NULL, pubScreen); return 0; }
@piotr_go, post #1
#define GAD_SCROLLER_ID 10 // wartosc tej stalej wpisujesz w definicji gadzetu // np: {25, 18, 270, 16, (UBYTE *)" ", &topaz8, GAD_SCROLLER_ID, PLACETEXT_IN, NULL, NULL} ...... switch(msg->Class) { case IDCMP_CLOSEWINDOW: QUIT = TRUE; // to zmienna ktora mowi czy chcesz wyjsc z petli glownej odczytu zdarzen break; case IDCMP_MOUSEMOVE: switch(((struct Gadget *) msg->IAddress)->GadgetID) { case GAD_SCROLLER_ID: printf("pozycja skrolera %d\n", msg->Code); break; } }
@Phibrizzo, post #6
@Phibrizzo, post #6
GT_GetGadgetAttrs(myGadgets[5], myWindow, NULL, GTLV_Selected, &position, TAG_END);
GT_SetGadgetAttrs(myGadgets[5], myWindow, NULL, GTLV_Selected, number, TAG_END);
myGadgets[5] = gad1 = CreateGadget(LISTVIEW_KIND, gad1, &Gadgetdata[5], GA_Disabled, 0, GTLV_Top, 2, GTLV_MakeVisible, 4, GTLV_Labels, (ULONG)&file_list, GTLV_Selected, 1, TAG_END);
@piotr_go, post #10
@piotr_go, post #10
@QUAD, post #16
Jest driver do AHI?