mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-28 17:23:09 +03:00
Slightly better looking scrollbar.
svn path=/trunk/netsurf/; revision=6790
This commit is contained in:
parent
61b806d5f3
commit
9e81d2e583
@ -73,7 +73,7 @@ framebuffer_t *framebuffer;
|
||||
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
/* private data for browser user widget */
|
||||
/* private data for browser user widget */
|
||||
struct browser_widget_s {
|
||||
struct browser_window *bw; /**< The browser window connected to this gui window */
|
||||
int scrollx, scrolly; /**< scroll offsets. */
|
||||
@ -106,8 +106,8 @@ fb_queue_redraw(struct fbtk_widget_s *widget, int x0, int y0, int x1, int y1)
|
||||
fbtk_request_redraw(widget);
|
||||
}
|
||||
|
||||
static void fb_pan(fbtk_widget_t *widget,
|
||||
struct browser_widget_s *bwidget,
|
||||
static void fb_pan(fbtk_widget_t *widget,
|
||||
struct browser_widget_s *bwidget,
|
||||
struct browser_window *bw)
|
||||
{
|
||||
struct content *c;
|
||||
@ -118,7 +118,7 @@ static void fb_pan(fbtk_widget_t *widget,
|
||||
|
||||
c = bw->current_content;
|
||||
|
||||
if ((!c) || (c->locked))
|
||||
if ((!c) || (c->locked))
|
||||
return;
|
||||
|
||||
height = fbtk_get_height(widget);
|
||||
@ -152,7 +152,7 @@ static void fb_pan(fbtk_widget_t *widget,
|
||||
|
||||
LOG(("panning up %d", bwidget->pany));
|
||||
|
||||
fb_plotters_move_block(x, y,
|
||||
fb_plotters_move_block(x, y,
|
||||
width, height + bwidget->pany,
|
||||
x, y - bwidget->pany);
|
||||
bwidget->scrolly += bwidget->pany;
|
||||
@ -180,7 +180,7 @@ static void fb_pan(fbtk_widget_t *widget,
|
||||
|
||||
LOG(("panning left %d", bwidget->panx));
|
||||
|
||||
fb_plotters_move_block(x, y,
|
||||
fb_plotters_move_block(x, y,
|
||||
width + bwidget->panx, height ,
|
||||
x - bwidget->panx, y );
|
||||
bwidget->scrollx += bwidget->panx;
|
||||
@ -207,8 +207,8 @@ static void fb_pan(fbtk_widget_t *widget,
|
||||
bwidget->pany = 0;
|
||||
}
|
||||
|
||||
static void fb_redraw(fbtk_widget_t *widget,
|
||||
struct browser_widget_s *bwidget,
|
||||
static void fb_redraw(fbtk_widget_t *widget,
|
||||
struct browser_widget_s *bwidget,
|
||||
struct browser_window *bw)
|
||||
{
|
||||
struct content *c;
|
||||
@ -219,7 +219,7 @@ static void fb_redraw(fbtk_widget_t *widget,
|
||||
|
||||
c = bw->current_content;
|
||||
|
||||
if ((!c) || (c->locked))
|
||||
if ((!c) || (c->locked))
|
||||
return;
|
||||
|
||||
height = fbtk_get_height(widget);
|
||||
@ -295,7 +295,7 @@ void gui_init(int argc, char** argv)
|
||||
fb_find_resource(buf, "messages", "./framebuffer/res/messages");
|
||||
LOG(("Using '%s' as Messages file", buf));
|
||||
messages_load(buf);
|
||||
|
||||
|
||||
/* load browser options */
|
||||
fb_find_resource(buf, "Options", "~/.netsurf/Options");
|
||||
LOG(("Using '%s' as Preferences file", buf));
|
||||
@ -391,10 +391,10 @@ void gui_quit(void)
|
||||
}
|
||||
|
||||
/* called back when click in browser window */
|
||||
static int
|
||||
fb_browser_window_click(fbtk_widget_t *widget,
|
||||
browser_mouse_state st,
|
||||
int x, int y,
|
||||
static int
|
||||
fb_browser_window_click(fbtk_widget_t *widget,
|
||||
browser_mouse_state st,
|
||||
int x, int y,
|
||||
void *pw)
|
||||
{
|
||||
struct browser_window *bw = pw;
|
||||
@ -403,23 +403,23 @@ fb_browser_window_click(fbtk_widget_t *widget,
|
||||
LOG(("browser window clicked at %d,%d",x,y));
|
||||
browser_window_mouse_click(bw,
|
||||
st,
|
||||
x + bwidget->scrollx,
|
||||
y + bwidget->scrolly);
|
||||
x + bwidget->scrollx,
|
||||
y + bwidget->scrolly);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* called back when movement in browser window */
|
||||
static int
|
||||
fb_browser_window_move(fbtk_widget_t *widget,
|
||||
int x, int y,
|
||||
static int
|
||||
fb_browser_window_move(fbtk_widget_t *widget,
|
||||
int x, int y,
|
||||
void *pw)
|
||||
{
|
||||
struct browser_window *bw = pw;
|
||||
struct browser_widget_s *bwidget = fbtk_get_userpw(widget);
|
||||
|
||||
browser_window_mouse_track(bw,
|
||||
0,
|
||||
x + bwidget->scrollx,
|
||||
browser_window_mouse_track(bw,
|
||||
0,
|
||||
x + bwidget->scrollx,
|
||||
y + bwidget->scrolly);
|
||||
|
||||
return 0;
|
||||
@ -467,8 +467,8 @@ fb_browser_window_input(fbtk_widget_t *widget, int value, void *pw)
|
||||
|
||||
/* left icon click routine */
|
||||
static int
|
||||
fb_leftarrow_click(fbtk_widget_t *widget,
|
||||
browser_mouse_state st,
|
||||
fb_leftarrow_click(fbtk_widget_t *widget,
|
||||
browser_mouse_state st,
|
||||
int x, int y, void *pw)
|
||||
{
|
||||
struct browser_window *bw = pw;
|
||||
@ -536,27 +536,27 @@ fb_url_enter(void *pw, char *text)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
fb_url_move(fbtk_widget_t *widget,
|
||||
int x, int y,
|
||||
static int
|
||||
fb_url_move(fbtk_widget_t *widget,
|
||||
int x, int y,
|
||||
void *pw)
|
||||
{
|
||||
fb_cursor_set(framebuffer->cursor, &caret_image);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
set_ptr_default_move(fbtk_widget_t *widget,
|
||||
int x, int y,
|
||||
static int
|
||||
set_ptr_default_move(fbtk_widget_t *widget,
|
||||
int x, int y,
|
||||
void *pw)
|
||||
{
|
||||
fb_cursor_set(framebuffer->cursor, &pointer_image);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
set_ptr_hand_move(fbtk_widget_t *widget,
|
||||
int x, int y,
|
||||
static int
|
||||
set_ptr_hand_move(fbtk_widget_t *widget,
|
||||
int x, int y,
|
||||
void *pw)
|
||||
{
|
||||
fb_cursor_set(framebuffer->cursor, &hand_image);
|
||||
@ -580,14 +580,14 @@ gui_create_browser_window(struct browser_window *bw,
|
||||
return NULL;
|
||||
|
||||
/* seems we need to associate the gui window with the underlying
|
||||
* browser window
|
||||
* browser window
|
||||
*/
|
||||
gw->bw = bw;
|
||||
|
||||
|
||||
switch(bw->browser_window_type) {
|
||||
case BROWSER_WINDOW_NORMAL:
|
||||
gw->window = fbtk_create_window(fbtk, 0, 0, 0, 0);
|
||||
gw->window = fbtk_create_window(fbtk, 0, 0, 0, 0);
|
||||
|
||||
top = 30;
|
||||
bot = -50;
|
||||
@ -615,17 +615,17 @@ gui_create_browser_window(struct browser_window *bw,
|
||||
fbtk_set_handler_move(widget, set_ptr_hand_move, bw);
|
||||
|
||||
/* url widget */
|
||||
gw->url = fbtk_create_writable_text(gw->window,
|
||||
125 , 3,
|
||||
fbtk_get_width(gw->window) - 160, 24,
|
||||
FB_COLOUR_WHITE,
|
||||
FB_COLOUR_BLACK,
|
||||
true,
|
||||
fb_url_enter,
|
||||
gw->url = fbtk_create_writable_text(gw->window,
|
||||
125 , 3,
|
||||
fbtk_get_width(gw->window) - 160, 24,
|
||||
FB_COLOUR_WHITE,
|
||||
FB_COLOUR_BLACK,
|
||||
true,
|
||||
fb_url_enter,
|
||||
bw);
|
||||
fbtk_set_handler_move(gw->url, fb_url_move, bw);
|
||||
|
||||
gw->throbber = fbtk_create_bitmap(gw->window,
|
||||
gw->throbber = fbtk_create_bitmap(gw->window,
|
||||
130 + fbtk_get_width(gw->url),
|
||||
3,
|
||||
FB_FRAME_COLOUR,
|
||||
@ -636,10 +636,10 @@ gui_create_browser_window(struct browser_window *bw,
|
||||
/* add status area widget, width of framebuffer less some for
|
||||
* scrollbar
|
||||
*/
|
||||
gw->status = fbtk_create_text(gw->window,
|
||||
0 , fbtk_get_height(gw->window) - 20,
|
||||
fbtk_get_width(gw->window) - 200, 20,
|
||||
FB_FRAME_COLOUR, FB_COLOUR_BLACK,
|
||||
gw->status = fbtk_create_text(gw->window,
|
||||
0 , fbtk_get_height(gw->window) - 20,
|
||||
fbtk_get_width(gw->window) - 200, 20,
|
||||
FB_FRAME_COLOUR, FB_COLOUR_BLACK,
|
||||
false);
|
||||
|
||||
fbtk_set_handler_move(gw->status, set_ptr_default_move, bw);
|
||||
@ -648,30 +648,30 @@ gui_create_browser_window(struct browser_window *bw,
|
||||
fbtk_create_button(gw->window, fbtk_get_width(gw->window) - 200, fbtk_get_height(gw->window) - 20, FB_FRAME_COLOUR, &scrolll, fb_scrolll_click, bw);
|
||||
fbtk_create_button(gw->window, fbtk_get_width(gw->window) - 20, fbtk_get_height(gw->window) - 20, FB_FRAME_COLOUR, &scrollr, fb_scrollr_click, bw);
|
||||
|
||||
gw->hscroll = fbtk_create_hscroll(gw->window,
|
||||
fbtk_get_width(gw->window) - 180,
|
||||
fbtk_get_height(gw->window) - 20,
|
||||
160,
|
||||
20,
|
||||
FB_COLOUR_BLACK,
|
||||
gw->hscroll = fbtk_create_hscroll(gw->window,
|
||||
fbtk_get_width(gw->window) - 180,
|
||||
fbtk_get_height(gw->window) - 20,
|
||||
160,
|
||||
20,
|
||||
FB_SCROLL_COLOUR,
|
||||
FB_FRAME_COLOUR);
|
||||
|
||||
break;
|
||||
|
||||
case BROWSER_WINDOW_FRAME:
|
||||
gw->window = fbtk_create_window(bw->parent->window->window, 0, 0, 0, 0);
|
||||
gw->window = fbtk_create_window(bw->parent->window->window, 0, 0, 0, 0);
|
||||
LOG(("create frame"));
|
||||
break;
|
||||
|
||||
default:
|
||||
gw->window = fbtk_create_window(bw->parent->window->window, 0, 0, 0, 0);
|
||||
gw->window = fbtk_create_window(bw->parent->window->window, 0, 0, 0, 0);
|
||||
LOG(("unhandled type"));
|
||||
|
||||
}
|
||||
|
||||
browser_widget = calloc(1, sizeof(struct browser_widget_s));
|
||||
|
||||
gw->browser = fbtk_create_user(gw->window, 0, top, 0, bot, browser_widget);
|
||||
|
||||
gw->browser = fbtk_create_user(gw->window, 0, top, 0, bot, browser_widget);
|
||||
|
||||
fbtk_set_handler_click(gw->browser, fb_browser_window_click, bw);
|
||||
fbtk_set_handler_input(gw->browser, fb_browser_window_input, gw);
|
||||
@ -721,10 +721,10 @@ void gui_window_redraw_window(struct gui_window *g)
|
||||
void gui_window_update_box(struct gui_window *g,
|
||||
const union content_msg_data *data)
|
||||
{
|
||||
fb_queue_redraw(g->browser,
|
||||
data->redraw.x,
|
||||
fb_queue_redraw(g->browser,
|
||||
data->redraw.x,
|
||||
data->redraw.y,
|
||||
data->redraw.x + data->redraw.width,
|
||||
data->redraw.x + data->redraw.width,
|
||||
data->redraw.y + data->redraw.height);
|
||||
}
|
||||
|
||||
@ -771,10 +771,10 @@ void gui_window_position_frame(struct gui_window *g, int x0, int y0,
|
||||
py = fbtk_get_y(parent->browser) + y0;
|
||||
w = x1 - x0;
|
||||
h = y1 - y0;
|
||||
if (w > (fbtk_get_width(parent->browser) - px))
|
||||
if (w > (fbtk_get_width(parent->browser) - px))
|
||||
w = fbtk_get_width(parent->browser) - px;
|
||||
|
||||
if (h > (fbtk_get_height(parent->browser) - py))
|
||||
if (h > (fbtk_get_height(parent->browser) - py))
|
||||
h = fbtk_get_height(parent->browser) - py;
|
||||
|
||||
fbtk_set_pos_and_size(g->window, px, py , w , h);
|
||||
@ -820,7 +820,7 @@ void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
|
||||
}
|
||||
|
||||
void gui_window_hide_pointer(struct gui_window *g)
|
||||
{
|
||||
{
|
||||
}
|
||||
|
||||
void gui_window_set_url(struct gui_window *g, const char *url)
|
||||
|
@ -43,7 +43,7 @@ enum fbtk_widgettype_e {
|
||||
FB_WIDGET_TYPE_FILL,
|
||||
FB_WIDGET_TYPE_TEXT,
|
||||
FB_WIDGET_TYPE_HSCROLL,
|
||||
FB_WIDGET_TYPE_USER,
|
||||
FB_WIDGET_TYPE_USER,
|
||||
};
|
||||
|
||||
typedef struct fbtk_widget_list_s fbtk_widget_list_t;
|
||||
@ -83,7 +83,7 @@ struct fbtk_widget_s {
|
||||
struct {
|
||||
framebuffer_t *fb;
|
||||
fbtk_widget_t *rootw;
|
||||
fbtk_widget_t *input;
|
||||
fbtk_widget_t *input;
|
||||
} root;
|
||||
|
||||
/* window */
|
||||
@ -150,7 +150,7 @@ get_root_widget(fbtk_widget_t *widget)
|
||||
LOG(("Widget with null parent that is not the root widget!"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
@ -194,7 +194,7 @@ add_widget_to_window(fbtk_widget_t *window, fbtk_widget_t *widget)
|
||||
}
|
||||
|
||||
newent = calloc(1, sizeof(struct fbtk_widget_list_s));
|
||||
|
||||
|
||||
newent->widget = widget;
|
||||
newent->next = NULL;
|
||||
newent->prev = prevent;
|
||||
@ -269,7 +269,7 @@ fb_redraw_fill(fbtk_widget_t *widget, void *pw)
|
||||
/* clear background */
|
||||
if ((widget->bg & 0xFF000000) != 0) {
|
||||
/* transparent polygon filling isnt working so fake it */
|
||||
plot.fill(fb_plot_ctx.x0, fb_plot_ctx.y0,
|
||||
plot.fill(fb_plot_ctx.x0, fb_plot_ctx.y0,
|
||||
fb_plot_ctx.x1, fb_plot_ctx.y1,
|
||||
widget->bg);
|
||||
}
|
||||
@ -282,26 +282,32 @@ fb_redraw_hscroll(fbtk_widget_t *widget, void *pw)
|
||||
int hscroll;
|
||||
int hpos;
|
||||
|
||||
plot.fill(fb_plot_ctx.x0, fb_plot_ctx.y0,
|
||||
plot.fill(fb_plot_ctx.x0, fb_plot_ctx.y0,
|
||||
fb_plot_ctx.x1, fb_plot_ctx.y1,
|
||||
widget->bg);
|
||||
|
||||
plot.rectangle(fb_plot_ctx.x0,
|
||||
plot.fill(fb_plot_ctx.x0 + 1,
|
||||
fb_plot_ctx.y0 + 3,
|
||||
fb_plot_ctx.x1 - 1,
|
||||
fb_plot_ctx.y1 - 3,
|
||||
widget->fg);
|
||||
|
||||
plot.rectangle(fb_plot_ctx.x0,
|
||||
fb_plot_ctx.y0 + 2,
|
||||
fb_plot_ctx.x1 - fb_plot_ctx.x0 - 1,
|
||||
fb_plot_ctx.y1 - fb_plot_ctx.y0 - 5,
|
||||
1, 0x00000000, false, false);
|
||||
1, 0xFF000000, false, false);
|
||||
|
||||
hscroll = ((widget->width - 4) * widget->u.scroll.pct) / 100 ;
|
||||
hpos = ((widget->width - 4) * widget->u.scroll.pos) / 100 ;
|
||||
|
||||
LOG(("hscroll %d",hscroll));
|
||||
|
||||
plot.fill(fb_plot_ctx.x0 + 3 + hpos,
|
||||
fb_plot_ctx.y0 + 5,
|
||||
fb_plot_ctx.x0 + hscroll + hpos,
|
||||
plot.fill(fb_plot_ctx.x0 + 3 + hpos,
|
||||
fb_plot_ctx.y0 + 5,
|
||||
fb_plot_ctx.x0 + hscroll + hpos,
|
||||
fb_plot_ctx.y0 + widget->height - 5,
|
||||
widget->fg);
|
||||
widget->bg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -312,7 +318,7 @@ fb_redraw_bitmap(fbtk_widget_t *widget, void *pw)
|
||||
/* clear background */
|
||||
if ((widget->bg & 0xFF000000) != 0) {
|
||||
/* transparent polygon filling isnt working so fake it */
|
||||
plot.fill(fb_plot_ctx.x0, fb_plot_ctx.y0,
|
||||
plot.fill(fb_plot_ctx.x0, fb_plot_ctx.y0,
|
||||
fb_plot_ctx.x1, fb_plot_ctx.y1,
|
||||
widget->bg);
|
||||
}
|
||||
@ -339,10 +345,10 @@ fbtk_window_default_redraw(fbtk_widget_t *window, void *pw)
|
||||
while (lent != NULL) {
|
||||
widget = lent->widget;
|
||||
|
||||
if ((widget->redraw != NULL) &&
|
||||
if ((widget->redraw != NULL) &&
|
||||
(widget->redraw_required)) {
|
||||
fbtk_redraw_widget(widget);
|
||||
|
||||
|
||||
}
|
||||
lent = lent->next;
|
||||
}
|
||||
@ -368,7 +374,7 @@ fbtk_window_default_move(fbtk_widget_t *window, int x, int y, void *pw)
|
||||
(y < widget->y + widget->height)) {
|
||||
if (widget->move != NULL) {
|
||||
res = widget->move(widget,
|
||||
x - widget->x,
|
||||
x - widget->x,
|
||||
y - widget->y,
|
||||
widget->movepw);
|
||||
}
|
||||
@ -380,7 +386,7 @@ fbtk_window_default_move(fbtk_widget_t *window, int x, int y, void *pw)
|
||||
}
|
||||
|
||||
static int
|
||||
fbtk_window_default_click(fbtk_widget_t *window, browser_mouse_state st, int x, int y, void *pw)
|
||||
fbtk_window_default_click(fbtk_widget_t *window, browser_mouse_state st, int x, int y, void *pw)
|
||||
{
|
||||
fbtk_widget_list_t *lent;
|
||||
fbtk_widget_t *widget;
|
||||
@ -402,16 +408,16 @@ fbtk_window_default_click(fbtk_widget_t *window, browser_mouse_state st, int x,
|
||||
}
|
||||
|
||||
if (widget->click != NULL) {
|
||||
res = widget->click(widget,
|
||||
res = widget->click(widget,
|
||||
st,
|
||||
x - widget->x,
|
||||
x - widget->x,
|
||||
y - widget->y,
|
||||
widget->clickpw);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
lent = lent->next;
|
||||
}
|
||||
@ -424,7 +430,7 @@ fb_redraw_text(fbtk_widget_t *widget, void *pw)
|
||||
/* clear background */
|
||||
if ((widget->bg & 0xFF000000) != 0) {
|
||||
/* transparent polygon filling isnt working so fake it */
|
||||
plot.fill(fb_plot_ctx.x0, fb_plot_ctx.y0,
|
||||
plot.fill(fb_plot_ctx.x0, fb_plot_ctx.y0,
|
||||
fb_plot_ctx.x1, fb_plot_ctx.y1,
|
||||
widget->bg);
|
||||
}
|
||||
@ -468,14 +474,14 @@ text_input(fbtk_widget_t *widget, int value, void *pw)
|
||||
widget->u.text.idx--;
|
||||
widget->u.text.text[widget->u.text.idx] = 0;
|
||||
break;
|
||||
|
||||
|
||||
case '\r':
|
||||
widget->u.text.enter(widget->u.text.pw, widget->u.text.text);
|
||||
break;
|
||||
|
||||
default:
|
||||
/* allow for new character and null */
|
||||
widget->u.text.text = realloc(widget->u.text.text, widget->u.text.idx + 2);
|
||||
widget->u.text.text = realloc(widget->u.text.text, widget->u.text.idx + 2);
|
||||
widget->u.text.text[widget->u.text.idx] = value;
|
||||
widget->u.text.text[widget->u.text.idx + 1] = '\0';
|
||||
widget->u.text.idx++;
|
||||
@ -517,7 +523,7 @@ fbtk_get_x(fbtk_widget_t *widget)
|
||||
{
|
||||
int x = widget->x;
|
||||
|
||||
while (widget->parent != NULL) {
|
||||
while (widget->parent != NULL) {
|
||||
widget = widget->parent;
|
||||
x += widget->x;
|
||||
}
|
||||
@ -530,7 +536,7 @@ fbtk_get_y(fbtk_widget_t *widget)
|
||||
{
|
||||
int y = widget->y;
|
||||
|
||||
while (widget->parent != NULL) {
|
||||
while (widget->parent != NULL) {
|
||||
widget = widget->parent;
|
||||
y += widget->y;
|
||||
}
|
||||
@ -569,7 +575,7 @@ fbtk_set_handler_move(fbtk_widget_t *widget, fbtk_move_t move, void *pw)
|
||||
void *
|
||||
fbtk_get_userpw(fbtk_widget_t *widget)
|
||||
{
|
||||
if ((widget == NULL) || (widget->type != FB_WIDGET_TYPE_USER))
|
||||
if ((widget == NULL) || (widget->type != FB_WIDGET_TYPE_USER))
|
||||
return NULL;
|
||||
|
||||
return widget->u.user.pw;
|
||||
@ -578,7 +584,7 @@ fbtk_get_userpw(fbtk_widget_t *widget)
|
||||
void
|
||||
fbtk_set_text(fbtk_widget_t *widget, const char *text)
|
||||
{
|
||||
if ((widget == NULL) || (widget->type != FB_WIDGET_TYPE_TEXT))
|
||||
if ((widget == NULL) || (widget->type != FB_WIDGET_TYPE_TEXT))
|
||||
return;
|
||||
if (widget->u.text.text != NULL) {
|
||||
if (strcmp(widget->u.text.text, text) == 0)
|
||||
@ -594,7 +600,7 @@ fbtk_set_text(fbtk_widget_t *widget, const char *text)
|
||||
void
|
||||
fbtk_set_scroll(fbtk_widget_t *widget, int pct)
|
||||
{
|
||||
if ((widget == NULL) || (widget->type != FB_WIDGET_TYPE_HSCROLL))
|
||||
if ((widget == NULL) || (widget->type != FB_WIDGET_TYPE_HSCROLL))
|
||||
return;
|
||||
|
||||
widget->u.scroll.pct = pct;
|
||||
@ -605,7 +611,7 @@ fbtk_set_scroll(fbtk_widget_t *widget, int pct)
|
||||
void
|
||||
fbtk_set_scroll_pos(fbtk_widget_t *widget, int pos)
|
||||
{
|
||||
if ((widget == NULL) || (widget->type != FB_WIDGET_TYPE_HSCROLL))
|
||||
if ((widget == NULL) || (widget->type != FB_WIDGET_TYPE_HSCROLL))
|
||||
return;
|
||||
|
||||
widget->u.scroll.pos = pos;
|
||||
@ -616,7 +622,7 @@ fbtk_set_scroll_pos(fbtk_widget_t *widget, int pos)
|
||||
void
|
||||
fbtk_set_bitmap(fbtk_widget_t *widget, struct bitmap *image)
|
||||
{
|
||||
if ((widget == NULL) || (widget->type != FB_WIDGET_TYPE_BITMAP))
|
||||
if ((widget == NULL) || (widget->type != FB_WIDGET_TYPE_BITMAP))
|
||||
return;
|
||||
|
||||
widget->u.bitmap.bitmap = image;
|
||||
@ -666,10 +672,10 @@ fbtk_count_children(fbtk_widget_t *widget)
|
||||
void
|
||||
fbtk_input(fbtk_widget_t *widget, uint32_t ucs4)
|
||||
{
|
||||
fbtk_widget_t *input;
|
||||
fbtk_widget_t *input;
|
||||
|
||||
widget = get_root_widget(widget);
|
||||
|
||||
|
||||
/* obtain widget with input focus */
|
||||
input = widget->u.root.input;
|
||||
if (input == NULL)
|
||||
@ -747,7 +753,7 @@ fbtk_redraw(fbtk_widget_t *widget)
|
||||
|
||||
fb_cursor_clear(root->u.root.fb);
|
||||
|
||||
if (window->redraw != NULL)
|
||||
if (window->redraw != NULL)
|
||||
fbtk_redraw_widget(window);
|
||||
|
||||
root->redraw_required = false;
|
||||
@ -774,7 +780,7 @@ int fbtk_destroy_widget(fbtk_widget_t *widget)
|
||||
|
||||
/************** Widget creation *************/
|
||||
fbtk_widget_t *
|
||||
fbtk_create_text(fbtk_widget_t *window,
|
||||
fbtk_create_text(fbtk_widget_t *window,
|
||||
int x, int y,
|
||||
int width, int height,
|
||||
colour bg, colour fg,
|
||||
@ -826,7 +832,7 @@ fbtk_width_height(fbtk_widget_t *parent, int x, int y, int *width, int *height)
|
||||
if ((*width + x) > parent->width) {
|
||||
*width = parent->width - x;
|
||||
}
|
||||
|
||||
|
||||
if (*height == 0) {
|
||||
*height = parent->height - y;
|
||||
} else if (*height < 0) {
|
||||
@ -874,7 +880,7 @@ fbtk_create_hscroll(fbtk_widget_t *window, int x, int y, int width, int height,
|
||||
}
|
||||
|
||||
fbtk_widget_t *
|
||||
fbtk_create_button(fbtk_widget_t *window,
|
||||
fbtk_create_button(fbtk_widget_t *window,
|
||||
int x, int y,
|
||||
colour c,
|
||||
struct bitmap *image,
|
||||
@ -890,11 +896,11 @@ fbtk_create_button(fbtk_widget_t *window,
|
||||
}
|
||||
|
||||
fbtk_widget_t *
|
||||
fbtk_create_writable_text(fbtk_widget_t *window,
|
||||
int x, int y,
|
||||
int width, int height,
|
||||
colour bg, colour fg,
|
||||
bool outline,
|
||||
fbtk_create_writable_text(fbtk_widget_t *window,
|
||||
int x, int y,
|
||||
int width, int height,
|
||||
colour bg, colour fg,
|
||||
bool outline,
|
||||
fbtk_enter_t enter, void *pw)
|
||||
{
|
||||
fbtk_widget_t *newt = fbtk_create_text(window, x, y, width, height, bg,fg,outline);
|
||||
@ -906,14 +912,14 @@ fbtk_create_writable_text(fbtk_widget_t *window,
|
||||
return newt;
|
||||
}
|
||||
|
||||
/* create user widget
|
||||
/* create user widget
|
||||
*
|
||||
* @param x coord relative to parent
|
||||
* @param x coord relative to parent
|
||||
*/
|
||||
fbtk_widget_t *
|
||||
fbtk_create_user(fbtk_widget_t *window,
|
||||
int x, int y,
|
||||
int width, int height,
|
||||
fbtk_create_user(fbtk_widget_t *window,
|
||||
int x, int y,
|
||||
int width, int height,
|
||||
void *pw)
|
||||
{
|
||||
fbtk_widget_t *newu = new_widget(FB_WIDGET_TYPE_USER);
|
||||
@ -928,7 +934,7 @@ fbtk_create_user(fbtk_widget_t *window,
|
||||
if ((width + x) > window->width) {
|
||||
width = window->width - x;
|
||||
}
|
||||
|
||||
|
||||
if (height == 0) {
|
||||
height = window->height - y;
|
||||
} else if (height < 0) {
|
||||
@ -949,21 +955,21 @@ fbtk_create_user(fbtk_widget_t *window,
|
||||
}
|
||||
|
||||
|
||||
/* create new window
|
||||
/* create new window
|
||||
*
|
||||
* @param x coord relative to parent
|
||||
* @param x coord relative to parent
|
||||
*/
|
||||
fbtk_widget_t *
|
||||
fbtk_create_window(fbtk_widget_t *parent,
|
||||
fbtk_create_window(fbtk_widget_t *parent,
|
||||
int x, int y, int width, int height)
|
||||
{
|
||||
fbtk_widget_t *newwin;
|
||||
fbtk_widget_t *newwin;
|
||||
|
||||
LOG(("Creating window %p %d,%d %d,%d",parent,x,y,width,height));
|
||||
if (parent == NULL)
|
||||
return NULL;
|
||||
|
||||
if ((parent->type == FB_WIDGET_TYPE_ROOT) &&
|
||||
if ((parent->type == FB_WIDGET_TYPE_ROOT) &&
|
||||
(parent->u.root.rootw != NULL)) {
|
||||
LOG(("Using root window"));
|
||||
parent = parent->u.root.rootw;
|
||||
@ -980,7 +986,7 @@ fbtk_create_window(fbtk_widget_t *parent,
|
||||
if ((width + x) > parent->width) {
|
||||
width = parent->width - x;
|
||||
}
|
||||
|
||||
|
||||
if (height == 0) {
|
||||
height = parent->height - y;
|
||||
} else if (height < 0) {
|
||||
|
@ -1,4 +1,5 @@
|
||||
|
||||
#define FB_SCROLL_COLOUR 0xFF888888
|
||||
#define FB_FRAME_COLOUR 0xFFDDDDDD
|
||||
#define FB_COLOUR_BLACK 0xFF000000
|
||||
#define FB_COLOUR_WHITE 0xFFFFFFFF
|
||||
@ -41,10 +42,10 @@ fbtk_widget_t *fbtk_init(framebuffer_t *fb);
|
||||
* @param x The x location relative to the parent window.
|
||||
* @param y the y location relative to the parent window.
|
||||
* @param width The width of the window. 0 indicates parents width should be
|
||||
* used. Negative value indicates parents width less the value
|
||||
* should be used. The width is limited to lie within the parent
|
||||
* used. Negative value indicates parents width less the value
|
||||
* should be used. The width is limited to lie within the parent
|
||||
* window.
|
||||
* @param height The height of the window limited in a similar way to the
|
||||
* @param height The height of the window limited in a similar way to the
|
||||
* /a width.
|
||||
* @param c The background colour.
|
||||
* @return new window widget handle or NULL on error.
|
||||
@ -52,18 +53,18 @@ fbtk_widget_t *fbtk_init(framebuffer_t *fb);
|
||||
fbtk_widget_t *fbtk_create_window(fbtk_widget_t *parent, int x, int y, int width, int height);
|
||||
|
||||
/** Create a text widget.
|
||||
*
|
||||
*
|
||||
* @param window The window to add the text widget to.
|
||||
* @return new widget handle or NULL on error.
|
||||
* @return new widget handle or NULL on error.
|
||||
*/
|
||||
fbtk_widget_t *fbtk_create_text(fbtk_widget_t *window, int x, int y, int width, int height, colour bg, colour fg, bool outline);
|
||||
|
||||
/** Create a bitmap widget.
|
||||
*
|
||||
*
|
||||
* Create a widget which shows a bitmap.
|
||||
*
|
||||
*
|
||||
* @param window The window to add the bitmap widget to.
|
||||
* @return new widget handle or NULL on error.
|
||||
* @return new widget handle or NULL on error.
|
||||
*/
|
||||
fbtk_widget_t *fbtk_create_bitmap(fbtk_widget_t *window, int x, int y, colour c,struct bitmap *image);
|
||||
|
||||
@ -72,7 +73,7 @@ fbtk_widget_t *fbtk_create_bitmap(fbtk_widget_t *window, int x, int y, colour c,
|
||||
* Create a widget which is a filled rectangle, usually used for backgrounds.
|
||||
*
|
||||
* @param window The window to add the filled area widget to.
|
||||
* @return new widget handle or NULL on error.
|
||||
* @return new widget handle or NULL on error.
|
||||
*/
|
||||
fbtk_widget_t *
|
||||
fbtk_create_fill(fbtk_widget_t *window, int x, int y, int width, int height, colour c);
|
||||
@ -82,40 +83,40 @@ fbtk_create_fill(fbtk_widget_t *window, int x, int y, int width, int height, col
|
||||
* Create a horizontal scroll widget.
|
||||
*
|
||||
* @param window The window to add the filled area widget to.
|
||||
* @return new widget handle or NULL on error.
|
||||
* @return new widget handle or NULL on error.
|
||||
*/
|
||||
fbtk_widget_t *
|
||||
fbtk_create_hscroll(fbtk_widget_t *window, int x, int y, int width, int height, colour fg, colour bg);
|
||||
|
||||
/** Create a user widget.
|
||||
*
|
||||
*
|
||||
* Create a widget which is to be handled entirely by the calling application.
|
||||
*
|
||||
*
|
||||
* @param window The window to add the user widget to.
|
||||
* @param pw The private pointer which can be read using ::fbtk_get_pw
|
||||
* @return new widget handle or NULL on error.
|
||||
* @return new widget handle or NULL on error.
|
||||
*/
|
||||
fbtk_widget_t *fbtk_create_user(fbtk_widget_t *window, int x, int y, int width, int height, void *pw);
|
||||
|
||||
|
||||
/** Create a button widget.
|
||||
*
|
||||
*
|
||||
* Helper function which creates a bitmap widget and associate a handler for
|
||||
* when it is clicked.
|
||||
*
|
||||
*
|
||||
* @param window The window to add the button widget to.
|
||||
* @return new widget handle or NULL on error.
|
||||
* @return new widget handle or NULL on error.
|
||||
*/
|
||||
fbtk_widget_t *fbtk_create_button(fbtk_widget_t *window, int x, int y, colour c, struct bitmap *image, fbtk_mouseclick_t click, void *pw);
|
||||
|
||||
/** Create a writable text widget.
|
||||
*
|
||||
*
|
||||
* Helper function which creates a text widget and configures an input handler
|
||||
* to create a writable text field. This call is equivalent to calling
|
||||
* ::fbtk_create_text followed by ::fbtk_writable_text
|
||||
*
|
||||
* @param window The window to add the text widget to.
|
||||
* @return new widget handle or NULL on error.
|
||||
* @return new widget handle or NULL on error.
|
||||
*/
|
||||
fbtk_widget_t *fbtk_create_writable_text(fbtk_widget_t *window, int x, int y, int width, int height, colour bg, colour fg, bool outline, fbtk_enter_t enter, void *pw);
|
||||
|
||||
@ -172,11 +173,11 @@ void fbtk_move_pointer(fbtk_widget_t *widget, int x, int y, bool relative);
|
||||
*/
|
||||
void fbtk_click(fbtk_widget_t *widget, browser_mouse_state st);
|
||||
|
||||
/** Input has been recived
|
||||
/** Input has been recived
|
||||
*/
|
||||
void fbtk_input(fbtk_widget_t *widget, uint32_t ucs4);
|
||||
|
||||
/** Indicate a widget has to be redrawn
|
||||
/** Indicate a widget has to be redrawn
|
||||
*/
|
||||
void fbtk_request_redraw(fbtk_widget_t *widget);
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 522 B After Width: | Height: | Size: 285 B |
Binary file not shown.
Before Width: | Height: | Size: 509 B After Width: | Height: | Size: 304 B |
Loading…
Reference in New Issue
Block a user