예제 #1
0
void wxsDialog::OnBuildCreatingCode()
{
    switch ( GetLanguage() )
    {
        case wxsCPP:
        {
            AddHeader(_T("<wx/dialog.h>"),GetInfo().ClassName,hfInPCH);
            Codef(_T("%C(%W, %I, %t, wxDefaultPosition, wxDefaultSize, %T, %N);\n"),Title.wx_str());
            if ( !GetBaseProps()->m_Size.IsDefault || (GetPropertiesFlags()&flSource && IsRootItem() && GetBaseProps()->m_SizeFromArg) )
            {
                Codef(_T("%ASetClientSize(%S);\n"));
            }
            if ( !GetBaseProps()->m_Position.IsDefault || (GetPropertiesFlags()&flSource && IsRootItem() && GetBaseProps()->m_PositionFromArg) )
            {
                Codef(_T("%AMove(%P);\n"));
            }
            BuildSetupWindowCode();
            AddChildrenCode();
            if ( Centered )
            {
                Codef(_T("%ACenter();\n"));
            }

            return;
        }

        case wxsUnknownLanguage: // fall-through
        default:
        {
            wxsCodeMarks::Unknown(_T("wxsDialog::OnBuildCreatingCode"),GetLanguage());
        }
    }
}
예제 #2
0
void wxsFrame::OnBuildCreatingCode()
{
    switch ( GetLanguage() )
    {
        case wxsCPP:
        {
            AddHeader(_T("<wx/frame.h>"),GetInfo().ClassName,hfInPCH);
            #if wxCHECK_VERSION(2, 9, 0)
            Codef(_T("%C(%W, %I, %t, wxDefaultPosition, wxDefaultSize, %T, %N);\n"),Title.wx_str());
            #else
            Codef(_T("%C(%W, %I, %t, wxDefaultPosition, wxDefaultSize, %T, %N);\n"),Title.c_str());
            #endif
            if ( !GetBaseProps()->m_Size.IsDefault || (GetPropertiesFlags()&flSource && IsRootItem() && GetBaseProps()->m_SizeFromArg) )
            {
                Codef(_T("%ASetClientSize(%S);\n"));
            }
            if ( !GetBaseProps()->m_Position.IsDefault || (GetPropertiesFlags()&flSource && IsRootItem() && GetBaseProps()->m_PositionFromArg) )
            {
                Codef(_T("%AMove(%P);\n"));
            }
            BuildSetupWindowCode();
            if ( !Icon.IsEmpty() )
            {
                AddHeader(_T("<wx/icon.h>"), GetInfo().ClassName, hfLocal);
                Codef(
                    _T("{\n")
                    _T("\twxIcon FrameIcon;\n")
                    _T("\tFrameIcon.CopyFromBitmap(%i);\n")
                    _T("\t%ASetIcon(FrameIcon);\n")
                    _T("}\n"),
                        &Icon,_T("wxART_FRAME_ICON"));
            }

            AddChildrenCode();
            if ( Centered )
            {
                Codef(_T("%ACenter();\n"));
            }

            return;
        }

        default:
        {
            wxsCodeMarks::Unknown(_T("wxsFrame::OnBuildCreatingCode"),GetLanguage());
        }
    }
}
예제 #3
0
wxObject* wxsAxis::OnBuildPreview(wxWindow* Parent,long Flags) {
    wxStaticText    *Preview;
    mpWindow        *mp;
    mpScaleX        *xx;
    mpScaleY        *yy;
    wxPen           pen;
    wxColour        cc;
    wxFont          ff;
    bool            hide;

// if parent is not an mpWindow, then exit out

    if (! Parent->IsKindOf(CLASSINFO(mpWindow))) return NULL;
    mp = (mpWindow *) Parent;

// hide this axis?

    hide = ((Flags & pfExact) && (GetPropertiesFlags() & flHidden) && GetBaseProps()->m_Hidden);

// make the place-holder

    Preview = new wxStaticText(Parent, GetId(), mLabel, Pos(Parent), Size(Parent), (wxSUNKEN_BORDER|Style()));
    Preview->SetForegroundColour(wxColour(255,255,255));
    Preview->SetBackgroundColour(wxColour(0,128,0));
    SetupWindow(Preview,Flags);
    if (Flags & pfExact) Preview->Hide();

// pen color

    cc = mPenColour.GetColour();
    if (cc.IsOk()) pen.SetColour(cc);

// text font

    ff = mPenFont.BuildFont();

// update the place-holder

    if (cc.IsOk()) Preview->SetBackgroundColour(cc);
    Preview->SetFont(ff);

// make the axis

    if (mType == 0) {
        xx = new mpScaleX(mLabel, mAlign, mTics);
        xx->SetPen(pen);
        xx->SetFont(ff);
        if (! hide) mp->AddLayer(xx);
    }
    else {
        yy = new mpScaleY(mLabel, mAlign, mTics);
        yy->SetPen(pen);
        yy->SetFont(ff);
        if (! hide) mp->AddLayer(yy);
    };

// done

    return Preview;
}
예제 #4
0
void wxsCustomWidget::OnEnumWidgetProperties(long Flags)
{
    wxString XmlDataInit = m_XmlData;
    if ( GetPropertiesFlags() & flSource )
    {
        WXS_STRING(wxsCustomWidget,m_CreatingCode,_("Creating code"),_T("creating_code"),_T(""),true);
        WXS_SHORT_STRING(wxsCustomWidget,m_IncludeFile,_("Include file"), _T("include_file"), _T(""),false);
        WXS_BOOL(wxsCustomWidget,m_IncludeIsLocal,_(" Use \"\" for include (instead of <>)"), _T("local_include"), false);
    }
    else
    {
        if ( !(Flags&flXml) )
        {
            WXS_STRING(wxsCustomWidget,m_XmlData,_("Xml Data"),_T(""),_T(""),false);
        }
    }

    WXS_SHORT_STRING(wxsCustomWidget,m_Style,_("Style"),_T("style"),_T("0"),false);

    if ( Flags&flPropGrid )
    {
        if ( XmlDataInit != m_XmlData )
        {
            // We know it's propgrid operation and xml data has changed,
            // need to reparse this data
            RebuildXmlDataDoc();
        }
    }
}
예제 #5
0
bool wxsCustomWidget::OnXmlWrite(TiXmlElement* Element,bool IsXRC,bool IsExtra)
{
    bool Ret = wxsItem::OnXmlWrite(Element,IsXRC,IsExtra);

    if ( IsXRC )
    {
        if ( !(GetPropertiesFlags() & flSource) )
        {
            Element->SetAttribute("class",cbU2C(GetUserClass()));
            Element->RemoveAttribute("subclass");
            Element->InsertEndChild(TiXmlElement("style"))->InsertEndChild(TiXmlText(cbU2C(m_Style)));

            for ( TiXmlElement* Child = m_XmlDataDoc.FirstChildElement(); Child; Child = Child->NextSiblingElement() )
            {
                // Skipping all standard elements
                wxString Name = cbC2U(Child->Value());
                if ( Name != _T("pos") &&
                     Name != _T("size") &&
                     Name != _T("style") &&
                     Name != _T("enabled") &&
                     Name != _T("focused") &&
                     Name != _T("hidden") &&
                     Name != _T("fg") &&
                     Name != _T("bg") &&
                     Name != _T("font") &&
                     Name != _T("handler") )
                {
                    Element->InsertEndChild(*Child);
                }
            }
        }
    }

    return Ret;
}
예제 #6
0
bool wxsCustomWidget::OnXmlRead(TiXmlElement* Element,bool IsXRC,bool IsExtra)
{
    bool Ret = wxsItem::OnXmlRead(Element,IsXRC,IsExtra);

    if ( IsXRC )
    {
        if ( !(GetPropertiesFlags() & flSource) )
        {
            SetUserClass(cbC2U(Element->Attribute("class")));
            m_XmlDataDoc.Clear();
            for ( TiXmlElement* Child = Element->FirstChildElement(); Child; Child = Child->NextSiblingElement() )
            {
                // Skipping all standard elements
                wxString Name = cbC2U(Child->Value());
                if ( Name != _T("pos") &&
                     Name != _T("size") &&
                     Name != _T("style") &&
                     Name != _T("enabled") &&
                     Name != _T("focused") &&
                     Name != _T("hidden") &&
                     Name != _T("fg") &&
                     Name != _T("bg") &&
                     Name != _T("font") &&
                     Name != _T("handler") )
                {
                    m_XmlDataDoc.InsertEndChild(*Child);
                }
            }
            RebuildXmlData();
        }
    }

    return Ret;
}
void wxsPropertyContainer::PropStreamRead(wxsPropertyStream* Stream)
{
    wxMutexLocker Lock(Mutex);
    Flags = (GetPropertiesFlags() & ~(flPropGrid|flXml)) | flPropStream;
    IsRead = true;
    CurrentStream = Stream;
    OnEnumProperties(Flags);
    NotifyPropertyChange(true);
    Flags = 0;
}
void wxsPropertyContainer::XmlWrite(TiXmlElement* Element)
{
    wxMutexLocker Lock(Mutex);
    // Just to make sure we will read exactly what we've saved
    TiXmlNode::SetCondenseWhiteSpace(false);
    Flags = (GetPropertiesFlags() & ~(flPropGrid|flPropStream)) | flXml;
    IsRead = false;
    CurrentElement = Element;
    OnEnumProperties(Flags);
    Flags = 0;
}
void wxsPropertyContainer::PropStreamWrite(wxsPropertyStream* Stream)
{
    wxMutexLocker Lock(Mutex);
    Flags = (GetPropertiesFlags() & ~(flPropGrid|flXml)) | flPropStream;
    IsRead = false;
    CurrentStream = Stream;
    OnEnumProperties(Flags);

    // Notifying about change since this method could correct some values
    NotifyPropertyChange(true);
    Flags = 0;
}
예제 #10
0
void wxsMenuItem::OnBuildXRCFetchingCode()
{
    // Menu items can not be found through FindWindow stuff, we need to
    // fetch them using wxMenuBar::FindItem.
    long Flags = GetPropertiesFlags();
    if ( (Flags&flVariable) && (Flags&flId) )
    {
        AddXRCFetchingCode(
            GetVarName() + _T(" = GetMenuBar() ? ")
            _T("(") + GetUserClass() + _T("*)")
            _T("GetMenuBar()->FindItem(XRCID(\"") + GetIdName() + _T("\")) : NULL;\n"));
    }
}
예제 #11
0
void wxsAxis::OnBuildCreatingCode() {
    wxString    vname;
    wxString    pname;
    wxString    cname;
    wxString    fname;
    wxString    dtext;

// we only know C++ language

    if (GetLanguage() != wxsCPP) wxsCodeMarks::Unknown(_T("wxsAxis::OnBuildCreatingCode"),GetLanguage());

// usefull names

    vname = GetVarName();
    pname = GetParent()->GetVarName();
    cname = vname + _("_PEN");
    fname = vname + _("_FONT");

// the header for mathplot

    AddHeader(_T("<mathplot.h>"),GetInfo().ClassName,hfInPCH);

// create the axis -- but not the setup code

    if (mType == 0) Codef(_T("%s = new mpScaleX(_(\"%s\"), %d, %b);\n"), vname.wx_str(), mLabel.wx_str(), mAlign, mTics);
    else            Codef(_T("%s = new mpScaleY(_(\"%s\"), %d, %b);\n"), vname.wx_str(), mLabel.wx_str(), mAlign, mTics);
//  BuildSetupWindowCode();

// assign a pen to the layer

    dtext = mPenColour.BuildCode(GetCoderContext());
    if (dtext.Len() > 0) {
        Codef(_T("wxPen   %s(%s);\n"), cname.wx_str(), dtext.wx_str());
        Codef(_T("%s->SetPen(%s);\n"), vname.wx_str(), cname.wx_str());
    };

// assign a font to the layer

    dtext = mPenFont.BuildFontCode(fname, GetCoderContext());
    if (dtext.Len() > 0) {
        Codef(_T("%s"), dtext.wx_str());
        Codef(_T("%s->SetFont(%s);\n"), vname.wx_str(), fname.wx_str());
    };

// add to parent window -- should be a mpWindow

    if ((GetPropertiesFlags() & flHidden) && GetBaseProps()->m_Hidden)
        ; // do nothing
    else
        Codef(_T("%s->AddLayer(%s);\n"), pname.wx_str(), vname.wx_str());
}
예제 #12
0
void wxsPropertyContainer::ShowInPropertyGrid()
{
    wxMutexLocker Lock(Mutex);
    if ( !wxsPGRID() ) return;      // We're not sure that PropertyGridManager has been created
    Flags = (GetPropertiesFlags() & ~(flXml|flPropStream)) | flPropGrid;
    wxsPGRID()->Freeze();
    wxsPGRID()->StoreSelected();
    wxsPGRID()->NewPropertyContainerStart();
    OnEnumProperties(Flags);
    wxsPGRID()->NewPropertyContainerFinish(this);
    Flags = 0;
    OnAddExtraProperties(wxsPGRID());
    wxsPGRID()->Thaw();
    // call RestoreSelected() after Thaw(), to ensure the selected property is visible
    wxsPGRID()->RestoreSelected();
}
예제 #13
0
void wxsVector::OnBuildCreatingCode() {
int         i,n;
wxString    vname;
wxString    pname;
wxString    cname;
wxString    fname;
wxString    xname;
wxString    yname;
wxString    dtext;
wxString    s;

// we only know C++ language

    if (GetLanguage() != wxsCPP) wxsCodeMarks::Unknown(_T("wxsVector::OnBuildCreatingCode"),GetLanguage());

// usefull names

    vname = GetVarName();
    pname = GetParent()->GetVarName();
    cname = vname + _("_PEN");
    fname = vname + _("_FONT");
    xname = vname + _("_X");
    yname = vname + _("_Y");

// the header for mathplot

    AddHeader(_T("<mathplot.h>"),GetInfo().ClassName,hfInPCH);

// create the vector -- but not the setup code

    Codef(_T("%s = new mpFXYVector(_(\"%s\"), %d);\n"), vname.wx_str(), mLabel.wx_str(), mAlign);
//  BuildSetupWindowCode();

// assign a pen to the layer

    dtext = mPenColour.BuildCode(GetCoderContext());
    if (dtext.Len() > 0) {
        Codef(_T("wxPen   %s(%s);\n"), cname.wx_str(), dtext.wx_str());
        Codef(_T("%s->SetPen(%s);\n"), vname.wx_str(), cname.wx_str());
    };

// assign a font to the layer

    dtext = mPenFont.BuildFontCode(fname, GetCoderContext());
    if (dtext.Len() > 0) {
        Codef(_T("%s"), dtext.wx_str());
        Codef(_T("%s->SetFont(%s);\n"), vname.wx_str(), fname.wx_str());
    };

// define the arrays

    dtext = _("std::vector<double>  ") + xname + _(";");
    AddDeclaration(dtext);
    dtext = _("std::vector<double>  ") + yname + _(";");
    AddDeclaration(dtext);

// assign the data

    ParseXY();
    n = mXs.GetCount();
    if (n > 0) {
        for(i=0; i<n; i++) {
            Codef(_T("%s.push_back(%s);   %s.push_back(%s);\n"), xname.wx_str(), mXs[i].wx_str(),
                                                                 yname.wx_str(), mYs[i].wx_str());
        };

        Codef(_T("%ASetData(%s, %s);\n"), xname.wx_str(), yname.wx_str());
    };

// draw as points or a continuous line

    Codef(_T("%ASetContinuity(%b);\n"), mContinuous);

// add to parent window -- should be a mpWindow

    if ((GetPropertiesFlags() & flHidden) && GetBaseProps()->m_Hidden) n = 0;        // do nothing
    else Codef(_T("%s->AddLayer(%s);\n"), pname.wx_str(), vname.wx_str());


}
예제 #14
0
wxObject* wxsVector::OnBuildPreview(wxWindow* Parent, long Flags) {
int             n;
wxStaticText    *Preview;
mpFXYVector     *vec;
mpWindow        *mp;
wxPen           pen(*wxBLACK_PEN);
wxColour        cc;
wxFont          ff;
bool            hide;

// if parent is not an mpWindow, then exit out

    if (! Parent->IsKindOf(CLASSINFO(mpWindow))) return NULL;
    mp = (mpWindow *) Parent;

// hide this vector

    hide = ((Flags & pfExact) && (GetPropertiesFlags() & flHidden) && GetBaseProps()->m_Hidden);

// make the place-holder

    Preview = new wxStaticText(Parent, GetId(), mLabel, Pos(Parent), Size(Parent), (wxSUNKEN_BORDER|Style()));
    Preview->SetForegroundColour(wxColour(255,255,255));
    Preview->SetBackgroundColour(wxColour(0,0,128));
    SetupWindow(Preview,Flags);
    if (Flags & pfExact) Preview->Hide();

// the actual vector

    vec = new mpFXYVector(mLabel, mAlign);

// pen color

    cc = mPenColour.GetColour();
    if (cc.IsOk()) pen.SetColour(cc);
    vec->SetPen(pen);

// text font

    ff = mPenFont.BuildFont();
    vec->SetFont(ff);

// update the place-holder

    if (cc.IsOk()) Preview->SetBackgroundColour(cc);
    Preview->SetFont(ff);

// fill in the data

    ParseXY();
    n = mXs.GetCount();
    if (n > 0) {
        vec->SetData(mXf, mYf);
    };

// points or lines?

    vec->SetContinuity(mContinuous);

// and add layer to parent

    if (! hide) mp->AddLayer(vec);

// done

    return Preview;
}
예제 #15
0
void wxsGrid::OnBuildCreatingCode()
{
    switch ( GetLanguage() )
    {
        case wxsCPP:
        {
            AddHeader(_T("<wx/grid.h>"),GetInfo().ClassName,0);
            AddHeader(_T("<wx/grid.h>"),_T("wxGridEvent"),0);

            Codef( _T("%C(%W, %I, %P, %S, %T, %N);\n") );

            if ( GetPropertiesFlags() & flSource )
            {
                if ( m_ColsCount>=0 && m_RowsCount>=0 && (m_ColsCount>0 || m_RowsCount>0) )
                {
                    Codef( _T("%ACreateGrid(%d,%d);\n"), m_RowsCount, m_ColsCount );
                    BuildSetupWindowCode();

                    Codef( _T("%AEnableEditing(%b);\n"),  !m_ReadOnly);
                    Codef( _T("%AEnableGridLines(%b);\n"), m_GridLines);

                    if (m_LabelRowHeight > 0) Codef(_T("%ASetColLabelSize(%d);\n"), m_LabelRowHeight);
                    if (m_LabelColWidth  > 0) Codef(_T("%ASetRowLabelSize(%d);\n"), m_LabelColWidth);

                    if (m_DefaultRowSize  > 0) Codef(_T("%ASetDefaultRowSize(%d, %b);\n"), m_DefaultRowSize, true);
                    if (m_DefaultColSize  > 0) Codef(_T("%ASetDefaultColSize(%d, %b);\n"), m_DefaultColSize, true);

                    wxString ss = m_LabelTextColour.BuildCode( GetCoderContext() );
                    if (ss.Len() > 0) Codef(_T("%ASetLabelTextColour(%s);\n"), ss.wx_str());

                    ss = GetCoderContext()->GetUniqueName( _T("GridLabelFont") );
                    wxString tt = m_LabelFont.BuildFontCode(ss, GetCoderContext());
                    if (tt.Len() > 0)
                    {
                        Codef(_T("%s"), tt.wx_str());
                        Codef(_T("%ASetLabelFont(%s);\n"), ss.wx_str());
                    }

                    int n = wxMin( (int)m_ColLabels.GetCount(), m_ColsCount );
                    for ( int i=0; i<n; i++ )
                    {
                        Codef(_T("%ASetColLabelValue(%d, %t);\n"), i, m_ColLabels[i].wx_str());
                    }

                    n = wxMin( (int)m_RowLabels.GetCount(), m_RowsCount );
                    for ( int i=0; i<n; i++)
                    {
                        Codef(_T("%ASetRowLabelValue(%d, %t);\n"), i, m_RowLabels[i].wx_str());
                    }

                    n = (int)m_CellText.GetCount();
                    int i = 0;
                    for ( int j=0; j<m_RowsCount && i<n; j++ )
                    {
                        for ( int k=0; k<m_ColsCount && i<n; k++, i++ )
                        {
                            Codef( _T("%ASetCellValue(%d, %d, %t);\n"), j, k, m_CellText[i].wx_str());
                        }
                    }

                    // default cell font and text colour

                    Codef(_T("%ASetDefaultCellFont( %AGetFont() );\n"));

                    Codef(_T("%ASetDefaultCellTextColour( %AGetForegroundColour() );\n"));

                }
            }

            return;
        }

        case wxsUnknownLanguage: // fall-through
        default:
        {
            wxsCodeMarks::Unknown(_T("wxsGrid::OnBuildCreatingCode"),GetLanguage());
        }
    }
}
예제 #16
0
wxObject* wxsGrid::OnBuildPreview( wxWindow* parent, long flags )
{
    wxGrid* preview = new wxGrid( parent, GetId(), Pos(parent), Size(parent), Style() );

    if ( GetPropertiesFlags() & flSource )
    {
        if ( m_ColsCount>=0 && m_RowsCount>=0 && (m_ColsCount>0 || m_RowsCount>0) )
        {
            preview->CreateGrid( m_RowsCount, m_ColsCount );
            SetupWindow( preview, flags );

            preview->EnableEditing( !m_ReadOnly);
            preview->EnableGridLines( m_GridLines );

            if ( m_LabelRowHeight > 0 ) preview->SetColLabelSize( m_LabelRowHeight );
            if ( m_LabelColWidth  > 0 ) preview->SetRowLabelSize( m_LabelColWidth );

            if ( m_DefaultRowSize > 0 ) preview->SetDefaultRowSize( m_DefaultRowSize, true );
            if ( m_DefaultColSize > 0 ) preview->SetDefaultColSize( m_DefaultColSize, true );

            wxColour cc = m_LabelTextColour.GetColour();
            if ( cc.IsOk() )
            {
                preview->SetLabelTextColour(cc);
            }

            wxFont labelfont = m_LabelFont.BuildFont();
            if ( labelfont.IsOk() )
            {
                preview->SetLabelFont( labelfont );
            }

            int n = wxMin( (int)m_ColLabels.GetCount(), m_ColsCount );
            for ( int i=0; i<n; i++ )
            {
                preview->SetColLabelValue( i, m_ColLabels[i] );
            }

            n = wxMin( (int)m_RowLabels.GetCount(), m_RowsCount );
            for( int i=0; i<n; i++ )
            {
                preview->SetRowLabelValue( i, m_RowLabels[i] );
            }

            n = (int)m_CellText.GetCount();
            int i = 0;
            for ( int j=0; j<m_RowsCount && i<n; j++ )
            {
                for ( int k=0; k<m_ColsCount && i<n; k++, i++ )
                {
                    preview->SetCellValue( j, k, m_CellText[i] );
                }
            }

            wxFont cellfont = preview->GetFont();
            if ( cellfont.IsOk() )
            {
                preview->SetDefaultCellFont(cellfont);
            }

            cc = preview->GetForegroundColour();
            preview->SetDefaultCellTextColour(cc);

        }
    }

    return preview;
}