OpendTect  6.3
uifont.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*+
4 ________________________________________________________________________
5 
6  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
7  Author: A.H. Lammertink
8  Date: 22/05/2000
9 ________________________________________________________________________
10 
11 -*/
12 #include "uibasemod.h"
13 #include "fontdata.h"
14 #include "uistring.h"
15 #include "notify.h"
16 
17 class uiFont;
18 class uiParent;
19 class BufferStringSet;
20 class Settings;
21 mFDQtclass(QFont)
22 mFDQtclass(QFontMetrics)
23 
24 
25 mGlobal(uiBase) bool selectFont(uiFont&,uiParent* =0,
26  const uiString& title=uiString::emptyString());
31 mGlobal(uiBase) bool selectFont(FontData&,uiParent* =0,
32  const uiString& title = uiString::emptyString());
38 mExpClass(uiBase) uiFont : public CallBacker
39 {
40 friend class uiFontList;
41 
42 public:
43  virtual ~uiFont();
44 
45  uiFont& operator=(const uiFont&);
46 
47  FontData fontData() const ;
48  void setFontData(const FontData&);
50  static void setFontData(mQtclass(QFont)&,const FontData&);
51  static void getFontData(FontData&,const mQtclass(QFont)&);
52  static mQtclass(QFont)* createQFont(const FontData&);
53 
54  inline const mQtclass(QFont&) qFont() const { return *qfont_; }
55 
56  int height() const;
57  int leading() const;
58  int maxWidth() const;
59  int avgWidth() const;
60  int width(const uiString&) const;
61  int ascent() const;
62  int descent() const;
63 
64  const char* key() const { return key_; }
66 
67 protected:
69  uiFont(const char* ky, const char* family,
72  bool it=FontData::defaultItalic());
73  uiFont(const char* ky,FontData fd=FontData());
74  uiFont(const uiFont&);
75 
76  // don't change order of these attributes!
77  mQtclass(QFont*) qfont_;
78  mQtclass(QFontMetrics&) qfontmetrics_;
79 
81 
82  void updateMetrics();
83 };
84 
85 
86 mExpClass(uiBase) uiFontList : public CallBacker
87 {
88 friend class uiFontSettingsGroup;
89 
90 public:
91 
92  uiFontList() : inited_(false) {}
93  ~uiFontList();
94  static uiFontList& getInst();
95 
96  int nrKeys();
97  const char* key(int);
98  void listKeys(BufferStringSet&);
99 
100  const ObjectSet<uiFont>& fonts() const { return fonts_; }
101  ObjectSet<uiFont>& fonts() { return fonts_; }
102 
103  uiFont& get(const char* ky=0);
104  uiFont& get(FontData::StdSz);
105  uiFont& getFromQfnt(mQtclass(QFont*));
106 
107  uiFont& add(const char* ky,const FontData&);
108  uiFont& add(const char* ky,
109  const char* f=FontData::defaultFamily(),
110  int ptsz=FontData::defaultPointSize(),
112  bool it=FontData::defaultItalic());
113 
114  void update(Settings&);
115 
116 protected:
117 
119  void initialise();
120  uiFont& gtFont(const char*,const FontData* =0,
121  const mQtclass(QFont*) =0 );
122 
123  void use(const Settings&);
124 
125 private:
126 
127  bool inited_;
128 
129  void addOldGuess(const IOPar&,const char*);
130  void removeOldEntries(Settings&);
131  void setDefaults();
132 
133 };
134 
135 #define FontList uiFontList::getInst
#define mExpClass(module)
Definition: commondefs.h:157
Inherit from this class to be able to send and/or receive CallBacks.
Definition: callback.h:182
static bool defaultItalic()
uiFontList()
Definition: uifont.h:92
#define mQtclass(cls)
Definition: commondefs.h:232
#define mGlobal(module)
Definition: commondefs.h:160
bool inited_
Definition: uifont.h:127
Definition: uifont.h:38
Definition: uistring.h:88
mFDQtclass(QFont) mFDQtclass(QFontMetrics) bool selectFont(uiFont &
Definition: uiparent.h:24
Definition: uifont.h:86
Set of BufferString objects.
Definition: bufstringset.h:25
Weight
Definition: fontdata.h:22
Data needed to make an actual font.
Definition: fontdata.h:18
ObjectSet< uiFont > & fonts()
Definition: uifont.h:101
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:53
Settings class holds the user settings. It is an IOPar.
Definition: settings.h:32
const mQtclass(QFont &) qFont() const
Definition: uifont.h:54
static const char * defaultFamily()
uiParent const uiString & title
pops a selector box to select a new font
Definition: uifont.h:26
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:38
const ObjectSet< uiFont > & fonts() const
Definition: uifont.h:100
Definition: uifontsel.h:26
bool selectFont(FontData &, uiParent *=0, const uiString &title=uiString::emptyString())
pops a selector box to select a new font
StdSz
Definition: fontdata.h:66
ObjectSet< uiFont > fonts_
Definition: uifont.h:118
Notifier< uiFont > changed
Definition: uifont.h:65
const char * key() const
Definition: uifont.h:64
static Weight defaultWeight()
static int defaultPointSize()

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2017