uitoolkit.h
来自「这是VCF框架的代码」· C头文件 代码 · 共 1,066 行 · 第 1/3 页
H
1,066 行
#ifndef _VCF_UITOOLKIT_H__#define _VCF_UITOOLKIT_H__//UIToolkit.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#endifenum ComponentType{ CT_DEFAULT=0, CT_LIGHTWEIGHT, CT_HEAVYWEIGHT};namespace VCF{#define STANDARD_CATEGORY "Standard"#define ADDITIONAL_CATEGORY "Additional"#define SYSTEM_CATEGORY "System"#define DIALOG_CATEGORY "Dialogs"#define NETWORKING_CATEGORY "Networking"#define BORDER_CATEGORY "Borders"#define CONTAINER_CATEGORY "Containers"#define MODEL_CATEGORY "Models"#define VIEW_CATEGORY "Views"class ListviewPeer;class ComboBoxPeer;class TextPeer;class TextEditPeer;class RichTextPeer;class ControlPeer;class TreePeer;class ButtonPeer;class ScrollbarPeer;class TabbedPagesPeer;class HeaderPeer;class DialogPeer;class WindowPeer;class ToolbarPeer;class ClipboardPeer;class DragDropPeer;class DataObjectPeer;class DropTargetPeer;class Component;class ContextPeer;class ApplicationPeer;class TextControl;class TreeControl;class ListViewControl;class Dialog;class MenuItem;class MenuItemPeer;class MenuBar;class MenuBarPeer;class ComboBoxControl;class CommandButton;class CommonFileDialogPeer;class CommonColorDialogPeer;class CommonPrintDialogPeer;class Color;class Clipboard;class GraphicsToolkit;class PopupMenuPeer;class PopupMenu;class Frame;class Control;class CommonFolderBrowseDialogPeer;class CommonFontDialogPeer;class DesktopPeer;class Desktop;class ComponentInfo;class ScrollPeer;class AcceleratorKey;class Button;class Toolbar;class TimerEvent;class SystemTrayPeer;class MenuManagerPeer;/**\class UIToolkit UIToolkit.h "vcf/ApplicationKit/UIToolkit.h" The UIToolkit is used to create instances of various peer's needed by the VCF,as well as providing certain low level services, such as modal and non-modalevent loops, and getting at UI metrics. Each system the VCF is ported to hasa concrete implementation of the UIToolkit. The UIToolkit is a singleton, andthere should only be one instance for a given process running the VCF libraries.To work with the toolkit you just call it's static functions. Thesein turn forward the call to the toolkit instance. The UIToolkit is a singleton, meaning there is only ever one single instance of it.Developers porting the VCF to another platform will have to create a derived classfrom UIToolkit and implement the various virtual functions.*/class APPLICATIONKIT_API UIToolkit : public ObjectWithEvents {public: /** *These enum values specify the various return values that a modal loop can return. *The most typical values are mrTrue or mrFalse. If used in conjuction with displaying * a modal dialog then some of the other values may come into play ot indicate a *common button that was clicked, such as OK, Cancel, Yes, No, etc. */ enum ModalReturnType { mrNone = 0, mrOK, mrCancel, mrYes, mrNo, mrRetry, mrIgnore, mrHelp, mrAbort, mrTrue, mrFalse }; enum { defaultUpdateSpeed = 200 }; UIToolkit(); virtual ~UIToolkit(); void init(); /** *Initializes the toolkit. the default toolkit is created and any other initialization *functions called */ static void initToolKit(); /** *cleans up the toolkit instance and deletes it */ static void closeToolkit(); /** *creates a new instance of a ControlPeer *the component passed in represents the component the implmenter will get attached to. */ static ControlPeer* createControlPeer( Control* component, ComponentType componentType=CT_DEFAULT); /** creates a context peer for a control */ static ContextPeer* createContextPeer( Control* component ); /** creates a context peer given a windowing specific context id. This simply calls the GraphicsToolkit's createContextPeer(). @see GraphicsToolkit::createContextPeer */ static ContextPeer* createContextPeer( OSHandleID contextID ); /** creates a memory based context peer given a width and height. This simply calls the GraphicsToolkit's createContextPeer(). @see GraphicsToolkit::createContextPeer */ static ContextPeer* createContextPeer( const unsigned long& width, const unsigned long& height ); /** This creates a peer that implements the ListviewPeer interface. A ListviewPeer allows you to view a list of data in multiple ways. For Win32 systems this is equivalent to creating a window handle with the WC_LISTVIEW window class name. */ static ListviewPeer* createListViewPeer( ListViewControl* component); /** This creates a peer that implements the TreePeer interface. A TreePeer allows you to view a data in an outline or hierarchical style. For Win32 systems this is equivalent to creating a window handle with the WC_TREEVIEW window class name. */ static TreePeer* createTreePeer( TreeControl* component); /** This creates a peer that implements the TextPeer interface. A TextPeer allows you to view and edit text, either in a single line edit control, or a multiline edit control. For Win32 systems this is equivalent to creating a Richedit window handle. */ static TextPeer* createTextPeer( const bool& autoWordWrap, const bool& multiLined ); static TextEditPeer* createTextEditPeer( TextControl* component, const bool& isMultiLineControl); /** This creates a peer that implements the ButtonPeer interface. This ensures that you have a button control that correctly implements ALL the look and feel requirements for the windowing system. Some windowing systems have a more complex button control than others, making it more complicated to try and emulate, as opposed to just providing a peer that creates a native button control. For Win32 systems this is equivalent to creating a window handle with the BUTTON window class name. */ static ButtonPeer* createButtonPeer( CommandButton* component); static DialogPeer* createDialogPeer( Control* owner, Dialog* component); static DialogPeer* createDialogPeer(); static WindowPeer* createWindowPeer( Control* component, Control* owner ); static ToolbarPeer* createToolbarPeer( Toolbar* toolbar ); static MenuItemPeer* createMenuItemPeer( MenuItem* item ); static MenuBarPeer* createMenuBarPeer( MenuBar* menuBar ); static PopupMenuPeer* createPopupMenuPeer( PopupMenu* popupMenu ); static ClipboardPeer* createClipboardPeer(); static DragDropPeer* createDragDropPeer(); static DataObjectPeer* createDataObjectPeer(); static DropTargetPeer* createDropTargetPeer(); static ApplicationPeer* createApplicationPeer(); static Clipboard* getSystemClipboard(); static CommonFileDialogPeer* createCommonFileOpenDialogPeer( Control* owner ); static CommonFolderBrowseDialogPeer* createCommonFolderBrowseDialogPeer( Control* owner ); static CommonFileDialogPeer* createCommonFileSaveDialogPeer( Control* owner ); static CommonColorDialogPeer* createCommonColorDialogPeer( Control* owner ); static CommonFontDialogPeer* createCommonFontDialogPeer( Control* owner ); static CommonPrintDialogPeer* createCommonPrintDialogPeer( Control* owner ); static DesktopPeer* createDesktopPeer( Desktop* desktop ); static ScrollPeer* createScrollPeer( Control* control ); static CursorPeer* createCursorPeer( Cursor* cursor ); static SystemTrayPeer* createSystemTrayPeer(); static MenuManagerPeer* createMenuManagerPeer(); static GraphicsResourceBundlePeer* createGraphicsResourceBundlePeer( AbstractApplication* app ); static bool createCaret( Control* owningControl, Image* caretImage ); static bool destroyCaret( Control* owningControl ); static void setCaretVisible( const bool& caretVisible ); static void setCaretPos( Point* point ); /** This method posts an event to the underlying platform's windowing system. The event handler instance that is passed in is called when the event is processed later on in the event queue. Once this happens the handler's invoke() method is called and the event that was passed in to this method is passed into the EventHandler::invoke() method. Once invoke() returns, the event is deleted and the event handler is delete \em only if the deleteHandler parameter to postEvent() was true, otherwise it is left alone. @param EventHandler the event handler instance to use when the event is retrieved off the event queue later on. @param Event the event to pass to the eventHandler's invoke() method. This instance is managed by the UIToolkit, and \em must be created on the heap. If you create the event instance on the stack you'll corrupt memory and crash your program. Consider yourself warned. @param bool this parameter tells the UIToolkit whether or not it should delete the event handler instance. This means that you have a choice when calling the postEvent function - you can either have the UIToolkit clean up the event handler instance for you (deleteHandler=true), or you can manage this instance yourself. If you choose to let the UIToolkit manage the event handler instance, then make sure you don't maintain ownership of the event handler. If you are using EventHandlerInstance classes ( like GenericEventHandler, etc) then you can do the following: \code //note that we don't pass in a name for the event handler EventHandler* ev = new GenericEventHandler<MyClass>( this, &MyClass::onMyEvent ); Event* event = //create some event instance UIToolkit::postEvent( ev, event ); //defaults to deleting the event handler \endcode Note that in our example above we did \em not give the event handler a name. This prevents the event handler from being added to it's source, and insures that it will not be owned, allowing the UIToolkit to safely delete it. If we want to manage the event handler ourselves, then we might do the following: \code //assuming that we are in an object instance that derives from ObjectWithEvents. //all control classes do inherit from ObjectWithEvents. EventHandler* ev = getEventHandler( "MyClass::onMyEvent" ); if ( NULL == ev ) { ev = new GenericEventHandler<MyClass>( this, &MyClass::onMyEvent ); } Event* event = //create some event instance UIToolkit::postEvent( ev, event, false ); //defaults to deleting the event handler \endcode @see Event @see EventHandler @see EventHandlerInstance */ static void postEvent( EventHandler* eventHandler, Event* event, const bool& deleteHandler=true ); static void registerTimerHandler( Object* source, EventHandler* handler, const ulong32& timeoutInMilliSeconds ); static void unregisterTimerHandler( EventHandler* handler ); /* *this runs an event loop - the imeplementation is entirely system specific and *in implemented in subclasses of UIToolkit */ static void runEventLoop(); static ModalReturnType runModalEventLoopFor( Control* control ); /** this will attempt to send a message/event to the underlying windowing system's event loop (started due to a call to runEventLoop() or runModalEventLoopFor(...) ) and get it to quit running. It will not block and will return immediately. If an event loop ends, and there are no more event loops running then the application may quit cleanly. <p>On the Win32 system this is implemented with a PostQuitMessage(0) */ static void quitCurrentEventLoop(); /** *This method creates a new event from native windowing OS event *data. Each UIToolkit implementation must implement this method *and since we can't possibly know the event data at this point, *we just specify a void*. The concrete implementation will have to *typecast this to the specific datatype or structure. */ static Event* createEventFromNativeOSEventData( void* eventData );
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?