Torque3D Documentation / _generateds / VEditorScrollControl.cpp

VEditorScrollControl.cpp

Engine/source/Verve/GUI/VEditorScrollControl.cpp

More...

Detailed Description

Public Functions

IMPLEMENT_CONOBJECT(VEditorScrollControl )

 1
 2//-----------------------------------------------------------------------------
 3// Verve
 4// Copyright (C) 2014 - Violent Tulip
 5//
 6// Permission is hereby granted, free of charge, to any person obtaining a copy
 7// of this software and associated documentation files (the "Software"), to
 8// deal in the Software without restriction, including without limitation the
 9// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10// sell copies of the Software, and to permit persons to whom the Software is
11// furnished to do so, subject to the following conditions:
12//
13// The above copyright notice and this permission notice shall be included in
14// all copies or substantial portions of the Software.
15//
16// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22// IN THE SOFTWARE.
23//-----------------------------------------------------------------------------
24#include "Verve/GUI/VEditorScrollControl.h"
25#include "gfx/gfxDrawUtil.h"
26
27//-----------------------------------------------------------------------------
28IMPLEMENT_CONOBJECT( VEditorScrollControl );
29//-----------------------------------------------------------------------------
30
31//-----------------------------------------------------------------------------
32//
33// Mouse Methods.
34//
35//-----------------------------------------------------------------------------
36
37void VEditorScrollControl::onMouseUp( const GuiEvent &pEvent )
38{
39    Parent::onMouseUp( pEvent );
40
41    // Event.
42    onMouseEvent( "onMouseUp", pEvent );
43}
44
45void VEditorScrollControl::onRightMouseUp( const GuiEvent &pEvent )
46{
47    Parent::onMouseUp( pEvent );
48
49    // Event.
50    onMouseEvent( "onRightMouseUp", pEvent );
51}
52
53void VEditorScrollControl::onMouseEvent( const char *pEventName, const GuiEvent &pEvent )
54{
55    const S32 offsetX = ( mHasVScrollBar ) ? mScrollBarThickness : 0;
56    const S32 offsetY = ( mHasHScrollBar ) ? mScrollBarThickness : 0;
57
58    const RectI contentRect( 2, 2, getWidth() - offsetX - 4 - 1, getHeight() - offsetY - 4 - ( mHasHScrollBar ) );
59    if ( !contentRect.pointInRect( pEvent.mousePoint ) )
60    {
61        // Return!
62        return;
63    }
64
65    // Argument Buffers.
66    char argBuffer[3][32];
67
68    // Format Event-Position Buffer.
69    dSprintf( argBuffer[0], 32, "%d %d", pEvent.mousePoint.x, pEvent.mousePoint.y );
70
71    // Format Event-Modifier Buffer.
72    dSprintf( argBuffer[1], 32, "%d", pEvent.modifier );
73
74    // Format Mouse-Click Count Buffer.
75    dSprintf( argBuffer[2], 32, "%d", pEvent.mouseClickCount );
76
77    // Call Scripts.
78    Con::executef( this, pEventName, argBuffer[0], argBuffer[1], argBuffer[2] );
79}
80
81//-----------------------------------------------------------------------------
82//
83// Render Methods.
84//
85//-----------------------------------------------------------------------------
86
87void VEditorScrollControl::onRender( Point2I pOffset, const RectI &pUpdateRect )
88{
89    Parent::onRender( pOffset, pUpdateRect );
90
91    const S32 offsetX = ( mHasVScrollBar ) ? mScrollBarThickness : 1;
92    const S32 offsetY = ( mHasHScrollBar ) ? mScrollBarThickness : 1;
93
94    RectI contentRect( pOffset.x + 1, pOffset.y + 1, getWidth() - offsetX - 1, getHeight() - offsetY - 1 );
95    contentRect.intersect( pUpdateRect );
96
97    GFX->getDrawUtil()->drawRect( contentRect, mProfile->mBorderColor );
98}
99