source: trunk/Lucide/SOURCE/gui/findDlg.cpp @ 72

Last change on this file since 72 was 35, checked in by Eugene Romanenko, 16 years ago

added licence block to source files

File size: 4.0 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#define INCL_WIN
36#include <os2.h>
37
38#include "findDlg.h"
39#include "Lucide_res.h"
40#include "luutils.h"
41
42#define MAXSEARCHLENGTH 100
43
44FindDlg::FindDlg( HWND hWndFrame )
45{
46    hFrame        = hWndFrame;
47    searchString  = newstrdup( "" );
48    caseSensitive = false;
49}
50
51FindDlg::~FindDlg()
52{
53    delete searchString;
54}
55
56ULONG FindDlg::showDialog()
57{
58    return WinDlgBox( HWND_DESKTOP, hFrame, findDlgProc,
59                      NULLHANDLE, IDD_FIND, this );
60}
61
62
63
64MRESULT EXPENTRY FindDlg::findDlgProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
65{
66    // This is a static method, so we don't know which instantiation we're
67    // dealing with. But we can get a pseudo-this from the parameter to
68    // WM_INITDLG, which we therafter store with the window and retrieve
69    // as follows:
70    FindDlg *_this = (FindDlg *)WinQueryWindowULong( hwnd, QWL_USER );
71
72    switch (msg)
73    {
74
75        // Dialog has just been created
76        case WM_INITDLG:
77        {
78            // Save the mp2 into our user data so that subsequent calls have
79            // access to the parent C++ object
80            WinSetWindowULong( hwnd, QWL_USER, (ULONG)mp2 );
81            _this = (FindDlg *)mp2;
82            localizeDialog( hwnd );
83            centerWindow( _this->hFrame, hwnd );
84
85            WinSendDlgItemMsg( hwnd, IDC_FINDFIELD, EM_SETTEXTLIMIT,
86                               MPFROMSHORT( MAXSEARCHLENGTH ), MPVOID );
87            WinSetDlgItemText( hwnd, IDC_FINDFIELD, _this->searchString );
88            WinCheckButton( hwnd, IDC_FINDMATCHCASE, _this->caseSensitive );
89
90            return (MRESULT)FALSE;
91        }
92
93        case WM_COMMAND:
94            switch (SHORT1FROMMP(mp1))
95            {
96                case DID_OK:
97                    {
98                        char buf[ MAXSEARCHLENGTH + 1 ];
99                        WinQueryDlgItemText( hwnd, IDC_FINDFIELD, sizeof( buf ), buf );
100                        delete _this->searchString;
101                        _this->searchString = newstrdup( buf );
102                        _this->caseSensitive = WinQueryButtonCheckstate( hwnd, IDC_FINDMATCHCASE );
103                        WinDismissDlg( hwnd, DID_OK );
104                    }
105                    return (MRESULT)FALSE;
106
107                case DID_CANCEL:
108                    WinDismissDlg( hwnd, DID_CANCEL );
109                    return (MRESULT)FALSE;
110            };
111            return (MRESULT)FALSE;
112    }
113    return WinDefDlgProc( hwnd, msg, mp1, mp2 );
114}
115
116
Note: See TracBrowser for help on using the repository browser.