Permalink
Browse files

More coding style changes.

  • Loading branch information...
1 parent 1f1ee84 commit 54382660b800f2756a9e88b8661c84f33624da96 @adamv adamv committed Jul 23, 2009
Showing with 81 additions and 60 deletions.
  1. +3 −0 src/CurrentTabsPopup.cpp
  2. +1 −1 src/CurrentTabsPopup.h
  3. +21 −21 src/DiffBar.cpp
  4. +12 −15 src/DiffBar.h
  5. +12 −7 src/DiffMarkBar.cpp
  6. +8 −10 src/DiffMarkBar.h
  7. +11 −2 src/DiffPanel.cpp
  8. +7 −3 src/DiffPanel.h
  9. +5 −0 src/GutterCtrl.cpp
  10. +1 −1 src/GutterCtrl.h
View
@@ -66,6 +66,9 @@ void CurrentTabsPopup::ListEventHandler::OnItemActivated(wxListEvent& WXUNUSED(e
}
}
+CurrentTabsPopup::ListEventHandler::ListEventHandler( CurrentTabsPopup* parent ):
+ m_parent(parent) {}
+
BEGIN_EVENT_TABLE(CurrentTabsPopup, wxDialog)
EVT_SHOW(CurrentTabsPopup::OnShow)
END_EVENT_TABLE()
View
@@ -38,7 +38,7 @@ class CurrentTabsPopup: public wxDialog {
class ListEventHandler : public wxEvtHandler {
public:
- ListEventHandler(CurrentTabsPopup* parent): m_parent(parent){};
+ ListEventHandler(CurrentTabsPopup* parent);
private:
DECLARE_EVENT_TABLE();
View
@@ -27,10 +27,11 @@ END_EVENT_TABLE()
const unsigned int DiffBar::s_bracketWidth = 5;
-DiffBar::DiffBar(wxWindow* parent, CatalystWrapper& cw, EditorCtrl* leftEditor, EditorCtrl* rightEditor)
-: wxControl(parent, wxID_ANY, wxPoint(-100,-100), wxSize(40,100), wxNO_BORDER|wxWANTS_CHARS|wxCLIP_CHILDREN|wxNO_FULL_REPAINT_ON_RESIZE),
- m_catalyst(cw), m_leftEditor(leftEditor), m_rightEditor(rightEditor), m_leftStyler(m_diffs, true), m_rightStyler(m_diffs, false),
- m_needRedraw(false), m_needTransform(false), m_highlight(-1) {
+DiffBar::DiffBar(wxWindow* parent, CatalystWrapper& cw, EditorCtrl* leftEditor, EditorCtrl* rightEditor):
+ wxControl(parent, wxID_ANY, wxPoint(-100,-100), wxSize(40,100), wxNO_BORDER|wxWANTS_CHARS|wxCLIP_CHILDREN|wxNO_FULL_REPAINT_ON_RESIZE),
+ m_catalyst(cw), m_leftEditor(leftEditor), m_rightEditor(rightEditor), m_leftStyler(m_diffs, true), m_rightStyler(m_diffs, false),
+ m_needRedraw(false), m_needTransform(false), m_highlight(-1)
+{
SetMinSize(wxSize(40, -1));
SetMaxSize(wxSize(40, -1));
}
@@ -96,7 +97,7 @@ void DiffBar::TransformMatchlist() {
// Find matching lines in editorCtrls
unsigned int leftCount = 0;
unsigned int rightCount = 0;
- for (vector<Change>::const_iterator c = m_diffs.begin(); c != m_diffs.end(); ++c) {
+ for (std::vector<Change>::const_iterator c = m_diffs.begin(); c != m_diffs.end(); ++c) {
LineMatch m;
// Convert matches to lines
@@ -183,7 +184,7 @@ void DiffBar::DrawLayout(wxDC& dc) {
const unsigned int rightTopLine = m_rightEditor->GetTopLine();
// Ignore all matches above toplines
- vector<LineMatch>::const_iterator p = m_lineMatches.begin();
+ std::vector<LineMatch>::const_iterator p = m_lineMatches.begin();
for (; p != m_lineMatches.end(); ++p) {
if (p->left_end >= leftTopLine || p->right_end >= rightTopLine) break;
}
@@ -244,15 +245,15 @@ void DiffBar::OnMouseLeave(wxMouseEvent& WXUNUSED(evt)) {
}
}
-vector<DiffBar::LineMatch>::const_iterator DiffBar::OnLeftBracket(int y) {
+std::vector<DiffBar::LineMatch>::const_iterator DiffBar::OnLeftBracket(int y) {
const int ypos = y + m_leftEditor->GetScrollPos();
Lines& lines = m_leftEditor->GetLines();
if (ypos > lines.GetHeight()) return m_lineMatches.end();
const unsigned int line_id = lines.GetLineFromYPos(ypos);
// Are we over a bracket?
- vector<LineMatch>::const_iterator p = m_lineMatches.begin();
+ std::vector<LineMatch>::const_iterator p = m_lineMatches.begin();
for (; p != m_lineMatches.end(); ++p) {
if (p->left_end >= line_id) break;
}
@@ -268,15 +269,15 @@ vector<DiffBar::LineMatch>::const_iterator DiffBar::OnLeftBracket(int y) {
return m_lineMatches.end();
}
-vector<DiffBar::LineMatch>::const_iterator DiffBar::OnRightBracket(int y) {
+std::vector<DiffBar::LineMatch>::const_iterator DiffBar::OnRightBracket(int y) {
const int ypos = y + m_rightEditor->GetScrollPos();
Lines& lines = m_rightEditor->GetLines();
if (ypos > lines.GetHeight()) return m_lineMatches.end();
const unsigned int line_id = lines.GetLineFromYPos(ypos);
// Are we over a bracket?
- vector<LineMatch>::const_iterator p = m_lineMatches.begin();
+ std::vector<LineMatch>::const_iterator p = m_lineMatches.begin();
for (; p != m_lineMatches.end(); ++p) {
if (p->right_end >= line_id) break;
}
@@ -299,11 +300,11 @@ void DiffBar::OnMouseMotion(wxMouseEvent& evt) {
int highlight = -1;
if (mpos.x <= s_bracketWidth) {
- vector<LineMatch>::const_iterator p = OnLeftBracket(mpos.y);
+ std::vector<LineMatch>::const_iterator p = OnLeftBracket(mpos.y);
if( p != m_lineMatches.end()) highlight = p->left_start;
}
else if (mpos.x >= (int)rightBracket) {
- vector<LineMatch>::const_iterator p = OnRightBracket(mpos.y);
+ std::vector<LineMatch>::const_iterator p = OnRightBracket(mpos.y);
if( p != m_lineMatches.end()) highlight = p->left_start;
}
@@ -319,7 +320,7 @@ void DiffBar::OnMouseLeftUp(wxMouseEvent& evt) {
if (mpos.x <= s_bracketWidth) {
// Have we clicked a bracket?
- vector<LineMatch>::const_iterator p = OnLeftBracket(mpos.y);
+ std::vector<LineMatch>::const_iterator p = OnLeftBracket(mpos.y);
if (p == m_lineMatches.end()) return;
// Get positions
@@ -348,7 +349,7 @@ void DiffBar::OnMouseLeftUp(wxMouseEvent& evt) {
}
else if (mpos.x >= size.x - (int)s_bracketWidth) {
// Have we clicked a bracket?
- vector<LineMatch>::const_iterator p = OnRightBracket(mpos.y);
+ std::vector<LineMatch>::const_iterator p = OnRightBracket(mpos.y);
if (p == m_lineMatches.end()) return;
// Get positions
@@ -375,7 +376,6 @@ void DiffBar::OnMouseLeftUp(wxMouseEvent& evt) {
m_leftEditor->ReDraw();
m_rightEditor->ReDraw();
}
-
}
void DiffBar::OnPaint(wxPaintEvent& WXUNUSED(event)) {
@@ -388,9 +388,8 @@ void DiffBar::OnSize(wxSizeEvent& WXUNUSED(event)) {
DrawLayout(dc);
}
-void DiffBar::OnEraseBackground(wxEraseEvent& WXUNUSED(event)) {
- // # no evt.skip() as we don't want the control to erase the background
-}
+// # no evt.skip() as we don't want the control to erase the background
+void DiffBar::OnEraseBackground(wxEraseEvent& WXUNUSED(event)) {}
void DiffBar::OnBeforeEditorRedraw(void* data) { // static
DiffBar* self = (DiffBar*)data;
@@ -673,8 +672,9 @@ void DiffBar::OnRightDocumentChanged(cxChangeType type, unsigned int pos, unsign
// ---- DiffStyler ------------------------------
-DiffBar::DiffStyler::DiffStyler(const vector<Change>& diffs, bool isLeft)
-: m_isLeft(isLeft), m_diffs(diffs) {
+DiffBar::DiffStyler::DiffStyler(const std::vector<Change>& diffs, bool isLeft):
+ m_isLeft(isLeft), m_diffs(diffs)
+{
m_insColor.Set(192, 255, 192); // PASTEL GREEN
m_delColor.Set(255, 192, 192); // PASTEL RED
}
@@ -688,7 +688,7 @@ void DiffBar::DiffStyler::Style(StyleRun& sr) {
const wxColor& primaryColor = m_isLeft ? m_delColor : m_insColor;
const wxColor& secondaryColor = m_isLeft ? m_insColor : m_delColor;
- for (vector<Change>::const_iterator c = m_diffs.begin(); c != m_diffs.end(); ++c) {
+ for (std::vector<Change>::const_iterator c = m_diffs.begin(); c != m_diffs.end(); ++c) {
if (c->type == primaryType) {
if (c->end_pos > rstart && c->start_pos < rend) {
const unsigned int start = wxMax(rstart, c->start_pos);
View
@@ -14,19 +14,15 @@
#ifndef __DIFFBAR_H__
#define __DIFFBAR_H__
-#include "wx/wxprec.h" // For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+#ifndef WX_PRECOMP
+#include <wx/wx.h>
+#endif
+
#include "Catalyst.h"
#include "styler.h"
-// STL can't compile with Level 4
-#ifdef __WXMSW__
-#pragma warning(push, 1)
-#endif
#include <vector>
-#ifdef __WXMSW__
-#pragma warning(pop)
-#endif
-using namespace std;
// pre-definitions
class EditorFrame;
@@ -51,7 +47,7 @@ class DiffBar : public wxControl {
cxChangeType right_type;
};
- const vector<LineMatch>& GetLineMatches() const {return m_lineMatches;};
+ const std::vector<LineMatch>& GetLineMatches() const {return m_lineMatches;};
private:
class Change {
@@ -71,16 +67,16 @@ class DiffBar : public wxControl {
void Style(StyleRun& sr);
private:
bool m_isLeft;
- const vector<Change>& m_diffs;
+ const std::vector<Change>& m_diffs;
wxColor m_delColor;
wxColor m_insColor;
};
void TransformMatchlist();
void DrawLayout(wxDC& dc);
- vector<LineMatch>::const_iterator OnLeftBracket(int y);
- vector<LineMatch>::const_iterator OnRightBracket(int y);
+ std::vector<LineMatch>::const_iterator OnLeftBracket(int y);
+ std::vector<LineMatch>::const_iterator OnRightBracket(int y);
// Event handlers
void OnPaint(wxPaintEvent& event);
@@ -105,13 +101,14 @@ class DiffBar : public wxControl {
EditorCtrl* m_leftEditor;
EditorCtrl* m_rightEditor;
list<cxMatch> m_matchlist;
- vector<Change> m_diffs;
- vector<LineMatch> m_lineMatches;
+ std::vector<Change> m_diffs;
+ std::vector<LineMatch> m_lineMatches;
DiffStyler m_leftStyler;
DiffStyler m_rightStyler;
bool m_needRedraw;
bool m_needTransform;
int m_highlight;
+
static const unsigned int s_bracketWidth;
};
View
@@ -8,9 +8,10 @@ BEGIN_EVENT_TABLE(DiffMarkBar, wxControl)
EVT_ERASE_BACKGROUND(DiffMarkBar::OnEraseBackground)
END_EVENT_TABLE()
-DiffMarkBar::DiffMarkBar(wxWindow* parent, const vector<DiffBar::LineMatch>& lineMatches, EditorCtrl* editor, bool isLeft)
-: wxControl(parent, wxID_ANY, wxPoint(-100,-100), wxDefaultSize, wxNO_BORDER|wxCLIP_CHILDREN|wxNO_FULL_REPAINT_ON_RESIZE),
- m_lineMatches(lineMatches), m_editor(editor), m_isLeft(isLeft) {
+DiffMarkBar::DiffMarkBar(wxWindow* parent, const vector<DiffBar::LineMatch>& lineMatches, EditorCtrl* editor, bool isLeft):
+ wxControl(parent, wxID_ANY, wxPoint(-100,-100), wxDefaultSize, wxNO_BORDER|wxCLIP_CHILDREN|wxNO_FULL_REPAINT_ON_RESIZE),
+ m_lineMatches(lineMatches), m_editor(editor), m_isLeft(isLeft)
+{
// Fix width
SetMinSize(wxSize(10, -1));
SetMaxSize(wxSize(10, -1));
@@ -35,7 +36,7 @@ void DiffMarkBar::DrawLayout(wxDC& dc) {
dc.Clear();
// Draw the markers
- for (vector<DiffBar::LineMatch>::const_iterator p = m_lineMatches.begin(); p != m_lineMatches.end(); ++p) {
+ for (std::vector<DiffBar::LineMatch>::const_iterator p = m_lineMatches.begin(); p != m_lineMatches.end(); ++p) {
const unsigned int leftTop = lines.GetYPosFromLine(m_isLeft ? p->left_start : p->right_start);
const unsigned int leftBottom = lines.GetBottomYPosFromLine(m_isLeft ? p->left_end-1 : p->right_end-1);
@@ -61,6 +62,10 @@ void DiffMarkBar::OnSize(wxSizeEvent& WXUNUSED(event)) {
DrawLayout(dc);
}
-void DiffMarkBar::OnEraseBackground(wxEraseEvent& WXUNUSED(event)) {
- // # no evt.skip() as we don't want the control to erase the background
-}
+// # no evt.skip() as we don't want the control to erase the background
+void DiffMarkBar::OnEraseBackground(wxEraseEvent& WXUNUSED(event)) {}
+
+void DiffMarkBar::SetEditor( EditorCtrl* editor )
+{
+ m_editor = editor;
+}
View
@@ -14,23 +14,22 @@
#ifndef __DIFFMARKBAR_H__
#define __DIFFMARKBAR_H__
-#include "wx/wxprec.h" // For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+#ifndef WX_PRECOMP
+#include <wx/wx.h>
+#endif
+
#include "DiffBar.h"
-// STL can't compile with Level 4
-#pragma warning(push, 1)
#include <vector>
-#pragma warning(pop)
-using namespace std;
// pre-definitions
class EditorCtrl;
class DiffMarkBar : public wxControl {
public:
DiffMarkBar(wxWindow* parent, const vector<DiffBar::LineMatch>& m_lineMatches, EditorCtrl* editor, bool isLeft);
-
- void SetEditor(EditorCtrl* editor) {m_editor = editor;};
+ void SetEditor(EditorCtrl* editor);
private:
void DrawLayout(wxDC& dc);
@@ -42,7 +41,7 @@ class DiffMarkBar : public wxControl {
DECLARE_EVENT_TABLE();
// Member variables
- const vector<DiffBar::LineMatch>& m_lineMatches;
+ const std::vector<DiffBar::LineMatch>& m_lineMatches;
EditorCtrl* m_editor;
bool m_isLeft;
wxColour m_insColor;
@@ -51,5 +50,4 @@ class DiffMarkBar : public wxControl {
wxColour m_delBorder;
};
-
-#endif // __DIFFMARKBAR_H__
+#endif // __DIFFMARKBAR_H__
View
@@ -32,8 +32,10 @@ BEGIN_EVENT_TABLE(DiffPanel, wxPanel)
EVT_CHILD_FOCUS(DiffPanel::OnChildFocus)
END_EVENT_TABLE()
-DiffPanel::DiffPanel(wxWindow* parent, EditorFrame& parentFrame, CatalystWrapper& cw, wxBitmap& bitmap)
-: wxPanel(parent, wxID_ANY, wxPoint(-100,-100)), m_parentFrame(&parentFrame), m_leftEditor(NULL), m_rightEditor(NULL), m_currentEditor(NULL) {
+DiffPanel::DiffPanel(wxWindow* parent, EditorFrame& parentFrame, CatalystWrapper& cw, wxBitmap& bitmap):
+ wxPanel(parent, wxID_ANY, wxPoint(-100,-100)),
+ m_parentFrame(&parentFrame), m_leftEditor(NULL), m_rightEditor(NULL), m_currentEditor(NULL)
+{
Hide(); // Hidden during construction
// Create ctrls
@@ -73,6 +75,8 @@ DiffPanel::DiffPanel(wxWindow* parent, EditorFrame& parentFrame, CatalystWrapper
SetSizer(m_mainSizer);
}
+DiffPanel::DiffPanel(){}
+
DiffPanel::~DiffPanel() {
// Make sure the editorCtrls get closed correctly
// TODO: Better handling in EditorFrame
@@ -177,3 +181,8 @@ void DiffPanel::RestoreSettings(unsigned int i, eSettings& settings) {
const char** DiffPanel::RecommendedIcon() const {
return diff_xpm;
}
+
+EditorCtrl* DiffPanel::GetActiveEditor()
+{
+ return m_currentEditor;
+}
View
@@ -14,7 +14,11 @@
#ifndef __DIFFPANEL_H__
#define __DIFFPANEL_H__
-#include "wx/wxprec.h" // For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+#ifndef WX_PRECOMP
+#include <wx/wx.h>
+#endif
+
#include "Catalyst.h"
// Pre-definitions
@@ -26,7 +30,7 @@ class wxGridBagSizer;
class DiffPanel : public wxPanel {
public:
- DiffPanel() {}; // default const
+ DiffPanel(); // default const
DiffPanel(wxWindow* parent, EditorFrame& parentFrame, CatalystWrapper& cw, wxBitmap& bitmap);
~DiffPanel();
@@ -38,7 +42,7 @@ class DiffPanel : public wxPanel {
void SaveSettings(unsigned int i, eSettings& settings);
void RestoreSettings(unsigned int i, eSettings& settings);
- EditorCtrl* GetActiveEditor() {return m_currentEditor;};
+ EditorCtrl* GetActiveEditor();
const char** RecommendedIcon() const;
private:
View
@@ -316,6 +316,11 @@ void GutterCtrl::DrawGutter(wxDC& dc) {
#endif
}
+void GutterCtrl::DrawGutter()
+{
+ wxClientDC dc(this);DrawGutter(dc);
+}
+
void GutterCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) {
wxPaintDC dc(this);
Oops, something went wrong.

0 comments on commit 5438266

Please sign in to comment.