treelistcontrol.cpp
来自「这是VCF框架的代码」· C++ 代码 · 共 2,390 行 · 第 1/5 页
CPP
2,390 行
repaint();}void TreeListControl::showColumnHeader( const bool& show ){ if ( true == show ) { header_->setHeight( columnHeight_ ); displayOptions_ |= TreeListControl::tdoShowColumnHeader; } else { header_->setHeight( 0 ); displayOptions_ &= ~TreeListControl::tdoShowColumnHeader; } repaint();}ColumnModel* TreeListControl::getColumnModel(){ return header_->getColumnModel();}double TreeListControl::getColumnWidth( const unsigned long& index ){ double result = -1; ColumnModel* model = header_->getColumnModel(); ColumnItem* item = model->getItemFromIndex( index ); if ( NULL != item ) { result = item->getWidth(); } return result;}void TreeListControl::setColumnWidth( const unsigned long& index, const double& width ){ ColumnModel* model = header_->getColumnModel(); ColumnItem* item = model->getItemFromIndex( index ); if ( NULL != item ) { item->setWidth( width ); }}bool TreeListControl::listSelectedItems( std::vector<TreeItem*>& items, TreeItem* firstSelectedItem, TreeItem* lastSelectedItem, TreeItem* nextItem, bool& startFound ){ bool result = false; TreeItem* next = NULL; if ( false == startFound ) { startFound = (nextItem == firstSelectedItem); } if ( (true == startFound) && (nextItem != lastSelectedItem) ){ items.push_back( nextItem ); result = false; } else if ( (true == startFound) && (nextItem == lastSelectedItem) ){ items.push_back( nextItem ); result = true; } if ( (false == result) && (false == nextItem->isLeaf()) && (true == nextItem->isExpanded()) ) { next = nextItem->getChildren()->nextElement(); while ( next ) { if ( false == startFound ) { startFound = (next == firstSelectedItem); } if ( (true == startFound) && (next != lastSelectedItem) ) { items.push_back( next ); result = false; } else if ( (true == startFound) && (next == lastSelectedItem) ) { result = true; items.push_back( next ); break; } if ( false == result ) { result = listSelectedItems( items, firstSelectedItem, lastSelectedItem, next, startFound ); } next = next->getNextChildNodeItem(); } } return result;}void TreeListControl::onEditingControlKeyPressed( KeyboardEvent* event ) { switch ( event->getVirtualCode() ) { case vkEscape : { cancelEditing(); } break; case vkReturn : { event->setConsumed( true ); finishEditing(); } break; case vkDownArrow : case vkUpArrow : { setFocused(); // this will kill the edit KeyboardEvent* event2 = new KeyboardEvent( this, event->getType(), event->getRepeatCount(), event->getKeyMask(), event->getKeyValue(), event->getVirtualCode() ); handleEvent( event2 ); event2->free(); TreeItem* item = getSelectedItem(); if ( NULL != item ) { editItem( item, NULL ); } } break; }}bool TreeListControl::finishEditingFromFocusLoss( Control* lostFocusCtrl, Control* currentFocusedCtrl ){ bool result = true; Control* parent = currentFocusedCtrl->getParent(); while ( NULL != parent ) { if ( currentEditingControl_ == parent ) { //skip function, we don't need to do anything //at all! result = false; break; } parent = parent->getParent(); } return result;}void TreeListControl::onEditorFocusLost( Event* e ) { Control* control = (Control*)e->getSource(); //check to see if we have lost focus because //we have clicked on a child control of the //currentEditingControl_ Control* currentFocused = Control::getCurrentFocusedControl(); if ( finishEditingFromFocusLoss( control, currentFocused ) ) { finishEditing(); } }void TreeListControl::postFinishedEditing( Event* e ) { Control* editControl = (Control*) e->getUserData(); remove( editControl ); removeComponent( editControl ); editControl->free(); repaint(); }void TreeListControl::cancelEditing() { finishEditing( false );}void TreeListControl::finishEditing( bool applyEdit ) { if ( NULL == currentEditingControl_ ) { return; } if ( applyEdit ) { TreeItem* item = getSelectedItem(); finishEditingItem( item, currentEditingControl_ ); } EventHandler* ev = getEventHandler( "TreeListControl::postFinishedEditing" ); if ( NULL == ev ) { ev = new GenericEventHandler<TreeListControl>( this, &TreeListControl::postFinishedEditing, "TreeListControl::postFinishedEditing" ); } Event* e = new Event( this ); e->setUserData( currentEditingControl_ ); UIToolkit::postEvent( ev, e, false ); currentEditingControl_ = NULL;}void TreeListControl::editItem( TreeItem* item, Point* point ) { if ( NULL != currentEditingControl_ ) { finishEditing(); } currentEditingControl_ = NULL; if ( NULL != point ) { currentEditColumn_ = hitTestForEditColumn( point ); } Rect bounds = getBoundsForEdit( item, currentEditColumn_ ); if ( currentEditColumn_ != -1 ) { Control* editor = createEditor( item, currentEditColumn_ ); if ( NULL != editor ) { editor->setBounds( &bounds ); EventHandler* ev = getEventHandler( "TreeListControl::onEditorFocusLost" ); editor->FocusLost += ev; ev = getEventHandler( "TreeListControl::onEditingControlKeyPressed" ); editor->KeyDown.addHandler( ev ); add( editor ); editor->setVisible( true ); editor->setFocused(); currentEditingControl_ = editor; } } }/***CVS Log info*$Log$*Revision 1.5 2006/04/07 02:35:25 ddiego*initial checkin of merge from 0.6.9 dev branch.**Revision 1.4.2.7 2006/03/26 16:52:10 ddiego*fixed a bug in the treelist control that was incorrectly*calculating the virtual height for the control.**Revision 1.4.2.6 2006/03/22 03:18:20 ddiego*fixed a glitch in scroll vert and horz position values.**Revision 1.4.2.5 2006/03/21 00:57:35 ddiego*fixed bug in table control - problem was really with casting a*model to a table model, and having the pointer value not be right. Needed*to use dynamic_cast() to fix it. Curiously this problem was not flagegd in*debug at all.**Revision 1.4.2.4 2005/10/04 01:57:03 ddiego*fixed some miscellaneous issues, especially with model ownership.**Revision 1.4.2.3 2005/09/14 01:50:07 ddiego*minor adjustment to control for enable setting. and registered*more proeprty editors.**Revision 1.4.2.2 2005/09/12 03:47:04 ddiego*more prop editor updates.**Revision 1.4.2.1 2005/08/15 03:10:51 ddiego*minor updates to vff in out streaming.**Revision 1.4 2005/07/09 23:14:56 ddiego*merging in changes from devmain-0-6-7 branch.**Revision 1.3.2.8 2005/07/01 15:47:56 marcelloptr*minor improvements on a message**Revision 1.3.2.7 2005/03/04 04:41:55 ddiego*fixed a bug in the tree list control that was not taking into account the tree item text color or text bold.**Revision 1.3.2.6 2005/02/21 16:20:01 ddiego*minor changes to various things, property editors, and tree list control.**Revision 1.3.2.5 2005/02/16 05:09:31 ddiego*bunch o bug fixes and enhancements to the property editor and treelist control.**Revision 1.3.2.4 2005/02/10 04:38:46 augusto_roman** Fixed rect::makeIntersection routine to correctly compute intersections when rects have common edges** Fixed black background on image transformations (made background alpha 0)** Fixed column selection crashing in TreeListControl**Revision 1.3.2.3 2005/01/21 13:45:16 augusto_roman*Increased TreeListControl display speed for large trees by not trying to draw items that are off the screen. - aroman**Revision 1.3.2.2 2005/01/19 01:36:46 augusto_roman*Fixed drawing of checked state in TreeListControl [ left out of last commit ]**Revision 1.3.2.1 2005/01/17 22:44:51 augusto_roman*ErrorStrings - Fixed VCF namespace in VCF_ASSERT*ItemEvent - Added item unselected event*TreeListControl:*- Added handling for sending unselected event*- Added correct state drawing for checked/unchecked items**Revision 1.3 2004/12/01 04:31:38 ddiego*merged over devmain-0-6-6 code. Marcello did a kick ass job*of fixing a nasty bug (1074768VCF application slows down modal dialogs.)*that he found. Many, many thanks for this Marcello.**Revision 1.2.2.2 2004/09/21 23:41:24 ddiego*made some big changes to how the base list, tree, text, table, and tab models are laid out. They are not just plain interfaces. The actual*concrete implementations of them now derive from BOTH Model and the specific*tree, table, etc model interface.*Also made some fixes to the way the text input is handled for a text control.*We now process on a character by character basis and modify the model one*character at a time. Previously we were just using brute force and setting*the whole models text. This is more efficent, though its also more complex.**Revision 1.2.2.1 2004/08/21 21:06:52 ddiego*migrated over the Resource code to the FoudationKit.*Added support for a GraphicsResourceBundle that can get images.*Changed the AbstractApplication class to call the System::getResourceBundle.*Updated the various example code accordingly.**Revision 1.2 2004/08/07 02:49:10 ddiego*merged in the devmain-0-6-5 branch to stable**Revision 1.1.2.6 2004/07/30 17:27:13 kiklop74*Added first release of Borland midifications for VCF**Revision 1.1.2.5 2004/07/16 04:01:46 ddiego*fixed the last of border redraw issues, I hope.**Revision 1.1.2.4 2004/07/14 21:54:41 ddiego*attempts to fix problem with borders and drawing on common controls.*Sort of works on editor control. There is a subtle repaint problem in painting*damaged portions of the control.**Revision 1.1.2.3 2004/07/09 03:39:29 ddiego*merged in changes from the OSX branch for new theming API. Added*support for controlling the use of locale translated strings in components.**Revision 1.1.2.2.2.1 2004/06/27 18:19:15 ddiego*more osx updates**Revision 1.1.2.2 2004/04/29 03:43:15 marcelloptr*reformatting of source files: macros and csvlog and copyright sections**Revision 1.1.2.1 2004/04/28 00:28:19 ddiego*migration towards new directory structure**Revision 1.44 2004/04/03 16:09:31 ddiego*Found some more merge issues that needing resolving.**Revision 1.43 2003/12/18 05:16:00 ddiego*merge from devmain-0-6-2 branch into the stable branch**Revision 1.42.2.4 2003/10/10 04:33:01 ddiego*made the treelist look a bit better**Revision 1.42.2.3 2003/10/09 22:04:08 ddiego*menu item fix**Revision 1.42.2.2 2003/09/15 02:52:36 ddiego*miscellaneous changes**Revision 1.42.2.1 2003/08/18 19:52:38 ddiego*changed the Container from being a class you derive from to a separate*intance that is created and assigned dynamically to any Control.**Revision 1.42 2003/08/09 02:56:45 ddiego*merge over from the devmain-0-6-1 branch*Changes*Features:*-Added additional implementation to better support the MVC architecture in*the VCF**-Added a Document/View architecure that is similar to MFC's or NextSteps's*Doc/View architectures**-Integrated the Anti Grain Graphics library into the GraphicsKit. There is*now basic support for it in terms of drawing vector shapes*(fills and strokes). Image support will come in the next release**-Added several documented graphics tutorials**Bugfixes:**[ 775744 ] wrong buttons on a dialog*[ 585239 ] Painting weirdness in a modal dialog ?*[ 585238 ] Modal dialog which makes a modal Dialog*[ 509004 ] Opening a modal Dialog causes flicker*[ 524878 ] onDropped not called for MLTcontrol**Plus an issue with some focus and getting the right popup window to activate*has also been fixed**Revision 1.41.2.1 2003/07/24 04:10:44 ddiego*added fixes for the following tasks:*Task #82279 ApplicationKit: add static methods to singleton objects*Task #82277 FoundationKit: add static methods to singleton objects*this required a bunch of changes in terms of getting rid of older style code**Revision 1.41 2003/05/17 20:37:50 ddiego*this is the checkin for the 0.6.1 release - represents the merge over from*the devmain-0-6-0 branch plus a few minor bug fixes**Revision 1.40.2.2 2003/05/13 03:57:13 ddiego*cleaned up the GraphicsKit, got rid of some old crap files, cleaned*up the ContextPeer so that tehre are fewer methods to implement, and*moved the repetitive fillPath and strokePath code that was copied into*all the context peers back into the GraphicsContext where it belongs**Revision 1.40.2.1 2003/03/12 03:13:26 ddiego*switched all member variable that used the "m_"<name> prefix to* <name>"_" suffix nameing standard.*Also changed all vcf builder files to accomadate this.*Changes were made to the Stream classes to NOT multiple inheritance and to*be a little more correct. Changes include breaking the FileStream into two*distinct classes, one for input and one for output.**Revision 1.40 2003/02/26 04:30:57 ddiego*merge of code in the devmain-0-5-9 branch into the current tree.*most additions are in the area of the current linux port, but the major*addition to this release is the addition of a Condition class (currently*still under development) and the change over to using the Delegate class*exclusively from the older event handler macros.**Revision 1.39.2.5 2003/02/24 05:42:19 ddiego*moved the code for the VariantData calss into it's own header*migrated to the new event style using Delegates instead of relying on*the ugly macros that we were using before - same functionality though*made sure everything still works and compiles, including neccessary*changes in the VCF Builder so that it creates code in the new style*This changes to teh new style of using Delegates completes task 58837**Revision 1.39.2.4 2003/01/08 00:20:01 marcelloptr*mispellings and newlines at the end of all source files**Revision 1.39.2.3 2002/12/27 23:05:11 marcelloptr*Improved macros for automatic import/export of libraries. - Warning fixes. - Other Minor Changes.**Revision 1.39.2.2 2002/12/25 22:06:36 ddiego*whole bunch of little changes to the header files used by the ApplicationKit*to get rid of no newline warnings by gcc.*fixes to various event handlers in the ApplicationKit to compile with gcc*since gcc does not like a member function pointer without the "&"*addressof operator.*Added initial file for the X11 UIToolkit implementation**Revision 1.39.2.1 2002/12/02 00:38:36 ddiego*more fixes to get the ApplicationKit to compile under mingw. Everything now*compiles OK at this point.**Revision 1.39 2002/11/18 00:46:10 ddiego*this is the merge over of all the bug fixes and features (mostly*VCF Builder stuff) from the devmain-0-5-8 branch**Revision 1.38.10.5 2002/11/16 20:31:35 ddiego*this fixes the following bugs:*632802 TextControl's setViewModel not called*639416 ListViewControl's setViewModel not called*639417 TreeControl's setViewModel not called*639418 ListBoxControl's setViewModel not called*639419 ComboBoxControl's setViewModel not called*639420 TreeListControl's setViewModel not called*basically just required that setViewModel() get called. Also made changes to*the TableControl and teh TabbedPages control**Revision 1.38.10.4 2002/11/09 05:17:11 ddiego*changes are for fixing bug [ 634798 ] Property pane not scrolling.*ignore the inclusion of TreeListControl.cpp in this checkin.**Revision 1.38.10.3 2002/10/18 03:06:36 ddiego*changes to get the new form dialogs working**Revision 1.38.10.2 2002/10/16 05:39:31 ddiego*started working on adding support for creating a new form to a project**Revision 1.38.10.1 2002/10/01 20:34:59 ddiego*borders**Revision 1.38 2002/05/09 03:10:46 ddiego*merged over code from development branch devmain-0-5-1a into the main CVS trunk**Revision 1.37 2002/03/31 19:54:33 ddiego*fixed a release bug in the TreeListCon
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?