Code::Blocks
SVN r11506
sdk
confirmreplacedlg.cpp
Go to the documentation of this file.
1
/*
2
* This file is part of the Code::Blocks IDE and licensed under the GNU Lesser General Public License, version 3
3
* http://www.gnu.org/licenses/lgpl-3.0.html
4
*
5
* $Revision: 7294 $
6
* $Id: confirmreplacedlg.cpp 7294 2011-07-26 12:52:57Z tpetrov $
7
* $HeadURL: https://svn.code.sf.net/p/codeblocks/code/trunk/src/sdk/confirmreplacedlg.cpp $
8
*/
9
10
#include "
sdk_precomp.h
"
11
12
#ifndef CB_PRECOMP
13
#include <
wx/xrc/xmlres.h
>
14
#include <
wx/stattext.h
>
15
#include <
wx/settings.h
>
16
17
#include "
cbeditor.h
"
18
#endif
19
#include "
cbstyledtextctrl.h
"
20
21
#include "
confirmreplacedlg.h
"
22
23
BEGIN_EVENT_TABLE(
ConfirmReplaceDlg
,
wxScrollingDialog
)
24
EVT_BUTTON(XRCID(
"btnYes"
),
ConfirmReplaceDlg::OnYes
)
25
EVT_BUTTON(XRCID(
"btnNo"
),
ConfirmReplaceDlg::OnNo
)
26
EVT_BUTTON(XRCID(
"btnAllInFile"
),
ConfirmReplaceDlg::OnAllInFile
)
27
EVT_BUTTON(XRCID(
"btnSkipFile"
),
ConfirmReplaceDlg::OnSkipFile
)
28
EVT_BUTTON(XRCID(
"btnAll"
),
ConfirmReplaceDlg::OnAll
)
29
EVT_BUTTON(XRCID(
"btnCancel"
),
ConfirmReplaceDlg::OnCancel
)
30
END_EVENT_TABLE()
31
32
ConfirmReplaceDlg
::
ConfirmReplaceDlg
(
wxWindow
* parent,
bool
replaceInFiles, const
wxString
& label)
33
{
34
if
(replaceInFiles)
35
wxXmlResource::Get
()->
LoadObject
(
this
, parent,
_T
(
"dlgConfirmReplaceMultiple"
),
_T
(
"wxScrollingDialog"
));
36
else
37
wxXmlResource::Get
()->
LoadObject
(
this
, parent,
_T
(
"dlgConfirmReplace"
),
_T
(
"wxScrollingDialog"
));
38
XRCCTRL(*
this
,
"lblMessage"
,
wxStaticText
)->SetLabel(label);
39
this->SetEscapeId(XRCID(
"btnCancel"
));
40
}
41
42
ConfirmReplaceDlg::~ConfirmReplaceDlg
()
43
{
44
}
45
46
void
ConfirmReplaceDlg::OnYes
(
wxCommandEvent
& WXUNUSED(event))
47
{
48
EndModal
(
crYes
);
49
}
50
51
void
ConfirmReplaceDlg::OnNo
(
wxCommandEvent
& WXUNUSED(event))
52
{
53
EndModal
(
crNo
);
54
}
55
56
void
ConfirmReplaceDlg::OnAllInFile
(
wxCommandEvent
& WXUNUSED(event))
57
{
58
EndModal
(
crAllInFile
);
59
}
60
61
void
ConfirmReplaceDlg::OnSkipFile
(
wxCommandEvent
& WXUNUSED(event))
62
{
63
EndModal
(
crSkipFile
);
64
}
65
66
void
ConfirmReplaceDlg::OnAll
(
wxCommandEvent
& WXUNUSED(event))
67
{
68
EndModal
(
crAll
);
69
}
70
71
void
ConfirmReplaceDlg::OnCancel
(
wxCommandEvent
& WXUNUSED(event))
72
{
73
EndModal
(
crCancel
);
74
}
75
76
void
ConfirmReplaceDlg::CalcPosition
(
cbStyledTextCtrl
* ed)
77
{
78
if
(!ed)
79
return
;
80
81
int
w = 0, h = 0;
82
GetSize(&w,&h);
83
84
wxPoint
pt = ed->
PointFromPosition
(ed->
GetCurrentPos
());
85
int
ed_width = ed->GetSize().x;
86
pt.
x
= (ed_width - w) / 2;
87
if
(pt.
x
< 0)
88
pt.
x
= 0;
89
pt = ed->ClientToScreen(pt);
90
91
int
lineHeight = ed->
TextHeight
(ed->
GetCurrentLine
());
92
93
int
screenW =
wxSystemSettings::GetMetric
(
wxSYS_SCREEN_X
);
94
int
screenH =
wxSystemSettings::GetMetric
(
wxSYS_SCREEN_Y
);
95
// sanity check
96
if
(w > screenW)
97
w = screenW;
98
if
(h > screenH)
99
h = screenH;
100
101
// now we 're where we want to be, but check that the whole window is visible...
102
// the main goal here is that the caret *should* be visible...
103
104
// for the horizontal axis, easy stuff
105
if
(pt.
x
+ w > screenW)
106
pt.
x
= screenW - w;
107
108
// for the vertical axis, more work has to be done...
109
110
// Does it fit 4 lines above current line?
111
if
(h + 4*lineHeight < pt.
y
)
112
pt.
y
-= h + 4*lineHeight;
113
else
if
(pt.
y
+ lineHeight + (2*h) <= screenH)
114
{
115
// One line below current line?
116
pt.
y
+= lineHeight;
117
}
118
else
119
{
120
// Top of the screen
121
pt.
y
= 0;
122
}
123
// we should be OK now
124
SetSize(pt.
x
, pt.
y
, w, h);
125
}
ScriptBindings::EndModal
void EndModal(int retCode)
Definition:
sc_dialog.cpp:112
confirmreplacedlg.h
wxPoint::y
int y
crNo
Definition:
confirmreplacedlg.h:18
settings.h
_T
#define _T(string)
wxScrollingDialog
Definition:
scrollingdialog.h:163
crYes
Definition:
confirmreplacedlg.h:17
ConfirmReplaceDlg
Definition:
confirmreplacedlg.h:25
ConfirmReplaceDlg::OnSkipFile
void OnSkipFile(wxCommandEvent &event)
Definition:
confirmreplacedlg.cpp:61
ConfirmReplaceDlg::OnNo
void OnNo(wxCommandEvent &event)
Definition:
confirmreplacedlg.cpp:51
wxScintilla::TextHeight
int TextHeight(int line)
Retrieve the height of a particular line of text in pixels.
wxSYS_SCREEN_Y
wxCommandEvent
wxSystemSettings::GetMetric
static int GetMetric(wxSystemMetric index, wxWindow *win=NULL)
wxScintilla::GetCurrentLine
int GetCurrentLine()
Manually declared methods.
sdk_precomp.h
cbeditor.h
ConfirmReplaceDlg::OnAll
void OnAll(wxCommandEvent &event)
Definition:
confirmreplacedlg.cpp:66
wxScintilla::PointFromPosition
wxPoint PointFromPosition(int pos)
Retrieve the point in the window where a position is displayed.
wxString
crAll
Definition:
confirmreplacedlg.h:21
ConfirmReplaceDlg::OnCancel
void OnCancel(wxCommandEvent &event)
Definition:
confirmreplacedlg.cpp:71
cbStyledTextCtrl
Definition:
cbstyledtextctrl.h:21
ConfirmReplaceDlg::OnAllInFile
void OnAllInFile(wxCommandEvent &event)
Definition:
confirmreplacedlg.cpp:56
wxScintilla::GetCurrentPos
int GetCurrentPos() const
Returns the position of the caret.
crSkipFile
Definition:
confirmreplacedlg.h:20
ConfirmReplaceDlg::CalcPosition
void CalcPosition(cbStyledTextCtrl *ed)
Definition:
confirmreplacedlg.cpp:76
crAllInFile
Definition:
confirmreplacedlg.h:19
cbstyledtextctrl.h
wxStaticText
xmlres.h
ConfirmReplaceDlg::~ConfirmReplaceDlg
~ConfirmReplaceDlg() override
Definition:
confirmreplacedlg.cpp:42
stattext.h
wxSYS_SCREEN_X
wxXmlResource::Get
static wxXmlResource * Get()
crCancel
Definition:
confirmreplacedlg.h:22
wxPoint::x
int x
wxWindow
wxXmlResource::LoadObject
wxObject * LoadObject(wxWindow *parent, const wxString &name, const wxString &classname)
wxPoint
ConfirmReplaceDlg::OnYes
void OnYes(wxCommandEvent &event)
Definition:
confirmreplacedlg.cpp:46
Generated by
1.8.13