Global Type f_dw_sort From function_object
End Type
Forward Prototypes
Global Subroutine f_dw_sort (datawindow adw)
End Prototypes
Global Subroutine f_dw_sort (datawindow adw);
//====================================================================
// Function: f_dw_sort()
//--------------------------------------------------------------------
// Description: Sort When Click On Title Column
//--------------------------------------------------------------------
// Arguments:
// value datawindow adw
//--------------------------------------------------------------------
// Returns: (none)
//====================================================================
String ls_col, ls_sort, ls_old
Long li_pos
Long ll_X1, ll_Y1, ll_X2, ll_Y2, ll_X3, ll_x4, ll_Y3, ll_Y4
String ls_Mod
If adw.RowCount() < 1 Then Return
adw.SetRedraw( False )
//get old sort
ls_old = adw.Object.datawindow.Table.Sort
//get column click on
ls_col = adw.GetObjectAtPointer()
li_pos = Pos(ls_col,'~t')
ls_col = Left(ls_col, li_pos - 1)
If Not Lower(Right(ls_col,2)) = "_t" Then
adw.SetRedraw( True )
Return
End If
ls_Mod = "Destroy sort_ln1 Destroy sort_ln2 Destroy sort_ln3"
adw.Modify( ls_Mod )
ls_col = Left(ls_col, Len(ls_col) - 2)
ll_X1 = Long( adw.Describe( ls_col + '_t.X' ) ) + 5
ll_Y1 = Long( adw.Describe( ls_col + '_t.Y' ) ) + 3
ll_X2 = PixelsToUnits( UnitsToPixels( ll_X1, XUnitsToPixels! ) + 4, XPixelsToUnits! )
ll_X3 = PixelsToUnits( UnitsToPixels( ll_X1, XUnitsToPixels! ) + 3, XPixelsToUnits! )
ll_x4 = PixelsToUnits( UnitsToPixels( ll_X1, XUnitsToPixels! ) + 8, XPixelsToUnits! )
ll_Y2 = PixelsToUnits( UnitsToPixels( ll_Y1, YUnitsToPixels! ) + 4, YPixelsToUnits! )
ll_Y3 = PixelsToUnits( UnitsToPixels( ll_Y1, YUnitsToPixels! ) + 5, YPixelsToUnits! )
ll_Y4 = PixelsToUnits( UnitsToPixels( ll_Y1, YUnitsToPixels! ) - 1, YPixelsToUnits! )
ls_sort = ls_col + " A"
If ls_sort = ls_old Then
ls_sort = ls_col + " D"
ls_Mod = 'create line(band=header x1="' + String( ll_X1 ) &
+ '" y1="' + String( ll_Y2 ) &
+ '" x2="' + String( ll_x4 ) + '" y2="' + String( ll_Y2 ) &
+ '" pen.style="0" pen.width="5" ' &
+ 'pen.color="1089522856" background.mode="2" ' &
+ 'background.color="16777215" name=sort_ln1 )'
ls_Mod += ' create line(band=header x1="' + String( ll_X1 ) &
+ '" y1="' + String( ll_Y2 ) &
+ '" x2="' + String( ll_X2 ) + '" y2="' + String( ll_Y1 ) &
+ '" pen.style="0" pen.width="5" ' &
+ 'pen.color="33554432" background.mode="2" ' &
+ 'background.color="16777215" name=sort_ln2 )'
ls_Mod += ' create line(band=header x1="' + String( ll_x4 ) &
+ '" y1="' + String( ll_Y2 ) &
+ '" x2="' + String( ll_X3 ) + '" y2="' &
+ String( ll_Y4 ) + '" pen.style="0" pen.width="5" ' &
+ 'pen.color="1089522856" background.mode="2" ' &
+ 'background.color="16777215" name=sort_ln3 )'
Else
ls_sort = ls_col + " A"
ls_Mod = 'create line(band=header x1="' + String( ll_X1 ) &
+ '" y1="' + String( ll_Y1 ) &
+ '" x2="' + String( ll_x4 ) + '" y2="' &
+ String( ll_Y1 ) + '" pen.style="0" pen.width="5" ' &
+ 'pen.color="33554432" background.mode="2" ' &
+ 'background.color="16777215" name=sort_ln1 )'
ls_Mod += ' create line(band=header x1="' + String( ll_X1 ) &
+ '" y1="' + String( ll_Y1 ) &
+ '" x2="' + String( ll_X2 ) + '" y2="' &
+ String( ll_Y2 ) + '" pen.style="0" pen.width="5" ' &
+ 'pen.color="33554432" background.mode="2" ' &
+ 'background.color="16777215" name=sort_ln2 )'
ls_Mod += ' create line(band=header x1="' + String( ll_x4 ) &
+ '" y1="' + String( ll_Y1 ) &
+ '" x2="' + String( ll_X3 ) + '" y2="' &
+ String( ll_Y3 ) + '" pen.style="0" pen.width="5" ' &
+ 'pen.color="1089522856" background.mode="2" ' &
+ 'background.color="16777215" name=sort_ln3 )'
End If
// Create the triangle
adw.Modify( ls_Mod )
adw.SetSort(ls_sort)
adw.Sort()
adw.SetRedraw( True )
Return
End Subroutine