Changeset 67

Show
Ignore:
Timestamp:
05/19/07 13:52:24 (2 years ago)
Author:
lindquist
Message:

Win32: Pen style was incorrectly applied, GContext.fillPolygon was not implemented, Window default visibility back to hidden, update painting sample.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/bughunt/minwin/mswindows.d

    r53 r67  
    267267export int SetPolyFillMode(HDC hdc, int m); 
    268268export int GetPolyFillMode(HDC hdc); 
     269export BOOL Polygon(HDC hdc, POINT* pts, int len); 
    269270 
    270271/* 
  • branches/bughunt/minwin/paint.d

    r48 r67  
    4040    Dash =                       1, /* ------- */ 
    4141    Dot =                        2, /* ······· */ 
    42     DashDot =                    3 /* -·-·-·- */ 
    43     // todo: None? 
     42    DashDot =                    3, /* -·-·-·- */ 
     43    None =                       4  /*         */ 
    4444} 
    4545 
     
    120120        } 
    121121        void style(PenStyle s) { 
    122             native.lopnStyle = s; 
     122            native.lopnStyle = [ 
     123                PS_SOLID, 
     124                PS_DASH, 
     125                PS_DOT, 
     126                PS_DASHDOT, 
     127                PS_NULL 
     128            ][s]; 
    123129        } 
    124130        void lineJoin(LineJoin j) { 
     
    280286        void drawText(int x, int y, char[] str) { 
    281287            BOOL ok; 
    282             //int old = SetBkMode(peer,1); 
     288            //int old = SetBkMode(peer,1); // this fixes the solid bg problem 
    283289            if (useWfuncs) { 
    284                 wchar[] buf = toUTF16(str); 
     290                scope buf = toUTF16(str); 
    285291                ok = TextOutW(peer, x, y, buf.ptr, buf.length); 
    286292            } 
     
    316322            } 
    317323        } 
    318         void drawBezier(Point[] pts) { 
    319 //            PolyBezier(peer,pts.ptr,pts.length); 
    320         } 
    321324        void fillPolygon(Point[] pts) { 
    322             //? 
     325            //sysAssert(pen !is null, "Pen must be set for fillPolygon"); 
     326            sysAssert(brush !is null, "Brush must be set for fillPolygon"); 
     327            if (pts.length > 1) { 
     328                BOOL ok = Polygon(peer,&pts[0].native,pts.length); 
     329                sysAssert(ok != false, "Failed to fill polygon"); 
     330            } 
    323331        } 
    324332        void fillRegion(Region rgn) { 
    325333            sysAssert(brush !is null, "Brush must be set for fillRect"); 
     334            sysAssert(false, "GContext.fillRegion not yet implemented"); 
    326335//            FillRgn(peer,rgn,brush); 
    327336        } 
  • branches/bughunt/minwin/window.d

    r56 r67  
    388388        this(char[] title = "", char[] name = "") { 
    389389            peer = CreateWindowX("MinWinWindow", title, 
    390                  MinWinWindowStyle | WS_VISIBLE
     390                 MinWinWindowStyle
    391391                 CW_USEDEFAULT, CW_USEDEFAULT, 
    392392                 DefaultWindowWidth, DefaultWindowHeight, 
  • branches/bughunt/samples/painting.d

    r33 r67  
    1818    GContext gc = im.getGContext(); 
    1919 
    20     auto Pen p2 = new Pen(RGB(0,0,0)); 
     20    scope p2 = new Pen(RGB(0,0,0)); 
    2121    Pen oldPen = gc.setPen(p2); 
    2222    Rect r = LTWH(0,0,100,150); 
    23     auto Brush b2 = new Brush(RGB(255,255,255)); 
     23    scope b2 = new Brush(RGB(200,200,200)); 
    2424    Brush oldBrush = gc.setBrush(b2); 
    2525    gc.fillRect(r); 
     
    3030    pd.width = 4; 
    3131    pd.style = PenStyle.Solid; 
    32     pd.color = RGB(100,0,120); 
    33     auto Pen p = new Pen(&pd); 
     32    pd.color = RGB(150,0,180); 
     33    scope p = new Pen(&pd); 
    3434    gc.setPen(p); 
    3535    gc.drawLine(0,0,100,150); 
     
    4141    win.paintDelegate ~= delegate void(Component source, GContext pc) { 
    4242 
    43         auto Font font = new Font("", 20, FontWeight.Bold); 
    44         Font oldfont = pc.setFont(font); 
     43        scope font = new Font("", 20, FontWeight.Bold); 
     44        auto oldfont = pc.setFont(font); 
    4545        pc.drawText(100,100,"testing"); 
    4646        pc.setFont(oldfont); 
     
    5555        pc.drawPolygon(pts2); 
    5656 
     57        // use a background brush 
     58        scope b1 = new Brush(RGB(0,255,0)); 
     59        auto oldBrush = pc.setBrush(b1); 
     60 
    5761        static Point[4] pts3 = [{{100,10}},{{105,50}},{{110,30}},{{120,10}}]; 
    5862        pc.fillPolygon(pts3); 
    5963 
     64        scope b2 = new Brush(RGB(255,0,0)); 
     65        pc.setBrush(b2); 
     66        pc.fillRect(LTWH(130,10,20,20)); 
     67 
     68        pc.setBrush(oldBrush); 
     69 
    6070        // try different line styles and colors 
    61         PenData pd; 
    6271        pd.width = 4; 
    6372        pd.color = RGB(100,200,0); 
    6473        pd.style = PenStyle.Dash; 
    65         auto Pen p1 = new Pen(&pd); 
     74        scope p1 = new Pen(&pd); 
    6675        Pen oldPen = pc.setPen(p1); 
    6776        pc.drawLine(10,100,20,200); 
    6877 
    6978        pd.color = RGB(0,200,200); 
    70         auto Pen p2 = new Pen(&pd); 
     79        scope p2 = new Pen(&pd); 
    7180        pc.setPen(p2); 
    7281        pc.drawLine(50,100,50,200);