SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Demo: Picture Control: Icon display



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Dialog Programming
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Sun Nov 04, 2007 7:57 pm    Post subject: Demo: Picture Control: Icon display Reply with quote

Code:
program sap_picture_demo_icon.

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_control_click
          for event control_click of cl_gui_picture
          importing mouse_pos_x mouse_pos_y.
  methods event_handler_control_dblclick
          for event control_dblclick of cl_gui_picture
          importing mouse_pos_x mouse_pos_y.
endclass.


************************************************************************
* DATA
************************************************************************
data function like sy-ucomm.           " OK-Code field in screen 200
data event1(255) type c.
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 type cntl_simple_event.


************************************************************************
* PBO
* before_output
************************************************************************
module before_output output.
  set pf-status 'MAIN0001'.
  IF PICTURE_CONTROL_1 IS INITIAL.

* Create controls
    create object container_1
      exporting container_name = 'PICTURE_CONTROL_1'.
    create object container_2
      exporting container_name = 'PICTURE_CONTROL_2'.

    CREATE OBJECT PICTURE_CONTROL_1 exporting parent = container_1.
    CREATE OBJECT PICTURE_CONTROL_2 exporting parent = container_2.

* Register the events
    EVENT-eventid = CL_GUI_PICTURE=>EVENTID_CONTROL_DBLCLICK.
    append event to EVENT_TAB.
    CALL METHOD PICTURE_CONTROL_1->SET_REGISTERED_EVENTS
      exporting
        EVENTS = event_tab.
    clear event_tab.
    EVENT-EVENTID = CL_GUI_PICTURE=>EVENTID_CONTROL_CLICK.
    append event to EVENT_TAB.
    CALL METHOD PICTURE_CONTROL_2->SET_REGISTERED_EVENTS
      exporting
        EVENTS = event_tab.

* 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_control_dblclick
                FOR PICTURE_CONTROL_1.
    set handler event_receiver->event_handler_control_dblclick
                FOR PICTURE_CONTROL_2.
    set handler event_receiver->event_handler_control_click
                FOR PICTURE_CONTROL_1.
    set handler event_receiver->event_handler_control_click
                FOR PICTURE_CONTROL_2.

    CALL METHOD PICTURE_CONTROL_1->SET_DISPLAY_MODE
      EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT_CENTER.
    CALL METHOD PICTURE_CONTROL_2->SET_DISPLAY_MODE
      EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT_CENTER.

    CALL METHOD PICTURE_CONTROL_1->LOAD_PICTURE_FROM_SAP_ICONS
       exporting icon = '@01@'.
    CALL METHOD PICTURE_CONTROL_2->LOAD_PICTURE_FROM_SAP_ICONS
       exporting icon = '@02@'.

  endif.
endmodule.


************************************************************************
* PAI
* after_input
************************************************************************
module after_input input.
  case function.
* At the end of the program destroy the control
    when 'BACK'.
      CALL METHOD PICTURE_CONTROL_1->FREE.
      CALL METHOD PICTURE_CONTROL_2->FREE.
      CALL METHOD container_1->FREE.
      CALL METHOD container_2->FREE.
      leave to screen 0.

* Change the display mode
    when 'NORMAL'.
      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.
    when 'STRETCH'.
      CALL METHOD PICTURE_CONTROL_1->SET_DISPLAY_MODE
         EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_STRETCH.
      CALL METHOD PICTURE_CONTROL_2->SET_DISPLAY_MODE
         EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_STRETCH.
    when 'FIT'.
      CALL METHOD PICTURE_CONTROL_1->SET_DISPLAY_MODE
           EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT.
      CALL METHOD PICTURE_CONTROL_2->SET_DISPLAY_MODE
           EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT.
    when 'NORMAL_CTR'.
      CALL METHOD PICTURE_CONTROL_1->SET_DISPLAY_MODE
    EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL_CENTER.
      CALL METHOD PICTURE_CONTROL_2->SET_DISPLAY_MODE
    EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL_CENTER.
    when 'FIT_CTR'.
      CALL METHOD PICTURE_CONTROL_1->SET_DISPLAY_MODE
      EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT_CENTER.
      CALL METHOD PICTURE_CONTROL_2->SET_DISPLAY_MODE
      EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT_CENTER.

* 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_SAP_ICONS
           exporting icon = event1.

  endcase.

  clear function.
endmodule.


************************************************************************
* CLASS   c_event_receiver
* IMPLEMENTATION
************************************************************************
CLASS C_event_receiver implementation.


************************************************************************
* CLASS   c_event_receiver
* METHOD  event_handler_control_click
************************************************************************
  method event_handler_control_click.
*        for event control_click 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.

    MESSAGE I000(0K) WITH
      'Click' 'Lower Picture' POS_X POS_Y. "#EC NOTEXT
  endmethod.

************************************************************************
* CLASS   c_event_receiver
* METHOD  event_handler_control_dblclick
************************************************************************
  method event_handler_control_dblclick.
*        for event control_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.

    MESSAGE I000(0K) WITH
      'DoubleClick' 'Upper Picture' POS_X POS_Y. "#EC NOTEXT
  endmethod.

endclass.


*Messages
*----------------------------------------------------------
*
* Message class: 0K
*000   & & & &


****************************************************************
* This file was generated by Direct Download Enterprise. *
* Please do not change it manually. *
****************************************************************
%_DYNPRO
SAP_PICTURE_DEMO_ICON
0200
620
40
%_HEADER
SAP_PICTURE_DEMO_ICON 0200 0200 27 86192 35 0 0 27 86 0G D 19990226145619
%_DESCRIPTION
Screen with Two Image Controls
%_FIELDS
PICTURE_CONTROL_1 86 00 30 00 30 00 1 2 0 0 0 13 U 1 1 101
PICTURE_CONTROL_2 86 00 30 00 30 00 15 2 0 0 0
FUNCTION CHAR 20 80 10 00 00 00 255 1 O 0 0 0
%_FLOWLOGIC
PROCESS BEFORE OUTPUT.
MODULE BEFORE_OUTPUT.
*
PROCESS AFTER INPUT.
MODULE AFTER_INPUT.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Dialog Programming All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
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.