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

« back to all changes in this revision

Viewing changes to src/plugins/contrib/wxSmith/properties/wxslongproperty.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: wxslongproperty.cpp 4850 2008-01-29 21:45:49Z byo $
 
20
* $HeadURL: svn://svn.berlios.de/codeblocks/tags/8.02/src/plugins/contrib/wxSmith/properties/wxslongproperty.cpp $
 
21
*/
 
22
 
 
23
#include "wxslongproperty.h"
 
24
#include <globals.h>
 
25
 
 
26
// Helper macro for fetching variable
 
27
#define VALUE   wxsVARIABLE(Object,Offset,long)
 
28
 
 
29
wxsLongProperty::wxsLongProperty(const wxString& PGName, const wxString& DataName,long _Offset,long _Default,int Priority):
 
30
    wxsProperty(PGName,DataName,Priority),
 
31
    Offset(_Offset),
 
32
    Default(_Default)
 
33
{}
 
34
 
 
35
 
 
36
void wxsLongProperty::PGCreate(wxsPropertyContainer* Object,wxPropertyGridManager* Grid,wxPGId Parent)
 
37
{
 
38
    PGRegister(Object,Grid,Grid->AppendIn(Parent,wxIntProperty(GetPGName(),wxPG_LABEL,VALUE)));
 
39
}
 
40
 
 
41
bool wxsLongProperty::PGRead(wxsPropertyContainer* Object,wxPropertyGridManager* Grid,wxPGId Id,long Index)
 
42
{
 
43
    VALUE = Grid->GetPropertyValue(Id).GetLong();
 
44
    return true;
 
45
}
 
46
 
 
47
bool wxsLongProperty::PGWrite(wxsPropertyContainer* Object,wxPropertyGridManager* Grid,wxPGId Id,long Index)
 
48
{
 
49
    Grid->SetPropertyValue(Id,VALUE);
 
50
    return true;
 
51
}
 
52
 
 
53
bool wxsLongProperty::XmlRead(wxsPropertyContainer* Object,TiXmlElement* Element)
 
54
{
 
55
    if ( !Element )
 
56
    {
 
57
        VALUE = Default;
 
58
        return false;
 
59
    }
 
60
    const char* Text = Element->GetText();
 
61
    if ( !Text )
 
62
    {
 
63
        VALUE = Default;
 
64
        return false;
 
65
    }
 
66
    VALUE = atol(Text);
 
67
    return true;
 
68
}
 
69
 
 
70
bool wxsLongProperty::XmlWrite(wxsPropertyContainer* Object,TiXmlElement* Element)
 
71
{
 
72
    if ( VALUE != Default )
 
73
    {
 
74
        Element->InsertEndChild(TiXmlText(cbU2C(wxString::Format(_T("%d"),VALUE))));
 
75
        return true;
 
76
    }
 
77
    return false;
 
78
}
 
79
 
 
80
bool wxsLongProperty::PropStreamRead(wxsPropertyContainer* Object,wxsPropertyStream* Stream)
 
81
{
 
82
    return Stream->GetLong(GetDataName(),VALUE,Default);
 
83
}
 
84
 
 
85
bool wxsLongProperty::PropStreamWrite(wxsPropertyContainer* Object,wxsPropertyStream* Stream)
 
86
{
 
87
    return Stream->PutLong(GetDataName(),VALUE,Default);
 
88
}