-/////////////////////////////////////////////////////////////////////////////\r
-// Name: src/richtext/richtextimagedlg.cpp\r
-// Purpose: \r
-// Author: Mingquan Yang\r
-// Modified by: \r
-// Created: Wed 02 Jun 2010 11:27:23 CST\r
-// RCS-ID: \r
-// Copyright: (c) Mingquan Yang\r
-// Licence: wxWindows licence\r
-/////////////////////////////////////////////////////////////////////////////\r
-\r
-// For compilers that support precompilation, includes "wx/wx.h".\r
-#include "wx/wxprec.h"\r
-\r
-#ifdef __BORLANDC__\r
-#pragma hdrstop\r
-#endif\r
-\r
-#ifndef WX_PRECOMP\r
- #include "wx/button.h"\r
- #include "wx/combobox.h"\r
- #include "wx/textctrl.h"\r
-#endif\r
-\r
-#include "wx/statline.h"\r
-\r
-#include "wx/richtext/richtextimagedlg.h"\r
-#include "wx/richtext/richtextctrl.h"\r
-\r
-////@begin XPM images\r
-////@end XPM images\r
-\r
-\r
-/*!\r
- * wxRichTextImageDialog type definition\r
- */\r
-\r
-IMPLEMENT_DYNAMIC_CLASS( wxRichTextImageDialog, wxDialog )\r
-\r
-\r
-/*!\r
- * wxRichTextImageDialog event table definition\r
- */\r
-\r
-BEGIN_EVENT_TABLE( wxRichTextImageDialog, wxDialog )\r
-\r
-////@begin wxRichTextImageDialog event table entries\r
- EVT_BUTTON( ID_RICHTEXTIMAGEDIALOG_PARA_UP, wxRichTextImageDialog::OnRichtextimagedialogParaUpClick )\r
-\r
- EVT_BUTTON( ID_RICHTEXTIMAGEDIALOG_DOWN, wxRichTextImageDialog::OnRichtextimagedialogDownClick )\r
-\r
-////@end wxRichTextImageDialog event table entries\r
-\r
-END_EVENT_TABLE()\r
-\r
-\r
-/*!\r
- * wxRichTextImageDialog constructors\r
- */\r
-\r
-wxRichTextImageDialog::wxRichTextImageDialog()\r
-{\r
- Init();\r
-}\r
-\r
-wxRichTextImageDialog::wxRichTextImageDialog( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )\r
-{\r
- Init();\r
- Create(parent, id, caption, pos, size, style);\r
-}\r
-\r
-\r
-/*!\r
- * wxRichTextImageDlg creator\r
- */\r
-\r
-bool wxRichTextImageDialog::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )\r
-{\r
-////@begin wxRichTextImageDialog creation\r
- SetExtraStyle(wxDIALOG_EX_CONTEXTHELP);\r
- wxDialog::Create( parent, id, caption, pos, size, style );\r
-\r
- CreateControls();\r
- if (GetSizer())\r
- {\r
- GetSizer()->SetSizeHints(this);\r
- }\r
- Centre();\r
-////@end wxRichTextImageDialog creation\r
- return true;\r
-}\r
-\r
-\r
-/*!\r
- * wxRichTextImageDialog destructor\r
- */\r
-\r
-wxRichTextImageDialog::~wxRichTextImageDialog()\r
-{\r
-////@begin wxRichTextImageDialog destruction\r
-////@end wxRichTextImageDialog destruction\r
-}\r
-\r
-\r
-/*!\r
- * Member initialisation\r
- */\r
-\r
-void wxRichTextImageDialog::Init()\r
-{\r
-////@begin wxRichTextImageDialog member initialisation\r
- m_alignment = NULL;\r
- m_float = NULL;\r
- m_width = NULL;\r
- m_unitsW = NULL;\r
- m_height = NULL;\r
- m_unitsH = NULL;\r
- m_offset = NULL;\r
- m_unitsOffset = NULL;\r
- m_saveButton = NULL;\r
- m_cancelButton = NULL;\r
-////@end wxRichTextImageDialog member initialisation\r
-}\r
-\r
-\r
-/*!\r
- * Control creation for wxRichTextImageDlg\r
- */\r
-\r
-void wxRichTextImageDialog::CreateControls()\r
-{ \r
-#ifdef __WXMAC__\r
- SetWindowVariant(wxWINDOW_VARIANT_SMALL);\r
-#endif\r
-\r
-////@begin wxRichTextImageDialog content construction\r
- wxRichTextImageDialog* itemDialog1 = this;\r
-\r
- wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);\r
- itemDialog1->SetSizer(itemBoxSizer2);\r
-\r
- wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL);\r
- itemBoxSizer2->Add(itemBoxSizer3, 0, wxGROW|wxALL, 5);\r
-\r
- wxFlexGridSizer* itemFlexGridSizer4 = new wxFlexGridSizer(0, 2, 0, 0);\r
- itemBoxSizer3->Add(itemFlexGridSizer4, 0, wxALIGN_TOP|wxRIGHT, 5);\r
-\r
- wxStaticText* itemStaticText5 = new wxStaticText( itemDialog1, wxID_STATIC, _("Alignment:"), wxDefaultPosition, wxDefaultSize, 0 );\r
- itemStaticText5->Show(false);\r
- itemFlexGridSizer4->Add(itemStaticText5, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);\r
-\r
- wxArrayString m_alignmentStrings;\r
- m_alignmentStrings.Add(_("Left"));\r
- m_alignmentStrings.Add(_("Centre"));\r
- m_alignmentStrings.Add(_("Right"));\r
- m_alignment = new wxComboBox( itemDialog1, ID_COMBOBOX_ALIGN, _("Left"), wxDefaultPosition, wxSize(80, -1), m_alignmentStrings, wxCB_READONLY );\r
- m_alignment->SetStringSelection(_("Left"));\r
- m_alignment->Show(false);\r
- itemFlexGridSizer4->Add(m_alignment, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);\r
-\r
- wxStaticText* itemStaticText7 = new wxStaticText( itemDialog1, wxID_STATIC, _("&Floating mode:"), wxDefaultPosition, wxDefaultSize, 0 );\r
- itemFlexGridSizer4->Add(itemStaticText7, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);\r
-\r
- wxArrayString m_floatStrings;\r
- m_floatStrings.Add(_("None"));\r
- m_floatStrings.Add(_("Left"));\r
- m_floatStrings.Add(_("Right"));\r
- m_float = new wxComboBox( itemDialog1, ID_RICHTEXTIMAGEDIALOG_FLOATING_MODE, _("None"), wxDefaultPosition, wxSize(80, -1), m_floatStrings, wxCB_READONLY );\r
- m_float->SetStringSelection(_("None"));\r
- m_float->SetHelpText(_("How the image will float relative to the text."));\r
- if (wxRichTextImageDialog::ShowToolTips())\r
- m_float->SetToolTip(_("How the image will float relative to the text."));\r
- itemFlexGridSizer4->Add(m_float, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5);\r
-\r
- wxStaticText* itemStaticText9 = new wxStaticText( itemDialog1, wxID_STATIC, _("&Width:"), wxDefaultPosition, wxDefaultSize, 0 );\r
- itemFlexGridSizer4->Add(itemStaticText9, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);\r
-\r
- wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxHORIZONTAL);\r
- itemFlexGridSizer4->Add(itemBoxSizer10, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);\r
-\r
- m_width = new wxTextCtrl( itemDialog1, ID_RICHTEXTIMAGEDIALOG_WIDTH, wxEmptyString, wxDefaultPosition, wxSize(65, -1), 0 );\r
- m_width->SetHelpText(_("The image width to be shown - does not change the source image width."));\r
- if (wxRichTextImageDialog::ShowToolTips())\r
- m_width->SetToolTip(_("The image width to be shown - does not change the source image width."));\r
- itemBoxSizer10->Add(m_width, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);\r
-\r
- wxArrayString m_unitsWStrings;\r
- m_unitsWStrings.Add(_("px"));\r
- m_unitsWStrings.Add(_("cm"));\r
- m_unitsW = new wxComboBox( itemDialog1, ID_RICHTEXTIMAGEDIALOG_UNITS_W, _("px"), wxDefaultPosition, wxSize(60, -1), m_unitsWStrings, wxCB_READONLY );\r
- m_unitsW->SetStringSelection(_("px"));\r
- m_unitsW->SetHelpText(_("Units for the image width."));\r
- if (wxRichTextImageDialog::ShowToolTips())\r
- m_unitsW->SetToolTip(_("Units for the image width."));\r
- itemBoxSizer10->Add(m_unitsW, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);\r
-\r
- wxStaticText* itemStaticText13 = new wxStaticText( itemDialog1, wxID_STATIC, _("&Height:"), wxDefaultPosition, wxDefaultSize, 0 );\r
- itemFlexGridSizer4->Add(itemStaticText13, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);\r
-\r
- wxBoxSizer* itemBoxSizer14 = new wxBoxSizer(wxHORIZONTAL);\r
- itemFlexGridSizer4->Add(itemBoxSizer14, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);\r
-\r
- m_height = new wxTextCtrl( itemDialog1, ID_RICHTEXTIMAGEDIALOG_HEIGHT, wxEmptyString, wxDefaultPosition, wxSize(65, -1), 0 );\r
- m_height->SetHelpText(_("The image height to be shown - does not change the source image height."));\r
- if (wxRichTextImageDialog::ShowToolTips())\r
- m_height->SetToolTip(_("The image height to be shown - does not change the source image height."));\r
- itemBoxSizer14->Add(m_height, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);\r
-\r
- wxArrayString m_unitsHStrings;\r
- m_unitsHStrings.Add(_("px"));\r
- m_unitsHStrings.Add(_("cm"));\r
- m_unitsH = new wxComboBox( itemDialog1, ID_RICHTEXTIMAGEDIALOG_UNITS_H, _("px"), wxDefaultPosition, wxSize(60, -1), m_unitsHStrings, wxCB_READONLY );\r
- m_unitsH->SetStringSelection(_("px"));\r
- m_unitsH->SetHelpText(_("Units for the image height."));\r
- if (wxRichTextImageDialog::ShowToolTips())\r
- m_unitsH->SetToolTip(_("Units for the image height."));\r
- itemBoxSizer14->Add(m_unitsH, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);\r
-\r
- wxStaticText* itemStaticText17 = new wxStaticText( itemDialog1, wxID_STATIC, _("Image Vertical &Offset:"), wxDefaultPosition, wxDefaultSize, 0 );\r
- itemFlexGridSizer4->Add(itemStaticText17, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);\r
-\r
- wxBoxSizer* itemBoxSizer18 = new wxBoxSizer(wxHORIZONTAL);\r
- itemFlexGridSizer4->Add(itemBoxSizer18, 1, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);\r
-\r
- m_offset = new wxTextCtrl( itemDialog1, ID_RICHTEXTIMAGEDIALOG_OFFSET, wxEmptyString, wxDefaultPosition, wxSize(65, -1), 0 );\r
- m_offset->SetMaxLength(10);\r
- m_offset->SetHelpText(_("The vertical offset relative to the paragraph."));\r
- if (wxRichTextImageDialog::ShowToolTips())\r
- m_offset->SetToolTip(_("The vertical offset relative to the paragraph."));\r
- itemBoxSizer18->Add(m_offset, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);\r
-\r
- wxArrayString m_unitsOffsetStrings;\r
- m_unitsOffsetStrings.Add(_("px"));\r
- m_unitsOffsetStrings.Add(_("cm"));\r
- m_unitsOffset = new wxComboBox( itemDialog1, ID_RICHTEXTIMAGEDIALOG_OFFSET_UNITS, _("px"), wxDefaultPosition, wxSize(60, -1), m_unitsOffsetStrings, wxCB_READONLY );\r
- m_unitsOffset->SetStringSelection(_("px"));\r
- m_unitsOffset->SetHelpText(_("Units for the image offset."));\r
- if (wxRichTextImageDialog::ShowToolTips())\r
- m_unitsOffset->SetToolTip(_("Units for the image offset."));\r
- itemBoxSizer18->Add(m_unitsOffset, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);\r
-\r
- wxStaticText* itemStaticText21 = new wxStaticText( itemDialog1, wxID_STATIC, _("&Move the image to:"), wxDefaultPosition, wxDefaultSize, 0 );\r
- itemFlexGridSizer4->Add(itemStaticText21, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);\r
-\r
- wxBoxSizer* itemBoxSizer22 = new wxBoxSizer(wxHORIZONTAL);\r
- itemFlexGridSizer4->Add(itemBoxSizer22, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);\r
-\r
- wxButton* itemButton23 = new wxButton( itemDialog1, ID_RICHTEXTIMAGEDIALOG_PARA_UP, _("&Previous Paragraph"), wxDefaultPosition, wxDefaultSize, 0 );\r
- itemButton23->SetHelpText(_("Moves the image to the previous paragraph."));\r
- if (wxRichTextImageDialog::ShowToolTips())\r
- itemButton23->SetToolTip(_("Moves the image to the previous paragraph."));\r
- itemBoxSizer22->Add(itemButton23, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);\r
-\r
- wxButton* itemButton24 = new wxButton( itemDialog1, ID_RICHTEXTIMAGEDIALOG_DOWN, _("&Next Paragraph"), wxDefaultPosition, wxDefaultSize, 0 );\r
- itemButton24->SetHelpText(_("Moves the image to the next paragraph."));\r
- if (wxRichTextImageDialog::ShowToolTips())\r
- itemButton24->SetToolTip(_("Moves the image to the next paragraph."));\r
- itemBoxSizer22->Add(itemButton24, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP|wxBOTTOM, 5);\r
-\r
- wxStaticLine* itemStaticLine25 = new wxStaticLine( itemDialog1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );\r
- itemBoxSizer2->Add(itemStaticLine25, 0, wxGROW|wxALL, 5);\r
-\r
- wxStdDialogButtonSizer* itemStdDialogButtonSizer26 = new wxStdDialogButtonSizer;\r
-\r
- itemBoxSizer2->Add(itemStdDialogButtonSizer26, 0, wxGROW|wxALL, 5);\r
- m_saveButton = new wxButton( itemDialog1, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 );\r
- m_saveButton->SetHelpText(_("Click to confirm your changes."));\r
- if (wxRichTextImageDialog::ShowToolTips())\r
- m_saveButton->SetToolTip(_("Click to confirm your changes."));\r
- itemStdDialogButtonSizer26->AddButton(m_saveButton);\r
-\r
- m_cancelButton = new wxButton( itemDialog1, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );\r
- m_cancelButton->SetHelpText(_("Click to discard your changes."));\r
- if (wxRichTextImageDialog::ShowToolTips())\r
- m_cancelButton->SetToolTip(_("Click to discard your changes."));\r
- itemStdDialogButtonSizer26->AddButton(m_cancelButton);\r
-\r
- itemStdDialogButtonSizer26->Realize();\r
-\r
-////@end wxRichTextImageDialog content construction\r
-}\r
-\r
-\r
-/*!\r
- * Should we show tooltips?\r
- */\r
-\r
-bool wxRichTextImageDialog::ShowToolTips()\r
-{\r
- return true;\r
-}\r
-\r
-/*!\r
- * Get bitmap resources\r
- */\r
-\r
-wxBitmap wxRichTextImageDialog::GetBitmapResource( const wxString& name )\r
-{\r
- // Bitmap retrieval\r
-////@begin wxRichTextImageDialog bitmap retrieval\r
- wxUnusedVar(name);\r
- return wxNullBitmap;\r
-////@end wxRichTextImageDialog bitmap retrieval\r
-}\r
-\r
-/*!\r
- * Get icon resources\r
- */\r
-\r
-wxIcon wxRichTextImageDialog::GetIconResource( const wxString& name )\r
-{\r
- // Icon retrieval\r
-////@begin wxRichTextImageDialog icon retrieval\r
- wxUnusedVar(name);\r
- return wxNullIcon;\r
-////@end wxRichTextImageDialog icon retrieval\r
-}\r
-\r
-/*!\r
- * Set the image attribute\r
- */\r
-void wxRichTextImageDialog::SetImageAttr(const wxRichTextAnchoredObjectAttr& attr)\r
-{\r
- m_attr = attr;\r
- TransferDataToWindow();\r
-}\r
-\r
-/*!\r
- * Apply the new style\r
- */\r
-wxRichTextImage* wxRichTextImageDialog::ApplyImageAttr()\r
-{\r
- wxRichTextImage* image = wxDynamicCast(m_image, wxRichTextImage);\r
-\r
- TransferDataFromWindow();\r
- if (m_buffer->GetRichTextCtrl())\r
- {\r
- m_buffer->GetRichTextCtrl()->SetImageStyle(image, m_attr);\r
- }\r
- return image;\r
-}\r
-\r
-void wxRichTextImageDialog::SetImageObject(wxRichTextImage* image, wxRichTextBuffer* buffer)\r
-{\r
- wxRichTextObject* parent = image->GetParent();\r
-\r
- m_buffer = buffer;\r
- m_image = image;\r
- m_parent = parent;\r
- SetImageAttr(image->GetAnchoredAttr());\r
- if (image->GetImageCache().IsOk())\r
- {\r
- if (m_attr.m_width == -1)\r
- {\r
- m_attr.m_width = image->GetImageCache().GetWidth();\r
- wxASSERT(m_attr.m_unitsW == wxRICHTEXT_PX);\r
- \r
- m_attr.m_unitsW = wxRICHTEXT_PX;\r
- }\r
- if (m_attr.m_height == -1)\r
- {\r
- m_attr.m_height = image->GetImageCache().GetHeight();\r
- wxASSERT(m_attr.m_unitsH == wxRICHTEXT_PX);\r
- \r
- m_attr.m_unitsH = wxRICHTEXT_PX;\r
- }\r
- }\r
-}\r
-\r
-bool wxRichTextImageDialog::TransferDataToWindow()\r
-{\r
- int remain = 100;\r
-\r
- m_alignment->SetSelection(m_attr.m_align);\r
- m_float->SetSelection(m_attr.m_floating);\r
-\r
- // Update scale\r
- m_unitsW->SetSelection(m_attr.m_unitsW);\r
- m_unitsH->SetSelection(m_attr.m_unitsH);\r
- m_unitsOffset->SetSelection(m_attr.m_unitsOffset);\r
-\r
- // Update metric\r
- m_width->Clear();\r
- if (m_attr.m_unitsW == wxRICHTEXT_MM)\r
- {\r
- int remainder = m_attr.m_width % remain;\r
- *m_width << m_attr.m_width / remain;\r
- if (remainder)\r
- {\r
- *m_width << '.' << remainder;\r
- }\r
- }\r
- else\r
- {\r
- *m_width << m_attr.m_width;\r
- }\r
-\r
- m_height->Clear();\r
- if (m_attr.m_unitsH == wxRICHTEXT_MM)\r
- {\r
- int remainder = m_attr.m_height % remain;\r
- *m_height << m_attr.m_height / remain;\r
- if (remainder)\r
- {\r
- *m_height << '.' << remainder;\r
- }\r
- }\r
- else\r
- {\r
- *m_height << m_attr.m_height;\r
- }\r
-\r
- m_offset->Clear();\r
- if (m_attr.m_unitsOffset == wxRICHTEXT_MM)\r
- {\r
- int remainder = m_attr.m_offset % remain;\r
- *m_offset << m_attr.m_offset / remain;\r
- if (remainder)\r
- {\r
- *m_offset << '.' << remainder;\r
- }\r
- }\r
- else\r
- {\r
- *m_offset << m_attr.m_offset;\r
- }\r
-\r
- return true;\r
-}\r
-\r
-bool wxRichTextImageDialog::TransferDataFromWindow()\r
-{\r
- wxString width = m_width->GetValue();\r
- wxString height = m_height->GetValue();\r
- wxString offset = m_offset->GetValue();\r
- int w, h, o;\r
-\r
- m_attr.m_align = m_alignment->GetSelection();\r
- m_attr.m_floating = m_float->GetSelection();\r
-\r
- m_attr.m_unitsW = m_unitsW->GetSelection();\r
- m_attr.m_unitsH = m_unitsH->GetSelection();\r
- m_attr.m_unitsOffset = m_unitsOffset->GetSelection();\r
-\r
- if (ConvertFromString(width, w, m_attr.m_unitsW))\r
- m_attr.m_width = w;\r
- if (ConvertFromString(height, h, m_attr.m_unitsH))\r
- m_attr.m_height = h;\r
- if (ConvertFromString(offset, o, m_attr.m_unitsOffset))\r
- m_attr.m_offset = o;\r
-\r
- return true;\r
-}\r
-\r
-bool wxRichTextImageDialog::ConvertFromString(const wxString& string, int& ret, int scale)\r
-{\r
- const wxChar* chars = string.GetData();\r
- int remain = 2;\r
- bool dot = false;\r
- ret = 0;\r
-\r
- for (unsigned int i = 0; i < string.Len() && remain; i++)\r
- {\r
- if (!(chars[i] >= '0' && chars[i] <= '9') && !(scale == wxRICHTEXT_MM && chars[i] == '.'))\r
- return false;\r
-\r
- if (chars[i] == '.')\r
- {\r
- dot = true;\r
- continue;\r
- }\r
-\r
- if (dot)\r
- remain--;\r
-\r
- ret = ret * 10 + chars[i] - '0';\r
- }\r
-\r
- while (remain-- > 0 && scale == wxRICHTEXT_MM)\r
- ret *= 10;\r
-\r
- return true;\r
-}\r
-\r
-\r
-/*!\r
- * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_PARA_UP\r
- */\r
-void wxRichTextImageDialog::OnRichtextimagedialogParaUpClick( wxCommandEvent& WXUNUSED(event))\r
-{\r
- // Before editing this code, remove the block markers.\r
- wxRichTextRange range = m_image->GetRange();\r
- wxRichTextObjectList::compatibility_iterator iter = m_buffer->GetChildren().GetFirst();\r
- if (iter == NULL)\r
- return;\r
-\r
- while (iter)\r
- {\r
- if (iter->GetData() == m_parent)\r
- break;\r
- iter = iter->GetNext();\r
- }\r
-\r
- iter = iter->GetPrevious();\r
- if (iter == NULL)\r
- return;\r
-\r
- wxRichTextObject *obj = iter->GetData();\r
- wxRichTextRange rg = obj->GetRange();\r
- m_image = m_image->Clone();\r
-\r
- m_buffer->DeleteRangeWithUndo(range, m_buffer->GetRichTextCtrl());\r
- m_buffer->InsertObjectWithUndo(rg.GetEnd(), m_image, m_buffer->GetRichTextCtrl(), 0);\r
- m_parent = obj;\r
- m_image->SetRange(wxRichTextRange(rg.GetEnd(), rg.GetEnd()));\r
-}\r
-\r
-\r
-/*!\r
- * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_PARA_DOWN\r
- */\r
-\r
-void wxRichTextImageDialog::OnRichtextimagedialogDownClick( wxCommandEvent& WXUNUSED(event))\r
-{\r
- // Before editing this code, remove the block markers.\r
- wxRichTextRange range = m_image->GetRange();\r
- wxRichTextObjectList::compatibility_iterator iter = m_buffer->GetChildren().GetFirst();\r
- if (iter == NULL)\r
- return;\r
-\r
- while (iter)\r
- {\r
- if (iter->GetData() == m_parent)\r
- break;\r
- iter = iter->GetNext();\r
- }\r
-\r
- iter = iter->GetNext();\r
- if (iter == NULL)\r
- return;\r
-\r
- wxRichTextObject *obj = iter->GetData();\r
- wxRichTextRange rg = obj->GetRange();\r
- m_image = m_image->Clone();\r
-\r
- m_buffer->DeleteRangeWithUndo(range, m_buffer->GetRichTextCtrl());\r
- m_buffer->InsertObjectWithUndo(rg.GetEnd(), m_image, m_buffer->GetRichTextCtrl(), 0);\r
- m_parent = obj;\r
- m_image->SetRange(wxRichTextRange(rg.GetEnd(), rg.GetEnd()));\r
-}\r
-\r
+/////////////////////////////////////////////////////////////////////////////
+// Name: src/richtext/richtextimagedlg.cpp
+// Purpose:
+// Author: Mingquan Yang
+// Modified by: Julian Smart
+// Created: Wed 02 Jun 2010 11:27:23 CST
+// RCS-ID:
+// Copyright: (c) Mingquan Yang, Julian Smart
+// Licence: wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#if wxUSE_RICHTEXT
+
+#ifndef WX_PRECOMP
+ #include "wx/button.h"
+ #include "wx/combobox.h"
+ #include "wx/sizer.h"
+ #include "wx/stattext.h"
+ #include "wx/textctrl.h"
+#endif
+
+#include "wx/statline.h"
+
+#include "wx/richtext/richtextimagedlg.h"
+#include "wx/richtext/richtextctrl.h"
+
+////@begin XPM images
+////@end XPM images
+
+
+/*!
+ * wxRichTextObjectPropertiesDialog type definition
+ */
+
+IMPLEMENT_DYNAMIC_CLASS( wxRichTextObjectPropertiesDialog, wxRichTextFormattingDialog )
+
+
+/*!
+ * wxRichTextObjectPropertiesDialog event table definition
+ */
+
+BEGIN_EVENT_TABLE( wxRichTextObjectPropertiesDialog, wxRichTextFormattingDialog )
+
+////@begin wxRichTextObjectPropertiesDialog event table entries
+////@end wxRichTextObjectPropertiesDialog event table entries
+
+END_EVENT_TABLE()
+
+
+/*!
+ * wxRichTextObjectPropertiesDialog constructors
+ */
+
+wxRichTextObjectPropertiesDialog::wxRichTextObjectPropertiesDialog()
+{
+ Init();
+}
+
+wxRichTextObjectPropertiesDialog::wxRichTextObjectPropertiesDialog( wxRichTextObject* obj, wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
+{
+ Init();
+ Create(obj, parent, id, caption, pos, size, style);
+}
+
+
+/*!
+ * wxRichTextImageDlg creator
+ */
+
+bool wxRichTextObjectPropertiesDialog::Create( wxRichTextObject* obj, wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
+{
+ SetObject(obj);
+ SetExtraStyle(wxDIALOG_EX_CONTEXTHELP);
+ long flags = wxRICHTEXT_FORMAT_SIZE|wxRICHTEXT_FORMAT_MARGINS|wxRICHTEXT_FORMAT_BORDERS|wxRICHTEXT_FORMAT_BACKGROUND;
+ wxRichTextFormattingDialog::Create( flags, parent, caption, id, pos, size, style );
+
+ CreateControls();
+
+ return true;
+}
+
+
+/*!
+ * wxRichTextObjectPropertiesDialog destructor
+ */
+
+wxRichTextObjectPropertiesDialog::~wxRichTextObjectPropertiesDialog()
+{
+////@begin wxRichTextObjectPropertiesDialog destruction
+////@end wxRichTextObjectPropertiesDialog destruction
+}
+
+
+/*!
+ * Member initialisation
+ */
+
+void wxRichTextObjectPropertiesDialog::Init()
+{
+////@begin wxRichTextObjectPropertiesDialog member initialisation
+////@end wxRichTextObjectPropertiesDialog member initialisation
+}
+
+
+/*!
+ * Control creation for wxRichTextImageDlg
+ */
+
+void wxRichTextObjectPropertiesDialog::CreateControls()
+{
+}
+
+
+/*!
+ * Should we show tooltips?
+ */
+
+bool wxRichTextObjectPropertiesDialog::ShowToolTips()
+{
+ return true;
+}
+
+/*!
+ * Get bitmap resources
+ */
+
+wxBitmap wxRichTextObjectPropertiesDialog::GetBitmapResource( const wxString& name )
+{
+ // Bitmap retrieval
+////@begin wxRichTextObjectPropertiesDialog bitmap retrieval
+ wxUnusedVar(name);
+ return wxNullBitmap;
+////@end wxRichTextObjectPropertiesDialog bitmap retrieval
+}
+
+/*!
+ * Get icon resources
+ */
+
+wxIcon wxRichTextObjectPropertiesDialog::GetIconResource( const wxString& name )
+{
+ // Icon retrieval
+////@begin wxRichTextObjectPropertiesDialog icon retrieval
+ wxUnusedVar(name);
+ return wxNullIcon;
+////@end wxRichTextObjectPropertiesDialog icon retrieval
+}
+
+#if 0
+/*!
+ * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_PARA_UP
+ */
+void wxRichTextObjectPropertiesDialog::OnRichtextParaUpClick( wxCommandEvent& WXUNUSED(event))
+{
+ // Before editing this code, remove the block markers.
+ wxRichTextRange range = m_object->GetRange();
+ wxRichTextObjectList::compatibility_iterator iter = m_buffer->GetChildren().GetFirst();
+ if (!iter)
+ return;
+
+ while (iter)
+ {
+ if (iter->GetData() == m_parent)
+ break;
+ iter = iter->GetNext();
+ }
+
+ iter = iter->GetPrevious();
+ if (!iter)
+ return;
+
+ wxRichTextObject *obj = iter->GetData();
+ wxRichTextRange rg = obj->GetRange();
+ m_object = m_object->Clone();
+
+ m_buffer->DeleteRangeWithUndo(range, m_buffer->GetRichTextCtrl());
+ m_buffer->InsertObjectWithUndo(rg.GetEnd(), m_object, m_buffer->GetRichTextCtrl(), 0);
+ m_parent = obj;
+ m_object->SetRange(wxRichTextRange(rg.GetEnd(), rg.GetEnd()));
+}
+
+
+/*!
+ * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON_PARA_DOWN
+ */
+
+void wxRichTextObjectPropertiesDialog::OnRichtextDownClick( wxCommandEvent& WXUNUSED(event))
+{
+ // Before editing this code, remove the block markers.
+ wxRichTextRange range = m_object->GetRange();
+ wxRichTextObjectList::compatibility_iterator iter = m_buffer->GetChildren().GetFirst();
+ if (!iter)
+ return;
+
+ while (iter)
+ {
+ if (iter->GetData() == m_parent)
+ break;
+ iter = iter->GetNext();
+ }
+
+ iter = iter->GetNext();
+ if (!iter)
+ return;
+
+ wxRichTextObject *obj = iter->GetData();
+ wxRichTextRange rg = obj->GetRange();
+ m_object = m_object->Clone();
+
+ m_buffer->DeleteRangeWithUndo(range, m_buffer->GetRichTextCtrl());
+ m_buffer->InsertObjectWithUndo(rg.GetEnd(), m_object, m_buffer->GetRichTextCtrl(), 0);
+ m_parent = obj;
+ m_object->SetRange(wxRichTextRange(rg.GetEnd(), rg.GetEnd()));
+}
+
+#endif
+
+#endif
+ // wxUSE_RICHTEXT