Sets the key for the given index
| 352 | // Sets the key for the given index |
| 353 | // |
| 354 | bool |
| 355 | KeyView::SetKey(int index, const NormalizedKeyString & key) |
| 356 | { |
| 357 | // Make sure index is valid |
| 358 | if (index < 0 || index >= (int) mNodes.size()) |
| 359 | { |
| 360 | wxASSERT(false); |
| 361 | return false; |
| 362 | } |
| 363 | |
| 364 | // Cache the node |
| 365 | KeyNode & node = mNodes[index]; |
| 366 | |
| 367 | // Do not allow setting keys on branches |
| 368 | if (node.isparent) |
| 369 | { |
| 370 | return false; |
| 371 | } |
| 372 | |
| 373 | // Set the NEW key |
| 374 | node.key = key; |
| 375 | |
| 376 | // Check to see if the key column needs to be expanded |
| 377 | int x, y; |
| 378 | GetTextExtent(node.key.Display(), &x, &y); |
| 379 | if (x > mKeyWidth || y > mLineHeight) |
| 380 | { |
| 381 | // New key is wider than column so recalc extents (will refresh view) |
| 382 | RecalcExtents(); |
| 383 | return true; |
| 384 | } |
| 385 | |
| 386 | // Refresh the view lines |
| 387 | RefreshAll(); |
| 388 | |
| 389 | return true; |
| 390 | } |
| 391 | |
| 392 | // |
| 393 | // Sets the key for the given name |
no test coverage detected