Collected From: http://sheikyerbouti.developpez.com/moveitem/Designer_Forms_Move_item.htm
Because, when you generate Oracle Forms application from Oracle
Designer,
it is not always possible to place item at the exact position you want,
this is a
PL/SQL procedure which will do the job for you at runtime.
This procedure accept 4 parameters :
The reference item (VARCHAR2)
which is the item used to define the start display
The item to move (VARCHAR2)
which is the item you want to move
The horizontal position
(VARCHAR2) which can be ‘L’ (left) or ‘R’ (right)
The vertical position
(VARCHAR2) which can be 'F' (floor), 'C' (ceil), 'T' (top), 'B' (bottom)
Horizontal and vertical
arguments accept also a positive or a negative offset
specified in pixel
Demonstration
This is a hard copy of a
Forms dialog
And here is the procedure
called in the WHEN-BUTTON-PRESSED
PROCEDURE move_all IS
BEGIN
Move_Item
( 'BL.BTREF','BL.BT1','L','C') ;
Move_Item
( 'BL.BTREF','BL.BT2','L','T') ;
Move_Item
( 'BL.BTREF','BL.BT3','L','F') ;
Move_Item
( 'BL.BTREF','BL.BT4','L','B') ;
Move_Item
( 'BL.BTREF','BL.BT5','R','C') ;
Move_Item
( 'BL.BTREF','BL.BT6','R','T') ;
Move_Item
( 'BL.BTREF','BL.BT7','R','F') ;
Move_Item
( 'BL.BTREF','BL.BT8','R','B') ;
END;
Then the hard copy of the
screen after the calls to the move_item() procedure
This procedure is
coordinate-system independent so conversion is made
If your screen is in INCHES,
POINTS or CENTIMETERS coordinate-system
If you want the :BL.BT7 item
on the Right + 20 pixels from the reference item, enter :
Move_Item ( 'BL.BTREF','BL.BT7','R+20','F') ;
Code of the Move_item()
procedure
PROCEDURE Move_Item
(
PC$Item_Ref in Varchar2,
PC$Bouton in Varchar2,
PC$Horizontal in Varchar2,
PC$Vertical in Varchar2
) IS
--
------------------------------------------
--
Positionning of item from another one
------------------------------------------
--
-- IN : PC$Item_ref (reference item)
-- : PC$Bouton (item to move)
-- : PC$Horizontal ('L' on left, 'R' on
right)
-- : PC$Vertical ('F' floor, 'C' ceil, 'T'
top, 'B' bottom)
--
--
Reference item --
LN$PosX Number;
LN$PosY Number;
LN$Width NUMBER;
LN$Heigth NUMBER;
-- Item to
move --
LN$Bwidth NUMBER;
LN$Bheigth NUMBER;
LN$NewX NUMBER;
LN$NewY NUMBER ;
-- Offset
--
LN$Pos PLS_INTEGER ;
LN$HOffset NUMBER := 0 ;
LN$VOffset NUMBER := 0 ;
--
Coordinate system --
LC$Scoord VARCHAR2(100) := Get_Form_Property(
Name_in('system.current_form'), COORDINATE_SYSTEM ) ;
Begin
--
Reference item --
LN$PosX := Get_Item_Property(PC$Item_Ref, X_POS );
LN$PosY := Get_Item_Property(PC$Item_Ref, Y_POS );
LN$Width := Get_Item_Property(PC$Item_Ref, WIDTH );
LN$Heigth := Get_Item_Property(PC$Item_Ref, HEIGHT );
-- Item to
move --
LN$BWidth := Get_Item_Property(PC$Bouton, WIDTH );
LN$BHeigth
:= Get_Item_Property(PC$Bouton, HEIGHT );
-- Offsets
--
LN$Pos :=
Instr( PC$Horizontal, '-' ) ;
If LN$Pos
> 0 Then
LN$HOffset
:= To_Number( Substr( PC$Horizontal, LN$Pos, 5 ) ) ;
End if ;
LN$Pos :=
Instr( PC$Horizontal, '+' ) ;
If LN$Pos
> 0 Then
LN$HOffset
:= To_Number( Substr( PC$Horizontal, LN$Pos, 5 ) ) ;
End if ;
LN$Pos :=
Instr( PC$Vertical, '-' ) ;
If LN$Pos
> 0 Then
LN$VOffset
:= To_Number( Substr( PC$Vertical, LN$Pos, 5 ) ) ;
End if ;
LN$Pos :=
Instr( PC$Vertical, '+' ) ;
If LN$Pos
> 0 Then
LN$VOffset
:= To_Number( Substr( PC$Vertical, LN$Pos, 5 ) ) ;
End if ;
--
Conversion of offset in pixel --
If LC$Scoord
= 'INCHES' Then
LN$HOffset
:= LN$HOffset * 0.0104 ;
LN$VOffset := LN$VOffset * 0.0104 ;
ElsIf LC$Scoord = 'POINTS' Then
LN$HOffset
:= LN$HOffset * 1.333 ;
LN$VOffset := LN$VOffset * 1.333 ;
ElsIf LC$Scoord = 'CENTIMETERS' Then
LN$HOffset
:= LN$HOffset * 0.0263 ;
LN$VOffset := LN$VOffset * 0.0263 ;
End if ;
If
Substr(PC$Horizontal,1,1) = 'L' Then -- on left
If
Substr(PC$Vertical,1,1) Not in ('B','T') Then
LN$NewX
:= LN$PosX - LN$BWidth ;
Else
LN$NewX
:= LN$PosX ;
End
if ;
Else -- on
right
If
Substr(PC$Vertical,1,1) Not in ('B','T') Then
LN$NewX
:= LN$PosX + LN$Width ;
Else
LN$NewX
:= LN$PosX + LN$Width - LN$BWidth ;
End
if ;
End if ;
LN$NewX :=
LN$NewX + LN$HOffset ;
If
Substr(PC$Vertical,1,1) = 'F' Then -- floor
LN$NewY
:= (LN$PosY + LN$Heigth) - LN$BHeigth ;
ElsIf
Substr(PC$Vertical,1,1) = 'C' Then -- ceil
LN$NewY := LN$PosY ;
ElsIf
Substr(PC$Vertical,1,1) = 'T' Then -- top
LN$NewY := LN$PosY -
LN$BHeigth ;
Else -- bottom
LN$NewY := LN$PosY + LN$Heigth ;
End if ;
LN$NewY :=
LN$NewY + LN$VOffset ;
Set_Item_Property(
PC$Bouton, POSITION, LN$NewX, LN$NewY ) ;
END;
0 comments:
Post a Comment