Menu

Button text does not scale to fit in buttons

Help
2008-07-13
2013-04-15
  • Gary D Stewart

    Gary D Stewart - 2008-07-13

    When running this code the button text does not scale to fit inside the buttons. I've tried the OTK text scale and fit text in panel functions (using retry_pb and mw) and they do nothing. Again I'm not sure if I'm doing something wrong or if there is a problem.

    static void display_dev_init_err_message(int_32 message_number)
    {
      float y = 5.0, dy = 12.0,  dy1_5 = 15.0 ;

      OtkWidget mw, retry_pb, cont_pb, exit_pb  ;

      mw = OtkMakePanel(OtkOuterWindow, Otk_Recessed, Otk_LightGray, 10.0, 10.0, 70.0, 80.0) ;
      Otk_SetBorderThickness(mw, 0.5) ;

      switch (message_number)
        {
         case DEVICE_LOCKED:

           OtkMakeTextLabel(mw, "Selected system level device interface", Otk_Black, 3.0, 1.0, 4.0, y) ;
           y = y + dy ;
           OtkMakeTextLabel(mw, " is locked by another program", Otk_Black, 3.0, 1.0, 4.0, y) ;

           retry_pb = OtkMakeButton(mw, 10.0, 70.0, 30.0, 20.0, "Retry", retry_pb_cb, NULL) ;
           exit_pb = OtkMakeButton(mw, 50.0, 70.0, 30.0, 20.0, "Exit", exit_pb_cb, NULL) ;

           break ;

         More display messages switch case statements mostly using sub-windows instead of panels at this
          time...

        }
    }

    P.S. This is the same code giving me problems with multiple sub-windows. I went as far as use different OtkWidget
          structures for each window to no avail. I don't know if this panel does the same thing as the sub-windows.

     
    • kindman

      kindman - 2008-07-22

      Gary,

      This problem is caused by a slightly inaccurate estimate of the button's text-string font size.  A simple remedy is to add a space or two to the end of your button text string.

      For example:
        OtkMakeButton(mw, 50.0, 70.0, 30.0, 20.0, "Exit ", exit_pb_cb, NULL);

      I will look into adjusting the font-width measurement in the next release of OTK.
      In the meantime, this remedy should force the text to fit within your buttons.

      Thanks for mentioning this,
          Carl

       
    • Gary D Stewart

      Gary D Stewart - 2008-08-06

      Thanks, I'll give that a try. Right now I'm using another work around of just adding text to the button with OtkMakeTextLabel, but I find that to be a bit of a pain.

       

Log in to post a comment.

MongoDB Logo MongoDB