2009-07-08 16:58 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
* harbour/contrib/hbxbp/xbpbitmap.prg
+ Implemented XbpBitmap() class - mostly working.
* harbour/contrib/hbxbp/xbpfiledialog.prg
! Shifted constants to hbqt.ch
* harbour/contrib/hbxbp/xbpfontdialog.prg
+ Implemented XbpFontDialog() and XbpFont() class with interaction.
* harbour/contrib/hbxbp/xbpstatic.prg
+ Implemented :type == XBPSTATIC_TYPE_BITMAP.
* harbour/contrib/hbxbp/xbpwindow.prg
+ Implemented :setFont( oXbpFont ).
! Enhanced "Attribute" factor of :compoundName to accept bold and italic together.
Integrated with :setFont()
* harbour/contrib/hbxbp/tests/demoxbp.prg
+ Demonstrated XbpFontDialog() and XbpFont() implementation.
1. Click on <MLE> tab-page.
2. Click on <Font Dialog> toolbar icon.
3. Adjust and select a font.
4. See the result in MLE text editor.
+ Demonstrated XbpBitmap() functionality as in Xbase++, code shows up with both compilers.
This commit is contained in:
@@ -17,6 +17,33 @@
|
||||
past entries belonging to author(s): Viktor Szakats.
|
||||
*/
|
||||
|
||||
2009-07-08 16:58 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
|
||||
* harbour/contrib/hbxbp/xbpbitmap.prg
|
||||
+ Implemented XbpBitmap() class - mostly working.
|
||||
|
||||
* harbour/contrib/hbxbp/xbpfiledialog.prg
|
||||
! Shifted constants to hbqt.ch
|
||||
|
||||
* harbour/contrib/hbxbp/xbpfontdialog.prg
|
||||
+ Implemented XbpFontDialog() and XbpFont() class with interaction.
|
||||
|
||||
* harbour/contrib/hbxbp/xbpstatic.prg
|
||||
+ Implemented :type == XBPSTATIC_TYPE_BITMAP.
|
||||
|
||||
* harbour/contrib/hbxbp/xbpwindow.prg
|
||||
+ Implemented :setFont( oXbpFont ).
|
||||
! Enhanced "Attribute" factor of :compoundName to accept bold and italic together.
|
||||
Integrated with :setFont()
|
||||
|
||||
* harbour/contrib/hbxbp/tests/demoxbp.prg
|
||||
+ Demonstrated XbpFontDialog() and XbpFont() implementation.
|
||||
1. Click on <MLE> tab-page.
|
||||
2. Click on <Font Dialog> toolbar icon.
|
||||
3. Adjust and select a font.
|
||||
4. See the result in MLE text editor.
|
||||
|
||||
+ Demonstrated XbpBitmap() functionality as in Xbase++, code shows up with both compilers.
|
||||
|
||||
2009-07-08 16:50 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
|
||||
* harbour/contrib/hbqt/hbqt.ch
|
||||
|
||||
|
||||
@@ -68,6 +68,8 @@
|
||||
#define TAB_4 4
|
||||
#define TAB_5 5
|
||||
|
||||
STATIC oMLE /* Change Font elsewhere */
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
PROCEDURE Main()
|
||||
@@ -138,7 +140,7 @@ PROCEDURE BuildADialog()
|
||||
Build_SLEs( oDa )
|
||||
|
||||
/* Install Multi-Line Edit */
|
||||
Build_MLE( aTabs[ 2 ] )
|
||||
oMLE := Build_MLE( aTabs[ 2 ] )
|
||||
|
||||
/* Install ScrollBar */
|
||||
Build_ScrollBar( aTabs[ 5 ] )
|
||||
@@ -158,8 +160,7 @@ PROCEDURE BuildADialog()
|
||||
/* Build HTML Viewer */
|
||||
oHtm := Build_HTMLViewer( aTabs[ TAB_1 ] )
|
||||
|
||||
/* Gather Font INformation */
|
||||
Build_Font( oDlg )
|
||||
|
||||
|
||||
/* Present the dialog on the screen */
|
||||
oDlg:Show()
|
||||
@@ -191,10 +192,11 @@ PROCEDURE AppSys()
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
#ifdef __XPP__
|
||||
FUNCTION Hb_OutDebug( cStr );RETURN nil
|
||||
FUNCTION Hb_Symbol_Unused();RETURN nil
|
||||
FUNCTION Hb_NtoS( n );RETURN ltrim( str( n ) )
|
||||
FUNCTION Hb_ThreadStart();RETURN nil
|
||||
FUNCTION Hb_OutDebug( cStr ) ; RETURN nil
|
||||
FUNCTION Hb_Symbol_Unused() ; RETURN nil
|
||||
FUNCTION Hb_NtoS( n ) ; RETURN ltrim( str( n ) )
|
||||
FUNCTION Hb_ThreadStart() ; RETURN nil
|
||||
FUNCTION hb_DirBase() ; RETURN CurDir()
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
@@ -640,7 +642,6 @@ FUNCTION Build_SLEs( oWnd )
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
FUNCTION Build_MLE( oWnd )
|
||||
LOCAL oMLE
|
||||
LOCAL cText := "This is Xbase++ compatible implementation of XbpMLE()"
|
||||
|
||||
// Create MLE, specify position using :create() and
|
||||
@@ -656,9 +657,9 @@ FUNCTION Build_MLE( oWnd )
|
||||
|
||||
oMLE:setColorBG( GraMakeRGBColor( { 190,190,0 } ) )
|
||||
oMLE:setColorFG( GraMakeRGBColor( { 0,0,0 } ) )
|
||||
oMLE:setFontCompoundName( "14.Courier New bold normal" )
|
||||
oMLE:setFontCompoundName( "14.Courier bold" )
|
||||
|
||||
RETURN nil
|
||||
RETURN oMLE
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
@@ -844,7 +845,7 @@ PROCEDURE FieldStruct( oItem, aField )
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
FUNCTION Build_Statics( oWnd )
|
||||
LOCAL oGrp,oLbl, oLin, oBox
|
||||
LOCAL oGrp,oLbl, oLin, oBox, oBmp, oBmp1
|
||||
LOCAL nC1 := 10, nC2 := 45, nC3 := 110, nC4 := 175
|
||||
LOCAL nW := 50, nH := 50, nG := 10
|
||||
LOCAL nT := 60
|
||||
@@ -937,21 +938,27 @@ FUNCTION Build_Statics( oWnd )
|
||||
oBox:options := XBPSTATIC_FRAMETHICK
|
||||
oBox:create()
|
||||
|
||||
#ifdef __HARBOUR__
|
||||
oBox := XbpStatic():new( oGrp, , {nC4,nT}, {nW,nH+nH+nG} )
|
||||
oBox:type := XBPSTATIC_TYPE_BITMAP
|
||||
oBox:options := XBPSTATIC_BITMAP_SCALED
|
||||
oBox:caption := 'paste.png'
|
||||
oBmp := XbpBitmap():new():create()
|
||||
oBmp:loadFile( 'paste.png' )
|
||||
oBox:caption := oBmp
|
||||
oBox:create()
|
||||
oBox:setColorBG( GraMakeRGBColor( { 0,100,100 } ) )
|
||||
|
||||
oBox := XbpStatic():new( oGrp, , {nC4,nT+(nH+nG)*2}, {nW,nH} )
|
||||
oBox:type := XBPSTATIC_TYPE_BITMAP
|
||||
oBox:options := XBPSTATIC_BITMAP_TILED
|
||||
#ifdef __HARBOUR__
|
||||
oBox:caption := 'cut.png'
|
||||
#else
|
||||
oBmp1 := XbpBitmap():new():create()
|
||||
oBmp1:loadFile( 'paste.png' )
|
||||
oBox:caption := oBmp1
|
||||
#endif
|
||||
oBox:create()
|
||||
oBox:setColorBG( GraMakeRGBColor( { 100,0,100 } ) )
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __HARBOUR__ /* Differes from Xbase++ by Disk File | Resource Name, ID */
|
||||
@@ -1046,17 +1053,6 @@ FUNCTION Build_FileDialog( oWnd, cMode )
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
FUNCTION Build_FontDialog( oWnd )
|
||||
LOCAL oDlg
|
||||
|
||||
oDlg := XbpFontDialog():new( oWnd, , , , { 20,20 } )
|
||||
oDlg:create()
|
||||
oDlg:display( 0 )
|
||||
|
||||
RETURN nil
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
FUNCTION Build_Bitmap( oWnd )
|
||||
LOCAL oBmp, aFltr, cFile, cExt, nFrmt, oDlg
|
||||
LOCAL cExtns := { "png","gif","jpg","jpeg","bmp","tiff" }
|
||||
@@ -1114,15 +1110,22 @@ FUNCTION Build_Bitmap( oWnd )
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
FUNCTION Build_Font( oWnd )
|
||||
LOCAL oFont
|
||||
FUNCTION Build_FontDialog( oWnd )
|
||||
LOCAL oDlg
|
||||
|
||||
oFont := XbpFont():new()
|
||||
oDlg := XbpFontDialog():new( oWnd, , , , { 20,20 } )
|
||||
oDlg:activateOk := {|oFont| DisplayFontInfo( oFont ) }
|
||||
oDlg:create()
|
||||
|
||||
oFont:nominalPointSize := 16
|
||||
oFont:create( "Times New Roman" )
|
||||
|
||||
hb_outDebug( IF( oFont:bold(), "BOLD", "NORMAL" ) )
|
||||
oDlg:display( 0 )
|
||||
|
||||
RETURN nil
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
FUNCTION DisplayFontInfo( oFont )
|
||||
|
||||
oMLE:setFont( oFont )
|
||||
|
||||
RETURN nil
|
||||
|
||||
|
||||
@@ -79,12 +79,11 @@ CLASS XbpBitmap
|
||||
|
||||
ACCESS bits INLINE ::oWidget:depth()
|
||||
DATA bufferOffset INIT 0
|
||||
DATA planes INIT 0
|
||||
ACCESS planes INLINE 0
|
||||
DATA transparentColor INIT GRA_CLR_INVALID
|
||||
ACCESS xSize INLINE ::oWidget:width()
|
||||
ACCESS ySize INLINE ::oWidget:height()
|
||||
|
||||
|
||||
DATA oWidget
|
||||
DATA oPS
|
||||
DATA cImageFileName
|
||||
@@ -154,7 +153,6 @@ METHOD XbpBitmap:load( cDLLName, cID )
|
||||
METHOD XbpBitmap:loadFile( cImageFileName )
|
||||
LOCAL lSuccess
|
||||
|
||||
HB_SYMBOL_UNUSED( cImageFileName )
|
||||
// BMP, GIF, JPEG, PNG
|
||||
|
||||
::cImageFileName := cImageFileName
|
||||
|
||||
@@ -65,47 +65,6 @@
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
#define QFileDialog_AcceptOpen 0
|
||||
#define QFileDialog_AcceptSave 1
|
||||
|
||||
// enum #define QFileDialog_DialogLabel
|
||||
//
|
||||
#define QFileDialog_LookIn 0
|
||||
#define QFileDialog_FileName 1
|
||||
#define QFileDialog_FileType 2
|
||||
#define QFileDialog_Accept 3
|
||||
#define QFileDialog_Reject 4
|
||||
|
||||
// enum #define QFileDialog_FileMode
|
||||
// This enum is used to indicate what the user may select in the file dialog;
|
||||
// i.e. what the dialog will return if the user clicks OK.
|
||||
//
|
||||
#define QFileDialog_AnyFile 0 // The name of a file, whether it exists or not.
|
||||
#define QFileDialog_ExistingFile 1 // The name of a single existing file.
|
||||
#define QFileDialog_Directory 2 // The name of a directory. Both files and directories are displayed.
|
||||
#define QFileDialog_ExistingFiles 3 // The names of zero or more existing files.
|
||||
|
||||
// The Options type is a typedef for QFlags<Option>. It stores an OR combination of Option values.
|
||||
//
|
||||
#define QFileDialog_ShowDirsOnly 0x00000001 // Only show directories in the file dialog. By default both files and directories are shown. (Valid only in the Directory file mode.)
|
||||
#define QFileDialog_DontResolveSymlinks 0x00000002 // Don't resolve symlinks in the file dialog. By default symlinks are resolved.
|
||||
#define QFileDialog_DontConfirmOverwrite 0x00000004 // Don't ask for confirmation if an existing file is selected. By default confirmation is requested.
|
||||
#define QFileDialog_DontUseNativeDialog 0x00000010 // Don't use the native file dialog. By default on Mac OS X and Windows, the native file dialog is used.
|
||||
#define QFileDialog_ReadOnly 0x00000020 // Indicates that the model is readonly.
|
||||
#define QFileDialog_HideNameFilterDetails 0x00000040 // Indicates if the is hidden or not.
|
||||
|
||||
//enum QFileDialog::ViewMode
|
||||
//This enum describes the view mode of the file dialog; i.e. what information about each file will be displayed.
|
||||
//
|
||||
#define QFileDialog_Detail 0 // Displays an icon, a name, and details for each item in the directory.
|
||||
#define QFileDialog_List 1 // Displays only an icon and a name for each item in the directory.
|
||||
|
||||
#define QDialog_Accepted 1
|
||||
#define QDialog_Rejected 0
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
#include "hbclass.ch"
|
||||
#include "common.ch"
|
||||
|
||||
|
||||
@@ -77,6 +77,8 @@
|
||||
CLASS XbpFontDialog INHERIT XbpWindow
|
||||
|
||||
/* Appearance */
|
||||
DATA modalState INIT 0
|
||||
|
||||
DATA title INIT ""
|
||||
DATA buttonApply INIT .F.
|
||||
DATA buttonCancel INIT .T.
|
||||
@@ -143,9 +145,8 @@ CLASS XbpFontDialog INHERIT XbpWindow
|
||||
DATA aPos INIT { 0, 0 }
|
||||
DATA ok INIT .f.
|
||||
|
||||
METHOD GetXbpFont() PROTECTED
|
||||
|
||||
DATA oOptions
|
||||
DATA oFont
|
||||
METHOD xbpFontObject
|
||||
|
||||
ENDCLASS
|
||||
|
||||
@@ -196,15 +197,16 @@ METHOD XbpFontDialog:create( oParent, oOwner, oScreenPS, oPrinterPS, aPos )
|
||||
|
||||
::oWidget := QFontDialog():new()
|
||||
|
||||
if !empty( ::title )
|
||||
::oWidget:setWindowTitle( ::title )
|
||||
ENDIF
|
||||
|
||||
::connect( ::pwidget, "accepted()" , {|o,p| ::exeBlock( 1, p, o ) } )
|
||||
::connect( ::pwidget, "finished(int)" , {|o,p| ::exeBlock( 2, p, o ) } )
|
||||
::connect( ::pwidget, "rejected()" , {|o,p| ::exeBlock( 3, p, o ) } )
|
||||
::connect( ::pwidget, "currentFontChanged(QFont)", {|o,p| ::exeBlock( 4, p, o ) } )
|
||||
::connect( ::pwidget, "fontSelected(QFont)" , {|o,p| ::exeBlock( 5, p, o ) } )
|
||||
|
||||
IF ::aPos[ 1 ] + ::aPos[ 2 ] != 0
|
||||
::setPos()
|
||||
ENDIF
|
||||
::oParent:addChild( Self )
|
||||
RETURN Self
|
||||
|
||||
@@ -216,6 +218,11 @@ METHOD XbpFontDialog:exeBlock( nEvent, p1 )
|
||||
HB_SYMBOL_UNUSED( p1 )
|
||||
|
||||
DO CASE
|
||||
CASE nEvent == 1
|
||||
IF hb_isBlock( ::sl_activateOk )
|
||||
eval( ::sl_activateOk, ::XbpFontObject(), NIL, Self )
|
||||
ENDIF
|
||||
|
||||
CASE nEvent == 3
|
||||
IF hb_isBlock( ::sl_quit )
|
||||
nRet := eval( ::sl_quit, 0, 0, Self )
|
||||
@@ -232,102 +239,35 @@ METHOD XbpFontDialog:exeBlock( nEvent, p1 )
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD XbpFontDialog:display( nMode )
|
||||
LOCAL aInfo := nMode
|
||||
LOCAL nResult
|
||||
|
||||
//::setPosAndSize()
|
||||
DEFAULT nMode TO 0
|
||||
|
||||
IF nMode == 0 // Parent and modal
|
||||
::modalState := nMode
|
||||
|
||||
/* Before Display Initialize the Variables
|
||||
*/
|
||||
::oFont := QFont():new()
|
||||
|
||||
::oFont:setFamily( ::familyName )
|
||||
::oFont:setPointSize( ::nominalPointSize )
|
||||
|
||||
::oWidget:setCurrentFont( QT_PTROF( ::oFont ) )
|
||||
|
||||
IF ::aPos[ 1 ] + ::aPos[ 2 ] != 0
|
||||
::setPos()
|
||||
ENDIF
|
||||
|
||||
IF nMode == 0 // Parent and Modal
|
||||
nResult := ::oWidget:exec()
|
||||
nMode := nResult
|
||||
ELSE // Non-modal
|
||||
::oWidget:show()
|
||||
ENDIF
|
||||
|
||||
RETURN ::GetXbpFont( aInfo )
|
||||
RETURN nResult
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
#if 0
|
||||
METHOD XbpFontDialog:wndProc( hWnd, nMessage, nwParam, nlParam )
|
||||
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 )
|
||||
|
||||
HB_SYMBOL_UNUSED( nH )
|
||||
|
||||
DO CASE
|
||||
|
||||
CASE nL == IDOK
|
||||
::ok := .t.
|
||||
IF hb_isBlock( ::sl_activateOk )
|
||||
eval( ::sl_activateOk, ::GetxbpFont(), 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, ::GetxbpFont(), NIL, Self )
|
||||
ENDIF
|
||||
|
||||
CASE nL == 1038 /* Help */
|
||||
|
||||
ENDCASE
|
||||
|
||||
ENDCASE
|
||||
|
||||
RETURN 0
|
||||
#endif
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD XbpFontDialog:destroy()
|
||||
|
||||
::xbpWindow:destroy()
|
||||
@@ -335,32 +275,29 @@ METHOD XbpFontDialog:destroy()
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* Only callable from ::activateOK and ::activateApply
|
||||
*/
|
||||
METHOD XbpFontDialog:GetXbpFont( aFont )
|
||||
LOCAL oXbpFont := 0
|
||||
|
||||
HB_SYMBOL_UNUSED( aFont )
|
||||
#if 0
|
||||
DEFAULT aFont TO Wvg_ChooseFont_GetLogFont( ::hWnd )
|
||||
METHOD XbpFontDialog:XbpFontObject()
|
||||
LOCAL oXbp
|
||||
|
||||
oWvgFont := XbpFont():new()
|
||||
::oFont := QFont()
|
||||
::oFont:pPtr := ::oWidget:currentFont()
|
||||
|
||||
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()
|
||||
#endif
|
||||
RETURN oXbpFont
|
||||
oXbp := XbpFont():new()
|
||||
|
||||
oXbp:bold := ::oFont:bold()
|
||||
oXbp:italic := ::oFont:italic()
|
||||
oXbp:underscore := ::oFont:underline()
|
||||
oXbp:fixed := ::oFont:fixedPitch()
|
||||
|
||||
oXbp:familyName := ::oFont:family()
|
||||
oXbp:nominalPointSize := ::oFont:pointSize()
|
||||
oXbp:weightClass := ::oFont:weight()
|
||||
|
||||
oXbp:setCompoundName( hb_ntos( oXbp:nominalPointSize ) + "." + oXbp:familyName )
|
||||
|
||||
oXbp:create()
|
||||
|
||||
RETURN oXbp
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*----------------------------------------------------------------------*/
|
||||
@@ -372,15 +309,19 @@ METHOD XbpFontDialog:GetXbpFont( aFont )
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
|
||||
CLASS XbpFont
|
||||
|
||||
DATA oWidget
|
||||
|
||||
DATA hFont
|
||||
DATA oPS
|
||||
DATA hdc
|
||||
DATA oFontInfo
|
||||
|
||||
DATA familyName INIT ""
|
||||
DATA height INIT 0
|
||||
DATA nominalPointSize INIT 0
|
||||
DATA nominalPointSize INIT -1
|
||||
|
||||
DATA width INIT 0
|
||||
DATA widthClass INIT .F.
|
||||
@@ -396,7 +337,7 @@ CLASS XbpFont
|
||||
DATA fixed INIT .F.
|
||||
DATA antiAliased INIT .F.
|
||||
|
||||
DATA compoundName INIT ""
|
||||
DATA compoundName INIT "" READONLY
|
||||
METHOD setCompoundName( cName ) INLINE ::compoundName := cName
|
||||
|
||||
DATA generic INIT .T.
|
||||
@@ -433,24 +374,79 @@ METHOD XbpFont:new( oPS )
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD XbpFont:create( cFontName )
|
||||
LOCAL n, cFont, nPtSize
|
||||
|
||||
DEFAULT cFontName TO ::familyName
|
||||
IF !empty( cFontName )
|
||||
IF ( n := at( '.', cFontName ) ) > 0
|
||||
cFont := '"' + substr( cFontName, n + 1 ) + '"'
|
||||
nPtSize := val( substr( cFontName, 1, n - 1 ) )
|
||||
ENDIF
|
||||
ENDIF
|
||||
IF empty( cFont )
|
||||
cFont := ::familyName
|
||||
nPtSize := ::nominalPointSize
|
||||
ENDIF
|
||||
|
||||
::familyName := cFontName
|
||||
IF empty( nPtSize )
|
||||
nPtSize := 12
|
||||
ENDIF
|
||||
|
||||
::createFont()
|
||||
::oWidget := QFont():new( cFont, nPtSize )
|
||||
|
||||
::oWidget:setBold( ::bold )
|
||||
::oWidget:setItalic( ::italic )
|
||||
::oWidget:setUnderline( ::underscore )
|
||||
::oWidget:setStrikeOut( ::strikeout )
|
||||
::oWidget:setFixedPitch( ::fixed )
|
||||
::oWidget:setKerning( ::kerning )
|
||||
|
||||
|
||||
#if 0
|
||||
::oWidget:setStretch( factor )
|
||||
//
|
||||
::oWidget:setCapitalization( caps )
|
||||
::oWidget:setFamily( family )
|
||||
::oWidget:setLetterSpacing( type, spacing )
|
||||
::oWidget:setOverline( enable )
|
||||
::oWidget:setPixelSize( pixelSize )
|
||||
::oWidget:setPointSize( pointSize )
|
||||
::oWidget:setPointSizeF( pointSize )
|
||||
::oWidget:setRawMode( enable )
|
||||
::oWidget:setRawName( name )
|
||||
::oWidget:setStyle( style )
|
||||
::oWidget:setStyleHint( StyleHint hint, StyleStrategy strategy = PreferDefault )
|
||||
::oWidget:setStyleStrategy( StyleStrategy )
|
||||
::oWidget:setWeight( weight )
|
||||
::oWidget:setWordSpacing( spacing )
|
||||
#endif
|
||||
|
||||
/* Initializes the font structures internally */
|
||||
//::oWidget:initialize()
|
||||
|
||||
/* Call the final step - beyond that any changes to properties above will have NO effect */
|
||||
::oFontInfo := QFontInfo():new( QT_PTROF( ::oWidget ) )
|
||||
|
||||
/* Reassign actual properties */
|
||||
::bold := ::oFontInfo:bold()
|
||||
::italic := ::oFontInfo:italic()
|
||||
::fixed := ::oFontInfo:fixedPitch()
|
||||
::familyName := ::oFontInfo:family()
|
||||
::height := ::oFontInfo:pointSize()
|
||||
::weightClass := ::oFontInfo:weight()
|
||||
|
||||
#if 0
|
||||
bool exactMatch () const
|
||||
int pixelSize () const
|
||||
qreal pointSizeF () const
|
||||
bool rawMode () const
|
||||
QFont::Style style () const
|
||||
QFont::StyleHint styleHint () const
|
||||
#endif
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD XbpFont:configure( cFontName )
|
||||
|
||||
DEFAULT cFontName TO ::familyName
|
||||
|
||||
::familyName := cFontName
|
||||
|
||||
::createFont()
|
||||
METHOD XbpFont:configure()
|
||||
|
||||
RETURN Self
|
||||
|
||||
@@ -458,9 +454,7 @@ METHOD XbpFont:configure( cFontName )
|
||||
|
||||
METHOD XbpFont:destroy()
|
||||
|
||||
::xbpWindow:destroy()
|
||||
|
||||
RETURN Self
|
||||
RETURN NIL
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
@@ -488,7 +482,7 @@ METHOD XbpFont:createFont()
|
||||
::aFontInfo[ 1 ] := ::familyName
|
||||
::aFontInfo[ 2 ] := ::height
|
||||
::aFontInfo[ 3 ] := ::width
|
||||
::aFontInfo[ 4 ] := IF( ::bold, 0, 0 )
|
||||
::aFontInfo[ 4 ] := IF( ::bold, 75, -1 )
|
||||
::aFontInfo[ 5 ] := ::italic
|
||||
::aFontInfo[ 6 ] := ::underscore
|
||||
::aFontInfo[ 7 ] := ::strikeout
|
||||
|
||||
@@ -227,7 +227,8 @@ METHOD XbpStatic:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
|
||||
::oWidget := QLabel():new( ::pParent )
|
||||
|
||||
CASE ::type == XBPSTATIC_TYPE_BITMAP
|
||||
::oWidget := QFrame():new( ::pParent )
|
||||
//::oWidget := QFrame():new( ::pParent )
|
||||
::oWidget := QLabel():new( ::pParent )
|
||||
|
||||
OTHERWISE
|
||||
::oWidget := QFrame():new( ::pParent )
|
||||
@@ -288,10 +289,18 @@ METHOD XbpStatic:setCaption( xCaption, cDll )
|
||||
::oWidget:setText( ::caption )
|
||||
|
||||
CASE ::type == XBPSTATIC_TYPE_BITMAP
|
||||
IF ::options == XBPSTATIC_BITMAP_SCALED
|
||||
::oWidget:setStyleSheet( 'border-image: url('+ ::caption +');' )
|
||||
ELSE
|
||||
::oWidget:setStyleSheet( 'background: url('+ ::caption +'); repeat-xy;' )
|
||||
IF hb_isObject( ::caption ) /* XbpBitmap() */
|
||||
IF ::options == XBPSTATIC_BITMAP_SCALED
|
||||
::oWidget:setScaledContents( .t. )
|
||||
ENDIF
|
||||
::oWidget:setPixmap( QPixmap():fromImage( QT_PTROF( ::caption:oWidget ) ) )
|
||||
|
||||
ELSEIF hb_isChar( ::caption ) /* $HARBOUR$ */
|
||||
IF ::options == XBPSTATIC_BITMAP_SCALED
|
||||
::oWidget:setStyleSheet( 'border-image: url('+ ::caption +');' )
|
||||
ELSE
|
||||
::oWidget:setStyleSheet( 'background: url('+ ::caption +'); repeat-xy;' )
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
CASE ::type == XBPSTATIC_TYPE_ICON
|
||||
|
||||
@@ -872,9 +872,31 @@ METHOD XbpWindow:setColorFG( nRGB )
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD XbpWindow:setFont( oFont )
|
||||
LOCAL cAttr := ""
|
||||
|
||||
// TODO:
|
||||
//::oWidget:setFont( QT_PTROF( oFont:oWidget ) ) /* Works but need to be refined */
|
||||
|
||||
IF oFont:bold .and. oFont:italic
|
||||
cAttr := "bolditalic"
|
||||
ELSEIF oFont:bold
|
||||
cAttr := "bold"
|
||||
ELSEIF oFont:italic
|
||||
cAttr := "italic"
|
||||
ENDIF
|
||||
|
||||
::setFontCompoundName( oFont:compoundName + " " + cAttr )
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD XbpWindow:setFontCompoundName( xFont )
|
||||
LOCAL cOldFont, s, n, nPoint, cFont, cAttr, cFace
|
||||
LOCAL aAttr := { "normal","italic","bold" }
|
||||
LOCAL cOldFont, s, n, nPoint, cFont, cFace, cCSS
|
||||
LOCAL aAttr := { "bolditalic", "italic", "bold" }
|
||||
LOCAL cAttr := "normal"
|
||||
LOCAL cWeight := "normal"
|
||||
|
||||
cOldFont := Xbp_SetPresParam( ::aPresParams, XBP_PP_COMPOUNDNAME )
|
||||
|
||||
@@ -887,10 +909,8 @@ METHOD XbpWindow:setFontCompoundName( xFont )
|
||||
n := ascan( aAttr, {|e| at( e, cFont ) > 0 } )
|
||||
IF n > 0
|
||||
cAttr := aAttr[ n ]
|
||||
n := at( cAttr, s )
|
||||
cFont := substr( cFont,1,n-1 )
|
||||
ELSE
|
||||
cAttr := "normal"
|
||||
n := at( cAttr, s )
|
||||
cFont := substr( cFont, 1, n-1 )
|
||||
ENDIF
|
||||
IF ( n := at( ".", cFont ) ) > 0
|
||||
nPoint := val( substr( cFont,1,n-1 ) )
|
||||
@@ -902,7 +922,18 @@ METHOD XbpWindow:setFontCompoundName( xFont )
|
||||
|
||||
Xbp_SetPresParam( ::aPresParams, XBP_PP_COMPOUNDNAME, xFont )
|
||||
|
||||
::setStyleSheet( 'font-family: "'+ cFace +'"; font-style: '+ cAttr +'; font-size: '+ hb_ntos( nPoint )+'pt;' )
|
||||
IF cAttr == "bolditalic"
|
||||
cAttr := "italic"
|
||||
cWeight := "bold"
|
||||
ENDIF
|
||||
IF cAttr == "bold"
|
||||
cAttr := "normal"
|
||||
cWeight := "bold"
|
||||
ENDIF
|
||||
|
||||
cCSS := 'font-family: "'+ cFace + '"; font-style: ' + cAttr + '; font-size: ' + ;
|
||||
hb_ntos( nPoint ) + 'pt; font-weight: ' + cWeight + ';'
|
||||
::setStyleSheet( cCSS )
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
@@ -938,6 +969,7 @@ METHOD XbpWindow:setPointer( cDllName, xResID, nType )
|
||||
CASE nType == XBPWINDOW_POINTERTYPE_SYSPOINTER
|
||||
DO CASE
|
||||
CASE xResID == XBPSTATIC_SYSICON_DEFAULT // Default mouse pointer
|
||||
|
||||
CASE xResID == XBPSTATIC_SYSICON_ARROW // Normal arrow
|
||||
::oWidget:setCursor( QT_PTROF( QCursor():new( Qt_ArrowCursor ) ) )
|
||||
|
||||
@@ -1006,11 +1038,11 @@ METHOD XbpWindow:setPointer( cDllName, xResID, nType )
|
||||
IF valtype( xResID ) == "C" // Harbour compatibility
|
||||
IF file( xResID )
|
||||
#if 0 /* The original image size - but in practice pointer should be proper sized */
|
||||
::oWidget:setCursor( QT_PTROF( QCursor():new( QT_PTROF( QPixmap():new( xResID ) ) ) ) )
|
||||
::oWidget:setCursor( QT_PTROF( QCursor():new( "QPixmap", QT_PTROF( QPixmap():new( xResID ) ) ) ) )
|
||||
#else
|
||||
::oWidget:setCursor( QT_PTROF( QCursor():new( QPixmap():new( xResID ):scaled( 24,24 ) ) ) )
|
||||
hb_OutDebug( "sssssssssssss" )
|
||||
::oWidget:setCursor( QT_PTROF( QCursor():new( "QPixmap", QPixmap():new( xResID ):scaled( 24,24 ) ) ) )
|
||||
#endif
|
||||
//::oWidget:setCursor( QT_PTROF( QCursor():new( QT_PTROF( QIcon():new( xResID ) ) ) ) )
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
@@ -1137,14 +1169,6 @@ METHOD XbpWindow:winDevice()
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD XbpWindow:setFont()
|
||||
|
||||
// TODO:
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD XbpWindow:setPresParam( aPPNew )
|
||||
LOCAL i, aPP
|
||||
|
||||
|
||||
Reference in New Issue
Block a user