1// Copyright 2014 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef MOJO_EXAMPLES_KEYBOARD_KEYS_H_ 6#define MOJO_EXAMPLES_KEYBOARD_KEYS_H_ 7 8#include <vector> 9 10#include "base/basictypes.h" 11 12namespace mojo { 13namespace examples { 14 15enum SpecialKey { 16 SPECIAL_KEY_SHIFT = -1, 17 SPECIAL_KEY_NUMERIC = -2, 18 SPECIAL_KEY_ALPHA = -3, 19}; 20 21struct Key { 22 int keyboard_code() const { 23 // Handling of keycodes differs between in windows and others. 24#if defined(OS_WIN) 25 return generated_code ? generated_code : display_code; 26#else 27 return display_code; 28#endif 29 } 30 31 // Code used to get the value to display in the UI. This is either a 32 // KeyboardCode or a SpecialKey. 33 int display_code; 34 35 // How much space (as a percentage) the key is to take up. 36 float size; 37 38 // Any ui::EventFlags that are required to produce the key. 39 int event_flags; 40 41 // If non-zero KeyboardCode to generate. If 0 use the |display_code|. 42 int generated_code; 43}; 44 45struct Row { 46 float padding; 47 const Key* keys; 48 size_t num_keys; 49}; 50 51// Returns the rows for a qwerty style keyboard. The returned values are owned 52// by this object and should not be deleted. 53std::vector<const Row*> GetQWERTYRows(); 54 55// Returns the rows for a numeric keyboard. The returned values are owned 56// by this object and should not be deleted. 57std::vector<const Row*> GetNumericRows(); 58 59} // namespace examples 60} // namespace mojo 61 62#endif // MOJO_EXAMPLES_KEYBOARD_KEYS_H_ 63