* add dockable macros in a 4x12 matrix
    - provides access to all 48 macros.
    - group of 48 can be dragged to/from it's default position
      just below the main menu bar
  * change vertical raster height to 20 vice 60
    - decreased minimum vertical main dialog dimension for small
      netbook screens
  * update to documentation
pull/4/head
David Freese 2015-11-19 05:31:01 -06:00
rodzic 2e2c9e90f9
commit c86ec80332
25 zmienionych plików z 1203 dodań i 125 usunięć

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 34 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 16 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 8.0 KiB

Wyświetl plik

@ -30,9 +30,16 @@ fldigi macro bar positions will change immediately so you can see the
selection.
<br>
With 2 rows shown you obtain access to the primary set with normal
Function key press. The secondary set is accessed by a
SHIFT-Function-key press.
<center>
\image html macrobuttons.png "Macro Buttons"
\image latex macrobuttons.png "Macro Buttons" width=6.0in
</center>
<br>
<center>
\image html macro-scheme-4.png "Macro Buttons - Scheme 4"
\image latex macro-scheme-4.png "Macro Buttons - Scheme 4" width=6.0in
</center>
<br>
You edit any macro definition by using a mouse right-click on it's button.
@ -43,6 +50,25 @@ sub-sets. When checked you simply hover the mouse over the macro
bar and roll the mouse wheel.
<br>
All 48 macro buttons can be displayed in a matrix.
\image html macro-matrix.png "Macro Buttons Matrix"
\image latex macro-matrix.png "Macro Buttons Matrix" width=6.0in
<br>
The matrix display is toggled on and off using the menu item
<center>
\image html view-hide-48.png ""
\image latex view-hide-48.png "" width=1.0in
</center>
<br>
The matrix display can be dragged off and restored to it's position below
the main menu. The drag button is the knurled vertical button on the left
edge of the matrix. Left click on the drag button and drag the matrix with
the mouse.
<br>
Fldigi manages multiple files that contain macro definitions. You may
want to have the last used macro file be the one available the next time you
start fldigi. If so, simply enable the "load last used Macro file on

Wyświetl plik

@ -4,9 +4,17 @@
\tableofcontents
Macros are short text statements that contain imbedded references to text
data used by the program fldigi. Macro definition files(s) are located
in the $HOME/.fldigi/macros/ directory and all have the extention ".mdf". The
default set of macros are contained in the
data used by the program fldigi. A macro is accessed via the macro button
bar or function key.
<center>
\image html macrobuttons.png "Macro Buttons"
\image latex macrobuttons.png "Macro Buttons" width=6.0in
</center>
<br>
Macro definition files(s) are located in the $HOME/.fldigi/macros/ directory
and all have the extention ".mdf". The default set of macros are contained in the
file $HOME/.fldigi/macros/<b>macros.mdf</b>.
Fldigi will create this file with a set of default macros on its first
@ -15,7 +23,23 @@ execution.
Fldigi supports up to 48 macro definitions in sets of 12. Macro
definitions are not recursive, that is; a macro cannot reference
another macro or itself.
another macro or itself. All 48 macro buttons can be displayed in a matrix.
\image html macro-matrix.png "Macro Buttons Matrix"
\image latex macro-matrix.png "Macro Buttons Matrix" width=6.0in
<br>
The matrix display is toggled on and off using the menu item
<center>
\image html view-hide-48.png ""
\image latex view-hide-48.png "" width=1.0in
</center>
<br>
The matrix display can be dragged off and restored to it's position below
the main menu. The drag button is the knurled vertical button on the left
edge of the matrix. Left click on the drag button and drag the matrix with
the mouse.
<br>
The imbedded references are similar to those used by DigiPan and other

Wyświetl plik

@ -493,6 +493,12 @@ fldigi_SOURCES += \
include/psk_browser.h \
include/utf8file_io.h \
include/weather.h \
include/dock_events.h \
include/dock_gp.h \
include/drag_btn.h \
include/dropwin.h \
include/toolgrp.h \
include/toolwin.h \
irrxml/CXMLReaderImpl.h \
irrxml/fast_atof.h \
irrxml/heapsort.h \
@ -605,6 +611,11 @@ fldigi_SOURCES += \
widgets/psk_browser.cxx \
widgets/smeter.cxx \
widgets/pwrmeter.cxx \
widgets/dock_gp.cxx \
widgets/drag_btn.cxx \
widgets/dropwin.cxx \
widgets/toolgrp.cxx \
widgets/toolwin.cxx \
fsq/fsq.cxx \
ifkp/ifkp.cxx \
ifkp/tux.cxx \

Plik diff jest za duży Load Diff

Wyświetl plik

@ -55,6 +55,9 @@ LOG_FILE_SOURCE(debug::LOG_MODEM);
char feldmsg[80];
int feld::RxColumnLen = FELD_RX_COLUMN_LEN;
int feld::TxColumnLen = 14;
void feld::tx_init(SoundBase *sc)
{
scard = sc;

Wyświetl plik

@ -0,0 +1,9 @@
#ifndef _HAVE_DOCK_EVENTS_HDR_
#define _HAVE_DOCK_EVENTS_HDR_
# define FX_DROP_EVENT (FL_DND_RELEASE + 100)
# define DROP_REGION_HEIGHT 60
#endif

Wyświetl plik

@ -0,0 +1,31 @@
#ifndef _HAVE_DOCK_GRP_HDR_
#define _HAVE_DOCK_GRP_HDR_
#include <FL/Fl_Group.H>
#include <FL/Fl_Pack.H>
class dockgroup : public Fl_Group
{
protected:
Fl_Window *win;
Fl_Pack *pack;
int children;
int vis_h;
public:
// Normal FLTK constructors
dockgroup(int x, int y, int w, int h, const char *l = 0);
// point back to our parent
void set_window(Fl_Window *w) {win = w;}
// methods for adding or removing toolgroups from the dock
void add(Fl_Widget *w);
void remove(Fl_Widget *w);
// dock diagnostic
char *dock_check(void);
};
#endif // _HAVE_DOCK_GRP_HDR_

Wyświetl plik

@ -0,0 +1,27 @@
#ifndef _HAVE_DRAG_BTN_HDR_
#define _HAVE_DRAG_BTN_HDR_
#include <FL/Fl_Box.H>
class drag_btn : public Fl_Box
{
private:
int x1, y1; // click posn., used for dragging and docking checks
int xoff, yoff; // origin used for dragging calcs
int was_docked; // used in handle to note that we have just undocked
protected:
// override box draw method to do our textured dragger look
void draw();
// override handle method to catch drag/dock operations
int handle(int event);
public:
// basic constructor
drag_btn(int x, int y, int w, int h, const char *l = 0);
};
#endif // _HAVE_DRAG_BTN_HDR_
/* End of File */

Wyświetl plik

@ -0,0 +1,39 @@
#ifndef _HAVE_DROP_WIN_HDR_
#define _HAVE_DROP_WIN_HDR_
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Group.H>
#include "dock_gp.h"
class dropwin : public Fl_Double_Window
{
protected:
void init_dropwin(void);
dockgroup *dock;
int Wdrop;
int Hdrop;
public:
// Normal FLTK constructors
dropwin(int x, int y, int w, int h, const char *l = 0);
dropwin(int w, int h, const char *l = 0);
// The working area of this window
Fl_Group *workspace;
// override handle method to capture "drop" events
int handle(int);
// assign a dock widget to this window
void set_dock(dockgroup *d) {dock = d;}
// Resize the workspace area if the dock closes/opens
void dock_resize(int h);
void set_drop(int w, int h) { Wdrop = w; Hdrop = h; }
};
#endif // _HAVE_DROP_WIN_HDR_

Wyświetl plik

@ -37,15 +37,15 @@
#define FeldSampleRate 8000
#define FeldMaxSymLen 1024
#define RxColumnLen 30
#define TxColumnLen 14
#define PIXMAP_W 14
#define PIXMAP_H (TxColumnLen)
#define MAXLEN 512
#define FELD_RX_COLUMN_LEN 20
class feld : public modem {
enum FELD_STATE {PREAMBLE, POSTAMBLE, DATA};
public:
static int RxColumnLen;
static int TxColumnLen;
protected:
//rx
double rxphacc;
@ -55,7 +55,7 @@ protected:
double peakval;
double peakhold;
double minhold;
double rxpixrate;
double txpixrate;
double downsampleinc;
@ -89,7 +89,7 @@ protected:
double OnShape[MAXLEN];
double OffShape[MAXLEN];
mbuffer<int, 2*RxColumnLen> col_data;
mbuffer<int, 2*FELD_RX_COLUMN_LEN> col_data;
int col_pointer;
int fntnbr;

Wyświetl plik

@ -46,10 +46,13 @@
#include "smeter.h"
#include "pwrmeter.h"
#include "picture.h"
#include "dropwin.h"
extern fre_t seek_re;
extern Fl_Double_Window *fl_digi_main;
//extern Fl_Double_Window *fl_digi_main;
extern dropwin *fl_digi_main;
extern Fl_Double_Window *scopeview;
//extern Fl_Double_Window *opBrowserView;

Wyświetl plik

@ -24,6 +24,7 @@
#define _RASTER_H
#include <FL/Fl_Widget.H>
#include "feld.h"
class Raster : public Fl_Widget {
public:

Wyświetl plik

@ -37,6 +37,7 @@ struct status {
bool Rig_Log_UI;
bool Rig_Contest_UI;
bool DOCKEDSCOPE;
bool tbar_is_docked;
int RxTextHeight;
int tiled_group_x;
@ -71,6 +72,7 @@ struct status {
int tile_w;
int tile_y;
int tile_h;
double tile_y_ratio;
double fsq_ratio;
double ifkp_ratio;
bool LOGenabled;

Wyświetl plik

@ -0,0 +1,72 @@
#ifndef _HAVE_TOOL_GROUP_HDR_
#define _HAVE_TOOL_GROUP_HDR_
#include <FL/Fl_Group.H>
#include <FL/Fl_Button.H>
#include "dock_gp.h"
#include "drag_btn.h"
class toolgrp : public Fl_Group
{
private:
// control variables
short _docked;
dockgroup *dock;
// constructor helper function
void create_dockable_group(void);
void create_docked(dockgroup *d);
void create_floating(dockgroup *d, int state, int x, int y, int w, int h, const char *l);
protected:
// Widgets used by the toolbar
// Fl_Button *dismiss;
drag_btn *dragger;
Fl_Group *inner_group;
// Sets whether window is docked or not.
void docked(short r);
// Defines which dock the group can dock into
void set_dock(dockgroup *w) {dock = w;}
// get the dock group ID
dockgroup *get_dock(void) {return dock;}
// generic callback function for the dismiss button
// static void cb_dismiss(Fl_Button*, void* v);
public:
// Constructors for docked/floating window
toolgrp(dockgroup *d, int f, int w, int h, const char *l = 0);
toolgrp(dockgroup *d, int f, int x, int y, int w, int h, const char *l = 0);
// methods for hiding/showing *all* the floating windows
static void show_all(void);
static void hide_all(void);
// Tests whether window is docked, undocked or hidden
short docked() { return _docked; }
// generic callback function for the dock/undock checkbox
void dock_grp(void* v);
void undock_grp(void* v);
void hide_show();
// wrap some basic Fl_Group functions to access the enclosed inner_group
inline void begin() {inner_group->begin(); }
inline void end() {inner_group->end(); Fl_Group::end(); }
inline void resizable(Fl_Widget *box) {inner_group->resizable(box); }
inline void resizable(Fl_Widget &box) {inner_group->resizable(box); }
inline Fl_Widget *resizable() const { return inner_group->resizable(); }
inline void add( Fl_Widget &w ) { inner_group->add( w ); }
inline void add( Fl_Widget *w ) { inner_group->add( w ); }
inline void insert( Fl_Widget &w, int n ) { inner_group->insert( w, n ); }
inline void insert( Fl_Widget &w, Fl_Widget* beforethis ) { inner_group->insert( w, beforethis ); }
inline void remove( Fl_Widget &w ) { inner_group->remove( w ); }
inline void remove( Fl_Widget *w ) { inner_group->remove( w ); }
// inline void add_resizable( Fl_Widget &box ) { inner_group->add_resizable( box ); }
};
#endif // _HAVE_TOOL_GROUP_HDR_

Wyświetl plik

@ -0,0 +1,37 @@
#ifndef _HAVE_TOOLWIN_HDR_
#define _HAVE_TOOLWIN_HDR_
/* fltk includes */
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
class toolwin : public Fl_Double_Window
{
#define TW_MAX_FLOATERS 16
protected:
void create_dockable_window(void);
short idx;
static toolwin* active_list[TW_MAX_FLOATERS];
static short active;
void *tool_group;
public:
// Normal FLTK constructors
toolwin(int w, int h, const char *l = 0);
toolwin(int x, int y, int w, int h, const char *l = 0);
// destructor
~toolwin();
// methods for hiding/showing *all* the floating windows
static void show_all(void);
static void hide_all(void);
// set the inner group
void set_inner(void *v) {tool_group = v;}
};
#endif // _HAVE_TOOLWIN_HDR_
// End of file //

Wyświetl plik

@ -78,6 +78,7 @@ status progStatus = {
false, // bool Rig_Log_UI;
false, // bool Rig_Contest_UI;
false, // bool DOCKEDSCOPE;
false, // bool tbar_is_docked;
50, // int RxTextHeight;
WMIN/2, // int tiled_group_x;
false, // bool show_channels;
@ -110,6 +111,7 @@ status progStatus = {
200, // int tile_w;
90, // int tile_y;
150, // int tile_h;
0.5, // double tile_y_ratio;
0.5, // double fsq_ratio;
0.5, // double ifkp_ratio;
false, // bool LOGenabled
@ -251,6 +253,7 @@ void status::saveLastState()
tile_w = text_panel->w();
tile_y = progdefaults.rxtx_swap ? TransmitText->h() : ReceiveText->h();
tile_h = text_panel->h();
tile_y_ratio = 1.0 * tile_y / text_group->h();
if (text_panel->w() != ReceiveText->w())
tile_x = mvgroup->w();
fsq_ratio = 1.0 * fsq_rx_text->h() / fsq_group->h();
@ -363,6 +366,7 @@ if (!bWF_only) {
spref.set("rigcontest_ui", Rig_Contest_UI);
spref.set("noriglog", NO_RIGLOG);
spref.set("docked_scope", DOCKEDSCOPE);
spref.set("tbar_is_docked", tbar_is_docked);
spref.set("rigctl_x", rigX);
spref.set("rigctl_y", rigY);
@ -387,6 +391,7 @@ if (!bWF_only) {
spref.set("tile_y", tile_y);
spref.set("tile_w", tile_w);
spref.set("tile_h", tile_h);
spref.set("tile_y_ratio", tile_y_ratio);
spref.set("fsq_ratio", fsq_ratio);
spref.set("ifkp_ratio", ifkp_ratio);
@ -565,6 +570,7 @@ void status::loadLastState()
spref.get("rigcontest_ui", i, Rig_Contest_UI); Rig_Contest_UI = i;
spref.get("noriglog", i, NO_RIGLOG); NO_RIGLOG = i;
spref.get("docked_scope", i, DOCKEDSCOPE); DOCKEDSCOPE = i;
spref.get("tbar_is_docked", i, tbar_is_docked); tbar_is_docked = i;
spref.get("rigctl_x", rigX, rigX);
spref.get("rigctl_y", rigY, rigY);
@ -589,6 +595,7 @@ void status::loadLastState()
spref.get("tile_y", tile_y, tile_y);
spref.get("tile_w", tile_w, tile_w);
spref.get("tile_h", tile_h, tile_h);
spref.get("tile_y_ratio", tile_y_ratio, tile_y_ratio);
spref.get("fsq_ratio", fsq_ratio, fsq_ratio);
spref.get("ifkp_ratio", ifkp_ratio, ifkp_ratio);

Wyświetl plik

@ -40,7 +40,7 @@ Raster::Raster (int X, int Y, int W, int H) :
width = W - 4;
height = H - 4;
space = 2;
rowheight = 60;
rowheight = 2 * FELD_RX_COLUMN_LEN;//40;//60;
Nrows = (int)(height / (rowheight + space) - 0.5);
vidbuf = new unsigned char[width * height];
memset(vidbuf, 255, width * height);

Wyświetl plik

@ -0,0 +1,59 @@
#include <stdio.h>
#include <FL/Fl.H>
#include "dock_gp.h"
#include "dropwin.h"
// basic fltk constructors
dockgroup::dockgroup(int x, int y, int w, int h, const char *l)
: Fl_Group(x, y, w, h, l)
{
pack = new Fl_Pack(x, y, w, h);
pack->type(Fl_Pack::HORIZONTAL);
children = 0;
resizable(pack);
vis_h = h;
}
void dockgroup::add(Fl_Widget *grp)
{
int wd = w();
int ht = h();
// if the dock is "closed", open it back up
if (ht < vis_h)
{
dropwin *dw = (dropwin *)win;
size(wd, vis_h);
pack->size(wd, vis_h);
dw->dock_resize(ht - vis_h);
}
pack->add(grp);
pack->resizable(grp);
children++;
if (callback() != NULL) do_callback();
}
void dockgroup::remove(Fl_Widget *grp)
{
int wd = w();
pack->remove(grp);
children--;
pack->resizable(pack->child(pack->children() - 1));
// If the dock is empty, close it down
if (children <= 0) {
dropwin *dw = (dropwin *)win;
children = 0;
size(wd, 2);
dw->dock_resize(vis_h - 2);
}
if (callback() != NULL) do_callback();
}
char *dockgroup::dock_check(void)
{
static char szcheck[50];
snprintf(szcheck, sizeof(szcheck), "DG: %d - %dx%d", children, pack->w(), pack->h());
return szcheck;
}

Wyświetl plik

@ -0,0 +1,144 @@
#include <stdio.h>
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/fl_draw.H>
#include "drag_btn.h"
#include "dock_events.h"
#include "toolgrp.h"
static const char * grip_tile_xpm[] = {
"6 6 4 1",
" c None",
". c #FCFEFC",
"+ c #D4D6D4",
"@ c #9C9294",
".+++++",
"+@+.++",
"++++@+",
".+++++",
"+@+.++",
"++++@+"};
drag_btn::drag_btn(int x, int y, int w, int h, const char *l)
: Fl_Box(x, y, w, h, l)
{
was_docked = 0; // Assume we have NOT just undocked...
}
void drag_btn::draw()
{
int xo = x();
int yo = y();
// Draw the button box
draw_box(box(), color());
// set the clip region so we only "tile" the box
fl_push_clip(xo+1, yo+1, w()-3, h()-3);
// tile the pixmap onto the button face... there must be a better way
for(int i = 2; i <= w(); i += 6)
for(int j = 2; j <= h(); j += 6)
fl_draw_pixmap(grip_tile_xpm, (xo + i), (yo + j));
fl_pop_clip();
} // draw
int drag_btn::handle(int event)
{
toolgrp *tg = (toolgrp *)parent();
int docked = tg->docked();
int ret = 0;
int x2 = 0, y2 = 0;
int cx, cy;
// If we are not docked, deal with dragging the toolwin around
if (!docked) {
// get the enclosing parent widget
Fl_Widget *tw = (Fl_Widget *)(tg->parent());
if(!tw) return 0;
switch (event) {
case FL_PUSH: // downclick in button creates cursor offsets
x1 = Fl::event_x_root();
y1 = Fl::event_y_root();
xoff = tw->x() - x1;
yoff = tw->y() - y1;
ret = 1;
break;
case FL_DRAG: // drag the button (and its parent window) around the screen
if (was_docked) {
// Need to init offsets, we probably got here following a drag
// from the dock, so the PUSH (above) will not have happened.
was_docked = 0;
x1 = Fl::event_x_root();
y1 = Fl::event_y_root();
xoff = tw->x() - x1;
yoff = tw->y() - y1;
}
tw->position(xoff + Fl::event_x_root(), yoff + Fl::event_y_root());
tw->redraw();
ret = 1;
break;
case FL_RELEASE:
cx = Fl::event_x_root(); // Where did the release occur...
cy = Fl::event_y_root();
x2 = x1 - cx;
y2 = y1 - cy;
x2 = (x2 > 0) ? x2 : (-x2);
y2 = (y2 > 0) ? y2 : (-y2);
// See if anyone is able to accept a dock with this widget
// How to find the dock window? Search 'em all for now...
for(Fl_Window *win = Fl::first_window(); win; win = Fl::next_window(win)) {
// Get the co-ordinates of each window
int ex = win->x_root();
int ey = win->y_root();
// Are we inside the boundary of the window?
if (win->visible() &&
abs(cx - ex) < DROP_REGION_HEIGHT &&
abs(cy - ey) < DROP_REGION_HEIGHT) {
// Send the found window a message that we want to dock with it.
if(Fl::handle(FX_DROP_EVENT, win)) {
tg->dock_grp(tg);
break;
}
}
}
//show();
ret = 1;
break;
default:
break;
}
return(ret);
}
// OK, so we must be docked - are we being dragged out of the dock?
switch(event) {
case FL_PUSH: // downclick in button creates cursor offsets
x1 = Fl::event_x_root();
y1 = Fl::event_y_root();
ret = 1;
break;
case FL_DRAG:
// IF the drag has moved further than the drag_min distance
// THEN invoke an un-docking
x2 = Fl::event_x_root() - x1;
y2 = Fl::event_y_root() - y1;
x2 = (x2 > 0) ? x2 : (-x2);
y2 = (y2 > 0) ? y2 : (-y2);
if ((x2 > 10) || (y2 > 10)) {
tg->undock_grp((void *)tg); // undock the window
was_docked = -1; // note that we *just now* undocked
}
ret = 1;
break;
default:
break;
}
return ret;
} // handle

Wyświetl plik

@ -0,0 +1,67 @@
#include <stdio.h>
#include <FL/Fl.H>
#include "dropwin.h"
#include "dock_events.h"
// basic fltk constructors
dropwin::dropwin(int x, int y, int w, int h, const char *l)
: Fl_Double_Window(x, y, w, h, l)
{
init_dropwin();
}
dropwin::dropwin(int w, int h, const char *l)
: Fl_Double_Window(w, h, l)
{
init_dropwin();
}
void dropwin::init_dropwin(void)
{
dock = (dockgroup *)0;
workspace = (Fl_Group *)0;
Wdrop = DROP_REGION_HEIGHT;
Hdrop = DROP_REGION_HEIGHT;
}
void dropwin::dock_resize(int delta_h)
{
int xo = workspace->x();
int yo = workspace->y();
int wo = workspace->w();
int ho = workspace->h();
yo = yo - delta_h;
ho = ho + delta_h;
workspace->resize(xo, yo, wo, ho);
workspace->redraw();
redraw();
}
int dropwin::handle(int evt)
{
int res = Fl_Double_Window::handle(evt);
// Is this a dock_drop event?
if((evt == FX_DROP_EVENT) && (dock)) {
// Did the drop happen on us?
// Get our co-ordinates
int ex = x_root() + dock->x();
int ey = y_root() + dock->y();
// get the drop event co-ordinates
int cx = Fl::event_x_root();
int cy = Fl::event_y_root();
// Is the event inside the boundary of this window?
if (visible() &&
abs(cx - ex) < Wdrop &&
abs(cy - ey) < Hdrop) {
res = 1;
} else {
res = 0;
}
}
return res;
}

Wyświetl plik

@ -0,0 +1,204 @@
#include <stdio.h>
/* fltk includes */
#include <FL/Fl.H>
#include "toolgrp.h"
#include "toolwin.h"
#include "dropwin.h"
#include "dock_gp.h"
// function to handle the dock actions
void toolgrp::dock_grp(void* v)
{ // dock CB
toolgrp *gp = (toolgrp *)v;
dockgroup *dock = gp->get_dock();
// we can only dock a group that's not already docked...
// and only if a dock exists for it
if((gp->docked() == 0) && (dock))
{ //re-dock the group
toolwin *cur_parent = (toolwin *)gp->parent();
dock->add(gp); // move the toolgroup into the dock
dock->redraw();
gp->docked(-1); // toolgroup is docked...
// so we no longer need the tool window.
cur_parent->hide();
delete cur_parent;
}
}
// static CB to handle the undock actions
void toolgrp::undock_grp(void* v)
{ // undock CB
toolgrp *gp = (toolgrp *)v;
dockgroup *dock = gp->get_dock();
if(gp->docked() == -1)
{ // undock the group into its own non-modal tool window
int w = gp->w();
int h = gp->h();
Fl_Group::current(0);
toolwin *new_parent = new toolwin(Fl::event_x_root() - 10, Fl::event_y_root() - 35, w + 3, h + 3);
new_parent->end();
dock->remove(gp);
new_parent->add(gp);// move the tool group into the floating window
new_parent->set_inner((void *)gp);
gp->position(1, 1); // align group in floating window
new_parent->show(); // show floating window
gp->docked(0); // toolgroup is no longer docked
dock->redraw(); // update the dock, to show the group has gone...
}
}
void toolgrp::hide_show()
{
// if (docked() == 0) return;
dockgroup *dock = get_dock();
if (docked() == 0) {
toolwin *cur_parent = (toolwin *)parent();
dock->add(this); // move the toolgroup into the dock
dock->redraw();
cur_parent->remove(this);
cur_parent->hide(); // remove current parent window
delete cur_parent;
dock->remove(this); // remove toolgroup from docked parent
docked(-2);
dock->redraw();
}
else if (docked() == -1) {
dock->remove(this);
docked(-2);
dock->redraw();
} else { // docked() == -2 // the unassigned state
dock->add(this);
docked(-1);
dock->redraw();
}
}
// static CB to handle the dismiss action
//void toolgrp::cb_dismiss(Fl_Button*, void* v)
//{
// toolgrp *gp = (toolgrp *)v;
// dockgroup *dock = gp->get_dock();
// if(gp->docked())
// { // remove the group from the dock
// dock->remove(gp);
// gp->docked(0);
// dock->redraw(); // update the dock, to show the group has gone...
// Fl::delete_widget(gp);
// }
// else
// { // remove the group from the floating window,
// // and remove the floating window
// toolwin *cur_parent = (toolwin *)gp->parent();
// cur_parent->remove(gp);
// //delete cur_parent; // we no longer need the tool window.
// Fl::delete_widget(cur_parent);
// Fl::delete_widget(gp);
// }
//}
// Constructors for docked/floating window
// WITH x, y co-ordinates
toolgrp::toolgrp(dockgroup *dk, int floater, int x, int y, int w, int h, const char *lbl)
: Fl_Group(1, 1, w - 2 , h - 2, lbl)
{
if((floater) && (dk)) // create floating
{
create_floating(dk, 1, x, y, w, h, lbl);
}
else if(dk) // create docked
{
create_docked(dk);
}
// else //do nothing...
}
// WITHOUT x, y co-ordinates
toolgrp::toolgrp(dockgroup *dk, int floater, int w, int h, const char *lbl)
: Fl_Group(1, 1, w - 2, h - 2, lbl)
{
if((floater) && (dk)) // create floating
{
create_floating(dk, 0, 0, 0, w, h, lbl);
}
else if(dk) // create docked
{
create_docked(dk);
}
// else //do nothing...
}
// construction function
void toolgrp::create_dockable_group()
{
dragger = new drag_btn(2, 2, 12, h() - 4);
dragger->type(FL_TOGGLE_BUTTON);
dragger->box(FL_ENGRAVED_FRAME);
dragger->tooltip("Drag Box");
dragger->clear_visible_focus();
dragger->when(FL_WHEN_CHANGED);
inner_group = new Fl_Group(16, 2, w() - 18, h() - 4);
inner_group->box(FL_FLAT_BOX);
// inner_group->box(FL_ENGRAVED_FRAME);
}
void toolgrp::create_docked(dockgroup *dk)
{
// create the group itself
create_dockable_group();
// place it in the dock
dk->add(this);
set_dock(dk); // define where the toolgroup is allowed to dock
docked(-1); // docked
dk->redraw();
Fl_Group::resizable(inner_group);
}
void toolgrp::create_floating(dockgroup *dk, int full, int x, int y, int w, int h, const char *lbl)
{
toolwin *tw;
// create the group itself
create_dockable_group();
// create a floating toolbar window
// Ensure the window is not created as a child of its own inner group!
Fl_Group::current(0);
if(full)
tw = new toolwin(x, y, w + 4, h + 4, lbl);
else
tw = new toolwin(w + 4, h + 4, lbl);
tw->end();
tw->add(this); // move the tool group into the floating window
docked(0); // NOT docked
set_dock(dk); // define where the toolgroup is allowed to dock
tw->set_inner((void *)this);
tw->show();
Fl_Group::current(inner_group); // leave this group open when we leave the constructor...
Fl_Group::resizable(inner_group);
}
// function for setting the docked state and checkbox
void toolgrp::docked(short r)
{
_docked = r;
}
// methods for hiding/showing *all* the floating windows
// show all the active floating windows
void toolgrp::show_all(void)
{
toolwin::show_all();
}
// hide all the active floating windows
void toolgrp::hide_all(void)
{
toolwin::hide_all();
}

Wyświetl plik

@ -0,0 +1,101 @@
#include <stdio.h>
#include "toolwin.h"
#include "toolgrp.h"
#include "dock_events.h"
#include <FL/Fl_Button.H>
#define NTW (toolwin*)0 // Null Tool Window
// HACK:: This just stores the toolwindows in a static array. I'm too lazy
// to make a proper linked list to store these in...
toolwin* toolwin::active_list[TW_MAX_FLOATERS]; // list of active toolwins
short toolwin::active = 0; // count of active tool windows
// Dummy close button callback
static void cb_ignore(void)
{
// Just shrug off the close callback...
}
// constructors
toolwin::toolwin(int x, int y, int w, int h, const char *l)
: Fl_Double_Window(x, y, w, h, l)
{
create_dockable_window();
}
toolwin::toolwin(int w, int h, const char *l)
: Fl_Double_Window(w, h, l)
{
create_dockable_window();
}
// destructor
toolwin::~toolwin()
{
active_list[idx] = NTW;
active --;
}
// construction function
void toolwin::create_dockable_window()
{
static int first_window = 1;
tool_group = (void *)0;
// window list intialisation...
// this is a nasty hack, should make a proper list
if(first_window)
{
first_window = 0;
for(short i = 0; i < TW_MAX_FLOATERS; i++)
active_list[i] = NTW;
}
// find an empty index
for(short i = 0; i < TW_MAX_FLOATERS; i++)
{
if(!active_list[i])
{
idx = i;
active_list[idx] = this;
active ++;
clear_border();
set_non_modal();
callback((Fl_Callback *)cb_ignore);
return;
}
}
// if we get here, the list is probably full, what a hack.
// FIX THIS:: At present, we will get a non-modal window with
// decorations as a default instead...
set_non_modal();
}
// show all the active floating windows
void toolwin::show_all(void)
{
if (active)
{
for(short i = 0; i < TW_MAX_FLOATERS; i++)
{
if(active_list[i])
active_list[i]->show();
}
}
}
// hide all the active floating windows
void toolwin::hide_all(void)
{
if (active)
{
for(short i = 0; i < TW_MAX_FLOATERS; i++)
{
if(active_list[i])
active_list[i]->hide();
}
}
}