Changeset 61

Show
Ignore:
Timestamp:
04/07/08 08:20:34 (6 months ago)
Author:
Chris Miller
Message:

Fixed Windows issue with GroupBox? font.
Other minor changes.

Files:

Legend:

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

    r56 r61  
    15431543    { 
    15441544        Font result; 
    1545         result = _createOldFont(); 
    1546          
    1547         OSVERSIONINFOA osi; 
    1548         osi.dwOSVersionInfoSize = osi.sizeof; 
    1549         if(GetVersionExA(&osi) && osi.dwMajorVersion >= 5) 
    1550         { 
    1551             // "MS Shell Dlg" / "MS Shell Dlg 2" not always supported. 
    1552             result = new Font("MS Shell Dlg 2", result.getSize(GraphicsUnit.POINT), GraphicsUnit.POINT); 
    1553         } 
     1545        //result = _createOldFont(); 
     1546         
     1547        try 
     1548        { 
     1549            OSVERSIONINFOA osi; 
     1550            osi.dwOSVersionInfoSize = osi.sizeof; 
     1551            if(GetVersionExA(&osi) && osi.dwMajorVersion >= 5) 
     1552            { 
     1553                // "MS Shell Dlg" / "MS Shell Dlg 2" not always supported. 
     1554                result = new Font("MS Shell Dlg 2", result.getSize(GraphicsUnit.POINT), GraphicsUnit.POINT); 
     1555            } 
     1556        } 
     1557        catch 
     1558        { 
     1559        } 
     1560         
     1561        if(!result) 
     1562            result = _createOldFont(); 
    15541563         
    15551564        return result; 
  • trunk/win32/dfl/drawing.d

    r54 r61  
    20882088        fillRectangle(color, r.x, r.y, r.width, r.height); 
    20892089    } 
    2090      
    20912090     
    20922091    /// ditto 
  • trunk/win32/dfl/form.d

    r54 r61  
    19941994            if(visible) 
    19951995            { 
    1996                 debug 
    1997                 { 
    1998                     throw new DflException("Unable to show dialog because it is already visible"); 
    1999                 } 
    2000                 goto no_show; 
     1996                if(!wmodal && owner && sowner == owner.handle) 
     1997                { 
     1998                } 
     1999                else 
     2000                { 
     2001                    debug 
     2002                    { 
     2003                        throw new DflException("Unable to show dialog because it is already visible"); 
     2004                    } 
     2005                    goto no_show; 
     2006                } 
    20012007            } 
    20022008             
  • trunk/win32/dfl/groupbox.d

    r16 r61  
    5252        if(DEFTEXTHEIGHT_INIT == _defTextHeight) 
    5353        { 
    54             _recalcTextHeight(defaultFont); 
     54            //_recalcTextHeight(defaultFont); 
     55            _recalcTextHeight(font); 
    5556            _defTextHeight = _textHeight; 
    5657        } 
     
    117118        //msg.result = CallWindowProcA(buttonPrevWndProc, msg.hWnd, msg.msg, msg.wParam, msg.lParam); 
    118119        msg.result = dfl.internal.utf.callWindowProc(buttonPrevWndProc, msg.hWnd, msg.msg, msg.wParam, msg.lParam); 
     120         
     121        // Work around a Windows issue... 
     122        if(WM_PAINT == msg.msg) 
     123        { 
     124            auto hmuxt = GetModuleHandleA("uxtheme.dll"); 
     125            if(hmuxt) 
     126            { 
     127                auto isAppThemed = cast(typeof(&IsAppThemed))GetProcAddress(hmuxt, "IsAppThemed"); 
     128                if(isAppThemed && isAppThemed()) 
     129                { 
     130                    char[] txt = text; 
     131                    if(txt.length) 
     132                    { 
     133                        auto openThemeData = cast(typeof(&OpenThemeData))GetProcAddress(hmuxt, "OpenThemeData"); 
     134                        HTHEME htd; 
     135                        if(openThemeData 
     136                            && HTHEME.init != (htd = openThemeData(msg.hWnd, "Button"))) 
     137                        { 
     138                            HDC hdc = cast(HDC)msg.wParam; 
     139                            //PAINTSTRUCT ps; 
     140                            bool gotdc = false; 
     141                            if(!hdc) 
     142                            { 
     143                                //hdc = BeginPaint(msg.hWnd, &ps); 
     144                                gotdc = true; 
     145                                hdc = GetDC(msg.hWnd); 
     146                            } 
     147                            try 
     148                            { 
     149                                scope g = new Graphics(hdc, false); // Not owned. 
     150                                auto f = font; 
     151                                scope tfmt = new TextFormat(TextFormatFlags.SINGLE_LINE); 
     152                                 
     153                                Color c; 
     154                                COLORREF cr; 
     155                                auto getThemeColor = cast(typeof(&GetThemeColor))GetProcAddress(hmuxt, "GetThemeColor"); 
     156                                if(getThemeColor 
     157                                    && 0 == getThemeColor(htd, 4 /*BP_GROUPBOX*/, 1 /*PBS_NORMAL*/, 3803 /*TMT_TEXTCOLOR*/, &cr)) 
     158                                    c = Color.fromRgb(cr); 
     159                                else 
     160                                    c = foreColor; 
     161                                 
     162                                Size tsz = g.measureText(txt, f, tfmt); 
     163                                 
     164                                g.fillRectangle(backColor, 8, 0, 2 + tsz.width + 2, tsz.height + 2); 
     165                                g.drawText(txt, f, c, Rect(8 + 2, 0, tsz.width, tsz.height), tfmt); 
     166                            } 
     167                            finally 
     168                            { 
     169                                //if(ps.hdc) 
     170                                //  EndPaint(msg.hWnd, &ps); 
     171                                if(gotdc) 
     172                                    ReleaseDC(msg.hWnd, hdc); 
     173                                 
     174                                auto closeThemeData = cast(typeof(&CloseThemeData))GetProcAddress(hmuxt, "CloseThemeData"); 
     175                                assert(closeThemeData !is null); 
     176                                closeThemeData(htd); 
     177                            } 
     178                        } 
     179                    } 
     180                } 
     181            } 
     182        } 
    119183    } 
    120184     
  • trunk/win32/dfl/internal/winapi.d

    r60 r61  
    29512951    DWORD GetThemeAppProperties(); 
    29522952    BOOL IsAppThemed(); 
     2953    HTHEME OpenThemeData(HWND hwnd, LPCWSTR pszClassList); 
     2954    HRESULT CloseThemeData(HTHEME hTheme); 
     2955    HRESULT GetThemeColor(HTHEME hTheme, int iPartId, int iStateId, int iPropId, COLORREF *pColor); 
    29532956    HIMAGELIST ImageList_Create(int cx, int cy, UINT flags, int cInitial, int cGrow); 
    29542957    BOOL ImageList_Destroy(HIMAGELIST himl);