File: SToolBar.h

package info (click to toggle)
yudit 3.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 18,472 kB
  • sloc: cpp: 76,344; perl: 5,630; makefile: 989; ansic: 823; sh: 441
file content (145 lines) | stat: -rw-r--r-- 4,461 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/** 
 *  Yudit Unicode Editor Source File
 *
 *  GNU Copyright (C) 1997-2023  Gaspar Sinai <gaspar@yudit.org>  
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License, version 2,
 *  dated June 1991. See file COPYYING for details.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef SToolBar_h
#define SToolBar_h

#include "stoolkit/SProperties.h"
#include "swidget/SPanel.h"
#include "swidget/SButton.h"
#include "swidget/SLabel.h"
#include "stoolkit/SBinVector.h"
#include "stoolkit/SCharClass.h"
#include "stoolkit/SEvent.h"

class SIconUpdater : public SEventTarget
{
public:
  SIconUpdater (SWindow* _w, SButton* label, 
       int* currentEvent, int* displayEvent);
  ~SIconUpdater();
  bool timeout (const SEventSource* s);
  void start ();
  void setEncrypted(bool is);
private:
  bool           isEncrypted;
  SButton*       label;
  int*           currentEvent; 
  int*           displayEvent; 
  STimer*        eventTimer;
  SWindow*       window;
};

/**
 * A caret that redraws itself differently for lr and rl text 
 */
class SToolBarListener
{
public:
  SToolBarListener(void);
  virtual ~SToolBarListener();
  virtual void toolBarButtonPressed (void* src, int button, bool accel)=0;
  virtual void toolBarButtonEnter (void* src, int button);
  virtual void toolBarButtonLeave (void* src, int button);
};

class SToolBar  : public SPanel, public SButtonListener, public SSyntaxListener
{
public:
  enum SButtonIndex {SS_OPEN=0, 
   SS_SAVE, SS_PRINT, SS_PRINT_PREVIEW, SS_FIND, SS_GOTO, 
   SS_UNDO, SS_REDO, SS_DOCUMENT_EMBEDDING, SS_SET_OVERRIDE, SS_SET_EMBEDDING,
   SS_YIELD_EMBEDDING, SS_MAGNIFY_MINUS, SS_MAGNIFY_PLUS, 
   SS_HIGHLIGHTING,
   SS_FONT, SS_INPUT, SS_PARAGRAPH_BREAK, SS_MAX };

  SToolBar (const SProperties props);
  virtual ~SToolBar ();

  SButton* buttons[SS_MAX];
  void setListener (SToolBarListener* listener);
  void setFileName (const SString& fileName, const SString& encoding); 
  void setEncrypted (bool is); 
  void setHighlightName (const SString& _fileType);
  void inputChanged (const SStringVector& _inputs, unsigned int _current);

  virtual void buttonPressedAccel (void* source, const SAccelerator* accel);
  virtual void leaveComponent (void* source);
  virtual void enterComponent (void* source);
  virtual void redraw(SCanvas* w, int x, int y,
     unsigned int width ,unsigned int height);
  virtual void resize(const SDimension & d);
  // SSyntaxListener
  virtual void syntaxChanged (SS_EventType _evnt);

  unsigned int  currentFontSize;
  SStringVector fontsizes;
  unsigned int  currentInput;
  SStringVector inputs;
  unsigned int  currentFont;
  SStringVector fonts;

  enum SFormatIndex { SS_FORMAT_UNIX=0, SS_FORMAT_DOS, 
     SS_FORMAT_MAC, SS_FORMAT_PS };

  void setParagraphSeparator (int index, bool notify);
  void setEmbedding (SS_Embedding index, bool notify);

  SStringVector paragraphBreakStrings;
  unsigned int  currentParagraphSeparator;
  SS_Embedding  currentEmbedding;
  SStringVector paragraphBreaks;
  void          directionChanged (bool islr);
  bool   editorLR;

  void   setModified (bool flag);
  void   setPrinting (bool flag);

  bool   overrideLR;
  bool   embedLR;
  bool   currentLR;

  bool   modified;
  bool   printing;

private:
  SOpaqueLabel*     title;
  SOpaqueLabel*     titleEncoding;
  SLabel*           tooltip;
  SStringVector     displayInputs;
  SIconUpdater*     iconUpdater;
  SString           highlightName;

  void setFont (int index);
  void setFontSize (int index);
  void setInput (int index);
  void setButton (SButtonIndex index, const SString& txt, bool notify);
  void buildDisplayInputs();

  SDimension getMaxSize(SButton* b, const SStringVector&l, const SString& str);
  void setFAccelerator (SButton* b, unsigned int se, bool ctrl);
  int getFAccelerator (const SAccelerator* accel);
  unsigned int preferredWidth;
  SToolBarListener* listener;
  bool  xmanagerCludge;
  int   currentEvent;
  int   displayEvent;
};

#endif /* SToolBar_h */