|
|
|
|
|
Re: Setting Visual attribute differrent for diffrrent record in tabular block [message #127219 is a reply to message #127216] |
Sun, 10 July 2005 03:22 |
|
Maaher
Messages: 7065 Registered: December 2001
|
Senior Member |
|
|
I can't give you exact code but here are some pointers:
- evaluate the record_number: if it's odd use one visual_attribute and if it's even use another.
- use a set_item_instance_property built-in for each item you want to change.
This could be part of your post-query trigger (careful, not tested!)
BEGIN
IF MOD( to_number(:system.cursor_record)
, 2
) = 1
THEN
SET_ITEM_INSTANCE_PROPERTY( :system.cursor_record
, 'theblock.theitem'
, visual_attribute
, 'Your_first_visual_attribute');
ELSE
SET_ITEM_INSTANCE_PROPERTY( :system.cursor_record
, 'theblock.theitem'
, visual_attribute
, 'Your_other_visual_attribute');
END IF;
END;
HTH,
MHE
|
|
|
|
|
|
|
Re: Setting Visual attribute differrent for diffrrent record in tabular block [message #127567 is a reply to message #127552] |
Tue, 12 July 2005 04:55 |
|
Maaher
Messages: 7065 Registered: December 2001
|
Senior Member |
|
|
Code in post-query:
Declare
v_curr_rec PLS_INTEGER := get_block_property('EMP',CURRENT_RECORD);
Begin
if mod(v_curr_rec, 2) = 1
then -- odd_records: white
set_block_color('EMP', v_curr_rec, 'WHITE');
else -- even records: gray
set_block_color('EMP', v_curr_rec, 'GRAY');
end if;
End;
Here's the program unit's code:
PROCEDURE set_block_color (piv_block_name IN VARCHAR2, pin_rec_number IN NUMBER, piv_color IN VARCHAR2)
IS
/* PROCEDURE SET_BLOCK_COLOR
|| Purpose: Sets all text items in a block to a certain color through visual attributes.
||
|| Parameters: block name, record_number, color
||
|| DEMO: Verify before use in a production environment!
*/
v_item VARCHAR2 (120);
v_va_name VARCHAR2 (120);
v_va_id visualattribute;
BEGIN
-- construct the visual attribute's name ( convention: VA_<<COLOR>> )
v_va_name := 'VA_' || piv_color;
-- verify the existance of the visual attribute
v_va_id := FIND_VA (v_va_name);
IF ID_NULL (v_va_id)
THEN
-- visual attribute not found, default to 'WHITE'
v_va_name := 'WHITE';
END IF;
-- go to the first item in the block
v_item := GET_BLOCK_PROPERTY (piv_block_name, first_item);
<<va_loop>>
LOOP
-- check whether the item is a text item and whether the visual attribute was found
IF (GET_ITEM_PROPERTY (piv_block_name || '.' || v_item, item_type) = 'TEXT ITEM')
AND NOT ID_NULL (v_va_id)
THEN
-- set the item's visual attribute
SET_ITEM_INSTANCE_PROPERTY (piv_block_name || '.' || v_item, pin_rec_number, visual_attribute, v_va_name);
END IF;
-- if we've reached the last item in the block, exit the loop.
EXIT va_loop WHEN v_item = GET_BLOCK_PROPERTY (piv_block_name, last_item);
v_item := GET_ITEM_PROPERTY (piv_block_name || '.' || v_item, nextitem);
END LOOP va_loop;
END;
Seems to do the job. For the original poster it's not that hard to modify it to his needs.
MHE
|
|
|
Re: Setting Visual attribute differrent for diffrrent record in tabular block [message #336614 is a reply to message #127318] |
Mon, 28 July 2008 06:52 |
jale
Messages: 15 Registered: May 2008 Location: TURKEY
|
Junior Member |
|
|
Code is great..
But I have a problem that my block contains items which aren't on canvas and block is a view.
I tried in your form, if an item is not on canvas, code is working either, but in my forms, it doesn't work, I looked for item properties, I found nothing, so I add canvas property to code.
Thank you
PROCEDURE set_block_color (piv_block_name IN VARCHAR2, pin_rec_number IN NUMBER, piv_color IN VARCHAR2)
IS
/* PROCEDURE SET_BLOCK_COLOR
|| Purpose: Sets all text items in a block to a certain color through visual attributes.
||
|| Parameters: block name, record_number, color
||
|| DEMO: Verify before use in a production environment!
*/
v_item VARCHAR2 (120);
v_va_name VARCHAR2 (120);
v_va_id visualattribute;
v_canvas varchar2 (120);
BEGIN
-- construct the visual attribute's name ( convention: VA_<<COLOR>> )
v_va_name := 'VA_' || piv_color;
-- verify the existance of the visual attribute
v_va_id := FIND_VA (v_va_name);
IF ID_NULL (v_va_id)
THEN
-- visual attribute not found, default to 'WHITE'
v_va_name := 'WHITE';
END IF;
-- go to the first item in the block
v_item := GET_BLOCK_PROPERTY (piv_block_name, first_item);
<<va_loop>>
LOOP
--check the item_canvas
if GET_ITEM_PROPERTY (piv_block_name || '.' || v_item, item_CANVAS) is not null then
v_canvas:=GET_ITEM_PROPERTY (piv_block_name || '.' || v_item, item_CANVAS);
end if;
-- check whether the item is a text item and whether the visual attribute was found
IF (GET_ITEM_PROPERTY (piv_block_name || '.' || v_item, item_type) = 'TEXT ITEM')
AND NOT ID_NULL (v_va_id)
AND (GET_ITEM_PROPERTY (piv_block_name || '.' || v_item, item_CANVAS) = v_canvas)
THEN
-- set the item's visual attribute
SET_ITEM_INSTANCE_PROPERTY (piv_block_name || '.' || v_item, pin_rec_number, visual_attribute, v_va_name);
END IF;
-- if we've reached the last item in the block, exit the loop.
EXIT va_loop WHEN v_item = GET_BLOCK_PROPERTY (piv_block_name, last_item);
v_item := GET_ITEM_PROPERTY (piv_block_name || '.' || v_item, nextitem);
END LOOP va_loop;
END;
[Updated on: Mon, 28 July 2008 07:35] Report message to a moderator
|
|
|