Aegisub/aegisub/src/subs_edit_box.h

358 lines
6.5 KiB
C
Raw Normal View History

2006-01-16 22:02:54 +01:00
// Copyright (c) 2005, Rodrigo Braz Monteiro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of the Aegisub Group nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// Aegisub Project http://www.aegisub.org/
2006-01-16 22:02:54 +01:00
//
// $Id$
/// @file subs_edit_box.h
/// @see subs_edit_box.cpp
/// @ingroup main_ui
///
2006-01-16 22:02:54 +01:00
#pragma once
////////////
// Includes
#include <wx/wxprec.h>
#include <wx/spinctrl.h>
#include "subs_edit_ctrl.h"
2006-01-16 22:02:54 +01:00
//////////////
// Prototypes
class SubtitlesGrid;
class TimeEdit;
class SubsEditBox;
class AudioDisplay;
class HiliModTextCtrl;
class wxStyledTextCtrl;
/// DOCME
/// @class SubsEditBox
/// @brief DOCME
///
/// DOCME
2006-01-16 22:02:54 +01:00
class SubsEditBox : public wxPanel {
friend class SubsTextEditHandler;
friend class SubsTextEditCtrl;
friend class AudioDisplay;
2006-01-16 22:02:54 +01:00
private:
/// DOCME
bool splitLineMode;
/// DOCME
bool setupDone;
/// DOCME
2006-01-16 22:02:54 +01:00
bool enabled;
/// DOCME
2006-01-16 22:02:54 +01:00
bool textEditReady;
/// DOCME
2006-01-16 22:02:54 +01:00
bool controlState;
/// DOCME
2006-01-16 22:02:54 +01:00
wxColour origBgColour;
/// DOCME
2006-01-16 22:02:54 +01:00
wxColour disabledBgColour;
/// DOCME
2006-01-16 22:02:54 +01:00
SubtitlesGrid *grid;
/// DOCME
2006-01-16 22:02:54 +01:00
wxCheckBox *CommentBox;
/// DOCME
2006-01-16 22:02:54 +01:00
wxComboBox *StyleBox;
/// DOCME
2006-01-16 22:02:54 +01:00
wxComboBox *ActorBox;
/// DOCME
2006-01-16 22:02:54 +01:00
TimeEdit *StartTime;
/// DOCME
2006-01-16 22:02:54 +01:00
TimeEdit *EndTime;
/// DOCME
2006-01-16 22:02:54 +01:00
TimeEdit *Duration;
/// DOCME
wxSpinCtrl *Layer;
/// DOCME
2006-01-16 22:02:54 +01:00
HiliModTextCtrl *MarginL;
/// DOCME
2006-01-16 22:02:54 +01:00
HiliModTextCtrl *MarginR;
/// DOCME
2006-01-16 22:02:54 +01:00
HiliModTextCtrl *MarginV;
/// DOCME
HiliModTextCtrl *Effect;
/// DOCME
2006-01-16 22:02:54 +01:00
wxRadioButton *ByTime;
/// DOCME
2006-01-16 22:02:54 +01:00
wxRadioButton *ByFrame;
/// DOCME
2006-01-16 22:02:54 +01:00
wxCheckBox *SyntaxHighlight;
/// DOCME
2006-01-16 22:02:54 +01:00
wxButton *Bold;
/// DOCME
2006-01-16 22:02:54 +01:00
wxButton *Italics;
/// DOCME
2006-01-16 22:02:54 +01:00
wxButton *Underline;
/// DOCME
2006-01-16 22:02:54 +01:00
wxButton *Strikeout;
/// DOCME
2006-01-16 22:02:54 +01:00
wxButton *FontName;
/// DOCME
2006-01-16 22:02:54 +01:00
wxButton *Color1;
/// DOCME
2006-01-16 22:02:54 +01:00
wxButton *Color2;
/// DOCME
2006-01-16 22:02:54 +01:00
wxButton *Color3;
/// DOCME
2006-01-16 22:02:54 +01:00
wxButton *Color4;
/// DOCME
wxButton *CommitButton;
2006-01-16 22:02:54 +01:00
/// DOCME
wxSizer *TopSizer;
/// DOCME
wxSizer *MiddleBotSizer;
/// DOCME
wxSizer *MiddleSizer;
/// DOCME
wxSizer *MainSizer;
/// DOCME
wxSizer *DummySizer;
/// DOCME
wxSizer *BottomSizer;
2006-01-16 22:02:54 +01:00
void SetControlsState(bool state);
void CommitTimes(bool start,bool end,bool fromStart,bool commit=true);
2006-01-16 22:02:54 +01:00
int BlockAtPos(int pos);
void OnEditText(wxStyledTextEvent &event);
void OnNeedStyle(wxStyledTextEvent &event);
void OnCharAdded(wxStyledTextEvent &event);
void OnUpdateUI(wxStyledTextEvent &event);
2006-01-16 22:02:54 +01:00
void OnButtonColor1(wxCommandEvent &event);
void OnButtonColor2(wxCommandEvent &event);
void OnButtonColor3(wxCommandEvent &event);
void OnButtonColor4(wxCommandEvent &event);
void OnButtonFontFace(wxCommandEvent &event);
void OnButtonBold(wxCommandEvent &event);
void OnButtonItalics(wxCommandEvent &event);
void OnButtonUnderline(wxCommandEvent &event);
void OnButtonStrikeout(wxCommandEvent &event);
void OnButtonCommit(wxCommandEvent &event);
2006-01-16 22:02:54 +01:00
void OnSyntaxBox(wxCommandEvent &event);
void OnFrameRadio(wxCommandEvent &event);
void OnTimeRadio(wxCommandEvent &event);
void OnKeyDown(wxStyledTextEvent &event);
2006-01-16 22:02:54 +01:00
void OnStyleChange(wxCommandEvent &event);
void OnActorChange(wxCommandEvent &event);
void OnLayerEnter(wxCommandEvent &event);
void OnLayerChange(wxSpinEvent &event);
2006-01-16 22:02:54 +01:00
void OnStartTimeChange(wxCommandEvent &event);
void OnEndTimeChange(wxCommandEvent &event);
void OnDurationChange(wxCommandEvent &event);
void OnMarginLChange(wxCommandEvent &event);
void OnMarginRChange(wxCommandEvent &event);
void OnMarginVChange(wxCommandEvent &event);
void OnCommentChange(wxCommandEvent &event);
void OnEffectChange(wxCommandEvent &event);
void OnSize(wxSizeEvent &event);
2006-01-16 22:02:54 +01:00
public:
/// DOCME
2006-01-16 22:02:54 +01:00
int linen;
/// DOCME
2006-01-16 22:02:54 +01:00
AudioDisplay *audio;
/// DOCME
2006-01-16 22:02:54 +01:00
SubsTextEditCtrl *TextEdit;
SubsEditBox(wxWindow *parent,SubtitlesGrid *gridp);
~SubsEditBox();
2006-01-16 22:02:54 +01:00
void SetOverride (wxString tag,wxString preValue=_T(""),int pos=-1,bool getFocus=true);
void SetStyleFlag (wxString tag,wxString preValue=_T(""),int pos=-1);
2006-01-16 22:02:54 +01:00
void SetSplitLineMode(wxSize size=wxSize(-1,-1));
void CommitText(bool weak=false);
void Update(bool timeOnly=false,bool weak=false);
2006-01-16 22:02:54 +01:00
void UpdateGlobals();
void SetToLine(int n,bool weak=false);
2006-01-16 22:02:54 +01:00
void UpdateFrameTiming();
void DoKeyPress(wxKeyEvent &event);
void Commit(bool stay);
2006-01-16 22:02:54 +01:00
DECLARE_EVENT_TABLE()
2006-01-16 22:02:54 +01:00
};
/// DOCME
/// @class SubsEditBoxEvent
/// @brief DOCME
///
/// DOCME
2006-01-16 22:02:54 +01:00
class SubsEditBoxEvent : public wxEvtHandler {
private:
/// DOCME
2006-01-16 22:02:54 +01:00
SubsEditBox *control;
void OnKeyPress(wxKeyEvent &event);
public:
SubsEditBoxEvent(SubsEditBox *control);
DECLARE_EVENT_TABLE()
2006-01-16 22:02:54 +01:00
};
///////
// IDs
enum {
/// DOCME
2006-01-16 22:02:54 +01:00
EDIT_BOX = 1300,
/// DOCME
2006-01-16 22:02:54 +01:00
SYNTAX_BOX,
/// DOCME
2006-01-16 22:02:54 +01:00
RADIO_TIME_BY_FRAME,
/// DOCME
2006-01-16 22:02:54 +01:00
RADIO_TIME_BY_TIME,
/// DOCME
2006-01-16 22:02:54 +01:00
STYLE_COMBOBOX,
/// DOCME
2006-01-16 22:02:54 +01:00
ACTOR_COMBOBOX,
/// DOCME
2006-01-16 22:02:54 +01:00
LAYER_BOX,
/// DOCME
2006-01-16 22:02:54 +01:00
STARTTIME_BOX,
/// DOCME
2006-01-16 22:02:54 +01:00
ENDTIME_BOX,
/// DOCME
2006-01-16 22:02:54 +01:00
DURATION_BOX,
/// DOCME
2006-01-16 22:02:54 +01:00
MARGINL_BOX,
/// DOCME
2006-01-16 22:02:54 +01:00
MARGINR_BOX,
/// DOCME
2006-01-16 22:02:54 +01:00
MARGINV_BOX,
/// DOCME
EFFECT_BOX,
/// DOCME
2006-01-16 22:02:54 +01:00
COMMENT_CHECKBOX,
/// DOCME
2006-01-16 22:02:54 +01:00
BUTTON_BOLD,
/// DOCME
2006-01-16 22:02:54 +01:00
BUTTON_ITALICS,
/// DOCME
2006-01-16 22:02:54 +01:00
BUTTON_UNDERLINE,
/// DOCME
2006-01-16 22:02:54 +01:00
BUTTON_STRIKEOUT,
/// DOCME
2006-01-16 22:02:54 +01:00
BUTTON_FONT_NAME,
/// DOCME
2006-01-16 22:02:54 +01:00
BUTTON_COLOR1,
/// DOCME
2006-01-16 22:02:54 +01:00
BUTTON_COLOR2,
/// DOCME
2006-01-16 22:02:54 +01:00
BUTTON_COLOR3,
/// DOCME
BUTTON_COLOR4,
/// DOCME
BUTTON_COMMIT
2006-01-16 22:02:54 +01:00
};