widget.h

Go to the documentation of this file.
00001 
00007 /*
00008     This library is free software; you can redistribute it and/or
00009     modify it under the terms of the GNU Lesser General Public
00010     License as published by the Free Software Foundation; either
00011     version 2.1 of the License, or (at your option) any later version.
00012 
00013     This library is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016     Lesser General Public License for more details.
00017 
00018     You should have received a copy of the GNU Lesser General Public
00019     License along with this library; if not, write to the Free Software
00020     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00021 
00022     Copyright (C) 2005 Thomas Steinacher
00023     http://www.eggdrop.ch/
00024     tom (at) eggdrop [dot] ch
00025 */
00026 
00027 #ifndef OMGUI_COCOA_WIDGET_H
00028 #define OMGUI_COCOA_WIDGET_H
00029 
00030 #include <omgui/common/widget.h>
00031 #include <omgui/widget.h>
00032 #include <omgui/private/factory.h>
00033 #include <omgui/event.h>
00034 
00035 #import <Cocoa/Cocoa.h>
00036 
00037 // Two macros which create a subclass of a widget, so we
00038 // can store the implementation object in the widget
00039 
00040 #define OMGUI_COCOA_INTERFACE(type) \
00041   @interface Omgui ## type : NS ## type \
00042   { \
00043     omgui::cocoa::Widget *m_omgui_widget; \
00044   } \
00045   - (void)setOmguiWidget:(omgui::cocoa::Widget *)widget; \
00046   - (omgui::cocoa::Widget *)omguiWidget; \
00047   - (bool)omguiSendEvent:(omgui::event_id)event_id; \
00048   @end
00049 
00050 #define OMGUI_COCOA_IMPLEMENTATION(type) \
00051   @implementation Omgui ## type \
00052   - (void)setOmguiWidget:(omgui::cocoa::Widget *)widget \
00053   { \
00054     m_omgui_widget = widget; \
00055   } \
00056   - (omgui::cocoa::Widget *)omguiWidget { return m_omgui_widget; } \
00057   - (bool)omguiSendEvent:(omgui::event_id)event_id \
00058   { \
00059     if (m_omgui_widget) \
00060     { \
00061       omgui::Event event(event_id, m_omgui_widget->get_wrapper_id()); \
00062       omgui::EventManager::send_event(event); \
00063       return event.get_veto(); \
00064     } \
00065     return false; \
00066   } \
00067   @end
00068 
00069 namespace omgui {
00070     namespace cocoa {
00071         
00072 class Widget : public virtual omgui::common::Widget
00073 {
00074 protected:
00075     id m_object;
00076 
00077     void send_event(const omgui::event_id event_id); // cocoa specific
00078     void create(const omgui::initializer::WidgetData &params, id widget);
00079 
00080     omgui::Size m_natural_size;
00081 
00082     Widget() { }
00083 
00084 public:
00085     omgui::Size m_min_size, m_max_size;
00086 
00087     virtual ~Widget();
00088 
00089     // object interface
00090     virtual void set_size(const omgui::Size&);
00091     virtual void set_min_size(const omgui::Size&);
00092     virtual void set_max_size(const omgui::Size&);
00093     virtual void set_natural_size(const omgui::Size&);
00094     virtual void set_position(const omgui::Point&);
00095     virtual omgui::Size get_size() const;
00096     virtual omgui::Size get_min_size() const;
00097     virtual omgui::Size get_max_size() const;
00098     virtual omgui::Size get_natural_size() const;
00099     virtual omgui::Point get_position() const;
00100     virtual void set_rect(const omgui::Rect&);
00101     virtual omgui::Rect get_rect() const;
00102 
00103     // widget interface
00104     virtual void destroy();
00105     virtual void *get_handle() const { return m_object; }
00106     virtual void enable(bool sensitive);
00107     virtual void show(bool show, bool activate);
00108     virtual bool is_enabled() const;
00109     virtual bool is_shown() const;
00110     virtual bool is_hidden() const;
00111 
00112     virtual Pointer<omgui::Panel> get_parent() const;
00113     virtual Pointer<omgui::Window> get_parent_window() const;
00114 };
00115 
00116     } // cocoa
00117 } // omgui
00118 
00119 #endif // OMGUI_COCOA_WIDGET_H

doxygen SourceForge.net Logo