Skip to content

Commit

Permalink
More coding style changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamv committed Jul 23, 2009
1 parent 1f1ee84 commit 5438266
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 60 deletions.
3 changes: 3 additions & 0 deletions src/CurrentTabsPopup.cpp
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/CurrentTabsPopup.h
Expand Up @@ -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();
Expand Down
42 changes: 21 additions & 21 deletions src/DiffBar.cpp
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -375,7 +376,6 @@ void DiffBar::OnMouseLeftUp(wxMouseEvent& evt) {
m_leftEditor->ReDraw();
m_rightEditor->ReDraw();
}

}

void DiffBar::OnPaint(wxPaintEvent& WXUNUSED(event)) {
Expand All @@ -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;
Expand Down Expand Up @@ -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
}
Expand All @@ -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);
Expand Down
27 changes: 12 additions & 15 deletions src/DiffBar.h
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -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);
Expand All @@ -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;
};

Expand Down
19 changes: 12 additions & 7 deletions src/DiffMarkBar.cpp
Expand Up @@ -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));
Expand All @@ -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);

Expand All @@ -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;
}
18 changes: 8 additions & 10 deletions src/DiffMarkBar.h
Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -51,5 +50,4 @@ class DiffMarkBar : public wxControl {
wxColour m_delBorder;
};


#endif // __DIFFMARKBAR_H__
#endif // __DIFFMARKBAR_H__
13 changes: 11 additions & 2 deletions src/DiffPanel.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
10 changes: 7 additions & 3 deletions src/DiffPanel.h
Expand Up @@ -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
Expand All @@ -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();

Expand All @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions src/GutterCtrl.cpp
Expand Up @@ -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);
Expand Down

0 comments on commit 5438266

Please sign in to comment.