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

MouseHandler.h

Go to the documentation of this file.
00001 #ifndef MOUSEHANDLERH
00002 #define MOUSEHANDLERH
00003 
00004 /*******************************************************************************
00005 Copyright 1998,1999,2000,2001 Petr Kulhanek
00006 
00007     This file is part of Core plugin.
00008 
00009     Core plugin is free software; you can redistribute it and/or modify
00010     it under the terms of the GNU General Public License as published by
00011     the Free Software Foundation; either version 2 of the License, or
00012     (at your option) any later version.
00013 
00014     Core plugin is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017     GNU General Public License for more details.
00018 
00019     You should have received a copy of the GNU General Public License
00020     along with Core plugin; if not, write to the Free Software
00021     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 *******************************************************************************/
00023 /*******************************************************************************
00024 ** PROJEKT:             Projekt molekulového modelování
00025 ** SOUBOR:              MouseHandler.h
00026 ** úČEL:                obsluha událostí myši
00027 ** VERZE:               3.0
00028 ** JAZYK:               CBuilder C++ v1.0
00029 ** CÍLOVÝ POČÍTAČ:      IBM PC
00030 ** PROGRAMÁTOR:         Petr Kulhánek
00031 ** HISTORIE úPRAV:
00032 VERZE   DATUM       POZNÁMKA
00033 *******************************************************************************/
00034 
00038 /* HLAVIČKOVÉ SOUBORY *********************************************************/
00039 
00040 #include "CoreMainHeader.h"
00041 #include <vcl\controls.hpp>
00042 #include <vcl\classes.hpp>
00043 
00044 #include "Selection.h"
00045 #include "Point.h"
00046 
00047 /* KONEC HLAVIČKOVÝCH SOUBORů *************************************************/
00048 
00049 class TOpenGLWin;
00050 class CManipulator;
00051 class CProject;
00052 
00053 /* DEFINICE TŘÍD **************************************************************/
00054 
00055 //..............................................................................
00056 
00058 
00061 class NEMESIS_CORE_PACKAGE CMouseHandlerPrefs{
00062         public:
00063     enum EMouseAction{  // co se má myší provádět
00064         SELECT,
00065         RECTSEL,
00066         RECTSELMOVE,
00067         MOVE,
00068         ROTATE,
00069         NOTHING,
00070         };
00071 
00072     class CMouseStatus{ // stav tlačítek myši
00073         public:
00074         __fastcall CMouseStatus(void);
00075         unsigned LeftButton:1;
00076         unsigned MiddleButton:1;
00077         unsigned RightButton:1;
00078         unsigned RectSelMode:1;
00079         };
00080 
00081     static CPoint RSensitivity;      // citlivost pro rotaci
00082     static CPoint MSensitivity;      // citlivost pro posun
00083     static bool   ThreeButtonSimul;  // simulace třítlačítkové myši
00084 
00085     static bool                 __fastcall EncodingShift(TShiftState Shift);
00086     static bool                 __fastcall EncodingFirstManipulator(TShiftState Shift);
00087     static EMouseAction __fastcall EncodingButton(TMouseButton Button,CMouseStatus &Status,
00088                                                                bool down);
00089     };
00090 
00091 //..............................................................................
00092 
00093 typedef void __fastcall (__closure *TMouseHandlerEvent)(void);
00094 typedef void __fastcall (__closure *TMouseRectHandlerEvent)(int x,int y,int w,int h,bool add);
00095 
00097 
00100 class NEMESIS_CORE_PACKAGE CMouseHandler:public CMouseHandlerPrefs{
00101     public:
00102 
00103          __fastcall CMouseHandler(void);
00104          __fastcall CMouseHandler(CProject* p_project);
00105          __fastcall CMouseHandler(TOpenGLWin *win,CManipulator *manip);
00106     void __fastcall MouseDown(TObject* Sender,TMouseButton Button,TShiftState Shift,int mousex,int mousey);
00107     void __fastcall MouseUp(TObject* Sender,TMouseButton Button,TShiftState Shift,int mousex,int mousey);
00108     void __fastcall MouseMove(TObject* Sender,TShiftState Shift,int mousex, int mousey);
00109 
00110     inline void __fastcall SetManipulator(CManipulator *manip);
00111     inline void __fastcall SetSecondManipulator(CManipulator* manip);
00112     inline CManipulator* __fastcall GetSecondManipulator(void);
00113     inline bool __fastcall IsActiveSecondManipulator(void);
00114     inline void __fastcall SetWindowHandler(TOpenGLWin* win);
00115 
00116     void __fastcall ActivateSecondManipulator(void);
00117     void __fastcall DeactivateSecondManipulator(void);
00118 
00119     void __fastcall SetRectangleSelMode(bool set,bool addmode);
00120 
00121     int             MouseX,MouseY;
00122 
00123     __property TMouseHandlerEvent       OnSelectClick={write = SelectClick};
00124     __property TMouseRectHandlerEvent   OnRectSelectClick={write = RectSelectClick};
00125 
00126     private:
00127     TMouseHandlerEvent      SelectClick;
00128     TMouseRectHandlerEvent  RectSelectClick;
00129 
00130     CProject*       Project;
00131     TOpenGLWin*     Win;         // grafický výstup
00132     TBevel*         Bevel;
00133     CManipulator*   Manipulator;    // manipulátor objektu
00134     CManipulator*   DefaultManipulator;
00135     CManipulator*   SecondManipulator;
00136     bool            SecondIsActive;
00137     CMouseStatus    Status;          // status tlačítek myši
00138     EMouseAction    Action;          // prováděná akce
00139     bool            LevelX;          // level pro posun a rotaci
00140     int             StartX,StartY;   // pomocné proměnné
00141     bool            RectangleSelMode;
00142     bool            AddMode;
00143     };
00144 
00145 //..............................................................................
00146 
00147 inline void __fastcall CMouseHandler::SetManipulator(CManipulator *manip)
00148 {
00149  DefaultManipulator = manip;
00150  if( SecondIsActive == false) Manipulator = DefaultManipulator;
00151 }
00152 
00153 //..............................................................................
00154 
00155 inline void __fastcall CMouseHandler::SetSecondManipulator(CManipulator *manip)
00156 {
00157  SecondManipulator = manip;
00158  if( SecondIsActive == true) Manipulator = SecondManipulator;
00159 }
00160 
00161 //..............................................................................
00162 
00163 inline CManipulator* __fastcall CMouseHandler::GetSecondManipulator(void)
00164 {
00165  return(SecondManipulator);
00166 }
00167 
00168 //..............................................................................
00169 
00170 inline bool __fastcall CMouseHandler::IsActiveSecondManipulator(void)
00171 {
00172  return(SecondIsActive);
00173 }
00174 
00175 //..............................................................................
00176 
00177 inline void __fastcall CMouseHandler::SetWindowHandler(TOpenGLWin* win)
00178 {
00179  Win = win;
00180 }
00181 
00182 //..............................................................................
00183 
00184 inline void __fastcall CMouseHandler::ActivateSecondManipulator(void)
00185 {
00186  Manipulator = SecondManipulator;
00187  SecondIsActive = true;
00188 }
00189 
00190 //..............................................................................
00191 
00192 inline void __fastcall CMouseHandler::DeactivateSecondManipulator(void)
00193 {
00194  Manipulator = DefaultManipulator;
00195  SecondIsActive = false;
00196 }
00197 
00198 /* KONEC DEFINICE TŘÍD ********************************************************/
00199 #endif

Generated on Sun Feb 9 12:53:51 2003 for NemesisCore by doxygen1.3-rc2