OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Non-Modal Dialogs
Goto page 1, 2  Next
 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
Aaron
General User
General User


Joined: 14 Nov 2003
Posts: 34
Location: Cincinnati, OH

PostPosted: Wed Nov 10, 2004 10:08 am    Post subject: Non-Modal Dialogs Reply with quote

There has been a good amount of discussion regarding the ability (or lack thereof) to open non-modal (modaless) dialog boxes in OOo. Two of the more active discussions can be found here:
http://www.oooforum.org/forum/viewtopic.php?t=5381
http://www.oooforum.org/forum/viewtopic.php?t=5381

I wanted to reopen this discussion as it seems that no solution was ever found. I am hoping that maybe some fresh eyes on the problem may help. I think the basic goal here is to be able to open a dialog box, but still be able to interact with the windows behind the dialog box without closing it first.

Any ideas?

Thanks,
Aaron
Back to top
View user's profile Send private message AIM Address
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Wed Nov 10, 2004 10:35 am    Post subject: Reply with quote

I don't know if it is possible or not but believe it's possible. Have a look to frames, windows models components ... I have no clear skills on that but perhaps in the future....
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
Cybb20
Super User
Super User


Joined: 02 Mar 2004
Posts: 1569
Location: Frankfurt, Germany

PostPosted: Wed Nov 10, 2004 8:32 pm    Post subject: Reply with quote

Yes it is possible. There is a AWT Toolkit service that lets you integrate or create new frames. Those frames can be non-modal, modal or something else (the windowdescriptor is the one where you specify that).
Have a look at a simple Starbasic example:
http://www.oooforum.org/forum/viewtopic.php?t=9883

Hope this helps.
Christian
_________________
- Knowledge is Power -
Back to top
View user's profile Send private message Send e-mail
Robby
OOo Advocate
OOo Advocate


Joined: 21 Sep 2004
Posts: 249

PostPosted: Fri Nov 12, 2004 12:37 am    Post subject: Reply with quote

xxx

Last edited by Robby on Sun Dec 11, 2011 2:03 am; edited 1 time in total
Back to top
View user's profile Send private message
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Fri Nov 12, 2004 11:30 am    Post subject: Reply with quote

There are two different things here. Actually three.

1. Dialogs
2. AWT
3. Forms

Forms are much higher level than the other two.

Of the first two, Dialogs are something using the UnoDialogControl and its model. You can also create AWT windows with controls.

AWT windows are modeless, and are not tied to any other window.

AWT windows are not the same thing as dialogs.

Generally, dialogs are operated modally by calling execute() on the dialog.

I have also had some success operating dialogs modelessly. Just unhide the dialog, and it can be used modelessly. One drawback is that the modeless dialog seems to be tied to some concept of a "parent" window. I'm not sure, but I think that tends to be whatever window was in front when you created the dialog. So for example, you could create a modeless dialog that allows you to work with your document, but that modeless dialog's behavior appears to be tied to that document. Bring the modeless dialog to the front, and its document also comes to the front.
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
Cybb20
Super User
Super User


Joined: 02 Mar 2004
Posts: 1569
Location: Frankfurt, Germany

PostPosted: Fri Nov 12, 2004 3:19 pm    Post subject: Reply with quote

Good that you clarified that. I wasn't sure what was explicitly asked for as well, Aaron might let us know soon Wink.

Christian
_________________
- Knowledge is Power -
Back to top
View user's profile Send private message Send e-mail
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Sat Nov 13, 2004 9:32 am    Post subject: Reply with quote

Here are some links.


Here is a complete working example of how to create a modal dialog box on the fly.
http://www.oooforum.org/forum/viewtopic.php?p=11765#11765
This example is useful because it shows you a lot about how to work with the various services related to dialog boxes. In developing this code, I also played with modeless dialogs.

Enable / Disable dialog box buttons on the fly
http://www.oooforum.org/forum/viewtopic.php?t=4007

How to change the graphic of an image control in a dialog box
http://www.oooforum.org/forum/viewtopic.php?p=12942#12942

Center dialog box on screen
http://www.oooforum.org/forum/viewtopic.php?p=52909#52909

misc links....
http://www.oooforum.org/forum/viewtopic.php?t=4926
http://www.oooforum.org/forum/viewtopic.php?t=4601
http://www.oooforum.org/forum/viewtopic.php?p=16293#16293

Manipulating Basic Libraries and Dialogs
http://www.oooforum.org/forum/viewtopic.php?p=13050#13050
http://www.oooforum.org/forum/viewtopic.php?t=3504
http://api.openoffice.org/docs/DevelopersGuide/BasicAndDialogs/BasicAndDialogs.htm#1+4+Advanced+Library+Organization



Some articles from the Code Snippets section....

Playing with the AWT toolkit (in Basic)
http://www.oooforum.org/forum/viewtopic.php?t=8481

Embed multiple components into a single Window (in BASIC)
http://www.oooforum.org/forum/viewtopic.php?t=9883



These are about Forms, which is not what you asked for.

Creating Forms on the fly
http://www.oooforum.org/forum/viewtopic.php?t=10265

also see....
Programatically move/rezise a control in a sheet/document
http://www.oooforum.org/forum/viewtopic.php?p=32361#32361
How to add a button in a spreadsheet via macro?
http://www.oooforum.org/forum/viewtopic.php?p=38401#38401
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
Robby
OOo Advocate
OOo Advocate


Joined: 21 Sep 2004
Posts: 249

PostPosted: Sun Nov 14, 2004 1:18 am    Post subject: Reply with quote

xxx

Last edited by Robby on Sun Dec 11, 2011 2:03 am; edited 1 time in total
Back to top
View user's profile Send private message
stephan_beta
General User
General User


Joined: 13 Feb 2007
Posts: 16
Location: Genova, Italy

PostPosted: Tue Mar 06, 2007 1:40 am    Post subject: Reply with quote

I resume this very old thread to ask someone more expert than me if what I understood is correct on the basis of this following words from DannyB:
DannyB wrote:
One drawback is that the modeless dialog seems to be tied to some concept of a "parent" window. I'm not sure, but I think that tends to be whatever window was in front when you created the dialog. So for example, you could create a modeless dialog that allows you to work with your document, but that modeless dialog's behavior appears to be tied to that document. Bring the modeless dialog to the front, and its document also comes to the front.

Also referencing this thread about non-modal dialog, I wondered "why do I have to create an invisible window to pop up my dialog?".
Now, after some experiments I tend to think that a dialog is always modal no matter what.
What I tried is
Code:
XWindowPeer xPeer = xToolkit.getDesktopWindow( );
xControl.createPeer( xToolkit, xPeer );

instead of
Code:
XWindowPeer xPeer = xToolkit.createWindow( aDescriptor );
XWindow xWindow = (XWindow)UnoRuntime.queryInterface( XWindow.class, xPeer );
xWindow.setVisible( false );
xControl.createPeer( xToolkit, xPeer );

Doing this, the dialog I show is modal with respect for the document window I created the dialog upon. Say, I open OOo, create a new spreadsheet and a new writer document. If I execute my dialog from the spreadsheet window that one will be unaccessible, but the writer one will be not.
Funny thing is that if I do setVisible(true), I will see the blank window and the dialog. I can drag around the window, but until the dialog is open it will keep the focus. If I close the dialog the window will remain and I can't even close it! If I try again and close the dialog I will have 2 open windows, and so on! More, they remain alive even if I close the main OOo instance. On Linux I have to kill them.

Hence, creating "modeless dialog" seems to me more a workaround than a real solution.
Am I correct or am I missing something?
Back to top
View user's profile Send private message
dysmas
Power User
Power User


Joined: 14 Apr 2007
Posts: 59
Location: Grenoble, France

PostPosted: Sat Apr 14, 2007 9:38 am    Post subject: A modeless dialog Reply with quote

Hello,

using the information in the link :

http://www.oooforum.org/forum/viewtopic.phtml?t=9883

we have developped a fully featured non modal dialog. Which means :
A window with all the classic commands (buttons, togle buttons, check boxes, Radio buttons, list, labels. This window remains opened on top of the document and we can do anything in the document, selecting, moving and so on.


The only trouble we have is :
To be easy to use, this dialog must stay on top of the document. We have not find a way to achieve this inside OpenOffice. So we have used a small program, Deskpins, which can automatically pin a window and make it stay on top. In Windows, it works fine, but for Linux another solution must be found.
If anyone knows how to make a window created by the awt toolkit stay on top, I am interested. It is the last issue on this question.

[edited] See the solution of this problem below
_________________
Dysmas


Last edited by dysmas on Mon Apr 23, 2007 12:41 am; edited 1 time in total
Back to top
View user's profile Send private message
ms777
Super User
Super User


Joined: 07 Feb 2004
Posts: 1355

PostPosted: Sun Apr 15, 2007 7:12 am    Post subject: Re: A modeless dialog Reply with quote

dysmas wrote:
...The only trouble we have is :
To be easy to use, this dialog must stay on top of the document. We have not find a way to achieve this inside OpenOffice. ... If anyone knows how to make a window created by the awt toolkit stay on top, I am interested. It is the last issue on this question.

I am not aware of something like an AlwaysOnTop Property of anything in OO. A workaround would be to start a TopWindowListener on the mother document, when your dialog is shown. Whenever the mother document is activated, you can toFront() the dialog window

Good luck,

ms777
Back to top
View user's profile Send private message
dysmas
Power User
Power User


Joined: 14 Apr 2007
Posts: 59
Location: Grenoble, France

PostPosted: Sun Apr 15, 2007 7:40 am    Post subject: Reply with quote

We have tried this, but it is not a good solution because when you click on the document, the dialog window disappears and then reappears, and when it reappears, since it takes the focus, you loose the control of the document. For example, if you were opening a menu, the menu is closed.
If there is no other workaround, deskpins is a solution, but for windows users only...
_________________
Dysmas
Back to top
View user's profile Send private message
ms777
Super User
Super User


Joined: 07 Feb 2004
Posts: 1355

PostPosted: Sat Apr 21, 2007 8:55 am    Post subject: Reply with quote

Hi,

you can make the dialog window stay on top of the document by specifying ThisComponent.CurrentController.Frame.ContainerWindow as parentWindow, when you create the dialog's TopWindow.

I did not find a way to move the dialog with the mother document, though

Good luck,

ms777
Back to top
View user's profile Send private message
dysmas
Power User
Power User


Joined: 14 Apr 2007
Posts: 59
Location: Grenoble, France

PostPosted: Mon Apr 23, 2007 1:25 am    Post subject: Reply with quote

Wonderful, and many thanks it works !

so we have now a working solution for non-modal dialogs with the only trouble that it must be hard-coded.

I wondered if it would be possible to load in our window a dialog built with the GUI IDE. And I discovered a surprising thing : You can have a non-modal dialog by modifying just one line in your code.

Try this :
You have already prepared your (standard) dialog.
You load it by the commands :

dlg = loadDialog ("modaless","Dialog1")
answer = dlg.execute()

OK, this loads the normal modal dialog.

Now change the second line like this :

dlg = loadDialog ("modaless","Dialog1")
dlg.visible = true

AND (very important) either execute your macro step by step or place a break point after these lines. Your dialog opens and IS NOT MODAL !

To close it just continue your macro. When it closes, the dialog disappears.
And this is the problem : if you don't stop the macro, you will not be able to see the dialog.

I have found a dirty workaround :

After the lines above, I added

do
n = dlg.model.CloseButton.State
if n = 1 then exit do
wait (100)
loop


And II added a Toggle button in the dialog which name is CloseButton. The name can be different (just have to be the same as in the lines above) but it MUST me a TOGGLE button, otherwise the above code will not work.


Not too complicated, as you see. And now you can build your dialog with the GUI interface.


So I think we have now an answer to the question :
Non-modal dialogs are possible and easy in Open Office.

Perhaps developpers could integrate something more clean than my dirty workaround to display non-modal dialogs. All the basic mecanic is already present, so this should not be complicated.

Here is the summary of the code necessary to display a non-modal dialog Dialog1 of the library "modaless", provided the Dialog1 has a toggle button which name is CloseButton, to close the dialog.

=========================

Sub dialog_modal()

dim dlg as object
dim n as integer

dlg = loadDialog ("modaless","Dialog1")
dlg.visible = true

do
n = dlg.model.CloseButton.State
if n = 1 then exit do
wait (100)
loop

exit sub


That's all guys. Enjoy.
_________________
Dysmas
Back to top
View user's profile Send private message
pradhan
General User
General User


Joined: 01 Sep 2006
Posts: 48

PostPosted: Sun May 06, 2007 11:56 pm    Post subject: Reply with quote

I tried this code but i get a runtime error :
Quote:
Sub dialog_modal()

dim dlg as object
dim n as integer
dlg = loadDialog ("modaless","Dialog1")
dlg.visible = true

do
n = dlg.model.CloseButton.State
if n = 1 then exit do
wait (100)
loop

exit sub


the errore says "sub or function not defined" in line
Code:
dlg = loadDialog ("modaless","Dialog1")


What am I missing ?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group