/*
 * Copyright (c) 2010 Mark Liversedge (liversedge@gmail.com)
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 *
 * This program 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.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc., 51
 * Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef GC_QtMacPopUpButton_h
#define GC_QtMacPopUpButton_h

#include <QWidget>
#include <QVBoxLayout>
#include <QPointer>
#include <QMenu>
#include <QMacCocoaViewContainer>


// Qocoa already dit this, so re-used their code, saved a bit of effort!
class QtMacPopUpButtonWidget;
class QtMacPopUpButton : public QWidget
{
    Q_OBJECT
public:
    // Matches NSBezelStyle
    enum BezelStyle {
       Rounded           = 1,
       RegularSquare     = 2,
       Disclosure        = 5,
       ShadowlessSquare  = 6,
       Circular          = 7,
       TexturedSquare    = 8,
       HelpPopUpButton        = 9,
       SmallSquare       = 10,
       TexturedRounded   = 11,
       RoundRect         = 12,
       Recessed          = 13,
       RoundedDisclosure = 14,
#ifdef __MAC_10_7
       Inline            = 15
#endif
    };

    explicit QtMacPopUpButton(QWidget *parent, BezelStyle bezelStyle = Rounded);

public slots:
    void setText(const QString &text);
    void setToolTip(const QString &text);
    void setImage(const QPixmap &image);
    void setChecked(bool checked);
    void setMenu(QMenu *);

public:
    void setCheckable(bool checkable);
    bool isChecked();

signals:
    void clicked(bool checked = false);

private:
    friend class QtMacPopUpButtonWidget;
    QPointer<QtMacPopUpButtonWidget> qtw;
};

#endif
