gui "text_list" becomes "textlist"
view "textlist" becomes "view_textlist" (this one may change at some point)
This commit is contained in:
@@ -2,7 +2,7 @@ CC=gcc
|
||||
CFLAGS=-Wall -g -pthread
|
||||
|
||||
OBJS=init.o loop.o toplevel_window.o x.o container.o widget.o \
|
||||
gui.o label.o event.o xy_plot.o text_list.o notify.o
|
||||
gui.o label.o event.o xy_plot.o textlist.o notify.o
|
||||
|
||||
gui.a: $(OBJS)
|
||||
ar cr gui.a $(OBJS)
|
||||
|
||||
@@ -23,7 +23,7 @@ widget *new_container(gui *gui, int vertical);
|
||||
widget *new_label(gui *gui, const char *text);
|
||||
widget *new_xy_plot(gui *gui, int width, int height, char *label,
|
||||
int vruler_width);
|
||||
widget *new_text_list(gui *_gui, int width, int nlines, int background_color);
|
||||
widget *new_textlist(gui *_gui, int width, int nlines, int background_color);
|
||||
|
||||
void container_set_child_growable(gui *_gui, widget *_this,
|
||||
widget *child, int growable);
|
||||
@@ -33,18 +33,18 @@ void xy_plot_set_range(gui *gui, widget *this,
|
||||
void xy_plot_set_points(gui *gui, widget *this,
|
||||
int npoints, float *x, float *y);
|
||||
|
||||
void text_list_add(gui *gui, widget *this, const char *text, int position,
|
||||
void textlist_add(gui *gui, widget *this, const char *text, int position,
|
||||
int color);
|
||||
void text_list_del(gui *gui, widget *this, int position);
|
||||
void text_list_add_silent(gui *gui, widget *this, const char *text,
|
||||
void textlist_del(gui *gui, widget *this, int position);
|
||||
void textlist_add_silent(gui *gui, widget *this, const char *text,
|
||||
int position, int color);
|
||||
void text_list_del_silent(gui *gui, widget *this, int position);
|
||||
void text_list_state(gui *_gui, widget *_this,
|
||||
void textlist_del_silent(gui *gui, widget *this, int position);
|
||||
void textlist_state(gui *_gui, widget *_this,
|
||||
int *visible_lines, int *start_line, int *number_of_lines);
|
||||
void text_list_set_start_line(gui *gui, widget *this, int line);
|
||||
void text_list_get_line(gui *gui, widget *this, int line,
|
||||
void textlist_set_start_line(gui *gui, widget *this, int line);
|
||||
void textlist_get_line(gui *gui, widget *this, int line,
|
||||
char **text, int *color);
|
||||
void text_list_set_color(gui *gui, widget *this, int line, int color);
|
||||
void textlist_set_color(gui *gui, widget *this, int line, int color);
|
||||
|
||||
void gui_loop(gui *gui);
|
||||
|
||||
@@ -55,7 +55,7 @@ int new_color(gui *gui, char *color);
|
||||
|
||||
/* notifications */
|
||||
/* known notifications:
|
||||
* - text_list:
|
||||
* - textlist:
|
||||
* - scrollup { void *: NULL }
|
||||
* - scrolldown { void *: NULL }
|
||||
* - click { int [2]: line, button }
|
||||
|
||||
@@ -76,7 +76,7 @@ struct container_widget {
|
||||
int nchildren;
|
||||
};
|
||||
|
||||
struct text_list_widget {
|
||||
struct textlist_widget {
|
||||
struct widget common;
|
||||
char **text;
|
||||
int *color;
|
||||
|
||||
@@ -31,11 +31,11 @@ int main(void)
|
||||
#endif
|
||||
|
||||
tlcol = new_color(g, "#ddf");
|
||||
tl = new_text_list(g, 300, 10, tlcol);
|
||||
tl = new_textlist(g, 300, 10, tlcol);
|
||||
widget_add_child(g, c1, tl, -1);
|
||||
|
||||
text_list_add(g, tl, "hello", -1);
|
||||
text_list_add(g, tl, "world", -1);
|
||||
textlist_add(g, tl, "hello", -1, FOREGROUND_COLOR);
|
||||
textlist_add(g, tl, "world", -1, FOREGROUND_COLOR);
|
||||
|
||||
w = new_toplevel_window(g, 500, 400, "test window");
|
||||
widget_add_child(g, w, c1, 0);
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
static void paint(gui *_gui, widget *_this)
|
||||
{
|
||||
struct gui *g = _gui;
|
||||
struct text_list_widget *this = _this;
|
||||
struct textlist_widget *this = _this;
|
||||
int i, j;
|
||||
LOGD("PAINT text_list %p xywh %d %d %d %d starting line %d allocated nlines %d text_count %d\n", _this, this->common.x, this->common.y, this->common.width, this->common.height, this->starting_line, this->allocated_nlines, this->text_count);
|
||||
LOGD("PAINT textlist %p xywh %d %d %d %d starting line %d allocated nlines %d text_count %d\n", _this, this->common.x, this->common.y, this->common.width, this->common.height, this->starting_line, this->allocated_nlines, this->text_count);
|
||||
x_fill_rectangle(g->x, g->xwin, this->background_color,
|
||||
this->common.x, this->common.y,
|
||||
this->common.width, this->common.height);
|
||||
@@ -26,29 +26,29 @@ static void paint(gui *_gui, widget *_this)
|
||||
|
||||
static void hints(gui *_gui, widget *_w, int *width, int *height)
|
||||
{
|
||||
struct text_list_widget *w = _w;
|
||||
struct textlist_widget *w = _w;
|
||||
*width = w->wanted_width;
|
||||
*height = w->wanted_nlines * w->line_height;
|
||||
LOGD("HINTS text_list wh %d %d\n", *width, *height);
|
||||
LOGD("HINTS textlist wh %d %d\n", *width, *height);
|
||||
}
|
||||
|
||||
static void allocate(
|
||||
gui *gui, widget *_this, int x, int y, int width, int height)
|
||||
{
|
||||
struct text_list_widget *this = _this;
|
||||
struct textlist_widget *this = _this;
|
||||
this->common.x = x;
|
||||
this->common.y = y;
|
||||
this->common.width = width;
|
||||
this->common.height = height;
|
||||
this->allocated_nlines = height / this->line_height;
|
||||
LOGD("ALLOCATE text_list %p xywh %d %d %d %d nlines %d\n", this, x, y, width, height, this->allocated_nlines);
|
||||
LOGD("ALLOCATE textlist %p xywh %d %d %d %d nlines %d\n", this, x, y, width, height, this->allocated_nlines);
|
||||
}
|
||||
|
||||
static void button(gui *_g, widget *_this, int x, int y, int button, int up)
|
||||
{
|
||||
struct gui *g = _g;
|
||||
struct text_list_widget *this = _this;
|
||||
LOGD("BUTTON text_list %p xy %d %d button %d up %d\n", _this, x, y, button, up);
|
||||
struct textlist_widget *this = _this;
|
||||
LOGD("BUTTON textlist %p xy %d %d button %d up %d\n", _this, x, y, button, up);
|
||||
/* scroll up */
|
||||
if (button == 4 && up == 0) {
|
||||
gui_notify(g, "scrollup", _this, NULL);
|
||||
@@ -65,15 +65,15 @@ static void button(gui *_g, widget *_this, int x, int y, int button, int up)
|
||||
}
|
||||
}
|
||||
|
||||
widget *new_text_list(gui *_gui, int width, int nlines, int bgcol)
|
||||
widget *new_textlist(gui *_gui, int width, int nlines, int bgcol)
|
||||
{
|
||||
struct gui *g = _gui;
|
||||
struct text_list_widget *w;
|
||||
struct textlist_widget *w;
|
||||
int dummy;
|
||||
|
||||
glock(g);
|
||||
|
||||
w = new_widget(g, TEXT_LIST, sizeof(struct text_list_widget));
|
||||
w = new_widget(g, TEXT_LIST, sizeof(struct textlist_widget));
|
||||
|
||||
w->wanted_nlines = nlines;
|
||||
x_text_get_dimensions(g->x, ".", &dummy, &w->line_height, &w->baseline);
|
||||
@@ -95,11 +95,11 @@ widget *new_text_list(gui *_gui, int width, int nlines, int bgcol)
|
||||
/* public functions */
|
||||
/*************************************************************************/
|
||||
|
||||
static void _text_list_add(gui *_gui, widget *_this, const char *text,
|
||||
static void _textlist_add(gui *_gui, widget *_this, const char *text,
|
||||
int position, int color, int silent)
|
||||
{
|
||||
struct gui *g = _gui;
|
||||
struct text_list_widget *this = _this;
|
||||
struct textlist_widget *this = _this;
|
||||
|
||||
glock(g);
|
||||
|
||||
@@ -125,10 +125,10 @@ static void _text_list_add(gui *_gui, widget *_this, const char *text,
|
||||
gunlock(g);
|
||||
}
|
||||
|
||||
static void _text_list_del(gui *_gui, widget *_this, int position, int silent)
|
||||
static void _textlist_del(gui *_gui, widget *_this, int position, int silent)
|
||||
{
|
||||
struct gui *g = _gui;
|
||||
struct text_list_widget *this = _this;
|
||||
struct textlist_widget *this = _this;
|
||||
|
||||
glock(g);
|
||||
|
||||
@@ -157,33 +157,33 @@ done:
|
||||
gunlock(g);
|
||||
}
|
||||
|
||||
void text_list_add(gui *gui, widget *this, const char *text, int position,
|
||||
void textlist_add(gui *gui, widget *this, const char *text, int position,
|
||||
int color)
|
||||
{
|
||||
_text_list_add(gui, this, text, position, color, 0);
|
||||
_textlist_add(gui, this, text, position, color, 0);
|
||||
}
|
||||
|
||||
void text_list_del(gui *gui, widget *this, int position)
|
||||
void textlist_del(gui *gui, widget *this, int position)
|
||||
{
|
||||
_text_list_del(gui, this, position, 0);
|
||||
_textlist_del(gui, this, position, 0);
|
||||
}
|
||||
|
||||
void text_list_add_silent(gui *gui, widget *this, const char *text,
|
||||
void textlist_add_silent(gui *gui, widget *this, const char *text,
|
||||
int position, int color)
|
||||
{
|
||||
_text_list_add(gui, this, text, position, color, 1);
|
||||
_textlist_add(gui, this, text, position, color, 1);
|
||||
}
|
||||
|
||||
void text_list_del_silent(gui *gui, widget *this, int position)
|
||||
void textlist_del_silent(gui *gui, widget *this, int position)
|
||||
{
|
||||
_text_list_del(gui, this, position, 1);
|
||||
_textlist_del(gui, this, position, 1);
|
||||
}
|
||||
|
||||
void text_list_state(gui *_gui, widget *_this,
|
||||
void textlist_state(gui *_gui, widget *_this,
|
||||
int *visible_lines, int *start_line, int *number_of_lines)
|
||||
{
|
||||
struct gui *g = _gui;
|
||||
struct text_list_widget *this = _this;
|
||||
struct textlist_widget *this = _this;
|
||||
|
||||
glock(g);
|
||||
|
||||
@@ -194,10 +194,10 @@ void text_list_state(gui *_gui, widget *_this,
|
||||
gunlock(g);
|
||||
}
|
||||
|
||||
void text_list_set_start_line(gui *_gui, widget *_this, int line)
|
||||
void textlist_set_start_line(gui *_gui, widget *_this, int line)
|
||||
{
|
||||
struct gui *g = _gui;
|
||||
struct text_list_widget *this = _this;
|
||||
struct textlist_widget *this = _this;
|
||||
|
||||
glock(g);
|
||||
|
||||
@@ -208,11 +208,11 @@ void text_list_set_start_line(gui *_gui, widget *_this, int line)
|
||||
gunlock(g);
|
||||
}
|
||||
|
||||
void text_list_get_line(gui *_gui, widget *_this, int line,
|
||||
void textlist_get_line(gui *_gui, widget *_this, int line,
|
||||
char **text, int *color)
|
||||
{
|
||||
struct gui *g = _gui;
|
||||
struct text_list_widget *this = _this;
|
||||
struct textlist_widget *this = _this;
|
||||
|
||||
glock(g);
|
||||
|
||||
@@ -227,10 +227,10 @@ void text_list_get_line(gui *_gui, widget *_this, int line,
|
||||
gunlock(g);
|
||||
}
|
||||
|
||||
void text_list_set_color(gui *_gui, widget *_this, int line, int color)
|
||||
void textlist_set_color(gui *_gui, widget *_this, int line, int color)
|
||||
{
|
||||
struct gui *g = _gui;
|
||||
struct text_list_widget *this = _this;
|
||||
struct textlist_widget *this = _this;
|
||||
|
||||
glock(g);
|
||||
|
||||
Reference in New Issue
Block a user