static void nmt_newt_button_box_size_allocate (NmtNewtWidget *widget, int x, int y, int width, int height) { NmtNewtButtonBoxPrivate *priv = NMT_NEWT_BUTTON_BOX_GET_PRIVATE (widget); NmtNewtWidget *child; int child_x, child_y, child_width, child_height; int i; child_x = x; child_y = y; for (i = 0; i < priv->start_buttons->len; i++) { child = priv->start_buttons->pdata[i]; nmt_newt_widget_size_request (child, &child_width, &child_height); if (priv->orientation == NMT_NEWT_BUTTON_BOX_HORIZONTAL) { nmt_newt_widget_size_allocate (child, child_x, child_y, child_width, child_height); child_x += child_width + 1; } else { nmt_newt_widget_size_allocate (child, child_x, child_y, child_width, child_height); child_y += child_height + 1; } } if (priv->orientation == NMT_NEWT_BUTTON_BOX_HORIZONTAL) child_x = x + width; else child_y = y + height; for (i = priv->end_buttons->len - 1; i >= 0; i--) { child = priv->end_buttons->pdata[i]; nmt_newt_widget_size_request (child, &child_width, &child_height); if (priv->orientation == NMT_NEWT_BUTTON_BOX_HORIZONTAL) { nmt_newt_widget_size_allocate (child, child_x - child_width, child_y, child_width, child_height); child_x -= child_width + 1; } else { nmt_newt_widget_size_allocate (child, child_x, child_y - child_height, child_width, child_height); child_y -= child_height + 1; } } }
static void nmt_newt_section_size_allocate (NmtNewtWidget *widget, int x, int y, int width, int height) { NmtNewtSectionPrivate *priv = NMT_NEWT_SECTION_GET_PRIVATE (widget); if (priv->show_border) { int border_height, border_width; adjust_border_for_allocation (priv, height); nmt_newt_widget_size_request (priv->border_grid, &border_height, &border_width); nmt_newt_widget_size_allocate (priv->border_grid, x, y, 1, height); nmt_newt_widget_size_allocate (priv->header, x + 2, y, width, priv->hheight_req); } else nmt_newt_widget_size_allocate (priv->header, x, y, width, priv->hheight_req); if (priv->open) { nmt_newt_widget_size_allocate (priv->body, x + 2, y + priv->hheight_req, width, height - priv->hheight_req); } }
static void nmt_newt_form_build (NmtNewtForm *form) { NmtNewtFormPrivate *priv = NMT_NEWT_FORM_GET_PRIVATE (form); int screen_height, screen_width, form_height, form_width; newtComponent *cos; int i; priv->dirty = FALSE; nmt_newt_widget_realize (NMT_NEWT_WIDGET (form)); nmt_newt_widget_size_request (priv->content, &form_width, &form_height); newtGetScreenSize (&screen_width, &screen_height); if (!priv->fixed_width) priv->width = MIN (form_width + 2 * priv->padding, screen_width - 2); if (!priv->fixed_height) priv->height = MIN (form_height + 2 * priv->padding, screen_height - 2); if (!priv->fixed_x) priv->x = (screen_width - form_width) / 2; if (!priv->fixed_y) priv->y = (screen_height - form_height) / 2; nmt_newt_widget_size_allocate (priv->content, priv->padding, priv->padding, priv->width - 2 * priv->padding, priv->height - 2 * priv->padding); if (priv->height - 2 * priv->padding < form_height) { newtComponent scroll_bar = newtVerticalScrollbar (priv->width - 1, 0, priv->height, NEWT_COLORSET_WINDOW, NEWT_COLORSET_ACTCHECKBOX); priv->form = newtForm (scroll_bar, NULL, NEWT_FLAG_NOF12); newtFormAddComponent (priv->form, scroll_bar); newtFormSetHeight (priv->form, priv->height - 2); } else priv->form = newtForm (NULL, NULL, NEWT_FLAG_NOF12); if (priv->escape_exits) newtFormAddHotKey (priv->form, NEWT_KEY_ESCAPE); cos = nmt_newt_widget_get_components (priv->content); for (i = 0; cos[i]; i++) newtFormAddComponent (priv->form, cos[i]); g_free (cos); if (priv->focus) { newtComponent fco; fco = nmt_newt_widget_get_focus_component (priv->focus); if (fco) newtFormSetCurrent (priv->form, fco); } #ifdef HAVE_NEWTFORMGETSCROLLPOSITION if (priv->scroll_position) newtFormSetScrollPosition (priv->form, priv->scroll_position); #endif newtOpenWindow (priv->x, priv->y, priv->width, priv->height, priv->title_lc); }
static void nmt_editor_grid_size_allocate (NmtNewtWidget *widget, int x, int y, int width, int height) { NmtEditorGridPrivate *priv = NMT_EDITOR_GRID_GET_PRIVATE (widget); NmtEditorGridRow *rows = (NmtEditorGridRow *) priv->rows->data; NmtEditorGridFormState *state = get_form_state (widget); int col0_width, col1_width, col2_width; int i, row; col0_width = state->col_widths[0] - priv->indent; col1_width = state->col_widths[1]; col2_width = state->col_widths[2]; for (i = row = 0; i < priv->rows->len; i++) { if (!nmt_newt_widget_get_visible (rows[i].widget)) continue; if (rows[i].label) { int lwidth, lheight, lx; if (rows[i].flags & NMT_EDITOR_GRID_ROW_LABEL_ALIGN_LEFT) lx = x; else { nmt_newt_widget_size_request (rows[i].label, &lwidth, &lheight); lx = x + col0_width - lwidth; } nmt_newt_widget_size_allocate (rows[i].label, lx, y + row, col0_width, priv->row_heights[i]); nmt_newt_widget_size_allocate (rows[i].widget, x + col0_width + 1, y + row, col1_width, priv->row_heights[i]); } else { nmt_newt_widget_size_allocate (rows[i].widget, x, y + row, col0_width + col1_width + 1, priv->row_heights[i]); } if (rows[i].extra) { int wwidth, wheight, ex; if (rows[i].flags & NMT_EDITOR_GRID_ROW_EXTRA_ALIGN_RIGHT) ex = x + col0_width + col1_width + 2; else { nmt_newt_widget_size_request (rows[i].widget, &wwidth, &wheight); ex = x + col0_width + wwidth + 2; } nmt_newt_widget_size_allocate (rows[i].extra, ex, y + row, col2_width, priv->row_heights[i]); } row += priv->row_heights[i]; } }