~ubuntu-branches/ubuntu/oneiric/nux/oneiric

« back to all changes in this revision

Viewing changes to Nux/RadioButton.h

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-11-18 19:17:32 UTC
  • Revision ID: james.westby@ubuntu.com-20101118191732-rn35790vekj6o4my
Tags: upstream-0.9.4
ImportĀ upstreamĀ versionĀ 0.9.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2010 Inalogic Inc.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it
 
5
 * under the terms of the GNU Lesser General Public License version 3, as
 
6
 * published by the  Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful, but
 
9
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 
10
 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
 
11
 * PURPOSE.  See the applicable version of the GNU Lesser General Public
 
12
 * License for more details.
 
13
 *
 
14
 * You should have received a copy of both the GNU Lesser General Public
 
15
 * License version 3 along with this program.  If not, see
 
16
 * <http://www.gnu.org/licenses/>
 
17
 *
 
18
 * Authored by: Jay Taoko <jay.taoko_AT_gmail_DOT_com>
 
19
 *
 
20
 */
 
21
 
 
22
 
 
23
#ifndef RADIOBUTTON_H
 
24
#define RADIOBUTTON_H
 
25
 
 
26
#include "AbstractButton.h"
 
27
 
 
28
namespace nux
 
29
{
 
30
  class RadioButton;
 
31
  class RadioButtonGroup;
 
32
  class HLayout;
 
33
 
 
34
  class RadioButton: public AbstractButton
 
35
  {
 
36
  public:
 
37
    RadioButton (const TCHAR *Caption = 0, bool state = false, NUX_FILE_LINE_PROTO);
 
38
 
 
39
    ~RadioButton();
 
40
    virtual long ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
 
41
 
 
42
    virtual void Draw (GraphicsEngine &GfxContext, bool force_draw);
 
43
    virtual void DrawContent (GraphicsEngine &GfxContext, bool force_draw);
 
44
    virtual void PostDraw (GraphicsEngine &GfxContext, bool force_draw);
 
45
 
 
46
    void RecvMouseMove (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
 
47
    void RecvMouseEnter (int x, int y, unsigned long button_flags, unsigned long key_flags);
 
48
    void RecvMouseLeave (int x, int y, unsigned long button_flags, unsigned long key_flags);
 
49
    /*
 
50
        Signal emitted if a click happen. The state change and the check box need to redraw itself.
 
51
    */
 
52
    void RecvClick (int x, int y, unsigned long button_flags, unsigned long key_flags);
 
53
    /*
 
54
        Signal emitted if the mouse is released. Whether a click happened or not,
 
55
        the check box need to redraw itself.
 
56
    */
 
57
    void RecvMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags);
 
58
    void RecvMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags);
 
59
 
 
60
    sigc::signal<void, RadioButton *> sigStateToggled;
 
61
    sigc::signal<void> sigToggled;
 
62
    sigc::signal<void, bool> sigStateChanged;
 
63
 
 
64
    void EmitStateChangedSignal();
 
65
 
 
66
    //+++ Inherited from AbstractButton
 
67
    virtual bool IsCheckable() const
 
68
    {
 
69
      return true;
 
70
    }
 
71
 
 
72
    virtual void SetCaption (const TCHAR *Caption);
 
73
    virtual const NString &GetCaption() const;
 
74
 
 
75
    virtual void SetState (bool State);
 
76
    virtual void SetState (bool State, bool EmitSignal);
 
77
    virtual bool GetState() const;
 
78
    //---
 
79
 
 
80
  protected:
 
81
    void InitializeWidgets();
 
82
    void InitializeLayout();
 
83
    void DestroyLayout();
 
84
 
 
85
  private:
 
86
    void SetRadioGroupSelector (RadioButtonGroup *RadioSelector);
 
87
    //! Intended for RadioButtonGroup only.
 
88
    void SetStatePrivate (bool State);
 
89
    //! Intended for RadioButtonGroup only.
 
90
    void SetStatePrivate (bool State, bool EmitSignal);
 
91
 
 
92
 
 
93
    HLayout    *m_hlayout;
 
94
    CoreArea   *m_TextArea;
 
95
    CoreArea   *m_CheckArea;
 
96
    bool        m_State;
 
97
 
 
98
    RadioButtonGroup *m_Group;
 
99
    int m_GroupId;
 
100
 
 
101
    friend class RadioButtonGroup;
 
102
  };
 
103
}
 
104
 
 
105
#endif // RADIOBUTTON_H