home *** CD-ROM | disk | FTP | other *** search
- Save Format v1.3
- @begin ClassFile "PreviewFileDialog"
- Exported 0;
-
- @begin-code BaseClassList
-
- public WFileDialog
-
- @end-code;
-
- @begin UserFunction "PreviewFileDialog()"
- GencodeSrcLine 16;
- FunctionName "PreviewFileDialog::PreviewFileDialog()";
- @end;
-
- @begin UserFunction "Prototype for PreviewFileDialog()"
- Private 1;
- GencodeSrcLine 24;
- FunctionName "PreviewFileDialog::Prototype for PreviewFileDialog()";
- @end;
-
- @begin UserFunction "~PreviewFileDialog()"
- GencodeSrcLine 31;
- FunctionName "PreviewFileDialog::~PreviewFileDialog()";
- @end;
-
- @begin UserFunction "Prototype for ~PreviewFileDialog()"
- Private 1;
- GencodeSrcLine 26;
- FunctionName "PreviewFileDialog::Prototype for ~PreviewFileDialog()";
- @end;
-
- @begin UserFunction "handleCreate( WObject *, WEventData * )"
- Private 1;
- GencodeSrcLine 44;
- FunctionName "PreviewFileDialog::handleCreate( WObject *, WEventData * )";
- @end;
-
- @begin UserFunction "Prototype for handleCreate( WObject *, WEventData * )"
- Private 1;
- GencodeSrcLine 28;
- FunctionName "PreviewFileDialog::Prototype for handleCreate( WObject *, WEventData * )";
- @end;
-
- @begin UserFunction "handleChange( WObject *, WEventData * )"
- Private 1;
- GencodeSrcLine 91;
- FunctionName "PreviewFileDialog::handleChange( WObject *, WEventData * )";
- @end;
-
- @begin UserFunction "Prototype for handleChange( WObject *, WEventData * )"
- Private 1;
- GencodeSrcLine 30;
- FunctionName "PreviewFileDialog::Prototype for handleChange( WObject *, WEventData * )";
- @end;
-
- @begin UserFunction "handleMessage( WCommonDialog *, WMessageHookEventData * )"
- Private 1;
- GencodeSrcLine 117;
- FunctionName "PreviewFileDialog::handleMessage( WCommonDialog *, WMessageHookEventData * )";
- @end;
-
- @begin UserFunction "Prototype for handleMessage( WCommonDialog *, WMessageHookEventData * )"
- Private 1;
- GencodeSrcLine 32;
- FunctionName "PreviewFileDialog::Prototype for handleMessage( WCommonDialog *, WMessageHookEventData * )";
- @end;
-
- @begin HPPPrefixBlock
- @begin-code HPPPrefix
-
- // Declarations added here will be included at the top of the .HPP file
-
- @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"
-
- @end-code;
- GencodeSrcLine 11;
- @end;
-
- @begin ClassContentsBlock
- @begin-code ClassContents
-
- private:
- WPictureBox *_previewBox;
- WRect _previewRect;
- WLabel *_previewLabel;
-
- @end-code;
- GencodeSrcLine 18;
- @end;
-
- @begin-code GeneratedClassContents
-
-
- @end-code;
-
- @begin-code Code "PreviewFileDialog::PreviewFileDialog()"
-
- @@CLASSNAME@::@CLASSNAME@()
- {
- _previewBox = NULL;
- _previewLabel = NULL;
-
- SetEventHandler( WCreateEvent, this,
- (WEventHandler) handleCreate );
- if( GetStyle() & WFDSExplorer ) {
- SetEventHandler( WChangeEvent, this,
- (WEventHandler) handleChange );
- } else {
- SetEventHandler( WMessageHookEvent, this,
- (WEventHandler) handleMessage );
- }
- }
-
- @end-code;
-
- @begin-code Code "PreviewFileDialog::Prototype for PreviewFileDialog()"
-
- public:
- @@CLASSNAME@();
-
- @end-code;
-
- @begin-code Code "PreviewFileDialog::~PreviewFileDialog()"
-
- @@CLASSNAME@::~@CLASSNAME@()
- {
- /* Free memory associated with the preview box
- */
- if( _previewLabel ) {
- delete _previewLabel;
- _previewLabel = NULL;
- }
- if( _previewBox ) {
- delete _previewBox;
- _previewBox = NULL;
- }
- }
-
- @end-code;
-
- @begin-code Code "PreviewFileDialog::Prototype for ~PreviewFileDialog()"
-
- public:
- ~@CLASSNAME@();
-
- @end-code;
-
- @begin-code Code "PreviewFileDialog::handleCreate( WObject *, WEventData * )"
-
- WBool @CLASSNAME@::handleCreate( WObject *, WEventData * )
- {
- WDialog *dlg;
- WRect r;
- WFont font;
- float hDLUToPixels; // horizontal dialog units -> pixels conversion factor
- float vDLUToPixels; // vertical dialog units -> pixels conversion factor
-
- dlg = GetDialog();
- font = dlg->GetFont();
- hDLUToPixels = WApplication::GetDialogBaseWidth( font );
- vDLUToPixels = WApplication::GetDialogBaseHeight( font );
-
- /* Create preview box
- */
- _previewBox = new WPictureBox;
- _previewBox->Create( dlg );
- _previewBox->ChangeStyle( WSSCenterImage, TRUE );
- _previewBox->ChangeExtendedStyle( WSExClientEdge, TRUE );
-
- /* Size the picture box (all done in dialog units)
- */
- r.x = 280.0 * hDLUToPixels;
- r.y = 20.0 * vDLUToPixels;
- r.w = 68.0 * hDLUToPixels;
- r.h = 85.0 * vDLUToPixels;
- _previewBox->SetRectangle( r );
- _previewRect = r;
-
- /* Put a label over the preview window
- */
- r.x = 280.0 * hDLUToPixels;
- r.y = 9.0 * vDLUToPixels;
- r.w = 68.0 * hDLUToPixels;
- r.h = 12.0 * vDLUToPixels;
- _previewLabel = new WLabel;
- _previewLabel->Create( dlg, r, "Preview:" );
-
- /* Resize the dialog and center it.
- */
- r = dlg->GetRectangle( TRUE );
- r.w = _previewRect.x + _previewRect.w + 7.0 * hDLUToPixels;
- dlg->SetRectangle( r );
- dlg->Center();
-
- return FALSE;
- }
-
- @end-code;
-
- @begin-code Code "PreviewFileDialog::Prototype for handleCreate( WObject *, WEventData * )"
-
- private:
- WBool handleCreate( WObject *, WEventData * );
-
- @end-code;
-
- @begin-code Code "PreviewFileDialog::handleChange( WObject *, WEventData * )"
-
- WBool @CLASSNAME@::handleChange( WObject *, WEventData * )
- {
- // The definition of CDM_GETFILEPATH taken from windows.h
- #define CDM_GETFILEPATH 1125
-
- WDialog *dlg;
- WLong rc;
- WBitmap bmp;
- char buffer[ _MAX_PATH ];
- WMessage msg( CDM_GETFILEPATH, _MAX_PATH, (WDWord)buffer );
-
-
- /* Get the filename selected in the dialog. We do this by sending
- a message to the dialog.
- */
- dlg = GetDialog();
- rc = dlg->SendMessage( msg );
- if( _previewBox != NULL && rc > 0 ) {
-
- /* Update the preview box
- */
- bmp.Create( buffer, FALSE );
- _previewBox->SetBitmap( bmp );
- }
- return FALSE;
- }
-
- @end-code;
-
- @begin-code Code "PreviewFileDialog::Prototype for handleChange( WObject *, WEventData * )"
-
- private:
- WBool handleChange( WObject *, WEventData * );
-
- @end-code;
-
- @begin-code Code "PreviewFileDialog::handleMessage( WCommonDialog *, WMessageHookEventData * )"
-
- WBool @CLASSNAME@::handleMessage( WCommonDialog *, WMessageHookEventData *event )
- {
- int controlID, notifyCode, index;
-
- /* NOTE: You don't get WChangeEvents if you're not using the
- explorer style of dialog, so we have to watch for
- messages from the files list box explicitly.
- */
- if( event->message.msg == 0x0111 /* WM_COMMAND */ ) {
- notifyCode = event->message.wParam >> 16;
- controlID = event->message.wParam & 0xffff;
- if( controlID == 0x460 /* control ID of the list box */ &&
- notifyCode == 0x1 /* LBN_SELCHANGE */ ) {
- WListBox listBox;
- WString fileName;
- WBitmap bmp;
-
- listBox.AttachToWindow( (WWindowHandle)(event->message.lParam), FALSE );
- index = listBox.GetSelected();
- if( index != -1 ) {
- fileName = listBox.GetText( index );
- bmp.Create( fileName, FALSE );
- _previewBox->SetBitmap( bmp );
- }
- listBox.DetachFromWindow();
- }
- }
- return FALSE;
- }
-
- @end-code;
-
- @begin-code Code "PreviewFileDialog::Prototype for handleMessage( WCommonDialog *, WMessageHookEventData * )"
-
- private:
- WBool handleMessage( WCommonDialog *, WMessageHookEventData * );
-
- @end-code;
- @end;
-