• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #include "ui/oak/oak_aura_window_display.h"
6 
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 
15 namespace oak {
16 namespace internal {
17 namespace {
18 enum {
19 ROW_ID = 0,
20 ROW_DELEGATE,
21 ROW_TYPE,
22 ROW_NAME,
23 ROW_TITLE,
24 ROW_TRANSPARENT,
25 ROW_LAYER,
26 ROW_VISIBLE,
27 ROW_BOUNDS,
28 ROW_BOUNDSINROOTWINDOW,
29 ROW_TRANSFORM,
30 ROW_PARENT,
31 ROW_ROOTWINDOW,
32 ROW_TRANSIENTCHILDREN,
33 ROW_TRANSIENTPARENT,
34 ROW_USERDATA,
35 ROW_IGNOREEVENTS,
36 ROW_CANFOCUS,
37 ROW_HITTESTBOUNDSOVERRIDEOUTER,
38 ROW_HITTESTBOUNDSOVERRIDEINNER,
39 ROW_COUNT
40 };
41 
42 // aura::Window-specific pretty printing.
PropertyWithWindowType(int type)43 base::string16 PropertyWithWindowType(int type) {
44   std::string property = "Type: ";
45   switch (type) {
46     case aura::client::WINDOW_TYPE_UNKNOWN:
47       property.append("WINDOW_TYPE_UNKNOWN");
48       break;
49     case aura::client::WINDOW_TYPE_NORMAL:
50       property.append("WINDOW_TYPE_NORMAL");
51       break;
52     case aura::client::WINDOW_TYPE_POPUP:
53       property.append("WINDOW_TYPE_POPUP");
54       break;
55     case aura::client::WINDOW_TYPE_CONTROL:
56       property.append("WINDOW_TYPE_CONTROL");
57       break;
58     case aura::client::WINDOW_TYPE_PANEL:
59       property.append("WINDOW_TYPE_PANEL");
60       break;
61     case aura::client::WINDOW_TYPE_MENU:
62       property.append("WINDOW_TYPE_MENU");
63       break;
64     case aura::client::WINDOW_TYPE_TOOLTIP:
65       property.append("WINDOW_TYPE_TOOLTIP");
66       break;
67     default:
68       NOTREACHED();
69       break;
70   }
71   return ASCIIToUTF16(property);
72 }
73 
74 }  // namespace
75 
76 ////////////////////////////////////////////////////////////////////////////////
77 // OakAuraWindowDisplay, public:
78 
OakAuraWindowDisplay()79 OakAuraWindowDisplay::OakAuraWindowDisplay() : observer_(NULL), window_(NULL) {
80 }
81 
~OakAuraWindowDisplay()82 OakAuraWindowDisplay::~OakAuraWindowDisplay() {
83 }
84 
85 ////////////////////////////////////////////////////////////////////////////////
86 // OakAuraWindowDisplay, OakDetailsModel overrides:
87 
SetValue(aura::Window * window)88 void OakAuraWindowDisplay::SetValue(aura::Window* window) {
89   window_ = window;
90   observer_->OnModelChanged();
91 }
92 
93 ////////////////////////////////////////////////////////////////////////////////
94 // OakAuraWindowDisplay, ui::TableModel implementation:
95 
RowCount()96 int OakAuraWindowDisplay::RowCount() {
97   return ROW_COUNT;
98 }
99 
GetText(int row,int column_id)100 base::string16 OakAuraWindowDisplay::GetText(int row, int column_id) {
101   if (!window_)
102     return base::string16();
103 
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 ASCIIToUTF16("Name: " + window_->name());
114     case ROW_TITLE:
115       return 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 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("Transient Children: ",
135                                  window_->transient_children().size());
136     case ROW_TRANSIENTPARENT:
137       return PropertyWithVoidStar("Transient Parent: ",
138                                   window_->transient_parent());
139     case ROW_USERDATA:
140       return PropertyWithVoidStar("User Data: ", window_->user_data());
141     case ROW_IGNOREEVENTS:
142       return PropertyWithBool("Can receive events: ",
143                               window_->CanReceiveEvents());
144     case ROW_CANFOCUS:
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());
152     default:
153       NOTREACHED();
154       break;
155   }
156   return base::string16();
157 }
158 
SetObserver(ui::TableModelObserver * observer)159 void OakAuraWindowDisplay::SetObserver(ui::TableModelObserver* observer) {
160   observer_ = observer;
161 }
162 
163 }  // namespace internal
164 }  // namespace oak
165