#include "fivewin.ch"
#include "xbrowse.ch"
#define DT_WORDBREAK 0x00000010
#define DT_CALCRECT 0x00000400
function main()
local oMFont1 := UD_MFont(), oBrw, oDlg, aBrwData, nCnt1, bInit
CreateDbf()
use taxcode new exclusive
aBrwData := { ;
{ "taxcode", " Code " }, ;
{ "perc" , " Tax Rate" }, ;
{ "desc" , " Description" } ;
}
DEFINE DIALOG oDlg RESOURCE "xHelp" TITLE "Select" FONT oMFont1
REDEFINE COLUMN XBROWSE oBrw ID 13 OF oDlg ;
COLOR CLR_BLACK, CLR_YELLOW ;
FONT oMFont1 LINES
with object oBrw
:l2007 := .f.
:lRecordSelector := .f.
:nMarqueeStyle := MARQSTYLE_HIGHLROW
:bClrHeader := { || { CLR_YELLOW, CLR_BLUE } }
:bClrSelFocus := { || { CLR_WHITE, CLR_CYAN } }
:lAllowColSwapping := .f.
:lAllowColHiding := .f.
end
oBrw:blDblClick := { || oDlg:End() }
oBrw:lHScroll := .t.
oBrw:nStretchCol := STRETCHCOL_WIDEST //2
oBrw:bKeyDown := { | nKey | IF( GetKeyState( VK_RETURN ), ;
( ;
oDlg:End() ;
), ;
nil ;
) }
FOR nCnt1 := 1 TO LEN( aBrwData )
ADD COLUMN TO oBrw ;
DATA &( "{||" + aBrwData[ nCnt1, 1 ] + "}" ) ;
HEADER aBrwData[ nCnt1, 2 ]
NEXT
oBrw:nFreeze := nCnt1 - 1
bInit := <||
oBrw:aCols[3]:cDataType := "M"
oBrw:nRowHeight := XbrColMaxHeight( oBrw:aCols[3] )
oBrw:SetFocus()
>
ACTIVATE DIALOG oDlg CENTERED ;
ON INIT eval(bInit)
oMFont1 :End()
return nil
//----------------------------------------------------------------------
function CreateDbf()
local aCodes := { ;
{"TX ","6%","Purchases with GST incurred at 6% and directly attributable to taxable supplies."}, ;
{"IM ","6%","GST incurred for import of goods."}, ;
{"IS ","0%","Imports under special scheme with no GST incurred (e.g. Approved Trader Scheme, ATMS Scheme)."}, ;
{"BL ","6%","Purchases with GST incurred but not claimable (Disallowance of Input Tax) (e.g. medical expenses for staff)."}, ;
{"NR ","0%","Purchase from non GST-registered supplier with no GST incurred."}, ;
{"ZP ","0%","Purchase from GST-registered supplier with no GST incurred. (e.g. supplier provides transportation of goods that qualify as international services)."}, ;
{"EP ","0%","Purchases exempted from GST. E.g. purchase of residential property or financial services."}, ;
{"OP ","0%","Purchase transactions which is out of the scope of GST legislation (e.g. purchase of goods overseas)."}, ;
{"TX-E43","6%","GST incurred directly attributable to incidental exempt supplies."}, ;
{"TX-N43","6%","GST incurred directly attributable to non-incidental exempt supplies."}, ;
{"TX-RE ","6%","GST incurred that is not directly attributable to taxable or exempt supplies."}, ;
{"GP ","0%","Purchase transactions which disregarded under GST legislation (e.g. purchase within GST group registration)"}, ;
{"AJP ","6%","Any adjustment made to Input Tax e.g.: Bad Debt Relief & other input tax adjustment."} ;
}
local aRec
if !file("taxcode.dbf")
dbCreate("taxcode", { {"taxcode", "c", 6, 0}, ;
{"perc" , "c", 2, 0}, ;
{"desc" , "m",10, 0} ;
})
use taxcode new exclusive
for each aRec in aCodes
append blank
field->taxcode := aRec[1]
field->perc := aRec[2]
field->desc := aRec[3]
next
use
endif
return nil
//----------------------------------------------------------------------
function XbrColMaxHeight( oCol )
local oBrw, hDC
local nLeft, nHeight, nRight, nWidth
local cData, oFont, aRect
local uSave, nMaxHeight, nCurrentHeight
oBrw := oCol:oBrw
nMaxHeight := 0
nLeft := oCol:nDisplayCol
nRight := Min( nLeft + oCol:nWidth, oBrw:BrwWidth() - 5 )
if nRight - nLeft < 10
return oBrw:nRowHeight
endif
hDC := oBrw:GetDC()
oFont := If( ValType( oCol:oDataFont ) == 'B', Eval( oCol:oDataFont ), oCol:oDataFont )
oFont:Activate( hDC )
aRect := oBrw:DataRect():aRect
aRect[ 2 ] := nLeft
aRect[ 4 ] := nRight
uSave := oBrw:BookMark
oBrw:GoTop()
REPEAT
cData := Trim( cValToChar( Eval( oCol:bStrData ) ) )
if ! Empty( cData )
nCurrentHeight := DrawTextEx( hDC, cData, aRect, nOr( DT_CALCRECT, DT_WORDBREAK ) )
nMaxHeight := Max( nCurrentHeight, nMaxHeight )
*FWLOG hDC, cData, aRect, nMaxHeight
endif
// not handling bitmap width, indent, if any.
UNTIL oBrw:Skip( 1 ) != 1
oBrw:BookMark := uSave
return nMaxHeight
//----------------------------------------------------------------------
FUNC UD_MFont()
LOCAL oFont
LOCAL nWidth, ;
nHeight, ;
lFromUser, ;
lBold, ;
nEscapement, ;
nOrientation, ;
nWeight, ;
lItalic, ;
lUnderline, ;
lStrikeOut, ;
nCharSet, ;
nOutPrecision, ;
nClipPrecision, ;
nQuality, ;
oDevice
local cFaceName := "SYSTEM_FIXED_FONT"
nWidth := 0
nHeight := -10
lFromUser := .f.
lBold := .t.
nEscapement := 0
nOrientation := 0
nWeight := 500
lItalic := .f.
lUnderline := .f.
lStrikeOut := .f.
nCharSet := 1
nOutPrecision := 3
nClipPrecision := 2
nQuality := 0
oFont := TFONT():NEW( cFaceName, ;
nWidth, ;
nHeight, ;
lFromUser, ;
lBold, ;
nEscapement, ;
nOrientation, ;
nWeight, ;
lItalic, ;
lUnderline, ;
lStrikeOut, ;
nCharSet, ;
nOutPrecision, ;
nClipPrecision, ;
nQuality ;
)
RETURN oFont