Skip to main content
Inspiring
August 8, 2018
Answered

Background image in dialog?

  • August 8, 2018
  • 3 replies
  • 1766 views

Hello,

I know a dialog background color can easily be changed but, just to be sure, there is no way to add a background image to a dialog?

Thank you.

This topic has been closed for replies.
Correct answer Loic.Aigon

Go frenzy…

Image.prototype.onDraw = function()

{ // written by Marc Autret

// "this" is the container; "this.image" is the graphic

if( !this.image ) return;

var WH = this.size,

wh = this.image.size,

k = Math.min(WH[0]/wh[0], WH[1]/wh[1]),

xy;

// Resize proportionally:

wh = [k*wh[0],k*wh[1]];

// Center:

xy = [ (WH[0]-wh[0])/2, (WH[1]-wh[1])/2 ];

this.graphics.drawImage(this.image,xy[0],xy[1],wh[0],wh[1]);

WH = wh = xy = null;

}

var w  =new Window( 'dialog' );

var g = w.add('group');

var u;

var i = g.add ('image', u, File(Folder.desktop+"/campagne.jpeg" ) );

w.margins = 0;

g.orientation = "stack";

w.alignChildren = g.alignChildren = ["fill","fill"];

var mainGp = g.add('group');

mainGp.margins = 5;

mainGp.alignChildren = ["left", "top" ];

mainGp.add('edittext', u, 'What a nice background…');

mainGp.add('checkbox', u, 'Do you like it ?');

w.onDraw = function() {

i.size = w.size;

}

w.show();

3 replies

Known Participant
December 10, 2020

dont Work Were 😞

Loic.Aigon
Legend
August 8, 2018

ScriptUI is both exciting and annoying. For more advanced dialogs, have a look at CEP Panels.

Kukurykus
Legend
August 8, 2018

What is background image, and what dialog are you taking about?

JJMack
Community Expert
Community Expert
August 8, 2018

This is a scripting forum so I'll bet they mean a script's dialog using ScriptUI.

JJMack
Loic.Aigon
Loic.AigonCorrect answer
Legend
August 8, 2018

Go frenzy…

Image.prototype.onDraw = function()

{ // written by Marc Autret

// "this" is the container; "this.image" is the graphic

if( !this.image ) return;

var WH = this.size,

wh = this.image.size,

k = Math.min(WH[0]/wh[0], WH[1]/wh[1]),

xy;

// Resize proportionally:

wh = [k*wh[0],k*wh[1]];

// Center:

xy = [ (WH[0]-wh[0])/2, (WH[1]-wh[1])/2 ];

this.graphics.drawImage(this.image,xy[0],xy[1],wh[0],wh[1]);

WH = wh = xy = null;

}

var w  =new Window( 'dialog' );

var g = w.add('group');

var u;

var i = g.add ('image', u, File(Folder.desktop+"/campagne.jpeg" ) );

w.margins = 0;

g.orientation = "stack";

w.alignChildren = g.alignChildren = ["fill","fill"];

var mainGp = g.add('group');

mainGp.margins = 5;

mainGp.alignChildren = ["left", "top" ];

mainGp.add('edittext', u, 'What a nice background…');

mainGp.add('checkbox', u, 'Do you like it ?');

w.onDraw = function() {

i.size = w.size;

}

w.show();