Example #1
0
    def _drawKeys(self, dc):
        blackPen = wx.Pen('black')
        whiteBrush = wx.Brush('white')

        # set the font
        self.font = wx.Font(self._fontSize, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL,
                       wx.FONTWEIGHT_BOLD, False, 'Arial Rounded MT Bold')
        dc.SetFont(self.font)

        for displayKey in self._displayKeys.values():

            # draw key shadow
            shadowRect = Rect(*displayKey.scaled)
            shadowRect.OffsetXY(1, 1)
            dc.SetPen(wx.Pen('light grey', 3.5))
            dc.DrawRoundedRectangleRect(shadowRect.Get(), -.075)

            # handle selections
            if self._isKeySelected(displayKey.handle):
                if self.FindFocus() == self:
                    # TODO: Generalize this magic number from system settings.
                    #       Currently is Mac selection blue.
                    dc.SetPen(wx.Pen('#3e75d6', 2))
                else:
                    dc.SetPen(wx.Pen('dark grey', 2))
                dc.SetBrush(wx.Brush('light grey'))
            else:
                dc.SetPen(blackPen)
                dc.SetBrush(whiteBrush)

            # draw key outline
            dc.DrawRoundedRectangleRect(displayKey.scaled.Get(), -.075)

            # draw label
            self._drawLabels(dc, displayKey.labelRect, displayKey)