home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.amiga.programmer
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!torn!nott!cu23.crl.aecl.ca!wl.aecl.ca!taylorm
- From: taylorm@wl.aecl.ca
- Subject: Listview slider problem (Code included)
- Message-ID: <7NOV92.13340477@wl.aecl.ca>
- Sender: news@cu23.crl.aecl.ca (USENET News System)
- Nntp-Posting-Host: wc4.wl.aecl.ca
- Organization: AECL RESEARCH
- Date: Sat, 7 Nov 1992 19:34:04 GMT
- Lines: 272
-
- Here is the source code for a program that opens a window with a Listview
- gadget in it. The problem is that the slider on the listview does not
- render properly. The slider does, however, function properly in all other
- respects. The slider appears in blue and always seems to be full height.
-
- This code is part of a much larger program with other gadgets that function
- and look proper. I removed the rest of the code to make the bug easier to
- find.
-
- I am only posting this as a final resort. I have agonized over it for long
- hours with no luck. I have also poured through the examples in the RKMs.
- I have also checked it against the program "Demo" by Miller in the August
- 1991 Amigaworld Tech Journal which does compile and run properly.
- Anyone who could find the bug would receive my enternal gratitude and
- preserve my sanity.
-
- This should compile effortlessly under SAS/C 6.0.
-
- /*****************/
- /* Include Files */
- /*****************/
-
- #include <exec/types.h>
- #include <exec/memory.h>
- #include <exec/lists.h>
- #include <intuition/intuition.h>
- #include <intuition/imageclass.h>
- #include <intuition/gadgetclass.h>
- #include <libraries/gadtools.h>
- #include <clib/alib_protos.h>
- #include <clib/exec_protos.h>
- #include <clib/graphics_protos.h>
- #include <clib/intuition_protos.h>
- #include <clib/gadtools_protos.h>
- #include <stdio.h>
-
-
-
- struct List stack; /* Exec list structure for stack */
-
- long win_width = 221; /* Window width */
- long win_innerheight = 179; /* Inner height of window */
- long x_coord = 0; /* Coordinates for window to open at */
- long y_coord = 0;
-
- struct TextAttr Topaz80 = { "topaz.font", 8, 0, 0, };
- /* Font definition */
-
- struct Library *IntuitionBase; /* Pointers to libraries */
- struct Library *GfxBase;
- struct Library *GadToolsBase;
-
- struct Screen *calcsc = NULL; /* Screen pointer */
- struct Window *calcwin = NULL; /* Window pointer */
-
- struct Gadget *glist = NULL;
- void *vi; /* VisualInfo pointer */
-
- struct Remember *rmem = NULL;
-
- char *month_labels[] = {
- "January", "February", "March", "April", "May", "June", "July",
- "August", "September", "October", "November", "December", NULL
- };
-
-
- /***************/
- /* Subprograms */
- /***************/
-
-
- VOID errorMessage(char *message)
- {
- printf("%s\n",message);
- }
-
-
- /* Set up Gadgets */
- struct Gadget *createGadgets(UWORD topborder)
- {
- struct NewGadget ng;
- struct Gadget *gad;
- struct Node *node;
- int index;
-
- gad = CreateContext(&glist);
-
- NewList(&stack); /* Initialize Global Variables */
-
- index = 0;
- while (month_labels[index])
- {
- node = (struct Node *)AllocRemember(&rmem, sizeof(struct Node),
- MEMF_CLEAR);
- /* if (!node)
- abort("Couldn't allocate LISTVIEW List."); */
-
- node->ln_Name = month_labels[index++];
- AddTail(&stack, node);
- }
-
- ng.ng_LeftEdge = 10;
- ng.ng_Width = 201;
- ng.ng_GadgetText = NULL;
- ng.ng_TextAttr = &Topaz80;
- ng.ng_VisualInfo = vi;
- ng.ng_TopEdge = 7+topborder;
- ng.ng_Height = 80;
- ng.ng_GadgetID = 0;
- ng.ng_Flags = 0;
-
- gad = CreateGadget (LISTVIEW_KIND, gad, &ng,
- GTLV_Labels, &stack,
- GTLV_ReadOnly, TRUE,
- GTLV_ScrollWidth, 18,
- GTLV_Top, 1,
- LAYOUTA_Spacing, 1,
- TAG_END);
-
- return(gad);
- }
-
-
- VOID process_window_events(VOID)
- {
- struct IntuiMessage *imsg;
- ULONG imsgClass;
- UWORD imsgCode;
- struct Gadget *gad;
- BOOL terminated = FALSE;
-
- while (!terminated)
- {
- Wait (1 << calcwin->UserPort->mp_SigBit);
-
- while ((!terminated) &&
- (imsg = GT_GetIMsg(calcwin->UserPort)))
- {
- gad = (struct Gadget *)imsg->IAddress;
-
- imsgClass = imsg->Class;
- imsgCode = imsg->Code;
-
- GT_ReplyIMsg(imsg);
-
- switch (imsgClass)
- {
- case IDCMP_GADGETDOWN:
- break;
- case IDCMP_GADGETUP:
- break;
- case IDCMP_CLOSEWINDOW:
- terminated = TRUE;
- break;
- case IDCMP_REFRESHWINDOW:
- GT_BeginRefresh(calcwin);
- GT_EndRefresh(calcwin, TRUE);
- break;
- }
- }
- }
- }
-
-
- VOID gadtoolsWindow(int argc, char **argv)
- {
- struct TextFont *font;
- UWORD topborder;
-
-
- if (NULL == (font = OpenFont(&Topaz80)))
- errorMessage( "Failed to open Topaz 80");
- else
- {
- if (NULL == (calcsc = LockPubScreen("Workbench")))
- errorMessage( "Couldn't lock default public screen");
- else
- {
- if (NULL ==(vi = GetVisualInfo(calcsc, TAG_END)))
- errorMessage( "GetVisualInfo() failed");
- else
- {
- topborder = calcsc->WBorTop + (calcsc->Font->ta_YSize + 1);
-
- if (NULL == createGadgets(topborder))
- errorMessage ( "createAllGadgets() failed");
- else
- {
- if (NULL == (calcwin = OpenWindowTags(NULL,
- WA_Left, x_coord,
- WA_Top, y_coord,
- WA_Title, "Listview test",
- WA_Gadgets, glist,
- WA_AutoAdjust, FALSE,
- WA_Width, win_width,
- WA_InnerHeight, win_innerheight,
- WA_DragBar, TRUE,
- WA_DepthGadget, TRUE,
- WA_Activate, TRUE,
- WA_CloseGadget, TRUE,
- WA_SizeGadget, FALSE,
- WA_SimpleRefresh, TRUE,
- WA_DetailPen, -1,
- WA_BlockPen, -1,
- WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_REFRESHWINDOW |
- LISTVIEWIDCMP,
- WA_PubScreen, calcsc,
- TAG_END)))
- errorMessage( "OpenWindow() failed");
- else
- {
- /*AddGList(calcwin, glist, (UWORD)-1, (UWORD)-1, NULL); */
-
- /* AddGList(calcwin, &CUST_SQRT, ~0, 6L, NULL); */
- RefreshGList(glist, calcwin, NULL, (UWORD)-1);
-
- GT_RefreshWindow(calcwin, NULL);
-
- process_window_events();
-
- /* clear_stack(); */
-
- CloseWindow(calcwin);
- }
- }
- FreeGadgets(glist);
- FreeVisualInfo(vi);
- }
- UnlockPubScreen(NULL, calcsc);
- }
- CloseFont(font);
- }
- }
-
-
- /* Open Libraries and run main code */
- VOID main(int argc, char **argv)
- {
- if (NULL == (IntuitionBase = OpenLibrary("intuition.library", 37)))
- errorMessage( "Requires V37 intuition.library");
- else
- {
- if (NULL == (GfxBase = OpenLibrary("graphics.library", 37)))
- errorMessage ("Requires V37 graphics.library");
- else
- {
- if (NULL ==(GadToolsBase = OpenLibrary("gadtools.library", 37)))
- errorMessage( "Requires V37 gadtools.library");
- else
- {
- gadtoolsWindow(argc, argv);
-
- if (rmem) FreeRemember(&rmem, TRUE);
-
- CloseLibrary(GadToolsBase);
- }
- CloseLibrary(GfxBase);
- }
- CloseLibrary(IntuitionBase);
- }
- }
-
-
-
- -------Cut-------
-
- *****************************************************************************
- In search of the virtual world * /\/\ike Taylor
- * mataylor@undergrad.math.uwaterloo.ca
- Sometimes real is too real * taylorm@wl.aecl.ca
- *****************************************************************************
-
-