Page 1 of 1
2? names of headings of columns in DCBROWSECOL
Posted: Sun Aug 19, 2012 3:42 am
by Eugene Lutsenko
Dear visitors of a forum!
I had two questions of names of headings of columns in DCBROWSECOL:
1 whether. It is possible to do headings of columns with transfers as was in CLIPPER (";")?
2 whether. It is possible to have the text in headings vertically?
And still:), whether it is possible to replace the image of zero values, for example, blank or in general to represent nothing, that is zero values of fields not to represent?
Re: 2? names of headings of columns in DCBROWSECOL
Posted: Sun Aug 19, 2012 10:05 am
by rdonnay
The answer to all of your questions is YES.
It is possible to do headings of columns with transfers as was in CLIPPER (";")?
Use the HEADLINES clause of @ .. DCBROWSE to determine the number of heading lines.
Then use semicolons in your header text to divide the text.
whether. It is possible to have the text in headings vertically?
This is a strange request but it is possible. For example if you have headings that are 7 characters then you would want to use HEADLINES 7 in your @ .. DCBROWSE command and add a semicolon after each character in the heading.
whether it is possible to replace the image of zero values, for example, blank or in general to represent nothing, that is zero values of fields not to represent?
Use a custom code block for DCBROWSECOL. Example:
Code: Select all
DCBROWSECOL DATA {|x|x:=MYFILE->numfield,IIF(Empty(x),'',Str(x,6))}
Re: 2? names of headings of columns in DCBROWSECOL
Posted: Sun Aug 19, 2012 10:35 am
by Auge_Ohr
Eugene Lutsenko wrote:2 whether. It is possible to have the text in headings vertically?
"just" vertical like Roger say or rotate it 45° ?
you can do almost everything with Ownerdraw (CustomDrawCell)
Code: Select all
**************************************
CLASS XbpBrowseVHeading FROM XbpBrowse
**************************************
PROTECTED:
VAR nTextYSize
EXPORTED:
VAR aSAttrs
VAR nHeadingHeight
VAR nHeadingAlign
INLINE METHOD destroy
*********************
::XbpBrowse:destroy()
::nTextYSize:= ::aSAttrs:= ::nHeadingHeight:= ::nHeadingAlign:= nil
RETURN self
INLINE METHOD init( oParent, oOwner, aPos, aSize, aPP, lVisible )
*****************************************************************
::XbpBrowse:init( oParent, oOwner, aPos, aSize, aPP, lVisible )
::aSAttrs := Array( GRA_AS_COUNT )
* ::aSAttrs[ GRA_AS_ANGLE ]:= { 0, 1 }
::aSAttrs[ GRA_AS_ANGLE ]:= NIL
::aSAttrs[ GRA_AS_COLOR ]:= XBPSYSCLR_WINDOWSTATICTEXT
::nHeadingHeight := 110
::nHeadingAlign := XBPALIGN_LEFT
RETURN self
INLINE METHOD AddColumn( obCol, nWidth, xHeading, xFooting, nType )
*******************************************************************
LOCAL aPP, oColumn
IF ValType( obCol ) = 'O'
oColumn:= obCol
ELSE
aPP:= {}
IF nWidth <> nil ; Aadd( aPP, { XBP_PP_COL_DA_CHARWIDTH, nWidth } ) ; ENDIF
IF xHeading <> nil ; Aadd( aPP, { XBP_PP_COL_HA_CAPTION, xHeading } ) ; ENDIF
IF xFooting <> nil ; Aadd( aPP, { XBP_PP_COL_FA_CAPTION, xFooting } ) ; ENDIF
Aadd( aPP, { XBP_PP_COL_HA_HEIGHT, ::nHeadingHeight } )
oColumn:= XbpColumn():new( self,,,, aPP )
IF nType <> nil
oColumn:type:= nType
ENDIF
oColumn:datalink := obCol
ENDIF
oColumn:drawMode:= XBP_DRAW_OWNER
RETURN ::XbpBrowse:AddColumn( oColumn )
INLINE METHOD CustomDrawCell( oPS, aInfo )
******************************************
LOCAL xData, aRect
IF aInfo[ XBP_DRAWINFO_AREA ] = aInfo[ XBP_DRAWINFO_COLUMN ]:heading
xData:= aInfo[ XBP_DRAWINFO_AREA ]:getCell( 1 )
IF valType( xData ) = 'C'
IF ::aSAttrs[ GRA_AS_ANGLE ] = NIL
::aSAttrs[ GRA_AS_ANGLE ]:= { aInfo[ XBP_DRAWINFO_RECT, 3 ] ,;
aInfo[ XBP_DRAWINFO_RECT, 4 ] }
ENDIF
oPS:setAttrString( ::aSAttrs )
IF ::nHeadingAlign = XBPALIGN_HCENTER
IF ::nTextYSize = nil
aRect:= GraQueryTextBox( oPS, xData )
::nTextYSize:= aRect[ 3, 2 ] - aRect[ 2, 1 ]
ENDIF
GraCaptionStr( oPS, { Int( ( aInfo[ XBP_DRAWINFO_RECT, 1 ] + aInfo[ XBP_DRAWINFO_RECT, 3 ] - ::nTextYSize ) / 2 ), ;
aInfo[ XBP_DRAWINFO_RECT, 2 ] }, { aInfo[ XBP_DRAWINFO_RECT, 4 ], aInfo[ XBP_DRAWINFO_RECT, 4 ] }, ;
xData, XBPALIGN_LEFT + XBPALIGN_BOTTOM )
ELSE // IF XBPALIGN_LEFT
GraCaptionStr( oPS, { aInfo[ XBP_DRAWINFO_RECT, 1 ], aInfo[ XBP_DRAWINFO_RECT, 2 ] }, { aInfo[ XBP_DRAWINFO_RECT, 4 ], ;
aInfo[ XBP_DRAWINFO_RECT, 4 ] }, xData, XBPALIGN_LEFT + XBPALIGN_BOTTOM )
ENDIF
RETURN .F.
ENDIF
ENDIF
RETURN .T.
ENDCLASS
Re: 2? names of headings of columns in DCBROWSECOL
Posted: Sun Aug 19, 2012 11:30 am
by Eugene Lutsenko
Roger!
Thank you very much! Everything very well turned out:
Code: Select all
DCSETPARENT TO
@ 5, 0 DCBROWSE oBrowGrSc ALIAS 'Rsp_it' SIZE 132,22 ;
PRESENTATION DC_BrowPres() ; // Только просмотр БД
NOSOFTTRACK ;
HEADLINES 3 ; // Кол-во строк в заголовке (перенос строки - ";")
SCOPE ;
ITEMMARKED bItems
// Сделать MAX - красным, MIN - синим
DCSETPARENT oBrowGrSc
DCBROWSECOL DATA {|x|x:=Rsp_it->Kod_Obj, IIF(Empty(x),'',Str(x,5))} HEADER "Код" PARENT oBrowse WIDTH 5
DCBROWSECOL FIELD Rsp_it->Name_Obj HEADER "Наим.объекта расп.выборки" PARENT oBrowse WIDTH 25
DCBROWSECOL DATA {|x|x:=Rsp_it->Max_Value,IIF(Empty(x),'',Str(x,5))} HEADER "MAX;уров.;сходства" PARENT oBrowse WIDTH 7 COLOR GRA_CLR_RED
DCBROWSECOL DATA {|x|x:=Rsp_it->KodC_MaxV,IIF(Empty(x),'',Str(x,5))} HEADER "Класс" PARENT oBrowse WIDTH 5 COLOR GRA_CLR_RED
DCBROWSECOL DATA {|x|x:=Rsp_it->Min_Value,IIF(Empty(x),'',Str(x,5))} HEADER "MIN;уров.;сходства" PARENT oBrowse WIDTH 7 COLOR GRA_CLR_BLUE
DCBROWSECOL DATA {|x|x:=Rsp_it->KodC_MinV,IIF(Empty(x),'',Str(x,5))} HEADER "Класс" PARENT oBrowse WIDTH 5 COLOR GRA_CLR_BLUE
DCBROWSECOL DATA {|x|x:=Rsp_it->Dost, IIF(Empty(x),'',Str(x,5))} HEADER "Досто-;верность" PARENT oBrowse WIDTH 7
Re: 2? names of headings of columns in DCBROWSECOL
Posted: Sun Aug 19, 2012 11:48 am
by Eugene Lutsenko
Auge_Ohr wrote:Eugene Lutsenko wrote:2 whether. It is possible to have the text in headings vertically?
"just" vertical like Roger say or rotate it 45° ?
you can do almost everything with Ownerdraw (CustomDrawCell)
Code: Select all
**************************************
CLASS XbpBrowseVHeading FROM XbpBrowse
**************************************
PROTECTED:
VAR nTextYSize
EXPORTED:
VAR aSAttrs
VAR nHeadingHeight
VAR nHeadingAlign
INLINE METHOD destroy
*********************
::XbpBrowse:destroy()
::nTextYSize:= ::aSAttrs:= ::nHeadingHeight:= ::nHeadingAlign:= nil
RETURN self
INLINE METHOD init( oParent, oOwner, aPos, aSize, aPP, lVisible )
*****************************************************************
::XbpBrowse:init( oParent, oOwner, aPos, aSize, aPP, lVisible )
::aSAttrs := Array( GRA_AS_COUNT )
* ::aSAttrs[ GRA_AS_ANGLE ]:= { 0, 1 }
::aSAttrs[ GRA_AS_ANGLE ]:= NIL
::aSAttrs[ GRA_AS_COLOR ]:= XBPSYSCLR_WINDOWSTATICTEXT
::nHeadingHeight := 110
::nHeadingAlign := XBPALIGN_LEFT
RETURN self
INLINE METHOD AddColumn( obCol, nWidth, xHeading, xFooting, nType )
*******************************************************************
LOCAL aPP, oColumn
IF ValType( obCol ) = 'O'
oColumn:= obCol
ELSE
aPP:= {}
IF nWidth <> nil ; Aadd( aPP, { XBP_PP_COL_DA_CHARWIDTH, nWidth } ) ; ENDIF
IF xHeading <> nil ; Aadd( aPP, { XBP_PP_COL_HA_CAPTION, xHeading } ) ; ENDIF
IF xFooting <> nil ; Aadd( aPP, { XBP_PP_COL_FA_CAPTION, xFooting } ) ; ENDIF
Aadd( aPP, { XBP_PP_COL_HA_HEIGHT, ::nHeadingHeight } )
oColumn:= XbpColumn():new( self,,,, aPP )
IF nType <> nil
oColumn:type:= nType
ENDIF
oColumn:datalink := obCol
ENDIF
oColumn:drawMode:= XBP_DRAW_OWNER
RETURN ::XbpBrowse:AddColumn( oColumn )
INLINE METHOD CustomDrawCell( oPS, aInfo )
******************************************
LOCAL xData, aRect
IF aInfo[ XBP_DRAWINFO_AREA ] = aInfo[ XBP_DRAWINFO_COLUMN ]:heading
xData:= aInfo[ XBP_DRAWINFO_AREA ]:getCell( 1 )
IF valType( xData ) = 'C'
IF ::aSAttrs[ GRA_AS_ANGLE ] = NIL
::aSAttrs[ GRA_AS_ANGLE ]:= { aInfo[ XBP_DRAWINFO_RECT, 3 ] ,;
aInfo[ XBP_DRAWINFO_RECT, 4 ] }
ENDIF
oPS:setAttrString( ::aSAttrs )
IF ::nHeadingAlign = XBPALIGN_HCENTER
IF ::nTextYSize = nil
aRect:= GraQueryTextBox( oPS, xData )
::nTextYSize:= aRect[ 3, 2 ] - aRect[ 2, 1 ]
ENDIF
GraCaptionStr( oPS, { Int( ( aInfo[ XBP_DRAWINFO_RECT, 1 ] + aInfo[ XBP_DRAWINFO_RECT, 3 ] - ::nTextYSize ) / 2 ), ;
aInfo[ XBP_DRAWINFO_RECT, 2 ] }, { aInfo[ XBP_DRAWINFO_RECT, 4 ], aInfo[ XBP_DRAWINFO_RECT, 4 ] }, ;
xData, XBPALIGN_LEFT + XBPALIGN_BOTTOM )
ELSE // IF XBPALIGN_LEFT
GraCaptionStr( oPS, { aInfo[ XBP_DRAWINFO_RECT, 1 ], aInfo[ XBP_DRAWINFO_RECT, 2 ] }, { aInfo[ XBP_DRAWINFO_RECT, 4 ], ;
aInfo[ XBP_DRAWINFO_RECT, 4 ] }, xData, XBPALIGN_LEFT + XBPALIGN_BOTTOM )
ENDIF
RETURN .F.
ENDIF
ENDIF
RETURN .T.
ENDCLASS
Roger very much helped me, having prompted me practically everything that it is necessary to me. But generally I meant text rotation in headings, as in Word and Excel. The matter is that I have databases in which there are a lot of columns with long headings and I had a thought: "And suddenly and it is possible!". And as in practice to use the class given by you. You couldn't give an example?
Re: 2? names of headings of columns in DCBROWSECOL
Posted: Sun Aug 19, 2012 2:40 pm
by Auge_Ohr
Eugene Lutsenko wrote:You couldn't give an example?
while
Code: Select all
CLASS XbpBrowseVHeading FROM XbpBrowse
it is just a XbpBrowse()
use Help file Sample and replace
Code: Select all
FUNCTION GuiBrowseDB( oParent, aPos, aSize )
LOCAL oBrowse
oBrowse := XbpBrowse():new( oParent,, aPos, aSize ):create()
will be
oBrowse := XbpBrowseVHeading():new( oParent,, aPos, aSize ):create()
thats all
Re: 2? names of headings of columns in DCBROWSECOL
Posted: Sun Aug 19, 2012 7:26 pm
by Eugene Lutsenko
Thanks! It is surprising.
Re: 2? names of headings of columns in DCBROWSECOL
Posted: Sat Aug 25, 2012 10:14 am
by Eugene Lutsenko
I tried three options of preparation of the columns given for headings which I give below. I most of all liked the third option and I use it.
Code: Select all
//Options of preparation of headings of columns with transfers between lines
SELECT Classes //A database with names of headings of columns without transfers
M_NumVar = 3 //Option of formation of heading
DO CASE
CASE M_NumVar = 1 //1. To "cut" the name of classes on slices on the DL symbols and to write down in aHeadName through ";"
DL = 8 //Width of heading in number of symbols
Max_HeadLines = -999999999
FOR j=1 TO N_Cls
DBGOTO(j)
M_NameCls = ALLTRIM(Name_cls)
aHeadName[2+j] = ALLTRIM(STR(j,15))+".;"
DO WHILE LEN(M_NameCls) > 0
aHeadName[2+j] = aHeadName[2+j] + SUBSTR(M_NameCls,1,DL) + ";"
M_NameCls = SUBSTR(M_NameCls,DL+1)
ENDDO
Max_HeadLines = 1+MAX(Max_HeadLines, NUMAT(";", aHeadName[2+j])) //Definition of the maximum quantity of lines in heading
NEXT
CASE M_NumVar = 2 //2. "Transfers instead of gaps"
Max_HeadLines = -999999999
FOR j=1 TO N_Cls
DBGOTO(j)
aHeadName[2+j] = ALLTRIM(STR(j,15))+". "+STRTRAN(ALLTRIM((Name_cls))," ",";")
Max_HeadLines = 1+MAX(Max_HeadLines, NUMAT(";", aHeadName[2+j])) //Definition of the maximum quantity of lines in heading
NEXT
CASE M_NumVar = 3 //3. To fill lines of headings with the whole words until the maximum width of heading is exceeded
DL = 8 //Width of heading in number of symbols
Max_HeadLines = -999999999
FOR j=1 TO N_Cls
DBGOTO(j)
M_NameCls = ALLTRIM(Name_cls)
aHeadString := {} //Massif of lines of the heading j-y of a column
AADD(aHeadString, ALLTRIM(STR(j,15))+". ") //Class code
*** Начало цикла по словам
FOR w=1 TO NUMTOKEN(M_NameCls," ") //A divider between words - a gap
M_Word = UPPER(TOKEN(M_NameCls," ",w))
IF LEN(aHeadString[LEN(aHeadString)]+" "+M_Word) <= DL
//If after word addition to a line of heading its width less set,
//that to add a word by same line of heading
aHeadString[LEN(aHeadString)] = aHeadString[LEN(aHeadString)]+" "+M_Word
ELSE
//If after word addition to a line of heading its width more set,
//that to do a new line (";") and to it to add a word
AADD(aHeadString, ";"+M_Word)
ENDIF
NEXT
//To copy lines of heading in an array of names of columns
aHeadName[2+j] = ""
FOR s=1 TO LEN(aHeadString)
aHeadName[2+j] = aHeadName[2+j] + aHeadString[s]
NEXT
Max_HeadLines = LEN(aHeadString) //Definition of the maximum quantity of lines in heading
NEXT
ENDCASE