Posted: Sun Nov 04, 2007 7:53 pm Post subject: Demo: Picture Control: Screen Display
Code:
program sap_picture_demo.
set screen 200.
TYPE-POOLS cndp.
************************************************************************
* CLASS c_event_receiver
* DEFINITION
************************************************************************
class c_event_receiver definition.
* The class is used to test the events raised by the cl_gui_picture
* class
public section.
methods event_handler_picture_dblclick
for event picture_dblclick of cl_gui_picture
importing mouse_pos_x mouse_pos_y sender.
methods event_handler_context_menu
for event context_menu of cl_gui_picture
importing sender.
methods event_handler_context_menu_sel
for event context_menu_selected of cl_gui_picture
importing fcode sender.
endclass.
************************************************************************
* DATA
************************************************************************
data function like sy-ucomm. " OK-Code field in screen 200
data url type cndp_url. " URL-field in screen 200
data url2 type cndp_url. " URL-field in screen 200
data picture_control_1 type ref to cl_gui_picture.
data picture_control_2 type ref to cl_gui_picture.
data container_1 type ref to cl_gui_custom_container.
data container_2 type ref to cl_gui_custom_container.
data event_receiver type ref to c_event_receiver.
data event_tab type cntl_simple_events.
data event_tab_line type cntl_simple_event.
data return type i.
************************************************************************
* PBO
* before_output
************************************************************************
module before_output output.
set pf-status 'MAIN0001'.
IF PICTURE_CONTROL_1 IS INITIAL.
* Create the event_receiver object and set the handlers for the events
* of the picture controls
create object event_receiver.
set handler event_receiver->event_handler_picture_dblclick
FOR PICTURE_CONTROL_1.
set handler event_receiver->event_handler_context_menu
FOR PICTURE_CONTROL_1.
set handler event_receiver->event_handler_context_menu_sel
FOR PICTURE_CONTROL_1.
set handler event_receiver->event_handler_picture_dblclick
FOR PICTURE_CONTROL_2.
set handler event_receiver->event_handler_context_menu
FOR PICTURE_CONTROL_2.
set handler event_receiver->event_handler_context_menu_sel
FOR PICTURE_CONTROL_2.
* Set the display mode to 'normal' (0)
CALL METHOD PICTURE_CONTROL_1->SET_DISPLAY_MODE
EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL.
CALL METHOD PICTURE_CONTROL_2->SET_DISPLAY_MODE
EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL.
* Set 3D Border
CALL METHOD PICTURE_CONTROL_1->SET_3D_BORDER
exporting border = 1.
CALL METHOD PICTURE_CONTROL_2->SET_3D_BORDER
exporting border = 1.
* new async implementation since 4.6C
CALL FUNCTION 'DP_PUBLISH_WWW_URL'
EXPORTING
OBJID = 'HTMLCNTL_TESTHTM2_SAP_AG'
LIFETIME = cndp_lifetime_transaction
IMPORTING
URL = url
EXCEPTIONS
OTHERS = 1.
* Load the picture by using the url generated by the data provider.
if sy-subrc = 0.
CALL METHOD PICTURE_CONTROL_1->LOAD_PICTURE_FROM_URL_ASYNC
exporting url = url.
endif.
************************************************************************
* PAI
* after_input
************************************************************************
module after_input input.
case function.
* At the end of the program destroy the control
when 'BACK'.
CALL METHOD container_1->FREE.
CALL METHOD container_2->FREE.
leave to screen 0.
* Clear the picture
when 'CLEAR'.
CALL METHOD PICTURE_CONTROL_1->CLEAR_PICTURE.
* Load a new picture
when space.
CALL METHOD PICTURE_CONTROL_1->LOAD_PICTURE_FROM_URL
exporting url = url
importing result = return.
call method cl_gui_cfw=>flush.
if return = 0.
url = text-000.
endif.
endcase.
clear function.
endmodule.
************************************************************************
* CLASS c_event_receiver
* IMPLEMENTATION
************************************************************************
CLASS C_event_receiver implementation.
************************************************************************
* CLASS c_event_receiver
* METHOD event_handler_picture_dblclick
************************************************************************
METHOD EVENT_HANDLER_PICTURE_DBLCLICK.
* for event picture_dblclick of c_picture_control
* importing mouse_pos_x mouse_pos_y.
DATA pos_x(5) type c.
DATA pos_y(5) type c.
pos_x = mouse_pos_x.
pos_y = mouse_pos_y.
IF SENDER = PICTURE_CONTROL_1.
MESSAGE I000(0K) WITH
'DoubleClick' 'Upper Picture' POS_X POS_Y. "#EC NOTEXT
else.
MESSAGE I000(0K) WITH
'DoubleClick' 'Lower Picture' POS_X POS_Y. "#EC NOTEXT
endif.
endmethod.
************************************************************************
* CLASS c_event_receiver
* METHOD event_handler_context_menu
************************************************************************
METHOD EVENT_HANDLER_CONTEXT_MENU.
data menu type ref to cl_ctmenu.
create object menu.
call method menu->ADD_FUNCTION exporting
fcode = text-001
TEXT = TEXT-001.
call method menu->ADD_FUNCTION exporting
FCODE = TEXT-002
TEXT = TEXT-002.
call method menu->ADD_FUNCTION exporting
FCODE = TEXT-003
TEXT = TEXT-003.
call method menu->ADD_FUNCTION exporting
FCODE = TEXT-004
TEXT = TEXT-004.
call method menu->ADD_FUNCTION exporting
FCODE = TEXT-005
TEXT = TEXT-005.
************************************************************************
* CLASS c_event_receiver
* METHOD event_handler_context_menu_sel
************************************************************************
METHOD EVENT_HANDLER_CONTEXT_MENU_sel.
DATA DISPLAY_MODE TYPE I.
IF FCODE = TEXT-001.
DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL.
ENDIF.
IF FCODE = TEXT-002.
DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_STRETCH.
ENDIF.
IF FCODE = TEXT-003.
DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT.
ENDIF.
IF FCODE = TEXT-004.
DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL_CENTER.
ENDIF.
IF FCODE = TEXT-005.
DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT_CENTER.
ENDIF.
CALL METHOD SENDER->SET_DISPLAY_MODE
EXPORTING DISPLAY_MODE = DISPLAY_MODE.
endmethod.
endclass.
*Text elements
*----------------------------------------------------------
* 005 Fit and center
* 004 Normal/centered
* 003 Fit
* 002 Stretch
* 001 Normal
* 000 Error loading the screen
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.