Changeset 18

Show
Ignore:
Timestamp:
04/07/08 05:48:42 (4 years ago)
Author:
bobef
Message:

Updated HTMLayout wrapper to 0.7 (3.2.2.13)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/examples/behavior/build.bat

    r17 r18  
    22 
    33set HTMLAYOUT_FILES=../../import/htmlayout/capi.d ../../import/htmlayout/events.d ../../import/htmlayout/element.d ../../import/htmlayout/htmlayout.d ../../import/htmlayout/behaviors/translatable.d 
    4 set FLOWERD_FILES=../../import/flowerd/dfl.d ../../import/flowerd/common.d ../../import/flowerd/config.d 
     4set FLOWERD_FILES=../../import/flowerd/dfl.d ../../import/flowerd/common.d ../../import/flowerd/config.d ../../import/flowerd/sharedlib.d 
    55set DFL_STUFF=-version=DFL_import_libs -L/exet:nt/su:windows:4.0 
    66 
  • trunk/examples/behavior/resources/language.kfg

    r17 r18  
    55        2::АМглОйскО 
    66            title::ОбясМеМОе 
    7     header::ДеЌПстрацОя 
     7    header::ДеЌПМстрацОя 
    88en:: 
    99    button:: 
     
    1212        2::English 
    1313            title::Explanation 
    14     header::Demo 
     14    header::Demonstration 
  • trunk/examples/htmlayout/build.bat

    r17 r18  
    22 
    33set HTMLAYOUT_FILES=../../import/htmlayout/capi.d ../../import/htmlayout/events.d ../../import/htmlayout/element.d ../../import/htmlayout/htmlayout.d 
    4 set FLOWERD_FILES=../../import/flowerd/dfl.d ../../import/flowerd/common.d  
     4set FLOWERD_FILES=../../import/flowerd/dfl.d ../../import/flowerd/common.d ../../import/flowerd/sharedlib.d 
    55set DFL_STUFF=-version=DFL_import_libs -L/exet:nt/su:windows:4.0 
    66 
  • trunk/examples/sumatrapdf/build.bat

    r17 r18  
    22 
    33set HTMLAYOUT_FILES=../../import/htmlayout/capi.d ../../import/htmlayout/events.d ../../import/htmlayout/element.d ../../import/htmlayout/htmlayout.d 
    4 set FLOWERD_FILES=../../import/flowerd/dfl.d ../../import/flowerd/common.d  
     4set FLOWERD_FILES=../../import/flowerd/dfl.d ../../import/flowerd/common.d ../../import/flowerd/sharedlib.d 
    55set DFL_STUFF=-version=DFL_import_libs -L/exet:nt/su:windows:4.0 
    66 
  • trunk/import/flowerd/common.d

    r17 r18  
    77import tango.text.Util; 
    88 
    9 alias ulong Hash; 
     9//alias ulong Hash; 
     10alias uint Hash; 
    1011 
    1112Hash dhash(char[] s) 
     
    1617} 
    1718 
    18 template shash(char [] s, Hash sofar=0) 
    19 
    20    static if (s.length == 0) const shash = sofar; 
    21    else const shash = shash!(s[1 .. length], sofar * 11 + s[0]); 
     19template Shash(char [] s, Hash sofar=0) 
     20
     21   static if (s.length == 0) const Shash = sofar; 
     22   else const Shash = Shash!(s[1 .. length], sofar * 11 + s[0]); 
     23
     24 
     25template Itoa(int i) 
     26
     27    static if(i < 0) 
     28        const char[] Itoa = "-" ~ Itoa!(-i); 
     29    else static if(i >= 10) 
     30        const char[] Itoa = Itoa!(i / 10) ~ "0123456789"[i % 10]; 
     31    else 
     32        const char[] Itoa = "" ~ "0123456789"[i % 10]; 
    2233} 
    2334 
     
    7788} 
    7889 
     90//todo: add function to work with multiple items 
    7991class Array 
    8092{ 
     
    112124        ar=ar[0..index]~ar[index+len..ar.length]; 
    113125        return true; 
     126    } 
     127 
     128    static bool contains(T)(T[] ar,T item,uint start=0) 
     129    { 
     130        return index(ar,item,start)<ar.length; 
    114131    } 
    115132 
     
    131148        if(Array.movei(ar,ar.length-1,index)==false) return false; 
    132149        ar[index]=item; 
     150        return true; 
     151    } 
     152 
     153    static bool insert(T)(ref T[] ar,T[] items,uint index=uint.max) 
     154    { 
     155        if(index==uint.max) index=ar.length; 
     156        if(index>ar.length) return false; 
     157        ar=ar[0..index]~items~ar[index..$]; 
    133158        return true; 
    134159    } 
     
    191216class GrowStack(T) 
    192217{ 
    193     this(uint step=5,T bad=T.init){this.bad=bad;this.step=(step==0?1:step);} 
    194  
    195     void push(T item) 
     218    this(uint step=32,uint initial=0,T bad=T.init) 
     219    { 
     220        if(initial) stack.length=initial; 
     221        this.bad=bad; 
     222        this.step=(step==0?1:step); 
     223    } 
     224 
     225    T push(T item) 
    196226    { 
    197227        if(pointer==stack.length) stack.length=stack.length+step; 
    198         stack[pointer++]=item; 
    199     } 
    200  
    201     T unpush() 
    202     { 
    203         T ret=pop(); 
    204         if(stack.length) stack.length=stack.length-1; 
    205         return ret; 
     228        return stack[pointer++]=item; 
     229    } 
     230 
     231    void pusha(T[] items) 
     232    { 
     233        if(items.length==0) return; 
     234        uint end=pointer+items.length; 
     235        if(end>stack.length) stack.length=stack.length+step*(end/step+(end%step==0?0:1)); 
     236        stack[pointer..end]=items; 
     237        pointer=end; 
    206238    } 
    207239 
     
    211243        if(pointer>0) --pointer; 
    212244        return ret; 
     245    } 
     246 
     247    T[] popa(uint len) 
     248    { 
     249        if(len==0 || len>pointer) return null; 
     250        else 
     251        { 
     252            auto ret=stack[pointer-len..pointer]; 
     253            pointer-=len; 
     254            return ret; 
     255        } 
    213256    } 
    214257 
     
    270313    } 
    271314 
     315    //todo: NOT TESTED 
     316    bool remove(uint index,uint len=1) 
     317    { 
     318        if(index+len>pointer) return false; 
     319        else if(Array.removei(stack,index,len)) 
     320        { 
     321            pointer-=len; 
     322            return true; 
     323        } 
     324        else return false; 
     325    } 
     326 
     327    //todo: NOT TESTED 
     328    bool insert(T[] items,uint pos) 
     329    { 
     330        if(pos>pointer) return false; 
     331        if(Array.insert(stack,items,pos)) 
     332        { 
     333            pointer+=items.length; 
     334            return true; 
     335        } 
     336        else return false; 
     337    } 
     338 
    272339    void opCatAssign(T v){push(v);} 
    273340    GrowStack!(T) opCat(T v){push(v);return this;} 
     
    280347    } 
    281348 
    282     uint size(){return stack.length;} 
     349    uint limit(){return stack.length;} 
     350    uint limit(uint i) 
     351    { 
     352        stack.length=i; 
     353        return pointer>i?pointer=i:i; 
     354    } 
    283355    T[] slice(){if(pointer) return stack[0..pointer]; else return null;} 
    284     void empty(){if(stack.length) delete stack; stack=null;
     356    void empty(){if(stack.length) delete stack; stack=null; pointer=0;
    285357    T bad; 
    286358 
  • trunk/import/flowerd/config.d

    r17 r18  
    1111//todo: ConfigNode get is not handling ivalid paths, like multiple slashes or paths ending in slash 
    1212//todo: Config.load should accept filters, to load only specific nodes 
     13//todo: ConfigNode.merge to merge with another ConfigNode 
     14//todo: Config.merge to merge with another Config 
    1315 
    1416class ConfigNode 
     
    2729    const DEFTYPE=STRING; 
    2830 
    29     ~this(){remove();} 
     31    //~this(){remove();} 
    3032 
    3133    static ConfigNode opCall(char[] name,char[] value=null,uint type=DEFTYPE) 
  • trunk/import/flowerd/dfl.d

    r17 r18  
    3333class HLayoutControl : HLayout 
    3434{ 
    35     this(HWND parent) 
    36     { 
    37         ctrl=new HControl; 
    38         ctrl.parent=Control.fromHandle(cast(dfl.internal.winapi.HANDLE)parent); 
    39         ready=true; 
    40         super(ctrl.handle); 
    41     } 
    42  
    43     this(Control parent) 
    44     { 
    45         ctrl=new HControl; 
    46         ctrl.parent=parent; 
    47         ready=true; 
    48         super(ctrl.handle); 
    49     } 
    50  
    5135    class HControl : Control 
    5236    { 
    5337        void wndProc(inout Message msg) 
    5438        { 
    55             if(ready) 
     39            if(mReady) 
    5640            { 
    5741                BOOL bHandled; 
     
    6751    } 
    6852 
    69     HWND handle(){return ctrl.handle;} 
    70  
    71     HControl ctrl; 
    72     bool ready; 
     53    this(HWND parent) 
     54    { 
     55        mControl=new HControl; 
     56        mControl.parent=Control.fromHandle(cast(dfl.internal.winapi.HANDLE)parent); 
     57        mReady=true; 
     58        super(mControl.handle); 
     59    } 
     60 
     61    this(Control parent) 
     62    { 
     63        mControl=new HControl; 
     64        mControl.parent=parent; 
     65        mReady=true; 
     66        super(mControl.handle); 
     67    } 
     68 
     69    HWND handle(){return mControl.handle;} 
     70 
     71protected: 
     72    HControl mControl; 
     73    bool mReady; 
    7374} 
    7475 
    7576class HLayoutForm : HLayoutControl 
    7677{ 
    77     Form opCast() {return form;} 
    78  
    7978    class HForm : Form 
    8079    { 
     
    8887        { 
    8988            super.onClosing(args); 
    90             if(!args.cancel) ready=false; 
    91         } 
    92     } 
    93  
    94     HForm form; 
    95  
    96     HWND handle(){return form.handle;} 
     89            if(!args.cancel) mReady=false; 
     90        } 
     91    } 
    9792 
    9893    this() 
    9994    { 
    10095        syncCtor(); 
    101         form=new HForm; 
    102         form.visible=false; 
    103         super(form); 
    104         ctrl.dock=DockStyle.FILL; 
     96        mForm=new HForm; 
     97        mForm.visible=false; 
     98        super(mForm); 
     99        mControl.dock=DockStyle.FILL; 
    105100    } 
    106101 
    107102    ~this(){syncDtor();} 
    108103 
    109     mixin SyncExec; 
     104    void run(char[][] argv=null) 
     105    { 
     106        this.argv=argv; 
     107        main(); 
     108        Application.run(mForm,&execute); 
     109    } 
     110 
     111    Form opCast(){return mForm;} 
     112    HForm form(){return mForm;} 
     113    HWND handle(){return mForm.handle;} 
     114 
     115    mixin SyncExec!(HLayoutForm); 
     116    mixin TimerExec!(HLayoutForm); 
     117 
     118protected: 
     119 
     120    HForm mForm; 
     121    char[][] argv; 
     122    void main(){} 
    110123} 
    111124 
    112125class HLiteControl : HLite 
    113126{ 
    114     this() 
    115     { 
    116         //init(); 
    117     } 
     127    this(){} 
    118128 
    119129    this(HWND parent) 
    120130    { 
    121         ctrl=new HControl; 
    122         ctrl.parent=Control.fromHandle(cast(dfl.internal.winapi.HANDLE)parent); 
     131        mControl=new HControl; 
     132        mControl.parent=Control.fromHandle(cast(dfl.internal.winapi.HANDLE)parent); 
    123133    } 
    124134 
    125135    this(Control parent) 
    126136    { 
    127         ctrl=new HControl; 
    128         ctrl.parent=parent; 
    129     } 
    130  
    131     HWND handle(){return ctrl.handle;} 
    132     HControl ctrl; 
     137        mControl=new HControl; 
     138        mControl.parent=parent; 
     139    } 
     140 
     141    HWND handle(){return mControl.handle;} 
    133142 
    134143    class HControl : Control//DoubleBufferedControl 
     
    219228    bool onUpdateUI() 
    220229    { 
    221         ctrl.update(); 
     230        mControl.update(); 
    222231        return true; 
    223232    } 
     
    225234    bool onRefreshArea(HRefreshArea e) 
    226235    { 
    227         ctrl.invalidate(Rect(cast(dfl.internal.winapi.RECT*)&e.area())); 
    228         //ctrl.updateGraphics(Rect(&e.area)); 
     236        mControl.invalidate(Rect(cast(dfl.internal.winapi.RECT*)&e.area())); 
     237        //mControl.updateGraphics(Rect(&e.area)); 
    229238        return true; 
    230239    } 
     
    235244        if(last!=e.id) 
    236245        { 
    237             ctrl.cursor(new Cursor(cast(dfl.internal.winapi.HANDLE)LoadCursorA(null,e.res))); 
     246            mControl.cursor(new Cursor(cast(dfl.internal.winapi.HANDLE)LoadCursorA(null,e.res))); 
    238247            last=e.id; 
    239248        } 
     
    243252    bool onSetTimer(HSetTimer e) 
    244253    { 
    245         if(e.time==0) KillTimer(ctrl.handle,e.id); 
     254        if(e.time==0) return(KillTimer(mControl.handle,e.id)!=0); 
    246255        else 
    247256        { 
    248             if(!SetTimer(ctrl.handle,e.id,e.time,&traverseTimerEvent)) return true; 
    249             mTimers[ctrl.handle]=this; 
    250         } 
    251         return true; 
     257            if(SetTimer(mControl.handle,e.id,e.time,&traverseTimerEvent)!=0) 
     258            { 
     259                mTimers[mControl.handle]=this; 
     260                return true; 
     261            } 
     262        } 
     263        return false; 
    252264    } 
    253265 
     
    275287    } 
    276288 
     289protected: 
    277290    static extern(Windows) void traverseTimerEvent(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime) 
    278291    { 
     
    282295    } 
    283296 
     297    HControl mControl; 
    284298    static HLite[HWND] mTimers; 
    285299} 
     
    287301class HLiteForm : HLiteControl 
    288302{ 
    289     Form opCast() {return form;} 
    290  
    291     Form form; 
     303    class HForm : Form 
     304    { 
     305        void pack() 
     306        { 
     307            clientSize=Size(minWidth,minHeight); 
     308        } 
     309    } 
     310 
     311    Form opCast() {return mForm;} 
     312    HWND handle(){return mForm.handle;} 
     313    HForm form(){return mForm;} 
    292314 
    293315    this() 
    294316    { 
    295317        syncCtor(); 
    296         form=new Form; 
    297         form.visible=false; 
    298         super(form); 
    299         ctrl.dock=DockStyle.FILL; 
     318        mForm=new HForm; 
     319        mForm.visible=false; 
     320        super(mForm); 
     321        mControl.dock=DockStyle.FILL; 
    300322    } 
    301323 
    302324    ~this() {syncDtor();} 
    303325 
    304     mixin SyncExec; 
    305  
    306     HWND handle(){return form.handle;} 
     326    void run(char[][] argv=null) 
     327    { 
     328        this.argv=argv; 
     329        main(); 
     330        Application.run(mForm,&execute); 
     331    } 
     332 
     333    mixin SyncExec!(HLiteForm); 
     334    mixin TimerExec!(HLiteForm); 
    307335 
    308336    void onKeyDown(KeyEventArgs kea) 
    309337    { 
    310         ctrl.onKeyDown(kea); 
     338        mControl.onKeyDown(kea); 
    311339    } 
    312340     
    313341    void onKeyUp(KeyEventArgs kea) 
    314342    { 
    315         ctrl.onKeyUp(kea); 
     343        mControl.onKeyUp(kea); 
    316344    } 
    317345     
    318346    void onKeyPress(KeyPressEventArgs kea) 
    319347    { 
    320         ctrl.onKeyPress(kea); 
    321     } 
    322 
     348        mControl.onKeyPress(kea); 
     349    } 
     350 
     351protected: 
     352 
     353    HForm mForm; 
     354    char[][] argv; 
     355    void main(){} 
     356
  • trunk/import/flowerd/skin.d

    r17 r18  
    77module flowerd.skin; 
    88 
     9public import htmlayout.htmlayout; 
     10import tango.sys.win32.Types; 
     11import tango.sys.win32.Macros; 
    912import flowerd.syncexec; 
    10  
    11 class SkinnedForm 
    12 
    13     this(){syncCtor();} 
    14     ~this(){syncDtor();} 
    15  
     13import tango.stdc.stringz; 
     14 
     15version(WIN32_import_libs) 
     16
     17    //pragma(lib,"user32.lib"); 
     18    //pragma(lib,"kernel32.lib"); 
     19    //pragma(lib,"shell32.lib"); 
     20    pragma(lib,"gdi32.lib"); 
     21    //pragma(lib,"user32.lib"); 
     22    //pragma(lib,"uuid.lib"); 
     23    //pragma(lib,"comdlg32.lib"); 
     24    //pragma(lib,"ole32.lib"); 
     25    //pragma(lib,"oleaut32.lib"); 
     26    //pragma(lib,"advapi32.lib"); 
     27    //pragma(lib,"comctl32.lib"); 
     28
     29 
     30extern(Windows) 
     31
     32    WINBOOL GetMessageW(LPMSG, HWND, UINT, UINT); 
     33    WINBOOL GetMessageA(LPMSG, HWND, UINT, UINT); 
     34    WINBOOL TranslateMessage(LPMSG); 
     35    LONG DispatchMessageW(LPMSG); 
     36    LONG DispatchMessageA(LPMSG); 
     37    WINBOOL PostMessageA(HWND, UINT, WPARAM, LPARAM); 
     38    HMODULE GetModuleHandleA(LPCSTR); 
     39    void PostQuitMessage(int); 
     40    ATOM RegisterClassExA(LPWNDCLASSEX); 
     41    WINBOOL ShowWindow(HWND, int); 
     42    WINBOOL IsWindowVisible(HWND); 
     43    WINBOOL UpdateWindow(HWND); 
     44    WINBOOL SetWindowPos(HWND, HWND, int, int, int, int, UINT); 
     45    WINBOOL SetWindowTextW(HWND, LPCWSTR); 
     46    WINBOOL SetWindowTextA(HWND, LPCSTR); 
     47    HWND CreateWindowExA(DWORD, LPCSTR, LPCSTR, DWORD, int, int, int, int, HWND, HMENU, HINST, LPVOID); 
     48    HWND CreateWindowExW(DWORD, LPCWSTR, LPCWSTR, DWORD, int, int, int, int, HWND, HMENU, HINST, LPVOID); 
     49    WINBOOL GetWindowPlacement(HWND, WINDOWPLACEMENT*); 
     50    int MapWindowPoints(HWND, HWND, LPPOINT, UINT); 
     51    LRESULT DefWindowProcA(HWND, UINT, WPARAM, LPARAM); 
     52    LRESULT DefWindowProcW(HWND, UINT, WPARAM, LPARAM); 
     53    WINBOOL GetWindowRect(HWND, LPRECT); 
     54    WINBOOL DestroyWindow(HWND); 
     55    HCURSOR SetCursor(HCURSOR); 
     56    HCURSOR LoadCursorA(HINST, LPCSTR); 
     57
     58 
     59const WS_EX_LAYERED=0x00080000; 
     60int GET_X_LPARAM(LPARAM lParam){return cast(int)cast(short)LOWORD(lParam);} 
     61int GET_Y_LPARAM(LPARAM lParam){return cast(int)cast(short)HIWORD(lParam);} 
     62 
     63class HSkinLayout : HLayout 
     64
     65    this() 
     66    { 
     67        mWindow = SkinnedWindow(); 
     68        mWindow.msgHandler=&msgHandler; 
     69        super(handle); 
     70        syncCtor(); 
     71    } 
     72 
     73    ~this() 
     74    { 
     75        syncDtor(); 
     76    } 
     77 
     78    mixin SkinnedForm!(HSkinLayout); 
     79
     80 
     81/*class HSkinLite : HLite 
     82
     83    mixin SkinnedForm!(HSkinLite); 
     84}*/ 
     85 
     86template SkinnedForm(THIS_TYPE) 
     87
    1688    bool run(char[][] argv) 
    1789    { 
     
    1991 
    2092        // Perform application initialization: 
    21         if (!init()) return false; 
     93        if (!init()) return false; 
    2294 
    2395        main(); 
     96 
     97        mWindow.show; 
     98        mWindow.update; 
    2499         
    25100        // Main message loop: 
    26         while (GetMessageW(&msg, null, 0, 0))  
     101        while (GetMessageA(&msg, null, 0, 0))  
    27102        { 
    28103            // execute asynchronous tasks in GUI thread. 
     
    30105 
    31106            TranslateMessage(&msg); 
    32             DispatchMessageW(&msg); 
    33         } 
    34  
    35         return msg.wParam; 
    36     } 
    37  
    38     mixin SyncExec; 
     107            DispatchMessageA(&msg); 
     108        } 
     109 
     110        return cast(bool)msg.wParam; 
     111    } 
     112 
     113    SkinnedWindow window(){return mWindow;} 
     114    HWND handle(){return mWindow.handle;} 
     115 
     116    mixin SyncExec!(THIS_TYPE); 
     117    mixin TimerExec!(THIS_TYPE); 
    39118 
    40119protected: 
     120 
     121    LRESULT msgHandler(uint msg,WPARAM wParam,LPARAM lParam,out bool handled) 
     122    { 
     123        return defProcND(msg,wParam,lParam,handled); 
     124    } 
     125         
    41126    bool init() 
    42127    { 
    43         htmlayout::window* pwnd = htmlayout::window::create( 0, 0, 300, 300, L"Hello world!" ); 
     128        if(mWindow is null) 
     129        { 
     130            mWindow = SkinnedWindow(); 
     131            mWindow.msgHandler=&msgHandler; 
     132        } 
     133 
     134        mWindow.init(this); 
    44135         
    45         //hWnd = CreateWindowEx(WS_EX_APPWINDOW, szWindowClass, szWindowClass, WS_POPUP | WS_SYSMENU | WS_CLIPCHILDREN | WS_VISIBLE, 
    46         //   0, 0, 300, 300, NULL, NULL, hInstance, NULL); 
    47          
    48         if (!pwnd->hwnd) 
    49         { 
    50           return FALSE; 
    51         } 
    52          
    53         ShowWindow(pwnd->hwnd, nCmdShow); 
    54         UpdateWindow(pwnd->hwnd); 
    55          
    56         return TRUE; 
    57     } 
     136        return true; 
     137    } 
     138 
    58139    void main(){} 
    59140    char[] argv; 
    60     HINSTANCE hInst; 
    61 
    62  
    63  
    64 /+class SkinnedWindow 
    65 
    66  
    67 public:   
    68     HWND          hwnd; 
     141    SkinnedWindow mWindow; 
     142
     143 
     144 
     145class SkinnedWindow 
     146
     147    HWND handle(){return mHandle;} 
     148 
     149    static SkinnedWindow opCall(int x=CW_USEDEFAULT, int y=CW_USEDEFAULT, int width=CW_USEDEFAULT, int height=CW_USEDEFAULT) //CW_USEDEFAULT 
     150    { 
     151        static const CLASSNAME8="HTMLayoutSkinnedWindow\0"; 
     152        static const CLASSNAME16="HTMLayoutSkinnedWindow\0"w; 
     153        auto hInstance=GetModuleHandleA(null); 
     154 
     155        static bool registered; 
     156        if(registered == false) 
     157        { 
     158            WNDCLASSEX wcex; 
     159            wcex.cbSize = WNDCLASSEX.sizeof; 
     160             
     161            wcex.style              = CS_HREDRAW | CS_VREDRAW; 
     162            wcex.lpfnWndProc        = &wndProc; 
     163            wcex.cbClsExtra         = 0; 
     164            wcex.cbWndExtra         = 0; 
     165            wcex.hInstance          = hInstance; 
     166            //wcex.hIcon            = LoadIconA(hInstance, (LPCTSTR)IDI_SKIN); 
     167            wcex.hCursor            = LoadCursorA(null, IDC_ARROW); 
     168            wcex.hbrBackground      = cast(HBRUSH)(COLOR_WINDOW+1); 
     169            wcex.lpszMenuName       = null; 
     170            wcex.lpszClassName      = CLASSNAME8.ptr; 
     171            //wcex.hIconSm          = LoadIconA(wcex.hInstance, (LPCTSTR)IDI_SKINSMALL); 
     172             
     173            if(RegisterClassExA(&wcex)) registered=true; 
     174            else return null; 
     175        } 
     176 
     177        //const style = WS_POPUP | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SYSMENU | WS_SIZEBOX | WS_VISIBLE; 
     178        const style = WS_OVERLAPPEDWINDOW | WS_VISIBLE; 
     179        auto h = CreateWindowExA(WS_EX_APPWINDOW /*WS_EX_LAYERED*/, CLASSNAME8.ptr, null, style, x, y, width, height, null, null, hInstance, null); 
     180 
     181        return new SkinnedWindow(h); 
     182    } 
     183 
     184    HCURSOR cursor(HCURSOR c){return SetCursor(c);} 
     185 
     186    bool minimize(){return ShowWindow(mHandle,SW_MINIMIZE)!=FALSE;} 
     187 
     188    bool maximize(){return ShowWindow(mHandle,SW_MAXIMIZE)!=FALSE;} 
     189 
     190    bool restore(){return ShowWindow(mHandle,SW_RESTORE)!=FALSE;} 
     191 
     192    bool visible(bool bShow=true){return ShowWindow(mHandle,bShow?SW_SHOW:SW_HIDE)!=FALSE;} 
     193 
     194    bool hide(){return visible(false);} 
     195 
     196    bool show(){return visible(true);} 
     197 
     198    bool visible(){return IsWindowVisible(mHandle)!=FALSE;} 
     199 
     200    bool update(){return UpdateWindow(mHandle)!=FALSE;} 
     201 
     202    bool size(int x,int y){return SetWindowPos(mHandle,null,0,0,x,y,SWP_NOMOVE)!=FALSE;} 
     203 
     204    bool position(int x,int y){return SetWindowPos(mHandle,null,x,y,0,0,SWP_NOSIZE)!=FALSE;} 
     205 
     206    void init(HLayoutBase layout) 
     207    { 
     208        if(layout is null) return; 
     209        else mLayout=layout; 
     210        auto r=layout.rootElement; 
     211        if(r is null) return; 
     212 
     213        mBody = r.getTag("body")[0]; 
     214        mCaption = r.getId("skin_caption"); 
     215        if((mButton_min = r.getId("skin_minimize")) !is null) mButton_min.handleEvent(delegate(HBehaviorEvent p) 
     216        { 
     217            if(p.cmd!=BUTTON_CLICK) return false; 
     218            return (cast(SkinnedWindow)p.param).minimize; 
     219        },this); 
     220        if((mButton_max = r.getId("skin_maximize")) !is null) mButton_max.handleEvent(delegate(HBehaviorEvent p) 
     221        { 
     222            if(p.cmd!=BUTTON_CLICK) return false; 
     223            with(cast(SkinnedWindow)p.param) 
     224            { 
     225                if(maximized) return restore; 
     226                else return maximize; 
     227            } 
     228        },this); 
     229        if((mButton_close = r.getId("skin_close")) !is null) mButton_close.handleEvent(delegate(HBehaviorEvent p) 
     230        { 
     231            if(p.cmd!=BUTTON_CLICK) return false; 
     232            PostMessageA((cast(SkinnedWindow)p.param).mHandle,WM_CLOSE,0,0);  
     233            return true; 
     234        },this); 
     235        mButton_icon = r.getId("skin_icon"); 
     236        mCorner = r.getId("skin_corner"); 
     237 
     238        auto h=r.getTag("head"); 
     239        if(h.length) 
     240        { 
     241            h=h[0].getTag("title"); 
     242            if(h.length) caption=h[0].innerText; 
     243        } 
     244    } 
     245 
     246    void caption(char[] text) 
     247    { 
     248        SetWindowTextA(mHandle,toStringz(text)); 
     249        if(mCaption) 
     250        { 
     251            mCaption.innerText=text; 
     252            mCaption.update; 
     253        } 
     254    } 
     255 
     256    bool minimized() 
     257    { 
     258        WINDOWPLACEMENT wp; 
     259        GetWindowPlacement(mHandle,&wp); 
     260        return wp.showCmd == SW_SHOWMINIMIZED; 
     261    } 
     262 
     263    bool maximized() 
     264    { 
     265        WINDOWPLACEMENT wp; 
     266        GetWindowPlacement(mHandle,&wp); 
     267        return wp.showCmd == SW_SHOWMAXIMIZED; 
     268    } 
     269 
     270    LRESULT delegate(uint,WPARAM,LPARAM,out bool) msgHandler; 
     271 
     272protected: 
     273 
     274    this(HWND h) 
     275    { 
     276        if(h is null) throw new Exception("Invalid handle passed to SkinnedWindow.this!"); 
     277        mWindows[h]=this; 
     278    } 
     279 
     280    int mHitTest(int x, int y) 
     281    { 
     282        auto pt = POINT(x,y); 
     283        MapWindowPoints(cast(HWND)HWND_DESKTOP,mHandle,&pt,1u); 
     284 
     285        if(mButton_icon && mButton_icon.isInside(pt)) return HTSYSMENU; 
     286 
     287        if(mCaption && mCaption.isInside(pt)) return HTCAPTION; 
     288 
     289        if(mCorner && mCorner.isInside(pt)) return HTBOTTOMRIGHT; 
     290 
     291        if(mBody) 
     292        { 
     293            auto body_rc = mBody.location(ROOT_RELATIVE | CONTENT_BOX); 
    69294     
    70     dom::element  body; 
    71     dom::element  caption; 
    72     dom::element  button_min; 
    73     dom::element  button_max; 
    74     dom::element  button_icon; 
    75     dom::element  button_close; 
    76     dom::element  corner; 
     295            if(PtInRect(body_rc, pt)) return HTCLIENT; 
    77296     
    78     static  window* create( int x, int y, int width, int height, const wchar_t* caption = 0 ); 
    79     static  window* self(HWND hWnd) { return (window*)::GetWindowLongPtr(hWnd,GWLP_USERDATA); } 
     297            if( pt.y < body_rc.top + 10 )  
     298            { 
     299                if( pt.x < body_rc.left + 10 ) return HTTOPLEFT; 
     300                if( pt.x > body_rc.right - 10 ) return HTTOPRIGHT; 
     301            } 
    80302     
    81     void            set_caption( const wchar_t* text ); 
     303            else if( pt.y > body_rc.bottom - 10 )  
     304            { 
     305                if( pt.x < body_rc.left + 10 ) return HTBOTTOMLEFT; 
     306                if( pt.x > body_rc.right - 10 ) return HTBOTTOMRIGHT; 
     307            } 
    82308     
    83     static  ATOM              register_class(HINSTANCE hInstance); 
    84  
    85 protected: 
    86     window(): event_handler(HANDLE_BEHAVIOR_EVENT) {} 
    87      
    88     int       hit_test( int x, int y ); 
    89     HELEMENT  root(); 
    90     bool      is_minimized() const; 
    91     bool      is_maximized() const; 
    92      
    93     virtual BOOL  on_event (HELEMENT he, HELEMENT target, BEHAVIOR_EVENTS type, UINT_PTR reason ); 
    94      
    95     static  void              self(HWND hWnd, window* inst) { ::SetWindowLongPtr(hWnd,GWLP_USERDATA, LONG_PTR(inst)); } 
    96     static  LRESULT CALLBACK  win_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); 
    97      
    98     static  HINSTANCE         hinstance; 
    99  
    100  
    101 
    102  
    103  
    104 HINSTANCE window::hinstance = 0; 
    105  
    106   const wchar_t CLASSNAME[] = L"htmlayout::window"; 
    107  
    108   // register window class 
    109  
    110   ATOM  window::register_class(HINSTANCE hInstance) 
    111   { 
    112     hinstance = hInstance; 
    113  
    114       WNDCLASSEXW wcex; 
    115  
    116       wcex.cbSize = sizeof(WNDCLASSEX);  
    117  
    118       wcex.style                = CS_HREDRAW | CS_VREDRAW; 
    119       wcex.lpfnWndProc    = (WNDPROC)win_proc; 
    120       wcex.cbClsExtra         = 0; 
    121       wcex.cbWndExtra         = 0; 
    122       wcex.hInstance          = hInstance; 
    123       wcex.hIcon                = LoadIcon(hInstance, (LPCTSTR)IDI_SKIN); 
    124       wcex.hCursor          = LoadCursor(NULL, IDC_ARROW); 
    125       wcex.hbrBackground    = (HBRUSH)(COLOR_WINDOW+1); 
    126       wcex.lpszMenuName   = 0; 
    127       wcex.lpszClassName    = CLASSNAME; 
    128       wcex.hIconSm          = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SKINSMALL); 
    129  
    130       return RegisterClassExW(&wcex); 
    131   } 
    132  
    133 #ifndef WS_EX_LAYERED 
    134 #define WS_EX_LAYERED           0x00080000 
    135 #endif 
    136  
    137   // create window instance 
    138  
    139   window* window::create( int x, int y, int width, int height, const wchar_t* caption )  
    140   { 
    141     window* pw = new window(); 
    142  
    143     UINT style = WS_POPUP | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SYSMENU | WS_SIZEBOX; 
    144     pw->hwnd = CreateWindowExW( WS_EX_LAYERED, CLASSNAME, NULL, style , 
    145                                 x, y, width, height, NULL, NULL, hinstance, NULL); 
    146 //    pw->hwnd = CreateWindowExW( 0, CLASSNAME, NULL, style , 
    147 //                                x, y, width, height, NULL, NULL, hinstance, NULL); 
    148     self(pw->hwnd,pw); 
    149     HTMLayoutSetCallback(pw->hwnd,&callback,pw); 
    150     PBYTE pb; DWORD cb; 
    151     if(load_resource_data(L"DEFAULT",pb,cb)) 
    152     { 
    153       HTMLayoutLoadHtml(pw->hwnd,pb,cb); 
    154  
    155       dom::element r = pw->root(); 
    156  
    157       pw->body            = r.find_first("body"); 
    158       pw->caption         = r.get_element_by_id("caption"); 
    159       pw->button_min      = r.get_element_by_id("minimize"); 
    160       pw->button_max      = r.get_element_by_id("maximize"); 
    161       pw->button_icon     = r.get_element_by_id("icon"); 
    162       pw->button_close    = r.get_element_by_id("close"); 
    163       pw->corner          = r.get_element_by_id("corner"); 
    164  
    165       attach_event_handler(pw->hwnd, pw); 
    166  
    167       pw->set_caption(caption); 
    168  
    169     } 
    170     return pw; 
    171   } 
    172  
    173   void window::set_caption( const wchar_t* text ) 
    174   { 
    175     if(text) 
    176     { 
    177       ::SetWindowTextW(hwnd,text); 
    178       if( caption.is_valid() ) 
    179       { 
    180         caption.set_text(text); 
    181         caption.update(true); 
    182       } 
    183     } 
    184   } 
    185  
    186  
    187   HELEMENT  window::root() 
    188   { 
    189     return dom::element::root_element(hwnd); 
    190   } 
    191  
    192   int       window::hit_test( int x, int y ) 
    193   { 
    194      
    195     POINT pt; pt.x = x; pt.y = y; 
    196     ::MapWindowPoints(HWND_DESKTOP,hwnd,&pt,1); 
    197  
    198     if( caption.is_valid() && caption.is_inside(pt) ) 
    199       return HTCAPTION; 
    200  
    201     if( button_icon.is_valid() && button_icon.is_inside(pt) ) 
    202       return HTSYSMENU; 
    203  
    204     if( corner.is_valid() && corner.is_inside(pt) ) 
    205       return HTBOTTOMRIGHT; 
    206  
    207     RECT body_rc = body.get_location(ROOT_RELATIVE | CONTENT_BOX); 
    208  
    209     if( PtInRect(&body_rc, pt) ) 
    210       return HTCLIENT; 
    211  
    212     if( pt.y < body_rc.top + 10 )  
    213     { 
    214       if( pt.x < body_rc.left + 10 )  
    215         return HTTOPLEFT; 
    216       if( pt.x > body_rc.right - 10 )  
    217         return HTTOPRIGHT; 
    218     } 
    219     else if( pt.y > body_rc.bottom - 10 )  
    220     { 
    221       if( pt.x < body_rc.left + 10 )  
    222         return HTBOTTOMLEFT; 
    223       if( pt.x > body_rc.right - 10 )  
    224         return HTBOTTOMRIGHT; 
    225     } 
    226  
    227     if( pt.y < body_rc.top )  
    228       return HTTOP; 
    229     if( pt.y > body_rc.bottom )  
    230       return HTBOTTOM; 
    231     if( pt.x < body_rc.left )  
    232       return HTLEFT; 
    233     if( pt.x > body_rc.right )  
    234       return HTRIGHT; 
    235  
    236  
    237     return HTCLIENT; 
    238     
    239   } 
    240  
    241   BOOL window::on_event (HELEMENT he, HELEMENT target, BEHAVIOR_EVENTS type, UINT_PTR reason ) 
    242   { 
    243     if( type != BUTTON_CLICK) 
    244       return FALSE; // handling only button clicks here.  
    245  
    246     if( target == button_min) 
    247     { 
    248       ::ShowWindow(hwnd,SW_MINIMIZE);  
    249       return TRUE; 
    250     } 
    251     if( target == button_max) 
    252     { 
    253       if( is_maximized()) 
    254         ::ShowWindow(hwnd,SW_RESTORE);  
    255       else 
    256         ::ShowWindow(hwnd,SW_MAXIMIZE);  
    257        
    258       return TRUE; 
    259     } 
    260     if( target == button_close) 
    261     { 
    262       ::PostMessage(hwnd, WM_CLOSE, 0,0);  
    263       return TRUE; 
    264     } 
    265  
    266     // click on some other button 
    267     dom::element button = target; 
    268     ::MessageBoxW(button.get_element_hwnd(true),button.get_attribute("id"), L"Click on the button with id:", MB_OK); 
    269  
    270     return FALSE; 
    271   } 
    272  
    273   bool window::is_minimized() const 
    274   { 
    275       WINDOWPLACEMENT wp; 
    276       GetWindowPlacement(hwnd,&wp); 
    277       return wp.showCmd == SW_SHOWMINIMIZED; 
    278   } 
    279  
    280   bool window::is_maximized() const 
    281   { 
    282       WINDOWPLACEMENT wp; 
    283       GetWindowPlacement(hwnd,&wp); 
    284       return wp.showCmd == SW_SHOWMAXIMIZED; 
    285   } 
    286  
    287   LRESULT CALLBACK window::win_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) 
    288   { 
    289     LRESULT lResult; 
    290     BOOL    bHandled; 
    291  
    292   // HTMLayout + 
    293     // HTMLayout could be created as separate window  
    294     // using CreateWindow API. 
    295     // But in this case we are attaching HTMLayout functionality 
    296     // to the existing window delegating windows message handling to  
    297     // HTMLayoutProcND function. 
    298     lResult = HTMLayoutProcND(hwnd,message,wParam,lParam, &bHandled); 
    299     if(bHandled) 
    300       return lResult; 
    301   // HTMLayout - 
    302  
    303     window* me = self(hwnd); 
    304  
    305       switch (message)  
    306       { 
    307        
    308       case WM_NCHITTEST: 
    309         if(me) 
    310           return me->hit_test( GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) ); 
    311         break; 
    312  
    313       case WM_NCACTIVATE: 
    314         // change active state here 
    315         break; 
    316  
    317       case WM_NCCALCSIZE:   return 0; // we have no non-client areas. 
    318       case WM_NCPAINT:     return 0; // we have no non-client areas. 
    319  
    320       case WM_GETMINMAXINFO: 
    321         { 
    322           LRESULT lr = DefWindowProc(hwnd, message, wParam, lParam); 
    323           MINMAXINFO* pmmi = (MINMAXINFO*)lParam; 
    324           pmmi->ptMinTrackSize.x = ::HTMLayoutGetMinWidth(hwnd); 
    325           RECT rc; GetWindowRect(hwnd,&rc); 
    326           pmmi->ptMinTrackSize.y = ::HTMLayoutGetMinHeight(hwnd, rc.right - rc.left); 
    327           return lr; 
    328         } 
    329  
    330        
    331  
    332       case WM_CLOSE: 
    333         ::DestroyWindow(hwnd); 
    334         return 0; 
    335  
    336           case WM_DESTROY: 
    337         delete me; // delete window instance! 
    338         self(hwnd,0); 
    339         PostQuitMessage(0); 
    340               return 0; 
    341  
    342      } 
    343      return DefWindowProc(hwnd, message, wParam, lParam); 
    344   } 
    345  
    346 
    347  
    348 +/ 
     309            if( pt.y < body_rc.top ) return HTTOP; 
     310            if( pt.y > body_rc.bottom ) return HTBOTTOM; 
     311            if( pt.x < body_rc.left ) return HTLEFT; 
     312            if( pt.x > body_rc.right ) return HTRIGHT; 
     313        } 
     314 
     315        return HTCLIENT; 
     316    } 
     317 
     318    static SkinnedWindow[HWND] mWindows; 
     319 
     320    extern(Windows) static LRESULT wndProc(HWND mHandle, UINT message, WPARAM wParam, LPARAM lParam) 
     321    { 
     322        auto me = mHandle in mWindows; 
     323        if(me && me.msgHandler) 
     324        { 
     325            bool bHandled; 
     326            auto ret=me.msgHandler(message,wParam,lParam,bHandled); 
     327            if(bHandled) return ret; 
     328        } 
     329        /*if(me) 
     330        { 
     331            BOOL bHandled; 
     332            auto ret=HTMLayoutProcND(mHandle,message,wParam,lParam, &bHandled); 
     333            if(bHandled) return ret; 
     334        }*/ 
     335 
     336        switch (message)  
     337        { 
     338            case WM_NCHITTEST: 
     339                if(me) return me.mHitTest(GET_X_LPARAM(lParam),GET_Y_LPARAM(lParam)); 
     340                break; 
     341 
     342            case WM_NCACTIVATE: 
     343                if(me && me.mBody) 
     344                { 
     345                    if(wParam) {if(me.mBody.delClass("skin_inactive")) me.mBody.update;} 
     346                    else {if(me.mBody.addClass("skin_inactive")) me.mBody.update;} 
     347                } 
     348                break; 
     349 
     350            case WM_NCCALCSIZE: return 0; // we have no non-client areas. 
     351            case WM_NCPAINT: return 0; // we have no non-client areas. 
     352 
     353            case WM_GETMINMAXINFO: 
     354            { 
     355                if(me && me.mLayout) 
     356                { 
     357                    auto m1=cast(HLayout)me.mLayout; 
     358                    auto m2=m1?null:cast(HLite)me.mLayout; 
     359 
     360                    LRESULT lr = DefWindowProcA(mHandle, message, wParam, lParam); 
     361                    MINMAXINFO* pmmi = cast(MINMAXINFO*)lParam; 
     362                    pmmi.ptMinTrackSize.x = m1?m1.minWidth:m2.minWidth; 
     363                    RECT rc; 
     364                    GetWindowRect(mHandle,&rc); 
     365                    pmmi.ptMinTrackSize.y = m1?m1.minHeight(rc.right - rc.left):m2.minHeight; 
     366                    return lr; 
     367                } 
     368                else return 0; 
     369            } 
     370 
     371            case WM_CLOSE: 
     372                DestroyWindow(mHandle); 
     373                return 0; 
     374 
     375            case WM_DESTROY: 
     376                mWindows.remove(mHandle); 
     377                if(me) delete *me; // delete window instance! 
     378                PostQuitMessage(0); 
     379                return 0; 
     380 
     381            default: 
     382                break; 
     383         } 
     384 
     385         return DefWindowProcA(mHandle, message, wParam, lParam); 
     386    } 
     387 
     388    HWND mHandle; 
     389    HLayoutBase mLayout; 
     390    HElement mBody,mCaption,mButton_min,mButton_max,mButton_icon,mButton_close,mCorner; 
     391
  • trunk/import/flowerd/syncexec.d

    r17 r18  
    1111public import tango.core.sync.Mutex; 
    1212 
    13 extern(Windows) BOOL PostMessageA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); 
     13extern(Windows) 
     14
     15    alias VOID function(HWND, UINT, UINT, DWORD) TIMERPROC; 
     16    UINT SetTimer(HWND hWnd, UINT nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc); 
     17    BOOL KillTimer(HWND hWnd, UINT uIDEvent); 
     18    BOOL PostMessageA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); 
     19
    1420 
    1521/*class GuiQueue 
     
    2127}*/ 
    2228 
     29//the interval delegate should return false to stop the interval and true to continue 
     30template TimerExec(THIS_TYPE) 
     31{ 
     32    uint setInterval(uint time,bool delegate(uint,Object) dg,Object param=null) {return mSetTimer(time,new TIMEREXEC_BOOL1(dg,param));} 
     33    uint setInterval(uint time,bool delegate(uint) dg) {return mSetTimer(time,new TIMEREXEC_BOOL2(dg));} 
     34    uint setInterval(uint time,bool delegate(Object) dg,Object param=null) {return mSetTimer(time,new TIMEREXEC_BOOL1A(dg,param));} 
     35    uint setInterval(uint time,bool delegate() dg) {return mSetTimer(time,new TIMEREXEC_BOOL2A(dg));} 
     36    uint setInterval(uint time,void delegate(uint,Object) dg,Object param=null) {return mSetTimer(time,new TIMEREXEC_VOID1(dg,param,true));} 
     37    uint setInterval(uint time,void delegate(uint) dg) {return mSetTimer(time,new TIMEREXEC_VOID2(dg,true));} 
     38    uint setInterval(uint time,void delegate(Object) dg,Object param=null) {return mSetTimer(time,new TIMEREXEC_VOID1A(dg,param,true));} 
     39    uint setInterval(uint time,void delegate() dg) {return mSetTimer(time,new TIMEREXEC_VOID2A(dg,true));} 
     40    uint setTimeout(uint time,void delegate(uint,Object) dg,Object param=null) {return mSetTimer(time,new TIMEREXEC_VOID1(dg,param,false));} 
     41    uint setTimeout(uint time,void delegate(uint) dg) {return mSetTimer(time,new TIMEREXEC_VOID2(dg,false));} 
     42    uint setTimeout(uint time,void delegate(Object) dg,Object param=null) {return mSetTimer(time,new TIMEREXEC_VOID1A(dg,param,false));} 
     43    uint setTimeout(uint time,void delegate() dg) {return mSetTimer(time,new TIMEREXEC_VOID2A(dg,false));} 
     44 
     45    bool clearTimer(uint id) 
     46    { 
     47        if(KillTimer(null,id)!=0) 
     48        { 
     49            auto t=id in mTimers; 
     50            if(t) delete *t; 
     51            return true; 
     52        } 
     53        else return false; 
     54    } 
     55 
     56protected: 
     57 
     58    uint mSetTimer(uint time,TIMEREXEC t) 
     59    { 
     60        if(time==0) return 0; 
     61        t.id=cast(uint)SetTimer(null,0,time,&mTimerProc); 
     62        if(t.id==0) {delete t;return 0;} 
     63        mTimers[t.id]=t; 
     64        return t.id; 
     65    } 
     66 
     67    static extern(Windows) void mTimerProc(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime) 
     68    { 
     69        auto t=idEvent in mTimers; 
     70        if(t && t.exec()==false) t.outer.clearTimer(idEvent); 
     71    } 
     72 
     73    class TIMEREXEC 
     74    { 
     75        this(Object o=null) {param=o;} 
     76        ~this(){mTimers.remove(id);} 
     77        bool exec(){return false;} 
     78 
     79        uint id; 
     80        Object param; 
     81    } 
     82 
     83    class TIMEREXEC_BOOL1 : THIS_TYPE.TIMEREXEC 
     84    { 
     85        this(bool delegate(uint,Object) dg,Object o) {this.dg=dg; super(o);} 
     86        bool exec(){return dg(id,param);} 
     87 
     88        bool delegate(uint,Object) dg; 
     89    } 
     90 
     91    class TIMEREXEC_BOOL2 : THIS_TYPE.TIMEREXEC 
     92    { 
     93        this(bool delegate(uint) dg) {this.dg=dg;} 
     94        bool exec(){return dg(id);} 
     95 
     96        bool delegate(uint) dg; 
     97    } 
     98 
     99    class TIMEREXEC_BOOL1A : THIS_TYPE.TIMEREXEC 
     100    { 
     101        this(bool delegate(Object) dg,Object o) {this.dg=dg; super(o);} 
     102        bool exec(){return dg(param);} 
     103 
     104        bool delegate(Object) dg; 
     105    } 
     106 
     107    class TIMEREXEC_BOOL2A : THIS_TYPE.TIMEREXEC 
     108    { 
     109        this(bool delegate() dg) {this.dg=dg;} 
     110        bool exec(){return dg();} 
     111 
     112        bool delegate() dg; 
     113    } 
     114 
     115    class TIMEREXEC_VOID1 : THIS_TYPE.TIMEREXEC 
     116    { 
     117        this(void delegate(uint,Object) dg,Object o,bool ret) {this.dg=dg; this.ret=ret; super(o);} 
     118        bool exec(){dg(id,param);return ret;} 
     119 
     120        bool ret; 
     121        void delegate(uint,Object) dg; 
     122    } 
     123 
     124    class TIMEREXEC_VOID2 : THIS_TYPE.TIMEREXEC 
     125    { 
     126        this(void delegate(uint) dg,bool ret) {this.dg=dg; this.ret=ret;} 
     127        bool exec(){dg(id);return ret;} 
     128 
     129        bool ret; 
     130        void delegate(uint) dg; 
     131    } 
     132 
     133    class TIMEREXEC_VOID1A : THIS_TYPE.TIMEREXEC 
     134    { 
     135        this(void delegate(Object) dg,Object o,bool ret) {this.dg=dg; this.ret=ret; super(o);} 
     136        bool exec(){dg(param);return ret;} 
     137 
     138        bool ret; 
     139        void delegate(Object) dg; 
     140    } 
     141 
     142    class TIMEREXEC_VOID2A : THIS_TYPE.TIMEREXEC 
     143    { 
     144        this(void delegate() dg,bool ret) {this.dg=dg; this.ret=ret;} 
     145        bool exec(){dg();return ret;} 
     146 
     147        bool ret; 
     148        void delegate() dg; 
     149    } 
     150 
     151    static TIMEREXEC[uint] mTimers; 
     152} 
     153 
    23154// this one needs to be created as singleton - one instance per GUI thread(s) 
    24 template SyncExec(
     155template SyncExec(THIS_TYPE
    25156{ 
    26157    void syncCtor() 
     
    31162        mGuiThreads[mThread]=true; 
    32163        mGuard=new Mutex; 
     164        //mGuard2=new Mutex; 
    33165    } 
    34166 
     
    37169        mGuiThreads.remove(mThread); 
    38170        delete mGuard; 
    39     } 
    40  
    41     void asyncExec(void delegate(Object) exec,Object param=null) 
    42     { 
    43         auto job=new SyncJob; 
    44         job.param=param; 
    45         job.exec=exec; 
     171        //delete mGuard2; 
     172    } 
     173 
     174    void asyncExec(void delegate(Object) dg,Object param=null) 
     175    { 
     176        auto job=new SYNCEXEC_1(dg,param); 
     177        mAsyncExec(job); 
     178    } 
     179 
     180    void asyncExec(void delegate() dg) 
     181    { 
     182        auto job=new SYNCEXEC_2(dg); 
     183        mAsyncExec(job); 
     184    } 
     185 
     186/* these hang sometimes 
     187    void syncExec(void delegate() dg) 
     188    { 
     189        auto th=Thread.getThis; 
     190        if(th is mThread) dg(); 
     191        else 
     192        { 
     193            synchronized(mGuard2) 
     194            { 
     195                if(bSyncExecDone==false || bASyncExecDone==false) throw new Exception("Calling syncExec from syncExec is not possible!"); 
     196                bSyncExecDone=false; 
     197            } 
     198            asyncExec(dg); 
     199            while(bSyncExecDone==false) th.yield; 
     200        } 
     201    } 
     202 
     203    void syncExec(void delegate(Object) dg,Object param=null) 
     204    { 
     205        auto th=Thread.getThis; 
     206        if(th is mThread) dg(param); 
     207        else 
     208        { 
     209            synchronized(mGuard2) 
     210            { 
     211                if(bSyncExecDone==false || bASyncExecDone==false) throw new Exception("Calling syncExec from syncExec is not possible!"); 
     212                bSyncExecDone=false; 
     213            } 
     214            asyncExec(dg,param); 
     215            while(bSyncExecDone==false) th.yield; 
     216        } 
     217    } 
     218*/ 
     219 
     220    // Place this call after GetMessage()/PeekMessage() in main loop 
     221    void execute() 
     222    { 
     223        if(Thread.getThis !is mThread) throw new Exception("Calling SyncExec.execute from a wrong thread!"); 
     224        synchronized(mGuard) 
     225        { 
     226            //bASyncExecDone=false; 
     227            SYNCEXEC next; 
     228            while((next = pop()) !is null) 
     229            { 
     230                next.exec(); // do it 
     231                delete next; 
     232            } 
     233            //bSyncExecDone=true; 
     234            //bASyncExecDone=true; 
     235        } 
     236    } 
     237 
     238protected: 
     239    void mAsyncExec(SYNCEXEC job) 
     240    { 
    46241        synchronized(mGuard) 
    47242        { 
     
    53248    } 
    54249 
    55     void syncExec(void delegate() exec){syncExec(delegate(Object o){exec();});} 
    56  
    57     void syncExec(void delegate(Object) exec,Object param=null) 
    58     { 
    59         auto th=Thread.getThis; 
    60         if(th is mThread) exec(param); 
    61         else 
    62         { 
    63             bSyncExecDone=false; 
    64             asyncExec(exec,param); 
    65             while(bSyncExecDone==false) th.yield; 
    66         } 
    67     } 
    68  
    69     // Place this call after GetMessage()/PeekMessage() in main loop 
    70     void execute() 
    71     { 
    72         if(Thread.getThis !is mThread) throw new Exception("Calling SyncExec.execute from a wrong thread!"); 
    73         synchronized(mGuard) 
    74         { 
    75             SyncJob* next; 
    76             while((next = pop()) !is null) 
    77             { 
    78                 next.exec(next.param); // do it 
    79                 delete next; 
    80             } 
    81             bSyncExecDone=true; 
    82         } 
    83     } 
    84  
    85 protected: 
    86     SyncJob* pop() 
     250    SYNCEXEC pop() 
    87251    { 
    88252        //synchronized(guard) 
    89253        { 
    90254            if(mHead is null) return null; 
    91             SyncJob* t = mHead; 
     255            SYNCEXEC t = mHead; 
    92256            mHead = mHead.next; 
    93257            if(mHead is null) mTail = null; 
     
    96260    } 
    97261 
    98     struct SyncJob  
    99     { 
     262    class SYNCEXEC 
     263    { 
     264        this(Object o=null) {param=o;} 
     265        void exec(){} 
     266 
     267        SYNCEXEC next; 
    100268        Object param; 
    101         void delegate(Object) exec; 
    102         SyncJob* next; 
    103     } 
    104  
    105     SyncJob* mHead; 
    106     SyncJob* mTail; 
     269    } 
     270 
     271    class SYNCEXEC_1 : THIS_TYPE.SYNCEXEC 
     272    { 
     273        this(void delegate(Object) dg,Object o) {this.dg=dg; super(o);} 
     274        void exec(){dg(param);} 
     275 
     276        void delegate(Object) dg; 
     277    } 
     278 
     279    class SYNCEXEC_2 : THIS_TYPE.SYNCEXEC 
     280    { 
     281        this(void delegate() dg) {this.dg=dg;} 
     282        void exec(){dg();} 
     283 
     284        void delegate() dg; 
     285    } 
     286 
     287    SYNCEXEC mHead; 
     288    SYNCEXEC mTail; 
    107289    Mutex mGuard; 
     290    //Mutex mGuard2; 
    108291    Thread mThread; 
    109292    static bool[Thread] mGuiThreads; 
    110     bool bSyncExecDone; 
     293    //bool bSyncExecDone=true,bASyncExecDone=true; 
    111294} 
  • trunk/import/htmlayout/behaviors/translatable.d

    r17 r18  
    2121    } 
    2222 
     23    void reset() 
     24    { 
     25        if(elements) 
     26        { 
     27            elements.each(delegate(ref Translatable t){t.element.release;}); 
     28            elements.empty; 
     29            delete elements; 
     30            elements=null; 
     31        } 
     32        if(strings) 
     33        { 
     34            delete strings; 
     35            strings=null; 
     36        } 
     37        elements=new GrowStack!(Translatable); 
     38    } 
     39 
    2340    bool onInit(HInit p) 
    2441    { 
     
    3552        { 
    3653            elements.remove(delegate(Translatable t){ 
    37                 return t.element==p.element; 
     54                if(t.element==p.element) 
     55                { 
     56                    t.element.release; 
     57                    return true; 
     58                } 
     59                else return false; 
    3860            }); 
    3961            return true; 
     
    6183    } 
    6284 
    63     char[] opCall(char[] id
     85    char[] opCall(char[] id,char[][] params=null
    6486    { 
    65         return strings.getv(tango.text.Util.replace(id,'.','/')); 
     87        return strings.getv(tango.text.Util.replace(id,'.','/'),null,params); 
    6688    } 
    6789 
  • trunk/import/htmlayout/capi.d

    r17 r18  
    437437{ 
    438438    ExpandoRelease finalizer; // can be either NULL or valid pointer to function 
    439 }; 
    440  
     439
    441440 
    442441alias HLDOM_RESULT function( HELEMENT he, HTMLayoutElementExpando* pExpando ) HTMLayoutElementSetExpando_t; 
     
    913912{ 
    914913    METHOD_PARAMS methodparams; 
    915     LPCSTR          method_name; 
    916     UINT                argc; 
     914    LPCSTR  method_name; 
     915    UINT    argc; 
    917916    JSON_VALUE   *argv; 
    918917    JSON_VALUE   retval; 
     
    11271126struct DATA_ARRIVED_PARAMS 
    11281127{ 
    1129     HELEMENT    initiator;      // element intiator of HTMLayoutRequestElementData request,  
    1130     LPCBYTE  data;               // data buffer 
    1131     UINT            dataSize;        // size of data 
    1132     UINT            dataType;        // data type passed "as is" from HTMLayoutRequestElementData 
     1128    HELEMENT  initiator;    // element intiator of HTMLayoutRequestElementData request,  
     1129    LPCBYTE   data;         // data buffer 
     1130    UINT      dataSize;     // size of data 
     1131    UINT      dataType;     // data type passed "as is" from HTMLayoutRequestElementData 
     1132    UINT      status;       // status = 0 (dataSize == 0) - unknown error.  
     1133                          // status = 100..505 - http response status, Note: 200 - OK!  
     1134                          // status > 12000 - wininet error code, see ERROR_INTERNET_*** in wininet.h 
     1135    LPCWSTR   uri;          // requested url  
    11331136}; 
    11341137 
     
    11831186////////////////////////////////////////////////////////////////////////////// json 
    11841187 
     1188class HJson 
     1189{ 
     1190    ~this(){mValue.release;} 
     1191 
     1192    JSON_VALUE* handle(){return mValue;} 
     1193    JSON_VALUE* opCast(){return mValue;} 
     1194 
     1195    extern(D) char[] toString(){return mValue.toString;} //todo: remove this extern(D) 
     1196    //JSON_VALUE[] toArray(){return mValue.toArray;} 
     1197    HJson[] toArray() 
     1198    { 
     1199        auto a=mValue.toArray; 
     1200        HJson[] ret; 
     1201        ret.length=a.length; 
     1202        foreach(i,v;a) ret[i]=HJson(&a[i]); 
     1203        return ret; 
     1204    } 
     1205    double toFloat(){return mValue.toFloat;} 
     1206    long toInt(){return mValue.toInt;} 
     1207    bool toBool(){return mValue.toBool;} 
     1208    char[] typename(){return mValue.typename;} 
     1209    int type(){return mValue.v_type;} 
     1210 
     1211    static HJson parse(char[] text,uint mode=0){return HJson(JSON_VALUE.parse(text,mode));} 
     1212    static HJson opCall(){return HJson(JSON_VALUE());} 
     1213    static HJson opCall(ubyte[] v){return HJson(JSON_VALUE(v));} 
     1214    static HJson opCall(char[] v){return HJson(JSON_VALUE(v));} 
     1215    //static HJson opCall(JSON_VALUE[] v){return HJson(JSON_VALUE(v));} 
     1216    static HJson opCall(HJson[] v) 
     1217    { 
     1218        JSON_VALUE[] vals; 
     1219        vals.length=v.length; 
     1220        foreach(i,vv;v) vals[i]=*vv.handle; 
     1221        return HJson(JSON_VALUE(vals)); 
     1222    } 
     1223    static HJson opCall(bool v){return HJson(JSON_VALUE(v));} 
     1224    static HJson opCall(double v){return HJson(JSON_VALUE(v));} 
     1225    static HJson opCall(__int64 v){return HJson(JSON_VALUE(v));} 
     1226    static HJson fromAA(K,V)(V[K] v){return HJson(JSON_VALUE.fromAA(v));} 
     1227    static HJson opCall(JSON_VALUE* value){if(value is null) return null; else return new HJson(value);} 
     1228 
     1229protected: 
     1230    this(JSON_VALUE* value){if(value is null) throw new Exception("Invalid JSON_VALUE!"); mValue=value;} 
     1231 
     1232    JSON_VALUE* mValue; 
     1233} 
     1234 
    11851235enum VALUETYPE  
    11861236{  
    11871237    V_UNDEFINED = 0,    ///< empty 
    1188     V_BOOL = 1,          ///< bool 
    1189     V_INT = 2,              ///< int 
    1190     V_REAL = 3,          ///< double 
    1191     V_STRING = 4,        ///< string of wchar_t 
    1192     V_ARRAY = 5,            ///< array of value elements 
    1193     V_MAP = 6                ///< map of name/value pairs - simple map 
     1238    V_BOOL = 1,         ///< bool 
     1239    V_INT = 2,          ///< int 
     1240    V_REAL = 3,         ///< double 
     1241    V_STRING = 4,       ///< string of wchar_t 
     1242    V_ARRAY = 5,        ///< array of value elements 
     1243    V_MAP = 6,          ///< map of name/value pairs - simple map 
     1244    V_BYTES = 7         ///< vector of bytes, a.k.a. blob 
    11941245}; 
    11951246 
     
    12011252alias VALUETYPE.V_ARRAY V_ARRAY; 
    12021253alias VALUETYPE.V_MAP V_MAP; 
     1254alias VALUETYPE.V_BYTES V_BYTES; 
    12031255 
    12041256private extern(C) alias void function(void*) wiper_t; 
     
    12071259{ 
    12081260    int refcount; 
    1209        size_t length; 
    1210        wiper_t wipe; 
     1261    size_t length; 
     1262    wiper_t wipe; 
    12111263} 
    12121264 
     
    12141266{ 
    12151267    int refcount; 
    1216        size_t length; 
    1217        wiper_t wipe; 
     1268    size_t length; 
     1269    wiper_t wipe; 
    12181270} 
    12191271 
     
    12211273{ 
    12221274    JSON_VALUE key; 
    1223         JSON_VALUE val; 
    1224         HJsonMap* next; 
    1225         wiper_t wipe; 
    1226         int refcount; 
    1227 
    1228  
    1229 alias JSON_VALUE HJson; 
     1275    JSON_VALUE val; 
     1276    HJsonMap* next; 
     1277    wiper_t wipe; 
     1278    int refcount; 
     1279
     1280 
     1281align(4) struct HJsonBytes 
     1282
     1283    int refcount; 
     1284    ubyte* data; 
     1285    size_t length;    // number of elements used in the buffer  
     1286    wiper_t wipe; 
     1287
    12301288 
    12311289align(4) struct JSON_VALUE 
    12321290{ 
    1233     VALUETYPE                  v_type; 
     1291    VALUETYPE v_type; 
    12341292    union data_slot 
    12351293    { 
    1236         int                     i_val; 
    1237         double               r_val; 
    1238         __int64             l_val; 
    1239         HJsonString*     s_val; 
    1240         HJsonArray*     a_val; // array data 
    1241         HJsonMap*           m_val; // simple map of name/value pairs. 
     1294        int i_val; 
     1295        double r_val; 
     1296        __int64 l_val; 
     1297        HJsonString* s_val; 
     1298        HJsonArray* a_val; // array data 
     1299        HJsonMap* m_val; // simple map of name/value pairs. 
     1300        HJsonBytes* b_val; // bytes data 
    12421301    } 
    12431302    data_slot data; 
     
    12451304    char[] toString() 
    12461305    { 
    1247         if(v_type==V_STRING) return .toString((cast(wchar_t*)(data.s_val+1))[0..data.s_val.length]); 
     1306        if(v_type==V_STRING) 
     1307        { 
     1308            auto str=cast(wchar_t*)(data.s_val+1); 
     1309            //todo: is this right??? 
     1310            if(data.s_val.length && str[data.s_val.length-1]==0) return .toString(str[0..data.s_val.length-1]); 
     1311            return .toString(str[0..data.s_val.length]); 
     1312        } 
     1313        else if(v_type==V_BYTES) return (cast(char*)(data.b_val+1))[0..data.b_val.length]; 
    12481314        else if(v_type==V_UNDEFINED) 
    12491315        { 
     
    12541320        else if(v_type==V_BOOL) return data.i_val?"true":"false"; 
    12551321        else if(v_type==V_REAL) return Float.toString(data.r_val); 
    1256         else throw new Exception("Don't know how to convert "~typename~"to string"); 
     1322        else throw new Exception("Don't know how to convert "~typename~" to string"); 
    12571323    } 
    12581324 
     
    12601326    { 
    12611327        if(v_type==V_ARRAY) return ((cast(JSON_VALUE*)(data.a_val+1))[0..data.a_val.length]); 
    1262         else throw new Exception("Don't know how to convert "~typename~"to string"); 
     1328        else throw new Exception("Don't know how to convert "~typename~" to string"); 
    12631329    } 
    12641330 
     
    12691335        else if(v_type==V_INT || v_type==V_BOOL) return data.i_val; 
    12701336        else if(v_type==V_STRING) return Float.toFloat(toString); 
    1271         else return double.nan;//throw new Exception("Don't know how to convert "~typename~"to float"); 
     1337        else return double.nan;//throw new Exception("Don't know how to convert "~typename~" to float"); 
    12721338    } 
    12731339 
     
    12781344        else if(v_type==V_REAL) return cast(long)data.r_val; 
    12791345        else if(v_type==V_STRING) return Int.toLong(toString); 
    1280         else throw new Exception("Don't know how to convert "~typename~"to integer"); 
     1346        else throw new Exception("Don't know how to convert "~typename~" to integer"); 
    12811347    } 
    12821348 
     
    12901356        else if(v_type==V_INT || v_type==V_BOOL) return cast(bool)data.i_val; 
    12911357        else if(v_type==V_REAL) return cast(bool)data.r_val; 
    1292         else if(v_type==V_STRING) return cast(bool)toString.length; 
    1293         else throw new Exception("Don't know how to convert "~typename~"to boolean"); 
     1358        else if(v_type==V_STRING) return data.s_val.length>0; 
     1359        else if(v_type==V_BYTES) return data.b_val.length>0; 
     1360        else throw new Exception("Don't know how to convert "~typename~" to boolean"); 
    12941361    } 
    12951362 
     
    13071374        else if(v_type==V_ARRAY) return "array"; 
    13081375        else if(v_type==V_MAP) return "map"; 
     1376        else if(v_type==V_BYTES) return "bytes"; 
    13091377        else return null; 
    13101378    } 
     
    13271395        value.v_type=V_UNDEFINED; 
    13281396        value.data.l_val=0; 
     1397        return value; 
     1398    } 
     1399 
     1400    static JSON_VALUE* opCall(ubyte[] v) 
     1401    { 
     1402        auto value=new JSON_VALUE; 
     1403        HJsonBytes* r = cast(HJsonBytes*)malloc(HJsonBytes.sizeof + v.length); 
     1404        r.refcount = 1; 
     1405        r.length = v.length; 
     1406        r.wipe = &free; 
     1407        r.data = cast(ubyte*)(r+1); 
     1408        value.v_type=V_BYTES; 
     1409        value.data.b_val=r; 
    13291410        return value; 
    13301411    } 
     
    14061487        { 
    14071488             if(--data.s_val.refcount == 0) data.s_val.wipe(data.s_val); 
     1489        } 
     1490        else if(v_type==V_BYTES) 
     1491        { 
     1492             if(--data.b_val.refcount == 0) data.b_val.wipe(data.b_val); 
    14081493        } 
    14091494        else if(v_type==V_ARRAY) 
     
    14441529    union data  
    14451530    { 
    1446         int                     i_val; 
    1447         double               r_val; 
    1448         __int64             l_val; 
    1449         void*                   s_val; 
    1450         void*                   a_val; // array data 
    1451         void*                   m_val; // simple map of name/value pairs. 
     1531        int             i_val; 
     1532        double          r_val; 
     1533        __int64         l_val; 
     1534        void*           s_val; 
     1535        void*           a_val; // array data 
     1536        void*           m_val; // simple map of name/value pairs. 
     1537        void*           b_val; // bytes_data. 
    14521538    } 
    14531539}*/ 
     
    17251811alias BOOL function( LPVOID p, HELEMENT he, int pos, int postype, WCHAR code ) HTMLayoutEnumerationCallback; 
    17261812 
     1813alias HLDOM_RESULT function (HELEMENT he, LPRECT p_location, UINT areas /*ELEMENT_AREAS*/) HTMLayoutGetElementLocation_t; 
     1814HTMLayoutGetElementLocation_t HTMLayoutGetElementLocation; 
    17271815alias HLDOM_RESULT function (HELEMENT he) HTMLayout_UseElement_t; 
    17281816HTMLayout_UseElement_t HTMLayout_UseElement; 
     
    22202308////////////////////////////////////////////////////////////////////////////// import symbols 
    22212309 
    2222 import tango.sys.SharedLib; 
    2223  
    2224 void loadHTMLayout(char[] name=null) 
    2225 
    2226     static SharedLib dll; 
    2227     dll=SharedLib.load(name?name:"htmlayout.dll"); 
    2228     HTMLayout_UseElement=cast(HTMLayout_UseElement_t)dll.getSymbol("HTMLayout_UseElement\0"); 
    2229     HTMLayout_UnuseElement=cast(HTMLayout_UnuseElement_t)dll.getSymbol("HTMLayout_UnuseElement\0"); 
    2230     HTMLayoutGetRootElement=cast(HTMLayoutGetRootElement_t)dll.getSymbol("HTMLayoutGetRootElement\0"); 
    2231     HTMLayoutGetFocusElement=cast(HTMLayoutGetFocusElement_t)dll.getSymbol("HTMLayoutGetFocusElement\0"); 
    2232     HTMLayoutFindElement=cast(HTMLayoutFindElement_t)dll.getSymbol("HTMLayoutFindElement\0"); 
    2233     HTMLayoutGetChildrenCount=cast(HTMLayoutGetChildrenCount_t)dll.getSymbol("HTMLayoutGetChildrenCount\0"); 
    2234     HTMLayoutGetNthChild=cast(HTMLayoutGetNthChild_t)dll.getSymbol("HTMLayoutGetNthChild\0"); 
    2235     HTMLayoutGetParentElement=cast(HTMLayoutGetParentElement_t)dll.getSymbol("HTMLayoutGetParentElement\0"); 
    2236     HTMLayoutGetElementText=cast(HTMLayoutGetElementText_t)dll.getSymbol("HTMLayoutGetElementText\0"); 
    2237     HTMLayoutGetElementHtml=cast(HTMLayoutGetElementHtml_t)dll.getSymbol("HTMLayoutGetElementHtml\0"); 
    2238     HTMLayoutGetElementInnerText=cast(HTMLayoutGetElementInnerText_t)dll.getSymbol("HTMLayoutGetElementInnerText\0"); 
    2239     HTMLayoutSetElementInnerText=cast(HTMLayoutSetElementInnerText_t)dll.getSymbol("HTMLayoutSetElementInnerText\0"); 
    2240     HTMLayoutGetElementInnerText16=cast(HTMLayoutGetElementInnerText16_t)dll.getSymbol("HTMLayoutGetElementInnerText16\0"); 
    2241     HTMLayoutSetElementInnerText16=cast(HTMLayoutSetElementInnerText16_t)dll.getSymbol("HTMLayoutSetElementInnerText16\0"); 
    2242     HTMLayoutGetAttributeCount=cast(HTMLayoutGetAttributeCount_t)dll.getSymbol("HTMLayoutGetAttributeCount\0"); 
    2243     HTMLayoutGetNthAttribute=cast(HTMLayoutGetNthAttribute_t)dll.getSymbol("HTMLayoutGetNthAttribute\0"); 
    2244     HTMLayoutGetAttributeByName=cast(HTMLayoutGetAttributeByName_t)dll.getSymbol("HTMLayoutGetAttributeByName\0"); 
    2245     HTMLayoutSetAttributeByName=cast(HTMLayoutSetAttributeByName_t)dll.getSymbol("HTMLayoutSetAttributeByName\0"); 
    2246     HTMLayoutClearAttributes=cast(HTMLayoutClearAttributes_t)dll.getSymbol("HTMLayoutClearAttributes\0"); 
    2247     HTMLayoutGetElementIndex=cast(HTMLayoutGetElementIndex_t)dll.getSymbol("HTMLayoutGetElementIndex\0"); 
    2248     HTMLayoutGetElementType=cast(HTMLayoutGetElementType_t)dll.getSymbol("HTMLayoutGetElementType\0"); 
    2249     HTMLayoutGetStyleAttribute=cast(HTMLayoutGetStyleAttribute_t)dll.getSymbol("HTMLayoutGetStyleAttribute\0"); 
    2250     HTMLayoutSetStyleAttribute=cast(HTMLayoutSetStyleAttribute_t)dll.getSymbol("HTMLayoutSetStyleAttribute\0"); 
    2251     HTMLayoutUpdateElement=cast(HTMLayoutUpdateElement_t)dll.getSymbol("HTMLayoutUpdateElement\0"); 
    2252     HTMLayoutUpdateElementEx=cast(HTMLayoutUpdateElementEx_t)dll.getSymbol("HTMLayoutUpdateElementEx\0"); 
    2253     HTMLayoutSetCapture=cast(HTMLayoutSetCapture_t)dll.getSymbol("HTMLayoutSetCapture\0"); 
    2254     HTMLayoutGetElementHwnd=cast(HTMLayoutGetElementHwnd_t)dll.getSymbol("HTMLayoutGetElementHwnd\0"); 
    2255     HTMLayoutCombineURL=cast(HTMLayoutCombineURL_t)dll.getSymbol("HTMLayoutCombineURL\0"); 
    2256     HTMLayoutVisitElements=cast(HTMLayoutVisitElements_t)dll.getSymbol("HTMLayoutVisitElements\0"); 
    2257     HTMLayoutSelectElements=cast(HTMLayoutSelectElements_t)dll.getSymbol("HTMLayoutSelectElements\0"); 
    2258     HTMLayoutSelectParent=cast(HTMLayoutSelectParent_t)dll.getSymbol("HTMLayoutSelectParent\0"); 
    2259     HTMLayoutSetElementHtml=cast(HTMLayoutSetElementHtml_t)dll.getSymbol("HTMLayoutSetElementHtml\0"); 
    2260     HTMLayoutDeleteElement=cast(HTMLayoutDeleteElement_t)dll.getSymbol("HTMLayoutDeleteElement\0"); 
    2261     HTMLayoutGetElementUID=cast(HTMLayoutGetElementUID_t)dll.getSymbol("HTMLayoutGetElementUID\0"); 
    2262     HTMLayoutGetElementByUID=cast(HTMLayoutGetElementByUID_t)dll.getSymbol("HTMLayoutGetElementByUID\0"); 
    2263     HTMLayoutShowPopup=cast(HTMLayoutShowPopup_t)dll.getSymbol("HTMLayoutShowPopup\0"); 
    2264     HTMLayoutShowPopupAt=cast(HTMLayoutShowPopupAt_t)dll.getSymbol("HTMLayoutShowPopupAt\0"); 
    2265     HTMLayoutHidePopup=cast(HTMLayoutHidePopup_t)dll.getSymbol("HTMLayoutHidePopup\0"); 
    2266     HTMLayoutGetElementState=cast(HTMLayoutGetElementState_t)dll.getSymbol("HTMLayoutGetElementState\0"); 
    2267     HTMLayoutCreateElement=cast(HTMLayoutCreateElement_t)dll.getSymbol("HTMLayoutCreateElement\0"); 
    2268     HTMLayoutCloneElement=cast(HTMLayoutCloneElement_t)dll.getSymbol("HTMLayoutCloneElement\0"); 
    2269     HTMLayoutInsertElement=cast(HTMLayoutInsertElement_t)dll.getSymbol("HTMLayoutInsertElement\0"); 
    2270     HTMLayoutDetachElement=cast(HTMLayoutDetachElement_t)dll.getSymbol("HTMLayoutDetachElement\0"); 
    2271     HTMLayoutSetTimer=cast(HTMLayoutSetTimer_t)dll.getSymbol("HTMLayoutSetTimer\0"); 
    2272     HTMLayoutAttachEventHandler=cast(HTMLayoutAttachEventHandler_t)dll.getSymbol("HTMLayoutAttachEventHandler\0"); 
    2273     HTMLayoutAttachEventHandlerEx=cast(HTMLayoutAttachEventHandlerEx_t)dll.getSymbol("HTMLayoutAttachEventHandlerEx\0"); 
    2274     HTMLayoutWindowAttachEventHandler=cast(HTMLayoutWindowAttachEventHandler_t)dll.getSymbol("HTMLayoutWindowAttachEventHandler\0"); 
    2275     HTMLayoutSendEvent=cast(HTMLayoutSendEvent_t)dll.getSymbol("HTMLayoutSendEvent\0"); 
    2276     HTMLayoutPostEvent=cast(HTMLayoutPostEvent_t)dll.getSymbol("HTMLayoutPostEvent\0"); 
    2277     HTMLayoutCallBehaviorMethod=cast(HTMLayoutCallBehaviorMethod_t)dll.getSymbol("HTMLayoutCallBehaviorMethod\0"); 
    2278     HTMLayoutRequestElementData=cast(HTMLayoutRequestElementData_t)dll.getSymbol("HTMLayoutRequestElementData\0"); 
    2279     HTMLayoutGetScrollInfo=cast(HTMLayoutGetScrollInfo_t)dll.getSymbol("HTMLayoutGetScrollInfo\0"); 
    2280     HTMLayoutSetScrollPos=cast(HTMLayoutSetScrollPos_t)dll.getSymbol("HTMLayoutSetScrollPos\0"); 
    2281     HTMLayoutIsElementVisible=cast(HTMLayoutIsElementVisible_t)dll.getSymbol("HTMLayoutIsElementVisible\0"); 
    2282     HTMLayoutIsElementEnabled=cast(HTMLayoutIsElementEnabled_t)dll.getSymbol("HTMLayoutIsElementEnabled\0"); 
    2283     HTMLayoutSortElements=cast(HTMLayoutSortElements_t)dll.getSymbol("HTMLayoutSortElements\0"); 
    2284     HTMLayoutSwapElements=cast(HTMLayoutSwapElements_t)dll.getSymbol("HTMLayoutSwapElements\0"); 
    2285     HTMLayoutTraverseUIEvent=cast(HTMLayoutTraverseUIEvent_t)dll.getSymbol("HTMLayoutTraverseUIEvent\0"); 
    2286     HTMLayoutControlGetType=cast(HTMLayoutControlGetType_t)dll.getSymbol("HTMLayoutControlGetType\0"); 
    2287     HTMLayoutControlGetValue=cast(HTMLayoutControlGetValue_t)dll.getSymbol("HTMLayoutControlGetValue\0"); 
    2288     HTMLayoutControlSetValue=cast(HTMLayoutControlSetValue_t)dll.getSymbol("HTMLayoutControlSetValue\0"); 
    2289     HTMLayoutEnumerate=cast(HTMLayoutEnumerate_t)dll.getSymbol("HTMLayoutEnumerate\0"); 
    2290     HTMLayoutGetCharacterRect=cast(HTMLayoutGetCharacterRect_t)dll.getSymbol("HTMLayoutGetCharacterRect\0"); 
    2291     HTMLayoutClassNameA=cast(HTMLayoutClassNameA_t)dll.getSymbol("HTMLayoutClassNameA\0"); 
    2292     HTMLayoutClassNameW=cast(HTMLayoutClassNameW_t)dll.getSymbol("HTMLayoutClassNameW\0"); 
    2293     HTMLayoutDataReady=cast(HTMLayoutDataReady_t)dll.getSymbol("HTMLayoutDataReady\0"); 
    2294     HTMLayoutDataReadyAsync=cast(HTMLayoutDataReadyAsync_t)dll.getSymbol("HTMLayoutDataReadyAsync\0"); 
    2295     HTMLayoutProc=cast(HTMLayoutProc_t)dll.getSymbol("HTMLayoutProc\0"); 
    2296     HTMLayoutProcND=cast(HTMLayoutProcND_t)dll.getSymbol("HTMLayoutProcND\0"); 
    2297     HTMLayoutGetMinWidth=cast(HTMLayoutGetMinWidth_t)dll.getSymbol("HTMLayoutGetMinWidth\0"); 
    2298     HTMLayoutGetMinHeight=cast(HTMLayoutGetMinHeight_t)dll.getSymbol("HTMLayoutGetMinHeight\0"); 
    2299     HTMLayoutLoadFile=cast(HTMLayoutLoadFile_t)dll.getSymbol("HTMLayoutLoadFile\0"); 
    2300     HTMLayoutLoadHtml=cast(HTMLayoutLoadHtml_t)dll.getSymbol("HTMLayoutLoadHtml\0"); 
    2301     HTMLayoutLoadHtmlEx=cast(HTMLayoutLoadHtmlEx_t)dll.getSymbol("HTMLayoutLoadHtmlEx\0"); 
    2302     HTMLayoutSetMode=cast(HTMLayoutSetMode_t)dll.getSymbol("HTMLayoutSetMode\0"); 
    2303     HTMLayoutSetCallback=cast(HTMLayoutSetCallback_t)dll.getSymbol("HTMLayoutSetCallback\0"); 
    2304     HTMLayoutSelectionExist=cast(HTMLayoutSelectionExist_t)dll.getSymbol("HTMLayoutSelectionExist\0"); 
    2305     HTMLayoutGetSelectedHTML=cast(HTMLayoutGetSelectedHTML_t)dll.getSymbol("HTMLayoutGetSelectedHTML\0"); 
    2306     HTMLayoutClipboardCopy=cast(HTMLayoutClipboardCopy_t)dll.getSymbol("HTMLayoutClipboardCopy\0"); 
    2307     HTMLayoutEnumResources=cast(HTMLayoutEnumResources_t)dll.getSymbol("HTMLayoutEnumResources\0"); 
    2308     HTMLayoutSetMasterCSS=cast(HTMLayoutSetMasterCSS_t)dll.getSymbol("HTMLayoutSetMasterCSS\0"); 
    2309     HTMLayoutSetCSS=cast(HTMLayoutSetCSS_t)dll.getSymbol("HTMLayoutSetCSS\0"); 
    2310     HTMLayoutSetMediaType=cast(HTMLayoutSetMediaType_t)dll.getSymbol("HTMLayoutSetMediaType\0"); 
    2311     HTMLayoutSetHttpHeaders=cast(HTMLayoutSetHttpHeaders_t)dll.getSymbol("HTMLayoutSetHttpHeaders\0"); 
    2312     HTMLayoutRender=cast(HTMLayoutRender_t)dll.getSymbol("HTMLayoutRender\0"); 
    2313     HTMLayoutDialog=cast(HTMLayoutDialog_t)dll.getSymbol("HTMLayoutDialog\0"); 
    2314     HTMLiteCreateInstance=cast(HTMLiteCreateInstance_t)dll.getSymbol("HTMLiteCreateInstance\0"); 
    2315     HTMLiteDestroyInstance=cast(HTMLiteDestroyInstance_t)dll.getSymbol("HTMLiteDestroyInstance\0"); 
    2316     HTMLiteSetTag=cast(HTMLiteSetTag_t)dll.getSymbol("HTMLiteSetTag\0"); 
    2317     HTMLiteGetTag=cast(HTMLiteGetTag_t)dll.getSymbol("HTMLiteGetTag\0"); 
    2318     HTMLiteLoadHtmlFromFile=cast(HTMLiteLoadHtmlFromFile_t)dll.getSymbol("HTMLiteLoadHtmlFromFile\0"); 
    2319     HTMLiteLoadHtmlFromMemory=cast(HTMLiteLoadHtmlFromMemory_t)dll.getSymbol("HTMLiteLoadHtmlFromMemory\0"); 
    2320     HTMLiteMeasure=cast(HTMLiteMeasure_t)dll.getSymbol("HTMLiteMeasure\0"); 
    2321     HTMLiteRender=cast(HTMLiteRender_t)dll.getSymbol("HTMLiteRender\0"); 
    2322     HTMLiteRenderOnBitmap=cast(HTMLiteRenderOnBitmap_t)dll.getSymbol("HTMLiteRenderOnBitmap\0"); 
    2323     HTMLiteSetDataReady=cast(HTMLiteSetDataReady_t)dll.getSymbol("HTMLiteSetDataReady\0"); 
    2324     HTMLiteGetDocumentMinWidth=cast(HTMLiteGetDocumentMinWidth_t)dll.getSymbol("HTMLiteGetDocumentMinWidth\0"); 
    2325     HTMLiteGetDocumentMinHeight=cast(HTMLiteGetDocumentMinHeight_t)dll.getSymbol("HTMLiteGetDocumentMinHeight\0"); 
    2326     HTMLiteSetMediaType=cast(HTMLiteSetMediaType_t)dll.getSymbol("HTMLiteSetMediaType\0"); 
    2327     HTMLiteGetRootElement=cast(HTMLiteGetRootElement_t)dll.getSymbol("HTMLiteGetRootElement\0"); 
    2328     HTMLiteFindElement=cast(HTMLiteFindElement_t)dll.getSymbol("HTMLiteFindElement\0"); 
    2329     HTMLiteSetCallback=cast(HTMLiteSetCallback_t)dll.getSymbol("HTMLiteSetCallback\0"); 
    2330     HTMLiteAdvanceFocus=cast(HTMLiteAdvanceFocus_t)dll.getSymbol("HTMLiteAdvanceFocus\0"); 
    2331     HTMLiteTraverseUIEvent=cast(HTMLiteTraverseUIEvent_t)dll.getSymbol("HTMLiteTraverseUIEvent\0"); 
    2332     HTMLayoutSetElementState=cast(HTMLayoutSetElementState_t)dll.getSymbol("HTMLayoutSetElementState\0"); 
    2333     HTMLayoutDetachEventHandler=cast(HTMLayoutDetachEventHandler_t)dll.getSymbol("HTMLayoutDetachEventHandler\0"); 
    2334     HTMLayoutWindowDetachEventHandler=cast(HTMLayoutWindowDetachEventHandler_t)dll.getSymbol("HTMLayoutWindowDetachEventHandler\0"); 
    2335     HTMLayoutRangeCreate=cast(HTMLayoutRangeCreate_t)dll.getSymbol("HTMLayoutRangeCreate\0"); 
    2336     HTMLayoutRangeFromSelection=cast(HTMLayoutRangeFromSelection_t)dll.getSymbol("HTMLayoutRangeFromSelection\0"); 
    2337     HTMLayoutRangeFromPositions=cast(HTMLayoutRangeFromPositions_t)dll.getSymbol("HTMLayoutRangeFromPositions\0"); 
    2338     HTMLayoutRangeRelease=cast(HTMLayoutRangeRelease_t)dll.getSymbol("HTMLayoutRangeRelease\0"); 
    2339     HTMLayoutRangeAdvancePos=cast(HTMLayoutRangeAdvancePos_t)dll.getSymbol("HTMLayoutRangeAdvancePos\0"); 
    2340     HTMLayoutRangeToHtml=cast(HTMLayoutRangeToHtml_t)dll.getSymbol("HTMLayoutRangeToHtml\0"); 
    2341     HTMLayoutRangeReplace=cast(HTMLayoutRangeReplace_t)dll.getSymbol("HTMLayoutRangeReplace\0"); 
    2342     HTMLayoutRangeInsertHtml=cast(HTMLayoutRangeInsertHtml_t)dll.getSymbol("HTMLayoutRangeInsertHtml\0"); 
    2343     HTMLayoutRangeIsEmpty=cast(HTMLayoutRangeIsEmpty_t)dll.getSymbol("HTMLayoutRangeIsEmpty\0"); 
    2344     HTMLayoutSetOption=cast(HTMLayoutSetOption_t)dll.getSymbol("HTMLayoutSetOption\0"); 
    2345     HTMLayoutDeclareElementType=cast(HTMLayoutDeclareElementType_t)dll.getSymbol("HTMLayoutDeclareElementType\0"); 
    2346     HTMLayoutAppendMasterCSS=cast(HTMLayoutAppendMasterCSS_t)dll.getSymbol("HTMLayoutAppendMasterCSS\0"); 
    2347     HTMLayoutScrollToView=cast(HTMLayoutScrollToView_t)dll.getSymbol("HTMLayoutScrollToView\0"); 
    2348     HTMLayoutElementSetExpando=cast(HTMLayoutElementSetExpando_t)dll.getSymbol("HTMLayoutElementSetExpando\0"); 
    2349     HTMLayoutElementGetExpando=cast(HTMLayoutElementGetExpando_t)dll.getSymbol("HTMLayoutElementGetExpando\0"); 
    2350     HTMLayoutParseValue=cast(HTMLayoutParseValue_t)dll.getSymbol("HTMLayoutParseValue\0"); 
    2351     HTMLayoutGetGraphin=cast(HTMLayoutGetGraphin_t)dll.getSymbol("HTMLayoutGetGraphin\0"); 
    2352     HTMLayoutRenderElement=cast(HTMLayoutRenderElement_t)dll.getSymbol("HTMLayoutRenderElement\0"); 
    2353 
     2310import flowerd.sharedlib; 
     2311 
     2312bool loadHTMLayout(char[] name=null,void[] data=null) 
     2313
     2314    scope SharedLib dll; 
     2315    if(name is null) name="htmlayout.dll"; 
     2316    if(data is null) dll=SharedLib(name); 
     2317    else dll=SharedLib(name,data); 
     2318    if(dll is null) return false; 
     2319 
     2320    HTMLayout_UseElement=cast(HTMLayout_UseElement_t)dll.symbol("HTMLayout_UseElement\0"); 
     2321    HTMLayout_UnuseElement=cast(HTMLayout_UnuseElement_t)dll.symbol("HTMLayout_UnuseElement\0"); 
     2322    HTMLayoutGetRootElement=cast(HTMLayoutGetRootElement_t)dll.symbol("HTMLayoutGetRootElement\0"); 
     2323    HTMLayoutGetFocusElement=cast(HTMLayoutGetFocusElement_t)dll.symbol("HTMLayoutGetFocusElement\0"); 
     2324    HTMLayoutFindElement=cast(HTMLayoutFindElement_t)dll.symbol("HTMLayoutFindElement\0"); 
     2325    HTMLayoutGetChildrenCount=cast(HTMLayoutGetChildrenCount_t)dll.symbol("HTMLayoutGetChildrenCount\0"); 
     2326    HTMLayoutGetNthChild=cast(HTMLayoutGetNthChild_t)dll.symbol("HTMLayoutGetNthChild\0"); 
     2327    HTMLayoutGetParentElement=cast(HTMLayoutGetParentElement_t)dll.symbol("HTMLayoutGetParentElement\0"); 
     2328    HTMLayoutGetElementText=cast(HTMLayoutGetElementText_t)dll.symbol("HTMLayoutGetElementText\0"); 
     2329    HTMLayoutGetElementHtml=cast(HTMLayoutGetElementHtml_t)dll.symbol("HTMLayoutGetElementHtml\0"); 
     2330    HTMLayoutGetElementInnerText=cast(HTMLayoutGetElementInnerText_t)dll.symbol("HTMLayoutGetElementInnerText\0"); 
     2331    HTMLayoutSetElementInnerText=cast(HTMLayoutSetElementInnerText_t)dll.symbol("HTMLayoutSetElementInnerText\0"); 
     2332    HTMLayoutGetElementInnerText16=cast(HTMLayoutGetElementInnerText16_t)dll.symbol("HTMLayoutGetElementInnerText16\0"); 
     2333    HTMLayoutSetElementInnerText16=cast(HTMLayoutSetElementInnerText16_t)dll.symbol("HTMLayoutSetElementInnerText16\0"); 
     2334    HTMLayoutGetAttributeCount=cast(HTMLayoutGetAttributeCount_t)dll.symbol("HTMLayoutGetAttributeCount\0"); 
     2335    HTMLayoutGetNthAttribute=cast(HTMLayoutGetNthAttribute_t)dll.symbol("HTMLayoutGetNthAttribute\0"); 
     2336    HTMLayoutGetAttributeByName=cast(HTMLayoutGetAttributeByName_t)dll.symbol("HTMLayoutGetAttributeByName\0"); 
     2337    HTMLayoutSetAttributeByName=cast(HTMLayoutSetAttributeByName_t)dll.symbol("HTMLayoutSetAttributeByName\0"); 
     2338    HTMLayoutClearAttributes=cast(HTMLayoutClearAttributes_t)dll.symbol("HTMLayoutClearAttributes\0"); 
     2339    HTMLayoutGetElementIndex=cast(HTMLayoutGetElementIndex_t)dll.symbol("HTMLayoutGetElementIndex\0"); 
     2340    HTMLayoutGetElementType=cast(HTMLayoutGetElementType_t)dll.symbol("HTMLayoutGetElementType\0"); 
     2341    HTMLayoutGetStyleAttribute=cast(HTMLayoutGetStyleAttribute_t)dll.symbol("HTMLayoutGetStyleAttribute\0"); 
     2342    HTMLayoutSetStyleAttribute=cast(HTMLayoutSetStyleAttribute_t)dll.symbol("HTMLayoutSetStyleAttribute\0"); 
     2343    HTMLayoutUpdateElement=cast(HTMLayoutUpdateElement_t)dll.symbol("HTMLayoutUpdateElement\0"); 
     2344    HTMLayoutUpdateElementEx=cast(HTMLayoutUpdateElementEx_t)dll.symbol("HTMLayoutUpdateElementEx\0"); 
     2345    HTMLayoutSetCapture=cast(HTMLayoutSetCapture_t)dll.symbol("HTMLayoutSetCapture\0"); 
     2346    HTMLayoutGetElementHwnd=cast(HTMLayoutGetElementHwnd_t)dll.symbol("HTMLayoutGetElementHwnd\0"); 
     2347    HTMLayoutCombineURL=cast(HTMLayoutCombineURL_t)dll.symbol("HTMLayoutCombineURL\0"); 
     2348    HTMLayoutVisitElements=cast(HTMLayoutVisitElements_t)dll.symbol("HTMLayoutVisitElements\0"); 
     2349    HTMLayoutSelectElements=cast(HTMLayoutSelectElements_t)dll.symbol("HTMLayoutSelectElements\0"); 
     2350    HTMLayoutSelectParent=cast(HTMLayoutSelectParent_t)dll.symbol("HTMLayoutSelectParent\0"); 
     2351    HTMLayoutSetElementHtml=cast(HTMLayoutSetElementHtml_t)dll.symbol("HTMLayoutSetElementHtml\0"); 
     2352    HTMLayoutDeleteElement=cast(HTMLayoutDeleteElement_t)dll.symbol("HTMLayoutDeleteElement\0"); 
     2353    HTMLayoutGetElementUID=cast(HTMLayoutGetElementUID_t)dll.symbol("HTMLayoutGetElementUID\0"); 
     2354    HTMLayoutGetElementByUID=cast(HTMLayoutGetElementByUID_t)dll.symbol("HTMLayoutGetElementByUID\0"); 
     2355    HTMLayoutShowPopup=cast(HTMLayoutShowPopup_t)dll.symbol("HTMLayoutShowPopup\0"); 
     2356    HTMLayoutShowPopupAt=cast(HTMLayoutShowPopupAt_t)dll.symbol("HTMLayoutShowPopupAt\0"); 
     2357    HTMLayoutHidePopup=cast(HTMLayoutHidePopup_t)dll.symbol("HTMLayoutHidePopup\0"); 
     2358    HTMLayoutGetElementState=cast(HTMLayoutGetElementState_t)dll.symbol("HTMLayoutGetElementState\0"); 
     2359    HTMLayoutCreateElement=cast(HTMLayoutCreateElement_t)dll.symbol("HTMLayoutCreateElement\0"); 
     2360    HTMLayoutCloneElement=cast(HTMLayoutCloneElement_t)dll.symbol("HTMLayoutCloneElement\0"); 
     2361    HTMLayoutInsertElement=cast(HTMLayoutInsertElement_t)dll.symbol("HTMLayoutInsertElement\0"); 
     2362    HTMLayoutDetachElement=cast(HTMLayoutDetachElement_t)dll.symbol("HTMLayoutDetachElement\0"); 
     2363    HTMLayoutSetTimer=cast(HTMLayoutSetTimer_t)dll.symbol("HTMLayoutSetTimer\0"); 
     2364    HTMLayoutAttachEventHandler=cast(HTMLayoutAttachEventHandler_t)dll.symbol("HTMLayoutAttachEventHandler\0"); 
     2365    HTMLayoutAttachEventHandlerEx=cast(HTMLayoutAttachEventHandlerEx_t)dll.symbol("HTMLayoutAttachEventHandlerEx\0"); 
     2366    HTMLayoutWindowAttachEventHandler=cast(HTMLayoutWindowAttachEventHandler_t)dll.symbol("HTMLayoutWindowAttachEventHandler\0"); 
     2367    HTMLayoutSendEvent=cast(HTMLayoutSendEvent_t)dll.symbol("HTMLayoutSendEvent\0"); 
     2368    HTMLayoutPostEvent=cast(HTMLayoutPostEvent_t)dll.symbol("HTMLayoutPostEvent\0"); 
     2369    HTMLayoutCallBehaviorMethod=cast(HTMLayoutCallBehaviorMethod_t)dll.symbol("HTMLayoutCallBehaviorMethod\0"); 
     2370    HTMLayoutRequestElementData=cast(HTMLayoutRequestElementData_t)dll.symbol("HTMLayoutRequestElementData\0"); 
     2371    HTMLayoutGetScrollInfo=cast(HTMLayoutGetScrollInfo_t)dll.symbol("HTMLayoutGetScrollInfo\0"); 
     2372    HTMLayoutSetScrollPos=cast(HTMLayoutSetScrollPos_t)dll.symbol("HTMLayoutSetScrollPos\0"); 
     2373    HTMLayoutIsElementVisible=cast(HTMLayoutIsElementVisible_t)dll.symbol("HTMLayoutIsElementVisible\0"); 
     2374    HTMLayoutIsElementEnabled=cast(HTMLayoutIsElementEnabled_t)dll.symbol("HTMLayoutIsElementEnabled\0"); 
     2375    HTMLayoutSortElements=cast(HTMLayoutSortElements_t)dll.symbol("HTMLayoutSortElements\0"); 
     2376    HTMLayoutSwapElements=cast(HTMLayoutSwapElements_t)dll.symbol("HTMLayoutSwapElements\0"); 
     2377    HTMLayoutTraverseUIEvent=cast(HTMLayoutTraverseUIEvent_t)dll.symbol("HTMLayoutTraverseUIEvent\0"); 
     2378    HTMLayoutControlGetType=cast(HTMLayoutControlGetType_t)dll.symbol("HTMLayoutControlGetType\0"); 
     2379    HTMLayoutControlGetValue=cast(HTMLayoutControlGetValue_t)dll.symbol("HTMLayoutControlGetValue\0"); 
     2380    HTMLayoutControlSetValue=cast(HTMLayoutControlSetValue_t)dll.symbol("HTMLayoutControlSetValue\0"); 
     2381    HTMLayoutEnumerate=cast(HTMLayoutEnumerate_t)dll.symbol("HTMLayoutEnumerate\0"); 
     2382    HTMLayoutGetCharacterRect=cast(HTMLayoutGetCharacterRect_t)dll.symbol("HTMLayoutGetCharacterRect\0"); 
     2383    HTMLayoutClassNameA=cast(HTMLayoutClassNameA_t)dll.symbol("HTMLayoutClassNameA\0"); 
     2384    HTMLayoutClassNameW=cast(HTMLayoutClassNameW_t)dll.symbol("HTMLayoutClassNameW\0"); 
     2385    HTMLayoutDataReady=cast(HTMLayoutDataReady_t)dll.symbol("HTMLayoutDataReady\0"); 
     2386    HTMLayoutDataReadyAsync=cast(HTMLayoutDataReadyAsync_t)dll.symbol("HTMLayoutDataReadyAsync\0"); 
     2387    HTMLayoutProc=cast(HTMLayoutProc_t)dll.symbol("HTMLayoutProc\0"); 
     2388    HTMLayoutProcND=cast(HTMLayoutProcND_t)dll.symbol("HTMLayoutProcND\0"); 
     2389    HTMLayoutGetMinWidth=cast(HTMLayoutGetMinWidth_t)dll.symbol("HTMLayoutGetMinWidth\0"); 
     2390    HTMLayoutGetMinHeight=cast(HTMLayoutGetMinHeight_t)dll.symbol("HTMLayoutGetMinHeight\0"); 
     2391    HTMLayoutLoadFile=cast(HTMLayoutLoadFile_t)dll.symbol("HTMLayoutLoadFile\0"); 
     2392    HTMLayoutLoadHtml=cast(HTMLayoutLoadHtml_t)dll.symbol("HTMLayoutLoadHtml\0"); 
     2393    HTMLayoutLoadHtmlEx=cast(HTMLayoutLoadHtmlEx_t)dll.symbol("HTMLayoutLoadHtmlEx\0"); 
     2394    HTMLayoutSetMode=cast(HTMLayoutSetMode_t)dll.symbol("HTMLayoutSetMode\0"); 
     2395    HTMLayoutSetCallback=cast(HTMLayoutSetCallback_t)dll.symbol("HTMLayoutSetCallback\0"); 
     2396    HTMLayoutSelectionExist=cast(HTMLayoutSelectionExist_t)dll.symbol("HTMLayoutSelectionExist\0"); 
     2397    HTMLayoutGetSelectedHTML=cast(HTMLayoutGetSelectedHTML_t)dll.symbol("HTMLayoutGetSelectedHTML\0"); 
     2398    HTMLayoutClipboardCopy=cast(HTMLayoutClipboardCopy_t)dll.symbol("HTMLayoutClipboardCopy\0"); 
     2399    HTMLayoutEnumResources=cast(HTMLayoutEnumResources_t)dll.symbol("HTMLayoutEnumResources\0"); 
     2400    HTMLayoutSetMasterCSS=cast(HTMLayoutSetMasterCSS_t)dll.symbol("HTMLayoutSetMasterCSS\0"); 
     2401    HTMLayoutSetCSS=cast(HTMLayoutSetCSS_t)dll.symbol("HTMLayoutSetCSS\0"); 
     2402    HTMLayoutSetMediaType=cast(HTMLayoutSetMediaType_t)dll.symbol("HTMLayoutSetMediaType\0"); 
     2403    HTMLayoutSetHttpHeaders=cast(HTMLayoutSetHttpHeaders_t)dll.symbol("HTMLayoutSetHttpHeaders\0"); 
     2404    HTMLayoutRender=cast(HTMLayoutRender_t)dll.symbol("HTMLayoutRender\0"); 
     2405    HTMLayoutDialog=cast(HTMLayoutDialog_t)dll.symbol("HTMLayoutDialog\0"); 
     2406    HTMLiteCreateInstance=cast(HTMLiteCreateInstance_t)dll.symbol("HTMLiteCreateInstance\0"); 
     2407    HTMLiteDestroyInstance=cast(HTMLiteDestroyInstance_t)dll.symbol("HTMLiteDestroyInstance\0"); 
     2408    HTMLiteSetTag=cast(HTMLiteSetTag_t)dll.symbol("HTMLiteSetTag\0"); 
     2409    HTMLiteGetTag=cast(HTMLiteGetTag_t)dll.symbol("HTMLiteGetTag\0"); 
     2410    HTMLiteLoadHtmlFromFile=cast(HTMLiteLoadHtmlFromFile_t)dll.symbol("HTMLiteLoadHtmlFromFile\0"); 
     2411    HTMLiteLoadHtmlFromMemory=cast(HTMLiteLoadHtmlFromMemory_t)dll.symbol("HTMLiteLoadHtmlFromMemory\0"); 
     2412    HTMLiteMeasure=cast(HTMLiteMeasure_t)dll.symbol("HTMLiteMeasure\0"); 
     2413    HTMLiteRender=cast(HTMLiteRender_t)dll.symbol("HTMLiteRender\0"); 
     2414    HTMLiteRenderOnBitmap=cast(HTMLiteRenderOnBitmap_t)dll.symbol("HTMLiteRenderOnBitmap\0"); 
     2415    HTMLiteSetDataReady=cast(HTMLiteSetDataReady_t)dll.symbol("HTMLiteSetDataReady\0"); 
     2416    HTMLiteGetDocumentMinWidth=cast(HTMLiteGetDocumentMinWidth_t)dll.symbol("HTMLiteGetDocumentMinWidth\0"); 
     2417    HTMLiteGetDocumentMinHeight=cast(HTMLiteGetDocumentMinHeight_t)dll.symbol("HTMLiteGetDocumentMinHeight\0"); 
     2418    HTMLiteSetMediaType=cast(HTMLiteSetMediaType_t)dll.symbol("HTMLiteSetMediaType\0"); 
     2419    HTMLiteGetRootElement=cast(HTMLiteGetRootElement_t)dll.symbol("HTMLiteGetRootElement\0"); 
     2420    HTMLiteFindElement=cast(HTMLiteFindElement_t)dll.symbol("HTMLiteFindElement\0"); 
     2421    HTMLiteSetCallback=cast(HTMLiteSetCallback_t)dll.symbol("HTMLiteSetCallback\0"); 
     2422    HTMLiteAdvanceFocus=cast(HTMLiteAdvanceFocus_t)dll.symbol("HTMLiteAdvanceFocus\0"); 
     2423    HTMLiteTraverseUIEvent=cast(HTMLiteTraverseUIEvent_t)dll.symbol("HTMLiteTraverseUIEvent\0"); 
     2424    HTMLayoutSetElementState=cast(HTMLayoutSetElementState_t)dll.symbol("HTMLayoutSetElementState\0"); 
     2425    HTMLayoutDetachEventHandler=cast(HTMLayoutDetachEventHandler_t)dll.symbol("HTMLayoutDetachEventHandler\0"); 
     2426    HTMLayoutWindowDetachEventHandler=cast(HTMLayoutWindowDetachEventHandler_t)dll.symbol("HTMLayoutWindowDetachEventHandler\0"); 
     2427    HTMLayoutRangeCreate=cast(HTMLayoutRangeCreate_t)dll.symbol("HTMLayoutRangeCreate\0"); 
     2428    HTMLayoutRangeFromSelection=cast(HTMLayoutRangeFromSelection_t)dll.symbol("HTMLayoutRangeFromSelection\0"); 
     2429    HTMLayoutRangeFromPositions=cast(HTMLayoutRangeFromPositions_t)dll.symbol("HTMLayoutRangeFromPositions\0"); 
     2430    HTMLayoutRangeRelease=cast(HTMLayoutRangeRelease_t)dll.symbol("HTMLayoutRangeRelease\0"); 
     2431    HTMLayoutRangeAdvancePos=cast(HTMLayoutRangeAdvancePos_t)dll.symbol("HTMLayoutRangeAdvancePos\0"); 
     2432    HTMLayoutRangeToHtml=cast(HTMLayoutRangeToHtml_t)dll.symbol("HTMLayoutRangeToHtml\0"); 
     2433    HTMLayoutRangeReplace=cast(HTMLayoutRangeReplace_t)dll.symbol("HTMLayoutRangeReplace\0"); 
     2434    HTMLayoutRangeInsertHtml=cast(HTMLayoutRangeInsertHtml_t)dll.symbol("HTMLayoutRangeInsertHtml\0"); 
     2435    HTMLayoutRangeIsEmpty=cast(HTMLayoutRangeIsEmpty_t)dll.symbol("HTMLayoutRangeIsEmpty\0"); 
     2436    HTMLayoutSetOption=cast(HTMLayoutSetOption_t)dll.symbol("HTMLayoutSetOption\0"); 
     2437    HTMLayoutDeclareElementType=cast(HTMLayoutDeclareElementType_t)dll.symbol("HTMLayoutDeclareElementType\0"); 
     2438    HTMLayoutAppendMasterCSS=cast(HTMLayoutAppendMasterCSS_t)dll.symbol("HTMLayoutAppendMasterCSS\0"); 
     2439    HTMLayoutScrollToView=cast(HTMLayoutScrollToView_t)dll.symbol("HTMLayoutScrollToView\0"); 
     2440    HTMLayoutElementSetExpando=cast(HTMLayoutElementSetExpando_t)dll.symbol("HTMLayoutElementSetExpando\0"); 
     2441    HTMLayoutElementGetExpando=cast(HTMLayoutElementGetExpando_t)dll.symbol("HTMLayoutElementGetExpando\0"); 
     2442    HTMLayoutParseValue=cast(HTMLayoutParseValue_t)dll.symbol("HTMLayoutParseValue\0"); 
     2443    HTMLayoutGetGraphin=cast(HTMLayoutGetGraphin_t)dll.symbol("HTMLayoutGetGraphin\0"); 
     2444    HTMLayoutRenderElement=cast(HTMLayoutRenderElement_t)dll.symbol("HTMLayoutRenderElement\0"); 
     2445    HTMLayoutGetElementLocation=cast(HTMLayoutGetElementLocation_t)dll.symbol("HTMLayoutGetElementLocation\0"); 
     2446 
     2447    return true; 
     2448
  • trunk/import/htmlayout/element.d

    r17 r18  
    1212alias bool delegate(HElement e,UINT evtgm,LPVOID prms) HElement_event_callback_t; 
    1313alias bool delegate(HElement,PVOID param) HElement_callback_t; 
    14 alias bool delegate(HElement,LPVOID p,int pos, int postype, wchar code) HElement_enum_callback_t; 
    15  
    16 extern(Windows) BOOL ReleaseCapture(); 
     14alias bool delegate(HElement,LPVOID p,int pos,int postype,wchar code) HElement_enum_callback_t; 
     15 
     16extern(Windows) 
     17
     18    BOOL ReleaseCapture(); 
     19    BOOL PtInRect(RECT *lprc,POINT pt); 
     20
    1721 
    1822template EVENT_HANDLER_STRING2(char[] NAME,char[] EVENT) 
     
    6973        } 
    7074     
    71         bool opCall(char[] name, char[] value) //setter 
     75        bool opCall(char[] name,char[] value) //setter 
    7276        {return (lastResult=HTMLayoutSetStyleAttribute(mHandle,toStringz(name),toString16z(toString16(value))))==HLDOM_OK;} 
    7377    } 
     
    210214    } 
    211215 
    212     bool attribute(UINT n, ref char[] name, ref char[] value) //getter 
     216    bool attribute(UINT n,ref char[] name,ref char[] value) //getter 
    213217    { 
    214218        LPCSTR p_name; 
     
    287291    } 
    288292 
    289     HElement[] wildcard(char[] tagName, char[] attributeName=null, char[] attributeValue=null, DWORD depth=0, uint max=0) 
     293    HElement[] wildcard(char[] tagName,char[] attributeName=null,char[] attributeValue=null,DWORD depth=0,uint max=0) 
    290294    { 
    291295        auto ret=new GrowStack!(HElement)(max>0?max:15); 
     
    300304    } 
    301305 
    302     bool wildcard(char[] tagName, char[] attributeName, char[] attributeValue, HElement_callback_t callback, LPVOID param=null, DWORD depth=0) 
     306    bool wildcard(char[] tagName,char[] attributeName,char[] attributeValue,HElement_callback_t callback,LPVOID param=null,DWORD depth=0) 
    303307    {synchronized{ 
    304308 
     
    379383    } 
    380384 
    381     bool select(char[] CSS_selectors, HElement_callback_t callback, LPVOID param=null) 
     385    bool select(char[] CSS_selectors,HElement_callback_t callback,LPVOID param=null) 
    382386    {synchronized{ 
    383387         
     
    387391    }} 
    388392 
    389     HElement selectParent(char[] selector, UINT depth=0) 
     393    HElement selectParent(char[] selector,UINT depth=0) 
    390394    { 
    391395        HELEMENT heFound; 
     
    411415    } 
    412416 
    413     bool showAsPopup(HElement anchor,UINT placement=2) {return anchor.showPopup(this,placement);} 
    414     bool showPopup(HElement hePopup, UINT placement=2){return (lastResult=HTMLayoutShowPopup(hePopup.mHandle,mHandle,placement))==HLDOM_OK;} 
    415     bool showPopupAt(HElement hePopup, int x,int y, bool animate){return (lastResult=HTMLayoutShowPopupAt(hePopup.mHandle,POINT(x,y),animate))==HLDOM_OK;} 
    416     bool showAsPopupAt(int x,int y, bool animate){return showPopupAt(this,x,y,animate);} 
     417    bool showAsPopup(HElement anchor,UINT placement=2){return anchor.showPopup(this,placement);} 
     418    bool showPopup(HElement hePopup,UINT placement=2){return (lastResult=HTMLayoutShowPopup(hePopup.mHandle,mHandle,placement))==HLDOM_OK;} 
     419    bool showPopupAt(HElement hePopup,int x,int y,bool animate){return (lastResult=HTMLayoutShowPopupAt(hePopup.mHandle,POINT(x,y),animate))==HLDOM_OK;} 
     420    bool showAsPopupAt(int x,int y,bool animate){return showPopupAt(this,x,y,animate);} 
    417421    bool hidePopup(HElement hePopup=null){return (lastResult=HTMLayoutHidePopup(hePopup?hePopup.mHandle:mHandle))==HLDOM_OK;} 
    418422 
     
    424428    } 
    425429 
    426     bool state(UINT stateBitsToSet, UINT stateBitsToClear, bool updateView) //setter 
     430    bool state(UINT stateBitsToSet,UINT stateBitsToClear,bool updateView) //setter 
    427431    {return (lastResult=HTMLayoutSetElementState(mHandle,stateBitsToSet,stateBitsToClear,updateView))==HLDOM_OK;} 
    428432 
     433    bool link(){return (state&STATE_LINK)!=0;} 
     434    bool hovered(){return (state&STATE_HOVER)!=0;} 
     435    bool active(){return (state&STATE_ACTIVE)!=0;} 
     436    bool visited(){return (state&STATE_VISITED)!=0;} 
     437    bool current(){return (state&STATE_CURRENT)!=0;} 
     438    bool readOnly(){return (state&STATE_READONLY)!=0;} 
     439    bool readOnly(bool v){return state(v?STATE_READONLY:0,v?0:STATE_READONLY,true);} 
     440    bool expanded(){return (state&STATE_EXPANDED)!=0;} 
     441    bool collapsed(){return (state&STATE_COLLAPSED)!=0;} 
     442    bool incomplete(){return (state&STATE_INCOMPLETE)!=0;} 
     443    bool animating(){return (state&STATE_ANIMATING)!=0;} 
     444    bool synthetic(){return (state&STATE_SYNTHETIC)!=0;} 
     445    bool ownsPopup(){return (state&STATE_OWNS_POPUP)!=0;} 
     446    bool tabFocus(){return (state&STATE_TABFOCUS)!=0;} 
     447    bool empty(){return (state&STATE_EMPTY)!=0;} 
     448    bool busy(){return (state&STATE_BUSY)!=0;} 
     449    bool dragOver(){return (state&STATE_DRAG_OVER)!=0;} 
     450    bool dropTarget(){return (state&STATE_DROP_TARGET)!=0;} 
     451    bool moving(){return (state&STATE_MOVING)!=0;} 
     452    bool copying(){return (state&STATE_COPYING)!=0;} 
     453    bool dragSource(){return (state&STATE_DRAG_SOURCE)!=0;} 
     454    bool popup(){return (state&STATE_POPUP)!=0;} 
     455    bool pressed(){return (state&STATE_PRESSED)!=0;} 
     456    bool hasChildren(){return (state&STATE_HAS_CHILDREN)!=0;} 
     457    bool hasChild(){return (state&STATE_HAS_CHILD)!=0;} 
    429458    bool focus(){return state(STATE_FOCUS,0,true);} 
    430459    bool focused(){return (state&STATE_FOCUS)!=0;} 
     
    439468    { 
    440469        HELEMENT phe; 
    441         if((lastResult=HTMLayoutCloneElement(mHandle,&phe))==HLDOM_OK) return new HElement(phe,false); 
     470        if((lastResult=HTMLayoutCloneElement(mHandle,&phe))==HLDOM_OK) 
     471        { 
     472            auto r=new HElement(phe,false); 
     473            r.mUsed=true; 
     474            return r; 
     475        } 
    442476        return null; 
    443477    } 
    444478 
    445     bool insert(HElement hparent, UINT index=0){return (lastResult=HTMLayoutInsertElement(mHandle,hparent.mHandle,index))==HLDOM_OK;} 
    446     bool adopt(HElement child, UINT index=0){return child.insert(this,index);} 
     479    bool insert(HElement hparent,UINT index=0){return (lastResult=HTMLayoutInsertElement(mHandle,hparent.mHandle,index))==HLDOM_OK;} 
     480    bool adopt(HElement child,UINT index=0){return child.insert(this,index);} 
    447481    bool detach(){return (lastResult=HTMLayoutDetachElement(mHandle))==HLDOM_OK;} 
    448482    bool timer(UINT milliseconds){return (lastResult=HTMLayoutSetTimer(mHandle,milliseconds))==HLDOM_OK;} 
    449483 
    450     bool sendEvent(UINT appEventCode, HElement heSource, UINT reason, out bool handled) 
     484    bool sendEvent(UINT appEventCode,HElement heSource,UINT reason,out bool handled) 
    451485    { 
    452486        BOOL mHandled; 
     
    459493    } 
    460494 
    461     bool postEvent(UINT appEventCode, HElement heSource, UINT reason){return (lastResult=HTMLayoutPostEvent(mHandle,appEventCode,heSource?heSource.mHandle:null,reason))==HLDOM_OK;} 
     495    bool postEvent(UINT appEventCode,HElement heSource,UINT reason){return (lastResult=HTMLayoutPostEvent(mHandle,appEventCode,heSource?heSource.mHandle:null,reason))==HLDOM_OK;} 
    462496 
    463497    protected bool callMethod(HMethodParams* params){return (lastResult=HTMLayoutCallBehaviorMethod(mHandle,params))==HLDOM_OK;} 
    464498 
    465499    bool click(){return callMethod(&HMethodParams(DO_CLICK));} 
    466     bool xcall(char[] name,HJson[] values=null){return callMethod(HXcall(name,values).opCast);} 
    467     bool xcall(char[] name,HJson *value){return callMethod(HXcall(name,value).opCast);} 
    468  
    469     bool requestData(char[] url, UINT dataType, HElement initiator){return (lastResult=HTMLayoutRequestElementData(mHandle,toString16z(toString16(url)),dataType,initiator?initiator.mHandle:null))==HLDOM_OK;} 
    470     bool scrollInfo(ref POINT scrollPos, ref RECT viewRect,ref SIZE contentSize) //getter 
     500    bool xcall(char[] name,HJson[] values=null) 
     501    { 
     502        JSON_VALUE[] vals; 
     503        vals.length=values.length; 
     504        foreach(i,v;values) vals[i]=*v.handle; 
     505        return callMethod(HXcall(name,vals).opCast); 
     506    } 
     507    bool xcall(char[] name,HJson value){return callMethod(HXcall(name,value.handle).opCast);} 
     508 
     509    bool requestData(char[] url,UINT dataType,HElement initiator){return (lastResult=HTMLayoutRequestElementData(mHandle,toString16z(toString16(url)),dataType,initiator?initiator.mHandle:null))==HLDOM_OK;} 
     510    bool scrollInfo(ref POINT scrollPos,ref RECT viewRect,ref SIZE contentSize) //getter 
    471511    {return (lastResult=HTMLayoutGetScrollInfo(mHandle,&scrollPos,&viewRect,&contentSize))==HLDOM_OK;} 
    472512    POINT scrollPos() 
     
    494534    } 
    495535    bool scrollPos(POINT p,bool smooth=false) {return scrollPos(p.x,p.y,smooth);} 
    496     bool scrollPos(int x,int y, bool smooth=false) //setter 
     536    bool scrollPos(int x,int y,bool smooth=false) //setter 
    497537    {return (lastResult=HTMLayoutSetScrollPos(mHandle,POINT(x,y),smooth))==HLDOM_OK;} 
    498538 
     
    509549    } 
    510550 
    511     bool sort(UINT firstIndex, UINT lastIndex, ELEMENT_COMPARATOR cmpFunc, LPVOID cmpFuncParam){return (lastResult=HTMLayoutSortElements(mHandle,firstIndex,lastIndex,cmpFunc,cmpFuncParam))==HLDOM_OK;} 
     551    bool sort(UINT firstIndex,UINT lastIndex,ELEMENT_COMPARATOR cmpFunc,LPVOID cmpFuncParam){return (lastResult=HTMLayoutSortElements(mHandle,firstIndex,lastIndex,cmpFunc,cmpFuncParam))==HLDOM_OK;} 
    512552 
    513553    bool swap(HElement he2){return (lastResult=HTMLayoutSwapElements(mHandle,he2.mHandle))==HLDOM_OK;} 
     
    519559        else return -1; 
    520560    } 
    521     HJson *value() 
    522     { 
    523         auto r=new HJson
    524         if((lastResult=HTMLayoutControlGetValue(mHandle,r))==HLDOM_OK) return r
    525         else return null; 
    526     } 
    527     bool value(HJson *pVal){return (lastResult=HTMLayoutControlSetValue(mHandle,pVal))==HLDOM_OK;} 
    528  
    529     bool enumerate(HElement_enum_callback_t callback, LPVOID p, bool forward) 
     561    HJson value() 
     562    { 
     563        auto r=new JSON_VALUE
     564        if((lastResult=HTMLayoutControlGetValue(mHandle,r))==HLDOM_OK) return HJson(r)
     565        else return null; 
     566    } 
     567    bool value(HJson pVal){return (lastResult=HTMLayoutControlSetValue(mHandle,pVal.handle))==HLDOM_OK;} 
     568 
     569    bool enumerate(HElement_enum_callback_t callback,LPVOID p,bool forward) 
    530570    { 
    531571        if(!callback) return false; 
     
    541581    } 
    542582 
     583    RECT* location(UINT areas /*ELEMENT_AREAS*/) 
     584    { 
     585        auto outRect=new RECT; 
     586        if((lastResult=HTMLayoutGetElementLocation(mHandle,outRect,areas))==HLDOM_OK) return outRect; 
     587        else return null; 
     588    } 
     589 
     590    bool isInside(POINT client_pt) 
     591    { 
     592        auto rc = location(ROOT_RELATIVE | BORDER_BOX); 
     593        if(rc) return PtInRect(rc,client_pt) != FALSE; 
     594        else return false; 
     595    } 
     596 
    543597    HWND hwnd(BOOL rootWindow) 
    544598    { 
     
    551605    { 
    552606        HRANGE pRange; 
    553         if((lastResult=HTMLayoutRangeCreate(mHandle,&pRange, outer ))==HLDOM_OK) return new HRange(pRange); 
     607        if((lastResult=HTMLayoutRangeCreate(mHandle,&pRange,outer ))==HLDOM_OK) return new HRange(pRange); 
    554608        else return null; 
    555609    } 
     
    558612    { 
    559613        HRANGE pRange; 
    560         if((lastResult=HTMLayoutRangeFromSelection(mHandle, &pRange ))==HLDOM_OK) return new HRange(pRange); 
     614        if((lastResult=HTMLayoutRangeFromSelection(mHandle,&pRange ))==HLDOM_OK) return new HRange(pRange); 
    561615        else return null; 
    562616    } 
     
    565619    { 
    566620        HRANGE pRange; 
    567         if((lastResult=HTMLayoutRangeFromPositions(mHandle, &pStart, &pEnd ))==HLDOM_OK) return new HRange(pRange); 
     621        if((lastResult=HTMLayoutRangeFromPositions(mHandle,&pStart,&pEnd ))==HLDOM_OK) return new HRange(pRange); 
    568622        else return null; 
    569623    } 
     
    627681        else if(lastResult==HLDOM_INVALID_HANDLE) return "return HLDOM_INVALID_HANDLE - invalid HELEMENT"; 
    628682        else if(lastResult==HLDOM_PASSIVE_HANDLE) return "return HLDOM_PASSIVE_HANDLE - attempt to use HELEMENT which is not marked by HTMLayout_UseElement()"; 
    629         else if(lastResult==HLDOM_INVALID_PARAMETER) return "return HLDOM_INVALID_PARAMETER - parameter is invalid, e.g. pointer is null"; 
     683        else if(lastResult==HLDOM_INVALID_PARAMETER) return "return HLDOM_INVALID_PARAMETER - parameter is invalid,e.g. pointer is null"; 
    630684        else if(lastResult==HLDOM_OPERATION_FAILED) return "return HLDOM_OPERATION_FAILED"; 
    631685        else return null; 
     
    635689 
    636690    static HElement_enum_callback_t mEnumCallback; 
    637     extern(Windows) static BOOL mEnumerationCallback( LPVOID p, HELEMENT he, int pos, int postype, WCHAR code ) 
     691    extern(Windows) static BOOL mEnumerationCallback( LPVOID p,HELEMENT he,int pos,int postype,WCHAR code ) 
    638692    { 
    639693        return mEnumCallback(new HElement(he),p,pos,postype,code); 
     
    646700    } 
    647701 
    648     extern(Windows) static BOOL mStaticHandler(LPVOID tag, HELEMENT target, UINT event, LPVOID params ) 
     702    extern(Windows) static BOOL mStaticHandler(LPVOID tag,HELEMENT target,UINT event,LPVOID params ) 
    649703    { 
    650704        if(event==HANDLE_INITIALIZATION){return dgsInit(target).call(HInitialization(target,cast(INITIALIZATION_PARAMS*)params));} 
     
    741795 
    742796    bool release(){if((lastResult=HTMLayoutRangeRelease(mHandle))==HLDOM_OK) {mHandle=null;return true;} return false;} 
    743     bool advance(UINT cmd, ref INT c, ref HPOSITION pPos ){return (lastResult=HTMLayoutRangeAdvancePos( mHandle, cmd, &c, &pPos ))==HLDOM_OK;} 
     797    bool advance(UINT cmd,ref INT c,ref HPOSITION pPos ){return (lastResult=HTMLayoutRangeAdvancePos( mHandle,cmd,&c,&pPos ))==HLDOM_OK;} 
    744798    char[] html() 
    745799    { 
    746800        LPCBYTE ret; 
    747801        uint len; 
    748         if((lastResult=HTMLayoutRangeToHtml( mHandle, &ret, &len))==HLDOM_OK) return (cast(char*)ret)[0..len].dup; 
    749         else return null; 
    750     } 
    751     bool replace(char[] html){return (lastResult=HTMLayoutRangeReplace( mHandle, cast(LPCBYTE)html.ptr, html.length))==HLDOM_OK;} 
    752     bool insert(HPOSITION pPos,char[] html){return (lastResult=HTMLayoutRangeInsertHtml( &pPos, cast(LPBYTE) html.ptr, html.length ))==HLDOM_OK;} 
     802        if((lastResult=HTMLayoutRangeToHtml( mHandle,&ret,&len))==HLDOM_OK) return (cast(char*)ret)[0..len].dup; 
     803        else return null; 
     804    } 
     805    bool replace(char[] html){return (lastResult=HTMLayoutRangeReplace( mHandle,cast(LPCBYTE)html.ptr,html.length))==HLDOM_OK;} 
     806    bool insert(HPOSITION pPos,char[] html){return (lastResult=HTMLayoutRangeInsertHtml( &pPos,cast(LPBYTE) html.ptr,html.length ))==HLDOM_OK;} 
    753807    bool isEmpty() 
    754808    { 
    755809        BOOL pResult; 
    756         lastResult=HTMLayoutRangeIsEmpty( mHandle, &pResult ); 
     810        lastResult=HTMLayoutRangeIsEmpty( mHandle,&pResult ); 
    757811        return cast(bool)pResult; 
    758812    } 
     
    765819        else if(lastResult==HLDOM_INVALID_HANDLE) return "HLDOM_INVALID_HANDLE - invalid HELEMENT"; 
    766820        else if(lastResult==HLDOM_PASSIVE_HANDLE) return "HLDOM_PASSIVE_HANDLE - attempt to use HELEMENT which is not marked by HTMLayout_UseElement()"; 
    767         else if(lastResult==HLDOM_INVALID_PARAMETER) return "HLDOM_INVALID_PARAMETER - parameter is invalid, e.g. pointer is null"; 
     821        else if(lastResult==HLDOM_INVALID_PARAMETER) return "HLDOM_INVALID_PARAMETER - parameter is invalid,e.g. pointer is null"; 
    768822        else if(lastResult==HLDOM_OPERATION_FAILED) return "HLDOM_OPERATION_FAILED"; 
    769823        else return null; 
  • trunk/import/htmlayout/events.d

    r17 r18  
    291291    } 
    292292 
     293    void reset(){} 
     294 
     295    static void resetAll() {foreach(b;mBehaviors) b.reset();} 
     296 
    293297    final static HBehavior find(char[] name) 
    294298    { 
     
    565569    UINT dataSize(){return event.dataSize;} 
    566570    UINT dataType(){return event.dataType;} 
     571    UINT status(){return event.status;} 
     572    LPCWSTR uri(){return event.uri;} 
    567573} 
    568574 
  • trunk/import/htmlayout/htmlayout.d

    r17 r18  
    1 //wrapper for Andrew Fedoniouk's excellent HTMLayout (3.2.2.8) - http://www.terrainformatica.com/ 
     1//wrapper for Andrew Fedoniouk's excellent HTMLayout (3.2.2.13) - http://www.terrainformatica.com/ 
    22 
    33//todo: make the event struct wrappers (i.e. HMouse, HKey, etc) return HElement everywhere, not HELEMENT 
     
    66//todo: wrap HRange propperly 
    77//todo: handleEvent(size) followed by handleEvent(draw) makes draw to not work, but vice versa works 
    8 //todo: port Andrew's hpp behaviors 
     8//todo: port Andrew's hpp behaviors (or get some ideas from them) 
     9//todo: flowerd.skin: msgBox, SkinnedWindow.icon, dropped files (and other dropped stuff) handler, HSkinLite 
     10//todo: add scripting support 
     11//todo: add mootools style animator class 
    912 
    1013/* 
    1114 
    1215changelog: 
     16 
     170.7 
     18    JSON_VALUE.toString is not including the terminating null character for strings anymore 
     19    added shortcuts for all HElement states (most of which are only getters; i.e. readOnly, disabled, checked, etc.) 
     20    made HJson a separate class instead of alias of JSON_VALUE 
     21    upadated to HTMLayout 3.2.2.13 (new HDataArrived members) 
     22    added HJson.V_BYTES 
     23    renamed HLayout.elementByUID to HLayout.getUID 
     24    added HElement.location 
     25    added HElement.isInside 
     26    added flowerd.sharedlib, which can now load HTMLayout from memory 
     27    added HBehavior.reset and HBehavior.resetAll . This is intended to be used if HTMLayout is unloaded and loaded again in the lifetime of the application 
    1328 
    14290.6 
     
    343358    } 
    344359 
    345     HElement elementByUID(UINT uid) 
     360    HElement getUID(UINT uid) 
    346361    { 
    347362        HELEMENT hret;