1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: stest.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
33 #include <svtools/svmedit.hxx>
36 #ifndef _SV_BUTTON_HXX //autogen
37 #include <vcl/button.hxx>
39 #include <vcl/wrkwin.hxx>
40 #include <vcl/fixed.hxx>
41 #include <vcl/svapp.hxx>
43 class MyApp
: public Application
49 class SearchWindow
: public WorkWindow
52 FixedText aFT1
, aFT2
, aFT3
;
53 MultiLineEdit aEText
, aESrch
;
54 RadioButton aModeN
, aModeR
, aModeL
;
60 DECL_LINK( ClickHdl
, Button
* );
63 // --- SearchWindow::SearchWindow() ------------------------------------
65 SearchWindow::SearchWindow() :
66 WorkWindow( NULL
, WinBits( WB_APP
| WB_STDWORK
)),
67 aPB( this, WinBits( 0 )),
68 aFT1( this, WinBits( 0 )),
69 aFT2( this, WinBits( 0 )),
70 aFT3( this, WinBits( 0 )),
71 aEText( this, WinBits( WB_BORDER
)),
72 aESrch( this, WinBits( WB_BORDER
)),
73 aModeN( this, WinBits( 0 )),
74 aModeR( this, WinBits( 0 )),
75 aModeL( this, WinBits( 0 )),
78 aPB
.SetClickHdl( LINK( this, SearchWindow
, ClickHdl
));
79 aModeN
.SetClickHdl( LINK( this, SearchWindow
, ClickHdl
));
80 aModeR
.SetClickHdl( LINK( this, SearchWindow
, ClickHdl
));
81 aModeL
.SetClickHdl( LINK( this, SearchWindow
, ClickHdl
));
83 SetMapMode( MapMode( MAP_APPFONT
));
84 SetSizePixel( LogicToPixel( Size( 300, 180 ) ) );
86 aEText
.SetPosSizePixel( LogicToPixel( Point( 0, 22 )), LogicToPixel(Size( 270, 32 )) );
87 aFT1
.SetPosSizePixel( LogicToPixel( Point( 0, 10 )), LogicToPixel(Size( 18, 11 )) );
88 aFT2
.SetPosSizePixel( LogicToPixel( Point( 0, 60 )), LogicToPixel(Size( 24, 10 )) );
89 aESrch
.SetPosSizePixel( LogicToPixel( Point( 0, 70 )), LogicToPixel(Size( 270, 24 )) );
90 aPB
.SetPosSizePixel( LogicToPixel( Point( 223, 139 )), LogicToPixel(Size( 48, 12 )) );
91 aFT3
.SetPosSizePixel( LogicToPixel( Point( 0, 104 )), LogicToPixel(Size( 270, 15 )) );
92 aModeN
.SetPosSizePixel( LogicToPixel( Point( 5, 116 ) ), LogicToPixel( Size( 40, 12 ) ) );
93 aModeR
.SetPosSizePixel( LogicToPixel( Point( 5, 126 ) ), LogicToPixel( Size( 40, 12 ) ) );
94 aModeL
.SetPosSizePixel( LogicToPixel( Point( 5, 136 ) ), LogicToPixel( Size( 40, 12 ) ) );
106 aFT3
.SetText( "gefunden:" );
107 aFT1
.SetText( "Text:" );
108 aFT2
.SetText( "Suche:" );
109 aPB
.SetText( "starte Suche" );
110 aModeN
.SetText( "normal" );
111 aModeR
.SetText( "RegExp" );
112 aModeL
.SetText( "LevDis" );
114 SetText( "Such-Demo" );
118 // --- SearchWindow::SearchSelectHdl() ---------------------------------
120 IMPL_LINK( SearchWindow
, ClickHdl
, Button
*, pButton
)
122 if( pButton
== &aPB
)
124 String
sText( aEText
.GetText() );
125 String
sSrch( aESrch
.GetText() );
127 /* InfoBox( this, String( "T: " ) + sText +
128 String( "\nS: " ) + sSrch ).Execute();
131 USHORT nStt
= 0, nEnd
= sText
.Len();
134 aParam
.SetSrchStr( sSrch
);
135 SearchText
aSrchText( aParam
, GetpApp()->GetAppInternational() );
136 bRet
= aSrchText
.SearchFrwrd( sText
, &nStt
, &nEnd
);
138 // BOOL SearchBkwrd( const String &rStr, USHORT* pStart, USHORT* pEnde );
141 String
sFound( "gefunden" );
143 sFound
.Insert( "nicht ", 0 );
154 sFound
+= sText
.Copy( nStt
, nEnd
- nStt
+1 );
158 aFT3
.SetText( sFound
);
160 else if( pButton
== &aModeN
)
162 aParam
.SetSrchType( SearchParam::SRCH_NORMAL
);
164 else if( pButton
== &aModeR
)
166 aParam
.SetSrchType( SearchParam::SRCH_REGEXP
);
168 else if( pButton
== &aModeL
)
170 aParam
.SetSrchType( SearchParam::SRCH_LEVDIST
);
176 // --- MyApp::Main() -----------------------------------------------
180 SearchWindow
* pSearchWindow
= new SearchWindow
;
181 pSearchWindow
->Show();
183 delete pSearchWindow
;
187 // --- aMyApp ------------------------------------------------------