Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
ex_gui_combobox_wheel.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "nilorea/n_common.h"
#include "nilorea/n_gui.h"
#include "nilorea/n_log.h"
Include dependency graph for ex_gui_combobox_wheel.c:

Go to the source code of this file.

Macros

#define ALLEGRO_UNSTABLE   1
#define CB_H   30
 Where the combobox is and how tall one row of it is.
#define CB_W   200
 Where the combobox is and how tall one row of it is.
#define CB_X   10
 Where the combobox is and how tall one row of it is.
#define CB_Y   10
 Where the combobox is and how tall one row of it is.
#define ITEMS   9
 How many items: more than the six it shows.

Functions

static void click_at (N_GUI_CTX *gui, int x, int y)
 Move to (x, y) and click there.
static void expect_true (const char *label, int cond)
 Assert a condition, logging which check failed.
int main (void)
static ALLEGRO_EVENT mouse_event (int type, int x, int y, int dz)
 Build a left-button mouse event at (x, y).
static int row_y (int row)
 The screen y of the middle of one row of the open list.
static int wheel_then_click (N_GUI_CTX *gui, int cb, int row, int notches)
 Open the list, turn the wheel over one row, then click that row.

Variables

static int failures = 0
 Count of failed assertions.

Macro Definition Documentation

◆ ALLEGRO_UNSTABLE

#define ALLEGRO_UNSTABLE   1

Definition at line 41 of file ex_gui_combobox_wheel.c.

◆ CB_H

#define CB_H   30

Where the combobox is and how tall one row of it is.

Examples
ex_gui_combobox_wheel.c.

Definition at line 61 of file ex_gui_combobox_wheel.c.

Referenced by main(), row_y(), and wheel_then_click().

◆ CB_W

#define CB_W   200

Where the combobox is and how tall one row of it is.

Examples
ex_gui_combobox_wheel.c.

Definition at line 59 of file ex_gui_combobox_wheel.c.

Referenced by main(), and wheel_then_click().

◆ CB_X

#define CB_X   10

Where the combobox is and how tall one row of it is.

Examples
ex_gui_combobox_wheel.c.

Definition at line 55 of file ex_gui_combobox_wheel.c.

Referenced by main(), and wheel_then_click().

◆ CB_Y

#define CB_Y   10

Where the combobox is and how tall one row of it is.

Examples
ex_gui_combobox_wheel.c.

Definition at line 57 of file ex_gui_combobox_wheel.c.

Referenced by main(), row_y(), and wheel_then_click().

◆ ITEMS

#define ITEMS   9

How many items: more than the six it shows.

Examples
ex_gui_combobox_wheel.c.

Definition at line 64 of file ex_gui_combobox_wheel.c.

Referenced by main().

Function Documentation

◆ click_at()

void click_at ( N_GUI_CTX * gui,
int x,
int y )
static

Move to (x, y) and click there.

Parameters
guiGUI context.
xCursor x.
yCursor y.
Examples
ex_gui_combobox_wheel.c, ex_gui_double_click.c, ex_gui_splitpane.c, and ex_gui_zorder.c.

Definition at line 105 of file ex_gui_combobox_wheel.c.

References gui, mouse_event(), and n_gui_process_event().

Referenced by main(), main(), and wheel_then_click().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ expect_true()

void expect_true ( const char * label,
int cond )
static

Assert a condition, logging which check failed.

Parameters
labelWhat is being checked.
condNon-zero to pass.

Definition at line 71 of file ex_gui_combobox_wheel.c.

References failures, LOG_ERR, LOG_INFO, and n_log.

◆ main()

◆ mouse_event()

ALLEGRO_EVENT mouse_event ( int type,
int x,
int y,
int dz )
static

Build a left-button mouse event at (x, y).

Parameters
typeThe ALLEGRO_EVENT_MOUSE_* type.
xCursor x.
yCursor y.
dzWheel notches, positive up.
Returns
The event.
Examples
ex_gui_combobox_wheel.c, ex_gui_datagrid_keys.c, ex_gui_double_click.c, ex_gui_frameless_drag.c, ex_gui_hover.c, ex_gui_reentrant.c, ex_gui_slider_default.c, ex_gui_slider_handle.c, and ex_gui_slider_step.c.

Definition at line 88 of file ex_gui_combobox_wheel.c.

References type().

Referenced by click_and_report(), click_at(), click_at(), drag_right(), main(), main(), move_to(), press_at(), and wheel_then_click().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ row_y()

int row_y ( int row)
static

The screen y of the middle of one row of the open list.

Parameters
rowRow, 0 the top one shown.
Returns
The y.
Examples
ex_gui_combobox_wheel.c.

Definition at line 116 of file ex_gui_combobox_wheel.c.

References CB_H, CB_Y, and row().

Referenced by _popup_row_at(), n_gui_tree_draw_overlay(), and wheel_then_click().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wheel_then_click()

int wheel_then_click ( N_GUI_CTX * gui,
int cb,
int row,
int notches )
static

Open the list, turn the wheel over one row, then click that row.

Parameters
guiGUI context.
cbThe combobox.
rowWhich row the pointer rests on.
notchesWheel notches, positive down the list.
Returns
The index the click selected.
Examples
ex_gui_combobox_wheel.c.

Definition at line 128 of file ex_gui_combobox_wheel.c.

References CB_H, CB_W, CB_X, CB_Y, click_at(), gui, mouse_event(), n_gui_combobox_get_selected(), n_gui_process_event(), row(), and row_y().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ failures

int failures = 0
static

Count of failed assertions.

Definition at line 52 of file ex_gui_combobox_wheel.c.