// Description   : NANO User Interface Framework $Revision: 12 $

// Copyright     : Proxima Centauri Romania SRL, ALL RIGHTS RESERVED. (http://www.ProximaCentauri.org)

// Author        : Alexander Ioan Mihail

 

#ifndef nui_h

#define nui_h 1

 

#ifdef USE_QT

    #include <QtGui/QTreeWidgetItem>

    #include <QtGui/QTreeWidget>

    #include <QtGui/QApplication>

    #include "QtGui/QMainWindow.h"

    #include <QtCore/QTimer>

    #include "GUI/Dock/ui_Dock.h"

    typedef QTreeWidgetItem GTreeItem;

    typedef QTreeWidget GTreeView;

    typedef QTimer GTimer;

    typedef QApplication GApplication;

    typedef QWidget GControl;

    typedef QMainWindow GWindow;

    typedef QObjectUserData GObjectUserData;

    typedef QString GString;

    typedef GControl GTabControl;

    typedef GWindow GTabPage;

    #define CORE_APP(ptr) ((ELEMENT*)((GControl*)ptr)->userData(0))

#else

    typedef void* GObjectUserData;

#include "nano.h"

START_NAMESPACE(NANO_UI)

using namespace NANO_CORE;

class GApplication;

class GTabControl;

class GTreeView;

class GTabPage;

typedef char* GString;

struct QModelIndex

{

  public:

      void* internalPointer () const

      {

          return ptr;

      }

      void *ptr;

};

 

class GControl : public BOND

{

  public:

      GControl ();

      virtual ~GControl ();

      void* userData (int aspect);

      virtual void Remove ();

      virtual void Removing (GControl* ctrl) = 0;

      void setUserData (int aspect, void* value);

      void *data;

      static GApplication *qApp;

};

 

class GApplication : public GControl

{

  public:

      GApplication (int argc, char** argv);

      virtual void Removing (GControl* ctrl);

      int exec ();

      static long* WndProc (void* hwnd, unsigned int message, unsigned int wParam, unsigned long* lParam);

};

 

class GWindow : public GControl

{

  public:

      GWindow (void* hwnd);

      GWindow (GControl* parent, int flags, const char* classname);

      ~GWindow ();

      virtual void Removing (GControl* ctrl);

      void SetWnd (void* hwnd);

      void SetParent (GWindow* parent);

      void show ();

      void hide ();

      static GWindow* FromHandle (void* hwnd);

      virtual long* HandleMessage (unsigned int message, unsigned int wParam, unsigned long* lParam);

      virtual void onCreate ();

      void *hWnd;

      virtual void Notify(GWindow*Sender,int ctrlid);

};

 

class GSplitter : public GWindow

{

  public:

      GSplitter (GWindow* parent, int flags);

      virtual long* HandleMessage (unsigned int iMsg, unsigned int wParam, unsigned long* lParam);

      void SetWnds (GWindow* a, GWindow* b);

      int Divider;

      bool Sizing;

      bool Horizontal;

      GWindow *A;

      GWindow *B;

};

 

class GTimer

{

  public:

      GTimer (GWindow* win);

      void start (int period);

      static void DoTimeout (void* hwnd, int msg, void* id, unsigned int time);

      void *id;

      GWindow *Win;

      __event void timeout ();

};

 

class GEdit : public GWindow

{

  public:

      GEdit (GWindow* parent);

      int Access (int direction, int offset, char* buf, int len, int flags);

};

 

class GTreeItem

{

  public:

    typedef enum {ShowIndicator, UserType} EIndicators;

      GTreeItem (GTreeItem* parent, enum GTreeItem::EIndicators inds);

      GTreeItem (GTreeView* parent, enum GTreeItem::EIndicators inds);

      virtual ~GTreeItem ();

      GTreeItem* parent ();

      int childCount ();

      GTreeItem* child (int id);

      bool isExpanded ();

      void SetMeta (ELEMENT* meta);

      GString text (int aspect);

      void GetText (int aspect, GString s, int length);

      void setText (int aspect, GString s);

      GTreeView *tv;

      void *host_item;

      int Count;

};

class GTreeView : public GWindow

{

  public:

      GTreeView (GWindow* parent);

      virtual long* HandleMessage (unsigned int message, unsigned int wParam, unsigned long* lParam);

      virtual void onCreate ();

      GTreeItem* invisibleRootItem ();

      GTreeItem* currentItem ();

      virtual void onExpanded (const QModelIndex& index) = 0;

      virtual void onCollapsed (const QModelIndex& index) = 0;

      virtual void onItemDoubleClicked (const QModelIndex& index) = 0;

      virtual void onEdit () = 0;

      GTreeItem *Root;

      void *hEdit;

      bool Dragging;

};

 

class GTabControl : public GWindow

{

  public:

      GTabControl (GWindow* parent);

      virtual void Removing (GControl* ctrl);

      virtual long* HandleMessage (unsigned int message, unsigned int wParam, unsigned long* lParam);

      virtual void onCreate ();

      GTabPage* AddPage (GString name, GTabPage* child);

      GTabPage *Current;

};

 

class GTabPage : public GWindow

{

  public:

      GTabPage (GTabControl* parent, int resid);

      ~GTabPage ();

      static long* DlgProc (void* hwnd, unsigned int message, unsigned int wParam, unsigned long* lParam);

      virtual long* DlgMessage (unsigned int message, unsigned int wParam, unsigned long* lParam);

};

 

#define CORE_APP(ptr) ((ELEMENT*)((GControl*)ptr)->userData(0))

END_NAMESPACE(NANO_UI)

 

#endif

#endif