annotate uifunctor.h @ 15:d5758530a039 tip

oF0.84 Retina, and iPhone support
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Tue, 12 May 2015 15:48:52 +0100
parents c667dfe12d47
children
rev   line source
rt300@0 1 //
rt300@0 2 // uifunctor.h
rt300@0 3 // Wablet
rt300@0 4 //
rt300@0 5 // Created by Robert Tubb on 22/03/2012.
rt300@0 6 // Copyright (c) 2012 __MyCompanyName__. All rights reserved.
rt300@0 7 //
rt300@0 8
rt300@0 9 #ifndef Wablet_uifunctor_h
rt300@0 10 #define Wablet_uifunctor_h
rt300@0 11
rt300@0 12 //------------------- callback functor
rt300@0 13
rt300@0 14 // abstract base class
rt300@0 15 class UIFunctor
rt300@0 16 {
rt300@0 17 public:
rt300@0 18
rt300@0 19 // two possible functions to call member function. virtual cause derived
rt300@0 20 // classes will use a pointer to an object and a pointer to a member function
rt300@0 21 // to make the function call
rt300@0 22 virtual void operator()(int buttID)=0; // call using operator
rt300@0 23 virtual void Call(int buttID)=0; // call using function
rt300@0 24 };
rt300@0 25
rt300@0 26
rt300@0 27 // derived template class - this one is for memeber of testApp class
rt300@0 28 template <class testApp> class UISpecificFunctor : public UIFunctor
rt300@0 29 {
rt300@0 30 private:
rt300@0 31 void (testApp::*fpt)(int); // pointer to member function
rt300@0 32 testApp* pt2Object; // pointer to object
rt300@0 33
rt300@0 34 public:
rt300@0 35
rt300@0 36 // constructor - takes pointer to an object and pointer to a member and stores
rt300@0 37 // them in two private variables
rt300@0 38
rt300@0 39 UISpecificFunctor( testApp* _pt2Object, void(testApp::*_fpt)(int))
rt300@0 40 {
rt300@0 41 pt2Object = _pt2Object;
rt300@0 42 fpt=_fpt;
rt300@0 43 };
rt300@0 44
rt300@0 45 // override operator "()"
rt300@0 46
rt300@0 47 virtual void operator()(int buttID)
rt300@0 48 { (*pt2Object.*fpt)(buttID);}; // execute member function
rt300@0 49
rt300@0 50 // override function "Call"
rt300@0 51 virtual void Call(int buttID)
rt300@0 52 { (*pt2Object.*fpt)(buttID);}; // execute member function
rt300@0 53 };
rt300@0 54
rt300@0 55
rt300@0 56 #endif