|
D Paste by WasserDragoon
Description: Tooltip example snippet: create a balloon tooltip for a tray item
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | /* * Tooltip example snippet: create a balloon tooltip for a tray item * */ module main; import dwt.DWT; import dwt.graphics.Image; import dwt.widgets.Button; import dwt.widgets.Display; import dwt.widgets.Event; import dwt.widgets.Listener; import dwt.widgets.Shell; import dwt.widgets.ToolTip; import dwt.widgets.Tray; import dwt.widgets.TrayItem; void main() { Display display = new Display(); Shell shell = new Shell(display); Image image = null; ToolTip tip = new ToolTip(shell, DWT.BALLOON | DWT.ICON_INFORMATION); tip.setMessage("Here is a message for the user. When the message is too long it wraps. I should say something cool but nothing comes to my mind."); Tray tray = display.getSystemTray(); if (tray !is null) { TrayItem item = new TrayItem(tray, DWT.NONE); image = new Image(display, "yourFile.gif"); item.setImage(image); tip.setText("Notification from a tray item"); item.setToolTip(tip); } else { tip.setText("Notification from anywhere"); tip.setLocation(400, 400); } Button button = new Button(shell, DWT.PUSH); button.setText("Press for balloon tip"); button.addListener(DWT.Selection, new class Listener { public void handleEvent(Event e) { tip.setVisible(true); } }); button.pack(); shell.setBounds(50, 50, 300, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } if (image !is null) { image.dispose(); } display.dispose(); } |