home *** CD-ROM | disk | FTP | other *** search
- Save Format v1.3
- @begin ClassFile "ViewHelper"
- Exported 0;
-
- @begin UserFunction "ViewHelper( WForm * form, ViewCreateFunction create )"
- GencodeSrcLine 17;
- FunctionName "ViewHelper::ViewHelper( WForm * form, ViewCreateFunction create )";
- @end;
-
- @begin UserFunction "Prototype for ViewHelper( WForm * form, ViewCreateFunction create )"
- Private 1;
- GencodeSrcLine 35;
- FunctionName "ViewHelper::Prototype for ViewHelper( WForm * form, ViewCreateFunction create )";
- @end;
-
- @begin UserFunction "~ViewHelper()"
- GencodeSrcLine 26;
- FunctionName "ViewHelper::~ViewHelper()";
- @end;
-
- @begin UserFunction "Prototype for ~ViewHelper()"
- Private 1;
- GencodeSrcLine 37;
- FunctionName "ViewHelper::Prototype for ~ViewHelper()";
- @end;
-
- @begin UserFunction "Open( WForm * parent )"
- GencodeSrcLine 30;
- FunctionName "ViewHelper::Open( WForm * parent )";
- @end;
-
- @begin UserFunction "Prototype for Open( WForm * parent )"
- Private 1;
- GencodeSrcLine 39;
- FunctionName "ViewHelper::Prototype for Open( WForm * parent )";
- @end;
-
- @begin UserFunction "Create( WListView * listView, WQuery * query )"
- GencodeSrcLine 52;
- FunctionName "ViewHelper::Create( WListView * listView, WQuery * query )";
- @end;
-
- @begin UserFunction "Prototype for Create( WListView * listView, WQuery * query )"
- Private 1;
- GencodeSrcLine 41;
- FunctionName "ViewHelper::Prototype for Create( WListView * listView, WQuery * query )";
- @end;
-
- @begin UserFunction "SortList( WInt column )"
- GencodeSrcLine 90;
- FunctionName "ViewHelper::SortList( WInt column )";
- @end;
-
- @begin UserFunction "Prototype for SortList( WInt column )"
- Private 1;
- GencodeSrcLine 43;
- FunctionName "ViewHelper::Prototype for SortList( WInt column )";
- @end;
-
- @begin UserFunction "Destroy( void )"
- GencodeSrcLine 96;
- FunctionName "ViewHelper::Destroy( void )";
- @end;
-
- @begin UserFunction "Prototype for Destroy( void )"
- Private 1;
- GencodeSrcLine 45;
- FunctionName "ViewHelper::Prototype for Destroy( void )";
- @end;
-
- @begin UserFunction "Refresh( void )"
- GencodeSrcLine 119;
- FunctionName "ViewHelper::Refresh( void )";
- @end;
-
- @begin UserFunction "Prototype for Refresh( void )"
- Private 1;
- GencodeSrcLine 47;
- FunctionName "ViewHelper::Prototype for Refresh( void )";
- @end;
-
- @begin UserFunction "ToggleSortOrder( void )"
- GencodeSrcLine 131;
- FunctionName "ViewHelper::ToggleSortOrder( void )";
- @end;
-
- @begin UserFunction "Prototype for ToggleSortOrder( void )"
- Private 1;
- GencodeSrcLine 49;
- FunctionName "ViewHelper::Prototype for ToggleSortOrder( void )";
- @end;
-
- @begin UserFunction "sortList( void )"
- Private 1;
- GencodeSrcLine 137;
- FunctionName "ViewHelper::sortList( void )";
- @end;
-
- @begin UserFunction "Prototype for sortList( void )"
- Private 1;
- GencodeSrcLine 51;
- FunctionName "ViewHelper::Prototype for sortList( void )";
- @end;
-
- @begin HPPPrefixBlock
- @begin-code HPPPrefix
-
- // Declarations added here will be included at the top of the .HPP file
-
- // Define a member function pointer to handle calling the form Create method
-
- typedef WBool WCMDEF (WForm::*ViewCreateFunction)( WForm * parent );
-
- @end-code;
- GencodeSrcLine 11;
- @end;
-
- @begin CPPPrefixBlock
- @begin-code CPPPrefix
-
- // Code added here will be included at the top of the .CPP file
-
- // Include definitions for resources.
- #include "WRes.h"
-
- #define VH_PINNED 0
-
- @end-code;
- GencodeSrcLine 11;
- @end;
-
- @begin ClassContentsBlock
- @begin-code ClassContents
-
- public:
- // add your public instance data here
- private:
- // add your private instance data here
- ViewCreateFunction _create; // The form's Create function.
- WForm * _form; // The form we are helping
- WListView * _listView;
- WBool _open;
- WQuery * _query;
- WString _querySQL; // Query for list without ORDER BY
- WInt _sortColumn;
- WBool _sortAscending;
-
- protected:
- // add your protected instance data here
-
- @end-code;
- GencodeSrcLine 20;
- @end;
-
- @begin-code GeneratedClassContents
-
-
- @end-code;
-
- @begin-code Code "ViewHelper::ViewHelper( WForm * form, ViewCreateFunction create )"
-
- ViewHelper::ViewHelper( WForm * form, ViewCreateFunction create )
- {
- WASSERT( form != NULL );
- _form = form;
- _create = create;
- _open = FALSE;
- _sortColumn = 1;
- _sortAscending = TRUE;
- }
-
- @end-code;
-
- @begin-code Code "ViewHelper::Prototype for ViewHelper( WForm * form, ViewCreateFunction create )"
-
- public:
- ViewHelper( WForm * form, ViewCreateFunction create );
-
- @end-code;
-
- @begin-code Code "ViewHelper::~ViewHelper()"
-
- ViewHelper::~ViewHelper()
- {
-
- }
-
- @end-code;
-
- @begin-code Code "ViewHelper::Prototype for ~ViewHelper()"
-
- public:
- ~ViewHelper();
-
- @end-code;
-
- @begin-code Code "ViewHelper::Open( WForm * parent )"
-
- // Open
-
- // Load or show the form.
-
- // Note: We cannot directly call form->Create() because the form's Create
- // routine is not a virtual function. Instead we pass the address of the
- // correct create function to use in the ViewHelper constructor, and
- // use the special C++ syntax "->*" to call it here.
-
- WBool ViewHelper::Open( WForm * parent )
- {
- if( !_open ) {
- parent->SetCursor( WCursor(WSCWait), TRUE );
- _open = (_form->*_create)( parent );
- parent->SetCursor( WCursor(), TRUE );
- }
- else {
- _form->SetWindowState( WWindowStateNormal );
- _form->Activate();
- }
- return( _open );
- }
-
- @end-code;
-
- @begin-code Code "ViewHelper::Prototype for Open( WForm * parent )"
-
- public:
- WBool Open( WForm * parent );
-
- @end-code;
-
- @begin-code Code "ViewHelper::Create( WListView * listView, WQuery * query )"
-
- WBool ViewHelper::Create( WListView * listView, WQuery * query )
- {
- WForm * parent;
- WRect rect;
- WStatusBar * status;
-
- WASSERT( listView != NULL );
- WASSERT( query != NULL );
- _listView = listView;
- _query = query;
-
- parent = (WForm *)_form->GetParent();
-
- #if VH_PINNED
- // Pinning the window to its parent causes the window to move when the
- // parent window is moved.
- parent->AddPinnedWindow( _form );
- #endif
-
- // Make the list view fill and track the effective client area of
- // the form. The effective (adjusted) client area accounts for such
- // things as menus, tool bars, and a status area.
- _form->SetClientWindow( _listView );
- rect = _form->GetClientRectangle();
- _form->AdjustClientRectangle( rect );
-
- // Set Text for status bar
- status = _form->GetStatusBar();
- status->SetText( "Double click or right-mouse click on the first column." );
-
- // Save the query without an Order By clause
- _querySQL = _query->GetSQL();
-
- // Submit the query with an Order By clause.
- SortList( 1 );
-
- return FALSE;
- }
-
- @end-code;
-
- @begin-code Code "ViewHelper::Prototype for Create( WListView * listView, WQuery * query )"
-
- public:
- WBool Create( WListView * listView, WQuery * query );
-
- @end-code;
-
- @begin-code Code "ViewHelper::SortList( WInt column )"
-
- void ViewHelper::SortList( WInt column )
- {
- WASSERT( column >= 1 );
- _sortColumn = column;
- sortList();
- }
-
- @end-code;
-
- @begin-code Code "ViewHelper::Prototype for SortList( WInt column )"
-
- public:
- void SortList( WInt column );
-
- @end-code;
-
- @begin-code Code "ViewHelper::Destroy( void )"
-
- // Destroy
-
- // Handle the form Destroy event.
-
- WBool ViewHelper::Destroy( void )
- {
- WForm * parent;
-
- _form->SetClientWindow( NULL );
-
- parent = (WForm *)_form->GetParent();
-
- #if VH_PINNED
- parent->RemovePinnedWindow( _form );
- #endif
-
- parent->Activate();
- parent->SetFocus();
-
- _open = FALSE;
-
- return FALSE;
- }
-
- @end-code;
-
- @begin-code Code "ViewHelper::Prototype for Destroy( void )"
-
- public:
- WBool Destroy( void );
-
- @end-code;
-
- @begin-code Code "ViewHelper::Refresh( void )"
-
- void ViewHelper::Refresh( void )
- {
- #if 0
- // Refresh refetches the locally held rows. It is very fast but will not resort
- // items etc.
- _query->Refresh();
- #else
- // Resubmit re-executes the query. This will take longer but it resorts the rows
- _query->Resubmit();
- _query->MoveNext();
- #endif
- }
-
- @end-code;
-
- @begin-code Code "ViewHelper::Prototype for Refresh( void )"
-
- public:
- void Refresh( void );
-
- @end-code;
-
- @begin-code Code "ViewHelper::ToggleSortOrder( void )"
-
- WString ViewHelper::ToggleSortOrder( void )
- {
- _sortAscending = !_sortAscending;
- sortList();
- return( _sortAscending ? "&Sort Descending" : "&Sort Ascending" );
- }
-
- @end-code;
-
- @begin-code Code "ViewHelper::Prototype for ToggleSortOrder( void )"
-
- public:
- WString ToggleSortOrder( void );
-
- @end-code;
-
- @begin-code Code "ViewHelper::sortList( void )"
-
- void ViewHelper::sortList( void )
- {
- WString orderedQuery;
-
- _form->SetCursor( WCursor(WSCWait), TRUE );
- orderedQuery.Sprintf( "%s ORDER BY %d", _querySQL.GetText(), _sortColumn );
- if( !_sortAscending ) {
- orderedQuery.Concat( " DESC" );
- }
- _listView->SetPainting( false );
- _query->SetSQL( orderedQuery );
- _query->Open();
- _query->MoveFirst();
- _listView->SetPainting( true );
- _form->SetCursor( WCursor(), TRUE );
- }
-
- @end-code;
-
- @begin-code Code "ViewHelper::Prototype for sortList( void )"
-
- private:
- void sortList( void );
-
- @end-code;
- @end;
-