Implemented ColourButton class

Originally committed to SVN as r685.
This commit is contained in:
Rodrigo Braz Monteiro 2007-01-02 22:10:45 +00:00
parent cf94a0e77f
commit 48321dc868
8 changed files with 36 additions and 85 deletions

View file

@ -213,11 +213,6 @@ bool AssDialogue::Parse(wxString rawData, bool IsSSA) {
}
//////////////////
// Keep data flag
bool AssDialogue::keepData = true;
/////////////
// Make data
wxString AssDialogue::MakeData() {
@ -256,14 +251,12 @@ wxString AssDialogue::MakeData() {
//////////////////////////////////
// Update AssDialogue's data line
void AssDialogue::UpdateData () {
if (keepData) SetEntryData(MakeData());
}
//////////////////
// Get entry data
const wxString AssDialogue::GetEntryData() {
if (keepData) return AssEntry::GetEntryData();
return MakeData();
}
@ -271,7 +264,6 @@ const wxString AssDialogue::GetEntryData() {
//////////////////
// Set entry data
void AssDialogue::SetEntryData(wxString newData) {
if (keepData) AssEntry::SetEntryData(newData);
}

View file

@ -160,8 +160,6 @@ private:
wxString MakeData();
public:
static bool keepData;
std::vector<AssDialogueBlock*> Blocks; // Contains information about each block of text
bool Comment; // Is this a comment line?

View file

@ -39,7 +39,7 @@
////////////
// Includes
#include <wx/wx.h>
#include <wx/wxprec.h>
#include <wx/grid.h>
#include <list>
#include <vector>

View file

@ -47,6 +47,7 @@
#include "subs_grid.h"
#include "utils.h"
#include "dialog_colorpicker.h"
#include "colour_button.h"
///////////////
@ -107,18 +108,14 @@ DialogStyleEditor::DialogStyleEditor (wxWindow *parent, AssStyle *_style, Subtit
ColorsSizer->Add(ColorSizer3,0,wxLEFT,5);
ColorsSizer->Add(ColorSizer4,0,wxLEFT,5);
ColorsSizer->AddStretchSpacer(1);
ColorButton1 = new wxBitmapButton(this,BUTTON_COLOR_1,wxBitmap(45,16),wxDefaultPosition,wxDefaultSize);
ColorButton2 = new wxBitmapButton(this,BUTTON_COLOR_2,wxBitmap(45,16),wxDefaultPosition,wxDefaultSize);
ColorButton3 = new wxBitmapButton(this,BUTTON_COLOR_3,wxBitmap(45,16),wxDefaultPosition,wxDefaultSize);
ColorButton4 = new wxBitmapButton(this,BUTTON_COLOR_4,wxBitmap(45,16),wxDefaultPosition,wxDefaultSize);
SetBitmapColor(1,style->primary.GetWXColor());
SetBitmapColor(2,style->secondary.GetWXColor());
SetBitmapColor(3,style->outline.GetWXColor());
SetBitmapColor(4,style->shadow.GetWXColor());
ColorButton1->SetToolTip(_("Click to choose color"));
ColorButton2->SetToolTip(_("Click to choose color"));
ColorButton3->SetToolTip(_("Click to choose color"));
ColorButton4->SetToolTip(_("Click to choose color"));
colorButton[0] = new ColourButton(this,BUTTON_COLOR_1,wxSize(45,16),style->primary.GetWXColor());
colorButton[1] = new ColourButton(this,BUTTON_COLOR_2,wxSize(45,16),style->secondary.GetWXColor());
colorButton[2] = new ColourButton(this,BUTTON_COLOR_3,wxSize(45,16),style->outline.GetWXColor());
colorButton[3] = new ColourButton(this,BUTTON_COLOR_4,wxSize(45,16),style->shadow.GetWXColor());
colorButton[0]->SetToolTip(_("Click to choose primary color"));
colorButton[1]->SetToolTip(_("Click to choose secondary color"));
colorButton[2]->SetToolTip(_("Click to choose outline color"));
colorButton[3]->SetToolTip(_("Click to choose shadow color"));
ColorAlpha1Value = wxString::Format(_T("%i"),style->primary.a);
ColorAlpha1 = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(40,20),0,NumValidator(&ColorAlpha1Value));
ColorAlpha2Value = wxString::Format(_T("%i"),style->secondary.a);
@ -135,10 +132,10 @@ DialogStyleEditor::DialogStyleEditor (wxWindow *parent, AssStyle *_style, Subtit
ColorSizer2->Add(new wxStaticText(this,-1,_("Secondary")),0,wxBOTTOM | wxALIGN_CENTER,5);
ColorSizer3->Add(new wxStaticText(this,-1,_("Outline")),0,wxBOTTOM | wxALIGN_CENTER,5);
ColorSizer4->Add(new wxStaticText(this,-1,_("Shadow")),0,wxBOTTOM | wxALIGN_CENTER,5);
ColorSizer1->Add(ColorButton1,0,wxBOTTOM | wxALIGN_CENTER,5);
ColorSizer2->Add(ColorButton2,0,wxBOTTOM | wxALIGN_CENTER,5);
ColorSizer3->Add(ColorButton3,0,wxBOTTOM | wxALIGN_CENTER,5);
ColorSizer4->Add(ColorButton4,0,wxBOTTOM | wxALIGN_CENTER,5);
ColorSizer1->Add(colorButton[0],0,wxBOTTOM | wxALIGN_CENTER,5);
ColorSizer2->Add(colorButton[1],0,wxBOTTOM | wxALIGN_CENTER,5);
ColorSizer3->Add(colorButton[2],0,wxBOTTOM | wxALIGN_CENTER,5);
ColorSizer4->Add(colorButton[3],0,wxBOTTOM | wxALIGN_CENTER,5);
ColorSizer1->Add(ColorAlpha1,0,wxALIGN_CENTER,0);
ColorSizer2->Add(ColorAlpha2,0,wxALIGN_CENTER,0);
ColorSizer3->Add(ColorAlpha3,0,wxALIGN_CENTER,0);
@ -311,28 +308,6 @@ DialogStyleEditor::~DialogStyleEditor () {
}
////////////////////////////////////////////
// Sets the color of the bitmap of a button
void DialogStyleEditor::SetBitmapColor (int n,wxColour color) {
wxBitmapButton *but;
switch (n) {
case 1: but = ColorButton1; break;
case 2: but = ColorButton2; break;
case 3: but = ColorButton3; break;
case 4: but = ColorButton4; break;
default: return;
}
wxBitmap bmp (but->GetBitmapLabel());
wxMemoryDC dc;
dc.SelectObject(bmp);
dc.SetPen(*wxBLACK_PEN);
wxBrush brush(color);
dc.SetBrush(brush);
dc.DrawRectangle(0,0,bmp.GetWidth(),bmp.GetHeight());
but->SetBitmapLabel(bmp);
}
///////////////
// Event table
BEGIN_EVENT_TABLE(DialogStyleEditor, wxDialog)
@ -524,19 +499,7 @@ void DialogStyleEditor::OnSetColor (int n) {
case 4: modify = &work->shadow; break;
default: throw _T("Never gets here");
}
DialogColorPicker dlg(this, modify->GetWXColor());
if (dlg.ShowModal() == wxID_OK) {
wxColour color = dlg.GetColor();
modify->SetWXColor(color);
SetBitmapColor(n, color);
}
/*
wxColour newColor = wxGetColourFromUser(this,modify->GetWXColor());
if (newColor.Ok()) {
modify->SetWXColor(newColor);
SetBitmapColor(n,newColor);
}
*/
modify->SetWXColor(colorButton[n-1]->GetColour());
}

View file

@ -41,6 +41,7 @@
////////////
// Includes
#include <wx/wxprec.h>
#include "colour_button.h"
//////////////
@ -81,10 +82,7 @@ private:
wxCheckBox *BoxItalic;
wxCheckBox *BoxUnderline;
wxCheckBox *BoxStrikeout;
wxBitmapButton *ColorButton1;
wxBitmapButton *ColorButton2;
wxBitmapButton *ColorButton3;
wxBitmapButton *ColorButton4;
ColourButton *colorButton[4];
wxTextCtrl *ColorAlpha1;
wxTextCtrl *ColorAlpha2;
wxTextCtrl *ColorAlpha3;

View file

@ -82,7 +82,6 @@ bool AegisubApp::OnInit() {
Options.SetFile(folderName + _T("/config.dat"));
Options.Load();
AssTime::UseMSPrecision = Options.AsBool(_T("Use nonstandard Milisecond Times"));
AssDialogue::keepData = Options.AsBool(_T("Keep raw dialogue data"));
// Set hotkeys file
Hotkeys.SetFile(folderName + _T("/hotkeys.dat"));

View file

@ -92,6 +92,8 @@ void OptionsManager::LoadDefaults() {
SetText(_T("Auto save path"),_T("autosave"));
SetText(_T("Auto recovery path"),_T("recovered"));
SetInt(_T("Autoload linked files"),2);
SetText(_T("Text actor separator"),_T(":"));
SetText(_T("Text comment starter"),_T("#"));
// Dictionary
SetText(_T("Dictionaries path"),_T("dictionaries"));
@ -112,11 +114,6 @@ void OptionsManager::LoadDefaults() {
SetText(_T("Video resizer"),_T("BilinearResize"));
// Audio Options
SetBool(_T("Audio Link"),true);
SetBool(_T("Audio Autocommit"),false);
SetBool(_T("Audio Autoscroll"),true);
SetBool(_T("Audio SSA Mode"),false);
SetBool(_T("Audio Medusa Timing Hotkeys"),false);
SetBool(_T("Audio SSA Next Line on Commit"),true);
SetBool(_T("Audio SSA Allow Autocommit"),false);
SetBool(_T("Audio Autofocus"),false);
@ -131,6 +128,8 @@ void OptionsManager::LoadDefaults() {
SetInt(_T("Audio Cache"),1);
SetInt(_T("Audio Sample Rate"),0);
SetText(_T("Audio Downmixer"),_T("ConvertToMono"));
SetText(_T("Audio HD Cache Location"),_T("default"));
SetText(_T("Audio HD Cache Name"),_T("audio%02i.tmp"));
// Automation
SetText(_T("Automation Base Path"), AegisubApp::folderName + _T("automation/"));
@ -139,6 +138,7 @@ void OptionsManager::LoadDefaults() {
SetInt(_T("Automation Trace Level"), 3);
// Edit box cosmetic
SetBool(_T("Call Tips Enabled"),true);
SetBool(_T("Syntax Highlight Enabled"),true);
SetColour(_T("Syntax Highlight Normal"),wxColour(0,0,0));
SetColour(_T("Syntax Highlight Brackets"),wxColour(20,50,255));
@ -190,6 +190,11 @@ void OptionsManager::LoadDefaults() {
SetText(_T("Grid hide overrides char"),temp);
SetBool(_T("Grid allow focus"),true);
SetBool(_T("Highlight subs in frame"),true);
#if defined(__WINDOWS__)
SetInt(_T("Grid font size"),8);
#else
SetInt(_T("Grid font size"),10);
#endif
// Audio Cosmetic
SetInt(_T("Audio Spectrum Cutoff"),32);
@ -218,10 +223,14 @@ void OptionsManager::LoadDefaults() {
///// INTERNAL //////
// Options that are set by the program itself
SetInt(_T("Locale Code"),-1);
SetBool(_T("Keep raw dialogue data"),false);
SetBool(_T("Sync video with subs"),true);
SetBool(_T("Audio Link"),true);
SetBool(_T("Audio Autocommit"),false);
SetBool(_T("Audio Autoscroll"),true);
SetBool(_T("Audio SSA Mode"),false);
SetBool(_T("Audio Medusa Timing Hotkeys"),false);
SetBool(_T("Shift Times ByTime"),true);
SetInt(_T("Shift Times Type"),0);
SetInt(_T("Shift Times Length"),0);
@ -241,12 +250,6 @@ void OptionsManager::LoadDefaults() {
SetInt(_T("Grid hide overrides"),1);
for (int i=0;i<10;i++) SetBool(_T("Grid show column ") + IntegerToString(i),true);
#if defined(__WINDOWS__)
SetInt(_T("Grid font size"),8);
#else
SetInt(_T("Grid font size"),10);
#endif
for (int i=0;i<9;i++) SetBool(wxString::Format(_T("Paste Over #%i"),i),false);
SetBool(_T("Paste Over #9"),true);
@ -256,8 +259,6 @@ void OptionsManager::LoadDefaults() {
SetInt(_T("Audio Display Height"),100);
SetBool(_T("Audio Spectrum"),false);
SetText(_T("Audio HD Cache Location"),_T("default"));
SetText(_T("Audio HD Cache Name"),_T("audio%02i.tmp"));
SetInt(_T("Timing processor key start before thres"),5);
SetInt(_T("Timing processor key start after thres"),4);
@ -279,9 +280,6 @@ void OptionsManager::LoadDefaults() {
SetBool(_T("Select Match dialogues"),true);
SetBool(_T("Select Match comments"),false);
SetText(_T("Text actor separator"),_T(":"));
SetText(_T("Text comment starter"),_T("#"));
SetText(_T("Color Picker Recent"), _T("&H000000& &H0000FF& &H00FFFF& &H00FF00& &HFFFF00& &HFF0000& &HFF00FF& &HFFFFFF&"));
SetInt(_T("Color Picker Mode"), 4);

View file

@ -378,6 +378,9 @@ void SubsTextEditCtrl::UpdateStyle(int start, int _length) {
///////////////////
// Update call tip
void SubsTextEditCtrl::UpdateCallTip() {
// Enabled?
if (!Options.AsBool(_T("Call tips enabled"))) return;
// Get position and text
const unsigned int pos = GetReverseUnicodePosition(GetCurrentPos());
wxString text = GetText();