?? tnw-tut-5.html
字號:
</CODE></BLOCKQUOTE><P><H3>Callbacks</H3><P>The following callbacks can be specified while calling <I>tnRegisterCallBack</I> for a listbox.<UL><LI> CLICKED : Event occurs when user clicks in the listbox.</LI></UL><P><H3>Utility Functions</H3><P>The following utility functions have been provided for manipulating the listbox.<BLOCKQUOTE><CODE><HR><PRE>int tnGetSelectedListItems(TN_WIDGET *widget, char ***listitems,int *count)</PRE><HR></CODE></BLOCKQUOTE>Description : Allocates space and returns the selected items in the listbox(multiple items can be selected using the Cntrl key modifier). Count contains the number of selected items. The user is expected to free the Listitems after he has finished using them.<P><BLOCKQUOTE><CODE><HR><PRE>int tnGetAllListItems(TN_WIDGET *listbox, char ***items, int *count)</PRE><HR></CODE></BLOCKQUOTE>Description : Returns all the items in the Listbox. The user is again expected to free the list of items.<P><BLOCKQUOTE><CODE><HR><PRE>int tnGetSelectedListNum(TN_WIDGET *listbox)</PRE><HR></CODE></BLOCKQUOTE>Returns: The number of items selected in the Listbox, -1 if there is an error.<P><BLOCKQUOTE><CODE><HR><PRE>int tnGetSelectedListPos(TN_WIDGET *listbox,int **pos,int *count)</PRE><HR></CODE></BLOCKQUOTE>Description : Returns the indices of the selected list items and their count. The pos array is allocated in the function and hence the user must free it after he is finished.<P><BLOCKQUOTE><CODE><HR><PRE>int tnGetListItemPos(TN_WIDGET *listbox, char *item)</PRE><HR></CODE></BLOCKQUOTE>Description : Given an item, it returns its index in the Listbox.<P>Returns : -1 if the item was not found in the Listbox, or some error occured.<P><BLOCKQUOTE><CODE><HR><PRE>int tnAddItemToListBox(TN_WIDGET *listbox, char *item)</PRE><HR></CODE></BLOCKQUOTE>Description : Adds the item to the end of the list of items currently in the Listbox.<P><BLOCKQUOTE><CODE><HR><PRE>int tnAddItemToListBoxAt(TN_WIDGET *listbox, char *item, int pos)</PRE><HR></CODE></BLOCKQUOTE>Description : Adds the item to the list of items currently in the Listbox at the position specified by pos. If pos is greater than the number of items currently in the listbox then the item is added to the end of the list of items.<P><BLOCKQUOTE><CODE><HR><PRE>int tnDeleteItemFromListBox(TN_WIDGET *listbox, char *item)</PRE><HR></CODE></BLOCKQUOTE>Description : Deletes the item from the list of items currently displayed in the listbox.<P>Returns: -1 if the item was not found in the Listbox.<P><BLOCKQUOTE><CODE><HR><PRE>int tnDeleteItemFromListBoxAt(TN_WIDGET *listbox, int pos)</PRE><HR></CODE></BLOCKQUOTE>Description : Deletes the item from the Listbox whose index is specified by pos. <P>Returns: -1 if pos is greater than the number of items in the listbox.<P><BLOCKQUOTE><CODE><HR><PRE>int tnDeleteSelectedItems(TN_WIDGET *listbox)</PRE><HR></CODE></BLOCKQUOTE>Description : Deletes all the items in the listbox which have been selected by the user.<P><BLOCKQUOTE><CODE><HR><PRE>int tnDeleteAllItemsFromListBox(TN_WIDGET *listbox)</PRE><HR></CODE></BLOCKQUOTE>Description : Deletes all the items from the Listbox.<P><BLOCKQUOTE><CODE><HR><PRE>int tnSetSelectedListItem(TN_WIDGET *listbox,char *item, TN_BOOL selected)</PRE><HR></CODE></BLOCKQUOTE>Description : Sets the status of the item in the listbox as specified by the selected parameter (TN_TRUE = selected, TN_FALSE = unselected).<P>Returns : -1 if the item is not found in the Listbox.<P><BLOCKQUOTE><CODE><HR><PRE>int tnSetSelectedListItemAt(TN_WIDGET *listbox, int pos, TN_BOOL selected)</PRE><HR></CODE></BLOCKQUOTE>Description : Sets the status to selected, of the item whose index is specified by pos. <P>Returns : -1 if the index is specified is greater than the number of items in the listbox.<P><BLOCKQUOTE><CODE><HR><PRE>int tnListItemsLineUp(TN_WIDGET *widget, int number)</PRE><HR></CODE></BLOCKQUOTE>Description : Scrolls the list of items displayed in the listbox up by the number of lines specified. Work only if the TN_RESIZE property of the listbox is set to TN_FALSE. <P><BLOCKQUOTE><CODE><HR><PRE>int tnListItemsLineDown(TN_WIDGET *widget, int number)</PRE><HR></CODE></BLOCKQUOTE>Description : Scrolls the list of items displayed in the listbox up by the number of lines specified. Works only if the TN_RESIZE property of the listbox is set to TN_FALSE. <P><BLOCKQUOTE><CODE><HR><PRE>int tnGetListTop(TN_WIDGET *listbox)</PRE><HR></CODE></BLOCKQUOTE>Description : Gets the index of the item displayed at the top of the Listbox. Works only if the TN_RESIZE property of the listbox is set to TN_FALSE. The above three functions can be used in conjunction with the scrollbar to scroll the items displayed in the Listbox.<P><BLOCKQUOTE><CODE><HR><PRE>int tnGetListBoxResize(TN_WIDGET *listbox, TN_BOOL *resize)</PRE><HR></CODE></BLOCKQUOTE>Description : Returns the currently set resize property of the listbox<P><BLOCKQUOTE><CODE><HR><PRE>int tnSetListBoxResize(TN_WIDGET *listbox, TN_BOOL resize)</PRE><HR></CODE></BLOCKQUOTE>Description : Sets the resize property of the listbox as sepcified.<P><H2><A NAME="TN_PICTURE"></A> <A NAME="ss5.11">5.11 TN_PICTURE</A></H2><P><H3>Introduction</H3><P>This is the picture widget and allows the user to display images(BMP, JPEG, GIF etc) in a picture container. <P><H3>Specifications</H3><P>The following optional properties can be specified for a picture while calling <I>tnCreateWidget</I><UL><LI> TN_FILENAME : The filename of the image to be displayed in the container. The full path of the filename must be specified.</LI><LI> TN_STRETCH : This is a Boolean value. If True then the container will be resized to the size of the image to be displayed. If this value is false the image will be resized to the size of the container.By default this property is set to TN_FALSE. </LI></UL>Examples:<P>A picture specification with the image file "/root/Images/liz.jpg" where the container is resized to the size of the image.<P><BLOCKQUOTE><CODE><HR><PRE>mypicture=tnCreateWidget(TN_PICTURE,window0,50,50,TN_FILENAME,"/root/Images/liz.jpg",TN_STRETCH,TN_TRUE,TN_END);</PRE><HR></CODE></BLOCKQUOTE><P><H3>Callbacks</H3><P>The following callbacks can be specified while calling <I>tnRegisterCallBack</I> for a Picture.<UL><LI> CLICKED : Event occurs when user clicks on the Picture container.</LI></UL><P><H3>Utility Functions</H3><P><P>The following utility functions have been provided for the Picture widget to access and change its properties. <BLOCKQUOTE><CODE> <HR><PRE> int tnGetPictureProps(TN_WIDGET *picture, TN_BOOL *stretch, char **filename) </PRE><HR> </CODE></BLOCKQUOTE>Description: This function returns the currently set properties of the picture i.e. Stretch and the filename of the currently displayed image in the picture. The user is expected to free the filename string which this function allocates. <P>Returns: 1 on success, -1 on failure.<P><BLOCKQUOTE><CODE> <HR><PRE> int tnSetPicture(TN_WIDGET *picture, char *filename) </PRE><HR></CODE></BLOCKQUOTE>Description: This function loads the image specified by filename into the picture widget. <P>Returns: 1 if succesful, -1 in case of error. <P><BLOCKQUOTE><CODE> <HR><PRE> int tnSetPictureStretch(TN_WIDGET *picture,GR_BOOL stretch) </PRE><HR> </CODE></BLOCKQUOTE>Description: This function sets the Stretch property of the picture widget. <P><BLOCKQUOTE><CODE> <HR><PRE> int tnPictureDup(TN_WIDGET *destpic,TN_WIDGET *srcpic) </PRE><HR> </CODE></BLOCKQUOTE>Description: This function duplicates the image displayed in the srcpic widget into the destpic widget. This is especially useful in order to save memory. By using the Duplication of the image it is not loaded by the server again. <P><BLOCKQUOTE><CODE> <HR><PRE> int tnGetPictureImageProps(TN_WIDGET *picture, TN_IMAGE_INFO *iinfo) </PRE><HR> </CODE></BLOCKQUOTE>Description: Fills the iinfo structure with the following properties relevant to the image displayed in the picture container. <UL><LI> Height of the image.</LI><LI> Width of the image.</LI><LI> Bits per pixel.</LI><LI> Bytes per pixel.</LI></UL><P><H2><A NAME="TN_MENUBAR"></A> <A NAME="ss5.12">5.12 TN_MENUBAR</A></H2><P><H3>Introduction</H3><P>This is the menu bar widget. It is to be placed in a window widget. <H3>Specification</H3><P>A call to <I>tnCreateWidget</I> will create a horizontal menu bar, which is aligned to the window top and resized to the window width, by default. The x & y position can optionally be specified.<P>Examples:The following call will create a default menu bar (aligned to the window top) <BLOCKQUOTE><CODE><HR><PRE>menu_bar = tnCreateWidget(TN_MENUBAR,window,0,0,TN_END);</PRE><HR></CODE></BLOCKQUOTE><H2><A NAME="TN_POPUPMENU"></A> <A NAME="ss5.13">5.13 TN_POPUPMENU</A></H2><P><H3>Introduction</H3><P>This is the popup menu widget. It allows for creation of popup menus. It is to be placed inside a menubar widget.A popup menu widget must be defined for providing pull down menu functionality. <H3>Specification</H3><P>The following properties can be set via the <I>tnCreateWidget</I> call<UL><LI>TN_CAPTION : The label for the popup menu.</LI><LI>TN_EXCLUSIVE : This atrribute if set makes the subsequently added checkable menu items behave in a mutually exclusive manner.</LI></UL>Examples:The following call will create a default popup menu with the label "File". (The TN_AUTO keyword indicates that positioning will be automatically handled).<BLOCKQUOTE><CODE><HR><PRE>popup_menu = tnCreateWidget(TN_POPUPMENU,menu_bar,TN_AUTO,TN_AUTO,TN_CAPTION,"File",TN_END);</PRE><HR></CODE></BLOCKQUOTE><H2><A NAME="TN_CASCADEDMENU"></A> <A NAME="ss5.14">5.14 TN_CASCADEDMENU</A></H2><P><H3>Introduction</H3><P>This is the cascade menu widget. It is to be placed inside a popup menu widget. It provides cascade (horizontal menus) functionality. A cascade menu will be displayed as a label with a rightward pointing arrow.<H3>Specification</H3><P>The following properties can be set via the <I>tnCreateWidget</I> call<UL><LI>TN_CAPTION : The label for the cascade menu.</LI><LI>TN_EXCLUSIVE : This atrribute if set makes the subsequently added checkable menu items behave in a mutually exclusive manner.</LI></UL>Examples:The following call will create a default cascade menu atached to a popup menu, with the label "Tools". (The TN_AUTO keyword indicates that positioning will be automatically handled).<BLOCKQUOTE><CODE><HR><PRE>cascade_menu = tnCreateWidget(TN_CASCADEMENU,popup_menu,TN_AUTO,TN_AUTO,TN_CAPTION,"Tools",TN_END);</PRE><HR></CODE></BLOCKQUOTE><H2><A NAME="TN_MENUITEM"></A> <A NAME="ss5.15">5.15 TN_MENUITEM</A></H2><P><H3>Introduction</H3><P>This is the menu item widget. It can be placed inside any of the following<UL><LI>Menu Bar</LI><LI>PopUp Menu</LI><LI>Cascade Menu</LI></UL>It is the basic menu item which when clicked, a programmer defined action can be taken.<H3>Specification</H3><P>The following properties may be set via the <I>tnCreateWidget</I> call<UL><LI>TN_CAPTION : The label for the menu item.</LI><LI>TN_CHECKABLE : This attribute, if set, causes the menu item to toggle state when clicked. A dot appears against a selected menu item. (This can be used in conjunction with the TN_EXCLUSIVE flag for the popup & cascade menus to provide a mutually exclusive group of menu items).</LI></UL>Examples:The following call will create a basic menu item with the label "Open", within a popup menu. (TN_AUTO for the x & y positions indicates automatic positioning).<BLOCKQUOTE><CODE><HR><PRE>mitem0 = tnCreateWidget(TN_MENUITEM,popup_menu,TN_AUTO,TN_AUTO,TN_CAPTION,"Open",TN_END);</PRE><HR></CODE></BLOCKQUOTE><P>The following call will create a checkable (toggle) menu item within a cascade menu.<BLOCKQUOTE><CODE><HR><PRE>mitem1 = tnCreateWidget(TN_MENUITEM,cascade_menu,TN_AUTO,TN_AUTO,TN_CAPTION,"Tool1",TN_CHECKABLE,TN_TRUE,TN_END);</PRE><HR></CODE></BLOCKQUOTE><H3>Callbacks</H3><P>The following callback(s) can be registered via the <I>tnRegisterCallBack</I> call<UL><LI>CLICKED : Specifies the action routine to be called when the menu item is clicked.</LI></UL><HR><A HREF="tnw-tut-6.html">Next</A><A HREF="tnw-tut-4.html">Previous</A><A HREF="tnw-tut.html#toc5">Contents</A></BODY></HTML>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -