def create_tree_window(self, ctx, parent, ev=None): from mytools_Mri.ui.frame import create_window smgr = ctx.getServiceManager() def create(name): return smgr.createInstanceWithContext(name, ctx) WIDTH = 300 WINDOW_HEIGHT = 350 x = 100 y = 100 if ev: ps = ev.Source.getPosSize() x = ps.X + 250 y = ps.Y toolkit = parent.getToolkit() frame = create('com.sun.star.frame.Frame') window = create_window( toolkit, parent, WC_SIMPLE, "floatingwindow", WA_BORDER | WA_SHOW | WA_SIZEABLE | WA_MOVEABLE | WA_CLOSEABLE, x, y, WIDTH, WINDOW_HEIGHT) frame.initialize(window) frame.setTitle("History") cont = create('com.sun.star.awt.UnoControlContainer') cont_model = create('com.sun.star.awt.UnoControlContainerModel') cont.setModel(cont_model) cont.createPeer(toolkit, window) cont.setPosSize(0, 0, WIDTH, WINDOW_HEIGHT, PS_POSSIZE) #cont_model.BackgroundColor = 0xFAFAFA frame.setComponent(cont, None) try: tree = create('com.sun.star.awt.tree.TreeControl') tree_model = create('com.sun.star.awt.tree.TreeControlModel') tree_model.setPropertyValues(('SelectionType', 'RootDisplayed'), (ST_SINGLE, True)) #data_model = smgr.createInstanceWithContext( # 'com.sun.star.awt.tree.MutableTreeDataModel', ctx) tree_model.DataModel = CustomTreeDataModel() tree.setModel(tree_model) tree.setPosSize(0, 0, WIDTH, WINDOW_HEIGHT, PS_POSSIZE) cont.addControl('tree', tree) tree_listener = TreeSelectionListener(self) tree.addSelectionChangeListener(tree_listener) self.listeners['tree'] = tree_listener cont_listener = TreeComponentWindowListener(self) cont.addEventListener(cont_listener) self.listeners['tree_cont'] = cont_listener win_listener = TreeWindowListener(self) window.addWindowListener(win_listener) self.listeners['tree_win'] = win_listener listener = TreeMouseListener(self) self.listeners["tree_mouse"] = listener tree.addMouseListener(listener) except Exception as e: print(e) return frame
def create_tree_window(self, ctx, parent, ev=None): from mytools_Mri.ui.frame import create_window smgr = ctx.getServiceManager() def create(name): return smgr.createInstanceWithContext(name, ctx) WIDTH = 200 WINDOW_HEIGHT = 150 x = 100 y = 100 if ev: ps = ev.Source.getPosSize() x = ps.X + 250 y = ps.Y toolkit = parent.getToolkit() frame = create('com.sun.star.frame.Frame') window = create_window(toolkit, parent, WC_SIMPLE, "floatingwindow", WA_BORDER | WA_SHOW | WA_SIZEABLE | WA_MOVEABLE | WA_CLOSEABLE, x, y, WIDTH, WINDOW_HEIGHT) frame.initialize(window) frame.setTitle("History") cont = create('com.sun.star.awt.UnoControlContainer') cont_model = create('com.sun.star.awt.UnoControlContainerModel') cont.setModel(cont_model) cont.createPeer(toolkit,window) cont.setPosSize(0,0,WIDTH,WINDOW_HEIGHT,PS_POSSIZE) #cont_model.BackgroundColor = 0xFAFAFA frame.setComponent(cont, None) try: tree = create('com.sun.star.awt.tree.TreeControl') tree_model = create('com.sun.star.awt.tree.TreeControlModel') tree_model.setPropertyValues( ('SelectionType', 'RootDisplayed'), (ST_SINGLE, True)) #data_model = smgr.createInstanceWithContext( # 'com.sun.star.awt.tree.MutableTreeDataModel', ctx) tree_model.DataModel = CustomTreeDataModel() tree.setModel(tree_model) tree.setPosSize(0, 0, WIDTH, WINDOW_HEIGHT, PS_POSSIZE) cont.addControl('tree', tree) tree_listener = TreeSelectionListener(self) tree.addSelectionChangeListener(tree_listener) self.listeners['tree'] = tree_listener cont_listener = TreeComponentWindowListener(self) cont.addEventListener(cont_listener) self.listeners['tree_cont'] = cont_listener win_listener = TreeWindowListener(self) window.addWindowListener(win_listener) self.listeners['tree_win'] = win_listener listener = TreeMouseListener(self) self.listeners["tree_mouse"] = listener tree.addMouseListener(listener) except Exception as e: print(e) return frame
def _init_ui(self): from mytools_Mri.ui.frame import create_window WIDTH = self.WIDTH HEIGHT = self.HEIGHT x = self.X y = self.Y create = self.create font_name = self.font_name char_size = self.char_size parent = self.mri.ui.frame.getContainerWindow() toolkit = parent.getToolkit() frame = create('com.sun.star.frame.Frame') window = create_window(toolkit, parent, WC_SIMPLE, "floatingwindow", WA_BORDER | WA_SHOW | WA_SIZEABLE | WA_MOVEABLE | WA_CLOSEABLE, x, y, WIDTH, HEIGHT) frame.initialize(window) frame.setTitle(self.NAME) cont = create('com.sun.star.awt.UnoControlContainer') cont_model = create('com.sun.star.awt.UnoControlContainerModel') cont.setModel(cont_model) cont.createPeer(toolkit,window) cont.setPosSize(0,0,WIDTH,HEIGHT,PS_POSSIZE) window.addWindowListener(WindowListener(self)) frame.setComponent(cont, None) frame.addEventListener(ComponentWindowListener(self)) input_model = create("com.sun.star.awt.UnoControlEditModel") input = create("com.sun.star.awt.UnoControlEdit") input_model.setPropertyValues( ("CharHeight", "FontName", "HideInactiveSelection"), (char_size, font_name, False)) input.setPosSize(0, HEIGHT - self.INPUT_HEIGHT, WIDTH, self.INPUT_HEIGHT, PS_POSSIZE) input.setModel(input_model) edit_model = create("com.sun.star.form.component.RichTextControl") edit = create("com.sun.star.form.control.RichTextControl") edit_model.setPropertyValue("RichText", True) edit_model.setPropertyValues( ("Align", "CharFontName", "Border", "HardLineBreaks", "MultiLine", "ReadOnly", "VScroll"), (0, font_name, 0, False, True, True, True)) edit.setPosSize(0, 0, WIDTH, HEIGHT - self.INPUT_HEIGHT, PS_POSSIZE) edit.setModel(edit_model) input.addKeyListener(KeyListener(self)) cont.addControl("input", input) cont.addControl("rich", edit) input.setFocus() self.text = edit_model.getText() self.rich = edit self.input = input self.frame = frame self.text.CharFontName = font_name self.text.CharHeight = char_size self.cursor = self.text.createTextCursor() self.cursor.CharFontName = font_name self.cursor.CharHeight = char_size # ToDo asian fonts from mytools_Mri.ui.frame import get_editvscrollbar self.scroll = get_editvscrollbar(self.rich)
def _init_ui(self): from mytools_Mri.ui.frame import create_window WIDTH = self.WIDTH HEIGHT = self.HEIGHT x = self.X y = self.Y create = self.create font_name = self.font_name char_size = self.char_size parent = self.mri.ui.frame.getContainerWindow() toolkit = parent.getToolkit() frame = create('com.sun.star.frame.Frame') window = create_window( toolkit, parent, WC_SIMPLE, "floatingwindow", WA_BORDER | WA_SHOW | WA_SIZEABLE | WA_MOVEABLE | WA_CLOSEABLE, x, y, WIDTH, HEIGHT) frame.initialize(window) frame.setTitle(self.NAME) cont = create('com.sun.star.awt.UnoControlContainer') cont_model = create('com.sun.star.awt.UnoControlContainerModel') cont.setModel(cont_model) cont.createPeer(toolkit, window) cont.setPosSize(0, 0, WIDTH, HEIGHT, PS_POSSIZE) window.addWindowListener(WindowListener(self)) frame.setComponent(cont, None) frame.addEventListener(ComponentWindowListener(self)) input_model = create("com.sun.star.awt.UnoControlEditModel") input = create("com.sun.star.awt.UnoControlEdit") input_model.setPropertyValues( ("CharHeight", "FontName", "HideInactiveSelection"), (char_size, font_name, False)) input.setPosSize(0, HEIGHT - self.INPUT_HEIGHT, WIDTH, self.INPUT_HEIGHT, PS_POSSIZE) input.setModel(input_model) edit_model = create("com.sun.star.form.component.RichTextControl") edit = create("com.sun.star.form.control.RichTextControl") edit_model.setPropertyValue("RichText", True) edit_model.setPropertyValues( ("Align", "CharFontName", "Border", "HardLineBreaks", "MultiLine", "ReadOnly", "VScroll"), (0, font_name, 0, False, True, True, True)) edit.setPosSize(0, 0, WIDTH, HEIGHT - self.INPUT_HEIGHT, PS_POSSIZE) edit.setModel(edit_model) input.addKeyListener(KeyListener(self)) cont.addControl("input", input) cont.addControl("rich", edit) input.setFocus() self.text = edit_model.getText() self.rich = edit self.input = input self.frame = frame self.text.CharFontName = font_name self.text.CharHeight = char_size self.cursor = self.text.createTextCursor() self.cursor.CharFontName = font_name self.cursor.CharHeight = char_size # ToDo asian fonts from mytools_Mri.ui.frame import get_editvscrollbar self.scroll = get_editvscrollbar(self.rich)