<commit_before>/*
 * Copyright (c) 2012 ARM Limited
 * All rights reserved
 *
 * The license below extends only to copyright in the software and shall
 * not be construed as granting a license to any other intellectual
 * property including but not limited to intellectual property relating
 * to a hardware implementation of the functionality of the software
 * licensed hereunder.  You may use the software subject to the license
 * terms below provided that you ensure that this notice is replicated
 * unmodified and in its entirety in all distributions of the software,
 * modified or unmodified, in source code or in binary form.
 *
 * Copyright (c) 2002-2005 The Regents of The University of Michigan
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met: redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer;
 * redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution;
 * neither the name of the copyright holders nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * Authors: Nathan Binkert
 *          Steve Reinhardt
 *          Andreas Hansson
 */

#ifndef __BASE_ADDR_RANGE_HH__
#define __BASE_ADDR_RANGE_HH__

#include <vector>

#include "base/bitfield.hh"
#include "base/cprintf.hh"
#include "base/misc.hh"
#include "base/types.hh"

class AddrRange
{

  private:

    /// Private fields for the start and end of the range
    Addr _start;
    Addr _end;

    /// The high bit of the slice that is used for interleaving
    uint8_t intlvHighBit;

    /// The number of bits used for interleaving, set to 0 to disable
    uint8_t intlvBits;

    /// The value to compare the slice addr[high:(high - bits + 1)]
    /// with.
    uint8_t intlvMatch;

  public:

    AddrRange()
        : _start(1), _end(0), intlvHighBit(0), intlvBits(0), intlvMatch(0)
    {}

    AddrRange(Addr _start, Addr _end, uint8_t _intlv_high_bit,
              uint8_t _intlv_bits, uint8_t _intlv_match)
        : _start(_start), _end(_end), intlvHighBit(_intlv_high_bit),
          intlvBits(_intlv_bits), intlvMatch(_intlv_match)
    {}

    AddrRange(Addr _start, Addr _end)
        : _start(_start), _end(_end), intlvHighBit(0), intlvBits(0),
          intlvMatch(0)
    {}

    /**
     * Create an address range by merging a collection of interleaved
     * ranges.
     *
     * @param ranges Interleaved ranges to be merged
     */
    AddrRange(const std::vector<AddrRange>& ranges)
        : _start(1), _end(0), intlvHighBit(0), intlvBits(0), intlvMatch(0)
    {
        if (!ranges.empty()) {
            // get the values from the first one and check the others
            _start = ranges.front()._start;
            _end = ranges.front()._end;
            intlvHighBit = ranges.front().intlvHighBit;
            intlvBits = ranges.front().intlvBits;

            if (ranges.size() != (ULL(1) << intlvBits))
                fatal("Got %d ranges spanning %d interleaving bits\n",
                      ranges.size(), intlvBits);

            uint8_t match = 0;
            for (std::vector<AddrRange>::const_iterator r = ranges.begin();
                 r != ranges.end(); ++r) {
                if (!mergesWith(*r))
                    fatal("Can only merge ranges with the same start, end "
                          "and interleaving bits\n");

                if (r->intlvMatch != match)
                    fatal("Expected interleave match %d but got %d when "
                          "merging\n", match, r->intlvMatch);
                ++match;
            }

            // our range is complete and we can turn this into a
            // non-interleaved range
            intlvHighBit = 0;
            intlvBits = 0;
        }
    }

    /**
     * Determine if the range is interleaved or not.
     *
     * @return true if interleaved
     */
    bool interleaved() const { return intlvBits != 0; }

    /**
     * Determing the interleaving granularity of the range.
     *
     * @return The size of the regions created by the interleaving bits
     */
    uint64_t granularity() const { return ULL(1) << intlvHighBit; }

    /**
     * Determine the number of interleaved address stripes this range
     * is part of.
     *
     * @return The number of stripes spanned by the interleaving bits
     */
    uint32_t stripes() const { return ULL(1) << intlvBits; }

    /**
     * Get the size of the address range. For a case where
     * interleaving is used we make the simplifying assumption that
     * the size is a divisible by the size of the interleaving slice.
     */
    Addr size() const
    {
        return (_end - _start + 1) >> intlvBits;
    }

    /**
     * Determine if the range is valid.
     */
    bool valid() const { return _start < _end; }

    /**
     * Get the start address of the range.
     */
    Addr start() const { return _start; }

    /**
     * Get a string representation of the range. This could
     * alternatively be implemented as a operator<<, but at the moment
     * that seems like overkill.
     */
    std::string to_string() const
    {
        if (interleaved())
            return csprintf("[%#llx : %#llx], [%d : %d] = %d", _start, _end,
                            intlvHighBit, intlvHighBit - intlvBits + 1,
                            intlvMatch);
        else
            return csprintf("[%#llx : %#llx]", _start, _end);
    }

    /**
     * Determine if another range merges with the current one, i.e. if
     * they are part of the same contigous range and have the same
     * interleaving bits.
     *
     * @param r Range to evaluate merging with
     * @return true if the two ranges would merge
     */
    bool mergesWith(const AddrRange& r) const
    {
        return r._start == _start && r._end == _end &&
            r.intlvHighBit == intlvHighBit &&
            r.intlvBits == intlvBits;
    }

    /**
     * Determine if another range intersects this one, i.e. if there
     * is an address that is both in this range and the other
     * range. No check is made to ensure either range is valid.
     *
     * @param r Range to intersect with
     * @return true if the intersection of the two ranges is not empty
     */
    bool intersects(const AddrRange& r) const
    {
        if (!interleaved()) {
            return _start <= r._end && _end >= r._start;
        }

        // the current range is interleaved, split the check up in
        // three cases
        if (r.size() == 1)
            // keep it simple and check if the address is within
            // this range
            return contains(r.start());
        else if (!r.interleaved())
            // be conservative and ignore the interleaving
            return _start <= r._end && _end >= r._start;
        else if (mergesWith(r))
            // restrict the check to ranges that belong to the
            // same chunk
            return intlvMatch == r.intlvMatch;
        else
            panic("Cannot test intersection of interleaved range %s\n",
                  to_string());
    }

    /**
     * Determine if this range is a subset of another range, i.e. if
     * every address in this range is also in the other range. No
     * check is made to ensure either range is valid.
     *
     * @param r Range to compare with
     * @return true if the this range is a subset of the other one
     */
    bool isSubset(const AddrRange& r) const
    {
        if (interleaved())
            panic("Cannot test subset of interleaved range %s\n", to_string());
        return _start >= r._start && _end <= r._end;
    }

    /**
     * Determine if the range contains an address.
     *
     * @param a Address to compare with
     * @return true if the address is in the range
     */
    bool contains(const Addr& a) const
    {
        // check if the address is in the range and if there is either
        // no interleaving, or with interleaving also if the selected
        // bits from the address match the interleaving value
        return a >= _start && a <= _end &&
            (!interleaved() ||
             (bits(a, intlvHighBit, intlvHighBit - intlvBits + 1) ==
              intlvMatch));
    }

/**
 * Keep the operators away from SWIG.
 */
#ifndef SWIG

    /**
     * Less-than operator used to turn an STL map into a binary search
     * tree of non-overlapping address ranges.
     *
     * @param r Range to compare with
     * @return true if the start address is less than that of the other range
     */
    bool operator<(const AddrRange& r) const
    {
        if (_start != r._start)
            return _start < r._start;
        else
            // for now assume that the end is also the same, and that
            // we are looking at the same interleaving bits
            return intlvMatch < r.intlvMatch;
    }

#endif // SWIG
};

inline AddrRange
RangeEx(Addr start, Addr end)
{ return AddrRange(start, end - 1); }

inline AddrRange
RangeIn(Addr start, Addr end)
{ return AddrRange(start, end); }

inline AddrRange
RangeSize(Addr start, Addr size)
{ return AddrRange(start, start + size - 1); }

#endif // __BASE_ADDR_RANGE_HH__
<commit_msg>base: Fix address range granularity calculations<commit_after>/*
 * Copyright (c) 2012 ARM Limited
 * All rights reserved
 *
 * The license below extends only to copyright in the software and shall
 * not be construed as granting a license to any other intellectual
 * property including but not limited to intellectual property relating
 * to a hardware implementation of the functionality of the software
 * licensed hereunder.  You may use the software subject to the license
 * terms below provided that you ensure that this notice is replicated
 * unmodified and in its entirety in all distributions of the software,
 * modified or unmodified, in source code or in binary form.
 *
 * Copyright (c) 2002-2005 The Regents of The University of Michigan
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met: redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer;
 * redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution;
 * neither the name of the copyright holders nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * Authors: Nathan Binkert
 *          Steve Reinhardt
 *          Andreas Hansson
 */

#ifndef __BASE_ADDR_RANGE_HH__
#define __BASE_ADDR_RANGE_HH__

#include <vector>

#include "base/bitfield.hh"
#include "base/cprintf.hh"
#include "base/misc.hh"
#include "base/types.hh"

class AddrRange
{

  private:

    /// Private fields for the start and end of the range
    Addr _start;
    Addr _end;

    /// The high bit of the slice that is used for interleaving
    uint8_t intlvHighBit;

    /// The number of bits used for interleaving, set to 0 to disable
    uint8_t intlvBits;

    /// The value to compare the slice addr[high:(high - bits + 1)]
    /// with.
    uint8_t intlvMatch;

  public:

    AddrRange()
        : _start(1), _end(0), intlvHighBit(0), intlvBits(0), intlvMatch(0)
    {}

    AddrRange(Addr _start, Addr _end, uint8_t _intlv_high_bit,
              uint8_t _intlv_bits, uint8_t _intlv_match)
        : _start(_start), _end(_end), intlvHighBit(_intlv_high_bit),
          intlvBits(_intlv_bits), intlvMatch(_intlv_match)
    {}

    AddrRange(Addr _start, Addr _end)
        : _start(_start), _end(_end), intlvHighBit(0), intlvBits(0),
          intlvMatch(0)
    {}

    /**
     * Create an address range by merging a collection of interleaved
     * ranges.
     *
     * @param ranges Interleaved ranges to be merged
     */
    AddrRange(const std::vector<AddrRange>& ranges)
        : _start(1), _end(0), intlvHighBit(0), intlvBits(0), intlvMatch(0)
    {
        if (!ranges.empty()) {
            // get the values from the first one and check the others
            _start = ranges.front()._start;
            _end = ranges.front()._end;
            intlvHighBit = ranges.front().intlvHighBit;
            intlvBits = ranges.front().intlvBits;

            if (ranges.size() != (ULL(1) << intlvBits))
                fatal("Got %d ranges spanning %d interleaving bits\n",
                      ranges.size(), intlvBits);

            uint8_t match = 0;
            for (std::vector<AddrRange>::const_iterator r = ranges.begin();
                 r != ranges.end(); ++r) {
                if (!mergesWith(*r))
                    fatal("Can only merge ranges with the same start, end "
                          "and interleaving bits\n");

                if (r->intlvMatch != match)
                    fatal("Expected interleave match %d but got %d when "
                          "merging\n", match, r->intlvMatch);
                ++match;
            }

            // our range is complete and we can turn this into a
            // non-interleaved range
            intlvHighBit = 0;
            intlvBits = 0;
        }
    }

    /**
     * Determine if the range is interleaved or not.
     *
     * @return true if interleaved
     */
    bool interleaved() const { return intlvBits != 0; }

    /**
     * Determing the interleaving granularity of the range.
     *
     * @return The size of the regions created by the interleaving bits
     */
    uint64_t granularity() const
    {
        return ULL(1) << (intlvHighBit - intlvBits);
    }

    /**
     * Determine the number of interleaved address stripes this range
     * is part of.
     *
     * @return The number of stripes spanned by the interleaving bits
     */
    uint32_t stripes() const { return ULL(1) << intlvBits; }

    /**
     * Get the size of the address range. For a case where
     * interleaving is used we make the simplifying assumption that
     * the size is a divisible by the size of the interleaving slice.
     */
    Addr size() const
    {
        return (_end - _start + 1) >> intlvBits;
    }

    /**
     * Determine if the range is valid.
     */
    bool valid() const { return _start < _end; }

    /**
     * Get the start address of the range.
     */
    Addr start() const { return _start; }

    /**
     * Get a string representation of the range. This could
     * alternatively be implemented as a operator<<, but at the moment
     * that seems like overkill.
     */
    std::string to_string() const
    {
        if (interleaved())
            return csprintf("[%#llx : %#llx], [%d : %d] = %d", _start, _end,
                            intlvHighBit, intlvHighBit - intlvBits + 1,
                            intlvMatch);
        else
            return csprintf("[%#llx : %#llx]", _start, _end);
    }

    /**
     * Determine if another range merges with the current one, i.e. if
     * they are part of the same contigous range and have the same
     * interleaving bits.
     *
     * @param r Range to evaluate merging with
     * @return true if the two ranges would merge
     */
    bool mergesWith(const AddrRange& r) const
    {
        return r._start == _start && r._end == _end &&
            r.intlvHighBit == intlvHighBit &&
            r.intlvBits == intlvBits;
    }

    /**
     * Determine if another range intersects this one, i.e. if there
     * is an address that is both in this range and the other
     * range. No check is made to ensure either range is valid.
     *
     * @param r Range to intersect with
     * @return true if the intersection of the two ranges is not empty
     */
    bool intersects(const AddrRange& r) const
    {
        if (!interleaved()) {
            return _start <= r._end && _end >= r._start;
        }

        // the current range is interleaved, split the check up in
        // three cases
        if (r.size() == 1)
            // keep it simple and check if the address is within
            // this range
            return contains(r.start());
        else if (!r.interleaved())
            // be conservative and ignore the interleaving
            return _start <= r._end && _end >= r._start;
        else if (mergesWith(r))
            // restrict the check to ranges that belong to the
            // same chunk
            return intlvMatch == r.intlvMatch;
        else
            panic("Cannot test intersection of interleaved range %s\n",
                  to_string());
    }

    /**
     * Determine if this range is a subset of another range, i.e. if
     * every address in this range is also in the other range. No
     * check is made to ensure either range is valid.
     *
     * @param r Range to compare with
     * @return true if the this range is a subset of the other one
     */
    bool isSubset(const AddrRange& r) const
    {
        if (interleaved())
            panic("Cannot test subset of interleaved range %s\n", to_string());
        return _start >= r._start && _end <= r._end;
    }

    /**
     * Determine if the range contains an address.
     *
     * @param a Address to compare with
     * @return true if the address is in the range
     */
    bool contains(const Addr& a) const
    {
        // check if the address is in the range and if there is either
        // no interleaving, or with interleaving also if the selected
        // bits from the address match the interleaving value
        return a >= _start && a <= _end &&
            (!interleaved() ||
             (bits(a, intlvHighBit, intlvHighBit - intlvBits + 1) ==
              intlvMatch));
    }

/**
 * Keep the operators away from SWIG.
 */
#ifndef SWIG

    /**
     * Less-than operator used to turn an STL map into a binary search
     * tree of non-overlapping address ranges.
     *
     * @param r Range to compare with
     * @return true if the start address is less than that of the other range
     */
    bool operator<(const AddrRange& r) const
    {
        if (_start != r._start)
            return _start < r._start;
        else
            // for now assume that the end is also the same, and that
            // we are looking at the same interleaving bits
            return intlvMatch < r.intlvMatch;
    }

#endif // SWIG
};

inline AddrRange
RangeEx(Addr start, Addr end)
{ return AddrRange(start, end - 1); }

inline AddrRange
RangeIn(Addr start, Addr end)
{ return AddrRange(start, end); }

inline AddrRange
RangeSize(Addr start, Addr size)
{ return AddrRange(start, start + size - 1); }

#endif // __BASE_ADDR_RANGE_HH__
<|endoftext|>


<commit_before>// Copyright 2014 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 "chrome/browser/ui/views/extensions/bookmark_app_bubble_view.h"

#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/app_icon_loader_impl.h"
#include "chrome/browser/extensions/bookmark_app_helper.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/launch_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_list/app_list_service.h"
#include "chrome/browser/ui/app_list/app_list_util.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/host_desktop.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/pref_names.h"
#include "extensions/browser/uninstall_reason.h"
#include "extensions/common/constants.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/views/controls/button/checkbox.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/layout/layout_constants.h"
#include "ui/views/widget/widget.h"

using views::ColumnSet;
using views::GridLayout;

namespace {

// Minimum width of the the bubble.
const int kMinBubbleWidth = 300;
// Minimum width of the the textfield.
const int kMinTextfieldWidth = 200;
// Size of the icon.
const int kIconSize = extension_misc::EXTENSION_ICON_MEDIUM;

ExtensionService* GetExtensionService(Profile* profile) {
  return extensions::ExtensionSystem::Get(profile)->extension_service();
}

}  // namespace

BookmarkAppBubbleView* BookmarkAppBubbleView::bookmark_app_bubble_ = NULL;

BookmarkAppBubbleView::~BookmarkAppBubbleView() {
}

// static
void BookmarkAppBubbleView::ShowBubble(views::View* anchor_view,
                                       Profile* profile,
                                       const WebApplicationInfo& web_app_info,
                                       const std::string& extension_id) {
  if (bookmark_app_bubble_ != NULL)
    return;

  bookmark_app_bubble_ = new BookmarkAppBubbleView(
      anchor_view, profile, web_app_info, extension_id);
  views::BubbleDelegateView::CreateBubble(bookmark_app_bubble_)->Show();
  // Select the entire title textfield contents when the bubble is first shown.
  bookmark_app_bubble_->title_tf_->SelectAll(true);
  bookmark_app_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE);
}

BookmarkAppBubbleView::BookmarkAppBubbleView(
    views::View* anchor_view,
    Profile* profile,
    const WebApplicationInfo& web_app_info,
    const std::string& extension_id)
    : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT),
      profile_(profile),
      web_app_info_(web_app_info),
      extension_id_(extension_id),
      add_button_(NULL),
      cancel_button_(NULL),
      open_as_tab_checkbox_(NULL),
      title_tf_(NULL),
      remove_app_(true),
      app_icon_loader_(new extensions::AppIconLoaderImpl(profile,
                                                         kIconSize,
                                                         this)) {
  const SkColor background_color = GetNativeTheme()->GetSystemColor(
      ui::NativeTheme::kColorId_DialogBackground);
  set_arrow(views::BubbleBorder::TOP_CENTER);
  set_color(background_color);
  set_background(views::Background::CreateSolidBackground(background_color));
  set_margins(gfx::Insets(views::kPanelVertMargin, 0, 0, 0));
}

void BookmarkAppBubbleView::Init() {
  views::Label* title_label = new views::Label(
      l10n_util::GetStringUTF16(IDS_BOOKMARK_APP_BUBBLE_TITLE));
  ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
  title_label->SetFontList(rb->GetFontList(ui::ResourceBundle::MediumFont));
  title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);

  add_button_ =
      new views::LabelButton(this, l10n_util::GetStringUTF16(IDS_ADD));
  add_button_->SetStyle(views::Button::STYLE_BUTTON);
  add_button_->SetIsDefault(true);

  cancel_button_ =
      new views::LabelButton(this, l10n_util::GetStringUTF16(IDS_CANCEL));
  cancel_button_->SetStyle(views::Button::STYLE_BUTTON);

  GridLayout* layout = new GridLayout(this);
  SetLayoutManager(layout);

  // Column sets used in the layout of the bubble.
  enum ColumnSetID {
    TITLE_COLUMN_SET_ID,
    TITLE_TEXT_COLUMN_SET_ID,
    CONTENT_COLUMN_SET_ID
  };

  // The column layout used for the title and checkbox.
  ColumnSet* cs = layout->AddColumnSet(TITLE_COLUMN_SET_ID);
  cs->AddPaddingColumn(0, views::kButtonHEdgeMarginNew);
  cs->AddColumn(
      GridLayout::LEADING, GridLayout::CENTER, 0, GridLayout::USE_PREF, 0, 0);
  cs->AddPaddingColumn(0, views::kButtonHEdgeMarginNew);

  // The column layout used for the icon and text box.
  cs = layout->AddColumnSet(TITLE_TEXT_COLUMN_SET_ID);
  cs->AddPaddingColumn(0, views::kButtonHEdgeMarginNew);
  cs->AddColumn(GridLayout::LEADING,
                GridLayout::CENTER,
                0,
                GridLayout::USE_PREF,
                0,
                0);
  cs->AddPaddingColumn(0, views::kButtonHEdgeMarginNew);
  cs->AddColumn(GridLayout::FILL,
                GridLayout::CENTER,
                1,
                GridLayout::USE_PREF,
                0,
                kMinTextfieldWidth);
  cs->AddPaddingColumn(0, views::kButtonHEdgeMarginNew);

  // The column layout used for the row with buttons.
  cs = layout->AddColumnSet(CONTENT_COLUMN_SET_ID);
  cs->AddPaddingColumn(0, views::kButtonHEdgeMarginNew);
  cs->AddColumn(
      GridLayout::LEADING, GridLayout::CENTER, 0, GridLayout::USE_PREF, 0, 0);
  cs->AddPaddingColumn(1, views::kUnrelatedControlHorizontalSpacing);
  cs->AddColumn(
      GridLayout::LEADING, GridLayout::CENTER, 0, GridLayout::USE_PREF, 0, 0);
  cs->AddPaddingColumn(0, views::kRelatedButtonHSpacing);
  cs->AddColumn(
      GridLayout::LEADING, GridLayout::CENTER, 0, GridLayout::USE_PREF, 0, 0);
  cs->AddPaddingColumn(0, views::kButtonHEdgeMarginNew);

  layout->StartRow(0, TITLE_COLUMN_SET_ID);
  layout->AddView(title_label);
  layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);

  const extensions::Extension* extension =
      extensions::ExtensionRegistry::Get(profile_)->GetExtensionById(
          extension_id_, extensions::ExtensionRegistry::EVERYTHING);

  layout->StartRow(0, TITLE_TEXT_COLUMN_SET_ID);
  icon_image_view_ = new views::ImageView();
  icon_image_view_->SetImageSize(gfx::Size(kIconSize, kIconSize));
  layout->AddView(icon_image_view_);
  app_icon_loader_->FetchImage(extension_id_);

  title_tf_ = new views::Textfield();
  title_tf_->SetText(extension ? base::UTF8ToUTF16(extension->name())
                               : web_app_info_.title);
  layout->AddView(title_tf_);
  layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);

  layout->StartRow(0, CONTENT_COLUMN_SET_ID);
  open_as_tab_checkbox_ = new views::Checkbox(
      l10n_util::GetStringUTF16(IDS_BOOKMARK_APP_BUBBLE_OPEN_AS_TAB));
  open_as_tab_checkbox_->SetChecked(
      profile_->GetPrefs()->GetInteger(
          extensions::pref_names::kBookmarkAppCreationLaunchType) ==
              extensions::LAUNCH_TYPE_REGULAR);
  layout->AddView(open_as_tab_checkbox_);
  layout->AddView(add_button_);
  layout->AddView(cancel_button_);
  layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing);

  AddAccelerator(ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE));
}

views::View* BookmarkAppBubbleView::GetInitiallyFocusedView() {
  return title_tf_;
}

void BookmarkAppBubbleView::WindowClosing() {
  // We have to reset |bookmark_app_bubble_| here, not in our destructor,
  // because we'll be destroyed asynchronously and the shown state will be
  // checked before then.
  DCHECK_EQ(bookmark_app_bubble_, this);
  bookmark_app_bubble_ = NULL;

  if (remove_app_) {
    GetExtensionService(profile_)
        ->UninstallExtension(extension_id_,
                             extensions::UNINSTALL_REASON_INSTALL_CANCELED,
                             base::Bind(&base::DoNothing),
                             NULL);
  } else {
    ApplyEdits();
  }
}

bool BookmarkAppBubbleView::AcceleratorPressed(
    const ui::Accelerator& accelerator) {
  if (accelerator.key_code() == ui::VKEY_RETURN) {
    HandleButtonPressed(add_button_);
  }

  return BubbleDelegateView::AcceleratorPressed(accelerator);
}

gfx::Size BookmarkAppBubbleView::GetMinimumSize() const {
  gfx::Size size(views::BubbleDelegateView::GetPreferredSize());
  size.SetToMax(gfx::Size(kMinBubbleWidth, 0));
  return size;
}

void BookmarkAppBubbleView::ButtonPressed(views::Button* sender,
                                          const ui::Event& event) {
  HandleButtonPressed(sender);
}

void BookmarkAppBubbleView::SetAppImage(const std::string& id,
                                        const gfx::ImageSkia& image) {
  DCHECK_EQ(extension_id_, id);
  icon_image_view_->SetImage(image);
}

void BookmarkAppBubbleView::HandleButtonPressed(views::Button* sender) {
  // Unset |remove_app_| so we don't delete the bookmark after the window
  // closes.
  if (sender == add_button_)
    remove_app_ = false;

  GetWidget()->Close();
}

void BookmarkAppBubbleView::ApplyEdits() {
  // Set the launch type based on the checkbox.
  extensions::LaunchType launch_type = open_as_tab_checkbox_->checked()
      ? extensions::LAUNCH_TYPE_REGULAR
      : extensions::LAUNCH_TYPE_WINDOW;
  profile_->GetPrefs()->SetInteger(
          extensions::pref_names::kBookmarkAppCreationLaunchType, launch_type);
  extensions::SetLaunchType(GetExtensionService(profile_),
                            extension_id_,
                            launch_type);

  const extensions::Extension* extension =
      extensions::ExtensionRegistry::Get(profile_)->GetExtensionById(
          extension_id_, extensions::ExtensionRegistry::EVERYTHING);

  if (!extension)
    return;

  if (base::UTF8ToUTF16(extension->name()) != title_tf_->text()) {
    // Reinstall the app with an updated name.
    WebApplicationInfo install_info(web_app_info_);
    install_info.title = title_tf_->text();

    // This will asynchronously reload the extension, causing the Extension*
    // we have to be destroyed. The extension ID will stay the same so that is
    // used later on to highlight the app.
    extensions::CreateOrUpdateBookmarkApp(GetExtensionService(profile_),
                                          &install_info);
  }

  // As the extension could be destroyed after this point, set it to null to
  // prevent anyone trying to use it in future.
  extension = nullptr;

  // Show the newly installed app in the app launcher or chrome://apps. Don't
  // do this on ash, as the icon will have been added to the shelf.
  chrome::HostDesktopType desktop =
      chrome::GetHostDesktopTypeForNativeWindow(GetWidget()->GetNativeWindow());
  if (desktop == chrome::HOST_DESKTOP_TYPE_ASH)
    return;

  Profile* current_profile = profile_->GetOriginalProfile();
  if (IsAppLauncherEnabled()) {
    AppListService::Get(desktop)
        ->ShowForAppInstall(current_profile, extension_id_, false);
    return;
  }

  chrome::NavigateParams params(current_profile,
                                GURL(chrome::kChromeUIAppsURL),
                                ui::PAGE_TRANSITION_LINK);
  params.disposition = SINGLETON_TAB;
  chrome::Navigate(&params);

  content::NotificationService::current()->Notify(
      chrome::NOTIFICATION_APP_INSTALLED_TO_NTP,
      content::Source<content::WebContents>(params.target_contents),
      content::Details<const std::string>(&extension_id_));
}
<commit_msg>Show app launcher on Ash after creating a bookmark app.<commit_after>// Copyright 2014 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 "chrome/browser/ui/views/extensions/bookmark_app_bubble_view.h"

#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/app_icon_loader_impl.h"
#include "chrome/browser/extensions/bookmark_app_helper.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/launch_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_list/app_list_service.h"
#include "chrome/browser/ui/app_list/app_list_util.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/host_desktop.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/pref_names.h"
#include "extensions/browser/uninstall_reason.h"
#include "extensions/common/constants.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/views/controls/button/checkbox.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/layout/layout_constants.h"
#include "ui/views/widget/widget.h"

using views::ColumnSet;
using views::GridLayout;

namespace {

// Minimum width of the the bubble.
const int kMinBubbleWidth = 300;
// Minimum width of the the textfield.
const int kMinTextfieldWidth = 200;
// Size of the icon.
const int kIconSize = extension_misc::EXTENSION_ICON_MEDIUM;

ExtensionService* GetExtensionService(Profile* profile) {
  return extensions::ExtensionSystem::Get(profile)->extension_service();
}

}  // namespace

BookmarkAppBubbleView* BookmarkAppBubbleView::bookmark_app_bubble_ = NULL;

BookmarkAppBubbleView::~BookmarkAppBubbleView() {
}

// static
void BookmarkAppBubbleView::ShowBubble(views::View* anchor_view,
                                       Profile* profile,
                                       const WebApplicationInfo& web_app_info,
                                       const std::string& extension_id) {
  if (bookmark_app_bubble_ != NULL)
    return;

  bookmark_app_bubble_ = new BookmarkAppBubbleView(
      anchor_view, profile, web_app_info, extension_id);
  views::BubbleDelegateView::CreateBubble(bookmark_app_bubble_)->Show();
  // Select the entire title textfield contents when the bubble is first shown.
  bookmark_app_bubble_->title_tf_->SelectAll(true);
  bookmark_app_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE);
}

BookmarkAppBubbleView::BookmarkAppBubbleView(
    views::View* anchor_view,
    Profile* profile,
    const WebApplicationInfo& web_app_info,
    const std::string& extension_id)
    : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT),
      profile_(profile),
      web_app_info_(web_app_info),
      extension_id_(extension_id),
      add_button_(NULL),
      cancel_button_(NULL),
      open_as_tab_checkbox_(NULL),
      title_tf_(NULL),
      remove_app_(true),
      app_icon_loader_(new extensions::AppIconLoaderImpl(profile,
                                                         kIconSize,
                                                         this)) {
  const SkColor background_color = GetNativeTheme()->GetSystemColor(
      ui::NativeTheme::kColorId_DialogBackground);
  set_arrow(views::BubbleBorder::TOP_CENTER);
  set_color(background_color);
  set_background(views::Background::CreateSolidBackground(background_color));
  set_margins(gfx::Insets(views::kPanelVertMargin, 0, 0, 0));
}

void BookmarkAppBubbleView::Init() {
  views::Label* title_label = new views::Label(
      l10n_util::GetStringUTF16(IDS_BOOKMARK_APP_BUBBLE_TITLE));
  ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
  title_label->SetFontList(rb->GetFontList(ui::ResourceBundle::MediumFont));
  title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);

  add_button_ =
      new views::LabelButton(this, l10n_util::GetStringUTF16(IDS_ADD));
  add_button_->SetStyle(views::Button::STYLE_BUTTON);
  add_button_->SetIsDefault(true);

  cancel_button_ =
      new views::LabelButton(this, l10n_util::GetStringUTF16(IDS_CANCEL));
  cancel_button_->SetStyle(views::Button::STYLE_BUTTON);

  GridLayout* layout = new GridLayout(this);
  SetLayoutManager(layout);

  // Column sets used in the layout of the bubble.
  enum ColumnSetID {
    TITLE_COLUMN_SET_ID,
    TITLE_TEXT_COLUMN_SET_ID,
    CONTENT_COLUMN_SET_ID
  };

  // The column layout used for the title and checkbox.
  ColumnSet* cs = layout->AddColumnSet(TITLE_COLUMN_SET_ID);
  cs->AddPaddingColumn(0, views::kButtonHEdgeMarginNew);
  cs->AddColumn(
      GridLayout::LEADING, GridLayout::CENTER, 0, GridLayout::USE_PREF, 0, 0);
  cs->AddPaddingColumn(0, views::kButtonHEdgeMarginNew);

  // The column layout used for the icon and text box.
  cs = layout->AddColumnSet(TITLE_TEXT_COLUMN_SET_ID);
  cs->AddPaddingColumn(0, views::kButtonHEdgeMarginNew);
  cs->AddColumn(GridLayout::LEADING,
                GridLayout::CENTER,
                0,
                GridLayout::USE_PREF,
                0,
                0);
  cs->AddPaddingColumn(0, views::kButtonHEdgeMarginNew);
  cs->AddColumn(GridLayout::FILL,
                GridLayout::CENTER,
                1,
                GridLayout::USE_PREF,
                0,
                kMinTextfieldWidth);
  cs->AddPaddingColumn(0, views::kButtonHEdgeMarginNew);

  // The column layout used for the row with buttons.
  cs = layout->AddColumnSet(CONTENT_COLUMN_SET_ID);
  cs->AddPaddingColumn(0, views::kButtonHEdgeMarginNew);
  cs->AddColumn(
      GridLayout::LEADING, GridLayout::CENTER, 0, GridLayout::USE_PREF, 0, 0);
  cs->AddPaddingColumn(1, views::kUnrelatedControlHorizontalSpacing);
  cs->AddColumn(
      GridLayout::LEADING, GridLayout::CENTER, 0, GridLayout::USE_PREF, 0, 0);
  cs->AddPaddingColumn(0, views::kRelatedButtonHSpacing);
  cs->AddColumn(
      GridLayout::LEADING, GridLayout::CENTER, 0, GridLayout::USE_PREF, 0, 0);
  cs->AddPaddingColumn(0, views::kButtonHEdgeMarginNew);

  layout->StartRow(0, TITLE_COLUMN_SET_ID);
  layout->AddView(title_label);
  layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);

  const extensions::Extension* extension =
      extensions::ExtensionRegistry::Get(profile_)->GetExtensionById(
          extension_id_, extensions::ExtensionRegistry::EVERYTHING);

  layout->StartRow(0, TITLE_TEXT_COLUMN_SET_ID);
  icon_image_view_ = new views::ImageView();
  icon_image_view_->SetImageSize(gfx::Size(kIconSize, kIconSize));
  layout->AddView(icon_image_view_);
  app_icon_loader_->FetchImage(extension_id_);

  title_tf_ = new views::Textfield();
  title_tf_->SetText(extension ? base::UTF8ToUTF16(extension->name())
                               : web_app_info_.title);
  layout->AddView(title_tf_);
  layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);

  layout->StartRow(0, CONTENT_COLUMN_SET_ID);
  open_as_tab_checkbox_ = new views::Checkbox(
      l10n_util::GetStringUTF16(IDS_BOOKMARK_APP_BUBBLE_OPEN_AS_TAB));
  open_as_tab_checkbox_->SetChecked(
      profile_->GetPrefs()->GetInteger(
          extensions::pref_names::kBookmarkAppCreationLaunchType) ==
              extensions::LAUNCH_TYPE_REGULAR);
  layout->AddView(open_as_tab_checkbox_);
  layout->AddView(add_button_);
  layout->AddView(cancel_button_);
  layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing);

  AddAccelerator(ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE));
}

views::View* BookmarkAppBubbleView::GetInitiallyFocusedView() {
  return title_tf_;
}

void BookmarkAppBubbleView::WindowClosing() {
  // We have to reset |bookmark_app_bubble_| here, not in our destructor,
  // because we'll be destroyed asynchronously and the shown state will be
  // checked before then.
  DCHECK_EQ(bookmark_app_bubble_, this);
  bookmark_app_bubble_ = NULL;

  if (remove_app_) {
    GetExtensionService(profile_)
        ->UninstallExtension(extension_id_,
                             extensions::UNINSTALL_REASON_INSTALL_CANCELED,
                             base::Bind(&base::DoNothing),
                             NULL);
  } else {
    ApplyEdits();
  }
}

bool BookmarkAppBubbleView::AcceleratorPressed(
    const ui::Accelerator& accelerator) {
  if (accelerator.key_code() == ui::VKEY_RETURN) {
    HandleButtonPressed(add_button_);
  }

  return BubbleDelegateView::AcceleratorPressed(accelerator);
}

gfx::Size BookmarkAppBubbleView::GetMinimumSize() const {
  gfx::Size size(views::BubbleDelegateView::GetPreferredSize());
  size.SetToMax(gfx::Size(kMinBubbleWidth, 0));
  return size;
}

void BookmarkAppBubbleView::ButtonPressed(views::Button* sender,
                                          const ui::Event& event) {
  HandleButtonPressed(sender);
}

void BookmarkAppBubbleView::SetAppImage(const std::string& id,
                                        const gfx::ImageSkia& image) {
  DCHECK_EQ(extension_id_, id);
  icon_image_view_->SetImage(image);
}

void BookmarkAppBubbleView::HandleButtonPressed(views::Button* sender) {
  // Unset |remove_app_| so we don't delete the bookmark after the window
  // closes.
  if (sender == add_button_)
    remove_app_ = false;

  GetWidget()->Close();
}

void BookmarkAppBubbleView::ApplyEdits() {
  // Set the launch type based on the checkbox.
  extensions::LaunchType launch_type = open_as_tab_checkbox_->checked()
      ? extensions::LAUNCH_TYPE_REGULAR
      : extensions::LAUNCH_TYPE_WINDOW;
  profile_->GetPrefs()->SetInteger(
          extensions::pref_names::kBookmarkAppCreationLaunchType, launch_type);
  extensions::SetLaunchType(GetExtensionService(profile_),
                            extension_id_,
                            launch_type);

  const extensions::Extension* extension =
      extensions::ExtensionRegistry::Get(profile_)->GetExtensionById(
          extension_id_, extensions::ExtensionRegistry::EVERYTHING);

  if (!extension)
    return;

  if (base::UTF8ToUTF16(extension->name()) != title_tf_->text()) {
    // Reinstall the app with an updated name.
    WebApplicationInfo install_info(web_app_info_);
    install_info.title = title_tf_->text();

    // This will asynchronously reload the extension, causing the Extension*
    // we have to be destroyed. The extension ID will stay the same so that is
    // used later on to highlight the app.
    extensions::CreateOrUpdateBookmarkApp(GetExtensionService(profile_),
                                          &install_info);
  }

  // As the extension could be destroyed after this point, set it to null to
  // prevent anyone trying to use it in future.
  extension = nullptr;

  // Show the newly installed app in the app launcher or chrome://apps.
  Profile* current_profile = profile_->GetOriginalProfile();
  if (IsAppLauncherEnabled()) {
    chrome::HostDesktopType desktop = chrome::GetHostDesktopTypeForNativeWindow(
        GetWidget()->GetNativeWindow());
    AppListService::Get(desktop)
        ->ShowForAppInstall(current_profile, extension_id_, false);
    return;
  }

  chrome::NavigateParams params(current_profile,
                                GURL(chrome::kChromeUIAppsURL),
                                ui::PAGE_TRANSITION_LINK);
  params.disposition = SINGLETON_TAB;
  chrome::Navigate(&params);

  content::NotificationService::current()->Notify(
      chrome::NOTIFICATION_APP_INSTALLED_TO_NTP,
      content::Source<content::WebContents>(params.target_contents),
      content::Details<const std::string>(&extension_id_));
}
<|endoftext|>


<commit_before>#include "PimInternal.h"

#include "PimVec2.h"
#include "PimGameNode.h"
#include "PimAssert.h"
#include "PimInput.h"
#include "PimGameControl.h"
#include "PimLayer.h"
#include "PimPolygonShape.h"
#include "PimScene.h"
#include "PimLightingSystem.h"
#include "PimAction.h"

#include <iostream>

namespace Pim {
	/*
	=====================
	GameNode::GameNode
	=====================
	*/
	GameNode::GameNode() {
		parent					= NULL;
		rotation				= 0.f;
		zOrder					= 0;
		dirtyZOrder				= false;
		willDelete				= false;
		shadowShape				= NULL;
		dbgShadowShape			= false;
		userData				= NULL;
	}

	/*
	=====================
	GameNode::~GameNode
	=====================
	*/
	GameNode::~GameNode() {
		if (!willDelete) {
			PrepareDeletion();
		}

		RemoveAllChildren();

		UnlistenFrame();
		UnlistenInput();
		UnlistenController();
	}

	/*
	=====================
	GameNode::PrepareDeletion
	=====================
	*/
	void GameNode::PrepareDeletion() {
		if (GetParentLayer()) {
			GetParentLayer()->RemoveLight(this);
			GetParentLayer()->RemoveShadowCaster(this);
		}

		if (shadowShape) {
			delete shadowShape;
		}

		RemoveAllChildren();

		UnlistenInput();
		UnlistenController();

		parent = NULL;
		willDelete = true;
	}

	/*
	=====================
	GameNode::AddChild
	=====================
	*/
	void GameNode::AddChild(GameNode *ch) {
		PimAssert(!ch->GetParent(), "Node already has a parent");

		Layer *layer = dynamic_cast<Layer*>(ch);
		if (layer) {
			layer->LoadResources();
		}

		ch->parent = this;
		children.push_back(ch);

		dirtyZOrder = true;
	}

	/*
	=====================
	GameNode::RemoveChild
	=====================
	*/
	void GameNode::RemoveChild(GameNode *ch, const bool cleanup) {
		for (unsigned int i=0; i<children.size(); i++) {
			if (children[i] == ch) {
				children.erase(children.begin() + i);

				if (cleanup) {
					GameControl::GetSingleton()->AddNodeToDelete(ch);
				} else {
					ch->parent = NULL;
				}
			}
		}
	}

	/*
	=====================
	GameNode::RemoveAllChildren
	=====================
	*/
	void GameNode::RemoveAllChildren(const bool cleanup) {
		// Delete all if required
		for (unsigned i=0; i<children.size(); i++) {
			if (cleanup) {
				GameControl::GetSingleton()->AddNodeToDelete(children[i]);
			} else {
				children[i]->parent = NULL;
			}
		}

		// THEN clear the array
		children.clear();
	}

	/*
	=====================
	GameNode::GetParent
	=====================
	*/
	GameNode* GameNode::GetParent() const {
		return parent;
	}

	/*
	=====================
	GameNode::GetParentScene
	=====================
	*/
	Scene* GameNode::GetParentScene() const {
		if (parent) {
			return parent->GetParentScene();
		}
		return NULL;
	}

	/*
	=====================
	GameNode::GetParentLayer
	=====================
	*/
	Layer* GameNode::GetParentLayer() {
		if (parent) {
			return parent->GetParentLayer();
		}
		return NULL;
	}

	/*
	=====================
	GameNode::ListenInput
	=====================
	*/
	void GameNode::ListenInput() {
		GameControl::GetSingleton()->AddKeyListener(this);
		GameControl::GetSingleton()->AddMouseListener(this);
	}

	/*
	=====================
	GameNode::UnlistenInput
	=====================
	*/
	void GameNode::UnlistenInput() {
		GameControl::GetSingleton()->RemoveKeyListener(this);
		GameControl::GetSingleton()->RemoveMouseListener(this);
	}

	/*
	=====================
	GameNode::ListenKeys
	=====================
	*/
	void GameNode::ListenKeys() {
		GameControl::GetSingleton()->AddKeyListener(this);
	}

	/*
	=====================
	GameNode::UnlistenKeys
	=====================
	*/
	void GameNode::UnlistenKeys() {
		GameControl::GetSingleton()->RemoveKeyListener(this);
	}

	/*
	=====================
	GameNode::ListenMouse
	=====================
	*/
	void GameNode::ListenMouse() {
		GameControl::GetSingleton()->AddMouseListener(this);
	}

	/*
	=====================
	GameNode::UnlistenMouse
	=====================
	*/
	void GameNode::UnlistenMouse() {
		GameControl::GetSingleton()->RemoveMouseListener(this);
	}

	/*
	=====================
	GameNode::ListenController
	=====================
	*/
	void GameNode::ListenController() {
		GameControl::GetSingleton()->AddControlListener(this);
	}

	/*
	=====================
	GameNode::UnlistenController
	=====================
	*/
	void GameNode::UnlistenController() {
		GameControl::GetSingleton()->RemoveControlListener(this);
	}

	/*
	=====================
	GameNode::ListenFrame
	=====================
	*/
	void GameNode::ListenFrame() {
		GameControl::GetSingleton()->AddFrameListener(this);
	}

	/*
	=====================
	GameNode::UnlistenFrame
	=====================
	*/
	void GameNode::UnlistenFrame() {
		GameControl::GetSingleton()->RemoveFrameListener(this);
	}

	/*
	=====================
	GameNode::GetWorldPosition
	=====================
	*/
	Vec2 GameNode::GetWorldPosition() const {
		if (parent) {
			return position + parent->GetWorldPosition();
		}
		return position;
	}

	/*
	=====================
	GameNode::GetWorldRotation
	=====================
	*/
	float GameNode::GetWorldRotation() const {
		if (parent) {
			return rotation + parent->GetWorldRotation();
		}
		return rotation;
	}

	/*
	=====================
	GameNode::GetLayerPosition
	=====================
	*/
	Vec2 GameNode::GetLayerPosition() const {
		if (parent) {
			return position + parent->GetLayerPosition();
		}

		return position;
	}

	/*
	=====================
	GameNode::Draw
	=====================
	*/
	void GameNode::Draw() {
		glPushMatrix();
		Vec2 fac = GameControl::GetSingleton()->GetCoordinateFactor();

		glTranslatef(position.x / fac.x, position.y / fac.y, 0.f);
		glRotatef(rotation, 0.f, 0.f, 1.f);

		if (shadowShape && dbgShadowShape) {
			glPushMatrix();

			fac = GameControl::GetSingleton()->GetWindowScale();
			glScalef(fac.x, fac.y, 1.f);

			shadowShape->DebugDraw();

			glPopMatrix();
		}

		OrderChildren();

		for (unsigned int i=0; i<children.size(); i++) {
			children[i]->Draw();
		}

		glPopMatrix();
	}

	/*
	=====================
	GameNode::BatchDraw
	=====================
	*/
	void GameNode::BatchDraw() {
		glPushMatrix();
		Vec2 fac = GameControl::GetSingleton()->GetCoordinateFactor();

		glTranslatef(position.x / fac.x, position.y / fac.y, 0.f);
		glRotatef(rotation, 0.f, 0.f, 1.f);

		if (shadowShape && dbgShadowShape) {
			glPushMatrix();

			fac = GameControl::GetSingleton()->GetWindowScale();
			glScalef(fac.x, fac.y, 1.f);

			shadowShape->DebugDraw();

			glPopMatrix();
		}

		OrderChildren();

		for (unsigned int i=0; i<children.size(); i++) {
			// This is the only difference from GameNode::draw(): batchDraw is called
			// on the node's children.
			children[i]->BatchDraw();
		}

		glPopMatrix();
	}

	/*
	=====================
	GameNode::SetZOrder
	=====================
	*/
	void GameNode::SetZOrder(const int z) {
		if (parent) {
			parent->dirtyZOrder = true;
		}

		zOrder = z;
	}

	/*
	=====================
	GameNode::GetZOrder
	=====================
	*/
	int GameNode::GetZOrder() const {
		return zOrder;
	}

	/*
	=====================
	GameNode::OrderChildren
	=====================
	*/
	void GameNode::OrderChildren() {
		if (!dirtyZOrder || children.size() <= 1) {
			return;
		}

		// Insertion sorting - the children should be somewhat sorted already.
		for (unsigned int j=1; j<children.size(); j++) {
			GameNode *key = children[j];
			int i = j - 1;

			while (i >= 0 && children[i]->zOrder < key->zOrder) {
				children[i+1] = children[i];
				i--;
			}
			children[i+1] = key;
		}

		dirtyZOrder = false;
	}

	/*
	=====================
	GameNode::RunAction
	=====================
	*/
	void GameNode::RunAction(Action *a) {
		AddChild(a);
		a->Activate();
	}

	/*
	=====================
	GameNode::RunActionQueue
	=====================
	*/
	void GameNode::RunActionQueue(ActionQueue *aq) {
		AddChild(aq);
		aq->Activate();
	}

	/*
	=====================
	GameNode::SetShadowShape
	=====================
	*/
	void GameNode::SetShadowShape(Vec2 vertices[], const int vertexCount) {
		if (shadowShape) {
			delete shadowShape;
		}

		shadowShape = new PolygonShape(vertices, vertexCount, this);
	}

	/*
	=====================
	GameNode::SetShadowShapeDebugDraw
	=====================
	*/
	void GameNode::SetShadowShapeDebugDraw(const bool flag) {
		dbgShadowShape = flag;
	}

	/*
	=====================
	GameNode::GetShadowShape
	=====================
	*/
	PolygonShape* GameNode::GetShadowShape() const {
		return shadowShape;
	}

	/*
	==================
	GameNode::ReloadTextures
	==================
	*/
	void GameNode::ReloadTextures() {
		for (unsigned i=0; i<children.size(); i++) {
			children[i]->ReloadTextures();
		}
	}
}
<commit_msg>Fixed GetWorldPos and GetLayerPos<commit_after>#include "PimInternal.h"

#include "PimVec2.h"
#include "PimGameNode.h"
#include "PimAssert.h"
#include "PimInput.h"
#include "PimGameControl.h"
#include "PimLayer.h"
#include "PimPolygonShape.h"
#include "PimScene.h"
#include "PimLightingSystem.h"
#include "PimAction.h"

#include <iostream>

namespace Pim {
	/*
	=====================
	GameNode::GameNode
	=====================
	*/
	GameNode::GameNode() {
		parent					= NULL;
		rotation				= 0.f;
		zOrder					= 0;
		dirtyZOrder				= false;
		willDelete				= false;
		shadowShape				= NULL;
		dbgShadowShape			= false;
		userData				= NULL;
	}

	/*
	=====================
	GameNode::~GameNode
	=====================
	*/
	GameNode::~GameNode() {
		if (!willDelete) {
			PrepareDeletion();
		}

		RemoveAllChildren();

		UnlistenFrame();
		UnlistenInput();
		UnlistenController();
	}

	/*
	=====================
	GameNode::PrepareDeletion
	=====================
	*/
	void GameNode::PrepareDeletion() {
		if (GetParentLayer()) {
			GetParentLayer()->RemoveLight(this);
			GetParentLayer()->RemoveShadowCaster(this);
		}

		if (shadowShape) {
			delete shadowShape;
		}

		RemoveAllChildren();

		UnlistenInput();
		UnlistenController();

		parent = NULL;
		willDelete = true;
	}

	/*
	=====================
	GameNode::AddChild
	=====================
	*/
	void GameNode::AddChild(GameNode *ch) {
		PimAssert(!ch->GetParent(), "Node already has a parent");

		Layer *layer = dynamic_cast<Layer*>(ch);
		if (layer) {
			layer->LoadResources();
		}

		ch->parent = this;
		children.push_back(ch);

		dirtyZOrder = true;
	}

	/*
	=====================
	GameNode::RemoveChild
	=====================
	*/
	void GameNode::RemoveChild(GameNode *ch, const bool cleanup) {
		for (unsigned int i=0; i<children.size(); i++) {
			if (children[i] == ch) {
				children.erase(children.begin() + i);

				if (cleanup) {
					GameControl::GetSingleton()->AddNodeToDelete(ch);
				} else {
					ch->parent = NULL;
				}
			}
		}
	}

	/*
	=====================
	GameNode::RemoveAllChildren
	=====================
	*/
	void GameNode::RemoveAllChildren(const bool cleanup) {
		// Delete all if required
		for (unsigned i=0; i<children.size(); i++) {
			if (cleanup) {
				GameControl::GetSingleton()->AddNodeToDelete(children[i]);
			} else {
				children[i]->parent = NULL;
			}
		}

		// THEN clear the array
		children.clear();
	}

	/*
	=====================
	GameNode::GetParent
	=====================
	*/
	GameNode* GameNode::GetParent() const {
		return parent;
	}

	/*
	=====================
	GameNode::GetParentScene
	=====================
	*/
	Scene* GameNode::GetParentScene() const {
		if (parent) {
			return parent->GetParentScene();
		}
		return NULL;
	}

	/*
	=====================
	GameNode::GetParentLayer
	=====================
	*/
	Layer* GameNode::GetParentLayer() {
		if (parent) {
			return parent->GetParentLayer();
		}
		return NULL;
	}

	/*
	=====================
	GameNode::ListenInput
	=====================
	*/
	void GameNode::ListenInput() {
		GameControl::GetSingleton()->AddKeyListener(this);
		GameControl::GetSingleton()->AddMouseListener(this);
	}

	/*
	=====================
	GameNode::UnlistenInput
	=====================
	*/
	void GameNode::UnlistenInput() {
		GameControl::GetSingleton()->RemoveKeyListener(this);
		GameControl::GetSingleton()->RemoveMouseListener(this);
	}

	/*
	=====================
	GameNode::ListenKeys
	=====================
	*/
	void GameNode::ListenKeys() {
		GameControl::GetSingleton()->AddKeyListener(this);
	}

	/*
	=====================
	GameNode::UnlistenKeys
	=====================
	*/
	void GameNode::UnlistenKeys() {
		GameControl::GetSingleton()->RemoveKeyListener(this);
	}

	/*
	=====================
	GameNode::ListenMouse
	=====================
	*/
	void GameNode::ListenMouse() {
		GameControl::GetSingleton()->AddMouseListener(this);
	}

	/*
	=====================
	GameNode::UnlistenMouse
	=====================
	*/
	void GameNode::UnlistenMouse() {
		GameControl::GetSingleton()->RemoveMouseListener(this);
	}

	/*
	=====================
	GameNode::ListenController
	=====================
	*/
	void GameNode::ListenController() {
		GameControl::GetSingleton()->AddControlListener(this);
	}

	/*
	=====================
	GameNode::UnlistenController
	=====================
	*/
	void GameNode::UnlistenController() {
		GameControl::GetSingleton()->RemoveControlListener(this);
	}

	/*
	=====================
	GameNode::ListenFrame
	=====================
	*/
	void GameNode::ListenFrame() {
		GameControl::GetSingleton()->AddFrameListener(this);
	}

	/*
	=====================
	GameNode::UnlistenFrame
	=====================
	*/
	void GameNode::UnlistenFrame() {
		GameControl::GetSingleton()->RemoveFrameListener(this);
	}

	/*
	=====================
	GameNode::GetWorldPosition
	=====================
	*/
	Vec2 GameNode::GetWorldPosition() const {
		if (parent) {
			return position.RotateAroundPoint(Vec2(0.f, 0.f), parent->rotation) +
					parent->GetWorldPosition();
		}
		return position;
	}

	/*
	=====================
	GameNode::GetWorldRotation
	=====================
	*/
	float GameNode::GetWorldRotation() const {
		if (parent) {
			return rotation + parent->GetWorldRotation();
		}
		return rotation;
	}

	/*
	=====================
	GameNode::GetLayerPosition
	=====================
	*/
	Vec2 GameNode::GetLayerPosition() const {
		if (parent) {
			return position.RotateAroundPoint(Vec2(0.f, 0.f), parent->rotation) +
					parent->GetLayerPosition();
		}

		return position;
	}

	/*
	=====================
	GameNode::Draw
	=====================
	*/
	void GameNode::Draw() {
		glPushMatrix();
		Vec2 fac = GameControl::GetSingleton()->GetCoordinateFactor();

		glTranslatef(position.x / fac.x, position.y / fac.y, 0.f);
		glRotatef(rotation, 0.f, 0.f, 1.f);

		if (shadowShape && dbgShadowShape) {
			glPushMatrix();

			fac = GameControl::GetSingleton()->GetWindowScale();
			glScalef(fac.x, fac.y, 1.f);

			shadowShape->DebugDraw();

			glPopMatrix();
		}

		OrderChildren();

		for (unsigned int i=0; i<children.size(); i++) {
			children[i]->Draw();
		}

		glPopMatrix();
	}

	/*
	=====================
	GameNode::BatchDraw
	=====================
	*/
	void GameNode::BatchDraw() {
		glPushMatrix();
		Vec2 fac = GameControl::GetSingleton()->GetCoordinateFactor();

		glTranslatef(position.x / fac.x, position.y / fac.y, 0.f);
		glRotatef(rotation, 0.f, 0.f, 1.f);

		if (shadowShape && dbgShadowShape) {
			glPushMatrix();

			fac = GameControl::GetSingleton()->GetWindowScale();
			glScalef(fac.x, fac.y, 1.f);

			shadowShape->DebugDraw();

			glPopMatrix();
		}

		OrderChildren();

		for (unsigned int i=0; i<children.size(); i++) {
			// This is the only difference from GameNode::draw(): batchDraw is called
			// on the node's children.
			children[i]->BatchDraw();
		}

		glPopMatrix();
	}

	/*
	=====================
	GameNode::SetZOrder
	=====================
	*/
	void GameNode::SetZOrder(const int z) {
		if (parent) {
			parent->dirtyZOrder = true;
		}

		zOrder = z;
	}

	/*
	=====================
	GameNode::GetZOrder
	=====================
	*/
	int GameNode::GetZOrder() const {
		return zOrder;
	}

	/*
	=====================
	GameNode::OrderChildren
	=====================
	*/
	void GameNode::OrderChildren() {
		if (!dirtyZOrder || children.size() <= 1) {
			return;
		}

		// Insertion sorting - the children should be somewhat sorted already.
		for (unsigned int j=1; j<children.size(); j++) {
			GameNode *key = children[j];
			int i = j - 1;

			while (i >= 0 && children[i]->zOrder < key->zOrder) {
				children[i+1] = children[i];
				i--;
			}
			children[i+1] = key;
		}

		dirtyZOrder = false;
	}

	/*
	=====================
	GameNode::RunAction
	=====================
	*/
	void GameNode::RunAction(Action *a) {
		AddChild(a);
		a->Activate();
	}

	/*
	=====================
	GameNode::RunActionQueue
	=====================
	*/
	void GameNode::RunActionQueue(ActionQueue *aq) {
		AddChild(aq);
		aq->Activate();
	}

	/*
	=====================
	GameNode::SetShadowShape
	=====================
	*/
	void GameNode::SetShadowShape(Vec2 vertices[], const int vertexCount) {
		if (shadowShape) {
			delete shadowShape;
		}

		shadowShape = new PolygonShape(vertices, vertexCount, this);
	}

	/*
	=====================
	GameNode::SetShadowShapeDebugDraw
	=====================
	*/
	void GameNode::SetShadowShapeDebugDraw(const bool flag) {
		dbgShadowShape = flag;
	}

	/*
	=====================
	GameNode::GetShadowShape
	=====================
	*/
	PolygonShape* GameNode::GetShadowShape() const {
		return shadowShape;
	}

	/*
	==================
	GameNode::ReloadTextures
	==================
	*/
	void GameNode::ReloadTextures() {
		for (unsigned i=0; i<children.size(); i++) {
			children[i]->ReloadTextures();
		}
	}
}
<|endoftext|>


<commit_before>// Copyright (c) 2010 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 "chrome/browser/views/tab_contents/tab_contents_container.h"

#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/render_widget_host_view.h"
#include "chrome/browser/tab_contents/interstitial_page.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/ui/view_ids.h"
#include "chrome/browser/ui/views/tab_contents/native_tab_contents_container.h"
#include "chrome/common/notification_details.h"
#include "chrome/common/notification_source.h"

#if defined(TOUCH_UI)
#include "chrome/browser/ui/views/tab_contents/native_tab_contents_container_gtk.h"
#include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h"
#include "views/border.h"
#include "views/fill_layout.h"
#endif

////////////////////////////////////////////////////////////////////////////////
// TabContentsContainer, public:

TabContentsContainer::TabContentsContainer()
    : native_container_(NULL),
      tab_contents_(NULL),
      reserved_area_delegate_(NULL) {
  SetID(VIEW_ID_TAB_CONTAINER);
}

TabContentsContainer::~TabContentsContainer() {
  if (tab_contents_)
    RemoveObservers();
}

void TabContentsContainer::ChangeTabContents(TabContents* contents) {
  if (tab_contents_) {
#if !defined(TOUCH_UI)
    native_container_->DetachContents(tab_contents_);
#endif
    tab_contents_->WasHidden();
    RemoveObservers();
  }
#if !defined(TOUCH_UI)
  TabContents* old_contents = tab_contents_;
#endif
  tab_contents_ = contents;
  // When detaching the last tab of the browser ChangeTabContents is invoked
  // with NULL. Don't attempt to do anything in that case.
  if (tab_contents_) {
#if defined(TOUCH_UI)
    views::View *v = static_cast<TabContentsViewViews*>(contents->view());
    // Guard against re-adding ourselves, which happens because the NULL
    // value is ignored by the pre-existing if() above.
    if (v->GetParent() != this) {
      AddChildView(v);
      SetLayoutManager(new views::FillLayout());
      Layout();
    }
#else
    RenderWidgetHostViewChanged(
        old_contents ? old_contents->GetRenderWidgetHostView() : NULL,
        tab_contents_->GetRenderWidgetHostView());
    native_container_->AttachContents(tab_contents_);
#endif
    AddObservers();
  }
}

void TabContentsContainer::TabContentsFocused(TabContents* tab_contents) {
  if (native_container_)
    native_container_->TabContentsFocused(tab_contents);
}

void TabContentsContainer::SetFastResize(bool fast_resize) {
  if (native_container_)
    native_container_->SetFastResize(fast_resize);
}

////////////////////////////////////////////////////////////////////////////////
// TabContentsContainer, NotificationObserver implementation:

void TabContentsContainer::Observe(NotificationType type,
                                   const NotificationSource& source,
                                   const NotificationDetails& details) {
  if (type == NotificationType::RENDER_VIEW_HOST_CHANGED) {
    RenderViewHostSwitchedDetails* switched_details =
        Details<RenderViewHostSwitchedDetails>(details).ptr();
    RenderViewHostChanged(switched_details->old_host,
                          switched_details->new_host);
  } else if (type == NotificationType::TAB_CONTENTS_DESTROYED) {
    TabContentsDestroyed(Source<TabContents>(source).ptr());
  } else {
    NOTREACHED();
  }
}

////////////////////////////////////////////////////////////////////////////////
// TabContentsContainer, View overrides:

void TabContentsContainer::Layout() {
#if defined(TOUCH_UI)
  views::View::Layout();
#else
  if (native_container_) {
    if (reserved_area_delegate_)
      reserved_area_delegate_->UpdateReservedContentsRect(this);
    native_container_->GetView()->SetBounds(0, 0, width(), height());
    native_container_->GetView()->Layout();
  }
#endif
}

AccessibilityTypes::Role TabContentsContainer::GetAccessibleRole() {
  return AccessibilityTypes::ROLE_WINDOW;
}

void TabContentsContainer::ViewHierarchyChanged(bool is_add,
                                                views::View* parent,
                                                views::View* child) {
#if defined(TOUCH_UI)
  views::View::ViewHierarchyChanged(is_add, parent, child);
#else
  if (is_add && child == this) {
    native_container_ = NativeTabContentsContainer::CreateNativeContainer(this);
    AddChildView(native_container_->GetView());
  }
#endif
}

////////////////////////////////////////////////////////////////////////////////
// TabContentsContainer, private:

void TabContentsContainer::AddObservers() {
  // TabContents can change their RenderViewHost and hence the HWND that is
  // shown and getting focused.  We need to keep track of that so we install
  // the focus subclass on the shown HWND so we intercept focus change events.
  registrar_.Add(this,
                 NotificationType::RENDER_VIEW_HOST_CHANGED,
                 Source<NavigationController>(&tab_contents_->controller()));

  registrar_.Add(this,
                 NotificationType::TAB_CONTENTS_DESTROYED,
                 Source<TabContents>(tab_contents_));
}

void TabContentsContainer::RemoveObservers() {
  registrar_.RemoveAll();
}

void TabContentsContainer::RenderViewHostChanged(RenderViewHost* old_host,
                                                 RenderViewHost* new_host) {
#if defined(TOUCH_UI)
  NOTIMPLEMENTED();  // TODO(anicolao)
#else
  if (new_host) {
    RenderWidgetHostViewChanged(
        old_host ? old_host->view() : NULL, new_host->view());
  }
  native_container_->RenderViewHostChanged(old_host, new_host);
#endif
}

void TabContentsContainer::TabContentsDestroyed(TabContents* contents) {
  // Sometimes, a TabContents is destroyed before we know about it. This allows
  // us to clean up our state in case this happens.
  DCHECK(contents == tab_contents_);
  ChangeTabContents(NULL);
}

void TabContentsContainer::RenderWidgetHostViewChanged(
    RenderWidgetHostView* old_view, RenderWidgetHostView* new_view) {
  // Carry over the reserved rect, if possible.
  if (old_view && new_view) {
    new_view->set_reserved_contents_rect(old_view->reserved_contents_rect());
  } else {
    if (reserved_area_delegate_)
      reserved_area_delegate_->UpdateReservedContentsRect(this);
  }
}
<commit_msg>Remove undisplayed tabs from the views hierarchy because event delivery doesn't respect z-order.<commit_after>// Copyright (c) 2010 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 "chrome/browser/views/tab_contents/tab_contents_container.h"

#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/render_widget_host_view.h"
#include "chrome/browser/tab_contents/interstitial_page.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/ui/view_ids.h"
#include "chrome/browser/ui/views/tab_contents/native_tab_contents_container.h"
#include "chrome/common/notification_details.h"
#include "chrome/common/notification_source.h"

#if defined(TOUCH_UI)
#include "chrome/browser/ui/views/tab_contents/native_tab_contents_container_gtk.h"
#include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h"
#include "views/border.h"
#include "views/fill_layout.h"
#endif

////////////////////////////////////////////////////////////////////////////////
// TabContentsContainer, public:

TabContentsContainer::TabContentsContainer()
    : native_container_(NULL),
      tab_contents_(NULL),
      reserved_area_delegate_(NULL) {
  SetID(VIEW_ID_TAB_CONTAINER);
}

TabContentsContainer::~TabContentsContainer() {
  if (tab_contents_)
    RemoveObservers();
}

void TabContentsContainer::ChangeTabContents(TabContents* contents) {
  if (tab_contents_) {
#if !defined(TOUCH_UI)
    native_container_->DetachContents(tab_contents_);
#else
    views::View *v = static_cast<TabContentsViewViews*>(tab_contents_->view());
    RemoveChildView(v);
#endif
    tab_contents_->WasHidden();
    RemoveObservers();
  }
#if !defined(TOUCH_UI)
  TabContents* old_contents = tab_contents_;
#endif
  tab_contents_ = contents;
  // When detaching the last tab of the browser ChangeTabContents is invoked
  // with NULL. Don't attempt to do anything in that case.
  if (tab_contents_) {
#if defined(TOUCH_UI)
    views::View *v = static_cast<TabContentsViewViews*>(contents->view());
    // Guard against re-adding ourselves, which happens because the NULL
    // value is ignored by the pre-existing if() above.
    if (v->GetParent() != this) {
      AddChildView(v);
      SetLayoutManager(new views::FillLayout());
      Layout();
    }
#else
    RenderWidgetHostViewChanged(
        old_contents ? old_contents->GetRenderWidgetHostView() : NULL,
        tab_contents_->GetRenderWidgetHostView());
    native_container_->AttachContents(tab_contents_);
#endif
    AddObservers();
  }
}

void TabContentsContainer::TabContentsFocused(TabContents* tab_contents) {
  if (native_container_)
    native_container_->TabContentsFocused(tab_contents);
}

void TabContentsContainer::SetFastResize(bool fast_resize) {
  if (native_container_)
    native_container_->SetFastResize(fast_resize);
}

////////////////////////////////////////////////////////////////////////////////
// TabContentsContainer, NotificationObserver implementation:

void TabContentsContainer::Observe(NotificationType type,
                                   const NotificationSource& source,
                                   const NotificationDetails& details) {
  if (type == NotificationType::RENDER_VIEW_HOST_CHANGED) {
    RenderViewHostSwitchedDetails* switched_details =
        Details<RenderViewHostSwitchedDetails>(details).ptr();
    RenderViewHostChanged(switched_details->old_host,
                          switched_details->new_host);
  } else if (type == NotificationType::TAB_CONTENTS_DESTROYED) {
    TabContentsDestroyed(Source<TabContents>(source).ptr());
  } else {
    NOTREACHED();
  }
}

////////////////////////////////////////////////////////////////////////////////
// TabContentsContainer, View overrides:

void TabContentsContainer::Layout() {
#if defined(TOUCH_UI)
  views::View::Layout();
#else
  if (native_container_) {
    if (reserved_area_delegate_)
      reserved_area_delegate_->UpdateReservedContentsRect(this);
    native_container_->GetView()->SetBounds(0, 0, width(), height());
    native_container_->GetView()->Layout();
  }
#endif
}

AccessibilityTypes::Role TabContentsContainer::GetAccessibleRole() {
  return AccessibilityTypes::ROLE_WINDOW;
}

void TabContentsContainer::ViewHierarchyChanged(bool is_add,
                                                views::View* parent,
                                                views::View* child) {
#if defined(TOUCH_UI)
  views::View::ViewHierarchyChanged(is_add, parent, child);
#else
  if (is_add && child == this) {
    native_container_ = NativeTabContentsContainer::CreateNativeContainer(this);
    AddChildView(native_container_->GetView());
  }
#endif
}

////////////////////////////////////////////////////////////////////////////////
// TabContentsContainer, private:

void TabContentsContainer::AddObservers() {
  // TabContents can change their RenderViewHost and hence the HWND that is
  // shown and getting focused.  We need to keep track of that so we install
  // the focus subclass on the shown HWND so we intercept focus change events.
  registrar_.Add(this,
                 NotificationType::RENDER_VIEW_HOST_CHANGED,
                 Source<NavigationController>(&tab_contents_->controller()));

  registrar_.Add(this,
                 NotificationType::TAB_CONTENTS_DESTROYED,
                 Source<TabContents>(tab_contents_));
}

void TabContentsContainer::RemoveObservers() {
  registrar_.RemoveAll();
}

void TabContentsContainer::RenderViewHostChanged(RenderViewHost* old_host,
                                                 RenderViewHost* new_host) {
#if defined(TOUCH_UI)
  NOTIMPLEMENTED();  // TODO(anicolao)
#else
  if (new_host) {
    RenderWidgetHostViewChanged(
        old_host ? old_host->view() : NULL, new_host->view());
  }
  native_container_->RenderViewHostChanged(old_host, new_host);
#endif
}

void TabContentsContainer::TabContentsDestroyed(TabContents* contents) {
  // Sometimes, a TabContents is destroyed before we know about it. This allows
  // us to clean up our state in case this happens.
  DCHECK(contents == tab_contents_);
  ChangeTabContents(NULL);
}

void TabContentsContainer::RenderWidgetHostViewChanged(
    RenderWidgetHostView* old_view, RenderWidgetHostView* new_view) {
  // Carry over the reserved rect, if possible.
  if (old_view && new_view) {
    new_view->set_reserved_contents_rect(old_view->reserved_contents_rect());
  } else {
    if (reserved_area_delegate_)
      reserved_area_delegate_->UpdateReservedContentsRect(this);
  }
}
<|endoftext|>


<commit_before>#include <halley.hpp>
using namespace Halley;

#include "halley/entity/components/transform_2d_component.h"
#include "components/camera_component.h"
#include "components/sprite_component.h"
#include "components/sprite_animation_component.h"
#include "components/text_label_component.h"

// System factory functions

using SystemFactoryPtr = System* (*)();
using SystemFactoryMap = HashMap<String, SystemFactoryPtr>;

static SystemFactoryMap makeSystemFactories() {
	SystemFactoryMap result;
	return result;
}

using ComponentFactoryPtr = std::function<CreateComponentFunctionResult(EntityFactory&, EntityRef&, const ConfigNode&)>;
using ComponentFactoryMap = HashMap<String, ComponentFactoryPtr>;

static ComponentFactoryMap makeComponentFactories() {
	ComponentFactoryMap result;
	result["Transform2D"] = [] (EntityFactory& factory, EntityRef& e, const ConfigNode& node) -> CreateComponentFunctionResult { return factory.createComponent<Transform2DComponent>(e, node); };
	result["Camera"] = [] (EntityFactory& factory, EntityRef& e, const ConfigNode& node) -> CreateComponentFunctionResult { return factory.createComponent<CameraComponent>(e, node); };
	result["Sprite"] = [] (EntityFactory& factory, EntityRef& e, const ConfigNode& node) -> CreateComponentFunctionResult { return factory.createComponent<SpriteComponent>(e, node); };
	result["SpriteAnimation"] = [] (EntityFactory& factory, EntityRef& e, const ConfigNode& node) -> CreateComponentFunctionResult { return factory.createComponent<SpriteAnimationComponent>(e, node); };
	result["TextLabel"] = [] (EntityFactory& factory, EntityRef& e, const ConfigNode& node) -> CreateComponentFunctionResult { return factory.createComponent<TextLabelComponent>(e, node); };
	return result;
}

namespace Halley {
	std::unique_ptr<System> createSystem(String name) {
		static SystemFactoryMap factories = makeSystemFactories();
		auto result = factories.find(name);
		if (result == factories.end()) {
			throw Exception("System not found: " + name, HalleyExceptions::Entity);
		}
		return std::unique_ptr<System>(result->second());
	}

   CreateComponentFunctionResult createComponent(EntityFactory& factory, const String& name, EntityRef& entity, const ConfigNode& componentData) {
		static ComponentFactoryMap factories = makeComponentFactories();
		auto result = factories.find(name);
		if (result == factories.end()) {
			throw Exception("Component not found: " + name, HalleyExceptions::Entity);
		}
		return result->second(factory, entity, componentData);
   }
}
<commit_msg>Update registry<commit_after>#include <halley.hpp>
using namespace Halley;

#include "halley/entity/components/transform_2d_component.h"
#include "components/sprite_component.h"
#include "components/text_label_component.h"
#include "components/sprite_animation_component.h"
#include "components/camera_component.h"

// System factory functions

using SystemFactoryPtr = System* (*)();
using SystemFactoryMap = HashMap<String, SystemFactoryPtr>;

static SystemFactoryMap makeSystemFactories() {
	SystemFactoryMap result;
	return result;
}

using ComponentFactoryPtr = std::function<CreateComponentFunctionResult(EntityFactory&, EntityRef&, const ConfigNode&)>;
using ComponentFactoryMap = HashMap<String, ComponentFactoryPtr>;

static ComponentFactoryMap makeComponentFactories() {
	ComponentFactoryMap result;
	result["Transform2D"] = [] (EntityFactory& factory, EntityRef& e, const ConfigNode& node) -> CreateComponentFunctionResult { return factory.createComponent<Transform2DComponent>(e, node); };
	result["Sprite"] = [] (EntityFactory& factory, EntityRef& e, const ConfigNode& node) -> CreateComponentFunctionResult { return factory.createComponent<SpriteComponent>(e, node); };
	result["TextLabel"] = [] (EntityFactory& factory, EntityRef& e, const ConfigNode& node) -> CreateComponentFunctionResult { return factory.createComponent<TextLabelComponent>(e, node); };
	result["SpriteAnimation"] = [] (EntityFactory& factory, EntityRef& e, const ConfigNode& node) -> CreateComponentFunctionResult { return factory.createComponent<SpriteAnimationComponent>(e, node); };
	result["Camera"] = [] (EntityFactory& factory, EntityRef& e, const ConfigNode& node) -> CreateComponentFunctionResult { return factory.createComponent<CameraComponent>(e, node); };
	return result;
}

namespace Halley {
	std::unique_ptr<System> createSystem(String name) {
		static SystemFactoryMap factories = makeSystemFactories();
		auto result = factories.find(name);
		if (result == factories.end()) {
			throw Exception("System not found: " + name, HalleyExceptions::Entity);
		}
		return std::unique_ptr<System>(result->second());
	}

   CreateComponentFunctionResult createComponent(EntityFactory& factory, const String& name, EntityRef& entity, const ConfigNode& componentData) {
		static ComponentFactoryMap factories = makeComponentFactories();
		auto result = factories.find(name);
		if (result == factories.end()) {
			throw Exception("Component not found: " + name, HalleyExceptions::Entity);
		}
		return result->second(factory, entity, componentData);
   }
}
<|endoftext|>


<commit_before>/**
 * \file StatusFrame.cpp
 * \brief Main Windows Class
 */

#include "StatusFrame.h"

BEGIN_EVENT_TABLE(StatusFrame,wxFrame)
    EVT_MENU(ID_NEWSTATUS, StatusFrame::NewStatusWindow)
    EVT_MENU(ID_NEWGRAPH, StatusFrame::NewGraphWindow)
    EVT_MENU(-1, StatusFrame::SelectDevice)
    EVT_CLOSE(StatusFrame::OnClose)
END_EVENT_TABLE()

StatusFrame::StatusFrame(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style)
: wxFrame(parent, id, title, position, size, style) {
    /**
    *   Constructor for the Main frame.
    */
    deviceId = "Please select a device from the menu.";

    CreateGUIControls();
}

StatusFrame::~StatusFrame() {
    /**
    *   Destructor for the Main form.
    */
}

void StatusFrame::Update() {
    /**
     * Updates the GUI with new database information
     */
    wxMenuBar *menubar = new wxMenuBar;
    wxMenu *devices = new wxMenu;
    wxMenu *view = new wxMenu;

    deviceIds = DB_getAllDevices();

    menubar->Append(devices, wxT("&Devices"));

    for(unsigned int i = 0; i < deviceIds.size(); i++) {
        devices->Append(10000+i, deviceIds[i]);
    }

    menubar->Append(view, wxT("&View"));

    view->Append(ID_NEWSTATUS, "New Status Window");
    view->Append(ID_NEWGRAPH, "New Graph Window");

    SetMenuBar(menubar);

    map<string, string> gps_info;
    gps_info = DB_getMostRecentGPS(atoi(deviceId.c_str()));

    wxString info = wxString::Format(wxT(""
        ""
        "Device: %s\n"
        "
\n"
        "Location\n
"
        "Latitude: %s\n
"
        "Longitude: %s\n
"
        "Altitude (M): %s\n
"
        "Altitude (Ft): %s\n
"
        "Speed (Knots): %s\n
"
        "Speed (M/S): %s\n
"
        "Bearing: %s\n
"
        "Climb: %s\n
"
        "GPS Status: %s\n"
        "\n
"
        "Status\n
"
        "Battery 1 (V): \n
"
        "Battery 2 (V): \n
"
        "Buss (V): \n
"
        "Signal (%%): \n
"
        "Temperature Int. (c): \n
"
        "Temperature Ext. (c): \n
"
        "Pressure (HPA): \n
"
        "RH (%%): \n"
        ""
        ),
        deviceId.c_str(),
        gps_info["Latitude"].c_str(),
        gps_info["Longitude"].c_str(),
        gps_info["Altitude_m"].c_str(),
        gps_info["Altitude_ft"].c_str(),
        gps_info["Spd_knots"].c_str(),
        gps_info["Spd_mps"].c_str(),
        gps_info["Hdg"].c_str(),
        gps_info["Rate_mps"].c_str(),
        gps_info["Status"].c_str()
        );

    deviceInfo->SetPage(info);
}

void StatusFrame::CreateGUIControls() {
   /**
    *   Creates all of the GUI controls on the main form.
    */

    // Set window properties and title bar
    SetTitle(wxT("Device Status"));
    SetIcon(wxNullIcon);

    mainPanel = new wxPanel(this, wxID_ANY);
    mainSizer = new wxBoxSizer(wxVERTICAL);
    mainPanel->SetSizer(mainSizer);

    deviceInfo = new wxHtmlWindow(mainPanel);
    mainSizer->Add(deviceInfo, 1, wxEXPAND | wxALL);

    Update();

}

void StatusFrame::OnClose(wxCloseEvent& event) {
    /**
    *   Event handler for the form closing event
    *   Exit the ChaosConnect Program
    */
    Destroy();
}

void StatusFrame::SelectDevice( wxCommandEvent& event ) {
    /**
     * Selects a device from the menu
     *
     * This is a catchall menu event handler becasue I couldn't think
     * of a better way to do this because the menu is dynamic
     */

    int id = event.GetId();

    if(id > 10000) {
        /// We're selecting a device
        deviceId = deviceIds[id - 10000];
    }

    Update();
}

void StatusFrame::NewStatusWindow( wxCommandEvent& event ) {
    /**
     * Launches a new status window
     */

    StatusFrame* frame = new StatusFrame(NULL);
    frame->Show();
}

void StatusFrame::NewGraphWindow( wxCommandEvent& event ) {
    /**
     * Launches a new graph window
     */

    GraphFrame* frame = new GraphFrame(NULL);
    frame->Show();
}
<commit_msg>- updated comments<commit_after>/**
 * \file StatusFrame.cpp
 * \brief Main Windows Class
 */

#include "StatusFrame.h"

BEGIN_EVENT_TABLE(StatusFrame,wxFrame)
    EVT_MENU(ID_NEWSTATUS, StatusFrame::NewStatusWindow)
    EVT_MENU(ID_NEWGRAPH, StatusFrame::NewGraphWindow)
    EVT_MENU(-1, StatusFrame::SelectDevice)
    EVT_CLOSE(StatusFrame::OnClose)
END_EVENT_TABLE()

/**
   Constructor for the Main frame.
*/

StatusFrame::StatusFrame(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style)
: wxFrame(parent, id, title, position, size, style) {
    deviceId = "Please select a device from the menu.";

    CreateGUIControls();
}

/**
   Destructor for the Main form.
*/

StatusFrame::~StatusFrame() {
}

/**
    Updates the GUI with new database information
*/

void StatusFrame::Update() {
    wxMenuBar *menubar = new wxMenuBar;
    wxMenu *devices = new wxMenu;
    wxMenu *view = new wxMenu;

    deviceIds = DB_getAllDevices();

    menubar->Append(devices, wxT("&Devices"));

    for(unsigned int i = 0; i < deviceIds.size(); i++) {
        devices->Append(10000+i, deviceIds[i]);
    }

    menubar->Append(view, wxT("&View"));

    view->Append(ID_NEWSTATUS, "New Status Window");
    view->Append(ID_NEWGRAPH, "New Graph Window");

    SetMenuBar(menubar);

    map<string, string> gps_info;
    gps_info = DB_getMostRecentGPS(atoi(deviceId.c_str()));

    wxString info = wxString::Format(wxT(""
        ""
        "Device: %s\n"
        "
\n"
        "Location\n
"
        "Latitude: %s\n
"
        "Longitude: %s\n
"
        "Altitude (M): %s\n
"
        "Altitude (Ft): %s\n
"
        "Speed (Knots): %s\n
"
        "Speed (M/S): %s\n
"
        "Bearing: %s\n
"
        "Climb: %s\n
"
        "GPS Status: %s\n"
        "\n
"
        "Status\n
"
        "Battery 1 (V): \n
"
        "Battery 2 (V): \n
"
        "Buss (V): \n
"
        "Signal (%%): \n
"
        "Temperature Int. (c): \n
"
        "Temperature Ext. (c): \n
"
        "Pressure (HPA): \n
"
        "RH (%%): \n"
        ""
        ),
        deviceId.c_str(),
        gps_info["Latitude"].c_str(),
        gps_info["Longitude"].c_str(),
        gps_info["Altitude_m"].c_str(),
        gps_info["Altitude_ft"].c_str(),
        gps_info["Spd_knots"].c_str(),
        gps_info["Spd_mps"].c_str(),
        gps_info["Hdg"].c_str(),
        gps_info["Rate_mps"].c_str(),
        gps_info["Status"].c_str()
        );

    deviceInfo->SetPage(info);
}

/**
   Creates all of the GUI controls on the main form.
*/

void StatusFrame::CreateGUIControls() {

    // Set window properties and title bar
    SetTitle(wxT("Device Status"));
    SetIcon(wxNullIcon);

    mainPanel = new wxPanel(this, wxID_ANY);
    mainSizer = new wxBoxSizer(wxVERTICAL);
    mainPanel->SetSizer(mainSizer);

    deviceInfo = new wxHtmlWindow(mainPanel);
    mainSizer->Add(deviceInfo, 1, wxEXPAND | wxALL);

    Update();

}

/**
    Event handler for the form closing event
    Exit the ChaosConnect Program
*/

void StatusFrame::OnClose(wxCloseEvent& event) {
    Destroy();
}

/**
    Selects a device from the menu

    This is a catchall menu event handler becasue I couldn't think
    of a better way to do this because the menu is dynamic
*/

void StatusFrame::SelectDevice( wxCommandEvent& event ) {

    int id = event.GetId();

    if(id > 10000) {
        /// We're selecting a device
        deviceId = deviceIds[id - 10000];
    }

    Update();
}

/**
    Launches a new status window
*/

void StatusFrame::NewStatusWindow( wxCommandEvent& event ) {

    StatusFrame* frame = new StatusFrame(NULL);
    frame->Show();
}

/**
    Launches a new graph window
*/

void StatusFrame::NewGraphWindow( wxCommandEvent& event ) {

    GraphFrame* frame = new GraphFrame(NULL);
    frame->Show();
}
<|endoftext|>


<commit_before>/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2000, 2010 Oracle and/or its affiliates.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_desktop.hxx"

#define COMPHELPER_SERVICEDECL_COMPONENT_HELPER_MAX_ARGS 12
#include "comphelper/servicedecl.hxx"

using namespace com::sun::star;
namespace sdecl = comphelper::service_decl;

namespace dp_registry {
namespace backend {

namespace configuration {
extern sdecl::ServiceDecl const serviceDecl;
}

namespace component {
extern sdecl::ServiceDecl const serviceDecl;
}

namespace script {
extern sdecl::ServiceDecl const serviceDecl;
}

namespace sfwk {
extern sdecl::ServiceDecl const serviceDecl;
}

namespace help {
extern sdecl::ServiceDecl const serviceDecl;
}

namespace executable {
extern sdecl::ServiceDecl const serviceDecl;
}

} // namespace backend
} // namespace dp_registry

namespace dp_manager {
namespace factory {
extern sdecl::ServiceDecl const serviceDecl;
bool singleton_entries( uno::Reference<registry::XRegistryKey> const& );
}
extern sdecl::ServiceDecl const serviceDecl;
bool singleton_entries( uno::Reference<registry::XRegistryKey> const& );
}

namespace dp_log {
extern sdecl::ServiceDecl const serviceDecl;
}

namespace dp_info {
extern sdecl::ServiceDecl const serviceDecl;
bool singleton_entries( uno::Reference<registry::XRegistryKey> const& );
}

extern "C" {

struct uno_Environment;

void SAL_CALL component_getImplementationEnvironment(
    const sal_Char ** ppEnvTypeName, uno_Environment ** )
{
    *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
}

void * SAL_CALL component_getFactory(
    sal_Char const * pImplName,
    lang::XMultiServiceFactory * pServiceManager,
    registry::XRegistryKey * pRegistryKey )
{
    return component_getFactoryHelper(
        pImplName, pServiceManager, pRegistryKey,
        dp_registry::backend::configuration::serviceDecl,
        dp_registry::backend::component::serviceDecl,
        dp_registry::backend::help::serviceDecl,
        dp_registry::backend::script::serviceDecl,
        dp_registry::backend::sfwk::serviceDecl,
        dp_registry::backend::executable::serviceDecl,
        dp_manager::factory::serviceDecl,
        dp_log::serviceDecl,
        dp_info::serviceDecl,
        dp_manager::serviceDecl);
}

} // extern "C"

<commit_msg>masterfix DEV300: #i10000# build fix<commit_after>/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2000, 2010 Oracle and/or its affiliates.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_desktop.hxx"

#define COMPHELPER_SERVICEDECL_COMPONENT_HELPER_MAX_ARGS 12
#include "comphelper/servicedecl.hxx"

using namespace com::sun::star;
namespace sdecl = comphelper::service_decl;

namespace dp_registry {
namespace backend {

namespace configuration {
extern sdecl::ServiceDecl const serviceDecl;
}

namespace component {
extern sdecl::ServiceDecl const serviceDecl;
}

namespace script {
extern sdecl::ServiceDecl const serviceDecl;
}

namespace sfwk {
extern sdecl::ServiceDecl const serviceDecl;
}

namespace help {
extern sdecl::ServiceDecl const serviceDecl;
}

namespace executable {
extern sdecl::ServiceDecl const serviceDecl;
}

} // namespace backend
} // namespace dp_registry

namespace dp_manager {
namespace factory {
extern sdecl::ServiceDecl const serviceDecl;
bool singleton_entries( uno::Reference<registry::XRegistryKey> const& );
}
extern sdecl::ServiceDecl const serviceDecl;
bool singleton_entries( uno::Reference<registry::XRegistryKey> const& );
}

namespace dp_log {
extern sdecl::ServiceDecl const serviceDecl;
}

namespace dp_info {
extern sdecl::ServiceDecl const serviceDecl;
bool singleton_entries( uno::Reference<registry::XRegistryKey> const& );
}

extern "C" {

void SAL_CALL component_getImplementationEnvironment(
    const sal_Char ** ppEnvTypeName, uno_Environment ** )
{
    *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
}

void * SAL_CALL component_getFactory(
    sal_Char const * pImplName,
    lang::XMultiServiceFactory * pServiceManager,
    registry::XRegistryKey * pRegistryKey )
{
    return component_getFactoryHelper(
        pImplName, pServiceManager, pRegistryKey,
        dp_registry::backend::configuration::serviceDecl,
        dp_registry::backend::component::serviceDecl,
        dp_registry::backend::help::serviceDecl,
        dp_registry::backend::script::serviceDecl,
        dp_registry::backend::sfwk::serviceDecl,
        dp_registry::backend::executable::serviceDecl,
        dp_manager::factory::serviceDecl,
        dp_log::serviceDecl,
        dp_info::serviceDecl,
        dp_manager::serviceDecl);
}

} // extern "C"

<|endoftext|>