I'm writing a script that will generate a GUI for displaying images, using a rowstate handler to pass the images over to the window.
Is there a way to set a picture box object to:
- Stretch with window size (with a minimum and maximum size defined)
- Maintain it's original aspect ratio (e.g. square) (see script 2)
- Forbid direct user re-sizing.
Here's some JSL that uses the sample table of images.
Clear Globals();
Names Default To Here(1);
dt = Open( "$SAMPLE_DATA/Big Class Families.jmp" );
//Set the picture equal to selected row
rs_updateviewer = Expr(
SelectedRows = (dt << Get Selected Rows());
i = If(N Items(SelectedRows) == 0, 1, SelectedRows[1]);
img = column(dt, "pet")[i];
pb << Set Image(img);
);
//Viewer Window
Viewer = New Window(
"Viewer",
Show Menu( 0 ),
<< On Close(Clear Globals(rs);
),
<< Size Window( 1000, 700),
vb = V List Box("Center",
H Center Box( Text Box( "Viewer" ) ),
H List Box(
// tb = dt << New Data Box(),
tb = Data Grid Box(),
pb = Picture Box()
)
)
,
pb << Set Stretch( "Fill", "Fill" );
pb << Border( 1 );
tb << Set Stretch( "Off", "Off" );
tb << Set Data Table( dt );
tb << Close Side Panels( 1 );
);
//Initiate image
rs_updateviewer;
// Define the handler function
f = Function( {a},
rs_updateviewer
);
// Register the row state handler to the table
set_rowstate = Expr(
rs = dt << Make Row State Handler( f );
);
set_rowstate;
Here's an script index example of a graph with it's aspect ratio fixed, the behaviour I'd like on the picture
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = Graph Builder( Show Control Panel( 0 ), Variables( X( :height ), Y( :weight ) ), Elements( Points( X, Y ), Smoother( X, Y ) ) );
gb << Fit to Window( "Maintain Aspect Ratio" );