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

Function init_info_form

win/X11/winstat.c:2411–2467  ·  view source on GitHub ↗

* Produce a form that looks like the following: * * title * location * col1_indices[0] col2_indices[0] col3_indices[0] * col1_indices[1] col2_indices[1] col3_indices[1] * ... ... ... * col1_indices[5] col2_indices[5] col3_indices[5] * * The status conditions are managed separately and appear to

Source from the content-addressed store, hash-verified

2409 * TODO: widen title field and implement hitpoint bar on it.
2410 */
2411static Widget
2412init_info_form(Widget parent, Widget top, Widget left)
2413{
2414 Widget form, col1, col2;
2415 struct X_status_value *sv_name, *sv_dlevel;
2416 Arg args[6];
2417 Cardinal num_args;
2418 int total_width, *ip;
2419
2420 num_args = 0;
2421 if (top != (Widget) 0) {
2422 XtSetArg(args[num_args], nhStr(XtNfromVert), top); num_args++;
2423 }
2424 if (left != (Widget) 0) {
2425 XtSetArg(args[num_args], nhStr(XtNfromHoriz), left); num_args++;
2426 }
2427 XtSetArg(args[num_args], nhStr(XtNdefaultDistance), 2); num_args++;
2428 form = XtCreateManagedWidget("status_info", formWidgetClass, parent,
2429 args, num_args);
2430
2431 /* top line/row of form */
2432 sv_name = &shown_stats[F_NAME]; /* title */
2433 create_widget(form, sv_name, F_NAME);
2434
2435 /* second line/row */
2436 sv_dlevel = &shown_stats[F_DLEVEL]; /* location */
2437 create_widget(form, sv_dlevel, F_DLEVEL);
2438
2439 num_args = 0;
2440 XtSetArg(args[num_args], nhStr(XtNfromVert), sv_name->w); num_args++;
2441 XtSetValues(sv_dlevel->w, args, num_args);
2442
2443 /* there are 3 columns beneath but top 2 rows are centered over first 2 */
2444 col1 = init_column("name_col1", form, sv_dlevel->w, (Widget) 0,
2445 col1_indices, 0);
2446 col2 = init_column("name_col2", form, sv_dlevel->w, col1,
2447 col2_indices, 5);
2448 (void) init_column("status_characteristics", form, sv_dlevel->w, col2,
2449 characteristics_indices, 15);
2450
2451 /* Add calculated widths. */
2452 for (ip = col1_indices; *ip >= 0; ip++)
2453 ; /* skip to end */
2454 total_width = *++ip;
2455 total_width += *++ip;
2456 for (ip = col2_indices; *ip >= 0; ip++)
2457 ; /* skip to end */
2458 total_width += *++ip;
2459 total_width += *++ip;
2460
2461 XtSetArg(args[0], XtNwidth, total_width);
2462 XtSetValues(sv_name->w, args, ONE);
2463 XtSetArg(args[0], XtNwidth, total_width);
2464 XtSetValues(sv_dlevel->w, args, ONE);
2465
2466 return form;
2467}
2468

Callers 1

create_fancy_statusFunction · 0.85

Calls 2

create_widgetFunction · 0.85
init_columnFunction · 0.85

Tested by

no test coverage detected