~ubuntu-branches/ubuntu/raring/codeblocks/raring-proposed

« back to all changes in this revision

Viewing changes to src/include/wxFlatNotebook/include/wx/wxFlatNotebook/wxFNBDropTarget.h

  • Committer: Bazaar Package Importer
  • Author(s): Cosme Domínguez Díaz
  • Date: 2010-08-09 04:38:38 UTC
  • mfrom: (1.1.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20100809043838-a59ygguym4eg0jgw
Tags: 10.05-0ubuntu1
* New upstream release. Closes (LP: #322350)
 - Switch to dpkg-source 3.0 (quilt) format
 - Remove unneeded README.source
 - Add debian/get-source-orig script that removes all
   Windows prebuilt binaries
* Bump Standards-Version to 3.9.1
 - Stop shipping *.la files
* debian/control
 - Add cdbs package as Build-Depend
 - Add libbz2-dev and zlib1g-dev packages as
   Build-Depends (needed by libhelp_plugin.so)
 - Remove dpatch package of Build-Depends
 - Add codeblocks-contrib-debug package
 - Split architecture-independent files of codeblocks
   package in codeblocks-common package
* debian/rules
 - Switch to CDBS rules system
 - Add parallel build support
 - Add a call to debian/get-source-orig script
 - Use lzma compression (saves 23,5 MB of free space)
* debian/patches
 - Refresh 01_codeblocks_plugin_path
 - Add 02_no_Makefiles_in_debian_dir to remove any link
   in codeblocks build system to deleted Makefiles of debian directory
 - Drop 02_ftbfs_gcc44 and 03_ftbfs_glib221 (merged in upstream)
* debian/watch
 - Update to use the new host (berlios.de)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef _WX_FNB_DROP_TARGET_H 
2
 
#define _WX_FNB_DROP_TARGET_H
3
 
 
4
 
#include <wx/wx.h>
5
 
#include <wx/dnd.h>
6
 
 
7
 
/**
8
 
\brief Contains the information about dragged page (page index and container).
9
 
*/
10
 
class wxFNBDragInfo
11
 
{
12
 
        wxWindow * m_Container;
13
 
        int m_PageIndex;        
14
 
public:         
15
 
        /**
16
 
        Constructor
17
 
        \param container - pointer to wxPageContainer object which contains dragged page
18
 
        \param pageindex - index of dragged page
19
 
        */
20
 
        wxFNBDragInfo(wxWindow * container, int pageindex) : m_Container(container), m_PageIndex(pageindex){}   
21
 
 
22
 
        /**
23
 
         * \brief default constructor
24
 
         */
25
 
        wxFNBDragInfo() : m_Container(0), m_PageIndex(0){} 
26
 
 
27
 
        /**
28
 
        Returns wxPageContainer object which contains dragged page
29
 
        */
30
 
        wxWindow * GetContainer() {return m_Container;}
31
 
 
32
 
        /**
33
 
        Returns the index of dragged page
34
 
        */
35
 
        int GetPageIndex() {return m_PageIndex;}
36
 
};
37
 
 
38
 
class wxFNBDragInfoDataObject : public wxDataObjectSimple
39
 
{
40
 
public:
41
 
    wxFNBDragInfoDataObject(const wxDataFormat& format):wxDataObjectSimple(format)
42
 
    {}
43
 
 
44
 
    wxFNBDragInfo DragInfo;
45
 
 
46
 
    wxFNBDragInfo *GetData()
47
 
    {
48
 
        return &DragInfo;
49
 
    }
50
 
 
51
 
    // get the size of our data
52
 
    virtual size_t GetDataSize() const
53
 
    { return sizeof(wxFNBDragInfo); }
54
 
 
55
 
    // copy our data to the buffer
56
 
    virtual bool GetDataHere(void *buf) const
57
 
    {
58
 
        memcpy(buf, &DragInfo, sizeof(wxFNBDragInfo));
59
 
        return true;
60
 
    }
61
 
 
62
 
    // copy data from buffer to our data
63
 
    virtual bool SetData(size_t WXUNUSED(len), const void *buf)
64
 
    {
65
 
        // don't check the len. Under Win98 the value of 'len' == 0
66
 
        memcpy(&DragInfo, buf, sizeof(wxFNBDragInfo));
67
 
        return true;
68
 
    }
69
 
};
70
 
 
71
 
/**
72
 
\brief Used for processing drag-n-drop opeartions
73
 
*/
74
 
template <class T>
75
 
class wxFNBDropTarget : public wxDropTarget
76
 
{
77
 
private:
78
 
        typedef wxDragResult (T::*pt2Func)(wxCoord, wxCoord, int, wxWindow *);
79
 
        T* m_pParent;
80
 
        pt2Func m_pt2CallbackFunc;
81
 
        wxFNBDragInfoDataObject * m_DataObject;
82
 
public:
83
 
        /**
84
 
        \brief Constructor
85
 
        \param pParent - Object that will handle drag-n-drop operation
86
 
        \param pt2CallbackFunc - Pointer to callback method which should be called after dragging the notebook page
87
 
        */
88
 
    wxFNBDropTarget(T* pParent, pt2Func pt2CallbackFunc)
89
 
                : m_pParent(pParent)
90
 
                , m_pt2CallbackFunc(pt2CallbackFunc)
91
 
                , m_DataObject(NULL)
92
 
        {
93
 
                m_DataObject = new wxFNBDragInfoDataObject(wxDataFormat(wxT("wxFNB")));
94
 
                SetDataObject(m_DataObject);
95
 
        }
96
 
        /**
97
 
        \brief Virtual Destructor
98
 
        */
99
 
        virtual ~wxFNBDropTarget(void) {}
100
 
        /**
101
 
        \brief Used for processing drop operation
102
 
        \param x - X-coordinate
103
 
        \param y - Y-coordinate
104
 
        \param def - Result of drag-n-drop operation
105
 
        */
106
 
    virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult WXUNUSED(def))
107
 
        {               
108
 
                GetData();
109
 
                wxFNBDragInfo * draginfo = (wxFNBDragInfo *)m_DataObject->GetData();
110
 
                if(!draginfo) 
111
 
                {
112
 
                        return wxDragNone;
113
 
                }
114
 
                return (m_pParent->*m_pt2CallbackFunc)(x, y, draginfo->GetPageIndex(), (T *)draginfo->GetContainer());  
115
 
        }
116
 
};
117
 
 
118
 
/**
119
 
 * \ingroup wxFlatNotebook
120
 
 * This class represents a source for a drag and drop operation
121
 
 * We override wxDropSource class to provide user with a feedback
122
 
 *
123
 
 * \version 1.0
124
 
 * first version
125
 
 *
126
 
 * \date 10-11-2006
127
 
 *
128
 
 * \author Eran
129
 
 */
130
 
class wxFNBDropSource : public wxDropSource 
131
 
{
132
 
        wxWindow* m_win;
133
 
public:
134
 
        /**
135
 
         * Parameterized constructor
136
 
         * \param win 
137
 
         * \param iconCopy 
138
 
         * \param iconMove 
139
 
         * \param iconNone 
140
 
         */
141
 
        wxFNBDropSource(wxWindow* win = NULL)
142
 
        : wxDropSource(win)
143
 
                , m_win( win )
144
 
        {
145
 
        }
146
 
 
147
 
        /**
148
 
         * Destructor
149
 
         */
150
 
        virtual ~wxFNBDropSource()
151
 
        {
152
 
        }
153
 
 
154
 
        /**
155
 
         * give some custom UI feedback during the drag and drop operation in this function. It is called on each mouse move, so your implementation must not be too slow
156
 
         * \param effect The effect to implement. One of wxDragCopy, wxDragMove, wxDragLink and wxDragNone
157
 
         * \return 
158
 
         */
159
 
        virtual bool GiveFeedback(wxDragResult effect);
160
 
};
161
 
#endif