Ignore:
Timestamp:
Jul 25, 2006, 5:22:20 PM (15 years ago)
Author:
Eugene Romanenko
Message:

'Go to page' dialog, some play with djvu plugin.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Lucide/SOURCE/gui/findDlg.cpp

    r35 r87  
    2222 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
    2323 * in which case the provisions of the LGPL are applicable instead of those
    24  * above. If you wish to allow use of your version of this file only under the 
     24 * above. If you wish to allow use of your version of this file only under the
    2525 * terms of the LGPL, and not to allow others to use your version of this file
    2626 * under the terms of the CDDL, indicate your decision by deleting the
    2727 * provisions above and replace them with the notice and other provisions
    2828 * required by the LGPL. If you do not delete the provisions above, a recipient
    29  * may use your version of this file under the terms of any one of the CDDL 
     29 * may use your version of this file under the terms of any one of the CDDL
    3030 * or the LGPL.
    3131 *
     
    3535#define INCL_WIN
    3636#include <os2.h>
     37
     38#include <stdio.h>
    3739
    3840#include "findDlg.h"
    3941#include "Lucide_res.h"
    4042#include "luutils.h"
     43#include "messages.h"
    4144
    4245#define MAXSEARCHLENGTH 100
     
    115118
    116119
     120//
     121// ------------------ GotoDlg ---------------------
     122//
     123
     124GotoDlg::GotoDlg( HWND hWndFrame, long _pages, long _curpage )
     125{
     126    hFrame  = hWndFrame;
     127    page    = -1;
     128    pages   = _pages;
     129    curpage = _curpage;
     130}
     131
     132GotoDlg::~GotoDlg()
     133{
     134}
     135
     136ULONG GotoDlg::showDialog()
     137{
     138    return WinDlgBox( HWND_DESKTOP, hFrame, gotoDlgProc,
     139                      NULLHANDLE, IDD_GOTOPAGE, this );
     140}
     141
     142
     143
     144MRESULT EXPENTRY GotoDlg::gotoDlgProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
     145{
     146    // This is a static method, so we don't know which instantiation we're
     147    // dealing with. But we can get a pseudo-this from the parameter to
     148    // WM_INITDLG, which we therafter store with the window and retrieve
     149    // as follows:
     150    GotoDlg *_this = (GotoDlg *)WinQueryWindowULong( hwnd, QWL_USER );
     151
     152    switch (msg)
     153    {
     154
     155        // Dialog has just been created
     156        case WM_INITDLG:
     157        {
     158            // Save the mp2 into our user data so that subsequent calls have
     159            // access to the parent C++ object
     160            WinSetWindowULong( hwnd, QWL_USER, (ULONG)mp2 );
     161            _this = (GotoDlg *)mp2;
     162            localizeDialog( hwnd );
     163            centerWindow( _this->hFrame, hwnd );
     164
     165            WinSendDlgItemMsg( hwnd, IDC_PAGE, SPBM_SETLIMITS,
     166                               MPFROMLONG( _this->pages ), MPFROMLONG( 1 ) );
     167            WinSendDlgItemMsg( hwnd, IDC_PAGE, SPBM_SETCURRENTVALUE,
     168                               MPFROMLONG( _this->curpage ), MPVOID );
     169            char *pgfrm = newstrdupL( GTP_OF );
     170            char pgnum[ 32 ];
     171            snprintf( pgnum, sizeof( pgnum ), pgfrm, _this->pages );
     172            delete pgfrm;
     173            WinSetDlgItemText( hwnd, IDC_PAGES, pgnum );
     174            return (MRESULT)FALSE;
     175        }
     176
     177        case WM_COMMAND:
     178            switch (SHORT1FROMMP(mp1))
     179            {
     180                case DID_OK:
     181                    {
     182                        LONG spbmValue = 0;
     183                        BOOL rc = (BOOL)WinSendDlgItemMsg( hwnd, IDC_PAGE, SPBM_QUERYVALUE,
     184                                            MPFROMP( &spbmValue ),
     185                                            MPFROM2SHORT( 0, SPBQ_UPDATEIFVALID ) );
     186
     187                        if ( rc && ( spbmValue > 0 ) ) {
     188                            _this->page = spbmValue;
     189                        }
     190                        WinDismissDlg( hwnd, DID_OK );
     191                    }
     192                    return (MRESULT)FALSE;
     193
     194                case DID_CANCEL:
     195                    WinDismissDlg( hwnd, DID_CANCEL );
     196                    return (MRESULT)FALSE;
     197            };
     198            return (MRESULT)FALSE;
     199    }
     200    return WinDefDlgProc( hwnd, msg, mp1, mp2 );
     201}
     202
Note: See TracChangeset for help on using the changeset viewer.