Buttons are getting a fixed value of 100 pixels when the button caption is empty.
Fix:
In SfRibbonToolbarButton.CalculateWidth, added code to deal with the empty Caption:
LOCAL lnWidth
DO CASE
CASE NOT EMPTY(THIS.CAPTION)
IF THIS.WORDWRAP
THIS.oGDI.SETSIZE(THIS.LBLBUTTON.WIDTH, THIS.LBLBUTTON.HEIGHT)
ENDIF THIS.WORDWRAP
THIS.oGDI.MEASURESTRING(THIS.LBLBUTTON.CAPTION)
m.lnWidth = MAX(CEILING(THIS.oGDI.nWidth) + 2 THIS.LBLBUTTON.LEFT, ;
THIS.IMGBUTTON.WIDTH + 2 THIS.Padding)
&& use a width of the label or the image, whichever is wider
&& This.lblButton.Width is inaccurate if the form isn't visible yet
IF THIS.WIDTH <> m.lnWidth AND NOT THIS.WORDWRAP
THIS.WIDTH = m.lnWidth
THIS.LBLBUTTON.WIDTH = THIS.WIDTH - 2 * THIS.LBLBUTTON.LEFT
ENDIF THIS.WIDTH <> m.lnWidth ...
THIS.IMGBUTTON.LEFT = INT((THIS.WIDTH - THIS.IMGBUTTON.WIDTH) / 2)
&& center the image
* If there's one line of text, center the down button below the label.
IF THIS.oGDI.nLines = 1
THIS.IMGDOWN.LEFT = INT((THIS.WIDTH - THIS.IMGDOWN.WIDTH) / 2)
THIS.IMGDOWN.TOP = THIS.LBLBUTTON.TOP + 24
ELSE
THIS.IMGDOWN.LEFT = THIS.LBLBUTTON.LEFT + THIS.LBLBUTTON.WIDTH - 5
THIS.IMGDOWN.TOP = THIS.LBLBUTTON.TOP + THIS.LBLBUTTON.HEIGHT - 10
ENDIF THIS.oGDI.nLines = 1
THIS.nLines = THIS.oGDI.nLines
THIS.PARENT.CalculateWidth()
Buttons are getting a fixed value of 100 pixels when the button caption is empty. Fix:
In SfRibbonToolbarButton.CalculateWidth, added code to deal with the empty Caption:
LOCAL lnWidth
DO CASE CASE NOT EMPTY(THIS.CAPTION) IF THIS.WORDWRAP THIS.oGDI.SETSIZE(THIS.LBLBUTTON.WIDTH, THIS.LBLBUTTON.HEIGHT) ENDIF THIS.WORDWRAP THIS.oGDI.MEASURESTRING(THIS.LBLBUTTON.CAPTION) m.lnWidth = MAX(CEILING(THIS.oGDI.nWidth) + 2 THIS.LBLBUTTON.LEFT, ; THIS.IMGBUTTON.WIDTH + 2 THIS.Padding) && use a width of the label or the image, whichever is wider && This.lblButton.Width is inaccurate if the form isn't visible yet IF THIS.WIDTH <> m.lnWidth AND NOT THIS.WORDWRAP THIS.WIDTH = m.lnWidth THIS.LBLBUTTON.WIDTH = THIS.WIDTH - 2 * THIS.LBLBUTTON.LEFT ENDIF THIS.WIDTH <> m.lnWidth ... THIS.IMGBUTTON.LEFT = INT((THIS.WIDTH - THIS.IMGBUTTON.WIDTH) / 2) && center the image
Align empty captions OTHERWISE && Empty(This.Caption) m.lnWidth = THIS.IMGBUTTON.WIDTH + (2 THIS.Padding) THIS.WIDTH = m.lnWidth THIS.LBLBUTTON.WIDTH = THIS.WIDTH - 2 THIS.LBLBUTTON.LEFT THIS.IMGBUTTON.LEFT = INT((THIS.WIDTH - THIS.IMGBUTTON.WIDTH) / 2) && center the image
ENDCASE