Re: [api-dev] creating non-modal dialog
Paolo Mantovani wrote: Hi Laurent, Alle 13:58, giovedì 20 aprile 2006, Laurent Godard ha scritto: Hi Paolo It sounds quite strange to me that a UNOControlDialog behaves as non-modal. a hack iirc is to set the visible property to true do not use execute but loop over a global boolean to detect a stop set do not forget a wait statement in the loop to allow other process to work :-) the global idea (tested a long time ago) [...] Feel free to ask, i may find some old code Np, your example is perfectly understandable It works! Cool!! I didn't know this trick! :-) It's not a trick - all vcl based dialogs can be executed either modal (using execute) or modeless (using setVisible(True)). But this alone is not enough, a dialog started with setVisible is still a modal one if you have a polling loop like in Laurents example, the only difference is that the modality is in the macro code and not in VCL (where BTW it takes *much* less CPU cycles to do nothing except waiting). There might be another unexpected side effect with the basic loop: the existence of such a loop (either in Basic or in VCL) makes it necessary to prevent the closing(/destruction of the dialog or its parent window before the loop ends (otherwise a crash will happen sooner or later). For this reason VCL disables the parent window of the dialog so that you can't close it while the excute() call is done. It's possible that in the example with the Basic loop where vcl doesn't know about this modality the parent window is not disabled and so you can shoot yourself in the foot by closing the parent window while the dialog is waiting for input. You can try it out, but please try the Basic IDE and a document window as a parent (by starting the macro from inside either one), they might behave differently here. A real modeless treatment that does not suffer from this pain needs that your macro terminates after the dialog is shown (no wait loop!) and sleeps until a callback from the dialog awakes it again (click handler). AFAIK this means that your dialog must be kept in a global variable so that termination of your macro does not kill the dialog automatically. Best regards, Mathias -- Mathias Bauer - OpenOffice.org Application Framework Project Lead Please reply to the list only, [EMAIL PROTECTED] is a spam sink. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] creating non-modal dialog
Tuomas Räsänen wrote: My goal is to create a non-modal dialog to replace default Styles and Formatting - dialog. MyDialog contains a listbox for styles just like the Style and Formatting - dialog. I would appreciate your opinion about the way I have done this dialog. There is also a problem: this dialog won't close when clicking that cross at top right corner of the dialog. What I've done wrong? I'm not a dialog API expert, but the following line of code looks strange to me: xPSetDialog.setPropertyValue(Closeable, new Boolean(false)); I understand this as a command that this dialog shouldn't be closeable and so it isn't surprising that nothing happens when you click on the closer. OTOH I wonder why there is a closer at all in this case but this might be a bug or imperfection. Best regards, Mathias -- Mathias Bauer - OpenOffice.org Application Framework Project Lead Please reply to the list only, [EMAIL PROTECTED] is a spam sink. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[api-dev] creating non-modal dialog
Hi, My goal is to create a non-modal dialog to replace default Styles and Formatting - dialog. MyDialog contains a listbox for styles just like the Style and Formatting - dialog. I would appreciate your opinion about the way I have done this dialog. There is also a problem: this dialog won't close when clicking that cross at top right corner of the dialog. What I've done wrong? Is the dialog even the right way to do this? private void createDialog() throws java.lang.Exception { String listBoxName = StyleListBox; // create the dialog model and set its properties Object dialogModel = xRemoteServiceManager.createInstanceWithContext( com.sun.star.awt.UnoControlDialogModel, xRemoteContext); XPropertySet xPSetDialog = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, dialogModel); xPSetDialog.setPropertyValue(Sizeable, new Boolean(false)); xPSetDialog.setPropertyValue(PositionX, new Integer(100)); xPSetDialog.setPropertyValue(PositionY, new Integer(100)); xPSetDialog.setPropertyValue(Width, new Integer(120)); xPSetDialog.setPropertyValue(Height, new Integer(280)); xPSetDialog.setPropertyValue(Title, new String(Styles and Formatting)); xPSetDialog.setPropertyValue(Closeable, new Boolean(false)); // get the service manager from the dialog model XMultiServiceFactory xMultiServiceFactory = (XMultiServiceFactory) UnoRuntime.queryInterface( XMultiServiceFactory.class, dialogModel); // create the listbox model and set its properties Object listBoxModel = xMultiServiceFactory.createInstance( com.sun.star.awt.UnoControlListBoxModel); String[] a = {My Heading1, My Heading2}; XPropertySet xPSetListBox = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, listBoxModel); xPSetListBox.setPropertyValue(MultiSelection, new Boolean(false)); xPSetListBox.setPropertyValue(StringItemList, a); xPSetListBox.setPropertyValue(Name, listBoxName); xPSetListBox.setPropertyValue(PositionX, new Integer(0)); xPSetListBox.setPropertyValue(PositionY, new Integer(0)); xPSetListBox.setPropertyValue(Width, new Integer(120)); xPSetListBox.setPropertyValue(Height, new Integer(280)); // insert listbox model into the dialog model XNameContainer xNameCont = (XNameContainer) UnoRuntime.queryInterface( XNameContainer.class, dialogModel); xNameCont.insertByName(listBoxName, listBoxModel); // create the dialog control and set the model Object dialog = xRemoteServiceManager.createInstanceWithContext( com.sun.star.awt.UnoControlDialog, xRemoteContext); XControl xControl = (XControl) UnoRuntime.queryInterface( XControl.class, dialog); XControlModel xControlModel = (XControlModel) UnoRuntime.queryInterface( XControlModel.class, dialogModel); xControl.setModel(xControlModel); // not quite sure what this does but it works XWindow xWindow = (XWindow) UnoRuntime.queryInterface( XWindow.class, xControl); xWindow.setVisible(true); } Tuomas - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] creating non-modal dialog
Hi Laurent, Alle 13:58, giovedì 20 aprile 2006, Laurent Godard ha scritto: Hi Paolo It sounds quite strange to me that a UNOControlDialog behaves as non-modal. a hack iirc is to set the visible property to true do not use execute but loop over a global boolean to detect a stop set do not forget a wait statement in the loop to allow other process to work :-) the global idea (tested a long time ago) [...] Feel free to ask, i may find some old code Np, your example is perfectly understandable It works! Cool!! I didn't know this trick! :-) Thank you Paolo M - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]