2008-12-15 08:07 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
* harbour/contrib/gtwvg/wvtwin.ch
+ Added more constants.
* harbour/contrib/gtwvg/wvgwin.c
+ Added functions to manipulate ChooseFont() WINAPI.
* harbour/contrib/gtwvg/wvgsysw.prg
+ Implemented WvgFontDialog(), WvgFon() Xbase++ compatible classes.
* harbour/contrib/gtwvg/tests/demoxbp.prg
+ Incorporated WvgFontDialog() and WvgFont() functionality.
;IMPORTANT: XBase++ documentation describes that WvgFontDialog()
cannot be opened in modeless state under Windows.
Additionally it also states that its event blocks cannot
be implemented in Windows. It is possible only in OS/2.
But Harbour implementation of WvgFontDialog() has
provided this important functionality in Windows also.
You can :display the font dialog in modeless state as
well as :activate* codeblocks also get fired.
This commit is contained in:
@@ -8,6 +8,29 @@
|
||||
2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org)
|
||||
*/
|
||||
|
||||
2008-12-15 08:07 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
|
||||
* harbour/contrib/gtwvg/wvtwin.ch
|
||||
+ Added more constants.
|
||||
|
||||
* harbour/contrib/gtwvg/wvgwin.c
|
||||
+ Added functions to manipulate ChooseFont() WINAPI.
|
||||
|
||||
* harbour/contrib/gtwvg/wvgsysw.prg
|
||||
+ Implemented WvgFontDialog(), WvgFon() Xbase++ compatible classes.
|
||||
|
||||
* harbour/contrib/gtwvg/tests/demoxbp.prg
|
||||
+ Incorporated WvgFontDialog() and WvgFont() functionality.
|
||||
|
||||
;IMPORTANT: XBase++ documentation describes that WvgFontDialog()
|
||||
cannot be opened in modeless state under Windows.
|
||||
Additionally it also states that its event blocks cannot
|
||||
be implemented in Windows. It is possible only in OS/2.
|
||||
|
||||
But Harbour implementation of WvgFontDialog() has
|
||||
provided this important functionality in Windows also.
|
||||
You can :display the font dialog in modeless state as
|
||||
well as :activate* codeblocks also get fired.
|
||||
|
||||
2008-12-12 12:10 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
|
||||
* harbour/contrib/gtwvg/wvtwin.ch
|
||||
+ Added more constants.
|
||||
|
||||
@@ -154,23 +154,28 @@ FUNCTION Main()
|
||||
oListBox:setColorFG( RGB( 218,61,34 ) )
|
||||
//oListBox:setColorBG( RGB( 250,244,182 ) )
|
||||
|
||||
aadd( aParts, 'XbpDialog' )
|
||||
aadd( aParts, 'XbpMenuBar' )
|
||||
aadd( aParts, 'XbpToolBar' )
|
||||
aadd( aParts, 'XbpStatusBar' )
|
||||
aadd( aParts, 'XbpStatic' )
|
||||
aadd( aParts, 'XbpTreeView' )
|
||||
aadd( aParts, 'XbpActiveX' )
|
||||
aadd( aParts, 'XbpListBox' )
|
||||
aadd( aParts, 'XbpPushButton' )
|
||||
aadd( aParts, 'XbpCheckBox' )
|
||||
aadd( aParts, 'XbpRadioButton')
|
||||
aadd( aParts, 'Xbp3State' )
|
||||
aadd( aParts, 'XbpSLE' )
|
||||
aadd( aParts, 'XbpMLE' )
|
||||
aadd( aParts, 'XbpHTMLViewer' )
|
||||
aadd( aParts, '-------------' )
|
||||
aadd( aParts, 'DataRef' )
|
||||
aadd( aParts, 'XbpDialog' )
|
||||
aadd( aParts, 'XbpMenuBar' )
|
||||
aadd( aParts, 'XbpToolBar' )
|
||||
aadd( aParts, 'XbpToolBarButton' )
|
||||
aadd( aParts, 'XbpStatusBar' )
|
||||
aadd( aParts, 'XbpStatic' )
|
||||
aadd( aParts, 'XbpTreeView' )
|
||||
aadd( aParts, 'XbpTreeViewItem' )
|
||||
aadd( aParts, 'XbpActiveXControl')
|
||||
aadd( aParts, 'XbpListBox' )
|
||||
aadd( aParts, 'XbpPushButton' )
|
||||
aadd( aParts, 'XbpCheckBox' )
|
||||
aadd( aParts, 'XbpRadioButton' )
|
||||
aadd( aParts, 'Xbp3State' )
|
||||
aadd( aParts, 'XbpSLE' )
|
||||
aadd( aParts, 'XbpMLE' )
|
||||
aadd( aParts, 'XbpHTMLViewer' )
|
||||
aadd( aParts, 'XbpSysWindow' )
|
||||
aadd( aParts, 'XbpFontDialog' )
|
||||
aadd( aParts, 'XbpFont' )
|
||||
aadd( aParts, '-------------' )
|
||||
aadd( aParts, 'DataRef' )
|
||||
|
||||
aeval( aParts, {|e| oListBox:addItem( e ) } )
|
||||
oListBox:itemSelected := {|| Win_MessageBox( , oListBox:getCurItem() ) }
|
||||
@@ -242,6 +247,7 @@ FUNCTION Main()
|
||||
oTBar:buttonClick := {|oBtn| IF( oBtn:caption == 'Hide' , oStatic:hide(), nil ),;
|
||||
IF( oBtn:caption == 'Show' , oStatic:show(), nil ),;
|
||||
IF( oBtn:caption == 'Tools', oStatic2:show():toFront(), nil ),;
|
||||
IF( oBtn:caption == 'Font Dlg', ExeFontDialog( oCrt ), nil ),;
|
||||
IF( oBtn:caption $ 'Hide,Show', oCrt:sendMessage( WM_SIZE, 0, 0 ), NIL ),;
|
||||
oPanel2:caption := "Button [ " + oBtn:caption + " ] clicked!" }
|
||||
oCrt:resize := {|| ResizeDialog( oCrt, oTBar, oSBar, oStatic, oCom, oTree, oAddr ) }
|
||||
@@ -260,6 +266,17 @@ FUNCTION Main()
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
STATIC FUNCTION HB_GTSYS()
|
||||
|
||||
REQUEST HB_GT_GUI_DEFAULT
|
||||
REQUEST HB_GT_WVG
|
||||
REQUEST HB_GT_WVT
|
||||
REQUEST HB_GT_WGU
|
||||
|
||||
RETURN NIL
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
STATIC FUNCTION ResizeDialog( oCrt, oTBar, oSBar, oStatic, oCom, oTree, oAddr )
|
||||
LOCAL aCrt, aTBar, aSBar, aStatic, aCom, aTree
|
||||
LOCAL nH, nT
|
||||
@@ -330,6 +347,9 @@ Static Function ActiveXBuildMenu( oCrt, oStatic, oStatic2 )
|
||||
oSubMenu:addItem( { "~Hide or Show Left Panel" , {|| IF( oStatic:isVisible, ;
|
||||
oStatic:hide(), oStatic:show() ), oCrt:sendMessage( WM_SIZE,0,0 ) } } )
|
||||
oSubMenu:addItem( { "~Show My Panel" , {|| oStatic2:show() } } )
|
||||
oSubMenu:addItem()
|
||||
oSubMenu:addItem( { "~Font Dialog" , {|| ExeFontDialog( oCrt ) } } )
|
||||
|
||||
oMenuBar:addItem( { oSubMenu, NIL } )
|
||||
|
||||
Return nil
|
||||
@@ -354,7 +374,7 @@ STATIC FUNCTION ActiveXBuildToolBar( oCrt )
|
||||
|
||||
oTBar:addItem( "New" , 'c:\harbour\contrib\gtwvg\tests\v_new.bmp' )
|
||||
oTBar:addItem( "Select" , 'c:\harbour\contrib\gtwvg\tests\v_selct1.bmp' )
|
||||
oTBar:addItem( "Calendar" , 'c:\harbour\contrib\gtwvg\tests\v_calend.bmp' )
|
||||
oTBar:addItem( "Font Dlg" , 'c:\harbour\contrib\gtwvg\tests\v_calend.bmp' )
|
||||
oTBar:addItem( "Tools" , 'c:\harbour\contrib\gtwvg\tests\v_lock.bmp' )
|
||||
oTBar:addItem( "Index" , 'c:\harbour\contrib\gtwvg\tests\v_index.bmp' )
|
||||
oTBar:addItem( "Show" , 'c:\harbour\contrib\gtwvg\tests\v_clclt.bmp' )
|
||||
@@ -396,14 +416,35 @@ Static Function MyFunction( nMode )
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
Function HB_GTSYS()
|
||||
STATIC FUNCTION ExeFontDialog( oCrt )
|
||||
LOCAL oFontDlg, oWvgFont
|
||||
|
||||
REQUEST HB_GT_GUI_DEFAULT
|
||||
REQUEST HB_GT_WVG
|
||||
REQUEST HB_GT_WVT
|
||||
REQUEST HB_GT_WGU
|
||||
STATIC nMode := 0
|
||||
|
||||
Return NIL
|
||||
oFontDlg := WvgFontDialog():new( oCrt )
|
||||
|
||||
oFontDlg:title := 'Select a Screen Font'
|
||||
oFontDlg:aPos := { 150,150 }
|
||||
oFontDlg:buttonApply := .t.
|
||||
oFontDlg:activateApply := {|| NIL }
|
||||
oFontDlg:familyName := "Courier New"
|
||||
oFontDlg:strikeout := .T.
|
||||
oFontDlg:underscore := .f.
|
||||
//oFontDlg:activateOk := {|| Win_MessageBox( , 'activateOK Event Handelled in Windows!' ) }
|
||||
oFontDlg:nominalPointSize := 12
|
||||
|
||||
//oFontDlg:size := .f.
|
||||
//oFontDlg:style := .f.
|
||||
|
||||
oFontDlg:create()
|
||||
// Every 2nd FontDialog will be MODAL
|
||||
oWvgFont := oFontDlg:display( ++nMode % 2 )
|
||||
oFontDlg:destroy()
|
||||
|
||||
#if 0
|
||||
hb_ToOutDebug( '%s %i', oWvgFont:compoundName, oWvgFont:nominalPointSize )
|
||||
#endif
|
||||
RETURN nil
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
|
||||
@@ -92,7 +92,6 @@ CLASS WvgSysWindow INHERIT WvgPartHandler
|
||||
|
||||
METHOD currentPos()
|
||||
METHOD currentSize()
|
||||
METHOD WndProc()
|
||||
|
||||
DATA aPos INIT { 0, 0 }
|
||||
|
||||
@@ -187,21 +186,29 @@ METHOD show() CLASS WvgSysWindow
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
METHOD setPos() CLASS WvgSysWindow
|
||||
METHOD setPos( aPos ) CLASS WvgSysWindow
|
||||
|
||||
Win_SetWindowPosition( ::hWnd, aPos[ 1 ], aPos[ 2 ], .f. )
|
||||
|
||||
RETURN Self
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
METHOD currentPos() CLASS WvgSysWindow
|
||||
LOCAL aRect
|
||||
|
||||
RETURN Self
|
||||
aRect := Win_GetWindowRect( ::hWnd )
|
||||
|
||||
RETURN { aRect[ 1 ], aRect[ 2 ] }
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
METHOD currentSize() CLASS WvgSysWindow
|
||||
LOCAL aRect
|
||||
|
||||
RETURN Self
|
||||
aRect := Win_GetClientRect( ::hWnd )
|
||||
|
||||
RETURN { aRect[ 3 ] - aRect[ 1 ], aRect[ 4 ] - aRect[ 2 ] }
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
//----------------------------------------------------------------------//
|
||||
@@ -215,36 +222,48 @@ METHOD currentSize() CLASS WvgSysWindow
|
||||
|
||||
CLASS WvgFontDialog INHERIT WvgSysWindow
|
||||
|
||||
DATA bitmapOnly INIT .F.
|
||||
DATA buttonApply INIT .F.
|
||||
DATA buttonCancel INIT .T.
|
||||
DATA buttonHelp INIT .F.
|
||||
DATA buttonOk INIT .T.
|
||||
DATA buttonReset INIT .F.
|
||||
DATA displayFilter INIT .T.
|
||||
DATA familyName INIT " "
|
||||
DATA fixedOnly INIT .F.
|
||||
DATA name INIT .T.
|
||||
DATA nominalPointSize INIT 10
|
||||
DATA outLine INIT .T.
|
||||
DATA previewBGClr INIT RGB( 255,255,255 )
|
||||
DATA previewFGClr INIT RGB( 0,0,0 )
|
||||
DATA previewString INIT ' '
|
||||
DATA printerFilter INIT .T.
|
||||
DATA printerPS INIT NIL
|
||||
DATA proportionalOnly INIT .T.
|
||||
DATA screenPS INIT NIL
|
||||
DATA size INIT .T.
|
||||
DATA strikeOut INIT .T.
|
||||
DATA style INIT .T.
|
||||
DATA synthesizeFonts INIT .T.
|
||||
DATA title INIT 'Font Dialog'
|
||||
DATA underscore INIT .T.
|
||||
DATA vectorOnly INIT .F.
|
||||
DATA vectorSizes INIT {}
|
||||
DATA viewPrinterFonts INIT .F.
|
||||
DATA viewScreenFonts INIT .T.
|
||||
// Appearance
|
||||
//
|
||||
DATA title INIT ''
|
||||
DATA buttonApply INIT .F.
|
||||
DATA buttonCancel INIT .T.
|
||||
DATA buttonHelp INIT .F.
|
||||
DATA buttonOk INIT .T.
|
||||
DATA buttonReset INIT .F.
|
||||
DATA strikeOut INIT .T.
|
||||
DATA underscore INIT .T.
|
||||
//
|
||||
DATA name INIT .T.
|
||||
DATA style INIT .T.
|
||||
DATA size INIT .T.
|
||||
//
|
||||
DATA displayFilter INIT .T.
|
||||
DATA printerFilter INIT .T.
|
||||
|
||||
DATA familyName INIT " "
|
||||
DATA nominalPointSize INIT 0
|
||||
|
||||
DATA bitmapOnly INIT .F.
|
||||
DATA fixedOnly INIT .F.
|
||||
DATA proportionalOnly INIT .T.
|
||||
|
||||
|
||||
DATA outLine INIT .T.
|
||||
DATA previewBGClr INIT RGB( 255,255,255 )
|
||||
DATA previewFGClr INIT RGB( 0,0,0 )
|
||||
DATA previewString INIT ' '
|
||||
DATA printerPS INIT NIL
|
||||
DATA screenPS INIT NIL
|
||||
|
||||
DATA synthesizeFonts INIT .T.
|
||||
|
||||
DATA vectorOnly INIT .F.
|
||||
DATA vectorSizes INIT {}
|
||||
|
||||
DATA viewPrinterFonts INIT .F.
|
||||
DATA viewScreenFonts INIT .T.
|
||||
|
||||
METHOD new()
|
||||
METHOD create()
|
||||
METHOD destroy()
|
||||
METHOD display( nMode )
|
||||
@@ -265,13 +284,346 @@ CLASS WvgFontDialog INHERIT WvgSysWindow
|
||||
ACCESS activateReset INLINE ::sl_activateReset
|
||||
ASSIGN activateReset( bBlock ) INLINE ::sl_activateReset := bBlock
|
||||
|
||||
DATA hFont
|
||||
DATA oScreenPS
|
||||
DATA oPrinterPS
|
||||
DATA aPos INIT { 0, 0 }
|
||||
DATA ok INIT .f.
|
||||
|
||||
METHOD WndProc()
|
||||
METHOD GetWvgFont() PROTECTED
|
||||
|
||||
ENDCLASS
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
METHOD new( oParent, oOwner, oScreenPS, oPrinterPS, aPos ) CLASS WvgFontDialog
|
||||
|
||||
DEFAULT oParent TO ::oParent
|
||||
DEFAULT oOwner TO ::oOwner
|
||||
DEFAULT oScreenPS TO ::oScreenPS
|
||||
DEFAULT oPrinterPS TO ::oPrinterPS
|
||||
DEFAULT aPos TO ::aPos
|
||||
|
||||
::oParent := oParent
|
||||
::oOwner := oOwner
|
||||
::oScreenPS := oScreenPS
|
||||
::oPrinterPS := oPrinterPS
|
||||
::aPos := aPos
|
||||
|
||||
::WvgSysWindow:new( oParent, oOwner )
|
||||
|
||||
RETURN Self
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
METHOD create( oParent, oOwner, oScreenPS, oPrinterPS, aPos ) CLASS WvgFontDialog
|
||||
|
||||
DEFAULT oParent TO ::oParent
|
||||
DEFAULT oOwner TO ::oOwner
|
||||
DEFAULT oScreenPS TO ::oScreenPS
|
||||
DEFAULT oPrinterPS TO ::oPrinterPS
|
||||
DEFAULT aPos TO ::aPos
|
||||
|
||||
::oParent := oParent
|
||||
::oOwner := oOwner
|
||||
::oScreenPS := oScreenPS
|
||||
::oPrinterPS := oPrinterPS
|
||||
::aPos := aPos
|
||||
|
||||
IF ::viewPrinterFonts .and. ::oPrinterPS == NIL
|
||||
::viewPrinterFonts := .f.
|
||||
ENDIF
|
||||
IF ( ! ::viewScreenFonts .and. ! ::viewPrinterFonts )
|
||||
::viewScreenFonts := .t.
|
||||
ENDIF
|
||||
|
||||
::WvgSysWindow:create( oParent, oOwner )
|
||||
|
||||
::nWndProc := hb_AsCallBack( 'WNDPROC', Self )
|
||||
|
||||
RETURN Self
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
METHOD wndProc( hWnd, nMessage, nwParam, nlParam ) CLASS WvgFontDialog
|
||||
LOCAL aRect, nL, nH
|
||||
|
||||
HB_SYMBOL_UNUSED( nlParam )
|
||||
|
||||
DO CASE
|
||||
|
||||
CASE nMessage == WM_INITDIALOG
|
||||
::hWnd := hWnd
|
||||
|
||||
IF !empty( ::title )
|
||||
Win_setWindowText( ::hWnd, ::title )
|
||||
ENDIF
|
||||
IF !( ::buttonCancel )
|
||||
Win_EnableWindow( Win_GetDlgItem( ::hWnd,IDCANCEL ), .f. )
|
||||
ENDIF
|
||||
IF !( ::buttonApply )
|
||||
Win_EnableWindow( Win_GetDlgItem( ::hWnd,1026 ), .f. )
|
||||
ENDIF
|
||||
IF !( ::buttonHelp )
|
||||
Win_EnableWindow( Win_GetDlgItem( ::hWnd,1038 ), .f. )
|
||||
ENDIF
|
||||
IF !( ::strikeOut )
|
||||
Win_EnableWindow( Win_GetDlgItem( ::hWnd,1040 ), .f. )
|
||||
ENDIF
|
||||
IF !( ::underscore )
|
||||
Win_EnableWindow( Win_GetDlgItem( ::hWnd,1041 ), .f. )
|
||||
ENDIF
|
||||
IF !( ::name )
|
||||
Win_EnableWindow( Win_GetDlgItem( ::hWnd,1136 ), .f. )
|
||||
ENDIF
|
||||
IF !( ::style )
|
||||
Win_EnableWindow( Win_GetDlgItem( ::hWnd,1137 ), .f. )
|
||||
ENDIF
|
||||
IF !( ::size )
|
||||
Win_EnableWindow( Win_GetDlgItem( ::hWnd,1138 ), .f. )
|
||||
ENDIF
|
||||
|
||||
IF ::aPos[ 1 ] > 0 .OR. ::aPos[ 2 ] > 0
|
||||
aRect := Win_GetWindowRect( ::hWnd )
|
||||
Win_MoveWindow( ::hWnd, ::aPos[ 1 ], ::aPos[ 2 ], aRect[3]-aRect[1], aRect[4]-aRect[2], .f. )
|
||||
ENDIF
|
||||
|
||||
RETURN 1
|
||||
|
||||
CASE nMessage == WM_COMMAND
|
||||
nL := Win_LoWord( nwParam )
|
||||
nH := Win_HiWord( nwParam )
|
||||
|
||||
DO CASE
|
||||
|
||||
CASE nL == IDOK
|
||||
::ok := .t.
|
||||
IF hb_isBlock( ::sl_activateOk )
|
||||
eval( ::sl_activateOk, ::GetWvgFont(), NIL, Self )
|
||||
ENDIF
|
||||
|
||||
CASE nL == IDCANCEL
|
||||
IF hb_isBlock( ::sl_activateCancel )
|
||||
eval( ::sl_activateCancel, NIL, NIL, Self )
|
||||
ENDIF
|
||||
|
||||
CASE nL == 1026
|
||||
IF hb_isBlock( ::sl_activateApply )
|
||||
eval( ::sl_activateApply, ::GetWvgFont(), NIL, Self )
|
||||
ENDIF
|
||||
|
||||
CASE nL == 1038 // Help
|
||||
|
||||
ENDCASE
|
||||
|
||||
ENDCASE
|
||||
|
||||
RETURN 0
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
METHOD display( nMode ) CLASS WvgFontDialog
|
||||
LOCAL hWnd, aInfo
|
||||
|
||||
IF nMode == 0
|
||||
hWnd := ::oParent:hWnd
|
||||
ELSE
|
||||
hWnd := Win_GetDesktopWindow()
|
||||
ENDIF
|
||||
|
||||
::ok := .f.
|
||||
aInfo := Wvg_ChooseFont( hWnd, ::nWndProc, ::familyName, ;
|
||||
::nominalPointSize, ::viewScreenFonts, ::viewPrinterFonts )
|
||||
|
||||
IF !( ::ok )
|
||||
RETURN NIL
|
||||
ENDIF
|
||||
|
||||
RETURN ::GetWvgFont( aInfo )
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
METHOD destroy() CLASS WvgFontDialog
|
||||
|
||||
hb_FreeCallBack( ::nWndProc )
|
||||
|
||||
RETURN Self
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
// Only callable from ::activateOK and ::activateApply
|
||||
//
|
||||
METHOD GetWvgFont( aFont ) CLASS WvgFontDialog
|
||||
LOCAL oWvgFont
|
||||
|
||||
DEFAULT aFont TO Wvg_ChooseFont_GetLogFont( ::hWnd )
|
||||
|
||||
oWvgFont := WvgFont():new()
|
||||
|
||||
oWvgFont:familyName := aFont[ 1 ]
|
||||
oWvgFont:height := aFont[ 2 ]
|
||||
oWvgFont:nominalPointSize := Wvg_HeightToPointSize( /* hdc */, oWvgFont:height )
|
||||
oWvgFont:width := aFont[ 3 ]
|
||||
oWvgFont:bold := aFont[ 4 ] > 400
|
||||
oWvgFont:italic := aFont[ 5 ]
|
||||
oWvgFont:underscore := aFont[ 6 ]
|
||||
oWvgFont:strikeOut := aFont[ 7 ]
|
||||
oWvgFont:codePage := aFont[ 8 ]
|
||||
oWvgFont:setCompoundName( trim( aFont[ 1 ] +' '+ IF( oWvgFont:bold, 'Bold ', '' ) + ;
|
||||
IF( oWvgFont:italic, 'Italic', '' ) ) )
|
||||
oWvgFont:create()
|
||||
|
||||
RETURN oWvgFont
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
//----------------------------------------------------------------------//
|
||||
//----------------------------------------------------------------------//
|
||||
//
|
||||
// Class WvgFont()
|
||||
//
|
||||
//----------------------------------------------------------------------//
|
||||
//----------------------------------------------------------------------//
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
CLASS WvgFont
|
||||
|
||||
DATA hFont
|
||||
DATA oPS
|
||||
DATA hdc
|
||||
|
||||
DATA familyName INIT ''
|
||||
DATA height INIT 0
|
||||
DATA nominalPointSize INIT 0
|
||||
|
||||
DATA width INIT 0
|
||||
DATA widthClass INIT .F.
|
||||
|
||||
DATA bold INIT .F.
|
||||
DATA weightClass INIT FW_DONTCARE
|
||||
|
||||
DATA italic INIT .F.
|
||||
DATA strikeout INIT .F.
|
||||
DATA underscore INIT .F.
|
||||
DATA codePage INIT DEFAULT_CHARSET
|
||||
|
||||
DATA fixed INIT .F.
|
||||
DATA antiAliased INIT .F.
|
||||
|
||||
DATA compoundName INIT ''
|
||||
METHOD setCompoundName( cName ) INLINE ::compoundName := cName
|
||||
|
||||
DATA generic INIT .T.
|
||||
|
||||
DATA baseLine INIT 0 READONLY
|
||||
DATA dbcs INIT .F.
|
||||
DATA kerning INIT .F.
|
||||
DATA mbcs INIT .F.
|
||||
DATA vector INIT .F.
|
||||
DATA outlined INIT .F.
|
||||
|
||||
DATA aFontInfo INIT {}
|
||||
|
||||
METHOD new( oPS )
|
||||
METHOD create( cFontName )
|
||||
METHOD configure( cFontName )
|
||||
METHOD list()
|
||||
METHOD createFont()
|
||||
|
||||
DESTRUCTOR destroy()
|
||||
|
||||
ENDCLASS
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
METHOD new( oPS ) CLASS WvgFont
|
||||
|
||||
DEFAULT oPS TO ::oPS
|
||||
|
||||
::oPS := oPS
|
||||
|
||||
RETURN Self
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
METHOD create( cFontName ) CLASS WvgFont
|
||||
|
||||
DEFAULT cFontName TO ::familyName
|
||||
|
||||
::familyName := cFontName
|
||||
|
||||
::createFont()
|
||||
|
||||
RETURN Self
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
METHOD configure( cFontName ) CLASS WvgFont
|
||||
|
||||
DEFAULT cFontName TO ::familyName
|
||||
|
||||
::familyName := cFontName
|
||||
|
||||
::createFont()
|
||||
|
||||
RETURN Self
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
METHOD destroy() CLASS WvgFont
|
||||
|
||||
IF ::hFont <> NIL
|
||||
Win_DeleteObject( ::hFont )
|
||||
ENDIF
|
||||
|
||||
RETURN Self
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
METHOD list() CLASS WvgFont
|
||||
LOCAL aList := {}
|
||||
|
||||
RETURN aList
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
METHOD createFont() CLASS WvgFont
|
||||
LOCAL aFont
|
||||
|
||||
IF ::hFont <> NIL
|
||||
Win_DeleteObject( ::hFont )
|
||||
::hFont := NIL
|
||||
ENDIF
|
||||
|
||||
IF ::oPS <> NIL
|
||||
::height := Wvg_PointSizeToHeight( ::oPS:hdc, ::nominalPointSize )
|
||||
ENDIF
|
||||
|
||||
::aFontInfo := array( 15 )
|
||||
|
||||
::aFontInfo[ 1 ] := ::familyName
|
||||
::aFontInfo[ 2 ] := ::height
|
||||
::aFontInfo[ 3 ] := ::width
|
||||
::aFontInfo[ 4 ] := IF( ::bold, FW_BOLD, 0 )
|
||||
::aFontInfo[ 5 ] := ::italic
|
||||
::aFontInfo[ 6 ] := ::underscore
|
||||
::aFontInfo[ 7 ] := ::strikeout
|
||||
::aFontInfo[ 8 ] := ::codePage
|
||||
::aFontInfo[ 9 ] := 0
|
||||
::aFontInfo[ 10 ] := 0
|
||||
::aFontInfo[ 11 ] := 0
|
||||
::aFontInfo[ 12 ] := 0
|
||||
::aFontInfo[ 13 ] := DEFAULT_QUALITY
|
||||
::aFontInfo[ 14 ] := NIL
|
||||
|
||||
aFont := Wvg_FontCreate( ::aFontInfo )
|
||||
|
||||
IF empty( aFont[ 1 ] )
|
||||
RETURN nil
|
||||
ENDIF
|
||||
|
||||
::hFont := aFont[ 15 ]
|
||||
::aFontInfo := aFont
|
||||
|
||||
RETURN ::hFont
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
|
||||
@@ -518,6 +518,13 @@ HB_FUNC( WIN_MOVEWINDOW )
|
||||
|
||||
//-------------------------------------------------------------------//
|
||||
|
||||
HB_FUNC( WIN_GETDESKTOPWINDOW )
|
||||
{
|
||||
wvg_rethandle( GetDesktopWindow() );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
HB_FUNC( WIN_SETPARENT )
|
||||
{
|
||||
hb_retnint( ( HB_PTRDIFF ) SetParent( (HWND) ( HB_PTRDIFF ) hb_parnint( 1 ), (HWND) ( HB_PTRDIFF ) hb_parnint( 2 ) ) );
|
||||
@@ -539,6 +546,15 @@ HB_FUNC( WIN_SETFOREGROUNDWINDOW )
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
HB_FUNC( WIN_SETWINDOWTEXT )
|
||||
{
|
||||
LPTSTR text = HB_TCHAR_CONVTO( hb_parc( 2 ) );
|
||||
SetWindowText( wvg_parhwnd( 1 ), text );
|
||||
HB_TCHAR_FREE( text );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
HB_FUNC( WIN_SETWINDOWLONG )
|
||||
{
|
||||
hb_retnl( SetWindowLong( ( HWND ) ( HB_PTRDIFF ) hb_parnint( 1 ), hb_parni( 2 ), hb_parnl( 3 ) ) );
|
||||
@@ -1811,3 +1827,222 @@ HB_FUNC( WIN_SETWINDOWPOSANDSIZE )
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
// WvgFontDialog()
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
PHB_ITEM wvg_logfontTOarray( LPLOGFONT lf, BOOL bEmpty )
|
||||
{
|
||||
PHB_ITEM aFont = hb_itemNew( NULL );
|
||||
hb_arrayNew( aFont, 15 );
|
||||
|
||||
if( bEmpty )
|
||||
{
|
||||
hb_arraySetC( aFont , 1, "" );
|
||||
hb_arraySetNL( aFont, 2, 0 );
|
||||
hb_arraySetNL( aFont, 3, 0 );
|
||||
hb_arraySetNL( aFont, 4, 0 );
|
||||
hb_arraySetL( aFont, 5, 0 );
|
||||
hb_arraySetL( aFont, 6, 0 );
|
||||
hb_arraySetL( aFont, 7, 0 );
|
||||
hb_arraySetNI( aFont, 8, 0 );
|
||||
hb_arraySetNI( aFont, 9, 0 );
|
||||
hb_arraySetNI( aFont, 10, 0 );
|
||||
hb_arraySetNI( aFont, 11, 0 );
|
||||
hb_arraySetNI( aFont, 12, 0 );
|
||||
hb_arraySetNI( aFont, 13, 0 );
|
||||
hb_arraySetNI( aFont, 14, 0 );
|
||||
hb_arraySetNInt( aFont,15, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
char *szFaceName = HB_TCHAR_CONVFROM( lf->lfFaceName );
|
||||
|
||||
hb_arraySetC( aFont, 1, szFaceName );
|
||||
hb_arraySetNL( aFont, 2, lf->lfHeight );
|
||||
hb_arraySetNL( aFont, 3, lf->lfWidth );
|
||||
hb_arraySetNL( aFont, 4, lf->lfWeight );
|
||||
hb_arraySetL( aFont, 5, lf->lfItalic );
|
||||
hb_arraySetL( aFont, 6, lf->lfUnderline );
|
||||
hb_arraySetL( aFont, 7, lf->lfStrikeOut );
|
||||
hb_arraySetNI( aFont, 8, lf->lfCharSet );
|
||||
hb_arraySetNI( aFont, 9, lf->lfEscapement );
|
||||
hb_arraySetNI( aFont, 10, lf->lfOrientation );
|
||||
hb_arraySetNI( aFont, 11, lf->lfOutPrecision );
|
||||
hb_arraySetNI( aFont, 12, lf->lfClipPrecision );
|
||||
hb_arraySetNI( aFont, 13, lf->lfQuality );
|
||||
hb_arraySetNI( aFont, 14, lf->lfPitchAndFamily );
|
||||
|
||||
HB_TCHAR_FREE( szFaceName );
|
||||
}
|
||||
|
||||
return( aFont );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
// Wvg_ChooseFont( hWnd, nWndProc, familyName, nominalPointSize, ;
|
||||
// viewScreenFonts, viewPrinterFonts )
|
||||
//
|
||||
HB_FUNC( WVG_CHOOSEFONT )
|
||||
{
|
||||
CHOOSEFONT cf; // = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
|
||||
LOGFONT lf; // = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
|
||||
DWORD Flags;
|
||||
LONG PointSize = 0;
|
||||
HWND hWnd = wvg_parhwnd( 1 );
|
||||
TCHAR szStyle[ MAX_PATH + 1 ];
|
||||
|
||||
if ( ISCHAR( 3 ) )
|
||||
{
|
||||
HB_TCHAR_CPTO( lf.lfFaceName, hb_parc( 3 ), sizeof( lf.lfFaceName ) - 1 );
|
||||
}
|
||||
if ( ( ! ISNIL( 4 ) ) && hb_parnl( 4 ) )
|
||||
{
|
||||
HDC hdc = GetDC( hWnd );
|
||||
PointSize = -MulDiv( ( LONG ) hb_parnl( 4 ), GetDeviceCaps( hdc, LOGPIXELSY ), 72 ) ;
|
||||
ReleaseDC( hWnd, hdc );
|
||||
}
|
||||
lf.lfHeight = PointSize;
|
||||
lf.lfWidth = 0;
|
||||
lf.lfWeight = 0;
|
||||
lf.lfItalic = 0;
|
||||
lf.lfUnderline = 0;
|
||||
lf.lfStrikeOut = 0;
|
||||
lf.lfCharSet = DEFAULT_CHARSET;
|
||||
lf.lfQuality = DEFAULT_QUALITY;
|
||||
lf.lfPitchAndFamily = FF_DONTCARE;
|
||||
|
||||
Flags = CF_EFFECTS | CF_SHOWHELP | CF_APPLY | CF_INITTOLOGFONTSTRUCT | CF_ENABLEHOOK;
|
||||
|
||||
#if 0
|
||||
Flags = Flags | CF_TTONLY;
|
||||
Flags = Flags | CF_FIXEDPITCHONLY;
|
||||
Flags = Flags | CF_SCALABLEONLY;
|
||||
Flags = Flags | CF_NOVECTORFONTS;
|
||||
Flags = Flags | CF_NOSCRIPTSEL;
|
||||
Flags = Flags | CF_NOSIMULATIONS; // ::synthesizeFonts == .f.
|
||||
#endif
|
||||
|
||||
if( ISLOG( 5 ) && hb_parl( 5 ) )
|
||||
Flags = Flags | CF_SCREENFONTS;
|
||||
if( ISLOG( 6 ) && hb_parl( 6 ) )
|
||||
Flags = Flags | CF_PRINTERFONTS;
|
||||
|
||||
cf.lStructSize = sizeof( CHOOSEFONT );
|
||||
cf.hwndOwner = hWnd;
|
||||
cf.hDC = ( HDC ) NULL; // only when ::oPrinterPS is defined
|
||||
cf.lpLogFont = &lf;
|
||||
cf.iPointSize = PointSize;
|
||||
cf.Flags = Flags;
|
||||
cf.rgbColors = RGB( 0,0,0 );
|
||||
cf.lCustData = 0L;
|
||||
cf.lpfnHook = ( LPCFHOOKPROC ) wvg_parwndproc( 2 );
|
||||
cf.lpTemplateName = ( LPTSTR ) NULL;
|
||||
cf.hInstance = ( HINSTANCE ) NULL;
|
||||
cf.lpszStyle = ( LPTSTR ) szStyle;
|
||||
cf.nFontType = SCREEN_FONTTYPE; // ??
|
||||
cf.nSizeMin = 0;
|
||||
cf.nSizeMax = 0;
|
||||
|
||||
if ( ChooseFont( &cf ) )
|
||||
{
|
||||
PHB_ITEM aFont = wvg_logfontTOarray( &lf, FALSE );
|
||||
PHB_ITEM aInfo = hb_itemNew( NULL );
|
||||
|
||||
hb_arrayNew( aInfo, 4 );
|
||||
hb_arraySetNI( aInfo, 1, cf.iPointSize );
|
||||
hb_arraySetNInt( aInfo, 2, cf.rgbColors );
|
||||
hb_arraySetNI( aInfo, 3, cf.nFontType );
|
||||
{
|
||||
char * szText = HB_TCHAR_CONVFROM( cf.lpszStyle );
|
||||
hb_arraySetC( aInfo, 4, szText );
|
||||
HB_TCHAR_FREE( szText );
|
||||
}
|
||||
hb_arraySet( aFont, 15, aInfo );
|
||||
|
||||
hb_itemReturnRelease( aFont );
|
||||
hb_itemRelease( aInfo );
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
HB_FUNC( WVG_CHOOSEFONT_GETLOGFONT )
|
||||
{
|
||||
LOGFONT lf;
|
||||
PHB_ITEM aFont;
|
||||
|
||||
memset( &lf, 0, sizeof( LOGFONT ) );
|
||||
|
||||
SendMessage( wvg_parhwnd( 1 ), WM_CHOOSEFONT_GETLOGFONT, ( WPARAM ) 0, ( LPARAM ) &lf );
|
||||
|
||||
aFont = wvg_logfontTOarray( &lf, FALSE );
|
||||
|
||||
hb_itemReturnRelease( aFont );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
HB_FUNC( WVG_FONTCREATE )
|
||||
{
|
||||
LOGFONT lf;
|
||||
HFONT hFont;
|
||||
|
||||
memset( &lf, 0, sizeof( LOGFONT ) );
|
||||
|
||||
HB_TCHAR_CPTO( lf.lfFaceName, hb_parc( 1, 1 ), sizeof( lf.lfFaceName ) - 1 );
|
||||
lf.lfHeight = ( LONG ) hb_parnl( 1, 2 );
|
||||
lf.lfWidth = ( LONG ) hb_parnl( 1, 3 );
|
||||
lf.lfWeight = ( LONG ) hb_parnl( 1, 4 );
|
||||
lf.lfItalic = ( BYTE ) hb_parl( 1, 5 );
|
||||
lf.lfUnderline = ( BYTE ) hb_parl( 1, 6 );
|
||||
lf.lfStrikeOut = ( BYTE ) hb_parl( 1, 7 );
|
||||
lf.lfCharSet = ( BYTE ) hb_parni( 1, 8 );
|
||||
lf.lfEscapement = ( BYTE ) hb_parni( 1, 9 );
|
||||
lf.lfOrientation = ( BYTE ) hb_parni( 1,10 );
|
||||
lf.lfOutPrecision = ( BYTE ) hb_parni( 1,11 );
|
||||
lf.lfClipPrecision = ( BYTE ) hb_parni( 1,12 );
|
||||
lf.lfQuality = ( BYTE ) hb_parni( 1,13 );
|
||||
lf.lfPitchAndFamily = ( BYTE ) hb_parni( 1,14 );
|
||||
|
||||
hFont = CreateFontIndirect( &lf );
|
||||
|
||||
if( hFont )
|
||||
{
|
||||
PHB_ITEM aFont = wvg_logfontTOarray( &lf, FALSE );
|
||||
hb_arraySetNInt( aFont, 15, ( HB_PTRDIFF ) hFont );
|
||||
hb_itemReturnRelease( aFont );
|
||||
}
|
||||
else
|
||||
{
|
||||
PHB_ITEM aFont = wvg_logfontTOarray( &lf, TRUE );
|
||||
hb_itemReturnRelease( aFont );
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
// Wvg_PointSizeToHeight( hdc, nPointSize )
|
||||
//
|
||||
HB_FUNC( WVG_POINTSIZETOHEIGHT )
|
||||
{
|
||||
HDC hdc = ISNIL( 1 ) ? GetDC( GetDesktopWindow() ) : wvg_parhdc( 1 );
|
||||
|
||||
hb_retnl( ( LONG ) -MulDiv( ( LONG ) hb_parnl( 2 ), GetDeviceCaps( hdc, LOGPIXELSY ), 72 ) ) ;
|
||||
|
||||
if( ISNIL( 1 ) )
|
||||
ReleaseDC( GetDesktopWindow(), hdc );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
// Wvg_HeightToPointSize( hdc, nHeight )
|
||||
//
|
||||
HB_FUNC( WVG_HEIGHTTOPOINTSIZE )
|
||||
{
|
||||
HDC hdc = ISNIL( 1 ) ? GetDC( GetDesktopWindow() ) : wvg_parhdc( 1 );
|
||||
|
||||
hb_retnl( ( LONG ) -MulDiv( hb_parnl( 2 ), 72, GetDeviceCaps( hdc, LOGPIXELSY ) ) ) ;
|
||||
|
||||
if( ISNIL( 1 ) )
|
||||
ReleaseDC( GetDesktopWindow(), hdc );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user