コード例 #1
0
ファイル: Painting.java プロジェクト: 0x90sled/jdosbox
  // HDC WINAPI BeginPaint( HWND hwnd, PAINTSTRUCT *lps )
  public static int BeginPaint(int hwnd, int lps) {
    WinWindow win = WinWindow.get(hwnd);

    if (lps == 0) return 0;

    Caret.HideCaret(hwnd);

    int rgn = WinRegion.CreateRectRgn(0, 0, win.rectWindow.width(), win.rectWindow.height());
    Message.SendMessageA(hwnd, WM_NCPAINT, rgn, 0);
    GdiObj.DeleteObject(rgn);

    WinDC dc = win.getDC();
    if (win.invalidationRect == null) {
      new WinRect(0, 0, win.rectClient.width(), win.rectClient.height()).write(lps + 8);
    } else {
      dc.clipX = win.invalidationRect.left;
      dc.clipY = win.invalidationRect.top;
      dc.clipCx = win.invalidationRect.width();
      dc.clipCy = win.invalidationRect.height();
      win.invalidationRect.write(lps + 8);
    }
    int hdc = dc.handle;
    writed(lps, hdc);
    writed(lps + 4, Message.SendMessageA(hwnd, WM_ERASEBKGND, hdc, 0));
    return readd(lps);
  }
コード例 #2
0
ファイル: Painting.java プロジェクト: 0x90sled/jdosbox
 // BOOL EndPaint(HWND hWnd, const PAINTSTRUCT *lpPaint)
 public static int EndPaint(int hWnd, int lpPaint) {
   WinDC dc = WinDC.get(readd(lpPaint));
   if (dc != null) dc.close();
   Caret.ShowCaret(hWnd);
   Main.drawImage(StaticData.screen.getImage());
   WinWindow.get(hWnd).validate();
   return TRUE;
 }
コード例 #3
0
ファイル: Painting.java プロジェクト: 0x90sled/jdosbox
 // int ReleaseDC(HWND hWnd, HDC hDC)
 public static int ReleaseDC(int hWnd, int hDC) {
   WinDC dc = WinDC.get(hDC);
   if (dc == null) return 0;
   if (dc.isScreen()) {
     Main.drawImage(dc.getImage());
   }
   dc.close();
   return 1;
 }
コード例 #4
0
ファイル: Painting.java プロジェクト: 0x90sled/jdosbox
 // HDC WINAPI GetDC(HWND hwnd)
 public static int GetDC(int hwnd) {
   WinWindow win;
   if (hwnd == 0) {
     win = WinWindow.get(StaticData.desktopWindow);
   } else win = WinWindow.get(hwnd);
   if (win == null) return 0;
   WinDC dc = win.getDC();
   dc.open();
   return dc.handle;
 }
コード例 #5
0
ファイル: Painting.java プロジェクト: 0x90sled/jdosbox
  // BOOL Pie(HDC hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect, int nXRadial1,
  // int nYRadial1, int nXRadial2, int nYRadial2)
  public static int Pie(
      int hdc,
      int nLeftRect,
      int nTopRect,
      int nRightRect,
      int nBottomRect,
      int xstart,
      int ystart,
      int xend,
      int yend) {
    WinDC dc = WinDC.get(hdc);
    if (dc == null) return FALSE;

    if (nLeftRect == nRightRect || nTopRect == nBottomRect) return TRUE;
    WinPen pen = WinPen.get(dc.hPen);
    WinBrush brush = WinBrush.get(dc.hBrush);

    if (pen == null || brush == null) return FALSE;

    Graphics2D graphics = dc.getGraphics();
    int width = nRightRect - nLeftRect;
    int height = nBottomRect - nTopRect;

    int start =
        (int) (Math.atan2(height / 2.0 - ystart, xstart - width / 2.0) * 180 / Math.PI + 360) % 360;
    int end =
        (int) (Math.atan2(height / 2.0 - yend, xend - width / 2.0) * 180 / Math.PI + 360) % 360;
    int len;
    if (end < start) len = 360 - start + end;
    else len = end - start;
    Arc2D arc2D =
        new Arc2D.Double(dc.x + nLeftRect, dc.y + nTopRect, width, height, start, len, Arc2D.PIE);
    // inside
    if (brush.setPaint(graphics)) graphics.fill(arc2D);
    // border
    if (pen.setStroke(dc, graphics)) graphics.draw(arc2D);

    graphics.dispose();

    return TRUE;
  }
コード例 #6
0
ファイル: Painting.java プロジェクト: 0x90sled/jdosbox
  // BOOL Ellipse(HDC hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect)
  public static int Ellipse(int hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect) {
    WinDC dc = WinDC.get(hdc);
    if (dc == null) return FALSE;

    if (nLeftRect == nRightRect || nTopRect == nBottomRect) return TRUE;
    WinPen pen = WinPen.get(dc.hPen);
    WinBrush brush = WinBrush.get(dc.hBrush);

    if (pen == null || brush == null) return FALSE;

    Graphics2D graphics = dc.getGraphics();
    Ellipse2D ellipse2D =
        new Ellipse2D.Float(
            dc.x + nLeftRect, dc.y + nTopRect, nRightRect - nLeftRect, nBottomRect - nTopRect);
    // inside
    if (brush.setPaint(graphics)) graphics.fill(ellipse2D);
    // border
    if (pen.setStroke(dc, graphics)) graphics.draw(ellipse2D);

    graphics.dispose();
    return TRUE;
  }
コード例 #7
0
ファイル: Painting.java プロジェクト: 0x90sled/jdosbox
  // BOOL Rectangle(HDC hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect)
  public static int Rectangle(
      int hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect) {
    WinDC dc = WinDC.get(hdc);
    if (dc == null) return FALSE;
    if (nLeftRect == nRightRect || nTopRect == nBottomRect) return TRUE;
    WinPen pen = WinPen.get(dc.hPen);
    WinBrush brush = WinBrush.get(dc.hBrush);

    if (pen == null || brush == null) return FALSE;

    int width = nRightRect - nLeftRect - 1;
    int height = nBottomRect - nTopRect - 1;

    Graphics2D graphics = dc.getGraphics();
    Rectangle rectangle = new Rectangle(dc.x + nLeftRect, dc.y + nTopRect, width, height);
    // inside
    if (brush.setPaint(graphics)) graphics.fill(rectangle);
    // border
    if (pen.setStroke(dc, graphics)) graphics.draw(rectangle);

    graphics.dispose();
    if (dc.getImage() == StaticData.screen.getImage()) Main.drawImage(dc.getImage());
    return TRUE;
  }