Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_wrap.h
Go to the documentation of this file.
1/*
2 * Nilorea Library
3 * Copyright (C) 2005-2026 Castagnier Mickael
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14 * implied. See the License for the specific language governing
15 * permissions and limitations under the License.
16 *
17 * SPDX-License-Identifier: Apache-2.0
18 */
19
58
59#ifndef N_WRAP_H
60#define N_WRAP_H
61
62#ifdef __cplusplus
63extern "C" {
64#endif
65
66#include <stddef.h>
67
70#define N_WRAP_SPACE (1u << 0)
72#define N_WRAP_NEWLINE (1u << 1)
73
76typedef struct n_wrap_item {
78 double width;
80 unsigned int flags;
82
92typedef void (*n_wrap_emit)(size_t first, size_t last, size_t line, double width, void* user);
93
94size_t n_wrap_layout(const n_wrap_item* items, size_t count, double max_width, n_wrap_emit emit, void* user);
95
102typedef void (*n_wrap_rect_emit)(size_t line, double x0, double x1, void* user);
103
104size_t n_wrap_index_at(const n_wrap_item* items, size_t count, double max_width, double line_height, double x, double y);
105
106size_t n_wrap_span_rects(const n_wrap_item* items, size_t count, double max_width, size_t lo, size_t hi, n_wrap_rect_emit emit, void* user);
107
108#ifdef __cplusplus
109}
110#endif
111
112#endif /* N_WRAP_H */
static N_GUI_MOUSE_EVENT last
the last event the widget was told of, and how many
void line(BITMAP *bmp, int x1, int y1, int x2, int y2, int color)
draw a line
size_t n_wrap_layout(const n_wrap_item *items, size_t count, double max_width, n_wrap_emit emit, void *user)
Break items into lines no wider than max_width.
Definition n_wrap.c:50
void(* n_wrap_rect_emit)(size_t line, double x0, double x1, void *user)
Called once per line that a span covers, by n_wrap_span_rects().
Definition n_wrap.h:102
double width
advance width in the caller's units (pixels, columns, ...)
Definition n_wrap.h:78
unsigned int flags
N_WRAP_SPACE / N_WRAP_NEWLINE, or 0
Definition n_wrap.h:80
size_t n_wrap_span_rects(const n_wrap_item *items, size_t count, double max_width, size_t lo, size_t hi, n_wrap_rect_emit emit, void *user)
The rectangles that cover the items [lo, hi): one per line the range touches, in order,...
Definition n_wrap.c:249
void(* n_wrap_emit)(size_t first, size_t last, size_t line, double width, void *user)
Called once per laid-out line, in order.
Definition n_wrap.h:92
size_t n_wrap_index_at(const n_wrap_item *items, size_t count, double max_width, double line_height, double x, double y)
The item boundary nearest a point: the inverse of n_wrap_layout(), for turning a click or a drag into...
Definition n_wrap.c:176
One pre-measured layout item: a glyph, an emoji cell, an inline image, or a whole word,...
Definition n_wrap.h:76