OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
uinotepad.h
1/*
2===========================================================================
3Copyright (C) 2024 the OpenMoHAA team
4
5This file is part of OpenMoHAA source code.
6
7OpenMoHAA source code is free software; you can redistribute it
8and/or modify it under the terms of the GNU General Public License as
9published by the Free Software Foundation; either version 2 of the License,
10or (at your option) any later version.
11
12OpenMoHAA source code is distributed in the hope that it will be
13useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with OpenMoHAA source code; if not, write to the Free Software
19Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20===========================================================================
21*/
22
23#pragma once
24
25class UINotepad;
26
27class UINotepadEdit : public UIMultiLineEdit {
28protected:
29 UINotepad *m_notepad;
30
31public:
32 CLASS_PROTOTYPE( UINotepadEdit );
33
34public:
35 UINotepadEdit();
36
37 void CharEvent( int ch ) override;
38 void setNotepad( UINotepad *notepad );
39 bool GotoLine( int line );
40 bool FindText( const char *text, int offsetFromSel );
41 void MousePressed( Event *ev );
42};
43
44typedef enum { STATE_NONE, STATE_GOTO_LINE, STATE_FIND_TEXT, STATE_SAVE_AS, STATE_TIMED_MESSAGE, STATE_CONFIRMCLOSE } state_t;
45
46typedef struct textinput_s {
47 str text;
48} textinput_t;
49
50typedef struct timedmessage_s {
51 int die;
52 str text;
53} timedmessage_t;
54
55typedef struct ctrlevent_s {
56 char ch;
57 Event *ev;
58} ctrlevent_t;
59
60class UINotepad : public UIFloatingWindow {
61 friend class UINotepadEdit; // UINotepadEdit needs m_state
62private:
64
65protected:
66 state_t m_state;
67 textinput_s m_textinput;
68 timedmessage_s m_timedmessage;
69 str m_lastfind;
70 str m_filename;
71 UINotepadEdit *m_edit;
72 UIStatusBar *m_status;
73 class UIPulldownMenu *m_menu;
74
75public:
76 CLASS_PROTOTYPE( UINotepad );
77
78protected:
79 void TimeMessage( const char *message, int howlong );
80
81public:
82 UINotepad();
83 ~UINotepad();
84
85 bool OpenFile( const char *filename );
86 bool Create( UIWidget *parent, UIRect2D& rect, const char *filename );
87 void ChildSizeChanged( Event *ev );
88 void SaveAs( Event *ev );
89 void Save( Event *ev );
90 void Open( Event *ev );
91 void OpenFile( Event *ev );
92 void ClosePressed( Event *ev );
93 void OnFind( Event *ev );
94 void OnGoto( Event *ev );
95 void OnCopy( Event *ev );
96 void OnPaste( Event *ev );
97 void OnCut( Event *ev );
98 bool ProcessControlEvents( int ch );
99 bool ProcessCharEvent( int ch );
100 void Draw( void ) override;
101 void setFileName( const char *filename );
102};
103
104bool UI_LoadNotepadFile( const char *filename );
Definition container.h:85
Definition listener.h:246
Definition uinotepad.h:60
Definition uipulldownmenu.h:62
Definition uirect2d.h:28
Definition uistatus.h:56
Definition str.h:77
Definition uinotepad.h:55
Definition uinotepad.h:46
Definition uinotepad.h:50