]>
git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/modules/lseditor/finddlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Contrib. demo
4 // Author: Aleksandras Gluchovas
8 // Copyright: (c) Aleksandars Gluchovas
9 // Licence: GNU General Public License
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx/wx.h".
13 #include "wx/wxprec.h"
25 /***** Implementation for class wxFindTextDialog *****/
27 //#define wxID_OK 3453453
29 BEGIN_EVENT_TABLE( wxFindTextDialog
, wxDialog
)
31 // FIXME:: why OnOk() is not called??
32 //EVT_BUTTON( wxID_OK, wxFindTextDialog::OnOK )
34 EVT_CHAR_HOOK(wxFindTextDialog::OnKeyHook
)
38 wxString
wxFindTextDialog::mLastExpr
;
39 bool wxFindTextDialog::mMatchCase
= TRUE
;
40 bool wxFindTextDialog::mMatchWord
= FALSE
;
41 StrListT
wxFindTextDialog::mExprList
;
43 // FIXME:: workaround for mystic. crashes wiht MSDev4.0
45 static wxComboBox
* __gpCombo
= NULL
;
47 wxFindTextDialog::wxFindTextDialog( wxWindow
* parent
, const string
& expr
)
49 : wxDialog( parent
, -1, "Find",
50 wxDefaultPosition
, wxSize( 335, 130 ),
51 wxDIALOG_MODAL
| wxCAPTION
| wxTAB_TRAVERSAL
|
52 wxDEFAULT_DIALOG_STYLE
61 wxStaticText
* pStatic
=
62 new wxStaticText( this, -1, "Fi&nd what:",
63 wxPoint( leftMargin
, inputY
) );
65 int checkY
= inputY
+ 25;
67 mpWordCheck
= new wxCheckBox( this, -1, "Match &whole word only",
68 wxPoint( leftMargin
, checkY
) );
70 mpCaseCheck
= new wxCheckBox( this, -1, "Match &case",
71 wxPoint( leftMargin
, checkY
+ 20 ) );
73 mpCaseCheck
->SetValue( mMatchCase
);
74 mpWordCheck
->SetValue( mMatchWord
);
76 int btnX
= inputWidth
+ leftMargin
+ 23;
77 int btnY
= inputY
- 4;
79 wxSize
btnSize( 70, 25 );
81 wxButton
* pOkBtn
= new wxButton( this, wxID_OK
, "&Find",
82 wxPoint( btnX
, btnY
), btnSize
);
84 wxButton
* pCancelBtn
= new wxButton( this, wxID_CANCEL
, "&Cancel",
85 wxPoint( btnX
, btnY
+ 10 + btnSize
.y
), btnSize
);
87 __gpCombo
= new wxComboBox( this, -1, mLastExpr
,
88 wxPoint( leftMargin
+ 60, inputY
- 2 ),
89 wxSize( inputWidth
- 50, 20 ) );
91 for( size_t i
= 0; i
!= mExprList
.size(); ++i
)
93 __gpCombo
->Append( mExprList
[i
] );
96 __gpCombo
->SetFocus();
101 void wxFindTextDialog::SetExpr( const wxString
& expr
)
104 __gpCombo
->SetValue( mLastExpr
);
108 wxComboBox
* wxFindTextDialog::GetCombo()
113 bool wxFindTextDialog::TransferDataFromWindow()
115 mLastExpr
= GetCombo()->GetValue();
116 mMatchCase
= mpCaseCheck
->GetValue();
117 mMatchWord
= mpWordCheck
->GetValue();
119 if ( mLastExpr
!= "" )
121 for( size_t i
= 0; i
!= mExprList
.size(); ++i
)
123 if ( mExprList
[i
] == mLastExpr
)
128 if ( mExprList
.size() > 20 )
130 mExprList
.pop_back();
132 mExprList
.push_back( mLastExpr
);
137 void wxFindTextDialog::OnKeyHook( wxKeyEvent
& event
)
139 if ( event
.m_keyCode
== WXK_RETURN
)
141 TransferDataFromWindow();