TVision - Perl glue to the TurboVision library
SYNOPSIS
use TVision;
my $tapp = tnew 'TVApp';
my $w = tnew 'TWindow', [1,1,120,15], 'моё окно, товарищи',5;
my $b = tnew 'TButton', [1,1,30,3], 'кнопка', 125, 0;
my $checkboxes = tnew 'TCheckBoxes', [3,3,81,9], ['a'..'s'];
my $e = tnew TInputLine => ([3,11,81,13],100);
$tapp->deskTop->insert($w);
$w->insert($_) for ($checkboxes, $e, $b);
$e->focus();
$tapp->run;
DESCRIPTION
The TVision package is a perl glue to the TurboVision library github.com/magiblot/tvision.
TVision namespace contains subpakages of 2 types: * turbovision widgets (or 'controls') such as TButton, etc. * and also some helper packages.
All the TVision::xxxx widgets are array refs, where first item at index 0 holds address of the underlying C++ object, 2nd ($obj->[1]) generated widget name, 3rd - its path. 4rd item - left to user, any scalar could be stored there, please see the methods store_user_value/retrieve_user_value for this.
Some widgets (TButton) has 'num' key, which is usually small integer for the onCommand event. If 0 - then next availlable is taken.
TRect is array ref of 4 integers, which isn't always blessed to TVision::TRect. TPoint is array ref of 2 integers, which isn't always blessed to TVision::TPoint. TKey is array ref of 2 integers or just integer.
Following classes and members are mapped to the underlying c++ TurboVision library:
Mapping of following constructors are implemented:
TBackground(TRect r, char aPattern)
TDeskTop(TRect r)
TScroller(TRect r, TScrollBar *aHScrollBar, TScrollBar *aVScrollBar)
TLabel(TRect r, TStringView aText, TView *aLink )
TButton(TRect r, char *title, int cmd, int flags)
TScrollBar(TRect r)
TIndicator(TRect r)
TInputLine(TRect r, int limit)
TMenuBar(TRect r, TSubMenu* &aMenu)
TMenuBar1(TRect r, TMenu *aMenu)
TMenu()
TMenu1( TMenuItem*& itemList )
TMenu2( TMenuItem*& itemList, TMenuItem*& TheDefault)
TMenuItem(TStringView aName, int aCommand, TKey aKey, int aHelpCtx=hcNoContext, TStringView p=0, TMenuItem *aNext=0)
TMenuItem1(TStringView aName, TKey aKey, TMenu *aSubMenu, int aHelpCtx=hcNoContext, TMenuItem *aNext=0)
TSubMenu( TStringView nm, TKey key, int helpCtx = hcNoContext )
TEditor(TRect r, TScrollBar *sb1=0, TScrollBar *sb2=0, TIndicator *ind=0, int n=1000)
TEditWindow(TRect r, char *title, int num)
TWindow(TRect r, char *title, int num)
TView(TRect r)
TDialog(TRect r, char *title)
TStaticText(TRect r, char *title)
THistory( TRect bounds, TInputLine *aLink, int aHistoryId )
TSItem( TStringView aValue, TSItem *aNext )
TNode(TStringView aText)
TNode1(TStringView aText, TNode* aChildren, TNode* aNext, int initialState=1)
TOutline(TRect r, TScrollBar* aHScrollBar, TScrollBar* aVScrollBar, TNode* aRoot)
Mapping of following methods are implemented:
TApplication:
void cascade()
void dosShell()
void tile()
void shutDown()
TProgram:
void run()
void idle()
void setScreenMode(int mode)
TView *validView(TView *p)
TView:
void locate(TRect r)
TRect getBounds()
TRect getExtent()
TRect getClipRect()
int mouseInView( TPoint mouse )
void growTo( short x, short y )
void moveTo( short x, short y )
void setBounds(TRect r)
void hide()
void show()
void drawView()
int exposed()
int focus()
void hideCursor()
void drawHide( TView *lastView )
void drawShow( TView *lastView )
void drawUnderRect(TRect r, TView *lastView ) self->drawUnderRect( r, lastView);
void drawUnderView( int doShadow, TView *lastView )
void blockCursor()
void normalCursor()
void setCursor( int x, int y )
void showCursor()
void drawCursor()
int eventAvail()
int commandEnabled( int command )
void disableCommand( int command )
void enableCommand( int command )
int getState( int aState )
void select()
TPoint makeGlobal( TPoint source )
TPoint makeLocal( TPoint source )
TView *nextView()
TView *prevView()
TView *prev()
void makeFirst()
void putInFrontOf( TView *Target )
TView *TopView()
int getHelpCtx()
int valid( int command )
void draw()
int dataSize()
void getData( void *rec )
void setData( void *rec )
void awaken()
void resetCursor()
void endModal( int command )
int execute()
void setState( int aState, int enable )
TScrollBar:
void setParams( int aValue, int aMin, int aMax, int aPgStep, int aArStep )
void setRange( int aMin, int aMax )
void setStep( int aPgStep, int aArStep )
void setValue( int aValue )
void drawPos( int pos )
int getPos()
int getSize()
TScroller:
void scrollTo( int x, int y )
void setLimit( int x, int y )
void checkDraw()
TWindow:
TFrame *initFrame( TRect r)
TScrollBar *standardScrollBar( int aOptions )
void zoom()
void shutDown()
TEditor:
char bufChar( int a)
int bufPtr( int a)
int cursorVisible()
void deleteSelect()
int insertMultilineText( char *a, int b)
int insertBuffer( char *c, int uint1, int uint2, int Boolean1, int Boolean2 )
int insertEOL( int Boolean )
int insertText( char *cv, int uint, int Boolean )
void scrollTo( int x, int y)
int search(char *c, int ushort )
void setCmdState( int ushort, int Boolean )
void setSelect( int a, int b, int Boolean)
void trackCursor( int Boolean )
void undo()
int charPos( int uint1, int uint2 )
int charPtr( int uint1, int a)
int clipCopy()
void clipCut()
void clipPaste()
void deleteRange( int uint1, int uint2, int Boolean )
void doUpdate()
void doSearchReplace()
void drawLines( int a, int b, int uint )
void find()
unsigned_int getMousePtr( TPoint p)
int hasSelection()
void hideSelect()
int isClipboard()
int lineEnd( int uint )
int lineMove( int uint, int i)
int lineStart( int uint )
int indentedLineStart( int uint )
void lock()
void newLine()
int nextChar( int uint )
int nextLine( int uint )
int nextWord( int uint )
int prevChar( int uint )
int prevLine( int uint )
int prevWord( int uint )
void replace()
void setBufLen( int uint )
void setCurPtr( int uint, int uchar )
void startSelect()
void toggleEncoding()
void toggleInsMode()
void unlock()
void update( int uchar )
void detectEol()
TMenuItem:
void append(TMenuItem *aNext)
TGroup:
void xinsert(TWindow *what) self->insert(what);
void insertView(TView *p, TView *Target)
void remove( TView *p )
void removeView( TView *p )
void resetCurrent()
void selectNext( int forwards )
void redraw()
TInputLine:
void setData(char *data)
TButton:
void setTitle(char *title)
TOutlineViewer:
void update()
void expandAll(TNode* node)
char* createGraph(int level, int lines, int flags, int levWidth, int endWidth, char* chars)
TOutline:
void adjust(TNode* node, int expand)
TNode* getRoot()
int getNumChildren(TNode* node)
TNode* getNext(TNode *node)
TNode* getChild(TNode* node, int i)
int isExpanded(TNode* node)
int hasChildren(TNode* node)
EOS
}}}
{{{
# getters/setters:
use strict;
my $pkg='';
my $first=1;
join '', (map {
if (/^\s*#/) {()} # ignore comment
elsif (/^\s*$/) {()} # ignore empty line
elsif (/^\s*(\S+):/) {$pkg=$1; $first=1;() }
else {
my ($type, $var) = /^\s*(.+)\s+(\S+)/;
if ($var=~s/^\*//) {$type.='*'}
my $line0 = $first ? "MODULE=TVision::$pkg PACKAGE=TVision::$pkg" : "";
$first=0;
<<"EOS"
$line0
$type get_$var($pkg *self)
CODE:
RETVAL = self->$var;
OUTPUT:
RETVAL
Mapping of following public class members are implemented:
TEditor:
TScrollBar *hScrollBar
TScrollBar *vScrollBar
TIndicator *indicator
char *buffer
int bufSize
int bufLen
int gapLen
int selStart
int selEnd
int curPtr
TPoint curPos
TPoint delta
TPoint limit
int drawLine
int drawPtr
int delCount
int insCount
int isValid
int canUndo
int modified
int selecting
int overwrite
int autoIndent
int lockCount
int updateFlags
int keyState
TEditWindow:
TFileEditor *editor
TWindow:
int flags
TRect zoomRect
int number
int palette
TFrame *frame
TView:
TView *next
TPoint size
int options
int eventMask
int state
TPoint origin
TPoint cursor
int growMode
int dragMode
int helpCtx
int commandSetChanged
TGroup *owner
int showMarkers
int errorAttr
TScrollBar:
int value
int minVal
int maxVal
int pgStep
int arStep
TScroller:
TPoint delta
TProgram:
TProgram *application
TStatusLine *statusLine
TMenuBar *menuBar
TDeskTop *deskTop
int appPalette
int eventTimeoutMs
TMenuItem:
TMenuItem *next
int command
int disabled
TKey keyCode
int helpCtx
TNode:
TNode* next
const char* text
TNode* childList
int expanded
TOutlineViewer:
int foc
TOutline:
TNode* root
Getters and setters are named get_xxxx and set_xxxx respectively.
Functions
Most TVision functions are mapped into perl.
$str = TVision::messageBox($str, $options);
$str = TVision::messageBoxRect([$x0,$y0,$x1,$y1],$str, $options);
$str = TVision::inputBox($title, $label, $default="", $imit=1000);
$str = TVision::inputBoxRect([$x0,$y0,$x1,$y1],$title, $label, $default="", $imit=1000);
TVision::spin_loop();
TVision::TApplication::onCommand($coderef) function
Registers callback for a function to be invoked in TApplication event loop. This function takes 2 integers as its arguments - command ID and any user data. Example:
$tvapp->onCommand(sub {
my ($cmd, $arg) = @_;
if ($cmd == 123) { # e.g. - button pressed
# do something on button press
}
elsif ($cmd == 125) {
...
}
});
Pass undef or 0 to reset such callback.
TVision::TApplication::on_idle($coderef) function
Registers callback for a function to be invoked after TProgram::idle().
Pass undef or 0 to reset such callback.
Geometry managers (not ready yet, pleae ignore this entire section)
Geometry manager tkpack stolen/hijacked from tcl/tk. In order for it to function properly, each widget gets its name ("path") TDesktop is '.', frame on it is .f, buttin on it could be named as .f.btn2, etc. Ideally widget's name is either specified by user, or generated on the fly at creation time. However we don't know who is widget's parent until it is "inserted" by the ...->insert method.
We hold widget's path in widget object, which is array ref, at item 2.
Mapping of widget names to correspoiding objects is held in %TVision::names, widget paths in %TVision::paths.