Hi
I am trying to add a new class (called UIViewComponent precisely) to Juce. I downloaded it from git repositery.
But when I compile the Juce iPhone project i have got this :
Actually, i add those lines in juce_mac_nativecode.mm
#include "../gui/components/special/juce_UIViewComponent.h"
#include "mac/juce_iphone_UIViewComponent.mm"
And those in juce_app_config.h
#ifndef __JUCE_UIVIEWCOMPONENT_JUCEHEADER__
#include "gui/components/special/juce_UIViewComponent.h"
#endif
Actually, UIViewComponent.h and .mm are very closed to NSViewComponent.
Here they are :
Source/gui/components/special/juce_UIViewComponent.h
[code]#ifndef JUCE_UIVIEWCOMPONENT_JUCEHEADER
#define JUCE_UIVIEWCOMPONENT_JUCEHEADER
#include “../juce_Component.h”
#if ! DOXYGEN
class UIViewComponentInternal;
#endif
#if JUCE_MAC || DOXYGEN
//==============================================================================
/**
A Mac-specific class that can create and embed an UIView inside itself.
To use it, create one of these, put it in place and make sure it’s visible in a
window, then use setView() to assign an UIView to it. The view will then be
moved and resized to follow the movements of this component.
Of course, since the view is a native object, it’ll obliterate any
juce components that may overlap this component, but that’s life.
/
class JUCE_API UIViewComponent : public Component
{
public:
//==============================================================================
/* Create an initially-empty container. */
UIViewComponent();
/** Destructor. */
~UIViewComponent();
/** Assigns an UIView to this peer.
The view will be retained and released by this component for as long as
it is needed. To remove the current view, just call setView (0).
Note: a void* is used here to avoid including the cocoa headers as
part of the juce.h, but the method expects an UIView*.
/
void setView (void UIView);
/** Returns the current UIView.
Note: a void* is returned here to avoid including the cocoa headers as
a requirement of juce.h, so you should just cast the object to an UIView*.
/
void getView() const;
//==============================================================================
/** @internal */
void paint (Graphics& g);
juce_UseDebuggingNewOperator
private:
friend class UIViewComponentInternal;
ScopedPointer info;
UIViewComponent (const UIViewComponent&);
UIViewComponent& operator= (const UIViewComponent&);
};
#endif
#endif // JUCE_UIVIEWCOMPONENT_JUCEHEADER
[/code]
Source/native/mac/UIViewComponent.mm
[code]/*
This file is part of the JUCE library - “Jules’ Utility Class Extensions”
Copyright 2004-10 by Raw Material Software Ltd.
JUCE can be redistributed and/or modified under the terms of the GNU General
Public License (Version 2), as published by the Free Software Foundation.
A copy of the license is included in the JUCE distribution, or can be found
online at Licenses - GNU Project - Free Software Foundation.
JUCE 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 General Public License for more details.
To release a closed-source product which uses JUCE, commercial licenses are
available: visit www.rawmaterialsoftware.com/juce for more information.
==============================================================================
*/
// (This file gets included by juce_mac_NativeCode.mm, rather than being
// compiled on its own).
#if JUCE_INCLUDED_FILE
//==============================================================================
class UIViewComponentInternal : public ComponentMovementWatcher
{
Component* const owner;
UIViewComponentPeer* currentPeer;
bool wasShowing;
public:
UIView* const view;
//==============================================================================
UIViewComponentInternal (UIView* const view_, Component* const owner_)
: ComponentMovementWatcher (owner_),
owner (owner_),
currentPeer (0),
wasShowing (false),
view (view_)
{
[view_ retain];
if (owner_->isShowing())
componentPeerChanged();
}
~UIViewComponentInternal()
{
[view removeFromSuperview];
[view release];
}
//==============================================================================
void componentMovedOrResized (Component& comp, bool wasMoved, bool wasResized)
{
ComponentMovementWatcher::componentMovedOrResized (comp, wasMoved, wasResized);
// The ComponentMovementWatcher version of this method avoids calling
// us when the top-level comp is resized, but for an UIView we need to know this
// because with inverted co-ords, we need to update the position even if the
// top-left pos hasn't changed
if (comp.isOnDesktop() && wasResized)
componentMovedOrResized (wasMoved, wasResized);
}
void componentMovedOrResized (bool /wasMoved/, bool /wasResized/)
{
Component* const topComp = owner->getTopLevelComponent();
if (topComp->getPeer() != 0)
{
const Point<int> pos (owner->relativePositionToOtherComponent (topComp, Point<int>()));
CGRect r;
r.origin.x = (float) pos.getX();
r.origin.y = (float) pos.getY();
r.size.width = (float) owner->getWidth();
r.size.height = (float) owner->getHeight();
r.origin.y = [[view superview] frame].size.height - (r.origin.y + r.size.height);
[view setFrame: r];
}
}
void componentPeerChanged()
{
UIViewComponentPeer* const peer = dynamic_cast <UIViewComponentPeer*> (owner->getPeer());
if (currentPeer != peer)
{
[view removeFromSuperview];
currentPeer = peer;
if (peer != 0)
{
[peer->view addSubview: view];
componentMovedOrResized (false, false);
}
}
[view setHidden: ! owner->isShowing()];
}
void componentVisibilityChanged (Component&)
{
componentPeerChanged();
}
juce_UseDebuggingNewOperator
private:
UIViewComponentInternal (const UIViewComponentInternal&);
UIViewComponentInternal& operator= (const UIViewComponentInternal&);
};
//==============================================================================
UIViewComponent::UIViewComponent()
{
}
UIViewComponent::~UIViewComponent()
{
}
void UIViewComponent::setView (void* view)
{
if (view != getView())
{
if (view != 0)
info = new UIViewComponentInternal ((UIView*) view, this);
else
info = 0;
}
}
void* UIViewComponent::getView() const
{
return info == 0 ? 0 : info->view;
}
void UIViewComponent::paint (Graphics&)
{
}
#endif
[/code]
I really don’t understand what is missing.
Thanks.

