How not to create a gadget

5 posts / 0 new
Last post
mritter0
mritter0's picture
Offline
Last seen: 2 years 5 months ago
Joined: 2014-04-21 21:15
How not to create a gadget

I have a layout designed and working just fine. But let's say I don't want to create one of the gadgets, by user choice, in the layout. How do I "skip over it"?

I have been doing this:

  1. !Prefs->StatusBar ? TAG_IGNORE : StartHGroup,
  2. LAYOUT_BevelStyle, BVS_SBAR_VERT,
  3. LAYOUT_SpaceOuter, TRUE,
  4. LAYOUT_FixedVert, FALSE,
  5. LAYOUT_InnerSpacing, 0,
  6. LAYOUT_LeftSpacing, 0,
  7. LAYOUT_RightSpacing, 0,
  8. LAYOUT_TopSpacing, 0,
  9. LAYOUT_BottomSpacing, 0,
  10. LAYOUT_AddChild, Objects[GAD_STATUSBAR]=NewObject(ButtonClass,NULL,
  11. GA_ID, GAD_STATUSBAR,
  12. GA_ReadOnly, TRUE,
  13. GA_Underscore, "^",
  14. GA_Text, "",
  15. BUTTON_BevelStyle, BVS_NONE,
  16. BUTTON_Justification, BCJ_LEFT,
  17. TAG_END),
  18. EndHGroup,

This works fine. But for some reason when I do display the gadget all the memory is freed. When I don't display the gadget I lose 3,800 bytes.

Is there a better way to "skip over" a gadget when creating the layout?

salass00
salass00's picture
Offline
Last seen: 6 months 1 week ago
Joined: 2011-02-03 11:27
Are you sure that is the

Are you sure that is the exact code you are using because I don't see how it could work at all?

Anyway you need to do something like this:

  1. !Prefs->StatusBar ? TAG_IGNORE : LAYOUT_AddChild, !Prefs->StatusBar ? NULL : StartHGroup,
  2. /* ... */
  3. EndHGroup,

Or you could create the status bar separately:

  1. Object *status_bar = NULL;
  2. if (Prefs->StatusBar) {
  3. status_bar = StartHGroup,
  4. /* ... */
  5. EndHGroup,
  6. }

and then add it to your layout using:

  1. Prefs->StatusBar ? LAYOUT_AddChild : TAG_IGNORE, status_bar,
mritter0
mritter0's picture
Offline
Last seen: 2 years 5 months ago
Joined: 2014-04-21 21:15
You can't create a Group as

You can't create a Group as an Object, so that doesn't work.

I have tried every combination I can think of. Still have the memory loss issue. I can't add/remove the gadget after layout creation and window open because of the StartHGroup with the horizontal bar.

I will keep trying.....

Thanks

salass00
salass00's picture
Offline
Last seen: 6 months 1 week ago
Joined: 2011-02-03 11:27
You can't create a Group as


You can't create a Group as an Object, so that doesn't work.

Yes, you can. I notice I made a mistake though in that I forgot to replace the comma in after "EndHGroup" with a semicolon in my example above.

The StartHGroup and EndHGroup are just macros that hide a single call to IIntuition->NewObject() which surprise, surprise returns a pointer to a BOOPSI Object.

Edit:
I just noticed that the Start#? macros include an explicit "LAYOUT_AddChild, " in their definition unlike the #?Object ones I'm familiar with, so just replace StartHGroup with HGroupObject in the code fragments I posted above and it should be fine.

mritter0
mritter0's picture
Offline
Last seen: 2 years 5 months ago
Joined: 2014-04-21 21:15
Nice! Changing the group

Nice! Changing the group tags did it.

Thank you, sir!

Log in or register to post comments