Changeset 60

Show
Ignore:
Timestamp:
04/03/08 05:44:47 (6 months ago)
Author:
Chris Miller
Message:

Added text box functions (char/line/position).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/win32/dfl/internal/winapi.d

    r59 r60  
    297297        EM_EXGETSEL = WM_USER + 52, 
    298298        EM_EXLIMITTEXT = WM_USER + 53, 
     299        EM_EXLINEFROMCHAR = WM_USER + 54, 
    299300        EM_EXSETSEL = WM_USER + 55, 
    300301        EM_GETCHARFORMAT = WM_USER + 58, 
  • trunk/win32/dfl/richtextbox.d

    r54 r60  
    710710     
    711711     
     712    /// 
     713    override int getLineFromCharIndex(int charIndex) 
     714    { 
     715        if(!isHandleCreated) 
     716            return -1; // ... 
     717        if(charIndex < 0) 
     718            return -1; 
     719        return SendMessageA(hwnd, EM_EXLINEFROMCHAR, 0, charIndex); 
     720    } 
     721     
     722     
    712723    private void _getFormat(CHARFORMAT2A* cf, BOOL selection = TRUE) 
    713724    in 
  • trunk/win32/dfl/textbox.d

    r54 r60  
    792792     
    793793    alias Control.cursor cursor; // Overload. 
     794     
     795     
     796    /// 
     797    int getFirstCharIndexFromLine(int line) 
     798    { 
     799        if(!isHandleCreated) 
     800            return -1; // ... 
     801        if(line < 0) 
     802            return -1; 
     803        return SendMessageA(hwnd, EM_LINEINDEX, line, 0); 
     804    } 
     805     
     806    /// ditto 
     807    int getFirstCharIndexOfCurrentLine() 
     808    { 
     809        if(!isHandleCreated) 
     810            return -1; // ... 
     811        return SendMessageA(hwnd, EM_LINEINDEX, -1, 0); 
     812    } 
     813     
     814     
     815    /// 
     816    int getLineFromCharIndex(int charIndex) 
     817    { 
     818        if(!isHandleCreated) 
     819            return -1; // ... 
     820        if(charIndex < 0) 
     821            return -1; 
     822        return SendMessageA(hwnd, EM_LINEFROMCHAR, charIndex, 0); 
     823    } 
     824     
     825     
     826    /// 
     827    Point getPositionFromCharIndex(int charIndex) 
     828    { 
     829        if(!isHandleCreated) 
     830            return Point(0, 0); // ... 
     831        if(charIndex < 0) 
     832            return Point(0, 0); 
     833        POINT point; 
     834        SendMessageA(hwnd, EM_POSFROMCHAR, cast(WPARAM)&point, charIndex); 
     835        return Point(point.x, point.y); 
     836    } 
     837     
     838    /// ditto 
     839    int getCharIndexFromPosition(Point pt) 
     840    { 
     841        if(!isHandleCreated) 
     842            return -1; // ... 
     843        if(!multiline) 
     844            return 0; 
     845        auto lresult = SendMessageA(hwnd, EM_CHARFROMPOS, 0, MAKELPARAM(pt.x, pt.y)); 
     846        if(-1 == lresult) 
     847            return -1; 
     848        return cast(int)cast(short)(lresult & 0xFFFF); 
     849    } 
    794850     
    795851