Changeset 97 for trunk/include


Ignore:
Timestamp:
Jul 6, 2006, 11:25:56 PM (19 years ago)
Author:
dmik
Message:

kernel: Created the initial implementation of the Drag'n'Drop support for OS/2 (not fully functiona yet: updating widget contents under the drag pointer will cause screen corruption, setting the drag object's pixmap is not possible). See ticket:22 for more info.

Location:
trunk/include
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/qdragobject.h

    r8 r97  
    219219
    220220#ifndef QT_NO_DRAGANDDROP
    221 //@@TODO (dmik): no QDragManager yet (MOC ignores preprocessor macros)
     221
     222// QDragManager is not part of the public API.  It is defined in a
     223// header file simply so different .cpp files can implement different
     224// member functions.
    222225//
    223 //// QDragManager is not part of the public API.  It is defined in a
    224 //// header file simply so different .cpp files can implement different
    225 //// member functions.
    226 ////
    227 //
    228 //class Q_EXPORT QDragManager: public QObject {
    229 //    Q_OBJECT
    230 //
    231 //private:
    232 //    QDragManager();
    233 //    ~QDragManager();
    234 //    // only friend classes can use QDragManager.
    235 //    friend class QDragObject;
    236 //    friend class QDragMoveEvent;
    237 //    friend class QDropEvent;
    238 //    friend class QApplication;
    239 //
    240 //    bool eventFilter( QObject *, QEvent * );
    241 //    void timerEvent( QTimerEvent* );
    242 //
    243 //    bool drag( QDragObject *, QDragObject::DragMode );
    244 //
    245 //    void cancel( bool deleteSource = TRUE );
    246 //    void move( const QPoint & );
    247 //    void drop();
    248 //    void updatePixmap();
    249 //
    250 //private:
    251 //    QDragObject * object;
    252 //    void updateMode( ButtonState newstate );
    253 //    void updateCursor();
    254 //
    255 //    QWidget * dragSource;
    256 //    QWidget * dropWidget;
    257 //    bool beingCancelled;
    258 //    bool restoreCursor;
    259 //    bool willDrop;
    260 //
    261 //    QPixmap *pm_cursor;
    262 //    int n_cursor;
    263 //#if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator=
    264 //    QDragManager( const QDragManager & );
    265 //    QDragManager &operator=( const QDragManager & );
    266 //#endif
    267 //};
    268 //
     226
     227class Q_EXPORT QDragManager: public QObject {
     228    Q_OBJECT
     229
     230private:
     231    QDragManager();
     232    ~QDragManager();
     233    // only friend classes can use QDragManager.
     234    friend class QDragObject;
     235    friend class QDragMoveEvent;
     236    friend class QDropEvent;
     237    friend class QApplication;
     238
     239    bool eventFilter( QObject *, QEvent * );
     240    void timerEvent( QTimerEvent* );
     241
     242    bool drag( QDragObject *, QDragObject::DragMode );
     243
     244    void cancel( bool deleteSource = TRUE );
     245    void move( const QPoint & );
     246    void drop();
     247    void updatePixmap();
     248
     249private:
     250    QDragObject * object;
     251    void updateMode( ButtonState newstate );
     252    void updateCursor();
     253
     254    QWidget * dragSource;
     255    QWidget * dropWidget;
     256    bool beingCancelled;
     257    bool restoreCursor;
     258    bool willDrop;
     259
     260    QPixmap *pm_cursor;
     261    int n_cursor;
     262#if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator=
     263    QDragManager( const QDragManager & );
     264    QDragManager &operator=( const QDragManager & );
     265#endif
     266};
     267
    269268#endif
    270269
  • trunk/include/qmime.h

    r8 r97  
    160160
    161161#ifndef QT_H
    162 #include "qptrlist.h" // down here for GCC 2.7.* compatibility
     162#include "qptrlist.h"
     163#include "qstrlist.h"
    163164#endif // QT_H
    164165
    165166/*
    166   Encapsulation of conversion between MIME and OS/2 PM clipboard formats.
    167   Not need on X11, as the underlying protocol uses the MIME standard
    168   directly.
     167  Encapsulation of conversion between MIME and OS/2 PM clipboard formats
     168  and between MIME and Direct Manipulation (DND) mechanisms and formats.
    169169*/
    170170
    171 class Q_EXPORT QPMMime {
     171class Q_EXPORT QPMMime
     172{
    172173public:
     174
     175#if !defined(QT_NO_DRAGANDDROP)
     176
     177    class Messenger
     178    {
     179    public:
     180        Messenger();
     181        virtual ~Messenger();
     182        HWND hwnd() const { return w; }
     183        virtual MRESULT message( ULONG msg, MPARAM mp1, MPARAM mp2 ) = 0;
     184    private:
     185        HWND w;
     186        static MRESULT EXPENTRY windowProc( HWND, ULONG, MPARAM, MPARAM );
     187    };
     188
     189    class DragWorker
     190    {
     191    public:
     192        DragWorker() : src( NULL ) {}
     193        virtual ~DragWorker() {}
     194   
     195        const QMimeSource *source() const { return src; }
     196       
     197        virtual void init() {}
     198        // methods always implemented
     199        virtual bool cleanup( bool isCancelled ) = 0;
     200        virtual bool isExclusive() const = 0;
     201        virtual ULONG itemCount() const = 0;
     202        virtual HWND hwnd() const = 0;
     203        // methods implemented if isExclusive() == TRUE and itemCount() == 0
     204        virtual DRAGINFO *createDragInfo( const char *name, USHORT supportedOps )
     205                                        { return NULL; }
     206        // methods implemented if itemCount() >= 0
     207        virtual QCString composeFormatString() { return QCString(); }
     208        virtual bool prepare( const char *drm, const char *drf, DRAGITEM *item,
     209                              ULONG itemIndex ) { return FALSE; }
     210        virtual void defaultFileType( const char *&type, const char *&ext ) {};
     211       
     212    private:
     213        const QMimeSource *src;
     214        friend class QPMCoopDragWorker;
     215        friend class QDragManager;
     216    };
     217   
     218    class DefaultDragWorker : public DragWorker, public Messenger
     219    {
     220    private:
     221        DefaultDragWorker( bool exclusive );
     222    public:
     223        virtual ~DefaultDragWorker();
     224   
     225        // DragpWorker interface
     226        bool cleanup( bool isCancelled );
     227        bool isExclusive() const;
     228        ULONG itemCount() const;
     229        HWND hwnd() const { return Messenger::hwnd(); }
     230        QCString composeFormatString();
     231        bool prepare( const char *drm, const char *drf, DRAGITEM *item,
     232                      ULONG itemIndex );
     233        void defaultFileType( const char *&type, const char *&ext );
     234       
     235        // Messenger interface
     236        MRESULT message( ULONG msg, MPARAM mp1, MPARAM mp2 );
     237
     238        class Provider
     239        {
     240        public:
     241            virtual const char *format( const char *drf ) const = 0;
     242            virtual bool provide( const char *drf, const QByteArray &allData,
     243                                  ULONG itemIndex, QByteArray &itemData ) = 0;
     244            virtual void fileType( const char *drf, const char *&type,
     245                                   const char *&ext ) {};
     246        };
     247       
     248        bool addProvider( const char *drf, Provider *provider,
     249                          ULONG itemCount = 1 );
     250       
     251        static bool canRender( const char *drm );
     252       
     253    private:
     254        struct Data;
     255        Data *d;
     256        friend class QPMMime;
     257    };
     258   
     259    class DropWorker
     260    {
     261    public:
     262        DropWorker() : nfo( NULL ) {}
     263        virtual ~DropWorker() {}
     264       
     265        DRAGINFO *info() const { return nfo; }
     266
     267        virtual void init() {}
     268        virtual void cleanup( bool isAccepted, bool isActAccepted ) {}
     269        virtual bool isExclusive() const = 0;
     270        virtual bool provides( const char *format ) const = 0;
     271        virtual int formatCount() const = 0;
     272        virtual const char *format( int fn ) const = 0;
     273        virtual QByteArray encodedData( const char *format ) const = 0;
     274       
     275    private:
     276        DRAGINFO *nfo;
     277        friend class QPMDragData;
     278    };
     279
     280    class DefaultDropWorker : public DropWorker, public Messenger
     281    {
     282    private:
     283        DefaultDropWorker();
     284    public:
     285        virtual ~DefaultDropWorker();
     286   
     287        // DropWorker interface
     288        void cleanup( bool isAccepted, bool isActAccepted );
     289        bool isExclusive() const;
     290        bool provides( const char *format ) const;
     291        int formatCount() const;
     292        const char *format( int fn ) const;
     293        QByteArray encodedData( const char *format ) const;
     294       
     295        // Messenger interface
     296        MRESULT message( ULONG msg, MPARAM mp1, MPARAM mp2 );
     297   
     298        class Provider
     299        {
     300        public:
     301            virtual const char *drf( const char *format ) const = 0;
     302            virtual bool provide( const char *format, ULONG itemIndex,
     303                                  const QByteArray &itemData,
     304                                  QByteArray &allData ) = 0;
     305        };
     306       
     307        bool addProvider( const char *format, Provider *provider );
     308        bool addExclusiveProvider( const char *format, Provider *provider );
     309       
     310        static bool canRender( DRAGITEM *item, const char *drf );
     311        static bool getSupportedRMFs( DRAGITEM *item, QPtrList<QStrList> &list );
     312       
     313    private:
     314        struct Data;
     315        Data *d;
     316        friend class QPMMime;
     317    };
     318
     319#endif // !QT_NO_DRAGANDDROP
     320
    173321    enum { CFI_Storage = CFI_POINTER & CFI_HANDLE };
    174322   
     
    182330    static const char* cfToMime( ulong cf );
    183331
    184     static ulong registerMimeType( const char *mime );
    185 
     332#if !defined(QT_NO_DRAGANDDROP)
     333   
     334    static QCString queryHSTR( HSTR hstr );
     335    static QCString querySourceNameFull( DRAGITEM *item );
     336    static bool canTargetRenderAsOS2File( DRAGITEM *item, QCString *fullName = NULL );
     337    static bool parseRMFs( HSTR rmfs, QPtrList<QStrList> &list );
     338    static bool parseRMF( HSTR rmf, QCString &mechanism, QCString &format );
     339   
     340    static DefaultDragWorker *defaultCoopDragWorker();
     341    static DefaultDragWorker *defaultExclDragWorker();
     342    static DefaultDropWorker *defaultDropWorker();
     343
     344#endif // !QT_NO_DRAGANDDROP
     345
     346    // Clipboard format convertor interface
     347   
    186348    virtual const char* convertorName() = 0;
    187349    virtual int countCf() = 0;
     
    193355    virtual QByteArray convertToMime( QByteArray data, const char *mime, ulong cf ) = 0;
    194356    virtual QByteArray convertFromMime( QByteArray data, const char *mime, ulong cf ) = 0;
     357   
     358#if !defined(QT_NO_DRAGANDDROP)
     359
     360    // Direct Manipulation (DND) convertor interface
     361
     362    virtual DragWorker *dragWorkerFor( const char *mime, QMimeSource *src ) { return 0; }
     363    virtual DropWorker *dropWorkerFor( DRAGINFO *info ) { return 0; }
     364   
     365#endif // !QT_NO_DRAGANDDROP
    195366};
    196367
  • trunk/include/qwindowdefs_pm.h

    r61 r97  
    7878#endif
    7979
     80/*
     81 *  Undoc'd DC_PREPAREITEM, see
     82 *  http://lxr.mozilla.org/seamonkey/source/widget/src/os2/nsDragService.cpp
     83 */
     84#if !defined (DC_PREPAREITEM)
     85#define DC_PREPAREITEM 0x40
     86#endif
     87
    8088typedef HWND WId;
    8189
Note: See TracChangeset for help on using the changeset viewer.