java - Is there a way to zoom an SWT Composite and its' children? -


I would like to develop an overall control, which ideally will be on its own scale in the allotted size.

I want to display a numeric value and 3 LED type images. As the size of overall growth, the font size of the value and the size of the images proportional increase.

I am reminded that there is something like that in .NET's WPF. Is there any way to do this in SWT?

(I know that I can add a setting page and set font size there, just looking for a way to do it automatically)

so what can you do, a canvas / Code>, drag your image . S and apply the scale to the text and width and height itself This scale varies depending on the mouse wheel movement.

Here is an example:

  Private static float scale = 1; Private static font font; Public stationary zero main (string [] args) {final display display = new display (); Last Shell Shell = New Shell (Display); Shell.setText ("StackOverflow"); Shell.setLayout (new FillLayout ()); Last image image = new image (display, "button.png"); Final Canvas Canvas = New Canvas (Shell, SWT.NONE); Canvas.Ed Listener (SWT.Paint, New Audience) {Private Initial Fontusys = -1; @ Override Public Wide Hand Event (Event Event) {Font Template Font = event.gc.getFont (); Font Data Data = tempFont.getFontData () [0]; if (initialFontSize == -1) initialFontSize = tempFont.getFontData () [0] .getHeight (); and (if (font! = Null & font.isDisposed ()) font.dispose (); Data.setHeight ((int) (initialFontSize * scale)); font = new font (display, data); event.gc.setFont (font);} rectangle borders = image.getBounds (); event.gc .drawImage (image, 0, 0, limitations width, bound. Hat, 0, 0, (aa (Bounds. Scale * scale); event.gc.setForeground (display.getSystemColor (SWT.COLOR_WHITE)); event.gc.drawText ("some text here",). (10 * scale), (int) (10 * scale), true);}}); canvas.ed listener (SWT.MouseWheel, new listener) {@ Override Public Wide Handel Event (Event Event) { If (event. Coat> 0) scale + = .2f; other scale - = .2f; scale = monastery. Max (scale, 0); canvas. Radra ();}}); Canvas.Ed Listener (SWT.Dispose, New Audience) {@Override Public Zero Handel Event (Event Event) {If Image.isDisposed ()) image.dispose (); If (! Font.isDisposed ()) font Dispose ();}}); Shell.pack (); Shell.setSize (400, 200); Shell.open (); While (! Shell.isDisposed ()) {if (! Display.readAndDispatch ()) {display.sleep (); }} Display.dispose (); }  

looks like:

Enter image details Please here


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -