Flu_Combo_Tree.cpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:3k
- /*
- * ===========================================================================
- * PRODUCTION $Log: Flu_Combo_Tree.cpp,v $
- * PRODUCTION Revision 1000.1 2004/06/01 21:05:42 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.2
- * PRODUCTION
- * ===========================================================================
- */
- /*
- * These files were imported into NCBI's CVS directly from FLU version 2.9.1.
- * Modifications to the source are listed below.
- *
- * ==========================================================================
- * $Log: Flu_Combo_Tree.cpp,v $
- * Revision 1000.1 2004/06/01 21:05:42 gouriano
- * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.2
- *
- * Revision 1.2 2004/05/21 22:27:51 gorelenk
- * Added PCH ncbi_pch.hpp
- *
- * Revision 1.1 2004/03/11 13:51:39 dicuccio
- * Imported FLU version 2.9.1. Altered export specifiers to match NCBI layout.
- * Altered include paths to match NCBI toolkit layout.
- *
- * ==========================================================================
- */
- // $Id: Flu_Combo_Tree.cpp,v 1000.1 2004/06/01 21:05:42 gouriano Exp $
- /***************************************************************
- * FLU - FLTK Utility Widgets
- * Copyright (C) 2002 Ohio Supercomputer Center, Ohio State University
- *
- * This file and its content is protected by a software license.
- * You should have received a copy of this license with this file.
- * If not, please contact the Ohio Supercomputer Center immediately:
- * Attn: Jason Bryan Re: FLU 1224 Kinnear Rd, Columbus, Ohio 43212
- *
- ***************************************************************/
- #include <ncbi_pch.hpp>
- #include <stdio.h>
- #include <FL/Fl.H>
- #include <FL/fl_draw.H>
- #include <string.h>
- #include <stdlib.h>
- #include <FL/math.h>
- #include <gui/widgets/FLU/Flu_Combo_Tree.h>
- Flu_Combo_Tree :: Flu_Combo_Tree( int X, int Y, int W, int H, const char* l )
- : Flu_Combo_Box( X, Y, W, H, l ), tree(0,0,0,0)
- {
- tree.callback( _cb, this );
- tree.selection_mode( FLU_SINGLE_SELECT );
- tree.when( FL_WHEN_RELEASE );
- set_combo_widget( &tree );
- }
- Flu_Combo_Tree :: ~Flu_Combo_Tree()
- {
- }
- void Flu_Combo_Tree :: cb()
- {
- //if( tree.callback_reason() == FLU_UNSELECTED )
- //selected( 0 );
- if( tree.callback_reason() == FLU_SELECTED )
- selected( tree.callback_node()->find_path() );
- }
- bool Flu_Combo_Tree :: _value( const char *v )
- {
- // see if 'v' is in the tree, and if so, make it the current selection
- Flu_Tree_Browser::Node *n = tree.find( v );
- if( n )
- {
- tree.unselect_all();
- tree.set_hilighted( n );
- n->select( true );
- return true;
- }
- return false;
- }
- const char* Flu_Combo_Tree :: _next()
- {
- Flu_Tree_Browser::Node *n = tree.get_selected( 1 );
- if( n )
- {
- Flu_Tree_Browser::Node *n2 = n->next();
- if( n2 )
- {
- n->select( false );
- n2->select( true );
- tree.set_hilighted( n2 );
- const char *path = n2->find_path();
- return( strlen(path) ? path : NULL );
- }
- }
- return NULL;
- }
- const char* Flu_Combo_Tree :: _previous()
- {
- Flu_Tree_Browser::Node *n = tree.get_selected( 1 );
- if( n )
- {
- Flu_Tree_Browser::Node *n2 = n->previous();
- if( n2 )
- {
- if( n2->is_root() && !tree.show_root() )
- return NULL;
- n->select( false );
- n2->select( true );
- tree.set_hilighted( n2 );
- const char *path = n2->find_path();
- return( strlen(path) ? path : NULL );
- }
- }
- return NULL;
- }