示例#1
0
def MakeWidgetDialog(widget):
    Frame = UI.BaseDialog(parent=widget.Canvas.F,
                          title=widget.NAME,
                          style=wx.FRAME_FLOAT_ON_PARENT,
                          main=(widget.DIALOG, {"widget": widget}),
                          head=(DetachedHead, {"help": widget.DIALOG.HELP}),
                          grip={"minSize": widget.DIALOG.MIN_SIZE}, )
    x, y = widget.DialogSize or Frame.GetEffectiveMinSize()
    Frame.SetSize((max(x, widget.DIALOG.MIN_SIZE[0]), max(y, UI.SETTINGS["DLG_HEAD"] + widget.DIALOG.MIN_SIZE[1])))
    Frame.SetPosition(widget.DialogPos or UI.EnsureWindowInScreen(widget.Canvas.ClientToScreen(widget.GetPosition() + wx.Point(64, 0)), (x, y)))
    Frame.Main.GetData()
    Frame.Play("FADEIN")
    return Frame.Main
示例#2
0
 def OnMouse(self, evt):  # TODO Multiple screen see wx.Display
     if evt.GetEventType() == wx.wxEVT_MOTION and self.lastMousePos:
         newPos = self.lastFramePos - self.lastMousePos + self.Frame.ClientToScreen(evt.GetPosition())
         size = self.Frame.GetSize()
         UI.EnsureWindowInScreen(newPos, size, 12)
         l, t = newPos
         b = t + size[1]
         r = l + size[0]
         closestH = closestV = UI.SETTINGS["DLG_HEAD"] // 2
         for frame in wx.GetTopLevelWindows():
             if isinstance(frame, UI.BaseDialog) and frame != self.Frame and frame.IsShown():
                 _l, _t = frame.GetPosition()
                 _b = _t + frame.GetSize()[1]
                 _r = _l + frame.GetSize()[0]
                 if _l <= l < _r or _l < r <= _r:
                     d = abs(t - _b)
                     if d < closestV:
                         closestV = d
                         newPos[1] = _b
                     d = abs(b - _t)
                     if d < closestV:
                         closestV = d
                         newPos[1] = _t - size[1]
                     d = abs(t - _t)
                     if d < closestV:
                         closestV = d
                         newPos[1] = _t
                     d = abs(b - _b)
                     if d < closestV:
                         closestV = d
                         newPos[1] = _b - size[1]
                 if _t <= t < _b or _t < b <= _b:
                     d = abs(l - _r)
                     if d < closestH:
                         closestH = d
                         newPos[0] = _r
                     d = abs(r - _l)
                     if d < closestH:
                         closestH = d
                         newPos[0] = _l - size[0]
                     d = abs(l - _l)
                     if d < closestH:
                         closestH = d
                         newPos[0] = _l
                     d = abs(r - _r)
                     if d < closestH:
                         closestH = d
                         newPos[0] = _r - size[0]
         self.Frame.SetPosition(newPos)
     else:
         super().OnMouse(evt)