[Solved] Struggling with dialogs
[Solved] Struggling with dialogs
I've been struggling with dialogs for way too long, but I'm winning ground, "mm by mm of the km long route".
E.g. it took me some nights to (hopefully) get the hang of
dlgModel = createUnoService( "com.sun.star.awt.UnoControlDialogModel" )
compared to
dlg = createUnoService( "com.sun.star.awt.UnoControlDialog" ) : dlgModel = dlg.Model
My current road block (aside from difficulties with event listening/handling beyond actionlistener - can someone point me to examples referring to dialogs?) is
how to make the labels of radio buttons transparent
(like those of the dialog defined graphically in the Basic IDE). The isTransparent method returns true, but the appearance isn't. I can't find any property that differs from the rb-labels from the graphical definition, still their appearance differs.
btw - if I set my dialog visible during debug (to view graphical changes step by step) and am thrown out of the code execution (by an "uncaught" exception) before the dialog is explicitly set invisible / disposed, I can't find a way to dispose that window (and suspect that independent of the visibility it still resides somewhere in memory). Any hint how to get rid of such garbage?
E.g. it took me some nights to (hopefully) get the hang of
dlgModel = createUnoService( "com.sun.star.awt.UnoControlDialogModel" )
compared to
dlg = createUnoService( "com.sun.star.awt.UnoControlDialog" ) : dlgModel = dlg.Model
My current road block (aside from difficulties with event listening/handling beyond actionlistener - can someone point me to examples referring to dialogs?) is
how to make the labels of radio buttons transparent
(like those of the dialog defined graphically in the Basic IDE). The isTransparent method returns true, but the appearance isn't. I can't find any property that differs from the rb-labels from the graphical definition, still their appearance differs.
btw - if I set my dialog visible during debug (to view graphical changes step by step) and am thrown out of the code execution (by an "uncaught" exception) before the dialog is explicitly set invisible / disposed, I can't find a way to dispose that window (and suspect that independent of the visibility it still resides somewhere in memory). Any hint how to get rid of such garbage?
Last edited by Hardy on Fri Mar 13, 2009 2:42 am, edited 1 time in total.
OOo 3.0.X on Ms Windows W2k
Re: Struggling with dialogs
There is a high chance I'm not understanding your question. When you say "how to make the labels of radio buttons transparent (like those of the dialog defined graphically in the Basic IDE)" I understand that you want to set the BackgroundColor to white. That is, use code like
That makes the control look like it does in design mode in the IDE but is not what is usually meant by transparent, so I suspect I'm confused.
Code: Select all
oDialog1Model = oDialog1.Model
OptButtonModel = oDialog1Model.getByName("OptionButton1")
OptButtonModel.BackgroundColor = RGB(255,255,255)
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Re: Struggling with dialogs
oh dear - that simple!? &Hffffff = transparent!? didn't show me white in any property - trying immediately!
Nope, doesn't work: white labels now.
And yes, the graphically defined ones look white in the IDE, transparent when applied. Those, defined in the code remain white.
Tried to cut something out that should almost be executable by itself:
(contains lot of debug garbage, but that might be helpful for experiments)
(not yet any inline documentation)
graphical definition (not all specs of the above seem to be definable that way):
Nope, doesn't work: white labels now.
And yes, the graphically defined ones look white in the IDE, transparent when applied. Those, defined in the code remain white.
Tried to cut something out that should almost be executable by itself:
(contains lot of debug garbage, but that might be helpful for experiments)
(not yet any inline documentation)
Edit: supplemented the code with the sCR shortcut |
Code: Select all
REM ***** BASIC *****
option explicit
global sCR as string
sub main
sCR = chr(13)
msgbox lDialog( dlgCheck4obdFailed )
end sub
function lDialog( dlg as object ) as long
dlg.getControl("option2").label = "option~2 (text can be pretty long, especially in other languages)..."
dlg.getControl("option3").label = "option~3 (it can actually be long enough to require multiple lines for complete display)"
' dlgActivate( dlg )
dlg.Visible = true
'dim ctl as object : ctl = dlg.getControl("option2")
'globalScope.basicLibraries.loadLibrary( "XrayTool" )
'xray ctl
dlg.execute()
dlg.dispose()
end function
function dlgCheck4obdFailed as object
dim i as integer, dlg as object', ctl as object
'
dlg = dlgStandard480x360
with dlg.Model
.Title = "dlgCheck4obdFailed" : .BackgroundColor = &H8BACCA ': .TextColor = &H333366
.ImageURL = convertToURL( ##### <some valid path here> ##### & "Logo08 4 dlgs 480×360.jpg" )
end with
dlg.Visible = true : on error resume next
'
with dlg.getControl("intro").Model
.Label = "i" & sCR & "n" & sCR & "t" & sCR & "r" & sCR & "o"
'.Width = 240 : .Height = 60 : .PositionX = 12 : .PositionY = 34
'.FontName = "Arial" : .FontHeight = 10. : .FontStyleName = "Standard"
'.TextColor = &H333366 : .MultiLine = true' : .BackgroundColor = 0
'.Align = 0 : .VerticalAlign = com.sun.star.style.VerticalAlignment.MIDDLE
'dlgMdl.insertByName( .Name, ctlMdl )
end with
'
with dlg.getControl("options").Model
'.Label = .Name ': .enabled = true
'.Width = 256 : .Height = 112 : .PositionX = 5 : .PositionY = 88
'.FontName = "Arial" : .FontHeight = 10. : .FontStyleName = "Standard"
'.TextColor = &H333366
end with
'
for i = 0 to 4
'dim ctl as object : ctl = dlg.getControl("option" & i)
'globalScope.basicLibraries.loadLibrary( "XrayTool" )
'xray ctl
with dlg.getControl("option" & i).Model
.TabIndex = i : .TabStop = true : '.Label = .Name : .enabled = true
if i then
.PositionX = 10. : .PositionY = 74 + 25 * i ': Width = 244 : .Height = 22
else
.PositionX = 9 : .PositionY = 99 : .State = true ': .Width = 0 : .Height = 0
end if
'.FontName = "Arial" : .FontHeight = 10. : .FontStyleName = "Standard"
'.Align = 0 : .VerticalAlign = com.sun.star.style.VerticalAlignment.MIDDLE
'.MultiLine = true : .TextColor = &H333366 : .ImageURL = ""
.BackgroundColor = RGB(255,255,255) 'won't show transparent - neither here nor when defined as 'standard'
end with
next i
'
for i = 5 to 6
with dlg.getControl("fp" & (i-4)).Model
'.Text = .Name : .enabled = true : .TabIndex = i : .Tabstop = false
'.Width = 14 : .Height = 15 : .PositionX = 240 : .PositionY = 3 + 25 * i
'.FontName = "Arial" : .FontHeight = 10. : .FontStyleName = "Standard"
'.BackgroundColor = &H8BACCA : '.TextColor = &H333366 ': .ImageURL = ""
end with
next i
'
dlg.Visible = false : on error goto 0
dlgCheck4obdFailed = dlg
end function
function dlgStandard480x360
dim i as integer, dlgMdl as object, dlgCtl as object, ctlMdl as object', ctlCtl as object
'
dlgMdl = createUnoService( "com.sun.star.awt.UnoControlDialogModel" )
with dlgMdl
.Title = "title" : .Width = 266 : .Height = 206
.FontName = "Arial" : .FontHeight = 10. : .FontStyleName = "Standard" : .TextColor = &H333366
end with
dlgCtl = createUnoService( "com.sun.star.awt.UnoControlDialog" )
dlgCtl.setModel( dlgMdl )
dlgCtl.Visible = true : on error resume next
'
ctlMdl = dlgMdl.createInstance( "com.sun.star.awt.UnoControlFixedTextModel" )
with ctlMdl
.Name = "intro" : .Label = "intro" ': .Label = "i" & sCR & "n" & sCR & "t" & sCR & "r" & sCR & "o"
.Width = 240 : .Height = 60 : .PositionX = 12 : .PositionY = 34
.FontName = "Arial" : .FontHeight = 10. : .FontStyleName = "Standard" : .TextColor = &H333366
.MultiLine = true : .Align = 0 : .VerticalAlign = com.sun.star.style.VerticalAlignment.MIDDLE
dlgMdl.insertByName( .Name, ctlMdl )
end with
'
ctlMdl = dlgMdl.createInstance( "com.sun.star.awt.UnoControlGroupBoxModel" )
with ctlMdl
.Name = "options": .Label = .Name ': .enabled = true
.Width = 256 : .Height = 112 : .PositionX = 5 : .PositionY = 88
.FontName = "Arial" : .FontHeight = 10. : .FontStyleName = "Standard" : .TextColor = &H333366
dlgMdl.insertByName( .Name, ctlMdl )
end with
'
for i = 0 to 4
ctlMdl = dlgMdl.createInstance( "com.sun.star.awt.UnoControlRadioButtonModel" )
with ctlMdl
.Name = "option" & i : .Label = .Name : .enabled = true : .TabIndex = i : .Tabstop = true
if i then
.Width = 225 : .Height = 22 : .PositionX = 10 : .PositionY = 74 + 25 * i
else
.Width = 0 : .Height = 0 : .PositionX = 9 : .PositionY = 90 : .State = true
end if
.FontName = "Arial" : .FontHeight = 10. : .FontStyleName = "Standard" : .TextColor = &H333366
.MultiLine = true : .Align = 0 : .VerticalAlign = com.sun.star.style.VerticalAlignment.MIDDLE
dlgMdl.insertByName( .Name, ctlMdl )
end with
next i
'
for i = 5 to 6
ctlMdl = dlgMdl.createInstance( "com.sun.star.awt.UnoControlFileControlModel" )
with ctlMdl
.Name = "fp" & (i-4) : .Text = .Name : .enabled = true : .TabIndex = i : .Tabstop = false
.Width = 14 : .Height = 15 : .PositionX = 240 : .PositionY = 3 + 25 * i
.FontName = "Arial" : .FontHeight = 10. : .FontStyleName = "Standard" : '.TextColor = &H333366
.BackgroundColor = &H8BACCA
dlgMdl.insertByName( .Name, ctlMdl )
end with
next i
'
dlgCtl.Visible = false : on error goto 0
dlgStandard480x360 = dlgCtl
end function
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "dialog.dtd">
<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:style-id="2" dlg:id="dlgCheck4odbFailed" dlg:tab-index="2" dlg:left="228" dlg:top="107" dlg:width="270" dlg:height="221" dlg:closeable="true" dlg:moveable="true" dlg:withtitlebar="false" dlg:image-src="file:/// ##### <some valid path here> ##### /Logo08%204%20dlgs%20480%C3%97360.jpg">
<dlg:styles>
<dlg:style dlg:style-id="0" dlg:text-color="0x333366" dlg:font-name="Arial" dlg:font-height="10" dlg:font-stylename="Standard" dlg:font-family="swiss"/>
<dlg:style dlg:style-id="1" dlg:look="simple"/>
<dlg:style dlg:style-id="2" dlg:background-color="0x8cabca" dlg:text-color="0x333366" dlg:font-name="Arial" dlg:font-height="10" dlg:font-stylename="Standard" dlg:font-family="swiss"/>
</dlg:styles>
<dlg:bulletinboard>
<dlg:text dlg:style-id="0" dlg:id="intro" dlg:tab-index="5" dlg:left="13" dlg:top="54" dlg:width="242" dlg:height="49" dlg:value="intro" dlg:multiline="true"/>
<dlg:titledbox dlg:style-id="0" dlg:id="options" dlg:tab-index="6" dlg:left="6" dlg:top="105" dlg:width="256" dlg:height="108">
<dlg:title dlg:value="options"/>
</dlg:titledbox>
<dlg:radiogroup>
<dlg:radio dlg:style-id="0" dlg:id="option1" dlg:tab-index="1" dlg:left="10" dlg:top="118" dlg:width="232" dlg:height="21" dlg:value="option1" dlg:multiline="true">
<script:event script:event-name="on-keyup" script:macro-name="vnd.sun.star.script:Standard.initApp.aDlgCheck4odbFailed?language=Basic&location=document" script:language="Script"/>
<script:event script:event-name="on-mouseup" script:macro-name="vnd.sun.star.script:Standard.initApp.aDlgCheck4odbFailed?language=Basic&location=document" script:language="Script"/>
</dlg:radio>
<dlg:radio dlg:style-id="0" dlg:id="option2" dlg:tab-index="2" dlg:left="10" dlg:top="140" dlg:width="232" dlg:height="21" dlg:value="option2" dlg:multiline="true">
<script:event script:event-name="on-keyup" script:macro-name="vnd.sun.star.script:Standard.initApp.aDlgCheck4odbFailed?language=Basic&location=document" script:language="Script"/>
<script:event script:event-name="on-mouseup" script:macro-name="vnd.sun.star.script:Standard.initApp.aDlgCheck4odbFailed?language=Basic&location=document" script:language="Script"/>
</dlg:radio>
<dlg:radio dlg:style-id="0" dlg:id="option3" dlg:tab-index="3" dlg:left="10" dlg:top="162" dlg:width="232" dlg:height="21" dlg:value="option3" dlg:multiline="true">
<script:event script:event-name="on-keyup" script:macro-name="vnd.sun.star.script:Standard.initApp.aDlgCheck4odbFailed?language=Basic&location=document" script:language="Script"/>
<script:event script:event-name="on-mouseup" script:macro-name="vnd.sun.star.script:Standard.initApp.aDlgCheck4odbFailed?language=Basic&location=document" script:language="Script"/>
</dlg:radio>
<dlg:radio dlg:style-id="0" dlg:id="option4" dlg:tab-index="4" dlg:left="10" dlg:top="184" dlg:width="232" dlg:height="21" dlg:value="option4" dlg:multiline="true">
<script:event script:event-name="on-keyup" script:macro-name="vnd.sun.star.script:Standard.initApp.aDlgCheck4odbFailed?language=Basic&location=document" script:language="Script"/>
<script:event script:event-name="on-mouseup" script:macro-name="vnd.sun.star.script:Standard.initApp.aDlgCheck4odbFailed?language=Basic&location=document" script:language="Script"/>
</dlg:radio>
<dlg:radio dlg:style-id="1" dlg:id="option0" dlg:tab-index="0" dlg:left="3" dlg:top="115" dlg:width="72" dlg:height="1" dlg:value="
option0 - dummy" dlg:align="center" dlg:checked="true"/>
</dlg:radiogroup>
<dlg:filecontrol dlg:style-id="2" dlg:id="filePicker1" dlg:tab-index="7" dlg:left="242" dlg:top="144" dlg:width="15" dlg:height="15" dlg:tabstop="false" dlg:value="filePicker1">
<script:event script:event-name="on-mouseup" script:macro-name="vnd.sun.star.script:Standard.initApp.aDlgCheck4odbFailed?language=Basic&location=document" script:language="Script"/>
<script:event script:event-name="on-textchange" script:macro-name="vnd.sun.star.script:Standard.initApp.aDlgCheck4odbFailed?language=Basic&location=document" script:language="Script"/>
<script:event script:event-name="on-keyup" script:macro-name="vnd.sun.star.script:Standard.initApp.aDlgCheck4odbFailed?language=Basic&location=document" script:language="Script"/>
</dlg:filecontrol>
<dlg:filecontrol dlg:style-id="2" dlg:id="filePicker2" dlg:tab-index="8" dlg:left="242" dlg:top="165" dlg:width="15" dlg:height="15" dlg:tabstop="false" dlg:value="filePicker2">
<script:event script:event-name="on-mouseup" script:macro-name="vnd.sun.star.script:Standard.initApp.aDlgCheck4odbFailed?language=Basic&location=document" script:language="Script"/>
<script:event script:event-name="on-textchange" script:macro-name="vnd.sun.star.script:Standard.initApp.aDlgCheck4odbFailed?language=Basic&location=document" script:language="Script"/>
<script:event script:event-name="on-keyup" script:macro-name="vnd.sun.star.script:Standard.initApp.aDlgCheck4odbFailed?language=Basic&location=document" script:language="Script"/>
</dlg:filecontrol>
</dlg:bulletinboard>
Last edited by Hardy on Thu Mar 12, 2009 9:03 am, edited 1 time in total.
OOo 3.0.X on Ms Windows W2k
Re: Struggling with dialogs
I only had time to take a quick look at your code today. Before I jump in to try to make it run - maybe that will be quick, maybe not - could you post images showing what you mean by transparent and non-transparent labels? It will likely be clear once I run you code, but if I get hung up on that, having an image might give me some ideas. I'll work on this over the next few days. You have more skill at this than I do, so I may not contribute much.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Re: Struggling with dialogs
Hi FJCC, I take this:
Transparent just means that you see the text of the controls' labels directly on the background of the image that makes the background of the dialog (and is rather like a watermark in the region where the controls reside). And sure, I can/will attach screen shots (but I'm surprised that "transparent" should be a such an uncomon notion). *going2takeThoseScreenShots*
... as a big compliment, but can hardly believe it - I feel like a bloody rookie with OOo.FJCC wrote:... You have more skill at this than I ...
Transparent just means that you see the text of the controls' labels directly on the background of the image that makes the background of the dialog (and is rather like a watermark in the region where the controls reside). And sure, I can/will attach screen shots (but I'm surprised that "transparent" should be a such an uncomon notion). *going2takeThoseScreenShots*
OOo 3.0.X on Ms Windows W2k
Re: Struggling with dialogs
o dear, that was an exhausting struggle... but eventually OOo gave in before I did.
The solution is an undocumented special color, the code of which I had already tried out much earlier, but...
it's also crucial at which point between the definition and the execution of the dialog the background color is applied.
(Same is true for the specification of a background image: depending on where (in the sequence - not(!) for which element!) you define it, it applies to different sets of elements in the dialog.)
I had come earlier to the (wrong) conclusion that it relates to differences of
createUnoService( "com.sun.star.awt.UnoControlDialogModel" ) vs. createUnoService( "com.sun.star.awt.UnoControlDialog" ).Model
but now doubt that this is true.
Anyway, my dialog is now working perfectly.
And once again, thank you FJCC for your responsiveness!
Even though it didn't lead me directly to the solution this time, it's just encouraging for going on fighting when you get the feeling that there's someone else who cares.
The solution is an undocumented special color, the code of which I had already tried out much earlier, but...
it's also crucial at which point between the definition and the execution of the dialog the background color is applied.
(Same is true for the specification of a background image: depending on where (in the sequence - not(!) for which element!) you define it, it applies to different sets of elements in the dialog.)
I had come earlier to the (wrong) conclusion that it relates to differences of
createUnoService( "com.sun.star.awt.UnoControlDialogModel" ) vs. createUnoService( "com.sun.star.awt.UnoControlDialog" ).Model
but now doubt that this is true.
Anyway, my dialog is now working perfectly.
And once again, thank you FJCC for your responsiveness!
Even though it didn't lead me directly to the solution this time, it's just encouraging for going on fighting when you get the feeling that there's someone else who cares.
OOo 3.0.X on Ms Windows W2k
Re: Struggling with dialogs
Great! I know the frustration of finding those details that somehow don't appear in the documentation. My uncertainty about what you meant by "transparent" was that I didn't see the difference between a transparent label and one that had the same background color as the rest of the dialog. It seems we were talking about the same thing, but written messages sent hours apart can be a tough way to communicate. Good luck with the rest of your work.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Re: [Solved] Struggling with dialogs
Almost 10 years ago (I know...), Hardy told us that OOo gave in before he did on this subject as he found the solution with "an undocumented special color' (transparent background of controls). But he did not tell us what was this special color code!
Does anybody here have this magic code?
Does anybody here have this magic code?
LibreOffice 5.3.6.1 on MacOS Sierra 10.12.6 / LibreOffice 5.3.6.1 on Windows
Re: [Solved] Struggling with dialogs
Fanfan:
Try -1
Try -1
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: [Solved] Struggling with dialogs
Hi Jeje!
Thks for your quick answer ! What is quite surprising to me is that it seems I get transparency (by default!) on my mac for all the controls but I get a light grey background for all of them on Windows with "the same" LO version. And I get the same light grey background even if I specify the backgroundcolor as -1.
Do you have any clue on this?
Thks for your quick answer ! What is quite surprising to me is that it seems I get transparency (by default!) on my mac for all the controls but I get a light grey background for all of them on Windows with "the same" LO version. And I get the same light grey background even if I specify the backgroundcolor as -1.
Do you have any clue on this?
LibreOffice 5.3.6.1 on MacOS Sierra 10.12.6 / LibreOffice 5.3.6.1 on Windows
Re: [Solved] Struggling with dialogs
Fanfan - maybe this thread and changing the NativeWidgetLook will help you:
viewtopic.php?f=6&t=6133
viewtopic.php?f=6&t=6133
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: [Solved] Struggling with dialogs
Jeje,
I've gone through this thread already but it does not change anything. I can't get transparency of any controls on windows with LO...
As I saw Hardy saying that "the solution is an undocumented special color" but not telling us which special color it is, I was hoping that maybe somebody else would have got it...
I've gone through this thread already but it does not change anything. I can't get transparency of any controls on windows with LO...
As I saw Hardy saying that "the solution is an undocumented special color" but not telling us which special color it is, I was hoping that maybe somebody else would have got it...
LibreOffice 5.3.6.1 on MacOS Sierra 10.12.6 / LibreOffice 5.3.6.1 on Windows