def created(self, data):
        self.flags = flags = BitDict(
            'HorizontalScrollbar', 'HorizontalAutoscroll', 'VerticalScrollbar',
            'VerticalAutoscroll', 'ReadOnly', 'Multiline', 'Password',
            'Border', 'HideOnStart', 'Uppercase', 'Lowercase', 'Tabstop',
            'SystemColor', '3DLook', 'Transparent', None, 'AlignCenter',
            'AlignRight')
        self.width = data.readShort(True)
        self.height = data.readShort(True)
        # XXX support unicode when the unicode build is out!
        self.logFont = LogFont(data, old=True)
        data.skipBytes(4 * 16)  # custom colors?
        self.foregroundColor = data.readColor()
        self.backgroundColor = data.readColor()
        data.skipBytes(40)  # text-style?
        flags.setFlags(data.readInt())

        if flags['HideOnStart']:
            self.parent.visible = False

        self.enable_mouse()
        self.widget = self.new(Edit)
        self.widget.initialize(
            int(self.x),
            int(self.y) - self.height, self.width, self.height,
            self.foregroundColor, self.backgroundColor, self.logFont,
            flags['Password'], flags['AlignCenter'], flags['AlignRight'],
            flags['Uppercase'], flags['Lowercase'], flags['ReadOnly'],
            flags['Multiline'], flags['Transparent'], flags['Border'])
        self.player.window.push_handlers(
            on_text_motion=self.widget.on_text_motion,
            on_text=self.widget.on_text,
            on_text_motion_select=self.widget.on_text_motion_select)
 def created(self, data):
     self.width = width = data.readShort()
     self.height = height = data.readShort()
     from mmfparser.data.font import LogFont
     self.font = font = LogFont(data, old = True)
     listFontColor = data.readColor()
     data.skipBytes(40)
示例#3
0
    def write_init(self, writer):
        data = self.get_data()
        width = data.readShort(True)
        height = data.readShort(True)
        log_font = LogFont(data, old=True)
        font_color = data.readColor()
        font_style = data.readString(40)
        flags = data.readInt(True)
        line_count = data.readShort(True)
        bg_color = data.readColor()
        data.skipBytes(12)

        writer.putlnc('width = %s;', width)
        writer.putlnc('height = %s;', height)
        writer.putlnc('combo_box.m_BackgroundColor = Gwen::Color%s;', bg_color)
        writer.putlnc('Gwen::Color font_color%s;', font_color)
        writer.putlnc('combo_box.SetTextColorOverride(font_color);')
        writer.putlnc('combo_box.m_Menu->m_Color = font_color;')
        writer.putlnc(
            'combo_box.m_Menu->m_BackgroundColor = combo_box.m_BackgroundColor;'
        )

        for _ in xrange(0, line_count):
            line = data.readString()
            writer.putlnc('combo_box.AddItem(L"%s");', line)
示例#4
0
    def write_init(self, writer):
        data = self.get_data()
        width = data.readShort()
        height = data.readShort()
        writer.putlnc('width = %s;', width)
        writer.putlnc('height = %s;', height)
        width_def = data.readShort()
        height_def = data.readShort()

        images = []
        for _ in xrange(16):
            images.append(data.readShort())

        image_count = data.readShort()
        images = images[:image_count]

        load_first = data.readByte() != 0  # always true!
        use_abs = data.readByte() != 0
        threaded_io = data.readByte() != 0  # unused (I bet)
        keep_points = data.readByte() != 0  # unused
        multi_imgs = data.readByte() != 0
        disp_target = data.readByte() != 0
        select_last = data.readByte() != 0  # always false!

        data.skipBytes(3)  # what is this

        font = LogFont(data)
        color = data.readColor()
        flags = data.readInt()

        writer.putlnc('display_selected = %s;', disp_target)
        writer.putlnc('use_abs_coords = %s;', use_abs)

        image_names = [self.converter.get_image(image) for image in images]

        if multi_imgs:
            if image_count == 0:
                writer.putln('images.resize(1);')
                writer.putln('images[0].reset(width, height);')
            else:
                writer.putlnc('images.resize(%s);', image_count)

            for i, image in enumerate(images):
                # non-blank images
                if image != -1:
                    writer.putlnc('images[%s].set_image(%s);', i,
                                  image_names[i])
                else:
                    writer.putlnc('images[%s].reset();', i)
        else:
            writer.putln('images.resize(1);')
            # single image
            if image_count > 0 and images[0] != -1:
                writer.putlnc('images[0].set_image(%s);', image_names[0])
            else:
                writer.putlnc('images[0].reset(width, height);')
        # load_first always true -> there will always be an image 0
        writer.putln('set_edit_image(0, true);')
示例#5
0
 def created(self, data):
     self.flags = flags = BitDict('HideOnStart', 'DisableOnStart',
                                  'TextOnLeft', 'Transparent',
                                  'SystemColor')
     strings = []
     width = data.readShort()
     height = data.readShort()
     self.buttonType = buttonType = data.readShort()
     self.buttonCount = buttonCount = data.readShort()
     flags.setFlags(data.readInt())
     self.font = LogFont(data)
     self.fontColor = data.readColor()
     self.backColor = data.readColor()
     if self.flags['SystemColor']:
         self.backColor = (255, 255, 255)
     buttonImages = [data.readShort() for _ in xrange(3)]
     if buttonType in (PUSHBITMAP_BUTTON, PUSHTEXTBITMAP_BUTTON):
         self.textures = textures = []
         for item in buttonImages:
             textures.append(
                 self.make_image_handle(item) if item != -1 else None)
     if buttonType == PUSHBITMAP_BUTTON:
         width = max([item.width
                      for item in textures if item is not None] + [32])
         height = max(
             [item.height for item in textures if item is not None] + [32])
     data.readShort()  # fourth word in img array
     data.readInt()  # ebtnSecu
     align = data.readShort()
     tooltip = ''
     if buttonType == RADIO_BUTTON:
         strings = [data.readString() for _ in xrange(buttonCount)]
     else:
         strings.append(data.readString())
         tooltip = data.readString()
     self.values = [False for _ in xrange(buttonCount)]
     self.width = width
     self.height = height
     self.strings = strings
     self.tooltip = tooltip
     self.enable_mouse()
     if flags['DisableOnStart']:
         value = False
     else:
         value = True
     self.enabled = [value for _ in xrange(self.buttonCount)]
     if flags['HideOnStart']:
         self.parent.visible = False
     self.setup()
    def write_init(self, writer):
        if not self.has_updates():
            return
        data = self.get_data()
        width = data.readShort(True)
        height = data.readShort(True)
        logFont = LogFont(data, old=True)
        data.skipBytes(4 * 16)  # custom colors?
        foregroundColor = data.readColor()
        backgroundColor = data.readColor()
        data.skipBytes(40)  # text-style?
        flags = EDIT_FLAGS.copy()
        flags.setFlags(data.readInt())

        writer.putlnc('width = %s;', width)
        writer.putlnc('height = %s;', height)
        if flags['Password']:
            writer.putlnc('edit_flags |= PASSWORD;')
示例#7
0
    def write_init(self, writer):
        if not self.has_updates():
            return
        flags = BUTTON_FLAGS.copy()
        data = self.get_data()
        width = data.readShort(True)
        height = data.readShort(True)
        writer.putlnc('width = %s;', width)
        writer.putlnc('height = %s;', height)
        button_type = data.readShort()
        button_count = data.readShort()
        button_flags = []
        if button_type == CHECKBOX_BUTTON:
            button_flags += ['IS_CHECKBOX']
        if button_flags:
            button_flags = ' | '.join(button_flags)
        else:
            button_flags = '0'
        writer.putlnc('init_button(%s);', button_flags)
        flags.setFlags(data.readInt())
        font = LogFont(data)
        font_color = data.readColor()
        back_color = data.readColor()
        if flags['SystemColor']:
            back_color = (255, 255, 255)
        images = [data.readShort() for _ in xrange(3)]
        data.readShort()  # fourth word in img array
        data.readInt()  # ebtnSecu
        align = data.readShort()
        tooltip = ''
        strings = []
        if button_type == RADIO_BUTTON:
            strings = [data.readString() for _ in xrange(button_count)]
        else:
            strings.append(data.readString())
            tooltip = data.readString()

        if flags['DisableOnStart']:
            writer.putlnc('disable();')
    def created(self, data):
        self.flags = flags = BitDict('FreeFlag', 'VerticalScrollbar', 'Sort',
                                     'Border', 'HideOnStart', 'SystemColor',
                                     '3DLook', 'ScrollToNewline')
        self.width = data.readShort()
        self.height = data.readShort()
        # XXX support unicode
        self.font = font = LogFont(data, old=True)
        self.fontColor = data.readColor()
        data.readString(40)
        data.skipBytes(16 * 4)
        self.backColor = data.readColor()
        flags.setFlags(data.readInt())
        lineCount = data.readShort(True)
        self.indexOffset = -1 if data.readInt() == 1 else 0
        data.skipBytes(4 * 3)
        lines = []
        for _ in xrange(lineCount):
            lines.append(data.readString())

        if flags['HideOnStart']:
            self.parent.visible = False

        self.listObject = self.new(List)
        self.listObject.initialize(0,
                                   0,
                                   self.width,
                                   self.height,
                                   border=flags['Border'],
                                   border3d=flags['3DLook'],
                                   scrollBar=flags['VerticalScrollbar'],
                                   backColor=self.backColor,
                                   font=font,
                                   fontColor=self.fontColor)

        self.enable_mouse()

        self.listObject.extend(lines)
示例#9
0
    def write_init(self, writer):
        data = self.get_data()
        flags = BitDict('FreeFlag', 'VerticalScrollbar', 'Sort', 'Border',
                        'HideOnStart', 'SystemColor', '3DLook',
                        'ScrollToNewline')
        width = data.readShort()
        height = data.readShort()
        # XXX support unicode
        font = LogFont(data, old=True)
        font_color = data.readColor()
        data.readString(40)
        data.skipBytes(16 * 4)
        back_color = data.readColor()
        flags.setFlags(data.readInt())
        line_count = data.readShort(True)
        index_offset = -1 if data.readInt() == 1 else 0
        data.skipBytes(4 * 3)
        lines = []
        for _ in xrange(line_count):
            line = data.readString()
            writer.putln(to_c('add_line(%r);', line))

        if flags['HideOnStart']:
            writer.putln('set_visible(false);')
    def write_init(self, writer):
        data = self.get_data()
        # data.skipBytes(4)

        width = data.readShort(True)
        height = data.readShort(True)
        writer.putlnc('width = %s;', width)
        writer.putlnc('height = %s;', height)

        flags = FLAGS.copy()
        flags.setFlags(data.readInt())
        self.show_border = flags['ShowButtonBorder']
        self.image_checkbox = flags['ImageCheckbox']
        if flags['Hyperlink']:
            display_type = HYPERLINK
        elif flags['Button']:
            if flags['Checkbox']:
                display_type = CHECKBOX
            else:
                display_type = BUTTON
        else:
            display_type = NONE
        align_top_left = flags['AlignImageTopLeft']
        align_center = flags['AlignImageCenter']
        pattern = flags['AlignImagePattern']
        fill = read_system_color(data)
        border1 = read_system_color(data)
        border2 = read_system_color(data)
        self.image = data.readShort()

        if self.image == -1:
            writer.putln('image = NULL;')
            writer.putlnc('blend_color = %s;', make_color(fill))
        else:
            writer.putln('image = %s;' % self.converter.get_image(self.image))
            if pattern:
                writer.putln('type = PATTERN_IMAGE;')
            elif align_center:
                writer.putln('type = CENTER_IMAGE;')
            elif align_top_left:
                writer.putln('type = TOPLEFT_IMAGE;')
            else:
                raise NotImplementedError()

        data.skipBytes(2)  # rData_wFree
        text_color = read_system_color(data)
        margin_left = data.readShort()
        margin_top = data.readShort()
        margin_right = data.readShort()
        margin_bottom = data.readShort()

        font = LogFont(data, old=True)
        data.skipBytes(40)  # file.readStringSize(40)
        data.adjust(8)
        text = data.readReader(data.readInt(True)).readString().rsplit(
            '\\n', 1)
        if len(text) == 1:
            text, = text
            tooltip = None
        else:
            text, tooltip = text
        new_width = width - margin_left - margin_right
        new_height = height - margin_top - margin_bottom

        if text:
            writer.putlnc('text = %r;', text)

        if flags['AlignTop']:
            y_align = 'top'
        elif flags['AlignVerticalCenter']:
            y_align = 'center'
        elif flags['AlignBottom']:
            y_align = 'bottom'

        if flags['AlignLeft']:
            x_align = 'left'
        elif flags['AlignHorizontalCenter']:
            x_align = 'center'
        elif flags['AlignRight']:
            x_align = 'right'

        version = data.readInt()
        hyperlink_color = read_system_color(data)
示例#11
0
 def created(self, data):
     self.savedPlayers = [0 for _ in xrange(4)]
     self.scoreCount = data.readShort(True)
     self.nameLength = data.readShort(True)
     self.flags = HIGHSCORE_FLAGS.copy()
     self.flags.setFlags(data.readShort(True))
     if self.flags['HideOnStart']:
         self.parent.visible = False
     self.hideScores = self.flags['HideScores']
     self.nameFirst = self.flags['NameFirst'] or self.hideScores
     self.font = LogFont(data, old=True)
     self.color = data.readColor()
     data.skipBytes(40)
     name_list = []
     score_list = []
     for _ in xrange(20):
         name_list.append(data.readString(41))
     for _ in xrange(20):
         score_list.append(data.readInt())
     self.originalScores = [(name_list[i], score_list[i])
                            for i in xrange(self.scoreCount)]
     self.scores = self.originalScores[:]
     self.width = data.readShort(True)
     self.height = data.readShort(True)
     self.name = data.readString(260)
     self.enable_mouse()
     self.pendingScores = []
     self.set_file(self.name or 'Game.ini')
     if self.flags['CheckOnStart']:
         for index, item in enumerate(self.player.players.items):
             if item.score > self.scores[-1][1]:
                 self.pendingScores.insert(0, (item.score, index + 1))
     self.nameLabel = Label('Enter your name',
                            color=(0, 0, 0, 255),
                            bold=True,
                            anchor_x='center',
                            anchor_y='center',
                            y=25)
     self.currentName = Label('',
                              color=(0, 0, 0, 255),
                              anchor_x='center',
                              anchor_y='center',
                              width=BOX_WIDTH - 20)
     self.labels = labels = []
     height = self.height / self.scoreCount
     y = 0
     for name, score in self.scores:
         label1 = self.create_label(self.font, '', self.color, self.width,
                                    self.height)
         label2 = self.create_label(self.font, '', self.color, self.width,
                                    self.height)
         label2.set_style('align', 'right')
         for label in (label1, label2):
             label.y = y
         labels.append((label1, label2))
         y -= height
     self.update_labels()
     self.updateEnabled = True
     self.player.window.push_handlers(on_text_motion=self.on_text_motion,
                                      on_text=self.on_text,
                                      on_key_press=self.on_key_press)
示例#12
0
    def write_init(self, writer):
        data = self.get_data()
        # data.skipBytes(4)

        width = data.readShort(True)
        height = data.readShort(True)
        writer.putlnc('width = %s;', width)
        writer.putlnc('height = %s;', height)

        flags = FLAGS.copy()
        flags.setFlags(data.readInt())
        self.show_border = flags['ShowButtonBorder']
        self.image_checkbox = flags['ImageCheckbox']
        if flags['Hyperlink']:
            display_type = HYPERLINK
        elif flags['Button']:
            if flags['Checkbox']:
                display_type = CHECKBOX
            else:
                display_type = BUTTON
        else:
            display_type = NONE

        align_top_left = flags['AlignImageTopLeft']
        align_center = flags['AlignImageCenter']
        pattern = flags['AlignImagePattern']
        fill = read_system_color(data)
        border1 = read_system_color(data)
        border2 = read_system_color(data)
        self.image = data.readShort()

        data.skipBytes(2)  # rData_wFree
        text_color = read_system_color(data)
        margin_left = data.readShort()
        margin_top = data.readShort()
        margin_right = data.readShort()
        margin_bottom = data.readShort()

        font = LogFont(data, old=True)
        data.skipBytes(40)  # file.readStringSize(40)
        data.adjust(8)
        text = data.readReader(data.readInt(True)).readString().rsplit(
            '\\n', 1)
        if len(text) == 1:
            text, = text
            tooltip = None
        else:
            text, tooltip = text
        new_width = width - margin_left - margin_right
        new_height = height - margin_top - margin_bottom

        alignment = []
        if flags['AlignTop']:
            alignment.append('ALIGN_TOP')
        elif flags['AlignVerticalCenter']:
            alignment.append('ALIGN_VCENTER')
        elif flags['AlignBottom']:
            alignment.append('ALIGN_BOTTOM')

        if flags['AlignLeft']:
            alignment.append('ALIGN_LEFT')
        elif flags['AlignHorizontalCenter']:
            alignment.append('ALIGN_HCENTER')
        elif flags['AlignRight']:
            alignment.append('ALIGN_RIGHT')

        if alignment:
            alignment = ' | '.join(alignment)
        else:
            alignment = '0'

        if self.image == -1:
            writer.putln('image = NULL;')
            if border1 is None or fill is None:
                color = (0, 0, 0, 0)
            else:
                color = fill + (255, )
            writer.putlnc('box_color = %s;', make_color(color))
            writer.putlnc('blend_color = %s;', make_color(text_color))
            writer.putlnc('box_flags = %s;', alignment)
        else:
            writer.putln('image = %s;' % self.converter.get_image(self.image))
            if pattern:
                writer.putln('type = PATTERN_IMAGE;')
            elif align_center:
                writer.putln('type = CENTER_IMAGE;')
            elif align_top_left:
                writer.putln('type = TOPLEFT_IMAGE;')
            else:
                raise NotImplementedError()

        if text:
            writer.putlnc('text = %r;', text)

        version = data.readInt()
        hyperlink_color = read_system_color(data)

        if self.converter.config.use_gwen():
            writer.putlnc('margin[0] = %s;', margin_left)
            writer.putlnc('margin[1] = %s;', margin_top)
            writer.putlnc('margin[2] = %s;', margin_right)
            writer.putlnc('margin[3] = %s;', margin_bottom)
            if flags['Button']:
                writer.putlnc('init_button();')
示例#13
0
    def created(self, data):
        self.width = data.readShort(True)
        self.height = data.readShort(True)
        data.skipBytes(4 * 16)
        displayType = self.displayType = data.readShort(True)
        self.clockMode = data.readShort(True)
        self.drawBorder = data.readShort() != 0
        self.drawLines = data.readShort() != 0
        analogClockMarkerType = data.readShort(True)
        font = LogFont(data)
        if font.height in (8, -8) and font.faceName.lower() == 'system':
            font.height = -13
            font.weight = 700
        color = self.color = data.readColor()
        data.skipBytes(40)
        
        self.displaySeconds = data.readShort(True) != 0
        self.secondsColor = data.readColor()
        self.displayMinutes = data.readShort(True) != 0
        self.minutesColor = data.readColor()
        self.displayHours = data.readShort(True) != 0
        self.hoursColor = data.readColor()
        
        digitalClockType = data.readShort(True)
        calenderType = data.readShort(True)
        calenderFormat = data.readShort(True)
        data.skipBytes(40)
        
        if self.clockMode == COUNTDOWN:
            countHours = data.readShort(True)
            countMinutes = data.readShort(True)
            countSeconds = data.readShort(True)
            self.currentTime = (countSeconds + countMinutes * 60 + 
                countHours * 60 * 60)
        elif self.clockMode == CLOCK:
            self.currentTime = time.time()
        
        minWidth = data.readShort(True)
        minHeight = data.readShort(True)
    
        if displayType == ANALOG_CLOCK:
            if analogClockMarkerType != 2:
                self.clockLabels = []
                for i in xrange(1, 13):
                    if analogClockMarkerType == 0:
                        text = str(i)
                    else:
                        text = roman_characters[i-1]
                    label = self.create_label(font, text, color)
                    label.width = label.content_width
                    label.height = label.content_height
                    label.y = label.content_height / 2
                    label.x = -label.content_width / 2
                    self.clockLabels.append(label)
            self.make_border()
        elif displayType == DIGITAL_CLOCK:
            if digitalClockType == 0:
                formatString = '%(hour)s:%(minute)s'
            elif digitalClockType == 1:
                formatString = '%(hour)s:%(minute)s:%(second)s'
            elif digitalClockType == 2:
                formatString = '%(full_hour)s:%(minute)s'
            elif digitalClockType == 3:
                formatString = '%(full_hour)s:%(minute)s:%(second)s'
            self.formatString = formatString
        elif displayType == CALENDAR:
            if calenderType == SHORTDATE:
                formatString = '%d-%m-%Y'
            elif calenderType == LONGDATE:
                formatString = '%d. %B %Y'
            else:
                if calenderFormat == 0:
                    formatString = '%d/%m/%y'
                elif calenderFormat == 1:
                    formatString = '%d %B %Y'
                elif calenderFormat == 2:
                    formatString = '%d %B, %Y'
                elif calenderFormat == 3:
                    formatString = '%B %d, %Y'
                elif calenderFormat == 4:
                    formatString = '%d-%b-%y'
                elif calenderFormat == 5:
                    formatString = '%B, %y'
                elif calenderFormat == 6:
                    formatString = '%b-%Y'
            self.formatString = formatString
        if displayType in (DIGITAL_CLOCK, CALENDAR):
            label = self.label = self.create_label(font, '', color, 
                multiline = True)
            label.height = self.height
            label.width = self.width
            label.content_valign = 'center'
            label.set_style('align', 'center')
            label.x = label.y = 0

        glEnable(GL_LINE_SMOOTH)
        glEnable(GL_POINT_SMOOTH)
        
        self.updateEnabled = True
示例#14
0
    def created(self, data):
        self.width = data.readShort(True)
        self.height = data.readShort(True)
        data.skipBytes(4 * 16)
        displayType = self.displayType = data.readShort(True)
        self.clockMode = data.readShort(True)
        self.drawBorder = data.readShort() != 0
        self.drawLines = data.readShort() != 0
        analogClockMarkerType = data.readShort(True)
        font = LogFont(data)
        if font.height in (8, -8) and font.faceName.lower() == 'system':
            font.height = -13
            font.weight = 700
        color = self.color = data.readColor()
        data.skipBytes(40)

        self.displaySeconds = data.readShort(True) != 0
        self.secondsColor = data.readColor()
        self.displayMinutes = data.readShort(True) != 0
        self.minutesColor = data.readColor()
        self.displayHours = data.readShort(True) != 0
        self.hoursColor = data.readColor()

        digitalClockType = data.readShort(True)
        calenderType = data.readShort(True)
        calenderFormat = data.readShort(True)
        data.skipBytes(40)

        if self.clockMode == COUNTDOWN:
            countHours = data.readShort(True)
            countMinutes = data.readShort(True)
            countSeconds = data.readShort(True)
            self.currentTime = (countSeconds + countMinutes * 60 +
                                countHours * 60 * 60)
        elif self.clockMode == CLOCK:
            self.currentTime = time.time()

        minWidth = data.readShort(True)
        minHeight = data.readShort(True)

        if displayType == ANALOG_CLOCK:
            if analogClockMarkerType != 2:
                self.clockLabels = []
                for i in xrange(1, 13):
                    if analogClockMarkerType == 0:
                        text = str(i)
                    else:
                        text = roman_characters[i - 1]
                    label = self.create_label(font, text, color)
                    label.width = label.content_width
                    label.height = label.content_height
                    label.y = label.content_height / 2
                    label.x = -label.content_width / 2
                    self.clockLabels.append(label)
            self.make_border()
        elif displayType == DIGITAL_CLOCK:
            if digitalClockType == 0:
                formatString = '%(hour)s:%(minute)s'
            elif digitalClockType == 1:
                formatString = '%(hour)s:%(minute)s:%(second)s'
            elif digitalClockType == 2:
                formatString = '%(full_hour)s:%(minute)s'
            elif digitalClockType == 3:
                formatString = '%(full_hour)s:%(minute)s:%(second)s'
            self.formatString = formatString
        elif displayType == CALENDAR:
            if calenderType == SHORTDATE:
                formatString = '%d-%m-%Y'
            elif calenderType == LONGDATE:
                formatString = '%d. %B %Y'
            else:
                if calenderFormat == 0:
                    formatString = '%d/%m/%y'
                elif calenderFormat == 1:
                    formatString = '%d %B %Y'
                elif calenderFormat == 2:
                    formatString = '%d %B, %Y'
                elif calenderFormat == 3:
                    formatString = '%B %d, %Y'
                elif calenderFormat == 4:
                    formatString = '%d-%b-%y'
                elif calenderFormat == 5:
                    formatString = '%B, %y'
                elif calenderFormat == 6:
                    formatString = '%b-%Y'
            self.formatString = formatString
        if displayType in (DIGITAL_CLOCK, CALENDAR):
            label = self.label = self.create_label(font,
                                                   '',
                                                   color,
                                                   multiline=True)
            label.height = self.height
            label.width = self.width
            label.content_valign = 'center'
            label.set_style('align', 'center')
            label.x = label.y = 0

        glEnable(GL_LINE_SMOOTH)
        glEnable(GL_POINT_SMOOTH)

        self.updateEnabled = True
示例#15
0
    def created(self, data):
        self.width = data.readShort(True)
        self.height = data.readShort(True)
        self.flags = flags = FLAGS.copy()
        self.flags.setFlags(data.readInt())
        self.showBorder = flags['ShowButtonBorder']
        self.imageCheckbox = flags['ImageCheckbox']
        if flags['Hyperlink']:
            self.displayType = HYPERLINK
        elif flags['Button']:
            if flags['Checkbox']:
                self.displayType = CHECKBOX
            else:
                self.displayType = BUTTON
        else:
            self.displayType = NONE
        self.alignTopLeft = flags['AlignImageTopLeft']
        self.alignCenter = flags['AlignImageCenter']
        self.pattern = flags['AlignImagePattern']
        self.fill = read_system_color(data)
        self.border1 = read_system_color(data)
        self.border2 = read_system_color(data)
        image = data.readShort()
        if image != -1:
            self.imageSprite = sprite = self.make_sprite(
                self.make_image_handle(image))
            if self.alignCenter:
                sprite.shape.left = -sprite.width / 2
                sprite.shape.bottom = -sprite.height / 2
        data.skipBytes(2)  # rData_wFree
        self.textColor = textColor = read_system_color(data)
        marginLeft = data.readShort()
        marginTop = data.readShort()
        marginRight = data.readShort()
        marginBottom = data.readShort()
        self.margin = (marginLeft, marginTop, marginRight, marginBottom)
        # XXX support unicode when the unicode build is out!
        logFont = self.font = LogFont(data, old=True)
        data.skipBytes(40)  # file.readStringSize(40)
        data.adjust(8)
        text = data.readReader(data.readInt(True)).readString().rsplit(
            '\\n', 1)
        if len(text) == 1:
            text, = text
            tooltip = None
        else:
            text, tooltip = text
        self.tooltip = tooltip
        width = self.width - marginLeft - marginRight
        height = self.height - marginTop - marginBottom

        self.label = self.create_label(logFont, text, textColor or (0, 0, 0),
                                       width, height)
        self.set_position(0, 0)

        if flags['AlignTop']:
            verticalAlignment = 'top'
        elif flags['AlignVerticalCenter']:
            verticalAlignment = 'center'
        elif flags['AlignBottom']:
            verticalAlignment = 'bottom'

        if flags['AlignLeft']:
            horizontalAlignment = 'left'
        elif flags['AlignHorizontalCenter']:
            horizontalAlignment = 'center'
        elif flags['AlignRight']:
            horizontalAlignment = 'right'

        self.label.content_valign = verticalAlignment
        self.label.set_style('align', horizontalAlignment)

        version = data.readInt()
        self.hyperlinkColor = read_system_color(data)

        self.enable_mouse()