home *** CD-ROM | disk | FTP | other *** search
/ Geek 6 / Geek-006.iso / linux / video / xmovie-1.5.3.tar.gz / xmovie-1.5.3.tar / xmovie-1.5.3 / guicast / bclistbox.h < prev    next >
C/C++ Source or Header  |  2000-11-29  |  6KB  |  239 lines

  1. #ifndef BCLISTBOX_H
  2. #define BCLISTBOX_H
  3.  
  4. #include "bcdragwindow.inc"
  5. #include "bcpixmap.inc"
  6. #include "bcpopuplistbox.inc"
  7. #include "bcscrollbar.h"
  8. #include "bcsubwindow.h"
  9. #include "colors.h"
  10.  
  11. #define BCPOPUPLISTBOX_W 25
  12. #define BCPOPUPLISTBOX_H 25
  13.  
  14. #define LISTBOX_UP 0
  15. #define LISTBOX_HIGH 1
  16. #define LISTBOX_DN 2
  17.  
  18. // Every item in a list inherits this
  19. class BC_ListBoxItem
  20. {
  21. public:
  22.     BC_ListBoxItem();
  23.     BC_ListBoxItem(char *text, int color = BLACK);
  24. // Going to need the png file for window masks.
  25.     BC_ListBoxItem(int x, int y, char *text, BC_Pixmap *icon, int color = BLACK);
  26.     virtual ~BC_ListBoxItem();
  27.  
  28.     friend BC_ListBox;
  29.  
  30.     BC_ListBoxItem& operator=(BC_ListBoxItem& item);
  31.     void set_text(char *new_text);
  32.     char* get_text();
  33.     int get_x();
  34.     int get_y();
  35.  
  36. private:
  37.     int initialize();
  38.     int get_icon_w();
  39.     int get_icon_h();
  40.  
  41. // y position in listbox relative to top.
  42.     BC_Pixmap *icon;
  43.     int x, y;
  44.     char *text;
  45.     int color;
  46.     int selected;
  47.     BC_ListBox *listbox;
  48. };
  49.  
  50. class BC_ListBoxYScroll : public BC_ScrollBar
  51. {
  52. public:
  53.     BC_ListBoxYScroll(BC_ListBox *listbox, 
  54.                       int total_height, 
  55.                       int view_height, 
  56.                       int position);
  57.     int handle_event();
  58. private:
  59.     BC_ListBox *listbox;
  60. };
  61.  
  62. class BC_ListBoxXScroll : public BC_ScrollBar
  63. {
  64. public:
  65.     BC_ListBoxXScroll(BC_ListBox *listbox, 
  66.                       int total_width, 
  67.                       int view_width,
  68.                       int position);
  69.     int handle_event();
  70. private:
  71.     BC_ListBox *listbox;
  72. };
  73.  
  74. class BC_ListBox : public BC_SubWindow
  75. {
  76. public:
  77.     BC_ListBox(int x, 
  78.         int y, 
  79.         int w, 
  80.         int h,
  81.         int display_format,                   // Display text list or icons
  82.         ArrayList<BC_ListBoxItem*> *data = 0, // Each column has an ArrayList of BC_ListBoxItems.
  83.         char **column_titles = 0,             // Titles for columns.  Set to 0 for no titles
  84.         int *column_width = 0,                // width of each column
  85.         int columns = 1,                      // Total columns.
  86.         int yposition = 0,                    // Pixel of top of window.
  87.         int popup = 0,                        // If this listbox is a popup window
  88.         int selection_mode = LISTBOX_SINGLE,  // Select one item or multiple items
  89.         int icon_position = ICON_LEFT,        // Position of icon relative to text of each item
  90.         int assign_icon_coords = 1,           // Assign default coordinates to icons
  91.         int allow_drag = 0);                  // Allow user to drag icons around
  92.     virtual ~BC_ListBox();
  93.  
  94.     friend BC_PopupListBox;
  95.  
  96.     int initialize();
  97.  
  98. // user event handler for new selections
  99.     virtual int selection_changed() { return 0; };
  100.     virtual int handle_event() { return 0; };
  101.     BC_ListBoxItem* get_selection(int column, int selection_number);
  102.     int get_selection_number(int column, int selection_number);
  103.  
  104.     int button_press_event();
  105.     int button_release_event();
  106.     int cursor_enter_event();
  107.     int cursor_leave_event();
  108.     int cursor_motion_event();
  109.     int drag_start_event();
  110.     int drag_motion_event();
  111.     int drag_stop_event();
  112.     int deactivate();
  113.     int activate();
  114.     int keypress_event();
  115.     int translation_event();
  116.     int repeat_event(long repeat_id);
  117.     int get_yposition();
  118.     int get_xposition();
  119.     
  120. // change the contents
  121.     int update(ArrayList<BC_ListBoxItem*> *data,
  122.                         char **column_titles,
  123.                         int columns,
  124.                         int yposition = 0,
  125.                         int xposition = 0, 
  126.                         int currentitem = -1,
  127.                         int set_coords = 1);
  128.  
  129.     int set_selection_mode(int mode);
  130.     int set_yposition(int position);
  131.     int set_xposition(int position);
  132.  
  133.     int get_yscroll_x();
  134.     int get_yscroll_y();
  135.     int get_yscroll_height();
  136.     int get_xscroll_x();
  137.     int get_xscroll_y();
  138.     int get_xscroll_width();
  139.     int get_column_offset(int column);
  140.     int get_column_width(int column);
  141.     int get_w();
  142.     int get_h();
  143.     int get_display_mode();
  144.     void reset_query();
  145.     int reposition_window(int x, int y, int w = -1, int h = -1);
  146.  
  147. private:
  148.     int draw_face();
  149.     int draw_items();
  150.     int draw_border();
  151.     void query_list();
  152.     void init_column_width();
  153.  
  154.     int set_item_coords();
  155.     int get_items_width();
  156.     int get_items_height();
  157.     int get_icon_w(int column, int item);
  158.     int get_icon_h(int column, int item);
  159.     int get_item_x(int column, int item);
  160.     int get_item_y(int column, int item);
  161.     int get_item_w(int column, int item);
  162.     int get_item_h(int column, int item);
  163.     int get_item_highlight(int column, int item);
  164.     int get_item_color(int column, int item);
  165.     int get_icon_mask(int column, int item, int &x, int &y, int &w, int &h);
  166.     int get_text_mask(int column, int item, int &x, int &y, int &w, int &h);
  167.     BC_Pixmap* get_item_pixmap(int item);
  168.     void clear_listbox(int x, int y, int w, int h);
  169.     void test_drag_scroll(int &redraw, int cursor_x, int cursor_y);
  170.     void move_vertical(int pixels);
  171.     void move_horizontal(int pixels);
  172.     void fix_positions();
  173.  
  174.     int get_scrollbars();
  175.     void update_scrollbars();
  176.  
  177. // Item the cursor is over
  178.     int cursor_item(int cursor_x, int cursor_y);
  179.  
  180.     void center_selection(int selection);
  181.  
  182. // Array of one list of pointers for each column
  183.     ArrayList<BC_ListBoxItem*> *data;
  184. // Mode
  185.     int popup;
  186. // Dimensions for a popup if there is one
  187.     int popup_w, popup_h;
  188. // pixel of top of display relative to top of list
  189.     int yposition;
  190. // pixel of left display relative to first column
  191.     int xposition;
  192. // dimensions of a row in the list
  193.     int row_height, row_ascent, row_descent;
  194. // item cursor is over
  195.     int highlighted_item;
  196. // double click eliminator
  197.     int last_selection1, last_selection2;
  198.     int highlighted;
  199.     int selection_mode;
  200.     int display_format;
  201.     int icon_position;
  202. // Scrollbars are created as needed
  203.     BC_ListBoxXScroll *xscrollbar;
  204.     BC_ListBoxYScroll *yscrollbar;
  205.     char query[BCTEXTLEN];
  206. // Window containing the listbox
  207.     BC_WindowBase *gui;
  208. // Size of the popup if there is one
  209.     char **column_titles;
  210.     int *column_width;
  211.     int default_column_width[1];
  212.     int columns;
  213.     int items_per_column;
  214.     int view_h, view_w;
  215.     int title_h;
  216.     int selection_active;
  217.     int active;
  218.     int new_value;
  219.     int need_xscroll, need_yscroll;
  220.     int assign_icon_coords;
  221.     int allow_drag;
  222. // Item being dragged
  223.     int selection;
  224. // Background color of listbox
  225.     int list_background;
  226.     BC_Pixmap *bg_tile;
  227. // Popup button
  228.     BC_Pixmap *images[3];
  229.     int status;
  230.     int button_releases;
  231. // Window for dragging
  232.     BC_DragWindow *drag_popup;
  233. };
  234.  
  235.  
  236.  
  237.  
  238. #endif
  239.