# Path: drawingDimensioning/py3_helpers.py
#     def unicode(*args):
# def translate(*args):
# def encode_if_py2(unicode_object):
# def map(function, arg):
# 
# Path: drawingDimensioning/svgLib.py
# class SvgTextRenderer:
#     def __init__(self, font_family='inherit', font_size='inherit', fill='rgb(0,0,0)'):
#         self.font_family = font_family
#         self.font_size = font_size
#         self.fill = fill
#     def __call__(self, x, y, text, text_anchor='inherit', rotation=None):
#         '''
#         text_anchor = start | middle | end | inherit
#         rotation is in degress, and is done about x,y
#         '''
#         try:
#             XML = '''<text x="%f" y="%f" font-family="%s" font-size="%s" fill="%s" text-anchor="%s" %s >%s</text>'''  % (  x, y, self.font_family, self.font_size,  self.fill, text_anchor, 'transform="rotate(%f %f,%f)"' % (rotation,x,y) if rotation != None else '', text )
#         except UnicodeDecodeError:
#             text_utf8 = unicode( text, 'utf8' )
#             XML = '''<text x="%f" y="%f" font-family="%s" font-size="%s" fill="%s" text-anchor="%s" %s >%s</text>'''  % (  x, y, self.font_family, self.font_size,  self.fill, text_anchor, 'transform="rotate(%f %f,%f)"' % (rotation,x,y) if rotation != None else '', text_utf8 )
#         return XML
#     def __repr__(self):
#         return '<svgLib_dd.SvgTextRenderer family="%s" font_size="%s" fill="%s">' % (self.font_family, self.font_size, self.fill )


import sys
import FreeCAD
from drawingDimensioning.py3_helpers import unicode, unicode_type, map, encode_if_py2
from PySide import QtGui, QtCore, QtSvg
from drawingDimensioning.svgConstructor import SvgTextRenderer
    def revertToDefault( self ):
        self.textbox.setText( self.getDefaultValue() )
    def generateWidget( self, dimensioningProcess ):
        self.dimensioningProcess = dimensioningProcess
        textbox = QtGui.QLineEdit()
        #debugPrint(1,self.getDefaultValue() )
        textbox.setText( self.getDefaultValue() )
        textbox.textChanged.connect( self.valueChanged )
        self.textbox = textbox
        return  DimensioningTaskDialog_generate_row_hbox( self.label, textbox )
    def add_properties_to_dimension_object( self, obj ):
        obj.addProperty("App::PropertyString", self.name, self.category)
        KWs = self.dimensioningProcess.dimensionConstructorKWs
        setattr( obj, self.name, encode_if_py2(KWs[ self.name ]) )
    def get_values_from_dimension_object( self, obj, KWs ):
        #KWs[self.name] =  unicode( getattr( obj, self.name ), 'utf8'  )
        KWs[self.name] =  getattr( obj, self.name )
        if not type(KWs[self.name]) == unicode_type:
            raise ValueError("type(KWs[%s]) != unicode but == %s" % (self.name, type(KWs[self.name]) ))
if sys.version_info.major < 3:
    DimensioningPreferenceClasses["<type 'unicode'>"] = DimensioningPreference_unicode
else:
    DimensioningPreferenceClasses["<class 'str'>"] = DimensioningPreference_unicode


class DimensioningPreference_choice(DimensioningPreference_unicode):
    def valueChanged( self, value ):
        self.dimensioningProcess.dimensionConstructorKWs[ self.name ] = self.combobox.currentText()
    def getDefaultValue(self):
        encoded_value = self.dd_parms.GetString( self.name, encode_if_py2(self.defaultValue[0]) )  

# Path: drawingDimensioning/py3_helpers.py
#     def unicode(*args):
# def translate(*args):
# def encode_if_py2(unicode_object):
# def map(function, arg):
# 
# Path: drawingDimensioning/svgLib.py
# class SvgTextRenderer:
#     def __init__(self, font_family='inherit', font_size='inherit', fill='rgb(0,0,0)'):
#         self.font_family = font_family
#         self.font_size = font_size
#         self.fill = fill
#     def __call__(self, x, y, text, text_anchor='inherit', rotation=None):
#         '''
#         text_anchor = start | middle | end | inherit
#         rotation is in degress, and is done about x,y
#         '''
#         try:
#             XML = '''<text x="%f" y="%f" font-family="%s" font-size="%s" fill="%s" text-anchor="%s" %s >%s</text>'''  % (  x, y, self.font_family, self.font_size,  self.fill, text_anchor, 'transform="rotate(%f %f,%f)"' % (rotation,x,y) if rotation != None else '', text )
#         except UnicodeDecodeError:
#             text_utf8 = unicode( text, 'utf8' )
#             XML = '''<text x="%f" y="%f" font-family="%s" font-size="%s" fill="%s" text-anchor="%s" %s >%s</text>'''  % (  x, y, self.font_family, self.font_size,  self.fill, text_anchor, 'transform="rotate(%f %f,%f)"' % (rotation,x,y) if rotation != None else '', text_utf8 )
#         return XML
#     def __repr__(self):
#         return '<svgLib_dd.SvgTextRenderer family="%s" font_size="%s" fill="%s">' % (self.font_family, self.font_size, self.fill )


# Path: drawingDimensioning/command/preferences.py
import sys
import FreeCAD
from drawingDimensioning.py3_helpers import unicode, unicode_type, map, encode_if_py2
from PySide import QtGui, QtCore, QtSvg
from drawingDimensioning.svgConstructor import SvgTextRenderer

    def revertToDefault( self ):
        self.textbox.setText( self.getDefaultValue() )
    def generateWidget( self, dimensioningProcess ):
        self.dimensioningProcess = dimensioningProcess
        textbox = QtGui.QLineEdit()
        #debugPrint(1,self.getDefaultValue() )
        textbox.setText( self.getDefaultValue() )
        textbox.textChanged.connect( self.valueChanged )
        self.textbox = textbox
        return  DimensioningTaskDialog_generate_row_hbox( self.label, textbox )
    def add_properties_to_dimension_object( self, obj ):
        obj.addProperty("App::PropertyString", self.name, self.category)
        KWs = self.dimensioningProcess.dimensionConstructorKWs
        setattr( obj, self.name, encode_if_py2(KWs[ self.name ]) )
    def get_values_from_dimension_object( self, obj, KWs ):
        #KWs[self.name] =  unicode( getattr( obj, self.name ), 'utf8'  )
        KWs[self.name] =  getattr( obj, self.name )
        if not type(KWs[self.name]) == unicode_type:
            raise ValueError("type(KWs[%s]) != unicode but == %s" % (self.name, type(KWs[self.name]) ))
if sys.version_info.major < 3:
    DimensioningPreferenceClasses["<type 'unicode'>"] = DimensioningPreference_unicode
else:
    DimensioningPreferenceClasses["<class 'str'>"] = DimensioningPreference_unicode


class DimensioningPreference_choice(DimensioningPreference_unicode):
    def valueChanged( self, value ):
        self.dimensioningProcess.dimensionConstructorKWs[ self.name ] = self.combobox.currentText()
    def getDefaultValue(self):
        encoded_value = self.dd_parms.GetString( self.name, encode_if_py2(self.defaultValue[0]) )  

        return unicode( encoded_value, 'utf8' )