| 1 | /////////////////////////////////////////////////////////////////////////////// |
| 2 | // Name: src/common/headercolcmn.cpp |
| 3 | // Purpose: wxHeaderColumn implementation |
| 4 | // Author: Vadim Zeitlin |
| 5 | // Created: 2008-12-02 |
| 6 | // RCS-ID: $Id$ |
| 7 | // Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org> |
| 8 | // Licence: wxWindows licence |
| 9 | /////////////////////////////////////////////////////////////////////////////// |
| 10 | |
| 11 | // ============================================================================ |
| 12 | // declarations |
| 13 | // ============================================================================ |
| 14 | |
| 15 | // ---------------------------------------------------------------------------- |
| 16 | // headers |
| 17 | // ---------------------------------------------------------------------------- |
| 18 | |
| 19 | // for compilers that support precompilation, includes "wx.h". |
| 20 | #include "wx/wxprec.h" |
| 21 | |
| 22 | #ifdef __BORLANDC__ |
| 23 | #pragma hdrstop |
| 24 | #endif |
| 25 | |
| 26 | #ifndef WX_PRECOMP |
| 27 | #endif // WX_PRECOMP |
| 28 | |
| 29 | #include "wx/headercol.h" |
| 30 | |
| 31 | // ============================================================================ |
| 32 | // wxHeaderColumn implementation |
| 33 | // ============================================================================ |
| 34 | |
| 35 | int wxHeaderColumn::GetFromIndividualFlags() const |
| 36 | { |
| 37 | int flags = 0; |
| 38 | |
| 39 | if ( IsResizeable() ) |
| 40 | flags |= wxCOL_RESIZABLE; |
| 41 | if ( IsSortable() ) |
| 42 | flags |= wxCOL_SORTABLE; |
| 43 | if ( IsReorderable() ) |
| 44 | flags |= wxCOL_REORDERABLE; |
| 45 | if ( IsHidden() ) |
| 46 | flags |= wxCOL_HIDDEN; |
| 47 | |
| 48 | return flags; |
| 49 | } |
| 50 | |
| 51 | // ============================================================================ |
| 52 | // wxSettableHeaderColumn implementation |
| 53 | // ============================================================================ |
| 54 | |
| 55 | void wxSettableHeaderColumn::SetIndividualFlags(int flags) |
| 56 | { |
| 57 | SetResizeable((flags & wxCOL_RESIZABLE) != 0); |
| 58 | SetSortable((flags & wxCOL_SORTABLE) != 0); |
| 59 | SetReorderable((flags & wxCOL_REORDERABLE) != 0); |
| 60 | SetHidden((flags & wxCOL_HIDDEN) != 0); |
| 61 | } |
| 62 | |
| 63 | void wxSettableHeaderColumn::ChangeFlag(int flag, bool set) |
| 64 | { |
| 65 | if ( HasFlag(flag) != set ) |
| 66 | ToggleFlag(flag); |
| 67 | } |
| 68 | |
| 69 | void wxSettableHeaderColumn::SetFlag(int flag) |
| 70 | { |
| 71 | int flags = GetFlags(); |
| 72 | if ( !(flags & flag) ) |
| 73 | SetFlags(flags | flag); |
| 74 | } |
| 75 | |
| 76 | void wxSettableHeaderColumn::ClearFlag(int flag) |
| 77 | { |
| 78 | int flags = GetFlags(); |
| 79 | if ( flags & flag ) |
| 80 | SetFlags(flags & ~flag); |
| 81 | } |
| 82 | |
| 83 | void wxSettableHeaderColumn::ToggleFlag(int flag) |
| 84 | { |
| 85 | int flags = GetFlags(); |
| 86 | if ( flags & flag ) |
| 87 | flags &= ~flag; |
| 88 | else |
| 89 | flags |= flag; |
| 90 | |
| 91 | SetFlags(flags); |
| 92 | } |
| 93 | |
| 94 | |