~damien-moore/+junk/codeblocks

« back to all changes in this revision

Viewing changes to src/plugins/contrib/wxSmith/wxsresourcetree.h

  • Committer: Damien Moore
  • Date: 2013-10-11 14:25:27 UTC
  • Revision ID: damienlmoore@gmail.com-20131011142527-w13ki0x8yjd7973d
copy of Code::Blocks repo based on SVN rev 9395

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
* This file is part of wxSmith plugin for Code::Blocks Studio
 
3
* Copyright (C) 2006-2007  Bartlomiej Swiecki
 
4
*
 
5
* wxSmith is free software; you can redistribute it and/or modify
 
6
* it under the terms of the GNU General Public License as published by
 
7
* the Free Software Foundation; either version 3 of the License, or
 
8
* (at your option) any later version.
 
9
*
 
10
* wxSmith is distributed in the hope that it will be useful,
 
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
13
* GNU General Public License for more details.
 
14
*
 
15
* You should have received a copy of the GNU General Public License
 
16
* along with wxSmith. If not, see <http://www.gnu.org/licenses/>.
 
17
*
 
18
* $Revision: 8251 $
 
19
* $Id: wxsresourcetree.h 8251 2012-08-28 02:31:00Z ollydbg $
 
20
* $HeadURL: svn://svn.code.sf.net/p/codeblocks/code/trunk/src/plugins/contrib/wxSmith/wxsresourcetree.h $
 
21
*/
 
22
 
 
23
#ifndef WXSRESOURCETREE_H
 
24
#define WXSRESOURCETREE_H
 
25
 
 
26
#include <wx/treectrl.h>
 
27
#include "wxsresourcetreeitemdata.h"
 
28
 
 
29
#if defined(__WXMSW__) && defined(LoadImage)
 
30
    // Fix Windows winuser.h Header define of LoadImage.
 
31
    #undef LoadImage
 
32
#endif
 
33
 
 
34
 
 
35
class wxsResource;
 
36
class wxsProject;
 
37
 
 
38
/** \brief Definition of resource tree identifier. Separate name of type could be useful in future */
 
39
typedef wxTreeItemId wxsResourceItemId;
 
40
 
 
41
// TODO: Rewrite this class with custom widget
 
42
 
 
43
/** \brief Resource tree class */
 
44
class wxsResourceTree: public wxTreeCtrl
 
45
{
 
46
    public:
 
47
 
 
48
        /** \brief Ctor */
 
49
        wxsResourceTree(wxWindow* Parent);
 
50
 
 
51
        /** \brief Dctor */
 
52
        virtual ~wxsResourceTree();
 
53
 
 
54
        /** \brief Function building new tree item for project
 
55
         *
 
56
         * This item takes name of associated cbProject and initializes
 
57
         * item data to point to project.
 
58
         */
 
59
        wxsResourceItemId NewProjectItem(const wxString& ProjectTitle,wxsProject* Project);
 
60
 
 
61
        /** \brief Function returning item id for external resources */
 
62
        wxsResourceItemId ExternalResourcesId();
 
63
 
 
64
        /** \brief Function deleting identifier for external resources */
 
65
        void DeleteExternalResourcesId();
 
66
 
 
67
        /** \brief Getting singleton instance */
 
68
        static inline wxsResourceTree* Get() { return m_Singleton; }
 
69
 
 
70
        /** \brief Getting global image list
 
71
         *
 
72
         * This list is declared as static, so it can be used even
 
73
         * before wxsResourceTree is created
 
74
         */
 
75
        static wxImageList& GetGlobalImageList();
 
76
 
 
77
        /** \brief Loading image to list
 
78
         *  \param FileName name relative to codeblock's data path
 
79
         *  \return Index in list
 
80
         */
 
81
        static int LoadImage(const wxString& FileName);
 
82
 
 
83
        /** \brief Adding bitmap into global list
 
84
         *  \param Bitmap bitmap to be added
 
85
         *  \return Index in list
 
86
         */
 
87
        static int InsertImage(const wxBitmap& Bitmap);
 
88
 
 
89
        /** \brief Freeing image at given index
 
90
         *
 
91
         * This function marks image at given index as freed, so
 
92
         * it may be replaced by LoadImage in future without
 
93
         * unnecessarily increasing size of list
 
94
         */
 
95
        static void FreeImage(int Index);
 
96
 
 
97
        /** \brief Blocking processing select events
 
98
         * \note This function must be paired with UnblockSelect
 
99
         */
 
100
        void BlockSelect();
 
101
 
 
102
        /** \brief Unblocking select events
 
103
         * \note This function must be paired with BlockSelect
 
104
         */
 
105
        void UnblockSelect();
 
106
 
 
107
    private:
 
108
 
 
109
        wxsResourceItemId m_ExtId;              ///< \brief id of tree item containing external resources
 
110
        bool m_IsExt;                           ///< \brief True if there is item for external resources
 
111
        int m_BlockCount;                       ///< \brief if > 0 must block all select events
 
112
        wxsResourceTreeItemData* m_Data;        ///< \brief Pointer to item data object used in last action
 
113
        static wxsResourceTree* m_Singleton;    ///< \brief singleton object
 
114
 
 
115
        static int m_RootImageId;
 
116
        static int m_ProjectImageId;
 
117
        static int m_ExternalImageId;
 
118
 
 
119
        static wxArrayInt& GetFreedList();
 
120
 
 
121
        void PopupMenu(wxMenu* Menu,wxsResourceTreeItemData* ItemData);
 
122
        void InvalidateItemData(wxsResourceTreeItemData* ItemData);
 
123
 
 
124
        void OnSelect(wxTreeEvent& event);
 
125
        void OnRightClick(wxTreeEvent& event);
 
126
        void OnPopupMenu(wxCommandEvent& event);
 
127
 
 
128
        friend void wxsResourceTreeItemData::PopupMenu(wxMenu* Menu);
 
129
        friend wxsResourceTreeItemData::~wxsResourceTreeItemData();
 
130
 
 
131
        DECLARE_EVENT_TABLE()
 
132
};
 
133
 
 
134
/** \brief Helper function for getting resource tree singleton object */
 
135
inline wxsResourceTree* wxsTree() { return wxsResourceTree::Get(); }
 
136
 
 
137
#endif