mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 08:21:12 +02:00
CComponents: add new header file cc_signals.h with some basic members
This commit is contained in:
89
src/gui/components/cc_signals.h
Normal file
89
src/gui/components/cc_signals.h
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
Based up Neutrino-GUI - Tuxbox-Project
|
||||
Copyright (C) 2001 by Steffen Hehn 'McClean'
|
||||
|
||||
Classes for generic GUI-related components.
|
||||
Copyright (C) 2013, Thilo Graf 'dbt'
|
||||
|
||||
License: GPL
|
||||
|
||||
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 the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program 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
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/// Basic CComponentSignals class header.
|
||||
/*!
|
||||
Basic signal declarations for component sub classes
|
||||
|
||||
This class provides some general declarations of signals based up libsigc++.
|
||||
For more details see: http://libsigc.sourceforge.net/doc.shtml
|
||||
|
||||
If you want to use a signal in a class, some steps are required
|
||||
example:
|
||||
|
||||
#include <sigc++/slot.h>
|
||||
|
||||
class CYourClass : sigc::trackable //<- not forget, requierd by destructor!
|
||||
{
|
||||
public:
|
||||
CYourClass();
|
||||
~CYourClass();
|
||||
|
||||
//...your other stuff
|
||||
|
||||
//here is the member we will connect to a signal, here we have a member with one parameter (void*)
|
||||
void DoThis(void* arg)
|
||||
{
|
||||
//do something here
|
||||
};
|
||||
|
||||
//this is the member we will use to connect with a signal
|
||||
void RunExample()
|
||||
{
|
||||
CReceiverClass receiver;
|
||||
//this object contains the member in which is placed a signal, here: OnBeforePaint
|
||||
//note: OnBeforePaint is already inherited, if you use any CComponent Class. Otherwise, it must be done separatly
|
||||
//eg: class CNotACComponentClass : public CComponentSignals
|
||||
//this also handles the derivation of sigc::trackable
|
||||
|
||||
// here we use a void* parameter, can be filled with any stuff you can cast, you can use also other types
|
||||
void *vptr = yourStuff;
|
||||
|
||||
//now we create a slot...
|
||||
sigc::slot0<void> sl = sigc::bind<0>(sigc::mem_fun1(*this, &CYourClass::DoThis), vptr);
|
||||
|
||||
//...and connect with signal in the receiver object
|
||||
receiver.OnBeforePaint.connect(sl);
|
||||
|
||||
//thats' all. If DoThis(bla) is connected, OnBeforePaint is doing the same like the DoThis(), but in the foreign object
|
||||
};
|
||||
};
|
||||
*/
|
||||
|
||||
#ifndef __CC_SIGNALS_H__
|
||||
#define __CC_SIGNALS_H____
|
||||
|
||||
#include <sigc++/signal.h>
|
||||
|
||||
|
||||
class CComponentsSignals : public sigc::trackable
|
||||
{
|
||||
public:
|
||||
CComponentsSignals(){};
|
||||
|
||||
sigc::signal<void> OnBeforePaint;
|
||||
sigc::signal<void> OnAfterPaint;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user