~ubuntu-branches/ubuntu/oneiric/codeblocks/oneiric

« back to all changes in this revision

Viewing changes to src/plugins/contrib/wxSmith/wxwidgets/defitems/wxsslider.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michael Casadevall
  • Date: 2008-07-17 04:39:23 UTC
  • Revision ID: james.westby@ubuntu.com-20080717043923-gmsy5cwkdjswghkm
Tags: upstream-8.02
ImportĀ upstreamĀ versionĀ 8.02

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
* This file is part of wxSmith plugin for Code::Blocks Studio
 
3
* Copyright (C) 2006-2007  Bartlomiej Swiecki
 
4
*
 
5
* wxSmith is free software; you can redistribute it and/or modify
 
6
* it under the terms of the GNU General Public License as published by
 
7
* the Free Software Foundation; either version 3 of the License, or
 
8
* (at your option) any later version.
 
9
*
 
10
* wxSmith is distributed in the hope that it will be useful,
 
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
13
* GNU General Public License for more details.
 
14
*
 
15
* You should have received a copy of the GNU General Public License
 
16
* along with wxSmith. If not, see <http://www.gnu.org/licenses/>.
 
17
*
 
18
* $Revision: 4850 $
 
19
* $Id: wxsslider.cpp 4850 2008-01-29 21:45:49Z byo $
 
20
* $HeadURL: svn://svn.berlios.de/codeblocks/tags/8.02/src/plugins/contrib/wxSmith/wxwidgets/defitems/wxsslider.cpp $
 
21
*/
 
22
 
 
23
#include <wx/slider.h>
 
24
#include "wxsslider.h"
 
25
 
 
26
 
 
27
// TODO: Add some flag like "Using Selection range" to note when using selmin / selmax (current comparision to 0 isn't enough)
 
28
namespace
 
29
{
 
30
    wxsRegisterItem<wxsSlider> Reg(_T("Slider"),wxsTWidget,_T("Standard"),50);
 
31
 
 
32
    WXS_ST_BEGIN(wxsSliderStyles,_T(""))
 
33
        WXS_ST(wxSL_HORIZONTAL)
 
34
        WXS_ST(wxSL_VERTICAL)
 
35
        WXS_ST(wxSL_AUTOTICKS)
 
36
        WXS_ST(wxSL_LABELS)
 
37
        WXS_ST(wxSL_LEFT)
 
38
        WXS_ST(wxSL_TOP)
 
39
        WXS_ST(wxSL_RIGHT)
 
40
        WXS_ST(wxSL_BOTTOM)
 
41
        WXS_ST(wxSL_BOTH)
 
42
        WXS_ST(wxSL_SELRANGE)
 
43
        WXS_ST(wxSL_INVERSE)
 
44
        WXS_ST_DEFAULTS()
 
45
    WXS_ST_END()
 
46
 
 
47
 
 
48
    WXS_EV_BEGIN(wxsSliderEvents)
 
49
        WXS_EVI(EVT_COMMAND_SCROLL,wxEVT_SCROLL_TOP|wxEVT_SCROLL_BOTTOM|wxEVT_SCROLL_LINEUP|wxEVT_SCROLL_LINEDOWN|wxEVT_SCROLL_PAGEUP|wxEVT_SCROLL_PAGEDOWN|wxEVT_SCROLL_THUMBTRACK|wxEVT_SCROLL_THUMBRELEASE|wxEVT_SCROLL_CHANGED,wxScrollEvent,CmdScroll)
 
50
        WXS_EVI(EVT_COMMAND_SCROLL_TOP,wxEVT_SCROLL_TOP,wxScrollEvent,ScrollTop)
 
51
        WXS_EVI(EVT_COMMAND_SCROLL_BOTTOM,wxEVT_SCROLL_BOTTOM,wxScrollEvent,CmdScrollBottom)
 
52
        WXS_EVI(EVT_COMMAND_SCROLL_LINEUP,wxEVT_SCROLL_LINEUP,wxScrollEvent,CmdScrollLineUp)
 
53
        WXS_EVI(EVT_COMMAND_SCROLL_LINEDOWN,wxEVT_SCROLL_LINEDOWN,wxScrollEvent,CmdScrollLineDown)
 
54
        WXS_EVI(EVT_COMMAND_SCROLL_PAGEUP,wxEVT_SCROLL_PAGEUP,wxScrollEvent,CmdScrollPageUp)
 
55
        WXS_EVI(EVT_COMMAND_SCROLL_PAGEDOWN,wxEVT_SCROLL_PAGEDOWN,wxScrollEvent,CmdScrollPageDown)
 
56
        WXS_EVI(EVT_COMMAND_SCROLL_THUMBTRACK,wxEVT_SCROLL_THUMBTRACK,wxScrollEvent,CmdScrollThumbTrack)
 
57
        WXS_EVI(EVT_COMMAND_SCROLL_THUMBRELEASE,wxEVT_SCROLL_THUMBRELEASE,wxScrollEvent,CmdScrollThumbRelease)
 
58
        WXS_EVI(EVT_COMMAND_SCROLL_CHANGED,wxEVT_SCROLL_CHANGED,wxScrollEvent,CmdScrollChanged)
 
59
    WXS_EV_END()
 
60
 
 
61
}
 
62
 
 
63
 
 
64
wxsSlider::wxsSlider(wxsItemResData* Data):
 
65
    wxsWidget(
 
66
        Data,
 
67
        &Reg.Info,
 
68
        wxsSliderEvents,
 
69
        wxsSliderStyles),
 
70
    Value(0),
 
71
    Min(0),
 
72
    Max(100),
 
73
    TickFrequency(0),
 
74
    PageSize(0),
 
75
    LineSize(0),
 
76
    ThumbLength(0),
 
77
    Tick(0),
 
78
    SelMin(0),
 
79
    SelMax(0)
 
80
{}
 
81
 
 
82
void wxsSlider::OnBuildCreatingCode()
 
83
{
 
84
    switch ( GetLanguage() )
 
85
    {
 
86
        case wxsCPP:
 
87
        {
 
88
            AddHeader(_T("<wx/slider.h>"),GetInfo().ClassName,hfInPCH);
 
89
            Codef(_T("%C(%W, %I, %d, %d, %d, %P, %S, %T, %V, %N);\n"),Value,Min,Max);
 
90
 
 
91
            if ( TickFrequency )    Codef( _T("%ASetTickFreq(%d);\n"), TickFrequency);
 
92
            if ( PageSize )         Codef( _T("%ASetPageSize(%d);\n"), PageSize);
 
93
            if ( LineSize )         Codef( _T("%ASetLineSize(%d);\n"), LineSize);
 
94
            if ( ThumbLength )      Codef( _T("%ASetThumbLength(%d);\n"), ThumbLength);
 
95
            if ( Tick )             Codef( _T("%ASetTick(%d);\n"), Tick);
 
96
            if ( SelMin || SelMax ) Codef( _T("%ASetSelection(%d, %d);\n"), SelMin, SelMax);
 
97
            BuildSetupWindowCode();
 
98
            return;
 
99
        }
 
100
 
 
101
        default:
 
102
        {
 
103
            wxsCodeMarks::Unknown(_T("wxsSlider::OnBuildCreatingCode"),GetLanguage());
 
104
        }
 
105
    }
 
106
}
 
107
 
 
108
wxObject* wxsSlider::OnBuildPreview(wxWindow* Parent,long Flags)
 
109
{
 
110
    wxSlider* Preview = new wxSlider(Parent,GetId(),Value,Min,Max,Pos(Parent),Size(Parent),Style());
 
111
    if ( TickFrequency )    Preview->SetTickFreq(TickFrequency,0);
 
112
    if ( PageSize )         Preview->SetPageSize(PageSize);
 
113
    if ( LineSize )         Preview->SetLineSize(LineSize);
 
114
    if ( ThumbLength )      Preview->SetThumbLength(ThumbLength);
 
115
    if ( Tick )             Preview->SetTick(Tick);
 
116
    if ( SelMin || SelMax ) Preview->SetSelection(SelMin,SelMax);
 
117
    return SetupWindow(Preview,Flags);
 
118
}
 
119
 
 
120
void wxsSlider::OnEnumWidgetProperties(long Flags)
 
121
{
 
122
   WXS_LONG(wxsSlider,Value,_("Value"),_T("value"),0)
 
123
   WXS_LONG(wxsSlider,Min,_("Min"),_T("min"),0)
 
124
   WXS_LONG(wxsSlider,Max,_("Max"),_T("max"),100)
 
125
   WXS_LONG(wxsSlider,TickFrequency,_("Tick Frequency"),_T("tickfreq"),0)
 
126
   WXS_LONG(wxsSlider,PageSize,_("Page Size"),_T("pagesize"),0)
 
127
   WXS_LONG(wxsSlider,LineSize,_("Line Size"),_T("linesize"),0)
 
128
   WXS_LONG(wxsSlider,ThumbLength,_("Thumb Length"),_T("thumb"),0)
 
129
   WXS_LONG(wxsSlider,Tick,_("Tick"),_T("tick"),0)
 
130
   WXS_LONG(wxsSlider,SelMin,_("Selection Min"),_T("selmin"),0)
 
131
   WXS_LONG(wxsSlider,SelMax,_("Selection Max"),_T("selmax"),0)
 
132
}