File: ctlSQLBox.h

package info (click to toggle)
pgadmin3 1.20.0~beta2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 73,704 kB
  • ctags: 18,591
  • sloc: cpp: 193,786; ansic: 18,736; sh: 5,154; pascal: 1,120; yacc: 927; makefile: 516; lex: 421; xml: 126; perl: 40
file content (89 lines) | stat: -rw-r--r-- 2,497 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//////////////////////////////////////////////////////////////////////////
//
// pgAdmin III - PostgreSQL Tools
//
// Copyright (C) 2002 - 2014, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
// ctlSQLBox.h - SQL syntax highlighting textbox
//
//////////////////////////////////////////////////////////////////////////

#ifndef CTLSQLBOX_H
#define CTLSQLBOX_H

// wxWindows headers
#include <wx/wx.h>
#include <wx/stc/stc.h>
#include <wx/fdrepdlg.h>

#include "db/pgConn.h"
#include "dlg/dlgFindReplace.h"

// These structs are from Scintilla.h which isn't easily #included :-(
struct CharacterRange
{
	long cpMin;
	long cpMax;
};

struct TextToFind
{
	struct CharacterRange chrg;
	char *lpstrText;
	struct CharacterRange chrgText;
};

// Class declarations
class ctlSQLBox : public wxStyledTextCtrl
{
	static wxString sqlKeywords;

public:
	ctlSQLBox(wxWindow *parent, wxWindowID id = -1, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, long style = 0);
	ctlSQLBox();
	~ctlSQLBox();

	void Create(wxWindow *parent, wxWindowID id = -1, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, long style = 0);

	void SetDatabase(pgConn *db);

	void OnKeyDown(wxKeyEvent &event);
	void OnAutoComplete(wxCommandEvent &event);
	void OnSearchReplace(wxCommandEvent &event);
	void OnKillFocus(wxFocusEvent &event);

	bool Find(const wxString &find, bool wholeWord, bool matchCase, bool useRegexps, bool startAtTop, bool reverse);
	bool Replace(const wxString &find, const wxString &replace, bool wholeWord, bool matchCase, bool useRegexps, bool startAtTop, bool reverse);
	bool ReplaceAll(const wxString &find, const wxString &replace, bool wholeWord, bool matchCase, bool useRegexps);
	bool DoFind(const wxString &find, const wxString &replace, bool doReplace, bool wholeWord, bool matchCase, bool useRegexps, bool startAtTop, bool reverse);
	void SetAutoIndent(bool on)
	{
		m_autoIndent = on;
	}
	void EnableAutoComp(bool on)
	{
		m_autocompDisabled = on;
	}
	bool BlockComment(bool uncomment = false);
	void UpdateLineNumber();

	CharacterRange RegexFindText(int minPos, int maxPos, const wxString &text);

	DECLARE_DYNAMIC_CLASS(ctlSQLBox)
	DECLARE_EVENT_TABLE()

private:

	void OnPositionStc(wxStyledTextEvent &event);
	void OnMarginClick(wxStyledTextEvent &event);

	dlgFindReplace *m_dlgFindReplace;
	pgConn *m_database;
	bool m_autoIndent, m_autocompDisabled;

	friend class QueryPrintout;
};

#endif