summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
1bf55f4)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54601
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
// get the background colour of selected cells
const wxColour& GetSelectionBackground() const { return m_colBgSel; }
// get the background colour of selected cells
const wxColour& GetSelectionBackground() const { return m_colBgSel; }
+ // get the item rect, returns empty rect if the item is not visible
+ wxRect GetItemRect(size_t n) const;
// operations
// ----------
// operations
// ----------
*/
wxPoint GetMargins() const;
*/
wxPoint GetMargins() const;
+ /**
+ Returns the rectangle occupied by this item in physical coordinates.
+
+ If the item is not currently visible, returns an empty rectangle.
+ */
+ wxRect GetItemRect(size_t item) const;
+
/**
Returns the index of the next selected item or @c wxNOT_FOUND if there
are no more.
/**
Returns the index of the next selected item or @c wxNOT_FOUND if there
are no more.
void OnToggleMulti(wxCommandEvent& event);
void OnSelectAll(wxCommandEvent& event);
void OnUpdateItem(wxCommandEvent& event);
void OnToggleMulti(wxCommandEvent& event);
void OnSelectAll(wxCommandEvent& event);
void OnUpdateItem(wxCommandEvent& event);
+ void OnGetItemRect(wxCommandEvent& event);
void OnSetBgCol(wxCommandEvent& event);
void OnSetSelBgCol(wxCommandEvent& event);
void OnSetBgCol(wxCommandEvent& event);
void OnSetSelBgCol(wxCommandEvent& event);
HtmlLbox_ToggleMulti,
HtmlLbox_SelectAll,
HtmlLbox_UpdateItem,
HtmlLbox_ToggleMulti,
HtmlLbox_SelectAll,
HtmlLbox_UpdateItem,
HtmlLbox_SetBgCol,
HtmlLbox_SetSelBgCol,
HtmlLbox_SetBgCol,
HtmlLbox_SetSelBgCol,
EVT_MENU(HtmlLbox_ToggleMulti, MyFrame::OnToggleMulti)
EVT_MENU(HtmlLbox_SelectAll, MyFrame::OnSelectAll)
EVT_MENU(HtmlLbox_UpdateItem, MyFrame::OnUpdateItem)
EVT_MENU(HtmlLbox_ToggleMulti, MyFrame::OnToggleMulti)
EVT_MENU(HtmlLbox_SelectAll, MyFrame::OnSelectAll)
EVT_MENU(HtmlLbox_UpdateItem, MyFrame::OnUpdateItem)
+ EVT_MENU(HtmlLbox_GetItemRect, MyFrame::OnGetItemRect)
EVT_MENU(HtmlLbox_About, MyFrame::OnAbout)
EVT_MENU(HtmlLbox_About, MyFrame::OnAbout)
menuHLbox->AppendSeparator();
menuHLbox->Append(HtmlLbox_SelectAll, _T("Select &all items\tCtrl-A"));
menuHLbox->Append(HtmlLbox_UpdateItem, _T("Update &first item\tCtrl-U"));
menuHLbox->AppendSeparator();
menuHLbox->Append(HtmlLbox_SelectAll, _T("Select &all items\tCtrl-A"));
menuHLbox->Append(HtmlLbox_UpdateItem, _T("Update &first item\tCtrl-U"));
+ menuHLbox->Append(HtmlLbox_GetItemRect, _T("Show &rectangle of item #10\tCtrl-R"));
menuHLbox->AppendSeparator();
menuHLbox->Append(HtmlLbox_SetBgCol, _T("Set &background...\tCtrl-B"));
menuHLbox->Append(HtmlLbox_SetSelBgCol,
menuHLbox->AppendSeparator();
menuHLbox->Append(HtmlLbox_SetBgCol, _T("Set &background...\tCtrl-B"));
menuHLbox->Append(HtmlLbox_SetSelBgCol,
GetMyBox()->UpdateFirstItem();
}
GetMyBox()->UpdateFirstItem();
}
+void MyFrame::OnGetItemRect(wxCommandEvent& WXUNUSED(event))
+{
+ static const int ITEM = 10;
+ const wxRect r = m_hlbox->GetItemRect(ITEM);
+ wxLogMessage("Rect of item %d: (%d, %d)-(%d, %d)",
+ ITEM, r.x, r.y, r.x + r.width, r.y + r.height);
+}
+
void MyFrame::OnSetBgCol(wxCommandEvent& WXUNUSED(event))
{
wxColour col = wxGetColourFromUser(this, m_hlbox->GetBackgroundColour());
void MyFrame::OnSetBgCol(wxCommandEvent& WXUNUSED(event))
{
wxColour col = wxGetColourFromUser(this, m_hlbox->GetBackgroundColour());
+wxRect wxVListBox::GetItemRect(size_t n) const
+{
+ wxRect itemrect;
+
+ // check that this item is visible
+ const size_t lineMax = GetVisibleEnd();
+ if ( n >= lineMax )
+ return itemrect;
+ size_t line = GetVisibleBegin();
+ if ( n < line )
+ return itemrect;
+
+ while ( line <= n )
+ {
+ itemrect.y += itemrect.height;
+ itemrect.height = OnGetRowHeight(line);
+
+ line++;
+ }
+
+ itemrect.width = GetClientSize().x;
+
+ return itemrect;
+}
+
// ----------------------------------------------------------------------------
// wxVListBox appearance parameters
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// wxVListBox appearance parameters
// ----------------------------------------------------------------------------