C# Class Mono.Terminal.Widget

Datei anzeigen Open project: mono/mono-curses Class Usage Examples

Public Properties

Property Type Description
Container Container
Fill Fill
h int
w int
x int
y int

Public Methods

Method Description
BaseMove ( int line, int col ) : void

Move relative to the top of the container

This moves the current cursor position to the specified line and column relative to the start of the container where this widget is located.

The difference between this method and Move is that this method goes to the beginning of the container, while Move goes to the first position that widgets should use.

For example, a Frame usually takes up a couple of characters for padding. This method would position the cursor at the beginning of the frame, while Move would position the cursor within the frame.

Clear ( ) : void

Clears the widget region withthe current color.

This clears the entire region used by this widget.

DoSizeChanged ( ) : void

Method to relayout on size changes.

This method can be overwritten by widgets that might be interested in adjusting their contents or children (if they are containers).

DrawFrame ( int col, int line, int width, int height ) : void

Utility function to draw frames

Draws a frame with the current color in the specified coordinates.

DrawFrame ( int col, int line, int width, int height, bool fill ) : void

Utility function to draw frames

Draws a frame with the current color in the specified coordinates.

DrawHotString ( string s, int hotcolor, int color ) : void

Utility function to draw strings that contain a hotkey

Draws a string with the given color. If a character "_" is found, then the next character is drawn using the hotcolor.

Log ( string s ) : void

Utility function to log messages

This is a utility function that you can use to log messages that will be stored in a file (as curses has taken over the screen and you can not really log information there).

The data is written to the file "log2" for now

Move ( int line, int col ) : void

Moves inside the first location inside the container

This moves the current cursor position to the specified line and column relative to the container client area where this widget is located.

The difference between this method and BaseMove is that this method goes to the beginning of the client area inside the container while BaseMove goes to the first position that container uses.

For example, a Frame usually takes up a couple of characters for padding. This method would position the cursor inside the client area, while BaseMove would position the cursor at the top of the frame.

PositionCursor ( ) : void

Moves inside the first location inside the container

A helper routine that positions the cursor at the logical beginning of the widget. The default implementation merely puts the cursor at the beginning, but derived classes should find a suitable spot for the cursor to be shown.

This method must be overwritten by most widgets since screen repaints can happen at any point and it is important to leave the cursor in a position that would make sense for the user (as not all terminals support hiding the cursor), and give the user an impression of where the cursor is. For a button, that would be the position where the hotkey is, for an entry the location of the editing cursor and so on.

ProcessColdKey ( int key ) : bool

This method can be overwritten by widgets that want to provide accelerator functionality (Alt-key for example), but without interefering with normal ProcessKey behavior.

After keys are sent to the widgets on the current Container, all the widgets are processed and the key is passed to the widgets to allow some of them to process the keystroke as a cold-key.

This functionality is used, for example, by default buttons to act on the enter key. Processing this as a hot-key would prevent non-default buttons from consuming the enter keypress when they have the focus.

ProcessHotKey ( int key ) : bool

This method can be overwritten by widgets that want to provide accelerator functionality (Alt-key for example).

Before keys are sent to the widgets on the current Container, all the widgets are processed and the key is passed to the widgets to allow some of them to process the keystroke as a hot-key.

For example, if you implement a button that has a hotkey ok "o", you would catch the combination Alt-o here. If the event is caught, you must return true to stop the keystroke from being dispatched to other widgets.

Typically to check if the keystroke is an Alt-key combination, you would use Curses.IsAlt(key) and then Char.ToUpper(key) to compare with your hotkey.

ProcessKey ( int key ) : bool

If the widget is focused, gives the widget a chance to process the keystroke.

Widgets can override this method if they are interested in processing the given keystroke. If they consume the keystroke, they must return true to stop the keystroke from being processed by other widgets or consumed by the widget engine. If they return false, the keystroke will be passed out to other widgets for processing.

ProcessMouse ( Curses ev ) : void

Gives widgets a chance to process the given mouse event.

Widgets can inspect the value of ev.ButtonState to determine if this is a message they are interested in (typically ev.ButtonState & Curses.Event.Button1Clicked).

Redraw ( ) : void

Redraws the current widget, must be overwritten.

This method should be overwritten by classes that derive from Widget. The default implementation of this method just fills out the region with the character 'x'.

Widgets are responsible for painting the entire region that they have been allocated.

Widget ( int x, int y, int w, int h ) : System

Public constructor for widgets

Constructs a widget that starts at positio (x,y) and has width w and height h. These parameters are used by the methods Clear and Redraw

Method Details

BaseMove() public method

Move relative to the top of the container

This moves the current cursor position to the specified line and column relative to the start of the container where this widget is located.

The difference between this method and Move is that this method goes to the beginning of the container, while Move goes to the first position that widgets should use.

For example, a Frame usually takes up a couple of characters for padding. This method would position the cursor at the beginning of the frame, while Move would position the cursor within the frame.

public BaseMove ( int line, int col ) : void
line int
col int
return void

Clear() public method

Clears the widget region withthe current color.

This clears the entire region used by this widget.

public Clear ( ) : void
return void

DoSizeChanged() public method

Method to relayout on size changes.

This method can be overwritten by widgets that might be interested in adjusting their contents or children (if they are containers).

public DoSizeChanged ( ) : void
return void

DrawFrame() public static method

Utility function to draw frames
Draws a frame with the current color in the specified coordinates.
public static DrawFrame ( int col, int line, int width, int height ) : void
col int
line int
width int
height int
return void

DrawFrame() public static method

Utility function to draw frames
Draws a frame with the current color in the specified coordinates.
public static DrawFrame ( int col, int line, int width, int height, bool fill ) : void
col int
line int
width int
height int
fill bool
return void

DrawHotString() public static method

Utility function to draw strings that contain a hotkey
Draws a string with the given color. If a character "_" is found, then the next character is drawn using the hotcolor.
public static DrawHotString ( string s, int hotcolor, int color ) : void
s string
hotcolor int
color int
return void

Log() public static method

Utility function to log messages

This is a utility function that you can use to log messages that will be stored in a file (as curses has taken over the screen and you can not really log information there).

The data is written to the file "log2" for now

public static Log ( string s ) : void
s string
return void

Move() public method

Moves inside the first location inside the container

This moves the current cursor position to the specified line and column relative to the container client area where this widget is located.

The difference between this method and BaseMove is that this method goes to the beginning of the client area inside the container while BaseMove goes to the first position that container uses.

For example, a Frame usually takes up a couple of characters for padding. This method would position the cursor inside the client area, while BaseMove would position the cursor at the top of the frame.

public Move ( int line, int col ) : void
line int
col int
return void

PositionCursor() public method

Moves inside the first location inside the container

A helper routine that positions the cursor at the logical beginning of the widget. The default implementation merely puts the cursor at the beginning, but derived classes should find a suitable spot for the cursor to be shown.

This method must be overwritten by most widgets since screen repaints can happen at any point and it is important to leave the cursor in a position that would make sense for the user (as not all terminals support hiding the cursor), and give the user an impression of where the cursor is. For a button, that would be the position where the hotkey is, for an entry the location of the editing cursor and so on.

public PositionCursor ( ) : void
return void

ProcessColdKey() public method

This method can be overwritten by widgets that want to provide accelerator functionality (Alt-key for example), but without interefering with normal ProcessKey behavior.

After keys are sent to the widgets on the current Container, all the widgets are processed and the key is passed to the widgets to allow some of them to process the keystroke as a cold-key.

This functionality is used, for example, by default buttons to act on the enter key. Processing this as a hot-key would prevent non-default buttons from consuming the enter keypress when they have the focus.

public ProcessColdKey ( int key ) : bool
key int
return bool

ProcessHotKey() public method

This method can be overwritten by widgets that want to provide accelerator functionality (Alt-key for example).

Before keys are sent to the widgets on the current Container, all the widgets are processed and the key is passed to the widgets to allow some of them to process the keystroke as a hot-key.

For example, if you implement a button that has a hotkey ok "o", you would catch the combination Alt-o here. If the event is caught, you must return true to stop the keystroke from being dispatched to other widgets.

Typically to check if the keystroke is an Alt-key combination, you would use Curses.IsAlt(key) and then Char.ToUpper(key) to compare with your hotkey.

public ProcessHotKey ( int key ) : bool
key int
return bool

ProcessKey() public method

If the widget is focused, gives the widget a chance to process the keystroke.

Widgets can override this method if they are interested in processing the given keystroke. If they consume the keystroke, they must return true to stop the keystroke from being processed by other widgets or consumed by the widget engine. If they return false, the keystroke will be passed out to other widgets for processing.

public ProcessKey ( int key ) : bool
key int
return bool

ProcessMouse() public method

Gives widgets a chance to process the given mouse event.
Widgets can inspect the value of ev.ButtonState to determine if this is a message they are interested in (typically ev.ButtonState & Curses.Event.Button1Clicked).
public ProcessMouse ( Curses ev ) : void
ev Curses
return void

Redraw() public method

Redraws the current widget, must be overwritten.

This method should be overwritten by classes that derive from Widget. The default implementation of this method just fills out the region with the character 'x'.

Widgets are responsible for painting the entire region that they have been allocated.

public Redraw ( ) : void
return void

Widget() public method

Public constructor for widgets

Constructs a widget that starts at positio (x,y) and has width w and height h. These parameters are used by the methods Clear and Redraw

public Widget ( int x, int y, int w, int h ) : System
x int
y int
w int
h int
return System

Property Details

Container public_oe property

Points to the container of this widget
public Container,Mono.Terminal Container
return Container

Fill public_oe property

public Fill Fill
return Fill

h public_oe property

The height of this widget, it is the area that receives mouse events and that must be repainted.
public int h
return int

w public_oe property

The width of this widget, it is the area that receives mouse events and that must be repainted.
public int w
return int

x public_oe property

The x position of this widget
public int x
return int

y public_oe property

The y position of this widget
public int y
return int