.\" Copyright (c) 2003-2007 Hypertriton, Inc.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
.\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
.\" (INCLUDING BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd November 20, 2003
.Dt AG_UCOMBO 3
.Os
.ds vT Agar API Reference
.ds oS Agar 1.0
.Sh NAME
.Nm AG_UCombo
.Nd agar button + drop-down menu widget
.Sh SYNOPSIS
.Bd -literal
#include
#include
.Ed
.Sh DESCRIPTION
The
.Nm
widget is a composite widget that displays a
.Xr AG_Button 3 ,
which causes a
.Xr AG_Tlist 3
to be displayed when pressed.
The tlist disappears when an option is selected, and is directly accessed
as the
.Va list
member of the
.Nm
structure.
.Pp
.Sh INHERITANCE HIERARCHY
.Xr AG_Object 3 ->
.Xr AG_Widget 3 ->
.Nm .
.Sh INITIALIZATION
.nr nS 1
.Ft "AG_UCombo *"
.Fn AG_UComboNew "AG_Widget *parent" "Uint flags"
.Pp
.Ft "AG_UCombo *"
.Fn AG_UComboNewPolled "AG_Widget *parent" "Uint flags" "AG_EventFn fn" "const char *fmt" "..."
.Pp
.Ft "void"
.Fn AG_UComboSizeHint "AG_UCombo *com" "const char *text" "int nitems"
.Pp
.Ft "void"
.Fn AG_UComboSizeHintPixels "AG_UCombo *com" "int w" "int h"
.Pp
.nr nS 0
The
.Fn AG_UComboNew
function allocates, initializes, and attaches a new
.Nm
widget.
Accepted
.Fa flags
include:
.Bl -tag -width "AG_UCOMBO_SCROLLTOSEL "
.It AG_UCOMBO_SCROLLTOSEL
Scroll to initial selection if it is not visible.
.El
.Pp
The
.Fn AG_UComboNewPolled
constructor configures a polled
.Xr AG_Tlist 3
and assigns the polling function.
.Pp
The
.Fn AG_ComboSizeHint
function arranges for the
.Xr AG_Tlist 3
widget displayed on popup to request a size large enough to display the given
number of items.
The
.Fn AG_ComboSizeHintPixels
variant specifies the size of the list in pixels.
.Sh ITEM SELECTION
.nr nS 1
.Ft void
.Fn AG_ComboSelect "AG_Combo *combo" "AG_TlistItem *item"
.Pp
.Sh EVENTS
The
.Nm
widget generates the following events:
.Pp
.Bl -tag -compact -width 2n
.It Fn ucombo-selected "AG_TlistItem *item"
An item was selected.
.El
.Sh STRUCTURE DATA
For the
.Ft AG_UCombo
object:
.Pp
.Bl -tag -compact -width "AG_Button *button "
.It Ft AG_Tlist *list
Pointer to the
.Xr AG_Tlist 3
displayed by
.Nm
when expanded (read-only).
.It Ft AG_Button *button
Pointer to the underlying
.Xr AG_Button 3
widget (read-only).
.El
.Sh EXAMPLES
The following code fragment reacts to a
.Nm
selection event by displaying a text dialog:
.Bd -literal -offset indent
void
Selected(AG_Event *event)
{
AG_TlistItem *item = AG_PTR(1);
AG_TextMsg(AG_MSG_INFO, "Selected item: %s", item->text);
}
AG_UCombo *com;
com = AG_UComboNew(NULL, 0);
AG_TlistAdd(com->list, NULL, "Foo");
AG_TlistAdd(com->list, NULL, "Bar");
AG_SetEvent(com, "ucombo-selected", Selected, NULL);
.Ed
.Sh SEE ALSO
.Xr AG_Intro 3 ,
.Xr AG_Button 3 ,
.Xr AG_Combo 3 ,
.Xr AG_Tlist 3 ,
.Xr AG_Widget 3 ,
.Xr AG_Window 3
.Sh HISTORY
The
.Nm
widget first appeared in Agar 1.0.