| OLD | NEW | 
|     1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |     1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 
|     2 // Use of this source code is governed by a BSD-style license that can be |     2 // Use of this source code is governed by a BSD-style license that can be | 
|     3 // found in the LICENSE file. |     3 // found in the LICENSE file. | 
|     4  |     4  | 
|     5 #include "views/controls/menu/menu_controller.h" |     5 #include "views/controls/menu/menu_controller.h" | 
|     6  |     6  | 
|     7 #include "app/l10n_util.h" |     7 #include "app/l10n_util.h" | 
|     8 #include "app/os_exchange_data.h" |     8 #include "app/os_exchange_data.h" | 
|     9 #include "base/i18n/rtl.h" |     9 #include "base/i18n/rtl.h" | 
|    10 #include "base/keyboard_codes.h" |    10 #include "base/keyboard_codes.h" | 
|    11 #include "base/time.h" |    11 #include "base/time.h" | 
|    12 #include "gfx/canvas.h" |    12 #include "gfx/canvas.h" | 
|    13 #include "views/controls/button/menu_button.h" |    13 #include "views/controls/button/menu_button.h" | 
|    14 #include "views/controls/menu/menu_scroll_view_container.h" |    14 #include "views/controls/menu/menu_scroll_view_container.h" | 
|    15 #include "views/controls/menu/submenu_view.h" |    15 #include "views/controls/menu/submenu_view.h" | 
|    16 #include "views/drag_utils.h" |    16 #include "views/drag_utils.h" | 
|    17 #include "views/screen.h" |    17 #include "views/screen.h" | 
|    18 #include "views/view_constants.h" |    18 #include "views/view_constants.h" | 
|    19 #include "views/widget/root_view.h" |    19 #include "views/widget/root_view.h" | 
|    20 #include "views/widget/widget.h" |    20 #include "views/widget/widget.h" | 
|    21 #if defined(OS_LINUX) |  | 
|    22 #include "base/keyboard_code_conversion_gtk.h" |  | 
|    23 #endif |  | 
|    24  |    21  | 
|    25 using base::Time; |    22 using base::Time; | 
|    26 using base::TimeDelta; |    23 using base::TimeDelta; | 
|    27  |    24  | 
|    28 // Period of the scroll timer (in milliseconds). |    25 // Period of the scroll timer (in milliseconds). | 
|    29 static const int kScrollTimerMS = 30; |    26 static const int kScrollTimerMS = 30; | 
|    30  |    27  | 
|    31 // Delay, in ms, between when menus are selected are moused over and the menu |    28 // Delay, in ms, between when menus are selected are moused over and the menu | 
|    32 // appears. |    29 // appears. | 
|    33 static const int kShowDelay = 400; |    30 static const int kShowDelay = 400; | 
| (...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   691  |   688  | 
|   692 #else |   689 #else | 
|   693 bool MenuController::Dispatch(GdkEvent* event) { |   690 bool MenuController::Dispatch(GdkEvent* event) { | 
|   694   gtk_main_do_event(event); |   691   gtk_main_do_event(event); | 
|   695  |   692  | 
|   696   if (exit_type_ == EXIT_ALL) |   693   if (exit_type_ == EXIT_ALL) | 
|   697     return false; |   694     return false; | 
|   698  |   695  | 
|   699   switch (event->type) { |   696   switch (event->type) { | 
|   700     case GDK_KEY_PRESS: { |   697     case GDK_KEY_PRESS: { | 
|   701       base::KeyboardCode win_keycode = |   698       if (!OnKeyDown(event->key.keyval)) | 
|   702           base::WindowsKeyCodeForGdkKeyCode(event->key.keyval); |  | 
|   703       if (!OnKeyDown(win_keycode)) |  | 
|   704         return false; |   699         return false; | 
|   705       guint32 keycode = gdk_keyval_to_unicode(event->key.keyval); |   700       guint32 keycode = gdk_keyval_to_unicode(event->key.keyval); | 
|   706       if (keycode) |   701       if (keycode) | 
|   707         return !SelectByChar(keycode); |   702         return !SelectByChar(keycode); | 
|   708       return true; |   703       return true; | 
|   709     } |   704     } | 
|   710  |   705  | 
|   711     default: |   706     default: | 
|   712       break; |   707       break; | 
|   713   } |   708   } | 
|   714  |   709  | 
|   715   return exit_type_ == EXIT_NONE; |   710   return exit_type_ == EXIT_NONE; | 
|   716 } |   711 } | 
|   717 #endif |   712 #endif | 
|   718  |   713  | 
|   719 bool MenuController::OnKeyDown(int key_code |   714 bool MenuController::OnKeyDown(int key_code | 
|   720 #if defined(OS_WIN) |   715 #if defined(OS_WIN) | 
|   721                                , const MSG& msg |   716                                , const MSG& msg | 
|   722 #else |   717 #else | 
|   723 #endif |   718 #endif | 
|   724                                ) { |   719                                ) { | 
|   725   DCHECK(blocking_run_); |   720   DCHECK(blocking_run_); | 
|   726   DLOG(WARNING) << "OnKeyDown: " << key_code; |  | 
|   727  |   721  | 
|   728   switch (key_code) { |   722   switch (key_code) { | 
|   729     case base::VKEY_UP: |   723     case base::VKEY_UP: | 
|   730       IncrementSelection(-1); |   724       IncrementSelection(-1); | 
|   731       break; |   725       break; | 
|   732  |   726  | 
|   733     case base::VKEY_DOWN: |   727     case base::VKEY_DOWN: | 
|   734       IncrementSelection(1); |   728       IncrementSelection(1); | 
|   735       break; |   729       break; | 
|   736  |   730  | 
| (...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1502   if (!scroll_task_.get()) |  1496   if (!scroll_task_.get()) | 
|  1503     scroll_task_.reset(new MenuScrollTask()); |  1497     scroll_task_.reset(new MenuScrollTask()); | 
|  1504   scroll_task_->Update(part); |  1498   scroll_task_->Update(part); | 
|  1505 } |  1499 } | 
|  1506  |  1500  | 
|  1507 void MenuController::StopScrolling() { |  1501 void MenuController::StopScrolling() { | 
|  1508   scroll_task_.reset(NULL); |  1502   scroll_task_.reset(NULL); | 
|  1509 } |  1503 } | 
|  1510  |  1504  | 
|  1511 }  // namespace views |  1505 }  // namespace views | 
| OLD | NEW |