📄 model.h
字号:
#ifndef _VCF_MODEL_H__#define _VCF_MODEL_H__//Model.h/*Copyright 2000-2004 The VCF Project.Please see License.txt in the top level directorywhere you installed the VCF.*/#if _MSC_VER > 1000# pragma once#endifnamespace VCF{class View;#define MODEL_CLASSID "ED88C0AD-26AB-11d4-B539-00C04F0196DA"/**\class Model Model.h "vcf/ApplicationKit/Model.h"A Model is the base class for storing data for a control or other visual elements.*/class APPLICATIONKIT_API Model : public Component {public: Model(); virtual ~Model(); enum ModelEvents{ MODEL_CHANGED = 2000, MODEL_VALIDATED, MODEL_EMPTIED, MODEL_LAST_EVENT }; /** @delegate ModelChanged fired when the model's empty() method is called. Should be fired for any change to the model's content. @event ModelEvent @eventtype Model::MODEL_EMPTIED @see empty() */ DELEGATE(ModelChanged) /** @delegate ModelValidate fired when the model's validate() method is called @event ValidationEvent @see validate() */ DELEGATE(ModelValidate) /** * Adds a validation listener to the model */ virtual void addModelValidationHandler( EventHandler* handler ) = 0; /** * removes a validation listener from the model */ virtual void removeModelValidationHandler( EventHandler* handler ) = 0; /** * validate the model. * The implementation for this can vary widely, or even be nonexistant for model's that do not require validation. * The basic idea is to call all the listeners in the list , passing in a local variable to the * onModelValidate() methods of the listener's. The variable is initialized to true, and if it is * still true at the end of the listener iterations, then it is safe to apply the changes to the * model, other wise the changes are removed. */ virtual void validate() = 0; /** * Adds a model listener to the model */ virtual void addModelHandler( EventHandler* handler ) = 0; /** * removes a model listener from the model */ virtual void removeModelHandler( EventHandler* handler ) = 0; /** * clears out the model's data */ virtual void empty() = 0; /** *adds a new view to the model */ virtual void addView( View* view ); /** *removes a view from the model */ virtual void removeView( View* view ); /** *notifies all the views the model has changed *calls View::updateView( ), passing itself *in as the updated Model */ virtual void updateAllViews(); Enumerator<View*>* getViews() { return viewContainer_.getEnumerator(); } void changed( ModelEvent* event ) { ModelChanged.fireEvent( event ); updateAllViews(); }protected: std::vector<View*> views_; EnumeratorContainer<std::vector<View*>,View*> viewContainer_;};};/***CVS Log info*$Log$*Revision 1.4 2006/04/07 02:35:24 ddiego*initial checkin of merge from 0.6.9 dev branch.**Revision 1.3.4.1 2006/03/14 02:25:47 ddiego*large amounts of source docs updated.**Revision 1.3 2004/12/01 04:31:21 ddiego*merged over devmain-0-6-6 code. Marcello did a kick ass job*of fixing a nasty bug (1074768VCF application slows down modal dialogs.)*that he found. Many, many thanks for this Marcello.**Revision 1.2.2.1 2004/09/21 23:41:23 ddiego*made some big changes to how the base list, tree, text, table, and tab models are laid out. They are not just plain interfaces. The actual*concrete implementations of them now derive from BOTH Model and the specific*tree, table, etc model interface.*Also made some fixes to the way the text input is handled for a text control.*We now process on a character by character basis and modify the model one*character at a time. Previously we were just using brute force and setting*the whole models text. This is more efficent, though its also more complex.**Revision 1.2 2004/08/07 02:49:08 ddiego*merged in the devmain-0-6-5 branch to stable**Revision 1.1.2.4 2004/06/06 07:05:30 marcelloptr*changed macros, text reformatting, copyright sections**Revision 1.1.2.3 2004/04/29 19:05:50 ddiego*added MVC example, plus the Model::changed() method. Also*added more documentation.**Revision 1.1.2.2 2004/04/29 03:43:14 marcelloptr*reformatting of source files: macros and csvlog and copyright sections**Revision 1.1.2.1 2004/04/28 00:28:18 ddiego*migration towards new directory structure**Revision 1.14.4.1 2004/04/26 21:58:20 marcelloptr*changes for dir reorganization: _VCF_MACRO_H__**Revision 1.14 2003/12/18 05:15:57 ddiego*merge from devmain-0-6-2 branch into the stable branch**Revision 1.13.2.4 2003/12/08 05:05:28 ddiego*added a bunch more documentation to classes, and added support for new doc*keywords (@delegates, @del, @delegate, @event, and @eventtype). This*makes it easier to see at a glance what events a class fires off.*Added finishing touches for the Action implementation and have a partially*complete example for this checked in.**Revision 1.13.2.3 2003/12/02 05:50:05 ddiego*added preliminary support for teh Action class. This will make it easier*to hook up complimentary UI elements (such as a "copy" menu item, and a*"copy" toolbar item) and have tehm respond to update and actions via a*single source.*Got rid of the old toolbar button and separator class. Merged in Marcellos*new fixes for the Container and Splitter classes.*Some misc fixes to the Toolbar, groups and checks now work correctly.**Revision 1.13.2.2 2003/09/12 16:46:33 ddiego*finished adding header changes to improve compile speed (at least*with MS VC++) and to get rid of some of the clutter that the RTTI macros*add.*But Where'd the RTTI info go!?!?*Have no fear it's still there! It is now located in three .inl files, one*for each kit. Each kit will consolidate it's RTTI decls in the following*files:*FoundationKit:* vcf/include/FoundationKitRTTI.inl*GraphicsKit:* vcf/include/GraphicsKitRTTI.inl*ApplicationKit:* vcf/include/ApplicationKitRTTI.inl**Please alter these files as neeccessary to add/subtract/alter the various*RTTI info. Each kit is also responsible for registering any of the class*in the ClassRegistry.*A side effect of this is that I had to alter the memory allocation for the*VC6 build for the Application it went from /Zm120 to /Zm150. I find this*pretty lame but I don't know what else to do. Hopefully this will improve*compile times when using the Appkit in other programs.**Revision 1.13.2.1 2003/09/12 00:09:32 ddiego*added better tabbing behaviour - fixed an earlier bug.*Code is easier to understand and it simplified the implementation*a bit as well*Moved around the RTTI definitions for various Appkit classes to a*single inline and stripped them from the various class headers**Revision 1.13 2003/08/09 02:56:42 ddiego*merge over from the devmain-0-6-1 branch*Changes*Features:*-Added additional implementation to better support the MVC architecture in*the VCF**-Added a Document/View architecure that is similar to MFC's or NextSteps's*Doc/View architectures**-Integrated the Anti Grain Graphics library into the GraphicsKit. There is*now basic support for it in terms of drawing vector shapes*(fills and strokes). Image support will come in the next release**-Added several documented graphics tutorials**Bugfixes:**[ 775744 ] wrong buttons on a dialog*[ 585239 ] Painting weirdness in a modal dialog ?*[ 585238 ] Modal dialog which makes a modal Dialog*[ 509004 ] Opening a modal Dialog causes flicker*[ 524878 ] onDropped not called for MLTcontrol**Plus an issue with some focus and getting the right popup window to activate*has also been fixed**Revision 1.12.2.2 2003/08/08 21:40:11 ddiego*little fix in constructor (it was missing! DOH!)**Revision 1.12.2.1 2003/08/07 21:43:35 ddiego*minor change to the Win32 reg peer (allows "/" instead of "\")*added a getViews() method to Model class**Revision 1.12 2003/05/17 20:37:03 ddiego*this is the checkin for the 0.6.1 release - represents the merge over from*the devmain-0-6-0 branch plus a few minor bug fixes**Revision 1.11.2.1 2003/03/12 03:09:39 ddiego*switched all member variable that used the "m_"<name> prefix to* <name>"_" suffix nameing standard.*Also changed all vcf builder files to accomadate this.*Changes were made to the Stream classes to NOT multiple inheritance and to*be a little more correct. Changes include breaking the FileStream into two*distinct classes, one for input and one for output.**Revision 1.11 2003/02/26 04:30:38 ddiego*merge of code in the devmain-0-5-9 branch into the current tree.*most additions are in the area of the current linux port, but the major*addition to this release is the addition of a Condition class (currently*still under development) and the change over to using the Delegate class*exclusively from the older event handler macros.**Revision 1.10.20.1 2002/12/25 22:06:19 ddiego*whole bunch of little changes to the header files used by the ApplicationKit*to get rid of no newline warnings by gcc.*fixes to various event handlers in the ApplicationKit to compile with gcc*since gcc does not like a member function pointer without the "&"*addressof operator.*Added initial file for the X11 UIToolkit implementation**Revision 1.10 2002/03/01 01:02:37 ddiego*fixes bug [ 524006 ] TreeListControl crash*makes some changes to model classes to utilize event types better**Revision 1.9 2002/01/24 01:46:47 ddiego*added a cvs "log" comment to the top of all files in vcf/src and vcf/include*to facilitate change tracking**/#endif // _VCF_MODEL_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -