X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/07854e5edda33cdb2c4ff50f545f7a3eb94badc3..0d53638f7147c18153f63fdfc096b17be6e22a27:/src/richtext/richtextsymboldlg.cpp diff --git a/src/richtext/richtextsymboldlg.cpp b/src/richtext/richtextsymboldlg.cpp index 7f53ddd320..b5ab4f39b0 100644 --- a/src/richtext/richtextsymboldlg.cpp +++ b/src/richtext/richtextsymboldlg.cpp @@ -1,19 +1,18 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: richtextsymboldlg.cpp +// Name: src/richtext/richtextsymboldlg.cpp // Purpose: // Author: Julian Smart // Modified by: // Created: 10/5/2006 3:11:58 PM -// RCS-ID: // Copyright: (c) Julian Smart -// Licence: +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // For compilers that support precompilation, includes "wx/wx.h". #include "wx/wxprec.h" #ifdef __BORLANDC__ -#pragma hdrstop + #pragma hdrstop #endif #if wxUSE_RICHTEXT @@ -21,18 +20,19 @@ #include "wx/richtext/richtextsymboldlg.h" #ifndef WX_PRECOMP -#include "wx/wx.h" + #include "wx/sizer.h" + #include "wx/stattext.h" + #include "wx/combobox.h" + #include "wx/button.h" + #include "wx/settings.h" + #include "wx/icon.h" + #include "wx/listbox.h" #endif -////@begin includes -////@end includes - -#include "wx/fontenum.h" #include "wx/dcbuffer.h" -#include "wx/settings.h" -////@begin XPM images -////@end XPM images +// Only for cached font name +#include "wx/richtext/richtextctrl.h" /* Microsoft Unicode subset numbering */ @@ -119,7 +119,7 @@ static struct { int m_low, m_high; wxUnicodeSubsetCodes m_subset; - wxChar* m_name; + const wxChar* m_name; } g_UnicodeSubsetTable[] = { { 0x0000, 0x007E, @@ -275,6 +275,8 @@ bool wxSubsetValidForFont(int subsetIndex, FONTSIGNATURE *fontSig) } #endif +bool wxSymbolPickerDialog::sm_showToolTips = false; + /*! * wxSymbolPickerDialog type definition */ @@ -290,27 +292,24 @@ BEGIN_EVENT_TABLE( wxSymbolPickerDialog, wxDialog ) ////@begin wxSymbolPickerDialog event table entries EVT_COMBOBOX( ID_SYMBOLPICKERDIALOG_FONT, wxSymbolPickerDialog::OnFontCtrlSelected ) - #if defined(__UNICODE__) EVT_COMBOBOX( ID_SYMBOLPICKERDIALOG_SUBSET, wxSymbolPickerDialog::OnSubsetSelected ) + EVT_UPDATE_UI( ID_SYMBOLPICKERDIALOG_SUBSET, wxSymbolPickerDialog::OnSymbolpickerdialogSubsetUpdate ) #endif #if defined(__UNICODE__) EVT_COMBOBOX( ID_SYMBOLPICKERDIALOG_FROM, wxSymbolPickerDialog::OnFromUnicodeSelected ) #endif -#if defined(__WXMSW__) || defined(__WXGTK__) || defined(__WXOS2__) || defined(__WXMGL__) || defined(__WXMOTIF__) || defined(__WXCOCOA__) || defined(__WXX11__) || defined(__WXPALMOS__) EVT_UPDATE_UI( wxID_OK, wxSymbolPickerDialog::OnOkUpdate ) -#endif - -#if defined(__WXMAC__) - EVT_UPDATE_UI( wxID_OK, wxSymbolPickerDialog::OnOkUpdate ) -#endif - + EVT_BUTTON( wxID_HELP, wxSymbolPickerDialog::OnHelpClick ) + EVT_UPDATE_UI( wxID_HELP, wxSymbolPickerDialog::OnHelpUpdate ) ////@end wxSymbolPickerDialog event table entries END_EVENT_TABLE() +IMPLEMENT_HELP_PROVISION(wxSymbolPickerDialog) + /*! * wxSymbolPickerDialog constructors */ @@ -337,7 +336,7 @@ bool wxSymbolPickerDialog::Create( const wxString& symbol, const wxString& fontN m_symbol = symbol; ////@begin wxSymbolPickerDialog creation - SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS|wxDIALOG_EX_CONTEXTHELP); + SetExtraStyle(wxWS_EX_BLOCK_EVENTS|wxDIALOG_EX_CONTEXTHELP); wxDialog::Create( parent, id, caption, pos, size, style ); CreateControls(); @@ -368,6 +367,7 @@ void wxSymbolPickerDialog::Init() #if defined(__UNICODE__) m_fromUnicodeCtrl = NULL; #endif + m_stdButtonSizer = NULL; ////@end wxSymbolPickerDialog member initialisation m_dontUpdate = false; } @@ -378,6 +378,10 @@ void wxSymbolPickerDialog::Init() void wxSymbolPickerDialog::CreateControls() { +#ifdef __WXMAC__ + SetWindowVariant(wxWINDOW_VARIANT_SMALL); +#endif + ////@begin wxSymbolPickerDialog content construction wxSymbolPickerDialog* itemDialog1 = this; @@ -394,110 +398,97 @@ void wxSymbolPickerDialog::CreateControls() itemBoxSizer4->Add(itemBoxSizer5, 1, wxGROW, 5); wxStaticText* itemStaticText6 = new wxStaticText( itemDialog1, wxID_STATIC, _("&Font:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer5->Add(itemStaticText6, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5); + itemBoxSizer5->Add(itemStaticText6, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); - wxString* m_fontCtrlStrings = NULL; - m_fontCtrl = new wxComboBox( itemDialog1, ID_SYMBOLPICKERDIALOG_FONT, _T(""), wxDefaultPosition, wxSize(240, -1), 0, m_fontCtrlStrings, wxCB_READONLY ); + wxArrayString m_fontCtrlStrings; + m_fontCtrl = new wxComboBox( itemDialog1, ID_SYMBOLPICKERDIALOG_FONT, wxEmptyString, wxDefaultPosition, wxSize(240, -1), m_fontCtrlStrings, wxCB_READONLY ); + m_fontCtrl->SetHelpText(_("The font from which to take the symbol.")); + if (wxSymbolPickerDialog::ShowToolTips()) + m_fontCtrl->SetToolTip(_("The font from which to take the symbol.")); itemBoxSizer5->Add(m_fontCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); itemBoxSizer5->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); #if defined(__UNICODE__) wxStaticText* itemStaticText9 = new wxStaticText( itemDialog1, wxID_STATIC, _("&Subset:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer5->Add(itemStaticText9, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5); + itemBoxSizer5->Add(itemStaticText9, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); #endif #if defined(__UNICODE__) - wxString* m_subsetCtrlStrings = NULL; - m_subsetCtrl = new wxComboBox( itemDialog1, ID_SYMBOLPICKERDIALOG_SUBSET, _T(""), wxDefaultPosition, wxDefaultSize, 0, m_subsetCtrlStrings, wxCB_READONLY ); + wxArrayString m_subsetCtrlStrings; + m_subsetCtrl = new wxComboBox( itemDialog1, ID_SYMBOLPICKERDIALOG_SUBSET, wxEmptyString, wxDefaultPosition, wxDefaultSize, m_subsetCtrlStrings, wxCB_READONLY ); m_subsetCtrl->SetHelpText(_("Shows a Unicode subset.")); - if (ShowToolTips()) + if (wxSymbolPickerDialog::ShowToolTips()) m_subsetCtrl->SetToolTip(_("Shows a Unicode subset.")); itemBoxSizer5->Add(m_subsetCtrl, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5); #endif - m_symbolsCtrl = new wxSymbolListCtrl( itemDialog1, ID_SYMBOLPICKERDIALOG_LISTCTRL, wxDefaultPosition, wxSize(500, 240), wxSIMPLE_BORDER ); + m_symbolsCtrl = new wxSymbolListCtrl( itemDialog1, ID_SYMBOLPICKERDIALOG_LISTCTRL, wxDefaultPosition, wxSize(500, 200), 0 ); itemBoxSizer3->Add(m_symbolsCtrl, 1, wxGROW|wxALL, 5); wxBoxSizer* itemBoxSizer12 = new wxBoxSizer(wxHORIZONTAL); itemBoxSizer3->Add(itemBoxSizer12, 0, wxGROW, 5); m_symbolStaticCtrl = new wxStaticText( itemDialog1, wxID_STATIC, _("xxxx"), wxDefaultPosition, wxSize(40, -1), wxALIGN_CENTRE ); - itemBoxSizer12->Add(m_symbolStaticCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5); + itemBoxSizer12->Add(m_symbolStaticCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); itemBoxSizer12->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); wxStaticText* itemStaticText15 = new wxStaticText( itemDialog1, wxID_STATIC, _("&Character code:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer12->Add(itemStaticText15, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5); + itemBoxSizer12->Add(itemStaticText15, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); - m_characterCodeCtrl = new wxTextCtrl( itemDialog1, ID_SYMBOLPICKERDIALOG_CHARACTERCODE, _T(""), wxDefaultPosition, wxSize(140, -1), wxTE_READONLY|wxTE_CENTRE ); + m_characterCodeCtrl = new wxTextCtrl( itemDialog1, ID_SYMBOLPICKERDIALOG_CHARACTERCODE, wxEmptyString, wxDefaultPosition, wxSize(140, -1), wxTE_READONLY|wxTE_CENTRE ); + m_characterCodeCtrl->SetHelpText(_("The character code.")); + if (wxSymbolPickerDialog::ShowToolTips()) + m_characterCodeCtrl->SetToolTip(_("The character code.")); itemBoxSizer12->Add(m_characterCodeCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); itemBoxSizer12->Add(5, 5, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5); #if defined(__UNICODE__) wxStaticText* itemStaticText18 = new wxStaticText( itemDialog1, wxID_STATIC, _("&From:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer12->Add(itemStaticText18, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5); + itemBoxSizer12->Add(itemStaticText18, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); #endif #if defined(__UNICODE__) - wxString m_fromUnicodeCtrlStrings[] = { - _("ASCII"), - _("Unicode") - }; - m_fromUnicodeCtrl = new wxComboBox( itemDialog1, ID_SYMBOLPICKERDIALOG_FROM, _("ASCII"), wxDefaultPosition, wxDefaultSize, 2, m_fromUnicodeCtrlStrings, wxCB_READONLY ); - m_fromUnicodeCtrl->SetStringSelection(_("ASCII")); + wxArrayString m_fromUnicodeCtrlStrings; + m_fromUnicodeCtrlStrings.Add(_("ASCII")); + m_fromUnicodeCtrlStrings.Add(_("Unicode")); + m_fromUnicodeCtrl = new wxComboBox( itemDialog1, ID_SYMBOLPICKERDIALOG_FROM, _("Unicode"), wxDefaultPosition, wxDefaultSize, m_fromUnicodeCtrlStrings, wxCB_READONLY ); + m_fromUnicodeCtrl->SetStringSelection(_("Unicode")); + m_fromUnicodeCtrl->SetHelpText(_("The range to show.")); + if (wxSymbolPickerDialog::ShowToolTips()) + m_fromUnicodeCtrl->SetToolTip(_("The range to show.")); itemBoxSizer12->Add(m_fromUnicodeCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); #endif -#if defined(__WXMSW__) || defined(__WXGTK__) || defined(__WXOS2__) || defined(__WXMGL__) || defined(__WXMOTIF__) || defined(__WXCOCOA__) || defined(__WXX11__) || defined(__WXPALMOS__) - wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxHORIZONTAL); - itemBoxSizer3->Add(itemBoxSizer20, 0, wxGROW, 5); - - itemBoxSizer20->Add(5, 5, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5); - - wxButton* itemButton22 = new wxButton( itemDialog1, wxID_OK, _("Insert"), wxDefaultPosition, wxDefaultSize, 0 ); - itemButton22->SetDefault(); - itemButton22->SetHelpText(_("Inserts the chosen symbol.")); - if (ShowToolTips()) - itemButton22->SetToolTip(_("Inserts the chosen symbol.")); - itemBoxSizer20->Add(itemButton22, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); - - wxButton* itemButton23 = new wxButton( itemDialog1, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 ); - itemButton23->SetHelpText(_("Closes the dialog without inserting a symbol.")); - if (ShowToolTips()) - itemButton23->SetToolTip(_("Closes the dialog without inserting a symbol.")); - itemBoxSizer20->Add(itemButton23, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); - -#endif - -#if defined(__WXMAC__) - wxBoxSizer* itemBoxSizer24 = new wxBoxSizer(wxHORIZONTAL); - itemBoxSizer3->Add(itemBoxSizer24, 0, wxGROW, 5); + m_stdButtonSizer = new wxStdDialogButtonSizer; - itemBoxSizer24->Add(5, 5, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5); + itemBoxSizer3->Add(m_stdButtonSizer, 0, wxGROW|wxTOP|wxBOTTOM, 5); + wxButton* itemButton21 = new wxButton( itemDialog1, wxID_OK, _("Insert"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton21->SetDefault(); + m_stdButtonSizer->AddButton(itemButton21); - wxButton* itemButton26 = new wxButton( itemDialog1, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 ); - itemButton26->SetHelpText(_("Closes the dialog without inserting a symbol.")); - if (ShowToolTips()) - itemButton26->SetToolTip(_("Closes the dialog without inserting a symbol.")); - itemBoxSizer24->Add(itemButton26, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + wxButton* itemButton22 = new wxButton( itemDialog1, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 ); + m_stdButtonSizer->AddButton(itemButton22); - wxButton* itemButton27 = new wxButton( itemDialog1, wxID_OK, _("Insert"), wxDefaultPosition, wxDefaultSize, 0 ); - itemButton27->SetDefault(); - itemButton27->SetHelpText(_("Inserts the chosen symbol.")); - if (ShowToolTips()) - itemButton27->SetToolTip(_("Inserts the chosen symbol.")); - itemBoxSizer24->Add(itemButton27, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + wxButton* itemButton23 = new wxButton( itemDialog1, wxID_HELP, _("&Help"), wxDefaultPosition, wxDefaultSize, 0 ); + m_stdButtonSizer->AddButton(itemButton23); -#endif + m_stdButtonSizer->Realize(); ////@end wxSymbolPickerDialog content construction + if (GetHelpId() == -1) + { + wxWindow* button = FindWindowById(wxID_HELP); + if (button) + m_stdButtonSizer->Show(button, false); + } } /// Data transfer @@ -507,14 +498,14 @@ bool wxSymbolPickerDialog::TransferDataToWindow() if (m_fontCtrl->GetCount() == 0) { - wxArrayString faceNames = wxFontEnumerator::GetFacenames(); + wxArrayString faceNames = wxRichTextCtrl::GetAvailableFontNames(); faceNames.Sort(); faceNames.Insert(_("(Normal text)"), 0); m_fontCtrl->Append(faceNames); } - if (m_fontName.IsEmpty()) + if (m_fontName.empty()) m_fontCtrl->SetSelection(0); else { @@ -524,18 +515,12 @@ bool wxSymbolPickerDialog::TransferDataToWindow() m_fontCtrl->SetSelection(0); } - if (!m_symbol.IsEmpty()) - { - int sel = (int) m_symbol[0]; - m_symbolsCtrl->SetSelection(sel); - } - #if defined(__UNICODE__) if (m_subsetCtrl->GetCount() == 0) { // Insert items into subset combo int i; - for (i = 0; i < (int) (sizeof(g_UnicodeSubsetTable)/sizeof(g_UnicodeSubsetTable[0])); i++) + for (i = 0; i < (int) WXSIZEOF(g_UnicodeSubsetTable); i++) { m_subsetCtrl->Append(g_UnicodeSubsetTable[i].m_name); } @@ -543,7 +528,17 @@ bool wxSymbolPickerDialog::TransferDataToWindow() } #endif - UpdateSymbolDisplay(); +#if defined(__UNICODE__) + m_symbolsCtrl->SetUnicodeMode(m_fromUnicode); +#endif + + if (!m_symbol.empty()) + { + int sel = (int) m_symbol[0]; + m_symbolsCtrl->SetSelection(sel); + } + + UpdateSymbolDisplay(true, m_symbol.empty()); m_dontUpdate = false; @@ -554,12 +549,12 @@ void wxSymbolPickerDialog::UpdateSymbolDisplay(bool updateSymbolList, bool showA { wxFont font; wxString fontNameToUse; - if (m_fontName.IsEmpty()) + if (m_fontName.empty()) fontNameToUse = m_normalTextFontName; else fontNameToUse = m_fontName; - if (!fontNameToUse.IsEmpty()) + if (!fontNameToUse.empty()) { font = wxFont(14, wxDEFAULT, wxNORMAL, wxNORMAL, false, fontNameToUse); } @@ -571,7 +566,7 @@ void wxSymbolPickerDialog::UpdateSymbolDisplay(bool updateSymbolList, bool showA m_symbolsCtrl->SetFont(font); } - if (!m_symbol.IsEmpty()) + if (!m_symbol.empty()) { m_symbolStaticCtrl->SetFont(font); m_symbolStaticCtrl->SetLabel(m_symbol); @@ -624,7 +619,7 @@ void wxSymbolPickerDialog::OnSymbolSelected( wxCommandEvent& event ) return; int sel = event.GetSelection(); - if (sel == -1) + if (sel == wxNOT_FOUND) m_symbol = wxEmptyString; else { @@ -637,7 +632,7 @@ void wxSymbolPickerDialog::OnSymbolSelected( wxCommandEvent& event ) { // Need to make the subset selection reflect the current symbol int i; - for (i = 0; i < (int) (sizeof(g_UnicodeSubsetTable)/sizeof(g_UnicodeSubsetTable[0])); i++) + for (i = 0; i < (int) WXSIZEOF(g_UnicodeSubsetTable); i++) { if (sel >= g_UnicodeSubsetTable[i].m_low && sel <= g_UnicodeSubsetTable[i].m_high) { @@ -675,6 +670,18 @@ void wxSymbolPickerDialog::OnSubsetSelected( wxCommandEvent& WXUNUSED(event) ) } #endif +#if defined(__UNICODE__) + +/*! + * wxEVT_UPDATE_UI event handler for ID_SYMBOLPICKERDIALOG_SUBSET + */ + +void wxSymbolPickerDialog::OnSymbolpickerdialogSubsetUpdate( wxUpdateUIEvent& event ) +{ + event.Enable(m_fromUnicode); +} +#endif + /*! * wxEVT_UPDATE_UI event handler for wxID_OK */ @@ -702,22 +709,13 @@ void wxSymbolPickerDialog::SetUnicodeMode(bool unicodeMode) /// Get the selected symbol character int wxSymbolPickerDialog::GetSymbolChar() const { - if (m_symbol.IsEmpty()) + if (m_symbol.empty()) return -1; else return (int) m_symbol[0]; } -/*! - * Should we show tooltips? - */ - -bool wxSymbolPickerDialog::ShowToolTips() -{ - return true; -} - /*! * Get bitmap resources */ @@ -790,6 +788,10 @@ bool wxSymbolListCtrl::Create(wxWindow *parent, const wxString& name) { style |= wxWANTS_CHARS | wxFULL_REPAINT_ON_RESIZE; + + if ((style & wxBORDER_MASK) == wxBORDER_DEFAULT) + style |= wxBORDER_THEME; + if ( !wxVScrolledWindow::Create(parent, id, pos, size, style, name) ) return false; @@ -805,6 +807,8 @@ bool wxSymbolListCtrl::Create(wxWindow *parent, SetupCtrl(); + SetInitialSize(size); + return true; } @@ -826,7 +830,7 @@ bool wxSymbolListCtrl::DoSetCurrent(int current) { wxASSERT_MSG( current == wxNOT_FOUND || (current >= m_minSymbolValue && current <= m_maxSymbolValue), - _T("wxSymbolListCtrl::DoSetCurrent(): invalid symbol value") ); + wxT("wxSymbolListCtrl::DoSetCurrent(): invalid symbol value") ); if ( current == m_current ) { @@ -835,7 +839,7 @@ bool wxSymbolListCtrl::DoSetCurrent(int current) } if ( m_current != wxNOT_FOUND ) - RefreshLine(SymbolValueToLineNumber(m_current)); + RefreshRow(SymbolValueToLineNumber(m_current)); m_current = current; @@ -847,19 +851,19 @@ bool wxSymbolListCtrl::DoSetCurrent(int current) // don't need to refresh it -- it will be redrawn anyhow if ( !IsVisible(lineNo) ) { - ScrollToLine(lineNo); + ScrollToRow(lineNo); } else // line is at least partly visible { // it is, indeed, only partly visible, so scroll it into view to // make it entirely visible - while ( unsigned(lineNo) == GetLastVisibleLine() && - ScrollToLine(GetVisibleBegin()+1) ) + while ( (unsigned)lineNo + 1 == GetVisibleEnd() && + ScrollToRow(GetVisibleBegin() + 1) ) ; // but in any case refresh it as even if it was only partly visible // before we need to redraw it entirely as its background changed - RefreshLine(lineNo); + RefreshRow(lineNo); } } @@ -868,7 +872,7 @@ bool wxSymbolListCtrl::DoSetCurrent(int current) void wxSymbolListCtrl::SendSelectedEvent() { - wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, GetId()); + wxCommandEvent event(wxEVT_LISTBOX, GetId()); event.SetEventObject(this); event.SetInt(m_current); @@ -879,7 +883,7 @@ void wxSymbolListCtrl::SetSelection(int selection) { wxCHECK_RET( selection == wxNOT_FOUND || (selection >= m_minSymbolValue && selection < m_maxSymbolValue), - _T("wxSymbolListCtrl::SetSelection(): invalid symbol value") ); + wxT("wxSymbolListCtrl::SetSelection(): invalid symbol value") ); DoSetCurrent(selection); } @@ -907,7 +911,7 @@ void wxSymbolListCtrl::SetSelectionBackground(const wxColour& col) // wxSymbolListCtrl painting // ---------------------------------------------------------------------------- -wxCoord wxSymbolListCtrl::OnGetLineHeight(size_t WXUNUSED(line)) const +wxCoord wxSymbolListCtrl::OnGetRowHeight(size_t WXUNUSED(line)) const { return m_cellSize.y + 2*m_ptMargins.y + 1 /* for divider */ ; } @@ -988,34 +992,34 @@ void wxSymbolListCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) dc.SetFont(GetFont()); // the bounding rectangle of the current line - wxRect rectLine; - rectLine.width = clientSize.x; + wxRect rectRow; + rectRow.width = clientSize.x; dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT))); dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); // iterate over all visible lines const size_t lineMax = GetVisibleEnd(); - for ( size_t line = GetFirstVisibleLine(); line < lineMax; line++ ) + for ( size_t line = GetVisibleBegin(); line < lineMax; line++ ) { - const wxCoord hLine = OnGetLineHeight(line); + const wxCoord hRow = OnGetRowHeight(line); - rectLine.height = hLine; + rectRow.height = hRow; // and draw the ones which intersect the update rect - if ( rectLine.Intersects(rectUpdate) ) + if ( rectRow.Intersects(rectUpdate) ) { // don't allow drawing outside of the lines rectangle - wxDCClipper clip(dc, rectLine); + wxDCClipper clip(dc, rectRow); - wxRect rect = rectLine; + wxRect rect = rectRow; rect.Deflate(m_ptMargins.x, m_ptMargins.y); OnDrawItem(dc, rect, line); } else // no intersection { - if ( rectLine.GetTop() > rectUpdate.GetBottom() ) + if ( rectRow.GetTop() > rectUpdate.GetBottom() ) { // we are already below the update rect, no need to continue // further @@ -1024,7 +1028,7 @@ void wxSymbolListCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) //else: the next line may intersect the update rect } - rectLine.y += hLine; + rectRow.y += hRow; } } @@ -1175,7 +1179,7 @@ void wxSymbolListCtrl::OnLeftDClick(wxMouseEvent& eventMouse) // this event as a left-click instead if ( item == m_current ) { - wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, GetId()); + wxCommandEvent event(wxEVT_LISTBOX_DCLICK, GetId()); event.SetEventObject(this); event.SetInt(item); @@ -1203,12 +1207,12 @@ void wxSymbolListCtrl::SetupCtrl(bool scrollToSelection) m_symbolsPerLine = sz.x/(m_cellSize.x+m_ptMargins.x); int noLines = (1 + SymbolValueToLineNumber(m_maxSymbolValue)); - SetLineCount(noLines); + SetRowCount(noLines); Refresh(); if (scrollToSelection && m_current != wxNOT_FOUND && m_current >= m_minSymbolValue && m_current <= m_maxSymbolValue) { - ScrollToLine(SymbolValueToLineNumber(m_current)); + ScrollToRow(SymbolValueToLineNumber(m_current)); } } @@ -1217,7 +1221,7 @@ void wxSymbolListCtrl::EnsureVisible(int item) { if (item != wxNOT_FOUND && item >= m_minSymbolValue && item <= m_maxSymbolValue) { - ScrollToLine(SymbolValueToLineNumber(item)); + ScrollToRow(SymbolValueToLineNumber(item)); } } @@ -1225,7 +1229,7 @@ void wxSymbolListCtrl::EnsureVisible(int item) // hit testing int wxSymbolListCtrl::HitTest(const wxPoint& pt) { - wxCoord lineHeight = OnGetLineHeight(0); + wxCoord lineHeight = OnGetRowHeight(0); int atLine = GetVisibleBegin() + (pt.y/lineHeight); int symbol = (atLine*m_symbolsPerLine) + (pt.x/(m_cellSize.x+1)); @@ -1287,4 +1291,24 @@ wxSymbolListCtrl::GetClassDefaultAttributes(wxWindowVariant variant) return wxListBox::GetClassDefaultAttributes(variant); } -#endif // wxUSE_RICHTEXT +/*! + * wxEVT_BUTTON event handler for wxID_HELP + */ + +void wxSymbolPickerDialog::OnHelpClick( wxCommandEvent& WXUNUSED(event) ) +{ + if ((GetHelpInfo().GetHelpId() != -1) && GetHelpInfo().GetUICustomization()) + ShowHelp(this); +} + +/*! + * wxEVT_UPDATE_UI event handler for wxID_HELP + */ + +void wxSymbolPickerDialog::OnHelpUpdate( wxUpdateUIEvent& event ) +{ + event.Enable((GetHelpInfo().GetHelpId() != -1) && GetHelpInfo().GetUICustomization()); +} + +#endif + // wxUSE_RICHTEXT