summaryrefslogtreecommitdiffstats
path: root/ui/oak/oak_aura_window_display.cc
blob: 214a0054e1d2cb8fd5c9dddac553c718b367a51e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/oak/oak_aura_window_display.h"

#include "base/logging.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
#include "base/utf_string_conversions.h"
#include "ui/aura/window.h"
#include "ui/base/models/table_model_observer.h"
#include "ui/oak/oak_pretty_print.h"

namespace oak {
namespace internal {
namespace {
enum {
ROW_ID = 0,
ROW_DELEGATE,
ROW_TYPE,
ROW_NAME,
ROW_TITLE,
ROW_TRANSPARENT,
ROW_LAYER,
ROW_VISIBLE,
ROW_BOUNDS,
ROW_SCREENBOUNDS,
ROW_TRANSFORM,
ROW_PARENT,
ROW_ROOTWINDOW,
ROW_TRANSIENTCHILDREN,
ROW_TRANSIENTPARENT,
ROW_USERDATA,
ROW_STOPSEVENTPROPAGATION,
ROW_IGNOREEVENTS,
ROW_CANFOCUS,
ROW_HITTESTBOUNDSOVERRIDE,
ROW_COUNT
};

// aura::Window-specific pretty printing.
string16 PropertyWithWindowType(int type) {
  std::string property = "Type: ";
  switch (type) {
    case aura::client::WINDOW_TYPE_UNKNOWN:
      property.append("WINDOW_TYPE_UNKNOWN");
      break;
    case aura::client::WINDOW_TYPE_NORMAL:
      property.append("WINDOW_TYPE_NORMAL");
      break;
    case aura::client::WINDOW_TYPE_POPUP:
      property.append("WINDOW_TYPE_POPUP");
      break;
    case aura::client::WINDOW_TYPE_CONTROL:
      property.append("WINDOW_TYPE_CONTROL");
      break;
    case aura::client::WINDOW_TYPE_PANEL:
      property.append("WINDOW_TYPE_PANEL");
      break;
    case aura::client::WINDOW_TYPE_MENU:
      property.append("WINDOW_TYPE_MENU");
      break;
    case aura::client::WINDOW_TYPE_TOOLTIP:
      property.append("WINDOW_TYPE_TOOLTIP");
      break;
    default:
      NOTREACHED();
      break;
  }
  return ASCIIToUTF16(property);
}

}  // namespace

////////////////////////////////////////////////////////////////////////////////
// OakAuraWindowDisplay, public:

OakAuraWindowDisplay::OakAuraWindowDisplay() : observer_(NULL), window_(NULL) {
}

OakAuraWindowDisplay::~OakAuraWindowDisplay() {
}

////////////////////////////////////////////////////////////////////////////////
// OakAuraWindowDisplay, OakDetailsModel overrides:

void OakAuraWindowDisplay::SetValue(aura::Window* window) {
  window_ = window;
  observer_->OnModelChanged();
}

////////////////////////////////////////////////////////////////////////////////
// OakAuraWindowDisplay, ui::TableModel implementation:

int OakAuraWindowDisplay::RowCount() {
  return ROW_COUNT;
}

string16 OakAuraWindowDisplay::GetText(int row, int column_id) {
  if (!window_)
    return EmptyString16();

  string16 text;
  switch (row) {
    case ROW_ID:
      return PropertyWithInteger("Id: ", window_->id());
    case ROW_DELEGATE:
      return PropertyWithVoidStar("Delegate: ", window_->delegate());
    case ROW_TYPE:
      return PropertyWithWindowType(window_->type());
    case ROW_NAME:
      return ASCIIToUTF16("Name: " + window_->name());
    case ROW_TITLE:
      return ASCIIToUTF16("Title: ") + window_->title();
    case ROW_TRANSPARENT:
      return PropertyWithBool("Transparent: ", window_->transparent());
    case ROW_LAYER:
      return PropertyWithVoidStar("Layer: ", window_->layer());
    case ROW_VISIBLE:
      return PropertyWithBool("Visible: ", window_->IsVisible());
    case ROW_BOUNDS:
      return PropertyWithBounds("Bounds: ", window_->bounds());
    case ROW_SCREENBOUNDS:
      return PropertyWithBounds("Screen Bounds: ", window_->GetScreenBounds());
    case ROW_TRANSFORM:
      return ASCIIToUTF16("Transform:");
    case ROW_PARENT:
      return PropertyWithVoidStar("Parent: ", window_->parent());
    case ROW_ROOTWINDOW:
      return PropertyWithVoidStar("Root Window: ", window_->GetRootWindow());
    case ROW_TRANSIENTCHILDREN:
      return PropertyWithInteger("Transient Children: ",
                                 window_->transient_children().size());
    case ROW_TRANSIENTPARENT:
      return PropertyWithVoidStar("Transient Parent: ",
                                  window_->transient_parent());
    case ROW_USERDATA:
      return PropertyWithVoidStar("User Data: ", window_->user_data());
    case ROW_STOPSEVENTPROPAGATION:
      return PropertyWithBool("Stops event propagation: ",
                              window_->StopsEventPropagation());
    case ROW_IGNOREEVENTS:
      return PropertyWithBool("Can receive events: ",
                              window_->CanReceiveEvents());
    case ROW_CANFOCUS:
      return PropertyWithBool("Can Focus: ", window_->CanFocus());
    case ROW_HITTESTBOUNDSOVERRIDE: {
      int outer, inner;
      window_->GetHitTestBoundsOverride(&outer, &inner);
      return ASCIIToUTF16(
          base::StringPrintf("Hit test bounds override: outer %d, inner %d",
                             outer, inner));
    }
    default:
      NOTREACHED();
      break;
  }
  return EmptyString16();
}

void OakAuraWindowDisplay::SetObserver(ui::TableModelObserver* observer) {
  observer_ = observer;
}

}  // namespace internal
}  // namespace oak