Developing T++ 'in the bar'

git-svn-id: svn://ultimatepp.org/upp/trunk@488 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2008-09-28 21:03:32 +00:00
commit e6a8ecec6e
12 changed files with 132 additions and 26 deletions

View file

@ -1010,6 +1010,7 @@ CodeEditor::CodeEditor() {
findreplace.findback <<= THISBACK(DoFindBack);
found = notfoundfw = notfoundbk = foundsel = false;
bar.WhenBreakpoint = THISBACK(ForwardWhenBreakpoint);
bar.WhenAnnotationMove = Proxy(WhenAnnotationMove);
highlight = HIGHLIGHT_NONE;
hilite_scope = 0;
hilite_bracket = 2;

View file

@ -49,6 +49,7 @@ class EditorBar : public FrameLeft<Ctrl> {
public:
virtual void Paint(Draw& w);
virtual void MouseMove(Point p, dword flags);
virtual void MouseLeave();
virtual void LeftDown(Point p, dword flags);
virtual void LeftDouble(Point p, dword flags);
virtual void RightDown(Point p, dword flags);
@ -76,9 +77,10 @@ private:
bool bingenabled;
bool hilite_if_endif;
bool line_numbers;
bool annotations;
int annotations;
bool ignored_next_edit;
int next_age;
int active_annotation;
String& PointBreak(int& y);
void sPaintImage(Draw& w, int y, int fy, const Image& img);
@ -86,6 +88,7 @@ private:
public:
Callback1<int> WhenBreakpoint;
Callback WhenAnnotationMove;
void InsertLines(int i, int count);
void RemoveLines(int i, int count);
@ -120,12 +123,14 @@ public:
void SetPtr(int line, const Image& img, int i);
void HidePtr();
void EnableBreakpointing(bool b) { bingenabled = b; }
void HiliteIfEndif(bool b) { hilite_if_endif = b; Refresh(); }
void EnableBreakpointing(bool b) { bingenabled = b; }
void HiliteIfEndif(bool b) { hilite_if_endif = b; Refresh(); }
void LineNumbers(bool b);
void Annotations(bool b);
bool IsHiliteIfEndif() const { return hilite_if_endif; }
void Annotations(int width);
bool IsHiliteIfEndif() const { return hilite_if_endif; }
int GetActiveAnnotationLine() const { return active_annotation; }
EditorBar();
virtual ~EditorBar();
@ -365,6 +370,7 @@ public:
Callback WhenSelection;
Callback1<const String&> WhenDbgView;
Callback WhenLeftDown;
Callback WhenAnnotationMove;
FrameTop<Button> topsbbutton;
FrameTop<Button> topsbbutton1;
@ -463,9 +469,10 @@ public:
bool GetMarkLines() { return mark_lines; }
void AutoEnclose(bool b) { auto_enclose = b; }
void Annotations(bool b) { bar.Annotations(b); }
void Annotations(int width) { bar.Annotations(width); }
void SetAnnotation(int i, const Image& icon, const String& a) { bar.SetAnnotation(i, icon, a); }
void GetAnnotation(int i) const { bar.GetAnnotation(i); }
String GetAnnotation(int i) const { return bar.GetAnnotation(i); }
int GetActiveAnnotationLine() const { return bar.GetActiveAnnotationLine(); }
void HideBar() { bar.Hide(); }

View file

@ -145,7 +145,7 @@ void EditorBar::Paint(Draw& w) {
sPaintImage(w, y, fy, ptrimg[q]);
if(annotations && !IsNull(icon))
w.DrawImage(sz.cx - 12, y + (fy - icon.GetSize().cy) / 2, icon);
w.DrawImage(sz.cx - annotations, y + (fy - icon.GetSize().cy) / 2, icon);
y += fy;
i++;
@ -153,10 +153,25 @@ void EditorBar::Paint(Draw& w) {
}
void EditorBar::MouseMove(Point p, dword flags) {
int pa = active_annotation;
if(p.x > GetSize().cx - annotations)
active_annotation = p.y / editor->GetFont().Info().GetHeight() + editor->GetScrollPos().y;
if(active_annotation >= editor->GetLineCount())
active_annotation = -1;
if(pa != active_annotation)
WhenAnnotationMove();
if(editor)
editor->MouseMove(Point(0, p.y), flags);
}
void EditorBar::MouseLeave()
{
int pa = active_annotation;
active_annotation = -1;
if(pa != active_annotation)
WhenAnnotationMove();
}
void EditorBar::LeftDown(Point p, dword flags) {
if(editor)
editor->LeftDown(Point(0, p.y), flags);
@ -428,7 +443,7 @@ void EditorBar::HidePtr()
void EditorBar::SyncWidth()
{
Width((line_numbers ? 27 : 12) + annotations * 12);
Width((line_numbers ? 27 : 12) + annotations);
Refresh();
}
@ -438,9 +453,9 @@ void EditorBar::LineNumbers(bool b)
SyncWidth();
}
void EditorBar::Annotations(bool b)
void EditorBar::Annotations(int width)
{
annotations = b;
annotations = width;
SyncWidth();
}
@ -449,7 +464,8 @@ EditorBar::EditorBar() {
editor = NULL;
bingenabled = true;
hilite_if_endif = true;
line_numbers = annotations = false;
line_numbers = false;
annotations = 0;
ignored_next_edit = false;
next_age = 0;
}