Page 1 of 1

UnoControlDialogModel Resizable

PostPosted: Tue Oct 09, 2012 9:24 pm
by rjsteele
I see that "sizeable" is one of the properties of the UnoControlDialogModel. Is setting this property to TRUE supposed to give the user the ability to resize the dialog. I have a dialog with a calc spreadsheet embedded in it. I want to allow the user to resize the dialog. The dialog also has other controls as well.

Re: UnoControlDialogModel Resizable

PostPosted: Wed Oct 10, 2012 2:48 pm
by hanya
It can not be changed by the API. It looks dlg:window node support resizeable attribute in XDL file but it does not work with the dialog executed by the dialog provider.
Here is an example to make a dialog through general window creation mechanism. In the case, child controls should be created by code by it is troublesome so I embed the dialog created by the dialog editor as child window into the resizeable outer dialog. You need to resize and reposition child controls yourself.

Code: Select all   Expand viewCollapse view
' This is an example to make resizable modal dialog.
' A dialog created by the dialog editor can be embedded
' to make easy to create dialog.

' This example requires Standard.Dialog in application dialog
' with list box named ListBox1.
Sub ResizableDialogTest11
  ' parent
  oParent = ThisComponent.getCurrentController()._
  ' create base window as modal dialog
  oBaseDialog = CreateBaseDialog(oParent)
  ' embed the dialog created by the dialog editor
  sURL = ""
  oDialog = CreateInnerDialog(oBaseDialog, sURL)
  ' to show the dialog, have to be done by the outer dialog
  If oBaseDialog.execute() > 0 Then
    msgbox "Do something..."
  End If
End Sub

' Create new base dialog.
' @param oParent parent window peer
' @return dialog window
Function CreateBaseDialog(oParent As Variant) As Variant
  oToolkit = oParent.getToolkit()
  WA =
  aRect = CreateUnoStruct("")
  oDesc = CreateUnoStruct("")
  With oDesc
    .Type =
    .WindowServiceName = "dialog"
    .Parent = oParent
    .ParentIndex = -1
    .Bounds = aRect
  End With
  oDialog = oToolkit.createWindow(oDesc)
      "WindowListener_", ""))
      "WindowListener_", ""))
  CreateBaseDialog = oDialog
End Function

' Create child dialog embedded
' @param oParent parent window
' @param sURL dialog URL, without toolbar
Function CreateInnerDialog(oParent As Variant, sURL As String) As Variant
  PS =
  oDP = CreateUnoService("")
  oChildDialog = oDP.createContainerWindow(sURL, "", oParent, nothing)
  oChildDialog.setPosSize(0, 0, 0, 0, PS.POS)
  aSize = oChildDialog.getPosSize()
  oParent.setPosSize(0, 0, aSize.Width, aSize.Height, PS.SIZE)
      "oDialogWindow_", ""))
  CreateInnerDialog = oChildDialog
End Function

' XWindowListener
Sub oDialogWindow_windowResized(ev)
  ' this called indirect by resizeing of the outer dialog
  aRect = ev.Source.getPosSize()
  ' dialog controls have to be repositioned and resized by hand
  oListBox = ev.Source.getControl("ListBox1")
  oListBox.setPosSize(aRect.Width - 10 - oListBox.getPosSize().Width, _
                      0, 0, 0,
End Sub
Sub oDialogWindow_windowMoved(ev)
End Sub
Sub oDialogWindow_windowShown(ev)
End Sub
Sub oDialogWindow_windowHidden(ev)
End Sub

' Listeners for base dialog
' XTopWindowListener
Sub WindowListener_disposing(ev)
End Sub
Sub WindowListener_windowOpened(ev)
End Sub
Sub WindowListener_windowClosing(ev)
  ' helps to close the window by close button of the window
End Sub
Sub WindowListener_windowClosed(ev)
End Sub
Sub WindowListener_windowMinimized(ev)
End Sub
Sub WindowListener_windowNormalized(ev)
End Sub
Sub WindowListener_windowActivated(ev)
End Sub
Sub WindowListener_windowDeactivated(ev)
End Sub

' XWindowListener
Sub WindowListener_windowResized(ev)
  ' resize inner dialog as first child window
  aSize = ev.Source.getSize()
  ev.Source.Windows(0).setPosSize(0, 0, _
        aSize.Width, aSize.Height,
End Sub
Sub WindowListener_windowMoved(ev)
End Sub
Sub WindowListener_windowShown(ev)
End Sub
Sub WindowListener_windowHidden(ev)
End Sub

Re: UnoControlDialogModel Resizable

PostPosted: Thu Oct 11, 2012 4:51 pm
by rjsteele

Thanks for the response. I will try to implement this as soon as I can. I got pulled in another direction for the time being. Hopefully, when I do try, you will be available for follow-up questions.

Re: UnoControlDialogModel Resizable

PostPosted: Wed Apr 09, 2014 9:03 am
by roland65

I've tried the ResizableDialogTest11 example and it doesn't work properly in LibreOffice 4.x : the inner child dialog is shown as a separate window (non resizable) and not embedded in the resizable parent.
Any idea on how to fix this?
Thanks a lot,

Re: UnoControlDialogModel Resizable

PostPosted: Wed Apr 09, 2014 9:56 am
by hanya
Set "With title bar" of the dialog to No to make it embedded in the parent dialog.

Re: UnoControlDialogModel Resizable

PostPosted: Wed Apr 09, 2014 2:24 pm
by roland65
Very nice! I couldn't think the answer was so simple...
Thanks a lot,