Reaction Layout without RA Macros

7 posts / 0 new
Last post
fastbit66
fastbit66's picture
Offline
Last seen: 9 years 6 months ago
Joined: 2012-09-23 23:11
Reaction Layout without RA Macros
Hello Amiga Coders! I'm trying to get deeper in the programing of Reaction under Amiga OS4. Can someone please show me a litte code fragment about using the layout class in Reaction without using the RA macros? I have managed to create a little gui with buttons based on Trixies wonderful tutorial "Recommended practice in OS4 Reaction programming" I have a string gadget on top followed by two buttons. Layout is vertically orientated. Looks quite like this: -------------- String gadget -------------- -------------- Button1 -------------- -------------- Button2 -------------- I would like to have someting like: ---------------------------------- String gadget --------------------------------- -------------- ------------- Button1 Button2 -------------- ------------- Would you be so kind an show me how to achieve this? I don't need a full working source code example - only the addtion for the layout Here is the part from my listing to create the window: /* Create the window object. */ if ( (objects[OID_WINDOW] = IIntuition->NewObject(WindowClass, NULL, WA_Title, "ReAction AppWindow", WA_DragBar, TRUE, WA_CloseGadget, TRUE, WA_SizeGadget, TRUE, WA_DragBar, TRUE, WA_DepthGadget, TRUE, WA_Activate, TRUE, WA_InnerWidth, 200, WA_InnerHeight, 100, WINDOW_Position, WPOS_CENTERSCREEN, WINDOW_AppWindow, TRUE, WINDOW_IconifyGadget, TRUE, WINDOW_Layout, objects[OID_LAYOUT] = IIntuition->NewObject(LayoutClass, NULL, LAYOUT_Orientation, LAYOUT_ORIENT_VERT, LAYOUT_SpaceOuter, TRUE, LAYOUT_DeferLayout, TRUE, LAYOUT_AddChild, objects[OID_STRINGGADGET] = IIntuition->NewObject(StringClass, NULL, GA_ID,OID_STRINGGADGET, GA_ReadOnly, FALSE, GA_RelVerify, TRUE, STRINGA_WorkBuffer, StringInput, TAG_END), LAYOUT_AddChild, objects[OID_BUTTON1] = IIntuition->NewObject(ButtonClass, NULL, GA_ID,OID_BUTTON1, GA_ReadOnly, FALSE, GA_Text,"Show Input", GA_RelVerify, TRUE, TAG_END), LAYOUT_AddChild, objects[OID_BUTTON2] = IIntuition->NewObject(ButtonClass, NULL, GA_ID, OID_BUTTON2, GA_ReadOnly, FALSE, GA_Text, "Quit", GA_RelVerify, TRUE, TAG_END), TAG_END), TAG_END))) Thank you vermuch for your time an reading! Greets Andi
Steady
Steady's picture
Offline
Last seen: 1 month 1 week ago
Joined: 2011-07-18 05:02
Hey fastbit66. You need to
Hey fastbit66. You need to add an extra layout gadget with horizontal orientation below the string gadget and attach the button gadgets to that, like so (modified from your original example, check the autodocs for more details):
  1. /* Create the window object. */
  2. if ( (objects[OID_WINDOW] = IIntuition->NewObject(WindowClass, NULL,
  3. WA_Title, "ReAction AppWindow",
  4. WA_DragBar, TRUE,
  5. WA_CloseGadget, TRUE,
  6. WA_SizeGadget, TRUE,
  7. WA_DragBar, TRUE,
  8. WA_DepthGadget, TRUE,
  9. WA_Activate, TRUE,
  10. WA_InnerWidth, 200,
  11. WA_InnerHeight, 100,
  12. WINDOW_Position, WPOS_CENTERSCREEN,
  13. WINDOW_AppWindow, TRUE,
  14. WINDOW_IconifyGadget, TRUE,
  15. WINDOW_Layout, objects[OID_LAYOUT] = IIntuition->NewObject(LayoutClass, NULL,
  16. LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
  17. LAYOUT_SpaceOuter, TRUE,
  18. LAYOUT_DeferLayout, TRUE,
  19.  
  20. LAYOUT_AddChild, objects[OID_STRINGGADGET] = IIntuition->NewObject(StringClass, NULL,
  21. GA_ID,OID_STRINGGADGET,
  22. GA_ReadOnly, FALSE,
  23. GA_RelVerify, TRUE,
  24. STRINGA_WorkBuffer, StringInput,
  25. TAG_END),
  26.  
  27. /* This is the embedded layout gadget that will allow gadgets to be placed side-by-side */
  28. LAYOUT_AddChild, objects[OID_BUTTONLAYOUT] = IIntuition->NewObject(LayoutClass, NULL,
  29. LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ, /* I think that's what it's called from memory. Check autodocs */
  30.  
  31. /* This is now part of the OID_BUTTONLAYOUT layout gadget */
  32. LAYOUT_AddChild, objects[OID_BUTTON1] = IIntuition->NewObject(ButtonClass, NULL,
  33. GA_ID,OID_BUTTON1,
  34. GA_ReadOnly, FALSE,
  35. GA_Text,"Show Input",
  36. GA_RelVerify, TRUE,
  37. TAG_END),
  38.  
  39. /* This is now part of the OID_BUTTONLAYOUT layout gadget */
  40. LAYOUT_AddChild, objects[OID_BUTTON2] = IIntuition->NewObject(ButtonClass, NULL,
  41. GA_ID, OID_BUTTON2,
  42. GA_ReadOnly, FALSE,
  43. GA_Text, "Quit",
  44. GA_RelVerify, TRUE,
  45. TAG_END),
  46. TAG_END),
  47. TAG_END),
  48. TAG_END)))
The button should now be side by side. Sorry, I'm away from my Amiga and documentation so I couldn't test but it should be OK. Hope it helps. Cheers, Steady.
fastbit66
fastbit66's picture
Offline
Last seen: 9 years 6 months ago
Joined: 2012-09-23 23:11
@Steady: Woahhh ...Thank you
@Steady: Woahhh ...Thank you very much Steady! That works perfectly :-) Will now hopefully be able to continue with the autodocs. I gues I understand now the way Layouts are working in Reaction. Once again: Thanx for your fast reply! Best regards! fastbit66
SAM440ep@ 667MHz / 512 MB RAM / Radeon 9050 / AmigaOS 4.1 Update 5
LyleHaze
LyleHaze's picture
Offline
Last seen: 2 years 3 months ago
Joined: 2011-05-26 03:58
I usually only store the ID's
I usually only store the ID's of objects that I might need to access later. Since I probably wouldn't need to play with the added horizontal layout, storing a pointer to it is probably not necessary. so instead of:
  1. LAYOUT_AddChild, objects[OID_BUTTONLAYOUT] = IIntuition->NewObject(LayoutClass, NULL,
  2. LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
I would probably just:
  1. LAYOUT_AddChild, IIntuition->NewObject(LayoutClass, NULL,
  2. LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
This also reduces the size of the objects array by one. Admittedly not a big difference, but if there's some reason to keep pointers to ALL the layout objects, I'm guessing someone will jump in and educate me! :) Have Fun, LyleHaze
LyleHaze
Steady
Steady's picture
Offline
Last seen: 1 month 1 week ago
Joined: 2011-07-18 05:02
@fastbit66: No problems. Glad
@fastbit66: No problems. Glad I could help. Good luck. Developing for Amiga is fun ... and sometimes challenging. @LyleHaze: I agree completely, however it was easier to describe the relationships in the example if names are involved.
trixie
trixie's picture
Offline
Last seen: 8 hours 53 min ago
Joined: 2011-02-03 13:58
As Lyle says, pointers to
As Lyle says, pointers to layout objects are rarely needed so save memory unless you have some use for them. For example, you may need to refresh the particular layout (instead of refreshing the whole window contents), or you may want to disable an entire gadget group at once (instead of doing it per gadget). Then the pointer comes in handy.
AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2
fastbit66
fastbit66's picture
Offline
Last seen: 9 years 6 months ago
Joined: 2012-09-23 23:11
@Trixie @Lyle Thanx a lot
@Trixie @Lyle Thanx a lot for your help and clarifying the reason for pointers in context with Reaction gadgets. That helps a lot !!! __________________________________________________________________________________________________ SAM440ep@ 667MHz / 512 MB RAM / Radeon 9050 / AmigaOS 4.1 Update 5
SAM440ep@ 667MHz / 512 MB RAM / Radeon 9050 / AmigaOS 4.1 Update 5
Log in or register to post comments