Ejemplo n.º 1
0
void JButton::OnMouse( JMouseEvent& m )
{
    //  check if button being pressed
    if ((m.Action() == aKeyDown || m.Action() == aDblClick) &&
        m.MouseKey() == mkLeft)
    {
        if (m_bTwoState)
        {
            if (m_bPressed)
            {
                Unpress();
            }
            else
            {
                Press();
            }
        }
        else
        {
            CaptureMouse( true );
            Press();
        }
        SetFocus();
        m.Consume();
    }

    //  check if being unpressed (for one-state buttons)
    if (m.Action() == aKeyUp &&
        m.MouseKey() == mkLeft && !m_bTwoState)
    {
        CaptureMouse( false );
        Unpress();
        m.Consume();
    }

    //  automatically unpress when leaving button area
    if (m.Action() == aMouseMove &&
        !GetExt().PtIn( m.MouseX(), m.MouseY() ) &&
        m_bPressed)
    {
        CaptureMouse( false );
        if (!m_bTwoState)
        {
            Unpress();
        }
    }

    if (IsConsumeEvents())
    {
        m.Consume();
    }
} // JButton::OnMouse
Ejemplo n.º 2
0
FReply SButton::OnMouseButtonDown( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent )
{
	FReply Reply = FReply::Unhandled();
	if (IsEnabled() && (MouseEvent.GetEffectingButton() == EKeys::LeftMouseButton || MouseEvent.IsTouchEvent()))
	{
		Press();
		
		if( ClickMethod == EButtonClickMethod::MouseDown )
		{
			//get the reply from the execute function
			Reply = OnClicked.IsBound() ? OnClicked.Execute() : FReply::Handled();

			//You should ALWAYS handle the OnClicked event.
			ensure(Reply.IsEventHandled() == true);
		}
		else if ( IsPreciseTapOrClick(MouseEvent) )
		{
			// do not capture the pointer for precise taps or clicks
			// 
		}
		else
		{
			//we need to capture the mouse for MouseUp events
			Reply =  FReply::Handled().CaptureMouse( AsShared() );
		}
	}

	Invalidate(EInvalidateWidget::Layout);

	//return the constructed reply
	return Reply;
}
Ejemplo n.º 3
0
FReply SButton::OnKeyDown( const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent )
{
	FReply Reply = FReply::Unhandled();
	if (IsEnabled() && (InKeyEvent.GetKey() == EKeys::Enter || InKeyEvent.GetKey() == EKeys::SpaceBar || InKeyEvent.GetKey() == EKeys::Gamepad_FaceButton_Bottom))
	{
		Press();

		if (PressMethod == EButtonPressMethod::ButtonPress)
		{
			//execute our "OnClicked" delegate, and get the reply
			Reply = OnClicked.IsBound() ? OnClicked.Execute() : FReply::Handled();

			//You should ALWAYS handle the OnClicked event.
			ensure(Reply.IsEventHandled() == true);
		}
		else
		{
			Reply = FReply::Handled();
		}
	}
	else
	{
		Reply = SBorder::OnKeyDown(MyGeometry, InKeyEvent);
	}

	//return the constructed reply
	return Reply;
}
Ejemplo n.º 4
0
//=============================================================================
//
// LoadStdImage()
//
// Purpose:     The LoadStdImage() Loads the image for the button.  This 
//				function (or LoadStdStyle()) must be called at a minimum.  
//				Automatically generates the other standard states.
//
// Parameters:  
//		[IN]	id
//				resource id, one of the resources already imported with the 
//				resource editor, usually begins with IDR_  
//
//		[IN]	pType
//				pointer to string describing the resource type
//				
// Returns:     BOOL
//				Non zero if successful, otherwise zero
//
//=============================================================================
BOOL StyleButton::LoadStdImage(UINT id, LPCTSTR pType)
{
	CRect rect; GetClientRect(rect);

	Stack Std(rect);
	Std.AddImage(CPoint(0,0), id, pType);
	m_StdStyle.AddStack(Std);

	Stack Press(rect);
	Press.AddImage(CPoint(1,1), id, pType);
	m_StdPStyle.AddStack(Press);

	Stack Hot(rect);
	Hot.AddImage(CPoint(0,0), id, pType, FALSE, LIGHTEN);
	m_StdHStyle.AddStack(Hot);

	Stack Gray(rect);
	Gray.AddImage(CPoint(0,0), id, pType, FALSE, GRAYSCALE);
	m_StdGStyle.AddStack(Gray);

	// create background
	Stack Back(rect);
	Back.FillSolid(CLEAR);
	m_Background.AddStack(Back);

	return TRUE;
}
Ejemplo n.º 5
0
DLL_EXPORT
int SendKey( int vKey )
{
    int ret;
    ret = Press(vKey);
    Sleep(10);
    ret += Release(vKey);
    return ret;                                 // 2 if all success
}
Ejemplo n.º 6
0
void Button::PressDraw(void)
{
    if(disable || pressed) return;

    Press();

    Draw();

    Display::Get().Flip();
}
Ejemplo n.º 7
0
 void Keyboard::HandleEvent(SDL_KeyboardEvent* e)
 {
   if(e->type == SDL_KEYUP)
     {
       Release(e->keysym.sym);
     }
   else if(e->type == SDL_KEYDOWN)
     {
       Press(e->keysym.sym);
     }
 }
Ejemplo n.º 8
0
void wxButton::Toggle()
{
    if ( m_isPressed )
        Release();
    else
        Press();

    if ( !m_isPressed )
    {
        // releasing button after it had been pressed generates a click event
        Click();
    }
}
Ejemplo n.º 9
0
void wxToggleButton::Toggle()
{
    if ( m_isPressed )
        Release();
    else
        Press();

    if ( !m_isPressed )
    {
        // releasing button after it had been pressed generates a click event
        // and toggles value
        m_value = !m_value;
        Click();
    }
}
Ejemplo n.º 10
0
void wxStdScrollBarInputHandler::StopScrolling(wxScrollBar *control)
{
    // return everything to the normal state
    if ( m_winCapture )
    {
        m_winCapture->ReleaseMouse();
        m_winCapture = NULL;
    }

    m_btnCapture = -1;

    wxDELETE(m_timerScroll);

    // unpress the arrow and highlight the current element
    Press(control, false);
}
Ejemplo n.º 11
0
bool wxButton::PerformAction(const wxControlAction& action,
                             long numArg,
                             const wxString& strArg)
{
    if ( action == wxACTION_BUTTON_TOGGLE )
        Toggle();
    else if ( action == wxACTION_BUTTON_CLICK )
        Click();
    else if ( action == wxACTION_BUTTON_PRESS )
        Press();
    else if ( action == wxACTION_BUTTON_RELEASE )
        Release();
    else
        return wxControl::PerformAction(action, numArg, strArg);

    return true;
}
Ejemplo n.º 12
0
//=============================================================================
//
// LoadAltImage()
//
// Purpose:     The LoadAltImage() Loads the alternate image for the button.  
//				This function call is optional
//				Automatically generates the other alternate states.
//
// Parameters:  
//		[IN]	id
//				resource id, one of the resources already imported with the 
//				resource editor, usually begins with IDR_  
//
//		[IN]	pType
//				pointer to string describing the resource type
//				
// Returns:     BOOL
//				Non zero if successful, otherwise zero
//
//=============================================================================
BOOL StyleButton::LoadAltImage(UINT id, LPCTSTR pType)
{
	CRect rect; GetClientRect(rect);

	Stack Std(rect);
	Std.AddImage(CPoint(0,0), id, pType);
	m_AltStyle.AddStack(Std);

	Stack Press(rect);
	Press.AddImage(CPoint(1,1), id, pType);
	m_AltPStyle.AddStack(Press);

	Stack Hot(rect);
	Hot.AddImage(CPoint(0,0), id, pType, FALSE, LIGHTEN);
	m_AltHStyle.AddStack(Hot);

	m_bHaveAltStyle = TRUE;

	return TRUE;
}
Ejemplo n.º 13
0
LOCAL void g_fprint_raw_Tstate(
	FILE		*file,
	Locstate	state,
	int		dim)
{
	int		i;
	static	char	vname[3][3] = { "vx", "vy", "vz"};

	(void) fprintf(file,"\tdensity = %"FFMT" pressure = %"FFMT" ",
		            Dens(state),Press(state));
	for (i = 0; i < dim; i++)
	    (void) fprintf(file,"%-8s = %"FFMT" ",vname[i],Vel(state)[i]);
	if (debugging("prt_params"))
	    fprint_Gas_param(file,Params(state));
	else
	    (void) fprintf(file,"Gas_param = %llu\n",
		                gas_param_number(Params(state)));


}		/*end g_fprint_raw_Tstate*/
Ejemplo n.º 14
0
/*ARGSUSED*/
LOCAL	void	get_state_rt_kh(
	float		*coords,
	Locstate	state,
	COMP_TYPE	*ct,
	HYPER_SURF	*hs,
	INTERFACE	*intfc,
	INIT_DATA	*init,
	int	        stype)
{
	int		    dim = ct->params->dim;
	STRATIFICATION_TYPE s_type = Rt_kh(ct)->stratification_type;
	float		    *ref_c = Rt_kh(ct)->ref_coords;
	Locstate	    ref_st = Rt_kh(ct)->ref_state;
	float		    z, z_r, g_z;
	const float	    *grav;

	debug_print("init_states","Entered get_state_rt_kh()\n");
	z = coords[dim-1]; 
	z_r = ref_c[dim-1];
	grav = gravity(coords,initial_time(init));
	g_z = grav[dim-1];
	get_state_in_stratified_region(s_type,state,z-z_r,g_z,ref_st);
	if (Dens(state) < 0)
	{
	    screen("ERROR in get_state_rt_kh().\n");
	    fprint_general_vector(stderr,"At point ",coords,dim,"");
	    print_general_vector("At point ",coords,dim,"");
	    screen(", the density of the state is less than 0.\n");
	    clean_up(ERROR);
	}
	if (Press(state) < 0.0)
	{
	    (void) printf("WARNING in get_state_rt_kh().\n");
	    print_general_vector("At point ",coords,dim,"");
	    (void) printf(", the pressure of the state is less than 0.\n");
	}
	set_state(state,stype,state);
}		/*end get_state_rt_kh*/
Ejemplo n.º 15
0
//-----------------------------------------------------------------------------
// Presses the button.
//-----------------------------------------------------------------------------
void CBaseButton::InputPress( inputdata_t &inputdata )
{
	Press( inputdata.pActivator, BUTTON_PRESS );
}
Ejemplo n.º 16
0
LOCAL	void		add_ext_deposition(
	Locstate	state,
	COMPONENT	comp,
	float		*coords,
	int		dim)
{
	float	dep, tcrds[MAXD+1];
	int	i, d;

	if (is_obstacle_state(state)) return;

	//TMP vel pertb
	if(NO)
	{
	    if(coords[2] < 0.8 && coords[2] > -0.8 && comp == deparam[0].comp)
	    {
		set_state(state,TGAS_STATE,state);
		Vel(state)[0] = 0.25*rand()/((float)RAND_MAX + 1);
		Vel(state)[1] = 0.25*rand()/((float)RAND_MAX + 1);
		Vel(state)[2] = 0.25*rand()/((float)RAND_MAX + 1);
		set_state(state,GAS_STATE,state);
	    }
	}

	// set tcrds
	tcrds[0] = 0;
	for (d = 0; d < dim; d++)  tcrds[d+1] = coords[d];
	
	//TMP for cylindy depo
	//tcrds[3] = 0;

	for (i = 0; i < dep_number; i++)
	{
	    if (comp != -1 && comp != deparam[i].comp) continue; // comp = -1 for all components
	    
	    // check if within deposition boundary
	    if ( tcrds[0] < deparam[i].bd[0][0] || tcrds[0] > deparam[i].bd[0][1] )
		continue; // check time
	    if (deparam[i].region == DEP_RECT)
	    {
		for (d = 1; d < dim+1; d++)
		    if ( tcrds[d] < deparam[i].bd[d][0] || tcrds[d] > deparam[i].bd[d][1] )
			    break;
		if (d < dim+1)  continue;
	    }
	    else // DEP_ELLIP
	    {
		float	sum = 0;
		for (d = 1; d < dim+1; d++)
		    sum += sqr((tcrds[d]-deparam[i].bd[d][0])/deparam[i].bd[d][1]);
		//if (sum > 1) continue;
	    }

	    dep = deparam[i].amp;
	    
	    for (d = 0; d < dim+1; d++)
	    {
		if (deparam[i].prof[d] == GAUSSIAN)
		{   // param[d][0] = decay length
		    if (deparam[i].flag[d][0] == false) // Gaussian
			dep /= exp(sqr((tcrds[d]-deparam[i].orig[d])/deparam[i].param[d][0]));
		    else // exponential
			dep /= exp((tcrds[d]-deparam[i].orig[d])/deparam[i].param[d][0]);
		}
		else if (deparam[i].prof[d] == POWER)
		{   // param[d][0] = decay exponent
		    dep /= pow(fabs(tcrds[d]-deparam[i].orig[d]),deparam[i].param[d][0]);
		}
		else if (deparam[i].prof[d] == SINUSOIDAL)
		{   // param[d][0] = wavelength, params[d][1] = phase
		    dep *= sin(2*PI*( (tcrds[d] - deparam[i].orig[d])
			/ deparam[i].param[d][0] + deparam[i].param[d][1]/360 ));
		}
	    }

	    dep += deparam[i].base;
	    switch(deparam[i].type)
	    {
		case EXT_ENERGY: // total energy density
		    Energy(state) = dep;
		    break;
		case EXT_PRESSURE:
		    set_state(state,TGAS_STATE,state);
		    //dep = interp_from_data(coords)*13000.0/0.009351;
		    //dep = interp_from_data(coords)*17500.0/0.03976;
		    //dep = interp_from_data(coords);
		    dep = interp_from_data(coords)*15000.0/0.01544;

		    Press(state) += dep;
		    
		    set_state(state,GAS_STATE,state);
		    break;
		case EXT_TEMPER: // keep density fixed
		    set_state(state,FGAS_STATE,state);
		    Temperature(state) = dep;
		    set_state(state,GAS_STATE,state);
		    break;
		case EXT_VX:
		    set_state(state,TGAS_STATE,state);
		    Vel(state)[0] = dep;
		    set_state(state,GAS_STATE,state);
		    break;
		case EXT_VY:
		    set_state(state,TGAS_STATE,state);
		    Vel(state)[1] = dep;
		    set_state(state,GAS_STATE,state);
		    break;
		case EXT_VZ:
		    set_state(state,TGAS_STATE,state);
		    Vel(state)[2] = dep;
		    set_state(state,GAS_STATE,state);
		    break;
		case EXT_DENSITY:
		    Dens(state) = dep;
		    break;
	    }
	    if (debugging("deposition"))
	    {
		printf("{%c}dep[",dep_name[deparam[i].type]);
		for (d = 0;d < dim-1;d++)  printf("%g,",coords[d]);
		printf("%g]=%g, ",coords[dim-1],dep);
	    }
	}
}	/* end add_ext_deposition() */
Ejemplo n.º 17
0
HRESULT CUIButton::Display(int OffsetX, int OffsetY) {
	if (!m_Visible) return S_OK;

	CUITiledImage *back = NULL;
	CBSprite *image = NULL;
	CBFont *font = 0;

	//RECT rect;
	//CBPlatform::SetRect(&rect, OffsetX + m_PosX, OffsetY + m_PosY, OffsetX+m_PosX+m_Width, OffsetY+m_PosY+m_Height);
	//m_Hover = (!m_Disable && CBPlatform::PtInRect(&rect, Game->m_MousePos)!=FALSE);
	m_Hover = (!m_Disable && Game->m_ActiveObject == this && (Game->m_Interactive || Game->m_State == GAME_SEMI_FROZEN));

	if ((m_Press && m_Hover && !Game->m_MouseLeftDown) ||
	        m_OneTimePress && CBPlatform::GetTime() - m_OneTimePressTime >= 100) Press();


	if (m_Disable) {
		if (m_BackDisable) back = m_BackDisable;
		if (m_ImageDisable) image = m_ImageDisable;
		if (m_Text && m_FontDisable) font = m_FontDisable;
	} else if (m_Press || m_OneTimePress || m_StayPressed) {
		if (m_BackPress) back = m_BackPress;
		if (m_ImagePress) image = m_ImagePress;
		if (m_Text && m_FontPress) font = m_FontPress;
	} else if (m_Hover) {
		if (m_BackHover) back = m_BackHover;
		if (m_ImageHover) image = m_ImageHover;
		if (m_Text && m_FontHover) font = m_FontHover;
	} else if (m_CanFocus && IsFocused()) {
		if (m_BackFocus) back = m_BackFocus;
		if (m_ImageFocus) image = m_ImageFocus;
		if (m_Text && m_FontFocus) font = m_FontFocus;
	}

	if (!back && m_Back) back = m_Back;
	if (!image && m_Image) image = m_Image;
	if (m_Text && !font) {
		if (m_Font) font = m_Font;
		else font = Game->m_SystemFont;
	}

	int ImageX = OffsetX + m_PosX;
	int ImageY = OffsetY + m_PosY;

	if (image && m_CenterImage) {
		RECT rc;
		image->GetBoundingRect(&rc, 0, 0);
		ImageX += (m_Width - (rc.right - rc.left)) / 2;
		ImageY += (m_Height - (rc.bottom - rc.top)) / 2;
	}

	if (back) back->Display(OffsetX + m_PosX, OffsetY + m_PosY, m_Width, m_Height);
	//if(image) image->Draw(ImageX +((m_Press||m_OneTimePress)&&back?1:0), ImageY +((m_Press||m_OneTimePress)&&back?1:0), NULL);
	if (image) image->Draw(ImageX + ((m_Press || m_OneTimePress) && back ? 1 : 0), ImageY + ((m_Press || m_OneTimePress) && back ? 1 : 0), m_PixelPerfect ? this : NULL);

	if (font && m_Text) {
		int text_offset = (m_Height - font->GetTextHeight((byte  *)m_Text, m_Width)) / 2;
		font->DrawText((byte  *)m_Text, OffsetX + m_PosX + ((m_Press || m_OneTimePress) ? 1 : 0), OffsetY + m_PosY + text_offset + ((m_Press || m_OneTimePress) ? 1 : 0), m_Width, m_Align);
	}

	if (!m_PixelPerfect || !m_Image) Game->m_Renderer->m_RectList.Add(new CBActiveRect(Game, this, NULL, OffsetX + m_PosX, OffsetY + m_PosY, m_Width, m_Height, 100, 100, false));

	// reset unused sprites
	if (m_Image && m_Image != image) m_Image->Reset();
	if (m_ImageDisable && m_ImageDisable != image) m_ImageDisable->Reset();
	if (m_ImageFocus && m_ImageFocus != image) m_ImageFocus->Reset();
	if (m_ImagePress && m_ImagePress != image) m_ImagePress->Reset();
	if (m_ImageHover && m_ImageHover != image) m_ImageHover->Reset();

	m_Press = m_Hover && Game->m_MouseLeftDown && Game->m_CapturedObject == this;

	return S_OK;
}
Ejemplo n.º 18
0
LOCAL	void	rt_add_to_state(
	float		*coords,
	Locstate	state, /* assumed to be TGAS_STATE */
	COMP_TYPE	*ct,
	INIT_DATA	*init)
{
#if defined(float)
	static const float ACC = 1.0e-14;		/*TOLERANCE*/
#else /* defined(float) */
	static const float ACC = 1.0e-7;		/*TOLERANCE*/
#endif /* defined(float) */

	int		i, j, k0, k1, dim, layer_label, num_modes, nstep;
	float		rho, csq, rho_prime, a_z, b_z, k_dot_r, sig, phase;
	float		tmp, ub, lb, z0, z1, a0, a1, b0, b1, z, h_z, g_z;
	const float	*grav;
	_RT_PERTURBED	*rtp = Rt_perturbed(ct);
	NORMAL_MODE	*n_m;

	dim = ct->params->dim;
	layer_label = rtp->layer_label;
	nstep = rtp->lin_pert_intvl;
	num_modes = rtp->num_modes;

	if (num_modes <= 0)	return;

	z0 = lb = get_surf_height(coords, rtp->lower_surf);
	z1 = ub = get_surf_height(coords, rtp->upper_surf);
	h_z = (ub-lb)/nstep;
	z = coords[dim-1];
	grav = gravity(coords,initial_time(init));
	g_z = grav[dim-1];

	/* find out which interval z belongs */
	if (ub < lb)
	{
	    screen("\nERROR in rt_add_to_state(), ");
	    screen("Interfaces are already tangled.\n");
	    (void) printf("ub = %g, lb = %g\n",ub,lb);
	    print_interface(current_interface());
	    clean_up(ERROR);
	}
	if (z >= ub)
	    k0 = k1 = nstep;
	else if (z <= lb)
	    k0 = k1 = 0;
	else
	{
	    k0 = 0,		k1 = nstep;
	    for (;;)
	    {
	    	tmp = (z0+z1)/2.0;
	    	if (z >= tmp)
	    	    k0 = (k0+k1)/2, 	z0 = tmp;
	    	else
	    	    k1 = (k0+k1)/2, 	z1 = tmp;
	    	if (k1-k0 == 1)	break;
	    }
	}

	z0 = lb+k0*h_z;	
	z1 = lb+k1*h_z;	
	rho = Dens(state);
	csq = sound_speed_squared(state);
	rho_prime = get_rho_prime(state,ct,g_z);
	/* sum over all the normal modes */
	for (i = 0; i < num_modes; ++i)
	{
	    n_m = rtp->normal_mode[i];
	    if (k0 == k1)
	    {
	    	a_z = n_m->a[layer_label][k1];
	    	b_z = n_m->b[layer_label][k1];
	    }
	    else
	    {
	    	a0 = n_m->a[layer_label][k0];
	    	a1 = n_m->a[layer_label][k1];
	    	a_z = ((a1-a0)*z+(a0*z1-a1*z0))/h_z;
	    	b0 = n_m->b[layer_label][k0];
	    	b1 = n_m->b[layer_label][k1];
	    	b_z = ((b1-b0)*z+(b0*z1-b1*z0))/h_z;
	    }
	    if ((fabs(a_z) < ACC) && (fabs(b_z) < ACC))	continue;

	    sig = n_m->sigma_r;
	    phase = n_m->phase;
	    k_dot_r = 0.0;
	    for (j = 0; j <= dim-2; ++j)
	    	k_dot_r += n_m->wv_num[j]*coords[j];
	    phase += k_dot_r;
	    Dens(state) += ((g_z*rho/csq-rho_prime)*a_z+b_z/csq)/sig*sin(phase);
	    Press(state) += b_z/sig*sin(phase);
	    Vel(state)[dim-1] += a_z*sin(phase);
	    set_type_of_state(state,TGAS_STATE);
	    phase += 3.0*PI/2;
	    for (j = 0; j <= dim-2; ++j)
	        Vel(state)[j] += sin(phase)*n_m->wv_num[j]*b_z/(rho*sig*sig);
            reset_gamma(state);
	}
}		/*end rt_add_to_state*/
Ejemplo n.º 19
0
bool wxStdScrollBarInputHandler::HandleMouse(wxInputConsumer *consumer,
                                             const wxMouseEvent& event)
{
    // is this a click event from an acceptable button?
    int btn = event.GetButton();
    if ( btn == wxMOUSE_BTN_LEFT )
    {
        // determine which part of the window mouse is in
        wxScrollBar *scrollbar = wxStaticCast(consumer->GetInputWindow(), wxScrollBar);
        wxHitTest ht = scrollbar->HitTestBar(event.GetPosition());

        // when the mouse is pressed on any scrollbar element, we capture it
        // and hold capture until the same mouse button is released
        if ( event.ButtonDown() || event.ButtonDClick() )
        {
            if ( !m_winCapture )
            {
                m_btnCapture = btn;
                m_winCapture = consumer->GetInputWindow();
                m_winCapture->CaptureMouse();

                // generate the command
                bool hasAction = true;
                wxControlAction action;
                switch ( ht )
                {
                    case wxHT_SCROLLBAR_ARROW_LINE_1:
                        action = wxACTION_SCROLL_LINE_UP;
                        break;

                    case wxHT_SCROLLBAR_ARROW_LINE_2:
                        action = wxACTION_SCROLL_LINE_DOWN;
                        break;

                    case wxHT_SCROLLBAR_BAR_1:
                        action = wxACTION_SCROLL_PAGE_UP;
                        m_ptStartScrolling = event.GetPosition();
                        break;

                    case wxHT_SCROLLBAR_BAR_2:
                        action = wxACTION_SCROLL_PAGE_DOWN;
                        m_ptStartScrolling = event.GetPosition();
                        break;

                    case wxHT_SCROLLBAR_THUMB:
                        consumer->PerformAction(wxACTION_SCROLL_THUMB_DRAG);
                        m_ofsMouse = GetMouseCoord(scrollbar, event) -
                                     scrollbar->ScrollbarToPixel();

                        // fall through: there is no immediate action

                    default:
                        hasAction = false;
                }

                // remove highlighting
                Highlight(scrollbar, false);
                m_htLast = ht;

                // and press the arrow or highlight thumb now instead
                if ( m_htLast == wxHT_SCROLLBAR_THUMB )
                    Highlight(scrollbar, true);
                else
                    Press(scrollbar, true);

                // start dragging
                if ( hasAction )
                {
                    m_timerScroll = new wxScrollBarTimer(this, action,
                                                         scrollbar);
                    m_timerScroll->StartAutoScroll();
                }
                //else: no (immediate) action

            }
            //else: mouse already captured, nothing to do
        }
        // release mouse if the *same* button went up
        else if ( btn == m_btnCapture )
        {
            if ( m_winCapture )
            {
                StopScrolling(scrollbar);

                // if we were dragging the thumb, send the last event
                if ( m_htLast == wxHT_SCROLLBAR_THUMB )
                {
                    scrollbar->PerformAction(wxACTION_SCROLL_THUMB_RELEASE);
                }

                m_htLast = ht;
                Highlight(scrollbar, true);
            }
            else
            {
                // this is not supposed to happen as the button can't go up
                // without going down previously and then we'd have
                // m_winCapture by now
                wxFAIL_MSG( wxT("logic error in mouse capturing code") );
            }
        }
    }

    return wxStdInputHandler::HandleMouse(consumer, event);
}
bool mitk::ExtrudedContourInteractor::ExecuteAction(mitk::Action* action, mitk::StateEvent const* stateEvent)
{
  mitk::Point3D eventPoint;
  mitk::Vector3D eventPlaneNormal;

  const mitk::PositionEvent* posEvent = dynamic_cast<const mitk::PositionEvent*>(stateEvent->GetEvent());

  if(posEvent==NULL)
  {
    const mitk::DisplayPositionEvent* displayPosEvent = dynamic_cast<const mitk::DisplayPositionEvent*>(stateEvent->GetEvent());
    mitk::VtkPropRenderer* sender = (mitk::VtkPropRenderer*) stateEvent->GetEvent()->GetSender();

    if((displayPosEvent == NULL) || (sender == NULL))
      return false;

    eventPoint[0] = displayPosEvent->GetDisplayPosition()[0];
    eventPoint[1] = displayPosEvent->GetDisplayPosition()[1];
    eventPoint[2] = 0;

    typedef itk::Point<double,3> DoublePoint3D;
    DoublePoint3D p;
    p.CastFrom(eventPoint);
    sender->GetVtkRenderer()->SetDisplayPoint(p.GetDataPointer());

    sender->GetVtkRenderer()->DisplayToWorld();

    double *vtkwp = sender->GetVtkRenderer()->GetWorldPoint();

    vtk2itk(vtkwp, eventPoint);

    double *vtkvpn = sender->GetVtkRenderer()->GetActiveCamera()->GetViewPlaneNormal();
    vtk2itk(vtkvpn, eventPlaneNormal); eventPlaneNormal = -eventPlaneNormal;
  }
  else
  {
    eventPoint = posEvent->GetWorldPosition();
    mitk::BaseRenderer* sender = (mitk::BaseRenderer*) stateEvent->GetEvent()->GetSender();
    eventPlaneNormal = sender->GetCurrentWorldPlaneGeometry()->GetAxisVector(2);
  }


  bool ok = false;
  switch (action->GetActionId())
  {
  case mitk::AcNEWPOINT:
    {
      Press(eventPoint);
      ok = true;
      m_Started = true;
      break;
    }
  case mitk::AcINITMOVEMENT:
    {
      if (m_Started)
      {
        Move(eventPoint);
        ok = true;
        break;
      }
    }
  case mitk::AcMOVEPOINT:
    {
      if (m_Started)
      {
        Move(eventPoint);
        ok = true;
        break;
      }
    }
  case mitk::AcFINISHMOVEMENT:
    {
      if (m_Started)
      {
        mitk::ExtrudedContour* extrudedcontour = dynamic_cast<mitk::ExtrudedContour*>(m_DataNode->GetData());
        extrudedcontour->SetContour(m_Contour);
        extrudedcontour->SetVector(eventPlaneNormal);
        Release(eventPoint);
        ok = true;
        m_Started = false;
        InvokeEvent(itk::EndEvent());
      }
      break;
    }
  default:
    ok = false;
    break;
  }
  return ok;
}
Ejemplo n.º 21
0
//-----------------------------------------------------------------------------
// Unpresses the button, sending it to the unpressed/bottom position.
//-----------------------------------------------------------------------------
void CBaseButton::InputPressOut( inputdata_t &inputdata )
{
	Press( inputdata.pActivator, BUTTON_RETURN );
}
Ejemplo n.º 22
0
//-----------------------------------------------------------------------------
// Presses the button, sending it to the top/pressed position.
//-----------------------------------------------------------------------------
void CBaseButton::InputPressIn( inputdata_t &inputdata )
{
	Press( inputdata.pActivator, BUTTON_ACTIVATE );
}
Ejemplo n.º 23
0
void FadePedal::onPressed()
{
	Press();
}
Ejemplo n.º 24
0
bool CButton::ProcessInput( const TInputMsg & tData )
{
	if ( IsMouseOver( g_pUIManager->GetMousePos() ) )
		SetText( "Over" );
	else
		SetText( "OK" );

	switch ( tData.eType )
	{
		case IMT_MOUSE_MOVE_X:
		case IMT_MOUSE_MOVE_Y:
		{
			if ( IsMouseOver( g_pUIManager->GetMousePos() ) )
			{
				if ( this == g_pUIManager->GetActiveControl() )
				{
					m_bPressed = true;
				}
			}
			else
			{
				m_bPressed = false;
			}
		}
		break;

		case IMT_MOUSE_LKEY:
		{
			if ( IsMouseOver( g_pUIManager->GetMousePos() ) )
			{
				if ( tData.dwData & 0x80 )
				{
					Press();
					g_pUIManager->SetActiveControl( this );
				}
				else
				{
					if ( this == g_pUIManager->GetActiveControl() )
					{
						g_pUIManager->SetActiveControl( NULL );
						MessageBeep( MB_OK );

						//if ( m_pParent )
						//	m_pParent->OnChildEvent( this );

						Press( false );
					}
				}

				return true;
			}
			else if ( this == g_pUIManager->GetActiveControl() )
			{
				if ( !( tData.dwData & 0x80 ) )
					g_pUIManager->SetActiveControl( NULL );
			}
		}
		break;
	}

	return false;
}