コード例 #1
0
ファイル: objectbase.cpp プロジェクト: heyuqi/wxFormBuilder
void ObjectBase::Serialize( ticpp::Document* serializedDocument )
{
	ticpp::Document document( "document" );

  #if wxUSE_UNICODE
	ticpp::Declaration dec( "1.0", "UTF-8", "yes" );
	#else
	ticpp::Declaration dec( "1.0", "ISO-8859-13", "yes" );
	#endif
	document.LinkEndChild( &dec );

	ticpp::Element root( "wxFormBuilder_Project" );

	ticpp::Element fileVersion( "FileVersion" );
	fileVersion.SetAttribute( "major", AppData()->m_fbpVerMajor );
	fileVersion.SetAttribute( "minor", AppData()->m_fbpVerMinor );

	root.LinkEndChild( &fileVersion );

	ticpp::Element element;
	SerializeObject( &element );

	root.LinkEndChild( &element );
	document.LinkEndChild( &root );

	*serializedDocument = document;
}
コード例 #2
0
ファイル: dataobject.cpp プロジェクト: heyuqi/wxFormBuilder
wxFBDataObject::wxFBDataObject( PObjectBase obj )
:
wxDataObject()
{
	if ( obj )
	{
		// create xml representation of ObjectBase
		ticpp::Element element;
		obj->SerializeObject( &element );

		// add version info to xml data, just in case it is pasted into a different version of wxFB
		element.SetAttribute( "fbp_version_major", AppData()->m_fbpVerMajor );
		element.SetAttribute( "fbp_version_minor", AppData()->m_fbpVerMinor );

		ticpp::Document doc;
		doc.LinkEndChild( &element );
		TiXmlPrinter printer;
        printer.SetIndent( "\t" );

        #if defined( __WXMSW__ )
            printer.SetLineBreak( "\r\n" );
        #else
            printer.SetLineBreak( "\n" );
        #endif

        doc.Accept( &printer );
		m_data = printer.Str();
	}
}
コード例 #3
0
ファイル: palette.cpp プロジェクト: joro75/wxFormBuilder
void wxFbPalette::OnSpinDown( wxSpinEvent& )
{
#if wxVERSION_NUMBER < 2900
	int page = m_notebook->GetSelection();
	if ( m_posVector[page] <= 0 ) return;

	m_posVector[page]--;
	wxToolBar *toolbar = m_tv[page];
	PObjectPackage pkg = AppData()->GetPackage( page );
	wxString widget( pkg->GetObjectInfo( m_posVector[page] )->GetClassName() );
	wxBitmap icon = pkg->GetObjectInfo( m_posVector[page] )->GetIconFile();

	#ifdef __WXMAC__
		wxBitmapButton* button = new wxBitmapButton( toolbar, nextId++, icon );
		button->SetToolTip( widget );
		toolbar->InsertControl( 0, button );
	#else
        #if wxVERSION_NUMBER < 2900
            toolbar->InsertTool( 0, nextId++, icon, wxNullBitmap, false, NULL, widget, widget );
        #else
            toolbar->InsertTool( 0, nextId++, widget, icon );
        #endif
	#endif

	toolbar->Realize();
#endif
}
コード例 #4
0
ファイル: visualeditor.cpp プロジェクト: noriter/wxfb
VisualEditor::VisualEditor(wxWindow *parent)
    :
    wxScrolledWindow(parent,-1,wxDefaultPosition,wxDefaultSize,wxSUNKEN_BORDER),
    m_stopSelectedEvent( false ),
    m_stopModifiedEvent( false )
{
    SetExtraStyle( wxWS_EX_BLOCK_EVENTS );

    AppData()->AddHandler( this->GetEventHandler() );

#ifdef __WXMSW__
    SetOwnBackgroundColour(wxColour(150,150,150));
#else
    SetOwnBackgroundColour(wxColour(192,192,192));
#endif

    SetScrollRate(5, 5);

    m_back = new DesignerWindow( this, wxID_ANY, wxPoint(10,10) );
    m_back->GetEventHandler()->Connect( wxID_ANY, wxEVT_LEFT_DOWN, wxMouseEventHandler( VisualEditor::OnClickBackPanel ), NULL, this );

    m_auimgr = NULL;
    m_auipanel = NULL;

    // scan aui panes in run-time
    m_AuiScaner.SetOwner( this, ID_TIMER_SCAN );
    m_AuiScaner.Start( 200 );

    m_wizard = NULL;
}
コード例 #5
0
ファイル: visualeditor.cpp プロジェクト: miquik/mkdb
void VisualEditor::OnClickBackPanel( wxMouseEvent& event )
{
	if ( m_form )
	{
		AppData()->SelectObject(m_form);
	}
	event.Skip();
}
コード例 #6
0
ファイル: visualeditor.cpp プロジェクト: noriter/wxfb
void VisualEditor::OnWizardPageChanged( WizardEvent &event )
{
    int i = event.GetInt();
    if ( !i )
    {
        AppData()->GetManager()->SelectObject( event.GetPage() );
        return;
    }
    event.Skip();
}
コード例 #7
0
ファイル: visualeditor.cpp プロジェクト: noriter/wxfb
VisualEditor::~VisualEditor()
{
    m_AuiScaner.Stop();

    AppData()->RemoveHandler( this->GetEventHandler() );
    DeleteAbstractObjects();

    ClearAui();
    ClearWizard();
    ClearComponents( m_back->GetFrameContentPanel() );
}
コード例 #8
0
ファイル: maingui.cpp プロジェクト: marekr/wxFormBuilder
void MyApp::MacOpenFile(const wxString &fileName)
{
    if(m_frame == NULL) m_mac_file_name = fileName;
    else
    {
        if(!m_frame->SaveWarning()) return;

        if ( AppData()->LoadProject( fileName ) )
            m_frame->InsertRecentProject( fileName );
    }
}
コード例 #9
0
ファイル: objectbase.cpp プロジェクト: idrassi/wxFormBuilder
TiXmlDocument* ObjectBase::Serialize()
{
	TiXmlDocument *document = new TiXmlDocument("document");

	TiXmlDeclaration* dec = new TiXmlDeclaration("1.0", "UTF-8", "yes");
	document->LinkEndChild( dec );

	TiXmlElement* root = new TiXmlElement( "wxFormBuilder_Project" );

	TiXmlElement* fileVersion = new TiXmlElement( "FileVersion" );
	fileVersion->SetAttribute( "major", AppData()->m_fbpVerMajor );
	fileVersion->SetAttribute( "minor", AppData()->m_fbpVerMinor );

	root->LinkEndChild( fileVersion );

	TiXmlElement *element = SerializeObject();
	root->LinkEndChild(element);
	document->LinkEndChild(root);
	return document;
}
コード例 #10
0
ファイル: codegen.cpp プロジェクト: joro75/wxFormBuilder
void TemplateParser::ParseLuaTable()
{
	PObjectBase project = PObjectBase(new ObjectBase(*AppData()->GetProjectData()));
	PProperty propNs= project->GetProperty( wxT( "ui_table" ) );
	if ( propNs )
	{
		wxString strTableName = propNs->GetValueAsString();
		if(strTableName.length() <= 0)
			strTableName = wxT("UI");
		m_out <<strTableName + wxT(".");
	}
}
コード例 #11
0
ファイル: palette.cpp プロジェクト: idrassi/wxFormBuilder
void wxFbPalette::OnButtonClick(wxCommandEvent &event)
{
  for (unsigned int i = 0; i < m_tv.size(); i++)
  {
    if (m_tv[i]->FindById(event.GetId()))
    {
      wxString name = m_tv[i]->GetToolShortHelp(event.GetId());
      AppData()->CreateObject(name);
      return;
    }
  }
}
コード例 #12
0
ファイル: palette.cpp プロジェクト: idrassi/wxFormBuilder
void wxFbPalette::OnSpinUp(wxSpinEvent& e)
{
  int page = m_notebook->GetSelection();
  PObjectPackage pkg = AppData()->GetPackage(page);

  if ((int)pkg->GetObjectCount() - m_posVector[page] - 1 <= 0) return;

  m_posVector[page]++;
  wxToolBar *toolbar = m_tv[page];
  toolbar->DeleteToolByPos(0);
  toolbar->Realize();
}
コード例 #13
0
ファイル: visualeditor.cpp プロジェクト: miquik/mkdb
void VisualEditor::OnResizeBackPanel (wxCommandEvent &) //(wxSashEvent &event)
{
	/*wxRect rect(event.GetDragRect());
	Debug::Print("VisualEditor::OnResizeBackPanel [%d,%d,%d,%d]",rect.x,rect.y,rect.width, rect.height);
	m_back->SetSize(rect.width,rect.height);
	m_back->Layout();*/

	PObjectBase form (AppData()->GetSelectedForm());

	if (form)
	{
		PProperty prop(form->GetProperty( wxT("size") ));
		if (prop)
		{
			wxString value(TypeConv::PointToString(wxPoint(m_back->GetSize().x, m_back->GetSize().y)));
			AppData()->ModifyProperty(prop, value);
		}
	}

	//event.Skip();
}
コード例 #14
0
ファイル: palette.cpp プロジェクト: idrassi/wxFormBuilder
void wxFbPalette::OnSpinDown(wxSpinEvent& e)
{
  int page = m_notebook->GetSelection();
  if (m_posVector[page] <= 0) return;

  m_posVector[page]--;
  wxToolBar *toolbar = m_tv[page];
  PObjectPackage pkg = AppData()->GetPackage(page);
  wxString widget( pkg->GetObjectInfo( m_posVector[page] )->GetClassName() );
  wxBitmap icon = pkg->GetObjectInfo(m_posVector[page])->GetIconFile();
  toolbar->InsertTool(0, nextId++, icon, wxNullBitmap, false, NULL, widget, widget);
  toolbar->Realize();
}
コード例 #15
0
ファイル: palette.cpp プロジェクト: joro75/wxFormBuilder
void wxFbPalette::OnButtonClick( wxCommandEvent &event )
{
	#ifdef __WXMAC__
		wxWindow* win = dynamic_cast< wxWindow* >( event.GetEventObject() );
		if ( win != 0 )
		{
			AppData()->CreateObject( win->GetToolTip()->GetTip() );
		}
	#else
		for ( unsigned int i = 0; i < m_tv.size(); i++ )
		{
			#if wxVERSION_NUMBER >= 2900
			if ( m_tv[i]->GetToolIndex( event.GetId() ) != wxNOT_FOUND )
			#else
			if ( m_tv[i]->FindById( event.GetId() ) )
			#endif
			{
				wxString name = m_tv[i]->GetToolShortHelp( event.GetId() );
				AppData()->CreateObject( name );
				return;
			}
		}
	#endif
}
コード例 #16
0
ファイル: visualeditor.cpp プロジェクト: miquik/mkdb
VisualEditor::VisualEditor(wxWindow *parent)
:
wxScrolledWindow(parent,-1,wxDefaultPosition,wxDefaultSize,wxSUNKEN_BORDER),
m_stopSelectedEvent( false ),
m_stopModifiedEvent( false )
{
	AppData()->AddHandler( this->GetEventHandler() );

	#ifdef __WXMSW__
		SetOwnBackgroundColour(wxColour(150,150,150));
	#else
		SetOwnBackgroundColour(wxColour(192,192,192));
	#endif

	SetScrollRate(5, 5);

	m_back = new DesignerWindow( this, wxID_ANY, wxPoint(10,10) );
	m_back->GetEventHandler()->Connect( wxID_ANY, wxEVT_LEFT_DOWN, wxMouseEventHandler( VisualEditor::OnClickBackPanel ), NULL, this );
}
コード例 #17
0
ファイル: dataobject.cpp プロジェクト: heyuqi/wxFormBuilder
PObjectBase wxFBDataObject::GetObj()
{
	if ( m_data.empty() )
	{
		return PObjectBase();
	}

	// Read Object from xml
	try
	{
		ticpp::Document doc;
		doc.Parse( m_data, true, TIXML_ENCODING_UTF8 );
		ticpp::Element* element = doc.FirstChildElement();


		int major, minor;
		element->GetAttribute( "fbp_version_major", &major );
		element->GetAttribute( "fbp_version_minor", &minor );

		if ( major > AppData()->m_fbpVerMajor || ( AppData()->m_fbpVerMajor == major && minor > AppData()->m_fbpVerMinor ) )
		{
			wxLogError( _("This object cannot be pasted because it is from a newer version of wxFormBuilder") );
		}

		if ( major < AppData()->m_fbpVerMajor || ( AppData()->m_fbpVerMajor == major && minor < AppData()->m_fbpVerMinor ) )
		{
			AppData()->ConvertObject( element, major, minor );
		}

		PObjectDatabase db = AppData()->GetObjectDatabase();
		return db->CreateObject( element );
	}
	catch( ticpp::Exception& ex )
	{
		wxLogError( _WXSTR( ex.m_details ) );
		return PObjectBase();
	}
}
コード例 #18
0
ファイル: palette.cpp プロジェクト: idrassi/wxFormBuilder
void wxFbPalette::Create()
{
  wxBoxSizer *top_sizer = new wxBoxSizer(wxVERTICAL);

  m_notebook = new ChooseNotebook( this, -1 );

  unsigned int pkg_count = AppData()->GetPackageCount();

  Debug::Print( wxT("[Palette] Pages %d"),pkg_count);

  // Populate icon vector
  for (unsigned int j = 0; j < pkg_count;j++)
  {
	PObjectPackage pkg = AppData()->GetPackage(j);
	m_icons.Add( pkg->GetPackageIcon() );
  }

  // Add icons to notebook
  m_notebook->SetImageList( &m_icons );

  for (unsigned int i = 0; i < pkg_count;i++)
  {
    PObjectPackage pkg = AppData()->GetPackage(i);
    wxString pkg_name = pkg->GetPackageName();

    wxPanel *panel = new wxPanel(m_notebook,-1);
	panel->SetBackgroundColour( wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE) );
    wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);

    wxPanel *tbPanel = new wxPanel(panel,-1);
	tbPanel->SetBackgroundColour( wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE) );
    wxBoxSizer *tbSizer = new wxBoxSizer(wxHORIZONTAL);

    wxPanel *sbPanel = new wxPanel(panel,-1);
	sbPanel->SetBackgroundColour( wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE) );
    wxBoxSizer *sbSizer = new wxBoxSizer(wxHORIZONTAL);

    wxToolBar *toolbar = new wxToolBar(tbPanel, -1, wxDefaultPosition, wxDefaultSize, wxTB_NODIVIDER | wxTB_FLAT);
    toolbar->SetToolBitmapSize(wxSize(22, 22));
	toolbar->SetBackgroundColour( wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE) );
    PopulateToolbar(pkg, toolbar);
    m_tv.push_back(toolbar);

    tbSizer->Add(toolbar, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL);
    tbPanel->SetSizer(tbSizer);

    wxSpinButton *sb = new wxSpinButton(sbPanel, -1, wxDefaultPosition, wxDefaultSize, wxSP_HORIZONTAL);
    sb->SetRange(0, (int)pkg->GetObjectCount() - 1);
    sb->SetValue(0);
    m_posVector.push_back(0);
    sbSizer->Add(sb, 0, wxEXPAND);//wxALL | wxALIGN_TOP, 0);
    sbPanel->SetSizer(sbSizer);

    sizer->Add(tbPanel,1,wxEXPAND, 0);
    sizer->Add(sbPanel,0,wxEXPAND, 0);
    panel->SetAutoLayout(true);
    panel->SetSizer(sizer);
    sizer->Fit(panel);
    sizer->SetSizeHints(panel);

    m_notebook->AddPage(panel, pkg_name, false, i);

  }
  Title *title = new Title( this, wxT("Component Palette") );
  top_sizer->Add(title,0,wxEXPAND,0);
  //top_sizer->Add(new wxFlatNotebookSizer(m_notebook),1,wxEXPAND,0);
  top_sizer->Add(m_notebook,1,wxEXPAND,0);
  SetAutoLayout(true);
  SetSizer(top_sizer);
  top_sizer->Fit(this);
  top_sizer->SetSizeHints(this);
}
コード例 #19
0
ファイル: phpcg.cpp プロジェクト: heyuqi/wxFormBuilder
/**
* Convert the value of the property to PHP code
*/
wxString PHPTemplateParser::ValueToCode( PropertyType type, wxString value )
{
	wxString result;

	switch ( type )
	{
	case PT_WXPARENT:
		{
			result = wxT("$this->") + value;
			break;
		}
	case PT_WXPARENT_SB:
		{
			result = wxT("$") + value + wxT("->GetStaticBox()");
			break;
		}
	case PT_WXSTRING:
	case PT_FILE:
	case PT_PATH:
		{
			if ( value.empty() )
			{
				result << wxT("wxEmptyString");
			}
			else
			{
				result << wxT("\"") << PHPCodeGenerator::ConvertPHPString( value ) << wxT("\"");
			}
			break;
		}
	case PT_WXSTRING_I18N:
		{
			if ( value.empty() )
			{
				result << wxT("wxEmptyString");
			}
			else
			{
				if ( m_i18n )
				{
					result << wxT("_(\"") << PHPCodeGenerator::ConvertPHPString(value) << wxT("\")");
				}
				else
				{
					result << wxT("\"") << PHPCodeGenerator::ConvertPHPString(value) << wxT("\"");
				}
			}
			break;
		}
	case PT_CLASS:
	case PT_MACRO:
	case PT_OPTION:
	case PT_EDIT_OPTION:
		{
			result = value;
			break;
		}
	case PT_TEXT:
	case PT_FLOAT:
	case PT_INT:
	case PT_UINT:
		{
			result = value;
			break;
		}
	case PT_BITLIST:
		{
			result = ( value.empty() ? wxT("0") : value );

			wxString pred, bit;
			wxStringTokenizer bits( result, wxT("|"), wxTOKEN_STRTOK );

			while( bits.HasMoreTokens() )
			{
				bit = bits.GetNextToken();
				pred = m_predModulePrefix[bit];

				/*if( bit.Contains( wxT("wx") ) )
				{
					if( !pred.empty() )	result.Replace( bit, pred + bit.AfterFirst('x') );
					else
						result.Replace( bit, wxT("wx") + bit.AfterFirst('x') );
				}*/
			}
			break;
		}
	case PT_WXPOINT:
		{
			if ( value.empty() )
			{
				result = wxT("wxDefaultPosition");
			}
			else
			{
				result << wxT("new wxPoint( ") << value << wxT(" )");
			}
			break;
		}
	case PT_WXSIZE:
		{
			if ( value.empty() )
			{
				result = wxT("wxDefaultSize");
			}
			else
			{
				result << wxT("new wxSize( ") << value << wxT(" )");
			}
			break;
		}
	case PT_BOOL:
		{
			result = ( value == wxT("0") ? wxT("false") : wxT("true") );
			break;
		}
	case PT_WXFONT:
		{
			if ( !value.empty() )
			{
				 wxFontContainer fontContainer = TypeConv::StringToFont( value );
				 wxFont font = fontContainer.GetFont();

				 const int pointSize = fontContainer.GetPointSize();

				 result = wxString::Format( "new wxFont( %s, %s, %s, %s, %s, %s )",
							 ((pointSize <= 0) ? "wxC2D(wxNORMAL_FONT)->GetPointSize()" : (wxString() << pointSize)),
							 TypeConv::FontFamilyToString( fontContainer.GetFamily() ),
							 font.GetStyleString(),
							 font.GetWeightString(),
							 ( fontContainer.GetUnderlined() ? "true" : "false" ),
							 ( fontContainer.m_faceName.empty() ? "wxEmptyString" : ("\"" + fontContainer.m_faceName + "\"") )
						 );
			}
			else
			{
				result = "wxC2D(wxNORMAL_FONT)";
			}
			break;
		}
		case PT_WXCOLOUR:
		{
			if ( !value.empty() )
			{
				if ( value.find_first_of( wxT("wx") ) == 0 )
				{
					// System Colour
					result << wxT("wxSystemSettings::GetColour( ") << ValueToCode( PT_OPTION, value ) << wxT(" )");
				}
				else
				{
					wxColour colour = TypeConv::StringToColour( value );
					result = wxString::Format( wxT("new wxColour( %i, %i, %i )"), colour.Red(), colour.Green(), colour.Blue() );
				}
			}
			else
			{
				result = wxT("new wxColour()");
			}
			break;
		}
	case PT_BITMAP:
		{
			wxString path;
			wxString source;
			wxSize icoSize;
			TypeConv::ParseBitmapWithResource( value, &path, &source, &icoSize );

			if ( path.empty() )
			{
				// Empty path, generate Null Bitmap
				result = wxT("wxNullBitmap");
				break;
			}

			if ( path.StartsWith( wxT("file:") ) )
			{
				wxLogWarning( wxT("PHP code generation does not support using URLs for bitmap properties:\n%s"), path.c_str() );
				result = wxT("wxNullBitmap");
				break;
			}

			if ( source == wxT("Load From File") )
			{
				wxString absPath;
				try
				{
					absPath = TypeConv::MakeAbsolutePath( path, AppData()->GetProjectPath() );
				}
				catch( wxFBException& ex )
				{
					wxLogError( ex.what() );
					result = wxT( "wxNullBitmap" );
					break;
				}

				wxString file = ( m_useRelativePath ? TypeConv::MakeRelativePath( absPath, m_basePath ) : absPath );

				result << wxT("new wxBitmap( \"") << PHPCodeGenerator::ConvertPHPString( file ) << wxT("\", wxBITMAP_TYPE_ANY )");
			}
			else if ( source == _("Load From Embedded File") )
			{
				result << wxT( "wxNullBitmap /* embedded files aren't supported */" );
			}
			else if ( source == wxT("Load From Resource") )
			{
				result << wxT("new wxBitmap( \"") << path << wxT("\", wxBITMAP_TYPE_RESOURCE )");
			}
			else if ( source == wxT("Load From Icon Resource") )
			{
				if ( wxDefaultSize == icoSize )
				{
					result << wxT("new wxICON( ") << path << wxT(" )");
				}
				else
				{
					result.Printf( wxT("new wxIcon( \"%s\", wxBITMAP_TYPE_ICO_RESOURCE, %i, %i )"), path.c_str(), icoSize.GetWidth(), icoSize.GetHeight() );
				}
			}
			else if ( source == _("Load From Art Provider") )
			{
				wxString rid = path.BeforeFirst( wxT(':') );
				if( rid.StartsWith( wxT("gtk-") ) ) rid = wxT("wxT(\"") + rid + wxT("\")");

				result = wxT("wxArtProvider::GetBitmap( ") + rid + wxT(", ") +  path.AfterFirst( wxT(':') ) + wxT(" )");
			}
			break;

			break;
		}
	case PT_STRINGLIST:
		{
			// Stringlists are generated like a sequence of wxString separated by ', '.
			wxArrayString array = TypeConv::StringToArrayString( value );
			if ( array.Count() > 0 )
			{
				result = ValueToCode( PT_WXSTRING_I18N, array[0] );
			}

			for ( size_t i = 1; i < array.Count(); i++ )
			{
				result << wxT(", ") << ValueToCode( PT_WXSTRING_I18N, array[i] );
			}
			break;
		}
	default:
		break;
	}

	return result;
}
コード例 #20
0
ファイル: palette.cpp プロジェクト: joro75/wxFormBuilder
void wxFbPalette::Create()
{
	wxBoxSizer *top_sizer = new wxBoxSizer( wxVERTICAL );

#ifdef USE_FLATNOTEBOOK
	long nbStyle;
	wxConfigBase* config = wxConfigBase::Get();
	config->Read( wxT( "/palette/notebook_style" ), &nbStyle, wxFNB_NO_X_BUTTON | wxFNB_NO_NAV_BUTTONS | DRAG_OPTION | wxFNB_DROPDOWN_TABS_LIST  | wxFNB_VC8 | wxFNB_CUSTOM_DLG );

	m_notebook = new wxFlatNotebook( this, -1, wxDefaultPosition, wxDefaultSize, FNB_STYLE_OVERRIDES( nbStyle ) );
	m_notebook->SetCustomizeOptions( wxFNB_CUSTOM_TAB_LOOK | wxFNB_CUSTOM_ORIENTATION | wxFNB_CUSTOM_LOCAL_DRAG );
#else
	m_notebook = new wxAuiNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_NB_TOP | wxAUI_NB_SCROLL_BUTTONS );
	m_notebook->SetArtProvider( new AuiTabArt() );
#endif

	unsigned int pkg_count = AppData()->GetPackageCount();

	LogDebug( wxT( "[Palette] Pages %d" ), pkg_count );

#ifdef USE_FLATNOTEBOOK
	// Populate icon vector
	for ( unsigned int j = 0; j < pkg_count;j++ )
	{
		PObjectPackage pkg = AppData()->GetPackage( j );
		m_icons.Add( pkg->GetPackageIcon() );
	}

	// Add icons to notebook
	m_notebook->SetImageList( &m_icons );
#else
	wxSize minsize;
#endif

	for ( unsigned int i = 0; i < pkg_count;i++ )
	{
		PObjectPackage pkg = AppData()->GetPackage( i );
		wxString pkg_name = pkg->GetPackageName();

		wxPanel *panel = new wxPanel( m_notebook, -1 );
		//panel->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DFACE ) );
		wxBoxSizer *sizer = new wxBoxSizer( wxHORIZONTAL );

#if wxVERSION_NUMBER >= 2900
		wxAuiToolBar *toolbar = new wxAuiToolBar( panel, -1, wxDefaultPosition, wxDefaultSize, wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_OVERFLOW | wxNO_BORDER );
		toolbar->SetToolBitmapSize( wxSize( 22, 22 ) );
		PopulateToolbar( pkg, toolbar );
		m_tv.push_back( toolbar );

		sizer->Add( toolbar, 1, wxEXPAND, 0 );
#else
		wxPanel *tbPanel = new wxPanel( panel, -1 );
		//tbPanel->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DFACE ) );
		wxBoxSizer *tbSizer = new wxBoxSizer( wxHORIZONTAL );

		wxPanel *sbPanel = new wxPanel( panel, -1 );
		//sbPanel->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DFACE ) );
		wxBoxSizer *sbSizer = new wxBoxSizer( wxHORIZONTAL );

		wxToolBar *toolbar = new wxToolBar( tbPanel, -1, wxDefaultPosition, wxDefaultSize, wxTB_NODIVIDER | wxTB_FLAT );
		toolbar->SetToolBitmapSize( wxSize( 22, 22 ) );
		//toolbar->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DFACE ) );
		PopulateToolbar( pkg, toolbar );
		m_tv.push_back( toolbar );

		tbSizer->Add( toolbar, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL );
		tbPanel->SetSizer( tbSizer );

		wxSpinButton *sb = new wxSpinButton( sbPanel, -1, wxDefaultPosition, wxDefaultSize, wxSP_HORIZONTAL );
		sb->SetRange( 0, ( int )pkg->GetObjectCount() - 1 );
		sb->SetValue( 0 );
		m_posVector.push_back( 0 );
		sbSizer->Add( sb, 0, wxEXPAND );//wxALL | wxALIGN_TOP, 0);
		sbPanel->SetSizer( sbSizer );

		sizer->Add( tbPanel, 1, wxEXPAND, 0 );
		sizer->Add( sbPanel, 0, wxEXPAND, 0 );
#endif

		panel->SetAutoLayout( true );
		panel->SetSizer( sizer );
		sizer->Fit( panel );
		sizer->SetSizeHints( panel );

#ifndef USE_FLATNOTEBOOK
		wxSize cursize = panel->GetSize();
		if( cursize.x > minsize.x ) minsize.x = cursize.x;
		if( cursize.y > minsize.y ) minsize.y = cursize.y + 30;
#endif

		m_notebook->AddPage( panel, pkg_name, false, i );
#ifndef USE_FLATNOTEBOOK
		m_notebook->SetPageBitmap( i, pkg->GetPackageIcon() );
#endif

	}
	//Title *title = new Title( this, wxT("Component Palette") );
	//top_sizer->Add(title,0,wxEXPAND,0);
#ifdef USE_FLATNOTEBOOK
	top_sizer->Add( m_notebook, 1, wxEXPAND, 0 );
	SetAutoLayout( true );
	SetSizer( top_sizer );
	top_sizer->Fit( this );
	top_sizer->SetSizeHints( this );
#else
	top_sizer->Add( m_notebook, 1, wxEXPAND, 0 );
	SetSizer( top_sizer );
	SetSize( minsize );
	SetMinSize( minsize );
	Layout();
	Fit();
#endif
}
コード例 #21
0
ファイル: visualeditor.cpp プロジェクト: miquik/mkdb
void VisualEditor::OnObjectSelected( wxFBObjectEvent &event )
{
	// It is only necessary to Create() if the selected object is on a different form
	if ( AppData()->GetSelectedForm() != m_form )
	{
		Create();
	}

	// Get the ObjectBase from the event
	PObjectBase obj = event.GetFBObject();
	if ( !obj )
	{
		// Strange...
		Debug::Print( wxT("The event object is NULL - why?") );
		return;
	}

	// Make sure this is a visible object
	ObjectBaseMap::iterator it = m_baseobjects.find( obj.get() );
	if ( m_baseobjects.end() == it )
	{
		m_back->SetSelectedSizer( NULL );
		m_back->SetSelectedItem( NULL );
		m_back->SetSelectedObject( PObjectBase() );
		m_back->SetSelectedPanel( NULL );
		m_back->Refresh();
		return;
	}

	// Save wxobject
	wxObject* item = it->second;

	int componentType = COMPONENT_TYPE_ABSTRACT;
	IComponent *comp = obj->GetObjectInfo()->GetComponent();
	if ( comp )
	{
		componentType = comp->GetComponentType();

		// Fire selection event in plugin
		if ( !m_stopSelectedEvent )
		{
			comp->OnSelected( item );
		}
	}

	if ( componentType != COMPONENT_TYPE_WINDOW && componentType != COMPONENT_TYPE_SIZER )
	{
		item = NULL;
	}

	// Fire selection event in plugin for all parents
	if ( !m_stopSelectedEvent )
	{
		PObjectBase parent = obj->GetParent();
		while ( parent )
		{
			IComponent* parentComp = parent->GetObjectInfo()->GetComponent();
			if ( parentComp )
			{
				ObjectBaseMap::iterator parentIt = m_baseobjects.find( parent.get() );
				if ( parentIt != m_baseobjects.end() )
				{
					parentComp->OnSelected( parentIt->second );
				}
			}
			parent = parent->GetParent();
		}
	}

	// Look for the active panel - this is where the boxes will be drawn during OnPaint
	// This is the closest parent of type COMPONENT_TYPE_WINDOW
	PObjectBase nextParent = obj->GetParent();
	while ( nextParent )
	{
		IComponent* parentComp = nextParent->GetObjectInfo()->GetComponent();
		if ( !parentComp )
		{
			nextParent.reset();
			break;
		}

		if ( parentComp->GetComponentType() == COMPONENT_TYPE_WINDOW )
		{
			break;
		}

		nextParent = nextParent->GetParent();
	}

	// Get the panel to draw on
	wxWindow* selPanel = NULL;
	if ( nextParent )
	{
		it = m_baseobjects.find( nextParent.get() );
		if ( m_baseobjects.end() == it )
		{
			selPanel = m_back->GetFrameContentPanel();
		}
		else
		{
			selPanel = wxDynamicCast( it->second, wxWindow );
		}
	}
	else
	{
		selPanel = m_back->GetFrameContentPanel();
	}

	// Find the first COMPONENT_TYPE_WINDOW or COMPONENT_TYPE_SIZER
	// If it is a sizer, save it
	wxSizer* sizer = NULL;
	PObjectBase nextObj = obj->GetParent();
	while ( nextObj )
	{
		IComponent* nextComp = nextObj->GetObjectInfo()->GetComponent();
		if ( !nextComp )
		{
			break;
		}

		if ( nextComp->GetComponentType() == COMPONENT_TYPE_SIZER )
		{
			it = m_baseobjects.find( nextObj.get() );
			if ( it != m_baseobjects.end() )
			{
				sizer = wxDynamicCast( it->second, wxSizer );
			}
			break;
		}
		else if ( nextComp->GetComponentType() == COMPONENT_TYPE_WINDOW )
		{
			break;
		}

		nextObj = nextObj->GetParent();
	}

  m_back->SetSelectedSizer( sizer );
	m_back->SetSelectedItem( item );
	m_back->SetSelectedObject( obj );
	m_back->SetSelectedPanel( selPanel );
	m_back->Refresh();
}
コード例 #22
0
ファイル: visualeditor.cpp プロジェクト: miquik/mkdb
/**
* Crea la vista preliminar borrando la previa.
*/
void VisualEditor::Create()
{
	if ( IsShown() )
	{
		Freeze(); // Prevent flickering
	}

	// Delete objects which had no parent
	DeleteAbstractObjects();

	// Clear selections, delete objects
	m_back->SetSelectedItem(NULL);
	m_back->SetSelectedSizer(NULL);
	m_back->SetSelectedObject(PObjectBase());
	ClearComponents( m_back->GetFrameContentPanel() );
	m_back->GetFrameContentPanel()->DestroyChildren();
	m_back->GetFrameContentPanel()->SetSizer( NULL ); // *!*

	// Clear all associations between ObjectBase and wxObjects
	m_wxobjects.clear();
	m_baseobjects.clear();

	m_form = AppData()->GetSelectedForm();
	if ( m_form )
	{
		m_back->Show(true);

		// --- [1] Configure the size of the form ---------------------------

		// Get size properties
		wxSize minSize( m_form->GetPropertyAsSize( wxT("minimum_size") ) );
		m_back->SetMinSize( minSize );

		wxSize maxSize( m_form->GetPropertyAsSize( wxT("maximum_size") ) );
		m_back->SetMaxSize( maxSize );

		wxSize size( m_form->GetPropertyAsSize( wxT("size") ) );

		// Determine necessary size for back panel
		wxSize backSize = size;
		if ( backSize.GetWidth() < minSize.GetWidth() && backSize.GetWidth() != wxDefaultCoord )
		{
			backSize.SetWidth( minSize.GetWidth() );
		}
		if ( backSize.GetHeight() < minSize.GetHeight() && backSize.GetHeight() != wxDefaultCoord )
		{
			backSize.SetHeight( minSize.GetHeight() );
		}
		if ( backSize.GetWidth() > maxSize.GetWidth() && maxSize.GetWidth() != wxDefaultCoord )
		{
			backSize.SetWidth( maxSize.GetWidth() );
		}
		if ( backSize.GetHeight() > maxSize.GetHeight() && maxSize.GetHeight() != wxDefaultCoord )
		{
			backSize.SetHeight( maxSize.GetHeight() );
		}

		// Modify size property to match
		if ( size != backSize )
		{
			PProperty psize = m_form->GetProperty( wxT("size") );
			if ( psize )
			{
				AppData()->ModifyProperty( psize, TypeConv::SizeToString( backSize ) );
			}
		}

		// --- [2] Set the color of the form -------------------------------
		PProperty background( m_form->GetProperty( wxT("bg") ) );
		if ( background && !background->GetValue().empty() )
		{
			m_back->GetFrameContentPanel()->SetBackgroundColour( TypeConv::StringToColour( background->GetValue() ) );
		}
		else
		{
			if ( m_form->GetClassName() == wxT("Frame") )
			{
				m_back->GetFrameContentPanel()->SetOwnBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_APPWORKSPACE ) );
			}
			else
			{
				m_back->GetFrameContentPanel()->SetOwnBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
			}
		}


		// --- [3] Title bar Setup
		if (  m_form->GetClassName() == wxT("Frame") || m_form->GetClassName() == wxT("Dialog") )
		{
			m_back->SetTitle( m_form->GetPropertyAsString( wxT("title") ) );
			long style = m_form->GetPropertyAsInteger( wxT("style") );
			m_back->SetTitleStyle( style );
			m_back->ShowTitleBar( (style & wxCAPTION) != 0 );
		}
		else
		  m_back->ShowTitleBar(false);

		// --- [4] Create the components of the form -------------------------

		// Used to save frame objects for later display
		PObjectBase menubar;
		wxWindow* statusbar = NULL;
		wxWindow* toolbar = NULL;

		for ( unsigned int i = 0; i < m_form->GetChildCount(); i++ )
		{
			PObjectBase child = m_form->GetChild( i );

			if (child->GetObjectTypeName() == wxT("menubar") )
			{
				// Create the menubar later
				menubar = child;
			}
			else
			{
				// Recursively generate the ObjectTree
				try
				{
				  // we have to put the content frame panel as parentObject in order
				  // to SetSizeHints be called.
					Generate( child, m_back->GetFrameContentPanel(), m_back->GetFrameContentPanel() );
				}
				catch ( wxFBException& ex )
				{
					wxLogError ( ex.what() );
				}
			}

			// Attach the status bar (if any) to the frame
			if ( child->GetClassName() == wxT("wxStatusBar") )
			{
				ObjectBaseMap::iterator it = m_baseobjects.find( child.get() );
				statusbar = wxDynamicCast( it->second, wxStatusBar );
			}

			// Attach the toolbar (if any) to the frame
			if (child->GetClassName() == wxT("wxToolBar") )
			{
				ObjectBaseMap::iterator it = m_baseobjects.find( child.get() );
				toolbar = wxDynamicCast( it->second, wxToolBar );
			}
		}

		if ( menubar || statusbar || toolbar )
		{
			m_back->SetFrameWidgets( menubar, toolbar, statusbar );
		}

		m_back->Layout();

		if ( backSize.GetHeight() == wxDefaultCoord || backSize.GetWidth() == wxDefaultCoord )
		{
		    m_back->GetSizer()->Fit( m_back );
			m_back->SetSize( m_back->GetBestSize() );
		}

		// Set size after fitting so if only one dimesion is -1, it still fits that dimension
		m_back->SetSize( backSize );

		PProperty enabled( m_form->GetProperty( wxT("enabled") ) );
		if ( enabled )
		{
			m_back->Enable( TypeConv::StringToInt( enabled->GetValue() ) != 0 );
		}

		PProperty hidden( m_form->GetProperty( wxT("hidden") ) );
		if ( hidden )
		{
			m_back->Show( TypeConv::StringToInt( hidden->GetValue() ) == 0 );
		}
	}
	else
	{
		// There is no form to display
		m_back->Show(false);
	}

	if ( IsShown() )
	{
		Thaw();
	}

	UpdateVirtualSize();
}
コード例 #23
0
ファイル: maingui.cpp プロジェクト: marekr/wxFormBuilder
int MyApp::OnRun()
{
    // Using a space so the initial 'w' will not be capitalized in wxLogGUI dialogs
    wxApp::SetAppName( wxT( " wxFormBuilder" ) );

    // Creating the wxConfig manually so there will be no space
    // The old config (if any) is returned, delete it
    delete wxConfigBase::Set( new wxConfig( wxT("wxFormBuilder") ) );

    // Get the data directory
    wxStandardPathsBase& stdPaths = wxStandardPaths::Get();
    wxString dataDir = stdPaths.GetDataDir();
    dataDir.Replace( GetAppName().c_str(), wxT("wxformbuilder") );

    // Log to stderr while working on the command line
    delete wxLog::SetActiveTarget( new wxLogStderr );

    // Message output to the same as the log target
    delete wxMessageOutput::Set( new wxMessageOutputLog );

    // Parse command line
    wxCmdLineParser parser( s_cmdLineDesc, argc, argv );
    if ( 0 != parser.Parse() )
    {
        return 1;
    }

    // Get project to load
    wxString projectToLoad = wxEmptyString;
    if ( parser.GetParamCount() > 0 )
    {
        projectToLoad = parser.GetParam();
    }

    bool justGenerate = false;
    wxString language;
    bool hasLanguage = parser.Found( wxT("l"), &language );
    if ( parser.Found( wxT("g") ) )
    {
        if ( projectToLoad.empty() )
        {
            wxLogError( _("You must pass a path to a project file. Nothing to generate.") );
            return 2;
        }

        if ( hasLanguage )
        {
            if ( language.empty() )
            {
                wxLogError( _("Empty language option. Nothing generated.") );
                return 3;
            }
            language.Replace( wxT(","), wxT("|"), true );
        }

        // generate code
        justGenerate = true;
    }
    else
    {
        delete wxLog::SetActiveTarget( new wxLogGui );
    }

    // Create singleton AppData - wait to initialize until sure that this is not the second
    // instance of a project file.
    AppDataCreate( dataDir );

    // Make passed project name absolute
    try
    {
        if ( !projectToLoad.empty() )
        {
            wxFileName projectPath( projectToLoad );
            if ( !projectPath.IsOk() )
            {
                THROW_WXFBEX( wxT("This path is invalid: ") << projectToLoad );
            }

            if ( !projectPath.IsAbsolute() )
            {
                if ( !projectPath.MakeAbsolute() )
                {
                    THROW_WXFBEX( wxT("Could not make path absolute: ") << projectToLoad );
                }
            }
            projectToLoad = projectPath.GetFullPath();
        }
    }
    catch ( wxFBException& ex )
    {
        wxLogError( ex.what() );
    }

    // If the project is already loaded in another instance, switch to that instance and quit
    if ( !projectToLoad.empty() && !justGenerate )
    {
        if ( ::wxFileExists( projectToLoad ) )
        {
            if ( !AppData()->VerifySingleInstance( projectToLoad ) )
            {
                return 4;
            }
        }
    }

    // Init handlers
    wxInitAllImageHandlers();
    wxXmlResource::Get()->InitAllHandlers();
#if wxVERSION_NUMBER >= 2905
    wxXmlResource::Get()->AddHandler(new wxAuiNotebookXmlHandler);
#endif

    // Init AppData
    try
    {
        AppDataInit();
    }
    catch( wxFBException& ex )
    {
        wxLogError( _("Error loading application: %s\nwxFormBuilder cannot continue."),	ex.what() );
        wxLog::FlushActive();
        return 5;
    }

    wxSystemOptions::SetOption( wxT( "msw.remap" ), 0 );
    wxSystemOptions::SetOption( wxT( "msw.staticbox.optimized-paint" ), 0 );

    m_frame = NULL;

#ifndef __WXFB_DEBUG__
    wxBitmap bitmap;
    std::unique_ptr< cbSplashScreen > splash;
    if ( !justGenerate )
    {
        if ( bitmap.LoadFile( dataDir + wxFILE_SEP_PATH + wxT( "resources" ) + wxFILE_SEP_PATH + wxT( "splash.png" ), wxBITMAP_TYPE_PNG ) )
        {
            splash = std::unique_ptr< cbSplashScreen >( new cbSplashScreen( bitmap, -1, 0, wxNewId() ) );
        }
    }
#endif

    wxYield();

    // Read size and position from config file
    wxConfigBase *config = wxConfigBase::Get();
    config->SetPath( wxT("/mainframe") );
    int x, y, w, h;
    x = y = w = h = -1;
    config->Read( wxT( "PosX" ), &x );
    config->Read( wxT( "PosY" ), &y );
    config->Read( wxT( "SizeW" ), &w );
    config->Read( wxT( "SizeH" ), &h );

    long style = config->Read( wxT("style"), wxFB_WIDE_GUI );
    if ( style != wxFB_CLASSIC_GUI )
    {
        style = wxFB_WIDE_GUI;
    }

    config->SetPath( wxT("/") );

    m_frame = new MainFrame( NULL ,-1, (int)style, wxPoint( x, y ), wxSize( w, h ) );
    if ( !justGenerate )
    {
        m_frame->Show( TRUE );
        SetTopWindow( m_frame );

#ifndef __WXFB_DEBUG__
        // turn off the splash screen
        delete splash.release();
#endif

#ifdef __WXFB_DEBUG__
        wxLogWindow* log = dynamic_cast< wxLogWindow* >( AppData()->GetDebugLogTarget() );
        if ( log )
        {
            m_frame->AddChild( log->GetFrame() );
        }
#endif //__WXFB_DEBUG__
    }

    // This is not necessary for wxFB to work. However, Windows sets the Current Working Directory
    // to the directory from which a .fbp file was opened, if opened from Windows Explorer.
    // This puts an unneccessary lock on the directory.
    // This changes the CWD to the already locked app directory as a workaround
#ifdef __WXMSW__
    ::wxSetWorkingDirectory( dataDir );
#endif

    if ( !projectToLoad.empty() )
    {
        if ( AppData()->LoadProject( projectToLoad, justGenerate ) )
        {
            if ( justGenerate )
            {
                if ( hasLanguage )
                {
                    PObjectBase project = AppData()->GetProjectData();
                    PProperty codeGen = project->GetProperty( _("code_generation") );
                    if ( codeGen )
                    {
                        codeGen->SetValue( language );
                    }
                }
                AppData()->GenerateCode( false, true );
                return 0;
            }
            else
            {
                m_frame->InsertRecentProject( projectToLoad );
                return wxApp::OnRun();
            }
        }
        else
        {
            wxLogError( wxT("Unable to load project: %s"), projectToLoad.c_str() );
        }
    }

    if ( justGenerate )
    {
        return 6;
    }

    AppData()->NewProject();

#ifdef __WXMAC__
    // document to open on startup
    if(!m_mac_file_name.IsEmpty())
    {
        if ( AppData()->LoadProject( m_mac_file_name ) )
            m_frame->InsertRecentProject( m_mac_file_name );
    }
#endif

    return wxApp::OnRun();
}
コード例 #24
0
ファイル: visualeditor.cpp プロジェクト: miquik/mkdb
VisualEditor::~VisualEditor()
{
	AppData()->RemoveHandler( this->GetEventHandler() );
	DeleteAbstractObjects();
	ClearComponents( m_back->GetFrameContentPanel() );
}
コード例 #25
0
ファイル: visualeditor.cpp プロジェクト: noriter/wxfb
void VisualEditor::ScanPanes( wxWindow* parent)
{
    bool updateNeeded;

    wxLogNull stopTheLogging;
    const wxWindowList& children = parent->GetChildren();
    for ( wxWindowList::const_reverse_iterator child = children.rbegin(); child != children.rend(); ++child )
    {
        ScanPanes(*child);

        PObjectBase obj = GetObjectBase( *child );

        if ( obj )
        {
            updateNeeded = false;

            PObjectInfo obj_info = obj->GetObjectInfo();
            wxString cname = obj_info->GetObjectType()->GetName();

            if( cname == wxT("widget") ||
                    cname == wxT("expanded_widget") ||
                    cname == wxT("toolbar") ||
                    cname == wxT("container") )
            {
                wxAuiPaneInfo inf = m_auimgr->GetPane(*child);
                if(inf.IsOk())
                {
                    // scan position and docking mode
                    if( !obj->GetPropertyAsInteger( wxT("center_pane") ) )
                    {
                        wxString dock;
                        if( inf.IsDocked())
                        {
                            wxString dockDir;
                            switch(inf.dock_direction)
                            {
                            case 1:
                                dockDir = wxT("Top");
                                break;

                            case 2:
                                dockDir = wxT("Right");
                                break;

                            case 3:
                                dockDir = wxT("Bottom");
                                break;

                            case 4:
                                dockDir = wxT("Left");
                                break;

                            case 5:
                                dockDir = wxT("Center");
                                break;

                            default:
                                dockDir = wxT("Left");
                                break;
                            }
                            PProperty pdock = obj->GetProperty( wxT("docking") );

                            if( pdock->GetValue() != dockDir )
                            {
                                pdock->SetValue( dockDir );
                                updateNeeded = true;
                            }

                            dock = wxT("Dock");
                        }
                        else
                        {
                            // scan "floating position"
                            wxPoint pos = inf.floating_pos;
                            if ( pos.x != -1 && pos.y != -1 )
                            {
                                PProperty pposition = obj->GetProperty( wxT("pane_position") );
                                if( pposition->GetValue() != TypeConv::PointToString( pos ) )
                                {
                                    pposition->SetValue( TypeConv::PointToString( pos ) );
                                    updateNeeded = true;
                                }
                            }

                            // scan "floating size"
                            wxSize paneSize = inf.floating_size;
                            if ( paneSize.x != -1 && paneSize.y != -1 )
                            {
                                PProperty psize = obj->GetProperty( wxT("pane_size") );

                                if( psize->GetValue() != TypeConv::SizeToString( paneSize ) )
                                {
                                    psize->SetValue( TypeConv::SizeToString( paneSize )  );
                                    obj->GetProperty( wxT("resize") )->SetValue( wxT("Resizable") );

                                    updateNeeded = true;
                                }
                            }

                            dock = wxT("Float");
                        }
                        PProperty pfloat = obj->GetProperty(wxT("dock") );
                        if( pfloat->GetValue() != dock )
                        {
                            pfloat->SetValue( dock );
                            updateNeeded = true;
                        }

                        // scan "best size"
                        /*wxSize bestSize = inf.best_size;
                        if ( bestSize.x != -1 && bestSize.y != -1 )
                        {
                        	PProperty psize = obj->GetProperty( wxT("best_size") );

                        	if( psize->GetValue() != TypeConv::SizeToString( bestSize ) )
                        	{
                        		psize->SetValue( TypeConv::SizeToString( bestSize )  );
                        		obj->GetProperty( wxT("resize") )->SetValue( wxT("Resizable") );

                        		updateNeeded = true;
                        	}
                        }*/

                        // scan "row" and "layer"
                        PProperty prop = obj->GetProperty(wxT("aui_row") );
                        if( obj->GetPropertyAsInteger( wxT("aui_row") ) != inf.dock_row )
                        {
                            prop->SetValue( inf.dock_row );
                            updateNeeded = true;
                        }
                        prop = obj->GetProperty(wxT("aui_layer") );
                        if( obj->GetPropertyAsInteger( wxT("aui_layer") ) != inf.dock_layer )
                        {
                            prop->SetValue( inf.dock_layer );
                            updateNeeded = true;
                        }
                    }

                    // scan "show" property
                    PProperty pshow = obj->GetProperty(wxT("show") );
                    if( obj->GetPropertyAsInteger( wxT("show") ) != (int) inf.IsShown() )
                    {
                        pshow->SetValue( inf.IsShown() );
                        updateNeeded = true;
                    }

                    if( updateNeeded ) AppData()->SelectObject( obj, true, true );
                }
            }
        }
    }

}
コード例 #26
0
ファイル: visualeditor.cpp プロジェクト: noriter/wxfb
/**
* Crea la vista preliminar borrando la previa.
*/
void VisualEditor::Create()
{
#if wxVERSION_NUMBER < 2900 && !defined(__WXGTK__ )
    if ( IsShown() )
    {
        Freeze();   // Prevent flickering on wx 2.8,
        // Causes problems on wx 2.9 in wxGTK (e.g. wxNoteBook objects)
    }
#endif
    // Delete objects which had no parent
    DeleteAbstractObjects();

    // Clear selections, delete objects
    m_back->SetSelectedItem(NULL);
    m_back->SetSelectedSizer(NULL);
    m_back->SetSelectedObject(PObjectBase());

    ClearAui();
    ClearWizard();
    ClearComponents( m_back->GetFrameContentPanel() );

    m_back->GetFrameContentPanel()->DestroyChildren();
    m_back->GetFrameContentPanel()->SetSizer( NULL ); // *!*

    // Clear all associations between ObjectBase and wxObjects
    m_wxobjects.clear();
    m_baseobjects.clear();

    if( IsShown() )
    {
        m_form = AppData()->GetSelectedForm();
        if ( m_form )
        {
            m_back->Show(true);

            // --- [1] Configure the size of the form ---------------------------

            // Get size properties
            wxSize minSize( m_form->GetPropertyAsSize( wxT("minimum_size") ) );
            m_back->SetMinSize( minSize );

            wxSize maxSize( m_form->GetPropertyAsSize( wxT("maximum_size") ) );
            m_back->SetMaxSize( maxSize );

            wxSize size( m_form->GetPropertyAsSize( wxT("size") ) );

            // Determine necessary size for back panel
            wxSize backSize = size;
            if ( backSize.GetWidth() < minSize.GetWidth() && backSize.GetWidth() != wxDefaultCoord )
            {
                backSize.SetWidth( minSize.GetWidth() );
            }
            if ( backSize.GetHeight() < minSize.GetHeight() && backSize.GetHeight() != wxDefaultCoord )
            {
                backSize.SetHeight( minSize.GetHeight() );
            }
            if ( backSize.GetWidth() > maxSize.GetWidth() && maxSize.GetWidth() != wxDefaultCoord )
            {
                backSize.SetWidth( maxSize.GetWidth() );
            }
            if ( backSize.GetHeight() > maxSize.GetHeight() && maxSize.GetHeight() != wxDefaultCoord )
            {
                backSize.SetHeight( maxSize.GetHeight() );
            }

            // Modify size property to match
            if ( size != backSize )
            {
                PProperty psize = m_form->GetProperty( wxT("size") );
                if ( psize )
                {
                    AppData()->ModifyProperty( psize, TypeConv::SizeToString( backSize ) );
                }
            }

            // --- [2] Set the color of the form -------------------------------
            PProperty background( m_form->GetProperty( wxT("bg") ) );
            if ( background && !background->GetValue().empty() )
            {
                m_back->GetFrameContentPanel()->SetBackgroundColour( TypeConv::StringToColour( background->GetValue() ) );
            }
            else
            {
                if ( m_form->GetClassName() == wxT("Frame") )
                {
                    m_back->GetFrameContentPanel()->SetOwnBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_APPWORKSPACE ) );
                }
                else
                {
#ifdef __WXGTK__
                    wxVisualAttributes attribs = wxToolBar::GetClassDefaultAttributes();
                    m_back->GetFrameContentPanel()->SetOwnBackgroundColour( attribs.colBg );
#else
                    m_back->GetFrameContentPanel()->SetOwnBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
#endif
                }
            }

            // --- [3] Title bar Setup
            if (  m_form->GetClassName() == wxT("Frame")  ||
                    m_form->GetClassName() == wxT("Dialog") ||
                    m_form->GetClassName() == wxT("Wizard") )
            {
                m_back->SetTitle( m_form->GetPropertyAsString( wxT("title") ) );
                long style = m_form->GetPropertyAsInteger( wxT("style") );
                m_back->SetTitleStyle( style );
                m_back->ShowTitleBar( (style & wxCAPTION) != 0 );
            }
            else
                m_back->ShowTitleBar(false);

            // --- AUI
            if(  m_form->GetObjectTypeName() == wxT("form") )
            {
                if(  m_form->GetPropertyAsInteger( wxT("aui_managed") ) == 1)
                {
                    m_auipanel = new wxPanel( m_back->GetFrameContentPanel() );
                    m_auimgr = new wxAuiManager( m_auipanel, m_form->GetPropertyAsInteger( wxT("aui_manager_style") ) );
                }
            }

            // --- Wizard
            if ( m_form->GetClassName() == wxT("Wizard") )
            {
                m_wizard = new Wizard( m_back->GetFrameContentPanel() );

                bool showbutton = false;
                PProperty pextra_style = m_form->GetProperty( wxT("extra_style") );
                if ( pextra_style )
                {
                    showbutton = pextra_style->GetValue().Contains( wxT("wxWIZARD_EX_HELPBUTTON") );
                }

                m_wizard->ShowHelpButton( showbutton );

                if ( !m_form->GetProperty( wxT("bitmap") )->IsNull() )
                {
                    wxBitmap bmp = m_form->GetPropertyAsBitmap( wxT("bitmap") );
                    if ( bmp.IsOk() )
                    {
                        m_wizard->SetBitmap( bmp );
                    }
                }
            }

            // --- [4] Create the components of the form -------------------------

            // Used to save frame objects for later display
            PObjectBase menubar;
            wxWindow* statusbar = NULL;
            wxWindow* toolbar = NULL;

            for ( unsigned int i = 0; i < m_form->GetChildCount(); i++ )
            {
                PObjectBase child = m_form->GetChild( i );

                if( !menubar && (m_form->GetObjectTypeName() == wxT("menubar_form")) )
                {
                    // main form acts as a menubar
                    menubar = m_form;
                }
                else if (child->GetObjectTypeName() == wxT("menubar") )
                {
                    // Create the menubar later
                    menubar = child;
                }
                else if( !toolbar && (m_form->GetObjectTypeName() == wxT("toolbar_form")) )
                {
                    Generate( m_form, m_back->GetFrameContentPanel(), m_back->GetFrameContentPanel() );

                    ObjectBaseMap::iterator it = m_baseobjects.find( m_form.get() );
                    toolbar = wxDynamicCast( it->second, wxToolBar );

                    break;
                }
                else
                {
                    // Recursively generate the ObjectTree
                    try
                    {
                        // we have to put the content frame panel as parentObject in order
                        // to SetSizeHints be called.
                        if( m_auipanel )
                        {
                            Generate( child, m_auipanel, m_auipanel );
                        }
                        else if( m_wizard )
                        {
                            Generate( child, m_wizard, m_wizard );
                        }
                        else
                            Generate( child, m_back->GetFrameContentPanel(), m_back->GetFrameContentPanel() );

                    }
                    catch ( wxFBException& ex )
                    {
                        wxLogError ( ex.what() );
                    }
                }

                // Attach the toolbar (if any) to the frame
                if (child->GetClassName() == wxT("wxToolBar") )
                {
                    ObjectBaseMap::iterator it = m_baseobjects.find( child.get() );
                    toolbar = wxDynamicCast( it->second, wxToolBar );
                }
                else if (child->GetClassName() == wxT("wxAuiToolBar") )
                {
                    ObjectBaseMap::iterator it = m_baseobjects.find( child.get() );
                    toolbar = wxDynamicCast( it->second, wxAuiToolBar );
                }

                // Attach the status bar (if any) to the frame
                if ( child->GetClassName() == wxT("wxStatusBar") )
                {
                    ObjectBaseMap::iterator it = m_baseobjects.find( child.get() );
                    statusbar = wxDynamicCast( it->second, wxStatusBar );
                }

                // Add toolbar(s) to AuiManager and update content
                if( m_auimgr && toolbar )
                {
                    SetupAui( GetObjectBase( toolbar ), toolbar );
                    toolbar = NULL;
                }
            }

            if ( menubar || statusbar || toolbar || m_auipanel || m_wizard )
            {
                if( m_auimgr )
                {
                    m_back->SetFrameWidgets( menubar, NULL, statusbar, m_auipanel );
                }
                else if( m_wizard )
                {
                    m_back->SetFrameWidgets( menubar, NULL, NULL, m_wizard );
                }
                else
                    m_back->SetFrameWidgets( menubar, toolbar, statusbar, m_auipanel );
            }

            m_back->Layout();

            if ( backSize.GetHeight() == wxDefaultCoord || backSize.GetWidth() == wxDefaultCoord )
            {
                m_back->GetSizer()->Fit( m_back );
                m_back->SetSize( m_back->GetBestSize() );
            }

            // Set size after fitting so if only one dimesion is -1, it still fits that dimension
            m_back->SetSize( backSize );

            if( m_auimgr ) m_auimgr->Update();
            else
                m_back->Refresh();

            PProperty enabled( m_form->GetProperty( wxT("enabled") ) );
            if ( enabled )
            {
                m_back->Enable( TypeConv::StringToInt( enabled->GetValue() ) != 0 );
            }

            PProperty hidden( m_form->GetProperty( wxT("hidden") ) );
            if ( hidden )
            {
                m_back->Show( TypeConv::StringToInt( hidden->GetValue() ) == 0 );
            }
        }
        else
        {
            // There is no form to display
            m_back->Show(false);
            Refresh();
        }
#if wxVERSION_NUMBER < 2900 && !defined(__WXGTK__)
        Thaw();
#endif
    }

    UpdateVirtualSize();
}