File: scrollwin.h

package info (click to toggle)
mp3blaster 1%3A3.2.6-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,692 kB
  • sloc: cpp: 18,606; ansic: 1,452; sh: 959; makefile: 91
file content (158 lines) | stat: -rw-r--r-- 5,542 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/* Changes:
 * 18 Apr 1999: Added changeItem() function.
 * 13 Feb 2000: Items are represented by winItems i/o charpointers.
 * 
 */
#ifndef _SCROLLWIN_CLASS_
#define _SCROLLWIN_CLASS_

#include "mp3blaster.h"
#include NCURSES_HEADER
#include "winitem.h"
#include "exceptions.h"
#include <stdio.h>

enum sw_searchflags { SW_SEARCH_NONE, SW_SEARCH_CASE_INSENSITIVE };

class scrollWin
{
public:
	/* Function Name: scrollWin::scrollWin
	 * Description  : Creates a new selection-window, setting width and
	 *              : height, items in this window, and whether or not the 
	 *              : entire path to each item should be displayed.
	 * Arguments    : sw      : selection-window to create
	 *              : lines   : amount of lines for this window
	 *              : ncols   : amount of columns for this window
	 *              : begin_y : y-coordinate of topleft corner from this window
	 *              :         : in stdscr.
	 *              : begin_x : as begin_y, but now x-coordinate.
	 *              : arr     : array of strings containing items for this
	 *              :         : window. May be NULL if narr is 0.
	 *              : narr    : amount of items.
	 *              : color   : Default colourpair to use
	 *              : x_offset: 1 if window has a (left-)border of 1, 0 otherwise.
	 * Throws       : IllegalArgumentsException when size requirements have not
	 *              : been met
	 */
	scrollWin(int lines, int ncols, int begin_y, int begin_x, char **arr,
		int narr, short color, short x_offset);

	virtual ~scrollWin();

	/* Function   : resize
	 * Description: Resizes the window
	 * Parameters : width
	 *            :  new width
	 *            : height
	 *            :  new height
	 * Returns    : Nothing.
	 * SideEffects: None.
	 * Throws     : IllegalArgumentsException when size requirements have not
	 *            : been met
	 */
	virtual void resize(int width, int height);

	void changeSelection(int);
	void invertSelection();
	void selectItem(int which = -1);
	void deselectItem(int);
	void deselectItems(); //deselect *all* items
	void selectItems(const char *pattern, const char *type = "regex",
		sw_searchflags flags = SW_SEARCH_CASE_INSENSITIVE,
		short display_index = 0);
	void setTitle(const char*);
	const char *getTitle();
	void swRefresh(short);
	virtual short addItem(const char*, short status=0, short colour=0, int index=-1,
	             short before=0, void *object=NULL, itemtype type=TEXT);
	virtual short addItem(const char **, short *, short colour=0, int index=-1,
	             short before=0, void *object=NULL, itemtype type=TEXT);
	int findItem(const char *, short nameindex = 0);
	void changeItem(int, const char *, short nameindex=0);
	void changeItem(int, char *(*)(void *), void *arg=NULL, short nameindex=0);
	void replaceItem(int, winItem *newitem);
	void setItem(int);
	virtual void delItem(int, int del=1);
	void delItems();
	void setBorder(chtype, chtype, chtype, chtype,
	               chtype, chtype, chtype, chtype);
	void pageDown();
	void pageUp();
	int isSelected(int);
	int getNitems();
	const char *getSelectedItem(short nameindex=0);
	char **getSelectedItems(int *itemcount, short nameindex=0);
	const char *getItem(int index, short name_index=0);
	char **getItems(short nameindex=0);
	void dump_contents();
	void dump_info();
	void setDisplayMode(short mode);
	short getDisplayMode() { return dispindex; }
	void setDefaultColor(short color);
	short moveItem(int index_from, int index_to, short before=0);
	short moveSelectedItems(int index_to, short before=0);
	void clearwin();
	void drawBorder();
	void drawTitleInBorder(int);
	int itemWidth() { return width - (xoffset ? 2 : 0); }
	void hideScrollbar() { hide_bar = 1; }
	/* setWrap: if enabled, list will wrap at boundaries when moving the 
	 * scrollbar with changeSelection */
	void setWrap(bool want_wrap) { wrap = (want_wrap ? 1 : 0); }
	void enableScreenUpdates() { enable_updates = 1; }
	void disableScreenUpdates() { enable_updates = 0; }
	int sw_selection;

/* Added by Douglas Richard <fmluder@imsa.edu> - March 11, 2002 */
	void resetPan();
	void pan(short);
	void jumpTop();
	void jumpBottom();
/* End Add */

protected:
	void init(int, int, int, int, short, short);
	short addItem(winItem *newitem, int index=-1, short before=0);
	winItem *getWinItem(int);
	winItem **getSelectedWinItems(int*);
	scrollWin() {};
	winItem *first, *last;

private:
	void checkSize(const int lines, const int ncols, const int x_offset);

	int nitems;
	int hide_bar;
	char *sw_title;
	int nselected;
	int width;
	int height;
	int by, bx;
	int showpath;
	int border[8];
	int shown_range[2];
	char *sw_emptyline;
	short xoffset;
	short wrap;
	short want_border;
	short max_pan_offset; /* maximum pansize */
	short dispindex; //which of the NAMEDIM names of each item to show
	short colour; //which (global) colourpair to use for drawing items
	int selectID; //increases after each select, used to sort selected items
	              //in the order they were selected.
	int draw_title; //1 if title should be drawn in border

	/* enable_updates determines whether functions in this class will call
	 * call swRefresh after altering this window's content. If zero, one
	 * should always call swRefresh(1) after calling a function that messes
	 * with content/layout. Default is to allow updates from within the class.
	 * You might want to disable it temporarily when performing lots of 
	 * addItems() in a loop, etc.
	 */
	short enable_updates; 

	int panoffset;
};

#endif /* _SCROLLWIN_CLASS_ */