NaCl: Update revision in DEPS, r12770 -> r12773
[chromium-blink-merge.git] / ui / oak / oak_aura_window_display.cc
blob0bfe88ffef61ca6dd01ebc7acdb441a5673e5343
1 // Copyright (c) 2012 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.
5 #include "ui/oak/oak_aura_window_display.h"
7 #include "base/logging.h"
8 #include "base/strings/string_util.h"
9 #include "base/strings/stringprintf.h"
10 #include "base/strings/utf_string_conversions.h"
11 #include "ui/aura/window.h"
12 #include "ui/base/models/table_model_observer.h"
13 #include "ui/oak/oak_pretty_print.h"
14 #include "ui/views/corewm/window_util.h"
16 namespace oak {
17 namespace internal {
18 namespace {
19 enum {
20 ROW_ID = 0,
21 ROW_DELEGATE,
22 ROW_TYPE,
23 ROW_NAME,
24 ROW_TITLE,
25 ROW_TRANSPARENT,
26 ROW_LAYER,
27 ROW_VISIBLE,
28 ROW_BOUNDS,
29 ROW_BOUNDSINROOTWINDOW,
30 ROW_TRANSFORM,
31 ROW_PARENT,
32 ROW_ROOTWINDOW,
33 ROW_TRANSIENTCHILDREN,
34 ROW_TRANSIENTPARENT,
35 ROW_USERDATA,
36 ROW_IGNOREEVENTS,
37 ROW_CANFOCUS,
38 ROW_HITTESTBOUNDSOVERRIDEINNER,
39 ROW_COUNT
42 // aura::Window-specific pretty printing.
43 base::string16 PropertyWithWindowType(int type) {
44 std::string property = "Type: ";
45 switch (type) {
46 case ui::wm::WINDOW_TYPE_UNKNOWN:
47 property.append("WINDOW_TYPE_UNKNOWN");
48 break;
49 case ui::wm::WINDOW_TYPE_NORMAL:
50 property.append("WINDOW_TYPE_NORMAL");
51 break;
52 case ui::wm::WINDOW_TYPE_POPUP:
53 property.append("WINDOW_TYPE_POPUP");
54 break;
55 case ui::wm::WINDOW_TYPE_CONTROL:
56 property.append("WINDOW_TYPE_CONTROL");
57 break;
58 case ui::wm::WINDOW_TYPE_PANEL:
59 property.append("WINDOW_TYPE_PANEL");
60 break;
61 case ui::wm::WINDOW_TYPE_MENU:
62 property.append("WINDOW_TYPE_MENU");
63 break;
64 case ui::wm::WINDOW_TYPE_TOOLTIP:
65 property.append("WINDOW_TYPE_TOOLTIP");
66 break;
67 default:
68 NOTREACHED();
69 break;
71 return base::ASCIIToUTF16(property);
74 } // namespace
76 ////////////////////////////////////////////////////////////////////////////////
77 // OakAuraWindowDisplay, public:
79 OakAuraWindowDisplay::OakAuraWindowDisplay() : observer_(NULL), window_(NULL) {
82 OakAuraWindowDisplay::~OakAuraWindowDisplay() {
85 ////////////////////////////////////////////////////////////////////////////////
86 // OakAuraWindowDisplay, OakDetailsModel overrides:
88 void OakAuraWindowDisplay::SetValue(aura::Window* window) {
89 window_ = window;
90 observer_->OnModelChanged();
93 ////////////////////////////////////////////////////////////////////////////////
94 // OakAuraWindowDisplay, ui::TableModel implementation:
96 int OakAuraWindowDisplay::RowCount() {
97 return ROW_COUNT;
100 base::string16 OakAuraWindowDisplay::GetText(int row, int column_id) {
101 if (!window_)
102 return base::string16();
104 base::string16 text;
105 switch (row) {
106 case ROW_ID:
107 return PropertyWithInteger("Id: ", window_->id());
108 case ROW_DELEGATE:
109 return PropertyWithVoidStar("Delegate: ", window_->delegate());
110 case ROW_TYPE:
111 return PropertyWithWindowType(window_->type());
112 case ROW_NAME:
113 return base::ASCIIToUTF16("Name: " + window_->name());
114 case ROW_TITLE:
115 return base::ASCIIToUTF16("Title: ") + window_->title();
116 case ROW_TRANSPARENT:
117 return PropertyWithBool("Transparent: ", window_->transparent());
118 case ROW_LAYER:
119 return PropertyWithVoidStar("Layer: ", window_->layer());
120 case ROW_VISIBLE:
121 return PropertyWithBool("Visible: ", window_->IsVisible());
122 case ROW_BOUNDS:
123 return PropertyWithBounds("Bounds: ", window_->bounds());
124 case ROW_BOUNDSINROOTWINDOW:
125 return PropertyWithBounds("Bounds in Root Window: ",
126 window_->GetBoundsInRootWindow());
127 case ROW_TRANSFORM:
128 return base::ASCIIToUTF16("Transform:");
129 case ROW_PARENT:
130 return PropertyWithVoidStar("Parent: ", window_->parent());
131 case ROW_ROOTWINDOW:
132 return PropertyWithVoidStar("Root Window: ", window_->GetRootWindow());
133 case ROW_TRANSIENTCHILDREN:
134 return PropertyWithInteger(
135 "Transient Children: ",
136 views::corewm::GetTransientChildren(window_).size());
137 case ROW_TRANSIENTPARENT:
138 return PropertyWithVoidStar("Transient Parent: ",
139 views::corewm::GetTransientParent(window_));
140 case ROW_USERDATA:
141 return PropertyWithVoidStar("User Data: ", window_->user_data());
142 case ROW_IGNOREEVENTS:
143 return PropertyWithBool("Can receive events: ",
144 window_->CanReceiveEvents());
145 case ROW_CANFOCUS:
146 return PropertyWithBool("Can Focus: ", window_->CanFocus());
147 case ROW_HITTESTBOUNDSOVERRIDEINNER:
148 return PropertyWithInsets("Hit test bounds override inner: ",
149 window_->hit_test_bounds_override_inner());
150 default:
151 NOTREACHED();
152 break;
154 return base::string16();
157 void OakAuraWindowDisplay::SetObserver(ui::TableModelObserver* observer) {
158 observer_ = observer;
161 } // namespace internal
162 } // namespace oak