]> git.saurik.com Git - wxWidgets.git/blame - src/generic/headerctrlg.cpp
Return NULL from wxWindow::GetCapture() when the capture is being lost.
[wxWidgets.git] / src / generic / headerctrlg.cpp
CommitLineData
56873923
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: src/generic/headerctrlg.cpp
3// Purpose: generic wxHeaderCtrl implementation
4// Author: Vadim Zeitlin
5// Created: 2008-12-03
56873923
VZ
6// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
7// Licence: wxWindows licence
8///////////////////////////////////////////////////////////////////////////////
9
10// ============================================================================
11// declarations
12// ============================================================================
13
14// ----------------------------------------------------------------------------
15// headers
16// ----------------------------------------------------------------------------
17
18// for compilers that support precompilation, includes "wx.h".
19#include "wx/wxprec.h"
20
21#ifdef __BORLANDC__
22 #pragma hdrstop
23#endif
24
e721a2a2 25#if wxUSE_HEADERCTRL
56873923
VZ
26
27#include "wx/headerctrl.h"
28
29#ifdef wxHAS_GENERIC_HEADERCTRL
30
b63f9a33
VZ
31#include "wx/dcbuffer.h"
32#include "wx/renderer.h"
33
34// ----------------------------------------------------------------------------
35// constants
36// ----------------------------------------------------------------------------
37
38namespace
39{
40
b63f9a33
VZ
41const unsigned COL_NONE = (unsigned)-1;
42
43} // anonymous namespace
44
56873923 45// ============================================================================
b63f9a33 46// wxHeaderCtrl implementation
56873923
VZ
47// ============================================================================
48
b63f9a33
VZ
49// ----------------------------------------------------------------------------
50// wxHeaderCtrl creation
51// ----------------------------------------------------------------------------
52
53void wxHeaderCtrl::Init()
54{
40dc2ae6 55 m_numColumns = 0;
aef252d9 56 m_hover =
6327cdd5
VZ
57 m_colBeingResized =
58 m_colBeingReordered = COL_NONE;
59 m_dragOffset = 0;
b63f9a33
VZ
60 m_scrollOffset = 0;
61}
62
63bool wxHeaderCtrl::Create(wxWindow *parent,
64 wxWindowID id,
65 const wxPoint& pos,
66 const wxSize& size,
67 long style,
68 const wxString& name)
69{
70 if ( !wxHeaderCtrlBase::Create(parent, id, pos, size,
71 style, wxDefaultValidator, name) )
72 return false;
73
74 // tell the system to not paint the background at all to avoid flicker as
75 // we paint the entire window area in our OnPaint()
76 SetBackgroundStyle(wxBG_STYLE_CUSTOM);
77
78 return true;
79}
80
81wxHeaderCtrl::~wxHeaderCtrl()
82{
83}
84
85// ----------------------------------------------------------------------------
86// wxHeaderCtrl columns manipulation
87// ----------------------------------------------------------------------------
88
40dc2ae6
VZ
89void wxHeaderCtrl::DoSetCount(unsigned int count)
90{
f6655391
VZ
91 // update the column indices order array before changing m_numColumns
92 DoResizeColumnIndices(m_colIndices, count);
74d283aa 93
40dc2ae6
VZ
94 m_numColumns = count;
95
7bf5be6b 96 InvalidateBestSize();
40dc2ae6
VZ
97 Refresh();
98}
99
b63f9a33
VZ
100unsigned int wxHeaderCtrl::DoGetCount() const
101{
40dc2ae6
VZ
102 return m_numColumns;
103}
104
105void wxHeaderCtrl::DoUpdate(unsigned int idx)
106{
7bf5be6b
VZ
107 InvalidateBestSize();
108
40dc2ae6
VZ
109 // we need to refresh not only this column but also the ones after it in
110 // case it was shown or hidden or its width changed -- it would be nice to
111 // avoid doing this unnecessary by storing the old column width (TODO)
112 RefreshColsAfter(idx);
b63f9a33
VZ
113}
114
b63f9a33
VZ
115// ----------------------------------------------------------------------------
116// wxHeaderCtrl scrolling
117// ----------------------------------------------------------------------------
118
119void wxHeaderCtrl::DoScrollHorz(int dx)
120{
121 m_scrollOffset += dx;
122
123 // don't call our own version which calls this function!
124 wxControl::ScrollWindow(dx, 0);
125}
126
127// ----------------------------------------------------------------------------
128// wxHeaderCtrl geometry
129// ----------------------------------------------------------------------------
130
131wxSize wxHeaderCtrl::DoGetBestSize() const
132{
b047e876
RR
133 wxWindow *win = GetParent();
134 int height = wxRendererNative::Get().GetHeaderButtonHeight( win );
135
b63f9a33
VZ
136 // the vertical size is rather arbitrary but it looks better if we leave
137 // some space around the text
7bf5be6b
VZ
138 const wxSize size(IsEmpty() ? wxHeaderCtrlBase::DoGetBestSize().x
139 : GetColEnd(GetColumnCount() - 1),
b047e876 140 height ); // (7*GetCharHeight())/4);
7bf5be6b
VZ
141 CacheBestSize(size);
142 return size;
b63f9a33
VZ
143}
144
145int wxHeaderCtrl::GetColStart(unsigned int idx) const
146{
04a33b50 147 int pos = m_scrollOffset;
6327cdd5 148 for ( unsigned n = 0; ; n++ )
b63f9a33 149 {
6327cdd5
VZ
150 const unsigned i = m_colIndices[n];
151 if ( i == idx )
152 break;
153
482d06f8 154 const wxHeaderColumn& col = GetColumn(i);
b63f9a33
VZ
155 if ( col.IsShown() )
156 pos += col.GetWidth();
157 }
158
159 return pos;
160}
161
6327cdd5
VZ
162int wxHeaderCtrl::GetColEnd(unsigned int idx) const
163{
164 int x = GetColStart(idx);
165
482d06f8 166 return x + GetColumn(idx).GetWidth();
6327cdd5
VZ
167}
168
169unsigned int wxHeaderCtrl::FindColumnAtPoint(int x, bool *onSeparator) const
fa3d4aaf 170{
fa3d4aaf
VZ
171 int pos = 0;
172 const unsigned count = GetColumnCount();
173 for ( unsigned n = 0; n < count; n++ )
174 {
6327cdd5 175 const unsigned idx = m_colIndices[n];
482d06f8 176 const wxHeaderColumn& col = GetColumn(idx);
fa3d4aaf
VZ
177 if ( col.IsHidden() )
178 continue;
179
180 pos += col.GetWidth();
181
d13b34d3 182 // if the column is resizable, check if we're approximatively over the
fa3d4aaf
VZ
183 // line separating it from the next column
184 //
185 // TODO: don't hardcode sensitivity
186 if ( col.IsResizeable() && abs(x - pos) < 8 )
187 {
6327cdd5
VZ
188 if ( onSeparator )
189 *onSeparator = true;
190 return idx;
fa3d4aaf
VZ
191 }
192
193 // inside this column?
194 if ( x < pos )
195 {
6327cdd5
VZ
196 if ( onSeparator )
197 *onSeparator = false;
198 return idx;
fa3d4aaf
VZ
199 }
200 }
201
22f4180e
VZ
202 if ( onSeparator )
203 *onSeparator = false;
fa3d4aaf
VZ
204 return COL_NONE;
205}
206
b63f9a33
VZ
207// ----------------------------------------------------------------------------
208// wxHeaderCtrl repainting
209// ----------------------------------------------------------------------------
210
211void wxHeaderCtrl::RefreshCol(unsigned int idx)
212{
213 wxRect rect = GetClientRect();
214 rect.x += GetColStart(idx);
40dc2ae6 215 rect.width = GetColumn(idx).GetWidth();
b63f9a33
VZ
216
217 RefreshRect(rect);
218}
219
6090efab
VZ
220void wxHeaderCtrl::RefreshColIfNotNone(unsigned int idx)
221{
222 if ( idx != COL_NONE )
223 RefreshCol(idx);
224}
225
b63f9a33
VZ
226void wxHeaderCtrl::RefreshColsAfter(unsigned int idx)
227{
228 wxRect rect = GetClientRect();
229 const int ofs = GetColStart(idx);
230 rect.x += ofs;
231 rect.width -= ofs;
232
233 RefreshRect(rect);
234}
235
aef252d9 236// ----------------------------------------------------------------------------
6327cdd5 237// wxHeaderCtrl dragging/resizing/reordering
aef252d9
VZ
238// ----------------------------------------------------------------------------
239
e36dcd10
VZ
240bool wxHeaderCtrl::IsResizing() const
241{
242 return m_colBeingResized != COL_NONE;
243}
244
6327cdd5
VZ
245bool wxHeaderCtrl::IsReordering() const
246{
247 return m_colBeingReordered != COL_NONE;
248}
249
250void wxHeaderCtrl::ClearMarkers()
251{
252 wxClientDC dc(this);
253
254 wxDCOverlay dcover(m_overlay, &dc);
255 dcover.Clear();
256}
257
aef252d9
VZ
258void wxHeaderCtrl::EndDragging()
259{
58e914f0
RR
260 // We currently only use markers for reordering, not for resizing
261 if (IsReordering())
262 {
263 ClearMarkers();
264 m_overlay.Reset();
265 }
10118a24
VZ
266
267 // don't use the special dragging cursor any more
268 SetCursor(wxNullCursor);
aef252d9
VZ
269}
270
6327cdd5
VZ
271void wxHeaderCtrl::CancelDragging()
272{
273 wxASSERT_MSG( IsDragging(),
274 "shouldn't be called if we're not dragging anything" );
275
276 EndDragging();
277
278 unsigned int& col = IsResizing() ? m_colBeingResized : m_colBeingReordered;
279
ce7fe42e 280 wxHeaderCtrlEvent event(wxEVT_HEADER_DRAGGING_CANCELLED, GetId());
6327cdd5
VZ
281 event.SetEventObject(this);
282 event.SetColumn(col);
283
284 GetEventHandler()->ProcessEvent(event);
285
286 col = COL_NONE;
287}
288
a45caa71
VZ
289int wxHeaderCtrl::ConstrainByMinWidth(unsigned int col, int& xPhysical)
290{
291 const int xStart = GetColStart(col);
292
293 // notice that GetMinWidth() returns 0 if there is no minimal width so it
294 // still makes sense to use it even in this case
295 const int xMinEnd = xStart + GetColumn(col).GetMinWidth();
296
297 if ( xPhysical < xMinEnd )
298 xPhysical = xMinEnd;
299
300 return xPhysical - xStart;
301}
302
303void wxHeaderCtrl::StartOrContinueResizing(unsigned int col, int xPhysical)
304{
ce7fe42e
VZ
305 wxHeaderCtrlEvent event(IsResizing() ? wxEVT_HEADER_RESIZING
306 : wxEVT_HEADER_BEGIN_RESIZE,
a45caa71
VZ
307 GetId());
308 event.SetEventObject(this);
309 event.SetColumn(col);
310
311 event.SetWidth(ConstrainByMinWidth(col, xPhysical));
312
313 if ( GetEventHandler()->ProcessEvent(event) && !event.IsAllowed() )
314 {
315 if ( IsResizing() )
316 {
317 ReleaseMouse();
6327cdd5 318 CancelDragging();
a45caa71
VZ
319 }
320 //else: nothing to do -- we just don't start to resize
321 }
322 else // go ahead with resizing
323 {
324 if ( !IsResizing() )
325 {
326 m_colBeingResized = col;
327 SetCursor(wxCursor(wxCURSOR_SIZEWE));
328 CaptureMouse();
329 }
330 //else: we had already done the above when we started
331
a45caa71
VZ
332 }
333}
334
335void wxHeaderCtrl::EndResizing(int xPhysical)
aef252d9 336{
e36dcd10 337 wxASSERT_MSG( IsResizing(), "shouldn't be called if we're not resizing" );
aef252d9
VZ
338
339 EndDragging();
340
6327cdd5 341 ReleaseMouse();
565804f2 342
ce7fe42e 343 wxHeaderCtrlEvent event(wxEVT_HEADER_END_RESIZE, GetId());
aef252d9
VZ
344 event.SetEventObject(this);
345 event.SetColumn(m_colBeingResized);
6327cdd5 346 event.SetWidth(ConstrainByMinWidth(m_colBeingResized, xPhysical));
aef252d9
VZ
347
348 GetEventHandler()->ProcessEvent(event);
349
350 m_colBeingResized = COL_NONE;
351}
352
6327cdd5
VZ
353void wxHeaderCtrl::UpdateReorderingMarker(int xPhysical)
354{
355 wxClientDC dc(this);
356
357 wxDCOverlay dcover(m_overlay, &dc);
358 dcover.Clear();
359
360 dc.SetPen(*wxBLUE);
361 dc.SetBrush(*wxTRANSPARENT_BRUSH);
362
363 // draw the phantom position of the column being dragged
364 int x = xPhysical - m_dragOffset;
365 int y = GetClientSize().y;
366 dc.DrawRectangle(x, 0,
367 GetColumn(m_colBeingReordered).GetWidth(), y);
368
369 // and also a hint indicating where it is going to be inserted if it's
370 // dropped now
371 unsigned int col = FindColumnAtPoint(xPhysical);
372 if ( col != COL_NONE )
373 {
374 static const int DROP_MARKER_WIDTH = 4;
375
376 dc.SetBrush(*wxBLUE);
377 dc.DrawRectangle(GetColEnd(col) - DROP_MARKER_WIDTH/2, 0,
378 DROP_MARKER_WIDTH, y);
379 }
380}
381
382void wxHeaderCtrl::StartReordering(unsigned int col, int xPhysical)
383{
ce7fe42e 384 wxHeaderCtrlEvent event(wxEVT_HEADER_BEGIN_REORDER, GetId());
6327cdd5
VZ
385 event.SetEventObject(this);
386 event.SetColumn(col);
387
388 if ( GetEventHandler()->ProcessEvent(event) && !event.IsAllowed() )
389 {
390 // don't start dragging it, nothing to do otherwise
391 return;
392 }
393
394 m_dragOffset = xPhysical - GetColStart(col);
395
396 m_colBeingReordered = col;
397 SetCursor(wxCursor(wxCURSOR_HAND));
398 CaptureMouse();
399
59704b49
VZ
400 // do not call UpdateReorderingMarker() here: we don't want to give
401 // feedback for reordering until the user starts to really move the mouse
402 // as he might want to just click on the column and not move it at all
6327cdd5
VZ
403}
404
59704b49 405bool wxHeaderCtrl::EndReordering(int xPhysical)
6327cdd5
VZ
406{
407 wxASSERT_MSG( IsReordering(), "shouldn't be called if we're not reordering" );
408
409 EndDragging();
410
411 ReleaseMouse();
412
59704b49
VZ
413 const int colOld = m_colBeingReordered,
414 colNew = FindColumnAtPoint(xPhysical);
6327cdd5 415
59704b49 416 m_colBeingReordered = COL_NONE;
6327cdd5 417
59704b49
VZ
418 if ( xPhysical - GetColStart(colOld) == m_dragOffset )
419 return false;
420
421 if ( colNew != colOld )
6327cdd5 422 {
ce7fe42e 423 wxHeaderCtrlEvent event(wxEVT_HEADER_END_REORDER, GetId());
59704b49
VZ
424 event.SetEventObject(this);
425 event.SetColumn(colOld);
426
427 const unsigned pos = GetColumnPos(FindColumnAtPoint(xPhysical));
428 event.SetNewOrder(pos);
429
430 if ( !GetEventHandler()->ProcessEvent(event) || event.IsAllowed() )
431 {
432 // do reorder the columns
433 DoMoveCol(colOld, pos);
434 }
6327cdd5
VZ
435 }
436
59704b49
VZ
437 // whether we moved the column or not, the user did move the mouse and so
438 // did try to do it so return true
439 return true;
6327cdd5
VZ
440}
441
20db5469
VZ
442// ----------------------------------------------------------------------------
443// wxHeaderCtrl column reordering
444// ----------------------------------------------------------------------------
445
446void wxHeaderCtrl::DoSetColumnsOrder(const wxArrayInt& order)
447{
448 m_colIndices = order;
449 Refresh();
450}
451
452wxArrayInt wxHeaderCtrl::DoGetColumnsOrder() const
453{
454 return m_colIndices;
455}
456
6327cdd5
VZ
457void wxHeaderCtrl::DoMoveCol(unsigned int idx, unsigned int pos)
458{
1bb74626 459 MoveColumnInOrderArray(m_colIndices, idx, pos);
6327cdd5
VZ
460
461 Refresh();
462}
463
b63f9a33
VZ
464// ----------------------------------------------------------------------------
465// wxHeaderCtrl event handlers
466// ----------------------------------------------------------------------------
467
3bfaa5a7 468BEGIN_EVENT_TABLE(wxHeaderCtrl, wxHeaderCtrlBase)
b63f9a33
VZ
469 EVT_PAINT(wxHeaderCtrl::OnPaint)
470
471 EVT_MOUSE_EVENTS(wxHeaderCtrl::OnMouse)
aef252d9
VZ
472
473 EVT_MOUSE_CAPTURE_LOST(wxHeaderCtrl::OnCaptureLost)
e36dcd10
VZ
474
475 EVT_KEY_DOWN(wxHeaderCtrl::OnKeyDown)
b63f9a33
VZ
476END_EVENT_TABLE()
477
478void wxHeaderCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
479{
480 int w, h;
481 GetClientSize(&w, &h);
03647350 482
b047e876 483#ifdef __WXGTK__
6a2a30a8
RR
484// int vw;
485// GetVirtualSize(&vw, NULL);
b047e876 486#endif
b63f9a33
VZ
487
488 wxAutoBufferedPaintDC dc(this);
489
490 dc.SetBackground(GetBackgroundColour());
491 dc.Clear();
492
493 // account for the horizontal scrollbar offset in the parent window
494 dc.SetDeviceOrigin(m_scrollOffset, 0);
495
40dc2ae6 496 const unsigned int count = m_numColumns;
b63f9a33
VZ
497 int xpos = 0;
498 for ( unsigned int i = 0; i < count; i++ )
499 {
6327cdd5 500 const unsigned idx = m_colIndices[i];
dcb6cbec 501 const wxHeaderColumn& col = GetColumn(idx);
b63f9a33
VZ
502 if ( col.IsHidden() )
503 continue;
504
b047e876 505 int colWidth = col.GetWidth();
b63f9a33
VZ
506
507 wxHeaderSortIconType sortArrow;
40dc2ae6 508 if ( col.IsSortKey() )
b63f9a33 509 {
40dc2ae6
VZ
510 sortArrow = col.IsSortOrderAscending() ? wxHDR_SORT_ICON_UP
511 : wxHDR_SORT_ICON_DOWN;
512 }
513 else // not sorting by this column
514 {
515 sortArrow = wxHDR_SORT_ICON_NONE;
b63f9a33
VZ
516 }
517
518 int state = 0;
519 if ( IsEnabled() )
520 {
6327cdd5 521 if ( idx == m_hover )
b63f9a33
VZ
522 state = wxCONTROL_CURRENT;
523 }
524 else // disabled
525 {
526 state = wxCONTROL_DISABLED;
527 }
03647350 528
b047e876
RR
529 if (i == 0)
530 state |= wxCONTROL_SPECIAL;
b63f9a33
VZ
531
532 wxHeaderButtonParams params;
533 params.m_labelText = col.GetTitle();
534 params.m_labelBitmap = col.GetBitmap();
535 params.m_labelAlignment = col.GetAlignment();
03647350 536
b047e876
RR
537#ifdef __WXGTK__
538 if (i == count-1)
539 {
6a2a30a8 540// colWidth = wxMax( colWidth, vw - xpos );
6f91f3a3 541 state |= wxCONTROL_DIRTY;
b047e876
RR
542 }
543#endif
b63f9a33
VZ
544
545 wxRendererNative::Get().DrawHeaderButton
546 (
547 this,
548 dc,
549 wxRect(xpos, 0, colWidth, h),
550 state,
551 sortArrow,
552 &params
553 );
554
555 xpos += colWidth;
556 }
557}
558
aef252d9
VZ
559void wxHeaderCtrl::OnCaptureLost(wxMouseCaptureLostEvent& WXUNUSED(event))
560{
6327cdd5
VZ
561 if ( IsDragging() )
562 CancelDragging();
e36dcd10
VZ
563}
564
565void wxHeaderCtrl::OnKeyDown(wxKeyEvent& event)
566{
6327cdd5 567 if ( event.GetKeyCode() == WXK_ESCAPE )
e36dcd10 568 {
6327cdd5
VZ
569 if ( IsDragging() )
570 {
571 ReleaseMouse();
572 CancelDragging();
573
574 return;
575 }
e36dcd10 576 }
6327cdd5
VZ
577
578 event.Skip();
aef252d9
VZ
579}
580
fa3d4aaf 581void wxHeaderCtrl::OnMouse(wxMouseEvent& mevent)
b63f9a33 582{
aef252d9
VZ
583 // do this in advance to allow simply returning if we're not interested,
584 // we'll undo it if we do handle the event below
fa3d4aaf
VZ
585 mevent.Skip();
586
aef252d9 587
04a33b50 588 // account for the control displacement
aef252d9
VZ
589 const int xPhysical = mevent.GetX();
590 const int xLogical = xPhysical - m_scrollOffset;
591
592 // first deal with the [continuation of any] dragging operations in
593 // progress
e36dcd10 594 if ( IsResizing() )
aef252d9
VZ
595 {
596 if ( mevent.LeftUp() )
a45caa71 597 EndResizing(xPhysical);
aef252d9 598 else // update the live separator position
a45caa71 599 StartOrContinueResizing(m_colBeingResized, xPhysical);
aef252d9
VZ
600
601 return;
602 }
603
6327cdd5
VZ
604 if ( IsReordering() )
605 {
59704b49
VZ
606 if ( !mevent.LeftUp() )
607 {
608 // update the column position
6327cdd5
VZ
609 UpdateReorderingMarker(xPhysical);
610
59704b49
VZ
611 return;
612 }
613
614 // finish reordering and continue to generate a click event below if we
615 // didn't really reorder anything
616 if ( EndReordering(xPhysical) )
617 return;
6327cdd5
VZ
618 }
619
04a33b50 620
fa3d4aaf
VZ
621 // find if the event is over a column at all
622 bool onSeparator;
6090efab
VZ
623 const unsigned col = mevent.Leaving()
624 ? (onSeparator = false, COL_NONE)
6327cdd5 625 : FindColumnAtPoint(xLogical, &onSeparator);
aef252d9 626
6090efab
VZ
627
628 // update the highlighted column if it changed
629 if ( col != m_hover )
630 {
631 const unsigned hoverOld = m_hover;
632 m_hover = col;
633
634 RefreshColIfNotNone(hoverOld);
635 RefreshColIfNotNone(m_hover);
636 }
637
fa3d4aaf
VZ
638 // update mouse cursor as it moves around
639 if ( mevent.Moving() )
640 {
641 SetCursor(onSeparator ? wxCursor(wxCURSOR_SIZEWE) : wxNullCursor);
642 return;
643 }
644
aef252d9
VZ
645 // all the other events only make sense when they happen over a column
646 if ( col == COL_NONE )
647 return;
648
649
650 // enter various dragging modes on left mouse press
fa3d4aaf
VZ
651 if ( mevent.LeftDown() )
652 {
fa3d4aaf 653 if ( onSeparator )
aef252d9
VZ
654 {
655 // start resizing the column
6327cdd5 656 wxASSERT_MSG( !IsResizing(), "reentering column resize mode?" );
a45caa71 657 StartOrContinueResizing(col, xPhysical);
aef252d9
VZ
658 }
659 else // on column itself
660 {
6327cdd5
VZ
661 // start dragging the column
662 wxASSERT_MSG( !IsReordering(), "reentering column move mode?" );
663
664 StartReordering(col, xPhysical);
aef252d9 665 }
fa3d4aaf
VZ
666
667 return;
668 }
669
aef252d9 670 // determine the type of header event corresponding to click events
3bfaa5a7
VZ
671 wxEventType evtType = wxEVT_NULL;
672 const bool click = mevent.ButtonUp(),
673 dblclk = mevent.ButtonDClick();
674 if ( click || dblclk )
fa3d4aaf
VZ
675 {
676 switch ( mevent.GetButton() )
677 {
678 case wxMOUSE_BTN_LEFT:
3bfaa5a7
VZ
679 // treat left double clicks on separator specially
680 if ( onSeparator && dblclk )
681 {
ce7fe42e 682 evtType = wxEVT_HEADER_SEPARATOR_DCLICK;
3bfaa5a7
VZ
683 }
684 else // not double click on separator
685 {
ce7fe42e
VZ
686 evtType = click ? wxEVT_HEADER_CLICK
687 : wxEVT_HEADER_DCLICK;
3bfaa5a7 688 }
fa3d4aaf
VZ
689 break;
690
691 case wxMOUSE_BTN_RIGHT:
ce7fe42e
VZ
692 evtType = click ? wxEVT_HEADER_RIGHT_CLICK
693 : wxEVT_HEADER_RIGHT_DCLICK;
fa3d4aaf
VZ
694 break;
695
696 case wxMOUSE_BTN_MIDDLE:
ce7fe42e
VZ
697 evtType = click ? wxEVT_HEADER_MIDDLE_CLICK
698 : wxEVT_HEADER_MIDDLE_DCLICK;
fa3d4aaf
VZ
699 break;
700
701 default:
702 // ignore clicks from other mouse buttons
3bfaa5a7 703 ;
fa3d4aaf 704 }
3bfaa5a7
VZ
705 }
706
707 if ( evtType == wxEVT_NULL )
708 return;
fa3d4aaf 709
3bfaa5a7
VZ
710 wxHeaderCtrlEvent event(evtType, GetId());
711 event.SetEventObject(this);
712 event.SetColumn(col);
fa3d4aaf 713
3bfaa5a7
VZ
714 if ( GetEventHandler()->ProcessEvent(event) )
715 mevent.Skip(false);
b63f9a33
VZ
716}
717
56873923 718#endif // wxHAS_GENERIC_HEADERCTRL
e721a2a2
VZ
719
720#endif // wxUSE_HEADERCTRL