diff options
Diffstat (limited to 'src/ui/edit.h')
-rw-r--r-- | src/ui/edit.h | 155 |
1 files changed, 100 insertions, 55 deletions
diff --git a/src/ui/edit.h b/src/ui/edit.h index dbd94d1..22ac577 100644 --- a/src/ui/edit.h +++ b/src/ui/edit.h @@ -1,5 +1,6 @@ // * This file is part of the COLOBOT source code // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch +// * Copyright (C) 2012, Polish Portal of Colobot (PPC) // * // * This program is free software: you can redistribute it and/or modify // * it under the terms of the GNU General Public License as published by @@ -14,69 +15,110 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. -// edit.h + +/** + * \file ui/edit.h + * \brief CEdit class + */ #pragma once -#include "common/struct.h" -#include "ui/control.h" +#include <ui/control.h> +#include <ui/scroll.h> + +#include <graphics/engine/engine.h> +#include <graphics/engine/text.h> + +#include <common/language.h> +#include <common/event.h> +#include <common/misc.h> +#include <common/iman.h> +#include <common/restext.h> + +#include <app/app.h> + +#include <vector> + -class CD3DEngine; -class CScroll; +namespace Ui { -const int EDITSTUDIOMAX = 20000; // maximum number of characters in CBOT edit -const int EDITLINEMAX = 1000; // maximum total number of lines -const int EDITIMAGEMAX = 50; // maximum total number of lines with images -const int EDITLINKMAX = 100; // maximum number of links -const int EDITHISTORYMAX = 50; // max number of levels preserves +//! maximum number of characters in CBOT edit +const int EDITSTUDIOMAX = 20000; +//! maximum total number of lines +const int EDITLINEMAX = 1000; +//! maximum total number of lines with images +const int EDITIMAGEMAX = 50; +//! maximum number of links +const int EDITLINKMAX = 100; +//! max number of levels preserves +const int EDITHISTORYMAX = 50; -const int EDITUNDOMAX = 20; // max number of successive undo +//! max number of successive undo +const int EDITUNDOMAX = 20; struct EditUndo { - char* text; // original text - int len; // length of the text - int cursor1; // offset cursor - int cursor2; // offset cursor - int lineFirst; // the first line displayed. + //! original text + char* text; + //! length of the text + int len; + //! offset cursor + int cursor1; + //! offset cursor + int cursor2; + //! the first line displayed. + int lineFirst; }; enum OperUndo { - OPERUNDO_SPEC = 0, // special operation - OPERUNDO_INSERT = 1, // inserting characters - OPERUNDO_DELETE = 2, // deleting characters + //! special operation + OPERUNDO_SPEC = 0, + //! inserting characters + OPERUNDO_INSERT = 1, + //! deleting characters + OPERUNDO_DELETE = 2, }; struct ImageLine { - char name[40]; // name of the image (without diagram \) - float offset; // vertical offset (v texture) - float height; // height of the part (dv texture) - float width; // width + //! name of the image (without diagram \) + char name[40]; + //! vertical offset (v texture) + float offset; + //! height of the part (dv texture) + float height; + //! width + float width; }; struct HyperLink { - char name[40]; // text file name (without help \) - char marker[20]; // name of the marker + //! text file name (without help \) + char name[40]; + //! name of the marker + char marker[20]; }; struct HyperMarker { - char name[20]; // name of the marker - int pos; // position in the text + //! name of the marker + char name[20]; + //! position in the text + int pos; }; struct HyperHistory { - char filename[50]; // full file name text - int firstLine; // rank of the first displayed line + //! full file name text + char filename[50]; + //! rank of the first displayed line + int firstLine; }; @@ -85,10 +127,11 @@ struct HyperHistory class CEdit : public CControl { public: - CEdit(CInstanceManager* iMan); +// CEdit(CInstanceManager* iMan); + CEdit (); virtual ~CEdit(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg); + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType); void SetPos(Math::Point pos); void SetDim(Math::Point dim); @@ -96,47 +139,47 @@ public: bool EventProcess(const Event &event); void Draw(); - void SetText(char *text, bool bNew=true); + void SetText(const char *text, bool bNew=true); void GetText(char *buffer, int max); - char* RetText(); - int RetTextLength(); + char* GetText(); + int GetTextLength(); - bool ReadText(char *filename, int addSize=0); - bool WriteText(char *filename); + bool ReadText(const char *filename, int addSize=0); + bool WriteText(const char *filename); void SetMaxChar(int max); - int RetMaxChar(); + int GetMaxChar(); void SetEditCap(bool bMode); - bool RetEditCap(); + bool GetEditCap(); void SetHiliteCap(bool bEnable); - bool RetHiliteCap(); + bool GetHiliteCap(); void SetInsideScroll(bool bInside); - bool RetInsideScroll(); + bool GetInsideScroll(); void SetSoluceMode(bool bSoluce); - bool RetSoluceMode(); + bool GetSoluceMode(); void SetGenericMode(bool bGeneric); - bool RetGenericMode(); + bool GetGenericMode(); void SetAutoIndent(bool bMode); - bool RetAutoIndent(); + bool GetAutoIndent(); void SetCursor(int cursor1, int cursor2); void GetCursor(int &cursor1, int &cursor2); void SetFirstLine(int rank); - int RetFirstLine(); + int GetFirstLine(); void ShowSelect(); void SetDisplaySpec(bool bDisplay); - bool RetDisplaySpec(); + bool GetDisplaySpec(); void SetMultiFont(bool bMulti); - bool RetMultiFont(); + bool GetMultiFont(); bool Cut(); bool Copy(); @@ -144,9 +187,9 @@ public: bool Undo(); void HyperFlush(); - void HyperHome(char *filename); - bool HyperTest(EventMsg event); - bool HyperGo(EventMsg event); + void HyperHome(const char *filename); + bool HyperTest(EventType event); + bool HyperGo(EventType event); void SetFontSize(float size); @@ -163,15 +206,15 @@ protected: int MouseDetect(Math::Point mouse); void MoveAdjust(); - void HyperJump(char *name, char *marker); - bool HyperAdd(char *filename, int firstLine); + void HyperJump(const char *name, const char *marker); + bool HyperAdd(const char *filename, int firstLine); - void DrawImage(Math::Point pos, char *name, float width, float offset, float height, int nbLine); + void DrawImage(Math::Point pos, const char *name, float width, float offset, float height, int nbLine); void DrawBack(Math::Point pos, Math::Point dim); void DrawPart(Math::Point pos, Math::Point dim, int icon); void FreeImage(); - void LoadImage(char *name); + void LoadImage(const char *name); void Scroll(int pos, bool bAdjustCursor); void Scroll(); void MoveChar(int move, bool bWord, bool bSelect); @@ -189,7 +232,7 @@ protected: bool Shift(bool bLeft); bool MinMaj(bool bMaj); void Justif(); - int RetCursorLine(int cursor); + int GetCursorLine(int cursor); void UndoFlush(); void UndoMemorize(OperUndo oper); @@ -200,10 +243,11 @@ protected: int m_maxChar; // max length of the buffer m_text char* m_text; // text (without zero terminator) - char* m_format; // format characters + std::vector<Gfx::FontMetaChar> m_format; // format characters int m_len; // length used in m_text int m_cursor1; // offset cursor int m_cursor2; // offset cursor + CApplication *m_app; bool m_bMulti; // true -> multi-line bool m_bEdit; // true -> editable @@ -246,3 +290,4 @@ protected: }; +} |