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
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
00074
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
00086
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
00096 return TRUE;
00097 }
00098
00099 BOOL LLTool::handleScrollWheel(S32 x, S32 y, S32 clicks)
00100 {
00101
00102
00103 return FALSE;
00104 }
00105
00106 BOOL LLTool::handleDoubleClick(S32 x,S32 y,MASK mask)
00107 {
00108
00109
00110 return FALSE;
00111 }
00112
00113 BOOL LLTool::handleRightMouseDown(S32 x,S32 y,MASK mask)
00114 {
00115
00116
00117 return FALSE;
00118 }
00119
00120 BOOL LLTool::handleRightMouseUp(S32 x, S32 y, MASK mask)
00121 {
00122
00123
00124 return FALSE;
00125 }
00126
00127 BOOL LLTool::handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect_screen)
00128 {
00129
00130
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
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 }