summaryrefslogtreecommitdiff
path: root/frontends/kolibrios/window_table.h
blob: 371926713f9bbffebdc820ecb41cd46ff3fbf4e2 (plain)
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
//Refer ~/dev-netsurf/workspace/netsurf/desktop/gui_window.h

/* ------------------------------ */
/* Part about GUI WINDOW table. Will contain all functions required as well. */
/* Only implement required functions right now. Optional later. */
/* ------------------------------ */

struct gui_window {
  struct browser_window *root;

  char *title;
  char *url;
  void *kobject; /* Kolibri GUI Window for now */
  
  struct gui_window *next, *prev;
};

struct gui_window *master_window;

struct gui_window* kolibri_create_window(struct browser_window *bw, struct gui_window *existing, gui_window_create_flags flags)
{
  struct gui_window *new_window = (struct gui_window *)malloc(sizeof(struct gui_window));
  
  unsigned int gui_event = KOLIBRI_EVENT_REDRAW;
  struct kolibri_window *main_window = kolibri_new_window(20, 20, 400, 400, "Netsurf: Official Port for KolibriOS.");
  struct edit_box *textbox = kolibri_new_edit_box(30, 30, 40);
  kolibri_window_add_element(main_window, KOLIBRI_EDIT_BOX, textbox);

  debug_board_write_str("Creating New GUI window for Netsurf \n");

  new_window->root = bw;
  new_window->url = NULL;
  new_window->title = NULL;
  new_window->kobject = main_window;

  /* do  /\* Start of main activity loop *\/ */
  /*   { */
  /*     if(gui_event == KOLIBRI_EVENT_REDRAW) */
  /* 	{ */
  /* 	  kolibri_handle_event_redraw(main_window); */
  /* 	} */
  /*     else if(gui_event == KOLIBRI_EVENT_KEY) */
  /* 	{ */
  /* 	  kolibri_handle_event_key(main_window); */
  /* 	} */
  /*     else if(gui_event == KOLIBRI_EVENT_BUTTON) */
  /* 	{ */

  /* 	} */
  /*     else if(gui_event == KOLIBRI_EVENT_MOUSE) */
  /* 	{ */
  /* 	  kolibri_handle_event_mouse(main_window); */
  /* 	} */
  /*   } while(gui_event = get_os_event()); /\* End of main activity loop *\/ */

  /* TODO:Fix this according to flags maybe> */

  if(existing)
    new_window->prev = existing;
  else
    new_window->prev = NULL;
  
  new_window->next = NULL;
  debug_board_write_str("Returning new GUI window to NS\n");

  master_window = new_window;
  return new_window;
}

void kolibri_destroy_window(struct gui_window *gw)
{
  free(gw);
}

void kolibri_redraw(struct gui_window *g)
{
  // SF 12,1
}

void kolibri_partial_redraw(struct gui_window *g, const struct rect *rect)
{
  // SF 12,1 for now
}

bool kolibri_get_scroll(struct gui_window *g, int *sx, int *sy)
{
  // SF 37,7
}

void kolibri_set_scroll(struct gui_window *g, int sx, int sy)
{
  
}

void kolibri_get_content_dimensions(struct gui_window *g, int *width, int *height, bool scaled)
{
  /* Return some part of the browser area resolution.
     If the browser is ALWAYS MAXIMIZED, return the Length x Height minus toolbar , url bar, tab area
  */
}


void kolibri_update_extent(struct gui_window *g)
{
  /* Not sure what to do, but some libimg magic here */
}


void kolibri_reformat_contents(struct gui_window *g)
{
    /* Not sure what to do, but some libimg magic here */
}

 /* Invoke libimg and reformat stuff in the contents area here */

static struct gui_window_table kolibri_window_table = {
    .create = kolibri_create_window,
    .destroy = kolibri_destroy_window,
    .redraw = kolibri_redraw,
    .update = kolibri_partial_redraw,
    .get_scroll = kolibri_get_scroll,
    .set_scroll = kolibri_set_scroll,
    .get_dimensions = kolibri_get_content_dimensions,
    .update_extent = kolibri_update_extent,
    .reformat = kolibri_reformat_contents,
    };