English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System

 
 
Thread Tools
Old 15 September 2019, 07:55   #1
peceha
Registered User

peceha's Avatar
 
Join Date: Dec 2017
Location: Poland
Age: 43
Posts: 178
How to remove/hide any gadget from window (gadtools)

Hi,
is there a way?
I did some searching and found this:
Quote:
Note that to modify the imagery of a gadget, you must first remove
that gadget from the window's gadget list, using RemoveGadget() (or
RemoveGList()). After changing the image, border, text (including
text for a string gadget), the gadget is replaced in the gadget list
(using AddGadget() or AddGList()). Adding gadgets does not cause
them to be displayed (refreshed), so this function, or RefreshGList()
is typically called.
I thought it could be applied to hide/remove the whole gadget but it didn't work.

At the beginning I used one of these:
Code:
RemoveGadget()
RemoveGList()
followed by one of these:
Code:
RefreshGadgets()
RefreshGList()
And the last was this (both):
Code:
RefreshGadgets()
GT_RefreshWindow()
Thanks
peceha is offline  
Old 15 September 2019, 16:41   #2
thomas
Registered User
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 5,853
Use RemoveGList, EraseRect to hide the gadget, AddGList, RefreshGList to show it.
thomas is offline  
Old 15 September 2019, 18:53   #3
peceha
Registered User

peceha's Avatar
 
Join Date: Dec 2017
Location: Poland
Age: 43
Posts: 178
Thanks for the answer.

Anyway I still have a problem with it.
Look at the movie.
There is a window with buttons on top, one listview under and one more button at the bottom.

There is a "LIST" gadget which I click in the movie and all it does is:
- RemoveGList(for listview and bottom gadget only)
- EraseRect(only ereases listview)

Now if I click on bottom gadget it doesn't respond so it is gone - good!
But when I click on Listview ... it is still alive

(actually in the movie, first, I click on the listview and later on the bottom gadget)

Am I missing something?

Thanks

[ Show youtube player ]
peceha is offline  
Old 15 September 2019, 20:33   #4
peceha
Registered User

peceha's Avatar
 
Join Date: Dec 2017
Location: Poland
Age: 43
Posts: 178
What I actually want to do is to make a toggle button to change my window size thus I wanted to hide viewlist and bottom gadget and then adjust window's size to accommodate only top row of gadget and white information bar.

In that case, do I really have to get rid of these gadgets from glist and then resize the window?
Or is it safe to just resize the window and leave the gadgets outside ?
peceha is offline  
Old 16 September 2019, 08:45   #5
thomas
Registered User
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 5,853
The problem is that Gadtools gadgets are not BOOPSI objects which means a Gadtools gadget can consist of multiple Intuition gadgets and you have to remove them all from the list. At the same time Gadtools gadgets should be considered black boxes so you can never be sure how many Intuition gadgets belong to one Gadtools gadget.

If you put the gadgets to be removed to the end of the glist, you can use RemoveGList with -1 as count. Then it will remove all gadgets until the end of the list.

In order to remove a gadget in the middle of the list you could remember the pointers you got from CreateGadget and count the number of gadgets in between by following the NextGadget pointers.

Or use the brute force method: remove all gadgets from the window, free the whole glist and rebuild it with only the gadgets which should remain.
thomas is offline  
Old 16 September 2019, 09:00   #6
peceha
Registered User

peceha's Avatar
 
Join Date: Dec 2017
Location: Poland
Age: 43
Posts: 178
Thanks for clarification.

So far I do have exactly what you are saying (When using CreateGadget I keep the pointers to individual gadgets and then I tried these with RemoveGList() and the proper count - that was on the movie).

Quote:
If you put the gadgets to be removed to the end of the glist, you can use RemoveGList with -1 as count. Then it will remove all gadgets until the end of the list.
I tried that as well (There are total 7 gadgets on the list: listwiev is second from the last and bottom button is very last)
Code:
RemoveGList_(*win,*gadlv,-1)
unfortunately it removes also "system" gadgets like dragbar, close gadget... they are still there but not ressponding


maybe there is something wrong in my code.


I think I'm going to leave it as it is - I will just add WA_Zoom to NewWindow structure to get zoom gadget an after zapping the window ListView and "prefs..." button will stay out of the reach.

Last edited by peceha; 16 September 2019 at 09:11.
peceha is offline  
Old 17 September 2019, 06:35   #7
Bruce Abbott
Registered User

Bruce Abbott's Avatar
 
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 253
Quote:
Originally Posted by peceha View Post
Or is it safe to just resize the window and leave the gadgets outside ?
Yes. So you shouldn't have to do anything special.

Quote:
I will just add WA_Zoom to NewWindow structure to get zoom gadget an after zapping the window ListView and "prefs..." button will stay out of the reach.
That's the easiest way to do it because Intuition will handle zooming the window for you.

All the gadgets can stay in place. You can't click on them while they are hidden, and Intuition will refresh them automatically when the window is zoomed back out again.
Bruce Abbott is offline  
Old 17 September 2019, 07:47   #8
thomas
Registered User
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 5,853
Make sure that you set GFLG_GIMMEZEROZERO, otherwise part of the gadgets will draw over the borders.
thomas is offline  
Old 17 September 2019, 23:28   #9
bubbob42
Registered User
 
Join Date: Oct 2012
Location: Germany
Posts: 405
Quote:
Originally Posted by peceha View Post
Thanks for clarification.

So far I do have exactly what you are saying (When using CreateGadget I keep the pointers to individual gadgets and then I tried these with RemoveGList() and the proper count - that was on the movie).
I just had a similar problem because I wanted to exchange gadgets in a window depending on the item selected in a listview gadget (which itself would stay visible all the time. Here’s what I did:

- Let's assume we have three Gadget "groups" A,B,C, containing 1-n Gadgets

- Call CreateContext() and save the returned Gadget pointer,

- Create all Gadgets with CreateGadgetA() in one go, but

- GadTools will create lots of sub-gadgets and the individual Gadget pointers returned by CreateGadgetA will only refer to the last of them. So you need to store the pointer to the first Gadget separately, e.g. "B_First =A_Last->NextGadget".

- I also saved the number of all "real" Gadgets per group for convenience.

- Next step is to cut out the individual Gadget lists by unlinking them. So we set A_Last->NextGadget = NULL, B_Last->NextGadget = NULL, etc.

- Now we can remove a Gadget group by calling RemoveGList(A_First,...),
RectFill(<region of the gadget group to be removed>)

- To display the next gadget group we use AddGList(B_First,...), RefreshGList(<pointer returned by CreateContext>), GT_RefreshDisplay()

- To clean up after the window has been closed, we need to link all the GadgetLists back together, like this "A_Last->NextGadget = B_First", etc. And finally call FreeGadgets(<pointer returned by CreateContext()>)

Hope this helps.
bubbob42 is offline  
Old 18 September 2019, 08:45   #10
peceha
Registered User

peceha's Avatar
 
Join Date: Dec 2017
Location: Poland
Age: 43
Posts: 178
Thanks!
I understand what you just wrote.
Will try something like this shortly (worked for you, should work for me)

At the moment, I left gadget list untouched (only made window smaller) but will play more.
peceha 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
Hide AmiTCPIP Log Window eva support.Apps 5 19 November 2014 15:30
gadtools zharn Coders. C/C++ 6 21 February 2014 20:26
How to add an Iconify-Gadget to a Window? AGS Coders. System 5 15 January 2014 15:41
Soft which hide whole border of AmigaDos Window olesio support.Apps 5 17 February 2009 01:21
Gadget/Layout.gadget V44 ruliovega support.Apps 6 02 January 2006 11:50

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 11:43.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Page generated in 0.10103 seconds with 15 queries