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"
28 ROW_BOUNDSINROOTWINDOW
,
32 ROW_TRANSIENTCHILDREN
,
37 ROW_HITTESTBOUNDSOVERRIDEOUTER
,
38 ROW_HITTESTBOUNDSOVERRIDEINNER
,
42 // aura::Window-specific pretty printing.
43 base::string16
PropertyWithWindowType(int type
) {
44 std::string property
= "Type: ";
46 case aura::client::WINDOW_TYPE_UNKNOWN
:
47 property
.append("WINDOW_TYPE_UNKNOWN");
49 case aura::client::WINDOW_TYPE_NORMAL
:
50 property
.append("WINDOW_TYPE_NORMAL");
52 case aura::client::WINDOW_TYPE_POPUP
:
53 property
.append("WINDOW_TYPE_POPUP");
55 case aura::client::WINDOW_TYPE_CONTROL
:
56 property
.append("WINDOW_TYPE_CONTROL");
58 case aura::client::WINDOW_TYPE_PANEL
:
59 property
.append("WINDOW_TYPE_PANEL");
61 case aura::client::WINDOW_TYPE_MENU
:
62 property
.append("WINDOW_TYPE_MENU");
64 case aura::client::WINDOW_TYPE_TOOLTIP
:
65 property
.append("WINDOW_TYPE_TOOLTIP");
71 return 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 EmptyString16();
107 return PropertyWithInteger("Id: ", window_
->id());
109 return PropertyWithVoidStar("Delegate: ", window_
->delegate());
111 return PropertyWithWindowType(window_
->type());
113 return ASCIIToUTF16("Name: " + window_
->name());
115 return 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 ASCIIToUTF16("Transform:");
130 return PropertyWithVoidStar("Parent: ", window_
->parent());
132 return PropertyWithVoidStar("Root Window: ", window_
->GetRootWindow());
133 case ROW_TRANSIENTCHILDREN
:
134 return PropertyWithInteger("Transient Children: ",
135 window_
->transient_children().size());
136 case ROW_TRANSIENTPARENT
:
137 return PropertyWithVoidStar("Transient Parent: ",
138 window_
->transient_parent());
140 return PropertyWithVoidStar("User Data: ", window_
->user_data());
141 case ROW_IGNOREEVENTS
:
142 return PropertyWithBool("Can receive events: ",
143 window_
->CanReceiveEvents());
145 return PropertyWithBool("Can Focus: ", window_
->CanFocus());
146 case ROW_HITTESTBOUNDSOVERRIDEOUTER
:
147 return PropertyWithInsets("Hit test bounds override outer: ",
148 window_
->hit_test_bounds_override_outer_mouse());
149 case ROW_HITTESTBOUNDSOVERRIDEINNER
:
150 return PropertyWithInsets("Hit test bounds override inner: ",
151 window_
->hit_test_bounds_override_inner());
156 return EmptyString16();
159 void OakAuraWindowDisplay::SetObserver(ui::TableModelObserver
* observer
) {
160 observer_
= observer
;
163 } // namespace internal