Changeset 7

Show
Ignore:
Timestamp:
10/26/07 02:18:22 (5 years ago)
Author:
Chris Miller
Message:

Bringing things up to date.

Files:

Legend:

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

    r5 r7  
    120120{ 
    121121    version = WINDOWS_HUNG_WORKAROUND; 
     122} 
     123 
     124 
     125deprecated enum DflCompat 
     126{ 
     127    NONE = 0, 
     128    MENU_092 = 0x1, // Adding to menus is the old way. 
     129    CONTROL_RECREATE_095 = 0x2, // Controls don't recreate automatically when necessary. 
     130    CONTROL_KEYEVENT_096 = 0x4, // Key events don't propagate up the control hierarchy when they are not handled. 
     131    FORM_DIALOGRESULT_096 = 0x8, // When a Form is in showDialog, changing the dialogResult from NONE doesn't close the form. 
    122132} 
    123133 
     
    236246     
    237247     
     248    /+ 
     249    // /// 
     250    bool visualStyles() // getter 
     251    { 
     252        // IsAppThemed: 
     253        // "Do not call this function during DllMain or global objects contructors. 
     254        // This may cause invalid return values in Microsoft Windows Vista and may cause Windows XP to become unstable." 
     255    } 
     256    +/ 
     257     
     258     
    238259    /// Path of the executable including its file name. 
    239260    char[] executablePath() // getter 
     
    11381159     
    11391160     
     1161    version(DFL_NO_COMPAT) 
     1162        package const DflCompat _compat = DflCompat.NONE; 
     1163    else 
     1164        package DflCompat _compat = DflCompat.NONE; 
     1165     
     1166     
     1167    deprecated void setCompat(DflCompat dflcompat) 
     1168    { 
     1169        version(DFL_NO_COMPAT) 
     1170        { 
     1171            assert(0, "Compatibility disabled"); // version=DFL_NO_COMPAT 
     1172        } 
     1173        else 
     1174        { 
     1175            if(messageLoop) 
     1176            { 
     1177                assert(0, "setCompat"); // Called too late, must enable compatibility sooner. 
     1178                return; 
     1179            } 
     1180             
     1181            _compat |= dflcompat; 
     1182        } 
     1183    } 
     1184     
     1185     
    11401186    private static size_t _doref(void* p, int by) 
    11411187    { 
     
    13801426 
    13811427 
    1382 /+ 
    13831428// Note: phobos-only. 
    13841429debug(SHOW_MESSAGE_INFO) 
     
    15561601    } 
    15571602} 
    1558 +/ 
    15591603 
    15601604 
  • trunk/win32/dfl/base.d

    r5 r7  
    297297 
    298298/// 
     299enum CheckState: ubyte 
     300{ 
     301    UNCHECKED = BST_UNCHECKED, /// 
     302    CHECKED = BST_CHECKED, /// ditto 
     303    INDETERMINATE = BST_INDETERMINATE, /// ditto 
     304} 
     305 
     306 
     307/// 
    299308struct Message // docmain 
    300309{ 
     
    512521 
    513522 
     523interface IDialogResult 
     524{ 
     525    // /// 
     526    DialogResult dialogResult(); // getter 
     527    // /// ditto 
     528    void dialogResult(DialogResult); // setter 
     529} 
     530 
     531 
    514532/// 
    515533enum SortOrder: ubyte 
     
    669687 
    670688/// 
     689enum ColorDepth: ubyte 
     690{ 
     691    DEPTH_4BIT = 1, /// 
     692    DEPTH_8BIT , /// ditto 
     693    DEPTH_16BIT, /// ditto 
     694    DEPTH_24BIT, /// ditto 
     695    DEPTH_32BIT, /// ditto 
     696} 
     697 
     698 
     699/// 
    671700class PaintEventArgs: EventArgs 
    672701{ 
     
    883912 
    884913 
     914/+ 
    885915/// 
    886916class LabelEditEventArgs: EventArgs 
     
    937967 
    938968alias Event!(LabelEditEventArgs) LabelEditEventHandler; // deprecated 
     969+/ 
    939970 
    940971 
  • trunk/win32/dfl/button.d

    r5 r7  
    1111 
    1212private extern(Windows) void _initButton(); 
    13  
    14  
    15 /// 
    16 enum CheckState: ubyte 
    17 { 
    18     UNCHECKED = BST_UNCHECKED, /// 
    19     CHECKED = BST_CHECKED, /// ditto 
    20     INDETERMINATE = BST_INDETERMINATE, /// ditto 
    21 } 
    2213 
    2314 
     
    325316         
    326317        onClick(EventArgs.empty); 
     318    } 
     319     
     320     
     321    protected override void onClick(EventArgs ea) 
     322    { 
     323        super.onClick(ea); 
     324         
     325        if(!(Application._compat & DflCompat.FORM_DIALOGRESULT_096)) 
     326        { 
     327            if(DialogResult.NONE != this.dialogResult) 
     328            { 
     329                auto xx = cast(IDialogResult)topLevelControl; 
     330                if(xx) 
     331                    xx.dialogResult = this.dialogResult; 
     332            } 
     333        } 
    327334    } 
    328335     
  • trunk/win32/dfl/collections.d

    r5 r7  
    265265                else 
    266266                { 
    267                     if(getObjectString(onval) == value) // ? 
    268                         return true
     267                    if(getObjectString(onval) == value) 
     268                        return idx
    269269                } 
    270270            } 
  • trunk/win32/dfl/combobox.d

    r5 r7  
    508508    static class ObjectCollection 
    509509    { 
    510         this(ComboBox lbox) 
     510        protected this(ComboBox lbox) 
    511511        { 
    512512            this.lbox = lbox; 
     
    514514         
    515515         
    516         this(ComboBox lbox, Object[] range) 
     516        protected this(ComboBox lbox, Object[] range) 
    517517        { 
    518518            this.lbox = lbox; 
     
    521521         
    522522         
    523         this(ComboBox lbox, char[][] range) 
     523        protected this(ComboBox lbox, char[][] range) 
    524524        { 
    525525            this.lbox = lbox; 
     
    529529         
    530530        /+ 
    531         this(ComboBox lbox, ObjectCollection range) 
     531        protected this(ComboBox lbox, ObjectCollection range) 
    532532        { 
    533533            this.lbox = lbox; 
  • trunk/win32/dfl/control.d

    r5 r7  
    670670    static class ControlCollection 
    671671    { 
    672         this(Control owner) 
     672        protected this(Control owner) 
    673673        { 
    674674            _owner = owner; 
     
    976976         
    977977        onControlAdded(cea); 
     978    } 
     979     
     980     
     981    private void _ctrlremoved(ControlEventArgs cea) 
     982    { 
     983        alayout(cea.control); 
     984         
     985        onControlRemoved(cea); 
    978986    } 
    979987     
     
    10701078        +/ 
    10711079         
    1072         sdock = cast(DockStyle)sdock.init; // Can't be set at the same time. 
     1080        //sdock = cast(DockStyle)sdock.init; // Can't be set at the same time. 
     1081        sdock = DockStyle.NONE; // Can't be set at the same time. 
    10731082    } 
    10741083     
     
    20552064     
    20562065     
     2066    /+ 
     2067    /// 
     2068    // ea is the new parent. 
     2069    protected void onParentChanging(ControlEventArgs ea) 
     2070    { 
     2071    } 
     2072    +/ 
     2073     
     2074     
    20572075    /// 
    20582076    final Form findForm() 
     
    20842102            throw new DflException("Cannot add a top level control to a control"); 
    20852103         
     2104        //scope ControlEventArgs pcea = new ControlEventArgs(c); 
     2105        //onParentChanging(pcea); 
     2106         
    20862107        Control oldparent; 
    20872108        _FixAmbientOld oldinfo; 
     
    21322153                onParentChanged(EventArgs.empty); 
    21332154                if(oldparent) 
    2134                     oldparent.onControlRemoved(cea); 
     2155                    oldparent._ctrlremoved(cea); 
    21352156                c._ctrladded(cea); 
    21362157                _fixAmbient(&oldinfo); 
     
    21462167                onParentChanged(EventArgs.empty); 
    21472168                if(oldparent) 
    2148                     oldparent.onControlRemoved(cea); 
     2169                    oldparent._ctrlremoved(cea); 
    21492170                c._ctrladded(cea); 
    21502171                _fixAmbient(&oldinfo); 
     
    21642185            onParentChanged(EventArgs.empty); 
    21652186            assert(oldparent !is null); 
    2166             oldparent.onControlRemoved(cea); 
     2187            oldparent._ctrlremoved(cea); 
    21672188            _fixAmbient(&oldinfo); 
    21682189        } 
     
    31873208     
    31883209     
     3210    override int opCmp(Object o) 
     3211    { 
     3212        Control ctrl = cast(Control)o; 
     3213        if(!ctrl) 
     3214            return -1; 
     3215        return opCmp(ctrl); 
     3216    } 
     3217     
     3218     
     3219    int opCmp(Control ctrl) 
     3220    { 
     3221        if(!isHandleCreated || hwnd != ctrl.hwnd) 
     3222            return super.opCmp(ctrl); 
     3223        return 0; 
     3224    } 
     3225     
     3226     
    31893227    /// 
    31903228    final bool focus() 
     
    33303368         
    33313369        RedrawWindow(hwnd, null, rgn.handle, RDW_ERASE | RDW_INVALIDATE | (andChildren ? RDW_ALLCHILDREN : RDW_NOCHILDREN)); 
     3370    } 
     3371     
     3372     
     3373    /// 
     3374    // Redraws the entire control, including nonclient area. 
     3375    final void redraw() 
     3376    { 
     3377        if(!hwnd) 
     3378            return; 
     3379         
     3380        RedrawWindow(hwnd, null, HRGN.init, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME); 
    33323381    } 
    33333382     
     
    44454494            case WM_SYSCHAR: 
    44464495            //case WM_IMECHAR: 
     4496                /+ 
    44474497                if(processKeyEventArgs(msg)) 
    44484498                { 
     
    44534503                msg.result = 1; // The key was not processed. 
    44544504                break; 
     4505                +/ 
     4506                msg.result = !processKeyEventArgs(msg); 
     4507                return; 
    44554508             
    44564509            case WM_MOUSEWHEEL: // Requires Windows 98 or NT4. 
     
    49144967                        if(ctrl) 
    49154968                        { 
    4916                             onControlRemoved(new ControlEventArgs(ctrl)); 
     4969                            _ctrlremoved(new ControlEventArgs(ctrl)); 
    49174970                             
    49184971                            // ? 
     
    49935046                        } 
    49945047                    } 
     5048                     
     5049                    defWndProc(msg); 
     5050                    // Only want chars if ALT isn't down, because it would break mnemonics. 
     5051                    if(!(GetAsyncKeyState(VK_MENU) & 0x8000)) 
     5052                        msg.result |= DLGC_WANTCHARS; 
     5053                    return; 
    49955054                } 
    49965055                 
    4997                 /+ // This prevents mnemonics from working. 
    4998                 defWndProc(msg); 
    4999                 msg.result |= DLGC_WANTCHARS; // For keyPress. 
    5000                 return; 
    5001                 +/ 
    50025056                break; 
    50035057             
     
    54295483    package final void doShow() 
    54305484    { 
    5431         //ShowWindow(hwnd, SW_SHOW); 
    5432         //SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW); 
    5433         //SetWindowPos(hwnd, GetParent(hwnd) ? HWND_BOTTOM : HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW); // ? 
    5434         //if(GetParent(hwnd)) 
    54355485        if(wparent) // Exclude owner. 
    54365486        { 
    5437             HWND hw; 
    5438             hw = GetWindow(hwnd, GW_HWNDPREV); 
    5439             if(!hw) 
    5440                 hw = HWND_BOTTOM; // ? 
    5441             SetWindowPos(hwnd, hw, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW); 
    5442             //SetWindowPos(hwnd, HWND.init, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW); 
     5487            SetWindowPos(hwnd, HWND.init, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER); 
    54435488        } 
    54445489        else 
     
    54515496    package final void doHide() 
    54525497    { 
    5453         //ShowWindow(hwnd, SW_HIDE); 
    5454         SetWindowPos(hwnd, HWND.init, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_HIDEWINDOW); 
     5498        SetWindowPos(hwnd, HWND.init, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_HIDEWINDOW | SWP_NOZORDER); 
    54555499    } 
    54565500     
     
    57305774     
    57315775    /+ 
    5732     //
     5776    // //
    57335777    final bool hasVisualStyle() // getter 
    57345778    { 
     5779        bool result = false; 
    57355780        HWND hw = handle; // Always reference handle. 
    57365781        HMODULE huxtheme = GetModuleHandleA("uxtheme.dll"); 
     
    57415786            if(getwintheme) 
    57425787            { 
    5743                 return getwintheme(hw) != null; 
    5744             } 
    5745             FreeLibrary(huxtheme); 
    5746         } 
    5747         return false
     5788                result = getwintheme(hw) != null; 
     5789            } 
     5790            //FreeLibrary(huxtheme); 
     5791        } 
     5792        return result
    57485793    } 
    57495794    +/ 
     
    63656410                    } 
    63666411                     
    6367                     return kea.handled; 
     6412                    if(kea.handled) 
     6413                        return true; 
    63686414                } 
    63696415                break; 
     
    63746420                    scope KeyEventArgs kea = new KeyEventArgs(cast(Keys)(msg.wParam | modifierKeys)); 
    63756421                    onKeyUp(kea); 
    6376                     return kea.handled; 
     6422                    if(kea.handled) 
     6423                        return true; 
    63776424                } 
    63786425                break; 
     
    63876434                    scope KeyEventArgs kea = new KeyEventArgs(cast(Keys)(vk | modifierKeys)); 
    63886435                    onKeyPress(kea); 
    6389                     return kea.handled; 
     6436                    if(kea.handled) 
     6437                        return true; 
    63906438                } 
    63916439                break; 
     
    64086456        } 
    64096457         
     6458        if(Application._compat & DflCompat.CONTROL_KEYEVENT_096) 
     6459            goto def_action; 
     6460         
     6461        // ? 
     6462        if(!parent 
     6463            || (IsWindowVisible(hwnd) 
     6464                && ((ctrlStyle & ControlStyles.SELECTABLE) 
     6465                    || (SendMessageA(hwnd, WM_GETDLGCODE, 0, 0) & DLGC_WANTALLKEYS)))) 
     6466        { 
     6467            def_action: 
     6468            defWndProc(msg); 
     6469            //return true; 
     6470            return !msg.result; 
     6471        } 
     6472        else 
     6473        { 
     6474            //if(parent) 
     6475            assert(parent !is null); 
     6476                return parent.processKeyEventArgs(msg); 
     6477        } 
     6478         
    64106479        return false; 
    64116480    } 
     
    64536522        else 
    64546523        { 
    6455             _compat = CCompat.DFL095; 
     6524            //_compat = CCompat.DFL095; 
     6525            Application.setCompat(DflCompat.CONTROL_RECREATE_095); 
    64566526        } 
    64576527    } 
     
    64646534     
    64656535    version(SET_DFL_095) 
    6466         private const ubyte _compat = CCompat.DFL095; 
     6536        package const ubyte _compat = CCompat.DFL095; 
     6537    else version(DFL_NO_COMPAT) 
     6538        package const ubyte _compat = CCompat.NONE; 
    64676539    else 
    6468         private ubyte _compat = CCompat.NONE; 
     6540        package CCompat _compat() // getter 
     6541            { if(Application._compat & DflCompat.CONTROL_RECREATE_095) return CCompat.DFL095; return CCompat.NONE; } 
    64696542     
    64706543     
     
    68156888            case WM_SYSKEYUP: 
    68166889            case WM_SYSCHAR: 
    6817             //case WM_IMECHAR: 
     6890            //case WM_IMECHAR: // ? 
    68186891                prevWndProc(m); 
    68196892                break; 
     
    70597132        result.height = result.height - dpad.bottom - dpad.top; 
    70607133         
     7134        // Add scroll width. 
    70617135        if(scrollSize.width > clientSize.width) 
    70627136            result.width = result.width + (scrollSize.width - clientSize.width); 
     
    70647138            result.height = result.height + (scrollSize.height - clientSize.height); 
    70657139         
     7140        // Adjust scroll position. 
     7141        result.location = Point(result.location.x - scrollPosition.x, result.location.y - scrollPosition.y); 
     7142         
    70667143        return result; 
    70677144    } 
     
    71967273     
    71977274    const Size DEFAULT_SCALE = { 5, 13 }; 
    7198      
    7199      
    7200     protected: 
    72017275     
    72027276    /// 
     
    72417315        return (_style() & WS_VSCROLL) != 0; 
    72427316    } 
     7317     
     7318     
     7319    protected: 
    72437320     
    72447321     
     
    73097386                            case SB_THUMBTRACK: 
    73107387                            case SB_THUMBPOSITION: 
    7311                                 delta = cast(int)HIWORD(m.wParam) - yspos; 
     7388                                //delta = cast(int)HIWORD(m.wParam) - yspos; // Limited to 16-bits. 
     7389                                delta = si.nTrackPos - yspos; 
    73127390                                break; 
    73137391                            case SB_BOTTOM: 
     
    73717449                            case SB_THUMBTRACK: 
    73727450                            case SB_THUMBPOSITION: 
    7373                                 delta = cast(int)HIWORD(m.wParam) - xspos; 
     7451                                //delta = cast(int)HIWORD(m.wParam) - xspos; // Limited to 16-bits. 
     7452                                delta = si.nTrackPos - xspos; 
    73747453                                break; 
    73757454                            case SB_RIGHT: 
     
    75757654    /// 
    75767655    Control activeControl(); // getter 
    7577     /// ditto 
     7656     
    75787657    deprecated void activeControl(Control); // setter 
    75797658     
    7580     /// 
    75817659    deprecated bool activateControl(Control); 
    75827660} 
  • trunk/win32/dfl/drawing.d

    r5 r7  
    10881088 
    10891089 
    1090 version(Tango) 
    1091 
    1092     // TO-DO: not implemented yet. 
    1093 
    1094 else 
    1095 
    1096     private import std.stream; // TO-DO: remove this import; use dfl.internal.dlib. 
    1097      
    1098      
    1099     /// 
    1100     class Picture: Image // docmain 
    1101     { 
    1102         // Note: requires OleInitialize(null). 
    1103          
    1104          
    1105         /// 
    1106         // Throws exception on failure. 
    1107         this(Stream stm) 
    1108         { 
    1109             this.ipic = _fromStdStream(stm); 
    1110             if(!this.ipic) 
    1111                 throw new DflException("Unable to load picture from stream"); 
    1112         } 
    1113          
    1114         /// ditto 
    1115         // Throws exception on failure. 
    1116         this(char[] fileName) 
    1117         { 
    1118             this.ipic = _fromFileName(fileName); 
    1119             if(!this.ipic) 
    1120                 throw new DflException("Unable to load picture from file '" ~ fileName ~ "'"); 
    1121         } 
    1122          
    1123          
    1124         private this(dfl.internal.wincom.IPicture ipic) 
    1125         { 
    1126             this.ipic = ipic; 
    1127         } 
    1128          
    1129          
    1130         /// 
    1131         // Returns null on failure instead of throwing exception. 
    1132         static Picture fromStream(Stream stm) 
    1133         { 
    1134             dfl.internal.wincom.IPicture ipic; 
    1135             ipic = _fromStdStream(stm); 
    1136             if(!ipic) 
    1137                 return null; 
    1138             return new Picture(ipic); 
    1139         } 
    1140          
    1141          
    1142         /// 
    1143         // Returns null on failure instead of throwing exception. 
    1144         static Picture fromFile(char[] fileName) 
    1145         { 
    1146             dfl.internal.wincom.IPicture ipic; 
    1147             ipic = _fromFileName(fileName); 
    1148             if(!ipic) 
    1149                 return null; 
    1150             return new Picture(ipic); 
    1151         } 
    1152          
    1153          
    1154         /// 
    1155         final void draw(HDC hdc, Point pt) // package 
    1156         { 
    1157             int lhx, lhy; 
    1158             int width, height; 
    1159             lhx = loghimX; 
    1160             lhy = loghimY; 
    1161             width = MAP_LOGHIM_TO_PIX(lhx, GetDeviceCaps(hdc, LOGPIXELSX)); 
    1162             height = MAP_LOGHIM_TO_PIX(lhy, GetDeviceCaps(hdc, LOGPIXELSY)); 
    1163             ipic.Render(hdc, pt.x, pt.y + height, width, -height, 0, 0, lhx, lhy, null); 
    1164         } 
    1165          
    1166         /// ditto 
    1167         final override void draw(Graphics g, Point pt) 
    1168         { 
    1169             return draw(g.handle, pt); 
    1170         } 
    1171          
    1172          
    1173         /// 
    1174         final void drawStretched(HDC hdc, Rect r) // package 
    1175         { 
    1176             int lhx, lhy; 
    1177             lhx = loghimX; 
    1178             lhy = loghimY; 
    1179             ipic.Render(hdc, r.x, r.y + r.height, r.width, -r.height, 0, 0, lhx, lhy, null); 
    1180         } 
    1181          
    1182         /// ditto 
    1183         final override void drawStretched(Graphics g, Rect r) 
    1184         { 
    1185             return drawStretched(g.handle, r); 
    1186         } 
    1187          
    1188          
    1189         /// 
    1190         final OLE_XSIZE_HIMETRIC loghimX() // getter 
    1191         { 
    1192             OLE_XSIZE_HIMETRIC xsz; 
    1193             if(S_OK != ipic.get_Width(&xsz)) 
    1194                 return 0; // ? 
    1195             return xsz; 
    1196         } 
    1197          
    1198         /// ditto 
    1199         final OLE_YSIZE_HIMETRIC loghimY() // getter 
    1200         { 
    1201             OLE_YSIZE_HIMETRIC ysz; 
    1202             if(S_OK != ipic.get_Height(&ysz)) 
    1203                 return 0; // ? 
    1204             return ysz; 
    1205         } 
    1206          
    1207          
    1208         /// 
    1209         final override int width() // getter 
    1210         { 
    1211             Graphics g; 
    1212             int result; 
    1213             g = Graphics.getScreen(); 
    1214             result = getWidth(g); 
    1215             g.dispose(); 
    1216             return result; 
    1217         } 
    1218          
    1219          
    1220         /// 
    1221         final override int height() // getter 
    1222         { 
    1223             Graphics g; 
    1224             int result; 
    1225             g = Graphics.getScreen(); 
    1226             result = getHeight(g); 
    1227             g.dispose(); 
    1228             return result; 
    1229         } 
    1230          
    1231          
    1232         /// 
    1233         final override Size size() // getter 
    1234         { 
    1235             Graphics g; 
    1236             Size result; 
    1237             g = Graphics.getScreen(); 
    1238             result = getSize(g); 
    1239             g.dispose(); 
    1240             return result; 
    1241         } 
    1242          
    1243          
    1244         /// 
    1245         final int getWidth(HDC hdc) // package 
    1246         { 
    1247             return MAP_LOGHIM_TO_PIX(loghimX, GetDeviceCaps(hdc, LOGPIXELSX)); 
    1248         } 
    1249          
    1250         /// ditto 
    1251         final int getWidth(Graphics g) 
    1252         { 
    1253             return getWidth(g.handle); 
    1254         } 
    1255          
    1256          
    1257         /// 
    1258         final int getHeight(HDC hdc) // package 
    1259         { 
    1260             return MAP_LOGHIM_TO_PIX(loghimY, GetDeviceCaps(hdc, LOGPIXELSX)); 
    1261         } 
    1262          
    1263         /// ditto 
    1264         final int getHeight(Graphics g) 
    1265         { 
    1266             return getHeight(g.handle); 
    1267         } 
    1268          
    1269          
    1270         final Size getSize(HDC hdc) // package 
    1271         { 
    1272             return Size(getWidth(hdc), getHeight(hdc)); 
    1273         } 
    1274          
    1275         /// 
    1276         final Size getSize(Graphics g) 
    1277         { 
    1278             return Size(getWidth(g), getHeight(g)); 
    1279         } 
    1280          
    1281          
    1282         /// 
    1283         void dispose() 
    1284         { 
    1285             if(ipic) 
     1090/// 
     1091class Picture: Image // docmain 
     1092
     1093    // Note: requires OleInitialize(null). 
     1094     
     1095     
     1096    /// 
     1097    // Throws exception on failure. 
     1098    this(DStream stm) 
     1099    { 
     1100        this.ipic = _fromDStream(stm); 
     1101        if(!this.ipic) 
     1102            throw new DflException("Unable to load picture from stream"); 
     1103    } 
     1104     
     1105    /// ditto 
     1106    // Throws exception on failure. 
     1107    this(char[] fileName) 
     1108    { 
     1109        this.ipic = _fromFileName(fileName); 
     1110        if(!this.ipic) 
     1111            throw new DflException("Unable to load picture from file '" ~ fileName ~ "'"); 
     1112    } 
     1113     
     1114     
     1115    private this(dfl.internal.wincom.IPicture ipic) 
     1116    { 
     1117        this.ipic = ipic; 
     1118    } 
     1119     
     1120     
     1121    /// 
     1122    // Returns null on failure instead of throwing exception. 
     1123    static Picture fromStream(DStream stm) 
     1124    { 
     1125        dfl.internal.wincom.IPicture ipic; 
     1126        ipic = _fromDStream(stm); 
     1127        if(!ipic) 
     1128            return null; 
     1129        return new Picture(ipic); 
     1130    } 
     1131     
     1132     
     1133    /// 
     1134    // Returns null on failure instead of throwing exception. 
     1135    static Picture fromFile(char[] fileName) 
     1136    { 
     1137        dfl.internal.wincom.IPicture ipic; 
     1138        ipic = _fromFileName(fileName); 
     1139        if(!ipic) 
     1140            return null; 
     1141        return new Picture(ipic); 
     1142    } 
     1143     
     1144     
     1145    /// 
     1146    final void draw(HDC hdc, Point pt) // package 
     1147    { 
     1148        int lhx, lhy; 
     1149        int width, height; 
     1150        lhx = loghimX; 
     1151        lhy = loghimY; 
     1152        width = MAP_LOGHIM_TO_PIX(lhx, GetDeviceCaps(hdc, LOGPIXELSX)); 
     1153        height = MAP_LOGHIM_TO_PIX(lhy, GetDeviceCaps(hdc, LOGPIXELSY)); 
     1154        ipic.Render(hdc, pt.x, pt.y + height, width, -height, 0, 0, lhx, lhy, null); 
     1155    } 
     1156     
     1157    /// ditto 
     1158    final override void draw(Graphics g, Point pt) 
     1159    { 
     1160        return draw(g.handle, pt); 
     1161    } 
     1162     
     1163     
     1164    /// 
     1165    final void drawStretched(HDC hdc, Rect r) // package 
     1166    { 
     1167        int lhx, lhy; 
     1168        lhx = loghimX; 
     1169        lhy = loghimY; 
     1170        ipic.Render(hdc, r.x, r.y + r.height, r.width, -r.height, 0, 0, lhx, lhy, null); 
     1171    } 
     1172     
     1173    /// ditto 
     1174    final override void drawStretched(Graphics g, Rect r) 
     1175    { 
     1176        return drawStretched(g.handle, r); 
     1177    } 
     1178     
     1179     
     1180    /// 
     1181    final OLE_XSIZE_HIMETRIC loghimX() // getter 
     1182    { 
     1183        OLE_XSIZE_HIMETRIC xsz; 
     1184        if(S_OK != ipic.get_Width(&xsz)) 
     1185            return 0; // ? 
     1186        return xsz; 
     1187    } 
     1188     
     1189    /// ditto 
     1190    final OLE_YSIZE_HIMETRIC loghimY() // getter 
     1191    { 
     1192        OLE_YSIZE_HIMETRIC ysz; 
     1193        if(S_OK != ipic.get_Height(&ysz)) 
     1194            return 0; // ? 
     1195        return ysz; 
     1196    } 
     1197     
     1198     
     1199    /// 
     1200    final override int width() // getter 
     1201    { 
     1202        Graphics g; 
     1203        int result; 
     1204        g = Graphics.getScreen(); 
     1205        result = getWidth(g); 
     1206        g.dispose(); 
     1207        return result; 
     1208    } 
     1209     
     1210     
     1211    /// 
     1212    final override int height() // getter 
     1213    { 
     1214        Graphics g; 
     1215        int result; 
     1216        g = Graphics.getScreen(); 
     1217        result = getHeight(g); 
     1218        g.dispose(); 
     1219        return result; 
     1220    } 
     1221     
     1222     
     1223    /// 
     1224    final override Size size() // getter 
     1225    { 
     1226        Graphics g; 
     1227        Size result; 
     1228        g = Graphics.getScreen(); 
     1229        result = getSize(g); 
     1230        g.dispose(); 
     1231        return result; 
     1232    } 
     1233     
     1234     
     1235    /// 
     1236    final int getWidth(HDC hdc) // package 
     1237    { 
     1238        return MAP_LOGHIM_TO_PIX(loghimX, GetDeviceCaps(hdc, LOGPIXELSX)); 
     1239    } 
     1240     
     1241    /// ditto 
     1242    final int getWidth(Graphics g) 
     1243    { 
     1244        return getWidth(g.handle); 
     1245    } 
     1246     
     1247     
     1248    /// 
     1249    final int getHeight(HDC hdc) // package 
     1250    { 
     1251        return MAP_LOGHIM_TO_PIX(loghimY, GetDeviceCaps(hdc, LOGPIXELSX)); 
     1252    } 
     1253     
     1254    /// ditto 
     1255    final int getHeight(Graphics g) 
     1256    { 
     1257        return getHeight(g.handle); 
     1258    } 
     1259     
     1260     
     1261    final Size getSize(HDC hdc) // package 
     1262    { 
     1263        return Size(getWidth(hdc), getHeight(hdc)); 
     1264    } 
     1265     
     1266    /// 
     1267    final Size getSize(Graphics g) 
     1268    { 
     1269        return Size(getWidth(g), getHeight(g)); 
     1270    } 
     1271     
     1272     
     1273    /// 
     1274    void dispose() 
     1275    { 
     1276        if(ipic) 
     1277        { 
     1278            ipic.Release(); 
     1279            ipic = null; 
     1280        } 
     1281    } 
     1282     
     1283     
     1284    ~this() 
     1285    { 
     1286        dispose(); 
     1287    } 
     1288     
     1289     
     1290    final HBITMAP toHBitmap(HDC hdc) // package 
     1291    { 
     1292        HDC memdc; 
     1293        HBITMAP result; 
     1294        HGDIOBJ oldbm; 
     1295        memdc = CreateCompatibleDC(hdc); 
     1296        if(!memdc) 
     1297            throw new DflException("Device error"); 
     1298        try 
     1299        { 
     1300            Size sz; 
     1301            sz = getSize(hdc); 
     1302            result = CreateCompatibleBitmap(hdc, sz.width, sz.height); 
     1303            if(!result) 
    12861304            { 
    1287                 ipic.Release(); 
    1288                 ipic = null
     1305                bad_bm: 
     1306                throw new DflException("Unable to allocate image")
    12891307            } 
    1290         } 
    1291          
    1292          
    1293         ~this() 
    1294         { 
    1295             dispose(); 
    1296         } 
    1297          
    1298          
    1299         final HBITMAP toHBitmap(HDC hdc) // package 
    1300         { 
    1301             HDC memdc; 
    1302             HBITMAP result; 
    1303             HGDIOBJ oldbm; 
    1304             memdc = CreateCompatibleDC(hdc); 
    1305             if(!memdc) 
    1306                 throw new DflException("Device error"); 
    1307             try 
    1308             { 
    1309                 Size sz; 
    1310                 sz = getSize(hdc); 
    1311                 result = CreateCompatibleBitmap(hdc, sz.width, sz.height); 
    1312                 if(!result) 
    1313                 { 
    1314                     bad_bm: 
    1315                     throw new DflException("Unable to allocate image"); 
    1316                 } 
    1317                 oldbm = SelectObject(memdc, result); 
    1318                 draw(memdc, Point(0, 0)); 
    1319             } 
    1320             finally 
    1321             { 
    1322                 if(oldbm) 
    1323                     SelectObject(memdc, oldbm); 
    1324                 DeleteDC(memdc); 
    1325             } 
    1326             return result; 
    1327         } 
    1328          
    1329          
    1330         final Bitmap toBitmap(HDC hdc) // package 
    1331         { 
    1332             HBITMAP hbm; 
    1333             hbm = toHBitmap(hdc); 
    1334             if(!hbm) 
    1335                 throw new DflException("Unable to create bitmap"); 
    1336             return new Bitmap(hbm, true); // Owned. 
    1337         } 
    1338          
    1339          
    1340         final Bitmap toBitmap() 
    1341         { 
    1342             Graphics g; 
    1343             Bitmap result; 
    1344             g = Graphics.getScreen(); 
    1345             result = toBitmap(g); 
    1346             g.dispose(); 
    1347             return result; 
    1348         } 
    1349          
    1350         /// ditto 
    1351         final Bitmap toBitmap(Graphics g) 
    1352         { 
    1353             return toBitmap(g.handle); 
    1354         } 
    1355          
    1356          
    1357         private: 
    1358         dfl.internal.wincom.IPicture ipic = null; 
    1359          
    1360          
    1361         static dfl.internal.wincom.IPicture _fromIStream(dfl.internal.wincom.IStream istm) 
    1362         { 
    1363             dfl.internal.wincom.IPicture ipic; 
    1364             if(S_OK != OleLoadPicture(istm, 0, FALSE, &_IID_IPicture, cast(void**)&ipic)) 
    1365                 return null; 
    1366             return ipic; 
    1367         } 
    1368          
    1369          
    1370         static dfl.internal.wincom.IPicture _fromStdStream(Stream stm) 
    1371         in 
    1372         { 
    1373             assert(stm !is null); 
    1374         } 
    1375         body 
    1376         { 
    1377             scope StdStreamToIStream istm = new StdStreamToIStream(stm); 
    1378             return _fromIStream(istm); 
    1379         } 
    1380          
    1381          
    1382         static dfl.internal.wincom.IPicture _fromFileName(char[] fileName) 
    1383         { 
    1384             alias dfl.internal.winapi.HANDLE HANDLE; // Otherwise, odd conflict with wine. 
    1385              
    1386             HANDLE hf; 
    1387             HANDLE hg; 
    1388             void* pg; 
    1389             DWORD dwsz, dw; 
    1390              
    1391             hf = dfl.internal.utf.createFile(fileName, GENERIC_READ, FILE_SHARE_READ, null, 
    1392                 OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, null); 
    1393             if(!hf) 
    1394                 return null; 
    1395              
    1396             dwsz = GetFileSize(hf, null); 
    1397             if(0xFFFFFFFF == dwsz) 
    1398             { 
    1399                 failclose: 
    1400                 CloseHandle(hf); 
    1401                 return null; 
    1402             } 
    1403              
    1404             hg = GlobalAlloc(GMEM_MOVEABLE, dwsz); 
    1405             if(!hg) 
    1406                 goto failclose; 
    1407              
    1408             pg = GlobalLock(hg); 
    1409             if(!pg) 
    1410             { 
    1411                 CloseHandle(hf); 
    1412                 CloseHandle(hg); 
    1413                 return null; 
    1414             } 
    1415              
    1416             if(!ReadFile(hf, pg, dwsz, &dw, null) || dwsz != dw) 
    1417             { 
    1418                 CloseHandle(hf); 
    1419                 GlobalUnlock(hg); 
    1420                 CloseHandle(hg); 
    1421                 return null; 
    1422             } 
    1423              
     1308            oldbm = SelectObject(memdc, result); 
     1309            draw(memdc, Point(0, 0)); 
     1310        } 
     1311        finally 
     1312        { 
     1313            if(oldbm) 
     1314                SelectObject(memdc, oldbm); 
     1315            DeleteDC(memdc); 
     1316        } 
     1317        return result; 
     1318    } 
     1319     
     1320     
     1321    final Bitmap toBitmap(HDC hdc) // package 
     1322    { 
     1323        HBITMAP hbm; 
     1324        hbm = toHBitmap(hdc); 
     1325        if(!hbm) 
     1326            throw new DflException("Unable to create bitmap"); 
     1327        return new Bitmap(hbm, true); // Owned. 
     1328    } 
     1329     
     1330     
     1331    final Bitmap toBitmap() 
     1332    { 
     1333        Graphics g; 
     1334        Bitmap result; 
     1335        g = Graphics.getScreen(); 
     1336        result = toBitmap(g); 
     1337        g.dispose(); 
     1338        return result; 
     1339    } 
     1340     
     1341    /// ditto 
     1342    final Bitmap toBitmap(Graphics g) 
     1343    { 
     1344        return toBitmap(g.handle); 
     1345    } 
     1346     
     1347     
     1348    private: 
     1349    dfl.internal.wincom.IPicture ipic = null; 
     1350     
     1351     
     1352    static dfl.internal.wincom.IPicture _fromIStream(dfl.internal.wincom.IStream istm) 
     1353    { 
     1354        dfl.internal.wincom.IPicture ipic; 
     1355        if(S_OK != OleLoadPicture(istm, 0, FALSE, &_IID_IPicture, cast(void**)&ipic)) 
     1356            return null; 
     1357        return ipic; 
     1358    } 
     1359     
     1360     
     1361    static dfl.internal.wincom.IPicture _fromDStream(DStream stm) 
     1362    in 
     1363    { 
     1364        assert(stm !is null); 
     1365    } 
     1366    body 
     1367    { 
     1368        scope DStreamToIStream istm = new DStreamToIStream(stm); 
     1369        return _fromIStream(istm); 
     1370    } 
     1371     
     1372     
     1373    static dfl.internal.wincom.IPicture _fromFileName(char[] fileName) 
     1374    { 
     1375        alias dfl.internal.winapi.HANDLE HANDLE; // Otherwise, odd conflict with wine. 
     1376         
     1377        HANDLE hf; 
     1378        HANDLE hg; 
     1379        void* pg; 
     1380        DWORD dwsz, dw; 
     1381         
     1382        hf = dfl.internal.utf.createFile(fileName, GENERIC_READ, FILE_SHARE_READ, null, 
     1383            OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, null); 
     1384        if(!hf) 
     1385            return null; 
     1386         
     1387        dwsz = GetFileSize(hf, null); 
     1388        if(0xFFFFFFFF == dwsz) 
     1389        { 
     1390            failclose: 
     1391            CloseHandle(hf); 
     1392            return null; 
     1393        } 
     1394         
     1395        hg = GlobalAlloc(GMEM_MOVEABLE, dwsz); 
     1396        if(!hg) 
     1397            goto failclose; 
     1398         
     1399        pg = GlobalLock(hg); 
     1400        if(!pg) 
     1401        { 
     1402            CloseHandle(hf); 
     1403            CloseHandle(hg); 
     1404            return null; 
     1405        } 
     1406         
     1407        if(!ReadFile(hf, pg, dwsz, &dw, null) || dwsz != dw) 
     1408        { 
    14241409            CloseHandle(hf); 
    14251410            GlobalUnlock(hg); 
    1426              
    1427             IStream istm; 
    1428             dfl.internal.wincom.IPicture ipic; 
    1429              
    1430             if(S_OK != CreateStreamOnHGlobal(hg, TRUE, &istm)) 
    1431             { 
    1432                 CloseHandle(hg); 
    1433                 return null; 
    1434             } 
    1435             // Don't need to CloseHandle(hg) due to 2nd param being TRUE. 
    1436              
    1437             ipic = _fromIStream(istm); 
    1438             if(!ipic) 
    1439             { 
    1440                 istm.Release(); 
    1441                 return null; 
    1442             } 
    1443              
     1411            CloseHandle(hg); 
     1412            return null; 
     1413        } 
     1414         
     1415        CloseHandle(hf); 
     1416        GlobalUnlock(hg); 
     1417         
     1418        IStream istm; 
     1419        dfl.internal.wincom.IPicture ipic; 
     1420         
     1421        if(S_OK != CreateStreamOnHGlobal(hg, TRUE, &istm)) 
     1422        { 
     1423            CloseHandle(hg); 
     1424            return null; 
     1425        } 
     1426        // Don't need to CloseHandle(hg) due to 2nd param being TRUE. 
     1427         
     1428        ipic = _fromIStream(istm); 
     1429        if(!ipic) 
     1430        { 
    14441431            istm.Release(); 
    1445              
    1446             return ipic; 
    1447         } 
     1432            return null; 
     1433        } 
     1434         
     1435        istm.Release(); 
     1436         
     1437        return ipic; 
    14481438    } 
    14491439} 
     
    17731763        if(vSplit) 
    17741764        { 
    1775             x = movableArea.width / 2 - MWIDTH / 2
     1765            x = movableArea.x + (movableArea.width / 2 - MWIDTH / 2)
    17761766            //y = movableArea.height / 2 - ((MWIDTH * count) + (MSPACE * (count - 1))) / 2; 
    1777             y = movableArea.height / 2 - ((MWIDTH * count) + (MSPACE * count)) / 2
     1767            y = movableArea.y + (movableArea.height / 2 - ((MWIDTH * count) + (MSPACE * count)) / 2)
    17781768             
    17791769            for(iw = 0; iw != count; iw++) 
     
    17861776        { 
    17871777            //x = movableArea.width / 2 - ((MHEIGHT * count) + (MSPACE * (count - 1))) / 2; 
    1788             x = movableArea.width / 2 - ((MHEIGHT * count) + (MSPACE * count)) / 2
    1789             y = movableArea.height / 2 - MHEIGHT / 2
     1778            x = movableArea.x + (movableArea.width / 2 - ((MHEIGHT * count) + (MSPACE * count)) / 2)
     1779            y = movableArea.y + (movableArea.height / 2 - MHEIGHT / 2)
    17901780             
    17911781            for(iw = 0; iw != count; iw++) 
     
    23562346     
    23572347     
    2358     /// 
    2359     final bool copyTo(HDC dest, int destX, int destY, int width, int height, int srcX, int srcY, DWORD rop) // package 
     2348    final bool copyTo(HDC dest, int destX, int destY, int width, int height, int srcX = 0, int srcY = 0, DWORD rop = SRCCOPY) // package 
    23602349    { 
    23612350        return cast(bool)dfl.internal.winapi.BitBlt(dest, destX, destY, width, height, this.handle, srcX, srcY, rop); 
    23622351    } 
    23632352     
    2364     /// ditto 
    2365     final bool copyTo(Graphics destGraphics, int destX, int destY, int width, int height, int srcX, int srcY, DWORD rop) 
     2353     
     2354    /// 
     2355    final bool copyTo(Graphics destGraphics, int destX, int destY, int width, int height, int srcX = 0, int srcY = 0, DWORD rop = SRCCOPY) 
    23662356    { 
    23672357        return copyTo(destGraphics.handle, destX, destY, width, height, srcX, srcY, rop); 
     
    23692359     
    23702360    /// ditto 
    2371     final bool copyTo(Graphics destGraphics, int destX, int destY, int width, int height, int srcX, int srcY) 
    2372     { 
    2373         return copyTo(destGraphics.handle, destX, destY, width, height, srcX, srcY, SRCCOPY); 
    2374     } 
    2375      
    2376     /// ditto 
    2377     final bool copyTo(Graphics destGraphics, int destX, int destY, int width, int height) 
    2378     { 
    2379         return copyTo(destGraphics.handle, destX, destY, width, height, 0, 0, SRCCOPY); 
    2380     } 
    2381      
    2382     /// ditto 
    23832361    final bool copyTo(Graphics destGraphics, Rect bounds) 
    23842362    { 
    2385         return copyTo(destGraphics.handle, bounds.x, bounds.y, bounds.width, bounds.height, 0, 0, SRCCOPY); 
     2363        return copyTo(destGraphics.handle, bounds.x, bounds.y, bounds.width, bounds.height); 
    23862364    } 
    23872365     
     
    24802458     
    24812459     
    2482     /+ 
    2483     // Requires creating yet another DC; compatible with screen? Picture.toBitmap() is. 
     2460    final Size size() // getter 
     2461    { 
     2462        return Size(_w, _h); 
     2463    } 
     2464     
     2465     
     2466    /// 
     2467    final HBITMAP hbitmap() // getter // package 
     2468    { 
     2469        return hbm; 
     2470    } 
     2471     
     2472     
     2473    // Needs to copy so it can be selected into other DC`s. 
     2474    final HBITMAP toHBitmap(HDC hdc) // package 
     2475    { 
     2476        HDC memdc; 
     2477        HBITMAP result; 
     2478        HGDIOBJ oldbm; 
     2479        memdc = CreateCompatibleDC(hdc); 
     2480        if(!memdc) 
     2481            throw new DflException("Device error"); 
     2482        try 
     2483        { 
     2484            result = CreateCompatibleBitmap(hdc, width, height); 
     2485            if(!result) 
     2486            { 
     2487                bad_bm: 
     2488                throw new DflException("Unable to allocate image"); 
     2489            } 
     2490            oldbm = SelectObject(memdc, result); 
     2491            copyTo(memdc, 0, 0, width, height); 
     2492        } 
     2493        finally 
     2494        { 
     2495            if(oldbm) 
     2496                SelectObject(memdc, oldbm); 
     2497            DeleteDC(memdc); 
     2498        } 
     2499        return result; 
     2500    } 
     2501     
     2502     
     2503    final Bitmap toBitmap(HDC hdc) // package 
     2504    { 
     2505        HBITMAP hbm; 
     2506        hbm = toHBitmap(hdc); 
     2507        if(!hbm) 
     2508            throw new DflException("Unable to create bitmap"); 
     2509        return new Bitmap(hbm, true); // Owned. 
     2510    } 
     2511     
     2512     
     2513    /// 
    24842514    final Bitmap toBitmap() 
    24852515    { 
    2486     } 
    2487     +/ 
    2488      
    2489      
    2490     /// 
    2491     final HBITMAP hbitmap() // getter // package 
    2492     { 
    2493         return hbm; 
     2516        Graphics g; 
     2517        Bitmap result; 
     2518        g = Graphics.getScreen(); 
     2519        result = toBitmap(g); 
     2520        g.dispose(); 
     2521        return result; 
     2522    } 
     2523     
     2524    /// ditto 
     2525    final Bitmap toBitmap(Graphics g) 
     2526    { 
     2527        return toBitmap(g.handle); 
    24942528    } 
    24952529     
     
    27982832{ 
    27992833    // Used internally. 
    2800     this(HFONT hf, LOGFONTA* lf, bool owned = true) // package 
    2801     { 
     2834    static void LOGFONTAtoLogFont(inout LogFont lf, LOGFONTA* plfa) // package // deprecated 
     2835    { 
     2836        lf.lfa = *plfa; 
     2837        lf.faceName = dfl.internal.utf.fromAnsiz(plfa.lfFaceName.ptr); 
     2838    } 
     2839     
     2840    // Used internally. 
     2841    static void LOGFONTWtoLogFont(inout LogFont lf, LOGFONTW* plfw) // package // deprecated 
     2842    { 
     2843        lf.lfw = *plfw; 
     2844        lf.faceName = dfl.internal.utf.fromUnicodez(plfw.lfFaceName.ptr); 
     2845    } 
     2846     
     2847     
     2848    // Used internally. 
     2849    this(HFONT hf, LOGFONTA* plfa, bool owned = true) // package // deprecated 
     2850    { 
     2851        LogFont lf; 
     2852        LOGFONTAtoLogFont(lf, plfa); 
     2853         
    28022854        this.hf = hf; 
    28032855        this.owned = owned; 
     
    28102862     
    28112863    // Used internally. 
    2812     this(HFONT hf, bool owned = true) // package 
     2864    this(HFONT hf, inout LogFont lf, bool owned = true) // package 
    28132865    { 
    28142866        this.hf = hf; 
     
    28162868        this._unit = GraphicsUnit.POINT; 
    28172869         
    2818         LOGFONTA lf; 
    2819         _info(&lf); 
    2820          
    2821         _fstyle = _style(&lf); 
    2822         _initLf(&lf); 
     2870        _fstyle = _style(lf); 
     2871        _initLf(lf); 
    28232872    } 
    28242873     
    28252874     
    28262875    // Used internally. 
    2827     this(LOGFONTA* lf, bool owned = true) // package 
    2828     { 
     2876    this(HFONT hf, bool owned = true) // package 
     2877    { 
     2878        this.hf = hf; 
     2879        this.owned = owned; 
     2880        this._unit = GraphicsUnit.POINT; 
     2881         
     2882        LogFont lf; 
     2883        _info(lf); 
     2884         
     2885        _fstyle = _style(lf); 
     2886        _initLf(lf); 
     2887    } 
     2888     
     2889     
     2890    // Used internally. 
     2891    this(LOGFONTA* plfa, bool owned = true) // package // deprecated 
     2892    { 
     2893        LogFont lf; 
     2894        LOGFONTAtoLogFont(lf, plfa); 
     2895         
    28292896        this(_create(lf), lf, owned); 
    28302897    } 
    28312898     
    28322899     
    2833     package static HFONT _create(LOGFONTA* lf) 
     2900    // Used internally. 
     2901    this(inout LogFont lf, bool owned = true) // package 
     2902    { 
     2903        this(_create(lf), lf, owned); 
     2904    } 
     2905     
     2906     
     2907    package static HFONT _create(inout LogFont lf) 
    28342908    { 
    28352909        HFONT result; 
    2836         result = CreateFontIndirectA(lf); 
     2910        result = dfl.internal.utf.createFontIndirect(lf); 
    28372911        if(!result) 
    28382912            throw new DflException("Unable to create font"); 
     
    28412915     
    28422916     
    2843     private static void _style(LOGFONTA* lf, FontStyle style) 
    2844     { 
    2845         lf.lfWeight = (style & FontStyle.BOLD) ? FW_BOLD : FW_NORMAL; 
    2846         lf.lfItalic = (style & FontStyle.ITALIC) ? TRUE : FALSE; 
    2847         lf.lfUnderline = (style & FontStyle.UNDERLINE) ? TRUE : FALSE; 
    2848         lf.lfStrikeOut = (style & FontStyle.STRIKEOUT) ? TRUE : FALSE; 
    2849     } 
    2850      
    2851      
    2852     private static FontStyle _style(LOGFONTA* lf) 
     2917    private static void _style(inout LogFont lf, FontStyle style) 
     2918    { 
     2919        lf.lf.lfWeight = (style & FontStyle.BOLD) ? FW_BOLD : FW_NORMAL; 
     2920        lf.lf.lfItalic = (style & FontStyle.ITALIC) ? TRUE : FALSE; 
     2921        lf.lf.lfUnderline = (style & FontStyle.UNDERLINE) ? TRUE : FALSE; 
     2922        lf.lf.lfStrikeOut = (style & FontStyle.STRIKEOUT) ? TRUE : FALSE; 
     2923    } 
     2924     
     2925     
     2926    private static FontStyle _style(inout LogFont lf) 
    28532927    { 
    28542928        FontStyle style = FontStyle.REGULAR; 
    28552929         
    2856         if(lf.lfWeight >= FW_BOLD) 
     2930        if(lf.lf.lfWeight >= FW_BOLD) 
    28572931            style |= FontStyle.BOLD; 
    2858         if(lf.lfItalic) 
     2932        if(lf.lf.lfItalic) 
    28592933            style |= FontStyle.ITALIC; 
    2860         if(lf.lfUnderline) 
     2934        if(lf.lf.lfUnderline) 
    28612935            style |= FontStyle.UNDERLINE; 
    2862         if(lf.lfStrikeOut) 
     2936        if(lf.lf.lfStrikeOut) 
    28632937            style |= FontStyle.STRIKEOUT; 
    28642938         
     
    28672941     
    28682942     
    2869     package void _info(LOGFONTA* lf) 
     2943    package void _info(LOGFONTA* lf) // deprecated 
    28702944    { 
    28712945        if(GetObjectA(hf, LOGFONTA.sizeof, lf) != LOGFONTA.sizeof) 
     2946            throw new DflException("Unable to get font information"); 
     2947    } 
     2948     
     2949    package void _info(LOGFONTW* lf) // deprecated 
     2950    { 
     2951        auto proc = cast(GetObjectWProc)GetProcAddress(GetModuleHandleA("gdi32.dll"), "GetObjectW"); 
     2952         
     2953        if(!proc || proc(hf, LOGFONTW.sizeof, lf) != LOGFONTW.sizeof) 
     2954            throw new DflException("Unable to get font information"); 
     2955    } 
     2956     
     2957     
     2958    package void _info(inout LogFont lf) 
     2959    { 
     2960        if(!dfl.internal.utf.getLogFont(hf, lf)) 
    28722961            throw new DflException("Unable to get font information"); 
    28732962    } 
     
    29833072    this(Font font, FontStyle style) 
    29843073    { 
    2985         LOGFONTA lf; 
     3074        LogFont lf; 
    29863075        _unit = font._unit; 
    2987         font._info(&lf); 
    2988         _style(&lf, style); 
    2989         this(_create(&lf)); 
     3076        font._info(lf); 
     3077        _style(lf, style); 
     3078        this(_create(lf)); 
    29903079         
    29913080        _fstyle = style; 
    2992         _initLf(font, &lf); 
     3081        _initLf(font, lf); 
    29933082    } 
    29943083     
     
    30223111        FontSmoothing smoothing = FontSmoothing.DEFAULT) 
    30233112    { 
    3024         LOGFONTA lf; 
     3113        LogFont lf; 
    30253114         
    30263115        _unit = unit; 
    30273116         
    3028         if(name.length >= lf.lfFaceName.length) 
    3029             throw new DflException("Invalid font name"); 
    3030         lf.lfFaceName[0 .. name.length] = name; 
    3031         lf.lfFaceName[name.length] = 0; 
    3032          
    3033         lf.lfHeight = -getLfHeight(emSize, unit); 
    3034         _style(&lf, style); 
    3035          
    3036         lf.lfCharSet = gdiCharSet; 
    3037         lf.lfOutPrecision = OUT_DEFAULT_PRECIS; 
    3038         lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; 
    3039         //lf.lfQuality = DEFAULT_QUALITY; 
    3040         lf.lfQuality = smoothing; 
    3041         lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; 
    3042          
    3043         this(_create(&lf)); 
     3117        lf.faceName = name; 
     3118         
     3119        lf.lf.lfHeight = -getLfHeight(emSize, unit); 
     3120        _style(lf, style); 
     3121         
     3122        lf.lf.lfCharSet = gdiCharSet; 
     3123        lf.lf.lfOutPrecision = OUT_DEFAULT_PRECIS; 
     3124        lf.lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; 
     3125        //lf.lf.lfQuality = DEFAULT_QUALITY; 
     3126        lf.lf.lfQuality = smoothing; 
     3127        lf.lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; 
     3128         
     3129        this(_create(lf)); 
    30443130         
    30453131        _fstyle = style; 
    3046         _initLf(&lf); 
     3132        _initLf(lf); 
    30473133    } 
    30483134     
     
    30753161        LOGFONTA lf; 
    30763162        _info(&lf); 
    3077         return getEmSize(lf.lfHeight, _unit); 
     3163        return getEmSize(lf.lf.lfHeight, _unit); 
    30783164        +/ 
    30793165        return getEmSize(this.lfHeight, _unit); 
     
    30873173        LOGFONTA lf; 
    30883174        _info(&lf); 
    3089         return getEmSize(lf.lfHeight, unit); 
     3175        return getEmSize(lf.lf.lfHeight, unit); 
    30903176        +/ 
    30913177        return getEmSize(this.lfHeight, unit); 
     
    31193205     
    31203206     
     3207    /+ 
    31213208    private void _initLf(LOGFONTA* lf) 
    31223209    { 
     
    31253212        this.lfCharSet = lf.lfCharSet; 
    31263213    } 
    3127      
    3128      
     3214    +/ 
     3215     
     3216    private void _initLf(inout LogFont lf) 
     3217    { 
     3218        this.lfHeight = lf.lf.lfHeight; 
     3219        this.lfName = lf.faceName; 
     3220        this.lfCharSet = lf.lf.lfCharSet; 
     3221    } 
     3222     
     3223     
     3224    /+ 
    31293225    private void _initLf(Font otherfont, LOGFONTA* lf) 
     3226    { 
     3227        this.lfHeight = otherfont.lfHeight; 
     3228        this.lfName = otherfont.lfName; 
     3229        this.lfCharSet = otherfont.lfCharSet; 
     3230    } 
     3231    +/ 
     3232     
     3233    private void _initLf(Font otherfont, inout LogFont lf) 
    31303234    { 
    31313235        this.lfHeight = otherfont.lfHeight; 
  • trunk/win32/dfl/fontdialog.d

    r5 r7  
    77 
    88private import dfl.base, dfl.commondialog, dfl.internal.winapi, dfl.application, 
    9     dfl.control, dfl.drawing, dfl.event
     9    dfl.control, dfl.drawing, dfl.event, dfl.internal.utf
    1010 
    1111 
     
    2525        cf.lStructSize = cf.sizeof; 
    2626        cf.Flags = INIT_FLAGS; 
    27         cf.lpLogFont = cast(typeof(cf.lpLogFont))&lf
     27        cf.lpLogFont = cast(typeof(cf.lpLogFont))&lfw
    2828        cf.lCustData = cast(typeof(cf.lCustData))cast(void*)this; 
    2929        cf.lpfnHook = &fondHookProc; 
     
    3535    { 
    3636        _fon = null; 
    37         //lf = lf.init; // It's completely updated when needed. 
    3837        cf.Flags = INIT_FLAGS; 
    3938        cf.rgbColors = 0; 
     
    334333        BOOL result = FALSE; 
    335334         
    336         font._info(&lf); // -font- gets default font if not set. 
    337335        cf.hwndOwner = owner; 
    338336         
    339         // TODO: fix this when LOGFONTW is implemented. 
    340         /+if(dfl.internal.utf.useUnicode) 
    341         { 
     337        if(dfl.internal.utf.useUnicode) 
     338        { 
     339            font._info(&lfw); // -font- gets default font if not set. 
     340             
    342341            const char[] NAME = "ChooseFontW"; 
    343342            static ChooseFontWProc proc = null; 
     
    345344            if(!proc) 
    346345            { 
    347                 proc = cast(ChooseFontWProc)GetProcAddress(GetModuleHandleA("comdlg32.dll"), NAME); 
     346                proc = cast(ChooseFontWProc)GetProcAddress(GetModuleHandleA("comdlg32.dll"), NAME.ptr); 
    348347                if(!proc) 
    349348                    throw new Exception("Unable to load procedure " ~ NAME ~ "."); 
     
    352351            result = proc(&cfw); 
    353352        } 
    354         else+/ 
    355         { 
     353        else 
     354        { 
     355            font._info(&lfa); // -font- gets default font if not set. 
     356             
    356357            result = ChooseFontA(&cfa); 
    357358        } 
     
    368369    private void _update() 
    369370    { 
    370         _fon = new Font(Font._create(&lf), true); 
     371        LogFont lf; 
     372         
     373        if(dfl.internal.utf.useUnicode) 
     374            Font.LOGFONTWtoLogFont(lf, &lfw); 
     375        else 
     376            Font.LOGFONTAtoLogFont(lf, &lfa); 
     377         
     378        _fon = new Font(Font._create(lf), true); 
    371379    } 
    372380     
     
    380388     
    381389    private: 
     390     
    382391    union 
    383392    { 
     
    391400    } 
    392401     
    393     LOGFONTA lf; 
     402    union 
     403    { 
     404        LOGFONTW lfw; 
     405        LOGFONTA lfa; 
     406         
     407        static assert(LOGFONTW.lfFaceName.offsetof == LOGFONTA.lfFaceName.offsetof); 
     408    } 
     409     
    394410    Font _fon; 
    395411     
  • trunk/win32/dfl/form.d

    r5 r7  
    1111private import dfl.application, dfl.base, dfl.menu, dfl.internal.utf; 
    1212private import dfl.collections; 
     13 
     14 
     15version(NO_DFL_PARK_WINDOW) 
     16{ 
     17} 
     18else 
     19{ 
     20    version = DFL_PARK_WINDOW; 
     21} 
    1322 
    1423 
     
    105114 
    106115/// 
    107 class Form: ContainerControl // docmain 
     116class Form: ContainerControl, IDialogResult // docmain 
    108117{ 
    109118    /// 
     
    130139    { 
    131140        cancelBtn = btn; 
     141         
     142        if(btn) 
     143        { 
     144            if(!(Application._compat & DflCompat.FORM_DIALOGRESULT_096)) 
     145            { 
     146                btn.dialogResult = DialogResult.CANCEL; 
     147            } 
     148        } 
    132149    } 
    133150     
     
    252269        version(DFL_PARK_WINDOW) 
    253270        { 
    254             if(!cp.parent && !showInTaskbar()
     271            if(!cp.parent && !showInTaskbar
    255272                cp.parent = getParkHwnd(); 
    256273        } 
     
    428445        } 
    429446         
     447        if(!nofilter) 
     448            Application.addMessageFilter(mfilter); // To process IsDialogMessage(). 
     449         
    430450        //createChildren(); 
    431451        try 
     
    460480                } 
    461481            } 
     482             
     483            // Load before shown. 
     484            // Not calling if recreating handle! 
     485            onLoad(EventArgs.empty); 
    462486        } 
    463487         
     
    488512        } 
    489513        //cbits &= ~CBits.FVISIBLE; 
    490          
    491         //Application.addMessageFilter(mfilter = new FormMessageFilter(this)); // To process IsDialogMessage(). 
    492         if(!nofilter) 
    493             Application.addMessageFilter(mfilter); // To process IsDialogMessage(). 
    494          
    495         //onHandleCreated(EventArgs.empty); // Called in Control's WM_CREATE now. 
    496          
    497         onLoad(EventArgs.empty); 
    498514    } 
    499515     
     
    599615    { 
    600616        fresult = dr; 
     617         
     618        if(!(Application._compat & DflCompat.FORM_DIALOGRESULT_096)) 
     619        { 
     620            if(modal && DialogResult.NONE != dr) 
     621                close(); 
     622        } 
    601623    } 
    602624     
     
    733755                    | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); // Recalculate the frame. 
    734756            } 
     757             
     758            invalidate(true); 
    735759             
    736760            _resetSystemMenu(); 
     
    13931417            wowner = frm; 
    13941418            if(isHandleCreated) 
    1395                 SetParent(hwnd, frm.hwnd); 
     1419            { 
     1420                if(CCompat.DFL095 == _compat) 
     1421                    SetParent(hwnd, frm.hwnd); 
     1422                else 
     1423                    _crecreate(); 
     1424            } 
    13961425        } 
    13971426        else 
    13981427        { 
    13991428            if(isHandleCreated) 
    1400                 SetParent(hwnd, HWND.init); 
     1429            { 
     1430                if(showInTaskbar || CCompat.DFL095 == _compat) 
     1431                    SetParent(hwnd, HWND.init); 
     1432                else 
     1433                    _crecreate(); 
     1434            } 
    14011435        } 
    14021436         
     
    14461480                version(DFL_PARK_WINDOW) 
    14471481                { 
     1482                    /+ // Not working, the form disappears (probably stuck as a child). 
    14481483                    if(!GetParent(handle)) 
     1484                    { 
     1485                        //_style((_style() | WS_POPUP) & ~WS_CHILD); 
     1486                         
    14491487                        SetParent(handle, getParkHwnd()); 
     1488                    } 
     1489                    +/ 
     1490                    _crecreate(); 
    14501491                } 
    14511492            } 
     
    24372478            +/ 
    24382479             
     2480            case WM_SETFOCUS: 
     2481                { 
     2482                    // Prevent DefDlgProc from getting this message because it'll focus controls it shouldn't. 
     2483                    bool didf = false; 
     2484                    enumChildWindows(msg.hWnd, 
     2485                        (HWND hw) 
     2486                        { 
     2487                            auto wl = GetWindowLongA(hw, GWL_STYLE); 
     2488                            if(((WS_VISIBLE | WS_TABSTOP) == ((WS_VISIBLE | WS_TABSTOP) & wl)) 
     2489                                && !(WS_DISABLED & wl)) 
     2490                            { 
     2491                                DefDlgProcA(msg.hWnd, WM_NEXTDLGCTL, cast(WPARAM)hw, MAKELPARAM(true, 0)); 
     2492                                didf = true; 
     2493                                return FALSE; 
     2494                            } 
     2495                            return TRUE; 
     2496                        }); 
     2497                    if(!didf) 
     2498                        SetFocus(msg.hWnd); 
     2499                } 
     2500                return; 
     2501             
    24392502            default: 
    24402503                version(NO_MDI) 
     
    25212584        } 
    25222585    } 
    2523      
    2524      
    2525     /+ 
    2526     // DMD 0.129: Internal error: ..\ztc\cod3.c 736 
    2527     protected override bool processTabKey(bool forward) 
    2528     { 
    2529         if(selectNextControl(activeControl, forward, true, true)) 
    2530             return true; 
    2531         return false; 
    2532     } 
    2533     +/ 
    25342586     
    25352587     
     
    26922744                } 
    26932745                 
     2746                // isDialogMessage seems to be eating WM_CHAR in some cases, so see for myself if it should get it. 
     2747                if(WM_CHAR == m.msg) 
     2748                { 
     2749                    // ? ... 
     2750                    return false; // Continue. 
     2751                } 
     2752                 
    26942753                //if(!form.isMdiChild && !form.isMdiContainer) 
    26952754                { 
     
    28642923version(DFL_PARK_WINDOW) 
    28652924{ 
    2866     static assert(0); 
    2867      
    2868      
    28692925    HWND getParkHwnd() 
    28702926    { 
    28712927        if(!_hwPark) 
    2872             _makePark(); 
     2928        { 
     2929            synchronized 
     2930            { 
     2931                if(!_hwPark) 
     2932                    _makePark(); 
     2933            } 
     2934        } 
    28732935        return _hwPark; 
    28742936    } 
     
    28782940    { 
    28792941        WNDCLASSEXA wce; 
    2880         (cast(ubyte*)&wce)[0 .. wce.sizeof] = 0; 
    28812942        wce.cbSize = wce.sizeof; 
    28822943        wce.style = CS_DBLCLKS; 
    2883         wce.lpszClassName = PARK_CLASSNAME
     2944        wce.lpszClassName = PARK_CLASSNAME.ptr
    28842945        wce.lpfnWndProc = &DefWindowProcA; 
    28852946        wce.hInstance = Application.getInstance(); 
     
    28952956        } 
    28962957         
    2897         _hwPark = CreateWindowExA(WS_EX_WINDOWEDGE | WS_EX_CONTROLPARENT, PARK_CLASSNAME, "", 
    2898             WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0, 0, 0, 0, 
     2958        _hwPark = CreateWindowExA(WS_EX_TOOLWINDOW, PARK_CLASSNAME.ptr, "", 
     2959            WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, 
    28992960            HWND.init, HMENU.init, wce.hInstance, null); 
    29002961        if(!_hwPark) 
  • trunk/win32/dfl/groupbox.d

    r5 r7  
    5050        _initButton(); 
    5151         
    52         if(_defTextHeight.init == _defTextHeight) 
     52        if(DEFTEXTHEIGHT_INIT == _defTextHeight) 
    5353        { 
    5454            _recalcTextHeight(defaultFont); 
     
    122122    private: 
    123123     
    124     static int _defTextHeight = -1; 
     124    const int DEFTEXTHEIGHT_INIT = -1; 
     125    static int _defTextHeight = DEFTEXTHEIGHT_INIT; 
    125126    int _textHeight = -1; 
    126127     
  • trunk/win32/dfl/internal/com.d

    r5 r7  
    55module dfl.internal.com; 
    66 
    7 private import dfl.internal.winapi, dfl.internal.wincom; 
    8  
    9 version(Tango) 
    10 
    11 
    12 else 
    13 
    14     private import std.stream; 
    15 
     7private import dfl.internal.winapi, dfl.internal.wincom, dfl.internal.dlib; 
    168 
    179 
     
    4436 
    4537 
    46 version(Tango) 
    47 
    48 
    49 else 
    50 
    51     class StdStreamToIStream: DflComObject, dfl.internal.wincom.IStream 
    52     { 
    53         this(Stream sourceStdStream) 
    54         { 
    55             this.stm = sourceStdStream; 
    56         } 
    57          
    58          
    59         // TODO: catch general exceptions and react. 
    60          
    61         extern(Windows): 
    62         override HRESULT QueryInterface(IID* riid, void** ppv) 
    63         { 
    64             if(*riid == _IID_IStream) 
    65             { 
    66                 *ppv = cast(void*)cast(dfl.internal.wincom.IStream)this; 
    67                 AddRef(); 
    68                 return S_OK; 
    69             } 
    70             else if(*riid == _IID_ISequentialStream) 
    71             { 
    72                 *ppv = cast(void*)cast(dfl.internal.wincom.ISequentialStream)this; 
    73                 AddRef(); 
    74                 return S_OK; 
    75             } 
    76             else if(*riid == _IID_IUnknown) 
    77             { 
    78                 *ppv = cast(void*)cast(IUnknown)this; 
    79                 AddRef(); 
    80                 return S_OK; 
     38class DStreamToIStream: DflComObject, dfl.internal.wincom.IStream 
     39
     40    this(DStream sourceDStream) 
     41    { 
     42        this.stm = sourceDStream; 
     43    } 
     44     
     45     
     46    extern(Windows): 
     47     
     48    override HRESULT QueryInterface(IID* riid, void** ppv) 
     49    { 
     50        if(*riid == _IID_IStream) 
     51        { 
     52            *ppv = cast(void*)cast(dfl.internal.wincom.IStream)this; 
     53            AddRef(); 
     54            return S_OK; 
     55        } 
     56        else if(*riid == _IID_ISequentialStream) 
     57        { 
     58            *ppv = cast(void*)cast(dfl.internal.wincom.ISequentialStream)this; 
     59            AddRef(); 
     60            return S_OK; 
     61        } 
     62        else if(*riid == _IID_IUnknown) 
     63        { 
     64            *ppv = cast(void*)cast(IUnknown)this; 
     65            AddRef(); 
     66            return S_OK; 
     67        } 
     68        else 
     69        { 
     70            *ppv = null; 
     71            return E_NOINTERFACE; 
     72        } 
     73    } 
     74     
     75     
     76    HRESULT Read(void* pv, ULONG cb, ULONG* pcbRead) 
     77    { 
     78        ULONG read; 
     79        HRESULT result = S_OK; 
     80         
     81        try 
     82        { 
     83            version(Tango) 
     84            { 
     85                read = stm.input.read(pv[0 .. cb]); 
    8186            } 
    8287            else 
    8388            { 
    84                 *ppv = null; 
    85                 return E_NOINTERFACE; 
    86             } 
    87         } 
    88          
    89          
    90         HRESULT Read(void* pv, ULONG cb, ULONG* pcbRead) 
    91         { 
    92             ULONG read; 
    93             read = stm.readBlock(pv, cb); 
    94             if(pcbRead) 
    95                 *pcbRead = read; 
    96             if(!read) 
    97                 return S_FALSE; 
    98             return S_OK; 
    99         } 
    100          
    101          
    102         HRESULT Write(void* pv, ULONG cb, ULONG* pcbWritten) 
    103         { 
    104             ULONG written; 
    105             written = stm.writeBlock(pv, cb); 
    106             if(pcbWritten) 
    107                 *pcbWritten = written; 
    108             if(!written) 
    109                 return S_FALSE; 
    110             return S_OK; 
    111         } 
    112          
    113          
    114         HRESULT Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition) 
     89                read = stm.readBlock(pv, cb); 
     90            } 
     91        } 
     92        catch(DStreamException e) 
     93        { 
     94            result = S_FALSE; // ? 
     95        } 
     96         
     97        if(pcbRead) 
     98            *pcbRead = read; 
     99        //if(!read) 
     100        //  result = S_FALSE; 
     101        return result; 
     102    } 
     103     
     104     
     105    HRESULT Write(void* pv, ULONG cb, ULONG* pcbWritten) 
     106    { 
     107        ULONG written; 
     108        HRESULT result = S_OK; 
     109         
     110        try 
     111        { 
     112            version(Tango) 
     113            { 
     114                written = stm.output.write(pv[0 .. cb]); 
     115            } 
     116            else 
     117            { 
     118                written = stm.writeBlock(pv, cb); 
     119            } 
     120        } 
     121        catch(DStreamException e) 
     122        { 
     123            result = S_FALSE; // ? 
     124        } 
     125         
     126        if(pcbWritten) 
     127            *pcbWritten = written; 
     128        //if(!written) 
     129        //  result = S_FALSE; 
     130        return result; 
     131    } 
     132     
     133     
     134    HRESULT Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition) 
     135    { 
     136        version(Tango) 
     137        { 
     138            auto stmseek = cast(DStream.Seek)stm; 
     139            if(!stmseek) 
     140                return S_FALSE; // ? 
     141        } 
     142        else 
    115143        { 
    116144            if(!stm.seekable) 
    117145                return S_FALSE; // ? 
    118              
    119             HRESULT result = S_OK; 
    120             ulong pos; 
    121             try 
    122             { 
     146        } 
     147         
     148        HRESULT result = S_OK; 
     149         
     150        try 
     151        { 
     152            version(Tango) 
     153            { 
     154                long pos; 
     155                switch(dwOrigin) 
     156                { 
     157                    case STREAM_SEEK_SET: 
     158                        pos = stmseek.seek(dlibMove.QuadPart, DStream.Seek.Anchor.Begin); 
     159                        if(plibNewPosition) 
     160                            plibNewPosition.QuadPart = pos; 
     161                        break; 
     162                     
     163                    case STREAM_SEEK_CUR: 
     164                        pos = stmseek.seek(dlibMove.QuadPart, DStream.Seek.Anchor.Current); 
     165                        if(plibNewPosition) 
     166                            plibNewPosition.QuadPart = pos; 
     167                        break; 
     168                     
     169                    case STREAM_SEEK_END: 
     170                        pos = stmseek.seek(dlibMove.QuadPart, DStream.Seek.Anchor.End); 
     171                        if(plibNewPosition) 
     172                            plibNewPosition.QuadPart = pos; 
     173                        break; 
     174                     
     175                    default: 
     176                        result = STG_E_INVALIDFUNCTION; 
     177                } 
     178            } 
     179            else 
     180            { 
     181                ulong pos; 
    123182                switch(dwOrigin) 
    124183                { 
     
    145204                } 
    146205            } 
    147             catch(SeekException se) 
    148             { 
    149                 result = S_FALSE; // ? 
    150             } 
    151              
    152             return result; 
    153         } 
    154          
    155          
    156         HRESULT SetSize(ULARGE_INTEGER libNewSize) 
    157         { 
    158             return E_NOTIMPL; 
    159         } 
    160          
    161          
    162         HRESULT CopyTo(IStream pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten) 
    163         { 
    164             // TODO: implement. 
    165             return E_NOTIMPL; 
    166         } 
    167          
    168          
    169         HRESULT Commit(DWORD grfCommitFlags) 
    170         { 
    171             // Ignore -grfCommitFlags- and just flush the stream.. 
     206        } 
     207        catch(DStreamException e) 
     208        { 
     209            result = S_FALSE; // ? 
     210        } 
     211         
     212        return result; 
     213    } 
     214     
     215     
     216    HRESULT SetSize(ULARGE_INTEGER libNewSize) 
     217    { 
     218        return E_NOTIMPL; 
     219    } 
     220     
     221     
     222    HRESULT CopyTo(IStream pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten) 
     223    { 
     224        // TODO: implement. 
     225        return E_NOTIMPL; 
     226    } 
     227     
     228     
     229    HRESULT Commit(DWORD grfCommitFlags) 
     230    { 
     231        // Ignore -grfCommitFlags- and just flush the stream.. 
     232        version(Tango) 
     233        { 
     234            stm.output.flush(); 
     235        } 
     236        else 
     237        { 
    172238            stm.flush(); 
    173             return S_OK; // ? 
    174         } 
    175          
    176          
    177         HRESULT Revert() 
    178         { 
    179             return E_NOTIMPL; // ? S_FALSE ? 
    180         } 
    181          
    182          
    183         HRESULT LockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) 
    184         { 
    185             return E_NOTIMPL; 
    186         } 
    187          
    188          
    189         HRESULT UnlockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) 
    190         { 
    191             return E_NOTIMPL; 
    192         } 
    193          
    194          
    195         HRESULT Stat(STATSTG* pstatstg, DWORD grfStatFlag) 
    196         { 
    197             return E_NOTIMPL; // ? 
    198         } 
    199          
    200          
    201         HRESULT Clone(IStream* ppstm) 
    202         { 
    203             // Cloned stream needs its own seek position. 
    204             return E_NOTIMPL; // ? 
    205         } 
    206          
    207          
    208         extern(D): 
    209          
    210         private: 
    211         Stream stm; 
    212     } 
    213 
    214  
     239        } 
     240        return S_OK; // ? 
     241    } 
     242     
     243     
     244    HRESULT Revert() 
     245    { 
     246        return E_NOTIMPL; // ? S_FALSE ? 
     247    } 
     248     
     249     
     250    HRESULT LockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) 
     251    { 
     252        return E_NOTIMPL; 
     253    } 
     254     
     255     
     256    HRESULT UnlockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) 
     257    { 
     258        return E_NOTIMPL; 
     259    } 
     260     
     261     
     262    HRESULT Stat(STATSTG* pstatstg, DWORD grfStatFlag) 
     263    { 
     264        return E_NOTIMPL; // ? 
     265    } 
     266     
     267     
     268    HRESULT Clone(IStream* ppstm) 
     269    { 
     270        // Cloned stream needs its own seek position. 
     271        return E_NOTIMPL; // ? 
     272    } 
     273     
     274     
     275    extern(D): 
     276     
     277    private: 
     278    DStream stm; 
     279
     280 
     281version(Tango) 
     282
     283
     284else 
     285
     286    alias DStreamToIStream StdStreamToIStream; // deprecated 
     287
     288 
  • trunk/win32/dfl/internal/dlib.d

    r5 r7  
    254254     
    255255     
     256    private import tango.io.model.IConduit; 
     257     
     258    alias tango.io.model.IConduit.IConduit DStream; 
     259     
     260    alias tango.core.Exception.IOException DStreamException; // Note: from tango.core.Exception. 
     261     
     262     
    256263    class DObject 
    257264    { 
     
    349356    alias std.ctype.isxdigit charIsHexDigit; 
    350357     
     358     
     359    private import std.stream; 
     360     
     361    alias std.stream.Stream DStream; 
     362     
     363    alias std.stream.StreamException DStreamException; 
     364     
     365     
    351366    alias Object DObject; 
    352367} 
    353368 
     369 
     370char* unsafeToStringz(char[] s) 
     371{ 
     372    if(!s.ptr[s.length]) 
     373        return s.ptr; 
     374    return stringToStringz(s); 
     375} 
     376 
  • trunk/win32/dfl/internal/utf.d

    r5 r7  
    6868} 
    6969 
    70 package HMODULE user32, kernel32, _advapi32, gdi32; 
     70package: 
     71 
     72version(DFL_LOAD_INTERNAL_LIBS) 
     73
     74    alias LoadLibraryA initInternalLib; 
     75
     76else 
     77
     78    version = DFL_GET_INTERNAL_LIBS; 
     79     
     80    alias GetModuleHandleA initInternalLib; 
     81
     82 
     83 
     84HMODULE _user32, _kernel32, _advapi32, _gdi32; 
    7185 
    7286package HMODULE advapi32() // getter 
    7387{ 
     88    // advapi32 generally always delay loads. 
    7489    if(!_advapi32) 
    7590        _advapi32 = LoadLibraryA("advapi32.dll"); 
    7691    return _advapi32; 
     92} 
     93 
     94package HMODULE gdi32() // getter 
     95{ 
     96    // gdi32 sometimes delay loads. 
     97    version(DFL_GET_INTERNAL_LIBS) 
     98    { 
     99        if(!_gdi32) 
     100            _gdi32 = LoadLibraryA("gdi32.dll"); 
     101    } 
     102    return _gdi32; 
     103} 
     104 
     105package HMODULE user32() // getter 
     106{ 
     107    version(DFL_GET_INTERNAL_LIBS) 
     108    { 
     109        if(!_user32) 
     110            _user32 = LoadLibraryA("user32.dll"); 
     111    } 
     112    return _user32; 
     113} 
     114 
     115package HMODULE kernel32() // getter 
     116{ 
     117    version(DFL_GET_INTERNAL_LIBS) 
     118    { 
     119        if(!_kernel32) 
     120            _kernel32 = LoadLibraryA("kernel32.dll"); 
     121    } 
     122    return _kernel32; 
    77123} 
    78124 
     
    101147        +/ 
    102148         
    103         user32 = GetModuleHandleA("user32.dll"); 
    104         kernel32 = GetModuleHandleA("kernel32.dll"); 
     149        _user32 = initInternalLib("user32.dll"); 
     150        _kernel32 = initInternalLib("kernel32.dll"); 
    105151        _advapi32 = GetModuleHandleA("advapi32.dll"); // Not guaranteed to be loaded. 
    106         gdi32 = GetModuleHandleA("gdi32.dll"); 
     152        _gdi32 = initInternalLib("gdi32.dll"); 
    107153    } 
    108154} 
     
    369415    alias typeof(&SetMenuItemInfoW) SetMenuItemInfoWProc; 
    370416    alias typeof(&InsertMenuItemW) InsertMenuItemWProc; 
     417    alias typeof(&CreateFontIndirectW) CreateFontIndirectWProc; 
     418    alias typeof(&GetObjectW) GetObjectWProc; 
    371419} 
    372420 
     
    374422private void getProcErr(char[] procName) 
    375423{ 
    376     throw new Exception("Unable to load procedure " ~ procName ~ "."); 
     424    char[] errdesc; 
     425    version(DFL_NO_PROC_ERROR_INFO) 
     426    { 
     427    } 
     428    else 
     429    { 
     430        auto le = cast(int)GetLastError(); 
     431        if(le) 
     432            errdesc = " (error " ~ intToString(le) ~ ")"; 
     433    } 
     434    throw new Exception("Unable to load procedure " ~ procName ~ errdesc); 
    377435} 
    378436 
     
    19812039} 
    19822040 
     2041 
     2042struct LogFont 
     2043{ 
     2044    union 
     2045    { 
     2046        LOGFONTW lfw; 
     2047        LOGFONTA lfa; 
     2048    } 
     2049    alias lfw lf; 
     2050     
     2051    char[] faceName; 
     2052} 
     2053 
     2054 
     2055HFONT createFontIndirect(inout LogFont lf) 
     2056{ 
     2057    if(useUnicode) 
     2058    { 
     2059        version(STATIC_UNICODE) 
     2060        { 
     2061            alias CreateFontIndirectW proc; 
     2062        } 
     2063        else 
     2064        { 
     2065            const char[] NAME = "CreateFontIndirectW"; 
     2066            static CreateFontIndirectWProc proc = null; 
     2067             
     2068            if(!proc) 
     2069            { 
     2070                proc = cast(CreateFontIndirectWProc)GetProcAddress(gdi32, NAME.ptr); 
     2071                if(!proc) 
     2072                    getProcErr(NAME); 
     2073            } 
     2074        } 
     2075         
     2076        wchar[] ws = toUnicode(lf.faceName); 
     2077        if(ws.length >= LF_FACESIZE) 
     2078            ws = ws[0 .. LF_FACESIZE - 1]; // ? 
     2079        foreach(idx, wch; ws) 
     2080        { 
     2081            lf.lfw.lfFaceName[idx] = wch; 
     2082        } 
     2083        lf.lfw.lfFaceName[ws.length] = 0; 
     2084         
     2085        return proc(&lf.lfw); 
     2086    } 
     2087    else 
     2088    { 
     2089        char[] as = toAnsi(lf.faceName); 
     2090        if(as.length >= LF_FACESIZE) 
     2091            as = as[0 .. LF_FACESIZE - 1]; // ? 
     2092        foreach(idx, ach; as) 
     2093        { 
     2094            lf.lfa.lfFaceName[idx] = ach; 
     2095        } 
     2096        lf.lfa.lfFaceName[as.length] = 0; 
     2097         
     2098        return CreateFontIndirectA(&lf.lfa); 
     2099    } 
     2100} 
     2101 
     2102 
     2103// GetObject for a LogFont. 
     2104int getLogFont(HFONT hf, inout LogFont lf) 
     2105{ 
     2106    if(useUnicode) 
     2107    { 
     2108        version(STATIC_UNICODE) 
     2109        { 
     2110            alias GetObjectW proc; 
     2111        } 
     2112        else 
     2113        { 
     2114            const char[] NAME = "GetObjectW"; 
     2115            static GetObjectWProc proc = null; 
     2116             
     2117            if(!proc) 
     2118            { 
     2119                proc = cast(GetObjectWProc)GetProcAddress(gdi32, NAME.ptr); 
     2120                if(!proc) 
     2121                    getProcErr(NAME); 
     2122            } 
     2123        } 
     2124         
     2125        if(LOGFONTW.sizeof != proc(hf, LOGFONTW.sizeof, &lf.lfw)) 
     2126            return 0; 
     2127        lf.faceName = fromUnicodez(lf.lfw.lfFaceName.ptr); 
     2128        return LOGFONTW.sizeof; 
     2129    } 
     2130    else 
     2131    { 
     2132        if(LOGFONTA.sizeof != GetObjectA(hf, LOGFONTA.sizeof, &lf.lfa)) 
     2133            return 0; 
     2134        lf.faceName = fromAnsiz(lf.lfa.lfFaceName.ptr); 
     2135        return LOGFONTA.sizeof; 
     2136    } 
     2137} 
     2138 
  • trunk/win32/dfl/internal/winapi.d

    r5 r7  
    11691169        LVN_FIRST = cast(UINT)-100, 
    11701170         
     1171        LVN_ITEMCHANGING = (LVN_FIRST - 0), 
     1172        LVN_ITEMCHANGED = (LVN_FIRST - 1), 
     1173         
     1174        LVN_BEGINLABELEDITA = LVN_FIRST - 5, 
     1175        LVN_BEGINLABELEDITW = LVN_FIRST - 75, 
     1176         
     1177        LVN_ENDLABELEDITA = LVN_FIRST - 6, 
     1178        LVN_ENDLABELEDITW = LVN_FIRST - 76, 
     1179         
    11711180        LVN_COLUMNCLICK = LVN_FIRST - 8, 
    11721181         
     
    14261435        SM_CYSMICON = 50, 
    14271436         
     1437        SM_CYSMCAPTION = 51, 
     1438         
    14281439        SM_CXSIZEFRAME = SM_CXFRAME, 
    14291440        SM_CYSIZEFRAME = SM_CYFRAME, 
     
    19161927     
    19171928     
     1929    struct TVITEMW 
     1930    { 
     1931        UINT mask; 
     1932        HTREEITEM hItem; 
     1933        UINT state; 
     1934        UINT stateMask; 
     1935        LPWSTR pszText; 
     1936        int cchTextMax; 
     1937        int iImage; 
     1938        int iSelectedImage; 
     1939        int cChildren; 
     1940        LPARAM lParam; 
     1941    } 
     1942    alias TVITEMW* LPTVITEMW; 
     1943    alias TVITEMW* PTVITEMW; 
     1944    alias TVITEMW TV_ITEMW; 
     1945    alias TVITEMW* LPTV_ITEMW; 
     1946    alias TVITEMW* PTV_ITEMW; 
     1947     
     1948     
    19181949    struct TVHITTESTINFO 
    19191950    { 
     
    19571988    alias NMTVDISPINFOA TV_DISPINFOA; 
    19581989    alias NMTVDISPINFOA* LPTV_DISPINFOA; 
     1990     
     1991     
     1992    struct NMTVDISPINFOW 
     1993    { 
     1994        NMHDR hdr; 
     1995        TVITEMW item; 
     1996    } 
     1997    alias NMTVDISPINFOW* LPNMTVDISPINFOW; 
     1998    alias NMTVDISPINFOW TV_DISPINFOW; 
     1999    alias NMTVDISPINFOW* LPTV_DISPINFOW; 
    19592000     
    19602001     
     
    27062747    int SetScrollInfo(HWND hwnd, int fnBar, LPSCROLLINFO lpsi, BOOL fRedraw); 
    27072748    BOOL GetScrollInfo(HWND hwnd, int fnBar, LPSCROLLINFO lpsi); 
     2749    BOOL DragDetect(HWND hwnd, POINT pt); 
     2750    HFONT CreateFontIndirectW(LOGFONTW *lplf); 
     2751    DWORD GetThemeAppProperties(); 
     2752    BOOL IsAppThemed(); 
    27082753 
    27092754//} // Temporary. 
  • trunk/win32/dfl/label.d

    r5 r7  
    350350        { 
    351351            case WM_GETDLGCODE: 
    352                 //m.result = 0
     352                super.wndProc(m)
    353353                //if(useMnemonic) 
    354                     m.result = DLGC_STATIC; 
     354                    m.result |= DLGC_STATIC; 
    355355                break; 
    356356             
  • trunk/win32/dfl/listbox.d

    r5 r7  
    203203         
    204204         
    205         this(ListBox lb) 
     205        protected this(ListBox lb) 
    206206        { 
    207207            lbox = lb; 
     
    361361         
    362362         
    363         this(ListBox lb) 
     363        protected this(ListBox lb) 
    364364        { 
    365365            lbox = lb; 
     
    999999    static class ObjectCollection 
    10001000    { 
    1001         this(ListBox lbox) 
     1001        protected this(ListBox lbox) 
    10021002        { 
    10031003            this.lbox = lbox; 
     
    10051005         
    10061006         
    1007         this(ListBox lbox, Object[] range) 
     1007        protected this(ListBox lbox, Object[] range) 
    10081008        { 
    10091009            this.lbox = lbox; 
     
    10121012         
    10131013         
    1014         this(ListBox lbox, char[][] range) 
     1014        protected this(ListBox lbox, char[][] range) 
    10151015        { 
    10161016            this.lbox = lbox; 
     
    10201020         
    10211021        /+ 
    1022         this(ListBox lbox, ObjectCollection range) 
     1022        protected this(ListBox lbox, ObjectCollection range) 
    10231023        { 
    10241024            this.lbox = lbox; 
  • trunk/win32/dfl/listview.d

    r5 r7  
    180180    static class ListViewSubItemCollection 
    181181    { 
    182         this(ListViewItem owner) 
     182        protected this(ListViewItem owner) 
    183183        in 
    184184        { 
     
    536536 
    537537/// 
     538class LabelEditEventArgs: EventArgs 
     539{ 
     540    /// 
     541    this(ListViewItem item, char[] label) 
     542    { 
     543        _item = item; 
     544        _label = label; 
     545    } 
     546     
     547    /// ditto 
     548    this(ListViewItem node) 
     549    { 
     550        _item = item; 
     551    } 
     552     
     553     
     554    /// 
     555    final ListViewItem item() // getter 
     556    { 
     557        return _item; 
     558    } 
     559     
     560     
     561    /// 
     562    final char[] label() // getter 
     563    { 
     564        return _label; 
     565    } 
     566     
     567     
     568    /// 
     569    final void cancelEdit(bool byes) // setter 
     570    { 
     571        _cancel = byes; 
     572    } 
     573     
     574    /// ditto 
     575    final bool cancelEdit() // getter 
     576    { 
     577        return _cancel; 
     578    } 
     579     
     580     
     581    private: 
     582    ListViewItem _item; 
     583    char[] _label; 
     584    bool _cancel = false; 
     585} 
     586 
     587 
     588alias Event!(LabelEditEventArgs) LabelEditEventHandler; // deprecated 
     589 
     590 
     591/+ 
     592class ItemCheckEventArgs: EventArgs 
     593{ 
     594    this(int index, CheckState newCheckState, CheckState oldCheckState) 
     595    { 
     596        this._idx = index; 
     597        this._ncs = newCheckState; 
     598        this._ocs = oldCheckState; 
     599    } 
     600     
     601     
     602    final CheckState currentValue() // getter 
     603    { 
     604        return _ocs; 
     605    } 
     606     
     607     
     608    /+ 
     609    final void newValue(CheckState cs) // setter 
     610    { 
     611        _ncs = cs; 
     612    } 
     613    +/ 
     614     
     615     
     616    final CheckState newValue() // getter 
     617    { 
     618        return _ncs; 
     619    } 
     620     
     621     
     622    private: 
     623    int _idx; 
     624    CheckState _ncs, _ocs; 
     625} 
     626+/ 
     627 
     628 
     629class ItemCheckedEventArgs: EventArgs 
     630{ 
     631    this(ListViewItem item) 
     632    { 
     633        this._item = item; 
     634    } 
     635     
     636     
     637    final ListViewItem item() // getter 
     638    { 
     639        return this._item; 
     640    } 
     641     
     642     
     643    private: 
     644    ListViewItem _item; 
     645} 
     646 
     647 
     648/// 
    538649class ListView: ControlSuperClass // docmain 
    539650{ 
     
    541652    static class ListViewItemCollection 
    542653    { 
    543         this(ListView lv) 
     654        protected this(ListView lv) 
    544655        in 
    545656        { 
     
    715826    static class ColumnHeaderCollection 
    716827    { 
    717         this(ListView owner) 
     828        protected this(ListView owner) 
    718829        in 
    719830        { 
     
    877988         
    878989         
    879         this(ListView lv) 
     990        protected this(ListView lv) 
    880991        { 
    881992            lview = lv; 
     
    9661077         
    9671078         
    968         this(ListView lv) 
     1079        protected this(ListView lv) 
    9691080        { 
    9701081            lview = lv; 
     
    10521163         
    10531164         
    1054         this(ListView lv) 
     1165        protected this(ListView lv) 
    10551166        { 
    10561167            lview = lv; 
     
    13921503    // Simple as addRow("item", "sub item1", "sub item2", "etc"); 
    13931504    // rowstrings[0] is the item and rowstrings[1 .. rowstrings.length] are its sub items. 
    1394     final void addRow(char[][] rowstrings ...) 
     1505    //final void addRow(char[][] rowstrings ...) 
     1506    final ListViewItem addRow(char[][] rowstrings ...) 
    13951507    { 
    13961508        if(rowstrings.length) 
     
    14011513                item.subItems.addRange(rowstrings[1 .. rowstrings.length]); 
    14021514            items.add(item); 
    1403         } 
     1515            return item; 
     1516        } 
     1517        assert(0); 
     1518        return null; 
    14041519    } 
    14051520     
     
    17941909     
    17951910     
    1796     Event!(ListView, ColumnClickEventArgs) columnClick; 
    1797      
    1798      
    1799     protected void onColumnClick(ColumnClickEventArgs ea) 
    1800     { 
    1801         columnClick(this, ea); 
    1802     } 
    1803      
    1804      
    18051911    // TODO: 
    1806     //LabelEditEventHandler afterLabelEdit; 
    1807     //LabelEditEventHandler beforeLabelEdit; 
    1808     //  itemActivate, itemCheck, itemDrag 
     1912    //  itemActivate, itemDrag 
    18091913    //EventHandler selectedIndexChanged; 
    18101914    //CancelEventHandler selectedIndexChanging; // ? 
     1915     
     1916    Event!(ListView, ColumnClickEventArgs) columnClick; /// 
     1917    Event!(ListView, LabelEditEventArgs) afterLabelEdit; /// 
     1918    Event!(ListView, LabelEditEventArgs) beforeLabelEdit; /// 
     1919    //Event!(ListView, ItemCheckEventArgs) itemCheck; /// 
     1920    Event!(ListView, ItemCheckedEventArgs) itemChecked; /// 
     1921     
     1922     
     1923    protected void onColumnClick(ColumnClickEventArgs ea) 
     1924    { 
     1925        columnClick(this, ea); 
     1926    } 
     1927     
     1928     
     1929    /// 
     1930    protected void onAfterLabelEdit(LabelEditEventArgs ea) 
     1931    { 
     1932        afterLabelEdit(this, ea); 
     1933    } 
     1934     
     1935     
     1936    /// 
     1937    protected void onBeforeLabelEdit(LabelEditEventArgs ea) 
     1938    { 
     1939        beforeLabelEdit(this, ea); 
     1940    } 
     1941     
     1942     
     1943    /+ 
     1944    protected void onItemCheck(ItemCheckEventArgs ea) 
     1945    { 
     1946        itemCheck(this, ea); 
     1947    } 
     1948    +/ 
     1949     
     1950     
     1951    protected void onItemChecked(ItemCheckedEventArgs ea) 
     1952    { 
     1953        itemChecked(this, ea); 
     1954    } 
    18111955     
    18121956     
     
    19862130                    { 
    19872131                        case LVN_GETDISPINFOA: 
     2132                            if(dfl.internal.utf.useUnicode) 
     2133                                break; 
    19882134                            { 
    19892135                                LV_DISPINFOA* lvdi; 
     
    20302176                            break; 
    20312177                         
     2178                        /+ 
     2179                        case LVN_ITEMCHANGING: 
     2180                            { 
     2181                                auto nmlv = cast(NM_LISTVIEW*)nmh; 
     2182                                if(-1 != nmlv.iItem) 
     2183                                { 
     2184                                    UINT stchg = nmlv.uNewState ^ nmlv.uOldState; 
     2185                                    if(stchg & (3 << 12)) 
     2186                                    { 
     2187                                        // Note: not tested. 
     2188                                        scope ItemCheckEventArgs ea = new ItemCheckEventArgs(nmlv.iItem, 
     2189                                            (((nmlv.uNewState >> 12) & 3) - 1) ? CheckState.CHECKED : CheckState.UNCHECKED, 
     2190                                            (((nmlv.uOldState >> 12) & 3) - 1) ? CheckState.CHECKED : CheckState.UNCHECKED); 
     2191                                        onItemCheck(ea); 
     2192                                    } 
     2193                                } 
     2194                            } 
     2195                            break; 
     2196                        +/ 
     2197                         
     2198                        case LVN_ITEMCHANGED: 
     2199                            { 
     2200                                auto nmlv = cast(NM_LISTVIEW*)nmh; 
     2201                                if(-1 != nmlv.iItem) 
     2202                                { 
     2203                                    UINT stchg = nmlv.uNewState ^ nmlv.uOldState; 
     2204                                    if(stchg & (3 << 12)) 
     2205                                    { 
     2206                                        scope ItemCheckedEventArgs ea = new ItemCheckedEventArgs(items[nmlv.iItem]); 
     2207                                        onItemChecked(ea); 
     2208                                    } 
     2209                                } 
     2210                            } 
     2211                            break; 
     2212                         
    20322213                        case LVN_COLUMNCLICK: 
    20332214                            { 
     
    20352216                                scope ccea = new ColumnClickEventArgs(nmlv.iSubItem); 
    20362217                                onColumnClick(ccea); 
     2218                            } 
     2219                            break; 
     2220                         
     2221                        case LVN_BEGINLABELEDITW: 
     2222                            goto begin_label_edit; 
     2223                         
     2224                        case LVN_BEGINLABELEDITA: 
     2225                            if(dfl.internal.utf.useUnicode) 
     2226                                break; 
     2227                            begin_label_edit: 
     2228                             
     2229                            { 
     2230                                LV_DISPINFOA* nmdi; 
     2231                                nmdi = cast(LV_DISPINFOA*)nmh; 
     2232                                if(nmdi.item.iSubItem) 
     2233                                { 
     2234                                    m.result = TRUE; 
     2235                                    break; 
     2236                                } 
     2237                                ListViewItem lvitem; 
     2238                                lvitem = cast(ListViewItem)cast(void*)nmdi.item.lParam; 
     2239                                scope LabelEditEventArgs leea = new LabelEditEventArgs(lvitem); 
     2240                                onBeforeLabelEdit(leea); 
     2241                                m.result = leea.cancelEdit; 
     2242                            } 
     2243                            break; 
     2244                         
     2245                        case LVN_ENDLABELEDITW: 
     2246                            { 
     2247                                char[] label; 
     2248                                LV_DISPINFOW* nmdi; 
     2249                                nmdi = cast(LV_DISPINFOW*)nmh; 
     2250                                if(nmdi.item.pszText) 
     2251                                { 
     2252                                    ListViewItem lvitem; 
     2253                                    lvitem = cast(ListViewItem)cast(void*)nmdi.item.lParam; 
     2254                                    if(nmdi.item.iSubItem) 
     2255                                    { 
     2256                                        m.result = FALSE; 
     2257                                        break; 
     2258                                    } 
     2259                                    label = fromUnicodez(nmdi.item.pszText); 
     2260                                    scope LabelEditEventArgs nleea = new LabelEditEventArgs(lvitem, label); 
     2261                                    onAfterLabelEdit(nleea); 
     2262                                    if(nleea.cancelEdit) 
     2263                                    { 
     2264                                        m.result = FALSE; 
     2265                                    } 
     2266                                    else 
     2267                                    { 
     2268                                        // TODO: check if correct implementation. 
     2269                                        // Update the lvitem's cached text.. 
     2270                                        lvitem.settextin(label); 
     2271                                         
     2272                                        m.result = TRUE; 
     2273                                    } 
     2274                                } 
     2275                            } 
     2276                            break; 
     2277                         
     2278                        case LVN_ENDLABELEDITA: 
     2279                            if(dfl.internal.utf.useUnicode) 
     2280                                break; 
     2281                            { 
     2282                                char[] label; 
     2283                                LV_DISPINFOA* nmdi; 
     2284                                nmdi = cast(LV_DISPINFOA*)nmh; 
     2285                                if(nmdi.item.pszText) 
     2286                                { 
     2287                                    ListViewItem lvitem; 
     2288                                    lvitem = cast(ListViewItem)cast(void*)nmdi.item.lParam; 
     2289                                    if(nmdi.item.iSubItem) 
     2290                                    { 
     2291                                        m.result = FALSE; 
     2292                                        break; 
     2293                                    } 
     2294                                    label = fromAnsiz(nmdi.item.pszText); 
     2295                                    scope LabelEditEventArgs nleea = new LabelEditEventArgs(lvitem, label); 
     2296                                    onAfterLabelEdit(nleea); 
     2297                                    if(nleea.cancelEdit) 
     2298                                    { 
     2299                                        m.result = FALSE; 
     2300                                    } 
     2301                                    else 
     2302                                    { 
     2303                                        // TODO: check if correct implementation. 
     2304                                        // Update the lvitem's cached text.. 
     2305                                        lvitem.settextin(label); 
     2306                                         
     2307                                        m.result = TRUE; 
     2308                                    } 
     2309                                } 
    20372310                            } 
    20382311                            break; 
  • trunk/win32/dfl/makelib.bat

    r5 r7  
    2020:dmc_set 
    2121 
     22if exist "%dmc_path%" goto got_dmc 
     23@echo DMC not found; using DMD path (if you get errors, install DMC) 
     24set dmc_path=%dmd_path% 
     25:got_dmc 
    2226 
    23 set dfl_files=base.d application.d internal/dlib.d internal/clib.d internal/utf.d internal/com.d control.d form.d registry.d drawing.d menu.d notifyicon.d commondialog.d filedialog.d folderdialog.d panel.d textbox.d richtextbox.d picturebox.d listbox.d groupbox.d splitter.d usercontrol.d button.d label.d collections.d internal/winapi.d internal/wincom.d event.d socket.d timer.d environment.d messagebox.d tooltip.d combobox.d treeview.d tabcontrol.d colordialog.d listview.d data.d clipboard.d fontdialog.d progressbar.d resources.d statusbar.d 
    2427 
    25 set dfl_objs=base.obj application.obj dlib.obj clib.obj utf.obj com.obj control.obj form.obj registry.obj drawing.obj menu.obj notifyicon.obj commondialog.obj filedialog.obj folderdialog.obj panel.obj textbox.obj richtextbox.obj picturebox.obj listbox.obj groupbox.obj splitter.obj usercontrol.obj button.obj label.obj collections.obj winapi.obj wincom.obj event.obj socket.obj timer.obj environment.obj messagebox.obj tooltip.obj combobox.obj treeview.obj tabcontrol.obj colordialog.obj listview.obj data.obj clipboard.obj fontdialog.obj progressbar.obj resources.obj statusbar.obj 
     28if not "%dlib%" == "Tango" goto dfl_not_tango_files 
     29set _stdcwindowsd=internal/_stdcwindows.d 
     30set _stdcwindowsobj=_stdcwindows.obj 
     31:dfl_not_tango_files 
     32 
     33set dfl_files=base.d application.d internal/dlib.d internal/clib.d internal/utf.d internal/com.d control.d form.d registry.d drawing.d menu.d notifyicon.d commondialog.d filedialog.d folderdialog.d panel.d textbox.d richtextbox.d picturebox.d listbox.d groupbox.d splitter.d usercontrol.d button.d label.d collections.d internal/winapi.d internal/wincom.d event.d socket.d timer.d environment.d messagebox.d tooltip.d combobox.d treeview.d tabcontrol.d colordialog.d listview.d data.d clipboard.d fontdialog.d progressbar.d resources.d statusbar.d %_stdcwindowsd% 
     34 
     35set dfl_objs=base.obj application.obj dlib.obj clib.obj utf.obj com.obj control.obj form.obj registry.obj drawing.obj menu.obj notifyicon.obj commondialog.obj filedialog.obj folderdialog.obj panel.obj textbox.obj richtextbox.obj picturebox.obj listbox.obj groupbox.obj splitter.obj usercontrol.obj button.obj label.obj collections.obj winapi.obj wincom.obj event.obj socket.obj timer.obj environment.obj messagebox.obj tooltip.obj combobox.obj treeview.obj tabcontrol.obj colordialog.obj listview.obj data.obj clipboard.obj fontdialog.obj progressbar.obj resources.obj statusbar.obj %_stdcwindowsobj% 
    2636 
    2737@rem   Also update link pragmas for build. 
     
    3343@rem set dfl_flags=%dfl_flags% -debug=SHOW_MESSAGENFO 
    3444set _dfl_flags=%dfl_flags% -v1  
     45 
     46if not "%dfl_debug_flags%" == "" goto dfl_debug_flags_set 
     47set dfl_debug_flags=-debug -g 
     48:dfl_debug_flags_set 
     49if not "%dfl_release_flags%" == "" goto dfl_release_flags_set 
     50    if not "%dlib%" == "Tango" goto dfl_not_release_tango 
     51    echo Due to a bug in DMD, release mode dfl lib will not include -inline; set environment variable dfl_release_flags to override. 
     52    set dfl_release_flags=-O -release 
     53    goto dfl_release_flags_set 
     54    :dfl_not_release_tango 
     55set dfl_release_flags=-O -inline -release 
     56:dfl_release_flags_set 
    3557 
    3658 
     
    6991@echo Compiling debug DFL... 
    7092 
    71 %dmd_path%\bin\dmd -c -debug -g -I.. %_dfl_flags% %dfl_files% 
     93%dmd_path%\bin\dmd -c %dfl_debug_flags% %_dfl_flags% -I.. %dfl_files% 
    7294@if errorlevel 1 goto oops 
    7395 
     
    82104@echo Compiling release DFL... 
    83105 
    84 %dmd_path%\bin\dmd -c -O -inline -release -I.. %_dfl_flags% %dfl_files% 
     106%dmd_path%\bin\dmd -c %dfl_release_flags% %_dfl_flags% -I.. %dfl_files% 
    85107@if errorlevel 1 goto oops 
    86108 
     
    99121 
    100122@rem   This file is used by dfl.exe 
    101 @%dmd_path%\bin\dmd > dflcompile.info 
     123@echo dlib=%dlib%>dflcompile.info 
     124@%dmd_path%\bin\dmd>>dflcompile.info 
    102125 
    103126 
  • trunk/win32/dfl/menu.d

    r5 r7  
    9999                    fType = ~MFT_SEPARATOR; 
    100100                mii.cbSize = mii.sizeof; 
    101                 mii.fMask = MIIM_TYPE; 
     101                mii.fMask = MIIM_TYPE | MIIM_STATE; // Not setting the state can cause implicit disabled/gray if the text was empty. 
    102102                mii.fType = fType; 
     103                mii.fState = fState; 
    103104                //mii.dwTypeData = stringToStringz(txt); 
    104105                 
     
    677678    UINT _state() // getter 
    678679    { 
    679         // if(mparent) fetch value ? 
     680        // if(mparent) fetch value ? No: Windows seems to add disabled/gray when the text is empty. 
    680681        return fState; 
    681682    } 
     
    695696        else 
    696697        { 
    697             _compat092 = true; 
     698            //_compat092 = true; 
     699            Application.setCompat(DflCompat.MENU_092); 
    698700        } 
    699701    } 
    700702     
    701703    version(SET_DFL_092) 
    702     { 
    703704        private const bool _compat092 = true; 
    704     } 
     705    else version(DFL_NO_COMPAT) 
     706        private const bool _compat092 = false; 
    705707    else 
    706     { 
    707         private static bool _compat092 = false; 
    708     } 
     708        private static bool _compat092() // getter 
     709            { return 0 != (Application._compat & DflCompat.MENU_092); } 
    709710     
    710711     
     
    712713    static class MenuItemCollection 
    713714    { 
    714         this(Menu owner) 
     715        protected this(Menu owner) 
    715716        { 
    716717            _owner = owner; 
     
    857858     
    858859    // Menu item that isn't popup (yet). 
    859     private this() 
     860    protected this() 
    860861    { 
    861862        _init(); 
  • trunk/win32/dfl/progressbar.d

    r5 r7  
    168168        super.onHandleCreated(ea); 
    169169         
    170         if(_min != _min.init || _max != _max.init
     170        if(_min != MIN_INIT || _max != MAX_INIT
    171171        { 
    172172            prevwproc(PBM_SETRANGE, 0, MAKELPARAM(_min, _max)); 
    173173        } 
    174174         
    175         if(_step != _step.init
     175        if(_step != STEP_INIT
    176176        { 
    177177            prevwproc(PBM_SETSTEP, _step, 0); 
    178178        } 
    179179         
    180         if(_val != _val.init
     180        if(_val != VAL_INIT
    181181        { 
    182182            prevwproc(PBM_SETPOS, _val, 0); 
     
    214214    private: 
    215215     
    216     int _min = 0, _max = 100, _step = 10, _val = 0; 
     216    const int MIN_INIT = 0; 
     217    const int MAX_INIT = 100; 
     218    const int STEP_INIT = 10; 
     219    const int VAL_INIT = 0; 
     220     
     221    int _min = MIN_INIT, _max = MAX_INIT, _step = STEP_INIT, _val = VAL_INIT; 
    217222     
    218223     
  • trunk/win32/dfl/registry.d

    r5 r7  
    1111 
    1212private import dfl.internal.winapi, dfl.base, dfl.internal.utf; 
     13 
     14 
     15class DflRegistryException: DflException // package 
     16{ 
     17    this(char[] msg, int errorCode = 0) 
     18    { 
     19        this.errorCode = errorCode; 
     20        debug 
     21        { 
     22            if(errorCode) 
     23                msg = msg ~ " (error " ~ intToString(errorCode) ~ ")"; // Dup. 
     24        } 
     25        super(msg); 
     26    } 
     27     
     28     
     29    int errorCode; 
     30} 
    1331 
    1432 
     
    256274        { 
    257275            if(!s.length) 
    258                 throw new DflException("Empty strings are not allowed in multi_sz registry values"); 
     276                throw new DflRegistryException("Empty strings are not allowed in multi_sz registry values"); 
    259277             
    260278            multi[i .. i + s.length] = s; 
     
    638656        DWORD count; 
    639657         
    640         if(ERROR_SUCCESS != RegQueryInfoKeyA(hkey, null, null, null, &count, 
    641             null, null, null, null, null, null, null)) 
    642             infoErr(); 
     658        LONG rr = RegQueryInfoKeyA(hkey, null, null, null, &count, 
     659            null, null, null, null, null, null, null); 
     660        if(ERROR_SUCCESS != rr) 
     661            infoErr(rr); 
    643662         
    644663        return count; 
     
    651670        DWORD count; 
    652671         
    653         if(ERROR_SUCCESS != RegQueryInfoKeyA(hkey, null, null, null, null, 
    654             null, null, &count, null, null, null, null)) 
    655             infoErr(); 
     672        LONG rr = RegQueryInfoKeyA(hkey, null, null, null, null, 
     673            null, null, &count, null, null, null, null); 
     674        if(ERROR_SUCCESS != rr) 
     675            infoErr(rr); 
    656676         
    657677        return count; 
     
    673693        DWORD cdisp; 
    674694         
    675         if(ERROR_SUCCESS != RegCreateKeyExA(hkey, unsafeStringz(name), 0, null, 0, KEY_ALL_ACCESS, null, &newHkey, &cdisp)) 
    676             throw new DflException("Unable to create registry key"); 
     695        LONG rr = RegCreateKeyExA(hkey, unsafeStringz(name), 0, null, 0, KEY_ALL_ACCESS, null, &newHkey, &cdisp); 
     696        if(ERROR_SUCCESS != rr) 
     697            throw new DflRegistryException("Unable to create registry key", rr); 
    677698         
    678699        return new RegistryKey(newHkey); 
     
    683704    final void deleteSubKey(char[] name, bool throwIfMissing) 
    684705    { 
    685         LONG opencode; 
    686706        HKEY openHkey; 
    687707        char* namez; 
    688708         
    689709        if(!name.length || !name[0]) 
    690         { 
    691             unable: 
    692             throw new DflException("Unable to delete subkey"); 
    693         } 
     710            throw new DflRegistryException("Unable to delete subkey"); 
    694711         
    695712        namez = unsafeStringz(name); 
    696713         
    697         opencode = RegOpenKeyExA(hkey, namez, 0, KEY_ALL_ACCESS, &openHkey); 
     714        LONG opencode = RegOpenKeyExA(hkey, namez, 0, KEY_ALL_ACCESS, &openHkey); 
    698715        if(ERROR_SUCCESS == opencode) 
    699716        { 
    700717            DWORD count; 
    701718             
    702             if(ERROR_SUCCESS == RegQueryInfoKeyA(openHkey, null, null, null, &count, 
    703                 null, null, null, null, null, null, null)) 
     719            LONG querycode = RegQueryInfoKeyA(openHkey, null, null, null, &count, 
     720                null, null, null, null, null, null, null); 
     721            if(ERROR_SUCCESS == querycode) 
    704722            { 
    705723                RegCloseKey(openHkey); 
    706724                 
     725                LONG delcode; 
    707726                if(!count) 
    708727                { 
    709                     if(ERROR_SUCCESS == RegDeleteKeyA(hkey, namez)) 
     728                    delcode = RegDeleteKeyA(hkey, namez); 
     729                    if(ERROR_SUCCESS == delcode) 
    710730                        return; // OK. 
    711731                     
    712                     goto unable
     732                    throw new DflRegistryException("Unable to delete subkey", delcode)
    713733                } 
    714734                 
    715                 throw new DflException("Cannot delete registry key with subkeys"); 
     735                throw new DflRegistryException("Cannot delete registry key with subkeys"); 
    716736            } 
    717737             
    718738            RegCloseKey(openHkey); 
     739             
     740            throw new DflRegistryException("Unable to delete registry key", querycode); 
    719741        } 
    720742        else 
     
    730752                } 
    731753            } 
    732         } 
    733          
    734         throw new DflException("Unable to delete registry key"); 
     754            
     755           throw new DflRegistryException("Unable to delete registry key", opencode); 
     756        } 
    735757    } 
    736758     
     
    758780        if(ERROR_SUCCESS == RegOpenKeyExA(shkey, namez, 0, KEY_ALL_ACCESS, &openHkey)) 
    759781        { 
    760             void ouch(
     782            void ouch(LONG why = 0
    761783            { 
    762                 throw new DflException("Unable to delete entire subkey tree"); 
     784                throw new DflRegistryException("Unable to delete entire subkey tree", why); 
    763785            } 
    764786             
     
    766788            DWORD count; 
    767789             
    768             if(ERROR_SUCCESS == RegQueryInfoKeyA(openHkey, null, null, null, &count, 
    769                 null, null, null, null, null, null, null)) 
     790            LONG querycode = RegQueryInfoKeyA(openHkey, null, null, null, &count, 
     791                null, null, null, null, null, null, null); 
     792            if(ERROR_SUCCESS == querycode) 
    770793            { 
    771794                if(!count) 
     
    773796                    del_me: 
    774797                    RegCloseKey(openHkey); 
    775                     if(ERROR_SUCCESS == RegDeleteKeyA(shkey, namez)) 
     798                    LONG delcode = RegDeleteKeyA(shkey, namez); 
     799                    if(ERROR_SUCCESS == delcode) 
    776800                        return; // OK. 
    777801                     
    778                     //throw new DflException("Unable to delete subkey"); 
    779                     ouch(); 
     802                    ouch(delcode); 
    780803                } 
    781804                else 
     
    790813                        next_subkey: 
    791814                        len = skn.length; 
    792                         switch(RegEnumKeyExA(openHkey, 0, skn.ptr, &len, null, null, null, null)) 
     815                        LONG enumcode = RegEnumKeyExA(openHkey, 0, skn.ptr, &len, null, null, null, null); 
     816                        switch(enumcode) 
    793817                        { 
    794818                            case ERROR_SUCCESS: 
     
    801825                             
    802826                            default: 
    803                                 ouch(); 
     827                                ouch(enumcode); 
    804828                        } 
    805829                         
     
    815839            else 
    816840            { 
    817                 ouch(); 
     841                ouch(querycode); 
    818842            } 
    819843        } 
     
    824848    final void deleteValue(char[] name, bool throwIfMissing) 
    825849    { 
    826         switch(RegDeleteValueA(hkey, unsafeStringz(name))) 
     850        LONG rr = RegDeleteValueA(hkey, unsafeStringz(name)); 
     851        switch(rr) 
    827852        { 
    828853            case ERROR_SUCCESS: 
     
    833858                    break; 
    834859            default: 
    835                 throw new DflException("Unable to delete registry value"); 
     860                throw new DflRegistryException("Unable to delete registry value", rr); 
    836861        } 
    837862    } 
     
    880905        { 
    881906            len = buf.length; 
    882             switch(RegEnumKeyExA(hkey, idx, buf.ptr, &len, null, null, null, null)) 
     907            LONG rr = RegEnumKeyExA(hkey, idx, buf.ptr, &len, null, null, null, null); 
     908            switch(rr) 
    883909            { 
    884910                case ERROR_SUCCESS: 
     
    891917                 
    892918                default: 
    893                     throw new DflException("Unable to obtain subkey names"); 
     919                    throw new DflRegistryException("Unable to obtain subkey names", rr); 
    894920            } 
    895921        } 
     
    907933         
    908934        len = 0; 
    909         switch(RegQueryValueExA(hkey, unsafeStringz(name), null, &type, null, &len)) 
     935        LONG querycode = RegQueryValueExA(hkey, unsafeStringz(name), null, &type, null, &len); 
     936        switch(querycode) 
    910937        { 
    911938            case ERROR_SUCCESS: 
     
    917944                return defaultValue; 
    918945             
    919             default: err
    920                 throw new DflException("Unable to get registry value"); 
     946            default: errquerycode
     947                throw new DflRegistryException("Unable to get registry value", querycode); 
    921948        } 
    922949         
    923950        data = new ubyte[len]; 
    924         if(ERROR_SUCCESS != RegQueryValueExA(hkey, unsafeStringz(name), null, &type, data.ptr, &len)) 
    925             goto err; 
     951        // Note: reusing querycode here and above. 
     952        querycode = RegQueryValueExA(hkey, unsafeStringz(name), null, &type, data.ptr, &len); 
     953        if(ERROR_SUCCESS != querycode) 
     954            goto errquerycode; 
    926955         
    927956        switch(type) 
     
    10141043             
    10151044            default: 
    1016                 throw new DflException("Unknown type for registry value"); 
     1045                throw new DflRegistryException("Unknown type for registry value"); 
    10171046        } 
    10181047         
     
    10391068        { 
    10401069            len = buf.length; 
    1041             switch(RegEnumValueA(hkey, idx, buf.ptr, &len, null, null, null, null)) 
     1070            LONG rr = RegEnumValueA(hkey, idx, buf.ptr, &len, null, null, null, null); 
     1071            switch(rr) 
    10421072            { 
    10431073                case ERROR_SUCCESS: 
     
    10501080                 
    10511081                default: 
    1052                     throw new DflException("Unable to obtain value names"); 
     1082                    throw new DflRegistryException("Unable to obtain value names", rr); 
    10531083            } 
    10541084        } 
     
    10631093        HKEY openHkey; 
    10641094         
    1065         if(ERROR_SUCCESS != RegConnectRegistryA(unsafeStringz(machineName), cast(HKEY)hhive, &openHkey)) 
    1066             throw new DflException("Unable to open remote base key"); 
     1095        LONG rr = RegConnectRegistryA(unsafeStringz(machineName), cast(HKEY)hhive, &openHkey); 
     1096        if(ERROR_SUCCESS != rr) 
     1097            throw new DflRegistryException("Unable to open remote base key", rr); 
    10671098         
    10681099        return new RegistryKey(openHkey); 
     
    10931124    final void setValue(char[] name, RegistryValue value) 
    10941125    { 
    1095         if(ERROR_SUCCESS != value.save(hkey, name)) 
    1096             throw new DflException("Unable to set registry value"); 
     1126        LONG rr = value.save(hkey, name); 
     1127        if(ERROR_SUCCESS != rr) 
     1128            throw new DflRegistryException("Unable to set registry value", rr); 
    10971129    } 
    10981130     
     
    11451177     
    11461178     
    1147     void infoErr(
    1148     { 
    1149         throw new DflException("Unable to obtain registry information"); 
    1150     } 
    1151 } 
    1152  
     1179    private void infoErr(LONG why
     1180    { 
     1181        throw new DflRegistryException("Unable to obtain registry information", why); 
     1182    } 
     1183} 
     1184 
  • trunk/win32/dfl/richtextbox.d

    r5 r7  
    502502        if(created) 
    503503        { 
     504            // To-do: support Unicode font names. 
     505             
    504506            CHARFORMAT2A cf; 
    505507            LOGFONTA lf; 
     
    566568                    lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; 
    567569                } 
    568                 return new Font(Font._create(&lf)); 
     570                //return new Font(Font._create(&lf)); 
     571                LogFont _lf; 
     572                Font.LOGFONTAtoLogFont(_lf, &lf); 
     573                return new Font(Font._create(_lf)); 
    569574            } 
    570575        } 
  • trunk/win32/dfl/socket.d

    r5 r7  
    189189     
    190190     
    191     override void close() 
    192     { 
    193         unregisterEvent(this); 
    194         super.close(); 
     191    static if(is(typeof(&this.detach))) 
     192    { 
     193        override void detach() 
     194        { 
     195            unregisterEvent(this); 
     196            super.detach(); 
     197        } 
     198    } 
     199    else 
     200    { 
     201        override void close() 
     202        { 
     203            unregisterEvent(this); 
     204            super.close(); 
     205        } 
    195206    } 
    196207     
  • trunk/win32/dfl/splitter.d

    r5 r7  
    118118     
    119119     
     120    package void initsplit(int sx, int sy) 
     121    { 
     122        capture = true; 
     123         
     124        downing = true; 
     125        //downpos = Point(mea.x, mea.y); 
     126         
     127        switch(dock) 
     128        { 
     129            case DockStyle.TOP: 
     130            case DockStyle.BOTTOM: 
     131                downpos = sy; 
     132                lastpos = 0; 
     133                drawxorClient(0, lastpos); 
     134                break; 
     135             
     136            default: // LEFT / RIGHT. 
     137                downpos = sx; 
     138                lastpos = 0; 
     139                drawxorClient(lastpos, 0); 
     140        } 
     141    } 
     142     
     143     
     144    final void resumeSplit(int sx, int sy) // package 
     145    { 
     146        if(Control.mouseButtons & MouseButtons.LEFT) 
     147        { 
     148            initsplit(sx, sy); 
     149             
     150            if(cursor) 
     151                Cursor.current = cursor; 
     152        } 
     153    } 
     154     
     155    // /// ditto 
     156    final void resumeSplit() // package 
     157    { 
     158        Point pt = pointToClient(Cursor.position); 
     159        return resumeSplit(pt.x, pt.y); 
     160    } 
     161     
     162     
    120163    /// 
    121164    void movingGrip(bool byes) // setter 
     
    149192        if(mgrip) 
    150193        { 
    151             ea.graphics.drawMoveGrip(bounds, DockStyle.LEFT == dock || DockStyle.RIGHT == dock); 
     194            ea.graphics.drawMoveGrip(displayRectangle, DockStyle.LEFT == dock || DockStyle.RIGHT == dock); 
    152195        } 
    153196    } 
     
    156199    protected override void onResize(EventArgs ea) 
    157200    { 
    158         super.onResize(ea); 
    159          
    160201        if(mgrip) 
    161202        { 
    162203            invalidate(); 
    163204        } 
     205         
     206        resize(this, ea); 
    164207    } 
    165208     
     
    171214        if(mea.button == MouseButtons.LEFT) 
    172215        { 
    173             capture = true; 
    174              
    175             downing = true; 
    176             //downpos = Point(mea.x, mea.y); 
    177              
    178             switch(dock) 
    179             { 
    180                 case DockStyle.TOP: 
    181                 case DockStyle.BOTTOM: 
    182                     downpos = mea.y; 
    183                     lastpos = 0; 
    184                     drawxorClient(0, lastpos); 
    185                     break; 
    186                  
    187                 default: // LEFT / RIGHT. 
    188                     downpos = mea.x; 
    189                     lastpos = 0; 
    190                     drawxorClient(lastpos, 0); 
    191             } 
     216            initsplit(mea.x, mea.y); 
    192217        } 
    193218    } 
     
    437462     
    438463    //SplitterEventHandler splitterMoved; 
    439     Event!(Splitter, EventArgs) splitterMoved; /// 
     464    Event!(Splitter, SplitterEventArgs) splitterMoved; /// 
    440465    //SplitterEventHandler splitterMoving; 
    441     Event!(Splitter, EventArgs) splitterMoving; /// 
     466    Event!(Splitter, SplitterEventArgs) splitterMoving; /// 
    442467     
    443468     
     
    446471    override Size defaultSize() // getter 
    447472    { 
    448         return Size(GetSystemMetrics(SM_CXSIZEFRAME), GetSystemMetrics(SM_CYSIZEFRAME)); 
     473        //return Size(GetSystemMetrics(SM_CXSIZEFRAME), GetSystemMetrics(SM_CYSIZEFRAME)); 
     474        int sx = GetSystemMetrics(SM_CXSIZEFRAME); 
     475        int sy = GetSystemMetrics(SM_CYSIZEFRAME); 
     476        // Need a bit extra room for the move-grips. 
     477        if(sx < 5) 
     478            sx = 5; 
     479        if(sy < 5) 
     480            sy = 5; 
     481        return Size(sx, sy); 
    449482    } 
    450483     
     
    453486    void onSplitterMoving(SplitterEventArgs sea) 
    454487    { 
    455          
    456          
    457488        splitterMoving(this, sea); 
    458489    } 
  • trunk/win32/dfl/statusbar.d

    r5 r7  
    146146        } 
    147147         
    148         if(_parent && _parent.created) 
     148        if(_parent && _parent.isHandleCreated) 
    149149        { 
    150150            _parent.panels._fixtexts(); // Also fixes styles. 
     
    199199    final void text(char[] txt) // setter 
    200200    { 
    201         if(_parent && _parent.created) 
     201        if(_parent && _parent.isHandleCreated) 
    202202        { 
    203203            int idx = _parent.panels.indexOf(this); 
     
    236236        _width = w; 
    237237         
    238         if(_parent && _parent.created) 
     238        if(_parent && _parent.isHandleCreated) 
    239239        { 
    240240            _parent.panels._fixwidths(); 
     
    285285    class StatusBarPanelCollection 
    286286    { 
    287         this(StatusBar sb) 
     287        protected this(StatusBar sb) 
    288288        in 
    289289        { 
     
    302302         
    303303         
    304         void _fixwidths() 
    305         { 
    306             assert(created); 
     304        package void _fixwidths() 
     305        { 
     306            assert(isHandleCreated); 
    307307             
    308308            UINT[20] _pws = void; 
     
    320320        void _fixtexts() 
    321321        { 
    322             assert(created); 
     322            assert(isHandleCreated); 
    323323             
    324324            if(dfl.internal.utf.useUnicode) 
     
    341341        void _setcurparts() 
    342342        { 
    343             assert(created); 
     343            assert(isHandleCreated); 
    344344             
    345345            _fixwidths(); 
     
    353353            if(size_t.max == idx) // Clear all. 
    354354            { 
    355                 if(sb.created) 
     355                if(sb.isHandleCreated) 
    356356                { 
    357357                    sb.prevwproc(SB_SETPARTS, 0, 0); // 0 parts. 
     
    360360            else 
    361361            { 
    362                 if(sb.created) 
     362                if(sb.isHandleCreated) 
    363363                { 
    364364                    _setcurparts(); 
     
    373373                throw new DflException("StatusBarPanel already belongs to a StatusBar"); 
    374374             
    375             if(sb.created) 
     375            val._parent = sb; 
     376             
     377            if(sb.isHandleCreated) 
    376378            { 
    377379                _setcurparts(); 
     
    446448            return; 
    447449         
    448         if(created) 
     450        if(isHandleCreated) 
    449451        { 
    450452            prevwproc(SB_SIMPLE, cast(WPARAM)!byes, 0); 
     
    496498    override void text(char[] txt) // setter 
    497499    { 
    498         if(created && !showPanels) 
     500        if(isHandleCreated && !showPanels) 
    499501        { 
    500502            _sendidxtext(255, 0, txt); 
     
    517519        super.onHandleCreated(ea); 
    518520         
    519         panels._setcurparts(); 
    520          
    521         if(_issimple && _simpletext.length) 
    522             _sendidxtext(255, 0, _simpletext); 
    523         prevwproc(SB_SIMPLE, cast(WPARAM)_issimple, 0); 
    524          
    525         panels._setcurparts(); 
     521        if(_issimple) 
     522        { 
     523            prevwproc(SB_SIMPLE, cast(WPARAM)true, 0); 
     524            panels._setcurparts(); 
     525            if(_simpletext.length) 
     526                _sendidxtext(255, 0, _simpletext); 
     527        } 
     528        else 
     529        { 
     530            panels._setcurparts(); 
     531            prevwproc(SB_SIMPLE, cast(WPARAM)false, 0); 
     532        } 
    526533    } 
    527534     
     
    587594    void _sendidxtext(int idx, WPARAM utype, char[] txt) 
    588595    { 
    589         assert(created); 
     596        assert(isHandleCreated); 
    590597         
    591598        if(dfl.internal.utf.useUnicode) 
  • trunk/win32/dfl/tabcontrol.d

    r5 r7  
    168168class TabPageCollection 
    169169{ 
    170     this(TabControl owner) 
     170    protected this(TabControl owner) 
    171171    in 
    172172    { 
  • trunk/win32/dfl/treeview.d

    r5 r7  
    17971797                            { 
    17981798                                case TVE_COLLAPSE: 
    1799                                     onAfterCollapse(new TreeViewEventArgs(cast(TreeNode)cast(void*)nmtv.itemNew.lParam, 
    1800                                         TreeViewAction.COLLAPSE)); 
     1799                                    { 
     1800                                        scope TreeViewEventArgs tvea = new TreeViewEventArgs( 
     1801                                            cast(TreeNode)cast(void*)nmtv.itemNew.lParam, 
     1802                                            TreeViewAction.COLLAPSE); 
     1803                                        onAfterCollapse(tvea); 
     1804                                    } 
    18011805                                    break; 
    18021806                                 
    18031807                                case TVE_EXPAND: 
    1804                                     onAfterExpand(new TreeViewEventArgs(cast(TreeNode)cast(void*)nmtv.itemNew.lParam, 
    1805                                         TreeViewAction.EXPAND)); 
     1808                                    { 
     1809                                        scope TreeViewEventArgs tvea = new TreeViewEventArgs( 
     1810                                            cast(TreeNode)cast(void*)nmtv.itemNew.lParam, 
     1811                                            TreeViewAction.EXPAND); 
     1812                                        onAfterExpand(tvea); 
     1813                                    } 
    18061814                                    break; 
    18071815                                 
     
    18211829                                TV_DISPINFOA* nmdi; 
    18221830                                nmdi = cast(TV_DISPINFOA*)nmh; 
    1823                                 NodeLabelEditEventArgs nleea; 
    18241831                                TreeNode node; 
    18251832                                node = cast(TreeNode)cast(void*)nmdi.item.lParam; 
    1826                                 // The nleea.label should contain the NEW text, which 
    1827                                 // there is no new text before it's edited... ? 
    1828                                 // TODO: check if correct implementation. 
    1829                                 nleea = new NodeLabelEditEventArgs(node /+ , node.text +/); 
     1833                                scope NodeLabelEditEventArgs nleea = new NodeLabelEditEventArgs(node); 
    18301834                                onBeforeLabelEdit(nleea); 
    18311835                                m.result = nleea.cancelEdit; 
     
    18341838                         
    18351839                        case TVN_ENDLABELEDITW: 
    1836                             goto end_label_edit; 
     1840                            { 
     1841                                char[] label; 
     1842                                TV_DISPINFOW* nmdi; 
     1843                                nmdi = cast(TV_DISPINFOW*)nmh; 
     1844                                if(nmdi.item.pszText) 
     1845                                { 
     1846                                    TreeNode node; 
     1847                                    node = cast(TreeNode)cast(void*)nmdi.item.lParam; 
     1848                                    label = fromUnicodez(nmdi.item.pszText); 
     1849                                    scope NodeLabelEditEventArgs nleea = new NodeLabelEditEventArgs(node, label); 
     1850                                    onAfterLabelEdit(nleea); 
     1851                                    if(nleea.cancelEdit) 
     1852                                    { 
     1853                                        m.result = FALSE; 
     1854                                    } 
     1855                                    else 
     1856                                    { 
     1857                                        // TODO: check if correct implementation. 
     1858                                        // Update the node's cached text.. 
     1859                                        node.ttext = label; 
     1860                                         
     1861                                        m.result = TRUE; 
     1862                                    } 
     1863                                } 
     1864                            } 
     1865                            break; 
    18371866                         
    18381867                        case TVN_ENDLABELEDITA: 
    18391868                            if(dfl.internal.utf.useUnicode) 
    18401869                                break; 
    1841                             end_label_edit: 
    1842                              
    18431870                            { 
    18441871                                char[] label; 
    18451872                                TV_DISPINFOA* nmdi; 
    18461873                                nmdi = cast(TV_DISPINFOA*)nmh; 
    1847                                 NodeLabelEditEventArgs nleea; 
    1848                                 TreeNode node; 
    1849                                 // TODO: check if correct implementation. 
    1850                                 node = cast(TreeNode)cast(void*)nmdi.item.lParam; 
    18511874                                if(nmdi.item.pszText) 
    1852                                     label = stringFromStringz(nmdi.item.pszText).dup; 
    1853                                 nleea = new NodeLabelEditEventArgs(node, label); 
    1854                                 if(!nmdi.item.pszText) 
    1855                                     nleea.cancelEdit = true; 
    1856                                 onAfterLabelEdit(nleea); 
    1857                                 if(nleea.cancelEdit) 
    18581875                                { 
    1859                                     m.result = FALSE; 
    1860                                 } 
    1861                                 else 
    1862                                 { 
    1863                                     // TODO: check if correct implementation. 
    1864                                     // Update the node's cached text.. 
    1865                                     node.ttext = label; 
    1866                                      
    1867                                     m.result = TRUE; 
     1876                                    TreeNode node; 
     1877                                    node = cast(TreeNode)cast(void*)nmdi.item.lParam; 
     1878                                    label = fromAnsiz(nmdi.item.pszText); 
     1879                                    scope NodeLabelEditEventArgs nleea = new NodeLabelEditEventArgs(node, label); 
     1880                                    onAfterLabelEdit(nleea); 
     1881                                    if(nleea.cancelEdit) 
     1882                                    { 
     1883                                        m.result = FALSE; 
     1884                                    } 
     1885                                    else 
     1886                                    { 
     1887                                        // TODO: check if correct implementation. 
     1888                                        // Update the node's cached text.. 
     1889                                        node.ttext = label; 
     1890                                         
     1891                                        m.result = TRUE; 
     1892                                    } 
    18681893                                } 
    18691894                            }