how to make button with 2 lines with centered text in ?

2 posts / 0 new
Last post
kas1e
kas1e's picture
Offline
Last seen: 3 days 14 hours ago
Joined: 2010-11-30 15:30
how to make button with 2 lines with centered text in ?

For some design reassons i need to make button with 2 lines of text, both of which should be centered and looks like usual button.

For first i simple tried "\n" for the button.gadget's GA_Text : it simple didnt' work, and \n treatet as fancy character.

Then, Javier point me out that we may try this way : create label.image object with LABLE_Text (this one handle \n fine), and then, attach it to a button:

  1. twolinesimage = IIntuition->NewObject(NULL, "label.image",
  2. LABEL_Text, "Replace All\nin All Tabs",
  3. LABEL_Justification, LJ_CENTER,
  4. TAG_END);
  5. ...
  6. LAYOUT_AddChild, IIntuition->NewObject(NULL, "button.gadget",
  7. GA_Image, twolinesimage,
  8. TAG_DONE),
  9. ...

While it more or less work, it have 2 issues :
1). LABEL_Justification, LJ_CENTER/LJ_RIGHT/LJ_LEFT, for the Label object seems do not work. Text centered if you just have it one in layout, but you can't control it seems so to be one left or on right by Justification.
2). When we press on this "button", it acts not like usual button visually, but bring some background. Can it be done somehow so to act like a button when pressed ?

So question is : how to make a 2 lines button , which looks like button, and press like button (even if it will be not real button), and have centered text in.

Thanks!

jabirulo
jabirulo's picture
Offline
Last seen: 1 hour 30 min ago
Joined: 2013-05-30 00:53
Re: how to make button with 2 lines with centered text in ?

Seems below code does the job.

  1. OBJ(OID_REPLACE_ALL_TABS) = NewObject(NULL, "label.image",
  2. LABEL_DrawInfo, dri,
  3. LABEL_Justification, LJ_CENTRE,
  4. LABEL_Text, "Replace All\n in All Tabs ", // added spaces or justification won't "work"
  5. LABEL_DisposeImage, TRUE,
  6. TAG_END);
  7. ...
  8. LAYOUT_AddChild, NewObject(NULL, "button.gadget",
  9. //GA_Text, "Replace in all tabs",
  10. //BUTTON_Justification, BCJ_CENTER,
  11. BUTTON_RenderImage, OBJ(OID_REPLACE_ALL_TABS),
  12. BUTTON_SelectImage, OBJ(OID_REPLACE_ALL_TABS),
  13. TAG_END),
  14. ...

AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonRX550/SSD240GB/DVDRW :-P

Log in or register to post comments