* window.cpp: Window class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: window.cpp,v 1.22 2003/04/30 21:16:24 asmax Exp $
+ * $Id: window.cpp,v 1.31 2003/06/22 00:00:28 asmax Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
+ * Cyril Deguet <asmax@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "banks.h"
#include "theme.h"
#include "skin_common.h"
+#include "dialogs.h"
#include <stdio.h>
//---------------------------------------------------------------------------
SkinWindow::~SkinWindow()
{
+ if( Image )
+ {
+ delete Image;
+ }
// Destroy the controls
for( unsigned int i = 0; i < ControlList.size(); i++ )
delete ControlList[i];
unsigned int i;
// Create Bitmap Buffer
-// Graphics *Buffer = (Graphics *)new OSGraphics( p_intf, w, h, this );
- Graphics *Buffer = (Graphics *)new OSGraphics( w, h, this );
+ Graphics *Buffer = (Graphics *)new OSGraphics( p_intf, w, h, this );
+// Graphics *Buffer = (Graphics *)new OSGraphics( w, h, this );
// Draw every control
- for( i = 0; i < ControlList.size(); i++ )
- ControlList[i]->Draw( x, y, w, h, Buffer );
+ for( i = 0; i < ControlList.size(); i++ )
+ ControlList[i]->Draw( x, y, w, h, Buffer );
// Copy buffer in Image
Image->CopyFrom( x, y, w, h, Buffer, 0, 0, SRC_COPY );
// And copy buffer to window
RefreshFromImage( x, y, w, h );
-
}
//---------------------------------------------------------------------------
void SkinWindow::RefreshAll()
void SkinWindow::MouseDown( int x, int y, int button )
{
// Checking event in controls
- for( int i = ControlList.size() - 1; i >= 0 ; i-- )
+ for( int i = ControlList.size() - 1; i >= 0; i-- )
{
- if( ControlList[i]->MouseDown( x, y, button ) )
+ if( ControlList[i]->IsVisible() &&
+ ControlList[i]->MouseDown( x, y, button ) )
{
- return;
+ msg_Dbg( p_intf, "Mouse down (ID=%s)",
+ ControlList[i]->GetId().c_str() );
+ break;
}
}
-
}
//---------------------------------------------------------------------------
void SkinWindow::MouseMove( int x, int y, int button )
}
// Checking event in controls
- for( i = ControlList.size() - 1; i >= 0 ; i-- )
+ for( i = ControlList.size() - 1; i >= 0; i-- )
{
- ControlList[i]->MouseMove( x, y, button );
+ if( ControlList[i]->IsVisible() &&
+ ControlList[i]->MouseMove( x, y, button ) )
+ {
+ break;
+ }
}
// Checking help text
- for( i = ControlList.size() - 1; i >= 0 ; i-- )
+ for( i = ControlList.size() - 1; i >= 0; i-- )
{
- if( ControlList[i]->MouseOver( x, y ) )
+ if( ControlList[i]->IsVisible() && ControlList[i]->MouseOver( x, y ) )
{
- if( ControlList[i]->SendNewHelpText() )
- {
- break;
- }
+ ControlList[i]->SendNewHelpText();
+ break;
}
}
}
// Checking for change in Tool Tip
- for( i = ControlList.size() - 1; i >= 0 ; i-- )
+ for( i = ControlList.size() - 1; i >= 0; i-- )
{
- if( ControlList[i]->ToolTipTest( x, y ) )
+ if( ControlList[i]->IsVisible() &&
+ ControlList[i]->ToolTipTest( x, y ) )
+ {
break;
+ }
}
// If no change, delete tooltip text
}
// Checking event in controls
- for( i = ControlList.size() - 1; i >= 0 ; i-- )
+ for( i = ControlList.size() - 1; i >= 0; i-- )
{
- if( ControlList[i]->MouseUp( x, y, button ) )
+ if( ControlList[i]->IsVisible() &&
+ ControlList[i]->MouseUp( x, y, button ) )
{
- return;
+ msg_Dbg( p_intf, "Mouse up (ID=%s)",
+ ControlList[i]->GetId().c_str() );
+ break;
}
}
+
+ if( i < 0 && button == MOUSE_RIGHT )
+ {
+ p_intf->p_sys->p_dialogs->ShowPopup();
+ }
}
//---------------------------------------------------------------------------
void SkinWindow::MouseDblClick( int x, int y, int button )
int i;
// Checking event in controls
- for( i = ControlList.size() - 1; i >= 0 ; i-- )
+ for( i = ControlList.size() - 1; i >= 0; i-- )
{
- if( ControlList[i]->MouseDblClick( x, y, button ) )
- return;
+ if( ControlList[i]->IsVisible() &&
+ ControlList[i]->MouseDblClick( x, y, button ) )
+ {
+ msg_Dbg( p_intf, "Double click (ID=%s)",
+ ControlList[i]->GetId().c_str() );
+ }
}
}
//---------------------------------------------------------------------------
void SkinWindow::MouseScroll( int x, int y, int direction )
{
// Checking event in controls
- for( int i = ControlList.size() - 1; i >= 0 ; i-- )
+ for( int i = ControlList.size() - 1; i >= 0; i-- )
+ {
+ if( ControlList[i]->IsVisible() &&
+ ControlList[i]->MouseScroll( x, y, direction ) )
+ {
+ break;
+ }
+ }
+
+ // Checking for change in Tool Tip
+ for( int i = ControlList.size() - 1; i >= 0; i-- )
{
- if( ControlList[i]->MouseScroll( x, y, direction ) )
+ if( ControlList[i]->IsVisible() &&
+ ControlList[i]->ToolTipTest( x, y ) )
{
- return;
+ break;
}
}
+
}
//---------------------------------------------------------------------------
void SkinWindow::Init()
{
#define min(a,b) ((a)<(b))?(a):(b)
#define max(a,b) ((a)>(b))?(a):(b)
- w = max( w, ControlList[i]->Left + ControlList[i]->Width );
- h = max( h, ControlList[i]->Top + ControlList[i]->Height );
- MinX = min( MinX, ControlList[i]->Left );
- MinY = min( MinY, ControlList[i]->Top );
+ w = max( w, ControlList[i]->GetLeft() + ControlList[i]->GetWidth() );
+ h = max( h, ControlList[i]->GetTop() + ControlList[i]->GetHeight() );
+ MinX = min( MinX, ControlList[i]->GetLeft() );
+ MinY = min( MinY, ControlList[i]->GetTop() );
#undef max
#undef min
}
// Change image buffer
if( Image != NULL )
delete (OSGraphics *)Image;
-// Image = (Graphics *)new OSGraphics( p_intf, w, h, this );
- Image = (Graphics *)new OSGraphics( w, h, this );
+ Image = (Graphics *)new OSGraphics( p_intf, w, h, this );
Size( w, h );
}
x = Left;
y = Top;
}
-//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
+// List of all the Skin Windows (singleton)
+//---------------------------------------------------------------------------
+SkinWindowList *SkinWindowList::_instance = NULL;
+//---------------------------------------------------------------------------
+SkinWindowList::SkinWindowList()
+{
+}
+//---------------------------------------------------------------------------
+SkinWindowList *SkinWindowList::Instance()
+{
+ if( _instance == NULL )
+ {
+ _instance = new SkinWindowList;
+ }
+ return _instance;
+}
+//---------------------------------------------------------------------------
+void SkinWindowList::Add( SkinWindow *win )
+{
+ _list.push_back( win );
+}
+//---------------------------------------------------------------------------
+SkinWindow *SkinWindowList::Back()
+{
+ return _list.back();
+}
+//---------------------------------------------------------------------------
+list<SkinWindow*>::const_iterator SkinWindowList::Begin()
+{
+ return _list.begin();
+}
+//---------------------------------------------------------------------------
+list<SkinWindow*>::const_iterator SkinWindowList::End()
+{
+ return _list.end();
+}
+//---------------------------------------------------------------------------