Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grid Column positions
Message
 
À
04/07/2002 06:23:35
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00675275
Message ID:
00675285
Vues:
12
Wow!!!

That is some one liner. I'll have to study that.

Thanks
Geoff

>>Hi
>>
>>I suspect this may be a one-liner but I'll ask anyway.
>>
>>I have a grid in which the user can move the columns. When the user clicks on the header of a column I sort the grid (change index) by that column. Wanting to show the user which determines the current sort order I display an icon in the header.
>>
>>Problem 1
>>
>>How do I determine the current left position of the column???
>>
>>Problem 2
>>
>>What about when they scroll the grid horizontally???
>>
>>Regards
>>Geoff Scott
>
>Geoff,
>
>(1)
>
>You may get away with objtoclient() although I have never used it since I do not know how it will react when the grid has 2 partitions
>
>I have a routine that does that. You'll have to change to code, but it gives you an idea
>
>What it does is the following
>I add a non visual container to each of the columns in a grid. It's a place holder for icons to be displayed in the header.
>If the grid moves in any way, columns get resized, ... the routine is called
>
>The same column can appear in either of the partitions
>In addition a column may be partially displayed (far right) or not at all (scrolled)
>
>I use this for a filter capability (a la excel)
>
>The best advice I can give is to prepend a '^ ' or 'v ' to the caption of the header that is sorted (change the colour of the header, set the font to bold) rather than go this route.
>
>Success
>
>
>
>#define	Grid_WIDTH_Border		1
>#define Grid_WIDTH_RecordMark	iif(this.Recordmark, 10, 0)
>#define	Grid_WIDTH_DeleteMark	iif(this.DeleteMark, 8, 0)
>#define	Grid_WIDTH_Scrollbar		iif(inlist(this.ScrollBars,SCROLLBARS_VERTICAL,SCROLLBARS_BOTH), ;
>									sysmetric(SYSMETRIC_VSCROLLBARWIDTH), ;
>									0 ;
>								)
>#define	Grid_WIDTH_Offset		(Grid_WIDTH_RecordMark + Grid_WIDTH_DeleteMark + Grid_WIDTH_Border)
>
>#define	Grid_WIDTH_SplitBar		iif(this.SplitBar and this.Partition > 0, 1, 0)
>
>*--------------------------------------------
>
>#define	TRUE	.T.
>#define	FALSE	.F.
>
>** DisplayHeaders
>
>local LockScreen, i, obj
>
>if(		( this.ColumnCount <= 0 ) ;
>	or	empty(this.Columns[1].ControlCount) ;
>  )
>	*or	( this.Columns[1].Header1.Class <> '_header' ) ;
>  )
>	return	&& moved, resize
>endif
>
>LockScreen = thisform.LockScreen
>thisform.LockScreen = TRUE
>
>&& columnOrders
>local h[this.ColumnCount,3]
>
>for i = 1 to this.ColumnCount
>	obj = this.Columns[i]
>	
>				
>	obj.Visible = !empty(obj.Width)
>	
>	h[i,1] = obj.ColumnOrder
>	h[i,2] = obj	&& column
>	
>	h[i,3] = iif(obj.Header1.Class == '_header', obj._Header_node, Null)
>	*h[i,4] = obj.ControlSource
>endfor
>
>=Asort(h)
>
>
>&& Panels
>local np, Panels[2,3]
>np = iif(this.Partition = 0, 1, 2)
>
>	&& Left
>Panels[1,1] = this.Left + Grid_WIDTH_Offset
>	&& Width
>Panels[1,2] = iif( np = 1, this.Width - Grid_WIDTH_Border, this.Partition + Grid_WIDTH_SplitBar) - Grid_WIDTH_Scrollbar - Grid_WIDTH_Offset
>	&& LeftColumn
>if( (np = 1) or empty(this.Panel) )
>	Panels[1,3] = this.LeftColumn
>else
>	this.Panel = 0
>	Panels[1,3] = this.LeftColumn
>	this.Panel = 1
>endif
>
>if( np > 1 )
>	Panels[2,1] = this.Left + this.Partition + Grid_WIDTH_Offset
>	Panels[2,2] = this.Width - Grid_WIDTH_Scrollbar - Grid_WIDTH_Offset - this.Partition - Grid_WIDTH_SplitBar
>	if( empty(this.Panel) )
>		this.Panel = 1
>		Panels[2,3] = this.LeftColumn
>		this.Panel = 0
>	else
>		Panels[2,3] = this.LeftColumn
>	endif
>else
>	Panels[2,1] = 0
>	Panels[2,2] = 0
>	Panels[2,3] = 999999
>endif
>		
>
>&& process panels
>
>local _Top, _Height, _Width, _left
>_Top = this.Top + 1
>_height = this.HeaderHeight -1 - 1
>
>local p, _Col, obj, _hdr, nObjects, AvailableWidth, ColWidth
>local objWidth, objHeight, objTop, objLeft
>
>
>for p = 1 to 2
>	_left = Panels[p,1]
>	_width = Panels[p,2]
>
>	for i = 1 to this.ColumnCount
>		
>		_col = h[i,2]
>
>		
>		do case
>		case !_Col.Visible
>			ColWidth = 0
>		case (i < Panels[p,3])
>			colWidth = -1
>		otherwise
>			ColWidth = _Col.Width
>		endcase
>		
>		
>		if( !isNull(h[i,3]) )
>			_hdr = h[i,3]
>			
>			nObjects = _hdr.ControlCount
>			
>			AvailableWidth = min(_Width, _Col.Width)
>			
>			for j = 1 to nObjects
>				obj = _hdr.Controls[j].Child[p]
>				
>				if( (AvailableWidth > 0) and (ColWidth > 0) )
>					if( isnull(obj) or (type('obj') <> T_OBJECT) ) && gone, Form destroy or release
>						thisform.LockScreen = LockScreen
>						return
>					endif
>					
>					objWidth = int(min(obj.Max_Width, min(AvailableWidth, ColWidth ) / nObjects))
>					objHeight = min(_height, obj.Max_Height)
>					
>					&& bottom Align
>					objTop = _Top + _height - objHeight
>					
>					&& there are two options
>					&& (1): squeeze
>					&& (2): if outside available width, do not display
>					&& take option (1)
>					objLeft = _left + (AvailableWidth - objWidth)* obj.Alignment
>					
>					obj.Move(objLeft, objTop, objWidth, objHeight )
>					obj.VisibleRange = TRUE
>				else
>					obj.VisibleRange = FALSE
>				endif
>			endfor
>		endif
>		
>		_Left	= _left  + ColWidth + 1
>		_Width	= _Width - ColWidth - 1
>	endfor
>endfor
>
>thisform.LockScreen = LockScreen
>
>
>
>(2) changes in Grid layout
>
>Call the routine if any of the following occur
>
>- Visible_Assign of the grid
>- RecordSource changes
>- AfterRowColChange() && horizontal scroll
>- Moved()
>- Resize()
>- Scrolled(): I don't do anything in there (rather in AfterRowColChange())
>- MouseUp when in
> - 5 && Splitbar (see gridhittest)
> - 13 && Column header sizing area
> - 16 && Horizontal scrollbar
>
>- I also track the mousedown and mouseup in the header
> MouseDown: save x, y
> MouseUp: compare saved x with x, saved y with y
> if either of them are not equal (header rezize, column moved, ..), call the routine
May all your weeds be wildflowers
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform