source: trunk/Lucide/gui/findDlg.cpp

Last change on this file was 563, checked in by Gregg Young, 5 years ago

Added "help" menu items and added context sensitive help to the dialogs. F1 brings up help most everywhere. Ticket #12 Prevent thumbnail creation on encrypted files. Make thumbnail optional globally and on a per file basis. Tickets #263 #267

File size: 8.3 KB
Line 
1/* ***** BEGIN LICENSE BLOCK *****
2 * Version: CDDL 1.0/LGPL 2.1
3 *
4 * The contents of this file are subject to the COMMON DEVELOPMENT AND
5 * DISTRIBUTION LICENSE (CDDL) Version 1.0 (the "License"); you may not use
6 * this file except in compliance with the License. You may obtain a copy of
7 * the License at http://www.sun.com/cddl/
8 *
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
13 *
14 * The Initial Developer of the Original Code is
15 * Eugene Romanenko, netlabs.org.
16 * Portions created by the Initial Developer are Copyright (C) 2006
17 * the Initial Developer. All Rights Reserved.
18 *
19 * Contributor(s):
20 *
21 * Alternatively, the contents of this file may be used under the terms of
22 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
23 * 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
25 * terms of the LGPL, and not to allow others to use your version of this file
26 * under the terms of the CDDL, indicate your decision by deleting the
27 * provisions above and replace them with the notice and other provisions
28 * 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
30 * or the LGPL.
31 *
32 * ***** END LICENSE BLOCK ***** */
33
34
35#include "os2all.h"
36
37#include <stdio.h>
38#include <string.h>
39
40#include "globals.h"
41#include "findDlg.h"
42#include "Lucide_res.h"
43#include "luutils.h"
44#include "messages.h"
45#include "Lucide.h"
46
47#define MAXSEARCHLENGTH 100
48
49FindDlg::FindDlg( HWND hWndFrame )
50{
51    hFrame        = hWndFrame;
52    searchString  = newstrdup( "" );
53    caseSensitive = false;
54    findBack = false;
55}
56
57FindDlg::~FindDlg()
58{
59    delete searchString;
60}
61
62ULONG FindDlg::showDialog()
63{
64    return WinDlgBox( HWND_DESKTOP, hFrame, findDlgProc,
65                      _hmod, IDD_FIND, this );
66}
67
68
69
70MRESULT EXPENTRY FindDlg::findDlgProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
71{
72    // This is a static method, so we don't know which instantiation we're
73    // dealing with. But we can get a pseudo-this from the parameter to
74    // WM_INITDLG, which we therafter store with the window and retrieve
75    // as follows:
76    FindDlg *_this = (FindDlg *)WinQueryWindowULong( hwnd, QWL_USER );
77
78    switch (msg)
79    {
80
81        // Dialog has just been created
82        case WM_INITDLG:
83        {
84            // Save the mp2 into our user data so that subsequent calls have
85            // access to the parent C++ object
86            WinSetWindowULong( hwnd, QWL_USER, (ULONG)mp2 );
87            _this = (FindDlg *)mp2;
88            localizeDialog( hwnd );
89            centerWindow( _this->hFrame, hwnd );
90
91            // setup the accelerators
92            WinSetAccelTable( hab, WinLoadAccelTable( hab, _hmod, IDA_ADDHELPACCEL ), hwnd );
93
94            WinSendDlgItemMsg( hwnd, IDC_FINDFIELD, EM_SETTEXTLIMIT,
95                               MPFROMSHORT( MAXSEARCHLENGTH ), MPVOID );
96            WinSetDlgItemText( hwnd, IDC_FINDFIELD, _this->searchString );
97            WinSendDlgItemMsg( hwnd, IDC_FINDFIELD, EM_SETSEL, MPFROM2SHORT( 0, MAXSEARCHLENGTH ), MPVOID );
98            WinCheckButton( hwnd, IDC_FINDMATCHCASE, _this->caseSensitive );
99            WinCheckButton( hwnd, IDC_FINDBACK, _this->findBack );
100
101
102            return (MRESULT)FALSE;
103        }
104
105        case WM_COMMAND:
106            switch (SHORT1FROMMP(mp1))
107            {
108                case DID_OK:
109                    {
110                        char buf[ MAXSEARCHLENGTH + 1 ];
111                        WinQueryDlgItemText( hwnd, IDC_FINDFIELD, sizeof( buf ), buf );
112                        delete _this->searchString;
113                        _this->searchString = newstrdup( buf );
114                        _this->caseSensitive = WinQueryButtonCheckstate( hwnd, IDC_FINDMATCHCASE );
115                        _this->findBack = WinQueryButtonCheckstate( hwnd, IDC_FINDBACK );
116                        WinDismissDlg( hwnd, DID_OK );
117                    }
118                    return (MRESULT)FALSE;
119
120                case DID_CANCEL:
121                    WinDismissDlg( hwnd, DID_CANCEL );
122                    return (MRESULT)FALSE;
123
124               case CM_HELP:
125                  if (Lucide::hwndHelp)
126                      WinSendMsg(Lucide::hwndHelp,HM_DISPLAY_HELP,
127                                 MPFROM2SHORT(108, 0), MPFROMSHORT(HM_RESOURCEID));
128                  return (MRESULT)FALSE;
129            };
130            return (MRESULT)FALSE;
131    }
132    return WinDefDlgProc( hwnd, msg, mp1, mp2 );
133}
134
135
136//
137// ------------------ GotoDlg ---------------------
138//
139
140GotoDlg::GotoDlg( HWND hWndFrame, long _pages, long _curpage )
141{
142    hFrame  = hWndFrame;
143    page    = -1;
144    pages   = _pages;
145    curpage = _curpage;
146}
147
148GotoDlg::~GotoDlg()
149{
150}
151
152ULONG GotoDlg::showDialog()
153{
154    return WinDlgBox( HWND_DESKTOP, hFrame, gotoDlgProc,
155                      _hmod, IDD_GOTOPAGE, this );
156}
157
158
159
160MRESULT EXPENTRY GotoDlg::gotoDlgProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
161{
162    // This is a static method, so we don't know which instantiation we're
163    // dealing with. But we can get a pseudo-this from the parameter to
164    // WM_INITDLG, which we therafter store with the window and retrieve
165    // as follows:
166    GotoDlg *_this = (GotoDlg *)WinQueryWindowULong( hwnd, QWL_USER );
167
168    switch (msg)
169    {
170
171        // Dialog has just been created
172        case WM_INITDLG:
173        {
174            // Save the mp2 into our user data so that subsequent calls have
175            // access to the parent C++ object
176            WinSetWindowULong( hwnd, QWL_USER, (ULONG)mp2 );
177            _this = (GotoDlg *)mp2;
178            localizeDialog( hwnd );
179            centerWindow( _this->hFrame, hwnd );
180
181            // setup the accelerators
182            WinSetAccelTable( hab, WinLoadAccelTable( hab, _hmod, IDA_ADDHELPACCEL ), hwnd );
183
184            char pgnum[ 32 ];
185
186            // set current page
187            snprintf(pgnum, sizeof(pgnum), "%d", _this->curpage);
188            WinSetDlgItemText(hwnd, IDC_PAGE, pgnum);
189
190            // set of pages
191            char *pgfrm = newstrdupL( GTP_OF );
192            snprintf( pgnum, sizeof( pgnum ), pgfrm, _this->pages );
193            delete pgfrm;
194            WinSetDlgItemText( hwnd, IDC_PAGES, pgnum );
195
196            // highlight the current page
197            WinSendDlgItemMsg( hwnd, IDC_PAGE, EM_SETSEL,
198                                      MPFROM2SHORT(0, 256), NULL);
199            // set the maximum length for current page
200            snprintf(pgnum, sizeof(pgnum), "%d", _this->pages);
201            WinSendDlgItemMsg( hwnd, IDC_PAGE, EM_SETTEXTLIMIT,
202                                      MPFROMSHORT((SHORT)strlen(pgnum)), NULL);
203
204            return (MRESULT)FALSE;
205        }
206
207        case WM_COMMAND:
208            switch (SHORT1FROMMP(mp1))
209            {
210                case DID_OK:
211                    {
212                        char szText[256];
213                        LONG newPage = 0;
214                        ULONG retLen = 0;
215                        retLen = WinQueryDlgItemText( hwnd, IDC_PAGE, sizeof(szText),
216                                            szText );
217
218                        if ( retLen > 0) {
219                                newPage = atol(szText);
220                                if (newPage > 0) {
221                                    _this->page = newPage;
222                                }
223                        }
224                        WinDismissDlg( hwnd, DID_OK );
225                    }
226                    return (MRESULT)FALSE;
227
228                case DID_CANCEL:
229                    WinDismissDlg( hwnd, DID_CANCEL );
230                    return (MRESULT)FALSE;
231
232                case CM_HELP:
233                  if (Lucide::hwndHelp)
234                      WinSendMsg(Lucide::hwndHelp,HM_DISPLAY_HELP,
235                                 MPFROM2SHORT(112, 0), MPFROMSHORT(HM_RESOURCEID));
236                  return (MRESULT)FALSE;
237            };
238            return (MRESULT)FALSE;
239    }
240    return WinDefDlgProc( hwnd, msg, mp1, mp2 );
241}
242
Note: See TracBrowser for help on using the repository browser.