Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module GuiDWT;
- import org.eclipse.swt.SWT;
- import org.eclipse.swt.layout.FillLayout;
- import org.eclipse.swt.widgets.Shell;
- import org.eclipse.swt.widgets.Display;
- import org.eclipse.swt.widgets.Event;
- import org.eclipse.swt.widgets.Composite;
- import org.eclipse.swt.widgets.Listener;
- import org.eclipse.swt.widgets.Text;
- import org.eclipse.swt.graphics.Color;
- import org.eclipse.swt.events.PaintEvent;
- import org.eclipse.swt.events.PaintListener;
- import org.eclipse.swt.events.KeyAdapter;
- import org.eclipse.swt.events.KeyEvent;
- import org.eclipse.swt.graphics.GC;
- import org.eclipse.swt.graphics.all;
- import derelict.allegro5;
- import java.lang.all;
- import std.conv;
- import core.sys.windows.windows;
- import allegroutils;
- class GuiDWT {
- Display display;
- Shell shell;
- Text text0;
- Text text1;
- Composite composite0;
- static ALLEGRO_DISPLAY *screen = null;
- Image im;
- this(){
- al_init();
- display = new Display();
- shell = new Shell(display);
- shell.setLayout(null);
- shell.setText("Goblin");
- composite0 = new Composite(shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
- composite0.setBounds(10,10,989,480);
- ALLEGRO_BITMAP *myALBitmap = al_create_bitmap(979, 470);
- al_set_target_bitmap(myALBitmap);
- al_clear_to_color(al_map_rgb(255,128,0));
- al_flip_display();
- //im = new Image(display,"./test.png");
- composite0.addPaintListener( new class PaintListener {
- override public void paintControl(PaintEvent event) {
- GC gc = event.gc;
- GCData gcdata = gc.getGCData();
- HWND hwnd = cast(HWND)gcdata.hwnd; //data. drawable.handle;
- HDC hdc = GetDC(hwnd);
- local_draw_to_hdc(hdc, myALBitmap, 0, 0);
- } });
- text0 = new Text (shell, SWT.BORDER | SWT.V_SCROLL | SWT.READ_ONLY);
- text0.setBounds(10,500,989,180);
- Color black = display.getSystemColor(SWT.COLOR_BLACK);
- Color cyan = display.getSystemColor(SWT.COLOR_CYAN);
- text0.setBackground(black);
- text0.setForeground(cyan);
- text0.setText("Goblin3D Client 0.0\r\n");
- text1 = new Text (shell, SWT.BORDER);
- text1.setBounds(10,681,989,25);
- text1.setBackground(black);
- text1.setForeground(cyan);
- text1.addKeyListener( new class KeyAdapter {
- override public void keyPressed(KeyEvent event) {
- switch(event.keyCode) {
- case SWT.CR:
- text0.append(text1.getText()~"\r\n");
- text1.setText("");
- break;
- default:
- break;
- }
- }
- });
- shell.setBounds(10, 10, 1024, 800);
- shell.open();
- };
- int run() {
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- //im.dispose();
- display.dispose();
- return 0;
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement