Add default properties to grid control
This commit is contained in:
parent
26bc9de84d
commit
ddc9ee00ae
|
@ -2703,12 +2703,17 @@ class LOCalcRange(object):
|
|||
|
||||
@property
|
||||
def empty(self):
|
||||
cursor = self.sheet.get_cursor(self.obj)
|
||||
cursor = self.cursor
|
||||
rangos = cursor.queryEmptyCells()
|
||||
rangos = [LOCalcRange(self.sheet[r.AbsoluteName].obj) for r in rangos]
|
||||
return tuple(rangos)
|
||||
|
||||
def query_content(self, type_content=1023):
|
||||
cursor = self.cursor
|
||||
rangos = cursor.queryContentCells(type_content)
|
||||
rangos = [LOCalcRange(self.sheet[r.AbsoluteName].obj) for r in rangos]
|
||||
return tuple(rangos)
|
||||
|
||||
@property
|
||||
def merge(self):
|
||||
return self.obj.IsMerged
|
||||
|
@ -5462,14 +5467,24 @@ class UnoGrid(UnoBaseObject):
|
|||
def column(self):
|
||||
return self.obj.CurrentColumn
|
||||
|
||||
@property
|
||||
def column(self):
|
||||
return self.obj.CurrentColumn
|
||||
|
||||
@property
|
||||
def is_valid(self):
|
||||
return not (self.row == -1 or self.column == -1)
|
||||
|
||||
@property
|
||||
def selected_rows(self):
|
||||
value = self.obj.SelectedRows
|
||||
return value
|
||||
|
||||
@property
|
||||
def row_background_colors(self):
|
||||
value = self.m.RowBackgroundColors
|
||||
return value
|
||||
@row_background_colors.setter
|
||||
def row_background_colors(self, colors):
|
||||
c = Color()
|
||||
self.m.RowBackgroundColors = (c(colors[0]), c(colors[1]))
|
||||
|
||||
@property
|
||||
def formats(self):
|
||||
return self._formats
|
||||
|
@ -5798,7 +5813,7 @@ class LODialog(object):
|
|||
'numeric': 'com.sun.star.awt.UnoControlNumericFieldModel',
|
||||
}
|
||||
|
||||
def __init__(self, args):
|
||||
def __init__(self, args={}):
|
||||
self._obj = self._create(args)
|
||||
self._model = self.obj.Model
|
||||
self._events = None
|
||||
|
@ -5836,6 +5851,11 @@ class LODialog(object):
|
|||
dlg = create_instance('com.sun.star.awt.UnoControlDialog', True)
|
||||
model = create_instance('com.sun.star.awt.UnoControlDialogModel', True)
|
||||
toolkit = create_instance('com.sun.star.awt.Toolkit', True)
|
||||
|
||||
args['Title'] = args.get('Title', TITLE)
|
||||
args['Width'] = args.get('Width', 200)
|
||||
args['Height'] = args.get('Height', 150)
|
||||
|
||||
_set_properties(model, args)
|
||||
dlg.setModel(model)
|
||||
dlg.setVisible(False)
|
||||
|
@ -5963,6 +5983,10 @@ class LODialog(object):
|
|||
|
||||
if tipo == 'grid':
|
||||
args['ShowRowHeader'] = args.get('ShowRowHeader', True)
|
||||
args['X'] = args.get('X', self.SEPARATION)
|
||||
args['Y'] = args.get('Y', self.SEPARATION)
|
||||
args['Width'] = args.get('Width', self.width - self.SEPARATION * 2)
|
||||
args['Height'] = args.get('Height', self.height - self.SEPARATION * 2)
|
||||
return args
|
||||
|
||||
if tipo == 'pages':
|
||||
|
@ -5979,6 +6003,7 @@ class LODialog(object):
|
|||
|
||||
args = self._special_properties(tipo, args)
|
||||
model = self.model.createInstance(self.MODELS[tipo])
|
||||
|
||||
_set_properties(model, args)
|
||||
name = args['Name']
|
||||
self.model.insertByName(name, model)
|
||||
|
@ -7239,10 +7264,12 @@ def __getattr__(name):
|
|||
return Dates
|
||||
if name == 'ios':
|
||||
return IOStream()
|
||||
if name == 'color':
|
||||
return Color()
|
||||
raise AttributeError(f"module '{__name__}' has no attribute '{name}'")
|
||||
|
||||
|
||||
def create_dialog(args):
|
||||
def create_dialog(args={}):
|
||||
return LODialog(args)
|
||||
|
||||
|
||||
|
@ -7339,6 +7366,10 @@ def get_filters():
|
|||
|
||||
# ~ https://en.wikipedia.org/wiki/Web_colors
|
||||
def get_color(value):
|
||||
|
||||
if isinstance(value, int):
|
||||
return value
|
||||
|
||||
COLORS = {
|
||||
'aliceblue': 15792383,
|
||||
'antiquewhite': 16444375,
|
||||
|
@ -7500,6 +7531,17 @@ def get_color(value):
|
|||
return color
|
||||
|
||||
|
||||
class Color():
|
||||
|
||||
def __call__(self, value):
|
||||
color = get_color(value)
|
||||
return color
|
||||
|
||||
def __getitem__(self, index):
|
||||
color = get_color(index)
|
||||
return color
|
||||
|
||||
|
||||
COLOR_ON_FOCUS = get_color('LightYellow')
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue