Top > OOoBasic > Window > Splitter

Splitter Edit

ドラッグでサイズを調整できる splitter コントロール。

splitter.png

ウィンドウを作成するときに WindowServiceName に splitter を指定します。

splitter ウィンドウの高さは 5 pixel が限度のようです。それ未満の値だとカーソルがリサイズ用に変化しません。

実行には Tools の関数も必要です。

  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
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
from com.sun.star.awt import XMouseMotionListener
from com.sun.star.awt.MouseButton import LEFT as MB_LEFT
from com.sun.star.awt.PosSize import POSSIZE as PS_POSSIZE, \
    SIZE as PS_SIZE, Y as PS_Y, HEIGHT as PS_HEIGHT
from com.sun.star.awt.WindowAttribute import \
    CLOSEABLE as WA_CLOSEABLE, SHOW as WA_SHOW, \
    MOVEABLE as WA_MOVEABLE, BORDER as WA_BORDER
 
class mouse_motion(unohelper.Base,XMouseMotionListener):
    def __init__(self,cont):
        self.cont = cont
        self.edit1 = self.cont.getControl("edit1")
        self.edit2 = self.cont.getControl("edit2")
        pass
    def disposing(self,ev):
        pass
    def mouseMoved(self,ev):
        pass
    def mouseDragged(self,ev):
        if ev.Buttons ==  MB_LEFT:
            split_pos = ev.Source.getPosSize()
            
            if 5 < split_pos.Y + ev.Y < 200:
                ev.Source.setPosSize(0,split_pos.Y + ev.Y,0,0,PS_Y)
                
                edit1_pos = self.edit1.getPosSize()
                edit2_pos = self.edit2.getPosSize()
                self.edit1.setPosSize(0,0,
                    0,edit1_pos.Height + ev.Y,PS_HEIGHT)
                self.edit2.setPosSize(0,edit2_pos.Y + ev.Y,
                    0,edit2_pos.Height - ev.Y,PS_Y + PS_HEIGHT)
 
def create_subwin3():
    ctx = XSCRIPTCONTEXT.getComponentContext()
    smgr = ctx.ServiceManager
    desktop = smgr.createInstanceWithContext(
        "com.sun.star.frame.Desktop",ctx)
    frame = desktop.getActiveFrame()
    parent = frame.getContainerWindow()
    toolkit = parent.getToolkit()
    
    subwin = createWindow(
        toolkit,
        parent,
        "modaldialog",
        WA_SHOW + WA_BORDER + WA_MOVEABLE + WA_CLOSEABLE,
        100,100,300,200)
    
    cont = createControl(
        smgr,ctx,
        "Container",
        0,0,300,200,(),())
    cont.setPosSize(0,0,300,200,PS_POSSIZE)
    cont.createPeer(toolkit,subwin)
    
    edit1 = createControl(
        smgr,ctx,
        "Edit",
        0,0,300,99,("AutoVScroll","MultiLine",),(True,True,))
    
    edit2 = createControl(
        smgr,ctx,
        "Edit",
        0,105,300,96,("AutoVScroll","MultiLine",),(True,True,))
    
    cont.addControl("edit1",edit1)
    cont.addControl("edit2",edit2)
    
    spl = createWindow(
        toolkit,
        cont.getPeer(),
        "splitter",
        WA_SHOW + WA_BORDER,
        0,100,300,5)
    spl.setProperty("BackgroundColor", 0xEEEEEE)
    spl.setProperty("Border",1)
    spl.addMouseMotionListener(mouse_motion(cont))
    
    #inspect(ctx,spl)
    subwin.execute()
    spl.dispose()
    subwin.dispose()

Attach file: filesplitter.png 416 download [Information]

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