From 9a305cac5adfd929b2c2cf5a1db33eea42ff1a3c Mon Sep 17 00:00:00 2001
From: Guillaume Lelarge <guillaume@lelarge.info>
Date: Mon, 11 Oct 2010 23:31:19 +0200
Subject: [PATCH] Add an option to set the cursor colour

This option allows the user to set the colour of the cursor. It's really
important if you change the background colour, so that the cursor is still
visible.

Implements #253.
---
 pgadmin/ctl/ctlSQLBox.cpp           |    2 ++
 pgadmin/frm/frmOptions.cpp          |    7 +++++++
 pgadmin/include/utils/sysSettings.h |    3 +++
 pgadmin/ui/frmOptions.xrc           |   35 ++++++++++++++++++++++++++++++++++-
 4 files changed, 46 insertions(+), 1 deletions(-)

diff --git a/pgadmin/ctl/ctlSQLBox.cpp b/pgadmin/ctl/ctlSQLBox.cpp
index 3cd5577..1760d9d 100644
--- a/pgadmin/ctl/ctlSQLBox.cpp
+++ b/pgadmin/ctl/ctlSQLBox.cpp
@@ -99,6 +99,8 @@ void ctlSQLBox::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, cons
     SetSelBackground(true, wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
     SetSelForeground(true, wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
 
+	SetCaretForeground(settings->GetSQLColourCaret());
+
     SetMarginWidth(1, 0);
     SetTabWidth(settings->GetIndentSpaces());
     SetUseTabs(!settings->GetSpacesForTabs());
diff --git a/pgadmin/frm/frmOptions.cpp b/pgadmin/frm/frmOptions.cpp
index ce28d14..bd570ea 100644
--- a/pgadmin/frm/frmOptions.cpp
+++ b/pgadmin/frm/frmOptions.cpp
@@ -97,6 +97,7 @@
 #define pickerSQLColour7            CTRL_COLOURPICKER("pickerSQLColour7")
 #define pickerSQLColour10           CTRL_COLOURPICKER("pickerSQLColour10")
 #define pickerSQLColour11           CTRL_COLOURPICKER("pickerSQLColour11")
+#define pickerSQLCaretColour               CTRL_COLOURPICKER("pickerSQLCaretColour")
 
 BEGIN_EVENT_TABLE(frmOptions, pgDialog)
     EVT_MENU(MNU_HELP,                                            frmOptions::OnHelp)
@@ -395,6 +396,8 @@ void frmOptions::UpdateColourControls()
 		stSQLCustomForegroundColour->Enable(true);
 	}
 
+	pickerSQLCaretColour->SetColour(settings->GetSQLColourCaret());
+
 	pickerSQLMarginBackgroundColour->SetColour(settings->GetSQLMarginBackgroundColour());
 }
 
@@ -665,6 +668,10 @@ void frmOptions::OnOK(wxCommandEvent &ev)
         changed = true;
     settings->SetSQLMarginBackgroundColour(pickerSQLMarginBackgroundColour->GetColourString());
 
+    if (pickerSQLCaretColour->GetColourString() != settings->GetSQLColourCaret())
+        changed = true;
+    settings->SetSQLColourCaret(pickerSQLCaretColour->GetColourString());
+
     if (pickerSQLColour1->GetColourString() != settings->GetSQLBoxColour(1))
         changed = true;
     settings->SetSQLBoxColour(1, pickerSQLColour1->GetColourString());
diff --git a/pgadmin/include/utils/sysSettings.h b/pgadmin/include/utils/sysSettings.h
index 7caae55..e081c36 100644
--- a/pgadmin/include/utils/sysSettings.h
+++ b/pgadmin/include/utils/sysSettings.h
@@ -156,6 +156,9 @@ public:
     wxString GetSQLBoxColourForeground() const { wxString s; Read(wxT("ctlSQLBox/ColourForeground"), &s, wxT("#000000")); return s; }
 	void SetSQLBoxColourForeground(const wxString &newval) { Write(wxT("ctlSQLBox/ColourForeground"), newval); }
 
+    wxString GetSQLColourCaret() const { wxString s; Read(wxT("ctlSQLBox/ColourCaret"), &s, wxT("#000000")); return s; }
+	void SetSQLColourCaret(const wxString &newval) { Write(wxT("ctlSQLBox/ColourCaret"), newval); }
+
     wxString GetSQLBoxColour(int index) const { wxString s; Read(wxString::Format(wxT("ctlSQLBox/Colour%i"), index), &s, getDefaultElementColor(index)); return s; }
 	void SetSQLBoxColour(int index, const wxString &newval) { Write(wxString::Format(wxT("ctlSQLBox/Colour%i"), index), newval); }
 
diff --git a/pgadmin/ui/frmOptions.xrc b/pgadmin/ui/frmOptions.xrc
index dfbd706..589a2d3 100644
--- a/pgadmin/ui/frmOptions.xrc
+++ b/pgadmin/ui/frmOptions.xrc
@@ -675,6 +675,39 @@
                 </object>
                 <object class="sizeritem">
                   <object class="wxStaticBoxSizer">
+                    <label>Caret</label>
+                    <orient>wxVERTICAL</orient>
+                    <object class="sizeritem">
+                      <object class="wxFlexGridSizer">
+                        <cols>2</cols>
+                        <rows>1</rows>
+                        <vgap>5</vgap>
+                        <hgap>5</hgap>
+                        <growablecols>0,2</growablecols>
+                        <object class="sizeritem">
+                          <object class="wxStaticText" name="stSQLCaretColour">
+                            <label>Caret</label>
+                          </object>
+                          <flag>wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                          <border>4</border>
+                        </object>
+                        <object class="sizeritem">
+                          <object class="ctlColourPicker" name="pickerSQLCaretColour">
+                            <size>70,12d</size>
+                          </object>
+                          <flag>wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                          <border>4</border>
+                        </object>
+                      </object>
+                      <flag>wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                      <border>4</border>
+                    </object>
+                  </object>
+                  <flag>wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                  <border>4</border>
+                </object>
+                <object class="sizeritem">
+                  <object class="wxStaticBoxSizer">
                     <label>SQL Syntax Highlighting</label>
                     <orient>wxVERTICAL</orient>
                     <object class="sizeritem">
@@ -982,4 +1015,4 @@
       </object>
     </object>
   </object>
-</resource>
\ No newline at end of file
+</resource>
-- 
1.7.0.4

