Использование GOS контейнера
Создание toolbar-a на экране выбора:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
DATA: o_cnt_gos TYPE REF TO cl_gui_gos_container. DATA: o_toolbar TYPE REF TO cl_gui_toolbar. CLASS lcl_events DEFINITION. PUBLIC SECTION. TYPES: ty_it_events TYPE STANDARD TABLE OF cntl_simple_event WITH DEFAULT KEY. CLASS-METHODS: on_function_selected FOR EVENT function_selected OF cl_gui_toolbar IMPORTING fcode. ENDCLASS. CLASS lcl_events IMPLEMENTATION. METHOD on_function_selected. MESSAGE fcode TYPE 'S'. ENDMETHOD. ENDCLASS. PARAMETERS: p_chk1 AS CHECKBOX USER-COMMAND cmd1. INITIALIZATION. o_cnt_gos = NEW #( width = 300 ). o_toolbar = NEW #( parent = o_cnt_gos display_mode = cl_gui_toolbar=>m_mode_horizontal ). o_toolbar->add_button( fcode = 'BTN1' icon = icon_open butn_type = cntb_btype_button ). o_toolbar->add_button( fcode = '' icon = '' butn_type = cntb_btype_sep ). o_toolbar->add_button( fcode = 'BTN2' icon = icon_system_save butn_type = cntb_btype_button ). DATA(it_events) = VALUE lcl_events=>ty_it_events( ( eventid = cl_gui_toolbar=>m_id_function_selected appl_event = abap_true ) ). o_toolbar->set_registered_events( events = it_events ). SET HANDLER lcl_events=>on_function_selected FOR o_toolbar. AT SELECTION-SCREEN. CASE sy-ucomm. WHEN 'CMD1'. o_cnt_gos->set_visible( COND abap_bool( WHEN p_chk1 = abap_true THEN abap_false ELSE abap_true ) ). ENDCASE. START-OF-SELECTION. WRITE: / p_chk1. |
Текстовый редактор в GOS контейнере:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
DATA: o_cnt_gos TYPE REF TO cl_gui_gos_container. DATA: o_edit TYPE REF TO cl_gui_textedit. PARAMETERS: p_test TYPE c. INITIALIZATION. DATA(lv_x_metric) = cl_gui_cfw=>compute_metric_from_dynp( metric = cl_gui_control=>metric_pixel x_or_y = 'X' in = sy-scols ). o_cnt_gos = NEW #( width = lv_x_metric ). o_edit = NEW #( wordwrap_mode = cl_gui_textedit=>wordwrap_at_windowborder wordwrap_to_linebreak_mode = cl_gui_textedit=>true parent = o_cnt_gos ). o_edit->set_font_fixed( mode = cl_gui_textedit=>true ). o_edit->set_toolbar_mode( toolbar_mode = cl_gui_textedit=>false ). o_edit->set_statusbar_mode( statusbar_mode = cl_gui_textedit=>false ). o_edit->set_textstream( 'Testtext' ). START-OF-SELECTION. IF o_edit IS BOUND. DATA(lv_text) = ||. o_edit->get_textstream( IMPORTING text = lv_text ). cl_gui_cfw=>flush( ). WRITE: / lv_text. ENDIF. |
HTML браузер:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
DATA: o_cnt_gos TYPE REF TO cl_gui_gos_container. DATA: o_html TYPE REF TO cl_gui_html_viewer. PARAMETERS: p_test TYPE c. INITIALIZATION. DATA(lv_x_metric) = cl_gui_cfw=>compute_metric_from_dynp( metric = cl_gui_control=>metric_pixel x_or_y = 'X' in = sy-scols ). o_cnt_gos = NEW #( width = lv_x_metric ). o_html = NEW cl_gui_html_viewer( parent = o_cnt_gos ). DATA(it_html) = VALUE w3_htmltab( ( '<html><head><style>body { margin: 0; background-color: #00BBCC; color: #001122; font: 18px "Courier" }</style></head>' ) ( '<body>Test</body></html>' ) ). DATA: lv_url TYPE swk_url. o_html->load_data( IMPORTING assigned_url = lv_url CHANGING data_table = it_html ). o_html->show_url( lv_url ). START-OF-SELECTION. WRITE: / p_test. |