~damien-moore/+junk/codeblocks

« back to all changes in this revision

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

  • Committer: Damien Moore
  • Date: 2013-10-11 14:25:27 UTC
  • Revision ID: damienlmoore@gmail.com-20131011142527-w13ki0x8yjd7973d
copy of Code::Blocks repo based on SVN rev 9395

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: 8307 $
 
19
* $Id: wxsslider.cpp 8307 2012-08-31 21:05:19Z mortenmacfly $
 
20
* $HeadURL: svn://svn.code.sf.net/p/codeblocks/code/trunk/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"),110);
 
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_EVI(EVT_COMMAND_SLIDER_UPDATED,wxEVT_COMMAND_SLIDER_UPDATED,wxScrollEvent,CmdSliderUpdated)
 
60
    WXS_EV_END()
 
61
 
 
62
}
 
63
 
 
64
 
 
65
wxsSlider::wxsSlider(wxsItemResData* Data):
 
66
    wxsWidget(
 
67
        Data,
 
68
        &Reg.Info,
 
69
        wxsSliderEvents,
 
70
        wxsSliderStyles),
 
71
    Value(0),
 
72
    Min(0),
 
73
    Max(100),
 
74
    TickFrequency(0),
 
75
    PageSize(0),
 
76
    LineSize(0),
 
77
    ThumbLength(0),
 
78
    Tick(0),
 
79
    SelMin(0),
 
80
    SelMax(0)
 
81
{}
 
82
 
 
83
void wxsSlider::OnBuildCreatingCode()
 
84
{
 
85
    switch ( GetLanguage() )
 
86
    {
 
87
        case wxsCPP:
 
88
        {
 
89
            AddHeader(_T("<wx/slider.h>"),GetInfo().ClassName,hfInPCH);
 
90
            Codef(_T("%C(%W, %I, %d, %d, %d, %P, %S, %T, %V, %N);\n"),Value,Min,Max);
 
91
 
 
92
            if ( TickFrequency )    Codef( _T("%ASetTickFreq(%d);\n"), TickFrequency);
 
93
            if ( PageSize )         Codef( _T("%ASetPageSize(%d);\n"), PageSize);
 
94
            if ( LineSize )         Codef( _T("%ASetLineSize(%d);\n"), LineSize);
 
95
            if ( ThumbLength )      Codef( _T("%ASetThumbLength(%d);\n"), ThumbLength);
 
96
            if ( Tick )             Codef( _T("%ASetTick(%d);\n"), Tick);
 
97
            if ( SelMin || SelMax ) Codef( _T("%ASetSelection(%d, %d);\n"), SelMin, SelMax);
 
98
            BuildSetupWindowCode();
 
99
            return;
 
100
        }
 
101
 
 
102
        default:
 
103
        {
 
104
            wxsCodeMarks::Unknown(_T("wxsSlider::OnBuildCreatingCode"),GetLanguage());
 
105
        }
 
106
    }
 
107
}
 
108
 
 
109
wxObject* wxsSlider::OnBuildPreview(wxWindow* Parent,long Flags)
 
110
{
 
111
    wxSlider* Preview = new wxSlider(Parent,GetId(),Value,Min,Max,Pos(Parent),Size(Parent),Style());
 
112
#if wxCHECK_VERSION(2, 9, 0)
 
113
    if ( TickFrequency )    Preview->SetTickFreq(TickFrequency);
 
114
#else
 
115
    if ( TickFrequency )    Preview->SetTickFreq(TickFrequency,0);
 
116
#endif
 
117
    if ( PageSize )         Preview->SetPageSize(PageSize);
 
118
    if ( LineSize )         Preview->SetLineSize(LineSize);
 
119
    if ( ThumbLength )      Preview->SetThumbLength(ThumbLength);
 
120
    if ( Tick )             Preview->SetTick(Tick);
 
121
    if ( SelMin || SelMax ) Preview->SetSelection(SelMin,SelMax);
 
122
    return SetupWindow(Preview,Flags);
 
123
}
 
124
 
 
125
void wxsSlider::OnEnumWidgetProperties(long Flags)
 
126
{
 
127
   WXS_LONG(wxsSlider,Value,_("Value"),_T("value"),0)
 
128
   WXS_LONG(wxsSlider,Min,_("Min"),_T("min"),0)
 
129
   WXS_LONG(wxsSlider,Max,_("Max"),_T("max"),100)
 
130
   WXS_LONG(wxsSlider,TickFrequency,_("Tick Frequency"),_T("tickfreq"),0)
 
131
   WXS_LONG(wxsSlider,PageSize,_("Page Size"),_T("pagesize"),0)
 
132
   WXS_LONG(wxsSlider,LineSize,_("Line Size"),_T("linesize"),0)
 
133
   WXS_LONG(wxsSlider,ThumbLength,_("Thumb Length"),_T("thumb"),0)
 
134
   WXS_LONG(wxsSlider,Tick,_("Tick"),_T("tick"),0)
 
135
   WXS_LONG(wxsSlider,SelMin,_("Selection Min"),_T("selmin"),0)
 
136
   WXS_LONG(wxsSlider,SelMax,_("Selection Max"),_T("selmax"),0)
 
137
}