|
From: Emilien K. <cur...@us...> - 2005-08-25 09:17:51
|
Update of /cvsroot/wxdevcenter/StdPlugin/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24776/src Modified Files: BitmapProp.cpp Log Message: Add resolution system in the bitmap properties dialog. Index: BitmapProp.cpp =================================================================== RCS file: /cvsroot/wxdevcenter/StdPlugin/src/BitmapProp.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BitmapProp.cpp 24 Aug 2005 15:43:30 -0000 1.2 --- BitmapProp.cpp 25 Aug 2005 09:17:43 -0000 1.3 *************** *** 74,79 **** wxRealPoint BitmapProperties::GetSize(const SizeUnit& unit)const { ! return wxRealPoint(SizeUnit::Convert(GetSize().x/GetRes(), Units::Point, unit), ! SizeUnit::Convert(GetSize().y/GetRes(), Units::Point, unit)); } --- 74,79 ---- wxRealPoint BitmapProperties::GetSize(const SizeUnit& unit)const { ! return wxRealPoint(SizeUnit::Convert(GetSize().x/GetRes(), Units::Inch, unit), ! SizeUnit::Convert(GetSize().y/GetRes(), Units::Inch, unit)); } *************** *** 81,85 **** double BitmapProperties::GetRes(const SizeUnit& unit)const { ! return SizeUnit::Convert(GetRes(), Units::Point, unit); } --- 81,85 ---- double BitmapProperties::GetRes(const SizeUnit& unit)const { ! return SizeUnit::Convert(GetRes(), Units::Inch, unit); } *************** *** 88,93 **** void BitmapProperties::SetSize(wxRealPoint size, const SizeUnit& unit) { ! SetSize(wxSize( (wxCoord) (SizeUnit::Convert(size.x, unit, Units::Point) * GetRes()) , ! (wxCoord) (SizeUnit::Convert(size.y, unit, Units::Point) * GetRes()) )); } --- 88,93 ---- void BitmapProperties::SetSize(wxRealPoint size, const SizeUnit& unit) { ! SetSize(wxSize( (wxCoord) (SizeUnit::Convert(size.x, unit, Units::Inch) * GetRes()) , ! (wxCoord) (SizeUnit::Convert(size.y, unit, Units::Inch) * GetRes()) )); } *************** *** 96,100 **** void BitmapProperties::SetRes(double dRes, const SizeUnit& unit) { ! SetRes(SizeUnit::Convert(dRes, unit, Units::Point)); } --- 96,100 ---- void BitmapProperties::SetRes(double dRes, const SizeUnit& unit) { ! SetRes(SizeUnit::Convert(dRes, unit, Units::Inch)); } *************** *** 117,120 **** --- 117,121 ---- EVT_TEXT(ID_WIDTH_TEXT_CTRL, BitmapPropertiesDialog::OnSizeChanged) EVT_TEXT(ID_HEIGHT_TEXT_CTRL, BitmapPropertiesDialog::OnSizeChanged) + EVT_TEXT(ID_RES_TEXT_CTRL, BitmapPropertiesDialog::OnResChanged) EVT_CHOICE(ID_UNIT_CHOICE, BitmapPropertiesDialog::OnChangeUnit) *************** *** 124,128 **** // Standard constructor. BitmapPropertiesDialog::BitmapPropertiesDialog(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style, const wxString& name): ! wxDialog(parent, id, title, pos, size, style, name) { // Création des controles. --- 125,130 ---- // Standard constructor. BitmapPropertiesDialog::BitmapPropertiesDialog(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style, const wxString& name): ! wxDialog(parent, id, title, pos, size, style, name), ! m_bIsUpdatingCtrl(false) { // Création des controles. *************** *** 131,139 **** m_pUnitChoice = new wxChoice(this, ID_UNIT_CHOICE, wxDefaultPosition, wxDefaultSize, 0, NULL); m_pSizeTextCtrl = new wxStaticText(this, ID_SIZETEXT_CTRL, wxT("")); - m_pResTextCtrl = new wxTextCtrl(this, ID_RES_TEXT_CTRL, wxT("72.0")); m_pResUnitChoice = new wxChoice(this, ID_RESUNIT_CHOICE, wxDefaultPosition, wxDefaultSize, 0, NULL); - // Mise en page wxSizer* pLineSizer; --- 133,139 ---- *************** *** 193,196 **** --- 193,198 ---- SizeUnit* pUnit; + m_bIsUpdatingCtrl = true; + // Zone de taille. if(bUpdateSize) *************** *** 226,231 **** // Récapitulatif de taille. ! m_pSizeTextCtrl->SetLabel(wxString::Format(wxT("%dx%d pixels - %gppp"), m_BmpProp.GetSize().x,m_BmpProp.GetSize().y, m_BmpProp.GetRes())); } --- 228,234 ---- // Récapitulatif de taille. ! m_pSizeTextCtrl->SetLabel(wxString::Format(wxT("%dx%d pixels - %gppp"), m_BmpProp.GetSize().x,m_BmpProp.GetSize().y, m_BmpProp.GetRes(Units::Inch))); + m_bIsUpdatingCtrl = false; } *************** *** 233,237 **** void BitmapPropertiesDialog::OnChangeUnit(wxCommandEvent& WXUNUSED(event)) { ! UpdateCtrl(); } --- 236,241 ---- void BitmapPropertiesDialog::OnChangeUnit(wxCommandEvent& WXUNUSED(event)) { ! if(!m_bIsUpdatingCtrl) ! UpdateCtrl(); } *************** *** 239,272 **** void BitmapPropertiesDialog::OnSizeChanged(wxCommandEvent& WXUNUSED(event)) { ! SizeUnit* pUnit; ! int id = m_pUnitChoice->GetSelection(); ! ! if(id==wxNOT_FOUND || id==0) ! { ! long lX, lY; ! if(!m_pWidthTextCtrl->GetValue().ToLong(&lX, 0)) ! lX = m_BmpProp.GetSize().x; ! if(!m_pHeightTextCtrl->GetValue().ToLong(&lY, 0)) ! lY = m_BmpProp.GetSize().y; ! m_BmpProp.SetSize(wxSize(lX, lY)); ! } ! else { ! double dX, dY; ! pUnit = (SizeUnit*) m_pUnitChoice->GetClientData(id); ! if(!m_pWidthTextCtrl->GetValue().ToDouble(&dX)) ! dX = m_BmpProp.GetSize(*pUnit).x; ! if(!m_pHeightTextCtrl->GetValue().ToDouble(&dY)) ! dY = m_BmpProp.GetSize(*pUnit).y; ! m_BmpProp.SetSize(wxRealPoint(dX, dY), *pUnit); } - - UpdateCtrl(false, true); } // Interception d'un changement de résolution. ! void BitmapPropertiesDialog::OnResChanged(wxCommandEvent& event) { ! UpdateCtrl(true, false); } --- 243,292 ---- void BitmapPropertiesDialog::OnSizeChanged(wxCommandEvent& WXUNUSED(event)) { ! if(!m_bIsUpdatingCtrl) { ! SizeUnit* pUnit; ! int id = m_pUnitChoice->GetSelection(); ! ! if(id==wxNOT_FOUND || id==0) ! { ! long lX, lY; ! if(!m_pWidthTextCtrl->GetValue().ToLong(&lX, 0)) ! lX = m_BmpProp.GetSize().x; ! if(!m_pHeightTextCtrl->GetValue().ToLong(&lY, 0)) ! lY = m_BmpProp.GetSize().y; ! m_BmpProp.SetSize(wxSize(lX, lY)); ! } ! else ! { ! double dX, dY; ! pUnit = (SizeUnit*) m_pUnitChoice->GetClientData(id); ! if(!m_pWidthTextCtrl->GetValue().ToDouble(&dX)) ! dX = m_BmpProp.GetSize(*pUnit).x; ! if(!m_pHeightTextCtrl->GetValue().ToDouble(&dY)) ! dY = m_BmpProp.GetSize(*pUnit).y; ! m_BmpProp.SetSize(wxRealPoint(dX, dY), *pUnit); ! } ! ! UpdateCtrl(false, true); } } // Interception d'un changement de résolution. ! void BitmapPropertiesDialog::OnResChanged(wxCommandEvent& WXUNUSED(event)) { ! if(!m_bIsUpdatingCtrl) ! { ! SizeUnit* pUnit; ! int id = m_pResUnitChoice->GetSelection(); ! if(id!=wxNOT_FOUND) ! { ! pUnit = (SizeUnit*) m_pResUnitChoice->GetClientData(id); ! double dR; ! if(!m_pResTextCtrl->GetValue().ToDouble(&dR)) ! dR = m_BmpProp.GetRes(*pUnit); ! m_BmpProp.SetRes(dR, *pUnit); ! UpdateCtrl(true, false); ! } ! } } |