void OnKey(wxKeyEvent& event);
void OnLeftClick(wxMouseEvent& event);
+ // Return the widest item width (recalculating it if necessary)
+ int GetWidestItemWidth() { CalcWidths(); return m_widestWidth; }
+
+ // Return the index of the widest item (recalculating it if necessary)
+ int GetWidestItem() { CalcWidths(); return m_widestItem; }
+
wxArrayString m_strings;
wxArrayPtrVoid m_clientDatas;
// has the mouse been released on this control?
bool m_clicked;
+ // Recalculate widths if they are dirty
+ void CalcWidths();
+
DECLARE_EVENT_TABLE()
};
wxComboCtrl::SetSelection(from,to);
}
+ // Return the widest item width (recalculating it if necessary)
+ virtual int GetWidestItemWidth() { EnsurePopupControl(); return GetVListBoxComboPopup()->GetWidestItemWidth(); }
+
+ // Return the index of the widest item (recalculating it if necessary)
+ virtual int GetWidestItem() { EnsurePopupControl(); return GetVListBoxComboPopup()->GetWidestItem(); }
+
wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
protected:
wxVListBox::SetSelection(index);
}
-wxSize wxVListBoxComboPopup::GetAdjustedSize( int minWidth, int prefHeight, int maxHeight )
+void wxVListBoxComboPopup::CalcWidths()
{
- int height = 250;
-
- if ( m_strings.GetCount() )
- {
- if ( prefHeight > 0 )
- height = prefHeight;
-
- if ( height > maxHeight )
- height = maxHeight;
-
- int totalHeight = GetTotalHeight(); // + 3;
- if ( height >= totalHeight )
- {
- height = totalHeight;
- }
- else
- {
- // Adjust height to a multiple of the height of the first item
- // NB: Calculations that take variable height into account
- // are unnecessary.
- int fih = GetLineHeight(0);
- int shown = height/fih;
- height = shown * fih;
- }
- }
- else
- height = 50;
-
bool doFindWidest = m_findWidest;
// Measure items with dirty width.
m_findWidest = false;
}
+}
+
+wxSize wxVListBoxComboPopup::GetAdjustedSize( int minWidth, int prefHeight, int maxHeight )
+{
+ int height = 250;
+
+ if ( m_strings.GetCount() )
+ {
+ if ( prefHeight > 0 )
+ height = prefHeight;
+
+ if ( height > maxHeight )
+ height = maxHeight;
+
+ int totalHeight = GetTotalHeight(); // + 3;
+ if ( height >= totalHeight )
+ {
+ height = totalHeight;
+ }
+ else
+ {
+ // Adjust height to a multiple of the height of the first item
+ // NB: Calculations that take variable height into account
+ // are unnecessary.
+ int fih = GetLineHeight(0);
+ int shown = height/fih;
+ height = shown * fih;
+ }
+ }
+ else
+ height = 50;
+
+ CalcWidths();
// Take scrollbar into account in width calculations
int widestWidth = m_widestWidth + wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);