Advertisement
Guest User

GuiDWT.d

a guest
Sep 25th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 2.69 KB | None | 0 0
  1. module GuiDWT;
  2.  
  3. import org.eclipse.swt.SWT;
  4.  
  5. import org.eclipse.swt.layout.FillLayout;
  6. import org.eclipse.swt.widgets.Shell;
  7. import org.eclipse.swt.widgets.Display;
  8. import org.eclipse.swt.widgets.Event;
  9. import org.eclipse.swt.widgets.Composite;
  10. import org.eclipse.swt.widgets.Listener;
  11. import org.eclipse.swt.widgets.Text;
  12. import org.eclipse.swt.graphics.Color;
  13. import org.eclipse.swt.events.PaintEvent;
  14. import org.eclipse.swt.events.PaintListener;
  15. import org.eclipse.swt.events.KeyAdapter;
  16. import org.eclipse.swt.events.KeyEvent;
  17. import org.eclipse.swt.graphics.GC;
  18. import org.eclipse.swt.graphics.all;
  19.  
  20. import derelict.allegro5;
  21.  
  22. import java.lang.all;
  23.  
  24. import std.conv;
  25.  
  26. import core.sys.windows.windows;
  27.  
  28. import allegroutils;
  29.  
  30. class GuiDWT  {
  31.    
  32.     Display display;
  33.     Shell shell;
  34.     Text text0;
  35.     Text text1;
  36.     Composite composite0;
  37.     static ALLEGRO_DISPLAY *screen = null;
  38.  
  39.     Image im;
  40.  
  41.     this(){
  42.  
  43.         al_init();
  44.  
  45.         display = new Display();
  46.         shell = new Shell(display);
  47.         shell.setLayout(null);
  48.  
  49.         shell.setText("Goblin");
  50.  
  51.         composite0 = new Composite(shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
  52.         composite0.setBounds(10,10,989,480);
  53.  
  54.         ALLEGRO_BITMAP *myALBitmap = al_create_bitmap(979, 470);
  55.         al_set_target_bitmap(myALBitmap);
  56.         al_clear_to_color(al_map_rgb(255,128,0));
  57.         al_flip_display();
  58.  
  59.         //im = new Image(display,"./test.png");
  60.  
  61.         composite0.addPaintListener( new class PaintListener {
  62.             override public void paintControl(PaintEvent event) {
  63.  
  64.                 GC gc = event.gc;
  65.                 GCData gcdata = gc.getGCData();
  66.                 HWND hwnd = cast(HWND)gcdata.hwnd; //data. drawable.handle;    
  67.                 HDC hdc = GetDC(hwnd);
  68.                 local_draw_to_hdc(hdc, myALBitmap, 0, 0);
  69.  
  70.             } });      
  71.  
  72.         text0 = new Text (shell, SWT.BORDER | SWT.V_SCROLL | SWT.READ_ONLY);
  73.         text0.setBounds(10,500,989,180);
  74.  
  75.         Color black = display.getSystemColor(SWT.COLOR_BLACK);
  76.         Color cyan = display.getSystemColor(SWT.COLOR_CYAN);
  77.         text0.setBackground(black);
  78.         text0.setForeground(cyan);
  79.         text0.setText("Goblin3D Client 0.0\r\n");
  80.  
  81.         text1 = new Text (shell, SWT.BORDER);
  82.         text1.setBounds(10,681,989,25);
  83.         text1.setBackground(black);
  84.         text1.setForeground(cyan);
  85.  
  86.         text1.addKeyListener( new class KeyAdapter {
  87.  
  88.             override public void keyPressed(KeyEvent event) {
  89.                 switch(event.keyCode) {
  90.                     case SWT.CR:
  91.                         text0.append(text1.getText()~"\r\n");  
  92.                         text1.setText("");                     
  93.                         break;
  94.                     default:
  95.                         break;
  96.                 }
  97.             }
  98.         });
  99.  
  100.         shell.setBounds(10, 10, 1024, 800);
  101.         shell.open();
  102.    
  103.     };
  104.  
  105.  
  106.  
  107.     int run() {
  108.  
  109.         while (!shell.isDisposed()) {
  110.             if (!display.readAndDispatch())
  111.                 display.sleep();
  112.         }
  113.         //im.dispose();
  114.         display.dispose();
  115.  
  116.         return 0;
  117.     };
  118.  
  119. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement