[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[paragui-dev] fixes and new widget
From: |
Martin Bickel |
Subject: |
[paragui-dev] fixes and new widget |
Date: |
Sun, 17 Jul 2005 12:27:04 +0200 |
Hi,
here is yet another update for the Paragui 1.2 development branch.
The patch fixes the following issues:
* Gradients on 32 Bit surfaces with Alpha channel now set the alpha
channel to fully opaque. This only has an effect if the surface has the
SDL_SRCALPHA flag set. The old behaviour caused the gradient to be
completely invisible if the flag was set.
* A small glitch of the PopupMenu is fixed that caused the second entry
to be selected when it was opened.
* A lot of C-style casts are replaced with C++ const_casts. This
shouldn't change anything. I replaced the casts when I was trying to
figure out why Paragui didn't work correctly with GCC 4.0.0 . I then
found out that the cause of the problems was a bug in GCC and the
original Paragui code was correct.
But since these casts const_casts are more elgant anyway and don't
trigger the GCC bug, I'm submitting them here ...
* There was yet another situation in which the ScrollWidget didn't work
correctly and didn't show scrollbars although it should, which I've
fixed.
And last but not least, here comes a new widget: PG_ToolTipHelp
It shows those nice little help messages when the mouse hovers over a
widget. I've updated the Makefiles, the default theme and the paratest
program. They can now be admired in Paratest on the buttons "Quit" and
"List" :-)
Martin
patch
Description: Binary data
/*
ParaGUI - crossplatform widgetset
Copyright (C) 2000,2001,2002 Alexander Pipelka
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Alexander Pipelka
address@hidden
Last Update: $Author: braindead $
Update Date: $Date: 2005/07/01 10:31:13 $
Source File: $Source: /cvsroot/paragui/paragui/include/pgwidget.h,v $
CVS/RCS Revision: $Revision: 1.3.6.3.2.30 $
Status: $State: Exp $
*/
/** \file pgwidget.h
Header file for the PG_Widget class.
*/
#ifndef PG_TOOLTIPHELP_H
#define PG_TOOLTIPHELP_H
#include "pgtimerobject.h"
class PG_Widget;
class PG_LineEdit;
/**
@author Martin Bickel
@short ToolTip Help for widgets
Displays ToolTip help that opens when a mouse cursor hovers over a widget.
It behaves similar to a PG_Widget, but it is not derived from it
The ToolTipHelp will delete itself when the parent widget is deleted.
It is also safe to delete the ToolTipHelp object manually prior to deleting
the widget.
@ToDo Query the cursor size and position the help so it doesn't overlap with
large cursors
*/
class DECLSPEC PG_ToolTipHelp: public SigC::Object {
private:
class Ticker: public PG_TimerObject {
volatile Uint32 ticker;
Uint32 eventTimer(Uint32 interval) {
++ticker;
return interval;
};
public:
Ticker( int interval ) {
SetTimer( interval );
};
Uint32 getTicker() {
return ticker;
};
};
static Ticker* ticker;
void startTimer();
protected:
PG_Widget* parentWidget;
PG_TimerObject::ID id;
Uint32 lastTick;
enum { off, counting, shown } status;
std::string my_text;
std::string labelStyle;
int my_delay;
static PG_LineEdit* toolTipLabel;
bool onParentEnter( PG_Pointer dummy );
bool onParentLeave( PG_Pointer dummy );
bool onParentDelete( const PG_MessageObject* object );
bool onMouseMotion( const SDL_MouseMotionEvent *motion );
bool onIdle();
public:
/**
Create a ToolTipHelp for the given widget
It automatically enables SigIdle calls for PG_Application
@param parent The widget for which the ToolTip Help shall be
shown
@param text The help text
@param delay The delay in 1/10 s after which the help appears
when the mouse has stopped moving
@param style The theme style for the Help. Default: Widget Type =
ToolTipHelp . Object Name = LineEdit
*/
PG_ToolTipHelp( PG_Widget* parent, const std::string& text, int delay =
10, const std::string &style="ToolTipHelp" );
/**
Changes the help text
*/
void SetText( const std::string& text );
/**
Show the help to be shown
@param pos The screen coordinates of the upper left corner
*/
void ShowHelp( const PG_Point& pos );
/**
Hides the ToolTip Help
*/
void HideHelp( );
};
#endif
/*
ParaGUI - crossplatform widgetset
Copyright (C) 2000,2001,2002 Alexander Pipelka
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Alexander Pipelka
address@hidden
Last Update: $Author: braindead $
Update Date: $Date: 2005/07/01 11:25:15 $
Source File: $Source:
/cvsroot/paragui/paragui/src/widgets/pgwidget.cpp,v $
CVS/RCS Revision: $Revision: 1.4.4.22.2.34 $
Status: $State: Exp $
*/
#include <cstring>
#include "pgapplication.h"
#include "pgeventsupplier.h"
#include "pgwidget.h"
#include "pglineedit.h"
#include "pgtooltiphelp.h"
PG_LineEdit* PG_ToolTipHelp::toolTipLabel = NULL;
PG_ToolTipHelp::Ticker* PG_ToolTipHelp::ticker = NULL;
PG_ToolTipHelp :: PG_ToolTipHelp( PG_Widget* parent, const std::string& text,
int delay, const std::string &style )
: parentWidget(parent), lastTick(0), status(off),
labelStyle(style), my_delay(delay) {
if ( !parent )
return;
parent->sigMouseEnter.connect( SigC::slot( *this,
&PG_ToolTipHelp::onParentEnter ), parent );
parent->sigMouseLeave.connect( SigC::slot( *this,
&PG_ToolTipHelp::onParentLeave ), parent );
parent->sigMouseMotion.connect( SigC::slot( *this,
&PG_ToolTipHelp::onMouseMotion ));
PG_Application::GetApp()->sigAppIdle.connect( SigC::slot( *this,
&PG_ToolTipHelp::onIdle ));
PG_Application::GetApp()->EnableAppIdleCalls();
parent->sigDelete.connect( SigC::slot( *this,
&PG_ToolTipHelp::onParentDelete ));
SetText( text );
}
void PG_ToolTipHelp :: SetText( const std::string& text ) {
my_text = text;
}
bool PG_ToolTipHelp :: onIdle( ) {
if ( !ticker )
return false;
if ( status != counting )
return false;
if ( ticker->getTicker() > lastTick + 10 ) {
if ( status < shown ) {
int x, y;
PG_Application::GetEventSupplier()->GetMouseState( x,y
);
ShowHelp( PG_Point(x+5,y+10) );
status = shown;
}
return true;
}
return false;
}
bool PG_ToolTipHelp :: onParentEnter( void* dummy ) {
if ( !ticker )
ticker = new Ticker(100);
status = counting;
lastTick = ticker->getTicker();
return true;
}
bool PG_ToolTipHelp :: onParentLeave( void* dummy ) {
// if the ToolTipLabel is beneath the mouse cursor, we'll receive a
onParentLeave notification that we'll ignore
if ( toolTipLabel && toolTipLabel->IsMouseInside() )
return false;
HideHelp();
status = off;
return false;
}
bool PG_ToolTipHelp :: onParentDelete( const PG_MessageObject* object ) {
if ( status != off)
HideHelp();
delete this;
return true;
}
bool PG_ToolTipHelp :: onMouseMotion( const SDL_MouseMotionEvent *motion ) {
if ( ticker )
lastTick = ticker->getTicker();
status = counting;
HideHelp();
return true;
}
void PG_ToolTipHelp :: ShowHelp( const PG_Point& pos ) {
PG_Point mousePos = pos;
/*
if ( ! parentWidget->IsInside( mousePos ) )
mousePos = PG_Point( parentWidget->x + parentWidget->Width() / 2,
parentWidget->y + parentWidget->Height() / 2 );
*/
if ( toolTipLabel )
delete toolTipLabel;
toolTipLabel = new PG_LineEdit( NULL, PG_Rect( mousePos.x, mousePos.y,
0, 0 ), labelStyle );
toolTipLabel->SetText( my_text );
toolTipLabel->SetEditable( false );
Uint16 w;
Uint16 h;
toolTipLabel->GetTextSize( w, h );
PG_Rect r = *toolTipLabel;
r.w = w + 6;
r.h = h + 4;
if ( r.x + r.w > PG_Application::GetScreen()->w )
r.x = PG_Application::GetScreen()->w - r.w;
if ( r.y + r.h > PG_Application::GetScreen()->h )
r.y = PG_Application::GetScreen()->h - r.h;
toolTipLabel->MoveWidget( r, false );
toolTipLabel->Show();
toolTipLabel->sigMouseMotion.connect( SigC::slot( *this,
&PG_ToolTipHelp::onMouseMotion ));
}
void PG_ToolTipHelp :: HideHelp( ) {
if ( toolTipLabel ) {
delete toolTipLabel;
toolTipLabel = NULL;
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [paragui-dev] fixes and new widget,
Martin Bickel <=