LCOV - code coverage report
Current view: top level - include/vcl - event.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 45 128 35.2 %
Date: 2014-04-11 Functions: 18 55 32.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_VCL_EVENT_HXX
      21             : #define INCLUDED_VCL_EVENT_HXX
      22             : 
      23             : #include <tools/solar.h>
      24             : #include <vcl/dllapi.h>
      25             : #include <tools/gen.hxx>
      26             : #include <vcl/keycod.hxx>
      27             : #include <vcl/cmdevt.hxx>
      28             : 
      29             : class AllSettings;
      30             : class OutputDevice;
      31             : class Window;
      32             : struct IDataObject;
      33             : 
      34             : namespace com { namespace sun { namespace star { namespace awt {
      35             :     struct KeyEvent;
      36             :     struct MouseEvent;
      37             : } } } }
      38             : 
      39             : enum TextDirectionality {
      40             :     TextDirectionality_LeftToRight_TopToBottom,
      41             :     TextDirectionality_RightToLeft_TopToBottom,
      42             :     TextDirectionality_TopToBottom_RightToLeft
      43             : };
      44             : 
      45             : 
      46             : // - KeyEvent -
      47             : 
      48           1 : class VCL_DLLPUBLIC KeyEvent
      49             : {
      50             : private:
      51             :     KeyCode         maKeyCode;
      52             :     sal_uInt16          mnRepeat;
      53             :     sal_Unicode     mnCharCode;
      54             : 
      55             : public:
      56             :                     KeyEvent();
      57             :                     KeyEvent( sal_Unicode nChar, const KeyCode& rKeyCode,
      58             :                               sal_uInt16 nRepeat = 0 );
      59             : 
      60           1 :     sal_Unicode     GetCharCode() const     { return mnCharCode; }
      61           1 :     const KeyCode&  GetKeyCode() const      { return maKeyCode;  }
      62           0 :     sal_uInt16          GetRepeat() const       { return mnRepeat;   }
      63             : 
      64             :     KeyEvent        LogicalTextDirectionality (TextDirectionality eMode) const;
      65             :                     KeyEvent (const KeyEvent& rKeyEvent);
      66             : 
      67             : };
      68             : 
      69           1 : inline KeyEvent::KeyEvent()
      70             : {
      71           1 :     mnCharCode  = 0;
      72           1 :     mnRepeat    = 0;
      73           1 : }
      74             : 
      75           1 : inline KeyEvent::KeyEvent( sal_Unicode nChar, const KeyCode& rKeyCode,
      76             :                            sal_uInt16 nRepeat ) :
      77           1 :             maKeyCode( rKeyCode )
      78             : 
      79             : {
      80           1 :     mnCharCode  = nChar;
      81           1 :     mnRepeat    = nRepeat;
      82           1 : }
      83             : 
      84             : 
      85             : // - MouseEvent-Types -
      86             : 
      87             : 
      88             : // Maus-Move-Modi
      89             : #define MOUSE_SIMPLEMOVE        ((sal_uInt16)0x0001)
      90             : #define MOUSE_DRAGMOVE          ((sal_uInt16)0x0002)
      91             : #define MOUSE_DRAGCOPY          ((sal_uInt16)0x0004)
      92             : #define MOUSE_ENTERWINDOW       ((sal_uInt16)0x0010)
      93             : #define MOUSE_LEAVEWINDOW       ((sal_uInt16)0x0020)
      94             : #define MOUSE_SYNTHETIC         ((sal_uInt16)0x0040)
      95             : #define MOUSE_MODIFIERCHANGED   ((sal_uInt16)0x0080)
      96             : 
      97             : // Maus-Button-Down/Up-Modi
      98             : #define MOUSE_SIMPLECLICK       ((sal_uInt16)0x0001)
      99             : #define MOUSE_SELECT            ((sal_uInt16)0x0002)
     100             : #define MOUSE_MULTISELECT       ((sal_uInt16)0x0004)
     101             : #define MOUSE_RANGESELECT       ((sal_uInt16)0x0008)
     102             : 
     103             : // Maus-Buttons
     104             : #define MOUSE_LEFT              ((sal_uInt16)0x0001)
     105             : #define MOUSE_MIDDLE            ((sal_uInt16)0x0002)
     106             : #define MOUSE_RIGHT             ((sal_uInt16)0x0004)
     107             : 
     108             : 
     109             : // - MouseEvent -
     110             : 
     111             : 
     112             : class VCL_DLLPUBLIC MouseEvent
     113             : {
     114             : private:
     115             :     Point           maPos;
     116             :     sal_uInt16          mnMode;
     117             :     sal_uInt16          mnClicks;
     118             :     sal_uInt16          mnCode;
     119             : 
     120             : public:
     121             :     explicit        MouseEvent();
     122             :     explicit        MouseEvent( const Point& rPos, sal_uInt16 nClicks = 1,
     123             :                                 sal_uInt16 nMode = 0, sal_uInt16 nButtons = 0,
     124             :                                 sal_uInt16 nModifier = 0 );
     125             : 
     126           0 :     const Point&    GetPosPixel() const     { return maPos; }
     127           0 :     sal_uInt16          GetMode() const         { return mnMode; }
     128             :                     /** inits this vcl KeyEvent with all settings from the given awt event **/
     129             :                     MouseEvent( const ::com::sun::star::awt::MouseEvent& rEvent );
     130             : 
     131           0 :     sal_uInt16          GetClicks() const       { return mnClicks; }
     132             : 
     133           0 :     bool            IsEnterWindow() const
     134           0 :                         { return ((mnMode & MOUSE_ENTERWINDOW) != 0); }
     135           0 :     bool            IsLeaveWindow() const
     136           0 :                         { return ((mnMode & MOUSE_LEAVEWINDOW) != 0); }
     137           0 :     bool            IsSynthetic() const
     138           0 :                         { return ((mnMode & MOUSE_SYNTHETIC) != 0); }
     139           0 :     bool            IsModifierChanged() const
     140           0 :                         { return ((mnMode & MOUSE_MODIFIERCHANGED) != 0); }
     141             : 
     142           0 :     sal_uInt16          GetButtons() const
     143           0 :                         { return (mnCode & (MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT)); }
     144           0 :     bool            IsLeft() const
     145           0 :                         { return ((mnCode & MOUSE_LEFT) != 0); }
     146           0 :     bool            IsMiddle() const
     147           0 :                         { return ((mnCode & MOUSE_MIDDLE) != 0); }
     148           0 :     bool            IsRight() const
     149           0 :                         { return ((mnCode & MOUSE_RIGHT) != 0); }
     150             : 
     151           0 :     sal_uInt16          GetModifier() const
     152           0 :                         { return (mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2)); }
     153           0 :     bool            IsShift() const
     154           0 :                         { return ((mnCode & KEY_SHIFT) != 0); }
     155           0 :     bool            IsMod1() const
     156           0 :                         { return ((mnCode & KEY_MOD1) != 0); }
     157           0 :     bool            IsMod2() const
     158           0 :                         { return ((mnCode & KEY_MOD2) != 0); }
     159           0 :     bool            IsMod3() const
     160           0 :                         { return ((mnCode & KEY_MOD3) != 0); }
     161             : };
     162             : 
     163       29266 : inline MouseEvent::MouseEvent()
     164             : {
     165       29266 :     mnMode      = 0;
     166       29266 :     mnClicks    = 0;
     167       29266 :     mnCode      = 0;
     168       29266 : }
     169             : 
     170           0 : inline MouseEvent::MouseEvent( const Point& rPos, sal_uInt16 nClicks,
     171             :                                sal_uInt16 nMode,
     172             :                                sal_uInt16 nButtons, sal_uInt16 nModifier ) :
     173           0 :             maPos( rPos )
     174             : {
     175           0 :     mnClicks    = nClicks;
     176           0 :     mnMode      = nMode;
     177           0 :     mnCode      = nButtons | nModifier;
     178           0 : }
     179             : 
     180             : class VCL_DLLPUBLIC ZoomEvent
     181             : {
     182             : private:
     183             :     Point           maCenter;
     184             :     float           mfScale;
     185             : 
     186             : public:
     187           0 :     ZoomEvent() :
     188           0 :         mfScale( 1 )
     189             :     {
     190           0 :     }
     191             : 
     192             :     ZoomEvent( const Point& rCenter,
     193             :                float fScale ) :
     194             :         maCenter( rCenter ),
     195             :         mfScale( fScale )
     196             :     {
     197             :     }
     198             : 
     199           0 :     const Point& GetCenter() const
     200             :     {
     201           0 :         return maCenter;
     202             :     }
     203             : 
     204           0 :     float GetScale() const
     205             :     {
     206           0 :         return mfScale;
     207             :     }
     208             : };
     209             : 
     210             : class VCL_DLLPUBLIC ScrollEvent
     211             : {
     212             : private:
     213             :     int mnXOffset;
     214             :     int mnYOffset;
     215             : 
     216             : public:
     217           0 :     ScrollEvent() :
     218             :         mnXOffset( 0 ),
     219           0 :         mnYOffset( 0 )
     220             :     {
     221           0 :     }
     222             : 
     223             :     ScrollEvent( int xOffset, int yOffset ) :
     224             :         mnXOffset( xOffset ),
     225             :         mnYOffset( yOffset )
     226             :     {
     227             :     }
     228             : 
     229           0 :     int GetXOffset() const
     230             :     {
     231           0 :         return mnXOffset;
     232             :     }
     233             : 
     234           0 :     int GetYOffset() const
     235             :     {
     236           0 :         return mnYOffset;
     237             :     }
     238             : };
     239             : 
     240             : 
     241             : // - HelpEvent -
     242             : 
     243             : 
     244             : #define HELPMODE_CONTEXT        ((sal_uInt16)0x0001)
     245             : #define HELPMODE_EXTENDED       ((sal_uInt16)0x0002)
     246             : #define HELPMODE_BALLOON        ((sal_uInt16)0x0004)
     247             : #define HELPMODE_QUICK          ((sal_uInt16)0x0008)
     248             : 
     249             : class VCL_DLLPUBLIC HelpEvent
     250             : {
     251             : private:
     252             :     Point           maPos;
     253             :     sal_uInt16          mnMode;
     254             :     bool            mbKeyboardActivated;
     255             : 
     256             : public:
     257             :     explicit        HelpEvent();
     258             :     explicit        HelpEvent( sal_uInt16 nHelpMode );
     259             :     explicit        HelpEvent( const Point& rMousePos, sal_uInt16 nHelpMode );
     260             : 
     261             :     const Point&    GetMousePosPixel() const;
     262           0 :     sal_uInt16          GetMode() const { return mnMode; }
     263           0 :     bool            KeyboardActivated() const { return mbKeyboardActivated; }
     264           0 :     void            SetKeyboardActivated( bool bKeyboard ) { mbKeyboardActivated = bKeyboard; }
     265             : };
     266             : 
     267             : inline HelpEvent::HelpEvent()
     268             : {
     269             :     mnMode  = HELPMODE_CONTEXT;
     270             :     mbKeyboardActivated = true;
     271             : }
     272             : 
     273           0 : inline HelpEvent::HelpEvent( const Point& rMousePos, sal_uInt16 nHelpMode ) :
     274           0 :             maPos( rMousePos )
     275             : {
     276           0 :     mnMode  = nHelpMode;
     277           0 :     mbKeyboardActivated = false;
     278           0 : }
     279             : 
     280             : inline HelpEvent::HelpEvent( sal_uInt16 nHelpMode )
     281             : {
     282             :     mnMode  = nHelpMode;
     283             :     mbKeyboardActivated = true;
     284             : }
     285             : 
     286             : 
     287             : // - UserDrawEvent -
     288             : 
     289             : 
     290             : class VCL_DLLPUBLIC UserDrawEvent
     291             : {
     292             : private:
     293             :     OutputDevice*       mpOutDev;
     294             :     Rectangle           maOutRect;
     295             :     sal_uInt16              mnItemId;
     296             :     sal_uInt16              mnStyle;
     297             : 
     298             : public:
     299             :                         UserDrawEvent();
     300             :                         UserDrawEvent( OutputDevice* pOut,
     301             :                                        const Rectangle& rOutRect,
     302             :                                        sal_uInt16 nId, sal_uInt16 nStyle = 0 );
     303             : 
     304       35807 :     OutputDevice*       GetDevice() const { return mpOutDev; }
     305       50687 :     const Rectangle&    GetRect() const { return maOutRect; }
     306       13788 :     sal_uInt16              GetItemId() const { return mnItemId; }
     307       10122 :     sal_uInt16              GetStyle() const { return mnStyle; }
     308             : };
     309             : 
     310             : inline UserDrawEvent::UserDrawEvent()
     311             : {
     312             :     mpOutDev    = NULL;
     313             :     mnItemId    = 0;
     314             :     mnStyle     = 0;
     315             : }
     316             : 
     317       25458 : inline UserDrawEvent::UserDrawEvent( OutputDevice* pOut,
     318             :                                      const Rectangle& rOutRect,
     319             :                                      sal_uInt16 nId, sal_uInt16 nStyle ) :
     320       25458 :             maOutRect( rOutRect )
     321             : {
     322       25458 :     mpOutDev    = pOut;
     323       25458 :     mnItemId    = nId;
     324       25458 :     mnStyle     = nStyle;
     325       25458 : }
     326             : 
     327             : 
     328             : // - Tracking-Types -
     329             : 
     330             : 
     331             : #define ENDTRACK_CANCEL         ((sal_uInt16)0x0001)
     332             : #define ENDTRACK_KEY            ((sal_uInt16)0x0002)
     333             : #define ENDTRACK_FOCUS          ((sal_uInt16)0x0004)
     334             : #define ENDTRACK_END            ((sal_uInt16)0x1000)
     335             : #define ENDTRACK_DONTCALLHDL    ((sal_uInt16)0x8000)
     336             : 
     337             : #define TRACKING_REPEAT         ((sal_uInt16)0x0100)
     338             : 
     339             : 
     340             : // - TrackingEvent -
     341             : 
     342             : 
     343             : class VCL_DLLPUBLIC TrackingEvent
     344             : {
     345             : private:
     346             :     MouseEvent          maMEvt;
     347             :     sal_uInt16              mnFlags;
     348             : 
     349             : public:
     350             :     explicit            TrackingEvent();
     351             :     explicit            TrackingEvent( const MouseEvent&,
     352             :                                        sal_uInt16 nTrackFlags = 0 );
     353             : 
     354           0 :     const MouseEvent&   GetMouseEvent() const { return maMEvt; }
     355             : 
     356           0 :     bool                IsTrackingRepeat() const
     357           0 :                             { return ((mnFlags & TRACKING_REPEAT) != 0); }
     358             : 
     359           0 :     bool                IsTrackingEnded() const
     360           0 :                             { return ((mnFlags & ENDTRACK_END) != 0); }
     361           0 :     bool                IsTrackingCanceled() const
     362           0 :                             { return ((mnFlags & ENDTRACK_CANCEL) != 0); }
     363             :     sal_uInt16              GetTrackingFlags() const { return mnFlags; }
     364             : };
     365             : 
     366             : inline TrackingEvent::TrackingEvent()
     367             : {
     368             :     mnFlags = 0;
     369             : }
     370             : 
     371           0 : inline TrackingEvent::TrackingEvent( const MouseEvent& rMEvt,
     372             :                                      sal_uInt16 nTrackFlags ) :
     373           0 :             maMEvt( rMEvt )
     374             : {
     375           0 :     mnFlags = nTrackFlags;
     376           0 : }
     377             : 
     378             : 
     379             : // - NotifyEvent -
     380             : 
     381             : 
     382             : #define EVENT_MOUSEBUTTONDOWN   1
     383             : #define EVENT_MOUSEBUTTONUP     2
     384             : #define EVENT_MOUSEMOVE         3
     385             : #define EVENT_KEYINPUT          4
     386             : #define EVENT_KEYUP             5
     387             : #define EVENT_GETFOCUS          6
     388             : #define EVENT_LOSEFOCUS         7
     389             : #define EVENT_COMMAND           8
     390             : #define EVENT_DESTROY           9
     391             : #define EVENT_INPUTENABLE       10
     392             : #define EVENT_INPUTDISABLE      11
     393             : #define EVENT_EXECUTEDIALOG     100
     394             : #define EVENT_ENDEXECUTEDIALOG  101
     395             : 
     396             : class VCL_DLLPUBLIC NotifyEvent
     397             : {
     398             : private:
     399             :     Window*                 mpWindow;
     400             :     void*                   mpData;
     401             :     sal_uInt16                  mnType;
     402             :     long                    mnRetValue;
     403             : 
     404             : public:
     405             :                             NotifyEvent();
     406             :                             NotifyEvent( sal_uInt16 nType,
     407             :                                          Window* pWindow,
     408             :                                          const void* pEvent = NULL,
     409             :                                          long nRet = 0 );
     410             : 
     411      618501 :     sal_uInt16                  GetType() const { return mnType; }
     412      111674 :     Window*                 GetWindow() const { return mpWindow; }
     413           0 :     void*                   GetData() const { return mpData; }
     414             : 
     415             :     void                    SetReturnValue( long nRet ) { mnRetValue = nRet; }
     416             :     long                    GetReturnValue() const { return mnRetValue; }
     417             : 
     418             :     const KeyEvent*         GetKeyEvent() const;
     419             :     const MouseEvent*       GetMouseEvent() const;
     420             :     const CommandEvent*     GetCommandEvent() const;
     421             : };
     422             : 
     423             : inline NotifyEvent::NotifyEvent()
     424             : {
     425             :     mpWindow    = NULL;
     426             :     mpData      = NULL;
     427             :     mnType      = 0;
     428             :     mnRetValue  = 0;
     429             : }
     430             : 
     431      156382 : inline NotifyEvent::NotifyEvent( sal_uInt16 nType, Window* pWindow,
     432             :                                  const void* pEvent, long nRet )
     433             : {
     434      156382 :     mpWindow    = pWindow;
     435      156382 :     mpData      = (void*)pEvent;
     436      156382 :     mnType      = nType;
     437      156382 :     mnRetValue  = nRet;
     438      156382 : }
     439             : 
     440           0 : inline const KeyEvent* NotifyEvent::GetKeyEvent() const
     441             : {
     442           0 :     if ( (mnType == EVENT_KEYINPUT) || (mnType == EVENT_KEYUP) )
     443           0 :         return (const KeyEvent*)mpData;
     444             :     else
     445           0 :         return NULL;
     446             : }
     447             : 
     448           0 : inline const MouseEvent* NotifyEvent::GetMouseEvent() const
     449             : {
     450           0 :     if ( (mnType >= EVENT_MOUSEBUTTONDOWN) && (mnType <= EVENT_MOUSEMOVE) )
     451           0 :         return (const MouseEvent*)mpData;
     452             :     else
     453           0 :         return NULL;
     454             : }
     455             : 
     456           0 : inline const CommandEvent* NotifyEvent::GetCommandEvent() const
     457             : {
     458           0 :     if ( mnType == EVENT_COMMAND )
     459           0 :         return (const CommandEvent*)mpData;
     460             :     else
     461           0 :         return NULL;
     462             : }
     463             : 
     464             : 
     465             : // - DataChangedEvent -
     466             : 
     467             : 
     468             : #define DATACHANGED_SETTINGS            ((sal_uInt16)1)
     469             : #define DATACHANGED_DISPLAY             ((sal_uInt16)2)
     470             : #define DATACHANGED_DATETIME            ((sal_uInt16)3)
     471             : #define DATACHANGED_FONTS               ((sal_uInt16)4)
     472             : #define DATACHANGED_PRINTER             ((sal_uInt16)5)
     473             : #define DATACHANGED_FONTSUBSTITUTION    ((sal_uInt16)6)
     474             : #define DATACHANGED_USER                ((sal_uInt16)10000)
     475             : 
     476             : class VCL_DLLPUBLIC DataChangedEvent
     477             : {
     478             : private:
     479             :     void*                   mpData;
     480             :     sal_uLong                   mnFlags;
     481             :     sal_uInt16                  mnType;
     482             : 
     483             : public:
     484             :     explicit                DataChangedEvent();
     485             :     explicit                DataChangedEvent( sal_uInt16 nType,
     486             :                                               const void* pData = NULL,
     487             :                                               sal_uLong nFlags = 0 );
     488             : 
     489       27046 :     sal_uInt16                  GetType() const { return mnType; }
     490             :     void*                   GetData() const { return mpData; }
     491       13519 :     sal_uLong                   GetFlags() const { return mnFlags; }
     492             : 
     493             :     const AllSettings*      GetOldSettings() const;
     494             : };
     495             : 
     496             : inline DataChangedEvent::DataChangedEvent()
     497             : {
     498             :     mpData  = NULL;
     499             :     mnFlags = 0;
     500             :     mnType  = 0;
     501             : }
     502             : 
     503        9853 : inline DataChangedEvent::DataChangedEvent( sal_uInt16 nType,
     504             :                                            const void* pData,
     505             :                                            sal_uLong nChangeFlags )
     506             : {
     507        9853 :     mpData  = (void*)pData;
     508        9853 :     mnFlags = nChangeFlags;
     509        9853 :     mnType  = nType;
     510        9853 : }
     511             : 
     512        2234 : inline const AllSettings* DataChangedEvent::GetOldSettings() const
     513             : {
     514        2234 :     if ( mnType == DATACHANGED_SETTINGS )
     515        2234 :         return (const AllSettings*)mpData;
     516             :     else
     517           0 :         return NULL;
     518             : }
     519             : 
     520             : #endif // INCLUDED_VCL_EVENT_HXX
     521             : 
     522             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10