Commit 81c55e65 authored by Olivier Teulière's avatar Olivier Teulière

* skins2/*: Change mouse cursor above a Resize control (win32 only)

parent 44bc88f3
......@@ -2,7 +2,7 @@
* ctrl_resize.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: ctrl_resize.cpp,v 1.2 2004/02/29 16:49:55 asmax Exp $
* $Id$
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -27,6 +27,7 @@
#include "../events/evt_mouse.hpp"
#include "../events/evt_motion.hpp"
#include "../src/generic_layout.hpp"
#include "../src/os_factory.hpp"
#include "../utils/position.hpp"
#include "../commands/async_queue.hpp"
#include "../commands/cmd_resize.hpp"
......@@ -36,19 +37,26 @@ CtrlResize::CtrlResize( intf_thread_t *pIntf, CtrlFlat &rCtrl,
GenericLayout &rLayout, const UString &rHelp,
VarBool *pVisible ):
CtrlFlat( pIntf, rHelp, pVisible ), m_fsm( pIntf ), m_rCtrl( rCtrl ),
m_rLayout( rLayout ), m_cmdResizeResize( this, &transResizeResize ),
m_rLayout( rLayout ), m_cmdOutStill( this, &transOutStill ),
m_cmdStillOut( this, &transStillOut ),
m_cmdStillStill( this, &transStillStill ),
m_cmdStillResize( this, &transStillResize ),
m_cmdResizeStill( this, &transResizeStill )
m_cmdResizeStill( this, &transResizeStill ),
m_cmdResizeResize( this, &transResizeResize )
{
m_pEvt = NULL;
m_xPos = 0;
m_yPos = 0;
// States
m_fsm.addState( "resize" );
m_fsm.addState( "out" );
m_fsm.addState( "still" );
m_fsm.addState( "resize" );
// Transitions
m_fsm.addTransition( "out", "enter", "still", &m_cmdOutStill );
m_fsm.addTransition( "still", "leave", "out", &m_cmdStillOut );
m_fsm.addTransition( "still", "motion", "still", &m_cmdStillStill );
m_fsm.addTransition( "resize", "mouse:left:up:none", "still",
&m_cmdResizeStill );
m_fsm.addTransition( "still", "mouse:left:down:none", "resize",
......@@ -95,11 +103,39 @@ void CtrlResize::handleEvent( EvtGeneric &rEvent )
}
void CtrlResize::transOutStill( SkinObject *pCtrl )
{
CtrlResize *pThis = (CtrlResize*)pCtrl;
OSFactory *pOsFactory = OSFactory::instance( pThis->getIntf() );
pOsFactory->changeCursor( OSFactory::kResizeNWSE );
}
void CtrlResize::transStillOut( SkinObject *pCtrl )
{
CtrlResize *pThis = (CtrlResize*)pCtrl;
OSFactory *pOsFactory = OSFactory::instance( pThis->getIntf() );
pOsFactory->changeCursor( OSFactory::kDefaultArrow );
}
void CtrlResize::transStillStill( SkinObject *pCtrl )
{
CtrlResize *pThis = (CtrlResize*)pCtrl;
OSFactory *pOsFactory = OSFactory::instance( pThis->getIntf() );
pOsFactory->changeCursor( OSFactory::kResizeNWSE );
}
void CtrlResize::transStillResize( SkinObject *pCtrl )
{
CtrlResize *pThis = (CtrlResize*)pCtrl;
EvtMouse *pEvtMouse = (EvtMouse*)pThis->m_pEvt;
// Set the cursor
OSFactory *pOsFactory = OSFactory::instance( pThis->getIntf() );
pOsFactory->changeCursor( OSFactory::kResizeNWSE );
pThis->m_xPos = pEvtMouse->getXPos();
pThis->m_yPos = pEvtMouse->getYPos();
......@@ -110,11 +146,27 @@ void CtrlResize::transStillResize( SkinObject *pCtrl )
}
void CtrlResize::transResizeStill( SkinObject *pCtrl )
{
CtrlResize *pThis = (CtrlResize*)pCtrl;
// Set the cursor
OSFactory *pOsFactory = OSFactory::instance( pThis->getIntf() );
pOsFactory->changeCursor( OSFactory::kResizeNWSE );
pThis->releaseMouse();
}
void CtrlResize::transResizeResize( SkinObject *pCtrl )
{
CtrlResize *pThis = (CtrlResize*)pCtrl;
EvtMotion *pEvtMotion = (EvtMotion*)pThis->m_pEvt;
// Set the cursor
OSFactory *pOsFactory = OSFactory::instance( pThis->getIntf() );
pOsFactory->changeCursor( OSFactory::kResizeNWSE );
int newWidth = pEvtMotion->getXPos() - pThis->m_xPos + pThis->m_width;
int newHeight = pEvtMotion->getYPos() - pThis->m_yPos + pThis->m_height;
......@@ -144,12 +196,3 @@ void CtrlResize::transResizeResize( SkinObject *pCtrl )
pQueue->remove( "resize" );
pQueue->push( CmdGenericPtr( pCmd ) );
}
void CtrlResize::transResizeStill( SkinObject *pCtrl )
{
CtrlResize *pThis = (CtrlResize*)pCtrl;
pThis->releaseMouse();
}
......@@ -2,7 +2,7 @@
* ctrl_resize.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: ctrl_resize.hpp,v 1.2 2004/02/29 16:49:55 asmax Exp $
* $Id$
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -57,9 +57,12 @@ class CtrlResize: public CtrlFlat
/// Get the position of the decorated control in the layout, if any
virtual const Position *getPosition() const;
static void transResizeResize( SkinObject *pCtrl );
static void transOutStill( SkinObject *pCtrl );
static void transStillOut( SkinObject *pCtrl );
static void transStillStill( SkinObject *pCtrl );
static void transStillResize( SkinObject *pCtrl );
static void transResizeStill( SkinObject *pCtrl );
static void transResizeResize( SkinObject *pCtrl );
private:
FSM m_fsm;
......@@ -72,9 +75,12 @@ class CtrlResize: public CtrlFlat
/// Position of the click that started the resizing
int m_xPos, m_yPos;
/// Callbacks
Callback m_cmdResizeResize;
Callback m_cmdOutStill;
Callback m_cmdStillOut;
Callback m_cmdStillStill;
Callback m_cmdStillResize;
Callback m_cmdResizeStill;
Callback m_cmdResizeResize;
// Size of the layout, before resizing
int m_width, m_height;
......
......@@ -2,7 +2,7 @@
* os_factory.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: os_factory.hpp,v 1.1 2004/01/03 23:31:33 asmax Exp $
* $Id$
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -42,6 +42,15 @@ class OSTimer;
class OSFactory: public SkinObject
{
public:
typedef enum
{
kDefaultArrow,
kResizeNS,
kResizeWE,
kResizeNWSE,
kResizeNESW
} CursorType_t;
/// Initialization method overloaded in derived classes.
/// It must return false if the init failed.
virtual bool init() { return true; }
......@@ -85,6 +94,9 @@ class OSFactory: public SkinObject
/// Get the position of the mouse
virtual void getMousePos( int &rXPos, int &rYPos ) const = 0;
/// Change the cursor
virtual void changeCursor( CursorType_t type ) const = 0;
/// Delete a directory recursively
virtual void rmDir( const string &rPath ) = 0;
......
......@@ -2,7 +2,7 @@
* win32_factory.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: win32_factory.cpp,v 1.2 2004/01/27 17:01:51 gbazin Exp $
* $Id$
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -271,6 +271,36 @@ void Win32Factory::getMousePos( int &rXPos, int &rYPos ) const
}
void Win32Factory::changeCursor( CursorType_t type ) const
{
LPCTSTR id;
switch( type )
{
case kDefaultArrow:
id = IDC_ARROW;
break;
case kResizeNWSE:
id = IDC_SIZENWSE;
break;
case kResizeNS:
id = IDC_SIZENS;
break;
case kResizeWE:
id = IDC_SIZEWE;
break;
case kResizeNESW:
id = IDC_SIZENESW;
break;
default:
id = IDC_ARROW;
break;
}
HCURSOR hCurs = LoadCursor( NULL, id );
SetCursor( hCurs );
}
void Win32Factory::rmDir( const string &rPath )
{
WIN32_FIND_DATA find;
......
......@@ -2,7 +2,7 @@
* win32_factory.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: win32_factory.hpp,v 1.3 2004/02/27 13:24:12 gbazin Exp $
* $Id$
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -25,7 +25,9 @@
#ifndef WIN32_FACTORY_HPP
#define WIN32_FACTORY_HPP
#define _WIN32_WINNT 0x0500
#ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0500
#endif
#include <windows.h>
#include "../src/os_factory.hpp"
......@@ -74,6 +76,9 @@ class Win32Factory: public OSFactory
/// Get the position of the mouse
virtual void getMousePos( int &rXPos, int &rYPos ) const;
/// Change the cursor
virtual void changeCursor( CursorType_t type ) const;
/// Delete a directory recursively
virtual void rmDir( const string &rPath );
......@@ -86,8 +91,8 @@ class Win32Factory: public OSFactory
// We dynamically load msimg32.dll to get a pointer to TransparentBlt()
BOOL (WINAPI *TransparentBlt)( HDC, int, int, int, int,
HDC, int, int, int, int, UINT );
BOOL (WINAPI *AlphaBlend)( HDC, int, int, int, int, HDC, int, int,
int, int, BLENDFUNCTION );
BOOL (WINAPI *AlphaBlend)( HDC, int, int, int, int,
HDC, int, int, int, int, BLENDFUNCTION );
// Idem for user32.dll and SetLayeredWindowAttributes()
BOOL (WINAPI *SetLayeredWindowAttributes)( HWND, COLORREF,
......
......@@ -2,7 +2,7 @@
* x11_factory.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: x11_factory.hpp,v 1.2 2004/01/18 00:25:02 asmax Exp $
* $Id$
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -82,6 +82,9 @@ class X11Factory: public OSFactory
/// Get the position of the mouse
virtual void getMousePos( int &rXPos, int &rYPos ) const;
/// Change the cursor
virtual void changeCursor( CursorType_t type ) const { /*TODO*/ }
/// Delete a directory recursively
virtual void rmDir( const string &rPath );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment