Пример #1
0
    def _createContentWidgets(self):
        self.settingsStaticBox = wx.StaticBox(
            self, wx.ID_ANY,
            _extstr(u"tabledialog.TableSettings"))  #$NON-NLS-1$
        if self.model.isInsertMode():
            self.rowsLabel = wx.StaticText(
                self, wx.ID_ANY, u"%s:" %
                _extstr(u"tabledialog.Rows"))  #$NON-NLS-1$ #$NON-NLS-2$
            self.rowsText = ZValidatingTextCtrl(
                ZIntegerSelectionValidator(
                    flags=ZIntegerSelectionValidator.POSITIVE_ONLY), self,
                wx.ID_ANY)
            self.colsLabel = wx.StaticText(
                self, wx.ID_ANY, u"%s:" %
                _extstr(u"tabledialog.Cols"))  #$NON-NLS-1$ #$NON-NLS-2$
            self.colsText = ZValidatingTextCtrl(
                ZIntegerSelectionValidator(
                    flags=ZIntegerSelectionValidator.POSITIVE_ONLY), self,
                wx.ID_ANY)

        flags = ZCssLengthSelectionValidator.ALLOW_EMPTY

        self.paddingLabel = wx.StaticText(
            self, wx.ID_ANY, u"%s:" %
            _extstr(u"tabledialog.CellPadding"))  #$NON-NLS-1$ #$NON-NLS-2$
        self.paddingText = ZValidatingTextCtrl(
            ZCssLengthSelectionValidator(flags=flags), self, wx.ID_ANY)
        self.spacingLabel = wx.StaticText(
            self, wx.ID_ANY, u"%s:" %
            _extstr(u"tabledialog.CellSpacing"))  #$NON-NLS-1$ #$NON-NLS-2$
        self.spacingText = ZValidatingTextCtrl(
            ZCssLengthSelectionValidator(flags=flags), self, wx.ID_ANY)
        self.borderLabel = wx.StaticText(
            self, wx.ID_ANY,
            u"%s:" % _extstr(u"tabledialog.Border"))  #$NON-NLS-1$ #$NON-NLS-2$
        self.borderText = ZValidatingTextCtrl(
            ZCssLengthSelectionValidator(flags=flags), self, wx.ID_ANY)
        self.widthLabel = wx.StaticText(
            self, wx.ID_ANY,
            u"%s:" % _extstr(u"tabledialog.Width"))  #$NON-NLS-1$ #$NON-NLS-2$
        self.widthText = ZValidatingTextCtrl(ZCssLengthSelectionValidator(),
                                             self, wx.ID_ANY)
Пример #2
0
    def _createNonHeaderWidgets(self):
        self.imagePropsStaticBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"imagedialog.ImageProperties")) #$NON-NLS-1$
        self.sizeStaticBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"imagedialog.Size")) #$NON-NLS-1$
        self.alignmentStaticBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"imagedialog.Alignment")) #$NON-NLS-1$
        self.borderStaticBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"imagedialog.Border")) #$NON-NLS-1$

        self.srcLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Src")) #$NON-NLS-1$ #$NON-NLS-2$
        self.altTextLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.ALTText")) #$NON-NLS-1$ #$NON-NLS-2$
        self.titleLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Title")) #$NON-NLS-1$ #$NON-NLS-2$
        self.classLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Class")) #$NON-NLS-1$ #$NON-NLS-2$

        self.widthLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Width")) #$NON-NLS-1$ #$NON-NLS-2$
        self.heightLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Height")) #$NON-NLS-1$ #$NON-NLS-2$
        wildcard = u"Image files|*.gif;*.jpg;*.png;*.jpeg" #$NON-NLS-1$
        self.filePicker = wx.FilePickerCtrl(self, wildcard=wildcard,style=wx.FLP_OPEN|wx.FLP_FILE_MUST_EXIST )#|wx.FLP_USE_TEXTCTRL)

        self.srcText = ZValidatingTextCtrl(ZFileUrlSelectionValidator(_extstr(u"imagedialog.InvalidImageURLError")), self, wx.ID_ANY) #$NON-NLS-1$
        self.altText = wx.TextCtrl(self, wx.ID_ANY)
        self.titleText = wx.TextCtrl(self, wx.ID_ANY)
        self.classText = wx.TextCtrl(self, wx.ID_ANY)

        self.lockAspect = wx.CheckBox(self,wx.ID_ANY, u"%s" % _extstr(u"imagedialog.LockAspect")) #$NON-NLS-2$ #$NON-NLS-1$
        flags = ZIntegerSelectionValidator.ALLOW_EMPTY | ZIntegerSelectionValidator.ALLOW_ZERO | ZIntegerSelectionValidator.POSITIVE_ONLY
        self.widthText = ZValidatingTextCtrl(ZIntegerSelectionValidator(flags=flags), self, wx.ID_ANY)
        self.heightText = ZValidatingTextCtrl(ZIntegerSelectionValidator(flags=flags), self, wx.ID_ANY)

        alignments = []
        for aname in ZImageAlignMenuLabels.ALIGN_KEYWORDS:
            alignments.append( ZImageAlignMenuLabels.ALIGN_LABELS[aname] ) #$NON-NLS-1$
        self.alignChoices = wx.Choice(self, wx.ID_ANY, (100, 50), choices = alignments)

        self.borderStyleLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Style")) #$NON-NLS-1$ #$NON-NLS-2$
        self.borderWidthLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Width")) #$NON-NLS-1$ #$NON-NLS-2$
        self.borderColorLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Color")) #$NON-NLS-1$ #$NON-NLS-2$
        
        borders = []
        for bname in ZImageBorderMenuLabels.BORDER_KEYWORDS:
            borders.append( ZImageBorderMenuLabels.BORDER_LABELS[bname] )
        
        self.borderStyles = wx.Choice(self, wx.ID_ANY, (200, 50), choices = borders)

        self.borderWidthValidator = ZCssLengthSelectionValidator()
        self.borderWidthText = ZValidatingTextCtrl(self.borderWidthValidator, self, wx.ID_ANY)
        self.borderColorPicker = wx.ColourPickerCtrl(self)

        self.marginStaticBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"imagedialog.Margin")) #$NON-NLS-1$
        self.marginLeftLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Left")) #$NON-NLS-1$ #$NON-NLS-2$
        self.marginRightLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Right")) #$NON-NLS-1$ #$NON-NLS-2$
        self.marginTopLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Top")) #$NON-NLS-1$ #$NON-NLS-2$
        self.marginBotLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Bottom")) #$NON-NLS-1$ #$NON-NLS-2$

        self.marginTopText = ZValidatingTextCtrl(ZCssLengthSelectionValidator(flags=ZCssLengthSelectionValidator.ALLOW_EMPTY), self, wx.ID_ANY)
        self.marginBotText = ZValidatingTextCtrl(ZCssLengthSelectionValidator(flags=ZCssLengthSelectionValidator.ALLOW_EMPTY), self, wx.ID_ANY)
        self.marginLeftText = ZValidatingTextCtrl(ZCssLengthSelectionValidator(flags=ZCssLengthSelectionValidator.ALLOW_EMPTY), self, wx.ID_ANY)
        self.marginRightText = ZValidatingTextCtrl(ZCssLengthSelectionValidator(flags=ZCssLengthSelectionValidator.ALLOW_EMPTY), self, wx.ID_ANY)
Пример #3
0
    def _createNonHeaderWidgets(self):
        self.doNotGenRadioButton = wx.RadioButton(self, wx.ID_ANY, _extstr(u"imagehandlerdialog.DoNotGenerateOption")) #$NON-NLS-1$
        self.genRadioButton = wx.RadioButton(self, wx.ID_ANY, _extstr(u"imagehandlerdialog.GenerateOption")) #$NON-NLS-1$

        self.tnSettingsGroupBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"imagehandlerdialog.ThumbnailSettings")) #$NON-NLS-1$
        self.sizeLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagehandlerdialog.Size")) #$NON-NLS-1$ #$NON-NLS-2$

        sizeChoices = []
        for size in ZThumbnailSizeMenuLabels.SIZE_KEYWORDS:
            sizeChoices.append(ZThumbnailSizeMenuLabels.SIZE_LABELS[size])
        self.sizeChoice = wx.Choice(self, wx.ID_ANY, (100, 50), choices = sizeChoices)

        self.alignLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _blogappextstr(u"imagedialog.Alignment")) #$NON-NLS-1$ #$NON-NLS-2$
        alignments = []
        for aname in ZImageAlignMenuLabels.ALIGN_KEYWORDS:
            alignments.append( ZImageAlignMenuLabels.ALIGN_LABELS[aname] ) #$NON-NLS-1$
        self.alignChoice = wx.Choice(self, wx.ID_ANY, (100, 50), choices = alignments)

        self.borderStaticBox = wx.StaticBox(self, wx.ID_ANY, _blogappextstr(u"imagedialog.Border")) #$NON-NLS-1$
        self.borderStyleLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _blogappextstr(u"imagedialog.Style")) #$NON-NLS-1$ #$NON-NLS-2$
        self.borderWidthLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _blogappextstr(u"imagedialog.Width")) #$NON-NLS-1$ #$NON-NLS-2$
        self.borderColorLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _blogappextstr(u"imagedialog.Color")) #$NON-NLS-1$ #$NON-NLS-2$

        borders = []
        for bname in ZImageBorderMenuLabels.BORDER_KEYWORDS:
            borders.append( ZImageBorderMenuLabels.BORDER_LABELS[bname] )
        self.borderStyleChoice = wx.Choice(self, wx.ID_ANY, (200, 50), choices = borders)

        self.borderWidthValidator = ZCssLengthSelectionValidator()
        self.borderWidthText = ZValidatingTextCtrl(self.borderWidthValidator, self, wx.ID_ANY)
        self.borderColorPicker = wx.ColourPickerCtrl(self)

        self.marginStaticBox = wx.StaticBox(self, wx.ID_ANY, _blogappextstr(u"imagedialog.Margin")) #$NON-NLS-1$
        self.marginLeftLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _blogappextstr(u"imagedialog.Left")) #$NON-NLS-1$ #$NON-NLS-2$
        self.marginRightLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _blogappextstr(u"imagedialog.Right")) #$NON-NLS-1$ #$NON-NLS-2$
        self.marginTopLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _blogappextstr(u"imagedialog.Top")) #$NON-NLS-1$ #$NON-NLS-2$
        self.marginBotLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _blogappextstr(u"imagedialog.Bottom")) #$NON-NLS-1$ #$NON-NLS-2$

        self.marginTopText = ZValidatingTextCtrl(ZCssLengthSelectionValidator(flags=ZCssLengthSelectionValidator.ALLOW_EMPTY), self, wx.ID_ANY, size=wx.Size(25, -1))
        self.marginBotText = ZValidatingTextCtrl(ZCssLengthSelectionValidator(flags=ZCssLengthSelectionValidator.ALLOW_EMPTY), self, wx.ID_ANY, size=wx.Size(25, -1))
        self.marginLeftText = ZValidatingTextCtrl(ZCssLengthSelectionValidator(flags=ZCssLengthSelectionValidator.ALLOW_EMPTY), self, wx.ID_ANY, size=wx.Size(25, -1))
        self.marginRightText = ZValidatingTextCtrl(ZCssLengthSelectionValidator(flags=ZCssLengthSelectionValidator.ALLOW_EMPTY), self, wx.ID_ANY, size=wx.Size(25, -1))
Пример #4
0
class ZImageDialog(ZValidatingHeaderDialog, ZPersistentDialogMixin):
    
    def __init__(self, parent, model):
        # model is instance of ZEditImageModel.
        self.model = model
        self.aspectRatio = 0.0
        
        title = _extstr(u"imagedialog.EditImageInformation") #$NON-NLS-1$
        if not self.model.isEditMode():
            title = _extstr(u"imagedialog.InsertImage") #$NON-NLS-1$
        ZValidatingHeaderDialog.__init__(self, parent, wx.ID_ANY, title, style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, name = u"ZImageDialog") #$NON-NLS-1$

        bestHeight = self.GetBestSizeTuple()[1]
        self.SetMinSize(wx.Size(-1, bestHeight))

        ZPersistentDialogMixin.__init__(self, IZBlogAppUserPrefsKeys.IMAGE_DIALOG, True, True)
    # end __init__()

    def _createNonHeaderWidgets(self):
        self.imagePropsStaticBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"imagedialog.ImageProperties")) #$NON-NLS-1$
        self.sizeStaticBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"imagedialog.Size")) #$NON-NLS-1$
        self.alignmentStaticBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"imagedialog.Alignment")) #$NON-NLS-1$
        self.borderStaticBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"imagedialog.Border")) #$NON-NLS-1$

        self.srcLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Src")) #$NON-NLS-1$ #$NON-NLS-2$
        self.altTextLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.ALTText")) #$NON-NLS-1$ #$NON-NLS-2$
        self.titleLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Title")) #$NON-NLS-1$ #$NON-NLS-2$
        self.classLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Class")) #$NON-NLS-1$ #$NON-NLS-2$

        self.widthLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Width")) #$NON-NLS-1$ #$NON-NLS-2$
        self.heightLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Height")) #$NON-NLS-1$ #$NON-NLS-2$
        wildcard = u"Image files|*.gif;*.jpg;*.png;*.jpeg" #$NON-NLS-1$
        self.filePicker = wx.FilePickerCtrl(self, wildcard=wildcard,style=wx.FLP_OPEN|wx.FLP_FILE_MUST_EXIST )#|wx.FLP_USE_TEXTCTRL)

        self.srcText = ZValidatingTextCtrl(ZFileUrlSelectionValidator(_extstr(u"imagedialog.InvalidImageURLError")), self, wx.ID_ANY) #$NON-NLS-1$
        self.altText = wx.TextCtrl(self, wx.ID_ANY)
        self.titleText = wx.TextCtrl(self, wx.ID_ANY)
        self.classText = wx.TextCtrl(self, wx.ID_ANY)

        self.lockAspect = wx.CheckBox(self,wx.ID_ANY, u"%s" % _extstr(u"imagedialog.LockAspect")) #$NON-NLS-2$ #$NON-NLS-1$
        flags = ZIntegerSelectionValidator.ALLOW_EMPTY | ZIntegerSelectionValidator.ALLOW_ZERO | ZIntegerSelectionValidator.POSITIVE_ONLY
        self.widthText = ZValidatingTextCtrl(ZIntegerSelectionValidator(flags=flags), self, wx.ID_ANY)
        self.heightText = ZValidatingTextCtrl(ZIntegerSelectionValidator(flags=flags), self, wx.ID_ANY)

        alignments = []
        for aname in ZImageAlignMenuLabels.ALIGN_KEYWORDS:
            alignments.append( ZImageAlignMenuLabels.ALIGN_LABELS[aname] ) #$NON-NLS-1$
        self.alignChoices = wx.Choice(self, wx.ID_ANY, (100, 50), choices = alignments)

        self.borderStyleLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Style")) #$NON-NLS-1$ #$NON-NLS-2$
        self.borderWidthLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Width")) #$NON-NLS-1$ #$NON-NLS-2$
        self.borderColorLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Color")) #$NON-NLS-1$ #$NON-NLS-2$
        
        borders = []
        for bname in ZImageBorderMenuLabels.BORDER_KEYWORDS:
            borders.append( ZImageBorderMenuLabels.BORDER_LABELS[bname] )
        
        self.borderStyles = wx.Choice(self, wx.ID_ANY, (200, 50), choices = borders)

        self.borderWidthValidator = ZCssLengthSelectionValidator()
        self.borderWidthText = ZValidatingTextCtrl(self.borderWidthValidator, self, wx.ID_ANY)
        self.borderColorPicker = wx.ColourPickerCtrl(self)

        self.marginStaticBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"imagedialog.Margin")) #$NON-NLS-1$
        self.marginLeftLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Left")) #$NON-NLS-1$ #$NON-NLS-2$
        self.marginRightLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Right")) #$NON-NLS-1$ #$NON-NLS-2$
        self.marginTopLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Top")) #$NON-NLS-1$ #$NON-NLS-2$
        self.marginBotLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Bottom")) #$NON-NLS-1$ #$NON-NLS-2$

        self.marginTopText = ZValidatingTextCtrl(ZCssLengthSelectionValidator(flags=ZCssLengthSelectionValidator.ALLOW_EMPTY), self, wx.ID_ANY)
        self.marginBotText = ZValidatingTextCtrl(ZCssLengthSelectionValidator(flags=ZCssLengthSelectionValidator.ALLOW_EMPTY), self, wx.ID_ANY)
        self.marginLeftText = ZValidatingTextCtrl(ZCssLengthSelectionValidator(flags=ZCssLengthSelectionValidator.ALLOW_EMPTY), self, wx.ID_ANY)
        self.marginRightText = ZValidatingTextCtrl(ZCssLengthSelectionValidator(flags=ZCssLengthSelectionValidator.ALLOW_EMPTY), self, wx.ID_ANY)
    # end _createNonHeaderWidgets()

    def _initAspectRatio(self):
        try:
            self.aspectRatio = (float(self.widthText.GetValue() ) / float(self.heightText.GetValue() ))
        except:
            self.aspectRatio = 0.0
        self.lockAspect.SetValue(self.aspectRatio > 0)
        self.lockAspect.Enable(self.aspectRatio > 0)
    # end _initAspectRatio()

    def _populateNonHeaderWidgets(self):
        self.srcText.SetValue( getSafeString( self.model.getAttribute(u"src") ) ) #$NON-NLS-1$
        self.altText.SetValue( getSafeString( self.model.getAttribute(u"alt") ) ) #$NON-NLS-1$
        self.titleText.SetValue( getSafeString( self.model.getAttribute(u"title") ) ) #$NON-NLS-1$
        self.classText.SetValue( getSafeString( self.model.getAttribute(u"class") ) ) #$NON-NLS-1$

        self.widthText.SetValue( getSafeString( self.model.getAttribute(u"width") ) ) #$NON-NLS-1$
        self.heightText.SetValue( getSafeString( self.model.getAttribute(u"height") ) ) #$NON-NLS-1$
        self._initAspectRatio()

        (top, right, bot, left) = self.model.getMargins()
        self.marginTopText.SetValue(getSafeString(top))
        self.marginRightText.SetValue(getSafeString(right))
        self.marginBotText.SetValue(getSafeString(bot))
        self.marginLeftText.SetValue(getSafeString(left))

        (width, style, cssColor) = self.model.getBorder()
        if cssColor:
            color = wx.Colour(cssColor.getRed(), cssColor.getGreen(), cssColor.getBlue())
            self.borderColorPicker.SetColour(color)
        self.borderWidthText.SetValue(getSafeString(width))
        style = getSafeString(style).lower()
        idx = 0
        try:
            idx = ZImageBorderMenuLabels.BORDER_KEYWORDS.index( style )
        except:
            idx = 0
        self.borderStyles.SetSelection(idx)
        self._updateBorderControlsState()

        align = getSafeString( self.model.getAttribute(u"align") ) #$NON-NLS-1$
        # align = None, Left etc.
        # find index within keywords
        idx = 0
        try:
            idx = ZImageAlignMenuLabels.ALIGN_KEYWORDS.index( align.lower() )
        except:
            idx = 0
        self.alignChoices.SetSelection(idx)

    # end _populateNonHeaderWidgets()

    def _layoutNonHeaderWidgets(self):
        # Image Properties
        srcAndFileSizer = wx.BoxSizer(wx.HORIZONTAL)
        srcAndFileSizer.Add(self.srcText, 1, wx.EXPAND | wx.ALL, 1)
        srcAndFileSizer.Add(self.filePicker, 0, wx.ALL, 1)

        imagePropsGridSizer = wx.FlexGridSizer(4, 2, 2, 2)
        imagePropsGridSizer.AddGrowableCol(1)
        imagePropsGridSizer.Add(self.srcLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1)
        imagePropsGridSizer.AddSizer(srcAndFileSizer, 1, wx.EXPAND | wx.ALL, 1)

        imagePropsGridSizer.Add(self.altTextLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1)
        imagePropsGridSizer.Add(self.altText, 1, wx.EXPAND | wx.ALL, 1)
        imagePropsGridSizer.Add(self.titleLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1)
        imagePropsGridSizer.Add(self.titleText, 1, wx.EXPAND | wx.ALL, 1)
        imagePropsGridSizer.Add(self.classLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1)
        imagePropsGridSizer.Add(self.classText, 1, wx.EXPAND | wx.ALL, 1)

        imagePropsStaticBoxSizer = wx.StaticBoxSizer(self.imagePropsStaticBox, wx.VERTICAL)
        imagePropsStaticBoxSizer.AddSizer(imagePropsGridSizer, 1, wx.EXPAND | wx.ALL, 5)

        # Size
        sizeGridSizer = wx.FlexGridSizer(2, 2, 2, 2)
        sizeGridSizer.Add(self.widthLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1)
        sizeGridSizer.Add(self.widthText, 1, wx.EXPAND | wx.ALL, 1)
        sizeGridSizer.Add(self.heightLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1)
        sizeGridSizer.Add(self.heightText, 1, wx.EXPAND | wx.ALL, 1)

        sizeStaticBoxSizer = wx.StaticBoxSizer(self.sizeStaticBox, wx.VERTICAL)
        sizeStaticBoxSizer.Add(self.lockAspect, 0,  wx.EXPAND | wx.ALL, 5)
        sizeStaticBoxSizer.AddSizer(sizeGridSizer, 1, wx.EXPAND | wx.ALL, 5)

        alignmentStaticBoxSizer = wx.StaticBoxSizer(self.alignmentStaticBox, wx.VERTICAL)
        alignmentStaticBoxSizer.Add(self.alignChoices, 1, wx.EXPAND | wx.ALL, 5)

        # Border
        borderGridSizer = wx.FlexGridSizer(3, 2, 2, 2)
        borderGridSizer.Add(self.borderStyleLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1)
        borderGridSizer.Add(self.borderStyles, 1, wx.EXPAND | wx.ALL, 1)
        borderGridSizer.Add(self.borderWidthLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1)
        borderGridSizer.Add(self.borderWidthText, 1, wx.EXPAND | wx.ALL, 1)
        borderGridSizer.Add(self.borderColorLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1)
        borderGridSizer.Add(self.borderColorPicker, 0,wx.ALL, 1)
        borderStaticBoxSizer = wx.StaticBoxSizer(self.borderStaticBox, wx.VERTICAL)
        borderStaticBoxSizer.AddSizer(borderGridSizer, 1, wx.EXPAND | wx.ALL, 5)

        marginGridSizer = wx.FlexGridSizer(4, 4, 2, 2)
        marginGridSizer.Add(self.marginTopLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1)
        marginGridSizer.Add(self.marginTopText, 1, wx.EXPAND | wx.ALL, 1)
        marginGridSizer.Add(self.marginLeftLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1)
        marginGridSizer.Add(self.marginLeftText, 1, wx.EXPAND | wx.ALL, 1)
        marginGridSizer.Add(self.marginBotLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1)
        marginGridSizer.Add(self.marginBotText, 1, wx.EXPAND | wx.ALL, 1)
        marginGridSizer.Add(self.marginRightLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1)
        marginGridSizer.Add(self.marginRightText, 1, wx.EXPAND | wx.ALL, 1)
        marginStaticBoxSizer = wx.StaticBoxSizer(self.marginStaticBox, wx.VERTICAL)
        marginStaticBoxSizer.AddSizer(marginGridSizer, 1, wx.EXPAND | wx.ALL, 5)


        # Size + Alignment Box Sizer
        sizeAndAlignmentBoxSizer = wx.FlexGridSizer(2, 2, 2, 2)
        sizeAndAlignmentBoxSizer.AddSizer(sizeStaticBoxSizer, 1, wx.EXPAND | wx.ALL, 2)
        sizeAndAlignmentBoxSizer.AddSizer(borderStaticBoxSizer, 1, wx.EXPAND | wx.ALL, 2)
        sizeAndAlignmentBoxSizer.AddSizer(alignmentStaticBoxSizer, 1, wx.EXPAND | wx.ALL, 2)
        sizeAndAlignmentBoxSizer.AddSizer(marginStaticBoxSizer, 1, wx.EXPAND | wx.ALL, 2)

        # Dialog Sizer
        dialogBoxSizer = wx.BoxSizer(wx.VERTICAL)
        dialogBoxSizer.AddSizer(imagePropsStaticBoxSizer, 0, wx.EXPAND | wx.ALL, 5)
        dialogBoxSizer.AddSizer(sizeAndAlignmentBoxSizer, 0, wx.EXPAND | wx.ALL, 5)

        return dialogBoxSizer
    # end _layoutNonHeaderWidgets()

    def _bindWidgetEvents(self):
        self.Bind(wx.EVT_FILEPICKER_CHANGED, self.onFilePickerChanged, self.filePicker)
        self.Bind(wx.EVT_CHOICE, self.onBorderStyleChanged, self.borderStyles)
        self.Bind(wx.EVT_TEXT, self.onImageWidthChange, self.widthText)
        self.Bind(wx.EVT_TEXT, self.onImageHeightChange, self.heightText)

        self._bindValidatingWidget(self.srcText)
        self._bindValidatingWidget(self.widthText)
        self._bindValidatingWidget(self.heightText)
        self._bindValidatingWidget(self.borderWidthText)
        self._bindValidatingWidget(self.marginTopText)
        self._bindValidatingWidget(self.marginRightText)
        self._bindValidatingWidget(self.marginBotText)
        self._bindValidatingWidget(self.marginLeftText)

        self.Bind(wx.EVT_BUTTON, self.onOK, self.FindWindowById(wx.ID_OK))
    # end _bindWidgetEvents()

    def _updateModel(self):
        self.model.setAttribute(u"src", self.srcText.GetValue().strip() ) #$NON-NLS-1$
        self.model.setAttribute(u"alt", self.altText.GetValue().strip() ) #$NON-NLS-1$
        self.model.setAttribute(u"title", self.titleText.GetValue().strip() ) #$NON-NLS-1$
        self.model.setAttribute(u"class", self.classText.GetValue().strip() ) #$NON-NLS-1$

        idx = self.alignChoices.GetSelection()
        if idx >=0 and idx < len(ZImageAlignMenuLabels.ALIGN_KEYWORDS):
            align = ZImageAlignMenuLabels.ALIGN_KEYWORDS[idx]
            self.model.setAttribute(u"align", align.lower() ) #$NON-NLS-1$

        # Width and height
        width = 0
        height = 0
        try:
            width = int(self.widthText.GetValue())
            height = int(self.heightText.GetValue())
        except:
            pass
        if width > 0 and height > 0:
            self.model.setAttribute(u"width", u"%d" % width ) #$NON-NLS-1$ #$NON-NLS-2$
            self.model.setAttribute(u"height", u"%d" % height ) #$NON-NLS-1$ #$NON-NLS-2$
        # Margin
        t = self.marginTopText.GetValue().strip()
        r = self.marginRightText.GetValue().strip()
        b = self.marginBotText.GetValue().strip()
        l = self.marginLeftText.GetValue().strip()
        self.model.setMargins(t,r,b,l)
        # Border
        style = ZImageBorderMenuLabels.BORDER_KEYWORDS[0] # default is None
        idx = self.borderStyles.GetSelection()
        if idx >=0 and idx < len(ZImageBorderMenuLabels.BORDER_KEYWORDS):
            style = ZImageBorderMenuLabels.BORDER_KEYWORDS[idx]
        width = self.borderWidthText.GetValue().strip()
        cssHexColor = self.borderColorPicker.GetColour().GetAsString(wx.C2S_HTML_SYNTAX)
        self.model.setBorder(width, style, cssHexColor)
    # end updateModel

    def onOK(self, event):
        self._updateModel()
        event.Skip()
    # end onOK()

    def onImageHeightChange(self, event): #@UnusedVariable
        if self.lockAspect.IsChecked() and self.aspectRatio > 0:
            try:
                height = int(self.heightText.GetValue())
                width = int(height * self.aspectRatio)
                self.widthText.ChangeValue(unicode(width))
            except:
                pass
            event.Skip()
    # end onImageHeightChange()

    def onImageWidthChange(self, event): #@UnusedVariable
        if self.lockAspect.IsChecked() and self.aspectRatio > 0:
            try:
                width = int(self.widthText.GetValue())
                height = int(width / self.aspectRatio)
                self.heightText.ChangeValue(unicode(height))
            except:
                pass
            event.Skip()
    # end onImageWidthChange()

    def _updateBorderControlsState(self):
        enable = self.borderStyles.GetCurrentSelection() > 0
        if enable:
            self.borderWidthValidator.setFlags(0)
        else:
            self.borderWidthValidator.setFlags(ZCssLengthSelectionValidator.ALLOW_EMPTY)
            self.borderWidthText.validate()

        if enable and not self.borderWidthText.GetValue():
            self.borderWidthText.SetValue(u"1px") #$NON-NLS-1$
        self.borderWidthText.Enable(enable)
        self.borderColorPicker.Enable(enable)
    # end _updateBorderControlsState()

    def onBorderStyleChanged(self, event): #@UnusedVariable
        self._updateBorderControlsState()
    # end onBorderStyleChanged

    def onFilePickerChanged(self, event):
        path = getNoneString( event.GetPath())
        if path:
            self.srcText.SetValue(path)
        event.Skip()
    # end onFilePickerChanged

    def _getHeaderTitle(self):
        if self.model.isEditMode():
            return _extstr(u"imagedialog.Edit_Image") #$NON-NLS-1$
        else:
            return _extstr(u"imagedialog.Insert_Image") #$NON-NLS-1$
    # end _getHeaderTitle()

    def _getHeaderMessage(self):
        if self.model.isEditMode():
            return _extstr(u"imagedialog.ImageDialogEditDescription") #$NON-NLS-1$
        else:
            return _extstr(u"imagedialog.ImageDialogInsertDescription") #$NON-NLS-1$
    # end _getHeaderMessage()

    def _getHeaderImagePath(self):
        return u"images/dialogs/image/header_image.png" #$NON-NLS-1$
    # end _getHeaderImagePath()

    def _getButtonTypes(self):
        return ZBaseDialog.OK_BUTTON | ZBaseDialog.CANCEL_BUTTON
Пример #5
0
class ZThumbnailImageDialog(ZValidatingHeaderDialog, ZPersistentDialogMixin):

    def __init__(self, parent):
        self.model = ZThumbnailImageDialogModel()
        title = _extstr(u"imagehandlerdialog.Generate_Thumbnail") #$NON-NLS-1$
        ZValidatingHeaderDialog.__init__(self, parent, wx.ID_ANY, title, style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, name = u"ZThumbnailImageDialog") #$NON-NLS-1$

        bestHeight = self.GetBestSizeTuple()[1]
        self.SetMinSize(wx.Size(-1, bestHeight))

        ZPersistentDialogMixin.__init__(self, IZBlogAppUserPrefsKeys.DND_THUMBNAIL_DIALOG, True, True)
    # end __init__()

    def _createNonHeaderWidgets(self):
        self.doNotGenRadioButton = wx.RadioButton(self, wx.ID_ANY, _extstr(u"imagehandlerdialog.DoNotGenerateOption")) #$NON-NLS-1$
        self.genRadioButton = wx.RadioButton(self, wx.ID_ANY, _extstr(u"imagehandlerdialog.GenerateOption")) #$NON-NLS-1$

        self.tnSettingsGroupBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"imagehandlerdialog.ThumbnailSettings")) #$NON-NLS-1$
        self.sizeLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagehandlerdialog.Size")) #$NON-NLS-1$ #$NON-NLS-2$

        sizeChoices = []
        for size in ZThumbnailSizeMenuLabels.SIZE_KEYWORDS:
            sizeChoices.append(ZThumbnailSizeMenuLabels.SIZE_LABELS[size])
        self.sizeChoice = wx.Choice(self, wx.ID_ANY, (100, 50), choices = sizeChoices)

        self.alignLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _blogappextstr(u"imagedialog.Alignment")) #$NON-NLS-1$ #$NON-NLS-2$
        alignments = []
        for aname in ZImageAlignMenuLabels.ALIGN_KEYWORDS:
            alignments.append( ZImageAlignMenuLabels.ALIGN_LABELS[aname] ) #$NON-NLS-1$
        self.alignChoice = wx.Choice(self, wx.ID_ANY, (100, 50), choices = alignments)

        self.borderStaticBox = wx.StaticBox(self, wx.ID_ANY, _blogappextstr(u"imagedialog.Border")) #$NON-NLS-1$
        self.borderStyleLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _blogappextstr(u"imagedialog.Style")) #$NON-NLS-1$ #$NON-NLS-2$
        self.borderWidthLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _blogappextstr(u"imagedialog.Width")) #$NON-NLS-1$ #$NON-NLS-2$
        self.borderColorLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _blogappextstr(u"imagedialog.Color")) #$NON-NLS-1$ #$NON-NLS-2$

        borders = []
        for bname in ZImageBorderMenuLabels.BORDER_KEYWORDS:
            borders.append( ZImageBorderMenuLabels.BORDER_LABELS[bname] )
        self.borderStyleChoice = wx.Choice(self, wx.ID_ANY, (200, 50), choices = borders)

        self.borderWidthValidator = ZCssLengthSelectionValidator()
        self.borderWidthText = ZValidatingTextCtrl(self.borderWidthValidator, self, wx.ID_ANY)
        self.borderColorPicker = wx.ColourPickerCtrl(self)

        self.marginStaticBox = wx.StaticBox(self, wx.ID_ANY, _blogappextstr(u"imagedialog.Margin")) #$NON-NLS-1$
        self.marginLeftLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _blogappextstr(u"imagedialog.Left")) #$NON-NLS-1$ #$NON-NLS-2$
        self.marginRightLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _blogappextstr(u"imagedialog.Right")) #$NON-NLS-1$ #$NON-NLS-2$
        self.marginTopLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _blogappextstr(u"imagedialog.Top")) #$NON-NLS-1$ #$NON-NLS-2$
        self.marginBotLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _blogappextstr(u"imagedialog.Bottom")) #$NON-NLS-1$ #$NON-NLS-2$

        self.marginTopText = ZValidatingTextCtrl(ZCssLengthSelectionValidator(flags=ZCssLengthSelectionValidator.ALLOW_EMPTY), self, wx.ID_ANY, size=wx.Size(25, -1))
        self.marginBotText = ZValidatingTextCtrl(ZCssLengthSelectionValidator(flags=ZCssLengthSelectionValidator.ALLOW_EMPTY), self, wx.ID_ANY, size=wx.Size(25, -1))
        self.marginLeftText = ZValidatingTextCtrl(ZCssLengthSelectionValidator(flags=ZCssLengthSelectionValidator.ALLOW_EMPTY), self, wx.ID_ANY, size=wx.Size(25, -1))
        self.marginRightText = ZValidatingTextCtrl(ZCssLengthSelectionValidator(flags=ZCssLengthSelectionValidator.ALLOW_EMPTY), self, wx.ID_ANY, size=wx.Size(25, -1))
    # end _createNonHeaderWidgets()

    def _populateNonHeaderWidgets(self):
        genTNFlag = self.model.generateTNFlag
        self.genRadioButton.SetValue(genTNFlag)
        self.doNotGenRadioButton.SetValue(not genTNFlag)
        self._enableWidgets(genTNFlag)

        tnSize = self._recallThumbnailSize()
        idx = 0
        try:
            idx = ZThumbnailSizeMenuLabels.SIZE_KEYWORDS.index( tnSize )
        except:
            idx = 1
        self.sizeChoice.SetSelection(idx)

        (top, right, bot, left) = self._recallMargins()
        self.marginTopText.SetValue(getSafeString(top))
        self.marginRightText.SetValue(getSafeString(right))
        self.marginBotText.SetValue(getSafeString(bot))
        self.marginLeftText.SetValue(getSafeString(left))

        (width, style, cssColor) = self._recallBorder()
        if cssColor:
            red = cssColor[0]
            green = cssColor[1]
            blue = cssColor[2]
            color = wx.Colour(red, green, blue)
            self.borderColorPicker.SetColour(color)
        self.borderWidthText.SetValue(getSafeString(width))
        style = getSafeString(style).lower()
        idx = 0
        try:
            idx = ZImageBorderMenuLabels.BORDER_KEYWORDS.index( style )
        except:
            idx = 0
        self.borderStyleChoice.SetSelection(idx)
        self._updateBorderControlsState()

        align = getSafeString(self._recallAlignment())
        idx = 0
        try:
            idx = ZImageAlignMenuLabels.ALIGN_KEYWORDS.index( align.lower() )
        except:
            idx = 0
        self.alignChoice.SetSelection(idx)
    # end _populateNonHeaderWidgets()

    def _recallThumbnailSize(self):
        return self.model.size
    # end _recallThumbnailSize()

    def _recallMargins(self):
        return (self.model.marginTop, self.model.marginRight, self.model.marginBottom, self.model.marginLeft)
    # end _recallMargins()

    def _recallBorder(self):
        return (self.model.borderWidth, self.model.borderStyle, self.model.borderColor)
    # end _recallBorder()

    def _recallAlignment(self):
        return self.model.alignment
    # end _recallAlignment()

    def _layoutNonHeaderWidgets(self):
        # Border
        borderGridSizer = wx.FlexGridSizer(3, 2, 2, 2)
        borderGridSizer.Add(self.borderStyleLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1)
        borderGridSizer.Add(self.borderStyleChoice, 1, wx.EXPAND | wx.ALL, 1)
        borderGridSizer.Add(self.borderWidthLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1)
        borderGridSizer.Add(self.borderWidthText, 1, wx.EXPAND | wx.ALL, 1)
        borderGridSizer.Add(self.borderColorLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1)
        borderGridSizer.Add(self.borderColorPicker, 0,wx.ALL, 1)

        # Margins
        marginGridSizer = wx.FlexGridSizer(4, 4, 2, 2)
        marginGridSizer.AddGrowableCol(1)
        marginGridSizer.AddGrowableCol(3)
        marginGridSizer.Add(self.marginTopLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1)
        marginGridSizer.Add(self.marginTopText, 1, wx.EXPAND | wx.ALL, 1)
        marginGridSizer.Add(self.marginLeftLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1)
        marginGridSizer.Add(self.marginLeftText, 1, wx.EXPAND | wx.ALL, 1)
        marginGridSizer.Add(self.marginBotLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1)
        marginGridSizer.Add(self.marginBotText, 1, wx.EXPAND | wx.ALL, 1)
        marginGridSizer.Add(self.marginRightLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1)
        marginGridSizer.Add(self.marginRightText, 1, wx.EXPAND | wx.ALL, 1)

        borderSizer = wx.StaticBoxSizer(self.borderStaticBox, wx.VERTICAL)
        borderSizer.AddSizer(borderGridSizer, 1, wx.EXPAND | wx.ALL, 2)

        marginSizer = wx.StaticBoxSizer(self.marginStaticBox, wx.VERTICAL)
        marginSizer.AddSizer(marginGridSizer, 1, wx.EXPAND | wx.ALL, 2)

        sizeSizer = wx.BoxSizer(wx.HORIZONTAL)
        sizeSizer.Add(self.sizeLabel, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 2)
        sizeSizer.Add(self.sizeChoice, 0, wx.ALL, 2)

        alignSizer = wx.BoxSizer(wx.HORIZONTAL)
        alignSizer.Add(self.alignLabel, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 2)
        alignSizer.Add(self.alignChoice, 0, wx.ALL, 2)

        sizeAndBorderSizer = wx.BoxSizer(wx.VERTICAL)
        sizeAndBorderSizer.AddSizer(sizeSizer, 0, wx.EXPAND | wx.ALL, 1)
        sizeAndBorderSizer.AddSizer(borderSizer, 1, wx.EXPAND | wx.ALL, 1)

        alignAndMarginSizer = wx.BoxSizer(wx.VERTICAL)
        alignAndMarginSizer.AddSizer(alignSizer, 0, wx.EXPAND | wx.ALL, 1)
        alignAndMarginSizer.AddSizer(marginSizer, 1, wx.EXPAND | wx.ALL, 1)

        twoColumnSizer = wx.BoxSizer(wx.HORIZONTAL)
        twoColumnSizer.AddSizer(sizeAndBorderSizer, 2, wx.EXPAND | wx.ALL, 1)
        twoColumnSizer.AddSizer(alignAndMarginSizer, 3, wx.EXPAND | wx.ALL, 1)

        tnSettingsSizer = wx.StaticBoxSizer(self.tnSettingsGroupBox, wx.VERTICAL)
        tnSettingsSizer.AddSizer(twoColumnSizer, 0, wx.EXPAND | wx.ALL, 2)

        mainSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(self.doNotGenRadioButton, 0, wx.ALL, 3)
        mainSizer.Add(self.genRadioButton, 0, wx.ALL, 3)
        mainSizer.AddSizer(tnSettingsSizer, 1, wx.EXPAND | wx.ALL, 3)

        return mainSizer
    # end _layoutNonHeaderWidgets()

    def _bindWidgetEvents(self):
        self.Bind(wx.EVT_CHOICE, self.onBorderStyleChanged, self.borderStyleChoice)
        self.Bind(wx.EVT_RADIOBUTTON, self.onDoNotGenButton, self.doNotGenRadioButton)
        self.Bind(wx.EVT_RADIOBUTTON, self.onGenerateButton, self.genRadioButton)

        self._bindValidatingWidget(self.borderWidthText)
        self._bindValidatingWidget(self.marginTopText)
        self._bindValidatingWidget(self.marginRightText)
        self._bindValidatingWidget(self.marginBotText)
        self._bindValidatingWidget(self.marginLeftText)

        self.Bind(wx.EVT_BUTTON, self.onOK, self.FindWindowById(wx.ID_OK))
    # end _bindWidgetEvents()

    def _enableWidgets(self, enabled = True):
        self.tnSettingsGroupBox.Enable(enabled)
        self.sizeLabel.Enable(enabled)
        self.sizeChoice.Enable(enabled)
        self.alignLabel.Enable(enabled)
        self.alignChoice.Enable(enabled)
        self.borderStaticBox.Enable(enabled)
        self.borderStyleLabel.Enable(enabled)
        self.borderStyleChoice.Enable(enabled)
        self.borderWidthLabel.Enable(enabled)
        self.borderWidthText.Enable(enabled)
        self.borderColorLabel.Enable(enabled)
        self.borderColorPicker.Enable(enabled)
        self.marginStaticBox.Enable(enabled)
        self.marginTopLabel.Enable(enabled)
        self.marginTopText.Enable(enabled)
        self.marginLeftLabel.Enable(enabled)
        self.marginLeftText.Enable(enabled)
        self.marginBotLabel.Enable(enabled)
        self.marginBotText.Enable(enabled)
        self.marginRightLabel.Enable(enabled)
        self.marginRightText.Enable(enabled)
    # end _enableWidgets()

    def _updateModel(self):
        self.model.generateTNFlag = self.genRadioButton.GetValue()

        # TN Size
        idx = self.sizeChoice.GetSelection()
        if idx >=0 and idx < len(ZThumbnailSizeMenuLabels.SIZE_KEYWORDS):
            size = ZThumbnailSizeMenuLabels.SIZE_KEYWORDS[idx]
            self.model.size = size

        # Alignment
        idx = self.alignChoice.GetSelection()
        if idx >=0 and idx < len(ZImageAlignMenuLabels.ALIGN_KEYWORDS):
            align = ZImageAlignMenuLabels.ALIGN_KEYWORDS[idx]
            self.model.alignment = align

        # Margin
        t = self.marginTopText.GetValue().strip()
        r = self.marginRightText.GetValue().strip()
        b = self.marginBotText.GetValue().strip()
        l = self.marginLeftText.GetValue().strip()
        self.model.marginTop = t
        self.model.marginRight = r
        self.model.marginBottom = b
        self.model.marginLeft = l

        # Border
        style = ZImageBorderMenuLabels.BORDER_KEYWORDS[0] # default is None
        idx = self.borderStyleChoice.GetSelection()
        if idx >=0 and idx < len(ZImageBorderMenuLabels.BORDER_KEYWORDS):
            style = ZImageBorderMenuLabels.BORDER_KEYWORDS[idx]
        width = self.borderWidthText.GetValue().strip()
        color = self.borderColorPicker.GetColour()

        self.model.borderStyle = style
        self.model.borderWidth = width
        self.model.borderColor = (color.Red(), color.Green(), color.Blue())
    # end updateModel()

    def onDoNotGenButton(self, event):
        self._enableWidgets(False)
        self.isValid = True
        self._doValid()
        event.Skip()
    # end onDoNotGenButton()

    def onGenerateButton(self, event):
        self._enableWidgets(True)
        self._validate()
        event.Skip()
    # end onGenerateButton()

    def onOK(self, event):
        self._updateModel()
        self.model._saveToPrefs()
        event.Skip()
    # end onOK()

    def _updateBorderControlsState(self):
        enable = self.borderStyleChoice.GetCurrentSelection() > 0
        if enable:
            self.borderWidthValidator.setFlags(0)
        else:
            self.borderWidthValidator.setFlags(ZCssLengthSelectionValidator.ALLOW_EMPTY)
            self.borderWidthText.validate()

        if enable and not self.borderWidthText.GetValue():
            self.borderWidthText.SetValue(u"1px") #$NON-NLS-1$
        self.borderWidthText.Enable(enable)
        self.borderColorPicker.Enable(enable)
    # end _updateBorderControlsState()

    def onBorderStyleChanged(self, event):
        self._updateBorderControlsState()
        event.Skip()
    # end onBorderStyleChanged()

    def getModel(self):
        return self.model
    # end getModel()

    def _getHeaderTitle(self):
        return _extstr(u"imagehandlerdialog.CreateImageThumbnail") #$NON-NLS-1$
    # end _getHeaderTitle()

    def _getHeaderMessage(self):
        return _extstr(u"imagehandlerdialog.CreateImageThumbnailDesc") #$NON-NLS-1$
    # end _getHeaderMessage()

    def _getHeaderImagePath(self):
        return u"images/dialogs/image/header_image.png" #$NON-NLS-1$