Ignore:
Timestamp:
May 23, 2006, 6:30:04 PM (15 years ago)
Author:
Eugene Romanenko
Message:

remember nav pane position/visibility

File:
1 edited

Legend:

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

    r25 r26  
    2323
    2424
     25#define ID_SPLITTER 1
     26
    2527const char *appName = "Lucide";
    26 const char *fwp = "FrameWindowPos";
    27 const char *lvd = "LastViewedDir";
     28const char *fwp     = "FrameWindowPos";
     29const char *lvd     = "LastViewedDir";
     30const char *splpos  = "SplitterPos";
     31const char *showind = "ShowIndex";
    2832
    2933
     
    3438HWND  hWndMenu;
    3539HWND  hToolBar;
     40HWND  hVertSplitter;
    3641
    3742Environment    *ev        = somGetGlobalEnvironment();
     
    4247FindDlg        *findDlg   = NULL;
    4348
    44 bool Lucide::dontSwitchPage = false;
     49bool  Lucide::dontSwitchPage = false;
     50SHORT Lucide::splitterPos    = 100;
     51bool  Lucide::showIndex      = true;
    4552
    4653PFNWP pOldSplProc;
     
    5158}
    5259
    53 static void setOfPages( long pages )
     60void Lucide::setOfPages( long pages )
    5461{
    5562    char *pgfrm = newstrdupL( TB_PAGENUM );
     
    8188}
    8289
    83 void enableZoomMenus()
     90void Lucide::enableZoomMenus()
    8491{
    8592    BOOL scalable = doc->isScalable( ev );
     
    97104
    98105
    99 void setZoomChecks( SHORT cmd, SHORT cbind, double zoom )
     106void Lucide::setZoomChecks( SHORT cmd, SHORT cbind, double zoom )
    100107{
    101108    if ( cmd != -1 )
     
    192199        WinEnableMenuItem( hWndMenu, CM_ROTATE90CW, FALSE );
    193200        WinEnableMenuItem( hWndMenu, CM_ROTATE90CCW, FALSE );
    194         WinEnableMenuItem( hWndMenu, CM_NAVPANE, FALSE );
    195         WinSendMsg( hToolBar, TBM_ENABLEITEM, MPFROMSHORT(CM_NAVPANE), (MPARAM)FALSE );
     201        //WinEnableMenuItem( hWndMenu, CM_NAVPANE, FALSE );
     202        //WinSendMsg( hToolBar, TBM_ENABLEITEM, MPFROMSHORT(CM_NAVPANE), (MPARAM)FALSE );
    196203        WinEnableMenuItem( hWndMenu, CM_SINGLEPAGE, FALSE );
    197204        WinEnableMenuItem( hWndMenu, CM_CONTINUOUS, FALSE );
     
    237244    docViewer->setDocument( _doc );
    238245    indexWin->setDocument( _doc );
    239     Lucide::checkMenus();
     246    checkMenus();
    240247}
    241248
     
    286293            char *error = NULL;
    287294            if ( d->loadFile( ev, (char *)fn, NULL, &error ) ) {
     295                docViewer->close();
    288296                delete doc;
    289297                doc = d;
    290                 Lucide::setDocument( doc );
     298                setDocument( doc );
    291299            }
    292300            else
     
    335343}
    336344
     345void Lucide::checkNavpane()
     346{
     347    if ( Lucide::showIndex )
     348    {
     349        WinSendMsg( hWndMenu, MM_SETITEMATTR, MPFROM2SHORT( CM_NAVPANE, TRUE ),
     350                MPFROM2SHORT( MIA_CHECKED, MIA_CHECKED ) );
     351        WinSendMsg( hToolBar, TBM_SETCHECK, MPFROMSHORT( CM_NAVPANE ), (MPARAM)TRUE );
     352    }
     353    else
     354    {
     355        WinSendMsg( hWndMenu, MM_SETITEMATTR, MPFROM2SHORT( CM_NAVPANE, TRUE ),
     356                MPFROM2SHORT( MIA_CHECKED, FALSE ) );
     357        WinSendMsg( hToolBar, TBM_SETCHECK, MPFROMSHORT( CM_NAVPANE ), (MPARAM)FALSE );
     358    }
     359}
    337360
    338361static MRESULT EXPENTRY splProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
     
    341364    switch ( msg )
    342365    {
     366        case WM_CONTROL:
     367        {
     368            if ( ( SHORT1FROMMP( mp1 ) == ID_SPLITTER ) &&
     369                 ( SHORT2FROMMP( mp1 ) == SBN_POSITIONCHANGED ) )
     370            {
     371                SHORT pos = SHORT1FROMMP( mp2 );
     372                if ( pos > 0 ) {
     373                    Lucide::splitterPos = pos;
     374                    Lucide::showIndex = true;
     375                }
     376                else {
     377                    Lucide::showIndex = false;
     378                }
     379                Lucide::checkNavpane();
     380            }
     381        }
     382        break;
    343383
    344384        case WM_COMMAND:
     
    433473                case CM_CONTINUOUS:
    434474                    Lucide::setViewMode( Continuous );
     475                    return (MRESULT)FALSE;
     476
     477                case CM_NAVPANE:
     478                    {
     479                        Lucide::showIndex = !Lucide::showIndex;
     480                        Lucide::checkNavpane();
     481                        WinSendMsg( hVertSplitter, SBM_SETSPLITTERPOS,
     482                            MPFROMSHORT( Lucide::showIndex ? Lucide::splitterPos : 0 ), MPVOID );
     483                    }
    435484                    return (MRESULT)FALSE;
    436485            }
     
    476525
    477526    // Vertical splitter and his windows - Index and Document view
    478     HWND hVertSplitter = WinCreateWindow( hWndFrame, WC_ER_SPLITTER, "",
    479                                           WS_VISIBLE | SBS_VSPLIT,
    480                                           0, 0, 0, 0, hWndFrame, HWND_TOP,
    481                                           0, NULL, NULL );
     527    hVertSplitter = WinCreateWindow( hWndFrame, WC_ER_SPLITTER, "",
     528                                     WS_VISIBLE | SBS_VSPLIT,
     529                                     0, 0, 0, 0, hWndFrame, HWND_TOP,
     530                                     ID_SPLITTER, NULL, NULL );
    482531
    483532    indexWin = new IndexWindow( hab, hWndFrame );
     
    489538    WinSendMsg( hVertSplitter, SBM_SETWINDOWS,
    490539                MPFROMHWND( indexWin->getHWND() ), MPFROMHWND( docViewer->getHWND() ) );
    491     WinSendMsg( hVertSplitter, SBM_SETSPLITTERPOS, MPFROMSHORT( 80 ), MPVOID );
     540    Lucide::splitterPos = PrfQueryProfileInt( HINI_USERPROFILE, appName, splpos, Lucide::splitterPos );
     541    Lucide::showIndex = PrfQueryProfileInt( HINI_USERPROFILE, appName, showind, Lucide::showIndex );
     542    WinSendMsg( hVertSplitter, SBM_SETSPLITTERPOS,
     543                MPFROMSHORT( Lucide::showIndex ? Lucide::splitterPos : 0 ), MPVOID );
    492544
    493545    // Horizontal splitter and its windows - Toolbar and Vertical splitter
     
    513565    }
    514566
     567    Lucide::checkNavpane();
     568
    515569    // ®ª § âì ®ª­® ¯à®£à ¬¬ë
    516570    if ( !PMRestoreWindowPos( NULL, appName, fwp, hWndFrame,
     
    526580    }
    527581
    528     if ( WinIsWindow( hab, hWndFrame ) ) {
     582    if ( WinIsWindow( hab, hWndFrame ) )
     583    {
     584        char valbuf[ 3 ] = "";
     585        PrfWriteProfileString( HINI_USERPROFILE, appName, splpos,
     586                               itoa( Lucide::splitterPos, valbuf, 10 ) );
     587        PrfWriteProfileString( HINI_USERPROFILE, appName, showind,
     588                               itoa( Lucide::showIndex, valbuf, 10 ) );
    529589        PMStoreWindowPos( NULL, appName, fwp, hWndFrame );
    530590    }
Note: See TracChangeset for help on using the changeset viewer.