| 1 | ///////////////////////////////////////////////////////////////////////////// |
| 2 | // Name: src/palmos/treectrl.cpp |
| 3 | // Purpose: wxTreeCtrl |
| 4 | // Author: William Osborne |
| 5 | // Modified by: |
| 6 | // Created: 10/13/04 |
| 7 | // RCS-ID: $Id: |
| 8 | // Copyright: (c) William Osborne |
| 9 | // Licence: wxWindows licence |
| 10 | ///////////////////////////////////////////////////////////////////////////// |
| 11 | |
| 12 | // ============================================================================ |
| 13 | // declarations |
| 14 | // ============================================================================ |
| 15 | |
| 16 | // ---------------------------------------------------------------------------- |
| 17 | // headers |
| 18 | // ---------------------------------------------------------------------------- |
| 19 | |
| 20 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
| 21 | #pragma implementation "treectrl.h" |
| 22 | #endif |
| 23 | |
| 24 | // For compilers that support precompilation, includes "wx.h". |
| 25 | #include "wx/wxprec.h" |
| 26 | |
| 27 | #ifdef __BORLANDC__ |
| 28 | #pragma hdrstop |
| 29 | #endif |
| 30 | |
| 31 | #if wxUSE_TREECTRL |
| 32 | |
| 33 | #include "wx/palmos/private.h" |
| 34 | |
| 35 | // Set this to 1 to be _absolutely_ sure that repainting will work for all |
| 36 | // comctl32.dll versions |
| 37 | #define wxUSE_COMCTL32_SAFELY 0 |
| 38 | |
| 39 | #include "wx/app.h" |
| 40 | #include "wx/log.h" |
| 41 | #include "wx/dynarray.h" |
| 42 | #include "wx/imaglist.h" |
| 43 | #include "wx/settings.h" |
| 44 | #include "wx/msw/treectrl.h" |
| 45 | #include "wx/msw/dragimag.h" |
| 46 | |
| 47 | #include "wx/palmos/wrapcctl.h" |
| 48 | |
| 49 | // macros to hide the cast ugliness |
| 50 | // -------------------------------- |
| 51 | |
| 52 | // ptr is the real item id, i.e. wxTreeItemId::m_pItem |
| 53 | #define HITEM_PTR(ptr) (HTREEITEM)(ptr) |
| 54 | |
| 55 | // item here is a wxTreeItemId |
| 56 | #define HITEM(item) HITEM_PTR((item).m_pItem) |
| 57 | |
| 58 | // the native control doesn't support multiple selections under MSW and we |
| 59 | // have 2 ways to emulate them: either using TVS_CHECKBOXES style and let |
| 60 | // checkboxes be the selection status (checked == selected) or by really |
| 61 | // emulating everything, i.e. intercepting mouse and key events &c. The first |
| 62 | // approach is much easier but doesn't work with comctl32.dll < 4.71 and also |
| 63 | // looks quite ugly. |
| 64 | #define wxUSE_CHECKBOXES_IN_MULTI_SEL_TREE 0 |
| 65 | |
| 66 | // ---------------------------------------------------------------------------- |
| 67 | // private functions |
| 68 | // ---------------------------------------------------------------------------- |
| 69 | |
| 70 | // ---------------------------------------------------------------------------- |
| 71 | // private classes |
| 72 | // ---------------------------------------------------------------------------- |
| 73 | |
| 74 | // ---------------------------------------------------------------------------- |
| 75 | // wxWin macros |
| 76 | // ---------------------------------------------------------------------------- |
| 77 | |
| 78 | #if wxUSE_EXTENDED_RTTI |
| 79 | WX_DEFINE_FLAGS( wxTreeCtrlStyle ) |
| 80 | |
| 81 | wxBEGIN_FLAGS( wxTreeCtrlStyle ) |
| 82 | // new style border flags, we put them first to |
| 83 | // use them for streaming out |
| 84 | wxFLAGS_MEMBER(wxBORDER_SIMPLE) |
| 85 | wxFLAGS_MEMBER(wxBORDER_SUNKEN) |
| 86 | wxFLAGS_MEMBER(wxBORDER_DOUBLE) |
| 87 | wxFLAGS_MEMBER(wxBORDER_RAISED) |
| 88 | wxFLAGS_MEMBER(wxBORDER_STATIC) |
| 89 | wxFLAGS_MEMBER(wxBORDER_NONE) |
| 90 | |
| 91 | // old style border flags |
| 92 | wxFLAGS_MEMBER(wxSIMPLE_BORDER) |
| 93 | wxFLAGS_MEMBER(wxSUNKEN_BORDER) |
| 94 | wxFLAGS_MEMBER(wxDOUBLE_BORDER) |
| 95 | wxFLAGS_MEMBER(wxRAISED_BORDER) |
| 96 | wxFLAGS_MEMBER(wxSTATIC_BORDER) |
| 97 | wxFLAGS_MEMBER(wxBORDER) |
| 98 | |
| 99 | // standard window styles |
| 100 | wxFLAGS_MEMBER(wxTAB_TRAVERSAL) |
| 101 | wxFLAGS_MEMBER(wxCLIP_CHILDREN) |
| 102 | wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) |
| 103 | wxFLAGS_MEMBER(wxWANTS_CHARS) |
| 104 | wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) |
| 105 | wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) |
| 106 | wxFLAGS_MEMBER(wxVSCROLL) |
| 107 | wxFLAGS_MEMBER(wxHSCROLL) |
| 108 | |
| 109 | wxFLAGS_MEMBER(wxTR_EDIT_LABELS) |
| 110 | wxFLAGS_MEMBER(wxTR_NO_BUTTONS) |
| 111 | wxFLAGS_MEMBER(wxTR_HAS_BUTTONS) |
| 112 | wxFLAGS_MEMBER(wxTR_TWIST_BUTTONS) |
| 113 | wxFLAGS_MEMBER(wxTR_NO_LINES) |
| 114 | wxFLAGS_MEMBER(wxTR_FULL_ROW_HIGHLIGHT) |
| 115 | wxFLAGS_MEMBER(wxTR_LINES_AT_ROOT) |
| 116 | wxFLAGS_MEMBER(wxTR_HIDE_ROOT) |
| 117 | wxFLAGS_MEMBER(wxTR_ROW_LINES) |
| 118 | wxFLAGS_MEMBER(wxTR_HAS_VARIABLE_ROW_HEIGHT) |
| 119 | wxFLAGS_MEMBER(wxTR_SINGLE) |
| 120 | wxFLAGS_MEMBER(wxTR_MULTIPLE) |
| 121 | wxFLAGS_MEMBER(wxTR_EXTENDED) |
| 122 | wxFLAGS_MEMBER(wxTR_DEFAULT_STYLE) |
| 123 | |
| 124 | wxEND_FLAGS( wxTreeCtrlStyle ) |
| 125 | |
| 126 | IMPLEMENT_DYNAMIC_CLASS_XTI(wxTreeCtrl, wxControl,"wx/treectrl.h") |
| 127 | |
| 128 | wxBEGIN_PROPERTIES_TABLE(wxTreeCtrl) |
| 129 | wxEVENT_PROPERTY( TextUpdated , wxEVT_COMMAND_TEXT_UPDATED , wxCommandEvent ) |
| 130 | wxEVENT_RANGE_PROPERTY( TreeEvent , wxEVT_COMMAND_TREE_BEGIN_DRAG , wxEVT_COMMAND_TREE_STATE_IMAGE_CLICK , wxTreeEvent ) |
| 131 | wxPROPERTY_FLAGS( WindowStyle , wxTreeCtrlStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style |
| 132 | wxEND_PROPERTIES_TABLE() |
| 133 | |
| 134 | wxBEGIN_HANDLERS_TABLE(wxTreeCtrl) |
| 135 | wxEND_HANDLERS_TABLE() |
| 136 | |
| 137 | wxCONSTRUCTOR_5( wxTreeCtrl , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size , long , WindowStyle ) |
| 138 | #else |
| 139 | IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrl, wxControl) |
| 140 | #endif |
| 141 | |
| 142 | // ---------------------------------------------------------------------------- |
| 143 | // constants |
| 144 | // ---------------------------------------------------------------------------- |
| 145 | |
| 146 | // indices in gs_expandEvents table below |
| 147 | enum |
| 148 | { |
| 149 | IDX_COLLAPSE, |
| 150 | IDX_EXPAND, |
| 151 | IDX_WHAT_MAX |
| 152 | }; |
| 153 | |
| 154 | enum |
| 155 | { |
| 156 | IDX_DONE, |
| 157 | IDX_DOING, |
| 158 | IDX_HOW_MAX |
| 159 | }; |
| 160 | |
| 161 | // handy table for sending events - it has to be initialized during run-time |
| 162 | // now so can't be const any more |
| 163 | static /* const */ wxEventType gs_expandEvents[IDX_WHAT_MAX][IDX_HOW_MAX]; |
| 164 | |
| 165 | /* |
| 166 | but logically it's a const table with the following entries: |
| 167 | = |
| 168 | { |
| 169 | { wxEVT_COMMAND_TREE_ITEM_COLLAPSED, wxEVT_COMMAND_TREE_ITEM_COLLAPSING }, |
| 170 | { wxEVT_COMMAND_TREE_ITEM_EXPANDED, wxEVT_COMMAND_TREE_ITEM_EXPANDING } |
| 171 | }; |
| 172 | */ |
| 173 | |
| 174 | // ============================================================================ |
| 175 | // implementation |
| 176 | // ============================================================================ |
| 177 | |
| 178 | // ---------------------------------------------------------------------------- |
| 179 | // construction and destruction |
| 180 | // ---------------------------------------------------------------------------- |
| 181 | |
| 182 | void wxTreeCtrl::Init() |
| 183 | { |
| 184 | } |
| 185 | |
| 186 | bool wxTreeCtrl::Create(wxWindow *parent, |
| 187 | wxWindowID id, |
| 188 | const wxPoint& pos, |
| 189 | const wxSize& size, |
| 190 | long style, |
| 191 | const wxValidator& validator, |
| 192 | const wxString& name) |
| 193 | { |
| 194 | return false; |
| 195 | } |
| 196 | |
| 197 | wxTreeCtrl::~wxTreeCtrl() |
| 198 | { |
| 199 | } |
| 200 | |
| 201 | // ---------------------------------------------------------------------------- |
| 202 | // accessors |
| 203 | // ---------------------------------------------------------------------------- |
| 204 | |
| 205 | /* static */ wxVisualAttributes |
| 206 | wxTreeCtrl::GetClassDefaultAttributes(wxWindowVariant variant) |
| 207 | { |
| 208 | wxVisualAttributes attrs; |
| 209 | |
| 210 | return attrs; |
| 211 | } |
| 212 | |
| 213 | |
| 214 | // simple wrappers which add error checking in debug mode |
| 215 | |
| 216 | bool wxTreeCtrl::DoGetItem(wxTreeViewItem* tvItem) const |
| 217 | { |
| 218 | return false; |
| 219 | } |
| 220 | |
| 221 | void wxTreeCtrl::DoSetItem(wxTreeViewItem* tvItem) |
| 222 | { |
| 223 | } |
| 224 | |
| 225 | size_t wxTreeCtrl::GetCount() const |
| 226 | { |
| 227 | return 0; |
| 228 | } |
| 229 | |
| 230 | unsigned int wxTreeCtrl::GetIndent() const |
| 231 | { |
| 232 | return 0; |
| 233 | } |
| 234 | |
| 235 | void wxTreeCtrl::SetIndent(unsigned int indent) |
| 236 | { |
| 237 | } |
| 238 | |
| 239 | wxImageList *wxTreeCtrl::GetImageList() const |
| 240 | { |
| 241 | return m_imageListNormal; |
| 242 | } |
| 243 | |
| 244 | wxImageList *wxTreeCtrl::GetStateImageList() const |
| 245 | { |
| 246 | return m_imageListState; |
| 247 | } |
| 248 | |
| 249 | void wxTreeCtrl::SetAnyImageList(wxImageList *imageList, int which) |
| 250 | { |
| 251 | } |
| 252 | |
| 253 | void wxTreeCtrl::SetImageList(wxImageList *imageList) |
| 254 | { |
| 255 | } |
| 256 | |
| 257 | void wxTreeCtrl::SetStateImageList(wxImageList *imageList) |
| 258 | { |
| 259 | } |
| 260 | |
| 261 | void wxTreeCtrl::AssignImageList(wxImageList *imageList) |
| 262 | { |
| 263 | } |
| 264 | |
| 265 | void wxTreeCtrl::AssignStateImageList(wxImageList *imageList) |
| 266 | { |
| 267 | } |
| 268 | |
| 269 | size_t wxTreeCtrl::GetChildrenCount(const wxTreeItemId& item, |
| 270 | bool recursively) const |
| 271 | { |
| 272 | return 0; |
| 273 | } |
| 274 | |
| 275 | // ---------------------------------------------------------------------------- |
| 276 | // control colours |
| 277 | // ---------------------------------------------------------------------------- |
| 278 | |
| 279 | bool wxTreeCtrl::SetBackgroundColour(const wxColour &colour) |
| 280 | { |
| 281 | return false; |
| 282 | } |
| 283 | |
| 284 | bool wxTreeCtrl::SetForegroundColour(const wxColour &colour) |
| 285 | { |
| 286 | return false; |
| 287 | } |
| 288 | |
| 289 | // ---------------------------------------------------------------------------- |
| 290 | // Item access |
| 291 | // ---------------------------------------------------------------------------- |
| 292 | |
| 293 | wxString wxTreeCtrl::GetItemText(const wxTreeItemId& item) const |
| 294 | { |
| 295 | return wxString; |
| 296 | } |
| 297 | |
| 298 | void wxTreeCtrl::SetItemText(const wxTreeItemId& item, const wxString& text) |
| 299 | { |
| 300 | } |
| 301 | |
| 302 | int wxTreeCtrl::DoGetItemImageFromData(const wxTreeItemId& item, |
| 303 | wxTreeItemIcon which) const |
| 304 | { |
| 305 | return -1; |
| 306 | } |
| 307 | |
| 308 | void wxTreeCtrl::DoSetItemImageFromData(const wxTreeItemId& item, |
| 309 | int image, |
| 310 | wxTreeItemIcon which) const |
| 311 | { |
| 312 | } |
| 313 | |
| 314 | void wxTreeCtrl::DoSetItemImages(const wxTreeItemId& item, |
| 315 | int image, |
| 316 | int imageSel) |
| 317 | { |
| 318 | } |
| 319 | |
| 320 | int wxTreeCtrl::GetItemImage(const wxTreeItemId& item, |
| 321 | wxTreeItemIcon which) const |
| 322 | { |
| 323 | return -1; |
| 324 | } |
| 325 | |
| 326 | void wxTreeCtrl::SetItemImage(const wxTreeItemId& item, int image, |
| 327 | wxTreeItemIcon which) |
| 328 | { |
| 329 | } |
| 330 | |
| 331 | wxTreeItemData *wxTreeCtrl::GetItemData(const wxTreeItemId& item) const |
| 332 | { |
| 333 | return NULL; |
| 334 | } |
| 335 | |
| 336 | void wxTreeCtrl::SetItemData(const wxTreeItemId& item, wxTreeItemData *data) |
| 337 | { |
| 338 | } |
| 339 | |
| 340 | void wxTreeCtrl::SetIndirectItemData(const wxTreeItemId& item, |
| 341 | wxTreeItemIndirectData *data) |
| 342 | { |
| 343 | } |
| 344 | |
| 345 | bool wxTreeCtrl::HasIndirectData(const wxTreeItemId& item) const |
| 346 | { |
| 347 | return false; |
| 348 | } |
| 349 | |
| 350 | void wxTreeCtrl::SetItemHasChildren(const wxTreeItemId& item, bool has) |
| 351 | { |
| 352 | } |
| 353 | |
| 354 | void wxTreeCtrl::SetItemBold(const wxTreeItemId& item, bool bold) |
| 355 | { |
| 356 | } |
| 357 | |
| 358 | void wxTreeCtrl::SetItemDropHighlight(const wxTreeItemId& item, bool highlight) |
| 359 | { |
| 360 | } |
| 361 | |
| 362 | void wxTreeCtrl::RefreshItem(const wxTreeItemId& item) |
| 363 | { |
| 364 | } |
| 365 | |
| 366 | wxColour wxTreeCtrl::GetItemTextColour(const wxTreeItemId& item) const |
| 367 | { |
| 368 | return wxNullColour; |
| 369 | } |
| 370 | |
| 371 | wxColour wxTreeCtrl::GetItemBackgroundColour(const wxTreeItemId& item) const |
| 372 | { |
| 373 | return wxNullColour; |
| 374 | } |
| 375 | |
| 376 | wxFont wxTreeCtrl::GetItemFont(const wxTreeItemId& item) const |
| 377 | { |
| 378 | return wxNullFont; |
| 379 | } |
| 380 | |
| 381 | void wxTreeCtrl::SetItemTextColour(const wxTreeItemId& item, |
| 382 | const wxColour& col) |
| 383 | { |
| 384 | } |
| 385 | |
| 386 | void wxTreeCtrl::SetItemBackgroundColour(const wxTreeItemId& item, |
| 387 | const wxColour& col) |
| 388 | { |
| 389 | } |
| 390 | |
| 391 | void wxTreeCtrl::SetItemFont(const wxTreeItemId& item, const wxFont& font) |
| 392 | { |
| 393 | } |
| 394 | |
| 395 | // ---------------------------------------------------------------------------- |
| 396 | // Item status |
| 397 | // ---------------------------------------------------------------------------- |
| 398 | |
| 399 | bool wxTreeCtrl::IsVisible(const wxTreeItemId& item) const |
| 400 | { |
| 401 | return false; |
| 402 | } |
| 403 | |
| 404 | bool wxTreeCtrl::ItemHasChildren(const wxTreeItemId& item) const |
| 405 | { |
| 406 | return false; |
| 407 | } |
| 408 | |
| 409 | bool wxTreeCtrl::IsExpanded(const wxTreeItemId& item) const |
| 410 | { |
| 411 | return false; |
| 412 | } |
| 413 | |
| 414 | bool wxTreeCtrl::IsSelected(const wxTreeItemId& item) const |
| 415 | { |
| 416 | return false; |
| 417 | } |
| 418 | |
| 419 | bool wxTreeCtrl::IsBold(const wxTreeItemId& item) const |
| 420 | { |
| 421 | return false; |
| 422 | } |
| 423 | |
| 424 | // ---------------------------------------------------------------------------- |
| 425 | // navigation |
| 426 | // ---------------------------------------------------------------------------- |
| 427 | |
| 428 | wxTreeItemId wxTreeCtrl::GetRootItem() const |
| 429 | { |
| 430 | // Root may be real (visible) or virtual (hidden). |
| 431 | if ( GET_VIRTUAL_ROOT() ) |
| 432 | return TVI_ROOT; |
| 433 | |
| 434 | return wxTreeItemId(TreeView_GetRoot(GetHwnd())); |
| 435 | } |
| 436 | |
| 437 | wxTreeItemId wxTreeCtrl::GetSelection() const |
| 438 | { |
| 439 | return 0; |
| 440 | } |
| 441 | |
| 442 | wxTreeItemId wxTreeCtrl::GetItemParent(const wxTreeItemId& item) const |
| 443 | { |
| 444 | return 0; |
| 445 | } |
| 446 | |
| 447 | wxTreeItemId wxTreeCtrl::GetFirstChild(const wxTreeItemId& item, |
| 448 | wxTreeItemIdValue& cookie) const |
| 449 | { |
| 450 | return 0; |
| 451 | } |
| 452 | |
| 453 | wxTreeItemId wxTreeCtrl::GetNextChild(const wxTreeItemId& WXUNUSED(item), |
| 454 | wxTreeItemIdValue& cookie) const |
| 455 | { |
| 456 | return 0; |
| 457 | } |
| 458 | |
| 459 | #if WXWIN_COMPATIBILITY_2_4 |
| 460 | |
| 461 | wxTreeItemId wxTreeCtrl::GetFirstChild(const wxTreeItemId& item, |
| 462 | long& cookie) const |
| 463 | { |
| 464 | return 0; |
| 465 | } |
| 466 | |
| 467 | wxTreeItemId wxTreeCtrl::GetNextChild(const wxTreeItemId& WXUNUSED(item), |
| 468 | long& cookie) const |
| 469 | { |
| 470 | return 0; |
| 471 | } |
| 472 | |
| 473 | #endif // WXWIN_COMPATIBILITY_2_4 |
| 474 | |
| 475 | wxTreeItemId wxTreeCtrl::GetLastChild(const wxTreeItemId& item) const |
| 476 | { |
| 477 | return 0; |
| 478 | } |
| 479 | |
| 480 | wxTreeItemId wxTreeCtrl::GetNextSibling(const wxTreeItemId& item) const |
| 481 | { |
| 482 | return 0; |
| 483 | } |
| 484 | |
| 485 | wxTreeItemId wxTreeCtrl::GetPrevSibling(const wxTreeItemId& item) const |
| 486 | { |
| 487 | return 0; |
| 488 | } |
| 489 | |
| 490 | wxTreeItemId wxTreeCtrl::GetFirstVisibleItem() const |
| 491 | { |
| 492 | return 0; |
| 493 | } |
| 494 | |
| 495 | wxTreeItemId wxTreeCtrl::GetNextVisible(const wxTreeItemId& item) const |
| 496 | { |
| 497 | return 0; |
| 498 | } |
| 499 | |
| 500 | wxTreeItemId wxTreeCtrl::GetPrevVisible(const wxTreeItemId& item) const |
| 501 | { |
| 502 | return 0; |
| 503 | } |
| 504 | |
| 505 | // ---------------------------------------------------------------------------- |
| 506 | // multiple selections emulation |
| 507 | // ---------------------------------------------------------------------------- |
| 508 | |
| 509 | bool wxTreeCtrl::IsItemChecked(const wxTreeItemId& item) const |
| 510 | { |
| 511 | return false; |
| 512 | } |
| 513 | |
| 514 | void wxTreeCtrl::SetItemCheck(const wxTreeItemId& item, bool check) |
| 515 | { |
| 516 | } |
| 517 | |
| 518 | size_t wxTreeCtrl::GetSelections(wxArrayTreeItemIds& selections) const |
| 519 | { |
| 520 | return 0; |
| 521 | } |
| 522 | |
| 523 | // ---------------------------------------------------------------------------- |
| 524 | // Usual operations |
| 525 | // ---------------------------------------------------------------------------- |
| 526 | |
| 527 | wxTreeItemId wxTreeCtrl::DoInsertItem(const wxTreeItemId& parent, |
| 528 | wxTreeItemId hInsertAfter, |
| 529 | const wxString& text, |
| 530 | int image, int selectedImage, |
| 531 | wxTreeItemData *data) |
| 532 | { |
| 533 | return 0; |
| 534 | } |
| 535 | |
| 536 | // for compatibility only |
| 537 | #if WXWIN_COMPATIBILITY_2_4 |
| 538 | |
| 539 | wxTreeItemId wxTreeCtrl::InsertItem(const wxTreeItemId& parent, |
| 540 | const wxString& text, |
| 541 | int image, int selImage, |
| 542 | long insertAfter) |
| 543 | { |
| 544 | return 0; |
| 545 | } |
| 546 | |
| 547 | #endif // WXWIN_COMPATIBILITY_2_4 |
| 548 | |
| 549 | wxTreeItemId wxTreeCtrl::AddRoot(const wxString& text, |
| 550 | int image, int selectedImage, |
| 551 | wxTreeItemData *data) |
| 552 | { |
| 553 | return 0; |
| 554 | } |
| 555 | |
| 556 | wxTreeItemId wxTreeCtrl::PrependItem(const wxTreeItemId& parent, |
| 557 | const wxString& text, |
| 558 | int image, int selectedImage, |
| 559 | wxTreeItemData *data) |
| 560 | { |
| 561 | return 0; |
| 562 | } |
| 563 | |
| 564 | wxTreeItemId wxTreeCtrl::InsertItem(const wxTreeItemId& parent, |
| 565 | const wxTreeItemId& idPrevious, |
| 566 | const wxString& text, |
| 567 | int image, int selectedImage, |
| 568 | wxTreeItemData *data) |
| 569 | { |
| 570 | return 0; |
| 571 | } |
| 572 | |
| 573 | wxTreeItemId wxTreeCtrl::InsertItem(const wxTreeItemId& parent, |
| 574 | size_t index, |
| 575 | const wxString& text, |
| 576 | int image, int selectedImage, |
| 577 | wxTreeItemData *data) |
| 578 | { |
| 579 | return 0; |
| 580 | } |
| 581 | |
| 582 | wxTreeItemId wxTreeCtrl::AppendItem(const wxTreeItemId& parent, |
| 583 | const wxString& text, |
| 584 | int image, int selectedImage, |
| 585 | wxTreeItemData *data) |
| 586 | { |
| 587 | return 0; |
| 588 | } |
| 589 | |
| 590 | void wxTreeCtrl::Delete(const wxTreeItemId& item) |
| 591 | { |
| 592 | return 0; |
| 593 | } |
| 594 | |
| 595 | // delete all children (but don't delete the item itself) |
| 596 | void wxTreeCtrl::DeleteChildren(const wxTreeItemId& item) |
| 597 | { |
| 598 | } |
| 599 | |
| 600 | void wxTreeCtrl::DeleteAllItems() |
| 601 | { |
| 602 | } |
| 603 | |
| 604 | void wxTreeCtrl::DoExpand(const wxTreeItemId& item, int flag) |
| 605 | { |
| 606 | } |
| 607 | |
| 608 | void wxTreeCtrl::Expand(const wxTreeItemId& item) |
| 609 | { |
| 610 | } |
| 611 | |
| 612 | void wxTreeCtrl::Collapse(const wxTreeItemId& item) |
| 613 | { |
| 614 | } |
| 615 | |
| 616 | void wxTreeCtrl::CollapseAndReset(const wxTreeItemId& item) |
| 617 | { |
| 618 | } |
| 619 | |
| 620 | void wxTreeCtrl::Toggle(const wxTreeItemId& item) |
| 621 | { |
| 622 | } |
| 623 | |
| 624 | #if WXWIN_COMPATIBILITY_2_4 |
| 625 | void wxTreeCtrl::ExpandItem(const wxTreeItemId& item, int action) |
| 626 | { |
| 627 | } |
| 628 | #endif |
| 629 | |
| 630 | void wxTreeCtrl::Unselect() |
| 631 | { |
| 632 | } |
| 633 | |
| 634 | void wxTreeCtrl::UnselectAll() |
| 635 | { |
| 636 | } |
| 637 | |
| 638 | void wxTreeCtrl::SelectItem(const wxTreeItemId& item, bool select) |
| 639 | { |
| 640 | } |
| 641 | |
| 642 | void wxTreeCtrl::UnselectItem(const wxTreeItemId& item) |
| 643 | { |
| 644 | } |
| 645 | |
| 646 | void wxTreeCtrl::ToggleItemSelection(const wxTreeItemId& item) |
| 647 | { |
| 648 | } |
| 649 | |
| 650 | void wxTreeCtrl::EnsureVisible(const wxTreeItemId& item) |
| 651 | { |
| 652 | } |
| 653 | |
| 654 | void wxTreeCtrl::ScrollTo(const wxTreeItemId& item) |
| 655 | { |
| 656 | } |
| 657 | |
| 658 | wxTextCtrl *wxTreeCtrl::GetEditControl() const |
| 659 | { |
| 660 | return NULL; |
| 661 | } |
| 662 | |
| 663 | void wxTreeCtrl::DeleteTextCtrl() |
| 664 | { |
| 665 | } |
| 666 | |
| 667 | wxTextCtrl* wxTreeCtrl::EditLabel(const wxTreeItemId& item, |
| 668 | wxClassInfo* textControlClass) |
| 669 | { |
| 670 | return NULL; |
| 671 | } |
| 672 | |
| 673 | // End label editing, optionally cancelling the edit |
| 674 | void wxTreeCtrl::EndEditLabel(const wxTreeItemId& WXUNUSED(item), bool discardChanges) |
| 675 | { |
| 676 | } |
| 677 | |
| 678 | wxTreeItemId wxTreeCtrl::HitTest(const wxPoint& point, int& flags) |
| 679 | { |
| 680 | return 0; |
| 681 | } |
| 682 | |
| 683 | bool wxTreeCtrl::GetBoundingRect(const wxTreeItemId& item, |
| 684 | wxRect& rect, |
| 685 | bool textOnly) const |
| 686 | { |
| 687 | return false; |
| 688 | } |
| 689 | |
| 690 | // ---------------------------------------------------------------------------- |
| 691 | // sorting stuff |
| 692 | // ---------------------------------------------------------------------------- |
| 693 | |
| 694 | // this is just a tiny namespace which is friend to wxTreeCtrl and so can use |
| 695 | // functions such as IsDataIndirect() |
| 696 | class wxTreeSortHelper |
| 697 | { |
| 698 | public: |
| 699 | static int CALLBACK Compare(LPARAM data1, LPARAM data2, LPARAM tree); |
| 700 | |
| 701 | private: |
| 702 | static wxTreeItemId GetIdFromData(wxTreeCtrl *tree, LPARAM item) |
| 703 | { |
| 704 | wxTreeItemData *data = (wxTreeItemData *)item; |
| 705 | if ( tree->IsDataIndirect(data) ) |
| 706 | { |
| 707 | data = ((wxTreeItemIndirectData *)data)->GetData(); |
| 708 | } |
| 709 | |
| 710 | return data->GetId(); |
| 711 | } |
| 712 | }; |
| 713 | |
| 714 | int CALLBACK wxTreeSortHelper::Compare(LPARAM pItem1, |
| 715 | LPARAM pItem2, |
| 716 | LPARAM htree) |
| 717 | { |
| 718 | wxCHECK_MSG( pItem1 && pItem2, 0, |
| 719 | wxT("sorting tree without data doesn't make sense") ); |
| 720 | |
| 721 | wxTreeCtrl *tree = (wxTreeCtrl *)htree; |
| 722 | |
| 723 | return tree->OnCompareItems(GetIdFromData(tree, pItem1), |
| 724 | GetIdFromData(tree, pItem2)); |
| 725 | } |
| 726 | |
| 727 | int wxTreeCtrl::OnCompareItems(const wxTreeItemId& item1, |
| 728 | const wxTreeItemId& item2) |
| 729 | { |
| 730 | return wxStrcmp(GetItemText(item1), GetItemText(item2)); |
| 731 | } |
| 732 | |
| 733 | void wxTreeCtrl::SortChildren(const wxTreeItemId& item) |
| 734 | { |
| 735 | wxCHECK_RET( item.IsOk(), wxT("invalid tree item") ); |
| 736 | |
| 737 | // rely on the fact that TreeView_SortChildren does the same thing as our |
| 738 | // default behaviour, i.e. sorts items alphabetically and so call it |
| 739 | // directly if we're not in derived class (much more efficient!) |
| 740 | if ( GetClassInfo() == CLASSINFO(wxTreeCtrl) ) |
| 741 | { |
| 742 | TreeView_SortChildren(GetHwnd(), HITEM(item), 0); |
| 743 | } |
| 744 | else |
| 745 | { |
| 746 | TV_SORTCB tvSort; |
| 747 | tvSort.hParent = HITEM(item); |
| 748 | tvSort.lpfnCompare = wxTreeSortHelper::Compare; |
| 749 | tvSort.lParam = (LPARAM)this; |
| 750 | TreeView_SortChildrenCB(GetHwnd(), &tvSort, 0 /* reserved */); |
| 751 | } |
| 752 | } |
| 753 | |
| 754 | // ---------------------------------------------------------------------------- |
| 755 | // implementation |
| 756 | // ---------------------------------------------------------------------------- |
| 757 | |
| 758 | bool wxTreeCtrl::MSWCommand(WXUINT cmd, WXWORD id) |
| 759 | { |
| 760 | return false; |
| 761 | } |
| 762 | |
| 763 | WXLRESULT wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) |
| 764 | { |
| 765 | return 0; |
| 766 | } |
| 767 | |
| 768 | // process WM_NOTIFY Windows message |
| 769 | bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) |
| 770 | { |
| 771 | return false; |
| 772 | } |
| 773 | |
| 774 | // ---------------------------------------------------------------------------- |
| 775 | // State control. |
| 776 | // ---------------------------------------------------------------------------- |
| 777 | |
| 778 | // why do they define INDEXTOSTATEIMAGEMASK but not the inverse? |
| 779 | #define STATEIMAGEMASKTOINDEX(state) (((state) & TVIS_STATEIMAGEMASK) >> 12) |
| 780 | |
| 781 | void wxTreeCtrl::SetState(const wxTreeItemId& node, int state) |
| 782 | { |
| 783 | } |
| 784 | |
| 785 | int wxTreeCtrl::GetState(const wxTreeItemId& node) |
| 786 | { |
| 787 | return 0; |
| 788 | } |
| 789 | |
| 790 | #endif // wxUSE_TREECTRL |
| 791 | |