Changeset 62

Show
Ignore:
Timestamp:
05/16/07 18:49:22 (2 years ago)
Author:
lindquist
Message:

Win32 fixed Label and MultiLineText? issues.

Files:

Legend:

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

    r33 r62  
    2828            HDC dc = GetDC(peer); 
    2929            sysAssert(dc !is null, "Failed to get label DC in preferredSize"); 
    30             SIZE s; 
     30            int x = 0; 
     31            int y = 0; 
    3132            try { 
    3233                Font f = standardFont(StandardFont.Gui); 
    3334                HFONT oldfont = SelectObject(dc,f.peer); 
    3435                sysAssert(oldfont !is null, "Failed to get Label font in preferredSize"); 
    35                 BOOL ok = GetTextExtentPoint32X(dc,text_data,text_data.length,&s); 
     36                scope lines = std.string.splitlines(text_data); 
     37                foreach(line; lines) { 
     38                    SIZE s = void; 
     39                    BOOL ok = GetTextExtentPoint32X(dc,line,line.length,&s); 
     40                    sysAssert(ok != false, "Failed to get font extents in preferredSize"); 
     41                    if (s.cx > x) x = s.cx; 
     42                    y += s.cy; 
     43                } 
    3644                SelectObject(dc,oldfont); 
    37                 sysAssert(ok != false, "Failed to get font extents in preferredSize"); 
    3845            } finally { 
    3946                ReleaseDC(peer,dc); 
    4047            } 
    4148            POINT p; 
    42             p.x = s.cx; 
    43             p.y = s.cy; 
     49            p.x = x; 
     50            p.y = y; 
    4451            if (userPreferredWidth > 0) 
    4552                p.x = userPreferredWidth; 
     
    6067            sysAssert(peer !is null, "Failed to create peer Label"); 
    6168            this.name = name; 
    62             text_data = text; 
     69            this.text = text; 
    6370            Font f = standardFont(StandardFont.Gui); 
    6471            SendMessageA(peer,WM_SETFONT,cast(WPARAM)f.peer,0); 
     
    6673            parent.addChild(this); 
    6774        } 
    68         char[] text() {return text_data;} 
    69         void text(char[] c) { 
    70             text_data = c; 
    71             SendMessageX(peer,WM_SETTEXT,0,c); 
    72         } 
    7375        mixin LabelPrefSizeImpl!(); 
    7476        mixin WindowChildImpl!(); 
     77 
     78        char[] text() { 
     79            return text_data; 
     80        } 
     81        void text(char[] str) { 
     82            scope lines = std.string.splitlines(str); 
     83            scope winstr = std.string.join(lines,std.string.newline); 
     84            SendMessageX(peer,WM_SETTEXT,0,winstr); 
     85            text_data = str; 
     86        } 
    7587    } 
    7688 
  • branches/bughunt/minwin/text.d

    r59 r62  
    7575            } 
    7676        } 
    77         // TODO: is the other way needed as well? 
    7877        void text(char[] str) { 
    7978            scope lines = std.string.splitlines(str); 
     
    108107            PeerForAdd parentp = parent.getPeerForAdd(); 
    109108            DWORD dwStyle = (vscroll?WS_VSCROLL:0) | (hscroll?WS_HSCROLL:0); 
    110             peer = CreateWindowX("EDIT",text, 
     109            scope lines = std.string.splitlines(text); 
     110            scope winstr = std.string.join(lines,std.string.newline); 
     111            peer = CreateWindowX("EDIT",winstr, 
    111112                 ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | dwStyle, 
    112113                 0,0,10,10,parentp,