From eccd9348b6e908a72bc22b985de4cba68ec00ea1 Mon Sep 17 00:00:00 2001 From: Cyril Deguet Date: Sat, 7 Jun 2003 12:19:23 +0000 Subject: [PATCH] * beginning of tooltips (only in the console at the moment ;) --- modules/gui/skins/controls/text.cpp | 5 ++-- modules/gui/skins/x11/x11_run.cpp | 5 ++-- modules/gui/skins/x11/x11_timer.cpp | 14 ++++++---- modules/gui/skins/x11/x11_timer.h | 7 +++-- modules/gui/skins/x11/x11_window.cpp | 42 +++++++++++++--------------- modules/gui/skins/x11/x11_window.h | 15 ++++++++-- 6 files changed, 52 insertions(+), 36 deletions(-) diff --git a/modules/gui/skins/controls/text.cpp b/modules/gui/skins/controls/text.cpp index 676975e72c..763f11c969 100644 --- a/modules/gui/skins/controls/text.cpp +++ b/modules/gui/skins/controls/text.cpp @@ -2,7 +2,7 @@ * text.cpp: Text control ***************************************************************************** * Copyright (C) 2003 VideoLAN - * $Id: text.cpp,v 1.10 2003/06/05 22:16:15 asmax Exp $ + * $Id: text.cpp,v 1.11 2003/06/07 12:19:23 asmax Exp $ * * Authors: Olivier Teulière * Emmanuel Puig @@ -121,13 +121,14 @@ extern intf_thread_t *g_pIntf; //----------------------------------------------------------------------- // X11 methods //----------------------------------------------------------------------- - void ScrollingTextTimer( void *data ) + bool ScrollingTextTimer( void *data ) { if( (ControlText *)data != NULL && !( (ControlText *)data )->GetSelected() ) { ( (ControlText *)data )->DoScroll(); } + return True; } //----------------------------------------------------------------------- diff --git a/modules/gui/skins/x11/x11_run.cpp b/modules/gui/skins/x11/x11_run.cpp index 3ddacfc696..22095dd9ff 100644 --- a/modules/gui/skins/x11/x11_run.cpp +++ b/modules/gui/skins/x11/x11_run.cpp @@ -2,7 +2,7 @@ * x11_run.cpp: ***************************************************************************** * Copyright (C) 2003 VideoLAN - * $Id: x11_run.cpp,v 1.16 2003/06/06 19:40:37 asmax Exp $ + * $Id: x11_run.cpp,v 1.17 2003/06/07 12:19:23 asmax Exp $ * * Authors: Cyril Deguet * @@ -150,9 +150,10 @@ int ProcessEvent( intf_thread_t *p_intf, VlcProc *proc, XEvent *event ) } -void RefreshCallback( void *data ) +bool RefreshCallback( void *data ) { SkinManage( (intf_thread_t*)data ); + return True; } diff --git a/modules/gui/skins/x11/x11_timer.cpp b/modules/gui/skins/x11/x11_timer.cpp index 71e7461c16..06b0c5892a 100644 --- a/modules/gui/skins/x11/x11_timer.cpp +++ b/modules/gui/skins/x11/x11_timer.cpp @@ -2,7 +2,7 @@ * x11_timer.cpp: helper class to implement timers ***************************************************************************** * Copyright (C) 2003 VideoLAN - * $Id: x11_timer.cpp,v 1.1 2003/06/05 22:16:15 asmax Exp $ + * $Id: x11_timer.cpp,v 1.2 2003/06/07 12:19:23 asmax Exp $ * * Authors: Cyril Deguet * @@ -55,9 +55,9 @@ mtime_t X11Timer::getNextDate( mtime_t current ) } -void X11Timer::Execute() +bool X11Timer::Execute() { - (*_callback)( _data ); + return (*_callback)( _data ); } //--------------------------------------------------------------------------- @@ -112,6 +112,7 @@ void X11TimerManager::Destroy() void *X11TimerManager::Thread( void *p_timer ) { vlc_thread_ready( (vlc_object_t*) p_timer ); + while( !((timer_thread_t*)p_timer)->die ) { list::iterator timer; @@ -119,11 +120,14 @@ void *X11TimerManager::Thread( void *p_timer ) for( timer = _instance->_timers.begin(); timer != _instance->_timers.end(); timer++ ) { - (*timer)->Execute(); + bool ret = (*timer)->Execute(); + if( !ret ) + { _instance->_timers.remove( *timer ); + break; + } } msleep( 100000 ); } - } #endif diff --git a/modules/gui/skins/x11/x11_timer.h b/modules/gui/skins/x11/x11_timer.h index 788a905783..ea181c9942 100644 --- a/modules/gui/skins/x11/x11_timer.h +++ b/modules/gui/skins/x11/x11_timer.h @@ -2,7 +2,7 @@ * x11_timer.h: helper class to implement timers ***************************************************************************** * Copyright (C) 2003 VideoLAN - * $Id: x11_timer.h,v 1.1 2003/06/05 22:16:15 asmax Exp $ + * $Id: x11_timer.h,v 1.2 2003/06/07 12:19:23 asmax Exp $ * * Authors: Cyril Deguet * @@ -36,7 +36,7 @@ typedef struct class X11Timer; // forward declaration -typedef void(*callback_t)( void* ); +typedef bool(*callback_t)( void* ); //--------------------------------------------------------------------------- class X11Timer @@ -53,7 +53,7 @@ class X11Timer ~X11Timer(); mtime_t getNextDate( mtime_t current ); - void Execute(); + bool Execute(); }; //--------------------------------------------------------------------------- class X11TimerManager @@ -74,6 +74,7 @@ class X11TimerManager void Destroy(); void addTimer( X11Timer *timer ) { _timers.push_back( timer ); } + void removeTimer( X11Timer *timer ) { _timers.remove( timer ); } }; //--------------------------------------------------------------------------- diff --git a/modules/gui/skins/x11/x11_window.cpp b/modules/gui/skins/x11/x11_window.cpp index ed3153faa8..97daaf907c 100644 --- a/modules/gui/skins/x11/x11_window.cpp +++ b/modules/gui/skins/x11/x11_window.cpp @@ -2,7 +2,7 @@ * x11_window.cpp: X11 implementation of the Window class ***************************************************************************** * Copyright (C) 2003 VideoLAN - * $Id: x11_window.cpp,v 1.11 2003/06/07 00:36:28 asmax Exp $ + * $Id: x11_window.cpp,v 1.12 2003/06/07 12:19:23 asmax Exp $ * * Authors: Cyril Deguet * @@ -47,6 +47,10 @@ #include "../src/skin_common.h" #include "../src/theme.h" #include "../os_theme.h" +#include "x11_timer.h" + + +bool ToolTipCallback( void *data ); //--------------------------------------------------------------------------- @@ -78,24 +82,6 @@ X11Window::X11Window( intf_thread_t *p_intf, Window wnd, int x, int y, CursorPos = new POINT; WindowPos = new POINT; - // Create Tool Tip Window - ToolTipWindow = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, - WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, - CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - hWnd, 0, GetModuleHandle( NULL ), 0); - - // Create Tool Tip infos - ToolTipInfo.cbSize = sizeof(TOOLINFO); - ToolTipInfo.uFlags = TTF_SUBCLASS|TTF_IDISHWND; - ToolTipInfo.hwnd = hWnd; - ToolTipInfo.hinst = GetModuleHandle( NULL ); - ToolTipInfo.uId = (unsigned int)hWnd; - ToolTipInfo.lpszText = NULL; - ToolTipInfo.rect.left = ToolTipInfo.rect.top = 0; - ToolTipInfo.rect.right = ToolTipInfo.rect.bottom = 0; - - SendMessage( ToolTipWindow, TTM_ADDTOOL, 0, - (LPARAM)(LPTOOLINFO) &ToolTipInfo ); */ if( DragDrop ) @@ -107,6 +93,9 @@ X11Window::X11Window( intf_thread_t *p_intf, Window wnd, int x, int y, // Create Tool Tip window ToolTipWindow = XCreateSimpleWindow( display, wnd, 0, 0, 1, 1, 0, 0, 0 ); + X11Timer *timer = new X11Timer( p_intf, 100, ToolTipCallback, &ToolTipInfo ); + ToolTipInfo.p_intf = p_intf; + ToolTipInfo.timer = timer; // Double-click handling ClickedX = 0; @@ -369,6 +358,15 @@ void X11Window::Size( int width, int height ) XResizeWindow( display, Wnd, width, height ); } //--------------------------------------------------------------------------- + + +bool ToolTipCallback( void *data ) +{ + fprintf(stderr," TOOLTIP: %s\n", ((tooltip_t*)data)->text.c_str()); + return False; +} + + void X11Window::ChangeToolTipText( string text ) { if( text == "none" ) @@ -385,10 +383,10 @@ void X11Window::ChangeToolTipText( string text ) if( text != ToolTipText ) { ToolTipText = text; + ToolTipInfo.text = text; + X11TimerManager *timerManager = X11TimerManager::Instance( p_intf ); + timerManager->addTimer( ToolTipInfo.timer ); // ToolTipInfo.lpszText = (char *)ToolTipText.c_str(); - /* SendMessage( ToolTipWindow, TTM_ACTIVATE, 1 , 0 ); - SendMessage( ToolTipWindow, TTM_UPDATETIPTEXT, 0, - (LPARAM)(LPTOOLINFO)&ToolTipInfo );*/ } } } diff --git a/modules/gui/skins/x11/x11_window.h b/modules/gui/skins/x11/x11_window.h index 9af118a0d6..a43072b07b 100644 --- a/modules/gui/skins/x11/x11_window.h +++ b/modules/gui/skins/x11/x11_window.h @@ -2,7 +2,7 @@ * x11_window.h: X11 implementation of the Window class ***************************************************************************** * Copyright (C) 2003 VideoLAN - * $Id: x11_window.h,v 1.3 2003/06/07 00:36:28 asmax Exp $ + * $Id: x11_window.h,v 1.4 2003/06/07 12:19:23 asmax Exp $ * * Authors: Cyril Deguet * @@ -29,10 +29,21 @@ //--- X11 ------------------------------------------------------------------- #include +#include "x11_timer.h" + //--------------------------------------------------------------------------- class Graphics; class Event; + +typedef struct +{ + intf_thread_t *p_intf; + X11Timer *timer; + string text; +} tooltip_t; + + //--------------------------------------------------------------------------- class X11Window : public SkinWindow { @@ -52,7 +63,7 @@ class X11Window : public SkinWindow // Tooltip texts Window ToolTipWindow; -// TOOLINFO ToolTipInfo; + tooltip_t ToolTipInfo; // Double-click handling int ClickedX; -- 2.39.2