1 // Copyright 2014 The ChromeOS IME Authors. All Rights Reserved.
2 // limitations under the License.
3 // See the License for the specific language governing permissions and
4 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5 // distributed under the License is distributed on an "AS-IS" BASIS,
6 // Unless required by applicable law or agreed to in writing, software
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // You may obtain a copy of the License at
11 // you may not use this file except in compliance with the License.
12 // Licensed under the Apache License, Version 2.0 (the "License");
14 goog.provide('i18n.input.chrome.inputview.elements.layout.HandwritingLayout');
16 goog.require('goog.dom.classlist');
17 goog.require('i18n.input.chrome.inputview.Css');
18 goog.require('i18n.input.chrome.inputview.elements.Element');
19 goog.require('i18n.input.chrome.inputview.elements.ElementType');
20 goog.require('i18n.input.chrome.inputview.elements.Weightable');
23 goog.scope(function() {
30 * @param {string} id The id.
31 * @param {goog.events.EventTarget=} opt_eventTarget The event target.
33 * @extends {i18n.input.chrome.inputview.elements.Element}
34 * @implements {i18n.input.chrome.inputview.elements.Weightable}
36 i18n.input.chrome.inputview.elements.layout.HandwritingLayout = function(id,
38 goog.base(this, id, i18n.input.chrome.inputview.elements.ElementType.
39 HANDWRITING_LAYOUT, opt_eventTarget);
41 goog.inherits(i18n.input.chrome.inputview.elements.layout.HandwritingLayout,
42 i18n.input.chrome.inputview.elements.Element);
43 var HandwritingLayout =
44 i18n.input.chrome.inputview.elements.layout.HandwritingLayout;
48 * The height in weight unit.
53 HandwritingLayout.prototype.heightInWeight_ = 0;
57 * The width in weight unit.
62 HandwritingLayout.prototype.widthInWeight_ = 0;
66 HandwritingLayout.prototype.createDom = function() {
67 goog.base(this, 'createDom');
69 goog.dom.classlist.add(this.getElement(), i18n.input.chrome.inputview.Css.
75 HandwritingLayout.prototype.enterDocument = function() {
76 goog.base(this, 'enterDocument');
83 * Gets the first child.
87 HandwritingLayout.prototype.calculate_ = function() {
88 var child = /** @type {i18n.input.chrome.inputview.elements.Weightable} */ (
90 this.heightInWeight_ = child.getHeightInWeight();
91 this.widthInWeight_ = child.getWidthInWeight();
96 HandwritingLayout.prototype.getHeightInWeight = function() {
97 return this.heightInWeight_;
102 HandwritingLayout.prototype.getWidthInWeight = function() {
103 return this.widthInWeight_;
108 HandwritingLayout.prototype.resize = function(width, height) {
109 goog.base(this, 'resize', width, height);
110 for (var i = 0; i < this.getChildCount(); i++) {
111 var child = /** @type {i18n.input.chrome.inputview.elements.Element} */ (
114 Math.ceil(width * child.getWidthInWeight() / this.widthInWeight_),
115 Math.ceil(height * child.getHeightInWeight() / this.heightInWeight_));
117 child.getElement().style.top =
118 Math.ceil(height * 0.6 / this.heightInWeight_);