Ejemplo n.º 1
0
    def __layout(self, *a):
        """Called when this ``ColourBarPanel`` needs to be laid out.
        Sets the panel size, and calls the :meth:`__refreshColourBar` method.
        """
        canvas = self.__cbCanvas
        w, h = self.GetClientSize().Get()
        cbarSize = cbar.colourBarMinorAxisSize(canvas.colourBar.fontSize)

        if canvas.colourBar.orientation == 'horizontal':
            canvas.SetSizeHints(-1, cbarSize, -1, cbarSize, -1, -1)
        else:
            canvas.SetSizeHints(cbarSize, -1, cbarSize, -1, -1, -1)

        wx.CallAfter(self.Layout)
Ejemplo n.º 2
0
def adjustSizeForColourBar(width,
                           height,
                           showColourBar,
                           colourBarLocation,
                           fontSize):
    """Calculates the widths and heights of the image display space, and the
    colour bar if it is enabled.

    :arg width:             Desired width in pixels

    :arg height:            Desired height in pixels

    :arg showColourBar:     ``True`` if a colour bar is to be shown, ``False``
                            otherwise.

    :arg colourBarLocation: Colour bar location (see
                            :func:`buildColourBarBitmap`).

    :arg fontSize           Font size (points) used in colour bar labels.

    :returns:               Two tuples - the first tuple contains the
                            ``(width, height)`` of the available canvas space,
                            and the second contains the ``(width, height)`` of
                            the colour bar.
    """

    if showColourBar:

        cbarWidth = int(round(cbar.colourBarMinorAxisSize(fontSize)))
        if colourBarLocation in ('top', 'bottom'):
            height     = height - cbarWidth
            cbarHeight = cbarWidth
            cbarWidth  = width
        else:
            width      = width  - cbarWidth
            cbarHeight = height
    else:
        cbarWidth  = 0
        cbarHeight = 0

    return (width, height), (cbarWidth, cbarHeight)