📄 dirindex.cpp
字号:
/*____________________________________________________________________________*\
*
Copyright (c) 1997-2003 John Roy, Holger Zimmermann. All rights reserved.
These sources, libraries and applications are
FREE FOR COMMERCIAL AND NON-COMMERCIAL USE
as long as the following conditions are adhered to.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHORS OR ITS CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
*____________________________________________________________________________*|
*
* $Source: /cvsroot/pi3web/Pi3Web_200/Source/Intrface/DirIndex.cpp,v $
* $Date: 2003/05/13 18:42:05 $
*
Description:
\*____________________________________________________________________________*/
//$SourceTop:$
#include <iostream.h>
#include <stdio.h>
#include <windowsx.h>
#include "IFaceBse.h"
#include "PIStrStr.h"
#include "StrToken.h"
#include "QConfig.h"
#include "DirIndex.hrc"
/*
** #define D { cerr << __FILE__ << ": " << __LINE__ << endl; }
*/
#define D
/*____________________________________________________________________________*\
*
Description:
\*____________________________________________________________________________*/
#define C_RESOURCENAME "DirIndexPage"
#define COLUMNCOUNT 6
#define FMT_DECIMAL "Size"
#define FMT_ABBREV "AbbrevSize"
#define FMT_FORMAT "FormatSize"
#define SET_LAYOUT( Idx ) SendMessage( GetDlgItem( hDlg, IDC_INDEX##Idx ), \
BM_SETCHECK, BST_CHECKED, 0 ); __iCurrentLayout = Idx
#define SET_FORMAT( Fmt ) SendMessage( GetDlgItem( hDlg, IDC_##Fmt ), \
BM_SETCHECK, BST_CHECKED, 0 ); __pCurrentSizeFmt = FMT_##Fmt
/*____________________________________________________________________________*\
*
Description:
\*____________________________________________________________________________*/
#if 0
/*
** HTML documentation for this handler
*/
/*___+++HTMLDOC_BEGIN+++___*/
Name:
DirIndexPage
Description:
Creates the eponymous property page and is used by the PropSheet object.
Example:
<PRE>
<Object>
Name DirIndexPage
Class DirIndexPageClass
PropertyPage DirIndexPage
</Object>
</PRE>
/*___+++HTMLDOC_END+++___*/
#endif
/*____________________________________________________________________________*\
*
Description:
\*____________________________________________________________________________*/
static BOOL CALLBACK fnDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam,
LPARAM lParam);
/*____________________________________________________________________________*\
*
Class:
Description:
\*____________________________________________________________________________*/
class DirIndexPage : public IFaceBase
{
private:
QConfig *pConfig;
PROPSHEETPAGE tPsp;
Interface *pInterface;
/*
** window private values
*/
HWND hWndSortCol;
HWND hWndColumns;
HWND hWndHyperlink;
HWND hWndICase;
HWND hWndDescending;
HWND hWndTag;
HWND hWndTruncate;
HWND hWndHeader;
HWND hWndFooter;
HWND hWndDescription;
int __iCurrentLayout;
const char *__pCurrentSizeFmt;
int Parameter( const char *pVariable, const char *pValue,
const char *pWhere )
{
assert( pVariable && pValue );
PIOStrStream os;
os << pWhere << "DirIndexPage: ";
if ( 0 )
{
}
else
{
os << "Unknown directive '" << pVariable <<
"'" << ends;
CONFIG_ERR( Object(), os.str() );
return 0;
};
return 1;
};
public:
DirIndexPage( PIObject *pObject, int iArgc, const char *ppArgv[] )
: IFaceBase( pObject ),
pConfig( FindParentQConfig( PIObject_getDB( pObject ) ) ),
pInterface( 0 ),
hWndSortCol( 0 ),
hWndColumns( 0 ),
hWndHyperlink( 0 ),
hWndICase( 0 ),
hWndDescending( 0 ),
hWndTag( 0 ),
hWndTruncate( 0 ),
hWndHeader( 0 ),
hWndFooter( 0 ),
hWndDescription( 0 ),
__iCurrentLayout( 0 ),
__pCurrentSizeFmt( FMT_ABBREV )
{
ReadParameters( iArgc, ppArgv );
if ( !IsOK() )
{ return; };
/*
** Setup the PROPSHEETPAGE
*/
memset( &tPsp, 0, sizeof( PROPSHEETPAGE ) );
tPsp.dwSize = sizeof( PROPSHEETPAGE );
tPsp.dwFlags = PSP_DEFAULT;
tPsp.hInstance = (HINSTANCE)PIDLL_getSystemHandle( PIClass_getLibrary(
PIObject_getClass( Object() ) ) );
/* Status page */
tPsp.pszTemplate = C_RESOURCENAME;
tPsp.pfnDlgProc = (DLGPROC)fnDialogProc;
tPsp.lParam = (LPARAM)this;
/*
** Set the data DB of this object
*/
PIDB *pDB = PIObject_getDB( Object() );
PIDB_add( pDB, PIDBTYPE_OPAQUE, INTRFACE_WINDOWTYPE,
(void *)INTRFACE_PROPPAGE, 0 );
assert(!PIDB_lookup( pDB, PIDBTYPE_OPAQUE, INTRFACE_PROPSHEETPAGE, 0));
PIDB_add( pDB, PIDBTYPE_OPAQUE, INTRFACE_PROPSHEETPAGE,
(void *)&tPsp, 0 );
/*
** Done
*/
};
~DirIndexPage()
{
};
virtual int Handle( Interface &tWindow )
{
switch( tWindow.iMessage )
{
case INTRFACE_MSG_INIT:
pInterface = &tWindow;
break;
case INTRFACE_MSG_WIN32CREATE:
return PIAPI_ABORT;
case INTRFACE_MSG_LOAD:
return PIAPI_ABORT;
case INTRFACE_MSG_DEFAULTS:
M_AddValue( pConfig, "DirIndex", "Layout", "1" );
// Type Name Alt Size Date Dscr
// 1 2 4 8 16 32
M_AddValue( pConfig, "DirIndex", "Columns", "59" );
M_AddValue( pConfig, "DirIndex", "SortColumn", "Type" );
// Link Case Desc
// 1 2 4
M_AddValue( pConfig, "DirIndex", "SortFlags", "1" );
// Hdr Ftr Dscr
// 1 2 4
M_AddValue( pConfig, "DirIndex", "FileFlags", "7" );
M_AddValue( pConfig, "DirIndex", "TagNew", "10" );
M_AddValue( pConfig, "DirIndex", "Truncate", "20" );
M_AddValue( pConfig, "DirIndex", "SizeFormat", "AbbrevSize" );
break;
default:
assert( 0 );
return PIAPI_ABORT;
};
return PIAPI_COMPLETED;
};
void Internal_SortColumnChanged( HWND hDlg )
{
if ( __iCurrentLayout == 6 ) return;
enum { BUF_SIZE=1023 };
char szBuf[BUF_SIZE+1];
int iIdx = ::SendMessage( hWndSortCol, CB_GETCURSEL, 0, 0 );
*szBuf = 0;
if (iIdx != CB_ERR )
{ ::SendMessage( hWndSortCol, CB_GETLBTEXT, iIdx, (LPARAM)szBuf); };
if (!*szBuf ) { return; };
if ( !strcmp(szBuf, "(none)" ))
{
::EnableWindow( hWndHyperlink, FALSE );
::EnableWindow( hWndICase, FALSE );
::EnableWindow( hWndDescending, FALSE );
}
else
{
::EnableWindow( hWndHyperlink, TRUE );
::EnableWindow( hWndICase, TRUE );
::EnableWindow( hWndDescending, TRUE );
}
}
void Internal_ColumnsChanged( HWND hDlg )
{
int iItems[COLUMNCOUNT];
ZeroMemory( &iItems, sizeof(iItems) );
int i = ::SendMessage( hWndColumns, LB_GETSELITEMS,
COLUMNCOUNT, (LPARAM)&iItems );
// Column 'Size' = index 3
for (;i>0;i--) {
if ( iItems[i-1] == 3 ) { break; }
}
if ( __iCurrentLayout == 6 ) i = 0;
EnableWindow( GetDlgItem( hDlg, IDC_DECIMAL ), i );
EnableWindow( GetDlgItem( hDlg, IDC_ABBREV ), i );
EnableWindow( GetDlgItem( hDlg, IDC_FORMAT ), i );
}
void Internal_LayoutChanged( HWND hDlg, int iNewLayout )
{
int iIdx = ::SendMessage( hWndSortCol, CB_GETCURSEL, 0, 0 );
if ( iNewLayout == __iCurrentLayout ) return;
if ( iNewLayout != 6 )
{
EnableWindow( hWndSortCol, TRUE );
EnableWindow( hWndColumns, TRUE );
EnableWindow( hWndTag, TRUE );
EnableWindow( hWndTruncate, TRUE );
EnableWindow( hWndHeader, TRUE );
EnableWindow( hWndFooter, TRUE );
EnableWindow( hWndDescription, TRUE );
// the rest will be done dynamically
}
switch (iNewLayout)
{
/*
** HTML table index
*/
case 1:
// Column 'Type' = index 0
::SendMessage( hWndColumns, LB_SETSEL, TRUE, 0 );
// Column 'Name' = index 1
::SendMessage( hWndColumns, LB_SETSEL, TRUE, 1 );
// Column 'AltName' = index 2
::SendMessage( hWndColumns, LB_SETSEL, FALSE, 2 );
// Column 'Size' = index 3
::SendMessage( hWndColumns, LB_SETSEL, TRUE, 3 );
// Column 'Date' = index 4
::SendMessage( hWndColumns, LB_SETSEL, TRUE, 4 );
// Column 'Description' = index 5
::SendMessage( hWndColumns, LB_SETSEL, TRUE, 5 );
// SortColumn '(Type)' = index 1
::SendMessage( hWndSortCol, CB_SETCURSEL, 1, 0 );
// Sort Flags
::SendMessage( hWndHyperlink, BM_SETCHECK, TRUE, 0 );
::SendMessage( hWndICase, BM_SETCHECK, FALSE, 0 );
::SendMessage( hWndDescending, BM_SETCHECK, FALSE, 0 );
// Options
if ( ::SendMessage( hWndTag, WM_GETTEXTLENGTH, 0, 0 ) == 0 )
{ ::SendMessage( hWndTag, WM_SETTEXT, 0, (LPARAM)"10" ); }
if ( ::SendMessage( hWndTruncate, WM_GETTEXTLENGTH, 0, 0 ) == 0 )
{ ::SendMessage( hWndTruncate, WM_SETTEXT, 0, (LPARAM)"20" ); }
// Axiliary Files
::SendMessage( hWndHeader, BM_SETCHECK, TRUE, 0 );
::SendMessage( hWndFooter, BM_SETCHECK, TRUE, 0 );
::SendMessage( hWndDescription, BM_SETCHECK, TRUE, 0 );
// SizeFormat
SendMessage( GetDlgItem( hDlg, IDC_DECIMAL ), BM_SETCHECK, BST_UNCHECKED, 0 );
SendMessage( GetDlgItem( hDlg, IDC_ABBREV ), BM_SETCHECK, BST_CHECKED, 0 );
SendMessage( GetDlgItem( hDlg, IDC_FORMAT ), BM_SETCHECK, BST_UNCHECKED, 0 );
break;
/*
** HTML index with fixed font
*/
case 2:
// Column 'Type' = index 0
::SendMessage( hWndColumns, LB_SETSEL, TRUE, 0 );
// Column 'Name' = index 1
::SendMessage( hWndColumns, LB_SETSEL, TRUE, 1 );
// Column 'AltName' = index 2
::SendMessage( hWndColumns, LB_SETSEL, FALSE, 2 );
// Column 'Size' = index 3
::SendMessage( hWndColumns, LB_SETSEL, TRUE, 3 );
// Column 'Date' = index 4
::SendMessage( hWndColumns, LB_SETSEL, TRUE, 4 );
// Column 'Description' = index 5
::SendMessage( hWndColumns, LB_SETSEL, TRUE, 5 );
// SortColumn '(Type)' = index 1
::SendMessage( hWndSortCol, CB_SETCURSEL, 1, 0 );
// Sort Flags
::SendMessage( hWndHyperlink, BM_SETCHECK, TRUE, 0 );
::SendMessage( hWndICase, BM_SETCHECK, FALSE, 0 );
::SendMessage( hWndDescending, BM_SETCHECK, FALSE, 0 );
// Options
if ( ::SendMessage( hWndTag, WM_GETTEXTLENGTH, 0, 0 ) == 0 )
{ ::SendMessage( hWndTag, WM_SETTEXT, 0, (LPARAM)"10" ); }
if ( ::SendMessage( hWndTruncate, WM_GETTEXTLENGTH, 0, 0 ) == 0 )
{ ::SendMessage( hWndTruncate, WM_SETTEXT, 0, (LPARAM)"20" ); }
// Axiliary Files
::SendMessage( hWndHeader, BM_SETCHECK, TRUE, 0 );
::SendMessage( hWndFooter, BM_SETCHECK, TRUE, 0 );
::SendMessage( hWndDescription, BM_SETCHECK, TRUE, 0 );
// SizeFormat
SendMessage( GetDlgItem( hDlg, IDC_DECIMAL ), BM_SETCHECK, BST_UNCHECKED, 0 );
SendMessage( GetDlgItem( hDlg, IDC_ABBREV ), BM_SETCHECK, BST_CHECKED, 0 );
SendMessage( GetDlgItem( hDlg, IDC_FORMAT ), BM_SETCHECK, BST_UNCHECKED, 0 );
break;
/*
** Generic HTML index
*/
case 3:
// Column 'Type' = index 0
::SendMessage( hWndColumns, LB_SETSEL, FALSE, 0 );
// Column 'Name' = index 1
::SendMessage( hWndColumns, LB_SETSEL, TRUE, 1 );
// Column 'AltName' = index 2
::SendMessage( hWndColumns, LB_SETSEL, FALSE, 2 );
// Column 'Size' = index 3
::SendMessage( hWndColumns, LB_SETSEL, TRUE, 3 );
// Column 'Date' = index 4
::SendMessage( hWndColumns, LB_SETSEL, TRUE, 4 );
// Column 'Description' = index 5
::SendMessage( hWndColumns, LB_SETSEL, TRUE, 5 );
// SortColumn '(Type)' = index 1
::SendMessage( hWndSortCol,CB_SETCURSEL, 1, 0 );
// Sort Flags
::SendMessage( hWndHyperlink, BM_SETCHECK, FALSE, 0 );
::SendMessage( hWndICase, BM_SETCHECK, FALSE, 0 );
::SendMessage( hWndDescending, BM_SETCHECK, FALSE, 0 );
// Options
if ( ::SendMessage( hWndTag, WM_GETTEXTLENGTH, 0, 0 ) == 0 )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -