/**
* Draw text box widget
*
- * @v widgets Text widget set
* @v widget Text widget
*/
-static void draw_editbox ( struct widgets *widgets, struct widget *widget ) {
+static void draw_editbox ( struct widget *widget ) {
struct edit_box *box = container_of ( widget, struct edit_box, widget );
const char *content = *(box->string.buf);
size_t width = widget->width;
/* Print box content and move cursor */
color_set ( CPAIR_EDIT, NULL );
- mvwprintw ( widgets->win, widget->row, widget->col, "%s", buf );
- wmove ( widgets->win, widget->row, ( widget->col + cursor_offset ) );
+ mvprintw ( widget->row, widget->col, "%s", buf );
+ move ( widget->row, ( widget->col + cursor_offset ) );
color_set ( CPAIR_NORMAL, NULL );
}
/**
* Edit text box widget
*
- * @v widgets Text widget set
* @v widget Text widget
* @v key Key pressed by user
* @ret key Key returned to application, or zero
*/
-static int edit_editbox ( struct widgets *widgets __unused,
- struct widget *widget, int key ) {
+static int edit_editbox ( struct widget *widget, int key ) {
struct edit_box *box = container_of ( widget, struct edit_box, widget );
return edit_string ( &box->string, key );
/**
* Draw text label widget
*
- * @v widgets Text widget set
* @v widget Text widget
*/
-static void draw_label ( struct widgets *widgets, struct widget *widget ) {
+static void draw_label ( struct widget *widget ) {
struct label *label = container_of ( widget, struct label, widget );
unsigned int width = widget->width;
unsigned int col = widget->col;
/* Print label content */
attron ( A_BOLD );
- mvwprintw ( widgets->win, widget->row, col, "%s", text );
+ mvprintw ( widget->row, col, "%s", text );
attroff ( A_BOLD );
}
/**
* Edit text label widget
*
- * @v widgets Text widget set
* @v widget Text widget
* @v key Key pressed by user
* @ret key Key returned to application, or zero
*/
-static int edit_label ( struct widgets *widgets __unused,
- struct widget *widget __unused, int key ) {
+static int edit_label ( struct widget *widget __unused, int key ) {
/* Cannot be edited */
return key;
/* Construct user interface */
memset ( &widgets, 0, sizeof ( widgets ) );
- init_widgets ( &widgets.widgets, NULL );
+ init_widgets ( &widgets.widgets );
init_label ( &widgets.username_label, USERNAME_LABEL_ROW, WIDGET_COL,
WIDGET_WIDTH, "Username" );
init_label ( &widgets.password_label, PASSWORD_LABEL_ROW, WIDGET_COL,
static int edit_setting ( struct settings_ui *ui, int key ) {
assert ( ui->row.setting.name != NULL );
ui->row.editing = 1;
- return edit_widget ( &ui->widgets, &ui->row.editbox.widget, key );
+ return edit_widget ( &ui->row.editbox.widget, key );
}
/**
/* Print initial screen content */
color_set ( CPAIR_NORMAL, NULL );
memset ( &ui, 0, sizeof ( ui ) );
- init_widgets ( &ui.widgets, NULL );
+ init_widgets ( &ui.widgets );
select_settings ( &ui, settings );
while ( 1 ) {
assert ( ui.row.setting.name != NULL );
/* Redraw edit box */
- draw_widget ( &ui.widgets, &ui.row.editbox.widget );
+ draw_widget ( &ui.row.editbox.widget );
/* Process keypress */
key = edit_setting ( &ui, getkey ( 0 ) );
/* Draw all widgets */
list_for_each_entry ( widget, &widgets->list, list )
- draw_widget ( widgets, widget );
+ draw_widget ( widget );
/* Count editable widgets */
count = 0;
return -ENOENT;
/* Redraw current widget */
- draw_widget ( widgets, widget );
+ draw_widget ( widget );
/* Process keypress */
- key = edit_widget ( widgets, widget, getkey ( 0 ) );
+ key = edit_widget ( widget, getkey ( 0 ) );
switch ( key ) {
case KEY_UP:
if ( current > 0 )
struct widgets {
/** List of widgets (in tab order) */
struct list_head list;
- /** Containing window */
- WINDOW *win;
};
/** A text widget */
/**
* Draw widget
*
- * @v widgets Text widget set
* @v widget Text widget
*/
- void ( * draw ) ( struct widgets *widgets, struct widget *widget );
+ void ( * draw ) ( struct widget *widget );
/**
* Edit widget
*
- * @v widgets Text widget set
* @v widget Text widget
* @v key Key pressed by user
* @ret key Key returned to application, or zero
* method to ensure that any changes to an editable widget are
* displayed to the user.
*/
- int ( * edit ) ( struct widgets *widgets, struct widget *widget,
- int key );
+ int ( * edit ) ( struct widget *widget, int key );
};
/**
* Initialise text widget set
*
* @v widgets Text widget set
- * @v win Containing window
*/
static inline __attribute__ (( always_inline )) void
-init_widgets ( struct widgets *widgets, WINDOW *win ) {
+init_widgets ( struct widgets *widgets ) {
INIT_LIST_HEAD ( &widgets->list );
- widgets->win = ( win ? win : stdscr );
}
/**
/**
* Draw text widget
*
- * @v widgets Text widget set
* @v widget Text widget
*/
static inline __attribute__ (( always_inline )) void
-draw_widget ( struct widgets *widgets, struct widget *widget ) {
+draw_widget ( struct widget *widget ) {
- widget->op->draw ( widgets, widget );
+ widget->op->draw ( widget );
}
/**
* Edit text widget
*
- * @v widgets Text widget set
* @v widget Text widget
* @v key Key pressed by user
* @ret key Key returned to application, or zero
* user.
*/
static inline __attribute__ (( always_inline )) int
-edit_widget ( struct widgets *widgets, struct widget *widget, int key ) {
+edit_widget ( struct widget *widget, int key ) {
- return widget->op->edit ( widgets, widget, key );
+ return widget->op->edit ( widget, key );
}
extern int widget_ui ( struct widgets *widgets );