PHP: Newt Functions - Manual

downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

newt_bell syslog

Last updated: Sat, 27 Jan 2007

view this page in

# C. Newt Functions

# Введение

This is a PHP language extension for RedHat Newt library, a terminal-based window and widget library for writing applications with user friendly interface. Once this extension is enabled in PHP it will provide the use of Newt widgets, such as windows, buttons, checkboxes, radiobuttons, labels, editboxes, scrolls, textareas, scales, etc. Use of this extension if very similar to the original Newt API of C programming language.

# Требования

This module uses the functions of the RedHat Newt library. You need libnewt version >= 0.51.0.

# Установка

Это расширение PECL не поставляется вместе с PHP. Дополнительная информация, такая как новый версии, скачивание, исходные файлы, информация о разработчике и CHANGELOG, могут быть найдены здесь: http://pecl.php.net/package/newt.

В PHP 4 исходные файлы этого расширения PECL могут быть найдены в директории `ext/` внутри исходных файлов PHP или по ссылке PECL выше. In order to use these functions you must compile CGI or CLI PHP with newt support by using the `--with-newt[=DIR]` configure option.

> Замечание: This extension is not available for Windows platform.

> You may need also `curses` and `slang` libraries, in order to compile this extension. To specify locations of these libraries, use the following configuration options: `--with-curses-dir=/path/to/libcurses` `--with-slang-dir=/path/to/libslang`

# Типы ресурсов

This extension uses two resource types: "newt component" and "newt grid". Resource type "newt component" is returned by functions, which create common newt widgets (for example: newt_button()) Resource type "newt grid" is a special link identifier for components, returned by newt grid factory functions (for example: newt_create_grid())

# Предопределенные константы

Перечисленные ниже константы определены данным расширением и могут быть доступны только в том случае, если PHP был собран с поддержкой этого расширения или же в том случае, если данное расширение подгружается во время выполнения.

## Newt form exit reasons

Таблица 1. Newt form exit reasons

constant | meaning
--- | ---
`NEWT_EXIT_HOTKEY` | hotkey defined by newt_form_add_hot_key() was pressed
`NEWT_EXIT_COMPONENT` | some component has caused form to exit
`NEWT_EXIT_FDREADY` | file descriptor specified in newt_form_watch_fd() is ready to be read or written to
`NEWT_EXIT_TIMER` | time specified in newt_form_set_timer() has elapsed

## Newt colorsets

Таблица 2. Newt colorsets

constant | meaning
--- | ---
`NEWT_COLORSET_ROOT` |
`NEWT_COLORSET_BORDER` |
`NEWT_COLORSET_WINDOW` |
`NEWT_COLORSET_SHADOW` |
`NEWT_COLORSET_TITLE` |
`NEWT_COLORSET_BUTTON` |
`NEWT_COLORSET_ACTBUTTON` |
`NEWT_COLORSET_CHECKBOX` |
`NEWT_COLORSET_ACTCHECKBOX` |
`NEWT_COLORSET_ENTRY` |
`NEWT_COLORSET_LABEL` |
`NEWT_COLORSET_LISTBOX` |
`NEWT_COLORSET_ACTLISTBOX` |
`NEWT_COLORSET_TEXTBOX` |
`NEWT_COLORSET_ACTTEXTBOX` |
`NEWT_COLORSET_HELPLINE` |
`NEWT_COLORSET_ROOTTEXT` |
`NEWT_COLORSET_ROOTTEXT` |
`NEWT_COLORSET_EMPTYSCALE` |
`NEWT_COLORSET_FULLSCALE` |
`NEWT_COLORSET_DISENTRY` |
`NEWT_COLORSET_COMPACTBUTTON` |
`NEWT_COLORSET_ACTSELLISTBOX` |
`NEWT_COLORSET_SELLISTBOX` |

## Newt argument flags

Таблица 3. Newt argument flags

constant | meaning
--- | ---
`NEWT_ARG_LAST` |
`NEWT_ARG_APPEND` |

## Newt Flags Sense

Таблица 4. Newt Flags Sense

constant | meaning
--- | ---
`NEWT_FLAGS_SET` |
`NEWT_FLAGS_RESET` |
`NEWT_FLAGS_TOGGLE` |

## Newt Components Flags

Таблица 5. Newt Components Flags

constant | meaning
--- | ---
`NEWT_FLAG_RETURNEXIT` | Exit form, when component is activated
`NEWT_FLAG_HIDDEN` | Component is hidden
`NEWT_FLAG_SCROLL` | Component is scrollable
`NEWT_FLAG_DISABLED` | Component is disabled
`NEWT_FLAG_BORDER` |
`NEWT_FLAG_WRAP` | Wrap text
`NEWT_FLAG_NOF12` | Don't exit form on pressing F12
`NEWT_FLAG_MULTIPLE` |
`NEWT_FLAG_SELECTED` | Component is selected
`NEWT_FLAG_CHECKBOX` | Component is checkbox
`NEWT_FLAG_PASSWORD` | Entry component is password entry
`NEWT_FLAG_SHOWCURSOR` | Show cursor

## File Descriptor Flags

Таблица 6. File Descriptor Flags

constant | meaning
--- | ---
`NEWT_FD_READ` |
`NEWT_FD_WRITE` |
`NEWT_FD_EXCEPT` |

## Checkbox Tree Flags

Таблица 7. Checkbox Tree Flags

constant | meaning
--- | ---
`NEWT_CHECKBOXTREE_UNSELECTABLE` |
`NEWT_CHECKBOXTREE_HIDE_BOX` |
`NEWT_CHECKBOXTREE_COLLAPSED` |
`NEWT_CHECKBOXTREE_EXPANDED` |
`NEWT_CHECKBOXTREE_UNSELECTED` |
`NEWT_CHECKBOXTREE_SELECTED` |

## Entry Flags

Таблица 8. Entry Flags

constant | meaning
--- | ---
`NEWT_ENTRY_SCROLL` |
`NEWT_ENTRY_HIDDEN` |
`NEWT_ENTRY_RETURNEXIT` |
`NEWT_ENTRY_DISABLED` |

## Listbox Flags

Таблица 9. Listbox Flags

constant | meaning
--- | ---
`NEWT_LISTBOX_RETURNEXIT` |

## Textbox Flags

Таблица 10. Textbox Flags

constant | meaning
--- | ---
`NEWT_TEXTBOX_WRAP` | Wrap text in the textbox
`NEWT_TEXTBOX_SCROLL` | Scroll text in the textbox

## Form Flags

Таблица 11. Form Flags

constant | meaning
--- | ---
`NEWT_FORM_NOF12` | Don't exit form on F12 press

## Newt Keys

Таблица 12. Newt Keys

constant | meaning
--- | ---
`NEWT_KEY_TAB` |
`NEWT_KEY_ENTER` |
`NEWT_KEY_SUSPEND` |
`NEWT_KEY_ESCAPE` |
`NEWT_KEY_RETURN` |
`NEWT_KEY_EXTRA_BASE` |
`NEWT_KEY_UP` |
`NEWT_KEY_DOWN` |
`NEWT_KEY_LEFT` |
`NEWT_KEY_RIGHT` |
`NEWT_KEY_BKSPC` |
`NEWT_KEY_DELETE` |
`NEWT_KEY_HOME` |
`NEWT_KEY_END` |
`NEWT_KEY_UNTAB` |
`NEWT_KEY_PGUP` |
`NEWT_KEY_PGDN` |
`NEWT_KEY_INSERT` |
`NEWT_KEY_F1` |
`NEWT_KEY_F2` |
`NEWT_KEY_F3` |
`NEWT_KEY_F4` |
`NEWT_KEY_F5` |
`NEWT_KEY_F6` |
`NEWT_KEY_F7` |
`NEWT_KEY_F8` |
`NEWT_KEY_F9` |
`NEWT_KEY_F10` |
`NEWT_KEY_F11` |
`NEWT_KEY_F12` |
`NEWT_KEY_RESIZE` |

## Newt Anchors

Таблица 13. Newt Anchors

constant | meaning
--- | ---
`NEWT_ANCHOR_LEFT` |
`NEWT_ANCHOR_RIGHT` |
`NEWT_ANCHOR_TOP` |
`NEWT_ANCHOR_BOTTOM` |

## Grid Flags

Таблица 14. Grid Flags

constant | meaning
--- | ---
`NEWT_GRID_FLAG_GROWX` |
`NEWT_GRID_FLAG_GROWY` |
`NEWT_GRID_EMPTY` |
`NEWT_GRID_COMPONENT` |
`NEWT_GRID_SUBGRID` |

# Примеры

This example is a PHP port of RedHat 'setup' utility dialog, executed in text mode.

Пример 1. Newt Usage Example

`<?php
newt_init ();
newt_cls ();
newt_draw_root_text (0, 0, "Test Mode Setup Utility 1.12");
newt_push_help_line (null);
newt_draw_root_text (-30, 0, "(c) 1999-2002 RedHat, Inc");
newt_get_screen_size (&$rows, &$cols);
newt_open_window ($rows/2-17, $cols/2-10, 34, 17, "Choose a Tool");
$form = newt_form ();
$list = newt_listbox (3, 2, 10);
foreach (array (
"Authentication configuration",
"Firewall configuration",
"Mouse configuration",
"Network configuration",
"Printer configuration",
"System services") as $l_item)
{
newt_listbox_add_entry ($list, $l_item, $l_item);
}
$b1 = newt_button (5, 12, "Run Tool");
$b2 = newt_button (21, 12, "Quit");
newt_form_add_component ($form, $list);
newt_form_add_components ($form, array($b1, $b2));
newt_refresh ();
newt_run_form ($form);
newt_pop_window ();
newt_pop_help_line ();
newt_finished ();
newt_form_destroy ($form);
?>`

add a note User Contributed Notes
Newt Functions
There are no user contributed notes for this page.
newt_bell syslog

Last updated: Sat, 27 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 11:33:19 2007 PST