gtk_search_win.h
上传用户:psq1974
上传日期:2007-01-06
资源大小:1195k
文件大小:2k
源码类别:

mpeg/mp3

开发平台:

C/C++

  1. /* Copyright (C) 1998, 1999 State University of New York at Stony Brook
  2.    Author: Andrew V. Shuvalov ( andrew@ecsl.cs.sunysb.edu )
  3.    Software license is located in file "COPYING"
  4. */
  5. #ifndef _gtk_search_win_h_
  6. #define _gtk_search_win_h_
  7. #include "session.h"
  8. #include <vector>
  9. class SearchItem : public Gtk_HBox {
  10.   /** session */
  11.   Session &session;
  12.   SearchWindow &searchWin;
  13.   /** position in queue */
  14.   int position;
  15.     
  16.   Gtk_Combo *boolOpEntry;
  17.   Gtk_Combo *textEntry;
  18.   Gtk_Button *lessButton;
  19.   Gtk_Button *moreButton;
  20.   Gtk_Button *searchButton;
  21. public:
  22.   typedef enum { and, andnot, or, resultand, resultandnot, err, result }
  23.   type;
  24. public:
  25.   SearchItem( Session &s, SearchWindow &w, int _pos );
  26.   void boolOpVisible( bool v ) {
  27.     if( v )
  28.       boolOpEntry->show();
  29.     else
  30.       boolOpEntry->hide();
  31.   }
  32.   void lessButVisible( bool v ) {
  33.     if( v )
  34.       lessButton->show();
  35.     else
  36.       lessButton->hide();
  37.   }
  38.   void buttonsVisible( bool v ) {
  39.     if( v ) {
  40.       moreButton->show();
  41.       searchButton->show();
  42.     }
  43.     else {
  44.       moreButton->hide();
  45.       searchButton->hide();
  46.     }
  47.   }
  48.   const gchar *get_text() const {
  49.     return textEntry->get_entry()->get_text().c_str();
  50.   }
  51.   type get_type() const;
  52.   
  53.   void callback_hint();
  54. };
  55. class SearchResults;
  56. class BoolSearchOperation;
  57. class SearchWindow : public Gtk_Window {
  58.   
  59.   /** session */
  60.   Session &session;
  61.   /** vector of text search items, connected by boolean operation */
  62.   vector< SearchItem * > searchItems;
  63.   /** and corresponding container */
  64.   Gtk_VBox *searchItemsVBox;
  65.   SearchResults *searchResults;
  66.   static const int topWindowInitSizeX;
  67.   static const int topWindowInitSizeY;
  68. public:
  69.   
  70.   SearchWindow( Session &s );
  71.   void find_hint_words( int position, GList *&hints );
  72.   /** callbacks */
  73.   void callback_less( int pos );
  74.   void callback_more( int pos );
  75.   void callback_close();
  76.   void callback_search();
  77. };
  78. /** clist to display search results */
  79. class SearchResults : public Gtk_CList {
  80.   Session &session;
  81.   SearchWindow &searchWindow;
  82.   /** each row is index in this vector
  83.    */
  84.   WordOccurencesT WordOccurences;
  85.   static const int col0width;
  86.   static const int col1width;
  87.   static const int col2width;
  88.   static const int TextColumns;
  89. public:
  90.   SearchResults( Session &s, SearchWindow &sw );
  91.   void display_results( const WordOccurencesT &result );
  92.   void callback_select_row( gint row, gint col, GdkEvent *button );
  93. };
  94. #endif // _gtk_search_win_h_