Changeset 7

Show
Ignore:
Timestamp:
10/26/07 02:18:22 (11 months 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 &