lltool.cpp

Go to the documentation of this file.
00001 
00032 #include "llviewerprecompiledheaders.h"
00033 
00034 #include "lltool.h"
00035 
00036 #include "indra_constants.h"
00037 #include "llerror.h"
00038 #include "llview.h"
00039 
00040 #include "llviewerwindow.h"
00041 #include "lltoolcomp.h"
00042 #include "lltoolfocus.h"
00043 #include "llfocusmgr.h"
00044 #include "llagent.h"
00045 
00046 extern BOOL gDebugClicks;
00047 
00048 //static
00049 const LLString LLTool::sNameNull("null");
00050 
00051 LLTool::LLTool( const LLString& name, LLToolComposite* composite ) :
00052         mComposite( composite ),
00053         mName(name)
00054 {
00055 }
00056 
00057 LLTool::~LLTool()
00058 {
00059         if( hasMouseCapture() )
00060         {
00061                 llwarns << "Tool deleted holding mouse capture.  Mouse capture removed." << llendl;
00062                 gFocusMgr.removeMouseCaptureWithoutCallback( this );
00063         }
00064 }
00065 
00066 
00067 BOOL LLTool::handleMouseDown(S32 x, S32 y, MASK mask)
00068 {
00069         if (gDebugClicks)
00070         {
00071                 llinfos << "LLTool left mouse down" << llendl;
00072         }
00073         // by default, didn't handle it
00074         // llinfos << "LLTool::handleMouseDown" << llendl;
00075         gAgent.setControlFlags(AGENT_CONTROL_LBUTTON_DOWN);
00076         return TRUE;
00077 }
00078 
00079 BOOL LLTool::handleMouseUp(S32 x, S32 y, MASK mask)
00080 {
00081         if (gDebugClicks) 
00082         {
00083                 llinfos << "LLTool left mouse up" << llendl;
00084         }
00085         // by default, didn't handle it
00086         // llinfos << "LLTool::handleMouseUp" << llendl;
00087         gAgent.setControlFlags(AGENT_CONTROL_LBUTTON_UP);
00088         return TRUE;
00089 }
00090 
00091 BOOL LLTool::handleHover(S32 x, S32 y, MASK mask)
00092 {
00093         gViewerWindow->getWindow()->setCursor(UI_CURSOR_ARROW);
00094         lldebugst(LLERR_USER_INPUT) << "hover handled by a tool" << llendl;             
00095         // by default, do nothing, say we handled it
00096         return TRUE;
00097 }
00098 
00099 BOOL LLTool::handleScrollWheel(S32 x, S32 y, S32 clicks)
00100 {
00101         // by default, didn't handle it
00102         // llinfos << "LLTool::handleScrollWheel" << llendl;
00103         return FALSE;
00104 }
00105 
00106 BOOL LLTool::handleDoubleClick(S32 x,S32 y,MASK mask)
00107 {
00108         // llinfos << "LLTool::handleDoubleClick" << llendl;
00109         // by default, pretend it's a left click
00110         return FALSE;
00111 }
00112 
00113 BOOL LLTool::handleRightMouseDown(S32 x,S32 y,MASK mask)
00114 {
00115         // by default, didn't handle it
00116         // llinfos << "LLTool::handleRightMouseDown" << llendl;
00117         return FALSE;
00118 }
00119 
00120 BOOL LLTool::handleRightMouseUp(S32 x, S32 y, MASK mask)
00121 {
00122         // by default, didn't handle it
00123         // llinfos << "LLTool::handleRightMouseDown" << llendl;
00124         return FALSE;
00125 }
00126 
00127 BOOL LLTool::handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect_screen)
00128 {
00129         // by default, didn't handle it
00130         // llinfos << "LLTool::handleToolTip" << llendl;
00131         return FALSE;
00132 }
00133 
00134 void LLTool::setMouseCapture( BOOL b )
00135 {
00136         if( b )
00137         {
00138                 gViewerWindow->setMouseCapture(mComposite ? mComposite : this );
00139         }
00140         else
00141         if( hasMouseCapture() )
00142         {
00143                 gViewerWindow->setMouseCapture( NULL );
00144         }
00145 }
00146 
00147 // virtual
00148 void LLTool::draw()
00149 { }
00150 
00151 BOOL LLTool::hasMouseCapture()
00152 {
00153         return gFocusMgr.getMouseCapture() == (mComposite ? mComposite : this);
00154 }
00155 
00156 BOOL LLTool::handleKey(KEY key, MASK mask)
00157 {
00158         return FALSE;
00159 }
00160 
00161 LLTool* LLTool::getOverrideTool(MASK mask)
00162 {
00163         if (mask & MASK_ALT)
00164         {
00165                 return LLToolCamera::getInstance();
00166         }
00167         return NULL;
00168 }

Generated on Fri May 16 08:34:05 2008 for SecondLife by  doxygen 1.5.5