Commit 4a8e884afc36cf962af227b7c07a5fe737c7787d
1 parent
3504b016
Exists in
master
and in
5 other branches
Ajustando tamanho mínimo da janela do terminal
Showing
2 changed files
with
101 additions
and
19 deletions
Show diff stats
src/gtk/v3270/v3270.h
@@ -170,6 +170,9 @@ | @@ -170,6 +170,9 @@ | ||
170 | 170 | ||
171 | struct v3270_metrics metrics; | 171 | struct v3270_metrics metrics; |
172 | 172 | ||
173 | + gint minimum_width; | ||
174 | + gint minimum_height; | ||
175 | + | ||
173 | /* Colors */ | 176 | /* Colors */ |
174 | GdkColor color[V3270_COLOR_COUNT]; /**< Terminal widget colors */ | 177 | GdkColor color[V3270_COLOR_COUNT]; /**< Terminal widget colors */ |
175 | 178 |
src/gtk/v3270/widget.c
@@ -116,7 +116,6 @@ static void v3270_toggle_changed(v3270 *widget,LIB3270_TOGGLE toggle_id, gboolea | @@ -116,7 +116,6 @@ static void v3270_toggle_changed(v3270 *widget,LIB3270_TOGGLE toggle_id, gboolea | ||
116 | break; | 116 | break; |
117 | 117 | ||
118 | case LIB3270_TOGGLE_BOLD: | 118 | case LIB3270_TOGGLE_BOLD: |
119 | - widget->font_weight = lib3270_get_toggle(widget->host,LIB3270_TOGGLE_BOLD) ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL; | ||
120 | v3270_reload(GTK_WIDGET(widget)); | 119 | v3270_reload(GTK_WIDGET(widget)); |
121 | gtk_widget_queue_draw(GTK_WIDGET(widget)); | 120 | gtk_widget_queue_draw(GTK_WIDGET(widget)); |
122 | break; | 121 | break; |
@@ -150,6 +149,70 @@ static gboolean v3270_popup_menu(GtkWidget * widget) | @@ -150,6 +149,70 @@ static gboolean v3270_popup_menu(GtkWidget * widget) | ||
150 | return TRUE; | 149 | return TRUE; |
151 | } | 150 | } |
152 | 151 | ||
152 | +#if GTK_CHECK_VERSION(3,0,0) | ||
153 | + | ||
154 | +static GtkSizeRequestMode get_request_mode(GtkWidget *widget) | ||
155 | +{ | ||
156 | + int rows, cols; | ||
157 | + | ||
158 | + trace("%s",__FUNCTION__); | ||
159 | + | ||
160 | + lib3270_get_screen_size(GTK_V3270(widget)->host,&rows,&cols); | ||
161 | + | ||
162 | + return rows > cols ? GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT : GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH; | ||
163 | + | ||
164 | +} | ||
165 | + | ||
166 | +void get_preferred_height(GtkWidget *widget, gint *minimum_height, gint *natural_height) | ||
167 | +{ | ||
168 | + int height = GTK_V3270(widget)->minimum_height; | ||
169 | + | ||
170 | + if(minimum_height) | ||
171 | + *minimum_height = height ? height : 10; | ||
172 | + | ||
173 | + if(natural_height) | ||
174 | + *natural_height = height ? height : 200; | ||
175 | + | ||
176 | +} | ||
177 | + | ||
178 | +void get_preferred_width(GtkWidget *widget, gint *minimum_width, gint *natural_width) | ||
179 | +{ | ||
180 | + int width = GTK_V3270(widget)->minimum_width; | ||
181 | + | ||
182 | + if(minimum_width) | ||
183 | + *minimum_width = width ? width : 10; | ||
184 | + | ||
185 | + if(natural_width) | ||
186 | + *natural_width = width ? width : 320; | ||
187 | +} | ||
188 | + | ||
189 | +/* | ||
190 | +void get_preferred_height_for_width(GtkWidget *widget, gint width, gint *minimum_height, gint *natural_height) | ||
191 | +{ | ||
192 | + trace("%s",__FUNCTION__); | ||
193 | + | ||
194 | + if(minimum_height) | ||
195 | + *minimum_height = 10; | ||
196 | + | ||
197 | + if(natural_height) | ||
198 | + *natural_height = 10; | ||
199 | +} | ||
200 | + | ||
201 | +static void get_preferred_width_for_height(GtkWidget *widget,gint height, gint *minimum_width, gint *natural_width) | ||
202 | +{ | ||
203 | + trace("%s",__FUNCTION__); | ||
204 | + | ||
205 | + if(minimum_width) | ||
206 | + *minimum_width = 10; | ||
207 | + | ||
208 | + if(natural_width) | ||
209 | + *natural_width = 10; | ||
210 | + | ||
211 | +} | ||
212 | +*/ | ||
213 | + | ||
214 | +#endif // GTK(3,0,0) | ||
215 | + | ||
153 | static void v3270_class_init(v3270Class *klass) | 216 | static void v3270_class_init(v3270Class *klass) |
154 | { | 217 | { |
155 | GObjectClass * gobject_class = G_OBJECT_CLASS(klass); | 218 | GObjectClass * gobject_class = G_OBJECT_CLASS(klass); |
@@ -157,26 +220,31 @@ static void v3270_class_init(v3270Class *klass) | @@ -157,26 +220,31 @@ static void v3270_class_init(v3270Class *klass) | ||
157 | 220 | ||
158 | lib3270_set_log_handler(loghandler); | 221 | lib3270_set_log_handler(loghandler); |
159 | 222 | ||
160 | - widget_class->realize = v3270_realize; | ||
161 | - widget_class->size_allocate = v3270_size_allocate; | ||
162 | - widget_class->key_press_event = v3270_key_press_event; | ||
163 | - widget_class->key_release_event = v3270_key_release_event; | ||
164 | - widget_class->focus_in_event = v3270_focus_in_event; | ||
165 | - widget_class->focus_out_event = v3270_focus_out_event; | ||
166 | - widget_class->button_press_event = v3270_button_press_event; | ||
167 | - widget_class->button_release_event = v3270_button_release_event; | ||
168 | - widget_class->motion_notify_event = v3270_motion_notify_event; | ||
169 | - widget_class->popup_menu = v3270_popup_menu; | ||
170 | - | ||
171 | - klass->activate = v3270_activate; | ||
172 | - klass->toggle_changed = v3270_toggle_changed; | ||
173 | - klass->message_changed = v3270_update_message; | ||
174 | - klass->luname_changed = v3270_update_luname; | 223 | + widget_class->realize = v3270_realize; |
224 | + widget_class->size_allocate = v3270_size_allocate; | ||
225 | + widget_class->key_press_event = v3270_key_press_event; | ||
226 | + widget_class->key_release_event = v3270_key_release_event; | ||
227 | + widget_class->focus_in_event = v3270_focus_in_event; | ||
228 | + widget_class->focus_out_event = v3270_focus_out_event; | ||
229 | + widget_class->button_press_event = v3270_button_press_event; | ||
230 | + widget_class->button_release_event = v3270_button_release_event; | ||
231 | + widget_class->motion_notify_event = v3270_motion_notify_event; | ||
232 | + widget_class->popup_menu = v3270_popup_menu; | ||
233 | + | ||
234 | + klass->activate = v3270_activate; | ||
235 | + klass->toggle_changed = v3270_toggle_changed; | ||
236 | + klass->message_changed = v3270_update_message; | ||
237 | + klass->luname_changed = v3270_update_luname; | ||
175 | 238 | ||
176 | #if GTK_CHECK_VERSION(3,0,0) | 239 | #if GTK_CHECK_VERSION(3,0,0) |
177 | 240 | ||
178 | - widget_class->destroy = v3270_destroy; | ||
179 | - widget_class->draw = v3270_draw; | 241 | + widget_class->get_preferred_height = get_preferred_height; |
242 | + widget_class->get_preferred_width = get_preferred_width; | ||
243 | +// widget_class->get_preferred_width_for_height = get_preferred_width_for_height; | ||
244 | +// widget_class->get_preferred_height_for_width = get_preferred_height_for_width; | ||
245 | + | ||
246 | + widget_class->destroy = v3270_destroy; | ||
247 | + widget_class->draw = v3270_draw; | ||
180 | 248 | ||
181 | #else | 249 | #else |
182 | 250 | ||
@@ -193,7 +261,6 @@ static void v3270_class_init(v3270Class *klass) | @@ -193,7 +261,6 @@ static void v3270_class_init(v3270Class *klass) | ||
193 | 261 | ||
194 | v3270_register_io_handlers(klass); | 262 | v3270_register_io_handlers(klass); |
195 | 263 | ||
196 | - | ||
197 | // Cursors | 264 | // Cursors |
198 | v3270_cursor[LIB3270_CURSOR_NORMAL] = gdk_cursor_new(GDK_XTERM); | 265 | v3270_cursor[LIB3270_CURSOR_NORMAL] = gdk_cursor_new(GDK_XTERM); |
199 | v3270_cursor[LIB3270_CURSOR_WAITING] = gdk_cursor_new(GDK_WATCH); | 266 | v3270_cursor[LIB3270_CURSOR_WAITING] = gdk_cursor_new(GDK_WATCH); |
@@ -329,6 +396,8 @@ void v3270_update_font_metrics(v3270 *terminal, cairo_t *cr, int width, int heig | @@ -329,6 +396,8 @@ void v3270_update_font_metrics(v3270 *terminal, cairo_t *cr, int width, int heig | ||
329 | 396 | ||
330 | lib3270_get_screen_size(terminal->host,&rows,&cols); | 397 | lib3270_get_screen_size(terminal->host,&rows,&cols); |
331 | 398 | ||
399 | + terminal->font_weight = lib3270_get_toggle(terminal->host,LIB3270_TOGGLE_BOLD) ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL; | ||
400 | + | ||
332 | cairo_select_font_face(cr, terminal->font_family, CAIRO_FONT_SLANT_NORMAL,terminal->font_weight); | 401 | cairo_select_font_face(cr, terminal->font_family, CAIRO_FONT_SLANT_NORMAL,terminal->font_weight); |
333 | 402 | ||
334 | for(f=0;font_size[f];f++) | 403 | for(f=0;font_size[f];f++) |
@@ -336,12 +405,22 @@ void v3270_update_font_metrics(v3270 *terminal, cairo_t *cr, int width, int heig | @@ -336,12 +405,22 @@ void v3270_update_font_metrics(v3270 *terminal, cairo_t *cr, int width, int heig | ||
336 | cairo_set_font_size(cr,font_size[f]); | 405 | cairo_set_font_size(cr,font_size[f]); |
337 | cairo_font_extents(cr,&extents); | 406 | cairo_font_extents(cr,&extents); |
338 | 407 | ||
408 | + if(f == 0) | ||
409 | + { | ||
410 | + terminal->minimum_width = (cols * extents.max_x_advance); | ||
411 | + terminal->minimum_height = ((rows+1) * (extents.height + extents.descent)) + (OIA_TOP_MARGIN+2); | ||
412 | + } | ||
413 | + | ||
339 | if( HEIGHT_IN_PIXELS(terminal,(extents.height+extents.descent)) < height && WIDTH_IN_PIXELS(terminal,extents.max_x_advance) < width ) | 414 | if( HEIGHT_IN_PIXELS(terminal,(extents.height+extents.descent)) < height && WIDTH_IN_PIXELS(terminal,extents.max_x_advance) < width ) |
340 | size = font_size[f]; | 415 | size = font_size[f]; |
341 | } | 416 | } |
342 | 417 | ||
343 | cairo_set_font_size(cr,size); | 418 | cairo_set_font_size(cr,size); |
344 | 419 | ||
420 | +#if !GTK_CHECK_VERSION(3,0,0) | ||
421 | + gtk_widget_set_size_request(GTK_WIDGET(terminal),terminal->minimum_width,terminal->minimum_height); | ||
422 | +#endif // !GTK(3,0,0) | ||
423 | + | ||
345 | /* | 424 | /* |
346 | double sx, sy; | 425 | double sx, sy; |
347 | cairo_matrix_t font_matrix; | 426 | cairo_matrix_t font_matrix; |