VLC_ADD_CXXFLAGS([skins2],[-O2 -fno-rtti])
VLC_ADD_LDFLAGS([skins2],[-loleaut32 -lwinspool -lwinmm -lshell32 -lctl3d32 -ladvapi32 -lwsock32 -lgdi32 -lcomdlg32 -lole32 -luuid -lcomctl32])
+ else if test "${skins2_missing_lib}" = "no" && (test "${SYS}" = "darwin"); then
+ VLC_ADD_PLUGINS([skins2])
+ ALIASES="${ALIASES} svlc"
+ VLC_ADD_CPPFLAGS([skins2],[-Imodules/gui/skins2 -DMACOSX_SKINS])
+ VLC_ADD_CXXFLAGS([skins2],[-O2 -fno-rtti])
+ VLC_ADD_LDFLAGS([skins2],[-framework Carbon])
+
else if test "${skins2_missing_lib}" = "no"; then
VLC_ADD_PLUGINS([skins2])
ALIASES="${ALIASES} svlc"
VLC_ADD_CPPFLAGS([skins2],[-Imodules/gui/skins2 ${X_CFLAGS} -DX11_SKINS])
VLC_ADD_CXXFLAGS([skins2],[-O2 -fno-rtti])
VLC_ADD_LDFLAGS([skins2],[${X_LIBS} ${X_PRE_LIBS} -lXext -lX11])
- fi fi
+ fi fi fi
fi
// TODO
}
-OSTimer *MacOSXFactory::createOSTimer( const Callback &rCallback )
+OSTimer *MacOSXFactory::createOSTimer( CmdGeneric &rCmd )
{
- return new MacOSXTimer( getIntf(), rCallback );
+ return new MacOSXTimer( getIntf(), rCmd );
}
}
-Rect MacOSXFactory::getWorkArea() const
+SkinsRect MacOSXFactory::getWorkArea() const
{
// XXX
- return Rect( 0, 0, getScreenWidth(), getScreenHeight() );
+ return SkinsRect( 0, 0, getScreenWidth(), getScreenHeight() );
}
virtual void destroyOSLoop();
/// Instantiate an OSTimer with the given callback
- virtual OSTimer *createOSTimer( const Callback &rCallback );
+ virtual OSTimer *createOSTimer( CmdGeneric &rCmd );
/// Minimize all the windows
virtual void minimize();
virtual int getScreenHeight() const;
/// Get the work area (screen area without taskbars)
- virtual Rect getWorkArea() const;
+ virtual SkinsRect getWorkArea() const;
/// Get the position of the mouse
virtual void getMousePos( int &rXPos, int &rYPos ) const;
#ifdef MACOSX_SKINS
#include "macosx_graphics.hpp"
+#include "macosx_window.hpp"
MacOSXGraphics::MacOSXGraphics( intf_thread_t *pIntf, int width, int height ):
void MacOSXGraphics::drawBitmap( const GenericBitmap &rBitmap, int xSrc,
int ySrc, int xDest, int yDest, int width,
- int height )
+ int height, bool blend )
{
// TODO
}
void MacOSXGraphics::copyToWindow( OSWindow &rWindow, int xSrc, int ySrc,
int width, int height, int xDest, int yDest )
{
- // TODO
+ // Get the graphics context
+ WindowRef win = ((MacOSXWindow&)rWindow).getWindowRef();
+ SetPortWindowPort( win );
+ GrafPtr port = GetWindowPort( win );
+ CGContextRef gc;
+ QDBeginCGContext( port, &gc );
+
+// CGContextSetRGBFillColor( gc, 1, 0, 0, 1 );
+// CGContextFillRect( gc, CGRectMake( 0, 0, 50, 50 ));
+
+ // Release the graphics context
+ QDEndCGContext( port, &gc );
}
#define MACOSX_GRAPHICS_HPP
#include "../src/os_graphics.hpp"
+#include <Carbon/Carbon.h>
class GenericWindow;
class GenericBitmap;
/// Render a bitmap on this graphics
virtual void drawBitmap( const GenericBitmap &rBitmap, int xSrc = 0,
int ySrc = 0, int xDest = 0, int yDest = 0,
- int width = -1, int height = -1 );
+ int width = -1, int height = -1,
+ bool blend = false );
/// Draw a filled rectangle on the grahics (color is #RRGGBB)
virtual void fillRect( int left, int top, int width, int height,
#ifdef MACOSX_SKINS
-#include <Carbon/Carbon.h>
#include "macosx_loop.hpp"
+#include "macosx_window.hpp"
+#include "../src/generic_window.hpp"
+#include "../events/evt_refresh.hpp"
+
+static pascal OSStatus WinEventHandler( EventHandlerCallRef handler,
+ EventRef event, void *data )
+{
+ GenericWindow *pWin = (GenericWindow*)data;
+ intf_thread_t *pIntf = pWin->getIntf();
+
+ //fprintf(stderr, "event\n" );
+ UInt32 evclass = GetEventClass( event );
+ UInt32 evkind = GetEventKind( event );
+
+ switch( evclass )
+ {
+ case kEventClassWindow:
+ EvtRefresh evt( pIntf, 0, 0, -1, -1);
+ pWin->processEvent( evt );
+ break;
+ }
+}
MacOSXLoop::MacOSXLoop( intf_thread_t *pIntf ):
// Main event loop
while( !m_exit )
{
- EventRef pEvent;
- OSStatus err = ReceiveNextEvent( 0, NULL, kEventDurationForever, true,
- &pEvent );
- if( err != noErr )
- {
- // Get the event type
- UInt32 evClass = GetEventClass( pEvent );
-
- switch( evClass )
- {
- case kEventClassMouse:
- {
- break;
- }
-
- case kEventClassKeyboard:
- {
- break;
- }
-
- case kEventClassWindow:
- {
- handleWindowEvent( pEvent );
- break;
- }
-
- default:
- {
- EventTargetRef pTarget;
- pTarget = GetEventDispatcherTarget();
- SendEventToEventTarget( pEvent, pTarget );
- ReleaseEvent( pEvent );
- }
- }
- }
+ sleep(1);
}
}
}
-void MacOSXLoop::handleWindowEvent( EventRef pEvent )
+void MacOSXLoop::registerWindow( GenericWindow &rGenWin, WindowRef win )
{
- UInt32 evKind = GetEventKind( pEvent );
-
+ // Create the event handler
+ EventTypeSpec evList[] = {
+ { kEventClassWindow, kEventWindowUpdate },
+ { kEventClassMouse, kEventMouseMoved }
+ };
+ EventHandlerUPP handler = NewEventHandlerUPP( WinEventHandler );
+ InstallWindowEventHandler( win, handler, GetEventTypeCount( evList ),
+ evList, &rGenWin, NULL );
}
-
#endif
#define MACOSX_LOOP_HPP
#include "../src/os_loop.hpp"
+#include <Carbon/Carbon.h>
class MacOSXDisplay;
class GenericWindow;
/// Exit the main loop
virtual void exit();
+ // Handle a window event
+ void registerWindow( GenericWindow &rGenWin, WindowRef win );
+
private:
// Private because it's a singleton
MacOSXLoop( intf_thread_t *pIntf );
virtual ~MacOSXLoop();
// Flag set to exit the loop
bool m_exit;
-
- // Handle a window event
- void handleWindowEvent( EventRef pEvent );
};
#endif
#ifdef MACOSX_SKINS
#include "macosx_timer.hpp"
+#include "../commands/cmd_generic.hpp"
-MacOSXTimer::MacOSXTimer( intf_thread_t *pIntf, const Callback &rCallback ):
- OSTimer( pIntf ), m_callback( rCallback )
+MacOSXTimer::MacOSXTimer( intf_thread_t *pIntf, CmdGeneric &rCmd ):
+ OSTimer( pIntf ), m_rCommand( rCmd )
{
// TODO
}
// Forward declaration
class MacOSXTimerLoop;
+class CmdGeneric;
// MacOSX specific timer
class MacOSXTimer: public OSTimer
{
public:
- MacOSXTimer( intf_thread_t *pIntf, const Callback &rCallback );
+ MacOSXTimer( intf_thread_t *pIntf, CmdGeneric &rCmd );
virtual ~MacOSXTimer();
/// (Re)start the timer with the given delay (in ms). If oneShot is
virtual void stop();
private:
- /// Callback to execute
- Callback m_callback;
+ /// Command to execute
+ CmdGeneric &m_rCommand;
};
#ifdef MACOSX_SKINS
#include "macosx_window.hpp"
+#include "macosx_loop.hpp"
+#include "../src/os_factory.hpp"
MacOSXWindow::MacOSXWindow( intf_thread_t *pIntf, GenericWindow &rWindow,
MacOSXWindow *pParentWindow ):
OSWindow( pIntf ), m_pParent( pParentWindow ), m_dragDrop( dragDrop )
{
- // TODO
+ // Create the window
+ Rect rect;
+ SetRect( &rect, 0, 0, 0, 0 );
+ CreateNewWindow( kDocumentWindowClass, kWindowNoShadowAttribute |
+ kWindowNoTitleBarAttribute, &rect, &m_win );
+
+ // Create the event handler for this window
+ OSFactory *pOSFactory = OSFactory::instance( getIntf() );
+ ((MacOSXLoop*)pOSFactory->getOSLoop())->registerWindow( rWindow, m_win );
}
MacOSXWindow::~MacOSXWindow()
{
- // TODO
+ DisposeWindow( m_win );
}
void MacOSXWindow::show( int left, int top ) const
{
- // TODO
+ ShowWindow( m_win );
}
void MacOSXWindow::hide() const
{
- // TODO
+ HideWindow( m_win );
}
void MacOSXWindow::moveResize( int left, int top, int width, int height ) const
{
- // TODO
+ MoveWindow( m_win, left, top, false );
+ SizeWindow( m_win, width, height, true );
}
void MacOSXWindow::raise() const
{
- // TODO
+ SelectWindow( m_win );
}
void MacOSXWindow::setOpacity( uint8_t value ) const
{
- // TODO
+ SetWindowAlpha( m_win, (float)value / 255.0 );
}
#define MACOSX_WINDOW_HPP
#include "../src/os_window.hpp"
+#include <Carbon/Carbon.h>
class MacOSXDisplay;
class MacOSXDragDrop;
/// Toggle the window on top
virtual void toggleOnTop( bool onTop ) const;
+ /// Get the Carbon window handle
+ WindowRef getWindowRef() const { return m_win; };
+
private:
/// Parent window
MacOSXWindow *m_pParent;
/// Indicates whether the window handles drag&drop events
bool m_dragDrop;
+ /// Carbon Window object
+ WindowRef m_win;
};
void GenericLayout::resize( int width, int height )
{
// Update the window size
- m_rect = Rect( 0, 0 , width, height );
+ m_rect = SkinsRect( 0, 0 , width, height );
// Recreate a new image
if( m_pImage )
/// Parent window of the layout
TopWindow *m_pWindow;
/// Layout size
- Rect m_rect;
+ SkinsRect m_rect;
int m_minWidth, m_maxWidth;
int m_minHeight, m_maxHeight;
/// Image of the layout
virtual int getScreenHeight() const = 0;
/// Get the work area (screen area without taskbars)
- virtual Rect getWorkArea() const = 0;
+ virtual SkinsRect getWorkArea() const = 0;
/// Get the position of the mouse
virtual void getMousePos( int &rXPos, int &rYPos ) const = 0;
void WindowManager::maximize( TopWindow &rWindow )
{
// Save the current position/size of the window, to be able to restore it
- m_maximizeRect = Rect( rWindow.getLeft(), rWindow.getTop(),
- rWindow.getLeft() + rWindow.getWidth(),
- rWindow.getTop() + rWindow.getHeight() );
+ m_maximizeRect = SkinsRect( rWindow.getLeft(), rWindow.getTop(),
+ rWindow.getLeft() + rWindow.getWidth(),
+ rWindow.getTop() + rWindow.getHeight() );
- Rect workArea = OSFactory::instance( getIntf() )->getWorkArea();
+ SkinsRect workArea = OSFactory::instance( getIntf() )->getWorkArea();
// Move the window
startMove( rWindow );
move( rWindow, workArea.getLeft(), workArea.getTop() );
AncList_t::const_iterator itAncMov, itAncSta;
// Check magnetism with screen edges first (actually it is the work area)
- Rect workArea = OSFactory::instance( getIntf() )->getWorkArea();
+ SkinsRect workArea = OSFactory::instance( getIntf() )->getWorkArea();
// Iterate through the moving windows
for( itMov = m_movingWindows.begin();
itMov != m_movingWindows.end(); itMov++ )
/// Direction of the current resizing
Direction_t m_direction;
/// Rect of the last maximized window
- Rect m_maximizeRect;
+ SkinsRect m_maximizeRect;
/// Tooltip
Tooltip *m_pTooltip;
/// Active popup, if any
const string VarBox::m_type = "box";
-Rect::Rect( int left, int top, int right, int bottom ):
+SkinsRect::SkinsRect( int left, int top, int right, int bottom ):
m_left( left ), m_top( top ), m_right( right ), m_bottom( bottom )
{
}
/// Characterization of a rectangle
-class Rect: public GenericRect
+class SkinsRect: public GenericRect
{
public:
- Rect( int left, int top, int right, int bottom );
+ SkinsRect( int left, int top, int right, int bottom );
virtual int getLeft() const { return m_left; }
virtual int getTop() const { return m_top; }
}
-Rect Win32Factory::getWorkArea() const
+SkinsRect Win32Factory::getWorkArea() const
{
RECT r;
SystemParametersInfo( SPI_GETWORKAREA, 0, &r, 0 );
// Fill a Rect object
- Rect rect( r.left, r.top, r.right, r.bottom );
+ SkinsRect SkinsRect( r.left, r.top, r.right, r.bottom );
return rect;
}
virtual int getScreenHeight() const;
/// Get the work area (screen area without taskbars)
- virtual Rect getWorkArea() const;
+ virtual SkinsRect getWorkArea() const;
/// Get the position of the mouse
virtual void getMousePos( int &rXPos, int &rYPos ) const;
}
-Rect X11Factory::getWorkArea() const
+SkinsRect X11Factory::getWorkArea() const
{
// XXX
- return Rect( 0, 0, getScreenWidth(), getScreenHeight() );
+ return SkinsRect( 0, 0, getScreenWidth(), getScreenHeight() );
}
virtual int getScreenHeight() const;
/// Get the work area (screen area without taskbars)
- virtual Rect getWorkArea() const;
+ virtual SkinsRect getWorkArea() const;
/// Get the position of the mouse
virtual void getMousePos( int &rXPos, int &rYPos ) const;