Part IX
Variable Font Sizing



    In some cases, you may want a grid function to resize kid grid fonts automatically according to the size of the grid. In DsCalendar ( ), I added a short subroutine SetMaxFontHeight which finds the largest font size that will fit into a grid. This SUB is called from the Resize subroutine for each kid grid k.

SUB SetMaxFontHeight
'determine max font size that can fit into kid grid
'k is static variable for kid grid
 XuiGetSize (grid, #GetSize, @x, @y, @width, @height, k, 0)
 XuiGetFont (grid, #GetFont, @size, @weight, @italic, @angle, k, @typeface$)
 XuiGetTextString(grid, #GetTextString, 0, 0, 0, 0, k, @text$)
 h = 0
 size = 40
 DO WHILE h < height
  size = size + 80
  XuiSetFont (grid, #SetFont, size, weight, italic, angle, k, typeface$)
  XuiGetFontNumber (grid, #GetFontNumber, @font, 0, 0, 0, k, 0 )
  XgrGetTextImageSize (font, text$, @dx, @dy, @w, @h, @topGap, @flags)
 LOOP
 XuiSetFont (grid, #SetFont, size-80, weight, italic, angle, k, typeface$)
END SUB

          

The code for our program up to this point can be found in Calendar10.x.

Next



    The DsCalendar grid function is now complete.  The next installment will take a look at creating a DLL (dynamic link library) from the grid function. We would also like to be able to add DsCalendar ( )  to the PDE Toolkit so it can be used in any GUI program.

Previous     Home     Next

(c) 2000  David SZAFRANSKI