Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

FoldersTree.h

Go to the documentation of this file.
00001 /* QuestDesigner - Open Zelda's Project
00002    Copyright (C) 2003 Kronuz
00003    Copyright (C) 2001/2003 Open Zelda's Project
00004  
00005    This program is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU General Public License
00007    as published by the Free Software Foundation; either version 2
00008    of the License, or (at your option) any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013    GNU General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with this program; if not, write to the Free Software
00017    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 */
00020 
00025 #pragma once
00026 
00027 #include <sstream>
00028 #include <ExtDockingWindow.h>
00029 
00030 class CFoldersTree :
00031     public dockwins::CTitleDockingWindowImpl< CFoldersTree,CWindow,dockwins::COutlookLikeTitleDockingWindowTraits>
00032 {
00033     typedef CFoldersTree    thisClass;
00034     typedef dockwins::CTitleDockingWindowImpl< CFoldersTree,CWindow,dockwins::COutlookLikeTitleDockingWindowTraits> baseClass;
00035 protected:
00036     void FillTree(CTreeViewCtrl& tree)
00037     {
00038         for( int i =0; i < 10; i++)
00039         {
00040             std::basic_stringstream<TCHAR> text;
00041             text<<_T("item ")<<i;
00042             HTREEITEM hItem=tree.InsertItem(text.str().c_str(),0,1,TVI_ROOT,TVI_LAST);
00043             for( int j = 0; j < 5; j++)
00044             {
00045                 std::basic_stringstream<TCHAR> text;
00046                 text<<_T("sub item ")<<j;
00047                 tree.InsertItem(text.str().c_str(),0,1,hItem,TVI_LAST);
00048             }
00049         }
00050 
00051     }
00052 public:
00053     void OnDocked(HDOCKBAR hBar,bool bHorizontal)
00054     {
00055         DWORD dwStyle = GetWindowLong(GWL_STYLE)&(~WS_SIZEBOX);
00056         SetWindowLong( GWL_STYLE, dwStyle);
00057 
00058         baseClass::OnDocked(hBar,bHorizontal);
00059     }
00060     void OnUndocked(HDOCKBAR hBar)
00061     {
00062         DWORD dwStyle = GetWindowLong(GWL_STYLE) | WS_SIZEBOX;
00063         SetWindowLong( GWL_STYLE , dwStyle);
00064 
00065         baseClass::OnUndocked(hBar);
00066     }
00067 
00068     DECLARE_WND_CLASS(_T("CFoldersTree"))
00069     BEGIN_MSG_MAP(thisClass)
00070         MESSAGE_HANDLER(WM_CREATE, OnCreate)
00071         MESSAGE_HANDLER(WM_SIZE, OnSize)
00072         CHAIN_MSG_MAP(baseClass)
00073     END_MSG_MAP()
00074 
00075     LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
00076     {
00077         m_images.Create(16, 16, TRUE, 3, 0);
00078 
00079         assert(m_images.m_hImageList);
00080         CBitmap bmp;
00081 
00082         bmp.LoadBitmap(IDB_FOLDERS);
00083 
00084         m_images.Add( bmp, RGB(255,255,255));
00085 
00086         m_tree.Create(m_hWnd,NULL,NULL,
00087                         TVS_SHOWSELALWAYS | TVS_HASBUTTONS |
00088                         TVS_LINESATROOT | TVS_HASLINES |
00089                         TVS_EDITLABELS|TVS_SHOWSELALWAYS|
00090                         TVS_DISABLEDRAGDROP|
00091                         WS_CHILD | WS_VISIBLE);
00092         m_tree.SetImageList(m_images, TVSIL_NORMAL);
00093         FillTree(m_tree);
00094         return 0;
00095     }
00096     LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
00097     {
00098         if(wParam != SIZE_MINIMIZED )
00099         {
00100             RECT rc;
00101             GetClientRect(&rc);
00102             ::SetWindowPos(m_tree.m_hWnd, NULL, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top ,SWP_NOZORDER | SWP_NOACTIVATE);
00103         }
00104         bHandled = FALSE;
00105         return 1;
00106     }
00107 protected:
00108     CTreeViewCtrl   m_tree;
00109     CImageList      m_images;
00110 };

Generated on Wed Apr 16 19:12:22 2003 for QuestDesigner by doxygen1.2.18