430 lines
		
	
	
		
			13 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			430 lines
		
	
	
		
			13 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| //
 | |
| // LISTPM.CPP
 | |
| //
 | |
| //  Source file for ArchiveLib 2.0
 | |
| //
 | |
| //  Copyright (c) Greenleaf Software, Inc. 1994-1996
 | |
| //  All Rights Reserved
 | |
| //
 | |
| // CONTENTS
 | |
| //
 | |
| //  ALEntryList::SetMarksFromListBox()
 | |
| //  ALEntryListSetMarksFromListBox()
 | |
| //  ALEntryList::FillListBox()
 | |
| //  ALEntryListFillListBox()
 | |
| //  ALEntryList::MakeEntriesFromListBox()
 | |
| //  ALEntryListMakeEntriesFromListBox()
 | |
| //
 | |
| // DESCRIPTION
 | |
| //
 | |
| //  This file contains the ALEntryList functions that interact with OS/2
 | |
| //  list boxes.
 | |
| //
 | |
| // REVISION HISTORY
 | |
| //
 | |
| //   February 14, 1996  2.0A : New release
 | |
| 
 | |
| #include "arclib.h"
 | |
| #if !defined( AL_IBM )
 | |
| #pragma hdrstop
 | |
| #endif
 | |
| 
 | |
| //
 | |
| // NAME
 | |
| //
 | |
| //  ALEntryList::SetMarksFromListBox()
 | |
| //
 | |
| // PLATFORMS/ENVIRONMENTS
 | |
| //
 | |
| //  PM
 | |
| //  C++  C
 | |
| //
 | |
| // SHORT DESCRIPTION
 | |
| //
 | |
| //  Set marks in an ALEntryList based on selections in a list box.
 | |
| //
 | |
| // C++ SYNOPSIS
 | |
| //
 | |
| //  #include "arclib.h"
 | |
| //
 | |
| //  int ALEntryList::SetMarksFromListBox( HWND hDlg,
 | |
| //                                        int list_box_id = -1 );
 | |
| //
 | |
| // C SYNOPSIS
 | |
| //
 | |
| //  #include "arclib.h"
 | |
| //
 | |
| //  int ALEntryListSetMarksFromListBox( hALEntryList this_object,
 | |
| //                                      HWND hDlg,
 | |
| //                                      int list_box_id );
 | |
| //
 | |
| // VB SYNOPSIS
 | |
| //
 | |
| //  None, VB and OS/2 don't mix.
 | |
| //
 | |
| // DELPHI SYNOPSIS
 | |
| //
 | |
| //  None, Delphi and OS/2 don't work.
 | |
| //
 | |
| // ARGUMENTS
 | |
| //
 | |
| //  this_object  :  A reference or pointer to the ALEntryList object that
 | |
| //                  is have some marks set.  Note that the C++ member function
 | |
| //                  version of this call doesn't have an explicit argument
 | |
| //                  here, since it has access to 'this' implicitly.
 | |
| //
 | |
| //  hDlg         :  This argument is a window handle.  If the next parameter,
 | |
| //                  list_box_id, is set to -1, it means this is the handle of
 | |
| //                  the list box.  If list_box_id is not -1, it means this
 | |
| //                  argument is the window handle of a dialog box that
 | |
| //                  contains the list box.
 | |
| //
 | |
| //  list_box_id  :  The id of the list box.  If set to -1, it means the list
 | |
| //                  box is not in a dialog box, and the hDlg parameter is the
 | |
| //                  actual handle of the list box.
 | |
| //
 | |
| // DESCRIPTION
 | |
| //
 | |
| //  This function is called after you have given a user the opportunity
 | |
| //  to set and clear items in a multiselection list box.  Once the user
 | |
| //  has done so, you can call this function, which will go through the
 | |
| //  list and set all the marks that have been set in the list box by the
 | |
| //  user.  Note that it will not clear the marks on any of the ALEntry
 | |
| //  objects in the list, you might want to do that first.
 | |
| //
 | |
| // RETURNS
 | |
| //
 | |
| //  A count of the items that have had their marks set.
 | |
| //
 | |
| // EXAMPLE
 | |
| //
 | |
| // SEE ALSO
 | |
| //
 | |
| // REVISION HISTORY
 | |
| //
 | |
| //   February 14, 1996  2.0A : New release
 | |
| //
 | |
| 
 | |
| int AL_PROTO
 | |
| ALEntryList::SetMarksFromListBox( HWND hDlg,  /* Tag public function */
 | |
|                                   int list_box_id /* = -1 */ )
 | |
| {
 | |
|     int mresReply = LIT_NONE;
 | |
|     int oldmresReply = LIT_NONE;
 | |
|     HWND window;
 | |
|     char name[ 256 ];
 | |
|     int count = 0;
 | |
| 
 | |
|     if ( list_box_id == -1 )
 | |
|         window = hDlg;
 | |
|     else
 | |
|         window = WinWindowFromID( hDlg, list_box_id );
 | |
|     mresReply = (int) WinSendMsg( window,
 | |
|                                   LM_QUERYSELECTION,
 | |
|                                   MPFROMSHORT( mresReply ),
 | |
|                                   0 );
 | |
|     oldmresReply = mresReply;
 | |
|     if ( mresReply != LIT_NONE ) {
 | |
|         do {
 | |
|             int l = (int) WinSendMsg( window,
 | |
|                                       LM_QUERYITEMTEXTLENGTH,
 | |
|                                       MPFROMSHORT( (SHORT) mresReply),
 | |
|                                       0 );
 | |
|             if ( l > 255 )
 | |
|                 l = 255;
 | |
|             WinQueryLboxItemText( window,
 | |
| 			                      mresReply,
 | |
| 			                      name,
 | |
| 			                      l );
 | |
|             name[ l ] = '\0';
 | |
|             count += SetMarks( name );
 | |
|             mresReply = (int) WinSendMsg( window,
 | |
|                                           LM_QUERYSELECTION,
 | |
|                                           MPFROMSHORT( (SHORT) mresReply ),
 | |
|                                           0 );
 | |
|             if( mresReply == oldmresReply )
 | |
|                 break;
 | |
|         } while( mresReply != LIT_NONE );
 | |
|     }
 | |
|     return count;
 | |
| }
 | |
| 
 | |
| #if !defined( AL_NO_C )
 | |
| 
 | |
| extern "C" AL_LINKAGE int AL_FUNCTION
 | |
| ALEntryListSetMarksFromListBox( hALEntryList this_object, /* Tag public function */
 | |
|                                 HWND hDlg,
 | |
|                                 int list_box_id )
 | |
| {
 | |
|     AL_ASSERT_OBJECT( this_object, ALEntryList, "ALEntryListSetMarksFromListBox" );
 | |
|     return ( (ALEntryList *) this_object)->SetMarksFromListBox( hDlg, list_box_id );
 | |
| }
 | |
| 
 | |
| #endif
 | |
| 
 | |
| 
 | |
| //
 | |
| // NAME
 | |
| //
 | |
| //  ALEntryList::FillListBox()
 | |
| //
 | |
| // PLATFORMS/ENVIRONMENTS
 | |
| //
 | |
| //  PM
 | |
| //  C++  C
 | |
| //
 | |
| // SHORT DESCRIPTION
 | |
| //
 | |
| //  Fill a list box with the object names from an ALEntryList.
 | |
| //
 | |
| // C++ SYNOPSIS
 | |
| //
 | |
| //  #include "arclib.h"
 | |
| //
 | |
| //  int ALEntryList::FillListBox( HWND hDlg,
 | |
| //                                int list_box_id = -1 );
 | |
| //
 | |
| // C SYNOPSIS
 | |
| //
 | |
| //  #include "arclib.h"
 | |
| //
 | |
| //  int ALEntryListFillListBox( hALEntryList this_object,
 | |
| //                              HWND hDlg,
 | |
| //                              int list_box_id )
 | |
| //
 | |
| // VB SYNOPSIS
 | |
| //
 | |
| //  None, VB won't run under OS/2.
 | |
| //
 | |
| // DELPHI SYNOPSIS
 | |
| //
 | |
| //  None, Delphi won't run under OS/2.
 | |
| //
 | |
| // ARGUMENTS
 | |
| //
 | |
| //  this_object  :  A reference or pointer to the ALEntryList object that
 | |
| //                  is going to supply all the entry names that are going
 | |
| //                  to be displayed in the list box.
 | |
| //
 | |
| //  hDlg         :  This argument is a window handle.  If the next parameter,
 | |
| //                  list_box_id, is set to -1, it means this is the handle of
 | |
| //                  the list box.  If list_box_id is not -1, it means this
 | |
| //                  argument is the window handle of a dialog box that
 | |
| //                  contains the list box.
 | |
| //
 | |
| //  list_box_id  :  The id of the list box.  If set to -1, it means the list
 | |
| //                  box is not in a dialog box, and the hDlg parameter is the
 | |
| //                  actual handle of the list box.
 | |
| //
 | |
| // DESCRIPTION
 | |
| //
 | |
| //  This function is a handy helper when writing PM applications.  It goes
 | |
| //  through an ALEntryList, and finds all the marked entries.  For every
 | |
| //  marked entry, it stuffs the name of the storage object into the list box.
 | |
| //  This means that if you are planning on letting the user select a list
 | |
| //  of storage objects, you can initialize the list with just one
 | |
| //  function call.
 | |
| //
 | |
| // RETURNS
 | |
| //
 | |
| //  The number of entries that were stuffed in the list box.
 | |
| //
 | |
| // EXAMPLE
 | |
| //
 | |
| // SEE ALSO
 | |
| //
 | |
| // REVISION HISTORY
 | |
| //
 | |
| //   February 14, 1996  2.0A : New release
 | |
| //
 | |
| 
 | |
| int AL_PROTO
 | |
| ALEntryList::FillListBox( HWND hDlg,  /* Tag public function */
 | |
|                           int list_box_id /* = -1 */ )
 | |
| {
 | |
|     HWND hwnd;
 | |
|     if ( list_box_id != -1 )
 | |
|         hwnd = WinWindowFromID( hDlg, list_box_id );
 | |
|     else
 | |
|         hwnd = hDlg;
 | |
|     WinSendMsg( hwnd,
 | |
|                 LM_DELETEALL,
 | |
|                 0,
 | |
|                 0 );
 | |
|     ALEntry *job = GetFirstEntry();
 | |
|     int count = 0;
 | |
|     while ( job ) {
 | |
|         if ( job->GetMark() ) {
 | |
|             count++;
 | |
|             WinSendMsg( hwnd,
 | |
|                         LM_INSERTITEM,
 | |
|                         MPFROMSHORT( LIT_END ),
 | |
| 			            MPFROMP( (PSZ) job->mpStorageObject->mName ) );
 | |
|         }
 | |
|         job = job->GetNextEntry();
 | |
|     }
 | |
|     if( count == 0 )
 | |
|         WinSendMsg( hwnd,
 | |
|                     LM_INSERTITEM,
 | |
|                     MPFROMSHORT( LIT_END ),
 | |
|                     MPFROMP( (PSZ) "<none>" ) );
 | |
|     return count;
 | |
| }
 | |
| 
 | |
| 
 | |
| #if !defined( AL_NO_C )
 | |
| 
 | |
| extern "C" AL_LINKAGE int AL_FUNCTION
 | |
| ALEntryListFillListBox( hALEntryList this_object,
 | |
|                         HWND hDlg,
 | |
|                         int list_box_id )
 | |
| {
 | |
|     AL_ASSERT_OBJECT( this_object, ALEntryList, "ALEntryListFillListBox" );
 | |
|     return ( (ALEntryList *) this_object )->FillListBox( hDlg, list_box_id );
 | |
| }
 | |
| 
 | |
| #endif
 | |
| 
 | |
| //
 | |
| // NAME
 | |
| //
 | |
| //  ALEntryList::MakeEntriesFromListBox()
 | |
| //
 | |
| // PLATFORMS/ENVIRONMENTS
 | |
| //
 | |
| //  PM
 | |
| //  C++  C
 | |
| //
 | |
| // SHORT DESCRIPTION
 | |
| //
 | |
| //  Create new entries in a list based on selected items in a list box.
 | |
| //
 | |
| // C++ SYNOPSIS
 | |
| //
 | |
| //  #include "arclib.h"
 | |
| //
 | |
| //  int ALEntryList::MakeEntriesFromListBox( HWND hDlg,
 | |
| //                                           int list_box = -1 );
 | |
| //
 | |
| // C SYNOPSIS
 | |
| //
 | |
| //  #include "arclib.h"
 | |
| //
 | |
| //  int ALEntryListMakeEntriesFromListBox( hALEntryList this_object,
 | |
| //                                         HWND hDlg,
 | |
| //                                         int list_box_id );
 | |
| //
 | |
| // VB SYNOPSIS
 | |
| //
 | |
| //  None, VB and PM don't mix.
 | |
| //
 | |
| // DELPHI SYNOPSIS
 | |
| //
 | |
| //  None.
 | |
| //
 | |
| // ARGUMENTS
 | |
| //
 | |
| //  this_object  :  A reference or pointer to the ALEntryList object that
 | |
| //                  is going to have new entries added.  Note that the C++
 | |
| //                  member function version of this call doesn't have an
 | |
| //                  an explicit argument here, since it has access to 'this'
 | |
| //                  implicitly.
 | |
| //
 | |
| //  hDlg         :  This argument is a window handle.  If the next parameter,
 | |
| //                  list_box_id, is set to -1, it means this is the handle of
 | |
| //                  the list box.  If list_box_id is not -1, it means this
 | |
| //                  argument is the window handle of a dialog box that
 | |
| //                  contains the list box.
 | |
| //
 | |
| //  list_box_id  :  The id of the list box.  If set to -1, it means the list
 | |
| //                  box is not in a dialog box, and the hDlg parameter is the
 | |
| //                  actual handle of the list box.
 | |
| //
 | |
| // DESCRIPTION
 | |
| //
 | |
| //  This function goes through a list box, and picks out all the
 | |
| //  highlighted entries.  It creates a new ALEntry object for each
 | |
| //  of the marked entires, using the storage objects and engines that
 | |
| //  are present in the toolkit owned by this ALEntryList.
 | |
| //
 | |
| // RETURNS
 | |
| //
 | |
| //  The number of new entries created from the list box.
 | |
| //
 | |
| // EXAMPLE
 | |
| //
 | |
| // SEE ALSO
 | |
| //
 | |
| // REVISION HISTORY
 | |
| //
 | |
| //   February 14, 1996  2.0A : New release
 | |
| //
 | |
| 
 | |
| int AL_PROTO
 | |
| ALEntryList::MakeEntriesFromListBox( HWND hDlg,  /* Tag public function */
 | |
|                                      int list_box_id /* = -1 */ )
 | |
| {
 | |
|     int mresReply = LIT_NONE;
 | |
|     int oldmresReply = LIT_NONE;
 | |
|     char name[ 256 ];
 | |
|     HWND hwnd;
 | |
|     int count = 0;
 | |
| 
 | |
|     if ( list_box_id != -1 )
 | |
|         hwnd = WinWindowFromID( hDlg, list_box_id );
 | |
|     else
 | |
|         hwnd = hDlg;
 | |
| 
 | |
|     mresReply = (int) WinSendMsg( hwnd,
 | |
|                                   LM_QUERYSELECTION,
 | |
|                                   MPFROMSHORT( (SHORT) mresReply ),
 | |
|                                   0 );
 | |
|     oldmresReply = mresReply;
 | |
|     if ( mresReply != LIT_NONE ) {
 | |
|         do {
 | |
|             int l = (int) WinSendMsg( hwnd,
 | |
|                                       LM_QUERYITEMTEXTLENGTH,
 | |
|                                       MPFROMSHORT( (SHORT) mresReply),
 | |
|                                       0 );
 | |
|             if ( l > 255 )
 | |
|                 l = 255;
 | |
|             WinQueryLboxItemText( hwnd,
 | |
|                                    mresReply,
 | |
|                                    name,
 | |
|                                    l );
 | |
|             name[ l ]='\0';
 | |
|             new ALEntry( *this,
 | |
| 		                 mToolKit.CreateStorageObject( name, AL_STORAGE_DEFAULT ),
 | |
|         		         mToolKit.CreateCompressor( AL_COMPRESSION_DEFAULT ),
 | |
|         		         mToolKit.CreateDecompressor( AL_COMPRESSION_DEFAULT ) );
 | |
|             count++;
 | |
|             WinSendMsg( hwnd,
 | |
|                         LM_SELECTITEM,
 | |
|                         MPFROMSHORT( mresReply ),
 | |
|                         MPFROMSHORT( 0 ) );
 | |
|             mresReply = (int) WinSendMsg( hwnd,
 | |
|                                           LM_QUERYSELECTION,
 | |
|                                           MPFROMSHORT( (SHORT) mresReply ),
 | |
|                                           0 );
 | |
|             if ( mresReply == oldmresReply )
 | |
|                 break;
 | |
|         } while ( mresReply != LIT_NONE );
 | |
|     }
 | |
|     return count;
 | |
| }
 | |
| 
 | |
| #if !defined( AL_NO_C )
 | |
| 
 | |
| extern "C" AL_LINKAGE int AL_FUNCTION
 | |
| ALEntryListMakeEntriesFromListBox( hALEntryList this_object,  /* Tag public function */
 | |
|                                    HWND hDlg,
 | |
|                                    int list_box_id )
 | |
| {
 | |
|     AL_ASSERT_OBJECT( this_object, ALEntryList, "ALEntryListMakeEntriesFromListBox" );
 | |
|     return ( (ALEntryList *) this_object )->MakeEntriesFromListBox( hDlg, list_box_id );
 | |
| }
 | |
| 
 | |
| #endif
 | |
| 
 | |
| 
 |