Step 6: Adding Main Window Support
Last updated on: 5/30/2013 8:54 PM
Created on: 11/2/2016 2:22 PM
The SC-7 framework handles the user interface aspects of applets. The main interface is handled by a window that calls into an interface that contains the main code to execute based on a user interaction. The framework will not allow an applet to be launched like an application unless it determines that an applet implements the ISCAppletWindowExtension. Simply adding support for this interface to the demo applet will cause the framework to add necessary menu and launch buttons which will bring up an empty main window until the needed methods are implemented.
The framework allows for multiple applet windows, one for each applet that implements the interface. As a result of this, each applet can control the size and placement of the applet window. These three methods will require implementation:
- void SetDefaultUISettings()
- void SetControlSizes( CONTROLHEIGHTS& ControlHeights )
- void LastKnownControlSizes( CONTROLHEIGHTS ControlHeights )
SetControlSizes in called prior to the window becoming activated and LastKnownControlSizes is called after the window is closed prior the applet being deactivated. It is in these methods that reading from and writing to the persistent storage class will be required to have the demo applet remember window sizes and positions. Additional calls to the methods Activate() and Deactivate() are made during the activation and deactivation process where implementations that should occur once for each window creation and destruction should occur.
The framework provides the main UI controls and Window, complete with tool bars, desktop menu bar and context menu support. The Applet Window allows for Multiple Tree Widgets, one List Widget and one HTML Browser Widget. To customize and isolate the rendering logic for each of these controls, window extensions must provide back the appropriate instances of view class based on the ISCView() interface. There are three common sub implementations of the ISCView() interface: ISCTreeWidgetView(), ISCBrowserWidgetView() and ISCListWidgetView(). Dervice a view implementation from one of these three view interfaces and return the proper instance of that view class when the framework calls SetView() with the Qt control that the view will be controlling. For each valid view the framework will then call ViewCaption() to obtain the proper text string to display as a caption for the view.
The framework handles all the behind the scenes logic required to perform copy and paste as well as drag and drop. Both techniques use similar technologies and will require implementation of up to five methods. These three are query based to determine if a view will support an operation based on the type of information available for paste or being dragged into the view:
- ViewHandlesMime( const QMimeData* pMimeSource, int nViewID )
- ViewBuildsScrap( int nViewID )
- ViewAllowsFileDrops( int nViewID )
If a copy operation or a paste operation, or in the case of a drag-n-drop if the selected object drag begins or a drop occurs, these methods are invoked and will require implementation based on what information is to be accepted as the paste/drop or built with the copy/drag actions:
- OnAcceptScrap( const QMimeData* pMimeSource, int nViewID )
- OnBuildScrap( QMimeData& Mime, int nViewID )
In order to have the applet respond to the user selecting any of the standard actions, the method for the associated action requires implementation. Each method takes as a parameter the view ID of the view that currently has the input focus. The methods are:
- void OnFileOpen( int nView )
- void OnFileSave( int nView )
- void OnFileSaveAs( int nView )
- void OnFilePublish( int nView )
- void OnFileEmail( int nView )
- void OnEditDelete( int nView )
- void OnEditSelectAll( int nView )
- void OnEditFind( int nView )
- void OnEditFindNext( int nView )
- void OnEditRename( int nView )
- void OnViewProperties( int nView )
During any change of input focus, change in the selection of the items within a view or when the window becomes the active window the framework will use the following query functions to determine which actions should be enabled:
- void OnUpdateFileOpen( int nView, PACTIONUI pCmdUI )
- void OnUpdateFileSave( int nView, PACTIONUI pCmdUI )
- void OnUpdateFileSaveAs( int nView, PACTIONUI pCmdUI )
- void OnUpdateFilePublish( int nView, PACTIONUI pCmdUI )
- void OnUpdateFileEmail( int nView, PACTIONUI pCmdUI )
- void OnUpdateEditDelete( int nView, PACTIONUI pCmdUI )
- void OnUpdateEditSelectAll( int nView, PACTIONUI pCmdUI )
- void OnUpdateEditFind( int nView, PACTIONUI pCmdUI )
- void OnUpdateEditFindNext( int nView, PACTIONUI pCmdUI )
- void OnUpdateEditRename( int nView, PACTIONUI pCmdUI )
- void OnUpdateViewProperties( int nView, PACTIONUI pCmdUI )
- void OnUpdateViewRefresh( int nView, PACTIONUI pCmdUI )
To react to any user interaction within the specific view implement one or more of these methods as needed:
- void OnContextMenu( int nView, unsigned long& ulFlags )
- void OnSelectionActivated( int nView, QListWidgetItem* item )
- void OnListCurrentRenamed( int nView, QString newText )
- void OnListCurrentChanged( int nView, QListWidgetItem* now, QListWidgetItem* previous )
- void OnListCurrentChanged( int nView, QTreeWidgetItem* now, QTreeWidgetItem* previous )
- void OnListCurrentRenamed( int nView )
- void OnSelectionActivated( int nView, QTreeWidgetItem* item, int nColumn )
- void OnSelectionChanged( int nView )
- void OnAnchorClicked( int nView, const QUrl &url )
Once these methods are implemented in our demo applet, the applet will have UI Windowing support and the ability to implement its own rendering using custom views.
Topics
Developer's Historical Persepctive Why A Platform Standards The User ExperienceInterfaces
ISCApplet ISCTaskListExtension ISCConfigPanelExtension ISCErrorReporterExtension ISCLogConnector/ISCLogEntry ISCCertificateStoreExtension ISCSystemTrayExtension ISCAppletWindowExtension ISCSecureObjectExtensionApplet Building Steps
Step 1: Create The Applet Step 2: Adding Action Items Step 3: Adding Configuration Panels Step 4: Adding Custom Error Text Step 5: Startup/Shutdown Step 6: Adding Main Window Support Step 7: Adding Obejct Window Support