Changeset 58

Show
Ignore:
Timestamp:
05/16/07 17:28:43 (2 years ago)
Author:
lindquist
Message:

Win32 added text control get/set properties.

Files:

Legend:

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

    r57 r58  
    6161    } 
    6262 
     63    template TextImpl() { 
     64        char[] text() { 
     65            if (useWfuncs) { 
     66                int len = SendMessageW(peer,WM_GETTEXTLENGTH,0,0); 
     67                scope buffer = new wchar[len+1]; 
     68                SendMessageW(peer,WM_GETTEXT,cast(WPARAM)(len+1),cast(LPARAM)buffer.ptr); 
     69                return toUTF8(buffer[0..$-1]); 
     70            } else { 
     71                int len = SendMessageA(peer,WM_GETTEXTLENGTH,0,0); 
     72                scope buffer = new char[len+1]; 
     73                SendMessageA(peer,WM_GETTEXT,cast(WPARAM)(len+1),cast(LPARAM)buffer.ptr); 
     74                return fromMBSz(buffer.ptr); 
     75            } 
     76        } 
     77        // TODO: is the other way needed as well? 
     78        private char[] lf_to_crlf(char[] str) { 
     79            scope lines = std.string.splitlines(str); 
     80            return std.string.join(lines,std.string.newline); 
     81        } 
     82        void text(char[] str) { 
     83            scope winstr = lf_to_crlf(str); 
     84            SendMessageX(peer,WM_SETTEXT,0,winstr); 
     85        } 
     86    } 
     87 
    6388    class Text : WindowChild { 
    6489        this(Component parent, char[] text = "", char[] name = "") { 
     
    79104        mixin TextPrefSizeImpl!(); 
    80105        mixin WindowChildImpl!(); 
     106        mixin TextImpl!(); 
    81107    } 
    82108    class MultiLineText : WindowChild { 
     
    98124        mixin TextPrefSizeImpl!(); 
    99125        mixin WindowChildImpl!(); 
     126        mixin TextImpl!(); 
    100127    } 
    101128 
  • branches/bughunt/samples/notepad.d

    r57 r58  
    5959    }; 
    6060 
    61     win.pack(); 
    6261    return app.enterEventLoop(); 
    6362}