From b8ddd30a0da2d80d820f41c5b711f55420c52413 Mon Sep 17 00:00:00 2001 From: David Capello Date: Wed, 29 Sep 2010 17:14:11 -0300 Subject: [PATCH] Move Vaca classes to base and gui libraries. + Remove Vaca::Referenceable class and move Vaca::SharedPtr<> to base/shared_ptr.h (now shared pointers can point to any type). + Move Vaca::Component/Event/Property/PreferredSizeEvent to gui/component.cpp. --- src/base/remove_from_container.h | 32 ++++ src/base/shared_ptr.h | 126 ++++++++++++++ src/base/shared_ptr_unittest.cpp | 99 +++++++++++ src/gui/CMakeLists.txt | 4 + src/gui/component.cpp | 49 ++++++ src/gui/component.h | 41 +++++ src/gui/event.cpp | 21 +++ src/gui/event.h | 31 ++++ src/gui/jbutton.cpp | 8 +- src/gui/jbutton.h | 6 +- src/gui/jcombobox.cpp | 4 +- src/gui/jpopup_window.cpp | 4 +- src/gui/jtooltips.cpp | 4 +- src/gui/jwidget.cpp | 2 +- src/gui/jwidget.h | 10 +- src/gui/jwindow.cpp | 4 +- src/gui/preferred_size_event.cpp | 69 ++++++++ src/gui/preferred_size_event.h | 35 ++++ src/gui/property.cpp | 21 +++ src/gui/property.h | 30 ++++ src/modules/gui.cpp | 11 +- src/modules/skinneable_theme.cpp | 11 +- src/modules/skinneable_theme.h | 13 +- src/widgets/color_button.cpp | 2 +- third_party/vaca/CMakeLists.txt | 7 +- third_party/vaca/include/Vaca/Component.h | 71 -------- third_party/vaca/include/Vaca/Event.h | 61 ------- .../vaca/include/Vaca/PreferredSizeEvent.h | 63 ------- third_party/vaca/include/Vaca/Property.h | 53 ------ third_party/vaca/include/Vaca/Referenceable.h | 68 -------- third_party/vaca/include/Vaca/SharedPtr.h | 160 ------------------ third_party/vaca/include/Vaca/Widget.h | 48 ------ third_party/vaca/src/Component.cpp | 90 ---------- third_party/vaca/src/Event.cpp | 64 ------- third_party/vaca/src/PreferredSizeEvent.cpp | 95 ----------- third_party/vaca/src/Property.cpp | 54 ------ third_party/vaca/src/Referenceable.cpp | 146 ---------------- 37 files changed, 596 insertions(+), 1021 deletions(-) create mode 100644 src/base/remove_from_container.h create mode 100644 src/base/shared_ptr.h create mode 100644 src/base/shared_ptr_unittest.cpp create mode 100644 src/gui/component.cpp create mode 100644 src/gui/component.h create mode 100644 src/gui/event.cpp create mode 100644 src/gui/event.h create mode 100644 src/gui/preferred_size_event.cpp create mode 100644 src/gui/preferred_size_event.h create mode 100644 src/gui/property.cpp create mode 100644 src/gui/property.h delete mode 100644 third_party/vaca/include/Vaca/Component.h delete mode 100644 third_party/vaca/include/Vaca/Event.h delete mode 100644 third_party/vaca/include/Vaca/PreferredSizeEvent.h delete mode 100644 third_party/vaca/include/Vaca/Property.h delete mode 100644 third_party/vaca/include/Vaca/Referenceable.h delete mode 100644 third_party/vaca/include/Vaca/SharedPtr.h delete mode 100644 third_party/vaca/include/Vaca/Widget.h delete mode 100644 third_party/vaca/src/Component.cpp delete mode 100644 third_party/vaca/src/Event.cpp delete mode 100644 third_party/vaca/src/PreferredSizeEvent.cpp delete mode 100644 third_party/vaca/src/Property.cpp delete mode 100644 third_party/vaca/src/Referenceable.cpp diff --git a/src/base/remove_from_container.h b/src/base/remove_from_container.h new file mode 100644 index 000000000..9f32c4582 --- /dev/null +++ b/src/base/remove_from_container.h @@ -0,0 +1,32 @@ +// ASE base library +// Copyright (C) 2001-2010 David Capello +// +// This source file is ditributed under a BSD-like license, please +// read LICENSE.txt for more information. + +#ifndef BASE_REMOVE_FROM_CONTAINER_H_INCLUDED +#define BASE_REMOVE_FROM_CONTAINER_H_INCLUDED + +namespace base { + +// Removes the first ocurrence of the specified element from the STL +// container. +template +void remove_from_container(ContainerType& container, + typename ContainerType::const_reference element) +{ + for (typename ContainerType::iterator + it = container.begin(), + end = container.end(); it != end; ) { + if (*it == element) { + it = container.erase(it); + end = container.end(); + } + else + ++it; + } +} + +} + +#endif diff --git a/src/base/shared_ptr.h b/src/base/shared_ptr.h new file mode 100644 index 000000000..1aee21583 --- /dev/null +++ b/src/base/shared_ptr.h @@ -0,0 +1,126 @@ +// ASE base library +// Copyright (C) 2001-2010 David Capello +// +// This source file is ditributed under a BSD-like license, please +// read LICENSE.txt for more information. + +#ifndef BASE_SHARED_PTR_H_INCLUDED +#define BASE_SHARED_PTR_H_INCLUDED + +// A class which wraps a pointer and keeps reference counting to +// automatically delete the pointed object when it is no longer +// used. +template +class SharedPtr +{ + friend class SharedPtr; + +public: + + SharedPtr() + : m_ptr(0) + , m_refCount(0) { + } + + explicit SharedPtr(T* ptr) + : m_ptr(ptr) + , m_refCount(ptr ? new int(0): 0) { + ref(); + } + + SharedPtr(const SharedPtr& other) + : m_ptr(other.m_ptr) + , m_refCount(other.m_refCount) { + ref(); + } + + template + SharedPtr(const SharedPtr& other) + : m_ptr(static_cast(other.m_ptr)) + , m_refCount(other.m_refCount) { + ref(); + } + + virtual ~SharedPtr() { + unref(); + } + + void reset(T* ptr = 0) { + if (m_ptr != ptr) { + unref(); + m_ptr = ptr; + m_refCount = (ptr ? new int(0): 0); + ref(); + } + } + + SharedPtr& operator=(const SharedPtr& other) { + if (m_ptr != other.m_ptr) { + unref(); + m_ptr = other.m_ptr; + m_refCount = other.m_refCount; + ref(); + } + return *this; + } + + template + SharedPtr& operator=(const SharedPtr& other) { + if (m_ptr != static_cast(other.m_ptr)) { + unref(); + m_ptr = static_cast(other.m_ptr); + m_refCount = other.m_refCount; + ref(); + } + return *this; + } + + inline T* get() const { return m_ptr; } + inline T& operator*() const { return *m_ptr; } + inline T* operator->() const { return m_ptr; } + inline operator T*() const { return m_ptr; } + + int getRefCount() const { return m_refCount ? *m_refCount: 0; } + +private: + + // Adds a reference to the pointee. + void ref() { + if (m_ptr) + ++(*m_refCount); + } + + // Removes the reference to the pointee. + void unref() { + if (m_ptr) { + if (--(*m_refCount) == 0) { + delete m_ptr; + delete m_refCount; + } + m_ptr = 0; + m_refCount = 0; + } + } + + + T* m_ptr; // The pointee object. + int* m_refCount; // Number of references. +}; + +// Compares if two shared-pointers points to the same place (object, +// memory address). +template +bool operator==(const SharedPtr& ptr1, const SharedPtr& ptr2) +{ + return ptr1.get() == ptr2.get(); +} + +// Compares if two shared-pointers points to different places +// (objects, memory addresses). +template +bool operator!=(const SharedPtr& ptr1, const SharedPtr& ptr2) +{ + return ptr1.get() != ptr2.get(); +} + +#endif diff --git a/src/base/shared_ptr_unittest.cpp b/src/base/shared_ptr_unittest.cpp new file mode 100644 index 000000000..8aa65ee2d --- /dev/null +++ b/src/base/shared_ptr_unittest.cpp @@ -0,0 +1,99 @@ +// ASE base library +// Copyright (C) 2001-2010 David Capello +// +// This source file is ditributed under a BSD-like license, please +// read LICENSE.txt for more information. + +#include "tests/test.h" + +#include "base/shared_ptr.h" + +TEST(SharedPtr, IntPtr) +{ + SharedPtr a(new int(5)); + EXPECT_EQ(5, *a); +} + +TEST(SharedPtr, RefCount) +{ + SharedPtr a(new int(5)); + EXPECT_EQ(1, a.getRefCount()); + a.reset(); + EXPECT_EQ(0, a.getRefCount()); + + SharedPtr b(new int(5)); + { + SharedPtr c(b); + EXPECT_EQ(2, b.getRefCount()); + EXPECT_EQ(2, c.getRefCount()); + a = c; + EXPECT_EQ(3, a.getRefCount()); + EXPECT_EQ(3, b.getRefCount()); + EXPECT_EQ(3, c.getRefCount()); + a.reset(); + EXPECT_EQ(2, b.getRefCount()); + EXPECT_EQ(2, c.getRefCount()); + } + EXPECT_EQ(1, b.getRefCount()); +} + +TEST(SharedPtr, DeleteIsCalled) +{ + class DeleteIsCalled + { + public: + DeleteIsCalled(bool& flag) : m_flag(flag) { } + ~DeleteIsCalled() { m_flag = true; } + private: + bool& m_flag; + }; + + bool flag = false; + { + SharedPtr a(new DeleteIsCalled(flag)); + } + EXPECT_EQ(true, flag); +} + +TEST(SharedPtr, Hierarchy) +{ + class A { }; + class B : public A { }; + SharedPtr a(new B); + SharedPtr b = a; + SharedPtr c = a; + SharedPtr d = b; + EXPECT_EQ(4, a.getRefCount()); +} + +TEST(SharedPtr, Compare) +{ + SharedPtr a(new int(0)); + SharedPtr b(a); + SharedPtr c(new int(0)); + + // Compare pointers + EXPECT_TRUE(a == b); + EXPECT_TRUE(a != c); + EXPECT_TRUE(b != c); + + // Compare pointers + a = c; + c = b; + EXPECT_TRUE(a != b); + EXPECT_TRUE(a != c); + EXPECT_TRUE(b == c); + + // Compare values + EXPECT_TRUE(*a == *b); + EXPECT_TRUE(*a == *c); + EXPECT_TRUE(*b == *c); + + // Change values + *a = 2; + *b = 5; + EXPECT_EQ(2, *a); + EXPECT_EQ(5, *b); + EXPECT_EQ(5, *c); +} + diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 17bc5ccc9..79530a348 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -2,6 +2,8 @@ # Copyright (C) 2001-2010 David Capello add_library(gui-lib + component.cpp + event.cpp jaccel.cpp jalert.cpp jbox.cpp @@ -43,4 +45,6 @@ add_library(gui-lib jview.cpp jwidget.cpp jwindow.cpp + preferred_size_event.cpp + property.cpp themes/jstandard_theme.cpp) diff --git a/src/gui/component.cpp b/src/gui/component.cpp new file mode 100644 index 000000000..4a8751f80 --- /dev/null +++ b/src/gui/component.cpp @@ -0,0 +1,49 @@ +// ASE gui library +// Copyright (C) 2001-2010 David Capello +// +// This source file is ditributed under a BSD-like license, please +// read LICENSE.txt for more information. + +#include "base/shared_ptr.h" +#include "gui/component.h" +#include "gui/property.h" + +Component::Component() +{ +} + +Component::~Component() +{ +} + +PropertyPtr Component::getProperty(const base::string& name) +{ + Properties::iterator it = m_properties.find(name); + if (it != m_properties.end()) + return it->second; + else + return PropertyPtr(); +} + +void Component::setProperty(PropertyPtr property) +{ + m_properties[property->getName()] = property; +} + +bool Component::hasProperty(const base::string& name) +{ + Properties::iterator it = m_properties.find(name); + return it != m_properties.end(); +} + +void Component::removeProperty(const base::string& name) +{ + Properties::iterator it = m_properties.find(name); + if (it != m_properties.end()) + m_properties.erase(it); +} + +const Component::Properties& Component::getProperties() const +{ + return m_properties; +} diff --git a/src/gui/component.h b/src/gui/component.h new file mode 100644 index 000000000..311df5907 --- /dev/null +++ b/src/gui/component.h @@ -0,0 +1,41 @@ +// ASE gui library +// Copyright (C) 2001-2010 David Capello +// +// This source file is ditributed under a BSD-like license, please +// read LICENSE.txt for more information. + +#ifndef GUI_COMPONENT_H_INCLUDED +#define GUI_COMPONENT_H_INCLUDED + +#include + +#include "base/string.h" +#include "base/disable_copying.h" +#include "gui/property.h" + +// A component is a visual object, such as widgets or menus. +// +// Components are non-copyable. +class Component +{ +public: + typedef std::map Properties; + + Component(); + virtual ~Component(); + + PropertyPtr getProperty(const base::string& name); + void setProperty(PropertyPtr property); + + bool hasProperty(const base::string& name); + void removeProperty(const base::string& name); + + const Properties& getProperties() const; + +private: + Properties m_properties; + + DISABLE_COPYING(Component); +}; + +#endif diff --git a/src/gui/event.cpp b/src/gui/event.cpp new file mode 100644 index 000000000..1e17b6206 --- /dev/null +++ b/src/gui/event.cpp @@ -0,0 +1,21 @@ +// ASE gui library +// Copyright (C) 2001-2010 David Capello +// +// This source file is ditributed under a BSD-like license, please +// read LICENSE.txt for more information. + +#include "gui/event.h" + +Event::Event(Component* source) + : m_source(source) +{ +} + +Event::~Event() +{ +} + +Component* Event::getSource() +{ + return m_source; +} diff --git a/src/gui/event.h b/src/gui/event.h new file mode 100644 index 000000000..ba6b697be --- /dev/null +++ b/src/gui/event.h @@ -0,0 +1,31 @@ +// ASE gui library +// Copyright (C) 2001-2010 David Capello +// +// This source file is ditributed under a BSD-like license, please +// read LICENSE.txt for more information. + +#ifndef GUI_EVENT_H_INCLUDED +#define GUI_EVENT_H_INCLUDED + +class Component; + +// Base class for every kind of event. +class Event +{ + // The component which generates the event. + Component* m_source; + +public: + + // Creates a new event specifying that it was generated from the + // source component. + Event(Component* source); + + virtual ~Event(); + + // Returns the component which generated the event. + Component* getSource(); + +}; + +#endif diff --git a/src/gui/jbutton.cpp b/src/gui/jbutton.cpp index 161c9a505..3c0db027f 100644 --- a/src/gui/jbutton.cpp +++ b/src/gui/jbutton.cpp @@ -20,7 +20,7 @@ #include "gui/jtheme.h" #include "gui/jwidget.h" #include "gui/jwindow.h" -#include "Vaca/PreferredSizeEvent.h" +#include "gui/preferred_size_event.h" ButtonBase::ButtonBase(const char* text, int type, int behaviorType, int drawType) : Widget(type) @@ -235,7 +235,7 @@ bool ButtonBase::onProcessMessage(JMessage msg) jwidget_emit_signal(this, JI_SIGNAL_CHECK_CHANGE); // Fire onClick() event - Vaca::Event ev(this); + Event ev(this); onClick(ev); dirty(); @@ -250,7 +250,7 @@ bool ButtonBase::onProcessMessage(JMessage msg) jwidget_emit_signal(this, JI_SIGNAL_RADIO_CHANGE); // Fire onClick() event - Vaca::Event ev(this); + Event ev(this); onClick(ev); } break; @@ -333,7 +333,7 @@ void ButtonBase::generateButtonSelectSignal() jwidget_emit_signal(this, JI_SIGNAL_BUTTON_SELECT); // Fire onClick() event - Vaca::Event ev(this); + Event ev(this); onClick(ev); } diff --git a/src/gui/jbutton.h b/src/gui/jbutton.h index 54e5f10f8..c1db8fced 100644 --- a/src/gui/jbutton.h +++ b/src/gui/jbutton.h @@ -9,14 +9,12 @@ #include "base/signal.h" #include "gui/jwidget.h" -#include "Vaca/NonCopyable.h" #include -namespace Vaca { class Event; } -using Vaca::Event; - struct BITMAP; +class Event; + // Generic button class ButtonBase : public Widget { diff --git a/src/gui/jcombobox.cpp b/src/gui/jcombobox.cpp index 5b2edbb4d..e4f8249ea 100644 --- a/src/gui/jcombobox.cpp +++ b/src/gui/jcombobox.cpp @@ -8,9 +8,9 @@ #include -#include "gui/jinete.h" #include "gfx/size.h" -#include "Vaca/PreferredSizeEvent.h" +#include "gui/jinete.h" +#include "gui/preferred_size_event.h" using namespace gfx; diff --git a/src/gui/jpopup_window.cpp b/src/gui/jpopup_window.cpp index 8c7129116..eb97c975e 100644 --- a/src/gui/jpopup_window.cpp +++ b/src/gui/jpopup_window.cpp @@ -8,10 +8,10 @@ #include +#include "gfx/size.h" #include "gui/jinete.h" #include "gui/jintern.h" -#include "gfx/size.h" -#include "Vaca/PreferredSizeEvent.h" +#include "gui/preferred_size_event.h" using namespace gfx; diff --git a/src/gui/jtooltips.cpp b/src/gui/jtooltips.cpp index 692c28202..558dd670e 100644 --- a/src/gui/jtooltips.cpp +++ b/src/gui/jtooltips.cpp @@ -20,10 +20,10 @@ #include +#include "gfx/size.h" #include "gui/jinete.h" #include "gui/jintern.h" -#include "gfx/size.h" -#include "Vaca/PreferredSizeEvent.h" +#include "gui/preferred_size_event.h" using namespace gfx; diff --git a/src/gui/jwidget.cpp b/src/gui/jwidget.cpp index 43c4560dc..79c8e6c52 100644 --- a/src/gui/jwidget.cpp +++ b/src/gui/jwidget.cpp @@ -23,7 +23,7 @@ #include "gui/jinete.h" #include "gui/jintern.h" -#include "Vaca/PreferredSizeEvent.h" +#include "gui/preferred_size_event.h" using namespace gfx; diff --git a/src/gui/jwidget.h b/src/gui/jwidget.h index 96a712dec..352cdbe22 100644 --- a/src/gui/jwidget.h +++ b/src/gui/jwidget.h @@ -9,12 +9,12 @@ #include +#include "gfx/rect.h" +#include "gui/component.h" #include "gui/jbase.h" #include "gui/jrect.h" -#include "gfx/rect.h" -#include "Vaca/Widget.h" -namespace Vaca { class PreferredSizeEvent; } +class PreferredSizeEvent; #ifndef NDEBUG #include "gui/jintern.h" @@ -24,8 +24,6 @@ namespace Vaca { class PreferredSizeEvent; } #define ASSERT_VALID_WIDGET(widget) ((void)0) #endif -using Vaca::PreferredSizeEvent; - struct FONT; struct BITMAP; @@ -127,7 +125,7 @@ bool jwidget_check_underscored(JWidget widget, int scancode); ////////////////////////////////////////////////////////////////////// -class Widget : public Vaca::Widget +class Widget : public Component { public: JID id; /* identify code */ diff --git a/src/gui/jwindow.cpp b/src/gui/jwindow.cpp index c7c15d1a0..e307bb89a 100644 --- a/src/gui/jwindow.cpp +++ b/src/gui/jwindow.cpp @@ -11,10 +11,10 @@ #include +#include "gfx/size.h" #include "gui/jinete.h" #include "gui/jintern.h" -#include "gfx/size.h" -#include "Vaca/PreferredSizeEvent.h" +#include "gui/preferred_size_event.h" using namespace gfx; diff --git a/src/gui/preferred_size_event.cpp b/src/gui/preferred_size_event.cpp new file mode 100644 index 000000000..76d551d3d --- /dev/null +++ b/src/gui/preferred_size_event.cpp @@ -0,0 +1,69 @@ +// ASE gui library +// Copyright (C) 2001-2010 David Capello +// +// This source file is ditributed under a BSD-like license, please +// read LICENSE.txt for more information. + +#include "gui/preferred_size_event.h" +#include "gui/jwidget.h" + +using namespace gfx; + +/** + Event generated to calculate the preferred size of a widget. + + @param source + The widget that want to know its preferred size. + + @param fitIn + This could be Size(0, 0) that means calculate the preferred size + without restrictions. If its width or height is greater than 0, + you could try to fit your widget to that width or height. +*/ +PreferredSizeEvent::PreferredSizeEvent(Widget* source, const Size& fitIn) + : Event(source) + , m_fitIn(fitIn) + , m_preferredSize(0, 0) +{ +} + +/** + Destroys the PreferredSizeEvent. +*/ +PreferredSizeEvent::~PreferredSizeEvent() +{ +} + +Size PreferredSizeEvent::fitInSize() const +{ + return m_fitIn; +} + +int PreferredSizeEvent::fitInWidth() const +{ + return m_fitIn.w; +} + +int PreferredSizeEvent::fitInHeight() const +{ + return m_fitIn.h; +} + +Size PreferredSizeEvent::getPreferredSize() const +{ + return m_preferredSize; +} + +void PreferredSizeEvent::setPreferredSize(const Size& preferredSize) +{ + m_preferredSize = preferredSize; +} + +/** + Sets the preferred size for the widget. +*/ +void PreferredSizeEvent::setPreferredSize(int w, int h) +{ + m_preferredSize.w = w; + m_preferredSize.h = h; +} diff --git a/src/gui/preferred_size_event.h b/src/gui/preferred_size_event.h new file mode 100644 index 000000000..0f40ee0cf --- /dev/null +++ b/src/gui/preferred_size_event.h @@ -0,0 +1,35 @@ +// ASE gui library +// Copyright (C) 2001-2010 David Capello +// +// This source file is ditributed under a BSD-like license, please +// read LICENSE.txt for more information. + +#ifndef GUI_PREFERRED_SIZE_EVENT_H_INCLUDED +#define GUI_PREFERRED_SIZE_EVENT_H_INCLUDED + +#include "gui/event.h" +#include "gfx/size.h" + +class Widget; + +class PreferredSizeEvent : public Event +{ + gfx::Size m_fitIn; + gfx::Size m_preferredSize; + +public: + + PreferredSizeEvent(Widget* source, const gfx::Size& fitIn); + virtual ~PreferredSizeEvent(); + + gfx::Size fitInSize() const; + int fitInWidth() const; + int fitInHeight() const; + + gfx::Size getPreferredSize() const; + void setPreferredSize(const gfx::Size& preferredSize); + void setPreferredSize(int w, int h); + +}; + +#endif diff --git a/src/gui/property.cpp b/src/gui/property.cpp new file mode 100644 index 000000000..739f87417 --- /dev/null +++ b/src/gui/property.cpp @@ -0,0 +1,21 @@ +// ASE gui library +// Copyright (C) 2001-2010 David Capello +// +// This source file is ditributed under a BSD-like license, please +// read LICENSE.txt for more information. + +#include "gui/property.h" + +Property::Property(const base::string& name) + : m_name(name) +{ +} + +Property::~Property() +{ +} + +base::string Property::getName() const +{ + return m_name; +} diff --git a/src/gui/property.h b/src/gui/property.h new file mode 100644 index 000000000..fc1259c01 --- /dev/null +++ b/src/gui/property.h @@ -0,0 +1,30 @@ +// ASE gui library +// Copyright (C) 2001-2010 David Capello +// +// This source file is ditributed under a BSD-like license, please +// read LICENSE.txt for more information. + +#ifndef GUI_PROPERTY_H_INCLUDED +#define GUI_PROPERTY_H_INCLUDED + +#include "base/string.h" +#include "base/disable_copying.h" +#include "base/shared_ptr.h" + +class Property +{ + base::string m_name; + +public: + Property(const base::string& name); + virtual ~Property(); + + base::string getName() const; + +private: + DISABLE_COPYING(Property); +}; + +typedef SharedPtr PropertyPtr; + +#endif diff --git a/src/modules/gui.cpp b/src/modules/gui.cpp index 5b1bdf80f..1af9f6283 100644 --- a/src/modules/gui.cpp +++ b/src/modules/gui.cpp @@ -28,11 +28,8 @@ #include #endif -#include "Vaca/SharedPtr.h" -#include "gui/jinete.h" -#include "gui/jintern.h" - #include "app.h" +#include "base/shared_ptr.h" #include "commands/command.h" #include "commands/commands.h" #include "commands/params.h" @@ -40,6 +37,8 @@ #include "core/cfg.h" #include "core/drop_files.h" #include "gfxmode.h" +#include "gui/jinete.h" +#include "gui/jintern.h" #include "modules/editors.h" #include "modules/gfx.h" #include "modules/gui.h" @@ -791,7 +790,7 @@ void get_widgets(JWidget window, ...) void setup_mini_look(Widget* widget) { - Vaca::SharedPtr skinProp; + SharedPtr skinProp; skinProp = widget->getProperty(SkinProperty::SkinPropertyName); if (skinProp == NULL) @@ -803,7 +802,7 @@ void setup_mini_look(Widget* widget) void setup_bevels(Widget* widget, int b1, int b2, int b3, int b4) { - Vaca::SharedPtr skinProp; + SharedPtr skinProp; skinProp = widget->getProperty(SkinProperty::SkinPropertyName); if (skinProp == NULL) diff --git a/src/modules/skinneable_theme.cpp b/src/modules/skinneable_theme.cpp index a350453f1..96b9dfb95 100644 --- a/src/modules/skinneable_theme.cpp +++ b/src/modules/skinneable_theme.cpp @@ -21,12 +21,11 @@ #include #include -#include "Vaca/SharedPtr.h" +#include "ase_exception.h" #include "base/bind.h" +#include "base/shared_ptr.h" #include "gui/jinete.h" #include "gui/jintern.h" - -#include "ase_exception.h" #include "loadpng.h" #include "modules/gui.h" #include "modules/skinneable_theme.h" @@ -627,7 +626,7 @@ void SkinneableTheme::draw_button(ButtonBase* widget, JRect clip) // Tool buttons are smaller bool isMiniLook = false; - Vaca::SharedPtr skinPropery = widget->getProperty(SkinProperty::SkinPropertyName); + SharedPtr skinPropery = widget->getProperty(SkinProperty::SkinPropertyName); if (skinPropery != NULL) isMiniLook = skinPropery->isMiniLook(); @@ -1117,7 +1116,7 @@ void SkinneableTheme::draw_slider(JWidget widget, JRect clip) // Tool buttons are smaller bool isMiniLook = false; - Vaca::SharedPtr skinPropery = widget->getProperty(SkinProperty::SkinPropertyName); + SharedPtr skinPropery = widget->getProperty(SkinProperty::SkinPropertyName); if (skinPropery != NULL) isMiniLook = skinPropery->isMiniLook(); @@ -1752,7 +1751,7 @@ bool SkinneableTheme::theme_frame_button_msg_proc(JWidget widget, JMessage msg) ////////////////////////////////////////////////////////////////////// -const Vaca::Char* SkinProperty::SkinPropertyName = L"SkinProperty"; +const char* SkinProperty::SkinPropertyName = "SkinProperty"; SkinProperty::SkinProperty() : Property(SkinPropertyName) diff --git a/src/modules/skinneable_theme.h b/src/modules/skinneable_theme.h index e5e5019ae..a44a67607 100644 --- a/src/modules/skinneable_theme.h +++ b/src/modules/skinneable_theme.h @@ -19,19 +19,20 @@ #ifndef MODULES_SKINNEABLE_THEME_H_INCLUDED #define MODULES_SKINNEABLE_THEME_H_INCLUDED +#include #include #include -#include -#include "gui/jtheme.h" -#include "gui/jrect.h" -#include "Vaca/Property.h" + #include "gfx/rect.h" +#include "gui/jrect.h" +#include "gui/jtheme.h" +#include "gui/property.h" // Property to show widgets with a special look (e.g.: buttons or sliders with mini-borders) -class SkinProperty : public Vaca::Property +class SkinProperty : public Property { public: - static const Vaca::Char* SkinPropertyName; + static const char* SkinPropertyName; SkinProperty(); ~SkinProperty(); diff --git a/src/widgets/color_button.cpp b/src/widgets/color_button.cpp index 30247380e..ba684f55f 100644 --- a/src/widgets/color_button.cpp +++ b/src/widgets/color_button.cpp @@ -20,10 +20,10 @@ #include -#include "Vaca/PreferredSizeEvent.h" #include "app/color.h" #include "app/color_utils.h" #include "gui/jinete.h" +#include "gui/preferred_size_event.h" #include "modules/gfx.h" #include "modules/gui.h" #include "raster/sprite.h" diff --git a/third_party/vaca/CMakeLists.txt b/third_party/vaca/CMakeLists.txt index 391c168a1..9152506e7 100644 --- a/third_party/vaca/CMakeLists.txt +++ b/third_party/vaca/CMakeLists.txt @@ -4,9 +4,4 @@ include_directories(include ../../src) add_library(vaca - src/Component.cpp - src/Event.cpp - src/Exception.cpp - src/PreferredSizeEvent.cpp - src/Property.cpp - src/Referenceable.cpp) + src/Exception.cpp) diff --git a/third_party/vaca/include/Vaca/Component.h b/third_party/vaca/include/Vaca/Component.h deleted file mode 100644 index e9a6f829d..000000000 --- a/third_party/vaca/include/Vaca/Component.h +++ /dev/null @@ -1,71 +0,0 @@ -// Vaca - Visual Application Components Abstraction -// Copyright (c) 2005-2009 David Capello -// 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 author 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. - -#ifndef VACA_COMPONENT_H -#define VACA_COMPONENT_H - -#include "Vaca/base.h" -#include "Vaca/Referenceable.h" -#include - -namespace Vaca { - -/** - A component is a visual object, such as widgets or menus. - - Components are non-copyable but are referenceable (e.g. you can - use them inside a SharedPtr). - - @see NonCopyable, Referenceable, SharedPtr -*/ -class VACA_DLL Component : public Referenceable -{ -public: - typedef std::map Properties; - - Component(); - virtual ~Component(); - - PropertyPtr getProperty(const String& name); - void setProperty(PropertyPtr property); - - bool hasProperty(const String& name); - void removeProperty(const String& name); - - const Properties& getProperties() const; - -private: - Properties m_properties; -}; - -} // namespace Vaca - -#endif // VACA_COMPONENT_H diff --git a/third_party/vaca/include/Vaca/Event.h b/third_party/vaca/include/Vaca/Event.h deleted file mode 100644 index 648a99a05..000000000 --- a/third_party/vaca/include/Vaca/Event.h +++ /dev/null @@ -1,61 +0,0 @@ -// Vaca - Visual Application Components Abstraction -// Copyright (c) 2005-2010 David Capello -// 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 author 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. - -#ifndef VACA_EVENT_H -#define VACA_EVENT_H - -#include "Vaca/base.h" - -namespace Vaca { - -/** - Base class for every kind of event. -*/ -class VACA_DLL Event -{ - /** - The component which generates the event. It's specified in the - @link Event#Event(Component*) Event's constructor@endlink - */ - Component* m_source; - -public: - - Event(Component* source); - virtual ~Event(); - - Component* getSource(); - -}; - -} // namespace Vaca - -#endif // VACA_EVENT_H diff --git a/third_party/vaca/include/Vaca/PreferredSizeEvent.h b/third_party/vaca/include/Vaca/PreferredSizeEvent.h deleted file mode 100644 index cafb55b3d..000000000 --- a/third_party/vaca/include/Vaca/PreferredSizeEvent.h +++ /dev/null @@ -1,63 +0,0 @@ -// Vaca - Visual Application Components Abstraction -// Copyright (c) 2005-2010 David Capello -// 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 author 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. - -#ifndef VACA_PREFERREDSIZEEVENT_H -#define VACA_PREFERREDSIZEEVENT_H - -#include "Vaca/base.h" -#include "Vaca/Event.h" -#include "gfx/size.h" - -namespace Vaca { - -class VACA_DLL PreferredSizeEvent : public Event -{ - gfx::Size m_fitIn; - gfx::Size m_preferredSize; - -public: - - PreferredSizeEvent(Widget* source, const gfx::Size& fitIn); - virtual ~PreferredSizeEvent(); - - gfx::Size fitInSize() const; - int fitInWidth() const; - int fitInHeight() const; - - gfx::Size getPreferredSize() const; - void setPreferredSize(const gfx::Size& preferredSize); - void setPreferredSize(int w, int h); - -}; - -} // namespace Vaca - -#endif // VACA_PREFERREDSIZEEVENT_H diff --git a/third_party/vaca/include/Vaca/Property.h b/third_party/vaca/include/Vaca/Property.h deleted file mode 100644 index 8dbe7085e..000000000 --- a/third_party/vaca/include/Vaca/Property.h +++ /dev/null @@ -1,53 +0,0 @@ -// Vaca - Visual Application Components Abstraction -// Copyright (c) 2005-2009 David Capello -// 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 author 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. - -#ifndef VACA_PROPERTY_H -#define VACA_PROPERTY_H - -#include "Vaca/base.h" -#include "Vaca/Referenceable.h" - -namespace Vaca { - -class VACA_DLL Property : public Referenceable -{ - String m_name; - -public: - Property(const String& name); - virtual ~Property(); - - String getName() const; -}; - -} // namespace Vaca - -#endif // VACA_PROPERTY_H diff --git a/third_party/vaca/include/Vaca/Referenceable.h b/third_party/vaca/include/Vaca/Referenceable.h deleted file mode 100644 index c8c5d3c9a..000000000 --- a/third_party/vaca/include/Vaca/Referenceable.h +++ /dev/null @@ -1,68 +0,0 @@ -// Vaca - Visual Application Components Abstraction -// Copyright (c) 2005-2009 David Capello -// 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 author 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. - -#ifndef VACA_REFERENCEABLE_H -#define VACA_REFERENCEABLE_H - -#include "Vaca/base.h" -#include "Vaca/NonCopyable.h" - -namespace Vaca { - -/** - Class that counts references and can be wrapped by a SharedPtr. -*/ -class VACA_DLL Referenceable : private NonCopyable -{ - template friend class SharedPtr; - unsigned m_refCount; - -public: - - Referenceable(); - virtual ~Referenceable(); - - void ref(); - unsigned unref(); - - unsigned getRefCount(); - -#ifndef NDEBUG - static void showLeaks(); -#endif - -private: - void destroy(); -}; - -} // namespace Vaca - -#endif // VACA_REFERENCEABLE_H diff --git a/third_party/vaca/include/Vaca/SharedPtr.h b/third_party/vaca/include/Vaca/SharedPtr.h deleted file mode 100644 index b23307e2d..000000000 --- a/third_party/vaca/include/Vaca/SharedPtr.h +++ /dev/null @@ -1,160 +0,0 @@ -// Vaca - Visual Application Components Abstraction -// Copyright (c) 2005-2009 David Capello -// 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 author 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. - -#ifndef VACA_SHAREDPTR_H -#define VACA_SHAREDPTR_H - -#include "Vaca/base.h" -#include "Vaca/Referenceable.h" - -namespace Vaca { - -/** - A pointer which maintains reference counting and - automatically deletes the pointed object when it is - no longer referenced. - - What is a shared pointer? It is a class that wraps a pointer to a - dynamically allocated object. Various shared pointers can share - the same object counting references for that object. When the - last shared pointer is destroyed, the object is automatically - deleted. - - The SharedPtr is mainly used to wrap classes that handle - graphics resources (like Brush, Pen, Image, Icon, etc.). - - @tparam T Must be of Referenceable type, because Referenceable has - the reference counter. -*/ -template -class SharedPtr -{ - T* m_ptr; - -public: - - SharedPtr() { - m_ptr = NULL; - } - - /*explicit*/ SharedPtr(T* ptr) { - m_ptr = ptr; - ref(); - } - - SharedPtr(const SharedPtr& other) { - m_ptr = other.get(); - ref(); - } - - template - SharedPtr(const SharedPtr& other) { - m_ptr = static_cast(other.get()); - ref(); - } - - virtual ~SharedPtr() { - unref(); - } - - void reset(T* ptr = NULL) { - if (m_ptr != ptr) { - unref(); - m_ptr = ptr; - ref(); - } - } - - SharedPtr& operator=(const SharedPtr& other) { - if (m_ptr != other.get()) { - unref(); - m_ptr = other.get(); - ref(); - } - return *this; - } - - template - SharedPtr& operator=(const SharedPtr& other) { - if (m_ptr != static_cast(other.get())) { - unref(); - m_ptr = static_cast(other.get()); - ref(); - } - return *this; - } - - inline T* get() const { return m_ptr; } - inline T& operator*() const { return *m_ptr; } - inline T* operator->() const { return m_ptr; } - inline operator T*() const { return m_ptr; } - -private: - - void ref() { - if (m_ptr) - ((Referenceable*)m_ptr)->ref(); - } - - void unref() { - if (m_ptr) { - if (((Referenceable*)m_ptr)->unref() == 0) - ((Referenceable*)m_ptr)->destroy(); - m_ptr = NULL; - } - } -}; - -/** - Compares if two shared-pointers points to the same place (object, memory address). - - @see @ref SharedPtr -*/ -template -bool operator==(const SharedPtr& ptr1, const SharedPtr& ptr2) -{ - return ptr1.get() == ptr2.get(); -} - -/** - Compares if two shared-pointers points to different places (objects, memory addresses). - - @see @ref SharedPtr -*/ -template -bool operator!=(const SharedPtr& ptr1, const SharedPtr& ptr2) -{ - return ptr1.get() != ptr2.get(); -} - -} // namespace Vaca - -#endif // VACA_SHAREDPTR_H diff --git a/third_party/vaca/include/Vaca/Widget.h b/third_party/vaca/include/Vaca/Widget.h deleted file mode 100644 index 202ddd3ad..000000000 --- a/third_party/vaca/include/Vaca/Widget.h +++ /dev/null @@ -1,48 +0,0 @@ -// Vaca - Visual Application Components Abstraction -// Copyright (c) 2005-2009 David Capello -// 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 author 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. - -#ifndef VACA_WIDGET_H -#define VACA_WIDGET_H - -#include "Vaca/Component.h" - -namespace Vaca { - -class VACA_DLL Widget : public Component -{ -public: - Widget() { } - virtual ~Widget() { } -}; - -} // namespace Vaca - -#endif // VACA_WIDGET_H diff --git a/third_party/vaca/src/Component.cpp b/third_party/vaca/src/Component.cpp deleted file mode 100644 index bb6f58ebe..000000000 --- a/third_party/vaca/src/Component.cpp +++ /dev/null @@ -1,90 +0,0 @@ -// Vaca - Visual Application Components Abstraction -// Copyright (c) 2005-2009 David Capello -// 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 author 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. - -#include "Vaca/Component.h" -#include "Vaca/SharedPtr.h" -#include "Vaca/Property.h" - -using namespace Vaca; - -/** - Creates a new component. - - With the debug version of the library, you will get in the - @ref page_debug_log a line specifying when the component - was created. -*/ -Component::Component() -{ -} - -/** - Destroys the component. - - With the debug version of the library, you will get in the - @ref page_debug_log a line specifying when the component - was destroyed. -*/ -Component::~Component() -{ -} - -PropertyPtr Component::getProperty(const String& name) -{ - Properties::iterator it = m_properties.find(name); - if (it != m_properties.end()) - return it->second; - else - return PropertyPtr(); -} - -void Component::setProperty(PropertyPtr property) -{ - m_properties[property->getName()] = property; -} - -bool Component::hasProperty(const String& name) -{ - Properties::iterator it = m_properties.find(name); - return it != m_properties.end(); -} - -void Component::removeProperty(const String& name) -{ - Properties::iterator it = m_properties.find(name); - if (it != m_properties.end()) - m_properties.erase(it); -} - -const Component::Properties& Component::getProperties() const -{ - return m_properties; -} diff --git a/third_party/vaca/src/Event.cpp b/third_party/vaca/src/Event.cpp deleted file mode 100644 index 56bf45b0d..000000000 --- a/third_party/vaca/src/Event.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// Vaca - Visual Application Components Abstraction -// Copyright (c) 2005-2010 David Capello -// 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 author 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. - -#include "Vaca/Event.h" - -using namespace Vaca; - -/** - Creates a new event specifying that it was generated - from the @a source component. - - @param source - The component which generates the event. -*/ -Event::Event(Component* source) - : m_source(source) -{ -} - -/** - Destroys the event. -*/ -Event::~Event() -{ -} - -/** - Returns the event's source. - - @return - The component which generates the event. -*/ -Component* Event::getSource() -{ - return m_source; -} diff --git a/third_party/vaca/src/PreferredSizeEvent.cpp b/third_party/vaca/src/PreferredSizeEvent.cpp deleted file mode 100644 index fecf16b20..000000000 --- a/third_party/vaca/src/PreferredSizeEvent.cpp +++ /dev/null @@ -1,95 +0,0 @@ -// Vaca - Visual Application Components Abstraction -// Copyright (c) 2005-2010 David Capello -// 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 author 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. - -#include "Vaca/PreferredSizeEvent.h" -#include "Vaca/Widget.h" - -using namespace gfx; -using namespace Vaca; - -/** - Event generated to calculate the preferred size of a widget. - - @param source - The widget that want to know its preferred size. - - @param fitIn - This could be Size(0, 0) that means calculate the preferred size - without restrictions. If its width or height is greater than 0, - you could try to fit your widget to that width or height. -*/ -PreferredSizeEvent::PreferredSizeEvent(Widget* source, const Size& fitIn) - : Event(source) - , m_fitIn(fitIn) - , m_preferredSize(0, 0) -{ -} - -/** - Destroys the PreferredSizeEvent. -*/ -PreferredSizeEvent::~PreferredSizeEvent() -{ -} - -Size PreferredSizeEvent::fitInSize() const -{ - return m_fitIn; -} - -int PreferredSizeEvent::fitInWidth() const -{ - return m_fitIn.w; -} - -int PreferredSizeEvent::fitInHeight() const -{ - return m_fitIn.h; -} - -Size PreferredSizeEvent::getPreferredSize() const -{ - return m_preferredSize; -} - -void PreferredSizeEvent::setPreferredSize(const Size& preferredSize) -{ - m_preferredSize = preferredSize; -} - -/** - Sets the preferred size for the widget. -*/ -void PreferredSizeEvent::setPreferredSize(int w, int h) -{ - m_preferredSize.w = w; - m_preferredSize.h = h; -} diff --git a/third_party/vaca/src/Property.cpp b/third_party/vaca/src/Property.cpp deleted file mode 100644 index 91fbddf69..000000000 --- a/third_party/vaca/src/Property.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Vaca - Visual Application Components Abstraction -// Copyright (c) 2005-2009 David Capello -// 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 author 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. - -#include "Vaca/Property.h" - -using namespace Vaca; - -/** - Creates a new named property. -*/ -Property::Property(const String& name) - : m_name(name) -{ -} - -/** - Destroys the property. -*/ -Property::~Property() -{ -} - -String Property::getName() const -{ - return m_name; -} diff --git a/third_party/vaca/src/Referenceable.cpp b/third_party/vaca/src/Referenceable.cpp deleted file mode 100644 index 1493ebd2e..000000000 --- a/third_party/vaca/src/Referenceable.cpp +++ /dev/null @@ -1,146 +0,0 @@ -// Vaca - Visual Application Components Abstraction -// Copyright (c) 2005-2009 David Capello -// 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 author 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. - -#include "Vaca/Referenceable.h" - -#ifndef NDEBUG - #include "base/mutex.h" - #include "base/scoped_lock.h" - #include - #include - #ifdef VACA_ON_WINDOWS - #define WIN32_LEAN_AND_MEAN - #include - #endif -#endif - -#include -#include - -using namespace Vaca; - -#ifndef NDEBUG - static Mutex s_mutex; - static std::vector s_list; -#endif - -/** - Constructs a new referenceable object starting with zero references. -*/ -Referenceable::Referenceable() -{ - m_refCount = 0; -#ifndef NDEBUG - { - ScopedLock hold(s_mutex); - s_list.push_back(this); - } -#endif -} - -/** - Destroys a referenceable object. - - When compiling with assertions it checks that the references' - counter is really zero. -*/ -Referenceable::~Referenceable() -{ -#ifndef NDEBUG - { - ScopedLock hold(s_mutex); - remove_from_container(s_list, this); - } -#endif - assert(m_refCount == 0); -} - -/** - Called by SharedPtr to destroy the referenceable. -*/ -void Referenceable::destroy() -{ - delete this; -} - -/** - Makes a new reference to this object. - - You are responsible for removing references using the #unref - member function. Remember that for each call to #ref that you made, - there should be a corresponding #unref. - - @see unref -*/ -void Referenceable::ref() -{ - ++m_refCount; -} - -/** - Deletes an old reference to this object. - - If assertions are activated this routine checks that the - reference counter never get negative, because that implies - an error of the programmer. - - @see ref -*/ -unsigned Referenceable::unref() -{ - assert(m_refCount > 0); - return --m_refCount; -} - -/** - Returns the current number of references that this object has. - - If it's zero you can delete the object safely. -*/ -unsigned Referenceable::getRefCount() -{ - return m_refCount; -} - -#ifndef NDEBUG -void Referenceable::showLeaks() -{ -#ifdef VACA_ON_WINDOWS - if (!s_list.empty()) - ::Beep(400, 100); -#endif - - for (std::vector::iterator - it=s_list.begin(); it!=s_list.end(); ++it) { - std::clog << "leak Referenceable " << (*it) << "\n"; - } -} -#endif