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"
29 ROW_BOUNDSINROOTWINDOW
,
33 ROW_TRANSIENTCHILDREN
,
38 ROW_HITTESTBOUNDSOVERRIDEINNER
,
42 // aura::Window-specific pretty printing.
43 base::string16
PropertyWithWindowType(int type
) {
44 std::string property
= "Type: ";
46 case ui::wm::WINDOW_TYPE_UNKNOWN
:
47 property
.append("WINDOW_TYPE_UNKNOWN");
49 case ui::wm::WINDOW_TYPE_NORMAL
:
50 property
.append("WINDOW_TYPE_NORMAL");
52 case ui::wm::WINDOW_TYPE_POPUP
:
53 property
.append("WINDOW_TYPE_POPUP");
55 case ui::wm::WINDOW_TYPE_CONTROL
:
56 property
.append("WINDOW_TYPE_CONTROL");
58 case ui::wm::WINDOW_TYPE_PANEL
:
59 property
.append("WINDOW_TYPE_PANEL");
61 case ui::wm::WINDOW_TYPE_MENU
:
62 property
.append("WINDOW_TYPE_MENU");
64 case ui::wm::WINDOW_TYPE_TOOLTIP
:
65 property
.append("WINDOW_TYPE_TOOLTIP");
71 return base::ASCIIToUTF16(property
);
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
) {
90 observer_
->OnModelChanged();
93 ////////////////////////////////////////////////////////////////////////////////
94 // OakAuraWindowDisplay, ui::TableModel implementation:
96 int OakAuraWindowDisplay::RowCount() {
100 base::string16
OakAuraWindowDisplay::GetText(int row
, int column_id
) {
102 return base::string16();
107 return PropertyWithInteger("Id: ", window_
->id());
109 return PropertyWithVoidStar("Delegate: ", window_
->delegate());
111 return PropertyWithWindowType(window_
->type());
113 return base::ASCIIToUTF16("Name: " + window_
->name());
115 return base::ASCIIToUTF16("Title: ") + window_
->title();
116 case ROW_TRANSPARENT
:
117 return PropertyWithBool("Transparent: ", window_
->transparent());
119 return PropertyWithVoidStar("Layer: ", window_
->layer());
121 return PropertyWithBool("Visible: ", window_
->IsVisible());
123 return PropertyWithBounds("Bounds: ", window_
->bounds());
124 case ROW_BOUNDSINROOTWINDOW
:
125 return PropertyWithBounds("Bounds in Root Window: ",
126 window_
->GetBoundsInRootWindow());
128 return base::ASCIIToUTF16("Transform:");
130 return PropertyWithVoidStar("Parent: ", window_
->parent());
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_
));
141 return PropertyWithVoidStar("User Data: ", window_
->user_data());
142 case ROW_IGNOREEVENTS
:
143 return PropertyWithBool("Can receive events: ",
144 window_
->CanReceiveEvents());
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());
154 return base::string16();
157 void OakAuraWindowDisplay::SetObserver(ui::TableModelObserver
* observer
) {
158 observer_
= observer
;
161 } // namespace internal