Top > OOoPython > mytools > window

window Edit

Window 作成など用。

window.py

  0
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
from com.sun.star.awt import Rectangle, WindowDescriptor
from com.sun.star.awt.PosSize import POSSIZE as PS_POSSIZE
 
 
def createCtrlContainer(smgr, ctx):
    cont = smgr.createInstanceWithContext( 
        u'com.sun.star.awt.UnoControlContainer', ctx)
    cont_model = smgr.createInstanceWithContext( 
        u'com.sun.star.awt.UnoControlContainerModel',ctx)
    cont.setModel(cont_model)
    return cont
 
 
def createWindow(toolkit, parent, wtype, service, attrs, nX,nY,nWidth,nHeight):
    aRect = Rectangle()
    aRect.X = nX
    aRect.Y = nY
    aRect.Width = nWidth
    aRect.Height = nHeight
    
    d = WindowDescriptor()
    d.Type = wtype
    d.WindowServiceName = service
    d.ParentIndex = -1
    d.Bounds = aRect
    d.Parent = parent
    d.WindowAttributes = attrs
    return toolkit.createWindow(d)
 
 
# create control by its type with property values
def createControl(smgr, ctx, ctrltype, x, y, width, height, names, values):
    ctrl = smgr.createInstanceWithContext( 
        u'com.sun.star.awt.UnoControl%s' % ctrltype,ctx)
    ctrl_model = smgr.createInstanceWithContext( 
        u'com.sun.star.awt.UnoControl%sModel' % ctrltype,ctx)
    ctrl_model.setPropertyValues(names,values)
    ctrl.setModel(ctrl_model)
    ctrl.setPosSize(x,y,width,height,PS_POSSIZE)
    return ctrl
 
 
# items [id,text,type,pos,command], if separator [-1,pos]
def create_popupmenu(smgr, ctx, items):
    menu = smgr.createInstanceWithContext(u'com.sun.star.awt.PopupMenu',ctx)
    for item in items:
        if -1 < item[0]:
            menu.insertItem(item[0],item[1],item[2],item[3])
            menu.setCommand(item[0],item[4])
        else:
            menu.insertSeparator(item[1])
    return menu

Reload   New Lower page making Edit Freeze Diff Upload Copy Rename   Front page List of pages Search Recent changes Backup   Help   RSS of recent changes