Skip to content

Commit 44f7003

Browse files
authored
Add SVIntInput
* Added new subclassed type SVIntInput which is subclassed from FLTK's Fl_Int_Input class. This only allows numbers in fields such as 'Quality', 'Compression', 'Port', etc.
1 parent 67bea84 commit 44f7003

File tree

3 files changed

+46
-17
lines changed

3 files changed

+46
-17
lines changed

src/app.cxx

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ struct AppOptionsControls
4141
Fl_Spinner * spinLocalSSHPort;
4242
SVInput * inSSHCommand;
4343
Fl_Check_Button * chkLogToFile;
44-
SVInput * inAppFontSize;
44+
SVIntInput * inAppFontSize;
4545
SVInput * inListFont;
46-
SVInput * inListFontSize;
47-
SVInput * inListWidth;
46+
SVIntInput * inListFontSize;
47+
SVIntInput * inListWidth;
4848
Fl_Check_Button * chkCBIcons;
4949
Fl_Check_Button * chkShowTooltips;
5050
Fl_Check_Button * chkShowReverseConnect;
@@ -73,12 +73,12 @@ struct ItemOptionsControls
7373
SVInput * inF12Macro;
7474
Fl_Radio_Round_Button * rbVNC;
7575
Fl_Radio_Round_Button * rbSVNC;
76-
SVInput * inVNCPort;
76+
SVIntInput * inVNCPort;
7777
SVSecretInput * inVNCPassword;
7878
SVInput * inVNCLoginUser;
7979
SVSecretInput * inVNCLoginPassword;
80-
SVInput * inVNCCompressLevel;
81-
SVInput * inVNCQualityLevel;
80+
SVIntInput * inVNCCompressLevel;
81+
SVIntInput * inVNCQualityLevel;
8282
Fl_Group * grpScaling;
8383
Fl_Radio_Round_Button * rbScaleOff;
8484
Fl_Radio_Round_Button * rbScaleZoom;
@@ -97,7 +97,7 @@ struct ItemOptionsControls
9797
Fl_Box * bxSSHSection;
9898
SVInput * inSSHName;
9999
//SVSecretInput * inSSHPassword;
100-
SVInput * inSSHPort;
100+
SVIntInput * inSSHPort;
101101
SVInput * inSSHPrvKey;
102102
Fl_Button * btnShowPrvKeyChooser;
103103
// 'Delete' button
@@ -125,6 +125,25 @@ int SVInput::handle (int evt)
125125
}
126126

127127

128+
/*
129+
handle method for SVIntInput
130+
(instance method)
131+
*/
132+
int SVIntInput::handle (int evt)
133+
{
134+
// handle child window input controls right-click
135+
if (evt == FL_PUSH && Fl::event_button3() != 0)
136+
{
137+
svPopUpEditMenu(this);
138+
139+
return 1;
140+
}
141+
142+
/* (apparently Fl_Int_Input isn't supported yet?? it's in the FLTK docs though...) */
143+
return Fl_Int_Input::handle(evt);
144+
}
145+
146+
128147
/*
129148
handle method for SVSecretInput
130149
(instance method)
@@ -3064,7 +3083,7 @@ void svShowAppOptions ()
30643083
lblSep01->labelfont(1);
30653084

30663085
// app font size
3067-
AppOpts.inAppFontSize = new SVInput(nXPos, nYPos += nYStep, 42, 28, "Application font size ");
3086+
AppOpts.inAppFontSize = new SVIntInput(nXPos, nYPos += nYStep, 42, 28, "Application font size ");
30683087
AppOpts.inAppFontSize->textsize(app->nAppFontSize);
30693088
AppOpts.inAppFontSize->labelsize(app->nAppFontSize);
30703089
AppOpts.inAppFontSize->value(std::to_string(app->nAppFontSize).c_str());
@@ -3081,15 +3100,15 @@ void svShowAppOptions ()
30813100
" see any changes");
30823101

30833102
// list font size
3084-
AppOpts.inListFontSize = new SVInput(nXPos + 260, nYPos, 42, 28, "Size:");
3103+
AppOpts.inListFontSize = new SVIntInput(nXPos + 260, nYPos, 42, 28, "Size:");
30853104
AppOpts.inListFontSize->textsize(app->nAppFontSize);
30863105
AppOpts.inListFontSize->labelsize(app->nAppFontSize);
30873106
AppOpts.inListFontSize->value(std::to_string(app->nListFontSize).c_str());
30883107
AppOpts.inListFontSize->tooltip("This is the font size used for the host list. Restart the app to"
30893108
" see any changes");
30903109

30913110
// list width
3092-
AppOpts.inListWidth = new SVInput(nXPos, nYPos += nYStep, 210, 28, "List width ");
3111+
AppOpts.inListWidth = new SVIntInput(nXPos, nYPos += nYStep, 210, 28, "List width ");
30933112
AppOpts.inListWidth->textsize(app->nAppFontSize);
30943113
AppOpts.inListWidth->labelsize(app->nAppFontSize);
30953114
AppOpts.inListWidth->value(std::to_string(app->requestedListWidth).c_str());
@@ -3285,7 +3304,7 @@ void svShowItemOptions (HostItem * im)
32853304

32863305
// window size
32873306
int nWinWidth = 545;
3288-
int nWinHeight = 605; //625; //595;
3307+
int nWinHeight = 605;
32893308

32903309
// set window position
32913310
int nX = app->hostList->w() + 50;
@@ -3300,7 +3319,7 @@ void svShowItemOptions (HostItem * im)
33003319

33013320
int nXPos = 195;
33023321
int nYStep = 28;
3303-
int nYPos = -24; //-(nYStep / 2); //-10;
3322+
int nYPos = -24;
33043323

33053324
// add itm value editors / selectors
33063325

@@ -3355,7 +3374,7 @@ void svShowItemOptions (HostItem * im)
33553374
ItmOpts.rbSVNC->set();
33563375

33573376
// vnc port
3358-
ItmOpts.inVNCPort = new SVInput(nXPos, nYPos += nYStep, 100, 28, "VNC port ");
3377+
ItmOpts.inVNCPort = new SVIntInput(nXPos, nYPos += nYStep, 100, 28, "VNC port ");
33593378
ItmOpts.inVNCPort->value(itm->vncPort.c_str());
33603379
ItmOpts.inVNCPort->tooltip("The VNC port/display number of the host. Defaults to 5900");
33613380

@@ -3378,13 +3397,13 @@ void svShowItemOptions (HostItem * im)
33783397
ItmOpts.inVNCLoginPassword->tooltip("The VNC login password for the host");
33793398

33803399
// vnc compression level
3381-
ItmOpts.inVNCCompressLevel = new SVInput(nXPos, nYPos += nYStep, 48, 28,
3400+
ItmOpts.inVNCCompressLevel = new SVIntInput(nXPos, nYPos += nYStep, 48, 28,
33823401
"Compression level (0-9) ");
33833402
ItmOpts.inVNCCompressLevel->value(std::to_string(itm->compressLevel).c_str());
33843403
ItmOpts.inVNCCompressLevel->tooltip("The level of compression, from 0 to 9");
33853404

33863405
// vnc quality level
3387-
ItmOpts.inVNCQualityLevel = new SVInput(nXPos, nYPos += nYStep, 48, 28, "Quality level (0-9) ");
3406+
ItmOpts.inVNCQualityLevel = new SVIntInput(nXPos, nYPos += nYStep, 48, 28, "Quality level (0-9) ");
33883407
ItmOpts.inVNCQualityLevel->value(std::to_string(itm->qualityLevel).c_str());
33893408
ItmOpts.inVNCQualityLevel->tooltip("The level of image quality, from 0 to 9");
33903409

@@ -3467,7 +3486,7 @@ void svShowItemOptions (HostItem * im)
34673486
//ItmOpts.inSSHPassword->deactivate(); // <<<--- We can't really do SSH password right now ---<<<
34683487

34693488
// ssh port (on the remote host)
3470-
ItmOpts.inSSHPort = new SVInput(nXPos, nYPos += nYStep, 100, 28, "SSH remote port ");
3489+
ItmOpts.inSSHPort = new SVIntInput(nXPos, nYPos += nYStep, 100, 28, "SSH remote port ");
34713490
ItmOpts.inSSHPort->value(itm->sshPort.c_str());
34723491
ItmOpts.inSSHPort->tooltip("The remote host's port number");
34733492

src/app.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
#include <FL/Fl_Image.H>
5555
#include <FL/Fl_Image_Surface.H>
5656
#include <FL/Fl_Input.H>
57+
#include <FL/Fl_Int_Input.H>
5758
#include <FL/Fl_Menu_Item.H>
5859
#include <FL/Fl_Pack.H>
5960
#include <FL/Fl_PNG_Image.H>
@@ -290,6 +291,16 @@ class SVInput : public Fl_Input
290291
int handle (int event);
291292
};
292293

294+
/* subclassed decimal number input box */
295+
/* (apparently Fl_Int_Input isn't supported yet?? it's in the FLTK docs though...) */
296+
class SVIntInput : public Fl_Int_Input
297+
{
298+
public:
299+
SVIntInput (int x, int y, int w, int h, const char * label = 0) :
300+
Fl_Int_Input(x, y, w, h, label) {}
301+
int handle (int event);
302+
};
303+
293304
/* subclassed password input box */
294305
class SVSecretInput : public Fl_Secret_Input
295306
{

src/spiritvnc.cxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ int main (int argc, char **argv)
126126
#endif
127127

128128
// maximize window if last state was maximized
129-
// (I guess FLTK can't do 'maximize' yet!?)
130129
if (app->maximized)
131130
app->mainWin->maximize();
132131

0 commit comments

Comments
 (0)