* win32_window.cpp: Win32 implementation of the Window class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: win32_window.cpp,v 1.2 2003/03/19 02:09:56 videolan Exp $
+ * $Id: win32_window.cpp,v 1.14 2003/10/22 19:12:56 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
* USA.
*****************************************************************************/
+#ifdef WIN32
+
+/* For TrackMouseEvent, WM_MOUSEWHEEL and GET_WHEEL_DELTA_WPARAM */
+#undef WINVER
+#undef _WIN32_WINNT
+#define _WIN32_WINNT 0x0500
+#define WINVER 0x0500
//--- GENERAL ---------------------------------------------------------------
//#include <math.h>
#include <windows.h>
//--- SKIN ------------------------------------------------------------------
-#include "os_api.h"
-#include "anchor.h"
-#include "generic.h"
-#include "window.h"
-#include "os_window.h"
-#include "event.h"
-#include "os_event.h"
-#include "graphics.h"
-#include "os_graphics.h"
-#include "skin_common.h"
-#include "theme.h"
-
-
+#include "../os_api.h"
+#include "../src/anchor.h"
+#include "../controls/generic.h"
+#include "../src/window.h"
+#include "../os_window.h"
+#include "../src/event.h"
+#include "../os_event.h"
+#include "../src/graphics.h"
+#include "../os_graphics.h"
+#include "../src/skin_common.h"
+#include "../src/theme.h"
+#include "../os_theme.h"
+#include "../src/banks.h"
//---------------------------------------------------------------------------
// Fading API
//---------------------------------------------------------------------------
#define LWA_COLORKEY 0x00000001
#define LWA_ALPHA 0x00000002
-typedef BOOL (WINAPI *SLWA)(HWND, COLORREF, BYTE, DWORD);
-HMODULE hModule = LoadLibrary( "user32.dll" );
-SLWA SetLayeredWindowAttributes =
- (SLWA)GetProcAddress( hModule, "SetLayeredWindowAttributes" );
-
//---------------------------------------------------------------------------
// Skinable Window
//---------------------------------------------------------------------------
Win32Window::Win32Window( intf_thread_t *p_intf, HWND hwnd, int x, int y,
bool visible, int transition, int normalalpha, int movealpha,
- bool dragdrop )
- : Window( p_intf, x, y, visible, transition, normalalpha, movealpha,
+ bool dragdrop, bool playondrop )
+ : SkinWindow( p_intf, x, y, visible, transition, normalalpha, movealpha,
dragdrop )
{
// Set handles
- hWnd = hwnd;
+ hWnd = hwnd;
// Set position parameters
- CursorPos = new POINT;
- WindowPos = new POINT;
+ CursorPos = new POINT;
+ WindowPos = new POINT;
// Create Tool Tip Window
ToolTipWindow = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL,
ToolTipInfo.uId = (unsigned int)hWnd;
ToolTipInfo.lpszText = NULL;
ToolTipInfo.rect.left = ToolTipInfo.rect.top = 0;
- ToolTipInfo.rect.right = ToolTipInfo.rect.bottom = 0;
+ ToolTipInfo.rect.right = ToolTipInfo.rect.bottom = 0;
SendMessage( ToolTipWindow, TTM_ADDTOOL, 0,
(LPARAM)(LPTOOLINFO) &ToolTipInfo );
{
// Initialize the OLE library
OleInitialize( NULL );
- DropTarget = (LPDROPTARGET) new Win32DropObject();
+ DropTarget = (LPDROPTARGET) new Win32DropObject( playondrop );
// register the listview as a drop target
RegisterDragDrop( hWnd, DropTarget );
}
-
}
//---------------------------------------------------------------------------
Win32Window::~Win32Window()
// Uninitialize the OLE library
OleUninitialize();
}
-
-}
-//---------------------------------------------------------------------------
-void Win32Window::OSShow( bool show )
-{
- if( show )
- {
- ShowWindow( hWnd, SW_SHOW );
- }
- else
- {
- ShowWindow( hWnd, SW_HIDE );
- }
}
//---------------------------------------------------------------------------
bool Win32Window::ProcessOSEvent( Event *evt )
case WM_MOUSEMOVE:
TRACKMOUSEEVENT TrackEvent;
- TrackEvent.cbSize = sizeof( TRACKMOUSEEVENT );\r
- TrackEvent.dwFlags = TME_LEAVE;\r
- TrackEvent.hwndTrack = hWnd;\r
+ TrackEvent.cbSize = sizeof( TRACKMOUSEEVENT );
+ TrackEvent.dwFlags = TME_LEAVE;
+ TrackEvent.hwndTrack = hWnd;
TrackEvent.dwHoverTime = 1;
TrackMouseEvent( &TrackEvent );
if( p1 == MK_LBUTTON )
return true;
case WM_MOUSELEAVE:
- MouseMove( -1, -1, 0 );
+ OSAPI_PostMessage( this, WINDOW_LEAVE, 0, 0 );
+ return true;
+
+ case WM_MOUSEWHEEL:
+ if( GET_WHEEL_DELTA_WPARAM( p1 ) > 0 )
+ MouseScroll( LOWORD( p2 ) - Left, HIWORD( p2 ) - Top,
+ MOUSE_SCROLL_UP );
+ else if( GET_WHEEL_DELTA_WPARAM( p1 ) < 0 )
+ MouseScroll( LOWORD( p2 ) - Left, HIWORD( p2 ) - Top,
+ MOUSE_SCROLL_DOWN );
return true;
default:
}
}
//---------------------------------------------------------------------------
+void Win32Window::ToggleOnTop()
+{
+ Win32Theme *winTheme = (Win32Theme *)p_intf->p_sys->p_theme;
+ HMENU hMenu = GetSystemMenu( winTheme->GetParentWindow(), false );
+ Event *event = p_intf->p_sys->p_theme->EvtBank->Get( "on_top" );
+
+ if( !p_intf->p_sys->b_on_top )
+ {
+ // Set the window on top
+ SetWindowPos( hWnd, HWND_TOPMOST, 0, 0, 0, 0,
+ SWP_NOSIZE | SWP_NOMOVE );
+ // Check the menu entry (FIXME: we shouldn't do that here...)
+ CheckMenuItem( hMenu, (unsigned int)event,
+ MF_BYCOMMAND | MFS_CHECKED );
+ }
+ else
+ {
+ // Set the window not on top
+ SetWindowPos( hWnd, HWND_NOTOPMOST, 0, 0, 0, 0,
+ SWP_NOSIZE | SWP_NOMOVE );
+ // Uncheck the menu entry (FIXME: we shouldn't do that here...)
+ CheckMenuItem( hMenu, (unsigned int)event,
+ MF_BYCOMMAND | MFS_UNCHECKED );
+ }
+}
+//---------------------------------------------------------------------------
+void Win32Window::OSShow( bool show )
+{
+ if( show )
+ {
+ ShowWindow( hWnd, SW_SHOW );
+ }
+ else
+ {
+ ShowWindow( hWnd, SW_HIDE );
+ }
+}
+//---------------------------------------------------------------------------
void Win32Window::SetTransparency( int Value )
{
if( Value > -1 )
Alpha = Value;
- SetLayeredWindowAttributes( hWnd, 0, Alpha, LWA_ALPHA | LWA_COLORKEY );
+
+ if( p_intf->p_sys->SetLayeredWindowAttributes )
+ p_intf->p_sys->SetLayeredWindowAttributes( hWnd, 0, Alpha,
+ LWA_ALPHA | LWA_COLORKEY );
+
UpdateWindow( hWnd );
}
//---------------------------------------------------------------------------
// Release window device context
ReleaseDC( hWnd, DC );
-
}
//---------------------------------------------------------------------------
void Win32Window::WindowManualMove()
// Free memory
delete[] NewPos;
-
}
//---------------------------------------------------------------------------
void Win32Window::WindowManualMoveInit()
(LPARAM)(LPTOOLINFO)&ToolTipInfo );
}
}
-
}
//---------------------------------------------------------------------------
+#endif