30 #include "wx/msw/wrapwin.h"
37 long style,
const wxValidator& validator,
const wxString& name)
39 if (!wxOwnerDrawnComboBox::Create(parent,
id, value, pos, size, wxArrayString(), style, validator, name))
54 if(e.GetWheelRotation()<0)
70 switch (e.GetKeyCode()){
74 case WXK_NUMPAD_RIGHT:
84 case WXK_NUMPAD_PAGEDOWN:
88 case WXK_NUMPAD_PAGEUP:
114 int index=std::min<int>(GetSelection()+step,GetCount()-1);
115 if(index!=GetSelection())
125 int index=std::max<int>(GetSelection()-step,0);
126 if(index!=GetSelection())
138 wxCommandEvent ne(wxEVT_COMMAND_COMBOBOX_SELECTED);
139 ne.SetEventObject(
this);
140 ne.SetId(this->GetId());
141 ne.SetInt(GetSelection());
154 int WXUNUSED(
flags))
const
156 if ( item == wxNOT_FOUND )
160 GetTextExtent(GetString(item), &w, &h);
161 wxCoord maxWidth=0.73*rect.width-3;
167 wxString qty_cp = wxT(
"");
170 qty_cp = wxString::Format(wxT(
" %d"),
CPCount[item]);
171 GetTextExtent(qty_cp, &qty_w, &h);
175 if (w +qty_w <= maxWidth)
178 dc.DrawText(GetString(item),rect.x + 3,rect.y + ((rect.height - dc.GetCharHeight())/2));
184 wxString ellipsis(wxT(
"..."));
186 GetTextExtent(ellipsis, &base_w, &h);
189 wxString drawntext = GetString(item);
190 while (drawntext.length() > 1)
192 drawntext.RemoveLast();
193 GetTextExtent(drawntext,&w,&h);
194 if (w + base_w + qty_w <= maxWidth)
199 dc.DrawText(drawntext, rect.x + 3, rect.y + ((rect.height - dc.GetCharHeight())/2));
200 dc.DrawText(ellipsis, rect.x + 3 + w, rect.y + ((rect.height - dc.GetCharHeight())/2));
207 x=rect.width / 5 *(1-std::min<double>(
CPConnection[item],10)/10);
209 x=std::max<wxCoord>(5,x);
210 const wxPen * oldPen = & dc.GetPen();
211 const wxBrush * oldBrush= & dc.GetBrush();
213 wxPen MyPen(wxColour(255, 0, 0), 1, wxPENSTYLE_SOLID);
214 wxBrush MyBrush(wxColour(255,0,0), wxBRUSHSTYLE_SOLID);
215 double red, green, blue;
223 MyPen.SetColour(wxColour(red,green,0));
224 MyBrush.SetColour(wxColour(red,green,0));
226 dc.SetBrush(MyBrush);
227 dc.DrawRectangle(rect.x+0.75*rect.width,rect.y+rect.height/6+1,x,2*rect.height/3);
258 MyPen.SetColour(dc.GetTextForeground());
260 dc.SetBrush(*wxTRANSPARENT_BRUSH);
261 dc.DrawRectangle(rect.x+0.75*rect.width,rect.y+rect.height/6+1,rect.width/5,2*rect.height/3);
263 dc.SetBrush(*oldBrush);
266 dc.DrawText(qty_cp, rect.x - 3 - qty_w +0.75*rect.width , rect.y + ((rect.height - dc.GetCharHeight())/2));
276 CPCount.resize(this->GetCount(),0);
279 for (
unsigned int ptIdx = 0 ; ptIdx < noPts ; ptIdx++)
299 CPImagesComboBoxXmlHandler::CPImagesComboBoxXmlHandler()
300 : wxOwnerDrawnComboBoxXmlHandler()
309 cp->Create(m_parentAsWindow,
310 GetID(), wxEmptyString,
311 GetPosition(), GetSize(),
312 GetStyle(wxT(
"style")), wxDefaultValidator,
322 return IsOfClass(node, wxT(
"CPImagesComboBox"));
void CalcCPDistance(HuginBase::Panorama *pano)
Get maximum CP distance for all images pairs containing the reference image.
void SelectPrev(int step=1)
std::vector< double > CPConnection
void OnKeyDown(wxKeyEvent &e)
Key handler to mimic wxChoice behavior.
Definition of CPImagesComboBox and CPImagesComboBoxXmlHandler class.
std::size_t getNrOfCtrlPoints() const
number of control points
Owner Drawn ComboBox for showing connected images on CP tab.
represents a control point
virtual void OnDrawItem(wxDC &dc, const wxRect &rect, int item, int WXUNUSED(flags)) const
Paint method for drawing text and indication bar of combo box.
virtual bool CanHandle(wxXmlNode *node)
Internal use to identify right xml handler.
const ControlPoint & getCtrlPoint(std::size_t nr) const
get a control point, counting starts with 0
void OnMouseWheel(wxMouseEvent &e)
Mouse wheel handler to mimic wxChoice behavior.
IMPLEMENT_DYNAMIC_CLASS(wxTreeListHeaderWindow, wxWindow)
virtual wxObject * DoCreateResource()
Create CPImagesComboBox from resource.
xrc handler for CPImagesComboBox
void ControlPointErrorColour(const double cperr, double &r, double &g, double &b)
bool Create(wxWindow *parent, wxWindowID id, const wxString &value, const wxPoint &pos, const wxSize &size, long style=0, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxASCII_STR(wxComboBoxNameStr))
create control, bind events
std::vector< unsigned int > CPCount
void SelectNext(int step=1)