From 8666d35f7c3129c101029eae1cd0a5124f35b7de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Konopacki?= Date: Mon, 20 Aug 2012 14:05:36 +0200 Subject: UI porting --- src/ui/edit.h | 123 +++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 78 insertions(+), 45 deletions(-) (limited to 'src/ui/edit.h') diff --git a/src/ui/edit.h b/src/ui/edit.h index dbd94d1..99ec693 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,99 @@ // * 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 "common/struct.h" #include "ui/control.h" +namespace Gfx{ +class CEngine; +}; -class CD3DEngine; +namespace Ui { class CScroll; +//! 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 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 - -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 +116,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); @@ -98,45 +130,45 @@ public: void SetText(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); 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(); @@ -145,8 +177,8 @@ public: void HyperFlush(); void HyperHome(char *filename); - bool HyperTest(EventMsg event); - bool HyperGo(EventMsg event); + bool HyperTest(EventType event); + bool HyperGo(EventType event); void SetFontSize(float size); @@ -189,7 +221,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); @@ -246,3 +278,4 @@ protected: }; +} -- cgit v1.2.3-1-g7c22 From 6ba0f42f22a170625f15879e01b4653a4ac153a1 Mon Sep 17 00:00:00 2001 From: erihel Date: Fri, 31 Aug 2012 22:28:07 +0200 Subject: latest changes; few more classes should compile now --- src/ui/edit.h | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) (limited to 'src/ui/edit.h') diff --git a/src/ui/edit.h b/src/ui/edit.h index 99ec693..22ac577 100644 --- a/src/ui/edit.h +++ b/src/ui/edit.h @@ -24,15 +24,26 @@ #pragma once -//#include "common/struct.h" -#include "ui/control.h" +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include + -namespace Gfx{ -class CEngine; -}; namespace Ui { -class CScroll; + //! maximum number of characters in CBOT edit @@ -128,13 +139,13 @@ 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* 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 GetMaxChar(); @@ -176,7 +187,7 @@ public: bool Undo(); void HyperFlush(); - void HyperHome(char *filename); + void HyperHome(const char *filename); bool HyperTest(EventType event); bool HyperGo(EventType event); @@ -195,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); @@ -232,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 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 -- cgit v1.2.3-1-g7c22