ntw.h File Reference

General utility functions. More...

#include "protocol.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include <assert.h>
#include "lookup.h"
#include "network.h"
#include "data_send.h"
#include "variables.h"
#include "container.h"
#include "window.h"
#include "dialog.h"
#include "grid.h"
#include "button.h"
#include "check_button.h"
#include "label.h"
#include "image.h"
#include "entry.h"
#include "menu_bar.h"
#include "menu.h"
#include "menu_item.h"
#include "tool_bar.h"
#include "tool_item.h"
#include "tool_button.h"
#include "tool_menu_button.h"
#include "radio_group.h"
#include "radio_button.h"
#include "notebook.h"
#include "notebook_page.h"
#include "scrollpane.h"
#include "list_model.h"
#include "tree_model.h"
#include "table.h"
#include "table_column.h"
#include "frame.h"
#include "split_pane.h"
#include "combo_box.h"
#include "combo_box_entry.h"
#include "image_buffer.h"
#include "cached_image.h"
#include "status_bar.h"
#include "spin_button.h"
#include "slider.h"
#include "progress_bar.h"
#include "text_editor.h"
#include "persist.h"
#include "timer.h"

Go to the source code of this file.

Data Structures

struct  ntw_event_data
struct  ntw_data_stack

Defines

#define FALSE   0
#define TRUE   1
#define NTW_WIDGET_SET_FLAG(x, y)   x->flags = x->flags | htonl(y)
#define NTW_WIDGET_CLEAR_FLAG(x, y)   x->flags = x->flags & htonl(0xffffffff ^ y)
#define NTW_WIDGET_TOGGLE_FLAG(x, y)   x->flags = x->flags ^ htonl(y)
#define NTW_WIDGET_GET_FLAG(x, y)   ((x->flags & htonl(y)) > 0)
#define NTW_INIT_CALLBACK(x)   ntw_init_callback(#x, &x);

Typedefs

typedef widget_header ntwWidget
typedef int(* func_ptr )(void *, void *)

Functions

void ntw_print_error (char *function_name, char *error)
 Prints an error message.
widget_data * ntw_initialize_widget (int32 type, int32 length)
 Sets data on a newly created widget to sane values.
ntw_event_table * ntw_initialize_event_handler (int32 event_count)
 Create event table.
int ntw_widget_remove_default_event_handler (ntwWidget *widget)
 Removes a widget's default event handler.
int ntw_widget_show (ntwWidget *widget)
 Makes invisible widgets visible.
int ntw_widget_hide (ntwWidget *widget)
 Makes visible widgets invisible.
int ntw_widget_destroy (ntwWidget *widget)
 Completely destroy a widget and all its children.
int ntw_init (int argc, char **argv)
 Initialize network connection.
void ntw_main ()
 Main event loop.
void ntw_main_quit ()
 Exit event loop.
int ntw_add_callback (ntwWidget *widget, int32 event, func_ptr callback, ntwWidget *user_data, int32 synchronized)
 Add a callback to a widget.


Detailed Description

General utility functions.


Function Documentation

int ntw_add_callback ntwWidget *  widget,
int32  event,
func_ptr  callback,
ntwWidget *  user_data,
int32  synchronized
 

Add a callback to a widget.

This assigns a particular function as a callback to a particular widget event. This function will be run after the default event handler, if any.

Parameters:
widget The widget to assign a callback function to
event The event to handle
callback Address of the callback function
user_data User-supplied data in pointer form. This allows passing of a widget as data, or another variable cast as a pointer
synchronized Whether or not to stop client execution until the server responds. In almost all cases this should be FALSE
Returns:
-1 on failure.

int ntw_init int  argc,
char **  argv
 

Initialize network connection.

Initializes the ntw library for use. Most importantly, this initializes the server's socket to listen for clients.

Parameters:
argc Number of command line arguments
argv NULL terminated array of command line argument strings
Returns:
-1 on failure

struct ntw_event_table* ntw_initialize_event_handler int32  event_count  ) 
 

Create event table.

For NTW internal use only
Allocates memory for a widget's event handler. This is an array of function pointers. A widget has GENERAL_EVENT_COUNT function pointers plus any widget specific pointers. So each event table array takes up about 80 bytes. (20 32-bit ints)

Parameters:
event_count Number of widget specific events
Returns:
Newly allocated event table

struct widget_data* ntw_initialize_widget int32  type,
int32  length
 

Sets data on a newly created widget to sane values.

For NTW internal use only
Allocates memory for widget data and sets some fields.

Parameters:
type Widget type
length Byte length of widget data
Returns:
Widget

void ntw_main  ) 
 

Main event loop.

This is the main event handling loop that must be called to handle messages from the client. This should be called after all callbacks are initialized and after ntw_init().

void ntw_main_quit  ) 
 

Exit event loop.

Programatic means to force the main event loop to exit and halt execution.

void ntw_print_error char *  function_name,
char *  error
 

Prints an error message.

Standard error printing facility that keeps things looking nice.

Parameters:
function_name Name of the function in which the error occured
error Error string

int ntw_widget_destroy ntwWidget *  widget  ) 
 

Completely destroy a widget and all its children.

This will recursively deconstruct widgets, reclaim all associated memory, and send appropriate messages to the client program to do the same. This is permanent -- to hide a widget, use ntw_widget_hide().

Parameters:
widget Widget to destroy
Returns:
-1 on failure

int ntw_widget_hide ntwWidget *  widget  ) 
 

Makes visible widgets invisible.

Parameters:
widget Widget to hide
Returns:
-1 on failure

int ntw_widget_remove_default_event_handler ntwWidget *  widget  ) 
 

Removes a widget's default event handler.

Some widgets, like the text entry widget, have a default event handler that handles changes automatically. A developer might want to do this manually, however, (so he could convert all text to uppercase before setting the widget state, for example) so this function exists.

Parameters:
widget Widget to remove the default event handler from
Returns:
-1 on failure

int ntw_widget_show ntwWidget *  widget  ) 
 

Makes invisible widgets visible.

Parameters:
widget Widget to show
Returns:
-1 on failure


Generated on Wed Jun 28 17:00:07 2006 for NTW Server C Library by  doxygen 1.4.6