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 #include "llviewborder.h"
00046
00047 extern BOOL gDebugClicks;
00048
00049
00050 const LLString LLTool::sNameNull("null");
00051
00052 LLTool::LLTool( const LLString& name, LLToolComposite* composite ) :
00053 mComposite( composite ),
00054 mName(name)
00055 {
00056 }
00057
00058 LLTool::~LLTool()
00059 {
00060 if( hasMouseCapture() )
00061 {
00062 llwarns << "Tool deleted holding mouse capture. Mouse capture removed." << llendl;
00063 gFocusMgr.removeMouseCaptureWithoutCallback( this );
00064 }
00065 }
00066
00067
00068 BOOL LLTool::handleMouseDown(S32 x, S32 y, MASK mask)
00069 {
00070 if (gDebugClicks)
00071 {
00072 llinfos << "LLTool left mouse down" << llendl;
00073 }
00074
00075
00076 gAgent.setControlFlags(AGENT_CONTROL_LBUTTON_DOWN);
00077 return TRUE;
00078 }
00079
00080 BOOL LLTool::handleMouseUp(S32 x, S32 y, MASK mask)
00081 {
00082 if (gDebugClicks)
00083 {
00084 llinfos << "LLTool left mouse up" << llendl;
00085 }
00086
00087
00088 gAgent.setControlFlags(AGENT_CONTROL_LBUTTON_UP);
00089 return TRUE;
00090 }
00091
00092 BOOL LLTool::handleHover(S32 x, S32 y, MASK mask)
00093 {
00094 gViewerWindow->getWindow()->setCursor(UI_CURSOR_ARROW);
00095 lldebugst(LLERR_USER_INPUT) << "hover handled by a tool" << llendl;
00096
00097 return TRUE;
00098 }
00099
00100 BOOL LLTool::handleScrollWheel(S32 x, S32 y, S32 clicks)
00101 {
00102
00103
00104 return FALSE;
00105 }
00106
00107 BOOL LLTool::handleDoubleClick(S32 x,S32 y,MASK mask)
00108 {
00109
00110
00111 return FALSE;
00112 }
00113
00114 BOOL LLTool::handleRightMouseDown(S32 x,S32 y,MASK mask)
00115 {
00116
00117
00118 return FALSE;
00119 }
00120
00121 BOOL LLTool::handleRightMouseUp(S32 x, S32 y, MASK mask)
00122 {
00123
00124
00125 return FALSE;
00126 }
00127
00128 BOOL LLTool::handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect_screen)
00129 {
00130
00131
00132 return FALSE;
00133 }
00134
00135 void LLTool::setMouseCapture( BOOL b )
00136 {
00137 if( b )
00138 {
00139 gViewerWindow->setMouseCapture(mComposite ? mComposite : this );
00140 }
00141 else
00142 if( hasMouseCapture() )
00143 {
00144 gViewerWindow->setMouseCapture( NULL );
00145 }
00146 }
00147
00148
00149 void LLTool::draw()
00150 { }
00151
00152 BOOL LLTool::hasMouseCapture()
00153 {
00154 return gFocusMgr.getMouseCapture() == (mComposite ? mComposite : this);
00155 }
00156
00157 BOOL LLTool::handleKey(KEY key, MASK mask)
00158 {
00159 return FALSE;
00160 }
00161
00162 LLTool* LLTool::getOverrideTool(MASK mask)
00163 {
00164 if (mask & MASK_ALT)
00165 {
00166 return gToolCamera;
00167 }
00168 return NULL;
00169 }