Skip to content

Commit

Permalink
use unicode symbols as check browser icons, update submodules
Browse files Browse the repository at this point in the history
  • Loading branch information
darealshinji committed Sep 4, 2020
1 parent e4529b5 commit 49424fd
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 186 deletions.
2 changes: 1 addition & 1 deletion args
Submodule args updated 1 files
+6 −1 args.hxx
2 changes: 1 addition & 1 deletion fltk
Submodule fltk updated 830 files
19 changes: 9 additions & 10 deletions fltk_patches.diff
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--- a/FL/Fl_Help_Dialog.H
+++ b/FL/Fl_Help_Dialog.H
@@ -43,8 +43,9 @@ class FL_EXPORT Fl_Help_Dialog {
int find_pos_;
@@ -41,8 +41,9 @@ class FL_EXPORT Fl_Help_Dialog {
int find_pos_;
public:
Fl_Help_Dialog();
-private:
Expand All @@ -11,7 +11,7 @@
Fl_Button *back_;
inline void cb_back__i(Fl_Button*, void*);
static void cb_back_(Fl_Button*, void*);
@@ -63,6 +64,8 @@ private:
@@ -61,6 +62,8 @@ private:
Fl_Help_View *view_;
inline void cb_view__i(Fl_Help_View*, void*);
static void cb_view_(Fl_Help_View*, void*);
Expand All @@ -22,10 +22,10 @@
int h();
--- a/src/Fl_Choice.cxx
+++ b/src/Fl_Choice.cxx
@@ -187,14 +187,14 @@ int Fl_Choice::handle(int e) {
@@ -185,14 +185,14 @@ int Fl_Choice::handle(int e) {
J1:
if (Fl::scheme()
|| fl_contrast(textcolor(), FL_BACKGROUND2_COLOR) != textcolor()) {
|| fl_contrast(textcolor(), FL_BACKGROUND2_COLOR) != textcolor()) {
- v = menu()->pulldown(x(), y(), w(), h(), mvalue(), this);
+ v = menu()->pulldown(x(), y(), w(), h(), 0, this);
if (wp.deleted()) return 1;
Expand All @@ -41,7 +41,7 @@
}
--- a/src/Fl_Color_Chooser.cxx
+++ b/src/Fl_Color_Chooser.cxx
@@ -571,7 +571,7 @@ Fl_Color_Chooser::Fl_Color_Chooser(int X, int Y, int W, int H, const char* L)
@@ -569,7 +569,7 @@ Fl_Color_Chooser::Fl_Color_Chooser(int X, int Y, int W, int H, const char* L)
bvalue.callback(rgb_cb);
choice.callback(mode_cb);
choice.box(FL_THIN_UP_BOX);
Expand All @@ -52,7 +52,7 @@
////////////////////////////////////////////////////////////////
--- a/src/Fl_Help_Dialog.cxx
+++ b/src/Fl_Help_Dialog.cxx
@@ -144,6 +144,9 @@ void Fl_Help_Dialog::cb_view__i(Fl_Help_View*, void*) {
@@ -142,6 +142,9 @@ void Fl_Help_Dialog::cb_view__i(Fl_Help_View*, void*) {
void Fl_Help_Dialog::cb_view_(Fl_Help_View* o, void* v) {
((Fl_Help_Dialog*)(o->parent()->user_data()))->cb_view__i(o,v);
}
Expand All @@ -62,7 +62,7 @@

Fl_Help_Dialog::Fl_Help_Dialog() {
{ window_ = new Fl_Double_Window(530, 385, "Help Dialog");
@@ -173,10 +176,10 @@ Fl_Help_Dialog::Fl_Help_Dialog() {
@@ -171,10 +174,10 @@ Fl_Help_Dialog::Fl_Help_Dialog() {
larger_->labelsize(16);
larger_->callback((Fl_Callback*)cb_larger_);
} // Fl_Button* larger_
Expand All @@ -75,7 +75,7 @@
find_->tooltip("find text in document");
find_->box(FL_FLAT_BOX);
find_->labelsize(13);
@@ -186,6 +189,12 @@ Fl_Help_Dialog::Fl_Help_Dialog() {
@@ -184,6 +187,12 @@ Fl_Help_Dialog::Fl_Help_Dialog() {
} // Fl_Input* find_
o->end();
} // Fl_Group* o
Expand All @@ -88,4 +88,3 @@
{ Fl_Box* o = new Fl_Box(150, 10, 190, 25);
Fl_Group::current()->resizable(o);
} // Fl_Box* o

1 change: 0 additions & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ _SRCS = \
notify.cpp \
progress.cpp \
radiolist.cpp \
radiolist_browser.cpp \
textinfo.cpp \
$(NULL)

Expand Down
40 changes: 38 additions & 2 deletions src/checklist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,42 @@

#include "fltk-dialog.hpp"

class checklist_browser : public Fl_Check_Browser
{
public:
checklist_browser(int X, int Y, int W, int H) : Fl_Check_Browser(X, Y, W, H) { }

/* The destructor deletes all list items and destroys the browser. */
~checklist_browser() { clear(); }

protected:
void item_draw(void *v, int X, int Y, int, int) const
{
/* https://unicode-table.com/en/blocks/miscellaneous-symbols/ */
const char *u = "\u2610"; /* Ballot Box */
const char *c = "\u2611"; /* Ballot Box with Check */
//const char *c = "\u2612"; /* Ballot Box with X */

cb_item *i = reinterpret_cast<cb_item *>(v);
int tsize = textsize();
Fl_Color col = active_r() ? textcolor() : fl_inactive(textcolor());

X += 2;
Y += tsize - 1;

fl_color(active_r() ? FL_FOREGROUND_COLOR : fl_inactive(FL_FOREGROUND_COLOR));
fl_font(FL_HELVETICA, tsize);
fl_draw(i->checked ? c : u, X, Y);

fl_font(textfont(), tsize);
if (i->selected) {
col = fl_contrast(col, selection_color());
}
fl_color(col);
fl_draw(i->text, X + tsize + 4, Y);
}
};

static Fl_Double_Window *win;
static int ret = 1;

Expand Down Expand Up @@ -70,7 +106,7 @@ int dialog_checklist(std::string checklist_options, bool return_value, bool chec
{
g_inside = new Fl_Group(0, 0, 420, 310);
{
browser = new Fl_Check_Browser(10, 10, 400, 299);
browser = new checklist_browser(10, 10, 400, 299);
browser->box(FL_THIN_DOWN_BOX);
browser->color(fl_lighter(fl_lighter(FL_BACKGROUND_COLOR)));
browser->clear_visible_focus();
Expand Down Expand Up @@ -120,7 +156,7 @@ int dialog_checklist(std::string checklist_options, bool return_value, bool chec
}
} else {
list.append(quote);
list += (browser->checked(i)) ? "TRUE" : "FALSE";
list += browser->checked(i) ? "TRUE" : "FALSE";
list.append(quote);
list.push_back(separator);
}
Expand Down
43 changes: 42 additions & 1 deletion src/radiolist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,48 @@
#include <vector>

#include "fltk-dialog.hpp"
#include "radiolist_browser.hpp"

class radiolist_browser : public Fl_Check_Browser
{
public:
radiolist_browser(int X, int Y, int W, int H) : Fl_Check_Browser(X, Y, W, H) { }

/* The destructor deletes all list items and destroys the browser. */
~radiolist_browser() { clear(); }

void item_select(void *v, int) {
check_none();
reinterpret_cast<cb_item *>(v)->checked = 1;
redraw();
}

protected:
void item_draw(void *v, int X, int Y, int, int) const
{
/* https://unicode-table.com/en/blocks/geometric-shapes/ */
const char *u = "\u25CB"; /* White Circle */
const char *c = "\u25C9"; /* Fisheye */
//const char *c = "\u25CF"; /* Black Circle */

cb_item *i = reinterpret_cast<cb_item *>(v);
int tsize = textsize();
Fl_Color col = active_r() ? textcolor() : fl_inactive(textcolor());

X += 2;
Y += tsize - 1;

fl_color(active_r() ? FL_FOREGROUND_COLOR : fl_inactive(FL_FOREGROUND_COLOR));
fl_font(FL_HELVETICA, tsize);
fl_draw(i->checked ? c : u, X, Y - 1);

fl_font(textfont(), tsize);
if (i->selected) {
col = fl_contrast(col, selection_color());
}
fl_color(col);
fl_draw(i->text, X + tsize + 4, Y);
}
};

static Fl_Double_Window *win;
static Fl_Return_Button *but_ok;
Expand Down
110 changes: 0 additions & 110 deletions src/radiolist_browser.cpp

This file was deleted.

60 changes: 0 additions & 60 deletions src/radiolist_browser.hpp

This file was deleted.

0 comments on commit 49424fd

Please sign in to comment.