Documentos de Académico
Documentos de Profesional
Documentos de Cultura
The Default
By default, Harbour will select the gtwin.lib. All GT commands will then be executed
through the functions in the gtwin.lib, which outputs
them to a WinXP console. Also, the next command pair are automatically included in your
Harbour app. You do not need to put in your program.
ANNOUNCE HB_GT_SYS
REQUEST HB_GT_WIN_DEFAULT
if you will want to use some GT you will have to add to your code:
REQUEST HB_GT_<name>
Setting the default GT driver is done exactly the same as setting the default RDD. In
RDD it request DBFNTX by default. It is done inside a
module with RDDSYS() symbol, and core code contains:
GT works with "console windows". and create several windows don't means that each routine will works
with a independent "console window".
A routine need to know how is it's "console window" to work.
In DBF you use SELECT to select a alias, in GT you use hb_gtSelect() to select a "console window".
SetGt() is a function to help to save/restore GT (or select a "console window" to work).
console window = window + keyboard + mouse
GT = GTWVG or any other GT
Note: "console window" here is not the same as "dos window".
Using harbour gt
Using non default terminal driver
To use an alternate driver, put these commands at the top of your main harbour prg
file. For example, to use the gtwvt.lib, which creates a real WinAPI window for the
output (rather than a simple console window) or gtwvg , use the following commands.
hbmk2 yourprg -gtwvt
hbmk2 yourprg -gtwvg
hbmk2 yourprg -gtqtc
ANNOUNCE HB_GT_SYS
REQUEST HB_GT_GUI_DEFAULT
Then GTNUL will be the default GT driver, and even if you would not disable GTWIN
and link it with your application, GTWIN will not be activated but GTNUL.
It could be intentional, because if your application is linked with more GTs, then you can
also set the default one when you start your application using //GT<name> switch, or
HB_GT environment variable. So you can create GUI application which will set the
default GT driver to NUL and will not activate GTWIN,
You can include muliple drivers in your applications, and then choose the one you want
at startup time. In this case you should set one of the drivers as the default, and then
request that the other drivers be included in the link so the the default can be changed
at startup time. For example, use the next commands to create an application that
outputs to GTWVT by default, but can use GTWIN by specifying it at startup (or in
ANNOUNCE HB_GT_SYS
REQUEST HB_GT_WIN
REQUEST HB_GT_WVT_DEFAULT
ANNOUNCE HB_GT_SYS
REQUEST HB_GT_GUI_DEFAULT
REQUEST HB_GT_WIN REQUEST
HB_GT_WVT FUNCTION
MAIN()
? HB_GTVERSION(), HB_GTVERSION(1)
TONE( 200, 3)
TONE( 300, 3)
TONE( 500, 3)
INKEY( 5 )
RETURN NIL
/* end */
Now run the programs three times, like this:
t
t //GTWIN
t //GTWVT
The first time the app will use GTGUI and you will hear the tones but not see any screen
output. Five seconds later the program will stop. Note that if you put an INKEY(0) or
READ in the program, it would hang, because this driver has no keyboard control.
The second time you should get a console window with the version text, and the third
time you should get a real WinAPI window with different version text. With these
drivers, you can speed up the program exit by hitting a key.
HB_GT: You can also control startup with the HB_GT environment variable. For
example to choose GTWVT when you run t, do this:
SET HB_GT=GTWVT
Other syntax
You can replace the above commands with Harbour function as follows:
Replace With
-------------------------- -----------------------
ANNOUNCE HB_GT_SYS PROC HB_GTSYS; RETURN
REQUEST HB_GT_WIN_DEFAULT PROC HB_GT_WIN_DEFAULT; RETURN
Sample template
REQUEST HB_GT_XWC_DEFAULT
#INCLUDE "HBGTINFO.CH"
proc main()
local cFont
hb_gtInfo( HB_GTI_FONTSEL, cFont := xFontSel() )
alert( "What do you think about it???;;" + cFont )
return
function xfontsel()
local hProcess, hStdOut, cFontSel, n
hProcess := hb_processOpen( "xfontsel -print",, @hStdOut
)
if hProcess != -1
cFontSel := space( 256 )
n := fread( hStdOut, @cFontSel, len( cFontSel ) )
cFontSel := left( cFontSel, n )
hb_processClose( hProcess )
fclose( hStdOut )
endif
return cFontSel
What is gtwtg?
Implemented: Xbase++ compliant SetAppWindow() function.
The function simulates a WvgCRT() window from current thread specific GT console
if the function is called without parameters and current thread has not posted any
application window. This facilitates hosting WVG*Gui controls on pure GT invoked
console
* contrib/gtwvg/wvgwnd.prg
+ Restructured: GTWVG at GUI space.
Xbase++ compatible controls can be hosted on CUI console.
The only requirement is that the parent of such GUI controls is an object created
with WvgCRT(). If there
is no object of type WvgCRT() is in sight, in case of a pure GT invoked console, a
WvgCRT() object is created and
current console window handle is assigned to it. This is achieved through
SetAppWindow() function which is called
if a control's parent is supplied as NIL, in accordance with Xbase++
documentation.
The events assigned and executed by such controls are not posted to inkey()
processing, instead, are executed directly.
Just before executing an assigned event, focus is imposed on GT console and
returned to GUI control after processing
the execution. This ensures that GT is always in focus while GUI control executes
an assignment.
+ Introduced: In accordance with console coordinate system, the positioning and size
parameters supplied at the time of
construction of GUI objects now support
aPos == { nRow, nColumn } and aSize == { nRows, nColumns }
protocol. This has been achieved by supplying all four values in negative. Thus
WVG engine checks for negativity of position
and size values and determines that coordinate system be interpreted as
row/column instead of x/y(s).
For example,
WvgPushButton( , , { -10, -2 }, { -3, -10 } )
call will render the push button at 10,2,13,12 console area in terms of rows and
columns.
These coordinates will be maintained with resizing of console, etc.
To extend this coordinate system a step further, the pos and size arrays can be
populated with code blocks evaluating
to a negative numeric value. This implimentation facilitates to ancor any GUI
control to a specific postion always. Thus,
WvgPushButton( , , { {|| -( maxrow()-3 ) }, -2 }, { -10, -3 } )
will always position push button on last row-3 of the console no matter how many
rows the console is resized to.
* contrib/gtwvg/tests/demowvg.prg
* contrib/gtwvg/tests/wvgtbrowser.prg
* contrib/gtwvg/tests/wvgutilities.prg
* contrib/gtwvg/tests/wvgxbp.prg
+ Restructured: the code parts to demonstrate newly introduced GTWVG concepts.
Specialy look at main window's menu system, push buttons at the bottom. Also
look at
<Main Menu><Traditional><Browser - GTWVG - Threaded>.
This example is reworked entirely and is a testimony to GTWVG power.
NOTE: more changes and code shifting and simplifying is on the drawing board.
Hopefully code will get an an overhaul in coming days.
Sample template for gtwvg
you can easy convert your source to gui adding a similar
template so you can maintain your source whith little
modificationand then start adding gui element in systax
compatible with xbp but with vgw prefix
// hbmk2 sample.prg -gtwvg -gui
REQUEST HB_GT_WVG_DEFAULT
REQUEST HB_GT_WVG
#INCLUDE "HBGTINFO.CH"
function main
set color to "N/W,N/BG,,,N/W*"
cls
SETMODE(25,80)
hb_gtInfo( HB_GTI_ICONFILE, "sample.ico" )
hb_gtInfo( HB_GTI_WINTITLE, "Programm Title" )
Hb_GtInfo( HB_GTI_SELECTCOPY,.T.)
Hb_GtInfo( HB_GTI_RESIZABLE, .T. )
HB_GTINFO( HB_GTI_CLOSABLE, .T. )
HB_GTINFO( HB_GTI_RESIZABLE, .T. )
HB_GTINFO( HB_GTI_CODEPAGE, 255 )
Hb_GTInfo(HB_GTI_MOUSESTATUS, 1 )
screenHeight:= HB_GTINFO( HB_GTI_SCREENWIDTH, HB_GTINFO(
HB_GTI_DESKTOPWIDTH ) )
screenHeight:HB_GTINFO( HB_GTI_SCREENHEIGHT, HB_GTINFO(
HB_GTI_DESKTOPHEIGHT ) - 50 )
*SETMODE( GTINFO( GTI_DESKTOPROWS ) - 5, GTINFO( GTI_DESKTOPCOLS ) )
HB_GTInfo(HB_GTI_FONTNAME, "Courier New")
HB_GTInfo(HB_GTI_FONTQUALITY,HB_GTI_FONTQ_HIGH )
if screenWidth >= 1920
Hb_GtInfo( HB_GTI_FONTWIDTH, 21 )
HB_GTInfo(HB_GTI_FONTSIZE, 40)
ELSEIF screenWidth >= 1600 // 1280 *960
Hb_GtInfo( HB_GTI_FONTWIDTH, 18 )
HB_GTInfo(HB_GTI_FONTSIZE, 32)
elseif screenWidth >= 1280 // 1280 *960
Hb_GtInfo( HB_GTI_FONTWIDTH, 13 )
HB_GTInfo(HB_GTI_FONTSIZE, 20) // 15*80=1200 36*25=900
elseif screenWidth >= 1024 // 1024*760
Hb_GtInfo( HB_GTI_FONTWIDTH, 12.5 )
HB_GTInfo(HB_GTI_FONTSIZE, 20)
elseif screenWidth >= 800
Hb_GtInfo( HB_GTI_FONTWIDTH, 10 )
HB_GTInfo(HB_GTI_FONTSIZE, 18)
ELSE
Hb_GtInfo( HB_GTI_FONTWIDTH, 14 )
HB_GTInfo(HB_GTI_FONTSIZE, 8)
ENDIF
// another intresting
// HB_GtInfo( HB_GTI_ISFULLSCREEN, .T. )
// hb_gtInfo( HB_GTI_RESIZEMODE, HB_GTI_RESIZEMODE_FONT )
return
gtqtc Universal gt
GTQTC is The most Complete Gt and is able to run on all plafrom where is aibable qt
grqtc include all GT features existing in other GTs so now it's probably the most completed GT and for
sure it's the most portable one and it can be used without HBQT,
Now I'm thinking about committing it but because it's pure QT code then it can be compiled for
platforms were we do not have any native graphic GT, i.e. Symbian, Android, RB10, etc. Even for
MacOSX and IPhones it should give much more native appearance then GTXWC. So I think about
committing it to Harbour
contrib code instead of updating HBQT. Of course you will be able to merge it with HBQT. I created
functions you can add to HBQT as replacement for HB_GTI_WIDGET and HB_GTI_DRAWINGAREA
GTQTC fills a wide-gap in using Harbour platform-independent without even changing the setup. Plus it
will provide a solid initiative for console mode programmers to turn to pure GUI and having a edge of
mixingGT and GUI screens. New GTQTC has the power to be run in MT mode flawlessly, a powerful
offering
Is Easy convert app compiled with GTQTC you need only linked it app, substituting GTWVT and all
worked very fin
hbmk2 -lgtqtc
2013-04-24 12:22 UTC+0200 Przemysaw Czerpak (druzus/at/poczta.onet.pl)
+ contrib/gtqtc/gtqtc.cpp
+ contrib/gtqtc/gtqtc.h
+ contrib/gtqtc/gtqtc.hbc
+ contrib/gtqtc/gtqtc.hbp
+ contrib/gtqtc/gtqtc.hbx
+ contrib/gtqtc/hbmk2_qtmoc.hb
* contrib/hbplist.txt
+ added new QT based GT driver: GTQTC.
This implementation is slightly based on GTQTC created by
Pritpal Bedi - many thanks.
Now GTQTC supports nearly all GT features existing in all other GTs,
i.e.
fullscreen mode:
hb_gtInfo( HB_GTI_ISFULLSCREEN, <lFullScreen> )
automatic fullscreen switch after ALT+ENTER:
hb_gtInfo( HB_GTI_ALTENTER, <lEnable> )
maximized mode controlled by user:
hb_gtInfo( HB_GTI_MAXIMIZED, <lEnable> )
clipboard selection with SHIFT + MouseLeftButton:
hb_gtInfo( HB_GTI_SELECTCOPY, <lEnable> )
terminal window resizing:
hb_gtInfo( HB_GTI_RESIZABLE, <lCanResize> )
both resize modes
a) change number of rowas and columns:
hb_gtInfo( HB_GTI_RESIZEMODE, HB_GTI_RESIZEMODE_ROWS )
b) keep number of rows and clomuns and update font size
hb_gtInfo( HB_GTI_RESIZEMODE, HB_GTI_RESIZEMODE_FONT )
blocking ALT+F4 and [X] window buttons:
hb_gtInfo( HB_GTI_CLOSABLE, <lCanClose> )
all cursor shapes and setting cursor blink rate:
hb_gtInfo( HB_GTI_CURSORBLINKRATE, <nMilliSec> )
window positioning in screen pixels:
hb_gtInfo( HB_GTI_SETPOS_XY, <aNewPosXY> ) -> <aPrevPosXY>
mouse positioning in screen pixels:
hb_gtInfo( HB_GTI_MOUSEPOS_XY ) -> <aPosXY>
full control on font behavior with:
a) box characters shown as predefined internally pixmapos:
hb_gtinfo( HB_GTI_FONTATTRIBUTE,
hb_bitOr( HB_GTI_FONTA_DRAWBOX,
hb_gtinfo( HB_GTI_FONTATTRIBUTE ) ) )
b) forcing fixed size font metric:
hb_gtinfo( HB_GTI_FONTATTRIBUTE,
hb_bitOr( HB_GTI_FONTA_FIXMETRIC,
hb_gtinfo( HB_GTI_FONTATTRIBUTE ) ) )
c) independent character cell clearing:
hb_gtinfo( HB_GTI_FONTATTRIBUTE,
hb_bitOr( HB_GTI_FONTA_CLRBKG,
hb_gtinfo( HB_GTI_FONTATTRIBUTE ) ) )
d) displaying control characters ( ASC( x ) < 32 ) in row form:
hb_gtinfo( HB_GTI_FONTATTRIBUTE,
hb_bitOr( HB_GTI_FONTA_CTRLCHARS,
hb_gtinfo( HB_GTI_FONTATTRIBUTE ) ) )
and many others like palette settings (HB_GTI_PALETTE), displaying pictures (HB_GTI_DISPIMAGE),
keyboard modifiers (HB_GTI_KBDSHIFTS),clipboard reading and setting (HB_GTI_CLIPBOARDDATA)
or icon and window title settings (HB_GTI_ICONFILE, HB_GTI_WINTITLE)
GTQTC also supports GFX graphic primitives (hb_gfx*()) and it operates on new Harbour extended
mouse and keyboard key codes.The console window is shown when some user outputs appears so
it can be linked with GT GUI application been invisible by default.
It's pure QT code so now is the most portable Harbour GT driver which can be used on platforms where
we haven't native any GT so far or current GTs like GTXWC do not have native appearance. Because it
uses only high level GUI interface then it should be quite easy to convert it to other GUI libraries, i.e. GTK
hbqt/tests/demoqtc.prg
at hbqt/tests/demoqtc.prg find a demonstration appln based on GTQTC having functionality of firing HbQt
widget in modal dialog plus GT specific actions. I
How use gtqtc with qtwidgets?
hbmk2 this.prg -gtqtc hbqtgui.hbc hbqtwidgets.hbc -run
#include "hbqtstd.ch"
procedure main ()
? "test gtxwc +hbqt
? hb_gtversion()
inkey(0)
callguitest()
? "Hello"
inkey(0)
return
FUNCTION CallGuitest()
LOCAL cOne, cTwo, cThree, cFour
LOCAL SAYLIST := {}
LOCAL GETLIST := {}
cOne := Space( 10 )
cTwo := Space( 10 )
cThree := Space( 10 )
cFour := Space( 10 )
@ 02, 05 Qsay "First: " Qget cOne
@ 03, 05 Qsay "Second:" Qget cTwo
QSET GETSFONT TO QFont( "Courier New", 14 )
HbQtSet( _QSET_LINESPACING, 10 )
QREAD LINESPACING "10"
// QApplication():exec()
RETURN NIL
Understanding multi gt
This issue will be addressed gradually.
Using an example in text mode, see how to use and gtwin gtwvt
the same application.
file: testgt.prg
procedure main ()
cls
? "Test"
INKEY (0)
return
testgt
testgt / / gtwin
testgt / / gtwvt
The function of the / / gtwin and / / indicate which is gtwvt gt should be used in implementing the
program.
In all three cases, we have a window using gtwin. This is because it be the standard (default) and be the
one used in compiling this example. The / / gtwvt is ignored in this case, since not gtwvt is present.
file: testgt.prg
request hb_gt_wvt
procedure main ()
cls
? "Test"
INKEY (0)
return
Here we add the line "request hb_gt_wvt", requesting the inclusion of gtwvt the compilation. But how did
not specify which gt default, the
gtwin continues as standard.
Compile and run the sample, as follows:
hbmk2 testgt.prg
testgt
testgt / / gtwin
testgt / / gtwvt
Here the / / gtwvt starts to work and we have a window created with
the gtwvt. See that is no longer a text window, but a window
graphics (with appearance of the text window).
Continuing with the subject, let's go back to our basic example:
file: testgt.prg
procedure main ()
cls
? "Test"
INKEY (0)
return
Compile as follows:
hbmk2 testgt.prg-gtwvt
The parameter-gtwvt gtwvt indicates that we want the default in the execution the program.
Run as follows:
testgt
testgt / / gtwin
For text-mode applications, can leave both the gtwin as gtwvt as standard. And using the / / gtwin and / /
gtwvt, we can gt specify which to use, regardless of the pattern.
In short, the compiled sample can be performed in two ways different, since we have two gt's (and gtwin
gtwvt) included in the compilation.
I know at this point, still can not see clearly how take advantage of this feature in MiniGUI, but things will
become clearer as we move in the matter.
hb_gtCreate ()
hb_gtSelect ()
With the function hb_gtCreate, create a new window using gtwvt. The function returns a pointer, which we
will use the function hb_gtSelect, To select this window as the current window.
Let's use the example below. In fact, it is the skeleton of a customer base. But it is enough for the desired
goal.
function query ()
cls
? "Query client"
INKEY (0)
return
--- End of example ---
The purpose of this application is to convert text to graphic, but because it a large application (pretend it
is), the conversion must be in stages.
The first step in conversion is the migration from one home screen to graphics window. So here we go:
Include a line with the command below, in order to use resources of MiniGUI:
# Include " minigui.ch "
Convert the text-mode menu to a window in graphical mode:
procedure main ()
DEFINE WINDOW MainWindow;
AT 0.0;
WIDTH 800;
HEIGHT 600;
TITLE "customer base";
MAIN
DEFINE MAIN MENU
POPUP "Options"
ITEM "inclusion" ACTION inclusion ()
ITEM "change" ACTION alteration ()
ITEM "exclusion" ACTION Delete ()
ITEM "consultation" ACTION query ()
END POPUP
END MENU
END WINDOW
ACTIVATE WINDOW MainWindow
return
Since our application is very large (keep pretending that is), you can not convert it to any chart. So we
have to maintain the routines of inclusion, change, delete, and query in text until they can be converted to
graphics mode. Here comes gtwvt into action and the functions and hb_gtCreate hb_gtSelect.
We put the line below, requesting the presence of our gtwvt application:
request hb_gt_wvt
And the routine inclusion, change, delete, and query are modified as follows:
inclusion function ()
local TMP
Local pNewGT
pNewGT: hb_gtCreate = ("WVT")
TMP: = hb_gtSelect (pNewGT)
cls
? "Inclusion of customers'
INKEY (0)
pNewGT: = nil
hb_gtSelect (TMP)
return
function change ()
local TMP
Local pNewGT
pNewGT: hb_gtCreate = ("WVT")
TMP: = hb_gtSelect (pNewGT)
cls
? "Alteration of the customers"
INKEY (0)
pNewGT: = nil
hb_gtSelect (TMP)
return
function Delete ()
local TMP
Local pNewGT
pNewGT: hb_gtCreate = ("WVT")
TMP: = hb_gtSelect (pNewGT)
cls
? "Exclusion of customers"
INKEY (0)
pNewGT: = nil
hb_gtSelect (TMP)
return
function query ()
local TMP
Local pNewGT
pNewGT: hb_gtCreate = ("WVT")
TMP: = hb_gtSelect (pNewGT)
cls
? "Query client"
INKEY (0)
pNewGT: = nil
hb_gtSelect (TMP)
return
Here is the code we use at the beginning of each routine in text mode:
pNewGT: hb_gtCreate = ("WVT")
TMP: = hb_gtSelect (pNewGT)
With the function hb_gtCreate, create a new window in our system, using gtwvt. And hb_gtSelect
function, we selected this window so we can work with it.
pNewGT: = nil
hb_gtSelect (TMP)
We eliminate the new window we created with the function and hb_gtCreate gt to restore the previous,
using the value returned by the function hb_gtSelect (at the beginning of the routine).
request hb_gt_wvt
procedure main ()
END WINDOW
return
function inclusao()
local TMP
Local pNewGT
pNewGT: hb_gtCreate = ("WVT")
TMP: = hb_gtSelect (pNewGT)
cls
? "Inclusion of customers'
INKEY (0)
pNewGT: = nil
hb_gtSelect (TMP)
return
function change ()
local TMP
Local pNewGT
cls
INKEY (0)
pNewGT: = nil
hb_gtSelect (TMP)
return
function Delete ()
local TMP
Local pNewGT
cls
? "Exclusion of customers"
INKEY (0)
pNewGT: = nil
hb_gtSelect (TMP)
return
function query ()
local TMP
Local pNewGT
cls
? "Query client"
INKEY (0)
pNewGT: = nil
hb_gtSelect (TMP)
return
--- End of example ---
Compile as follows:
Run the program and you have a graphics window. Choose an option menu and you will have a window
in text mode (using gtwvt). Close the window pressing ENTER.
Avoid clicking the X to close the window in text mode, in addition to not close the window, does it not to
close with ENTER. I need to do more tests to see the best way to deal with this inconvenience.
The developer will get you moving the windows to your application so graphic gradually.
Below is one more step in the process, where the window of inclusion changed from text mode to
graphic:
function inclusion ()
DEFINE WINDOW Window1;
AT 0.0;
WIDTH 640;
HEIGHT 480;
TITLE "Adding clients"
END WINDOW
ACTIVATE WINDOW Window1
return
function change ()
local TMP
Local pNewGT
pNewGT: hb_gtCreate = ("WVT")
TMP: = hb_gtSelect (pNewGT)
cls
? "Alteration of the customers"
INKEY (0)
pNewGT: = nil
hb_gtSelect (TMP)
return
function Delete ()
local TMP
Local pNewGT
pNewGT: hb_gtCreate = ("WVT")
TMP: = hb_gtSelect (pNewGT)
cls
? "Exclusion of customers"
INKEY (0)
pNewGT: = nil
hb_gtSelect (TMP)
return
function query ()
local TMP
Local pNewGT
pNewGT: hb_gtCreate = ("WVT")
TMP: = hb_gtSelect (pNewGT)
cls
? "Query client"
INKEY (0)
pNewGT: = nil
hb_gtSelect (TMP)
return
--- End of example ---
These examples were very rough, but hopefully we have given an idea
basic how to use these resources Harbour.
Now it's going to put into practice and improving the process
-
Sincerely,
Marcos Antonio Gambeta
http://marcosgambeta.wordpress.com
http://harbourgtk.wordpress.com
http://harbourqt.wordpress.com
__._,_.___