Copyright: ® Fiesta Publishing 1993


Contents

Introducing True Type TBrowses

The TT TBrowse

Extended graphic capabilities

Creating a TT TBrowse

Self resizing capabilities

Compatibility with Clipper's TBrowse

TT TBrowses as Windows Controls

Defining the general aspect of a TT TBrowse

Defining the aspect of each individual cell

Messages sent by a TT TBrowse

Creating and using a TT TBrowse

The TTBrowse API

Overview

CreateBrowse

RecDVAttribute

SetWindResizeStyle

Sample Code

Overview

Source code

Get more information

How to contact Fiesta Publishing, Inc.


The TT TBrowse

The TT TBrowse is part of Dolce Vita 1.11 for CA-Clipper. It has been designed to be fully compatible with the standard Clipper TBrowse and to take advantage of the graphic capabilities of Windows. Your TBrowses can be displayed using proportional True Type fonts, 24 bits colors as well as extended attributes such as 3D frames, shadowed or 3D text, spacing between lines, a grid and so on.

The complete aspect of your cells, header, footer can be defined using a DV function, and the Clipper color attributes can be used as is to define the particular aspect of each individual cell.

A TT TBrowse is assigned a True Type Font and a Grid style at creation.

The TT TBrowse is provided with special DV messages which give the row/column position of the mouse in it. This feature makes it very easy to add Windows mouse support to a TBrowse object.


Extended graphic capabilities

A TT TBrowse can be customized using a large set of possibilities.

  A TT Tbrowse is assigned a True Type Font name ("Arial" for example) and a Grid Style (normal, dash, dot, dash-dot ...) at creation.

  The TT TBrowse graphic attributes a Dolce Vita application can select for the header, cells or footer are:

- text color:	24 bits color used to display the text of a cell.
- background color:	24 bits color used to paint the background of a cell.
- frame style:	It can be one of the following values:
- No frame
- External 3D frame
- Internal 3D frame
- 3D frame
- text style:	The following font attribute can be combined:
- bold
- italic
- underline
- strike
Dolce Vita 1.11 offers a set of extra text attributes:
- 3D text
- shadowed text

  The TT TBrowse creation function offers a set of default values for these graphic attributes which already give a good aspect to a TT TBrowse. A developer can redefine any of the graphic attributes of a TT TBrowse at run time.


Creating a TT TBrowse

  From the Clipper point of view, creating a TT TBrowse is exactly the same thing as creating a standard one. Once the Clipper TBrowse has been created, it has to be inserted in an existing DV Window or Dialog Box, where it will appear exactly the same way as a List Box or Edit Box, as a Control in fact. Therefore, the steps involved in the creation of TT TBrowse are:

- create the TBrowse itself.
- for example create a Window or Dialog Box, from a Resource File.
- insert the TBrowse in the Window or Dialog Box at a chosen location
  (position and size).

  A TT TBrowse is a Window object identified by a Handle. The standard DV operations on Controls apply: moving, resizing, destroying.


Self resizing capabilities

  A TT TBrowse is self resizable: Dolce Vita 1.11 will adapt the size of its Font to display it entirely in the area of the window where it as been inserted. This is done transparently to the DV application.

Figure 1: Self resizing capabilities of a TT TBrowse (Part 1)

Figure 2: Self resizing capabilities of a TT TBrowse (Part 2)


Compatibility with Clipper's TBrowse

    A TT TBrowse only adds new display and mouse support capacities to the standard Clipper TBrowse. It does not interfere with it at all.


TT TBrowses as Windows Controls

  A TT TBrowse behaves exactly like a MS Windows control. It is given a Handle at creation time, it sends messages that can be retrieved in a GetMessage event loop. The standard DV operations on Controls (move, destroy, resize ..) apply.


Defining the general aspect of a TT TBrowse

  The general aspect of a TT TBrowse is given by a set of attributes that can be chosen at creation time or at runtime:

Font name	Name of the font used to display text (header, footer and
cells). Dolce Vita 1.11 adapts its size to the current
location of the TT TBrowse in its Window.

Grid Style	Defines how the grid is to be drawn in the cell part of a
TT TBrowse: normal, dashed, ...

Spacing	Extra space to be reserved vertically inside cells. It lets
you control the visibility of your TBrowse.

Header attribute	Graphic attributes to be used to paint the Header part of
the TT Tbrowse (colors, frame style, text style).

Cell attribute	Default graphic attributes to be used to paint the TT
TBrowse cells. Each cell can be assigned individual
attributes which will be used instead of the default.

Footer attribute	Graphic attributes to be used to paint the Header part of a
TT TBrowse.


Defining the aspect of each individual cell

  A Clipper TBrowse makes use of color string to customize the aspect (foreground/background colors) of such cell. TT TBrowse extends this mechanism to let you assign not only colors but also a Frame and Text Style to a given cell. A function is provided by the TT TBrowse API to let you link a standard color string with extended graphic attributes.


Messages sent by a TT TBrowse

  A TT TBrowse, as any Control, sends messages to reflect the user activity. The WM_MOUSEMOVE DV message provides the row and column number of the TBrowse pointed at by the cursor. This information makes it easy to add mouse support to a TBrowse. The source code given below gives more information about it.


Creating and using a TT TBrowse

Steps involved in creating a TT TBrowse

Inserting a TT TBrowse in a Window

Font name, Grid style and Spacing

The TT TBrowse graphic attributes

Header, Cell, Footer attributes

Modifying graphic attributes at runtime

Dolce Vita messages related to a TT TBrowse

Making a TT TBrowse self resizable


Steps involved in creating a TT TBrowse

The steps involved in creating a TT TBrowse are:

- create the Clipper TBrowse itself.

- open the DV Window or Dialog Box where you will insert the TBrowse.

- select the Font name, Grid Style (optional) and Spacing (optional).

- insert the TBrowse in the Window or Dialog Box (CreateBrowse
  function).

  Your TBrowse will then be displayed in its window, according to the graphic attributes it has been assigned. (See example below)


Inserting a TT TBrowse in a Window

  Once your TBrowse is created, you must insert it in a Window or Dialog Box, as you would do for a standard Windows Control (Button, Edit Box ...). The CreateBrowse function is provided for that purpose.

CreateBrowse( hOwner, aRect, L0,C0,L1,C1, cFontName,
nSpacing, nGridStyle )--> hBrowse

hOwner is the Handle of the Window (Dialog Box) where the TBrowse is to be inserted.

aRect gives the size and location of the TBrowse in hOwner, in pixels.

(L0,C0,L1,C1) are the DOS screen coordinates of the TBrowse, as passed to the TBrowseDB Clipper function.

cFontName is the name of the True Type Font to be used to display the TT TBrowse ("Arial" for example). The font size is dynamically adjusted by Dolce Vita to display the entire TBrowse in its Control, no matter what its size is.

nSpacing is the number of pixels left vertical between two cells.

nGridStyle specifies the way the grid will be drawn.

CreateBrowse returns the handle of the new Control (hBrowse).

Note: A TBrowse requires special delimiters to be recorded as a TT TBrowse. See the API Reference paragraph for more information.


Font name, Grid style and Spacing

The CreateBrowse function requires 3 parameters which define part of its aspect:

cFontName

This parameter must correspond to an existing True Type font. (ex: "Arial").

nGridStyle (optional)

This parameter must be given one of the following values:

TTB_GRID_SOLID:	the grid is drawn with a solid pen.
TTB_GRID_DASH:	the grid is drawn with a dashed pen.
TTB_GRID_DOT:	the grid is drawn with a dotted pen.
TTB_GRID_DASHDOT:	the grid is drawn with a pen alterning
dashed and dots
TTB_GRID_DASHDOTDOT:	the grid is drawn with a pen alterning
dashed and double dots

Default value: TTB_GRID_SOLID

nSpacing (optional)

This parameter gives the number of pixels to be left vertically inside a cell.

Default value: 0


The TT TBrowse graphic attributes

  The Footer, Cells or Header of TT Browse will be painted depending on their graphic attribute: Frame and Text Style, as well as Text and Background colors. A TT TBrowse is given default graphic attributes, which can be overridden at any time.

  The RecDVAttribute function lets you assign graphic attributes to an individual cell, given its Clipper color attribute..

RecDVAttribute( hBrowse, cColor/nColor , nFrameStyle,
nFontStyle,;{ RGBFore, RGBBack },
[lRepaint]) --> ErrorCode

hBrowse

Handle of the TT TBrowse Control, as returned by CreateBrowse.

cColor/nColor

  Specifies the character attribute to assign the graphic attributes to. This can either be a general attributes (nColor), or an individual attribute in the form of a standard Clipper color string (cColor).

nColor must be given one of the following values:

TTB_HEADER:	Header general attribute.
TTB_CELL:	Cell general attribute.
TTB_FOOTER:	Footer general attribute.

nColor can also be a valid Clipper numerical color (0-255).

cColor must be a valid Clipper string color. "W+/B" for example.

nFrameStyle

  Specifies the type of frame to draw around the cell which is given a cColor/nColor color attribute. It must be one of the following values:

TTB_FRAME_NONE:	No frame.
TTB_FRAME_3DEXT:	External frame.
TTB_FRAME_3DINT:	Internal Frame.
TTB_FRAME_3D:	Alternate 3D Frame.

Default values:

Header:	TTB_FRAME_3DEXT
Cell:	TTB_FRAME_NONE
Footer:	TTB_FRAME_3DEXT

nFontStyle

  Specifies the Font attribute to be used when the cell (header/footer) text is drawn. It must be a combination of the following values:

TTB_TEXT_NORMAL	no special effect.
TTB_TEXT_3D	3D Text.
TTB_TEXT_SHADOW	Shadowed text.
TTB_TEXT_ITALIC	Italic font.
TTB_TEXT_UNDERLINE	Underline font.
TTB_TEXT_STRIKE	Strike font.
TTB_TEXT_BOLD	Bold font.

The TTB_TEXT_3D and TTB_TEXT_SHADOW flags are exclusive.

The TTB_TEXT_SHADOW, TTB_TEXT_ITALIC, TTB_TEXT_UNDERLINE, TTB_TEXT_STRIKE and TTB_TEXT_BOLD can be combined.

Default values:

Header:	TTB_TEXT_NORMAL.
Cell:	TTB_TEXT_NORMAL.
Footer:	TTB_TEXT_NORMAL.

RGBFore

Color used to draw the text.

Default values:

Header:	White.
Cell:	Black.
Footer:	White.

RGBBack

Color used to paint the cell.

Default values:

Header:	System Button color.
Cell:	System Window color.
Footer:	System Button Color.

lRepaint

Specifies whether the TT TBrowse is to be repainted immediately or not.

Default value: FALSE.


Header, Cell, Footer attributes

There are two kinds of graphic attributes: the general attributes and the local ones.

A TT TBrowse is given 3 general attributes: Header, Cell and Footer.

  The general Cell attributes are overridden in the case an individual cell has been given explicit color attributes, i.e. its video character attribute has been assigned extended graphic attributes (RecordDVAttribute function). See the example given below for more information

Figure 3: Grid Style, General and Individual Attributes


Modifying graphic attributes at runtime

  The RecordDVAttribute function can be called at any time to modify either a general or an individual attribute. The Font and Grid Style can not be changed dynamically.


Dolce Vita messages related to a TT TBrowse

  A TT TBrowse, just like any standard Windows Control, sends messages to report the user activity. The DV WM_MOUSEMOVE message provides the column/row position of the mouse in the TT Tbrowse sending the message. This information makes mouse support in a TBrowse easy. The DV messages are retrieved with the GetMessage function. The mouse position is given by the GetXParam function:

GetXParam(3) --> TT Browse column pointed to by the mouse (0 ranged).
GetXParam(4) --> TT Browse row pointed to by the mouse (0 ranged).


Making a TT TBrowse self resizable

The SetWindResizeStyle function is provided to assign a Resize Style to a TT Tbrowse. A Resize Style defines how a Control is to be resized when its parent itself is resized or maximized.

SetWindResizeStyle( hWnd, nStyle ) --> ErrorCode

hWnd

Handle of the TT TBrowse to assign the Resize Style to.

nStyle

Flag specifying the new resize style. It must be a combination of  the following values:

X1RIGHT:	The Upper Left Corner of the Control is horizontally attached to
the right border of its parent.
Y1DOWN:	The Upper Left Corner of the Control is vertically attached to
the bottom border of its parent.
X2RIGHT:	The Lower Right Corner of the Control is horizontally attached to
the right border of its parent.
Y2DOWN:	The Lower Right Corner of the Control is vertically attached to
the bottom border of its parent.

By default, both the Upper Left and Lower Right corners of a Control are attached to the Left and Top borders of their parent.

Example:

You would make a hBrowse TT Tbrowse follow the size of its parent by assigning it a Resize Style like this:

_OR (X2RIGHT , Y2DOWN).


The TTBrowse API - Overview
Overview

  The TTBrowse API is made of three functions: CreateBrowse, RecDVAttribute, SetWindResizeStyle.

  CreateBrowse assumes a Clipper TBrowse has been created at a given screen location, and that the window or dialog box where it will be inserted already exists. It records the existing TBrowse in the DV window and specifies its Font name, Grid style and Spacing.

  RecDVAttribute lets a DV application record or modify the graphic properties of an attribute on the fly. Both general (Header, Cell, Footer) and individual cell attributes can be modified with RecDVAttribute. The attributes of a cell are:

- its colors (text, background).
- frame style (external 3D, internal 3D, 3D frame).
- font style (bold, italic, underline, strike, 3D, shadowed).

SetWindResizeStyle assigns a new Resize Style to a TT TBrowse.

Note: A DVBROWSE.CH include file provides the TT TBrowse manifest constants.


CreateBrowse

CreateBrowse( hOwner, aRect, L0,C0,L1,C1, cFontName,
nSpacing, nGridStyle ) --> hBrowse

Description

The CreateBrowse function records an existing Clipper TBrowse, and makes it a TT TBrowse.

Parameter	Description

hOwner	Handle of the Window where to insert the TBrowse.
aRect	Position and size, in pixels, of the TT TBrowse in hOwner.
L0,C0,L1,C1	Position and size of the TBrowse in the DOS screen.
cFontName	Name of the font to be used with the TT TBrowse.
nSpacing	Spacing, in pixels, between two cells.
nGridStyle	Grid style.
hBrowse	Receives the handle of the created TT TBrowse.
The GridStyle parameter must be given one of the following values:

Value	Meaning

TTB_GRID_SOLID	the grid is drawn with a solid pen.
TTB_GRID_DASH	the grid is drawn with a dashed pen.
TTB_GRID_DOT	the grid is drawn with a dotted pen.
TTB_GRID_DASHDOT	the grid is drawn with a pen alterning dashed and dots.
TTB_GRID_DASHDOTDOT	the grid is drawn with a pen alterning dashed and double dots.
Comments

ATTENTION: The Clipper TBrowse to be recorded must be given special column and row separators:

oTB:HeadSep := "--"
oTB:ColSep  := "¦"
oTB:FootSep := "--"

Example

oTB := TBrowseDB(2,3,23,74)
oTB:HeadSep := "--"
oTB:ColSep  := "¦"
oTB:FootSep := "--"

// add one column for each field
aTmp:=dbstruct()
for n := 1 to Fcount()
oTB:addColumn(TBColumnNew(FieldName(n), FieldBlock(FieldName(n)
next

// Open Session and Window
hSess:=OpenSess("Session",aRect)
hWnd:=CreateWindow("Window",aRect)

// Create the Windows Browse
aRect[3]-=20
aRect[4]-=20
nSpacing := 0
nGrid := TTB_GRID_DOT

hBrowse := CreateBrowse( hWnd, aRect, 2,3,23,74,"Arial", nSpacing, nGrid)


RecDVAttribute

RecDVAttribute( hBrowse, cColor/nColor , nFrameStyle,
nFontStyle,{ RGBFore, RGBBack }, lRepaint)
--> ErrorCode

Description

The RecDVAttribute function records or redefines a TT TBrowse attribute.

Parameter	Description

hBrowse	Handle of the TT TBrowse where to record the attributes.
cColor/nColor	Identifies the individual (cColor) or general (nColor) attribute to be modified or recorded. nColor must be one of the values given below. cColor must be a valid Clipper color string.
nFrameStyle	Defines how the cell (or header, footer) frame will be drawn. It must be one of the values given below.
nFontStyle	Defines the text style of the cell. It must be one of the values given below.
RGBFore	Text color of the cell.
RGBBack	Background color of the cell.
lRepaint	If this flag is set (TRUE), the hBrowse TT Browse will be immediately repainted after the attribute has been recorded.
The nColor parameter must be given one of the following values:

Value	Meaning

TTB_HEADER:	Header general attribute.
TTB_CELL:	Cell general attribute.
TTB_FOOTER:	Footer general attribute.
The nFrameStyle must be given one of the following values:

Value	Meaning

TTB_FRAME_NONE	No frame.
TTB_FRAME_3DEXT	External frame.
TTB_FRAME_3DINT	Internal Frame.
TTB_FRAME_3D	Alternate 3D Frame.
The nTextStyle must be given one of the following values:

Value	Meaning

TTB_TEXT_NORMAL	no special effect.
TTB_TEXT_3D	3D Text.
TTB_TEXT_SHADOW	Shadowed text.
TTB_TEXT_ITALIC	Italic font.
TTB_TEXT_UNDERLINE	Underline font.
TTB_TEXT_STRIKE	Strike font.
TTB_TEXT_BOLD	Bold font.
Returns

0	Success
1	hBrowse is not a valid TT TBrowse handle.
Example

#define NORMAL_COLOR { RGBColor(0,0,255),
RGBColor(255,255,255) }
#define HILITE_COLOR { RGBColor(255,255,255),
RGBColor(0,255,0) }
#define HEADER_COLOR { RGBColor(255,255,0),
RGBColor(0,0,255) }

RecDVAttributes( hBrowse, "W+/B", TTB_STD,
TTB_TEXT_ITALIC,
NORMAL_COLOR )

RecDVAttributes( hBrowse, "R/N", TTB_FRAME_3D,
OR(TTB_TEXT_SHADOW,TTB_TEXT_BOLD),
HILITE_COLOR )

RecDVAttributes( hBrowse, TTB_HEADER,  TTB_FRAME_3D,
OR(TTB_TEXT_SHADOW,
TTB_TEXT_BOLD), HEADER_COLOR,.T.)


SetWindResizeStyle

SetWindResizeStyle( hWnd, nStyle ) --> ErrorCode

Description

The SetWindResizeStyle function assigns a Resize Style to a given Window.

Parameter	Description

hWnd	Handle of the Control to assign the Resize Style to.
nStyle	New Resize Style. It must be one of the values given below.
The nStyle parameter must be given one of the values given below:

Value	Meaning

X1RIGHT	The Upper Left Corner of the Control is horizontally attached to the right border of its parent.
Y1DOWN	The Upper Left Corner of the Control is vertically attached to the bottom border of its parent.
X2RIGHT	The Lower Right Corner of the Control is horizontally attached to the right border of its parent.
Y2DOWN	The Lower Right Corner of the Control is vertically attached to the bottom border of its parent.
Returns

0	Successful.
1	hWnd is not a valid Control Handle.


Sample Code - Overview
Overview

This sample code shows how to create a TT TBrowse, and how to drive it through a Dolce Vita event loop, with mouse support.

Only the minimum events have been handled in the code provided here, so as to make it as small as possible.


Source code

#include "dolce.ch"
#include "DVBrowse.ch"

#define NORMAL_COLOR { RGBColor(0,0,255), RGBColor(255,255,255) }
#define HILITE_COLOR { RGBColor(255,255,255), RGBColor(0,255,0) }
#define HEADER_COLOR { RGBColor(255,255,0), RGBColor(0,0,255) }

function ttsimple()
local hSess,hWnd,nSpacing,nGrid
local hBrowse, oTB, aRect:= {10,10,600,400}
local hTarget:=0, nMsg:=0, wParam:=0, Xp:=0, Yp:=0, cCmd:=""
local n, aTmp, nKey, lStable:=.F.
local C,L

InitExec("TTS")

// Set the Tbrowse object
setcursor(0)
setcolor("W+/B,R/N")
cls
use TEST
SET deleted ON
GO TOP

oTB := TBrowseDB(2,3,23,74)

// IMPORTANT: Set the TBrowse row and column separators.
// This is required by Dolce Vita.
// Please take a look at the PRG file to get the correct values for
// the separators.
oTB:HeadSep := "ÂÄ"
oTB:ColSep:= "³"
oTB:FootSep := "ÁÄ"

// Add one column for each field
aTmp:=dbstruct()
for n := 1 to Fcount()
oTB:addColumn(TBColumnNew(FieldName(n), FieldBlock(FieldName(n))))
next

// Open a Dialog Box
hWnd:=CreateDlg("Simple TTBrowse",aRect,_OR(WS_CAPTION,WS_SYSMENU,
WS_THICKFRAME,WS_MINIMIZEBOX,WS_MAXIMIZEBOX))

// Setting the Icon of the new Dialog Box.
SetWindIcon(hWnd,LoadIcon("TTBROWSE.ICO"))

// Create the TT TBrowse
nSpacing := 0
nGrid := TTB_GRID_DOT

hBrowse := CreateBrowse( hWnd, aRect, 2,3,23,74,"Arial", nSpacing, nGrid)

// Make the TT TBrowse self resizeable
SetWindResizeStyle(hBrowse,_or(X2RIGHT,Y2DOWN))

// Recording an individual attribute, using the "R/N"
// Clipper color strings.
RecDVAttributes( hBrowse, "R/N",TTB_FRAME_3D,
_or(TTB_TEXT_SHADOW,TTB_TEXT_BOLD), HILITE_COLOR )

// Recording a general attribute (TTB_CELL: Cell attribute).
// The Cells will be painted with no frame (TTB_NOFRAME)
// and the text will be displayed using an italic font.
// The default Cell aspect will be overridden for those which
// are given a "R/N" Clipper color.
RecDVAttributes( hBrowse, TTB_CELL, TTB_NOFRAME, TTB_TEXT_ITALIC,
NORMAL_COLOR )

// Recording a general attribute (TTB_HEADER: Header attribute).
// The Header will be painted with a simple 3D frame (TTB_FRAME_3D)
// and the title will make use of a bold font, with a show effect.
// (TTB_TEXT_BOLD, TTB_TEXT_SHADOW).
RecDVAttributes( hBrowse, TTB_HEADER,TTB_FRAME_3D,
_OR(TTB_TEXT_SHADOW,TTB_TEXT_BOLD),
HEADER_COLOR,.T.)

// Initialiazing the current Color and Row.
C := 0
L := 0

// Main event loop
do while (.T.)

if GetMessage(@hTarget, @nMsg, @wParam, @Xp, @Yp, @cCmd)==0

if !lStable
if oTB:stabilize()
lStable:=.T.
endif
endif

ReleaseSlice()

else

if nMsg==WM_SYSCOMMAND // System menu -> Close
if wParam==SC_CLOSE
exit
endif
elseif hTarget == hBrowse // Browse events

// Minimum event handling
DO CASE

CASE nMsg == WM_KEYDOWN

nkey := wParam

do case

case nKey == VK_LEFT
oTB:Left()
lStable := .F.

case nKey == VK_RIGHT
oTB:Right()
lStable := .F.

case nKey == VK_DOWN
oTB:Down()
lStable := .F.

case nKey == VK_UP
oTB:Up()
lStable := .F.

case nKey == VK_NEXT
oTB:PageDown()
lStable := .F.

case nKey == VK_PRIOR
oTB:PageUp()
lStable := .F.

case nKey == VK_ESCAPE
exit

otherwise
tone(880,1)
endcase

// Change cursor position when left clicking
CASE nMsg == WM_LBUTTONDOWN

// Change cursor pos on left click
oTB:rowPos := L+1
oTB:colPos := C+oTB:LeftVisible()
oTB:RefreshAll()
lStable:=.F.

// Record actual position when the mouse move
CASE nMsg == WM_MOUSEMOVE

// Record Last mouse pos:
// GetXParam(3) gives the TBrowse column pointed by the cursor.
// GetXParam(4) gives the TBrowse row pointed by the cursor.
C:=GetXParam(3)
L:=GetXParam(4)

ENDCASE

endif

endif

enddo

use

EndExec()	// DVServer will clean up automatically all the Windows
// objects

return (NIL)


How to contact Fiesta Publishing, Inc.

  Feel free to contact us to get any additional information about The Dolce Vita True Type TBrowse, as well as about the future versions of Dolce Vita.

Fiesta Publishing, Inc.

1402 E. Las Olas Blvd., Suite 107,
Fort Lauderdale FL 33301-1416
USA

Phone 	(305) 728 8183
Fax 	(305) 523 2921
BBS 	(305) 525 0933