Esempio n. 1
0
bool wxMySQL::CreateRecordset(wxString query, wxMySQLRecordset * result)
{	
	if(result->IsOk())
	{		
		if(!result->Close())
		{
			m_LastErrorMessage = result->GetLastErrorMessage();
			return false;
		}
	}
	printf("MYSQL_STMT_INIT\r\n");
	MYSQL_STMT * stmt = mysql_stmt_init(m_pDB);
	if(!stmt)
	{
		m_LastErrorMessage = mysql_error(m_pDB);
		wxLogTrace(wxTraceMask(), "CreateRecordset error !stmt -> %s", m_LastErrorMessage);
		return false;
	}
	printf("MYSQL_STMT_PREPARE\r\n");
	if (mysql_stmt_prepare(stmt, query, (unsigned long)query.Length()))
	{
		m_LastErrorMessage = mysql_stmt_error(stmt);		
		wxLogTrace(wxTraceMask(), "CreateRecordset mysql_stmt_prepare error -> %s", m_LastErrorMessage);
		return false;
	}	
	result->SetHandle(stmt);		
	return true;
}
Esempio n. 2
0
bool wxFlatNotebook::InsertPage(size_t index, wxWindow* page, const wxString& text, bool select, const int imgindex)
{
	// sanity check
	if (!page)
		return false;

	// reparent the window to us
	page->Reparent(this);

	if( !m_pages->IsShown() )
		m_pages->Show();

	index = FNB_MIN((unsigned int)index, (unsigned int)m_windows.GetCount());
	// Insert tab
	bool bSelected = select || m_windows.empty();
	int curSel = m_pages->GetSelection();

	if(index <= m_windows.GetCount())
	{
		m_windows.Insert(page, index);
		wxLogTrace(wxTraceMask(), wxT("New page inserted. Index = %i"), index);
	}
	else
	{
		m_windows.Add(page);
		wxLogTrace(wxTraceMask(), wxT("New page appended. Index = %i"), index);
	}

	if( !m_pages->InsertPage(index, page, text, bSelected, imgindex) )
		return false;

	if((int)index <= curSel) curSel++;

	Freeze();

	// Check if a new selection was made
	if(bSelected)
	{
		if(curSel >= 0)
		{
			// Remove the window from the main sizer
			m_mainSizer->Detach(m_windows[curSel]);
			m_windows[curSel]->Hide();
		}
		m_pages->SetSelection(index);
	}
	else
	{
		// Hide the page
		page->Hide();
	}
	m_mainSizer->Layout();
	Thaw();
	Refresh();

	return true;
}
bool wxJigsawEditorCanvas::CreateDragImage(wxJigsawShape * shape)
{
	DestroyDragImage();
	do
	{
		if(!m_View || !shape) break;
		double scale = m_View->GetScale();
		wxSize shapeSize = shape->GetSize();
		wxBitmap bmp(shapeSize.GetWidth() * scale, shapeSize.GetHeight() * scale);
		wxMemoryDC mdc(bmp);
		wxFont font = GetFont();
		font.SetPointSize(font.GetPointSize()*m_View->GetScale());
		mdc.SetFont(font);
		mdc.SetBackground(wxBrush(wxColour(255, 0, 255)));
		mdc.Clear();
		mdc.SetPen(*wxBLACK_PEN);
		//mdc.DrawRectangle(0, 0, bmp.GetWidth(), bmp.GetHeight());
		wxSize offset(-shape->GetPosition().x*scale, -shape->GetPosition().y*scale);
		wxLogTrace(wxTraceMask(), _("DragShape offset = (%i,%i)"), 
			offset.GetWidth(), offset.GetHeight());
		wxPoint oldPos = shape->GetPosition();
		shape->SetPosition(wxPoint(0,0));
		shape->RequestSizeRecalculation();
		shape->Draw(mdc, wxSize(0,0), m_View->GetScale());
		shape->RequestSizeRecalculation();
		shape->SetPosition(oldPos);
		mdc.SelectObject(wxNullBitmap);
		bmp.SetMask(new wxMask(bmp, wxColour(255, 0, 255)));
		m_DragImage = new wxDragImage(bmp);
		return true;
	}
	while(false);
	return false;
}
void wxJigsawEditorCanvas::OnScrollThumbRelease(wxScrollWinEvent & event)
{
	wxLogTrace(wxTraceMask(), _("wxJigsawEditorCanvas::OnScrollThumbRelease; ScrollPos = %i"),
		event.GetPosition());
	SetScrollPos(event.GetOrientation(), event.GetPosition());
	FixViewOffset();
	RefreshBuffer();
}
void wxJigsawEditorCanvas::OnScrollPageDown(wxScrollWinEvent & event)
{
	wxLogTrace(wxTraceMask(), _("wxJigsawEditorCanvas::OnScrollPageDown;"));
	SetScrollPos(event.GetOrientation(), 
		GetScrollPos(event.GetOrientation()) + GetScrollThumb(event.GetOrientation()));
	FixViewOffset();
	RefreshBuffer();
}
void wxJigsawEditorCanvas::OnScrollLineDown(wxScrollWinEvent & event)
{
	wxLogTrace(wxTraceMask(), _("wxJigsawEditorCanvas::OnScrollLineDown;"));
	int increment = wxJigsawEditorCanvas::ScrollIncrement;
	SetScrollPos(event.GetOrientation(), GetScrollPos(event.GetOrientation()) + increment);
	FixViewOffset();
	RefreshBuffer();
}
void wxJigsawEditorMainFrame::OnCategorySelected(wxCommandEvent & event)
{
	wxJigsawShapeList * shapes = wxDynamicCast(event.GetClientData(), wxJigsawShapeList);
	if(shapes)
	{
		wxLogTrace(wxTraceMask(), _("%i shapes"), shapes->GetCount());
		m_Palette->SetShapes(shapes);
		m_Palette->Refresh();
		m_Palette->AdjustScrollBars();
	}
}
void wxJigsawEditorDocument::ReCreateHotSpots(wxDC & dc, wxJigsawHotSpotArray & hotSpots, 
		wxJigsawShapeGroup * groupToSkip, double scale)
{
	hotSpots.Clear();
	for(wxJigsawShapeGroupList::Node * node = GetGroups().GetFirst(); node; node = node->GetNext())
	{
		wxJigsawShapeGroup * group = node->GetData();
		if(!group || (group == groupToSkip)) continue;
		group->ReCreateHotSpots(dc, hotSpots, scale);
	}
	wxLogTrace(wxTraceMask(), 
		_("wxJigsawEditorDocument::ReCreateHotSpots; Count =  %i"), 
		hotSpots.GetCount());
}
bool wxJigsawEditorDocument::OnSaveDocument(const wxString& filename)
{
	wxLogTrace(wxTraceMask(), wxT("wxJigsawEditorDocument::OnSaveDocument"));
	do
	{
		m_XmlIO.SerializeToXml(filename, xsWITH_ROOT);

		Modify(false);
#ifdef __WXMAC__
		wxFileName fn(filename) ;
		fn.MacSetDefaultTypeAndCreator() ;
#endif
	}
	while(false);
    return true;
}
wxJigsawEditorCanvas::wxJigsawEditorCanvasHitTest wxJigsawEditorCanvas::HitTest(const wxPoint & pos, 
		wxJigsawShape::wxJigsawShapeHitTestInfo & info,
		wxJigsawShapeGroup * ignoreGroup)
{
	do
	{
		wxPoint realPoint = PointToViewPoint(pos);
		wxLogTrace(wxTraceMask(), _("wxJigsawEditorCanvas::HitTest - (%i,%i)"),
			realPoint.x, realPoint.y);
		wxJigsawShape * shape = m_View->GetShapeFromPoint(m_DoubleBufferDC, realPoint, info, ignoreGroup);
		if(!shape) break;
		return wxJSEC_HITTEST_SHAPE;
	}
	while(false);
	return wxJSEC_HITTEST_NONE;
}
bool wxJigsawEditorDocument::OnOpenDocument(const wxString& filename)
{
	wxLogTrace(wxTraceMask(), wxT("wxJigsawEditorDocument::OnOpenDocument"));
    do
	{
		m_XmlIO.DeserializeFromXml(filename);

		SetFilename(filename, true);
		Modify(false);
		m_Diagram->UpdateParents();
		//UpdateAllViews();
		//return true;
		break;
	}
	while(false);
    return true;
}
Esempio n. 12
0
void wxJigsawShape::ReCreateHotSpots(wxDC & dc, wxJigsawHotSpotArray & hotSpots, double scale)
{
	wxSize size = GetSize(dc, scale);
	wxSize headerSize = GetHeaderSize(dc, scale);
	wxPoint parameterPos = GetinputParametersPosition(dc, scale);
	if(m_Style == wxJigsawShapeStyle::wxJS_TYPE_NONE)
	{
		if(m_HasNotch)
		{
			hotSpots.Add(wxJigsawHotSpot(this,
				wxRect(m_Position.x, 
					m_Position.y-(wxJigsawShape::HotSpotHeight/2)*scale,
					headerSize.GetWidth(), 
					wxJigsawShape::HotSpotHeight*scale),
				wxJigsawHotSpotType::wxJS_HOTSPOT_BUMP));
		}
		if(m_HasBump)
		{
			int a = (m_Position.x);
			int b = m_Position.y+size.GetHeight()-wxJigsawShape::HotSpotHeight/2* scale;
			wxLogTrace(wxTraceMask(), _("Notch Hotspot: Position=(%i,%i); Size=(%i,%i)"),
				a, b,
				headerSize.GetWidth(), 
				(int)(wxJigsawShape::HotSpotHeight * scale));
			hotSpots.Add(wxJigsawHotSpot(this,
				wxRect(m_Position.x, 
					m_Position.y+size.GetHeight()-wxJigsawShape::HotSpotHeight/2* scale,
					headerSize.GetWidth(), 
					wxJigsawShape::HotSpotHeight * scale),
				wxJigsawHotSpotType::wxJS_HOTSPOT_NOTCH));
		}
		if(m_HasCShape)
		{
			if(!m_Children.GetCount())
			{
				hotSpots.Add(wxJigsawHotSpot(this,
					wxRect(m_Position.x+wxJigsawShape::CShapeThickness*scale, 
						m_Position.y+headerSize.GetHeight()+wxJigsawShape::ConnectorSize.GetHeight()*scale-1,
						headerSize.GetWidth()-wxJigsawShape::CShapeThickness*scale, 
						wxJigsawShape::HotSpotHeight*scale),
					wxJigsawHotSpotType::wxJS_HOTSPOT_NOTCH));				
			}
			else
			{
				for(wxJigsawShapeList::Node * node = m_Children.GetFirst(); node; node = node->GetNext())
				{
					wxJigsawShape * child = node->GetData();
					if(!child) continue;
					child->ReCreateHotSpots(dc, hotSpots, scale);
				}
			}
		}
	}

	if(m_InputParameters.GetCount())
	{
		int paramRectOffset = GetParametersOffset(scale);
		wxRect paramRect(GetPosition(), headerSize);
		paramRect.Offset(paramRectOffset, 0);
		int index = 0;
		int slotOffset = 0;
		int paramTop = -1;
		for(wxJigsawInputParameters::Node * node = m_InputParameters.GetFirst();
			node; node = node->GetNext(), index++)
		{
			wxJigsawInputParameter * param = node->GetData();

			//Hotspot size
			//paramRect.SetWidth(param->GetSize().GetWidth());
						
			paramRect.SetSize(param->GetSize());			
			paramTop = (headerSize.GetHeight() - paramRect.GetHeight())/2 + GetPosition().y;
			paramRect.SetTop(paramTop);

			slotOffset = param->GetSlotOffset(scale);
			if(!param->GetShape())
			{
				hotSpots.Add(wxJigsawHotSpot(this, 
					wxRect(paramRect.GetLeft()+slotOffset, 
					paramRect.GetTop(),
					paramRect.GetWidth()-slotOffset,
					paramRect.GetHeight()),					
					wxJigsawHotSpotType::wxJS_HOTSPOT_INPUT_PARAMETER, index));
			}
			param->ReCreateHotSpots(dc, hotSpots, scale);
			paramRect.Offset(paramRect.GetWidth() + wxJigsawInputParameter::ParameterSpacing, 0);
		}
	}
}
Esempio n. 13
0
wxDragResult wxPageContainer::OnDropTarget(wxCoord x, wxCoord y, int nTabPage, wxWindow * wnd_oldContainer)
{
	// Disable drag'n'drop for disabled tab
	if(!((wxPageContainer *)wnd_oldContainer)->m_pagesInfoVec[nTabPage].GetEnabled())
		return wxDragCancel;

#if wxVERSION_NUMBER < 2900
	wxLogTrace(wxTraceMask(), _("Old Page Index = %i"), nTabPage);
#endif

	wxPageContainer * oldContainer = (wxPageContainer *)wnd_oldContainer;
	int nIndex = -1;
	wxPageInfo pgInfo;
	int where = HitTest(wxPoint(x, y), pgInfo, nIndex);

#if wxVERSION_NUMBER < 2900
	wxLogTrace(wxTraceMask(), _("OnDropTarget: index by HitTest = %i"), nIndex);
#endif

	wxFlatNotebook * oldNotebook = (wxFlatNotebook *)oldContainer->GetParent();
	wxFlatNotebook * newNotebook = (wxFlatNotebook *)GetParent();

	if(oldNotebook == newNotebook)
	{
		if(nTabPage >= 0)
		{
			switch(where)
			{
			case wxFNB_TAB:
				MoveTabPage(nTabPage, nIndex);
				break;
			case wxFNB_NOWHERE:
				{
				}
				break;
			default:
				break;
			}
		}
	}
	else if ( GetParent()->GetWindowStyleFlag() & wxFNB_ALLOW_FOREIGN_DND )
	{
#if defined(__WXMSW__) || defined(__WXGTK__)
		if(nTabPage >= 0)
		{
			wxWindow * window = oldNotebook->GetPage(nTabPage);
			if(window)
			{
				wxString caption = oldContainer->GetPageText(nTabPage);

				// Pass the image to the new container
				// incase that the new container (this) does not have image list we dont pass the image
				// to the new notebook
				int newIndx( wxNOT_FOUND );

				if( m_ImageList )
				{
					int imageindex = oldContainer->GetPageImageIndex(nTabPage);
					if( imageindex >= 0 )
					{
						wxBitmap bmp( (*oldContainer->GetImageList())[imageindex] );
						m_ImageList->Add( bmp );
						newIndx = static_cast<int>(m_ImageList->GetCount() - 1);
					}
				}

				oldNotebook->RemovePage( nTabPage );
				window->Reparent( newNotebook );
				newNotebook->InsertPage(nIndex, window, caption, true, newIndx);
			}
		}
#endif
	}
	return wxDragMove;
}
void wxJigsawEditorCanvas::OnMotion( wxMouseEvent& event )
{
	UpdateCursor(event.GetPosition());
	if(HasCapture())
	{
		if(event.GetPosition() != m_MouseDownPos && m_MouseDownPos != wxPoint(-1, -1) && m_SelectedShape)
		{
			do
			{
				if(!m_View) break;
				wxJigsawEditorDocument * document = GetDocument();
				if(!document) break;
				document->ReCreateHotSpots(m_DoubleBufferDC, m_HotSpots, NULL, m_View->GetScale());
				wxPoint diagramPoint = PointToViewPoint(m_MouseDownPos);
				wxLogTrace(wxTraceMask(), 
					_("wxJigsawEditorCanvas::OnLeftDown: Client Pos (%i, %i); View offset (%i, %i); Point (%i, %i)"),
					m_MouseDownPos.x, m_MouseDownPos.y,
					m_View->GetViewOffset().GetWidth(), m_View->GetViewOffset().GetHeight(),
					diagramPoint.x, diagramPoint.y);

				wxJigsawShapeGroup * group(NULL);
				group = document->GetShapeGroup(m_SelectedShape);
				if(!group)
				{
					group = document->CreateGroupByShape(m_DoubleBufferDC, m_SelectedShape);
				}
				else
				{
					// If it is not the first shape in a group
					if(group->GetShapes().IndexOf(m_SelectedShape) > 0)
					{
						// Then extract the shape and all shapes after it into separate group
						group = document->CreateGroupByShape(m_DoubleBufferDC, m_SelectedShape);
					}
				}

				if(!group) 
				{
					wxLogTrace(wxTraceMask(), _("Error obtaining group of shapes"));
					break;
				}
				else
				{
					m_View->BringToFront(group);
					wxPoint groupPosition = m_View->GetRealGroupPosition(group);
					m_SelectedObjectOffset = wxSize(
						diagramPoint.x - groupPosition.x,
						diagramPoint.y - groupPosition.y);
				}

				SetSelectedObject(group);
				document->ReCreateHotSpots(m_DoubleBufferDC, m_HotSpots, m_View->GetSelectedObject(), m_View->GetScale());
				FixActiveHotSpot(diagramPoint);
				m_Mode = wxJSEC_MODE_DRAGGING;

				RefreshBuffer();
				m_TR = m_BL = m_MouseDownPos;
				m_SelectionRect.SetPosition(m_MouseDownPos);
				m_SelectionRect.SetSize(wxSize(0,0));
			}
			while(false);

			m_MouseDownPos = wxPoint(-1, -1);
		}
		else
		{
			MotionUpdate(event.GetPosition());
		}
	}
}
void wxJigsawEditorMainFrame::CreateControls()
{    
	SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY);
////@begin wxJigsawEditorMainFrame content construction
    wxJigsawEditorMainFrame* itemDocParentFrame1 = this;

    GetAuiManager().SetManagedWindow(this);

#ifndef USE_WXPANEL_FOR_FRAME
    wxMenuBar* menuBar = new wxMenuBar;
    wxMenu* itemMenu3 = new wxMenu;
    itemMenu3->Append(wxID_NEW, _("New\tCtrl+N"), _T(""), wxITEM_NORMAL);
    itemMenu3->Append(wxID_OPEN, _("Open\tCtrl+O"), _T(""), wxITEM_NORMAL);
    itemMenu3->AppendSeparator();
    itemMenu3->Append(wxID_SAVE, _("Save\tCtrl+S"), _T(""), wxITEM_NORMAL);
    itemMenu3->Append(wxID_SAVEAS, _("Save as..."), _T(""), wxITEM_NORMAL);
    itemMenu3->AppendSeparator();
    itemMenu3->Append(wxID_EXIT, _("Exit\tAlt+F4"), _T(""), wxITEM_NORMAL);
    menuBar->Append(itemMenu3, _("Menu"));
    wxMenu* itemMenu11 = new wxMenu;
    itemMenu11->Append(wxID_ABOUT, _("About..."), _T(""), wxITEM_NORMAL);
    menuBar->Append(itemMenu11, _("Help"));
    itemDocParentFrame1->SetMenuBar(menuBar);

    wxStatusBar* itemStatusBar13 = new wxStatusBar( itemDocParentFrame1, ID_JIGSAW_EDITOR_MAIN_STATUSBAR, wxST_SIZEGRIP|wxNO_BORDER );
    itemStatusBar13->SetFieldsCount(2);
    itemDocParentFrame1->SetStatusBar(itemStatusBar13);
#endif

	wxPanel* itemPanel14 = new wxPanel( itemDocParentFrame1, ID_PALETTE_CONTAINER, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
    itemDocParentFrame1->GetAuiManager().AddPane(itemPanel14, wxAuiPaneInfo()
        .Name(_T("Palette")).MinSize(wxSize(250, -1)).BestSize(wxSize(220, -1)).CaptionVisible(false).CloseButton(false).DestroyOnClose(false).Resizable(true).Floatable(false));

    wxBoxSizer* itemBoxSizer15 = new wxBoxSizer(wxVERTICAL);
    itemPanel14->SetSizer(itemBoxSizer15);	

	//Zoom is not working very well. So, doesn't use it now.
	m_ScaleSlider = NULL;
    /*m_ScaleSlider = new wxSlider( itemPanel14, ID_SCALE_SLIDER, 0, 1, 500, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL );
    itemBoxSizer15->Add(m_ScaleSlider, 0, wxGROW, 5);*/

    /*wxArrayString itemChoice17Strings;
    wxChoice* itemChoice17 = new wxChoice( itemPanel14, ID_SHAPE_GROUP_CHOICE, wxDefaultPosition, wxDefaultSize, itemChoice17Strings, 0 );
    itemBoxSizer15->Add(itemChoice17, 0, wxGROW|wxALL, 5);*/

    wxStaticText* itemStaticText18 = new wxStaticText( itemPanel14, wxID_STATIC, _(""), wxDefaultPosition, wxDefaultSize, 0 );
    itemBoxSizer15->Add(itemStaticText18, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5);

    wxBoxSizer* itemBoxSizer19 = new wxBoxSizer(wxHORIZONTAL);
    itemBoxSizer15->Add(itemBoxSizer19, 0, wxGROW, 0);

    m_SearchTextCtrl = new wxTextCtrl( itemPanel14, ID_SEARCH_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
    itemBoxSizer19->Add(m_SearchTextCtrl, 1, wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP|wxBOTTOM, 5);


    wxButton* itemButton21 = new wxButton( itemPanel14, wxID_FIND, _("&Search"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );
    itemBoxSizer19->Add(itemButton21, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
	

    wxSplitterWindow* itemSplitterWindow22 = new wxSplitterWindow( itemPanel14, ID_SPLITTERWINDOW, wxDefaultPosition, wxSize(100, 10), wxSP_3DBORDER|wxSP_3DSASH|wxNO_BORDER|wxSP_LIVE_UPDATE );
    itemSplitterWindow22->SetMinimumPaneSize(0);


    m_CategoryList = new CategoryList( itemSplitterWindow22, ID_CATEGORY_LIST, wxDefaultPosition, wxSize(100, 10), wxSUNKEN_BORDER );
	

    m_Palette = new wxJigsawShapeListBox( itemSplitterWindow22, ID_PALETTE, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );

#ifdef USE_WXPANEL_FOR_FRAME
	itemPanel14->SetBackgroundColour(wxBackground_Pen);
	m_CategoryList->SetBackgroundColour(wxBackground_Pen);
	m_Palette->SetBackgroundColour(wxBackground_Pen);
#endif

	itemSplitterWindow22->SplitHorizontally(m_CategoryList, m_Palette, 10);
    
    itemBoxSizer15->Add(itemSplitterWindow22, 1, wxGROW, 0);

    m_Canvas = new wxJigsawEditorCanvas( itemDocParentFrame1, ID_CANVAS, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxTAB_TRAVERSAL );
    m_Canvas->SetBackgroundColour(wxColour(128, 128, 128));
    itemDocParentFrame1->GetAuiManager().AddPane(m_Canvas, wxAuiPaneInfo()
        .Name(_T("Canvas")).Centre().CaptionVisible(false).CloseButton(false).DestroyOnClose(false).Resizable(true).Floatable(false));

    GetAuiManager().Update();

    // Set validators
	if(m_ScaleSlider)     m_ScaleSlider->SetValidator( wxGenericValidator(& m_ScaleValue) );
////@end wxJigsawEditorMainFrame content construction
	TransferDataToWindow();
	m_Canvas->SetDropTarget(new DnDJigsawShapeDropTarget(m_Canvas));
	m_Palette->SetAssociatedCanvas(m_Canvas);
	m_Palette->SetShapes(GetShapeRegistry());
	m_Palette->Refresh();
	m_Palette->AdjustScrollBars();

	wxLogTrace(wxTraceMask(), _("Palettes = %i"), GetPalettes().GetCount());
	for(wxJigsawPaletteList::Node * node = GetPalettes().GetFirst();
		node; node = node->GetNext())
	{
		wxJigsawPalette * palette = node->GetData();
		if(!palette) continue;
		m_CategoryList->AddCategory(palette);
	}


	itemSplitterWindow22->SetMinimumPaneSize(m_CategoryList->GetSize().GetHeight());


	Connect(m_CategoryList->GetId(), wxEVT_COMMAND_LISTBOX_SELECTED,
		wxCommandEventHandler(wxJigsawEditorMainFrame::OnCategorySelected));
}