コード例 #1
0
void PropertiesPalette_Table::handleCellSelectionChanged()
{
	if (!m_doc)
		return;
	if (!m_item)
		return;
	updateFillControls();
	updateStyleControls();
}
コード例 #2
0
/* TextStylePrefsPanel::onStyleSelected
 * Called when a style is selected in the style list
 *******************************************************************/
void TextStylePrefsPanel::onStyleSelected(wxCommandEvent& e)
{
	int sel = list_styles->GetSelection();
	if (sel == 0)
		ts_current = ss_current.getStyle("default");
	else if (sel == 1)
		ts_current = ss_current.getStyle("selection");
	else
		ts_current = ss_current.getStyle(sel - 2);

	updateStyleControls();
}
コード例 #3
0
/* TextStylePrefsPanel::onStyleSetSelected
 * Called when the style set selection is changed
 *******************************************************************/
void TextStylePrefsPanel::onStyleSetSelected(wxCommandEvent& e)
{
	if (init_done)
	{
		// Get selected styleset
		StyleSet* set = StyleSet::getSet(choice_styleset->GetSelection());
		if (set)
		{
			ss_current.copySet(set);
			updateStyleControls();
			updatePreview();
		}
	}
}
コード例 #4
0
void PropertiesPalette_Table::handleSelectionChanged()
{
	if (!m_doc)
		return;

	// We only handle a single item for now.
	if (m_doc->m_Selection->count() >= 1 && m_doc->m_Selection->itemAt(0)->isTable())
		m_item = m_doc->m_Selection->itemAt(0);
	else
		m_item = 0;

	// HACK: Guard against "false" re-selections resulting from m_item->update().
	if (m_item == m_previousItem)
		return;
	m_previousItem = m_item;

	sideSelector->setSelection(TableSideSelector::All);

	updateFillControls();
	updateStyleControls();
}
コード例 #5
0
/* TextStylePrefsPanel::TextStylePrefsPanel
 * TextStylePrefsPanel class constructor
 *******************************************************************/
TextStylePrefsPanel::TextStylePrefsPanel(wxWindow* parent) : PrefsPanelBase(parent)
{
	// Init variables
	ss_current.copySet(StyleSet::currentSet());
	ts_current = ss_current.getStyle("default");

	// Create main sizer
	wxBoxSizer* psizer = new wxBoxSizer(wxVERTICAL);
	SetSizer(psizer);

	// Create frame+sizer
	wxStaticBox* frame = new wxStaticBox(this, -1, "Text Editor Fonts and Colours");
	wxStaticBoxSizer* sizer = new wxStaticBoxSizer(frame, wxVERTICAL);
	psizer->Add(sizer, 1, wxEXPAND|wxALL, 4);

	// Styleset font override
	wxBoxSizer* hbox = new wxBoxSizer(wxHORIZONTAL);
	sizer->Add(hbox, 0, wxEXPAND | wxALL, 4);
	cb_font_override = new wxCheckBox(this, -1, "Override Default Font");
	cb_font_override->SetToolTip("Always use the selected font in the text editor, instead of the style's font below");
	hbox->Add(cb_font_override, 0, wxEXPAND | wxALL, 4);
	fp_font_override = new wxFontPickerCtrl(this, -1);
	hbox->Add(fp_font_override, 1, wxEXPAND | wxALL, 4);

	// Styleset controls
	hbox = new wxBoxSizer(wxHORIZONTAL);
	sizer->Add(hbox, 0, wxEXPAND|wxALL, 4);

	// Styleset selection dropdown
	wxArrayString style_sets;
	for (unsigned a = 0; a < StyleSet::numSets(); a++)
		style_sets.Add(StyleSet::getName(a));
	choice_styleset = new wxChoice(this, -1, wxDefaultPosition, wxDefaultSize, style_sets);
	hbox->Add(new wxStaticText(this, -1, "Style Set:"), 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 4);
	hbox->Add(choice_styleset, 1, wxEXPAND|wxRIGHT, 4);


	// Style configuration controls
	hbox = new wxBoxSizer(wxHORIZONTAL);
	sizer->Add(hbox, 1, wxEXPAND|wxALL, 4);
	wxBoxSizer* vbox = new wxBoxSizer(wxVERTICAL);
	hbox->Add(vbox, 0, wxEXPAND|wxALL, 4);

	// Style list
	wxArrayString style_names;
	style_names.Add("Default");
	style_names.Add("Selection");
	for (unsigned a = 0; a < ss_current.nStyles(); a++)
		style_names.Add(ss_current.getStyle(a)->getDescription());
	list_styles = new wxListBox(this, -1, wxDefaultPosition, wxDefaultSize, style_names);
	vbox->Add(list_styles, 1, wxEXPAND|wxBOTTOM, 4);

	// 'Save Set' button
	btn_savestyleset = new wxButton(this, -1, "Save Set");
	vbox->Add(btn_savestyleset, 0, wxEXPAND);


	// Style settings
	vbox = new wxBoxSizer(wxVERTICAL);
	hbox->Add(vbox, 1, wxEXPAND|wxALL, 4);

	// Font picker
	vbox->Add(new wxStaticText(this, -1, "Font:"), 0, wxBOTTOM, 2);
	fp_font = new wxFontPickerCtrl(this, -1);
	vbox->Add(fp_font, 0, wxEXPAND|wxBOTTOM, 4);

	// Font property overrides
	wxGridBagSizer* sizer_gb = new wxGridBagSizer(4, 4);
	vbox->Add(sizer_gb, 0, wxEXPAND|wxBOTTOM, 4);
	sizer_gb->Add(new wxStaticText(this, -1, "Override default font properties:"), wxGBPosition(0, 0), wxGBSpan(1, 3));
	cb_override_font_face = new wxCheckBox(this, -1, "Face");
	cb_override_font_size = new wxCheckBox(this, -1, "Size");
	cb_override_font_bold = new wxCheckBox(this, -1, "Bold");
	cb_override_font_italic = new wxCheckBox(this, -1, "Italic");
	cb_override_font_underlined = new wxCheckBox(this, -1, "Underlined");
	sizer_gb->Add(cb_override_font_face, wxGBPosition(1, 0));
	sizer_gb->Add(cb_override_font_size, wxGBPosition(1, 1));
	sizer_gb->Add(cb_override_font_bold, wxGBPosition(2, 0));
	sizer_gb->Add(cb_override_font_italic, wxGBPosition(2, 1));
	sizer_gb->Add(cb_override_font_underlined, wxGBPosition(2, 2));

	// Foreground colour
	vbox->Add(new wxStaticLine(this, -1, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL), 0, wxEXPAND|wxALL, 4);
	hbox = new wxBoxSizer(wxHORIZONTAL);
	vbox->Add(hbox, 0, wxEXPAND|wxBOTTOM, 4);
	hbox->Add(new wxStaticText(this, -1, "Foreground:"), 1, wxALIGN_CENTER_VERTICAL);
	cb_override_foreground = new wxCheckBox(this, -1, "Override Default");
	hbox->Add(cb_override_foreground, 1, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT);
	cp_foreground = new wxColourPickerCtrl(this, -1, WXCOL(COL_BLACK), wxDefaultPosition, wxDefaultSize, wxCLRP_SHOW_LABEL|wxCLRP_USE_TEXTCTRL);
	vbox->Add(cp_foreground, 0, wxEXPAND|wxBOTTOM, 4);

	// Background colour
	hbox = new wxBoxSizer(wxHORIZONTAL);
	vbox->Add(hbox, 0, wxEXPAND|wxBOTTOM, 4);
	hbox->Add(new wxStaticText(this, -1, "Background:"), 1, wxALIGN_CENTER_VERTICAL);
	cb_override_background = new wxCheckBox(this, -1, "Override Default");
	hbox->Add(cb_override_background, 1, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT);
	cp_background = new wxColourPickerCtrl(this, -1, WXCOL(COL_BLACK), wxDefaultPosition, wxDefaultSize, wxCLRP_SHOW_LABEL|wxCLRP_USE_TEXTCTRL);
	vbox->Add(cp_background, 0, wxEXPAND);

	// Preview
	te_preview = new TextEditor(this, -1);
	vbox->Add(te_preview, 1, wxEXPAND | wxTOP, 8);


	// Bind events
	list_styles->Bind(wxEVT_LISTBOX, &TextStylePrefsPanel::onStyleSelected, this);
	cb_override_font_face->Bind(wxEVT_CHECKBOX, &TextStylePrefsPanel::onCBOverrideFontFace, this);
	cb_override_font_size->Bind(wxEVT_CHECKBOX, &TextStylePrefsPanel::onCBOverrideFontSize, this);
	cb_override_font_bold->Bind(wxEVT_CHECKBOX, &TextStylePrefsPanel::onCBOverrideFontBold, this);
	cb_override_font_italic->Bind(wxEVT_CHECKBOX, &TextStylePrefsPanel::onCBOverrideFontItalic, this);
	cb_override_font_underlined->Bind(wxEVT_CHECKBOX, &TextStylePrefsPanel::onCBOverrideFontUnderlined, this);
	cb_override_foreground->Bind(wxEVT_CHECKBOX, &TextStylePrefsPanel::onCBOverrideForeground, this);
	cb_override_background->Bind(wxEVT_CHECKBOX, &TextStylePrefsPanel::onCBOverrideBackground, this);
	fp_font->Bind(wxEVT_FONTPICKER_CHANGED, &TextStylePrefsPanel::onFontChanged, this);
	cp_foreground->Bind(wxEVT_COLOURPICKER_CHANGED, &TextStylePrefsPanel::onForegroundChanged, this);
	cp_background->Bind(wxEVT_COLOURPICKER_CHANGED, &TextStylePrefsPanel::onBackgroundChanged, this);
	btn_savestyleset->Bind(wxEVT_BUTTON, &TextStylePrefsPanel::onBtnSaveStyleSet, this);
	choice_styleset->Bind(wxEVT_CHOICE, &TextStylePrefsPanel::onStyleSetSelected, this);
	cb_font_override->Bind(wxEVT_CHECKBOX, &TextStylePrefsPanel::onCBOverrideFont, this);
	fp_font_override->Bind(wxEVT_FONTPICKER_CHANGED, &TextStylePrefsPanel::onFontOverrideChanged, this);

	// Init controls
	if (txed_override_font != "")
	{
		cb_font_override->SetValue(true);
		fp_font_override->SetSelectedFont(
			wxFont(
				txed_override_font_size == 0 ? 10 : txed_override_font_size,
				wxFONTFAMILY_MODERN,
				wxFONTSTYLE_NORMAL,
				wxFONTWEIGHT_NORMAL,
				false,
				txed_override_font
				)
			);
		fp_font_override->Enable(true);
	}
	else
	{
		cb_font_override->SetValue(false);
		fp_font_override->SetSelectedFont(wxFont(10, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
		fp_font_override->Enable(false);
	}

	// Select default style
	init_done = false;
	list_styles->SetSelection(0);
	updateStyleControls();
	init_done = true;
}