| 1 |
// ---------------------------------------------------------------------------- |
| 2 |
// Font_Browser.h v 0.0.1 2005-10-17 |
| 3 |
// |
| 4 |
// for the Fast Light Tool Kit (FLTK) 1.1.x . |
| 5 |
// |
| 6 |
// David Freese, [email protected] |
| 7 |
// based on similar widget by Mariwan Jalal |
| 8 |
// |
| 9 |
// ---------------------------------------------------------------------------- |
| 10 |
// Copyright (C) 2014 |
| 11 |
// David Freese, W1HKJ |
| 12 |
// |
| 13 |
// This file is part of flmsg |
| 14 |
// |
| 15 |
// flrig is free software; you can redistribute it and/or modify |
| 16 |
// it under the terms of the GNU General Public License as published by |
| 17 |
// the Free Software Foundation; either version 3 of the License, or |
| 18 |
// (at your option) any later version. |
| 19 |
// |
| 20 |
// flrig is distributed in the hope that it will be useful, |
| 21 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 23 |
// GNU General Public License for more details. |
| 24 |
// |
| 25 |
// You should have received a copy of the GNU General Public License |
| 26 |
// along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 27 |
// ---------------------------------------------------------------------------- |
| 28 |
|
| 29 |
#ifndef FONTBROWSER_H |
| 30 |
#define FONTBROWSER_H |
| 31 |
|
| 32 |
#include <FL/Enumerations.H> |
| 33 |
#include <FL/Fl_Window.H> |
| 34 |
#include <FL/Fl_Widget.H> |
| 35 |
#include <FL/Fl_Browser.H> |
| 36 |
#include <FL/Fl_Button.H> |
| 37 |
#include <FL/Fl_Return_Button.H> |
| 38 |
#include "flslider2.h" |
| 39 |
|
| 40 |
// Preview box for showing font |
| 41 |
class Preview_Box : public Fl_Widget |
| 42 |
{ |
| 43 |
private: |
| 44 |
int fontName; |
| 45 |
int fontSize; |
| 46 |
Fl_Color fontColor; |
| 47 |
|
| 48 |
void draw(); |
| 49 |
public: |
| 50 |
Preview_Box(int x, int y, int w, int h, const char* l); |
| 51 |
void SetFont( int fontname, int fontsize, Fl_Color c); |
| 52 |
}; |
| 53 |
|
| 54 |
// Font browser widget |
| 55 |
class Font_Browser : public Fl_Window |
| 56 |
{ |
| 57 |
public: |
| 58 |
enum filter_t { FIXED_WIDTH, VARIABLE_WIDTH, ALL_TYPES }; |
| 59 |
|
| 60 |
private: |
| 61 |
int numfonts; |
| 62 |
Fl_Font fontnbr; |
| 63 |
int fontsize; |
| 64 |
Fl_Color fontcolor; |
| 65 |
filter_t filter; |
| 66 |
void *data_; |
| 67 |
|
| 68 |
Fl_Browser *lst_Font; |
| 69 |
Fl_Browser *lst_Size; |
| 70 |
Fl_Value_Input2 *txt_Size; |
| 71 |
Fl_Return_Button *btn_OK; |
| 72 |
Fl_Button *btn_Cancel; |
| 73 |
Fl_Button *btn_Color; |
| 74 |
Preview_Box *box_Example; |
| 75 |
|
| 76 |
void FontSort(); |
| 77 |
Fl_Callback* callback_; |
| 78 |
|
| 79 |
public: |
| 80 |
Font_Browser(int x = 100, int y = 100, int w = 430, int h = 225, const char *lbl = "Font Browser"); |
| 81 |
void callback(Fl_Callback* cb, void *d = 0) { callback_ = cb; data_ = d; } |
| 82 |
static void fb_callback(Fl_Widget* w, void* arg); |
| 83 |
void FontNameSelect(); |
| 84 |
void ColorSelect(); |
| 85 |
|
| 86 |
int numFonts() { return numfonts; } |
| 87 |
void fontNumber(Fl_Font n); |
| 88 |
Fl_Font fontNumber() { return fontnbr; } |
| 89 |
void fontSize(int s); |
| 90 |
int fontSize() { return fontsize; } |
| 91 |
void fontColor(Fl_Color c); |
| 92 |
Fl_Color fontColor() { return fontcolor; }; |
| 93 |
|
| 94 |
const char *fontName() { return lst_Font->text(lst_Font->value()); } |
| 95 |
void fontName(const char* n); |
| 96 |
|
| 97 |
static bool fixed_width(Fl_Font f); |
| 98 |
void fontFilter(filter_t filter); |
| 99 |
}; |
| 100 |
|
| 101 |
extern Font_Browser* font_browser; |
| 102 |
|
| 103 |
#endif |