www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - D GUI class library

reply Andrew Fedoniouk <news terrainformatica.com> writes:
Hi, gentlemen,

While ago I've created JavaVM and system of Java classes better suitable 
for GUI programming than standard one.

Project was named J-SMILE and I would like to port/redesign it in D.

J-SMILE project url and Java sources of GUI framework is here:
http://terrainformatica.com/org/j-smile/index.htm

Main principles of GUI are:

1) "windowless" widgets allowing to build lightweight feauture reach UI 
with exactly same look-n-feel on different platforms.

2) event capturing/bubbling propagation schema. Very flexible and 
inspires compact event handlers and interaction. Similar to what is used 
in DHTML:  http://catcode.com/domcontent/events/capture.html

3) Themed UI. CSS alike facilities.

I would like also to write wrappers for our HTML rendering and WYSIWYG 
editing engines : http://terrainformatica.com/htmlayout and
http://terrainformatica.com/htmengine using such GUI library.

Probably I am inventing the wheel and you know some existing GUI 
libraries for D? I will appreciate a lot for links then.

Any comments, requirements and wishes are also highly useful.

Andrew Fedoniouk.
http://terrainformatica.com
Jan 27 2005
parent reply "Thomas Kuehne" <eisvogel users.sourceforge.net> writes:
Andrew Fedoniouk schrieb in  news:ctc52d$n90$2 digitaldaemon.com :
 Probably I am inventing the wheel and you know some existing GUI
 libraries for D? I will appreciate a lot for links then.
http://www.prowiki.org/wiki4d/wiki.cgi?AvailableGuiLibraries Thomas
Jan 28 2005
parent reply Andrew Fedoniouk <news terrainformatica.com> writes:
Thomas Kuehne wrote:
 
 http://www.prowiki.org/wiki4d/wiki.cgi?AvailableGuiLibraries
 
Thanks, Thomas, I've already seen this list. Is this a full one? And I have a question: Suppose I have in D class window { HWND hwnd; } I need to store inside Win32::HWND structure (using either SetProp or SetWindowLong) reference to the instance of this class for callbacks. What is the most correct way to do this? My initial design is to use associated array for this like: class window { HWND hwnd; static window[HWND] all_instances; extern(C) static win_proc(HWND hwnd,UINT msg, ....) { window self = window[hwnd]; self.dispatch(msg,....); } } As far as I understand I cannot store reference to window instance directly inside HWND. Reference to the window is GC thing and its value could be changed by GC. I mean constantness of this reference value depends on GC implementation - e.g. generational/copying GC can move objects in memory. So in general I cannot rely on constantness of object references. Am I right? Thanks in advance, Andrew Fedoniouk. http://terrainformatica.com
Jan 28 2005
next sibling parent reply "Ben Hinkle" <bhinkle mathworks.com> writes:
[snip]

 As far as I understand I cannot store reference to window instance
 directly inside HWND. Reference to the window is GC thing and its value 
 could be changed by GC. I mean constantness of this reference value 
 depends on GC implementation - e.g. generational/copying
 GC can move objects in memory. So in general I cannot rely on constantness 
 of object references. Am I right?
You are right but I expect D will get an API to pin (or lock or whatever you want to call it) objects so that they don't get moved. Personally I wouldn't worry about moving data but I would worry about keeping a reference the GC can find so that it doesn't collect something prematurely. So that static array of window references will still be necessary (at least for the toplevel window references). -Ben
Jan 28 2005
parent Andrew Fedoniouk <news terrainformatica.com> writes:
Thanks, Ben,

Ben Hinkle wrote:
[snip]
 
 You are right but I expect D will get an API to pin (or lock or whatever you 
 want to call it) objects so that they don't get moved. Personally I wouldn't 
 worry about moving data but I would worry about keeping a reference the GC 
 can find so that it doesn't collect something prematurely. So that static 
 array of window references will still be necessary (at least for the 
 toplevel window references).
I understand that to protect object from GCollecting it should be accessible from GC/VM roots somehow. This is why I am using static associative array to map HWND value to the window instance - it serves also as a root for created windows. Andrew Fedoniouk. http://terrainformatica.com
Jan 28 2005
prev sibling next sibling parent "Thomas Kuehne" <thomas-dloop kuehne.cn> writes:
Andrew Fedoniouk schrieb in news:41FA988A.9080101 terrainformatica.com :
 Thomas Kuehne wrote:
 http://www.prowiki.org/wiki4d/wiki.cgi?AvailableGuiLibraries
Thanks, Thomas, I've already seen this list. Is this a full one?
As far as I'm aware: yes. The best one is - in my opinion - DUI, fairly stable and supports Linux and Windows.
 And I have a question:

 Suppose I have in D

 class window
 {
    HWND hwnd;
 }

 I need to store inside
 Win32::HWND structure (using either SetProp or SetWindowLong)
 reference to the instance of this class for callbacks.

 What is the most correct way to do this?

 My initial design is to use associated array for this like:

 class window
 {
    HWND hwnd;
    static window[HWND] all_instances;

    extern(C) static win_proc(HWND hwnd,UINT msg, ....)
    {
      window self = window[hwnd];
      self.dispatch(msg,....);
    }
 }
Your design seems to be sane. Minor problem:
      window* self = hwnd in all_instances;
      if( self !== null)  self.dispatch(msg,....);
Please capitalize the first letter of the class type ("Window"). This greatly improves readeability as one can instantly see if you are using the type "Window" or the instance "window". Thomas
Jan 28 2005
prev sibling parent "huang yicheng" <zergbird msn.com> writes:
"Andrew Fedoniouk" <news terrainformatica.com> wrote in message
news:41FA988A.9080101 terrainformatica.com...
 Thomas Kuehne wrote:
 http://www.prowiki.org/wiki4d/wiki.cgi?AvailableGuiLibraries
Thanks, Thomas, I've already seen this list. Is this a full one? And I have a question: Suppose I have in D class window { HWND hwnd; } I need to store inside Win32::HWND structure (using either SetProp or SetWindowLong) reference to the instance of this class for callbacks. What is the most correct way to do this? My initial design is to use associated array for this like: class window { HWND hwnd; static window[HWND] all_instances; extern(C) static win_proc(HWND hwnd,UINT msg, ....) { window self = window[hwnd]; self.dispatch(msg,....); } }
I do the samilar job by c++. I use api 'CreateWindowEx' and set 'this' to the last parameter : MDICREATESTRUCT mdic; memset(& mdic, 0, sizeof(mdic)); mdic.lParam = (LPARAM) this; m_hWnd = CreateWindowEx(dwExStyle, lpszClass, lpszName, dwStyle, x, y, nWidth, nHeight, hParent, hMenu, hInst, & mdic); Then in static winproc function, I can get 'this' from the last parameter for later dispatching: ZWinBase * pWindow; if ( uMsg==WM_NCCREATE ) { assert( ! IsBadReadPtr((void *) lParam, sizeof(CREATESTRUCT)) ); MDICREATESTRUCT * pMDIC = (MDICREATESTRUCT *) ((LPCREATESTRUCT) lParam)->lpCreateParams; pWindow = (ZWinBase *) (pMDIC->lParam); assert( ! IsBadReadPtr(pWindow, sizeof(ZWinBase)) ); SetWindowLong(hWnd, GWL_USERDATA, (LONG) pWindow); } else pWindow=(ZWinBase *)GetWindowLong(hWnd, GWL_USERDATA); if ( pWindow ) return pWindow->WndProc(hWnd, uMsg, wParam, lParam); else return DefWindowProc(hWnd, uMsg, wParam, lParam);
 As far as I understand I cannot store reference to window instance
 directly inside HWND. Reference to the window is GC thing and its value
 could be changed by GC. I mean constantness of this reference value
 depends on GC implementation - e.g. generational/copying
 GC can move objects in memory. So in general I cannot rely on
 constantness of object references. Am I right?

 Thanks in advance,

 Andrew Fedoniouk.
 http://terrainformatica.com
Jan 30 2005