MCPcopy Create free account
hub / github.com/NetHack/NetHack / init_column

Function init_column

win/X11/winstat.c:2290–2344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2288}
2289
2290static Widget
2291init_column(
2292 const char *name,
2293 Widget parent, Widget top, Widget left,
2294 int *col_indices, int xtrawidth)
2295{
2296 Widget form;
2297 Arg args[4];
2298 Cardinal num_args;
2299 int max_width1, width1, max_width2, width2;
2300 int *ip;
2301 struct X_status_value *sv;
2302
2303 num_args = 0;
2304 if (top != (Widget) 0) {
2305 XtSetArg(args[num_args], nhStr(XtNfromVert), top); num_args++;
2306 }
2307 if (left != (Widget) 0) {
2308 XtSetArg(args[num_args], nhStr(XtNfromHoriz), left); num_args++;
2309 }
2310 /* this was 0 but that resulted in the text being crammed together */
2311 XtSetArg(args[num_args], nhStr(XtNdefaultDistance), 2); num_args++;
2312 form = XtCreateManagedWidget(name, formWidgetClass, parent,
2313 args, num_args);
2314
2315 max_width1 = max_width2 = 0;
2316 for (ip = col_indices; *ip >= 0; ip++) {
2317 sv = &shown_stats[*ip];
2318 create_widget(form, sv, *ip); /* will set init width */
2319 if (ip != col_indices) { /* not first */
2320 num_args = 0;
2321 XtSetArg(args[num_args], nhStr(XtNfromVert),
2322 shown_stats[*(ip - 1)].w); num_args++;
2323 XtSetValues(sv->w, args, num_args);
2324 }
2325 get_widths(sv, &width1, &width2);
2326 if (width1 > max_width1)
2327 max_width1 = width1;
2328 if (width2 > max_width2)
2329 max_width2 = width2;
2330 }
2331
2332 /* insert some extra spacing between columns */
2333 max_width1 += xtrawidth;
2334
2335 for (ip = col_indices; *ip >= 0; ip++) {
2336 set_widths(&shown_stats[*ip], max_width1, max_width2);
2337 }
2338
2339 /* There is room behind the end marker for the two widths. */
2340 *++ip = max_width1;
2341 *++ip = max_width2;
2342
2343 return form;
2344}
2345
2346/*
2347 * These are the orders of the displayed columns. Change to suit. The -1

Callers 2

init_info_formFunction · 0.85
create_fancy_statusFunction · 0.85

Calls 3

create_widgetFunction · 0.85
get_widthsFunction · 0.85
set_widthsFunction · 0.85

Tested by

no test coverage detected