English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System

 
 
Thread Tools
Old 23 September 2016, 05:33   #1
Thorham
Computer Nerd
 
Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,751
GadTools ListView questions.

How do I get messages from a GadTools listview scroll bar and arrow keys? I have working code that allows selecting listview items with the cursor keys, but I can't get the scroll bar and arrow keys to send any messages.
Thorham is offline  
Old 23 September 2016, 10:41   #2
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
I don't think the Listview gadget passes those messages on, but first make sure your window has WFLG_REPORTMOUSE set and you're looking for IDCMP_MOUSEMOVE and IDCMP_INTUITICKS as these are needed for reading scrollbars. If that doesn't pass the messages through to your window, perhaps you just need to poll the Listview every time you get an Intuiticks message and see what the GTLV_Top value is. Not ideal but it should work.
Daedalus is online now  
Old 23 September 2016, 17:58   #3
Thorham
Computer Nerd
 
Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,751
Quote:
Originally Posted by Daedalus View Post
I don't think the Listview gadget passes those messages on
I think you may be right.

Quote:
Originally Posted by Daedalus View Post
If that doesn't pass the messages through to your window, perhaps you just need to poll the Listview every time you get an Intuiticks message and see what the GTLV_Top value is. Not ideal but it should work.
I was afraid I'd have to do something like that.

Thanks
Thorham is offline  
Old 23 September 2016, 19:10   #4
Thorham
Computer Nerd
 
Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,751
Anyone else have any ideas?
Thorham is offline  
Old 23 September 2016, 19:42   #5
Thorham
Computer Nerd
 
Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,751
Solved it. You can just calculate the top item from the selected item and the mouse position.
Thorham is offline  
Old 24 September 2016, 17:52   #6
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 6,985
Why don't you use the GTLV_Top attribute?
thomas is offline  
Old 24 September 2016, 19:48   #7
Thorham
Computer Nerd
 
Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,751
Quote:
Originally Posted by thomas View Post
Why don't you use the GTLV_Top attribute?
Because I didn't find a way to read it (just did: GT_GetGadgetAttrs). It's not in the AOS2.x documentation (which is why I didn't find it at first), because it's 3.x, and since it's 3.x only, I'm not using it. This stuff should just work on 2.x too.

Last edited by Thorham; 24 September 2016 at 20:19.
Thorham is offline  
Old 25 September 2016, 09:50   #8
bubbob42
Registered User
 
Join Date: Oct 2012
Location: Germany
Posts: 585
Hm, it's your decision, but nowadays ppl seem to have either 3.x or 1.3. Except for some A600s with soldered kick 2.x.
bubbob42 is offline  
Old 25 September 2016, 21:06   #9
Thorham
Computer Nerd
 
Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,751
Quote:
Originally Posted by bubbob42 View Post
Hm, it's your decision, but nowadays ppl seem to have either 3.x or 1.3. Except for some A600s with soldered kick 2.x.
While that's probably true, I see no reason to make this thing not work under 2.x, especially since it's written for use with FrexxEd, which is 2.x compatible.
Thorham is offline  
Old 28 March 2021, 01:31   #10
mateusz_s
Registered User
 
Join Date: Jan 2020
Location: Poland
Posts: 181
Quote:
Originally Posted by thomas View Post
Why don't you use the GTLV_Top attribute?
Another LISTVIEW GADGET question. I have created listview and filled it with some data.. but I can't select anything or even scroll, the scroll bar works itself, but not scrolling the content..

I noticed that listview getting the messages, for example I can close the application if I click on the listview.. here is my code:

Also I spent a lot of time, because nothis was showing in the listview, until I refreshed the window after creation..


Code:
int  APP_Init_Window()
{
	if (!(APP_pubscreen = LockPubScreen(NULL))) 
		return 0;

	APP_visual_info = GetVisualInfo(APP_pubscreen, TAG_DONE);

	// get some helpers to create more compact window
	ULONG	font_width = APP_pubscreen->RastPort.TxWidth;;
	ULONG	font_height = APP_pubscreen->RastPort.TxHeight;

	ULONG 	win_pos_x = APP_pubscreen->Width / 2 - 320 / 2;
	ULONG	win_pos_y = APP_pubscreen->Height / 2 - 240 / 2;

	struct Gadget*	    g_context;
	struct Gadget*	g_list_modes;

	g_context = CreateContext (&APP_g_list);


struct List *DaList; 

char *BassSpaces[] = {"Grass", "Eat", "Cows", "All", "Grass", "Eat", "Cows", "All", "Grass", "Eat", "Cows", "All", "Grass", "Eat", "Cows", "All", NULL};  

 struct Node *DaListNode;

  if (DaList = AllocMem (sizeof (struct List), MEMF_FAST))
  {
    NewList (DaList);

    for (int i = 0; BassSpaces[i] != NULL; i++)
    {
      if (DaListNode = AllocMem(sizeof(struct Node), MEMF_FAST) )
      {
        DaListNode->ln_Name = BassSpaces[i];
        DaListNode->ln_Type = 100L;
        DaListNode->ln_Pri = 0;
        AddTail (DaList, DaListNode);
      }
      else
      {
        printf ("Could not allocate memory for node\n");

      }
    }
  }
  else
  {
    printf ("Could not allocate memory for list\n");

  }

  	struct NewGadget ng;

	ng.ng_TextAttr   = APP_pubscreen->Font;
    ng.ng_VisualInfo = APP_visual_info;
	ng.ng_LeftEdge   = 10;
	ng.ng_TopEdge    = font_height + 30;
    ng.ng_Width      = 300;
    ng.ng_Height     = 150;
    ng.ng_GadgetText = (STRPTR)"Please select your screen resolution...";
    ng.ng_GadgetID   = G_ID_LIST_MODES;
    ng.ng_Flags      = 0;


    g_list_modes = g_context = CreateGadget (LISTVIEW_KIND, g_context, &ng, 
                                    GTLV_ShowSelected, NULL,
                                    GTLV_Selected, 0,
                                    GTLV_MakeVisible, 0,
                                    GTLV_Labels, DaList,
                                    TAG_END);


     // --- create window ---
     APP_window = OpenWindowTags(	NULL, 
	 								WA_Left, win_pos_x, 
									WA_Top, win_pos_y, 
									WA_Width, 320, 
									WA_Height, 240, 
									WA_Title, (ULONG)"Raycaster Launcher v01", 
									WA_SmartRefresh, TRUE,
									WA_Flags, WFLG_CLOSEGADGET | WFLG_DRAGBAR | WFLG_ACTIVATE, 
									WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_REFRESHWINDOW | BUTTONIDCMP | LISTVIEWIDCMP | IDCMP_GADGETDOWN | IDCMP_GADGETHELP | IDCMP_GADGETUP,
									WA_PubScreen, (ULONG)APP_pubscreen,
									WA_Gadgets, (ULONG)APP_g_list,
									TAG_END);


GT_RefreshWindow (APP_window, NULL);   <<<< WITHOUT THIS NOTHING APPEARS IN LISTVIEW


	// signals for event and messages
 	APP_signals = 1L << APP_window->UserPort->mp_SigBit;

    return 1;
}

void APP_Message_Loop()
{
	BOOL is_loop = TRUE;

	while(is_loop)
	{
		if(SetSignal(0L, APP_signals) & APP_signals)
		{
			struct IntuiMessage* imsg;
			while( imsg = (struct IntuiMessage *)GetMsg(APP_window->UserPort) )
			{
				switch (imsg->Class)
				{
					case IDCMP_REFRESHWINDOW:
						GT_BeginRefresh (APP_window);
						GT_EndRefresh (APP_window, TRUE);
					break;

					case IDCMP_CLOSEWINDOW:
						is_loop = FALSE;
						break;

					case IDCMP_GADGETUP:
					{
						struct Gadget *tmp_gadget = (struct Gadget *) imsg->IAddress;
						switch (tmp_gadget->GadgetID)
						{
							case G_ID_BUTTON_START:
							is_loop = FALSE;
							break;

							case G_ID_LIST_MODES:
							break;
						}
					}
					break;
				}

				ReplyMsg((struct Message *)imsg);
			}
		}
	}
}
mateusz_s is offline  
Old 28 March 2021, 10:06   #11
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 6,985
You have to use GT_GetIMsg instead of GetMsg and GT_ReplyIMsg instead of ReplyMsg in your message loop.

And somewhere im your program you should have a Wait(), otherwise your program is unsuitable for a multitasking environment. Once you use Wait() you can no longer use SetSignal. You have to use the return value of Wait() instead.
thomas is offline  
Old 28 March 2021, 15:47   #12
mateusz_s
Registered User
 
Join Date: Jan 2020
Location: Poland
Posts: 181
Quote:
Originally Posted by thomas View Post
You have to use GT_GetIMsg instead of GetMsg and GT_ReplyIMsg instead of ReplyMsg in your message loop.

And somewhere im your program you should have a Wait(), otherwise your program is unsuitable for a multitasking environment. Once you use Wait() you can no longer use SetSignal. You have to use the return value of Wait() instead.
Thank You very much for help @thomas !
mateusz_s is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change a gadtools button's text? alkis Coders. C/C++ 15 26 April 2016 19:11
gadtools zharn Coders. C/C++ 6 21 February 2014 20:26
How to build a ListView AGS Coders. General 0 22 December 2013 23:48
A few questions Muzer project.ClassicWB 10 12 September 2009 14:14
A few questions! One1 New to Emulation or Amiga scene 2 30 October 2002 17:41

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 22:05.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.08308 seconds with 13 queries