Index: pgadmin/ctl/ctlSQLBox.cpp =================================================================== --- pgadmin/ctl/ctlSQLBox.cpp (revision 8173) +++ pgadmin/ctl/ctlSQLBox.cpp (working copy) @@ -80,37 +80,35 @@ extern sysSettings *settings; wxFont fntSQLBox = settings->GetSQLFont(); + wxColour bgColor = settings->GetSQLBoxColourBackground(); + if (settings->GetSQLBoxUseSystemBackground()) + { + bgColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); + } + + wxColour frColor = settings->GetSQLBoxColourForeground(); + if (settings->GetSQLBoxUseSystemForeground()) + { + frColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); + } + StyleSetBackground(wxSTC_STYLE_DEFAULT, bgColor); + StyleSetForeground(wxSTC_STYLE_DEFAULT, frColor); StyleSetFont(wxSTC_STYLE_DEFAULT, fntSQLBox); - StyleSetFont(0, fntSQLBox); - StyleSetFont(1, fntSQLBox); - StyleSetFont(2, fntSQLBox); - StyleSetFont(3, fntSQLBox); - StyleSetFont(4, fntSQLBox); - StyleSetFont(5, fntSQLBox); - StyleSetFont(6, fntSQLBox); - StyleSetFont(7, fntSQLBox); - StyleSetFont(8, fntSQLBox); - StyleSetFont(9, fntSQLBox); - StyleSetFont(10, fntSQLBox); - StyleSetFont(11, fntSQLBox); SetMarginWidth(1, 0); SetTabWidth(settings->GetIndentSpaces()); SetUseTabs(!settings->GetSpacesForTabs()); // Setup the different highlight colurs - StyleSetForeground(0, wxColour(0x80, 0x80, 0x80)); - StyleSetForeground(1, wxColour(0x00, 0x7f, 0x00)); - StyleSetForeground(2, wxColour(0x00, 0x7f, 0x00)); - StyleSetForeground(3, wxColour(0x7f, 0x7f, 0x7f)); - StyleSetForeground(4, wxColour(0x00, 0x7f, 0x7f)); - StyleSetForeground(5, wxColour(0x00, 0x00, 0x7f)); - StyleSetForeground(6, wxColour(0x7f, 0x00, 0x7f)); - StyleSetForeground(7, wxColour(0x7f, 0x00, 0x7f)); - StyleSetForeground(8, wxColour(0x00, 0x7f, 0x7f)); - StyleSetForeground(9, wxColour(0x7f, 0x7f, 0x7f)); - StyleSetForeground(10, wxColour(0x00, 0x00, 0x00)); - StyleSetForeground(11, wxColour(0x00, 0x00, 0x00)); + for (int i = 0; i < 34; ++ i ) + { + if (i > 0 && i < 12) + StyleSetForeground(i, settings->GetSQLBoxColour(i)); + else + StyleSetForeground(i, frColor); + StyleSetBackground(i, bgColor); + StyleSetFont(i, fntSQLBox); + } // Brace maching styles StyleSetBackground(34, wxColour(0x99, 0xF9, 0xFF)); Index: pgadmin/frm/frmOptions.cpp =================================================================== --- pgadmin/frm/frmOptions.cpp (revision 8173) +++ pgadmin/frm/frmOptions.cpp (working copy) @@ -73,6 +73,12 @@ #define pickerActiveProcessColour CTRL_COLOURPICKER("pickerActiveProcessColour") #define pickerSlowProcessColour CTRL_COLOURPICKER("pickerSlowProcessColour") #define pickerBlockedProcessColour CTRL_COLOURPICKER("pickerBlockedProcessColour") +#define chkSQLUseSystemBackgroundColour CTRL_CHECKBOX("chkSQLUseSystemBackgroundColour") +#define chkSQLUseSystemForegroundColour CTRL_CHECKBOX("chkSQLUseSystemForegroundColour") +#define pickerSQLBackgroundColour CTRL_COLOURPICKER("pickerSQLBackgroundColour") +#define pickerSQLForegroundColour CTRL_COLOURPICKER("pickerSQLForegroundColour") +#define stSQLCustomBackgroundColour CTRL_STATIC("stSQLCustomBackgroundColour") +#define stSQLCustomForegroundColour CTRL_STATIC("stSQLCustomForegroundColour") BEGIN_EVENT_TABLE(frmOptions, pgDialog) EVT_MENU(MNU_HELP, frmOptions::OnHelp) @@ -86,6 +92,8 @@ EVT_BUTTON (XRCID("btnDefault"), frmOptions::OnDefault) EVT_CHECKBOX(XRCID("chkSuppressHints"), frmOptions::OnSuppressHints) EVT_CHECKBOX(XRCID("chkResetHints"), frmOptions::OnResetHints) + EVT_CHECKBOX(XRCID("chkSQLUseSystemBackgroundColour"), frmOptions::OnChangeSQLUseCustomColour) + EVT_CHECKBOX(XRCID("chkSQLUseSystemForegroundColour"), frmOptions::OnChangeSQLUseCustomColour) EVT_BUTTON (wxID_OK, frmOptions::OnOK) EVT_BUTTON (wxID_HELP, frmOptions::OnHelp) EVT_BUTTON (wxID_CANCEL, frmOptions::OnCancel) @@ -227,6 +235,18 @@ pickerSlowProcessColour->SetColour(settings->GetSlowProcessColour()); pickerBlockedProcessColour->SetColour(settings->GetBlockedProcessColour()); + chkSQLUseSystemBackgroundColour->SetValue(settings->GetSQLBoxUseSystemBackground()); + chkSQLUseSystemForegroundColour->SetValue(settings->GetSQLBoxUseSystemForeground()); + UpdateColourControls(); + + for (int i = 0; i <= 11; ++i) + { + wxString pickerId = wxString::Format(wxT("pickerSQLColour%i"), i); + wxColourPickerCtrl* picker = wxStaticCast(FindWindow(pickerId), wxColourPickerCtrl); + if (picker != NULL) + picker->SetColour(settings->GetSQLBoxColour(i)); + } + cbLanguage->Append(_("Default")); int sel=0; wxLanguage langId=settings->GetCanonicalLanguage(); @@ -355,7 +375,40 @@ chkSuppressHints->SetValue(false); } +void frmOptions::UpdateColourControls() +{ + if (chkSQLUseSystemBackgroundColour->GetValue()) + { + pickerSQLBackgroundColour->Enable(false); + pickerSQLBackgroundColour->SetColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); + stSQLCustomBackgroundColour->Enable(false); + } + else + { + pickerSQLBackgroundColour->Enable(true); + pickerSQLBackgroundColour->SetColour(settings->GetSQLBoxColourBackground()); + stSQLCustomBackgroundColour->Enable(true); + } + if (chkSQLUseSystemForegroundColour->GetValue()) + { + pickerSQLForegroundColour->Enable(false); + pickerSQLForegroundColour->SetColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); + stSQLCustomForegroundColour->Enable(false); + } + else + { + pickerSQLForegroundColour->Enable(true); + pickerSQLForegroundColour->SetColour(settings->GetSQLBoxColourForeground()); + stSQLCustomForegroundColour->Enable(true); + } +} + +void frmOptions::OnChangeSQLUseCustomColour(wxCommandEvent &ev) +{ + UpdateColourControls(); +} + void frmOptions::OnOK(wxCommandEvent &ev) { // Check the PostgreSQL and EnterpriseDB paths @@ -594,6 +647,51 @@ changed = true; settings->SetBlockedProcessColour(sColour); + // Change SQL Syntax colours + if (settings->GetSQLBoxUseSystemBackground() != chkSQLUseSystemBackgroundColour->GetValue()) + { + changed = true; + settings->SetSQLBoxUseSystemBackground(chkSQLUseSystemBackgroundColour->GetValue()); + } + + if (settings->GetSQLBoxUseSystemForeground() != chkSQLUseSystemForegroundColour->GetValue()) + { + changed = true; + settings->SetSQLBoxUseSystemForeground(chkSQLUseSystemForegroundColour->GetValue()); + } + + if (!settings->GetSQLBoxUseSystemBackground()) + { + colour = pickerSQLBackgroundColour->GetColour(); + sColour = colour.GetAsString(wxC2S_HTML_SYNTAX); + if (sColour != settings->GetSQLBoxColourBackground()) + changed = true; + settings->SetSQLBoxColourBackground(sColour); + } + + if (!settings->GetSQLBoxUseSystemForeground()) + { + colour = pickerSQLForegroundColour->GetColour(); + sColour = colour.GetAsString(wxC2S_HTML_SYNTAX); + if (sColour != settings->GetSQLBoxColourForeground()) + changed = true; + settings->SetSQLBoxColourForeground(sColour); + } + + for (int i = 0; i <= 11; ++i) + { + wxString pickerId = wxString::Format(wxT("pickerSQLColour%i"), i); + wxColourPickerCtrl* picker = wxStaticCast(FindWindow(pickerId), wxColourPickerCtrl); + if (picker != NULL) + { + colour = picker->GetColour(); + sColour = colour.GetAsString(wxC2S_HTML_SYNTAX); + if (sColour != settings->GetSQLBoxColour(i)) + changed = true; + settings->SetSQLBoxColour(i, sColour); + } + } + // Change the language last, as it will affect our tests for changes // in the display object types. int langNo=cbLanguage->GetCurrentSelection(); Index: pgadmin/include/frm/frmOptions.h =================================================================== --- pgadmin/include/frm/frmOptions.h (revision 8173) +++ pgadmin/include/frm/frmOptions.h (working copy) @@ -48,7 +48,9 @@ void OnSuppressHints(wxCommandEvent &ev); void OnResetHints(wxCommandEvent &ev); void OnChangeCopyQuote(wxCommandEvent &ev); + void OnChangeSQLUseCustomColour(wxCommandEvent &ev); wxString CheckColour(wxString colour); + void UpdateColourControls(); DECLARE_EVENT_TABLE() }; Index: pgadmin/include/utils/sysSettings.h =================================================================== --- pgadmin/include/utils/sysSettings.h (revision 8173) +++ pgadmin/include/utils/sysSettings.h (working copy) @@ -133,6 +133,20 @@ wxString GetBlockedProcessColour() const { wxString s; Read(wxT("BlockedProcessColour"), &s, wxT("#d96e5f")); return s; } void SetBlockedProcessColour(const wxString &newval) { Write(wxT("BlockedProcessColour"), newval); } + // SQL Editor Colours options + bool GetSQLBoxUseSystemBackground() const { bool b; Read(wxT("ctlSQLBox/UseSystemBackground"), &b, true); return b; } + void SetSQLBoxUseSystemBackground(const bool newval) { Write(wxT("ctlSQLBox/UseSystemBackground"), newval); } + bool GetSQLBoxUseSystemForeground() const { bool b; Read(wxT("ctlSQLBox/UseSystemForeground"), &b, true); return b; } + void SetSQLBoxUseSystemForeground(const bool newval) { Write(wxT("ctlSQLBox/UseSystemForeground"), newval); } + + wxString GetSQLBoxColourBackground() const { wxString s; Read(wxT("ctlSQLBox/ColourBackground"), &s, wxT("#ffffff")); return s; } + void SetSQLBoxColourBackground(const wxString &newval) { Write(wxT("ctlSQLBox/ColourBackground"), newval); } + 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 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); } + // Misc options long GetAutoRowCountThreshold() const { long l; Read(wxT("AutoRowCount"), &l, 2000L); return l; } void SetAutoRowCountThreshold(const long newval) { Write(wxT("AutoRowCount"), newval); } @@ -187,6 +201,17 @@ private: + static const wxString& getDefaultElementColor(int index) + { + static const wxString colors[] = + { + wxT("#808080"), wxT("#007f00"), wxT("#007f00"), wxT("#7f7f7f"), + wxT("#007f7f"), wxT("#00007f"), wxT("#7f007f"), wxT("#7f007f"), + wxT("#007f7f"), wxT("#7f7f7f"), wxT("#000000"), wxT("#000000") + }; + return colors[index]; + } + bool moveStringValue(const wxChar *oldKey, const wxChar *newKey, int index=-1); bool moveLongValue(const wxChar *oldKey, const wxChar *newKey, int index=-1); Index: pgadmin/ui/frmOptions.xrc =================================================================== --- pgadmin/ui/frmOptions.xrc (revision 8173) +++ pgadmin/ui/frmOptions.xrc (working copy) @@ -419,6 +419,124 @@ + + + + + + 5,5d + 226,12d + + + + + + 5,20d + 226,12d + + + + + + 5,35d + + + 80,35d + 50,12d + + + + + 5,50d + + + 80,50d + 50,12d + + + + + 5,75d + + + 80,75d + 50,12d + + + + + 5,90d + + + 80,90d + 50,12d + + + + + 5,105d + + + 80,105d + 50,12d + + + + + 5,120d + + + 80,120d + 50,12d + + + + + 5,135d + + + 80,135d + 50,12d + + + + + 5,150d + + + 80,150d + 50,12d + + + + + 125,75d + + + 195,75d + 50,12d + + + + + 125,90d + + + 195,90d + 50,12d + + + + + 125,105d + + + 195,105d + 50,12d + + + +