there is also some error because here not run ok
@ 10,5 GROUPEX oGr TO 100,175 OF oDlg ;
LABEL "Anagrafica cliente " PIXEL FONT oFont;
IMAGE "case.bmp" POSITION 0 MARGIN 2 ;
COLORHEADER METRO_TEAL,METRO_CYAN ;
GRADIENT TEXTALIGN 1 COLORTEXT CLR_RED SHADOW
you must try with all parameters
lGradient := false or true
lBorder:= false or true
lShadow:= false or true
for default is good noshadow and nogradient
Please use this release I add your modifies !!!
Tgroupex.ch
Code: Select all
#xcommand @ <nTop>, <nLeft> GROUPEX [ <oGroup> ] ;
[ TO <nBottom>, <nRight> ] ;
[ <label:LABEL,PROMPT> <cLabel> ] ;
[ OF <oWnd> ] ;
[ COLOR <nClrFore> [,<nClrBack>] ] ;
[ <lPixel: PIXEL> ] ;
[ <lDesign: DESIGN> ] ;
[ FONT <oFont> ] ;
[ <lTransparent: TRANSPARENT> ] ;
[ SIZE <nWidth>, <nHeight> ] ;
[ IMAGE <cImage> ] ;
[ POSITION <nImgAlign> ] ;
[ MARGIN <nMargin> ] ;
[ COLORHEADER <nClrfrom> ,<nClrto> ] ;
[ <lGradient: GRADIENT> ] ;
[ TEXTALIGN <nTextAlign> ] ;
[ COLORTEXT <nColorText> ] ;
[ <lshadow: SHADOW> ] ;
=> ;
[ <oGroup> := ] TGroupEx():New( <nTop>, <nLeft>, <nBottom>, <nRight>,;
<cLabel>, <oWnd>, <nClrFore>, <nClrBack>, <.lPixel.>,;
[<.lDesign.>], [<oFont>], [<.lTransparent.>], <nWidth>, <nHeight>,;
<cImage>,<nImgAlign>,<nMargin>,<nClrfrom>,<nClrto>,<.lGradient.>, <nTextAlign>,<nColorText>,<.lshadow.> )
TgroupEx class
Code: Select all
#include "FiveWin.ch"
#include "Constant.ch"
#define WM_NCHITTEST 132 // 0x84
#define WM_UPDATEUISTATE 296 // 0x0128
#define DT_TOP 0
#define DT_LEFT 0
#define DT_CENTER 1
#define DT_RIGHT 2
#define DT_VCENTER 4
#define DT_BOTTOM 8
#define DT_WORDBREAK 16
#define DT_SINGLELINE 32
#define DT_EXPANDTABS 64
#define DT_TABSTOP 128
#define DT_NOCLIP 256
#define DT_EXTERNALLEADING 512
#define DT_CALCRECT 1024
#define DT_NOPREFIX 2048
#define DT_INTERNAL 4096
CLASS TGroupEx FROM TControl
DATA lTransparent INIT .f.
DATA lRound
DATA lBorder
DATA nBorderColor
DATA nMargin INIT 2
DATA nClrfrom
DATA nClrTo
DATA lGradient
DATA lVertical
DATA cImage
DATA nTextAlign INIT 0
DATA nImgAlign INIT 0
DATA nColorText
DATA lShadow
METHOD New( nTop, nLeft, nBottom, nRight, cLabel, oWnd, nClrText,;
nClrPane, lPixel, lDesign, oFont, lTransparent, nWidth, nHeight, cImage,nMargin,nClrfrom ) CONSTRUCTOR
METHOD ReDefine( nId, cLabel, oWnd, nClrText, nClrPane, oFont, lTransparent ) CONSTRUCTOR
METHOD cGenPRG( lDlgUnits )
METHOD cToChar() INLINE ::Super:cToChar( "BUTTON" )
METHOD HandleEvent( nMsg, nWParam, nLParam )
METHOD Initiate( hDlg )
METHOD Paint()
METHOD Display() INLINE ::BeginPaint(), ::Paint(), ::EndPaint(), 0
METHOD SaveToRC( nIndent )
METHOD LoadImage( cImage )
METHOD PaintHeader (aRect)
ENDCLASS
//----------------------------------------------------------------------------//
METHOD New( nTop, nLeft, nBottom, nRight, cLabel, oWnd, nClrText, nClrPane,;
lPixel, lDesign, oFont, lTransparent, nWidth, nHeight,;
cImage,nImgAlign,nMargin,nClrfrom,nClrTo,lGradient,nTextAlign,nColorText,;
lRound,lBorder,nBorderColor,lShadow ) CLASS TGroupeX
DEFAULT nTop := 0, nLeft := 0, nBottom := 3, nRight := 3,;
oWnd := GetWndDefault(),;
nClrText := oWnd:nClrText, nClrPane := oWnd:nClrPane,;
lPixel := .f., lDesign := .f., ;
lTransparent := .f., oFont := oWnd:oFont , ;
nMargin := 2 , nClrfrom:= CLR_BLUE , nClrTo := CLR_WHITE ,;
nTextAlign := 1, nImgAlign:= 2 ,nColorText := CLR_WHITE , lRound:= .T. ,;
nBorderColor:= CLR_BLACK, lBorder:=.T. ,lGradient:= .t.,lShadow := .t.
::nTop = nTop * If( lPixel, 1, GRP_CHARPIX_H ) // 14
::nLeft = nLeft * If( lPixel, 1, GRP_CHARPIX_W ) // 7
::nMargin = nMargin
::nClrfrom = nClrfrom
::nClrTo = nClrTo
::lGradient = lGradient
::lRound = lRound
::cImage = cImage
::nTextAlign = nTextAlign
::nImgAlign = nImgAlign
::nColorText = nColorText
::lBorder = lBorder
::nBorderColor = CLR_BLACK
::lShadow = lShadow
if ::lShadow
::nBorderColor := nRGB(190,190,190)
else
::nBorderColor := nRGB(150,150,150)
endif
if nWidth != nil
::nRight = ::nLeft + nWidth
else
::nRight = nRight * If( lPixel, 1, GRP_CHARPIX_W ) // 7
endif
if nHeight != nil
::nBottom = ::nTop + nHeight
else
::nBottom = nBottom * If( lPixel, 1, GRP_CHARPIX_H ) // 14
endif
::cCaption = cLabel
::oWnd = oWnd
::nStyle = nOR( WS_CHILD, WS_VISIBLE, BS_GROUPBOX,;
If( lDesign, nOr( WS_TABSTOP, WS_CLIPSIBLINGS ), 0 ) )
::nId = ::GetNewId()
::lUpdate = .f.
::lDrag = lDesign
::lTransparent = lTransparent
::SetColor( nClrText, nClrPane )
if lTransparent
::SetBrush( TBrush():New( "NULL" ) )
endIf
if ! Empty( oWnd:hWnd )
::Create( "BUTTON" )
oWnd:AddControl( Self )
else
oWnd:DefControl( Self )
endif
if oFont != nil
::SetFont( oFont )
endIf
if lDesign
::CheckDots()
endif
return Self
//----------------------------------------------------------------------------//
METHOD ReDefine( nId, cLabel, oWnd, nClrText, nClrPane, oFont,;
lTransparent,cImage,nMargin,nClrfrom,nClrTo,lGradient,nTextAlign,;
nImgAlign,nColorText,lRound,lBorder,nBorderColor,lShadow ) CLASS TGroupeX
DEFAULT nId := ::GetNewId(),;
nClrText := oWnd:nClrText, nClrPane := oWnd:nClrPane,;
lTransparent:= .f., oWnd := GetWndDefault() ,;
nMargin := 2 , nClrfrom:= CLR_BLUE , nClrTo := CLR_WHITE ,;
nTextAlign := 1, nImgAlign:= 2 ,nColorText := CLR_WHITE , lRound:= .T. ,;
nBorderColor:= CLR_BLACK, lBorder:=.T.,lGradient:= .f. ,lShadow := .t.
::nId = nId
::cCaption = cLabel
::hWnd = 0
::oWnd = oWnd
::lUpdate = .f.
::lTransparent = lTransparent
::nMargin = nMargin
::nClrfrom = nClrfrom
::nClrTo = nClrTo
::lGradient = lGradient
::lRound = lRound
::cImage = cImage
::nTextAlign = nTextAlign
::nImgAlign = nImgAlign
::nColorText = nColorText
::lBorder = lBorder
::nBorderColor = CLR_BLACK
::lShadow = lShadow
if ::lShadow
::nBorderColor := nRGB(190,190,190)
else
::nBorderColor := nRGB(150,150,150)
endif
::SetColor( nClrText, nClrPane )
If lTransparent
::SetBrush( TBrush():New( "NULL" ) )
EndIf
if oFont != Nil
::SetFont( oFont )
endIf
oWnd:DefControl( Self )
return Self
//----------------------------------------------------------------------------//
METHOD cGenPRG( lDlgUnits ) CLASS TGroupeX
local cPrg := ""
local nFactorX, nFactorY
local cTop, cLeft, cWidth, cHeight
DEFAULT lDlgUnits := .F.
nFactorX = If( lDlgUnits, 4 / nLoWord( GetDlgBaseUnits() ), 1 )
nFactorY = If( lDlgUnits, 8 / nHiWord( GetDlgBaseUnits() ), 1 )
::CoorsUpdate()
if ::cCaption == nil
::cCaption = ::GetText()
endif
cTop = LTrim( Str( Int( ::nTop * nFactorX ) ) )
cLeft = LTrim( Str( Int( ::nLeft * nFactorY ) ) )
cWidth = LTrim( Str( Int( ::nWidth * nFactorY ) ) )
cHeight = LTrim( Str( Int( ::nHeight * nFactorX ) ) )
cPrg += CRLF + " @ " + cTop + ", " + cLeft + ;
' GROUPEX oGrp PROMPT "' + ::cCaption + '" SIZE ' + ;
cWidth + ", " + cHeight + ;
" PIXEL OF oWnd " + CRLF
return cPrg
//----------------------------------------------------------------------------//
METHOD Initiate( hDlg ) CLASS TGroupeX
::Super:Initiate( hDlg )
if Empty( ::cCaption )
::cCaption = ::GetText()
else
::SetText( ::cCaption )
endif
return nil
//----------------------------------------------------------------------------//
METHOD HandleEvent( nMsg, nWParam, nLParam ) CLASS TGroupeX
local nResult
if ::lDrag .and. nMsg == WM_NCHITTEST // To have a standard behavior on Clicks
return DefWindowProc( ::hWnd, nMsg, nWParam, nLParam )
endif
if nMsg == WM_UPDATEUISTATE // Groups and contained controls were erased when pressing ALT
nResult = ::Super:HandleEvent( nMsg, nWParam, nLParam )
::oWnd:Refresh( .f. ) // EMG: added .f. to alleviate flickering
return nResult
endif
return ::Super:HandleEvent( nMsg, nWParam, nLParam )
//----------------------------------------------------------------------------//
METHOD Paint() CLASS TGroupeX
local aRect := GetClientRect( ::hWnd )
* local i
if ::lShadow
/* linedraw( ::hDC, aRect[1]+6, aRect[4], aRect[3]+6, aRect[4], nRGB(130,130,130), 1 )
linedraw( ::hDC, aRect[1]+8, aRect[4]+1, aRect[3]+6, aRect[4]+1, nRGB(160,160,160), 1 )
linedraw( ::hDC, aRect[1]+10, aRect[4]+2, aRect[3]+6, aRect[4]+2, nRGB(190,190,190), 1 )
linedraw( ::hDC, aRect[1]+12, aRect[4]+3, aRect[3]+6, aRect[4]+3, nRGB(210,210,210), 1 )
linedraw( ::hDC, aRect[1]+16, aRect[4]+4, aRect[3]+6, aRect[4]+4, nRGB(210,210,210), 1 )
for i = 1 to 8
linedraw( ::hDC, aRect[3]+i, aRect[2]+i, aRect[3]+i, aRect[4]+i, nRGB(85+(i*20),85+(i*20),85+(i*20)), 1 )
next
*/
endif
IF ::lGradient
Gradient( ::hDC, { 0, 0, aRect[ 2 ] + 24, aRect[ 4 ] }, ::nClrfrom, ::nClrto, ::lVertical )
Gradient( ::hDC, { 24, 0, aRect[ 2 ] + 29, aRect[ 4 ] }, nRGB(190,190,190), nRGB(255,255,255), ::lVertical )
endif
aRect[1]+=1
aRect[2]+=1
aRect[3]-=1
aRect[4]-=1
IF ::lBorder
//hPen := CreatePen( 0, 1,::nBorderColor )
rectdraw( ::hDC, aRect[1]+26, aRect[2]+1, aRect[3]+1, aRect[4], CLR_WHITE, 2 )
endif
::PaintHeader (aRect)
return 1
//----------------------------------------------------------------------------//
METHOD SaveToRC( nIndent ) CLASS TGroupeX
local cRC := Space( nIndent ) + "GROUPBOX "
cRC += '"' + ::cCaption + '", '
cRC += AllTrim( Str( ::nId ) ) + ", "
cRC += AllTrim( Str( ::nTop ) ) + ", "
cRC += AllTrim( Str( ::nLeft ) ) + ", "
cRC += AllTrim( Str( ::nWidth ) ) + ", "
cRC += AllTrim( Str( ::nHeight ) )
cRC += ", BS_GROUPBOX"
return cRC
//----------------------------------------------------------------------------//
METHOD LoadImage( cImage ) CLASS TGroupeX
local hImage := 0
hImage := LoadBitmap( GetResources(), cImage )
if hImage == 0
hImage := ReadBitmap( 0, cImage )
endif
return (hImage)
//------------------------------------------------------------------------------//
METHOD PaintHeader (aRect) CLASS TGroupeX
LOCAL hImage, aRound
LOCAL nRad := 2
LOCAL hBrush, hPen, hOldPen
LOCAL nClrBorder := nRGB(0,0,150)
LOCAL nBmpWidth := 0
lOCAL nRow, nCol,nrow1,ncol1
IF ::lRound
aRound := AClone (aRect)
hBrush := SelectObject( ::hDC, ::oWnd:oBrush:hBrush )
hPen := CreatePen( 0, 1,::oWnd:nClrPane )
hOldPen := SelectObject( ::hDC, hPen )
aRound[4] -= 2
/* Left */
nrow := 0
ncol := 0
nrow1 := 0
ncol1 := 10
linedraw( ::hDC, nrow, ncol, nrow1, ncol1, ::oWnd:nClrPane, 1 )
nrow := 1
ncol := 0
nrow1 := 1
ncol1 := 7
linedraw( ::hDC, nrow, ncol, nrow1, ncol1, ::oWnd:nClrPane, 1 )
nrow := 2
ncol := 0
nrow1 := 2
ncol1 := 5
linedraw( ::hDC, nrow, ncol, nrow1, ncol1, ::oWnd:nClrPane, 1 )
nrow := 3
ncol := 0
nrow1 := 3
ncol1 := 4
linedraw( ::hDC, nrow, ncol, nrow1, ncol1, ::oWnd:nClrPane, 1 )
nrow := 4
ncol := 0
nrow1 := 4
ncol1 := 3.5
linedraw( ::hDC, nrow, ncol, nrow1, ncol1, ::oWnd:nClrPane, 1 )
nrow := 5
ncol := 0
nrow1 := 5
ncol1 := 2
linedraw( ::hDC, nrow, ncol, nrow1, ncol1, ::oWnd:nClrPane, 1 )
nrow := 5
ncol := 0
nrow1 := 5
ncol1 := 2
linedraw( ::hDC, nrow, ncol, nrow1, ncol1, ::oWnd:nClrPane, 1 )
nrow := 6
ncol := 0
nrow1 := 6
ncol1 := 1
linedraw( ::hDC, nrow, ncol, nrow1, ncol1, ::oWnd:nClrPane, 1 )
nrow := 7
ncol := 0
nrow1 := 7
ncol1 := 1
linedraw( ::hDC, nrow, ncol, nrow1, ncol1, ::oWnd:nClrPane, 1 )
** right
aRound[4] += 3
nrow := 0
ncol := aRound[4] - 9
nrow1 := 0
ncol1 := aRound[4]
linedraw( ::hDC, nrow, ncol, nrow1, ncol1, ::oWnd:nClrPane, 1 )
nrow := 1
ncol := aRound[4] - 6
nrow1 := 1
ncol1 := aRound[4]
linedraw( ::hDC, nrow, ncol, nrow1, ncol1, ::oWnd:nClrPane, 1 )
nrow := 2
ncol := aRound[4] - 4
nrow1 := 2
ncol1 := aRound[4]
linedraw( ::hDC, nrow, ncol, nrow1, ncol1, ::oWnd:nClrPane, 1 )
nrow := 3
ncol := aRound[4] - 3
nrow1 := 3
ncol1 := aRound[4]
linedraw( ::hDC, nrow, ncol, nrow1, ncol1, ::oWnd:nClrPane, 1 )
nrow := 4
ncol := aRound[4]- 1
nrow1 := 4
ncol1 := aRound[4]
linedraw( ::hDC, nrow, ncol, nrow1, ncol1, ::oWnd:nClrPane, 1 )
nrow := 5
ncol := aRound[4]-1
nrow1 := 5
ncol1 := aRound[4]
linedraw( ::hDC, nrow, ncol, nrow1, ncol1, ::oWnd:nClrPane, 1 )
nrow := 5
ncol := aRound[4] - 1
nrow1 := 5
ncol1 := aRound[4]
linedraw( ::hDC, nrow, ncol, nrow1, ncol1, ::oWnd:nClrPane, 1 )
SelectObject( ::hDC, hOldPen )
DeleteObject( hPen )
SelectObject( ::hDC, hBrush )
ENDIF
aRect[1]+=::nMargin // Margins
aRect[2]+=::nMargin
aRect[3]-=::nMargin
aRect[4]-=::nMargin
// Image
if !Empty (::cImage)
hImage := ::LoadImage( ::cImage )
nBmpWidth := nBmpWidth (hImage)
nCol := aRect[2]
nRow := aRect[1]
IF nAnd (::nImgAlign,DT_RIGHT) == DT_RIGHT
nCol := aRect[4]-nBmpWidth-10
ENDIF
IF nAnd (::nImgAlign,DT_CENTER) == DT_CENTER
nCol := (aRect[4]-aRect[2])/2-(nBmpWidth/2)
ENDIF
IF nAnd (::nImgAlign,DT_VCENTER) == DT_VCENTER
nRow := ((aRect[3]-aRect[1])/2)-(nBmpHeight(hImage)/2)
ENDIF
IF nAnd (::nImgAlign,DT_BOTTOM) == DT_BOTTOM
nRow := aRect[3]-nBmpHeight(hImage)
ENDIF
DrawMasked( ::hDC, hImage, nRow, nCol )
endif
// Label
IF !Empty (::cCaption)
IF nAnd (::nImgAlign,DT_CENTER) != DT_CENTER .and. nAnd (::nImgAlign,DT_RIGHT) != DT_RIGHT
aRect[2]+= (nBmpWidth+3)
ENDIF
IF nAnd (::nImgAlign,DT_CENTER) == DT_CENTER
::nTextAlign := IIF (::nTextAlign = DT_CENTER, DT_LEFT, ::nTextAlign)
IF nAnd (::nTextAlign,DT_RIGHT)==DT_RIGHT
aRect[2] := nCol+nBmpWidth+2
ELSE
aRect[4] := nCol-nBmpWidth-2
ENDIF
ENDIF
IF nAnd (::nImgAlign,DT_RIGHT) == DT_RIGHT
aRect[4]-= (nBmpWidth+3)
ENDIF
SetTextColor (::hDC, ::nColorText)
SetBkMode( ::hDC, 1 )
SelectObject( ::hDC, ::oFont:hFont )
DrawTextEx( ::hDC, ::cCaption, {aRect[1],aRect[2],aRect[3],aRect[4]}, ::nTextAlign)
ENDIF
return nil
#pragma BEGINDUMP
#include <hbvm.h>
#include <hbstack.h>
#include <WinTen.h>
#include <Windows.h>
#include <hbApi.h>
#include <commctrl.h>
#include <StdLib.h>
#include <ClipApi.h>
HB_FUNC( ELLIPSEDRAW )
{
HDC hDC = ( HDC ) _parnl( 1 );
HGDIOBJ hgdiobj1, hgdiobj2;
HPEN hpen;
HBRUSH hbrush;
LOGBRUSH br;
hpen = CreatePen( PS_SOLID, ( int ) hb_parni( 7 ), ( COLORREF ) RGB( ( int ) hb_parni( 6, 1 ), ( int ) hb_parni( 6, 2 ), ( int ) hb_parni( 6, 3 ) ) );
hgdiobj1 = SelectObject( hDC, hpen );
if( hb_parl( 9 ) )
{
hbrush = CreateSolidBrush( ( COLORREF ) RGB( ( int ) hb_parni( 10 ), ( int ) hb_parni( 11 ), ( int ) hb_parni( 12 ) ) );
hgdiobj2 = SelectObject( hDC, hbrush );
}
else
{
br.lbStyle = BS_HOLLOW;
hbrush = CreateBrushIndirect( &br );
hgdiobj2 = SelectObject( hDC, hbrush );
}
Ellipse( hDC, ( int ) hb_parni( 3 ), ( int ) hb_parni( 2 ), ( int ) hb_parni( 5 ), ( int ) hb_parni( 4 ) );
SelectObject( hDC, hgdiobj1 );
SelectObject( hDC, hgdiobj2 );
DeleteObject( hpen );
DeleteObject( hbrush );
}
HB_FUNC( RECTDRAW )
{
HDC hDC = ( HDC ) _parnl( 1 );
HGDIOBJ hgdiobj1, hgdiobj2;
HPEN hpen;
HBRUSH hbrush;
LOGBRUSH br;
hpen = CreatePen( PS_SOLID, ( int ) hb_parni( 7 ), ( COLORREF ) RGB( ( int ) hb_parni( 6, 1 ), ( int ) hb_parni( 6, 2 ), ( int ) hb_parni( 6, 3 ) ) );
hgdiobj1 = SelectObject( hDC, hpen );
br.lbStyle = BS_HOLLOW;
hbrush = CreateBrushIndirect( &br );
hgdiobj2 = SelectObject( hDC, hbrush );
Rectangle( hDC, ( int ) hb_parni( 3 ), ( int ) hb_parni( 2 ), ( int ) hb_parni( 5 ), ( int ) hb_parni( 4 ) );
SelectObject( hDC, hgdiobj1 );
SelectObject( hDC, hgdiobj2 );
DeleteObject( hpen );
DeleteObject( hbrush );
}
HB_FUNC( LINEDRAW )
{
HDC hDC = ( HDC ) _parnl( 1 );
HGDIOBJ hgdiobj1;
HPEN hpen;
hpen = CreatePen( PS_SOLID, ( int ) hb_parni( 7 ), ( COLORREF ) RGB( ( int ) hb_parni( 6, 1 ), ( int ) hb_parni( 6, 2 ), ( int ) hb_parni( 6, 3 ) ) );
hgdiobj1 = SelectObject( hDC, hpen );
MoveToEx( hDC, ( int ) hb_parni( 3 ), ( int ) hb_parni( 2 ), NULL );
LineTo( hDC, ( int ) hb_parni( 5 ), ( int ) hb_parni( 4 ) );
SelectObject( hDC, hgdiobj1 );
DeleteObject( hpen );
}
#pragma ENDDUM
test.prg
Code: Select all
#include "FiveWin.ch"
#include "tgroupex.ch"
Function Main()
Local oDlg,oGr,oGr1,oGr2
Local oFont
local oget
local cget:= space(30)
DEFINE FONT oFont NAME "CALIBRI" SIZE 0,-12
DEFINE DIALOG oDlg SIZE 800,400 pixel title "New Class TGroup from Mr. Silvio"
@ 10,5 GROUPEX oGr TO 100,175 OF oDlg ;
LABEL "Anagrafica cliente " PIXEL FONT oFont;
IMAGE "case.bmp" POSITION 0 MARGIN 2 ;
COLORHEADER METRO_TEAL,METRO_CYAN ;
GRADIENT TEXTALIGN 1 COLORTEXT CLR_RED SHADOW
@ 30,22 SAY "Name : " of oDlg PIXEL
@ 30,45 get oget var cget of oDlg size 100,12 PIXEL
oGr1 := TGroupeX():New( 10, 180, 100, 350, "Hello World !!!", oDlg,,, .T.,,,,, )
oGr1:cImage:="case.bmp"
oGr1:nImgAlign := 2
*é oGr2:lgradient := .f.
oGr2 := TGroupeX():New( 110, 12, 180, 350, "Hello FiveWin", oDlg,,, .T.,,,,, )
oGr2:cImage:="case.bmp"
oGr2:nImgAlign := 0
oGr2:lgradient:= .f.
oGr2:lshadow:= .f.
ACTIVATE DIALOG oDlg CENTER
RETURN NIL
//----------------------------------------------------------------------------//