Some code improvements

This commit is contained in:
Markus Gans 2017-09-11 03:06:02 +02:00
parent 1cd1e521c3
commit dc3c5d19e4
94 changed files with 6267 additions and 6137 deletions

View File

@ -1,3 +1,6 @@
2017-09-11 Markus Gans <guru.mail@muenster.de>
* Some code improvements
2017-09-09 Markus Gans <guru.mail@muenster.de> 2017-09-09 Markus Gans <guru.mail@muenster.de>
* Wrong UTF-8 string length fixed when attaching to FString * Wrong UTF-8 string length fixed when attaching to FString

View File

@ -1,6 +1,8 @@
// File: fapplication.cpp // File: fapplication.cpp
// Provides: class FApplication // Provides: class FApplication
#include <string>
#include "fapplication.h" #include "fapplication.h"
#include "fmenu.h" #include "fmenu.h"
#include "fstatusbar.h" #include "fstatusbar.h"
@ -33,7 +35,7 @@ FApplication::eventQueue* FApplication::event_queue = 0;
// constructors and destructor // constructors and destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FApplication::FApplication ( int& _argc FApplication::FApplication ( const int& _argc
, char* _argv[] , char* _argv[]
, bool disable_alt_screen ) , bool disable_alt_screen )
: FWidget(0, disable_alt_screen) : FWidget(0, disable_alt_screen)
@ -69,7 +71,7 @@ FApplication::FApplication ( int& _argc
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FApplication::~FApplication() // destructor FApplication::~FApplication() // destructor
{ {
if ( zero_point ) if ( zero_point )
delete zero_point; delete zero_point;
@ -143,7 +145,7 @@ void FApplication::exit (int retcode)
if ( ! rootObj ) // no global app object if ( ! rootObj ) // no global app object
return; return;
if ( quit_now ) // don't overwrite quit code if ( quit_now ) // don't overwrite quit code
return; return;
quit_now = true; quit_now = true;
@ -213,7 +215,9 @@ bool FApplication::sendEvent ( const FObject* receiver
return false; return false;
// For access to a protected base class member // For access to a protected base class member
FApplication* w = const_cast<FApplication*>(static_cast<const FApplication*>(widget)); const FApplication* const_w = static_cast<const FApplication*>(widget);
FApplication* w = const_cast<FApplication*>(const_w);
// Sends event event directly to receiver // Sends event event directly to receiver
return w->event(const_cast<FEvent*>(event)); return w->event(const_cast<FEvent*>(event));
} }
@ -314,7 +318,7 @@ void FApplication::init()
try try
{ {
zero_point = new FPoint(0,0); zero_point = new FPoint (0,0);
event_queue = new eventQueue; event_queue = new eventQueue;
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
@ -536,7 +540,7 @@ void FApplication::processKeyboardEvent()
if ( isKeyPressed ) if ( isKeyPressed )
{ {
register ssize_t bytesread; register ssize_t bytesread;
widget->getCurrentTime(time_keypressed); widget->getCurrentTime (&time_keypressed);
x11_mouse[0] = sgr_mouse[0] = urxvt_mouse[0] = '\0'; x11_mouse[0] = sgr_mouse[0] = urxvt_mouse[0] = '\0';
if ( quit_now || app_exit_loop ) if ( quit_now || app_exit_loop )
@ -694,8 +698,7 @@ void FApplication::processKeyboardEvent()
} }
} }
break; break;
} // end of switch
} // end of switch
} }
fifo_offset = int(std::strlen(fifo_buf)); fifo_offset = int(std::strlen(fifo_buf));
@ -725,7 +728,7 @@ void FApplication::processKeyboardEvent()
#if defined(__linux__) #if defined(__linux__)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FApplication::linuxModifierKeyCorrection (int& key_id) int FApplication::linuxModifierKeyCorrection (const int& key_id)
{ {
// get the current modifier key state // get the current modifier key state
FTerm::modifier_key& m = getLinuxModifierKey(); FTerm::modifier_key& m = getLinuxModifierKey();
@ -739,34 +742,34 @@ int FApplication::linuxModifierKeyCorrection (int& key_id)
switch ( key_id ) switch ( key_id )
{ {
case fc::Fkey_up: case fc::Fkey_up:
return fc::Fkey_sr; // Shift+Up return fc::Fkey_sr; // Shift+Up
case fc::Fkey_down: case fc::Fkey_down:
return fc::Fkey_sf; // Shift+Down return fc::Fkey_sf; // Shift+Down
case fc::Fkey_left: case fc::Fkey_left:
return fc::Fkey_sleft; // Shift+Left return fc::Fkey_sleft; // Shift+Left
case fc::Fkey_right: case fc::Fkey_right:
return fc::Fkey_sright; // Shift+Right return fc::Fkey_sright; // Shift+Right
case fc::Fkey_ic: case fc::Fkey_ic:
return fc::Fkey_sic; // Shift+Ins return fc::Fkey_sic; // Shift+Ins
case fc::Fkey_dc: case fc::Fkey_dc:
return fc::Fkey_sdc; // Shift+Del return fc::Fkey_sdc; // Shift+Del
case fc::Fkey_home: case fc::Fkey_home:
return fc::Fkey_shome; // Shift+Home return fc::Fkey_shome; // Shift+Home
case fc::Fkey_end: case fc::Fkey_end:
return fc::Fkey_send; // Shift+End return fc::Fkey_send; // Shift+End
case fc::Fkey_ppage: case fc::Fkey_ppage:
return fc::Fkey_sprevious; // Shift+PgUp return fc::Fkey_sprevious; // Shift+PgUp
case fc::Fkey_npage: case fc::Fkey_npage:
return fc::Fkey_snext; // Shift+PgDn return fc::Fkey_snext; // Shift+PgDn
default: default:
return key_id; return key_id;
@ -777,34 +780,34 @@ int FApplication::linuxModifierKeyCorrection (int& key_id)
switch ( key_id ) switch ( key_id )
{ {
case fc::Fkey_up: case fc::Fkey_up:
return fc::Fckey_up; // Ctrl+Up return fc::Fckey_up; // Ctrl+Up
case fc::Fkey_down: case fc::Fkey_down:
return fc::Fckey_down; // Ctrl+Down return fc::Fckey_down; // Ctrl+Down
case fc::Fkey_left: case fc::Fkey_left:
return fc::Fckey_left; // Ctrl+Left return fc::Fckey_left; // Ctrl+Left
case fc::Fkey_right: case fc::Fkey_right:
return fc::Fckey_right; // Ctrl+Right return fc::Fckey_right; // Ctrl+Right
case fc::Fkey_ic: case fc::Fkey_ic:
return fc::Fckey_ic; // Ctrl+Ins return fc::Fckey_ic; // Ctrl+Ins
case fc::Fkey_dc: case fc::Fkey_dc:
return fc::Fckey_dc; // Ctrl+Del return fc::Fckey_dc; // Ctrl+Del
case fc::Fkey_home: case fc::Fkey_home:
return fc::Fckey_home; // Ctrl+Home return fc::Fckey_home; // Ctrl+Home
case fc::Fkey_end: case fc::Fkey_end:
return fc::Fckey_end; // Ctrl+End return fc::Fckey_end; // Ctrl+End
case fc::Fkey_ppage: case fc::Fkey_ppage:
return fc::Fckey_ppage; // Ctrl+PgUp return fc::Fckey_ppage; // Ctrl+PgUp
case fc::Fkey_npage: case fc::Fkey_npage:
return fc::Fckey_npage; // Ctrl+PgDn return fc::Fckey_npage; // Ctrl+PgDn
default: default:
return key_id; return key_id;
@ -815,34 +818,34 @@ int FApplication::linuxModifierKeyCorrection (int& key_id)
switch ( key_id ) switch ( key_id )
{ {
case fc::Fkey_up: case fc::Fkey_up:
return fc::Fmkey_up; // Meta+Up return fc::Fmkey_up; // Meta+Up
case fc::Fkey_down: case fc::Fkey_down:
return fc::Fmkey_down; // Meta+Down return fc::Fmkey_down; // Meta+Down
case fc::Fkey_left: case fc::Fkey_left:
return fc::Fmkey_left; // Meta+Left return fc::Fmkey_left; // Meta+Left
case fc::Fkey_right: case fc::Fkey_right:
return fc::Fmkey_right; // Meta+Right return fc::Fmkey_right; // Meta+Right
case fc::Fkey_ic: case fc::Fkey_ic:
return fc::Fmkey_ic; // Meta+Ins return fc::Fmkey_ic; // Meta+Ins
case fc::Fkey_dc: case fc::Fkey_dc:
return fc::Fmkey_dc; // Meta+Del return fc::Fmkey_dc; // Meta+Del
case fc::Fkey_home: case fc::Fkey_home:
return fc::Fmkey_home; // Meta+Home return fc::Fmkey_home; // Meta+Home
case fc::Fkey_end: case fc::Fkey_end:
return fc::Fmkey_end; // Meta+End return fc::Fmkey_end; // Meta+End
case fc::Fkey_ppage: case fc::Fkey_ppage:
return fc::Fmkey_ppage; // Meta+PgUp return fc::Fmkey_ppage; // Meta+PgUp
case fc::Fkey_npage: case fc::Fkey_npage:
return fc::Fmkey_npage; // Meta+PgDn return fc::Fmkey_npage; // Meta+PgDn
default: default:
return key_id; return key_id;
@ -853,34 +856,34 @@ int FApplication::linuxModifierKeyCorrection (int& key_id)
switch ( key_id ) switch ( key_id )
{ {
case fc::Fkey_up: case fc::Fkey_up:
return fc::Fckey_sup; // Shift+Ctrl+Up return fc::Fckey_sup; // Shift+Ctrl+Up
case fc::Fkey_down: case fc::Fkey_down:
return fc::Fckey_sdown; // Shift+Ctrl+Down return fc::Fckey_sdown; // Shift+Ctrl+Down
case fc::Fkey_left: case fc::Fkey_left:
return fc::Fckey_sleft; // Shift+Ctrl+Left return fc::Fckey_sleft; // Shift+Ctrl+Left
case fc::Fkey_right: case fc::Fkey_right:
return fc::Fckey_sright; // Shift+Ctrl+Right return fc::Fckey_sright; // Shift+Ctrl+Right
case fc::Fkey_ic: case fc::Fkey_ic:
return fc::Fckey_sic; // Shift+Ctrl+Ins return fc::Fckey_sic; // Shift+Ctrl+Ins
case fc::Fkey_dc: case fc::Fkey_dc:
return fc::Fckey_sdc; // Shift+Ctrl+Del return fc::Fckey_sdc; // Shift+Ctrl+Del
case fc::Fkey_home: case fc::Fkey_home:
return fc::Fckey_shome; // Shift+Ctrl+Home return fc::Fckey_shome; // Shift+Ctrl+Home
case fc::Fkey_end: case fc::Fkey_end:
return fc::Fckey_send; // Shift+Ctrl+End return fc::Fckey_send; // Shift+Ctrl+End
case fc::Fkey_ppage: case fc::Fkey_ppage:
return fc::Fckey_sppage; // Shift+Ctrl+PgUp return fc::Fckey_sppage; // Shift+Ctrl+PgUp
case fc::Fkey_npage: case fc::Fkey_npage:
return fc::Fckey_snpage; // Shift+Ctrl+PgDn return fc::Fckey_snpage; // Shift+Ctrl+PgDn
default: default:
return key_id; return key_id;
@ -891,34 +894,34 @@ int FApplication::linuxModifierKeyCorrection (int& key_id)
switch ( key_id ) switch ( key_id )
{ {
case fc::Fkey_up: case fc::Fkey_up:
return fc::Fmkey_sup; // Shift+Meta+Up return fc::Fmkey_sup; // Shift+Meta+Up
case fc::Fkey_down: case fc::Fkey_down:
return fc::Fmkey_sdown; // Shift+Meta+Down return fc::Fmkey_sdown; // Shift+Meta+Down
case fc::Fkey_left: case fc::Fkey_left:
return fc::Fmkey_sright; // Shift+Meta+Left return fc::Fmkey_sright; // Shift+Meta+Left
case fc::Fkey_right: case fc::Fkey_right:
return fc::Fmkey_sleft; // Shift+Meta+Right return fc::Fmkey_sleft; // Shift+Meta+Right
case fc::Fkey_ic: case fc::Fkey_ic:
return fc::Fmkey_sic; // Shift+Meta+Ins return fc::Fmkey_sic; // Shift+Meta+Ins
case fc::Fkey_dc: case fc::Fkey_dc:
return fc::Fmkey_sdc; // Shift+Meta+Del return fc::Fmkey_sdc; // Shift+Meta+Del
case fc::Fkey_home: case fc::Fkey_home:
return fc::Fmkey_shome; // Shift+Meta+Home return fc::Fmkey_shome; // Shift+Meta+Home
case fc::Fkey_end: case fc::Fkey_end:
return fc::Fmkey_send; // Shift+Meta+End return fc::Fmkey_send; // Shift+Meta+End
case fc::Fkey_ppage: case fc::Fkey_ppage:
return fc::Fmkey_sppage; // Shift+Meta+PgUp return fc::Fmkey_sppage; // Shift+Meta+PgUp
case fc::Fkey_npage: case fc::Fkey_npage:
return fc::Fmkey_snpage; // Shift+Meta+PgDn return fc::Fmkey_snpage; // Shift+Meta+PgDn
default: default:
return key_id; return key_id;
@ -929,34 +932,34 @@ int FApplication::linuxModifierKeyCorrection (int& key_id)
switch ( key_id ) switch ( key_id )
{ {
case fc::Fkey_up: case fc::Fkey_up:
return fc::Fcmkey_up; // Ctrl+Meta+Up return fc::Fcmkey_up; // Ctrl+Meta+Up
case fc::Fkey_down: case fc::Fkey_down:
return fc::Fcmkey_down; // Ctrl+Meta+Down return fc::Fcmkey_down; // Ctrl+Meta+Down
case fc::Fkey_left: case fc::Fkey_left:
return fc::Fcmkey_left; // Ctrl+Meta+Left return fc::Fcmkey_left; // Ctrl+Meta+Left
case fc::Fkey_right: case fc::Fkey_right:
return fc::Fcmkey_right; // Ctrl+Meta+Right return fc::Fcmkey_right; // Ctrl+Meta+Right
case fc::Fkey_ic: case fc::Fkey_ic:
return fc::Fcmkey_ic; // Ctrl+Meta+Ins return fc::Fcmkey_ic; // Ctrl+Meta+Ins
case fc::Fkey_dc: case fc::Fkey_dc:
return fc::Fcmkey_dc; // Ctrl+Meta+Del return fc::Fcmkey_dc; // Ctrl+Meta+Del
case fc::Fkey_home: case fc::Fkey_home:
return fc::Fcmkey_home; // Ctrl+Meta+Home return fc::Fcmkey_home; // Ctrl+Meta+Home
case fc::Fkey_end: case fc::Fkey_end:
return fc::Fcmkey_end; // Ctrl+Meta+End return fc::Fcmkey_end; // Ctrl+Meta+End
case fc::Fkey_ppage: case fc::Fkey_ppage:
return fc::Fcmkey_ppage; // Ctrl+Meta+PgUp return fc::Fcmkey_ppage; // Ctrl+Meta+PgUp
case fc::Fkey_npage: case fc::Fkey_npage:
return fc::Fcmkey_npage; // Ctrl+Meta+PgDn return fc::Fcmkey_npage; // Ctrl+Meta+PgDn
default: default:
return key_id; return key_id;
@ -967,34 +970,34 @@ int FApplication::linuxModifierKeyCorrection (int& key_id)
switch ( key_id ) switch ( key_id )
{ {
case fc::Fkey_up: case fc::Fkey_up:
return fc::Fcmkey_sup; // Shift+Ctrl+Meta+Up return fc::Fcmkey_sup; // Shift+Ctrl+Meta+Up
case fc::Fkey_down: case fc::Fkey_down:
return fc::Fcmkey_sdown; // Shift+Ctrl+Meta+Down return fc::Fcmkey_sdown; // Shift+Ctrl+Meta+Down
case fc::Fkey_left: case fc::Fkey_left:
return fc::Fcmkey_sleft; // Shift+Ctrl+Meta+Left return fc::Fcmkey_sleft; // Shift+Ctrl+Meta+Left
case fc::Fkey_right: case fc::Fkey_right:
return fc::Fcmkey_sright; // Shift+Ctrl+Meta+Right return fc::Fcmkey_sright; // Shift+Ctrl+Meta+Right
case fc::Fkey_ic: case fc::Fkey_ic:
return fc::Fcmkey_sic; // Shift+Ctrl+Meta+Ins return fc::Fcmkey_sic; // Shift+Ctrl+Meta+Ins
case fc::Fkey_dc: case fc::Fkey_dc:
return fc::Fcmkey_sdc; // Shift+Ctrl+Meta+Del return fc::Fcmkey_sdc; // Shift+Ctrl+Meta+Del
case fc::Fkey_home: case fc::Fkey_home:
return fc::Fcmkey_shome; // Shift+Ctrl+Meta+Home return fc::Fcmkey_shome; // Shift+Ctrl+Meta+Home
case fc::Fkey_end: case fc::Fkey_end:
return fc::Fcmkey_send; // Shift+Ctrl+Meta+End return fc::Fcmkey_send; // Shift+Ctrl+Meta+End
case fc::Fkey_ppage: case fc::Fkey_ppage:
return fc::Fcmkey_sppage; // Shift+Ctrl+Meta+PgUp return fc::Fcmkey_sppage; // Shift+Ctrl+Meta+PgUp
case fc::Fkey_npage: case fc::Fkey_npage:
return fc::Fcmkey_snpage; // Shift+Ctrl+Meta+PgDn return fc::Fcmkey_snpage; // Shift+Ctrl+Meta+PgDn
default: default:
return key_id; return key_id;
@ -1198,7 +1201,7 @@ bool FApplication::parseX11Mouse()
x = uChar(x11_mouse[1] - 0x20); x = uChar(x11_mouse[1] - 0x20);
y = uChar(x11_mouse[2] - 0x20); y = uChar(x11_mouse[2] - 0x20);
new_mouse_position.setPoint(x,y); new_mouse_position.setPoint (x, y);
// fill bit field with 0 // fill bit field with 0
std::memset(&b_state, 0x00, sizeof(b_state)); std::memset(&b_state, 0x00, sizeof(b_state));
@ -1293,7 +1296,7 @@ bool FApplication::parseSGRMouse()
y = uChar(10 * y + (*p - '0')); y = uChar(10 * y + (*p - '0'));
} }
new_mouse_position.setPoint(x,y); new_mouse_position.setPoint (x, y);
// fill bit field with 0 // fill bit field with 0
std::memset(&b_state, 0x00, sizeof(b_state)); std::memset(&b_state, 0x00, sizeof(b_state));
@ -1491,7 +1494,7 @@ bool FApplication::parseUrxvtMouse()
if ( y > getLineNumber() ) if ( y > getLineNumber() )
y = uChar(getLineNumber()); y = uChar(getLineNumber());
new_mouse_position.setPoint(x,y); new_mouse_position.setPoint (x, y);
// fill bit field with 0 // fill bit field with 0
std::memset(&b_state, 0x00, sizeof(b_state)); std::memset(&b_state, 0x00, sizeof(b_state));
@ -1891,8 +1894,7 @@ void FApplication::processMouseEvent()
clicked_widget = 0; clicked_widget = 0;
sendEvent (scroll_over_widget, &wheel_ev); sendEvent (scroll_over_widget, &wheel_ev);
} }
} // end of if ( clicked_widget )
}
#ifdef F_HAVE_LIBGPM #ifdef F_HAVE_LIBGPM
if ( isGpmMouseEnabled() && gpm_ev.x != -1 ) if ( isGpmMouseEnabled() && gpm_ev.x != -1 )
@ -1920,7 +1922,7 @@ int FApplication::processTimerEvent()
timeval currentTime; timeval currentTime;
int activated = 0; int activated = 0;
getCurrentTime (currentTime); getCurrentTime (&currentTime);
if ( isTimerInUpdating() ) if ( isTimerInUpdating() )
return 0; return 0;

View File

@ -38,6 +38,8 @@
#include <getopt.h> #include <getopt.h>
#include <deque> #include <deque>
#include <string>
#include <utility>
#include "fevent.h" #include "fevent.h"
#include "fwidget.h" #include "fwidget.h"
@ -53,163 +55,163 @@
class FApplication : public FWidget class FApplication : public FWidget
{ {
public: public:
// Constructor // Constructor
FApplication (int&, char*[], bool = false); FApplication (const int&, char*[], bool = false);
// Destructor // Destructor
virtual ~FApplication(); virtual ~FApplication();
// Accessors // Accessors
const char* getClassName() const; const char* getClassName() const;
int getArgc() const; int getArgc() const;
char** getArgv() const; char** getArgv() const;
FWidget* getMainWidget() const; FWidget* getMainWidget() const;
FWidget* getFocusWidget() const; FWidget* getFocusWidget() const;
// Mutator // Mutator
void setMainWidget (FWidget*); void setMainWidget (FWidget*);
// Inquiry // Inquiry
static bool isQuit(); static bool isQuit();
// Methods // Methods
int exec(); // run int exec(); // run
int enter_loop(); int enter_loop();
void exit_loop(); void exit_loop();
static void exit (int = 0); static void exit (int = 0);
void quit(); void quit();
static bool sendEvent (const FObject*, const FEvent*); static bool sendEvent (const FObject*, const FEvent*);
static void queueEvent (const FObject*, const FEvent*); static void queueEvent (const FObject*, const FEvent*);
static void sendQueuedEvents (); static void sendQueuedEvents ();
static bool eventInQueue(); static bool eventInQueue();
static bool removeQueuedEvent(const FObject*); static bool removeQueuedEvent(const FObject*);
static void print_cmd_Options(); static void print_cmd_Options();
private: private:
// Typedefs and Enumerations // Typedefs and Enumerations
typedef std::pair<const FObject*, const FEvent*> eventPair; typedef std::pair<const FObject*, const FEvent*> eventPair;
typedef std::deque<eventPair> eventQueue; typedef std::deque<eventPair> eventQueue;
enum btn_state enum btn_state
{ {
Pressed = 1, Pressed = 1,
Released = 2, Released = 2,
DoubleClick = 3 DoubleClick = 3
}; };
#ifdef F_HAVE_LIBGPM #ifdef F_HAVE_LIBGPM
enum gpmEventType enum gpmEventType
{ {
no_event = 0, no_event = 0,
keyboard_event = 1, keyboard_event = 1,
mouse_event = 2 mouse_event = 2
}; };
#endif #endif
// Constants // Constants
static const int NEED_MORE_DATA = -1; // parseKeyString return value static const int NEED_MORE_DATA = -1; // parseKeyString return value
// Disable copy constructor // Disable copy constructor
FApplication (const FApplication&); FApplication (const FApplication&);
// Disable assignment operator (=) // Disable assignment operator (=)
FApplication& operator = (const FApplication&); FApplication& operator = (const FApplication&);
// Methods // Methods
void init(); void init();
void setExitMessage (std::string); void setExitMessage (std::string);
void cmd_options(); void cmd_options();
#ifdef F_HAVE_LIBGPM #ifdef F_HAVE_LIBGPM
int gpmEvent (bool = true); int gpmEvent (bool = true);
bool processGpmEvent(); bool processGpmEvent();
#endif #endif
bool KeyPressed(); bool KeyPressed();
ssize_t readKey(); ssize_t readKey();
void processKeyboardEvent(); void processKeyboardEvent();
#if defined(__linux__) #if defined(__linux__)
int linuxModifierKeyCorrection (int& key); int linuxModifierKeyCorrection (const int&);
#endif #endif
bool processDialogSwitchAccelerator(); bool processDialogSwitchAccelerator();
bool processAccelerator (const FWidget*&); bool processAccelerator (const FWidget*&);
void getX11ButtonState (int); void getX11ButtonState (int);
bool parseX11Mouse(); bool parseX11Mouse();
bool parseSGRMouse(); bool parseSGRMouse();
bool parseUrxvtMouse(); bool parseUrxvtMouse();
void processMouseEvent(); void processMouseEvent();
void processResizeEvent(); void processResizeEvent();
int processTimerEvent(); int processTimerEvent();
void processCloseWidget(); void processCloseWidget();
bool processNextEvent(); bool processNextEvent();
// Data Members // Data Members
int app_argc; int app_argc;
char** app_argv; char** app_argv;
int key; int key;
#ifdef F_HAVE_LIBGPM #ifdef F_HAVE_LIBGPM
Gpm_Event gpm_ev; Gpm_Event gpm_ev;
bool gpmMouseEvent; bool gpmMouseEvent;
#endif #endif
struct button_state // bit field struct button_state // bit field
{ {
uChar left_button : 2; // 0..3 uChar left_button : 2; // 0..3
uChar right_button : 2; // 0..3 uChar right_button : 2; // 0..3
uChar middle_button : 2; // 0..3 uChar middle_button : 2; // 0..3
uChar shift_button : 1; // 0..1 uChar shift_button : 1; // 0..1
uChar control_button : 1; // 0..1 uChar control_button : 1; // 0..1
uChar meta_button : 1; // 0..1 uChar meta_button : 1; // 0..1
uChar wheel_up : 1; // 0..1 uChar wheel_up : 1; // 0..1
uChar wheel_down : 1; // 0..1 uChar wheel_down : 1; // 0..1
uChar mouse_moved : 1; // 0..1 uChar mouse_moved : 1; // 0..1
uChar : 4; // padding bits uChar : 4; // padding bits
} b_state; } b_state;
char k_buf[1024]; char k_buf[1024];
char x11_mouse[4]; char x11_mouse[4];
char sgr_mouse[13]; char sgr_mouse[13];
char urxvt_mouse[13]; char urxvt_mouse[13];
char fifo_buf[512]; char fifo_buf[512];
int fifo_offset; int fifo_offset;
bool fifo_in_use; bool fifo_in_use;
int fifo_buf_size; int fifo_buf_size;
long key_timeout; long key_timeout;
long dblclick_interval; long dblclick_interval;
struct timeval time_keypressed; struct timeval time_keypressed;
struct timeval time_mousepressed; struct timeval time_mousepressed;
FPoint new_mouse_position; FPoint new_mouse_position;
static eventQueue* event_queue; static eventQueue* event_queue;
static int quit_code; static int quit_code;
static bool quit_now; static bool quit_now;
static int loop_level; static int loop_level;
static bool process_timer_event; static bool process_timer_event;
static FPoint* zero_point; static FPoint* zero_point;
static uChar x11_button_state; static uChar x11_button_state;
static FWidget* move_size_widget; static FWidget* move_size_widget;
static FWidget* main_widget; static FWidget* main_widget;
static FWidget* active_window; static FWidget* active_window;
static FWidget* focus_widget; static FWidget* focus_widget;
static FWidget* clicked_widget; static FWidget* clicked_widget;
static FWidget* open_menu; static FWidget* open_menu;
// Friend functions from FWidget // Friend functions from FWidget
friend FWidget* FWidget::getMainWidget(); friend FWidget* FWidget::getMainWidget();
friend FWidget* FWidget::getFocusWidget() const; friend FWidget* FWidget::getFocusWidget() const;
friend void FWidget::setFocusWidget (FWidget*); friend void FWidget::setFocusWidget (FWidget*);
friend FWidget* FWidget::getClickedWidget(); friend FWidget* FWidget::getClickedWidget();
friend void FWidget::setClickedWidget (FWidget*); friend void FWidget::setClickedWidget (FWidget*);
friend FWidget* FWidget::getMoveSizeWidget(); friend FWidget* FWidget::getMoveSizeWidget();
friend void FWidget::setMoveSizeWidget (FWidget*); friend void FWidget::setMoveSizeWidget (FWidget*);
friend FWidget* FWidget::getOpenMenu(); friend FWidget* FWidget::getOpenMenu();
friend void FWidget::setOpenMenu (FWidget*); friend void FWidget::setOpenMenu (FWidget*);
// Friend functions from FWindow // Friend functions from FWindow
friend bool FWindow::activateWindow (bool); friend bool FWindow::activateWindow (bool);
friend FWindow* FWindow::getActiveWindow(); friend FWindow* FWindow::getActiveWindow();
friend void FWindow::unsetActiveWindow(); friend void FWindow::unsetActiveWindow();
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -553,7 +553,7 @@ void FButton::draw()
for (int y = 1; y <= getHeight(); y++) for (int y = 1; y <= getHeight(); y++)
{ {
setPrintPos (1, y); setPrintPos (1, y);
print (' '); // clear one left █ print (' '); // clear one left █
} }
d = 1; d = 1;
@ -610,7 +610,7 @@ void FButton::draw()
for (int y = 0; y < getHeight(); y++) for (int y = 0; y < getHeight(); y++)
{ {
setPrintPos (1 + d, 1 + y); setPrintPos (1 + d, 1 + y);
print (space); // full block █ print (space); // full block █
} }
} }
@ -632,7 +632,7 @@ void FButton::draw()
setReverse(true); setReverse(true);
setPrintPos (1 + getWidth(), y); setPrintPos (1 + getWidth(), y);
print (' '); // clear right print (' '); // clear right
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
@ -654,17 +654,17 @@ void FButton::draw()
setColor (button_fg, button_bg); setColor (button_fg, button_bg);
for (x = 0; x < i; x++) for (x = 0; x < i; x++)
print (space); // █ print (space); // █
if ( hotkeypos == -1 ) if ( hotkeypos == -1 )
setCursorPos (1 + margin + i + mono_1st_char, 1 + j ); // first character setCursorPos (1 + margin + i + mono_1st_char, 1 + j ); // first character
else else
setCursorPos (1 + margin + i + hotkeypos, 1 + j ); // hotkey setCursorPos (1 + margin + i + hotkeypos, 1 + j ); // hotkey
if ( is_ActiveFocus && (isMonochron() || getMaxColor() < 16) ) if ( is_ActiveFocus && (isMonochron() || getMaxColor() < 16) )
setBold(); setBold();
for (int z = 0; x < i + length && z < getWidth(); z++,x++) for (int z = 0; x < i + length && z < getWidth(); z++, x++)
{ {
if ( (z == hotkeypos) && is_Active ) if ( (z == hotkeypos) && is_Active )
{ {
@ -696,7 +696,7 @@ void FButton::draw()
unsetBold(); unsetBold();
for (x = i + length; x < getWidth() - 1; x++) for (x = i + length; x < getWidth() - 1; x++)
print (space); // █ print (space); // █
if ( getHeight() >= 2 ) if ( getHeight() >= 2 )
{ {
@ -705,14 +705,14 @@ void FButton::draw()
setPrintPos (2 + d, 1 + i); setPrintPos (2 + d, 1 + i);
for (int z = 1; z < getWidth(); z++) for (int z = 1; z < getWidth(); z++)
print (space); // █ print (space); // █
} }
for (i = j + 1; i < getHeight(); i++) for (i = j + 1; i < getHeight(); i++)
{ {
setPrintPos (2 + d, 1 + i); setPrintPos (2 + d, 1 + i);
for (int z = 1; z < getWidth(); z++) for (int z = 1; z < getWidth(); z++)
print (space); // █ print (space); // █
} }
} }
@ -725,7 +725,7 @@ void FButton::draw()
setColor ( parent_widget->getForegroundColor() setColor ( parent_widget->getForegroundColor()
, parent_widget->getBackgroundColor() ); , parent_widget->getBackgroundColor() );
print(' '); // restore background after button down print(' '); // restore background after button down
drawShadow(); drawShadow();
} }
@ -760,7 +760,7 @@ void FButton::updateButtonColor()
else else
{ {
button_fg = getForegroundColor(); button_fg = getForegroundColor();
button_bg = getBackgroundColor() ; button_bg = getBackgroundColor();
} }
} }
else // inactive else // inactive

View File

@ -40,97 +40,97 @@
class FButton : public FWidget class FButton : public FWidget
{ {
public: public:
// Constructors // Constructors
explicit FButton (FWidget* = 0); explicit FButton (FWidget* = 0);
FButton (const FString&, FWidget* = 0); FButton (const FString&, FWidget* = 0);
// Destructor // Destructor
virtual ~FButton(); virtual ~FButton();
// Accessors // Accessors
const char* getClassName() const; const char* getClassName() const;
FString& getText(); FString& getText();
// Mutators // Mutators
void setForegroundColor (short); void setForegroundColor (short);
void setBackgroundColor (short); void setBackgroundColor (short);
void setHotkeyForegroundColor (short); void setHotkeyForegroundColor (short);
void setFocusForegroundColor (short); void setFocusForegroundColor (short);
void setFocusBackgroundColor (short); void setFocusBackgroundColor (short);
void setInactiveForegroundColor (short); void setInactiveForegroundColor (short);
void setInactiveBackgroundColor (short); void setInactiveBackgroundColor (short);
bool setNoUnderline(bool); bool setNoUnderline(bool);
bool setNoUnderline(); bool setNoUnderline();
bool unsetNoUnderline(); bool unsetNoUnderline();
bool setEnable(bool); bool setEnable(bool);
bool setEnable(); bool setEnable();
bool unsetEnable(); bool unsetEnable();
bool setDisable(); bool setDisable();
bool setFocus(bool); bool setFocus(bool);
bool setFocus(); bool setFocus();
bool unsetFocus(); bool unsetFocus();
bool setFlat(bool); bool setFlat(bool);
bool setFlat(); bool setFlat();
bool unsetFlat(); bool unsetFlat();
bool setShadow(bool); bool setShadow(bool);
bool setShadow(); bool setShadow();
bool unsetShadow(); bool unsetShadow();
bool setDown(bool); bool setDown(bool);
bool setDown(); bool setDown();
bool setUp(); bool setUp();
bool setClickAnimation(bool); bool setClickAnimation(bool);
bool setClickAnimation(); bool setClickAnimation();
bool unsetClickAnimation(); bool unsetClickAnimation();
void setText (const FString&); void setText (const FString&);
// Inquiries // Inquiries
bool isFlat() const; bool isFlat() const;
bool isDown() const; bool isDown() const;
bool hasShadow() const; bool hasShadow() const;
bool hasClickAnimation(); bool hasClickAnimation();
// Methods // Methods
void hide(); void hide();
// Event handlers // Event handlers
void onKeyPress (FKeyEvent*); void onKeyPress (FKeyEvent*);
void onMouseDown (FMouseEvent*); void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*); void onMouseUp (FMouseEvent*);
void onMouseMove (FMouseEvent*); void onMouseMove (FMouseEvent*);
void onTimer (FTimerEvent*); void onTimer (FTimerEvent*);
void onAccel (FAccelEvent*); void onAccel (FAccelEvent*);
void onFocusIn (FFocusEvent*); void onFocusIn (FFocusEvent*);
void onFocusOut (FFocusEvent*); void onFocusOut (FFocusEvent*);
private: private:
// Disable copy constructor // Disable copy constructor
FButton (const FButton&); FButton (const FButton&);
// Disable assignment operator (=) // Disable assignment operator (=)
FButton& operator = (const FButton&); FButton& operator = (const FButton&);
// Methods // Methods
void init(); void init();
uChar getHotkey(); uChar getHotkey();
void setHotkeyAccelerator(); void setHotkeyAccelerator();
void detectHotkey(); void detectHotkey();
void draw(); void draw();
void updateButtonColor(); void updateButtonColor();
void processClick(); void processClick();
// Data Members // Data Members
FString text; FString text;
bool button_down; bool button_down;
bool click_animation; bool click_animation;
int click_time; int click_time;
short button_fg; short button_fg;
short button_bg; short button_bg;
short button_hotkey_fg; short button_hotkey_fg;
short button_focus_fg; short button_focus_fg;
short button_focus_bg; short button_focus_bg;
short button_inactive_fg; short button_inactive_fg;
short button_inactive_bg; short button_inactive_bg;
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -240,7 +240,8 @@ void FButtonGroup::insert (FToggleButton* button)
// setChecked the first FRadioButton // setChecked the first FRadioButton
if ( buttonlist.size() == 1 ) if ( buttonlist.size() == 1 )
{ {
FToggleButton* first_button = static_cast<FToggleButton*>(*buttonlist.begin()); FToggleButton* first_button;
first_button = static_cast<FToggleButton*>(*buttonlist.begin());
if ( isRadioButton(first_button) ) if ( isRadioButton(first_button) )
first_button->setChecked(); first_button->setChecked();
@ -254,8 +255,6 @@ void FButtonGroup::insert (FToggleButton* button)
"toggled", "toggled",
F_METHOD_CALLBACK (this, &FButtonGroup::cb_buttonToggled) F_METHOD_CALLBACK (this, &FButtonGroup::cb_buttonToggled)
); );
//checkScrollSize (button);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -43,77 +43,77 @@ class FToggleButton;
class FButtonGroup : public FScrollView class FButtonGroup : public FScrollView
{ {
public: public:
// Constructors // Constructors
explicit FButtonGroup (FWidget* = 0); explicit FButtonGroup (FWidget* = 0);
FButtonGroup (const FString&, FWidget* = 0); FButtonGroup (const FString&, FWidget* = 0);
// Destructor // Destructor
virtual ~FButtonGroup(); virtual ~FButtonGroup();
// Accessor // Accessor
const char* getClassName() const; const char* getClassName() const;
FToggleButton* getFirstButton(); FToggleButton* getFirstButton();
FToggleButton* getLastButton(); FToggleButton* getLastButton();
FToggleButton* getButton (int) const; FToggleButton* getButton (int) const;
uInt getCount() const; uInt getCount() const;
FString& getText(); FString& getText();
// Mutator // Mutator
bool setEnable(bool); bool setEnable(bool);
bool setEnable(); bool setEnable();
bool unsetEnable(); bool unsetEnable();
bool setDisable(); bool setDisable();
void setText (const FString&); void setText (const FString&);
// Inquiries // Inquiries
bool isChecked(int) const; bool isChecked(int) const;
bool hasFocusedButton() const; bool hasFocusedButton() const;
bool hasCheckedButton() const; bool hasCheckedButton() const;
// Methods // Methods
void hide(); void hide();
void insert (FToggleButton*); void insert (FToggleButton*);
void remove (FToggleButton*); void remove (FToggleButton*);
void checkScrollSize (FToggleButton*); void checkScrollSize (FToggleButton*);
void checkScrollSize (const FRect&); void checkScrollSize (const FRect&);
// Event handlers // Event handlers
void onMouseDown (FMouseEvent*); void onMouseDown (FMouseEvent*);
void onAccel (FAccelEvent*); void onAccel (FAccelEvent*);
void onFocusIn (FFocusEvent*); void onFocusIn (FFocusEvent*);
// Callback method // Callback method
void cb_buttonToggled (FWidget*, data_ptr); void cb_buttonToggled (FWidget*, data_ptr);
protected: protected:
// Accessor // Accessor
uChar getHotkey(); uChar getHotkey();
// Mutator // Mutator
void setHotkeyAccelerator(); void setHotkeyAccelerator();
// Methods // Methods
virtual void draw(); virtual void draw();
void drawLabel(); void drawLabel();
private: private:
// Disable copy constructor // Disable copy constructor
FButtonGroup (const FButtonGroup&); FButtonGroup (const FButtonGroup&);
// Disable assignment operator (=) // Disable assignment operator (=)
FButtonGroup& operator = (const FButtonGroup&); FButtonGroup& operator = (const FButtonGroup&);
// Inquiries // Inquiries
bool isRadioButton (FToggleButton*) const; bool isRadioButton (FToggleButton*) const;
// Methods // Methods
void init(); void init();
void directFocus(); void directFocus();
// Data Members // Data Members
FString text; FString text;
FObjectList buttonlist; FObjectList buttonlist;
}; };
#pragma pack(pop) #pragma pack(pop)

2082
src/fc.h

File diff suppressed because it is too large Load Diff

View File

@ -109,45 +109,45 @@ const int lastCharItem = int(sizeof(character) / sizeof(character[0])) - 1;
static int vt100_key_to_utf8[][2] = static int vt100_key_to_utf8[][2] =
{ {
{fc::vt100_key_rarrow , fc::BlackRightPointingPointer}, // ► {fc::vt100_key_rarrow , fc::BlackRightPointingPointer}, // ►
{fc::vt100_key_larrow , fc::BlackLeftPointingPointer}, // ◄ {fc::vt100_key_larrow , fc::BlackLeftPointingPointer}, // ◄
{fc::vt100_key_uarrow , fc::BlackUpPointingTriangle}, // ▲ {fc::vt100_key_uarrow , fc::BlackUpPointingTriangle}, // ▲
{fc::vt100_key_darrow , fc::BlackDownPointingTriangle}, // ▼ {fc::vt100_key_darrow , fc::BlackDownPointingTriangle}, // ▼
{fc::vt100_key_block , fc::FullBlock}, // █ {fc::vt100_key_block , fc::FullBlock}, // █
{fc::vt100_key_nsup , fc::SuperscriptLatinSmallLetterN}, // ⁿ {fc::vt100_key_nsup , fc::SuperscriptLatinSmallLetterN}, // ⁿ
{fc::vt100_key_blackrect, fc::BlackVerticalRectangle}, // ▮ {fc::vt100_key_blackrect, fc::BlackVerticalRectangle}, // ▮
{fc::vt100_key_diamond , fc::BlackDiamond}, // ◆ {fc::vt100_key_diamond , fc::BlackDiamond}, // ◆
{fc::vt100_key_ckboard , fc::MediumShade}, // ▒ {fc::vt100_key_ckboard , fc::MediumShade}, // ▒
{fc::vt100_key_htab , fc::SymbolForHorizontalTab}, // ␉ {fc::vt100_key_htab , fc::SymbolForHorizontalTab}, // ␉
{fc::vt100_key_ff , fc::SymbolForFormFeed}, // ␌ {fc::vt100_key_ff , fc::SymbolForFormFeed}, // ␌
{fc::vt100_key_cr , fc::SymbolForCarriageReturn}, // ␍ {fc::vt100_key_cr , fc::SymbolForCarriageReturn}, // ␍
{fc::vt100_key_lf , fc::SymbolForLineFeed}, // ␊ {fc::vt100_key_lf , fc::SymbolForLineFeed}, // ␊
{fc::vt100_key_degree , fc::Degree}, // ° {fc::vt100_key_degree , fc::Degree}, // °
{fc::vt100_key_plminus , fc::PlusMinus}, // ± {fc::vt100_key_plminus , fc::PlusMinus}, // ±
{fc::vt100_key_board , fc::SymbolForNewline}, // ␤ {fc::vt100_key_board , fc::SymbolForNewline}, // ␤
{fc::vt100_key_lantern , fc::SymbolForVerticalTab}, // ␋ {fc::vt100_key_lantern , fc::SymbolForVerticalTab}, // ␋
{fc::vt100_key_lrcorner , fc::BoxDrawingsUpAndLeft}, // ┘ {fc::vt100_key_lrcorner , fc::BoxDrawingsUpAndLeft}, // ┘
{fc::vt100_key_urcorner , fc::BoxDrawingsDownAndLeft}, // ┐ {fc::vt100_key_urcorner , fc::BoxDrawingsDownAndLeft}, // ┐
{fc::vt100_key_ulcorner , fc::BoxDrawingsDownAndRight}, // ┌ {fc::vt100_key_ulcorner , fc::BoxDrawingsDownAndRight}, // ┌
{fc::vt100_key_llcorner , fc::BoxDrawingsUpAndRight}, // └ {fc::vt100_key_llcorner , fc::BoxDrawingsUpAndRight}, // └
{fc::vt100_key_plus , fc::BoxDrawingsCross}, // ┼ {fc::vt100_key_plus , fc::BoxDrawingsCross}, // ┼
{fc::vt100_key_s1 , fc::HorizontalScanLine1}, // ⎺ {fc::vt100_key_s1 , fc::HorizontalScanLine1}, // ⎺
{fc::vt100_key_s3 , fc::HorizontalScanLine3}, // ⎻ {fc::vt100_key_s3 , fc::HorizontalScanLine3}, // ⎻
{fc::vt100_key_hline , fc::BoxDrawingsHorizontal}, // ─ {fc::vt100_key_hline , fc::BoxDrawingsHorizontal}, // ─
{fc::vt100_key_s7 , fc::HorizontalScanLine7}, // ⎼ {fc::vt100_key_s7 , fc::HorizontalScanLine7}, // ⎼
{fc::vt100_key_s9 , fc::HorizontalScanLine9}, // ⎽ {fc::vt100_key_s9 , fc::HorizontalScanLine9}, // ⎽
{fc::vt100_key_ltee , fc::BoxDrawingsVerticalAndRight}, // ├ {fc::vt100_key_ltee , fc::BoxDrawingsVerticalAndRight}, // ├
{fc::vt100_key_rtee , fc::BoxDrawingsVerticalAndLeft}, // ┤ {fc::vt100_key_rtee , fc::BoxDrawingsVerticalAndLeft}, // ┤
{fc::vt100_key_btee , fc::BoxDrawingsUpAndHorizontal}, // ┴ {fc::vt100_key_btee , fc::BoxDrawingsUpAndHorizontal}, // ┴
{fc::vt100_key_ttee , fc::BoxDrawingsDownAndHorizontal}, // ┬ {fc::vt100_key_ttee , fc::BoxDrawingsDownAndHorizontal}, // ┬
{fc::vt100_key_vline , fc::BoxDrawingsVertical}, // │ {fc::vt100_key_vline , fc::BoxDrawingsVertical}, // │
{fc::vt100_key_lequal , fc::LessThanOrEqualTo}, // ≤ {fc::vt100_key_lequal , fc::LessThanOrEqualTo}, // ≤
{fc::vt100_key_gequal , fc::GreaterThanOrEqualTo}, // ≥ {fc::vt100_key_gequal , fc::GreaterThanOrEqualTo}, // ≥
{fc::vt100_key_pi , fc::Pi}, // π {fc::vt100_key_pi , fc::Pi}, // π
{fc::vt100_key_nequal , fc::NotEqualTo}, // ≠ {fc::vt100_key_nequal , fc::NotEqualTo}, // ≠
{fc::vt100_key_sterling , fc::Pound}, // £ {fc::vt100_key_sterling , fc::Pound}, // £
{fc::vt100_key_bullet , fc::SmallBullet}, // · {fc::vt100_key_bullet , fc::SmallBullet}, // ·
{fc::vt100_key_diamond , fc::Bullet} // ◆ {fc::vt100_key_diamond , fc::Bullet} // ◆
}; };
const int lastKeyItem = int ( sizeof(vt100_key_to_utf8) const int lastKeyItem = int ( sizeof(vt100_key_to_utf8)

View File

@ -45,28 +45,28 @@
class FCheckBox : public FToggleButton class FCheckBox : public FToggleButton
{ {
public: public:
// Constructors // Constructors
explicit FCheckBox (FWidget* = 0); explicit FCheckBox (FWidget* = 0);
FCheckBox (const FString&, FWidget* = 0); FCheckBox (const FString&, FWidget* = 0);
// Destructor // Destructor
virtual ~FCheckBox(); virtual ~FCheckBox();
// Accessor // Accessor
const char* getClassName() const; const char* getClassName() const;
private: private:
// Disable copy constructor // Disable copy constructor
FCheckBox (const FCheckBox&); FCheckBox (const FCheckBox&);
// Disable assignment operator (=) // Disable assignment operator (=)
FCheckBox& operator = (const FCheckBox&); FCheckBox& operator = (const FCheckBox&);
// Methods // Methods
void init(); void init();
void draw(); void draw();
void drawCheckButton(); void drawCheckButton();
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -37,9 +37,9 @@ void FCheckMenuItem::init (FWidget* parent)
if ( ! parent ) if ( ! parent )
return; return;
if ( isMenu(parent) ) // Parent is menu if ( isMenu(parent) ) // Parent is menu
{ {
FMenu* menu_ptr = dynamic_cast<FMenu*>(parent); FMenu* menu_ptr = static_cast<FMenu*>(parent);
if ( menu_ptr ) if ( menu_ptr )
menu_ptr->has_checkable_items = true; menu_ptr->has_checkable_items = true;

View File

@ -45,28 +45,28 @@
class FCheckMenuItem : public FMenuItem class FCheckMenuItem : public FMenuItem
{ {
public: public:
// Constructors // Constructors
explicit FCheckMenuItem (FWidget* = 0); explicit FCheckMenuItem (FWidget* = 0);
FCheckMenuItem (const FString&, FWidget* = 0); FCheckMenuItem (const FString&, FWidget* = 0);
// Destructor // Destructor
virtual ~FCheckMenuItem(); virtual ~FCheckMenuItem();
// Accessor // Accessor
const char* getClassName() const; const char* getClassName() const;
private: private:
// Disable copy constructor // Disable copy constructor
FCheckMenuItem (const FCheckMenuItem&); FCheckMenuItem (const FCheckMenuItem&);
// Disable assignment operator (=) // Disable assignment operator (=)
FCheckMenuItem& operator = (const FCheckMenuItem&); FCheckMenuItem& operator = (const FCheckMenuItem&);
// Methods // Methods
void init (FWidget*); void init (FWidget*);
void processToggle(); void processToggle();
void processClicked(); void processClicked();
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -1187,7 +1187,7 @@ void FDialog::drawBorder()
// lower left corner border ⎣ // lower left corner border ⎣
print (fc::NF_border_corner_lower_left); print (fc::NF_border_corner_lower_left);
for (int x = 1; x < getWidth() - 1; x++) // low line _ for (int x = 1; x < getWidth() - 1; x++) // low line _
print (fc::NF_border_line_bottom); print (fc::NF_border_line_bottom);
setPrintPos (x2, y2); setPrintPos (x2, y2);
@ -1204,7 +1204,7 @@ void FDialog::drawBorder()
void FDialog::drawTitleBar() void FDialog::drawTitleBar()
{ {
static const int menu_btn = 3; static const int menu_btn = 3;
int i,x,length, zoom_btn; int i, x, length, zoom_btn;
// draw the title button // draw the title button
setPrintPos (1, 1); setPrintPos (1, 1);
@ -1325,7 +1325,7 @@ void FDialog::drawTitleBar()
} }
} }
} }
else // is not zoomed else // is not zoomed
{ {
if ( isNewFont() ) if ( isNewFont() )
{ {

View File

@ -48,122 +48,122 @@
class FDialog : public FWindow class FDialog : public FWindow
{ {
public: public:
// Using-declaration
using FWindow::setResizeable;
using FWindow::move;
using FWindow::setPos;
// Enumeration
enum DialogCode
{
Reject = 0,
Accept = 1
};
// Constructors
explicit FDialog (FWidget* = 0);
FDialog (const FString&, FWidget* = 0);
// Destructor
virtual ~FDialog();
// Accessors
virtual const char* getClassName() const;
FString getText() const;
// Mutators
bool setDialogWidget (bool);
bool setDialogWidget();
bool unsetDialogWidget();
bool setModal (bool);
bool setModal();
bool unsetModal();
bool setResizeable (bool);
bool setScrollable (bool);
bool setScrollable();
bool unsetScrollable();
void setText (const FString&);
// Inquiries
bool isModal();
bool isScrollable();
// Methods
void show();
void hide();
int exec();
void setPos (int, int, bool = true);
void move (int, int);
void setSize (int, int, bool = true);
void activateDialog();
// Event handlers
void onKeyPress (FKeyEvent*);
void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*);
void onMouseMove (FMouseEvent*);
void onMouseDoubleClick (FMouseEvent*);
void onAccel (FAccelEvent*);
void onWindowActive (FEvent*);
void onWindowInactive (FEvent*);
void onWindowRaised (FEvent*);
void onWindowLowered (FEvent*);
protected:
// Methods
virtual void done (int);
virtual void draw();
void drawDialogShadow();
// Event handlers
virtual void onShow (FShowEvent*);
virtual void onHide (FHideEvent*);
virtual void onClose (FCloseEvent*);
private:
// Using-declaration // Using-declaration
using FWindow::setResizeable; using FWidget::drawBorder;
using FWindow::move;
using FWindow::setPos;
// Enumeration // Disable copy constructor
enum DialogCode FDialog (const FDialog&);
{
Reject = 0,
Accept = 1
};
// Constructors // Disable assignment operator (=)
explicit FDialog (FWidget* = 0); FDialog& operator = (const FDialog&);
FDialog (const FString&, FWidget* = 0);
// Destructor // Methods
virtual ~FDialog(); void init();
virtual void drawBorder();
void drawTitleBar();
void leaveMenu();
void openMenu();
void selectFirstMenuItem();
void setZoomItem();
static void addDialog (FWidget*);
static void delDialog (FWidget*);
// Accessors // Callback methods
virtual const char* getClassName() const; void cb_move (FWidget*, data_ptr);
FString getText() const; void cb_zoom (FWidget*, data_ptr);
void cb_close (FWidget*, data_ptr);
// Mutators // Data Members
bool setDialogWidget (bool); FString tb_text; // title bar text
bool setDialogWidget(); int result_code;
bool unsetDialogWidget(); bool zoom_button_pressed;
bool setModal (bool); bool zoom_button_active;
bool setModal(); FPoint titlebar_click_pos;
bool unsetModal(); FPoint resize_click_pos;
bool setResizeable (bool); FRect save_geometry; // required by keyboard move/size
bool setScrollable (bool); FMenu* dialog_menu;
bool setScrollable(); FMenuItem* dgl_menuitem;
bool unsetScrollable(); FMenuItem* move_size_item;
void setText (const FString&); FMenuItem* zoom_item;
FMenuItem* close_item;
FToolTip* tooltip;
// Inquiries // Friend function from FMenu
bool isModal(); friend void FMenu::hideSuperMenus();
bool isScrollable();
// Methods
void show();
void hide();
int exec();
void setPos (int, int, bool = true);
void move (int, int);
void setSize (int, int, bool = true);
void activateDialog();
// Event handlers
void onKeyPress (FKeyEvent*);
void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*);
void onMouseMove (FMouseEvent*);
void onMouseDoubleClick (FMouseEvent*);
void onAccel (FAccelEvent*);
void onWindowActive (FEvent*);
void onWindowInactive (FEvent*);
void onWindowRaised (FEvent*);
void onWindowLowered (FEvent*);
protected:
// Methods
virtual void done (int);
virtual void draw();
void drawDialogShadow();
// Event handlers
virtual void onShow (FShowEvent*);
virtual void onHide (FHideEvent*);
virtual void onClose (FCloseEvent*);
private:
// Using-declaration
using FWidget::drawBorder;
// Disable copy constructor
FDialog (const FDialog&);
// Disable assignment operator (=)
FDialog& operator = (const FDialog&);
// Methods
void init();
virtual void drawBorder();
void drawTitleBar();
void leaveMenu();
void openMenu();
void selectFirstMenuItem();
void setZoomItem();
static void addDialog (FWidget*);
static void delDialog (FWidget*);
// Callback methods
void cb_move (FWidget*, data_ptr);
void cb_zoom (FWidget*, data_ptr);
void cb_close (FWidget*, data_ptr);
// Data Members
FString tb_text; // title bar text
int result_code;
bool zoom_button_pressed;
bool zoom_button_active;
FPoint titlebar_click_pos;
FPoint resize_click_pos;
FRect save_geometry; // required by keyboard move/size
FMenu* dialog_menu;
FMenuItem* dgl_menuitem;
FMenuItem* move_size_item;
FMenuItem* zoom_item;
FMenuItem* close_item;
FToolTip* tooltip;
// Friend function from FMenu
friend void FMenu::hideSuperMenus();
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -52,26 +52,26 @@
class FDialogListMenu : public FMenu class FDialogListMenu : public FMenu
{ {
public: public:
// Constructors // Constructors
explicit FDialogListMenu (FWidget* = 0); explicit FDialogListMenu (FWidget* = 0);
FDialogListMenu (const FString&, FWidget* = 0); FDialogListMenu (const FString&, FWidget* = 0);
// Destructor // Destructor
virtual ~FDialogListMenu(); virtual ~FDialogListMenu();
// Accessors // Accessors
virtual const char* getClassName() const; virtual const char* getClassName() const;
private: private:
// Disable copy constructor // Disable copy constructor
FDialogListMenu (const FDialogListMenu&); FDialogListMenu (const FDialogListMenu&);
// Disable assignment operator (=) // Disable assignment operator (=)
FDialogListMenu& operator = (const FDialogListMenu&); FDialogListMenu& operator = (const FDialogListMenu&);
// Method // Method
void init(); void init();
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -64,15 +64,15 @@
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
class FEvent // event base class class FEvent // event base class
{ {
public: public:
explicit FEvent(int); explicit FEvent(int);
virtual ~FEvent(); virtual ~FEvent();
int type() const; int type() const;
protected: protected:
int t; int t;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -85,20 +85,20 @@ class FEvent // event base class
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
class FKeyEvent : public FEvent // keyboard event class FKeyEvent : public FEvent // keyboard event
{ {
public: public:
FKeyEvent (int, int); FKeyEvent (int, int);
~FKeyEvent(); ~FKeyEvent();
int key() const; int key() const;
bool isAccepted() const; bool isAccepted() const;
void accept(); void accept();
void ignore(); void ignore();
protected: protected:
int k; int k;
bool accpt; bool accpt;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -111,25 +111,25 @@ class FKeyEvent : public FEvent // keyboard event
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
class FMouseEvent : public FEvent // mouse event class FMouseEvent : public FEvent // mouse event
{ {
public: public:
FMouseEvent (int, const FPoint&, int); FMouseEvent (int, const FPoint&, int);
FMouseEvent (int, const FPoint&, const FPoint&, int); FMouseEvent (int, const FPoint&, const FPoint&, int);
~FMouseEvent(); ~FMouseEvent();
const FPoint& getPos() const; const FPoint& getPos() const;
const FPoint& getTermPos() const; const FPoint& getTermPos() const;
int getX() const; int getX() const;
int getY() const; int getY() const;
int getTermX() const; int getTermX() const;
int getTermY() const; int getTermY() const;
int getButton() const; int getButton() const;
protected: protected:
FPoint p; FPoint p;
FPoint tp; FPoint tp;
int b; int b;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -142,25 +142,25 @@ class FMouseEvent : public FEvent // mouse event
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
class FWheelEvent : public FEvent // wheel event class FWheelEvent : public FEvent // wheel event
{ {
public: public:
FWheelEvent (int, const FPoint&, int); FWheelEvent (int, const FPoint&, int);
FWheelEvent (int, const FPoint&, const FPoint&, int); FWheelEvent (int, const FPoint&, const FPoint&, int);
~FWheelEvent(); ~FWheelEvent();
const FPoint& getPos() const; const FPoint& getPos() const;
const FPoint& getTermPos() const; const FPoint& getTermPos() const;
int getX() const; int getX() const;
int getY() const; int getY() const;
int getTermX() const; int getTermX() const;
int getTermY() const; int getTermY() const;
int getWheel() const; int getWheel() const;
protected: protected:
FPoint p; FPoint p;
FPoint tp; FPoint tp;
int w; int w;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -173,22 +173,22 @@ class FWheelEvent : public FEvent // wheel event
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
class FFocusEvent : public FEvent // focus event class FFocusEvent : public FEvent // focus event
{ {
public: public:
explicit FFocusEvent (int); explicit FFocusEvent (int);
~FFocusEvent(); ~FFocusEvent();
bool gotFocus() const; bool gotFocus() const;
bool lostFocus() const; bool lostFocus() const;
fc::FocusTypes getFocusType() const; fc::FocusTypes getFocusType() const;
void setFocusType(fc::FocusTypes); void setFocusType(fc::FocusTypes);
bool isAccepted() const; bool isAccepted() const;
void accept(); void accept();
void ignore(); void ignore();
protected: protected:
bool accpt; bool accpt;
fc::FocusTypes focus_type; fc::FocusTypes focus_type;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -201,26 +201,26 @@ class FFocusEvent : public FEvent // focus event
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
class FAccelEvent : public FEvent // focus event class FAccelEvent : public FEvent // focus event
{ {
private: private:
// Disable copy constructor // Disable copy constructor
FAccelEvent (const FAccelEvent&); FAccelEvent (const FAccelEvent&);
// Disable assignment operator (=) // Disable assignment operator (=)
FAccelEvent& operator = (const FAccelEvent&); FAccelEvent& operator = (const FAccelEvent&);
public: public:
FAccelEvent (int, void*); FAccelEvent (int, void*);
~FAccelEvent(); ~FAccelEvent();
void* focusedWidget() const; void* focusedWidget() const;
bool isAccepted() const; bool isAccepted() const;
void accept(); void accept();
void ignore(); void ignore();
protected: protected:
bool accpt; bool accpt;
void* focus_widget; void* focus_widget;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -230,18 +230,18 @@ class FAccelEvent : public FEvent // focus event
// class FResizeEvent // class FResizeEvent
//---------------------------------------------------------------------- //----------------------------------------------------------------------
class FResizeEvent : public FEvent // resize event class FResizeEvent : public FEvent // resize event
{ {
public: public:
explicit FResizeEvent (int); explicit FResizeEvent (int);
~FResizeEvent(); ~FResizeEvent();
bool isAccepted() const; bool isAccepted() const;
void accept(); void accept();
void ignore(); void ignore();
protected: protected:
bool accpt; bool accpt;
}; };
@ -250,11 +250,11 @@ class FResizeEvent : public FEvent // resize event
// class FShowEvent // class FShowEvent
//---------------------------------------------------------------------- //----------------------------------------------------------------------
class FShowEvent : public FEvent // show event class FShowEvent : public FEvent // show event
{ {
public: public:
explicit FShowEvent (int); explicit FShowEvent (int);
~FShowEvent(); ~FShowEvent();
}; };
@ -263,11 +263,11 @@ class FShowEvent : public FEvent // show event
// class FHideEvent // class FHideEvent
//---------------------------------------------------------------------- //----------------------------------------------------------------------
class FHideEvent : public FEvent // hide event class FHideEvent : public FEvent // hide event
{ {
public: public:
explicit FHideEvent (int); explicit FHideEvent (int);
~FHideEvent(); ~FHideEvent();
}; };
@ -276,18 +276,18 @@ class FHideEvent : public FEvent // hide event
// class FCloseEvent // class FCloseEvent
//---------------------------------------------------------------------- //----------------------------------------------------------------------
class FCloseEvent : public FEvent // close event class FCloseEvent : public FEvent // close event
{ {
public: public:
explicit FCloseEvent(int); explicit FCloseEvent(int);
~FCloseEvent(); ~FCloseEvent();
bool isAccepted() const; bool isAccepted() const;
void accept(); void accept();
void ignore(); void ignore();
protected: protected:
bool accpt; bool accpt;
}; };
@ -299,16 +299,16 @@ class FCloseEvent : public FEvent // close event
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
class FTimerEvent : public FEvent // timer event class FTimerEvent : public FEvent // timer event
{ {
public: public:
FTimerEvent(int, int); FTimerEvent(int, int);
~FTimerEvent(); ~FTimerEvent();
int timerId() const; int timerId() const;
protected: protected:
int id; int id;
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -1,8 +1,11 @@
// File: ffiledialog.cpp // File: ffiledialog.cpp
// Provides: class FFileDialog // Provides: class FFileDialog
#include <vector>
#include "ffiledialog.h" #include "ffiledialog.h"
// non-member functions // non-member functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool sortByName ( const FFileDialog::dir_entry& lhs bool sortByName ( const FFileDialog::dir_entry& lhs
@ -230,7 +233,6 @@ void FFileDialog::onKeyPress (FKeyEvent* ev)
default: default:
break; break;
} }
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -268,7 +270,8 @@ int FFileDialog::readDir()
continue; continue;
} }
if ( dir[0] == '/' && dir[1] == '\0' && std::strcmp(next->d_name, "..") == 0 ) if ( dir[0] == '/' && dir[1] == '\0'
&& std::strcmp(next->d_name, "..") == 0 )
continue; continue;
dir_entry entry; dir_entry entry;
@ -280,7 +283,9 @@ int FFileDialog::readDir()
char resolved_path[MAXPATHLEN] = {}; char resolved_path[MAXPATHLEN] = {};
char symLink[MAXPATHLEN] = {}; char symLink[MAXPATHLEN] = {};
std::strncpy (symLink, dir, sizeof(symLink) - 1); std::strncpy (symLink, dir, sizeof(symLink) - 1);
std::strncat (symLink, next->d_name, sizeof(symLink) - std::strlen(symLink) - 1); std::strncat ( symLink
, next->d_name
, sizeof(symLink) - std::strlen(symLink) - 1);
if ( realpath(symLink, resolved_path) != 0 ) // follow link if ( realpath(symLink, resolved_path) != 0 ) // follow link
{ {
@ -310,7 +315,6 @@ int FFileDialog::readDir()
} }
else else
break; break;
} // end while } // end while
if ( closedir (directory_stream) != 0 ) if ( closedir (directory_stream) != 0 )
@ -326,11 +330,17 @@ int FFileDialog::readDir()
dir_num = numOfDirs(); dir_num = numOfDirs();
// directories first // directories first
std::sort(dir_entries.begin() + start, dir_entries.end(), sortDirFirst); std::sort ( dir_entries.begin() + start
, dir_entries.end()
, sortDirFirst );
// sort directories by name // sort directories by name
std::sort(dir_entries.begin() + start, dir_entries.begin() + dir_num, sortByName); std::sort ( dir_entries.begin() + start
, dir_entries.begin() + dir_num
, sortByName );
// sort files by name // sort files by name
std::sort(dir_entries.begin() + dir_num, dir_entries.end(), sortByName); std::sort ( dir_entries.begin() + dir_num
, dir_entries.end()
, sortByName );
// fill list with directory entries // fill list with directory entries
filebrowser->clear(); filebrowser->clear();
@ -525,9 +535,9 @@ void FFileDialog::init()
cancel->setGeometry(19, 10, 9, 1); cancel->setGeometry(19, 10, 9, 1);
if ( dlg_type == FFileDialog::Save ) if ( dlg_type == FFileDialog::Save )
open = new FButton("&Save",this); open = new FButton("&Save", this);
else else
open = new FButton("&Open",this); open = new FButton("&Open", this);
open->setGeometry(30, 10, 9, 1); open->setGeometry(30, 10, 9, 1);
setGeometry (x, y, getWidth(), getHeight()); setGeometry (x, y, getWidth(), getHeight());
@ -581,19 +591,18 @@ void FFileDialog::init()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
char* FFileDialog::getHomeDir() char* FFileDialog::getHomeDir()
{ {
struct passwd* pwd; struct passwd pwd;
pwd = getpwuid( geteuid() ); struct passwd* pwd_ptr;
char buf[1024];
if ( ! pwd ) if ( getpwuid_r (geteuid(), &pwd, buf, sizeof(buf), &pwd_ptr) )
return const_cast<char*>(""); return const_cast<char*>("");
else else
{ {
pwd = getpwnam(pwd->pw_name); if ( getpwnam_r (pwd.pw_name, &pwd, buf, sizeof(buf), &pwd_ptr) )
if ( ! pwd )
return const_cast<char*>(""); return const_cast<char*>("");
else else
return pwd->pw_dir; return pwd.pw_dir;
} }
} }
@ -695,7 +704,8 @@ int FFileDialog::changeDir (const FString& dirname)
{ {
int i = 1; int i = 1;
std::vector<dir_entry>::const_iterator iter, end; std::vector<dir_entry>::const_iterator iter, end;
const char* const baseName = basename(const_cast<char*>(lastdir.c_str())); const char* const baseName = \
basename(const_cast<char*>(lastdir.c_str()));
iter = dir_entries.begin(); iter = dir_entries.begin();
end = dir_entries.end(); end = dir_entries.end();

View File

@ -46,6 +46,7 @@
#include <pwd.h> #include <pwd.h>
#include <string> #include <string>
#include <vector>
#include "fbutton.h" #include "fbutton.h"
#include "fcheckbox.h" #include "fcheckbox.h"
@ -66,102 +67,102 @@
class FFileDialog : public FDialog class FFileDialog : public FDialog
{ {
public: public:
// Enumeration // Enumeration
enum DialogType enum DialogType
{ {
Open = 0, Open = 0,
Save = 1 Save = 1
}; };
// Constructors // Constructors
explicit FFileDialog (FWidget* = 0); explicit FFileDialog (FWidget* = 0);
FFileDialog (const FFileDialog&); // copy constructor FFileDialog (const FFileDialog&); // copy constructor
FFileDialog ( const FString& FFileDialog ( const FString&
, const FString& , const FString&
, DialogType = FFileDialog::Open , DialogType = FFileDialog::Open
, FWidget* = 0 ); , FWidget* = 0 );
// Destructor // Destructor
~FFileDialog(); ~FFileDialog();
// Assignment operator (=) // Assignment operator (=)
FFileDialog& operator = (const FFileDialog&); FFileDialog& operator = (const FFileDialog&);
// Accessors // Accessors
const char* getClassName() const; const char* getClassName() const;
const FString getPath() const; const FString getPath() const;
const FString getFilter() const; const FString getFilter() const;
const FString getSelectedFile() const; const FString getSelectedFile() const;
bool getShowHiddenFiles(); bool getShowHiddenFiles();
// Mutators // Mutators
void setPath (const FString&); void setPath (const FString&);
void setFilter (const FString&); void setFilter (const FString&);
bool setShowHiddenFiles(bool); bool setShowHiddenFiles(bool);
bool setShowHiddenFiles(); bool setShowHiddenFiles();
bool unsetShowHiddenFiles(); bool unsetShowHiddenFiles();
// Event handler // Event handler
void onKeyPress (FKeyEvent*); void onKeyPress (FKeyEvent*);
// Methods // Methods
int readDir(); int readDir();
static const FString fileOpenChooser ( FWidget* static const FString fileOpenChooser ( FWidget*
, const FString& = FString() , const FString& = FString()
, const FString& = FString() ); , const FString& = FString() );
static const FString fileSaveChooser ( FWidget* static const FString fileSaveChooser ( FWidget*
, const FString& = FString() , const FString& = FString()
, const FString& = FString() ); , const FString& = FString() );
protected: protected:
// Method // Method
void adjustSize(); void adjustSize();
private: private:
// Typedef // Typedef
struct dir_entry struct dir_entry
{ {
char* name; char* name;
uChar type; uChar type;
}; };
typedef std::vector<dir_entry> dirEntries; typedef std::vector<dir_entry> dirEntries;
// Method // Method
void init(); void init();
static char* getHomeDir(); static char* getHomeDir();
inline bool pattern_match (const char* const, char*&); inline bool pattern_match (const char* const, char*&);
void clear(); void clear();
int numOfDirs(); int numOfDirs();
int changeDir (const FString&); int changeDir (const FString&);
void printPath (const FString&); void printPath (const FString&);
// Callback methods // Callback methods
void cb_processActivate (FWidget*, data_ptr); void cb_processActivate (FWidget*, data_ptr);
void cb_processRowChanged (FWidget*, data_ptr); void cb_processRowChanged (FWidget*, data_ptr);
void cb_processClicked (FWidget*, data_ptr); void cb_processClicked (FWidget*, data_ptr);
void cb_processCancel (FWidget*, data_ptr); void cb_processCancel (FWidget*, data_ptr);
void cb_processOpen (FWidget*, data_ptr); void cb_processOpen (FWidget*, data_ptr);
void cb_processShowHidden (FWidget*, data_ptr); void cb_processShowHidden (FWidget*, data_ptr);
// Data Members // Data Members
DIR* directory_stream; DIR* directory_stream;
dirEntries dir_entries; dirEntries dir_entries;
FString directory; FString directory;
FString filter_pattern; FString filter_pattern;
FListBox* filebrowser; FListBox* filebrowser;
FLineEdit* filename; FLineEdit* filename;
FCheckBox* hidden; FCheckBox* hidden;
FButton* cancel; FButton* cancel;
FButton* open; FButton* open;
DialogType dlg_type; DialogType dlg_type;
bool show_hidden; bool show_hidden;
// Friend functions // Friend functions
friend bool sortByName ( const FFileDialog::dir_entry& friend bool sortByName ( const FFileDialog::dir_entry&
, const FFileDialog::dir_entry& ); , const FFileDialog::dir_entry& );
friend bool sortDirFirst ( const FFileDialog::dir_entry& friend bool sortDirFirst ( const FFileDialog::dir_entry&
, const FFileDialog::dir_entry& ); , const FFileDialog::dir_entry& );
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -3,6 +3,7 @@
#ifndef FKEYMAP_H #ifndef FKEYMAP_H
#define FKEYMAP_H #define FKEYMAP_H
#include <string>
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
@ -448,12 +449,12 @@ static keyname FkeyName[] =
{ fc::Fckey_e , "Ctrl+E" }, { fc::Fckey_e , "Ctrl+E" },
{ fc::Fckey_f , "Ctrl+F" }, { fc::Fckey_f , "Ctrl+F" },
{ fc::Fckey_g , "Ctrl+G" }, { fc::Fckey_g , "Ctrl+G" },
{ fc::Fkey_erase , "Backspace" }, // Ctrl+H { fc::Fkey_erase , "Backspace" }, // Ctrl+H
{ fc::Fkey_tab , "Tab" }, // Ctrl+I { fc::Fkey_tab , "Tab" }, // Ctrl+I
{ fc::Fckey_j , "Ctrl+J" }, { fc::Fckey_j , "Ctrl+J" },
{ fc::Fckey_h , "Ctrl+K" }, { fc::Fckey_h , "Ctrl+K" },
{ fc::Fckey_l , "Ctrl+L" }, { fc::Fckey_l , "Ctrl+L" },
{ fc::Fkey_return , "Return" }, // Ctrl+M { fc::Fkey_return , "Return" }, // Ctrl+M
{ fc::Fckey_n , "Ctrl+N" }, { fc::Fckey_n , "Ctrl+N" },
{ fc::Fckey_o , "Ctrl+O" }, { fc::Fckey_o , "Ctrl+O" },
{ fc::Fckey_p , "Ctrl+P" }, { fc::Fckey_p , "Ctrl+P" },
@ -467,13 +468,13 @@ static keyname FkeyName[] =
{ fc::Fckey_x , "Ctrl+X" }, { fc::Fckey_x , "Ctrl+X" },
{ fc::Fckey_y , "Ctrl+Y" }, { fc::Fckey_y , "Ctrl+Y" },
{ fc::Fckey_z , "Ctrl+Z" }, { fc::Fckey_z , "Ctrl+Z" },
{ fc::Fkey_escape , "Esc" }, // Ctrl+[ { fc::Fkey_escape , "Esc" }, // Ctrl+[
{ fc::Fckey_backslash , "Ctrl+\\" }, { fc::Fckey_backslash , "Ctrl+\\" },
{ fc::Fckey_right_square_bracket, "Ctrl+]" }, { fc::Fckey_right_square_bracket, "Ctrl+]" },
{ fc::Fckey_caret , "Ctrl+^" }, { fc::Fckey_caret , "Ctrl+^" },
{ fc::Fckey_underscore , "Ctrl+_" }, { fc::Fckey_underscore , "Ctrl+_" },
{ fc::Fkey_space , "Space" }, { fc::Fkey_space , "Space" },
{ fc::Fckey_space , "Ctrl+Space" }, // Ctrl+(Space or @) { fc::Fckey_space , "Ctrl+Space" }, // Ctrl+(Space or @)
{ fc::Fkey_backspace , "Backspace" }, { fc::Fkey_backspace , "Backspace" },
{ fc::Fkey_catab , "Clear-All-Tabs" }, { fc::Fkey_catab , "Clear-All-Tabs" },
{ fc::Fkey_clear , "Clear-Screen" }, { fc::Fkey_clear , "Clear-Screen" },

View File

@ -45,7 +45,7 @@ FLabel::FLabel (const FString& txt, FWidget* parent)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FLabel::~FLabel() // destructor FLabel::~FLabel() // destructor
{ {
delAccelerator(); delAccelerator();
} }

View File

@ -28,6 +28,7 @@
#ifndef FLABEL_H #ifndef FLABEL_H
#define FLABEL_H #define FLABEL_H
#include <vector>
#include "fwidget.h" #include "fwidget.h"
@ -40,79 +41,79 @@
class FLabel : public FWidget class FLabel : public FWidget
{ {
public: public:
// Using-declaration // Using-declaration
using FWidget::setEnable; using FWidget::setEnable;
// Constructor // Constructor
explicit FLabel (FWidget* = 0); explicit FLabel (FWidget* = 0);
FLabel (const FString&, FWidget* = 0); FLabel (const FString&, FWidget* = 0);
// Destructor // Destructor
virtual ~FLabel(); virtual ~FLabel();
// Accessors // Accessors
const char* getClassName() const; const char* getClassName() const;
FTerm* getAccelWidget(); FTerm* getAccelWidget();
fc::text_alignment getAlignment(); fc::text_alignment getAlignment();
FString& getText(); FString& getText();
// Mutators // Mutators
void setAccelWidget (FWidget* = 0); void setAccelWidget (FWidget* = 0);
void setAlignment(fc::text_alignment); void setAlignment(fc::text_alignment);
bool setEmphasis(bool); bool setEmphasis(bool);
bool setEmphasis(); bool setEmphasis();
bool unsetEmphasis(); bool unsetEmphasis();
bool setReverseMode(bool); bool setReverseMode(bool);
bool setReverseMode(); bool setReverseMode();
bool unsetReverseMode(); bool unsetReverseMode();
bool setEnable (bool); bool setEnable (bool);
void setNumber(long); void setNumber(long);
void setText (const FString&); void setText (const FString&);
// Inquiries // Inquiries
bool hasEmphasis(); bool hasEmphasis();
bool hasReverseMode(); bool hasReverseMode();
// Methods // Methods
void hide(); void hide();
// Event handlers // Event handlers
void onMouseDown (FMouseEvent*); void onMouseDown (FMouseEvent*);
void onAccel (FAccelEvent*); void onAccel (FAccelEvent*);
// Callback method // Callback method
void cb_accel_widget_destroyed (FWidget*, data_ptr); void cb_accel_widget_destroyed (FWidget*, data_ptr);
private: private:
// Typedef // Typedef
typedef std::vector<FString> multiLineText; typedef std::vector<FString> multiLineText;
// Disable copy constructor // Disable copy constructor
FLabel (const FLabel&); FLabel (const FLabel&);
// Disable assignment operator (=) // Disable assignment operator (=)
FLabel& operator = (const FLabel&); FLabel& operator = (const FLabel&);
// Methods // Methods
void init(); void init();
uChar getHotkey(); uChar getHotkey();
int getHotkeyPos (wchar_t*&, wchar_t*&, uInt); int getHotkeyPos (wchar_t*&, wchar_t*&, uInt);
void setHotkeyAccelerator(); void setHotkeyAccelerator();
int getAlignOffset (int); int getAlignOffset (int);
void printLine (wchar_t*&, uInt, int, int = 0); void printLine (wchar_t*&, uInt, int, int = 0);
void draw(); void draw();
// Data Members // Data Members
multiLineText multiline_text; multiLineText multiline_text;
bool multiline; bool multiline;
FString text; FString text;
fc::text_alignment alignment; fc::text_alignment alignment;
short emphasis_color; short emphasis_color;
short ellipsis_color; short ellipsis_color;
bool emphasis; bool emphasis;
bool reverse_mode; bool reverse_mode;
FWidget* accel_widget; FWidget* accel_widget;
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -272,7 +272,7 @@ void FLineEdit::onKeyPress (FKeyEvent* ev)
ev->accept(); ev->accept();
break; break;
case fc::Fkey_dc: // del key case fc::Fkey_dc: // del key
if ( len > 0 && cursor_pos < len ) if ( len > 0 && cursor_pos < len )
{ {
text.remove(uInt(cursor_pos), 1); text.remove(uInt(cursor_pos), 1);
@ -306,7 +306,7 @@ void FLineEdit::onKeyPress (FKeyEvent* ev)
ev->accept(); ev->accept();
break; break;
case fc::Fkey_ic: // insert key case fc::Fkey_ic: // insert key
insert_mode = not insert_mode; insert_mode = not insert_mode;
if ( insert_mode ) if ( insert_mode )

View File

@ -41,97 +41,97 @@
class FLineEdit : public FWidget class FLineEdit : public FWidget
{ {
public: public:
// Enumeration // Enumeration
enum label_o enum label_o
{ {
label_above = 0, label_above = 0,
label_left = 1 label_left = 1
}; };
// Constructor // Constructor
explicit FLineEdit (FWidget* = 0); explicit FLineEdit (FWidget* = 0);
FLineEdit (const FString&, FWidget* = 0); FLineEdit (const FString&, FWidget* = 0);
// Destructor // Destructor
virtual ~FLineEdit(); virtual ~FLineEdit();
// Accessors // Accessors
const char* getClassName() const; const char* getClassName() const;
FString getText() const; FString getText() const;
int getLabelOrientation(); int getLabelOrientation();
// Mutators // Mutators
void setText (const FString&); void setText (const FString&);
void setLabelText (const FString&); void setLabelText (const FString&);
void setLabelOrientation(const label_o); void setLabelOrientation(const label_o);
bool setEnable(bool); bool setEnable(bool);
bool setEnable(); bool setEnable();
bool unsetEnable(); bool unsetEnable();
bool setDisable(); bool setDisable();
bool setFocus(bool); bool setFocus(bool);
bool setFocus(); bool setFocus();
bool unsetFocus(); bool unsetFocus();
bool setShadow(bool); bool setShadow(bool);
bool setShadow(); bool setShadow();
bool unsetShadow(); bool unsetShadow();
// Inquiry // Inquiry
bool hasShadow(); bool hasShadow();
// Methods // Methods
void hide(); void hide();
void clearText(); void clearText();
// Event handlers // Event handlers
void onKeyPress (FKeyEvent*); void onKeyPress (FKeyEvent*);
void onMouseDown (FMouseEvent*); void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*); void onMouseUp (FMouseEvent*);
void onMouseMove (FMouseEvent*); void onMouseMove (FMouseEvent*);
void onTimer (FTimerEvent*); void onTimer (FTimerEvent*);
void onAccel (FAccelEvent*); void onAccel (FAccelEvent*);
void onHide (FHideEvent*); void onHide (FHideEvent*);
void onFocusIn (FFocusEvent*); void onFocusIn (FFocusEvent*);
void onFocusOut (FFocusEvent*); void onFocusOut (FFocusEvent*);
protected: protected:
void adjustLabel(); void adjustLabel();
void adjustSize(); void adjustSize();
private: private:
// Enumeration // Enumeration
enum dragScroll enum dragScroll
{ {
noScroll = 0, noScroll = 0,
scrollLeft = 1, scrollLeft = 1,
scrollRight = 2 scrollRight = 2
}; };
// Disable copy constructor // Disable copy constructor
FLineEdit (const FLineEdit&); FLineEdit (const FLineEdit&);
// Disable assignment operator (=) // Disable assignment operator (=)
FLineEdit& operator = (const FLineEdit&); FLineEdit& operator = (const FLineEdit&);
// Methods // Methods
void init(); void init();
bool hasHotkey(); bool hasHotkey();
void draw(); void draw();
void drawInputField(); void drawInputField();
void processActivate(); void processActivate();
void processChanged(); void processChanged();
// Data Members // Data Members
FString text; FString text;
FString label_text; FString label_text;
FLabel* label; FLabel* label;
label_o label_orientation; label_o label_orientation;
dragScroll drag_scroll; dragScroll drag_scroll;
bool scroll_timer; bool scroll_timer;
int scroll_repeat; int scroll_repeat;
bool insert_mode; bool insert_mode;
int cursor_pos; int cursor_pos;
int text_offset; int text_offset;
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -2,6 +2,8 @@
// Provides: class FListBoxItem // Provides: class FListBoxItem
// class FListBox // class FListBox
#include <algorithm>
#include "fapplication.h" #include "fapplication.h"
#include "flistbox.h" #include "flistbox.h"
#include "fscrollbar.h" #include "fscrollbar.h"
@ -38,7 +40,7 @@ FListBoxItem::FListBoxItem (const FString& txt, FWidget::data_ptr data)
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FListBoxItem::~FListBoxItem() FListBoxItem::~FListBoxItem() // destructor
{ } { }
// public methods of FListBoxItem // public methods of FListBoxItem
@ -403,7 +405,7 @@ void FListBox::clear()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListBox::onKeyPress (FKeyEvent* ev) void FListBox::onKeyPress (FKeyEvent* ev)
{ {
static const int padding_space = 2; // 1 leading space + 1 tailing space static const int padding_space = 2; // 1 leading space + 1 tailing space
int element_count = int(getCount()); int element_count = int(getCount());
int current_before = current; int current_before = current;
int xoffset_before = xoffset; int xoffset_before = xoffset;
@ -1306,8 +1308,8 @@ void FListBox::draw()
for (int y = 2; y < getHeight(); y++) for (int y = 2; y < getHeight(); y++)
{ {
setPrintPos (getWidth(),y); setPrintPos (getWidth(), y);
print (' '); // clear right side of the scrollbar print (' '); // clear right side of the scrollbar
} }
} }
@ -1448,7 +1450,7 @@ void FListBox::drawList()
setColor ( wc.selected_current_element_fg setColor ( wc.selected_current_element_fg
, wc.selected_current_element_bg ); , wc.selected_current_element_bg );
setCursorPos (3, 2 + int(y)); // first character setCursorPos (3, 2 + int(y)); // first character
} }
else else
{ {
@ -1464,10 +1466,11 @@ void FListBox::drawList()
if ( inc_len > 0 ) // incremental search if ( inc_len > 0 ) // incremental search
{ {
serach_mark = true; serach_mark = true;
setCursorPos (2 + b + int(inc_len), 2 + int(y)); // last found character // Place the cursor on the last found character
setCursorPos (2 + b + int(inc_len), 2 + int(y));
} }
else // only highlighted else // only highlighted
setCursorPos (3 + b, 2 + int(y)); // first character setCursorPos (3 + b, 2 + int(y)); // first character
} }
else else
setColor ( wc.current_element_fg setColor ( wc.current_element_fg
@ -1793,7 +1796,7 @@ void FListBox::cb_VBarChange (FWidget*, data_ptr)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListBox::cb_HBarChange (FWidget*, data_ptr) void FListBox::cb_HBarChange (FWidget*, data_ptr)
{ {
static const int padding_space = 2; // 1 leading space + 1 tailing space static const int padding_space = 2; // 1 leading space + 1 tailing space
FScrollbar::sType scrollType; FScrollbar::sType scrollType;
int distance = 1; int distance = 1;
int xoffset_before = xoffset; int xoffset_before = xoffset;

View File

@ -30,6 +30,8 @@
#ifndef FLISTBOX_H #ifndef FLISTBOX_H
#define FLISTBOX_H #define FLISTBOX_H
#include <vector>
#include "fscrollbar.h" #include "fscrollbar.h"
#include "fstring.h" #include "fstring.h"
#include "fwidget.h" #include "fwidget.h"
@ -44,35 +46,35 @@
class FListBoxItem class FListBoxItem
{ {
public: public:
// Constructors // Constructors
FListBoxItem (); FListBoxItem ();
FListBoxItem (const FListBoxItem&); // copy constructor FListBoxItem (const FListBoxItem&); // copy constructor
explicit FListBoxItem (const FString&, FWidget::data_ptr = 0); explicit FListBoxItem (const FString&, FWidget::data_ptr = 0);
// Destructor // Destructor
virtual ~FListBoxItem(); virtual ~FListBoxItem();
// Assignment operator (=) // Assignment operator (=)
FListBoxItem& operator = (const FListBoxItem&); FListBoxItem& operator = (const FListBoxItem&);
// Accessors // Accessors
virtual FString& getText(); virtual FString& getText();
virtual FWidget::data_ptr getData() const; virtual FWidget::data_ptr getData() const;
// Mutators // Mutators
void setText (const FString&); void setText (const FString&);
void setData (FWidget::data_ptr); void setData (FWidget::data_ptr);
private: private:
// Friend classes // Friend classes
friend class FListBox; friend class FListBox;
// Data Members // Data Members
FString text; FString text;
FWidget::data_ptr data_pointer; FWidget::data_ptr data_pointer;
fc::brackets_type brackets; fc::brackets_type brackets;
bool selected; bool selected;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -104,154 +106,154 @@ inline void FListBoxItem::setData (FWidget::data_ptr data)
class FListBox : public FWidget class FListBox : public FWidget
{ {
public: public:
// Typedef // Typedef
typedef std::vector<FListBoxItem> listBoxItems; typedef std::vector<FListBoxItem> listBoxItems;
// Using-declaration // Using-declaration
using FWidget::setGeometry; using FWidget::setGeometry;
// Constructor // Constructor
explicit FListBox (FWidget* = 0); explicit FListBox (FWidget* = 0);
template <class Iterator, class InsertConverter> template <class Iterator, class InsertConverter>
FListBox (Iterator, Iterator, InsertConverter, FWidget* = 0); FListBox (Iterator, Iterator, InsertConverter, FWidget* = 0);
template <class Container, class LazyConverter> template <class Container, class LazyConverter>
FListBox (Container, LazyConverter, FWidget* = 0); FListBox (Container, LazyConverter, FWidget* = 0);
// Destructor // Destructor
~FListBox(); ~FListBox();
// Accessors // Accessors
const char* getClassName() const; const char* getClassName() const;
uInt getCount() const; uInt getCount() const;
FListBoxItem getItem (int); FListBoxItem getItem (int);
FListBoxItem getItem (listBoxItems::iterator) const; FListBoxItem getItem (listBoxItems::iterator) const;
int currentItem() const; int currentItem() const;
FString& getText(); FString& getText();
// Mutators // Mutators
void setCurrentItem (int); void setCurrentItem (int);
void setCurrentItem (listBoxItems::iterator); void setCurrentItem (listBoxItems::iterator);
void selectItem (int); void selectItem (int);
void selectItem (listBoxItems::iterator); void selectItem (listBoxItems::iterator);
void unselectItem (int); void unselectItem (int);
void unselectItem (listBoxItems::iterator); void unselectItem (listBoxItems::iterator);
void showInsideBrackets (int, fc::brackets_type); void showInsideBrackets (int, fc::brackets_type);
void showNoBrackets (int); void showNoBrackets (int);
void showNoBrackets (listBoxItems::iterator); void showNoBrackets (listBoxItems::iterator);
void setGeometry (int, int, int, int, bool = true); void setGeometry (int, int, int, int, bool = true);
void setMultiSelection (bool); void setMultiSelection (bool);
void setMultiSelection (); void setMultiSelection ();
void unsetMultiSelection (); void unsetMultiSelection ();
bool setDisable(); bool setDisable();
bool setFocus (bool); bool setFocus (bool);
bool setFocus(); bool setFocus();
bool unsetFocus(); bool unsetFocus();
void setText (const FString&); void setText (const FString&);
// Inquiries // Inquiries
bool isSelected (int); bool isSelected (int);
bool isSelected (listBoxItems::iterator) const; bool isSelected (listBoxItems::iterator) const;
bool isMultiSelection() const; bool isMultiSelection() const;
bool hasBrackets (int); bool hasBrackets (int);
bool hasBrackets (listBoxItems::iterator) const; bool hasBrackets (listBoxItems::iterator) const;
// Methods // Methods
void hide(); void hide();
template <class Iterator, class InsertConverter> template <class Iterator, class InsertConverter>
void insert (Iterator, Iterator, InsertConverter); void insert (Iterator, Iterator, InsertConverter);
template <class Container, class LazyConverter> template <class Container, class LazyConverter>
void insert (Container, LazyConverter); void insert (Container, LazyConverter);
void insert (FListBoxItem); void insert (FListBoxItem);
void insert ( const FString& void insert ( const FString&
, fc::brackets_type = fc::NoBrackets , fc::brackets_type = fc::NoBrackets
, bool = false , bool = false
, data_ptr = 0 ); , data_ptr = 0 );
void insert ( long void insert ( long
, fc::brackets_type = fc::NoBrackets , fc::brackets_type = fc::NoBrackets
, bool = false , bool = false
, data_ptr = 0 ); , data_ptr = 0 );
void remove (int); void remove (int);
void clear(); void clear();
// Event handlers // Event handlers
void onKeyPress (FKeyEvent*); void onKeyPress (FKeyEvent*);
void onMouseDown (FMouseEvent*); void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*); void onMouseUp (FMouseEvent*);
void onMouseMove (FMouseEvent*); void onMouseMove (FMouseEvent*);
void onMouseDoubleClick (FMouseEvent*); void onMouseDoubleClick (FMouseEvent*);
void onWheel (FWheelEvent*); void onWheel (FWheelEvent*);
void onTimer (FTimerEvent*); void onTimer (FTimerEvent*);
void onFocusIn (FFocusEvent*); void onFocusIn (FFocusEvent*);
void onFocusOut (FFocusEvent*); void onFocusOut (FFocusEvent*);
protected: protected:
// Methods // Methods
void adjustYOffset(); void adjustYOffset();
void adjustSize(); void adjustSize();
private: private:
// Enumeration // Enumeration
enum convert_type enum convert_type
{ {
no_convert = 0, no_convert = 0,
direct_convert = 1, direct_convert = 1,
lazy_convert = 2 lazy_convert = 2
}; };
// Disable copy constructor // Disable copy constructor
FListBox (const FListBox&); FListBox (const FListBox&);
// Disable assignment operator (=) // Disable assignment operator (=)
FListBox& operator = (const FListBox&); FListBox& operator = (const FListBox&);
// Accessors // Accessors
static FString& getString (listBoxItems::iterator); static FString& getString (listBoxItems::iterator);
// Methods // Methods
void init(); void init();
void draw(); void draw();
void drawLabel(); void drawLabel();
void drawList(); void drawList();
void recalculateHorizontalBar (int, bool); void recalculateHorizontalBar (int, bool);
void recalculateVerticalBar (int); void recalculateVerticalBar (int);
void processClick(); void processClick();
void processSelect(); void processSelect();
void processChanged(); void processChanged();
listBoxItems::iterator index2iterator (int); listBoxItems::iterator index2iterator (int);
// Callback methods // Callback methods
void cb_VBarChange (FWidget*, data_ptr); void cb_VBarChange (FWidget*, data_ptr);
void cb_HBarChange (FWidget*, data_ptr); void cb_HBarChange (FWidget*, data_ptr);
// Function Pointer // Function Pointer
void (*convertToItem) ( FListBoxItem& void (*convertToItem) ( FListBoxItem&
, FWidget::data_ptr , FWidget::data_ptr
, int index ); , int index );
// Data Members // Data Members
listBoxItems data; listBoxItems data;
FWidget::data_ptr source_container; FWidget::data_ptr source_container;
convert_type conv_type; convert_type conv_type;
FScrollbar* vbar; FScrollbar* vbar;
FScrollbar* hbar; FScrollbar* hbar;
FString text; FString text;
FString inc_search; FString inc_search;
bool multi_select; bool multi_select;
bool mouse_select; bool mouse_select;
fc::dragScroll drag_scroll; fc::dragScroll drag_scroll;
bool scroll_timer; bool scroll_timer;
int scroll_repeat; int scroll_repeat;
int scroll_distance; int scroll_distance;
int current; int current;
int last_current; int last_current;
int secect_from_item; int secect_from_item;
int xoffset; int xoffset;
int yoffset; int yoffset;
int last_yoffset; int last_yoffset;
int nf_offset; int nf_offset;
int max_line_width; int max_line_width;
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -2,6 +2,8 @@
// Provides: class FListViewItem // Provides: class FListViewItem
// class FListView // class FListView
#include <vector>
#include "fapplication.h" #include "fapplication.h"
#include "flistview.h" #include "flistview.h"
#include "fscrollbar.h" #include "fscrollbar.h"
@ -109,7 +111,7 @@ FListViewItem::FListViewItem ( const std::vector<FString>& cols
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FListViewItem::~FListViewItem() FListViewItem::~FListViewItem() // destructor
{ } { }
@ -1074,7 +1076,7 @@ void FListView::draw()
for (int y = 2; y < getHeight(); y++) for (int y = 2; y < getHeight(); y++)
{ {
setPrintPos (getWidth(),y); setPrintPos (getWidth(), y);
print (' '); // clear right side of the scrollbar print (' '); // clear right side of the scrollbar
} }
} }
@ -1233,7 +1235,7 @@ void FListView::drawList()
{ {
setColor ( wc.current_element_focus_fg setColor ( wc.current_element_focus_fg
, wc.current_element_focus_bg ); , wc.current_element_focus_bg );
setCursorPos (3, 2 + int(y)); // first character setCursorPos (3, 2 + int(y)); // first character
} }
else else
setColor ( wc.current_element_fg setColor ( wc.current_element_fg

View File

@ -30,6 +30,8 @@
#ifndef FLISTVIEW_H #ifndef FLISTVIEW_H
#define FLISTVIEW_H #define FLISTVIEW_H
#include <vector>
#include "fscrollbar.h" #include "fscrollbar.h"
#include "fstring.h" #include "fstring.h"
#include "ftermbuffer.h" #include "ftermbuffer.h"
@ -47,55 +49,56 @@ class FListView;
class FListViewItem : public FObject class FListViewItem : public FObject
{ {
public: public:
FListViewItem (const FListViewItem&); // copy constructor // Constructor
FListViewItem (FListViewItem*); FListViewItem (const FListViewItem&); // copy constructor
FListViewItem (FListView*); explicit FListViewItem (FListViewItem*);
FListViewItem ( const std::vector<FString>& explicit FListViewItem (FListView*);
, FWidget::data_ptr = 0 FListViewItem ( const std::vector<FString>&
, FListView* = 0 ); , FWidget::data_ptr = 0
FListViewItem ( const std::vector<FString>& , FListView* = 0 );
, FWidget::data_ptr = 0 FListViewItem ( const std::vector<FString>&
, FListViewItem* = 0 ); , FWidget::data_ptr = 0
, FListViewItem* = 0 );
// Destructor // Destructor
~FListViewItem(); ~FListViewItem();
// Assignment operator (=) // Assignment operator (=)
FListViewItem& operator = (const FListViewItem&); FListViewItem& operator = (const FListViewItem&);
// Accessors // Accessors
const char* getClassName() const; const char* getClassName() const;
uInt getColumnCount() const; uInt getColumnCount() const;
FString getText (int) const; FString getText (int) const;
// Mutator // Mutator
void setText (int, const FString&); void setText (int, const FString&);
// Inquiry // Inquiry
bool isExpand(); bool isExpand();
// Methods // Methods
void insert (FListViewItem*); void insert (FListViewItem*);
void expand(); void expand();
void collapse(); void collapse();
private: private:
// Inquiry // Inquiry
bool isExpandable(); bool isExpandable();
// Methods // Methods
int getVisibleLines(); int getVisibleLines();
// Data Member // Data Member
std::vector<FString> column_value; std::vector<FString> column_value;
FWidget::data_ptr data_pointer; FWidget::data_ptr data_pointer;
int visible_lines; int visible_lines;
bool expandable; bool expandable;
bool is_expand; bool is_expand;
// Friend class // Friend class
friend class FListView; friend class FListView;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -127,126 +130,126 @@ inline bool FListViewItem::isExpandable()
class FListView : public FWidget class FListView : public FWidget
{ {
public: public:
// Typedef // Typedef
typedef std::vector<FListViewItem*> listViewItems; typedef std::vector<FListViewItem*> listViewItems;
// Using-declaration // Using-declaration
using FWidget::setGeometry; using FWidget::setGeometry;
// Constructor // Constructor
explicit FListView (FWidget* = 0); explicit FListView (FWidget* = 0);
// Destructor // Destructor
~FListView(); ~FListView();
// Accessors // Accessors
const char* getClassName() const; const char* getClassName() const;
fc::text_alignment getColumnAlignment (int) const; fc::text_alignment getColumnAlignment (int) const;
FString getColumnText (int) const; FString getColumnText (int) const;
FListViewItem* getCurrentItem() const; FListViewItem* getCurrentItem() const;
// Mutators // Mutators
void setGeometry (int, int, int, int, bool = true); void setGeometry (int, int, int, int, bool = true);
void setColumnAlignment (int, fc::text_alignment); void setColumnAlignment (int, fc::text_alignment);
void setColumnText (int, const FString&); void setColumnText (int, const FString&);
bool setTreeView (bool); bool setTreeView (bool);
bool setTreeView(); bool setTreeView();
bool unsetTreeView(); bool unsetTreeView();
// Methods // Methods
virtual int addColumn (const FString&, int = USE_MAX_SIZE); virtual int addColumn (const FString&, int = USE_MAX_SIZE);
void insert (FListViewItem*); void insert (FListViewItem*);
void insert ( const std::vector<FString>& void insert ( const std::vector<FString>&
, data_ptr = 0 , data_ptr = 0
, FListView* = 0 ); , FListView* = 0 );
void insert ( const std::vector<long>& void insert ( const std::vector<long>&
, data_ptr = 0 , data_ptr = 0
, FListView* = 0 ); , FListView* = 0 );
// Event handlers // Event handlers
void onKeyPress (FKeyEvent*); void onKeyPress (FKeyEvent*);
void onMouseDown (FMouseEvent*); void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*); void onMouseUp (FMouseEvent*);
void onMouseMove (FMouseEvent*); void onMouseMove (FMouseEvent*);
void onMouseDoubleClick (FMouseEvent*); void onMouseDoubleClick (FMouseEvent*);
void onWheel (FWheelEvent*); void onWheel (FWheelEvent*);
void onTimer (FTimerEvent*); void onTimer (FTimerEvent*);
void onFocusIn (FFocusEvent*); void onFocusIn (FFocusEvent*);
void onFocusOut (FFocusEvent*); void onFocusOut (FFocusEvent*);
protected: protected:
// Methods // Methods
void adjustYOffset(); void adjustYOffset();
void adjustSize(); void adjustSize();
private: private:
// Typedef // Typedef
struct Header struct Header
{ {
public: public:
Header() Header()
: name() : name()
, width (0) , width (0)
, fixed_width (false) , fixed_width (false)
, alignment (fc::alignLeft) , alignment (fc::alignLeft)
{ } { }
~Header() ~Header()
{ } { }
FString name; FString name;
int width; int width;
bool fixed_width; bool fixed_width;
fc::text_alignment alignment; fc::text_alignment alignment;
}; };
typedef std::vector<Header> headerItems; typedef std::vector<Header> headerItems;
// Constants // Constants
static const int USE_MAX_SIZE = -1; static const int USE_MAX_SIZE = -1;
// Disable copy constructor // Disable copy constructor
FListView (const FListView&); FListView (const FListView&);
// Disable assignment operator (=) // Disable assignment operator (=)
FListView& operator = (const FListView&); FListView& operator = (const FListView&);
// Methods // Methods
void init(); void init();
uInt getAlignOffset (fc::text_alignment, uInt, uInt); uInt getAlignOffset (fc::text_alignment, uInt, uInt);
void draw(); void draw();
void drawColumnLabels(); void drawColumnLabels();
void drawList(); void drawList();
void recalculateHorizontalBar (int); void recalculateHorizontalBar (int);
void recalculateVerticalBar (int); void recalculateVerticalBar (int);
void processClick(); void processClick();
void processChanged(); void processChanged();
listViewItems::iterator index2iterator (int); listViewItems::iterator index2iterator (int);
// Callback methods // Callback methods
void cb_VBarChange (FWidget*, data_ptr); void cb_VBarChange (FWidget*, data_ptr);
void cb_HBarChange (FWidget*, data_ptr); void cb_HBarChange (FWidget*, data_ptr);
// Data Members // Data Members
listViewItems data; listViewItems data;
headerItems header; headerItems header;
FTermBuffer headerline; FTermBuffer headerline;
FScrollbar* vbar; FScrollbar* vbar;
FScrollbar* hbar; FScrollbar* hbar;
fc::dragScroll drag_scroll; fc::dragScroll drag_scroll;
int scroll_repeat; int scroll_repeat;
int scroll_distance; int scroll_distance;
bool scroll_timer; bool scroll_timer;
bool tree_view; bool tree_view;
int current; int current;
int xoffset; int xoffset;
int yoffset; int yoffset;
int nf_offset; int nf_offset;
int max_line_width; int max_line_width;
// Friend class // Friend class
friend class FListViewItem; friend class FListViewItem;
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -1,6 +1,8 @@
// File: fmenu.cpp // File: fmenu.cpp
// Provides: class FMenu // Provides: class FMenu
#include <vector>
#include "fapplication.h" #include "fapplication.h"
#include "fdialog.h" #include "fdialog.h"
#include "fmenu.h" #include "fmenu.h"
@ -48,7 +50,7 @@ FMenu::FMenu (const FString& txt, FWidget* parent)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FMenu::~FMenu() FMenu::~FMenu() // destructor
{ {
FApplication* fapp = static_cast<FApplication*>(getRootWidget()); FApplication* fapp = static_cast<FApplication*>(getRootWidget());
@ -299,7 +301,7 @@ void FMenu::onMouseDown (FMouseEvent* ev)
iter = item_list.begin(); iter = item_list.begin();
end = item_list.end(); end = item_list.end();
mouse_pos = ev->getPos(); mouse_pos = ev->getPos();
mouse_pos -= FPoint(getRightPadding(),getTopPadding()); mouse_pos -= FPoint(getRightPadding(), getTopPadding());
while ( iter != end ) while ( iter != end )
{ {
@ -404,7 +406,7 @@ void FMenu::onMouseUp (FMouseEvent* ev)
iter = item_list.begin(); iter = item_list.begin();
end = item_list.end(); end = item_list.end();
mouse_pos = ev->getPos(); mouse_pos = ev->getPos();
mouse_pos -= FPoint(getRightPadding(),getTopPadding()); mouse_pos -= FPoint(getRightPadding(), getTopPadding());
while ( iter != end ) while ( iter != end )
{ {
@ -492,7 +494,7 @@ void FMenu::onMouseMove (FMouseEvent* ev)
iter = item_list.begin(); iter = item_list.begin();
end = item_list.end(); end = item_list.end();
mouse_pos = ev->getPos(); mouse_pos = ev->getPos();
mouse_pos -= FPoint(getRightPadding(),getTopPadding()); mouse_pos -= FPoint(getRightPadding(), getTopPadding());
if ( getTermGeometry().contains(ev->getTermPos()) ) if ( getTermGeometry().contains(ev->getTermPos()) )
mouse_over_menu = true; mouse_over_menu = true;
@ -794,14 +796,14 @@ void FMenu::init(FWidget* parent)
{ {
if ( isMenuBar(parent) ) if ( isMenuBar(parent) )
{ {
FMenuBar* mbar = dynamic_cast<FMenuBar*>(parent); FMenuBar* mbar = static_cast<FMenuBar*>(parent);
if ( mbar ) if ( mbar )
mbar->calculateDimensions(); mbar->calculateDimensions();
} }
else if ( isMenu(parent) ) else if ( isMenu(parent) )
{ {
FMenu* smenu = dynamic_cast<FMenu*>(parent); FMenu* smenu = static_cast<FMenu*>(parent);
if ( smenu ) if ( smenu )
smenu->calculateDimensions(); smenu->calculateDimensions();
@ -820,7 +822,7 @@ void FMenu::calculateDimensions()
std::vector<FMenuItem*>::const_iterator iter, end; std::vector<FMenuItem*>::const_iterator iter, end;
iter = item_list.begin(); iter = item_list.begin();
end = item_list.end(); end = item_list.end();
max_item_width = 10; // minimum width max_item_width = 10; // minimum width
// find the maximum item width // find the maximum item width
while ( iter != end ) while ( iter != end )
@ -994,11 +996,11 @@ bool FMenu::containsMenuStructure (int x, int y)
// Check mouse click position for item, menu and all sub menus // Check mouse click position for item, menu and all sub menus
FMenuItem* si = getSelectedItem(); FMenuItem* si = getSelectedItem();
if ( getTermGeometry().contains(x,y) ) if ( getTermGeometry().contains(x, y) )
return true; return true;
else if ( si && si->hasMenu() && open_sub_menu ) else if ( si && si->hasMenu() && open_sub_menu )
return si->getMenu()->containsMenuStructure(x,y); return si->getMenu()->containsMenuStructure(x, y);
else if ( item && item->getTermGeometry().contains(x,y) ) else if ( item && item->getTermGeometry().contains(x, y) )
return true; return true;
else else
return false; return false;
@ -1008,21 +1010,21 @@ bool FMenu::containsMenuStructure (int x, int y)
FMenu* FMenu::superMenuAt (int x, int y) FMenu* FMenu::superMenuAt (int x, int y)
{ {
// Check mouse click position for super menu // Check mouse click position for super menu
if ( getTermGeometry().contains(x,y) ) if ( getTermGeometry().contains(x, y) )
return 0; return 0;
FWidget* super = getSuperMenu(); FWidget* super = getSuperMenu();
if ( super && isMenu(super) ) if ( super && isMenu(super) )
{ {
if ( super->getTermGeometry().contains(x,y) ) if ( super->getTermGeometry().contains(x, y) )
return dynamic_cast<FMenu*>(super); return static_cast<FMenu*>(super);
else else
{ {
FMenu* smenu = dynamic_cast<FMenu*>(getSuperMenu()); FMenu* smenu = static_cast<FMenu*>(getSuperMenu());
if ( smenu ) if ( smenu )
return smenu->superMenuAt(x,y); return smenu->superMenuAt(x, y);
} }
} }
@ -1312,16 +1314,16 @@ void FMenu::drawItems()
if ( is_radio_btn ) if ( is_radio_btn )
{ {
if ( isNewFont() ) if ( isNewFont() )
print (fc::NF_Bullet); // NF_Bullet ● print (fc::NF_Bullet); // NF_Bullet ●
else else
print (fc::Bullet); // Bullet ● print (fc::Bullet); // Bullet ●
} }
else else
{ {
if ( isNewFont() ) if ( isNewFont() )
print (fc::NF_check_mark); // NF_check_mark ✓ print (fc::NF_check_mark); // NF_check_mark ✓
else else
print (fc::SquareRoot); // SquareRoot √ print (fc::SquareRoot); // SquareRoot √
} }
} }
else else

View File

@ -50,110 +50,110 @@
class FMenu : public FWindow, public FMenuList class FMenu : public FWindow, public FMenuList
{ {
public: public:
// Constructor // Constructor
explicit FMenu (FWidget* = 0); explicit FMenu (FWidget* = 0);
FMenu (const FString&, FWidget* = 0); FMenu (const FString&, FWidget* = 0);
// Destructor // Destructor
virtual ~FMenu(); virtual ~FMenu();
// Accessors // Accessors
virtual const char* getClassName() const; virtual const char* getClassName() const;
FString getText() const; FString getText() const;
FMenuItem* getItem() const; FMenuItem* getItem() const;
// Mutators // Mutators
bool setEnable(bool); bool setEnable(bool);
bool setEnable(); bool setEnable();
bool unsetEnable(); bool unsetEnable();
bool setDisable(); bool setDisable();
void setSelected(); void setSelected();
void unsetSelected(); void unsetSelected();
bool setMenuWidget (bool); bool setMenuWidget (bool);
bool setMenuWidget(); bool setMenuWidget();
bool unsetMenuWidget(); bool unsetMenuWidget();
void setStatusbarMessage (const FString&); void setStatusbarMessage (const FString&);
void setMenu (FMenu*); void setMenu (FMenu*);
void setText (const FString&); void setText (const FString&);
// Inquiries // Inquiries
bool isEnabled() const; bool isEnabled() const;
bool isSelected() const; bool isSelected() const;
bool hasHotkey() const; bool hasHotkey() const;
bool hasMenu() const; bool hasMenu() const;
// Methods // Methods
void show(); void show();
void hide(); void hide();
// Event handlers // Event handlers
void onKeyPress (FKeyEvent*); void onKeyPress (FKeyEvent*);
void onMouseDown (FMouseEvent*); void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*); void onMouseUp (FMouseEvent*);
void onMouseMove (FMouseEvent*); void onMouseMove (FMouseEvent*);
void onAccel (FAccelEvent*); void onAccel (FAccelEvent*);
// Callback method // Callback method
void cb_menuitem_toggled (FWidget*, data_ptr); void cb_menuitem_toggled (FWidget*, data_ptr);
private: private:
// Disable copy constructor // Disable copy constructor
FMenu (const FMenu&); FMenu (const FMenu&);
// Disable assignment operator (=) // Disable assignment operator (=)
FMenu& operator = (const FMenu&); FMenu& operator = (const FMenu&);
// Accessors // Accessors
FWidget* getSuperMenu() const; FWidget* getSuperMenu() const;
// Mutators // Mutators
void setSuperMenu (FWidget*); void setSuperMenu (FWidget*);
// Inquiries // Inquiries
bool isWindowsMenu (FWidget*) const; bool isWindowsMenu (FWidget*) const;
bool isMenuBar (FWidget*) const; bool isMenuBar (FWidget*) const;
bool isMenu (FWidget*) const; bool isMenu (FWidget*) const;
bool isRadioMenuItem (FWidget*) const; bool isRadioMenuItem (FWidget*) const;
bool isSubMenu() const; bool isSubMenu() const;
// Methods // Methods
void init(FWidget*); void init(FWidget*);
void calculateDimensions(); void calculateDimensions();
void adjustItems(); void adjustItems();
int adjustX(int); int adjustX(int);
void openSubMenu (FMenu*); void openSubMenu (FMenu*);
void hideSubMenus(); void hideSubMenus();
void hideSuperMenus(); void hideSuperMenus();
bool containsMenuStructure (const FPoint&); bool containsMenuStructure (const FPoint&);
bool containsMenuStructure (int, int); bool containsMenuStructure (int, int);
FMenu* superMenuAt (const FPoint&); FMenu* superMenuAt (const FPoint&);
FMenu* superMenuAt (int, int); FMenu* superMenuAt (int, int);
bool selectNextItem(); bool selectNextItem();
bool selectPrevItem(); bool selectPrevItem();
void keypressMenuBar (FKeyEvent*&); void keypressMenuBar (FKeyEvent*&);
bool hotkeyMenu (FKeyEvent*&); bool hotkeyMenu (FKeyEvent*&);
int getHotkeyPos (wchar_t*&, wchar_t*&, uInt); int getHotkeyPos (wchar_t*&, wchar_t*&, uInt);
void draw(); void draw();
void drawItems(); void drawItems();
void drawSeparator(int); void drawSeparator(int);
void processActivate(); void processActivate();
// Friend classes // Friend classes
friend class FApplication; friend class FApplication;
friend class FCheckMenuItem; friend class FCheckMenuItem;
friend class FDialog; friend class FDialog;
friend class FMenuBar; friend class FMenuBar;
friend class FMenuItem; friend class FMenuItem;
friend class FRadioMenuItem; friend class FRadioMenuItem;
// Data Members // Data Members
FMenuItem* item; FMenuItem* item;
FWidget* super_menu; FWidget* super_menu;
FMenu* open_sub_menu; FMenu* open_sub_menu;
uInt max_item_width; uInt max_item_width;
bool mouse_down; bool mouse_down;
bool has_checkable_items; bool has_checkable_items;
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -1,6 +1,8 @@
// File: fmenubar.cpp // File: fmenubar.cpp
// Provides: class FMenuBar // Provides: class FMenuBar
#include <vector>
#include "fapplication.h" #include "fapplication.h"
#include "fmenubar.h" #include "fmenubar.h"
#include "fstatusbar.h" #include "fstatusbar.h"
@ -20,7 +22,7 @@ FMenuBar::FMenuBar(FWidget* parent)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FMenuBar::~FMenuBar() FMenuBar::~FMenuBar() // destructor
{ {
setMenuBar(0); setMenuBar(0);
} }
@ -428,7 +430,8 @@ void FMenuBar::onMouseMove (FMouseEvent* ev)
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
std::cerr << "not enough memory to alloc " << ex.what() << std::endl; std::cerr << "not enough memory to alloc "
<< ex.what() << std::endl;
} }
} }
} }

View File

@ -49,60 +49,60 @@
class FMenuBar : public FWindow, public FMenuList class FMenuBar : public FWindow, public FMenuList
{ {
public: public:
// Constructor // Constructor
explicit FMenuBar (FWidget* = 0); explicit FMenuBar (FWidget* = 0);
// Destructor // Destructor
virtual ~FMenuBar(); virtual ~FMenuBar();
// Accessors // Accessors
virtual const char* getClassName() const; virtual const char* getClassName() const;
// Methods // Methods
void hide(); void hide();
void resetMenu(); void resetMenu();
void adjustSize(); void adjustSize();
// Event handlers // Event handlers
void onKeyPress (FKeyEvent*); void onKeyPress (FKeyEvent*);
void onMouseDown (FMouseEvent*); void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*); void onMouseUp (FMouseEvent*);
void onMouseMove (FMouseEvent*); void onMouseMove (FMouseEvent*);
void onAccel (FAccelEvent*); void onAccel (FAccelEvent*);
// Callback methods // Callback methods
void cb_item_deactivated (FWidget*, data_ptr); void cb_item_deactivated (FWidget*, data_ptr);
private: private:
// Disable copy constructor // Disable copy constructor
FMenuBar (const FMenuBar&); FMenuBar (const FMenuBar&);
// Disable assignment operator (=) // Disable assignment operator (=)
FMenuBar& operator = (const FMenuBar&); FMenuBar& operator = (const FMenuBar&);
// Inquiry // Inquiry
bool isMenu (FMenuItem*) const; bool isMenu (FMenuItem*) const;
// Methods // Methods
void init(); void init();
void calculateDimensions(); void calculateDimensions();
bool selectNextItem(); bool selectNextItem();
bool selectPrevItem(); bool selectPrevItem();
bool hotkeyMenu (FKeyEvent*&); bool hotkeyMenu (FKeyEvent*&);
int getHotkeyPos (wchar_t*&, wchar_t*&, uInt); int getHotkeyPos (wchar_t*&, wchar_t*&, uInt);
void draw(); void draw();
void drawItems(); void drawItems();
void adjustItems(); void adjustItems();
void leaveMenuBar(); void leaveMenuBar();
// Friend classes // Friend classes
friend class FMenu; friend class FMenu;
friend class FMenuItem; friend class FMenuItem;
// Data Members // Data Members
bool mouse_down; bool mouse_down;
bool drop_down; bool drop_down;
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -136,14 +136,14 @@ bool FMenuItem::setFocus (bool on)
if ( isMenuBar(parent) ) if ( isMenuBar(parent) )
{ {
FMenuBar* menubar_ptr = dynamic_cast<FMenuBar*>(parent); FMenuBar* menubar_ptr = static_cast<FMenuBar*>(parent);
if ( menubar_ptr ) if ( menubar_ptr )
menubar_ptr->redraw(); menubar_ptr->redraw();
} }
else if ( isMenu(parent) ) else if ( isMenu(parent) )
{ {
FMenu* menu_ptr = dynamic_cast<FMenu*>(parent); FMenu* menu_ptr = static_cast<FMenu*>(parent);
if ( menu_ptr ) if ( menu_ptr )
menu_ptr->redraw(); menu_ptr->redraw();
@ -215,7 +215,7 @@ void FMenuItem::addAccelerator (int key, FWidget* obj)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
FMenu* menu_ptr = dynamic_cast<FMenu*>(super_menu); FMenu* menu_ptr = static_cast<FMenu*>(super_menu);
if ( menu_ptr ) if ( menu_ptr )
menu_ptr->calculateDimensions(); menu_ptr->calculateDimensions();
@ -248,7 +248,7 @@ void FMenuItem::delAccelerator (FWidget* obj)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
FMenu* menu_ptr = dynamic_cast<FMenu*>(super_menu); FMenu* menu_ptr = static_cast<FMenu*>(super_menu);
if ( menu_ptr ) if ( menu_ptr )
menu_ptr->calculateDimensions(); menu_ptr->calculateDimensions();
@ -297,7 +297,7 @@ void FMenuItem::onKeyPress (FKeyEvent* ev)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
FMenu* smenu = dynamic_cast<FMenu*>(super_menu); FMenu* smenu = static_cast<FMenu*>(super_menu);
if ( smenu ) if ( smenu )
smenu->onKeyPress(ev); smenu->onKeyPress(ev);
@ -305,7 +305,7 @@ void FMenuItem::onKeyPress (FKeyEvent* ev)
if ( isMenuBar(super_menu) ) if ( isMenuBar(super_menu) )
{ {
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu); FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( mbar ) if ( mbar )
{ {
@ -328,7 +328,7 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
FMenu* smenu = dynamic_cast<FMenu*>(super_menu); FMenu* smenu = static_cast<FMenu*>(super_menu);
if ( smenu ) if ( smenu )
{ {
@ -336,20 +336,22 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
try try
{ {
FMouseEvent* _ev = new FMouseEvent (fc::MouseDoubleClick_Event, p2, t, b); FMouseEvent* _ev = new FMouseEvent ( fc::MouseDoubleClick_Event
, p2, t, b );
smenu->onMouseDoubleClick(_ev); smenu->onMouseDoubleClick(_ev);
delete _ev; delete _ev;
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
std::cerr << "not enough memory to alloc " << ex.what() << std::endl; std::cerr << "not enough memory to alloc "
<< ex.what() << std::endl;
} }
} }
} }
if ( isMenuBar(super_menu) ) if ( isMenuBar(super_menu) )
{ {
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu); FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( mbar ) if ( mbar )
{ {
@ -357,20 +359,22 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
try try
{ {
FMouseEvent* _ev = new FMouseEvent (fc::MouseDoubleClick_Event, p2, t, b); FMouseEvent* _ev = new FMouseEvent ( fc::MouseDoubleClick_Event
, p2, t, b );
mbar->onMouseDoubleClick(_ev); mbar->onMouseDoubleClick(_ev);
delete _ev; delete _ev;
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
std::cerr << "not enough memory to alloc " << ex.what() << std::endl; std::cerr << "not enough memory to alloc "
<< ex.what() << std::endl;
} }
} }
} }
if ( isWindowsMenu(super_menu) ) if ( isWindowsMenu(super_menu) )
{ {
FDialog* dgl = dynamic_cast<FDialog*>(super_menu); FDialog* dgl = static_cast<FDialog*>(super_menu);
if ( dgl ) if ( dgl )
{ {
@ -378,13 +382,15 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
try try
{ {
FMouseEvent* _ev = new FMouseEvent (fc::MouseDoubleClick_Event, p2, t, b); FMouseEvent* _ev = new FMouseEvent ( fc::MouseDoubleClick_Event
, p2, t, b );
dgl->onMouseDoubleClick(_ev); dgl->onMouseDoubleClick(_ev);
delete _ev; delete _ev;
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
std::cerr << "not enough memory to alloc " << ex.what() << std::endl; std::cerr << "not enough memory to alloc "
<< ex.what() << std::endl;
} }
} }
} }
@ -401,7 +407,7 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
FMenu* smenu = dynamic_cast<FMenu*>(super_menu); FMenu* smenu = static_cast<FMenu*>(super_menu);
if ( smenu ) if ( smenu )
{ {
@ -409,20 +415,22 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
try try
{ {
FMouseEvent* _ev = new FMouseEvent (fc::MouseDown_Event, p2, t, b); FMouseEvent* _ev = new FMouseEvent ( fc::MouseDown_Event
, p2, t, b );
smenu->onMouseDown(_ev); smenu->onMouseDown(_ev);
delete _ev; delete _ev;
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
std::cerr << "not enough memory to alloc " << ex.what() << std::endl; std::cerr << "not enough memory to alloc "
<< ex.what() << std::endl;
} }
} }
} }
if ( isMenuBar(super_menu) ) if ( isMenuBar(super_menu) )
{ {
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu); FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( mbar ) if ( mbar )
{ {
@ -430,20 +438,22 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
try try
{ {
FMouseEvent* _ev = new FMouseEvent (fc::MouseDown_Event, p2, t, b); FMouseEvent* _ev = new FMouseEvent ( fc::MouseDown_Event
, p2, t, b );
mbar->onMouseDown(_ev); mbar->onMouseDown(_ev);
delete _ev; delete _ev;
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
std::cerr << "not enough memory to alloc " << ex.what() << std::endl; std::cerr << "not enough memory to alloc "
<< ex.what() << std::endl;
} }
} }
} }
if ( isWindowsMenu(super_menu) ) if ( isWindowsMenu(super_menu) )
{ {
FDialog* dgl = dynamic_cast<FDialog*>(super_menu); FDialog* dgl = static_cast<FDialog*>(super_menu);
if ( dgl ) if ( dgl )
{ {
@ -451,13 +461,15 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
try try
{ {
FMouseEvent* _ev = new FMouseEvent (fc::MouseDown_Event, p2, t, b); FMouseEvent* _ev = new FMouseEvent ( fc::MouseDown_Event
, p2, t, b );
dgl->onMouseDown(_ev); dgl->onMouseDown(_ev);
delete _ev; delete _ev;
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
std::cerr << "not enough memory to alloc " << ex.what() << std::endl; std::cerr << "not enough memory to alloc "
<< ex.what() << std::endl;
} }
} }
} }
@ -474,7 +486,7 @@ void FMenuItem::onMouseUp (FMouseEvent* ev)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
FMenu* smenu = dynamic_cast<FMenu*>(super_menu); FMenu* smenu = static_cast<FMenu*>(super_menu);
if ( smenu ) if ( smenu )
{ {
@ -487,7 +499,7 @@ void FMenuItem::onMouseUp (FMouseEvent* ev)
if ( isMenuBar(super_menu) ) if ( isMenuBar(super_menu) )
{ {
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu); FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( mbar ) if ( mbar )
{ {
@ -500,7 +512,7 @@ void FMenuItem::onMouseUp (FMouseEvent* ev)
if ( isWindowsMenu(super_menu) ) if ( isWindowsMenu(super_menu) )
{ {
FDialog* dgl = dynamic_cast<FDialog*>(super_menu); FDialog* dgl = static_cast<FDialog*>(super_menu);
if ( dgl ) if ( dgl )
{ {
@ -523,7 +535,7 @@ void FMenuItem::onMouseMove (FMouseEvent* ev)
if ( isMenu(super_menu) ) if ( isMenu(super_menu) )
{ {
FMenu* smenu = dynamic_cast<FMenu*>(super_menu); FMenu* smenu = static_cast<FMenu*>(super_menu);
if ( smenu ) if ( smenu )
{ {
@ -536,7 +548,7 @@ void FMenuItem::onMouseMove (FMouseEvent* ev)
if ( isMenuBar(super_menu) ) if ( isMenuBar(super_menu) )
{ {
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu); FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( mbar ) if ( mbar )
{ {
@ -549,7 +561,7 @@ void FMenuItem::onMouseMove (FMouseEvent* ev)
if ( isWindowsMenu(super_menu) ) if ( isWindowsMenu(super_menu) )
{ {
FDialog* dgl = dynamic_cast<FDialog*>(super_menu); FDialog* dgl = static_cast<FDialog*>(super_menu);
if ( dgl ) if ( dgl )
{ {
@ -573,7 +585,7 @@ void FMenuItem::onAccel (FAccelEvent* ev)
return; return;
} }
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu); FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( ! mbar ) if ( ! mbar )
return; return;
@ -639,7 +651,7 @@ void FMenuItem::onFocusOut (FFocusEvent*)
if ( super_menu && isMenuBar(super_menu) ) if ( super_menu && isMenuBar(super_menu) )
{ {
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu); FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( mbar ) if ( mbar )
mbar->redraw(); mbar->redraw();
@ -703,16 +715,17 @@ void FMenuItem::init (FWidget* parent)
if ( menu_list ) if ( menu_list )
menu_list->insert(this); menu_list->insert(this);
if ( isMenuBar(parent) ) // Parent is menubar if ( isMenuBar(parent) ) // Parent is menubar
{ {
FMenuBar* menubar_ptr = dynamic_cast<FMenuBar*>(parent); FMenuBar* menubar_ptr = static_cast<FMenuBar*>(parent);
if ( menubar_ptr ) if ( menubar_ptr )
{ {
menubar_ptr->calculateDimensions(); menubar_ptr->calculateDimensions();
if ( hotkey ) // Meta + hotkey if ( hotkey ) // Meta + hotkey
menubar_ptr->addAccelerator (fc::Fmkey_meta + std::tolower(hotkey), this); menubar_ptr->addAccelerator ( fc::Fmkey_meta + std::tolower(hotkey)
, this );
} }
this->addCallback this->addCallback
@ -721,9 +734,9 @@ void FMenuItem::init (FWidget* parent)
F_METHOD_CALLBACK (parent, &FMenuBar::cb_item_deactivated) F_METHOD_CALLBACK (parent, &FMenuBar::cb_item_deactivated)
); );
} }
else if ( isMenu(parent) ) // Parent is menu else if ( isMenu(parent) ) // Parent is menu
{ {
FMenu* menu_ptr = dynamic_cast<FMenu*>(parent); FMenu* menu_ptr = static_cast<FMenu*>(parent);
if ( menu_ptr ) if ( menu_ptr )
menu_ptr->calculateDimensions(); menu_ptr->calculateDimensions();
@ -781,7 +794,7 @@ void FMenuItem::createDialogList (FMenu* winmenu)
while ( iter != dialog_list->end() && *iter ) while ( iter != dialog_list->end() && *iter )
{ {
FDialog* win = dynamic_cast<FDialog*>(*iter); FDialog* win = static_cast<FDialog*>(*iter);
if ( win ) if ( win )
{ {
@ -797,18 +810,19 @@ void FMenuItem::createDialogList (FMenu* winmenu)
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
std::cerr << "not enough memory to alloc " << ex.what() << std::endl; std::cerr << "not enough memory to alloc "
<< ex.what() << std::endl;
return; return;
} }
if ( n < 9 ) if ( n < 9 )
win_item->addAccelerator (fc::Fmkey_1 + n); // Meta + 1..9 win_item->addAccelerator (fc::Fmkey_1 + n); // Meta + 1..9
win_item->addCallback win_item->addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (win_item, &FMenuItem::cb_switchToDialog), F_METHOD_CALLBACK (win_item, &FMenuItem::cb_switchToDialog),
dynamic_cast<FWidget::data_ptr>(win) static_cast<FWidget::data_ptr>(win)
); );
win->addCallback win->addCallback

View File

@ -48,115 +48,115 @@ class FMenuList;
class FMenuItem : public FWidget class FMenuItem : public FWidget
{ {
public: public:
// Using-declarations // Using-declarations
using FWidget::addAccelerator; using FWidget::addAccelerator;
using FWidget::delAccelerator; using FWidget::delAccelerator;
using FWidget::setEnable; using FWidget::setEnable;
// Constructor // Constructor
explicit FMenuItem (FWidget* = 0); explicit FMenuItem (FWidget* = 0);
FMenuItem (const FString&, FWidget* = 0); FMenuItem (const FString&, FWidget* = 0);
FMenuItem (int, const FString&, FWidget* = 0); FMenuItem (int, const FString&, FWidget* = 0);
// Destructor // Destructor
virtual ~FMenuItem(); virtual ~FMenuItem();
// Accessors // Accessors
const char* getClassName() const; const char* getClassName() const;
int getHotkey() const; int getHotkey() const;
FMenu* getMenu() const; FMenu* getMenu() const;
uInt getTextLength() const; uInt getTextLength() const;
FString getText() const; FString getText() const;
// Mutators // Mutators
bool setEnable (bool); bool setEnable (bool);
bool setFocus (bool); bool setFocus (bool);
bool setFocus(); bool setFocus();
bool unsetFocus(); bool unsetFocus();
void setSelected(); void setSelected();
void unsetSelected(); void unsetSelected();
void setSeparator(); void setSeparator();
void unsetSeparator(); void unsetSeparator();
void setChecked(); void setChecked();
void unsetChecked(); void unsetChecked();
void setMenu (FMenu*); void setMenu (FMenu*);
void setText (const FString&); void setText (const FString&);
// Inquiries // Inquiries
bool isSelected() const; bool isSelected() const;
bool isSeparator() const; bool isSeparator() const;
bool isChecked() const; bool isChecked() const;
bool hasHotkey() const; bool hasHotkey() const;
bool hasMenu() const; bool hasMenu() const;
// Methods // Methods
void addAccelerator (int, FWidget*); void addAccelerator (int, FWidget*);
void delAccelerator (FWidget*); void delAccelerator (FWidget*);
void openMenu(); void openMenu();
// Event handlers // Event handlers
void onKeyPress (FKeyEvent*); void onKeyPress (FKeyEvent*);
void onMouseDoubleClick (FMouseEvent*); void onMouseDoubleClick (FMouseEvent*);
void onMouseDown (FMouseEvent*); void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*); void onMouseUp (FMouseEvent*);
void onMouseMove (FMouseEvent*); void onMouseMove (FMouseEvent*);
void onAccel (FAccelEvent*); void onAccel (FAccelEvent*);
void onFocusIn (FFocusEvent*); void onFocusIn (FFocusEvent*);
void onFocusOut (FFocusEvent*); void onFocusOut (FFocusEvent*);
protected: protected:
// Accessor // Accessor
FWidget* getSuperMenu() const; FWidget* getSuperMenu() const;
// Mutator // Mutator
void setSuperMenu (FWidget*); void setSuperMenu (FWidget*);
// Inquiries // Inquiries
bool isWindowsMenu (FWidget*) const; bool isWindowsMenu (FWidget*) const;
bool isMenuBar (FWidget*) const; bool isMenuBar (FWidget*) const;
bool isMenu (FWidget*) const; bool isMenu (FWidget*) const;
// Data Members // Data Members
FString text; FString text;
bool selected; bool selected;
bool separator; bool separator;
bool checkable; bool checkable;
bool checked; bool checked;
bool radio_button; bool radio_button;
bool dialog_index; bool dialog_index;
uInt text_length; uInt text_length;
int hotkey; int hotkey;
int accel_key; int accel_key;
FMenu* menu; FMenu* menu;
FWidget* super_menu; FWidget* super_menu;
FDialog* associated_window; FDialog* associated_window;
private: private:
// Disable copy constructor // Disable copy constructor
FMenuItem (const FMenuItem&); FMenuItem (const FMenuItem&);
// Disable assignment operator (=) // Disable assignment operator (=)
FMenuItem& operator = (const FMenuItem&); FMenuItem& operator = (const FMenuItem&);
// Methods // Methods
void init (FWidget*); void init (FWidget*);
uChar hotKey(); uChar hotKey();
void processActivate(); void processActivate();
void processDeactivate(); void processDeactivate();
void createDialogList (FMenu*); void createDialogList (FMenu*);
// Callback methods // Callback methods
void cb_switchToDialog (FWidget*, data_ptr); void cb_switchToDialog (FWidget*, data_ptr);
void cb_destroyDialog (FWidget*, data_ptr); void cb_destroyDialog (FWidget*, data_ptr);
virtual void processClicked(); virtual void processClicked();
// Friend classes // Friend classes
friend class FDialogListMenu; friend class FDialogListMenu;
friend class FMenuList; friend class FMenuList;
friend class FMenuBar; friend class FMenuBar;
friend class FMenu; friend class FMenu;
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -1,6 +1,8 @@
// File: fmenulist.cpp // File: fmenulist.cpp
// Provides: class FMenuList // Provides: class FMenuList
#include <vector>
#include "fmenulist.h" #include "fmenulist.h"
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -19,6 +19,8 @@
#ifndef FMENULIST_H #ifndef FMENULIST_H
#define FMENULIST_H #define FMENULIST_H
#include <vector>
#include "fmenuitem.h" #include "fmenuitem.h"
#include "fwidget.h" #include "fwidget.h"
@ -32,46 +34,46 @@
class FMenuList class FMenuList
{ {
public: public:
// Constructor // Constructor
explicit FMenuList(); explicit FMenuList();
// Destructor // Destructor
virtual ~FMenuList(); virtual ~FMenuList();
// Accessors // Accessors
virtual const char* getClassName() const; virtual const char* getClassName() const;
uInt getCount() const; uInt getCount() const;
FMenuItem* getItem (int) const; FMenuItem* getItem (int) const;
FMenuItem* getSelectedItem() const; FMenuItem* getSelectedItem() const;
// Mutators // Mutators
void enableItem (int); void enableItem (int);
void disableItem (int); void disableItem (int);
void setSelectedItem (FMenuItem*); void setSelectedItem (FMenuItem*);
// Inquiries // Inquiries
bool isSelected (int) const; bool isSelected (int) const;
bool hasSelectedItem() const; bool hasSelectedItem() const;
// Methods // Methods
virtual void insert (FMenuItem*); virtual void insert (FMenuItem*);
virtual void remove (FMenuItem*); virtual void remove (FMenuItem*);
void remove (int); void remove (int);
void clear(); void clear();
void selectFirstItem(); void selectFirstItem();
void unselectItem(); void unselectItem();
protected: protected:
FMenuItem* selected_item; FMenuItem* selected_item;
std::vector<FMenuItem*> item_list; std::vector<FMenuItem*> item_list;
private: private:
// Disable copy constructor // Disable copy constructor
FMenuList (const FMenuList&); FMenuList (const FMenuList&);
// Disable assignment operator (=) // Disable assignment operator (=)
FMenuList& operator = (const FMenuList&); FMenuList& operator = (const FMenuList&);
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -1,6 +1,8 @@
// File: fmessagebox.cpp // File: fmessagebox.cpp
// Provides: class FMessageBox // Provides: class FMessageBox
#include <algorithm>
#include "fapplication.h" #include "fapplication.h"
#include "fmessagebox.h" #include "fmessagebox.h"
@ -426,7 +428,8 @@ void FMessageBox::draw()
int head_offset = 0; int head_offset = 0;
int center_x = 0; int center_x = 0;
int msg_x = int((getWidth() - int(max_line_width)) / 2); // center the whole block // center the whole block
int msg_x = int((getWidth() - int(max_line_width)) / 2);
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);

View File

@ -54,96 +54,96 @@
class FMessageBox : public FDialog class FMessageBox : public FDialog
{ {
public: public:
// Enumeration // Enumeration
enum enum
{ {
Reject = 0, Reject = 0,
Ok = 1, Ok = 1,
Cancel = 2, Cancel = 2,
Yes = 3, Yes = 3,
No = 4, No = 4,
Abort = 5, Abort = 5,
Retry = 6, Retry = 6,
Ignore = 7 Ignore = 7
}; };
// Constructors // Constructors
explicit FMessageBox (FWidget* = 0); explicit FMessageBox (FWidget* = 0);
FMessageBox (const FMessageBox&); // copy constructor FMessageBox (const FMessageBox&); // copy constructor
FMessageBox ( const FString&, const FString& FMessageBox ( const FString&, const FString&
, int, int, int , int, int, int
, FWidget* = 0 ); , FWidget* = 0 );
// Destructor // Destructor
~FMessageBox(); ~FMessageBox();
// Assignment operator (=) // Assignment operator (=)
FMessageBox& operator = (const FMessageBox&); FMessageBox& operator = (const FMessageBox&);
// Accessor // Accessor
const char* getClassName() const; const char* getClassName() const;
const FString getTitlebarText() const; const FString getTitlebarText() const;
const FString getHeadline() const; const FString getHeadline() const;
const FString getText() const; const FString getText() const;
// Mutator // Mutator
void setTitlebarText (const FString&); void setTitlebarText (const FString&);
void setHeadline (const FString&); void setHeadline (const FString&);
bool setCenterText(bool); bool setCenterText(bool);
bool setCenterText(); bool setCenterText();
bool unsetCenterText(); bool unsetCenterText();
void setText (const FString&); void setText (const FString&);
// Methods // Methods
static int info ( FWidget* static int info ( FWidget*
, const FString& , const FString&
, const FString&
, int = FMessageBox::Ok
, int = 0
, int = 0 );
static int info ( FWidget*
, const FString&
, int
, int = FMessageBox::Ok
, int = 0
, int = 0 );
static int error ( FWidget*
, const FString& , const FString&
, int = FMessageBox::Ok , int = FMessageBox::Ok
, int = 0 , int = 0
, int = 0 ); , int = 0 );
protected:
// Method
void adjustSize();
// Callback method static int info ( FWidget*
void cb_processClick (FWidget*, data_ptr); , const FString&
, int
, int = FMessageBox::Ok
, int = 0
, int = 0 );
private: static int error ( FWidget*
// Typedef , const FString&
typedef std::vector<FString> textLines; , int = FMessageBox::Ok
, int = 0
, int = 0 );
protected:
// Method
void adjustSize();
// Methods // Callback method
void init (int, int, int); void cb_processClick (FWidget*, data_ptr);
void calculateDimensions();
virtual void draw();
void resizeButtons();
void adjustButtons();
// Data Members private:
FString headline_text; // Typedef
FString text; typedef std::vector<FString> textLines;
FString* text_components;
textLines text_split; // Methods
uInt max_line_width; void init (int, int, int);
bool center_text; void calculateDimensions();
short emphasis_color; virtual void draw();
uInt num_buttons; void resizeButtons();
uInt text_num_lines; void adjustButtons();
int button_digit[3];
FButton* button[3]; // Data Members
FString headline_text;
FString text;
FString* text_components;
textLines text_split;
uInt max_line_width;
bool center_text;
short emphasis_color;
uInt num_buttons;
uInt text_num_lines;
int button_digit[3];
FButton* button[3];
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -27,7 +27,6 @@ FObject::FObject (FObject* parent)
if ( parent == 0 ) if ( parent == 0 )
{ {
timer_modify_lock = false; timer_modify_lock = false;
if ( ! timer_list ) if ( ! timer_list )
@ -95,8 +94,6 @@ FObject::~FObject() // destructor
++iter; ++iter;
} }
} }
} }
// public methods of FObject // public methods of FObject
@ -159,27 +156,27 @@ void FObject::delChild (FObject* obj)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FObject::getCurrentTime (timeval &time) void FObject::getCurrentTime (timeval* time)
{ {
gettimeofday(&time, 0); gettimeofday(time, 0);
// NTP fix // NTP fix
while ( time.tv_usec >= 1000000 ) while ( time->tv_usec >= 1000000 )
{ {
time.tv_usec -= 1000000; time->tv_usec -= 1000000;
time.tv_sec++; time->tv_sec++;
} }
while ( time.tv_usec < 0 ) while ( time->tv_usec < 0 )
{ {
if ( time.tv_sec > 0 ) if ( time->tv_sec > 0 )
{ {
time.tv_usec += 1000000; time->tv_usec += 1000000;
time.tv_sec--; time->tv_sec--;
} }
else else
{ {
time.tv_usec = 0; time->tv_usec = 0;
break; break;
} }
} }
@ -232,7 +229,7 @@ int FObject::addTimer (int interval)
time_interval.tv_sec = interval / 1000; time_interval.tv_sec = interval / 1000;
time_interval.tv_usec = (interval % 1000) * 1000; time_interval.tv_usec = (interval % 1000) * 1000;
getCurrentTime (currentTime); getCurrentTime (&currentTime);
timeval timeout = currentTime + time_interval; timeval timeout = currentTime + time_interval;
timer_data t = { id, time_interval, timeout, this }; timer_data t = { id, time_interval, timeout, this };

View File

@ -12,7 +12,7 @@
#define FOBJECT_H #define FOBJECT_H
#include <stdint.h> #include <stdint.h>
#include <sys/time.h> // need for gettimeofday #include <sys/time.h> // need for gettimeofday
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <list> #include <list>
@ -22,24 +22,6 @@
#include "fevent.h" #include "fevent.h"
#include "ftypes.h" #include "ftypes.h"
#define null NULL
typedef unsigned char uChar;
typedef unsigned int uInt;
typedef unsigned long uLong;
typedef uint8_t uInt8;
typedef uint16_t uInt16;
typedef uint32_t uInt32;
typedef uint64_t uInt64;
typedef signed int sInt;
typedef signed long sLong;
typedef int8_t sInt8;
typedef int16_t sInt16;
typedef int32_t sInt32;
typedef int64_t sInt64;
typedef long double lDouble;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FObject // class FObject
@ -50,76 +32,76 @@ typedef long double lDouble;
class FObject class FObject
{ {
public: public:
// Typedef // Typedef
typedef std::list<FObject*> FObjectList; typedef std::list<FObject*> FObjectList;
// Constructor // Constructor
explicit FObject (FObject* = 0); explicit FObject (FObject* = 0);
// Destructor // Destructor
virtual ~FObject(); virtual ~FObject();
// Accessors // Accessors
virtual const char* getClassName() const; virtual const char* getClassName() const;
FObject* getParent() const; FObject* getParent() const;
FObject* getChild (int) const; FObject* getChild (int) const;
const FObjectList& getChildren() const; const FObjectList& getChildren() const;
int numOfChildren() const; int numOfChildren() const;
// Inquiries // Inquiries
bool hasParent() const; bool hasParent() const;
bool hasChildren() const; bool hasChildren() const;
bool isChild (FObject*) const; bool isChild (FObject*) const;
bool isDirectChild (FObject*) const; bool isDirectChild (FObject*) const;
bool isWidget() const; bool isWidget() const;
bool isInstanceOf (const char*) const; bool isInstanceOf (const char*) const;
bool isTimerInUpdating() const; bool isTimerInUpdating() const;
// Methods // Methods
void removeParent(); void removeParent();
void addChild (FObject*); void addChild (FObject*);
void delChild (FObject*); void delChild (FObject*);
// Timer methods // Timer methods
static void getCurrentTime (timeval&); static void getCurrentTime (timeval*);
int addTimer (int); int addTimer (int);
bool delTimer (int); bool delTimer (int);
bool delOwnTimer(); bool delOwnTimer();
bool delAllTimer(); bool delAllTimer();
protected: protected:
struct timer_data struct timer_data
{ {
int id; int id;
timeval interval; timeval interval;
timeval timeout; timeval timeout;
FObject* object; FObject* object;
}; };
// Typedef // Typedef
typedef std::vector<timer_data> TimerList; typedef std::vector<timer_data> TimerList;
// Event handler // Event handler
virtual bool event (FEvent*); virtual bool event (FEvent*);
virtual void onTimer (FTimerEvent*); virtual void onTimer (FTimerEvent*);
// Data Members // Data Members
static TimerList* timer_list; static TimerList* timer_list;
bool widget_object; bool widget_object;
private: private:
// Disable copy constructor // Disable copy constructor
FObject (const FObject&); FObject (const FObject&);
// Disable assignment operator (=) // Disable assignment operator (=)
FObject& operator = (const FObject&); FObject& operator = (const FObject&);
// Data Members // Data Members
FObject* parent_obj; FObject* parent_obj;
FObjectList children_list; FObjectList children_list;
bool has_parent; bool has_parent;
static bool timer_modify_lock; static bool timer_modify_lock;
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -60,7 +60,7 @@ FOptiAttr::FOptiAttr()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FOptiAttr::~FOptiAttr() // destructor FOptiAttr::~FOptiAttr() // destructor
{ } { }

View File

@ -11,11 +11,11 @@
#ifndef FOPTIATTR_H #ifndef FOPTIATTR_H
#define FOPTIATTR_H #define FOPTIATTR_H
#include <algorithm> // need for std::swap
#include <assert.h> #include <assert.h>
#include <term.h> // need for tparm #include <term.h> // need for tparm
#include <algorithm> // need for std::swap
#include "fc.h" #include "fc.h"
@ -28,244 +28,243 @@
class FOptiAttr class FOptiAttr
{ {
public: public:
// Typedef // Typedef
typedef struct typedef struct
{ {
int code; // character code int code; // character code
short fg_color; // foreground color short fg_color; // foreground color
short bg_color; // background color short bg_color; // background color
union attribute union attribute
{ {
struct struct
{ {
// Attribute byte #1 // Attribute byte #1
uChar bold : 1; // bold uChar bold : 1; // bold
uChar dim : 1; // dim uChar dim : 1; // dim
uChar italic : 1; // italic uChar italic : 1; // italic
uChar underline : 1; // underline uChar underline : 1; // underline
uChar blink : 1; // blink uChar blink : 1; // blink
uChar reverse : 1; // reverse uChar reverse : 1; // reverse
uChar standout : 1; // standout uChar standout : 1; // standout
uChar invisible : 1; // invisible uChar invisible : 1; // invisible
// Attribute byte #2 // Attribute byte #2
uChar protect : 1; // protect mode uChar protect : 1; // protect mode
uChar crossed_out : 1; // crossed out uChar crossed_out : 1; // crossed out
uChar dbl_underline : 1; // double underline uChar dbl_underline : 1; // double underline
uChar alt_charset : 1; // alternate character set (vt100) uChar alt_charset : 1; // alternate character set (vt100)
uChar pc_charset : 1; // pc character set (CP437) uChar pc_charset : 1; // pc character set (CP437)
uChar transparent : 1; // transparent uChar transparent : 1; // transparent
uChar trans_shadow : 1; // transparent shadow uChar trans_shadow : 1; // transparent shadow
uChar inherit_bg : 1; // inherit background uChar inherit_bg : 1; // inherit background
// Attribute byte #3 // Attribute byte #3
uChar no_changes : 1; // no changes required uChar no_changes : 1; // no changes required
uChar printed : 1; // is printed to VTerm uChar printed : 1; // is printed to VTerm
uChar : 6; // padding bits uChar : 6; // padding bits
} bit; } bit;
uChar byte1; uChar byte1;
uChar byte2; uChar byte2;
uChar byte3; uChar byte3;
} attr; } attr;
} char_data;
} char_data; // Constructor
explicit FOptiAttr();
// Constructor // Destructor
explicit FOptiAttr(); ~FOptiAttr();
// Destructor // Friend operator functions
~FOptiAttr(); friend bool operator == (const char_data&, const char_data&);
friend bool operator != (const char_data&, const char_data&);
// Friend operator functions // Mutators
friend bool operator == (const char_data&, const char_data&); void setMaxColor (const int&);
friend bool operator != (const char_data&, const char_data&); void setNoColorVideo (int);
void setDefaultColorSupport();
void setCygwinTerminal();
void set_enter_bold_mode (char*&);
void set_exit_bold_mode (char*&);
void set_enter_dim_mode (char*&);
void set_exit_dim_mode (char*&);
void set_enter_italics_mode (char*&);
void set_exit_italics_mode (char*&);
void set_enter_underline_mode (char*&);
void set_exit_underline_mode (char*&);
void set_enter_blink_mode (char*&);
void set_exit_blink_mode (char*&);
void set_enter_reverse_mode (char*&);
void set_exit_reverse_mode (char*&);
void set_enter_secure_mode (char*&);
void set_exit_secure_mode (char*&);
void set_enter_protected_mode (char*&);
void set_exit_protected_mode (char*&);
void set_enter_crossed_out_mode (char*&);
void set_exit_crossed_out_mode (char*&);
void set_enter_dbl_underline_mode (char*&);
void set_exit_dbl_underline_mode (char*&);
void set_enter_standout_mode (char*&);
void set_exit_standout_mode (char*&);
void set_set_attributes (char*&);
void set_exit_attribute_mode (char*&);
void set_enter_alt_charset_mode (char*&);
void set_exit_alt_charset_mode (char*&);
void set_enter_pc_charset_mode (char*&);
void set_exit_pc_charset_mode (char*&);
void set_a_foreground_color (char*&);
void set_a_background_color (char*&);
void set_foreground_color (char*&);
void set_background_color (char*&);
void set_term_color_pair (char*&);
void set_orig_pair (char*&);
void set_orig_orig_colors (char*&);
// Mutators // Inquiry
void setMaxColor (int&); static bool isNormal (char_data*&);
void setNoColorVideo (int);
void setDefaultColorSupport();
void setCygwinTerminal();
void set_enter_bold_mode (char*&);
void set_exit_bold_mode (char*&);
void set_enter_dim_mode (char*&);
void set_exit_dim_mode (char*&);
void set_enter_italics_mode (char*&);
void set_exit_italics_mode (char*&);
void set_enter_underline_mode (char*&);
void set_exit_underline_mode (char*&);
void set_enter_blink_mode (char*&);
void set_exit_blink_mode (char*&);
void set_enter_reverse_mode (char*&);
void set_exit_reverse_mode (char*&);
void set_enter_secure_mode (char*&);
void set_exit_secure_mode (char*&);
void set_enter_protected_mode (char*&);
void set_exit_protected_mode (char*&);
void set_enter_crossed_out_mode (char*&);
void set_exit_crossed_out_mode (char*&);
void set_enter_dbl_underline_mode (char*&);
void set_exit_dbl_underline_mode (char*&);
void set_enter_standout_mode (char*&);
void set_exit_standout_mode (char*&);
void set_set_attributes (char*&);
void set_exit_attribute_mode (char*&);
void set_enter_alt_charset_mode (char*&);
void set_exit_alt_charset_mode (char*&);
void set_enter_pc_charset_mode (char*&);
void set_exit_pc_charset_mode (char*&);
void set_a_foreground_color (char*&);
void set_a_background_color (char*&);
void set_foreground_color (char*&);
void set_background_color (char*&);
void set_term_color_pair (char*&);
void set_orig_pair (char*&);
void set_orig_orig_colors (char*&);
// Inquiry // Methods
static bool isNormal (char_data*&); void init();
static short vga2ansi (register short);
char* changeAttribute (char_data*&, char_data*&);
// Methods private:
void init(); // Typedefs and Enumerations
static short vga2ansi (register short); typedef unsigned char uChar;
char* changeAttribute (char_data*&, char_data*&);
private: typedef struct
// Typedefs and Enumerations {
typedef unsigned char uChar; char* cap;
bool caused_reset;
} capability;
typedef struct enum init_reset_tests
{ {
char* cap; no_test = 0x00,
bool caused_reset; test_ansi_reset = 0x01, // ANSI X3.64 terminal
} capability; test_adm3_reset = 0x02, // Lear Siegler ADM-3 terminal
same_like_ue = 0x04,
same_like_se = 0x08,
same_like_me = 0x10,
all_tests = 0x1f
};
enum init_reset_tests enum default_color
{ {
no_test = 0x00, Default = -1,
test_ansi_reset = 0x01, // ANSI X3.64 terminal Black = 0,
test_adm3_reset = 0x02, // Lear Siegler ADM-3 terminal LightGray = 7
same_like_ue = 0x04, };
same_like_se = 0x08,
same_like_me = 0x10,
all_tests = 0x1f
};
enum default_color // Disable copy constructor
{ FOptiAttr (const FOptiAttr&);
Default = -1,
Black = 0,
LightGray = 7
};
// Disable copy constructor // Disable assignment operator (=)
FOptiAttr (const FOptiAttr&); FOptiAttr& operator = (const FOptiAttr&);
// Disable assignment operator (=) // Mutators
FOptiAttr& operator = (const FOptiAttr&); bool setTermBold (char_data*&);
bool unsetTermBold (char_data*&);
bool setTermDim (char_data*&);
bool unsetTermDim (char_data*&);
bool setTermItalic (char_data*&);
bool unsetTermItalic (char_data*&);
bool setTermUnderline (char_data*&);
bool unsetTermUnderline (char_data*&);
bool setTermBlink (char_data*&);
bool unsetTermBlink (char_data*&);
bool setTermReverse (char_data*&);
bool unsetTermReverse (char_data*&);
bool setTermStandout (char_data*&);
bool unsetTermStandout (char_data*&);
bool setTermInvisible (char_data*&);
bool unsetTermInvisible (char_data*&);
bool setTermProtected (char_data*&);
bool unsetTermProtected (char_data*&);
bool setTermCrossedOut (char_data*&);
bool unsetTermCrossedOut (char_data*&);
bool setTermDoubleUnderline (char_data*&);
bool unsetTermDoubleUnderline (char_data*&);
bool setTermAttributes ( char_data*&
, bool, bool, bool
, bool, bool, bool
, bool, bool, bool );
bool unsetTermAttributes (char_data*&);
bool setTermAltCharset (char_data*&);
bool unsetTermAltCharset (char_data*&);
bool setTermPCcharset (char_data*&);
bool unsetTermPCcharset (char_data*&);
bool setTermDefaultColor (char_data*&);
// Mutators // Inquiries
bool setTermBold (char_data*&); static bool hasColor (char_data*&);
bool unsetTermBold (char_data*&); static bool hasAttribute (char_data*&);
bool setTermDim (char_data*&); static bool hasNoAttribute (char_data*&);
bool unsetTermDim (char_data*&);
bool setTermItalic (char_data*&);
bool unsetTermItalic (char_data*&);
bool setTermUnderline (char_data*&);
bool unsetTermUnderline (char_data*&);
bool setTermBlink (char_data*&);
bool unsetTermBlink (char_data*&);
bool setTermReverse (char_data*&);
bool unsetTermReverse (char_data*&);
bool setTermStandout (char_data*&);
bool unsetTermStandout (char_data*&);
bool setTermInvisible (char_data*&);
bool unsetTermInvisible (char_data*&);
bool setTermProtected (char_data*&);
bool unsetTermProtected (char_data*&);
bool setTermCrossedOut (char_data*&);
bool unsetTermCrossedOut (char_data*&);
bool setTermDoubleUnderline (char_data*&);
bool unsetTermDoubleUnderline (char_data*&);
bool setTermAttributes ( char_data*&
, bool, bool, bool
, bool, bool, bool
, bool, bool, bool );
bool unsetTermAttributes (char_data*&);
bool setTermAltCharset (char_data*&);
bool unsetTermAltCharset (char_data*&);
bool setTermPCcharset (char_data*&);
bool unsetTermPCcharset (char_data*&);
bool setTermDefaultColor (char_data*&);
// Inquiries // Methods
static bool hasColor (char_data*&); bool colorChange (char_data*&, char_data*&);
static bool hasAttribute (char_data*&); void resetColor (char_data*&);
static bool hasNoAttribute (char_data*&); void prevent_no_color_video_attributes (char_data*&);
void change_color (char_data*&, char_data*&);
void resetAttribute (char_data*&);
void reset (char_data*&);
bool caused_reset_attributes (char*&, uChar = all_tests);
void detectSwitchOn (char_data*&, char_data*&);
void detectSwitchOff (char_data*&, char_data*&);
bool switchOn();
bool switchOff();
bool append_sequence (char*&);
bool replace_sequence (char*&);
// Methods // Data Members
bool colorChange (char_data*&, char_data*&); capability F_enter_bold_mode;
void resetColor (char_data*&); capability F_exit_bold_mode;
void prevent_no_color_video_attributes (char_data*&); capability F_enter_dim_mode;
void change_color (char_data*&, char_data*&); capability F_exit_dim_mode;
void resetAttribute (char_data*&); capability F_enter_italics_mode;
void reset (char_data*&); capability F_exit_italics_mode;
bool caused_reset_attributes (char*&, uChar = all_tests); capability F_enter_underline_mode;
void detectSwitchOn (char_data*&, char_data*&); capability F_exit_underline_mode;
void detectSwitchOff (char_data*&, char_data*&); capability F_enter_blink_mode;
bool switchOn(); capability F_exit_blink_mode;
bool switchOff(); capability F_enter_reverse_mode;
bool append_sequence (char*&); capability F_exit_reverse_mode;
bool replace_sequence (char*&); capability F_enter_standout_mode;
capability F_exit_standout_mode;
capability F_enter_secure_mode;
capability F_exit_secure_mode;
capability F_enter_protected_mode;
capability F_exit_protected_mode;
capability F_enter_crossed_out_mode;
capability F_exit_crossed_out_mode;
capability F_enter_dbl_underline_mode;
capability F_exit_dbl_underline_mode;
capability F_set_attributes;
capability F_exit_attribute_mode;
capability F_enter_alt_charset_mode;
capability F_exit_alt_charset_mode;
capability F_enter_pc_charset_mode;
capability F_exit_pc_charset_mode;
capability F_set_a_foreground;
capability F_set_a_background;
capability F_set_foreground;
capability F_set_background;
capability F_set_color_pair;
capability F_orig_pair;
capability F_orig_colors;
// Data Members char_data on;
capability F_enter_bold_mode; char_data off;
capability F_exit_bold_mode;
capability F_enter_dim_mode;
capability F_exit_dim_mode;
capability F_enter_italics_mode;
capability F_exit_italics_mode;
capability F_enter_underline_mode;
capability F_exit_underline_mode;
capability F_enter_blink_mode;
capability F_exit_blink_mode;
capability F_enter_reverse_mode;
capability F_exit_reverse_mode;
capability F_enter_standout_mode;
capability F_exit_standout_mode;
capability F_enter_secure_mode;
capability F_exit_secure_mode;
capability F_enter_protected_mode;
capability F_exit_protected_mode;
capability F_enter_crossed_out_mode;
capability F_exit_crossed_out_mode;
capability F_enter_dbl_underline_mode;
capability F_exit_dbl_underline_mode;
capability F_set_attributes;
capability F_exit_attribute_mode;
capability F_enter_alt_charset_mode;
capability F_exit_alt_charset_mode;
capability F_enter_pc_charset_mode;
capability F_exit_pc_charset_mode;
capability F_set_a_foreground;
capability F_set_a_background;
capability F_set_foreground;
capability F_set_background;
capability F_set_color_pair;
capability F_orig_pair;
capability F_orig_colors;
char_data on; int max_color;
char_data off; int attr_without_color;
bool ansi_default_color;
int max_color; bool monochron;
int attr_without_color; bool fake_reverse;
bool ansi_default_color; bool cygwin_terminal;
bool monochron; char attr_buf[8192];
bool fake_reverse; char* attr_ptr;
bool cygwin_terminal;
char attr_buf[8192];
char* attr_ptr;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -288,7 +287,7 @@ inline bool operator != ( const FOptiAttr::char_data& lhs,
{ return ! ( lhs == rhs ); } { return ! ( lhs == rhs ); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FOptiAttr::setMaxColor (int& c) inline void FOptiAttr::setMaxColor (const int& c)
{ max_color = c; } { max_color = c; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -1,8 +1,10 @@
// File: foptimove.cpp // File: foptimove.cpp
// Provides: class FOptiMove // Provides: class FOptiMove
#include <cstring>
#include "foptimove.h" #include "foptimove.h"
#include "string.h"
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FOptiMove // class FOptiMove
@ -45,7 +47,7 @@ FOptiMove::FOptiMove (int baud)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FOptiMove::~FOptiMove() // destructor FOptiMove::~FOptiMove() // destructor
{ } { }
@ -620,24 +622,42 @@ char* FOptiMove::moveCursor (int xold, int yold, int xnew, int ynew)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FOptiMove::printDurations() void FOptiMove::printDurations()
{ {
std::cout << " speed: " << baudrate << " baud\r\n"; std::cout << " speed: "
std::cout << " char_duration: " << char_duration << " ms\r\n"; << baudrate << " baud\r\n";
std::cout << " cursor_home: " << F_cursor_home.duration << " ms\r\n"; std::cout << " char_duration: "
std::cout << " cursor_to_ll: " << F_cursor_to_ll.duration << " ms\r\n"; << char_duration << " ms\r\n";
std::cout << " carriage_return: " << F_carriage_return.duration << " ms\r\n"; std::cout << " cursor_home: "
std::cout << " tab: " << F_tab.duration << " ms\r\n"; << F_cursor_home.duration << " ms\r\n";
std::cout << " back_tab: " << F_back_tab.duration << " ms\r\n"; std::cout << " cursor_to_ll: "
std::cout << " cursor_up: " << F_cursor_up.duration << " ms\r\n"; << F_cursor_to_ll.duration << " ms\r\n";
std::cout << " cursor_down: " << F_cursor_down.duration << " ms\r\n"; std::cout << " carriage_return: "
std::cout << " cursor_left: " << F_cursor_left.duration << " ms\r\n"; << F_carriage_return.duration << " ms\r\n";
std::cout << " cursor_right: " << F_cursor_right.duration << " ms\r\n"; std::cout << " tab: "
std::cout << " cursor_address: " << F_cursor_address.duration << " ms\r\n"; << F_tab.duration << " ms\r\n";
std::cout << " column_address: " << F_column_address.duration << " ms\r\n"; std::cout << " back_tab: "
std::cout << " row_address: " << F_row_address.duration << " ms\r\n"; << F_back_tab.duration << " ms\r\n";
std::cout << " parm_up_cursor: " << F_parm_up_cursor.duration << " ms\r\n"; std::cout << " cursor_up: "
std::cout << " parm_down_cursor: " << F_parm_down_cursor.duration << " ms\r\n"; << F_cursor_up.duration << " ms\r\n";
std::cout << " parm_left_cursor: " << F_parm_left_cursor.duration << " ms\r\n"; std::cout << " cursor_down: "
std::cout << "parm_right_cursor: " << F_parm_right_cursor.duration << " ms\r\n"; << F_cursor_down.duration << " ms\r\n";
std::cout << " cursor_left: "
<< F_cursor_left.duration << " ms\r\n";
std::cout << " cursor_right: "
<< F_cursor_right.duration << " ms\r\n";
std::cout << " cursor_address: "
<< F_cursor_address.duration << " ms\r\n";
std::cout << " column_address: "
<< F_column_address.duration << " ms\r\n";
std::cout << " row_address: "
<< F_row_address.duration << " ms\r\n";
std::cout << " parm_up_cursor: "
<< F_parm_up_cursor.duration << " ms\r\n";
std::cout << " parm_down_cursor: "
<< F_parm_down_cursor.duration << " ms\r\n";
std::cout << " parm_left_cursor: "
<< F_parm_left_cursor.duration << " ms\r\n";
std::cout << "parm_right_cursor: "
<< F_parm_right_cursor.duration << " ms\r\n";
} }
@ -647,9 +667,9 @@ void FOptiMove::calculateCharDuration()
{ {
if ( baudrate != 0 ) if ( baudrate != 0 )
{ {
static const int baudbyte = 9; // = 7 bit + 1 parity + 1 stop static const int baudbyte = 9; // = 7 bit + 1 parity + 1 stop
char_duration = (baudbyte * 1000 * 10) char_duration = (baudbyte * 1000 * 10)
/ (baudrate > 0 ? baudrate : 9600); // milliseconds / (baudrate > 0 ? baudrate : 9600); // milliseconds
if ( char_duration <= 0 ) if ( char_duration <= 0 )
char_duration = 1; char_duration = 1;
@ -707,7 +727,7 @@ int FOptiMove::capDurationToLength (int duration)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FOptiMove::repeatedAppend (capability& o, int count, char* dst) int FOptiMove::repeatedAppend (const capability& o, int count, char* dst)
{ {
register std::size_t src_len; register std::size_t src_len;
register std::size_t dst_len; register std::size_t dst_len;
@ -786,7 +806,7 @@ int FOptiMove::relativeMove ( char*& move
vtime = repeatedAppend (F_cursor_down, num, move); vtime = repeatedAppend (F_cursor_down, num, move);
} }
} }
else // to_y < from_y else // to_y < from_y
{ {
num = from_y - to_y; num = from_y - to_y;
@ -874,10 +894,9 @@ int FOptiMove::relativeMove ( char*& move
std::strncpy (hmove, str, sizeof(move_buf) - 1); std::strncpy (hmove, str, sizeof(move_buf) - 1);
htime = htime_r; htime = htime_r;
} }
} }
} }
else // to_x < from_x else // to_x < from_x
{ {
num = from_x - to_x; num = from_x - to_x;
@ -924,7 +943,6 @@ int FOptiMove::relativeMove ( char*& move
std::strncpy (hmove, str, sizeof(move_buf) - 1); std::strncpy (hmove, str, sizeof(move_buf) - 1);
htime = htime_l; htime = htime_l;
} }
} }
} }
@ -947,7 +965,8 @@ int FOptiMove::relativeMove ( char*& move
inline bool FOptiMove::isWideMove ( int xold, int yold inline bool FOptiMove::isWideMove ( int xold, int yold
, int xnew, int ynew ) , int xnew, int ynew )
{ {
return bool ( (xnew > MOVE_LIMIT) return bool ( xnew > MOVE_LIMIT
&& (xnew < screen_width - 1 - MOVE_LIMIT) && xnew < screen_width - 1 - MOVE_LIMIT
&& (std::abs(xnew - xold) + std::abs(ynew - yold) > MOVE_LIMIT) ); && std::abs(xnew - xold) + std::abs(ynew - yold)
> MOVE_LIMIT );
} }

View File

@ -34,112 +34,112 @@
class FOptiMove class FOptiMove
{ {
public: public:
// Constructor // Constructor
explicit FOptiMove (int = 0); explicit FOptiMove (int = 0);
// Destructor // Destructor
~FOptiMove(); ~FOptiMove();
// Mutators // Mutators
void setBaudRate (int); void setBaudRate (int);
void setTabStop (int); void setTabStop (int);
void setTermSize (int, int); void setTermSize (int, int);
int set_cursor_home (char*&); int set_cursor_home (char*&);
int set_cursor_to_ll (char*&); int set_cursor_to_ll (char*&);
int set_carriage_return (char*&); int set_carriage_return (char*&);
int set_tabular (char*&); int set_tabular (char*&);
int set_back_tab (char*&); int set_back_tab (char*&);
int set_cursor_up (char*&); int set_cursor_up (char*&);
int set_cursor_down (char*&); int set_cursor_down (char*&);
int set_cursor_left (char*&); int set_cursor_left (char*&);
int set_cursor_right (char*&); int set_cursor_right (char*&);
int set_cursor_address (char*&); int set_cursor_address (char*&);
int set_column_address (char*&); int set_column_address (char*&);
int set_row_address (char*&); int set_row_address (char*&);
int set_parm_up_cursor (char*&); int set_parm_up_cursor (char*&);
int set_parm_down_cursor (char*&); int set_parm_down_cursor (char*&);
int set_parm_left_cursor (char*&); int set_parm_left_cursor (char*&);
int set_parm_right_cursor (char*&); int set_parm_right_cursor (char*&);
int set_erase_chars (char*&); int set_erase_chars (char*&);
int set_repeat_char (char*&); int set_repeat_char (char*&);
int set_clr_bol (char*&); int set_clr_bol (char*&);
int set_clr_eol (char*&); int set_clr_eol (char*&);
void set_auto_left_margin (bool&); void set_auto_left_margin (const bool&);
void set_eat_newline_glitch (bool&); void set_eat_newline_glitch (const bool&);
// Methods // Methods
char* moveCursor (int, int, int, int); char* moveCursor (int, int, int, int);
void printDurations(); void printDurations();
private: private:
// Typedefs // Typedefs
typedef unsigned char uChar; typedef unsigned char uChar;
typedef unsigned int uInt; typedef unsigned int uInt;
typedef struct typedef struct
{ {
char* cap; char* cap;
int duration; int duration;
int length; int length;
} capability; } capability;
// Constants // Constants
static const int LONG_DURATION = INT_MAX; static const int LONG_DURATION = INT_MAX;
// value for a long capability waiting time // value for a long capability waiting time
static const int MOVE_LIMIT = 7; static const int MOVE_LIMIT = 7;
// maximum character distance to avoid direct cursor addressing // maximum character distance to avoid direct cursor addressing
// Methods // Methods
void calculateCharDuration(); void calculateCharDuration();
int capDuration (char*&, int); int capDuration (char*&, int);
int capDurationToLength (int); int capDurationToLength (int);
int repeatedAppend (capability&, int, char*); int repeatedAppend (const capability&, int, char*);
int relativeMove (char*&, int, int, int, int); int relativeMove (char*&, int, int, int, int);
bool isWideMove (int, int, int, int); bool isWideMove (int, int, int, int);
// Data Members // Data Members
capability F_cursor_home; capability F_cursor_home;
capability F_carriage_return; capability F_carriage_return;
capability F_cursor_to_ll; capability F_cursor_to_ll;
capability F_tab; capability F_tab;
capability F_back_tab; capability F_back_tab;
capability F_cursor_up; capability F_cursor_up;
capability F_cursor_down; capability F_cursor_down;
capability F_cursor_left; capability F_cursor_left;
capability F_cursor_right; capability F_cursor_right;
capability F_cursor_address; capability F_cursor_address;
capability F_column_address; capability F_column_address;
capability F_row_address; capability F_row_address;
capability F_parm_up_cursor; capability F_parm_up_cursor;
capability F_parm_down_cursor; capability F_parm_down_cursor;
capability F_parm_left_cursor; capability F_parm_left_cursor;
capability F_parm_right_cursor; capability F_parm_right_cursor;
capability F_erase_chars; capability F_erase_chars;
capability F_repeat_char; capability F_repeat_char;
capability F_clr_bol; capability F_clr_bol;
capability F_clr_eol; capability F_clr_eol;
bool automatic_left_margin; bool automatic_left_margin;
bool eat_nl_glitch; bool eat_nl_glitch;
char move_buf[512]; char move_buf[512];
int char_duration; int char_duration;
int baudrate; int baudrate;
int tabstop; int tabstop;
int screen_width; int screen_width;
int screen_height; int screen_height;
}; };
#pragma pack(pop) #pragma pack(pop)
// FOptiMove inline functions // FOptiMove inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FOptiMove::set_auto_left_margin (bool& bcap) inline void FOptiMove::set_auto_left_margin (const bool& bcap)
{ automatic_left_margin = bcap; } { automatic_left_margin = bcap; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FOptiMove::set_eat_newline_glitch (bool& bcap) inline void FOptiMove::set_eat_newline_glitch (const bool& bcap)
{ eat_nl_glitch = bcap; } { eat_nl_glitch = bcap; }
#endif // FOPTIMOVE_H #endif // FOPTIMOVE_H

View File

@ -20,45 +20,45 @@
class FPoint class FPoint
{ {
public: public:
// Constructors // Constructors
FPoint (); FPoint ();
FPoint (const FPoint&); // copy constructor FPoint (const FPoint&); // copy constructor
FPoint (int, int); FPoint (int, int);
// Destructor // Destructor
virtual ~FPoint(); virtual ~FPoint();
// Overloaded operators // Overloaded operators
FPoint& operator = (const FPoint&); FPoint& operator = (const FPoint&);
FPoint& operator += (const FPoint&); FPoint& operator += (const FPoint&);
FPoint& operator -= (const FPoint&); FPoint& operator -= (const FPoint&);
friend inline bool operator == (const FPoint&, const FPoint&); friend inline bool operator == (const FPoint&, const FPoint&);
friend inline bool operator != (const FPoint&, const FPoint&); friend inline bool operator != (const FPoint&, const FPoint&);
friend inline FPoint operator + (const FPoint&, const FPoint&); friend inline FPoint operator + (const FPoint&, const FPoint&);
friend inline FPoint operator - (const FPoint&, const FPoint&); friend inline FPoint operator - (const FPoint&, const FPoint&);
friend inline FPoint operator - (const FPoint&); friend inline FPoint operator - (const FPoint&);
// Accessors // Accessors
virtual const char* getClassName(); virtual const char* getClassName();
int getX() const; int getX() const;
int getY() const; int getY() const;
void setX (int); void setX (int);
void setY (int); void setY (int);
void setPoint (int, int); void setPoint (int, int);
// Inquiry // Inquiry
bool isNull() const; bool isNull() const;
// Point references // Point references
short& x_ref(); short& x_ref();
short& y_ref(); short& y_ref();
private: private:
// Data Members // Data Members
short xpos; short xpos;
short ypos; short ypos;
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -19,7 +19,7 @@ FProgressbar::FProgressbar(FWidget* parent)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FProgressbar::~FProgressbar() FProgressbar::~FProgressbar() // destructor
{ } { }
@ -214,7 +214,7 @@ void FProgressbar::drawBar()
else else
{ {
setColor (wc.progressbar_fg, wc.progressbar_bg); setColor (wc.progressbar_fg, wc.progressbar_bg);
print (fc::LeftHalfBlock); // ▌ print (fc::LeftHalfBlock); // ▌
} }
i++; i++;

View File

@ -40,43 +40,43 @@
class FProgressbar : public FWidget class FProgressbar : public FWidget
{ {
public: public:
// Using-declarations // Using-declarations
using FWidget::setGeometry; using FWidget::setGeometry;
// Constructor // Constructor
explicit FProgressbar(FWidget* = 0); explicit FProgressbar(FWidget* = 0);
// Destructor // Destructor
virtual ~FProgressbar(); virtual ~FProgressbar();
// Accessors // Accessors
const char* getClassName() const; const char* getClassName() const;
int getPercentage(); int getPercentage();
// Mutators // Mutators
void setPercentage (int); void setPercentage (int);
void setGeometry (int, int, int, int, bool = true); void setGeometry (int, int, int, int, bool = true);
bool setShadow (bool); bool setShadow (bool);
bool setShadow(); bool setShadow();
bool unsetShadow(); bool unsetShadow();
// Inquiries // Inquiries
bool hasShadow(); bool hasShadow();
// Methods // Methods
void hide(); void hide();
void reset(); void reset();
private: private:
// Methods // Methods
virtual void draw(); virtual void draw();
void drawPercentage(); void drawPercentage();
void drawBar(); void drawBar();
// Data Members // Data Members
int percentage; int percentage;
int bar_length; int bar_length;
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -45,28 +45,28 @@
class FRadioButton : public FToggleButton class FRadioButton : public FToggleButton
{ {
public: public:
// Constructors // Constructors
explicit FRadioButton (FWidget* = 0); explicit FRadioButton (FWidget* = 0);
FRadioButton (const FString&, FWidget* = 0); FRadioButton (const FString&, FWidget* = 0);
// Destructor // Destructor
virtual ~FRadioButton(); virtual ~FRadioButton();
// Accessor // Accessor
const char* getClassName() const; const char* getClassName() const;
private: private:
// Disable copy constructor // Disable copy constructor
FRadioButton (const FRadioButton&); FRadioButton (const FRadioButton&);
// Disable assignment operator (=) // Disable assignment operator (=)
FRadioButton& operator = (const FRadioButton&); FRadioButton& operator = (const FRadioButton&);
// Methods // Methods
void init(); void init();
void draw(); void draw();
void drawRadioButton(); void drawRadioButton();
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -38,9 +38,9 @@ void FRadioMenuItem::init (FWidget* parent)
if ( ! parent ) if ( ! parent )
return; return;
if ( isMenu(parent) ) // Parent is menu if ( isMenu(parent) ) // Parent is menu
{ {
FMenu* menu_ptr = dynamic_cast<FMenu*>(parent); FMenu* menu_ptr = static_cast<FMenu*>(parent);
if ( menu_ptr ) if ( menu_ptr )
menu_ptr->has_checkable_items = true; menu_ptr->has_checkable_items = true;

View File

@ -45,28 +45,28 @@
class FRadioMenuItem : public FMenuItem class FRadioMenuItem : public FMenuItem
{ {
public: public:
// Constructors // Constructors
explicit FRadioMenuItem (FWidget* = 0); explicit FRadioMenuItem (FWidget* = 0);
FRadioMenuItem (const FString&, FWidget* = 0); FRadioMenuItem (const FString&, FWidget* = 0);
// Destructor // Destructor
virtual ~FRadioMenuItem(); virtual ~FRadioMenuItem();
// Accessor // Accessor
const char* getClassName() const; const char* getClassName() const;
private: private:
// Disable copy constructor // Disable copy constructor
FRadioMenuItem (const FRadioMenuItem&); FRadioMenuItem (const FRadioMenuItem&);
// Disable assignment operator (=) // Disable assignment operator (=)
FRadioMenuItem& operator = (const FRadioMenuItem&); FRadioMenuItem& operator = (const FRadioMenuItem&);
// Methods // Methods
void init (FWidget*); void init (FWidget*);
void processToggle(); void processToggle();
void processClicked(); void processClicked();
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -1,6 +1,8 @@
// File: frect.cpp // File: frect.cpp
// Provides: class FRect // Provides: class FRect
#include <algorithm>
#include "frect.h" #include "frect.h"
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -20,6 +22,7 @@ FRect::FRect (const FPoint& p1, const FPoint& p2)
FRect::~FRect() // destructor FRect::~FRect() // destructor
{ } { }
// public methods of FRect // public methods of FRect
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FRect::isNull() const bool FRect::isNull() const

View File

@ -24,82 +24,82 @@
class FRect class FRect
{ {
public: public:
// Constructors // Constructors
FRect (); FRect ();
FRect (const FRect&); // copy constructor FRect (const FRect&); // copy constructor
FRect (int, int, int, int); FRect (int, int, int, int);
FRect (const FPoint&, const FPoint&); FRect (const FPoint&, const FPoint&);
// Destructor // Destructor
virtual ~FRect(); virtual ~FRect();
// Overloaded operators // Overloaded operators
FRect& operator = (const FRect&); FRect& operator = (const FRect&);
friend FRect operator + (const FRect&, const FPoint&); friend FRect operator + (const FRect&, const FPoint&);
friend FRect operator - (const FRect&, const FPoint&); friend FRect operator - (const FRect&, const FPoint&);
friend bool operator == (const FRect&, const FRect&); friend bool operator == (const FRect&, const FRect&);
friend bool operator != (const FRect&, const FRect&); friend bool operator != (const FRect&, const FRect&);
// Accessors // Accessors
virtual const char* getClassName(); virtual const char* getClassName();
int getX1() const; int getX1() const;
int getY1() const; int getY1() const;
int getX2() const; int getX2() const;
int getY2() const; int getY2() const;
int getX() const; int getX() const;
int getY() const; int getY() const;
FPoint getPos() const; FPoint getPos() const;
FPoint getUpperLeftPos() const; FPoint getUpperLeftPos() const;
FPoint getUpperRightPos() const; FPoint getUpperRightPos() const;
FPoint getLowerLeftPos() const; FPoint getLowerLeftPos() const;
FPoint getLowerRightPos() const; FPoint getLowerRightPos() const;
int getWidth() const; int getWidth() const;
int getHeight() const; int getHeight() const;
// Mutators // Mutators
void setX1 (int); void setX1 (int);
void setY1 (int); void setY1 (int);
void setX2 (int); void setX2 (int);
void setY2 (int); void setY2 (int);
void setX (int); void setX (int);
void setY (int); void setY (int);
void setPos (int, int); void setPos (int, int);
void setPos (const FPoint&); void setPos (const FPoint&);
void setWidth (int); void setWidth (int);
void setHeight (int); void setHeight (int);
void setSize (int, int); void setSize (int, int);
void setRect (const FRect&); void setRect (const FRect&);
void setRect (int, int, int, int); void setRect (int, int, int, int);
void setCoordinates (const FPoint&, const FPoint&); void setCoordinates (const FPoint&, const FPoint&);
void setCoordinates (int, int, int, int); void setCoordinates (int, int, int, int);
// Inquiry // Inquiry
bool isNull() const; bool isNull() const;
// Coordinate references // Coordinate references
short& x1_ref(); short& x1_ref();
short& y1_ref(); short& y1_ref();
short& x2_ref(); short& x2_ref();
short& y2_ref(); short& y2_ref();
// Methods // Methods
void move (int, int); void move (int, int);
void move (const FPoint&); void move (const FPoint&);
bool contains (int, int) const; bool contains (int, int) const;
bool contains (const FPoint&) const; bool contains (const FPoint&) const;
bool contains (const FRect&) const; bool contains (const FRect&) const;
bool overlap (const FRect&) const; bool overlap (const FRect&) const;
FRect intersect (const FRect&) const; FRect intersect (const FRect&) const;
FRect combined (const FRect&) const; FRect combined (const FRect&) const;
private: private:
// Data Members // Data Members
short X1; short X1;
short Y1; short Y1;
short X2; short X2;
short Y2; short Y2;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -159,23 +159,23 @@ inline int FRect::getY() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FPoint FRect::getPos() const inline FPoint FRect::getPos() const
{ return FPoint(X1,Y1); } { return FPoint(X1, Y1); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FPoint FRect::getUpperLeftPos() const inline FPoint FRect::getUpperLeftPos() const
{ return FPoint(X1,Y1); } { return FPoint(X1, Y1); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FPoint FRect::getUpperRightPos() const inline FPoint FRect::getUpperRightPos() const
{ return FPoint(X2,Y1); } { return FPoint(X2, Y1); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FPoint FRect::getLowerLeftPos() const inline FPoint FRect::getLowerLeftPos() const
{ return FPoint(X1,Y2); } { return FPoint(X1, Y2); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FPoint FRect::getLowerRightPos() const inline FPoint FRect::getLowerRightPos() const
{ return FPoint(X2,Y2); } { return FPoint(X2, Y2); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline int FRect::getWidth() const inline int FRect::getWidth() const

View File

@ -1,6 +1,8 @@
// File: fscrollbar.cpp // File: fscrollbar.cpp
// Provides: class FScrollbar // Provides: class FScrollbar
#include <algorithm>
#include "fscrollbar.h" #include "fscrollbar.h"
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -19,8 +21,8 @@ FScrollbar::FScrollbar(FWidget* parent)
, slider_click_stop_pos(-1) , slider_click_stop_pos(-1)
, current_slider_pos(-1) , current_slider_pos(-1)
, slider_pos(0) , slider_pos(0)
, slider_length(18) // = bar_length , slider_length(18) // = bar_length
, bar_length(18) // = length - 2 , bar_length(18) // = length - 2
, val(0) , val(0)
, min(0) , min(0)
, max(99) , max(99)
@ -46,8 +48,8 @@ FScrollbar::FScrollbar(int o, FWidget* parent)
, slider_click_stop_pos(-1) , slider_click_stop_pos(-1)
, current_slider_pos(-1) , current_slider_pos(-1)
, slider_pos(0) , slider_pos(0)
, slider_length(18) // = bar_length , slider_length(18) // = bar_length
, bar_length(18) // = length - 2 , bar_length(18) // = length - 2
, val(0) , val(0)
, min(0) , min(0)
, max(99) , max(99)
@ -62,7 +64,7 @@ FScrollbar::FScrollbar(int o, FWidget* parent)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FScrollbar::~FScrollbar() FScrollbar::~FScrollbar() // destructor
{ {
delOwnTimer(); delOwnTimer();
} }
@ -163,7 +165,7 @@ void FScrollbar::setGeometry (int x, int y, int w, int h, bool adjust)
setWidth(isNewFont() ? 2 : 1); setWidth(isNewFont() ? 2 : 1);
setHeight(length); setHeight(length);
} }
else // horizontal else // horizontal
{ {
setWidth(length); setWidth(length);
setHeight(1); setHeight(1);
@ -243,7 +245,7 @@ void FScrollbar::drawButtons()
print (fc::NF_rev_down_arrow1); print (fc::NF_rev_down_arrow1);
print (fc::NF_rev_down_arrow2); print (fc::NF_rev_down_arrow2);
} }
else // horizontal else // horizontal
{ {
print (fc::NF_rev_left_arrow1); print (fc::NF_rev_left_arrow1);
print (fc::NF_rev_left_arrow2); print (fc::NF_rev_left_arrow2);
@ -261,15 +263,15 @@ void FScrollbar::drawButtons()
if ( bar_orientation == fc::vertical ) if ( bar_orientation == fc::vertical )
{ {
print (fc::BlackUpPointingTriangle); // ▲ print (fc::BlackUpPointingTriangle); // ▲
setPrintPos (1, length); setPrintPos (1, length);
print (fc::BlackDownPointingTriangle); // ▼ print (fc::BlackDownPointingTriangle); // ▼
} }
else // horizontal else // horizontal
{ {
print (fc::BlackLeftPointingPointer); // ◄ print (fc::BlackLeftPointingPointer); // ◄
setPrintPos (length, 1); setPrintPos (length, 1);
print (fc::BlackRightPointingPointer); // ► print (fc::BlackRightPointingPointer); // ►
} }
if ( isMonochron() ) if ( isMonochron() )
@ -294,10 +296,10 @@ void FScrollbar::drawBar()
setPrintPos (1, 1 + z); setPrintPos (1, 1 + z);
if ( isNewFont() ) if ( isNewFont() )
print (fc::NF_border_line_left); // ⎸ print (fc::NF_border_line_left); // ⎸
if ( isMonochron() || max_color < 16 ) if ( isMonochron() || max_color < 16 )
print (fc::MediumShade); // ▒ print (fc::MediumShade); // ▒
else else
print (' '); print (' ');
} }
@ -327,7 +329,7 @@ void FScrollbar::drawBar()
setPrintPos (1, 1 + z); setPrintPos (1, 1 + z);
if ( isNewFont() ) if ( isNewFont() )
print (fc::NF_border_line_left); // ⎸ print (fc::NF_border_line_left); // ⎸
if ( isMonochron() || max_color < 16 ) if ( isMonochron() || max_color < 16 )
print (fc::MediumShade); print (fc::MediumShade);
@ -348,9 +350,9 @@ void FScrollbar::drawBar()
for (; z < slider_pos; z++) for (; z < slider_pos; z++)
{ {
if ( isNewFont() ) if ( isNewFont() )
print (fc::NF_border_line_upper); // ¯ print (fc::NF_border_line_upper); // ¯
else if ( isMonochron() || max_color < 16 ) else if ( isMonochron() || max_color < 16 )
print (fc::MediumShade); // ▒ print (fc::MediumShade); // ▒
else else
print (' '); print (' ');
} }
@ -374,9 +376,9 @@ void FScrollbar::drawBar()
for (; z <= bar_length; z++) for (; z <= bar_length; z++)
{ {
if ( isNewFont() ) if ( isNewFont() )
print (fc::NF_border_line_upper); // ¯ print (fc::NF_border_line_upper); // ¯
else if ( isMonochron() || max_color < 16 ) else if ( isMonochron() || max_color < 16 )
print (fc::MediumShade); // ▒ print (fc::MediumShade); // ▒
else else
print (' '); print (' ');
} }
@ -638,7 +640,7 @@ FScrollbar::sType FScrollbar::getClickedScrollType (int x, int y)
} }
else if ( y == getHeight() ) else if ( y == getHeight() )
{ {
stype = FScrollbar::scrollStepForward; // increment button stype = FScrollbar::scrollStepForward; // increment button
} }
else else
stype = FScrollbar::noScroll; stype = FScrollbar::noScroll;

View File

@ -40,92 +40,92 @@
class FScrollbar : public FWidget class FScrollbar : public FWidget
{ {
public: public:
// Using-declarations // Using-declarations
using FWidget::setGeometry; using FWidget::setGeometry;
// Enumeration // Enumeration
enum sType enum sType
{ {
noScroll = 0, noScroll = 0,
scrollJump = 1, scrollJump = 1,
scrollStepBackward = 2, scrollStepBackward = 2,
scrollStepForward = 3, scrollStepForward = 3,
scrollPageBackward = 4, scrollPageBackward = 4,
scrollPageForward = 5, scrollPageForward = 5,
scrollWheelUp = 6, scrollWheelUp = 6,
scrollWheelDown = 7 scrollWheelDown = 7
}; };
// Constructors // Constructors
explicit FScrollbar(FWidget* = 0); explicit FScrollbar(FWidget* = 0);
FScrollbar (int = fc::vertical, FWidget* = 0); FScrollbar (int = fc::vertical, FWidget* = 0);
// Destructor // Destructor
virtual ~FScrollbar(); virtual ~FScrollbar();
// Accessors // Accessors
const char* getClassName() const; const char* getClassName() const;
int getValue() const; int getValue() const;
sType getScrollType() const; sType getScrollType() const;
// Mutators // Mutators
void setMinimum (int); void setMinimum (int);
void setMaximum (int); void setMaximum (int);
void setRange (int, int); void setRange (int, int);
void setValue (int); void setValue (int);
void setSteps (double); void setSteps (double);
void setPageSize (int, int); void setPageSize (int, int);
void setOrientation (int); void setOrientation (int);
void setGeometry (int, int, int, int, bool = true); void setGeometry (int, int, int, int, bool = true);
// Methods // Methods
void resize(); void resize();
void redraw(); void redraw();
void calculateSliderValues(); void calculateSliderValues();
void drawButtons(); void drawButtons();
void drawBar(); void drawBar();
// Event handlers // Event handlers
void onMouseDown (FMouseEvent*); void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*); void onMouseUp (FMouseEvent*);
void onMouseMove (FMouseEvent*); void onMouseMove (FMouseEvent*);
void onWheel (FWheelEvent*); void onWheel (FWheelEvent*);
void onTimer (FTimerEvent*); void onTimer (FTimerEvent*);
private: private:
// Disable copy constructor // Disable copy constructor
FScrollbar (const FScrollbar&); FScrollbar (const FScrollbar&);
// Disable assignment operator (=) // Disable assignment operator (=)
FScrollbar& operator = (const FScrollbar&); FScrollbar& operator = (const FScrollbar&);
// Methods // Methods
void init(); void init();
void draw(); void draw();
sType getClickedScrollType (int, int); sType getClickedScrollType (int, int);
void processMiddleButton (int, int); void processMiddleButton (int, int);
void processScroll(); void processScroll();
// Data Members // Data Members
sType scroll_type; sType scroll_type;
bool threshold_reached; bool threshold_reached;
int threshold_time; int threshold_time;
int repeat_time; int repeat_time;
int slider_click_pos; int slider_click_pos;
int slider_click_stop_pos; int slider_click_stop_pos;
int current_slider_pos; int current_slider_pos;
int slider_pos; int slider_pos;
int slider_length; int slider_length;
int bar_length; int bar_length;
int val; int val;
int min; int min;
int max; int max;
double steps; double steps;
int pageSize; int pageSize;
int length; int length;
int bar_orientation; int bar_orientation;
int max_color; int max_color;
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -13,7 +13,7 @@
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FScrollView::FScrollView (FWidget* parent) FScrollView::FScrollView (FWidget* parent)
: FWidget(parent) : FWidget(parent)
, scroll_geometry(1,1,1,1) , scroll_geometry(1, 1, 1, 1)
, viewport_geometry() , viewport_geometry()
, viewport(0) , viewport(0)
, vbar(0) , vbar(0)
@ -28,7 +28,7 @@ FScrollView::FScrollView (FWidget* parent)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FScrollView::~FScrollView() // destructor FScrollView::~FScrollView() // destructor
{ {
delete vbar; delete vbar;
delete hbar; delete hbar;
@ -96,6 +96,8 @@ void FScrollView::setScrollHeight (int height)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::setScrollSize (int width, int height) void FScrollView::setScrollSize (int width, int height)
{ {
int xoffset_end, yoffset_end;
if ( width < getViewportWidth() ) if ( width < getViewportWidth() )
width = getViewportWidth(); width = getViewportWidth();
@ -117,10 +119,12 @@ void FScrollView::setScrollSize (int width, int height)
child_print_area = viewport; child_print_area = viewport;
} }
xoffset_end = getScrollWidth() - getViewportWidth();
yoffset_end = getScrollHeight() - getViewportHeight();
setTopPadding (1 - getScrollY()); setTopPadding (1 - getScrollY());
setLeftPadding (1 - getScrollX()); setLeftPadding (1 - getScrollX());
setBottomPadding (1 - (getScrollHeight() - getViewportHeight() - getScrollY())); setBottomPadding (1 - (yoffset_end - getScrollY()));
setRightPadding (1 - (getScrollWidth() - getViewportWidth() - getScrollX()) + nf_offset); setRightPadding (1 - (xoffset_end - getScrollX()) + nf_offset);
hbar->setMaximum (width - getViewportWidth()); hbar->setMaximum (width - getViewportWidth());
hbar->setPageSize (width, getViewportWidth()); hbar->setPageSize (width, getViewportWidth());
@ -335,8 +339,8 @@ void FScrollView::scrollTo (int x, int y)
viewport->has_changes = true; viewport->has_changes = true;
setTopPadding (1 - yoffset); setTopPadding (1 - yoffset);
setLeftPadding (1 - xoffset); setLeftPadding (1 - xoffset);
setBottomPadding (1 - (getScrollHeight() - getViewportHeight() - yoffset)); setBottomPadding (1 - (yoffset_end - yoffset));
setRightPadding (1 - (getScrollWidth() - getViewportWidth() - xoffset) + nf_offset); setRightPadding (1 - (xoffset_end - xoffset) + nf_offset);
copy2area(); copy2area();
hbar->setValue (xoffset); hbar->setValue (xoffset);
vbar->setValue (yoffset); vbar->setValue (yoffset);
@ -468,8 +472,8 @@ void FScrollView::onKeyPress (FKeyEvent* ev)
viewport->has_changes = true; viewport->has_changes = true;
setTopPadding (1 - yoffset); setTopPadding (1 - yoffset);
setLeftPadding (1 - xoffset); setLeftPadding (1 - xoffset);
setBottomPadding (1 - (getScrollHeight() - getViewportHeight() - yoffset)); setBottomPadding (1 - (yoffset_end - yoffset));
setRightPadding (1 - (getScrollWidth() - getViewportWidth() - xoffset) + nf_offset); setRightPadding (1 - (xoffset_end - xoffset) + nf_offset);
copy2area(); copy2area();
hasChanges = true; hasChanges = true;
vbar->setValue (yoffset); vbar->setValue (yoffset);
@ -489,6 +493,7 @@ void FScrollView::onWheel (FWheelEvent* ev)
bool hasChanges = false; bool hasChanges = false;
short& yoffset = viewport_geometry.y1_ref(); short& yoffset = viewport_geometry.y1_ref();
short yoffset_before = yoffset; short yoffset_before = yoffset;
short yoffset_end = short(getScrollHeight() - getViewportHeight());
int save_height = viewport_geometry.getHeight(); int save_height = viewport_geometry.getHeight();
int wheel = ev->getWheel(); int wheel = ev->getWheel();
@ -507,8 +512,6 @@ void FScrollView::onWheel (FWheelEvent* ev)
case fc::WheelDown: case fc::WheelDown:
{ {
short yoffset_end = short(getScrollHeight() - getViewportHeight());
if ( yoffset_end < 0 ) if ( yoffset_end < 0 )
yoffset_end = 0; yoffset_end = 0;
@ -531,7 +534,7 @@ void FScrollView::onWheel (FWheelEvent* ev)
viewport_geometry.setHeight(save_height); viewport_geometry.setHeight(save_height);
viewport->has_changes = true; viewport->has_changes = true;
setTopPadding (1 - yoffset); setTopPadding (1 - yoffset);
setBottomPadding (1 - (getScrollHeight() - getViewportHeight() - yoffset)); setBottomPadding (1 - (yoffset_end - yoffset));
copy2area(); copy2area();
hasChanges = true; hasChanges = true;
vbar->setValue (yoffset); vbar->setValue (yoffset);
@ -712,8 +715,8 @@ void FScrollView::copy2area()
for (int y = 0; y < y_end; y++) // line loop for (int y = 0; y < y_end; y++) // line loop
{ {
char_data* vc; // viewport character char_data* vc; // viewport character
char_data* ac; // area character char_data* ac; // area character
int v_line_len = viewport->width; int v_line_len = viewport->width;
int a_line_len = print_area->width + print_area->right_shadow; int a_line_len = print_area->width + print_area->right_shadow;
vc = &viewport->text[(dy + y) * v_line_len + dx]; vc = &viewport->text[(dy + y) * v_line_len + dx];
@ -756,6 +759,8 @@ inline FPoint FScrollView::getViewportCursorPos()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::init (FWidget* parent) void FScrollView::init (FWidget* parent)
{ {
int xoffset_end, yoffset_end;
assert ( parent != 0 ); assert ( parent != 0 );
assert ( ! parent->isInstanceOf("FScrollView") ); assert ( ! parent->isInstanceOf("FScrollView") );
@ -792,11 +797,13 @@ void FScrollView::init (FWidget* parent)
F_METHOD_CALLBACK (this, &FScrollView::cb_HBarChange) F_METHOD_CALLBACK (this, &FScrollView::cb_HBarChange)
); );
xoffset_end = getScrollWidth() - getViewportWidth();
yoffset_end = getScrollHeight() - getViewportHeight();
nf_offset = isNewFont() ? 1 : 0; nf_offset = isNewFont() ? 1 : 0;
setTopPadding (1 - getScrollY()); setTopPadding (1 - getScrollY());
setLeftPadding (1 - getScrollX()); setLeftPadding (1 - getScrollX());
setBottomPadding (1 - (getScrollHeight() - getViewportHeight() - getScrollY())); setBottomPadding (1 - (yoffset_end - getScrollY()));
setRightPadding (1 - (getScrollWidth() - getViewportWidth() - getScrollX()) + nf_offset); setRightPadding (1 - (xoffset_end - getScrollX()) + nf_offset);
FPoint no_shadow(0,0); FPoint no_shadow(0,0);
int w = getViewportWidth(); int w = getViewportWidth();
@ -991,7 +998,7 @@ void FScrollView::cb_VBarChange (FWidget*, data_ptr)
viewport_geometry.setHeight(save_height); viewport_geometry.setHeight(save_height);
viewport->has_changes = true; viewport->has_changes = true;
setTopPadding (1 - yoffset); setTopPadding (1 - yoffset);
setBottomPadding (1 - (getScrollHeight() - getViewportHeight() - yoffset)); setBottomPadding (1 - (yoffset_end - yoffset));
copy2area(); copy2area();
hasChanges = true; hasChanges = true;
} }
@ -1096,7 +1103,7 @@ void FScrollView::cb_HBarChange (FWidget*, data_ptr)
viewport_geometry.setWidth(save_width); viewport_geometry.setWidth(save_width);
viewport->has_changes = true; viewport->has_changes = true;
setLeftPadding (1 - xoffset); setLeftPadding (1 - xoffset);
setRightPadding (1 - (getScrollWidth() - getViewportWidth() - xoffset) + nf_offset); setRightPadding (1 - (xoffset_end - xoffset) + nf_offset);
copy2area(); copy2area();
hasChanges = true; hasChanges = true;
} }

View File

@ -42,121 +42,121 @@
class FScrollView : public FWidget class FScrollView : public FWidget
{ {
public: public:
// Using-declaration // Using-declaration
using FWidget::setGeometry; using FWidget::setGeometry;
using FWidget::setPrintPos; using FWidget::setPrintPos;
using FWidget::setPos; using FWidget::setPos;
// Constructor // Constructor
explicit FScrollView (FWidget* = 0); explicit FScrollView (FWidget* = 0);
// Destructor // Destructor
virtual ~FScrollView(); virtual ~FScrollView();
// Accessors // Accessors
const char* getClassName() const; const char* getClassName() const;
int getViewportWidth() const; int getViewportWidth() const;
int getViewportHeight() const; int getViewportHeight() const;
int getScrollWidth() const; int getScrollWidth() const;
int getScrollHeight() const; int getScrollHeight() const;
const FPoint getScrollPos() const; const FPoint getScrollPos() const;
int getScrollX() const; int getScrollX() const;
int getScrollY() const; int getScrollY() const;
// Mutator // Mutator
virtual void setScrollWidth (int); virtual void setScrollWidth (int);
virtual void setScrollHeight (int); virtual void setScrollHeight (int);
virtual void setScrollSize (int, int); virtual void setScrollSize (int, int);
virtual void setX (int, bool = true); virtual void setX (int, bool = true);
virtual void setY (int, bool = true); virtual void setY (int, bool = true);
virtual void setPos (int, int, bool = true); virtual void setPos (int, int, bool = true);
virtual void setWidth (int, bool = true); virtual void setWidth (int, bool = true);
virtual void setHeight (int, bool = true); virtual void setHeight (int, bool = true);
virtual void setSize (int, int, bool = true); virtual void setSize (int, int, bool = true);
void setGeometry (int, int, int, int, bool = true); void setGeometry (int, int, int, int, bool = true);
void setCursorPos (register int, register int); void setCursorPos (register int, register int);
void setPrintPos (register int, register int); void setPrintPos (register int, register int);
bool setViewportPrint (bool); bool setViewportPrint (bool);
bool setViewportPrint(); bool setViewportPrint();
bool unsetViewportPrint(); bool unsetViewportPrint();
bool setBorder (bool); bool setBorder (bool);
bool setBorder(); bool setBorder();
bool unsetBorder(); bool unsetBorder();
void setHorizontalScrollBarMode (fc::scrollBarMode); void setHorizontalScrollBarMode (fc::scrollBarMode);
void setVerticalScrollBarMode (fc::scrollBarMode); void setVerticalScrollBarMode (fc::scrollBarMode);
// Inquiries // Inquiries
bool hasBorder(); bool hasBorder();
bool isViewportPrint(); bool isViewportPrint();
// Method // Method
virtual void clearArea (int = ' '); virtual void clearArea (int = ' ');
void scrollToX (int); void scrollToX (int);
void scrollToY (int); void scrollToY (int);
void scrollTo (const FPoint&); void scrollTo (const FPoint&);
void scrollTo (int, int); void scrollTo (int, int);
void scrollBy (int, int); void scrollBy (int, int);
virtual void draw(); virtual void draw();
// Event handlers // Event handlers
void onKeyPress (FKeyEvent*); void onKeyPress (FKeyEvent*);
void onWheel (FWheelEvent*); void onWheel (FWheelEvent*);
void onFocusIn (FFocusEvent*); void onFocusIn (FFocusEvent*);
void onChildFocusIn (FFocusEvent*); void onChildFocusIn (FFocusEvent*);
void onChildFocusOut (FFocusEvent*); void onChildFocusOut (FFocusEvent*);
protected: protected:
// Using-declaration // Using-declaration
using FVTerm::clearArea; using FVTerm::clearArea;
// Accessor // Accessor
term_area* getPrintArea(); term_area* getPrintArea();
// Method // Method
void adjustSize(); void adjustSize();
void copy2area(); void copy2area();
private: private:
// Constants // Constants
static const int vertical_border_spacing = 2; static const int vertical_border_spacing = 2;
static const int horizontal_border_spacing = 2; static const int horizontal_border_spacing = 2;
// Disable copy constructor // Disable copy constructor
FScrollView (const FScrollView&); FScrollView (const FScrollView&);
// Disable assignment operator (=) // Disable assignment operator (=)
FScrollView& operator = (const FScrollView&); FScrollView& operator = (const FScrollView&);
// Accessors // Accessors
FPoint getViewportCursorPos(); FPoint getViewportCursorPos();
// Methods // Methods
void init (FWidget*); void init (FWidget*);
void calculateScrollbarPos(); void calculateScrollbarPos();
void setHorizontalScrollBarVisibility(); void setHorizontalScrollBarVisibility();
void setVerticalScrollBarVisibility(); void setVerticalScrollBarVisibility();
void setViewportCursor(); void setViewportCursor();
void redrawHBar(); void redrawHBar();
void redrawVBar(); void redrawVBar();
void drawHBar(); void drawHBar();
void drawVBar(); void drawVBar();
// Callback methods // Callback methods
void cb_VBarChange (FWidget*, data_ptr); void cb_VBarChange (FWidget*, data_ptr);
void cb_HBarChange (FWidget*, data_ptr); void cb_HBarChange (FWidget*, data_ptr);
// Data Members // Data Members
FRect scroll_geometry; FRect scroll_geometry;
FRect viewport_geometry; FRect viewport_geometry;
term_area* viewport; // virtual scroll content term_area* viewport; // virtual scroll content
FScrollbar* vbar; FScrollbar* vbar;
FScrollbar* hbar; FScrollbar* hbar;
int nf_offset; int nf_offset;
bool border; bool border;
bool use_own_print_area; bool use_own_print_area;
fc::scrollBarMode vMode; // fc:Auto, fc::Hidden or fc::Scroll fc::scrollBarMode vMode; // fc:Auto, fc::Hidden or fc::Scroll
fc::scrollBarMode hMode; fc::scrollBarMode hMode;
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -2,6 +2,8 @@
// Provides: class FStatusKey // Provides: class FStatusKey
// class FStatusBar // class FStatusBar
#include <vector>
#include "fstatusbar.h" #include "fstatusbar.h"
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -84,7 +86,7 @@ bool FStatusKey::setMouseFocus(bool on)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FStatusKey::init (FWidget* parent) void FStatusKey::init (FWidget* parent)
{ {
setGeometry (1,1,1,1); setGeometry (1, 1, 1, 1);
if ( parent && parent->isInstanceOf("FStatusBar") ) if ( parent && parent->isInstanceOf("FStatusBar") )
{ {
@ -120,7 +122,7 @@ FStatusBar::FStatusBar(FWidget* parent)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FStatusBar::~FStatusBar() FStatusBar::~FStatusBar() // destructor
{ {
// delete all keys // delete all keys
if ( ! key_list.empty() ) if ( ! key_list.empty() )

View File

@ -36,6 +36,8 @@
#ifndef FSTATUSBAR_H #ifndef FSTATUSBAR_H
#define FSTATUSBAR_H #define FSTATUSBAR_H
#include <vector>
#include "fwindow.h" #include "fwindow.h"
@ -51,60 +53,60 @@ class FStatusBar;
class FStatusKey : public FWidget class FStatusKey : public FWidget
{ {
public: public:
// Constructors // Constructors
explicit FStatusKey (FWidget* = 0); explicit FStatusKey (FWidget* = 0);
FStatusKey (int, const FString&, FWidget* = 0); FStatusKey (int, const FString&, FWidget* = 0);
// Destructor // Destructor
virtual ~FStatusKey(); virtual ~FStatusKey();
// Accessors // Accessors
virtual const char* getClassName() const; virtual const char* getClassName() const;
virtual int getKey() const; virtual int getKey() const;
virtual FString getText() const; virtual FString getText() const;
// Mutators // Mutators
void setActive(); void setActive();
void unsetActive(); void unsetActive();
bool setMouseFocus(bool); bool setMouseFocus(bool);
bool setMouseFocus(); bool setMouseFocus();
bool unsetMouseFocus(); bool unsetMouseFocus();
// Inquiry // Inquiry
bool isActivated() const; bool isActivated() const;
bool hasMouseFocus() const; bool hasMouseFocus() const;
// Event handler // Event handler
void onAccel (FAccelEvent*); void onAccel (FAccelEvent*);
protected: protected:
// Mutators // Mutators
void setKey (int); void setKey (int);
void setText (const FString&); void setText (const FString&);
private: private:
// Disable copy constructor // Disable copy constructor
FStatusKey (const FStatusKey&); FStatusKey (const FStatusKey&);
// Disable assignment operator (=) // Disable assignment operator (=)
FStatusKey& operator = (const FStatusKey&); FStatusKey& operator = (const FStatusKey&);
// Methods // Methods
void init (FWidget*); void init (FWidget*);
void processActivate(); void processActivate();
FStatusBar* getConnectedStatusbar() const; FStatusBar* getConnectedStatusbar() const;
void setConnectedStatusbar (FStatusBar*); void setConnectedStatusbar (FStatusBar*);
// Friend class // Friend class
friend class FStatusBar; friend class FStatusBar;
// Data Members // Data Members
int key; int key;
FString text; FString text;
bool active; bool active;
bool mouse_focus; bool mouse_focus;
FStatusBar* bar; FStatusBar* bar;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -168,67 +170,67 @@ inline void FStatusKey::setConnectedStatusbar (FStatusBar* sb)
class FStatusBar : public FWindow class FStatusBar : public FWindow
{ {
public: public:
// Constructor // Constructor
explicit FStatusBar (FWidget* = 0); explicit FStatusBar (FWidget* = 0);
// Destructor // Destructor
virtual ~FStatusBar(); virtual ~FStatusBar();
// Accessors // Accessors
virtual const char* getClassName() const; virtual const char* getClassName() const;
FStatusKey* getStatusKey (int) const; FStatusKey* getStatusKey (int) const;
FString getMessage() const; FString getMessage() const;
uInt getCount() const; uInt getCount() const;
// Mutators // Mutators
void activateKey (int); void activateKey (int);
void deactivateKey (int); void deactivateKey (int);
void setMessage (const FString&); void setMessage (const FString&);
// Inquiries // Inquiries
bool isActivated (int) const; bool isActivated (int) const;
bool hasActivatedKey(); bool hasActivatedKey();
// Methods // Methods
void hide(); void hide();
void drawMessage(); void drawMessage();
void clearMessage(); void clearMessage();
void insert (FStatusKey*); void insert (FStatusKey*);
void remove (FStatusKey*); void remove (FStatusKey*);
void remove (int); void remove (int);
void clear(); void clear();
void adjustSize(); void adjustSize();
// Event handlers // Event handlers
void onMouseDown (FMouseEvent*); void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*); void onMouseUp (FMouseEvent*);
void onMouseMove (FMouseEvent*); void onMouseMove (FMouseEvent*);
// Callback method // Callback method
void cb_statuskey_activated (FWidget*, data_ptr); void cb_statuskey_activated (FWidget*, data_ptr);
private: private:
// Typedef // Typedef
typedef std::vector<FStatusKey*> keyList; typedef std::vector<FStatusKey*> keyList;
// Disable copy constructor // Disable copy constructor
FStatusBar (const FStatusBar&); FStatusBar (const FStatusBar&);
// Disable assignment operator (=) // Disable assignment operator (=)
FStatusBar& operator = (const FStatusBar&); FStatusBar& operator = (const FStatusBar&);
// Methods // Methods
void init(); void init();
void draw(); void draw();
void drawKeys(); void drawKeys();
// Data Members // Data Members
keyList key_list; keyList key_list;
FString text; FString text;
bool mouse_down; bool mouse_down;
int x; int x;
int x_msg; int x_msg;
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -1,6 +1,9 @@
// File: fstring.cpp // File: fstring.cpp
// Provides: class FString // Provides: class FString
#include <string>
#include <vector>
#include "fstring.h" #include "fstring.h"
// static class constant // static class constant
@ -500,12 +503,12 @@ uInt FString::getUTF8length() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FString& FString::sprintf (const wchar_t* format, ...) FString& FString::sprintf (const wchar_t* format, ...)
{ {
static const int buf_size = 4096; static const int BUFSIZE = 4096;
wchar_t buffer[buf_size]; wchar_t buffer[BUFSIZE];
va_list args; va_list args;
va_start (args, format); va_start (args, format);
std::vswprintf (buffer, buf_size, format, args); std::vswprintf (buffer, BUFSIZE, format, args);
va_end (args); va_end (args);
_assign (buffer); _assign (buffer);
@ -578,7 +581,7 @@ const wchar_t* FString::wc_str() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const char* FString::c_str() const const char* FString::c_str() const
{ {
if ( string ) if ( length > 0 )
return wc_to_c_str (string); return wc_to_c_str (string);
else else
return 0; return 0;
@ -808,7 +811,7 @@ double FString::toDouble() const
if ( ret >= HUGE_VAL || ret <= -HUGE_VAL ) if ( ret >= HUGE_VAL || ret <= -HUGE_VAL )
throw std::overflow_error ("overflow"); throw std::overflow_error ("overflow");
if ( std::fabs(ret) < DBL_EPSILON ) // ret == 0.0l if ( std::fabs(ret) < DBL_EPSILON ) // ret == 0.0l
throw std::underflow_error ("underflow"); throw std::underflow_error ("underflow");
} }
@ -1155,7 +1158,6 @@ FString& FString::setFormatedNumber (uLong num, char separator)
if ( num && ++n % 3 == 0 ) if ( num && ++n % 3 == 0 )
*--s = separator; *--s = separator;
} }
while ( num ); while ( num );

View File

@ -40,290 +40,290 @@
class FString class FString
{ {
public: public:
// Typedef // Typedef
typedef const wchar_t* iterator; typedef const wchar_t* iterator;
// Constructors // Constructors
FString (); FString ();
explicit FString (int); explicit FString (int);
explicit FString (uInt); explicit FString (uInt);
FString (int, wchar_t); FString (int, wchar_t);
FString (uInt, wchar_t); FString (uInt, wchar_t);
FString (int, char); FString (int, char);
FString (uInt, char); FString (uInt, char);
FString (const FString&); // implicit conversion copy constructor FString (const FString&); // implicit conversion copy constructor
FString (const std::wstring&); // implicit conversion constructor FString (const std::wstring&); // implicit conversion constructor
FString (const wchar_t*); // implicit conversion constructor FString (const wchar_t*); // implicit conversion constructor
FString (const std::string&); // implicit conversion constructor FString (const std::string&); // implicit conversion constructor
FString (const char*); // implicit conversion constructor FString (const char*); // implicit conversion constructor
FString (const wchar_t); // implicit conversion constructor FString (const wchar_t); // implicit conversion constructor
FString (const char); // implicit conversion constructor FString (const char); // implicit conversion constructor
// Destructor // Destructor
virtual ~FString (); virtual ~FString ();
// Overloaded operators // Overloaded operators
FString& operator = (const FString&); FString& operator = (const FString&);
FString& operator = (const std::wstring&); FString& operator = (const std::wstring&);
const FString& operator = (const wchar_t*); const FString& operator = (const wchar_t*);
FString& operator = (const std::string&); FString& operator = (const std::string&);
const FString& operator = (const char*); const FString& operator = (const char*);
const FString& operator = (const wchar_t); const FString& operator = (const wchar_t);
const FString& operator = (const char); const FString& operator = (const char);
const FString& operator += (const FString&); const FString& operator += (const FString&);
const FString& operator += (const std::wstring&); const FString& operator += (const std::wstring&);
const FString& operator += (const wchar_t*); const FString& operator += (const wchar_t*);
const FString& operator += (const std::string&); const FString& operator += (const std::string&);
const FString& operator += (const char*); const FString& operator += (const char*);
const FString& operator += (const wchar_t); const FString& operator += (const wchar_t);
const FString& operator += (const char); const FString& operator += (const char);
const FString operator + (const FString&); const FString operator + (const FString&);
const FString operator + (const std::wstring&); const FString operator + (const std::wstring&);
const FString operator + (const wchar_t*); const FString operator + (const wchar_t*);
const FString operator + (const std::string&); const FString operator + (const std::string&);
const FString operator + (const char*); const FString operator + (const char*);
const FString operator + (const wchar_t); const FString operator + (const wchar_t);
const FString operator + (const char); const FString operator + (const char);
wchar_t& operator [] (int); wchar_t& operator [] (int);
wchar_t& operator [] (uInt); wchar_t& operator [] (uInt);
const FString& operator () (); const FString& operator () ();
bool operator < (const FString&) const; bool operator < (const FString&) const;
bool operator < (const std::wstring&) const; bool operator < (const std::wstring&) const;
bool operator < (const wchar_t*) const; bool operator < (const wchar_t*) const;
bool operator < (const std::string&) const; bool operator < (const std::string&) const;
bool operator < (const char*) const; bool operator < (const char*) const;
bool operator < (const wchar_t) const; bool operator < (const wchar_t) const;
bool operator < (const char) const; bool operator < (const char) const;
bool operator <= (const FString&) const; bool operator <= (const FString&) const;
bool operator <= (const std::wstring&) const; bool operator <= (const std::wstring&) const;
bool operator <= (const wchar_t*) const; bool operator <= (const wchar_t*) const;
bool operator <= (const std::string&) const; bool operator <= (const std::string&) const;
bool operator <= (const char*) const; bool operator <= (const char*) const;
bool operator <= (const wchar_t) const; bool operator <= (const wchar_t) const;
bool operator <= (const char) const; bool operator <= (const char) const;
bool operator == (const FString&) const; bool operator == (const FString&) const;
bool operator == (const std::wstring&) const; bool operator == (const std::wstring&) const;
bool operator == (const wchar_t*) const; bool operator == (const wchar_t*) const;
bool operator == (const std::string&) const; bool operator == (const std::string&) const;
bool operator == (const char*) const; bool operator == (const char*) const;
bool operator == (const wchar_t) const; bool operator == (const wchar_t) const;
bool operator == (const char) const; bool operator == (const char) const;
bool operator != (const FString&) const; bool operator != (const FString&) const;
bool operator != (const std::wstring&) const; bool operator != (const std::wstring&) const;
bool operator != (const wchar_t*) const; bool operator != (const wchar_t*) const;
bool operator != (const std::string&) const; bool operator != (const std::string&) const;
bool operator != (const char*) const; bool operator != (const char*) const;
bool operator != (const wchar_t) const; bool operator != (const wchar_t) const;
bool operator != (const char) const; bool operator != (const char) const;
bool operator >= (const FString&) const; bool operator >= (const FString&) const;
bool operator >= (const std::wstring&) const; bool operator >= (const std::wstring&) const;
bool operator >= (const wchar_t*) const; bool operator >= (const wchar_t*) const;
bool operator >= (const std::string&) const; bool operator >= (const std::string&) const;
bool operator >= (const char*) const; bool operator >= (const char*) const;
bool operator >= (const wchar_t) const; bool operator >= (const wchar_t) const;
bool operator >= (const char) const; bool operator >= (const char) const;
bool operator > (const FString&) const; bool operator > (const FString&) const;
bool operator > (const std::wstring&) const; bool operator > (const std::wstring&) const;
bool operator > (const wchar_t*) const; bool operator > (const wchar_t*) const;
bool operator > (const std::string&) const; bool operator > (const std::string&) const;
bool operator > (const char*) const; bool operator > (const char*) const;
bool operator > (const wchar_t) const; bool operator > (const wchar_t) const;
bool operator > (const char) const; bool operator > (const char) const;
operator const char* () const { return c_str(); } operator const char* () const { return c_str(); }
// Non-member operators // Non-member operators
friend std::ostream& operator << (std::ostream& outstr, const FString& s); friend std::ostream& operator << (std::ostream& outstr, const FString& s);
friend std::istream& operator >> (std::istream& instr, FString& s); friend std::istream& operator >> (std::istream& instr, FString& s);
friend std::wostream& operator << (std::wostream& outstr, const FString& s); friend std::wostream& operator << (std::wostream& outstr, const FString& s);
friend std::wistream& operator >> (std::wistream& instr, FString& s); friend std::wistream& operator >> (std::wistream& instr, FString& s);
friend const FString operator + (const FString&, const FString&); friend const FString operator + (const FString&, const FString&);
friend const FString operator + (const FString&, const wchar_t); friend const FString operator + (const FString&, const wchar_t);
friend const FString operator + (const std::wstring&, const FString&); friend const FString operator + (const std::wstring&, const FString&);
friend const FString operator + (const wchar_t*, const FString&); friend const FString operator + (const wchar_t*, const FString&);
friend const FString operator + (const std::string&, const FString&); friend const FString operator + (const std::string&, const FString&);
friend const FString operator + (const char*, const FString&); friend const FString operator + (const char*, const FString&);
friend const FString operator + (const wchar_t, const FString&); friend const FString operator + (const wchar_t, const FString&);
friend const FString operator + (const char, const FString&); friend const FString operator + (const char, const FString&);
friend const FString operator + (const wchar_t, const std::wstring&); friend const FString operator + (const wchar_t, const std::wstring&);
// inquiries // inquiries
bool isNull() const; bool isNull() const;
bool isEmpty() const; bool isEmpty() const;
// Methods // Methods
uInt getLength() const; uInt getLength() const;
uInt getUTF8length() const; uInt getUTF8length() const;
iterator begin() const; iterator begin() const;
iterator end() const; iterator end() const;
wchar_t front() const; wchar_t front() const;
wchar_t back() const; wchar_t back() const;
FString& sprintf (const wchar_t*, ...); FString& sprintf (const wchar_t*, ...);
FString& sprintf (const char*, ...) FString& sprintf (const char*, ...)
#if defined(__clang__) #if defined(__clang__)
__attribute__((__format__ (__printf__, 2, 3))) __attribute__((__format__ (__printf__, 2, 3)))
#elif defined(__GNUC__) #elif defined(__GNUC__)
__attribute__ ((format (printf, 2, 3))) __attribute__ ((format (printf, 2, 3)))
#endif #endif
; ;
FString clear(); FString clear();
const wchar_t* wc_str() const; const wchar_t* wc_str() const;
const char* c_str() const; const char* c_str() const;
const std::string toString() const; const std::string toString() const;
FString toLower() const; FString toLower() const;
FString toUpper() const; FString toUpper() const;
sInt16 toShort() const; sInt16 toShort() const;
uInt16 toUShort() const; uInt16 toUShort() const;
int toInt() const; int toInt() const;
uInt toUInt() const; uInt toUInt() const;
long toLong() const; long toLong() const;
uLong toULong() const; uLong toULong() const;
float toFloat() const; float toFloat() const;
double toDouble() const; double toDouble() const;
FString ltrim() const; FString ltrim() const;
FString rtrim() const; FString rtrim() const;
FString trim() const; FString trim() const;
FString left (int) const; FString left (int) const;
FString left (uInt) const; FString left (uInt) const;
FString right (int) const; FString right (int) const;
FString right (uInt) const; FString right (uInt) const;
FString mid (int, int) const; FString mid (int, int) const;
FString mid (uInt, uInt) const; FString mid (uInt, uInt) const;
std::vector<FString> split (const FString&); std::vector<FString> split (const FString&);
std::vector<FString> split (std::wstring&); std::vector<FString> split (const std::wstring&);
std::vector<FString> split (const wchar_t*); std::vector<FString> split (const wchar_t*);
std::vector<FString> split (const std::string&); std::vector<FString> split (const std::string&);
std::vector<FString> split (const char*); std::vector<FString> split (const char*);
std::vector<FString> split (const wchar_t); std::vector<FString> split (const wchar_t);
std::vector<FString> split (const char); std::vector<FString> split (const char);
FString& setString (const wchar_t*); FString& setString (const wchar_t*);
FString& setString (const char*); FString& setString (const char*);
FString& setNumber (sInt16); FString& setNumber (sInt16);
FString& setNumber (uInt16); FString& setNumber (uInt16);
FString& setNumber (int); FString& setNumber (int);
FString& setNumber (uInt); FString& setNumber (uInt);
FString& setNumber (long); FString& setNumber (long);
FString& setNumber (uLong); FString& setNumber (uLong);
FString& setNumber (float, int = 8); FString& setNumber (float, int = 8);
FString& setNumber (double, int = 11); FString& setNumber (double, int = 11);
FString& setNumber (lDouble, int = 11); FString& setNumber (lDouble, int = 11);
FString& setFormatedNumber (sInt16, char = nl_langinfo(THOUSEP)[0]); FString& setFormatedNumber (sInt16, char = nl_langinfo(THOUSEP)[0]);
FString& setFormatedNumber (uInt16, char = nl_langinfo(THOUSEP)[0]); FString& setFormatedNumber (uInt16, char = nl_langinfo(THOUSEP)[0]);
FString& setFormatedNumber (int, char = nl_langinfo(THOUSEP)[0]); FString& setFormatedNumber (int, char = nl_langinfo(THOUSEP)[0]);
FString& setFormatedNumber (uInt, char = nl_langinfo(THOUSEP)[0]); FString& setFormatedNumber (uInt, char = nl_langinfo(THOUSEP)[0]);
FString& setFormatedNumber (long, char = nl_langinfo(THOUSEP)[0]); FString& setFormatedNumber (long, char = nl_langinfo(THOUSEP)[0]);
FString& setFormatedNumber (uLong, char = nl_langinfo(THOUSEP)[0]); FString& setFormatedNumber (uLong, char = nl_langinfo(THOUSEP)[0]);
const FString& insert (const FString&, uInt); const FString& insert (const FString&, uInt);
const FString& insert (const wchar_t*, uInt); const FString& insert (const wchar_t*, uInt);
const FString& insert (const char*, uInt); const FString& insert (const char*, uInt);
const FString& insert (const wchar_t, uInt); const FString& insert (const wchar_t, uInt);
const FString& insert (const char, uInt); const FString& insert (const char, uInt);
FString replace (const FString&, const FString&); FString replace (const FString&, const FString&);
FString replace (const FString&, const std::wstring&); FString replace (const FString&, const std::wstring&);
FString replace (const FString&, const wchar_t*); FString replace (const FString&, const wchar_t*);
FString replace (const FString&, const std::string&); FString replace (const FString&, const std::string&);
FString replace (const FString&, const char*); FString replace (const FString&, const char*);
FString replace (const FString&, const wchar_t); FString replace (const FString&, const wchar_t);
FString replace (const FString&, const char); FString replace (const FString&, const char);
FString replace (const std::wstring&, const FString&); FString replace (const std::wstring&, const FString&);
FString replace (const std::wstring&, const std::wstring&); FString replace (const std::wstring&, const std::wstring&);
FString replace (const std::wstring&, const wchar_t*); FString replace (const std::wstring&, const wchar_t*);
FString replace (const std::wstring&, const std::string&); FString replace (const std::wstring&, const std::string&);
FString replace (const std::wstring&, const char*); FString replace (const std::wstring&, const char*);
FString replace (const std::wstring&, const wchar_t); FString replace (const std::wstring&, const wchar_t);
FString replace (const std::wstring&, const char); FString replace (const std::wstring&, const char);
FString replace (const std::string&, const FString&); FString replace (const std::string&, const FString&);
FString replace (const std::string&, const std::wstring&); FString replace (const std::string&, const std::wstring&);
FString replace (const std::string&, const wchar_t*); FString replace (const std::string&, const wchar_t*);
FString replace (const std::string&, const std::string&); FString replace (const std::string&, const std::string&);
FString replace (const std::string&, const char*); FString replace (const std::string&, const char*);
FString replace (const std::string&, const wchar_t); FString replace (const std::string&, const wchar_t);
FString replace (const std::string&, const char); FString replace (const std::string&, const char);
FString replace (const wchar_t*, const FString&); FString replace (const wchar_t*, const FString&);
FString replace (const wchar_t*, const std::wstring&); FString replace (const wchar_t*, const std::wstring&);
FString replace (const wchar_t*, const wchar_t*); FString replace (const wchar_t*, const wchar_t*);
FString replace (const wchar_t*, const std::string&); FString replace (const wchar_t*, const std::string&);
FString replace (const wchar_t*, const char*); FString replace (const wchar_t*, const char*);
FString replace (const wchar_t*, const wchar_t); FString replace (const wchar_t*, const wchar_t);
FString replace (const wchar_t*, const char); FString replace (const wchar_t*, const char);
FString replace (const char*, const FString&); FString replace (const char*, const FString&);
FString replace (const char*, const std::wstring&); FString replace (const char*, const std::wstring&);
FString replace (const char*, const wchar_t*); FString replace (const char*, const wchar_t*);
FString replace (const char*, const std::string&); FString replace (const char*, const std::string&);
FString replace (const char*, const char*); FString replace (const char*, const char*);
FString replace (const char*, const wchar_t); FString replace (const char*, const wchar_t);
FString replace (const char*, const char); FString replace (const char*, const char);
FString replace (const wchar_t, const FString&); FString replace (const wchar_t, const FString&);
FString replace (const wchar_t, const std::wstring&); FString replace (const wchar_t, const std::wstring&);
FString replace (const wchar_t, const wchar_t*); FString replace (const wchar_t, const wchar_t*);
FString replace (const wchar_t, const std::string&); FString replace (const wchar_t, const std::string&);
FString replace (const wchar_t, const char*); FString replace (const wchar_t, const char*);
FString replace (const wchar_t, const wchar_t); FString replace (const wchar_t, const wchar_t);
FString replace (const wchar_t, const char); FString replace (const wchar_t, const char);
FString replace (const char, const FString&); FString replace (const char, const FString&);
FString replace (const char, const std::wstring&); FString replace (const char, const std::wstring&);
FString replace (const char, const wchar_t*); FString replace (const char, const wchar_t*);
FString replace (const char, const std::string&); FString replace (const char, const std::string&);
FString replace (const char, const char*); FString replace (const char, const char*);
FString replace (const char, const wchar_t); FString replace (const char, const wchar_t);
FString replace (const char, const char); FString replace (const char, const char);
FString replaceControlCodes() const; FString replaceControlCodes() const;
FString expandTabs (int = 8) const; FString expandTabs (int = 8) const;
FString removeDel() const; FString removeDel() const;
FString removeBackspaces() const; FString removeBackspaces() const;
const FString& overwrite (const FString&, uInt); const FString& overwrite (const FString&, uInt);
const FString& overwrite (const wchar_t*, uInt); const FString& overwrite (const wchar_t*, uInt);
const FString& overwrite (const wchar_t, uInt); const FString& overwrite (const wchar_t, uInt);
const FString& remove (uInt, uInt); const FString& remove (uInt, uInt);
bool includes (const FString&); bool includes (const FString&);
bool includes (const wchar_t*); bool includes (const wchar_t*);
bool includes (const char*); bool includes (const char*);
bool includes (const wchar_t); bool includes (const wchar_t);
bool includes (const char); bool includes (const char);
private: private:
// Constants // Constants
static const uInt FWDBUFFER = 15; static const uInt FWDBUFFER = 15;
static const uInt INPBUFFER = 200; static const uInt INPBUFFER = 200;
static const uInt CHAR_SIZE = sizeof(wchar_t); // bytes per character static const uInt CHAR_SIZE = sizeof(wchar_t); // bytes per character
static const char* const bad_alloc_str; static const char* const bad_alloc_str;
// Methods // Methods
void initLength (uInt); void initLength (uInt);
void _assign (const wchar_t*); void _assign (const wchar_t*);
void _insert (uInt, uInt, const wchar_t*); void _insert (uInt, uInt, const wchar_t*);
void _remove (uInt, uInt); void _remove (uInt, uInt);
char* wc_to_c_str (const wchar_t*) const; char* wc_to_c_str (const wchar_t*) const;
wchar_t* c_to_wc_str (const char*) const; wchar_t* c_to_wc_str (const char*) const;
wchar_t* extractToken (wchar_t**, const wchar_t*, const wchar_t*); wchar_t* extractToken (wchar_t**, const wchar_t*, const wchar_t*);
// Data Members // Data Members
wchar_t* string; wchar_t* string;
uInt length; uInt length;
uInt bufsize; uInt bufsize;
mutable char* c_string; mutable char* c_string;
}; };
@ -363,7 +363,7 @@ inline wchar_t FString::back() const
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline std::vector<FString> FString::split (std::wstring& s) inline std::vector<FString> FString::split (const std::wstring& s)
{ return split(FString(s)); } { return split(FString(s)); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -45,39 +45,39 @@
class FSwitch : public FToggleButton class FSwitch : public FToggleButton
{ {
public: public:
// Constructors // Constructors
explicit FSwitch (FWidget* = 0); explicit FSwitch (FWidget* = 0);
FSwitch (const FString&, FWidget* = 0); FSwitch (const FString&, FWidget* = 0);
// Destructor // Destructor
virtual ~FSwitch(); virtual ~FSwitch();
// Accessor // Accessor
const char* getClassName() const; const char* getClassName() const;
// Mutator // Mutator
void setText (const FString&); void setText (const FString&);
// Event handlers // Event handlers
void onKeyPress (FKeyEvent*); void onKeyPress (FKeyEvent*);
void onMouseDown (FMouseEvent*); void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*); void onMouseUp (FMouseEvent*);
private: private:
// Disable copy constructor // Disable copy constructor
FSwitch (const FSwitch&); FSwitch (const FSwitch&);
// Disable assignment operator (=) // Disable assignment operator (=)
FSwitch& operator = (const FSwitch&); FSwitch& operator = (const FSwitch&);
// Methods // Methods
void draw(); void draw();
void drawCheckButton(); void drawCheckButton();
// Data Members // Data Members
int switch_offset_pos; int switch_offset_pos;
bool button_pressed; bool button_pressed;
}; };
#pragma pack(pop) #pragma pack(pop)

File diff suppressed because it is too large Load Diff

View File

@ -34,9 +34,9 @@
#endif #endif
#if defined(__linux__) #if defined(__linux__)
#include <linux/fb.h> // Linux framebuffer console #include <linux/fb.h> // Linux framebuffer console
#include <linux/keyboard.h> // need for gpm keyboard modifiers #include <linux/keyboard.h> // need for gpm keyboard modifiers
#include <sys/io.h> // <asm/io.h> is deprecated, use <sys/io.h> instead #include <sys/io.h> // <asm/io.h> is deprecated
#include <sys/kd.h> #include <sys/kd.h>
#endif #endif
@ -53,10 +53,9 @@
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <langinfo.h> #include <langinfo.h>
#include <term.h> // termcap #include <term.h> // termcap
#include <termios.h> #include <termios.h>
#include <ttyent.h> #include <ttyent.h>
#include <unistd.h> #include <unistd.h>
@ -66,6 +65,7 @@
#include <csignal> #include <csignal>
#include <map> #include <map>
#include <queue> #include <queue>
#include <string>
#include "fc.h" #include "fc.h"
#include "fobject.h" #include "fobject.h"
@ -91,397 +91,398 @@
class FTerm class FTerm
{ {
public: public:
// Typedefs // Typedefs
typedef FOptiAttr::char_data char_data; typedef FOptiAttr::char_data char_data;
static struct modifier_key // bit field static struct modifier_key // bit field
{ {
uChar shift : 1; // 0..1 uChar shift : 1; // 0..1
uChar alt_gr : 1; // 0..1 uChar alt_gr : 1; // 0..1
uChar ctrl : 1; // 0..1 uChar ctrl : 1; // 0..1
uChar alt : 1; // 0..1 uChar alt : 1; // 0..1
uChar : 4; // padding bits uChar : 4; // padding bits
} mod_key; } mod_key;
// Constructor // Constructor
explicit FTerm (bool = false); explicit FTerm (bool = false);
// Destructor // Destructor
virtual ~FTerm(); virtual ~FTerm();
// Accessors // Accessors
virtual const char* getClassName() const; virtual const char* getClassName() const;
static termios getTTY(); static termios getTTY();
static int getLineNumber(); static int getLineNumber();
static int getColumnNumber(); static int getColumnNumber();
static const FString getKeyName (int); static const FString getKeyName (int);
#if defined(__linux__) #if defined(__linux__)
static modifier_key& getLinuxModifierKey(); static modifier_key& getLinuxModifierKey();
#endif #endif
static char* getTermType(); static char* getTermType();
static char* getTermName(); static char* getTermName();
static int getTabstop(); static int getTabstop();
static int getMaxColor(); static int getMaxColor();
#if defined(__linux__) #if defined(__linux__)
static fc::linuxConsoleCursorStyle getLinuxConsoleCursorStyle(); static fc::linuxConsoleCursorStyle getLinuxConsoleCursorStyle();
#endif #endif
#if defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__DragonFly__)
static fc::freebsdConsoleCursorStyle getFreeBSDConsoleCursorStyle(); static fc::freebsdConsoleCursorStyle getFreeBSDConsoleCursorStyle();
#endif #endif
#if DEBUG #if DEBUG
static const FString& getAnswerbackString(); static const FString& getAnswerbackString();
static const FString& getSecDAString(); static const FString& getSecDAString();
#endif #endif
// Inquiries // Inquiries
static bool isKeyTimeout (timeval*, register long); static bool isKeyTimeout (timeval*, register long);
static bool isNormal (char_data*&); static bool isNormal (char_data*&);
static bool isRaw(); static bool isRaw();
static bool hasPCcharset(); static bool hasPCcharset();
static bool hasUTF8(); static bool hasUTF8();
static bool hasVT100(); static bool hasVT100();
static bool hasASCII(); static bool hasASCII();
static bool isMonochron(); static bool isMonochron();
static bool isXTerminal(); static bool isXTerminal();
static bool isAnsiTerminal(); static bool isAnsiTerminal();
static bool isRxvtTerminal(); static bool isRxvtTerminal();
static bool isUrxvtTerminal(); static bool isUrxvtTerminal();
static bool isMltermTerminal(); static bool isMltermTerminal();
static bool isPuttyTerminal(); static bool isPuttyTerminal();
static bool isKdeTerminal(); static bool isKdeTerminal();
static bool isGnomeTerminal(); static bool isGnomeTerminal();
static bool isKtermTerminal(); static bool isKtermTerminal();
static bool isTeraTerm(); static bool isTeraTerm();
static bool isCygwinTerminal(); static bool isCygwinTerminal();
static bool isMinttyTerm(); static bool isMinttyTerm();
static bool isLinuxTerm(); static bool isLinuxTerm();
static bool isScreenTerm(); static bool isScreenTerm();
static bool isTmuxTerm(); static bool isTmuxTerm();
static bool isInputDataPending(); static bool isInputDataPending();
static bool isNewFont(); static bool isNewFont();
static bool isUTF8(); static bool isUTF8();
static bool isUTF8_linux_terminal(); static bool isUTF8_linux_terminal();
// Mutators // Mutators
static bool setCursorOptimisation (bool); static bool setCursorOptimisation (bool);
static void setXTermDefaultColors (bool); static void setXTermDefaultColors (bool);
#if defined(__linux__) #if defined(__linux__)
static void setLinuxConsoleCursorStyle ( fc::linuxConsoleCursorStyle static void setLinuxConsoleCursorStyle \
, bool ); (fc::linuxConsoleCursorStyle, bool);
#endif #endif
#if defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__DragonFly__)
static void setFreeBSDConsoleCursorStyle ( fc::freebsdConsoleCursorStyle static void setFreeBSDConsoleCursorStyle \
, bool ); (fc::freebsdConsoleCursorStyle, bool);
#endif #endif
static void setTTY (termios&); static void setTTY (const termios&);
static void noHardwareEcho(); static void noHardwareEcho();
static bool setRawMode (bool); static bool setRawMode (bool);
static bool setRawMode(); static bool setRawMode();
static bool unsetRawMode(); static bool unsetRawMode();
static bool setCookedMode(); static bool setCookedMode();
static void disableAltScreen(); static void disableAltScreen();
static bool setUTF8 (bool); static bool setUTF8 (bool);
static bool setUTF8(); static bool setUTF8();
static bool unsetUTF8(); static bool unsetUTF8();
static bool setNonBlockingInput (bool); static bool setNonBlockingInput (bool);
static bool setNonBlockingInput(); static bool setNonBlockingInput();
static bool unsetNonBlockingInput(); static bool unsetNonBlockingInput();
// Methods // Methods
static int parseKeyString (char[], int, timeval*); static int parseKeyString (char[], int, timeval*);
static bool& unprocessedInput(); static bool& unprocessedInput();
static bool setVGAFont(); static bool setVGAFont();
static bool setNewFont(); static bool setNewFont();
static bool setOldFont(); static bool setOldFont();
static char* moveCursor (int, int, int, int); static char* moveCursor (int, int, int, int);
static void printMoveDurations(); static void printMoveDurations();
static char* enableCursor(); static char* enableCursor();
static char* disableCursor(); static char* disableCursor();
static void detectTermSize(); static void detectTermSize();
static void setTermSize (int, int); static void setTermSize (int, int);
static void setKDECursor (fc::kdeKonsoleCursorShape); static void setKDECursor (fc::kdeKonsoleCursorShape);
static const FString* getXTermFont(); static const FString* getXTermFont();
static const FString* getXTermTitle(); static const FString* getXTermTitle();
static const FString getXTermColorName (int); static const FString getXTermColorName (int);
static void setXTermCursorStyle (fc::xtermCursorStyle); static void setXTermCursorStyle (fc::xtermCursorStyle);
static void setXTermTitle (const FString&); static void setXTermTitle (const FString&);
static void setXTermForeground (const FString&); static void setXTermForeground (const FString&);
static void setXTermBackground (const FString&); static void setXTermBackground (const FString&);
static void setXTermCursorColor (const FString&); static void setXTermCursorColor (const FString&);
static void setXTermMouseForeground (const FString&); static void setXTermMouseForeground (const FString&);
static void setXTermMouseBackground (const FString&); static void setXTermMouseBackground (const FString&);
static void setXTermHighlightBackground (const FString&); static void setXTermHighlightBackground (const FString&);
static void setXTermDefaults(); static void setXTermDefaults();
static void resetXTermColors(); static void resetXTermColors();
static void resetXTermForeground(); static void resetXTermForeground();
static void resetXTermBackground(); static void resetXTermBackground();
static void resetXTermCursorColor(); static void resetXTermCursorColor();
static void resetXTermMouseForeground(); static void resetXTermMouseForeground();
static void resetXTermMouseBackground(); static void resetXTermMouseBackground();
static void resetXTermHighlightBackground(); static void resetXTermHighlightBackground();
static void resetXTermDefaults(); static void resetXTermDefaults();
static void saveColorMap(); static void saveColorMap();
static void resetColorMap(); static void resetColorMap();
static void setPalette (short, int, int, int); static void setPalette (short, int, int, int);
static void setBeep (int, int); static void setBeep (int, int);
static void resetBeep(); static void resetBeep();
static void beep(); static void beep();
static void setEncoding (std::string); static void setEncoding (std::string);
static std::string getEncoding(); static std::string getEncoding();
static bool scrollTermForward(); static bool scrollTermForward();
static bool scrollTermReverse(); static bool scrollTermReverse();
static const FString getAnswerbackMsg(); static const FString getAnswerbackMsg();
static const FString getSecDA(); static const FString getSecDA();
// function pointer -> static function // function pointer -> static function
static int (*Fputchar)(int); static int (*Fputchar)(int);
static void putstringf (const char* const, ...) static void putstringf (const char* const, ...)
#if defined(__clang__) #if defined(__clang__)
__attribute__((__format__ (__printf__, 1, 2))) __attribute__((__format__ (__printf__, 1, 2)))
#elif defined(__GNUC__) #elif defined(__GNUC__)
__attribute__ ((format (printf, 1, 2))) __attribute__ ((format (printf, 1, 2)))
#endif #endif
; ;
static void putstring (const char* const, int = 1); static void putstring (const char* const, int = 1);
static int putchar_ASCII (register int); static int putchar_ASCII (register int);
static int putchar_UTF8 (register int); static int putchar_UTF8 (register int);
static int UTF8decode (const char[]); static int UTF8decode (const char[]);
#if DEBUG #if DEBUG
static char termtype_256color[30]; static char termtype_256color[256];
static char termtype_Answerback[30]; static char termtype_Answerback[256];
static char termtype_SecDA[30]; static char termtype_SecDA[256];
#endif #endif
protected: protected:
// Methods // Methods
#if defined(__linux__) #if defined(__linux__)
static void initLinuxConsoleCharMap(); static void initLinuxConsoleCharMap();
#endif #endif
#if defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__DragonFly__)
static void initFreeBSDConsoleCharMap(); static void initFreeBSDConsoleCharMap();
#endif #endif
static void initCygwinCharMap(); static void initCygwinCharMap();
static void initTeraTermCharMap(); static void initTeraTermCharMap();
static bool charEncodable (uInt); static bool charEncodable (uInt);
static uInt charEncode (uInt); static uInt charEncode (uInt);
static uInt charEncode (uInt, fc::encoding); static uInt charEncode (uInt, fc::encoding);
static char* changeAttribute ( char_data*& static char* changeAttribute ( char_data*&
, char_data*& ); , char_data*& );
static bool hasChangedTermSize(); static bool hasChangedTermSize();
static void changeTermSizeFinished(); static void changeTermSizeFinished();
static void xtermMetaSendsESC (bool); static void xtermMetaSendsESC (bool);
static void xtermMouse (bool); static void xtermMouse (bool);
static void enableXTermMouse(); static void enableXTermMouse();
static void disableXTermMouse(); static void disableXTermMouse();
#ifdef F_HAVE_LIBGPM #ifdef F_HAVE_LIBGPM
static bool gpmMouse (bool); static bool gpmMouse (bool);
static bool enableGpmMouse(); static bool enableGpmMouse();
static bool disableGpmMouse(); static bool disableGpmMouse();
static bool isGpmMouseEnabled(); static bool isGpmMouseEnabled();
#endif // F_HAVE_LIBGPM #endif // F_HAVE_LIBGPM
static FPoint& getMousePos(); static FPoint& getMousePos();
static void setMousePos (const FPoint&); static void setMousePos (const FPoint&);
static void setMousePos (short, short); static void setMousePos (short, short);
// Data Members // Data Members
static int stdin_no; static int stdin_no;
static int stdout_no; static int stdout_no;
static int erase_ch_length; static int erase_ch_length;
static int repeat_char_length; static int repeat_char_length;
static int clr_bol_length; static int clr_bol_length;
static int clr_eol_length; static int clr_eol_length;
static int cursor_addres_lengths; static int cursor_addres_lengths;
static bool NewFont; static bool NewFont;
static bool VGAFont; static bool VGAFont;
static bool no_shadow_character; static bool no_shadow_character;
static bool no_half_block_character; static bool no_half_block_character;
static bool cursor_optimisation; static bool cursor_optimisation;
static bool xterm_default_colors; static bool xterm_default_colors;
static bool use_alternate_screen; static bool use_alternate_screen;
static fc::encoding Encoding; static fc::encoding Encoding;
static char exit_message[8192]; static char exit_message[8192];
private: private:
// Typedefs // Typedefs
typedef FTermcap::tcap_map termcap_map; typedef FTermcap::tcap_map termcap_map;
typedef struct typedef struct
{ {
uChar red; uChar red;
uChar green; uChar green;
uChar blue; uChar blue;
} dacreg; } dacreg;
// Constants // Constants
static const int NEED_MORE_DATA = -1; // parseKeyString return value static const int NEED_MORE_DATA = -1; // parseKeyString return value
// Disable copy constructor // Disable copy constructor
FTerm (const FTerm&); FTerm (const FTerm&);
// Disable assignment operator (=) // Disable assignment operator (=)
FTerm& operator = (const FTerm&); FTerm& operator = (const FTerm&);
// Inquiries // Inquiries
#if defined(__linux__) #if defined(__linux__)
static int isLinuxConsole(); static int isLinuxConsole();
#endif #endif
#if defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__DragonFly__)
static bool isFreeBSDConsole(); static bool isFreeBSDConsole();
#endif #endif
#if defined(__NetBSD__) || defined(__OpenBSD__) #if defined(__NetBSD__) || defined(__OpenBSD__)
static bool isWSConsConsole(); static bool isWSConsConsole();
#endif #endif
// Methods // Methods
#if defined(__linux__) #if defined(__linux__)
static uInt16 getInputStatusRegisterOne(); static uInt16 getInputStatusRegisterOne();
static uChar readAttributeController (uChar); static uChar readAttributeController (uChar);
static void writeAttributeController (uChar, uChar); static void writeAttributeController (uChar, uChar);
static uChar getAttributeMode(); static uChar getAttributeMode();
static void setAttributeMode (uChar); static void setAttributeMode (uChar);
static int setBlinkAsIntensity (bool); static int setBlinkAsIntensity (bool);
static int getFramebuffer_bpp(); static int getFramebuffer_bpp();
#endif #endif
static int openConsole(); static int openConsole();
static int closeConsole(); static int closeConsole();
static void getSystemTermType(); static void getSystemTermType();
static void storeTTYsettings(); static void storeTTYsettings();
static void restoreTTYsettings(); static void restoreTTYsettings();
#if defined(__linux__) #if defined(__linux__)
static int getScreenFont(); static int getScreenFont();
static int setScreenFont (uChar*, uInt, uInt, uInt, bool = false); static int setScreenFont ( uChar*, uInt, uInt, uInt
static int setUnicodeMap (struct unimapdesc*); , bool = false );
static int getUnicodeMap (); static int setUnicodeMap (struct unimapdesc*);
static void initLinuxConsole(); static int getUnicodeMap ();
static void initLinuxConsole();
#endif #endif
#if defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__DragonFly__)
static bool saveFreeBSDAltKey(); static bool saveFreeBSDAltKey();
static bool setFreeBSDAltKey (uInt); static bool setFreeBSDAltKey (uInt);
static bool setFreeBSDAlt2Meta(); static bool setFreeBSDAlt2Meta();
static bool resetFreeBSDAlt2Meta(); static bool resetFreeBSDAlt2Meta();
static void initFreeBSDConsole(); static void initFreeBSDConsole();
#endif #endif
#if defined(__NetBSD__) || defined(__OpenBSD__) #if defined(__NetBSD__) || defined(__OpenBSD__)
static bool saveWSConsEncoding(); static bool saveWSConsEncoding();
static bool setWSConsEncoding (kbd_t); static bool setWSConsEncoding (kbd_t);
static bool setWSConsMetaEsc(); static bool setWSConsMetaEsc();
static bool resetWSConsEncoding(); static bool resetWSConsEncoding();
static void initWSConsConsole(); static void initWSConsConsole();
#endif #endif
static uInt getBaudRate (const struct termios*); static uInt getBaudRate (const struct termios*);
static char* init_256colorTerminal(); static char* init_256colorTerminal();
static char* parseAnswerbackMsg (char*&); static char* parseAnswerbackMsg (char*&);
static char* parseSecDA (char*&); static char* parseSecDA (char*&);
static void oscPrefix(); static void oscPrefix();
static void oscPostfix(); static void oscPostfix();
static void init_alt_charset(); static void init_alt_charset();
static void init_pc_charset(); static void init_pc_charset();
static void init_termcaps(); static void init_termcaps();
static void init_encoding(); static void init_encoding();
void init(); void init();
void finish(); void finish();
static uInt cp437_to_unicode (uChar); static uInt cp437_to_unicode (uChar);
static void signal_handler (int); static void signal_handler (int);
// Data Members // Data Members
static std::map <uChar,uChar>* vt100_alt_char; static std::map <uChar,uChar>* vt100_alt_char;
static std::map <std::string,fc::encoding>* encoding_set; static std::map <std::string,fc::encoding>* encoding_set;
static FTermcap::tcap_map* tcap; static FTermcap::tcap_map* tcap;
static bool mouse_support; static bool mouse_support;
static bool terminal_detection; static bool terminal_detection;
static bool raw_mode; static bool raw_mode;
static bool input_data_pending; static bool input_data_pending;
static bool non_blocking_stdin; static bool non_blocking_stdin;
static bool gpm_mouse_enabled; static bool gpm_mouse_enabled;
static bool pc_charset_console; static bool pc_charset_console;
static bool utf8_input; static bool utf8_input;
static bool utf8_state; static bool utf8_state;
static bool utf8_console; static bool utf8_console;
static bool utf8_linux_terminal; static bool utf8_linux_terminal;
static bool force_vt100; static bool force_vt100;
static bool vt100_console; static bool vt100_console;
static bool ascii_console; static bool ascii_console;
static bool color256; static bool color256;
static bool monochron; static bool monochron;
static bool xterm_terminal; static bool xterm_terminal;
static bool ansi_terminal; static bool ansi_terminal;
static bool rxvt_terminal; static bool rxvt_terminal;
static bool urxvt_terminal; static bool urxvt_terminal;
static bool mlterm_terminal; static bool mlterm_terminal;
static bool putty_terminal; static bool putty_terminal;
static bool kde_konsole; static bool kde_konsole;
static bool gnome_terminal; static bool gnome_terminal;
static bool kterm_terminal; static bool kterm_terminal;
static bool tera_terminal; static bool tera_terminal;
static bool cygwin_terminal; static bool cygwin_terminal;
static bool mintty_terminal; static bool mintty_terminal;
static bool linux_terminal; static bool linux_terminal;
static bool netbsd_terminal; static bool netbsd_terminal;
static bool openbsd_terminal; static bool openbsd_terminal;
static bool screen_terminal; static bool screen_terminal;
static bool tmux_terminal; static bool tmux_terminal;
static char termtype[30]; static char termtype[256];
static char* term_name; static char term_name[256];
static char* locale_name; static char* locale_name;
static char* locale_xterm; static char* locale_xterm;
static FRect* term; // current terminal geometry static FRect* term; // current terminal geometry
static FPoint* mouse; // mouse click position static FPoint* mouse; // mouse click position
static int stdin_status_flags; static int stdin_status_flags;
static int fd_tty; static int fd_tty;
static uInt baudrate; static uInt baudrate;
static bool resize_term; static bool resize_term;
static struct termios term_init; static struct termios term_init;
static fc::linuxConsoleCursorStyle linux_console_cursor_style; static fc::linuxConsoleCursorStyle linux_console_cursor_style;
static fc::freebsdConsoleCursorStyle freebsd_console_cursor_style; static fc::freebsdConsoleCursorStyle freebsd_console_cursor_style;
static struct console_font_op screen_font; static struct console_font_op screen_font;
static struct unimapdesc screen_unicode_map; static struct unimapdesc screen_unicode_map;
#if defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__DragonFly__)
static uInt bsd_alt_keymap; static uInt bsd_alt_keymap;
#endif #endif
#if defined(__NetBSD__) || defined(__OpenBSD__) #if defined(__NetBSD__) || defined(__OpenBSD__)
static kbd_t wscons_keyboard_encoding; static kbd_t wscons_keyboard_encoding;
#endif #endif
static FOptiMove* opti_move; static FOptiMove* opti_move;
static FOptiAttr* opti_attr; static FOptiAttr* opti_attr;
static const FString* xterm_font; static const FString* xterm_font;
static const FString* xterm_title; static const FString* xterm_title;
static const FString* answer_back; static const FString* answer_back;
static const FString* sec_da; static const FString* sec_da;
struct struct
{ {
dacreg d[16]; dacreg d[16];
} color_map; } color_map;
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -1,6 +1,9 @@
// File: ftermbuffer.cpp // File: ftermbuffer.cpp
// Provides: class FTermBuffer // Provides: class FTermBuffer
#include <string>
#include <vector>
#include "ftermbuffer.h" #include "ftermbuffer.h"
@ -15,7 +18,7 @@ FTermBuffer::FTermBuffer()
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FTermBuffer::~FTermBuffer() // destructor FTermBuffer::~FTermBuffer() // destructor
{ } { }
@ -24,12 +27,12 @@ FTermBuffer::~FTermBuffer() // destructor
int FTermBuffer::writef (const wchar_t* format, ...) int FTermBuffer::writef (const wchar_t* format, ...)
{ {
assert ( format != 0 ); assert ( format != 0 );
static const int buf_size = 1024; static const int BufSize = 1024;
wchar_t buffer[buf_size]; wchar_t buffer[BufSize];
va_list args; va_list args;
va_start (args, format); va_start (args, format);
std::vswprintf (buffer, buf_size, format, args); std::vswprintf (buffer, BufSize, format, args);
va_end (args); va_end (args);
FString str(buffer); FString str(buffer);
@ -116,7 +119,7 @@ int FTermBuffer::write (const FString& s)
{ {
while ( *p ) while ( *p )
{ {
char_data nc; // next character char_data nc; // next character
nc = FVTerm::getAttribute(); nc = FVTerm::getAttribute();
nc.code = *p; nc.code = *p;
nc.attr.bit.no_changes = false; nc.attr.bit.no_changes = false;
@ -126,7 +129,7 @@ int FTermBuffer::write (const FString& s)
p++; p++;
len++; len++;
} // end of while } // end of while
} }
return len; return len;
@ -135,7 +138,7 @@ int FTermBuffer::write (const FString& s)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FTermBuffer::write (register int c) int FTermBuffer::write (register int c)
{ {
char_data nc; // next character char_data nc; // next character
nc = FVTerm::getAttribute(); nc = FVTerm::getAttribute();
nc.code = c; nc.code = c;
nc.attr.bit.no_changes = false; nc.attr.bit.no_changes = false;
@ -148,8 +151,9 @@ int FTermBuffer::write (register int c)
// FTermBuffer non-member operators // FTermBuffer non-member operators
//---------------------------------------------------------------------- //----------------------------------------------------------------------
std::vector< FTermBuffer::char_data>& operator << ( std::vector<FTermBuffer::char_data>& termString std::vector<FTermBuffer::char_data>& operator << \
, const FTermBuffer& buf ) ( std::vector<FTermBuffer::char_data>& termString
, const FTermBuffer& buf )
{ {
if ( ! buf.data.empty() ) if ( ! buf.data.empty() )
termString.assign(buf.data.begin(), buf.data.end()); termString.assign(buf.data.begin(), buf.data.end());

View File

@ -12,8 +12,9 @@
#ifndef FTERMBUFFER_H #ifndef FTERMBUFFER_H
#define FTERMBUFFER_H #define FTERMBUFFER_H
#include <vector>
#include <sstream> // std::stringstream #include <sstream> // std::stringstream
#include <string>
#include <vector>
#include "fvterm.h" #include "fvterm.h"
#include "fstring.h" #include "fstring.h"
@ -28,50 +29,50 @@
class FTermBuffer class FTermBuffer
{ {
public: public:
// Typedef // Typedef
typedef FOptiAttr::char_data char_data; typedef FOptiAttr::char_data char_data;
// Constructor // Constructor
explicit FTermBuffer(); explicit FTermBuffer();
// Destructor // Destructor
virtual ~FTermBuffer(); virtual ~FTermBuffer();
// Overloaded operators // Overloaded operators
template<class type> FTermBuffer& operator << (const type&); template<class type> FTermBuffer& operator << (const type&);
// Non-member operators // Non-member operators
friend std::vector<char_data>& operator << ( std::vector<char_data>& friend std::vector<char_data>& operator << ( std::vector<char_data>&
, const FTermBuffer& ); , const FTermBuffer& );
// Accessors // Accessors
virtual const char* getClassName() const; virtual const char* getClassName() const;
int getLength() const; int getLength() const;
// Inquiry // Inquiry
bool isEmpty () const; bool isEmpty() const;
// Methods // Methods
void clear(); void clear();
int writef (const wchar_t*, ...); int writef (const wchar_t*, ...);
int writef (const char*, ...) int writef (const char*, ...)
#if defined(__clang__) #if defined(__clang__)
__attribute__((__format__ (__printf__, 2, 3))) __attribute__((__format__ (__printf__, 2, 3)))
#elif defined(__GNUC__) #elif defined(__GNUC__)
__attribute__ ((format (printf, 2, 3))) __attribute__ ((format (printf, 2, 3)))
#endif #endif
; ;
int write (const std::wstring&); int write (const std::wstring&);
int write (const wchar_t*); int write (const wchar_t*);
int write (const char*); int write (const char*);
int write (const std::string&); int write (const std::string&);
int write (const FString&); int write (const FString&);
int write (int); int write (int);
FTermBuffer& write (); FTermBuffer& write ();
std::vector<char_data> getBuffer(); std::vector<char_data> getBuffer();
private: private:
std::vector<char_data> data; std::vector<char_data> data;
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -11,6 +11,10 @@
#ifndef FTERMCAP_H #ifndef FTERMCAP_H
#define FTERMCAP_H #define FTERMCAP_H
// FTermcap string macro
#define TCAP(s) tcap[(s)].string
#include <string>
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FTermcap // class FTermcap
@ -20,50 +24,50 @@
class FTermcap class FTermcap
{ {
public: public:
// Typedef // Typedef
typedef struct typedef struct
{ {
char* string; char* string;
char tname[3]; char tname[3];
} }
tcap_map; tcap_map;
// Constructors // Constructors
FTermcap() FTermcap()
{ } { }
// Destructor // Destructor
~FTermcap() ~FTermcap()
{ } { }
// Accessor // Accessor
static tcap_map* getTermcapMap() static tcap_map* getTermcapMap()
{ {
return tcap; return tcap;
} }
// Mutator // Mutator
static void setTermcapMap (tcap_map* t) static void setTermcapMap (tcap_map* t)
{ {
tcap = t; tcap = t;
} }
// Data Members // Data Members
static bool background_color_erase; static bool background_color_erase;
static bool automatic_left_margin; static bool automatic_left_margin;
static bool automatic_right_margin; static bool automatic_right_margin;
static bool eat_nl_glitch; static bool eat_nl_glitch;
static bool ansi_default_color; static bool ansi_default_color;
static bool osc_support; static bool osc_support;
static bool no_utf8_acs_chars; static bool no_utf8_acs_chars;
static int max_color; static int max_color;
static int tabstop; static int tabstop;
static int attr_without_color; static int attr_without_color;
private: private:
// Data Members // Data Members
static tcap_map* tcap; static tcap_map* tcap;
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -28,6 +28,8 @@
#ifndef FTEXTVIEW_H #ifndef FTEXTVIEW_H
#define FTEXTVIEW_H #define FTEXTVIEW_H
#include <vector>
#include "fapplication.h" #include "fapplication.h"
#include "fscrollbar.h" #include "fscrollbar.h"
#include "fstatusbar.h" #include "fstatusbar.h"
@ -44,78 +46,78 @@
class FTextView : public FWidget class FTextView : public FWidget
{ {
public: public:
// Using-declarations // Using-declarations
using FWidget::setGeometry; using FWidget::setGeometry;
// Typedef // Typedef
typedef std::vector<FString> stringLines; typedef std::vector<FString> stringLines;
// Constructor // Constructor
explicit FTextView (FWidget* = 0); explicit FTextView (FWidget* = 0);
// Destructor // Destructor
~FTextView(); ~FTextView();
// Accessors // Accessors
const char* getClassName() const; const char* getClassName() const;
uInt getColumns() const; uInt getColumns() const;
uInt getRows() const; uInt getRows() const;
const FString getText() const; const FString getText() const;
const stringLines& getLines() const; const stringLines& getLines() const;
// Mutators // Mutators
void setGeometry (int, int, int, int, bool = true); void setGeometry (int, int, int, int, bool = true);
void setPosition (int); void setPosition (int);
void setText (const FString&); void setText (const FString&);
// Methods // Methods
void hide(); void hide();
void append (const FString&); void append (const FString&);
void insert (const FString&, int); void insert (const FString&, int);
void replaceRange (const FString&, int, int); void replaceRange (const FString&, int, int);
void deleteRange (int, int); void deleteRange (int, int);
void deleteLine (int); void deleteLine (int);
void clear(); void clear();
// Event handlers // Event handlers
void onKeyPress (FKeyEvent*); void onKeyPress (FKeyEvent*);
void onMouseDown (FMouseEvent*); void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*); void onMouseUp (FMouseEvent*);
void onMouseMove (FMouseEvent*); void onMouseMove (FMouseEvent*);
void onWheel (FWheelEvent*); void onWheel (FWheelEvent*);
void onFocusIn (FFocusEvent*); void onFocusIn (FFocusEvent*);
void onFocusOut (FFocusEvent*); void onFocusOut (FFocusEvent*);
protected: protected:
// Method // Method
void adjustSize(); void adjustSize();
private: private:
// Disable copy constructor // Disable copy constructor
FTextView (const FTextView&); FTextView (const FTextView&);
// Disable assignment operator (=) // Disable assignment operator (=)
FTextView& operator = (const FTextView&); FTextView& operator = (const FTextView&);
// Methods // Methods
void init(); void init();
void draw(); void draw();
void drawText(); void drawText();
void processChanged(); void processChanged();
// Callback methods // Callback methods
void cb_VBarChange (FWidget*, data_ptr); void cb_VBarChange (FWidget*, data_ptr);
void cb_HBarChange (FWidget*, data_ptr); void cb_HBarChange (FWidget*, data_ptr);
// Data Members // Data Members
stringLines data; stringLines data;
FScrollbar* vbar; FScrollbar* vbar;
FScrollbar* hbar; FScrollbar* hbar;
int xoffset; int xoffset;
int yoffset; int yoffset;
int nf_offset; int nf_offset;
uInt maxLineWidth; uInt maxLineWidth;
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -43,99 +43,99 @@ class FButtonGroup;
class FToggleButton : public FWidget class FToggleButton : public FWidget
{ {
public: public:
// Using-declaration // Using-declaration
using FWidget::setGeometry; using FWidget::setGeometry;
// Constructors // Constructors
explicit FToggleButton (FWidget* = 0); explicit FToggleButton (FWidget* = 0);
FToggleButton (const FString&, FWidget* = 0); FToggleButton (const FString&, FWidget* = 0);
// Destructor // Destructor
virtual ~FToggleButton(); virtual ~FToggleButton();
// Accessors // Accessors
virtual const char* getClassName() const; virtual const char* getClassName() const;
FString& getText(); FString& getText();
// Mutators // Mutators
void setGeometry (int, int, int, int, bool = true); void setGeometry (int, int, int, int, bool = true);
bool setNoUnderline (bool); bool setNoUnderline (bool);
bool setNoUnderline(); bool setNoUnderline();
bool unsetNoUnderline(); bool unsetNoUnderline();
bool setEnable (bool); bool setEnable (bool);
bool setEnable(); bool setEnable();
bool unsetEnable(); bool unsetEnable();
bool setDisable(); bool setDisable();
bool setFocus (bool); bool setFocus (bool);
bool setFocus(); bool setFocus();
bool unsetFocus(); bool unsetFocus();
bool setChecked (bool); bool setChecked (bool);
bool setChecked(); bool setChecked();
bool unsetChecked(); bool unsetChecked();
virtual void setText (const FString&); virtual void setText (const FString&);
// Inquiries // Inquiries
bool isChecked(); bool isChecked();
// Methods // Methods
void hide(); void hide();
// Event handlers // Event handlers
void onMouseDown (FMouseEvent*); void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*); void onMouseUp (FMouseEvent*);
void onWheel (FWheelEvent*); void onWheel (FWheelEvent*);
void onAccel (FAccelEvent*); void onAccel (FAccelEvent*);
void onFocusIn (FFocusEvent*); void onFocusIn (FFocusEvent*);
void onFocusOut (FFocusEvent*); void onFocusOut (FFocusEvent*);
protected: protected:
// Accessor // Accessor
uChar getHotkey(); uChar getHotkey();
FButtonGroup* getGroup() const; FButtonGroup* getGroup() const;
// Mutator // Mutator
void setHotkeyAccelerator(); void setHotkeyAccelerator();
// Inquiries // Inquiries
bool isRadioButton() const; bool isRadioButton() const;
bool isCheckboxButton() const; bool isCheckboxButton() const;
bool hasGroup() const; bool hasGroup() const;
// Methods // Methods
virtual void draw(); virtual void draw();
void drawLabel(); void drawLabel();
void processClick(); void processClick();
void processToggle(); void processToggle();
// Event handler // Event handler
virtual void onKeyPress (FKeyEvent*); virtual void onKeyPress (FKeyEvent*);
// Data Members // Data Members
bool checked; bool checked;
int label_offset_pos; int label_offset_pos;
int button_width; // plus margin spaces int button_width; // plus margin spaces
private: private:
// Disable copy constructor // Disable copy constructor
FToggleButton (const FToggleButton&); FToggleButton (const FToggleButton&);
// Disable assignment operator (=) // Disable assignment operator (=)
FToggleButton& operator = (const FToggleButton&); FToggleButton& operator = (const FToggleButton&);
// Mutator // Mutator
void setGroup (FButtonGroup*); void setGroup (FButtonGroup*);
// Methods // Methods
void init(); void init();
// Friend classes // Friend classes
friend class FButtonGroup; friend class FButtonGroup;
// Data Members // Data Members
FButtonGroup* button_group; FButtonGroup* button_group;
bool focus_inside_group; bool focus_inside_group;
FString text; FString text;
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -137,7 +137,7 @@ void FToolTip::calculateDimensions()
max_line_width = len; max_line_width = len;
} }
h = int(text_num_lines) + 2 ; h = int(text_num_lines) + 2;
w = int(max_line_width + 4); w = int(max_line_width + 4);
if ( r ) if ( r )

View File

@ -33,6 +33,8 @@
#ifndef FTOOLTIP_H #ifndef FTOOLTIP_H
#define FTOOLTIP_H #define FTOOLTIP_H
#include <vector>
#include "fwindow.h" #include "fwindow.h"
@ -45,50 +47,50 @@
class FToolTip : public FWindow class FToolTip : public FWindow
{ {
public: public:
// Constructor // Constructor
explicit FToolTip (FWidget* = 0); explicit FToolTip (FWidget* = 0);
FToolTip (const FString&, FWidget* = 0); FToolTip (const FString&, FWidget* = 0);
// Destructor // Destructor
virtual ~FToolTip (); virtual ~FToolTip ();
// Accessors // Accessors
const char* getClassName() const; const char* getClassName() const;
const FString getText() const; const FString getText() const;
// Mutators // Mutators
void setText (const FString&); void setText (const FString&);
// Methods // Methods
virtual void draw(); virtual void draw();
void show(); void show();
void hide(); void hide();
// Event handler // Event handler
void onMouseDown (FMouseEvent*); void onMouseDown (FMouseEvent*);
private: private:
// Typedef // Typedef
typedef std::vector<FString> textLines; typedef std::vector<FString> textLines;
// Disable copy constructor // Disable copy constructor
FToolTip (const FToolTip&); FToolTip (const FToolTip&);
// Disable assignment operator (=) // Disable assignment operator (=)
FToolTip& operator = (const FToolTip&); FToolTip& operator = (const FToolTip&);
// Methods // Methods
void init(); void init();
void calculateDimensions(); void calculateDimensions();
virtual void adjustSize(); virtual void adjustSize();
// Data Members // Data Members
FString text; FString text;
FString* text_components; FString* text_components;
textLines text_split; textLines text_split;
uInt max_line_width; uInt max_line_width;
uInt text_num_lines; uInt text_num_lines;
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -5,6 +5,8 @@
#include <sys/types.h> #include <sys/types.h>
#define null NULL
typedef unsigned char uChar; typedef unsigned char uChar;
typedef unsigned int uInt; typedef unsigned int uInt;
typedef unsigned long uLong; typedef unsigned long uLong;

View File

@ -1,6 +1,10 @@
// File: fvterm.cpp // File: fvterm.cpp
// Provides: class FVTerm // Provides: class FVTerm
#include <queue>
#include <string>
#include <vector>
#include "fapplication.h" #include "fapplication.h"
#include "fvterm.h" #include "fvterm.h"
#include "fwidget.h" #include "fwidget.h"
@ -105,7 +109,7 @@ void FVTerm::setTermXY (register int x, register int y)
appendOutputBuffer(move_str); appendOutputBuffer(move_str);
flush_out(); flush_out();
term_pos->setPoint(x,y); term_pos->setPoint(x, y);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -289,12 +293,12 @@ void FVTerm::delPreprocessingHandler (FVTerm* instance)
int FVTerm::printf (const wchar_t* format, ...) int FVTerm::printf (const wchar_t* format, ...)
{ {
assert ( format != 0 ); assert ( format != 0 );
static const int buf_size = 1024; static const int BufSize = 1024;
wchar_t buffer[buf_size]; wchar_t buffer[BufSize];
va_list args; va_list args;
va_start (args, format); va_start (args, format);
std::vswprintf (buffer, buf_size, format, args); std::vswprintf (buffer, BufSize, format, args);
va_end (args); va_end (args);
FString str(buffer); FString str(buffer);
@ -475,7 +479,7 @@ int FVTerm::print (term_area* area, const FString& s)
int ax = area->cursor_x - 1; int ax = area->cursor_x - 1;
int ay = area->cursor_y - 1; int ay = area->cursor_y - 1;
char_data nc; // next character char_data nc; // next character
nc.code = *p; nc.code = *p;
nc.fg_color = next_attribute.fg_color; nc.fg_color = next_attribute.fg_color;
nc.bg_color = next_attribute.bg_color; nc.bg_color = next_attribute.bg_color;
@ -503,7 +507,7 @@ int FVTerm::print (term_area* area, const FString& s)
&& ax < area->width + area->right_shadow && ax < area->width + area->right_shadow
&& ay < area->height + area->bottom_shadow ) && ay < area->height + area->bottom_shadow )
{ {
char_data* ac; // area character char_data* ac; // area character
int line_len = area->width + area->right_shadow; int line_len = area->width + area->right_shadow;
ac = &area->text[ay * line_len + ax]; ac = &area->text[ay * line_len + ax];
@ -553,7 +557,7 @@ int FVTerm::print (term_area* area, const FString& s)
p++; p++;
len++; len++;
} // end of while } // end of while
} }
return len; return len;
@ -639,7 +643,7 @@ int FVTerm::print (term_area* area, const std::vector<char_data>& termString)
&& ax < area->width + area->right_shadow && ax < area->width + area->right_shadow
&& ay < area->height + area->bottom_shadow ) && ay < area->height + area->bottom_shadow )
{ {
char_data* ac; // area character char_data* ac; // area character
int line_len = area->width + area->right_shadow; int line_len = area->width + area->right_shadow;
ac = &area->text[ay * line_len + ax]; ac = &area->text[ay * line_len + ax];
@ -689,7 +693,7 @@ int FVTerm::print (term_area* area, const std::vector<char_data>& termString)
len++; len++;
++iter; ++iter;
} // end of while } // end of while
return len; return len;
} }
@ -713,7 +717,7 @@ int FVTerm::print (register int c)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FVTerm::print (term_area* area, register int c) int FVTerm::print (term_area* area, register int c)
{ {
char_data nc; // next character char_data nc; // next character
int width, height, rsh, bsh, ax, ay; int width, height, rsh, bsh, ax, ay;
if ( ! area ) if ( ! area )
@ -753,7 +757,7 @@ int FVTerm::print (term_area* area, register int c)
&& ax < area->width + area->right_shadow && ax < area->width + area->right_shadow
&& ay < area->height + area->bottom_shadow ) && ay < area->height + area->bottom_shadow )
{ {
char_data* ac; // area character char_data* ac; // area character
int line_len = area->width + area->right_shadow; int line_len = area->width + area->right_shadow;
ac = &area->text[ay * line_len + ax]; ac = &area->text[ay * line_len + ax];
@ -1087,10 +1091,10 @@ void FVTerm::restoreVTerm (const FRect& box)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::restoreVTerm (int x, int y, int w, int h) void FVTerm::restoreVTerm (int x, int y, int w, int h)
{ {
char_data* tc; // terminal character char_data* tc; // terminal character
char_data* sc; // shown character char_data* sc; // shown character
char_data s_ch; // shadow character char_data s_ch; // shadow character
char_data i_ch; // inherit background character char_data i_ch; // inherit background character
FWidget* widget; FWidget* widget;
x--; x--;
@ -1248,7 +1252,7 @@ FVTerm::covered_state FVTerm::isCovered ( int x, int y
, win->width + win->right_shadow , win->width + win->right_shadow
, win->height + win->bottom_shadow ); , win->height + win->bottom_shadow );
if ( found && geometry.contains(x,y) ) if ( found && geometry.contains(x, y) )
{ {
char_data* tmp; char_data* tmp;
int line_len = win->width + win->right_shadow; int line_len = win->width + win->right_shadow;
@ -1336,8 +1340,8 @@ void FVTerm::updateVTerm (term_area* area)
// Update area data on VTerm // Update area data on VTerm
int ax, ay, aw, ah, rsh, bsh, y_end, ol; int ax, ay, aw, ah, rsh, bsh, y_end, ol;
char_data* tc; // terminal character char_data* tc; // terminal character
char_data* ac; // area character char_data* ac; // area character
if ( ! area ) if ( ! area )
return; return;
@ -1500,7 +1504,6 @@ void FVTerm::updateVTerm (term_area* area)
} }
else if ( ! modified ) else if ( ! modified )
line_xmin++; // don't update covered character line_xmin++; // don't update covered character
} }
_xmin = ax + line_xmin - ol; _xmin = ax + line_xmin - ol;
@ -1574,7 +1577,7 @@ bool FVTerm::isInsideArea (int x, int y, term_area* area)
ah = area->height; ah = area->height;
FRect area_geometry(ax, ay, aw, ah); FRect area_geometry(ax, ay, aw, ah);
if ( area_geometry.contains(x,y) ) if ( area_geometry.contains(x, y) )
return true; return true;
else else
return false; return false;
@ -1613,8 +1616,8 @@ void FVTerm::getArea (int ax, int ay, term_area* area)
// Copies a block from the virtual terminal position to the given area // Copies a block from the virtual terminal position to the given area
int y_end; int y_end;
int length; int length;
char_data* tc; // terminal character char_data* tc; // terminal character
char_data* ac; // area character char_data* ac; // area character
if ( ! area ) if ( ! area )
return; return;
@ -1661,8 +1664,8 @@ void FVTerm::getArea (int x, int y, int w, int h, term_area* area)
{ {
// Copies a block from the virtual terminal rectangle to the given area // Copies a block from the virtual terminal rectangle to the given area
int y_end, length, dx, dy; int y_end, length, dx, dy;
char_data* tc; // terminal character char_data* tc; // terminal character
char_data* ac; // area character char_data* ac; // area character
if ( ! area ) if ( ! area )
return; return;
@ -1719,8 +1722,8 @@ void FVTerm::putArea (int ax, int ay, term_area* area)
{ {
// Copies the given area block to the virtual terminal position // Copies the given area block to the virtual terminal position
int aw, ah, rsh, bsh, y_end, length, ol; int aw, ah, rsh, bsh, y_end, length, ol;
char_data* tc; // terminal character char_data* tc; // terminal character
char_data* ac; // area character char_data* ac; // area character
if ( ! area ) if ( ! area )
return; return;
@ -1833,10 +1836,10 @@ void FVTerm::scrollAreaForward (term_area* area)
int total_width; int total_width;
int length; int length;
int y_max; int y_max;
char_data nc; // next character char_data nc; // next character
char_data* lc; // last character char_data* lc; // last character
char_data* sc; // source character char_data* sc; // source character
char_data* dc; // destination character char_data* dc; // destination character
if ( ! area ) if ( ! area )
return; return;
@ -1871,7 +1874,7 @@ void FVTerm::scrollAreaForward (term_area* area)
if ( area == vdesktop ) if ( area == vdesktop )
{ {
if ( tcap[fc::t_scroll_forward].string ) if ( TCAP(fc::t_scroll_forward) )
{ {
setTermXY (0, vdesktop->height); setTermXY (0, vdesktop->height);
scrollTermForward(); scrollTermForward();
@ -1894,10 +1897,10 @@ void FVTerm::scrollAreaReverse (term_area* area)
int total_width; int total_width;
int length; int length;
int y_max; int y_max;
char_data nc; // next character char_data nc; // next character
char_data* lc; // last character char_data* lc; // last character
char_data* sc; // source character char_data* sc; // source character
char_data* dc; // destination character char_data* dc; // destination character
if ( ! area ) if ( ! area )
return; return;
@ -1932,7 +1935,7 @@ void FVTerm::scrollAreaReverse (term_area* area)
if ( area == vdesktop ) if ( area == vdesktop )
{ {
if ( tcap[fc::t_scroll_reverse].string ) if ( TCAP(fc::t_scroll_reverse) )
{ {
setTermXY (0, 0); setTermXY (0, 0);
scrollTermReverse(); scrollTermReverse();
@ -2058,9 +2061,9 @@ FVTerm::char_data FVTerm::getCharacter ( character_type char_type
{ {
// Gets the overlapped or the covered character for the position (x,y) // Gets the overlapped or the covered character for the position (x,y)
int xx, yy; int xx, yy;
char_data* cc; // covered character char_data* cc; // covered character
char_data s_ch; // shadow character char_data s_ch; // shadow character
char_data i_ch; // inherit background character char_data i_ch; // inherit background character
FWidget* w; FWidget* w;
x--; x--;
@ -2120,7 +2123,7 @@ FVTerm::char_data FVTerm::getCharacter ( character_type char_type
, win->height + win->bottom_shadow ); , win->height + win->bottom_shadow );
// window visible and contains current character // window visible and contains current character
if ( geometry.contains(x,y) ) if ( geometry.contains(x, y) )
{ {
char_data* tmp; char_data* tmp;
int line_len = win->width + win->right_shadow; int line_len = win->width + win->right_shadow;
@ -2257,7 +2260,7 @@ void FVTerm::init()
try try
{ {
term_pos = new FPoint(-1,-1); term_pos = new FPoint(-1, -1);
output_buffer = new std::queue<int>; output_buffer = new std::queue<int>;
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
@ -2344,9 +2347,9 @@ void FVTerm::finish()
bool FVTerm::clearTerm (int fillchar) bool FVTerm::clearTerm (int fillchar)
{ {
// Clear the real terminal and put cursor at home // Clear the real terminal and put cursor at home
char*& cl = tcap[fc::t_clear_screen].string; char*& cl = TCAP(fc::t_clear_screen);
char*& cd = tcap[fc::t_clr_eos].string; char*& cd = TCAP(fc::t_clr_eos);
char*& cb = tcap[fc::t_clr_eol].string; char*& cb = TCAP(fc::t_clr_eol);
bool ut = FTermcap::background_color_erase; bool ut = FTermcap::background_color_erase;
char_data* next = &next_attribute; char_data* next = &next_attribute;
bool normal = isNormal(next); bool normal = isNormal(next);
@ -2367,11 +2370,11 @@ bool FVTerm::clearTerm (int fillchar)
{ {
setTermXY (0, 0); setTermXY (0, 0);
appendOutputBuffer (cd); appendOutputBuffer (cd);
term_pos->setPoint(-1,-1); term_pos->setPoint(-1, -1);
} }
else if ( cb ) else if ( cb )
{ {
term_pos->setPoint(-1,-1); term_pos->setPoint(-1, -1);
for (int i = 0; i < getLineNumber(); i++) for (int i = 0; i < getLineNumber(); i++)
{ {
@ -2401,10 +2404,10 @@ void FVTerm::updateTerminalLine (uInt y)
bool is_eol_clean = false; bool is_eol_clean = false;
bool draw_leading_ws = false; bool draw_leading_ws = false;
bool draw_tailing_ws = false; bool draw_tailing_ws = false;
char*& ce = tcap[fc::t_clr_eol].string; char*& ce = TCAP(fc::t_clr_eol);
char*& cb = tcap[fc::t_clr_bol].string; char*& cb = TCAP(fc::t_clr_bol);
char*& ec = tcap[fc::t_erase_chars].string; char*& ec = TCAP(fc::t_erase_chars);
char*& rp = tcap[fc::t_repeat_char].string; char*& rp = TCAP(fc::t_repeat_char);
bool ut = FTermcap::background_color_erase; bool ut = FTermcap::background_color_erase;
char_data* first_char = &vt->text[y * uInt(vt->width)]; char_data* first_char = &vt->text[y * uInt(vt->width)];
char_data* last_char = &vt->text[(y + 1) * uInt(vt->width) - 1]; char_data* last_char = &vt->text[(y + 1) * uInt(vt->width) - 1];
@ -2653,7 +2656,7 @@ void FVTerm::updateTerminalLine (uInt y)
{ {
if ( FTermcap::eat_nl_glitch ) if ( FTermcap::eat_nl_glitch )
{ {
term_pos->setPoint(-1,-1); term_pos->setPoint(-1, -1);
} }
else if ( FTermcap::automatic_right_margin ) else if ( FTermcap::automatic_right_margin )
{ {
@ -2677,7 +2680,7 @@ bool FVTerm::updateTerminalCursor()
if ( isInsideTerminal(x, y) ) if ( isInsideTerminal(x, y) )
{ {
setTermXY (x,y); setTermXY (x, y);
showCursor(); showCursor();
return true; return true;
} }
@ -2694,7 +2697,7 @@ bool FVTerm::isInsideTerminal (int x, int y)
// Check whether the coordinates are within the virtual terminal // Check whether the coordinates are within the virtual terminal
FRect term_geometry (0, 0, getColumnNumber(), getLineNumber()); FRect term_geometry (0, 0, getColumnNumber(), getLineNumber());
if ( term_geometry.contains(x,y) ) if ( term_geometry.contains(x, y) )
return true; return true;
else else
return false; return false;
@ -2782,8 +2785,8 @@ inline void FVTerm::charsetChanges (char_data*& next_char)
else if ( Encoding == fc::PC ) else if ( Encoding == fc::PC )
{ {
next_char->attr.bit.pc_charset = true; next_char->attr.bit.pc_charset = true;
// Character 0x00..0x1f
if ( isXTerminal() && hasUTF8() && ch_enc < 0x20 ) // Character 0x00..0x1f if ( isXTerminal() && hasUTF8() && ch_enc < 0x20 )
next_char->code = int(charEncode(code, fc::ASCII)); next_char->code = int(charEncode(code, fc::ASCII));
} }
} }
@ -2830,8 +2833,8 @@ inline void FVTerm::appendAttributes (char_data*& next_attr)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FVTerm::appendLowerRight (char_data*& screen_char) int FVTerm::appendLowerRight (char_data*& screen_char)
{ {
char* SA = tcap[fc::t_enter_am_mode].string; char* SA = TCAP(fc::t_enter_am_mode);
char* RA = tcap[fc::t_exit_am_mode].string; char* RA = TCAP(fc::t_exit_am_mode);
if ( ! FTermcap::automatic_right_margin ) if ( ! FTermcap::automatic_right_margin )
{ {
@ -2846,11 +2849,11 @@ int FVTerm::appendLowerRight (char_data*& screen_char)
else else
{ {
int x, y; int x, y;
char* IC = tcap[fc::t_parm_ich].string; char* IC = TCAP(fc::t_parm_ich);
char* im = tcap[fc::t_enter_insert_mode].string; char* im = TCAP(fc::t_enter_insert_mode);
char* ei = tcap[fc::t_exit_insert_mode].string; char* ei = TCAP(fc::t_exit_insert_mode);
char* ip = tcap[fc::t_insert_padding].string; char* ip = TCAP(fc::t_insert_padding);
char* ic = tcap[fc::t_insert_character].string; char* ic = TCAP(fc::t_insert_character);
x = getColumnNumber() - 2; x = getColumnNumber() - 2;
y = getLineNumber() - 1; y = getLineNumber() - 1;
@ -2890,14 +2893,14 @@ int FVTerm::appendLowerRight (char_data*& screen_char)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FVTerm::appendOutputBuffer (std::string& s) inline void FVTerm::appendOutputBuffer (const std::string& s)
{ {
const char* const& c_string = s.c_str(); const char* const& c_string = s.c_str();
tputs (c_string, 1, appendOutputBuffer); tputs (c_string, 1, appendOutputBuffer);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FVTerm::appendOutputBuffer (const char* const& s) inline void FVTerm::appendOutputBuffer (const char*& s)
{ {
tputs (s, 1, appendOutputBuffer); tputs (s, 1, appendOutputBuffer);
} }

View File

@ -46,376 +46,376 @@ class FWidget;
class FVTerm : public FObject, public FTerm class FVTerm : public FObject, public FTerm
{ {
public: public:
// Typedefs and Enumeration // Typedefs and Enumeration
typedef struct typedef struct
{ {
uInt xmin; // X-position with the first change uInt xmin; // X-position with the first change
uInt xmax; // X-position with the last change uInt xmax; // X-position with the last change
uInt trans_count; // Number of transparent characters uInt trans_count; // Number of transparent characters
} line_changes; } line_changes;
typedef FOptiAttr::char_data char_data; typedef FOptiAttr::char_data char_data;
typedef void (FVTerm::*FPreprocessingHandler)(); typedef void (FVTerm::*FPreprocessingHandler)();
struct vterm_preprocessing struct vterm_preprocessing
{ {
FVTerm* instance; FVTerm* instance;
FPreprocessingHandler handler; FPreprocessingHandler handler;
}; };
typedef std::vector<vterm_preprocessing> FPreprocessing; typedef std::vector<vterm_preprocessing> FPreprocessing;
// define virtual terminal character properties // define virtual terminal character properties
struct term_area struct term_area
{ {
public: public:
term_area() term_area()
: offset_left (0) : offset_left (0)
, offset_top (0) , offset_top (0)
, width (-1) , width (-1)
, height (-1) , height (-1)
, right_shadow (0) , right_shadow (0)
, bottom_shadow (0) , bottom_shadow (0)
, cursor_x (0) , cursor_x (0)
, cursor_y (0) , cursor_y (0)
, input_cursor_x (-1) , input_cursor_x (-1)
, input_cursor_y (-1) , input_cursor_y (-1)
, widget() , widget()
, preprocessing_call() , preprocessing_call()
, changes (0) , changes (0)
, text (0) , text (0)
, input_cursor_visible (false) , input_cursor_visible (false)
, has_changes (false) , has_changes (false)
, visible (false) , visible (false)
{ } { }
~term_area() ~term_area()
{ } { }
int offset_left; // Distance from left terminal side int offset_left; // Distance from left terminal side
int offset_top; // Distance from top of the terminal int offset_top; // Distance from top of the terminal
int width; // Window width int width; // Window width
int height; // Window height int height; // Window height
int right_shadow; // Right window shadow int right_shadow; // Right window shadow
int bottom_shadow; // Bottom window shadow int bottom_shadow; // Bottom window shadow
int cursor_x; // X-position for the next write operation int cursor_x; // X-position for the next write operation
int cursor_y; // Y-position for the next write operation int cursor_y; // Y-position for the next write operation
int input_cursor_x; // X-position input cursor int input_cursor_x; // X-position input cursor
int input_cursor_y; // Y-position input cursor int input_cursor_y; // Y-position input cursor
FWidget* widget; // Widget that owns this term_area FWidget* widget; // Widget that owns this term_area
FPreprocessing preprocessing_call; FPreprocessing preprocessing_call;
line_changes* changes; line_changes* changes;
char_data* text; // Text data for the output char_data* text; // Text data for the output
bool input_cursor_visible; bool input_cursor_visible;
bool has_changes; bool has_changes;
bool visible; bool visible;
private: private:
// Disable copy constructor // Disable copy constructor
term_area (const term_area&); term_area (const term_area&);
// Disable assignment operator (=) // Disable assignment operator (=)
term_area& operator = (const term_area&); term_area& operator = (const term_area&);
}; };
enum covered_state enum covered_state
{ {
non_covered, non_covered,
half_covered, half_covered,
fully_covered fully_covered
}; };
// Constructor // Constructor
explicit FVTerm (FVTerm* = 0, bool = false); explicit FVTerm (FVTerm* = 0, bool = false);
// Destructor // Destructor
~FVTerm(); ~FVTerm();
// Overloaded operators // Overloaded operators
template<class type> FVTerm& operator << (const type&); template<class type> FVTerm& operator << (const type&);
FVTerm& operator << (const std::vector<char_data>&); FVTerm& operator << (const std::vector<char_data>&);
// Accessors // Accessors
virtual const char* getClassName() const; virtual const char* getClassName() const;
static short getTermForegroundColor(); static short getTermForegroundColor();
static short getTermBackgroundColor(); static short getTermBackgroundColor();
term_area* getVWin() const; term_area* getVWin() const;
FPoint getPrintCursor(); FPoint getPrintCursor();
static char_data getAttribute(); static char_data getAttribute();
// Mutators // Mutators
static void setTermXY (register int, register int); static void setTermXY (register int, register int);
static bool hideCursor (bool); static bool hideCursor (bool);
static bool hideCursor(); static bool hideCursor();
static bool showCursor(); static bool showCursor();
void setPrintCursor (const FPoint&); void setPrintCursor (const FPoint&);
void setPrintCursor (register int, register int); void setPrintCursor (register int, register int);
void setColor (short, short); void setColor (short, short);
static void setNormal(); static void setNormal();
static bool setBold (register bool); static bool setBold (register bool);
static bool setBold(); static bool setBold();
static bool unsetBold(); static bool unsetBold();
static bool setDim (register bool); static bool setDim (register bool);
static bool setDim(); static bool setDim();
static bool unsetDim(); static bool unsetDim();
static bool setItalic (register bool); static bool setItalic (register bool);
static bool setItalic(); static bool setItalic();
static bool unsetItalic(); static bool unsetItalic();
static bool setUnderline (register bool); static bool setUnderline (register bool);
static bool setUnderline(); static bool setUnderline();
static bool unsetUnderline(); static bool unsetUnderline();
static bool setBlink (register bool); static bool setBlink (register bool);
static bool setBlink(); static bool setBlink();
static bool unsetBlink(); static bool unsetBlink();
static bool setReverse (register bool); static bool setReverse (register bool);
static bool setReverse(); static bool setReverse();
static bool unsetReverse(); static bool unsetReverse();
static bool setStandout (register bool); static bool setStandout (register bool);
static bool setStandout(); static bool setStandout();
static bool unsetStandout(); static bool unsetStandout();
static bool setInvisible (register bool); static bool setInvisible (register bool);
static bool setInvisible(); static bool setInvisible();
static bool unsetInvisible(); static bool unsetInvisible();
static bool setProtected (register bool); static bool setProtected (register bool);
static bool setProtected(); static bool setProtected();
static bool unsetProtected(); static bool unsetProtected();
static bool setCrossedOut (register bool); static bool setCrossedOut (register bool);
static bool setCrossedOut(); static bool setCrossedOut();
static bool unsetCrossedOut(); static bool unsetCrossedOut();
static bool setDoubleUnderline (register bool); static bool setDoubleUnderline (register bool);
static bool setDoubleUnderline(); static bool setDoubleUnderline();
static bool unsetDoubleUnderline(); static bool unsetDoubleUnderline();
static bool setAltCharset (register bool); static bool setAltCharset (register bool);
static bool setAltCharset(); static bool setAltCharset();
static bool unsetAltCharset(); static bool unsetAltCharset();
static bool setPCcharset (register bool); static bool setPCcharset (register bool);
static bool setPCcharset(); static bool setPCcharset();
static bool unsetPCcharset(); static bool unsetPCcharset();
static bool setTransparent (register bool); static bool setTransparent (register bool);
static bool setTransparent(); static bool setTransparent();
static bool unsetTransparent(); static bool unsetTransparent();
static bool setTransShadow (register bool); static bool setTransShadow (register bool);
static bool setTransShadow(); static bool setTransShadow();
static bool unsetTransShadow(); static bool unsetTransShadow();
static bool setInheritBackground (register bool); static bool setInheritBackground (register bool);
static bool setInheritBackground(); static bool setInheritBackground();
static bool unsetInheritBackground(); static bool unsetInheritBackground();
// Inquiries // Inquiries
static bool isCursorHidden(); static bool isCursorHidden();
static bool isBold(); static bool isBold();
static bool isDim(); static bool isDim();
static bool isItalic(); static bool isItalic();
static bool isUnderline(); static bool isUnderline();
static bool isBlink(); static bool isBlink();
static bool isReverse(); static bool isReverse();
static bool isStandout(); static bool isStandout();
static bool isInvisible(); static bool isInvisible();
static bool isProtected(); static bool isProtected();
static bool isCrossedOut(); static bool isCrossedOut();
static bool isDoubleUnderline(); static bool isDoubleUnderline();
static bool isAltCharset(); static bool isAltCharset();
static bool isPCcharset(); static bool isPCcharset();
static bool isTransparent(); static bool isTransparent();
static bool isTransShadow(); static bool isTransShadow();
static bool isInheritBackground(); static bool isInheritBackground();
// Methods // Methods
virtual void clearArea (int = ' '); virtual void clearArea (int = ' ');
void createVTerm (const FRect&); void createVTerm (const FRect&);
void createVTerm (int, int); void createVTerm (int, int);
static void resizeVTerm (const FRect&); static void resizeVTerm (const FRect&);
static void resizeVTerm (int, int); static void resizeVTerm (int, int);
static void putVTerm(); static void putVTerm();
static void updateTerminal (bool); static void updateTerminal (bool);
static void updateTerminal(); static void updateTerminal();
void addPreprocessingHandler ( FVTerm* void addPreprocessingHandler ( FVTerm*
, FPreprocessingHandler ); , FPreprocessingHandler );
void delPreprocessingHandler (FVTerm*); void delPreprocessingHandler (FVTerm*);
int printf (const wchar_t*, ...); int printf (const wchar_t*, ...);
int printf (const char*, ...) int printf (const char*, ...)
#if defined(__clang__) #if defined(__clang__)
__attribute__((__format__ (__printf__, 2, 3))) __attribute__((__format__ (__printf__, 2, 3)))
#elif defined(__GNUC__) #elif defined(__GNUC__)
__attribute__ ((format (printf, 2, 3))) __attribute__ ((format (printf, 2, 3)))
#endif #endif
; ;
int print (const std::wstring&); int print (const std::wstring&);
int print (term_area*, const std::wstring&); int print (term_area*, const std::wstring&);
int print (const wchar_t*); int print (const wchar_t*);
int print (term_area*, const wchar_t*); int print (term_area*, const wchar_t*);
int print (const char*); int print (const char*);
int print (term_area*, const char*); int print (term_area*, const char*);
int print (const std::string&); int print (const std::string&);
int print (term_area*, const std::string&); int print (term_area*, const std::string&);
int print (const FString&); int print (const FString&);
int print (term_area*, const FString&); int print (term_area*, const FString&);
int print (const std::vector<char_data>&); int print (const std::vector<char_data>&);
int print (term_area*, const std::vector<char_data>&); int print (term_area*, const std::vector<char_data>&);
int print (int); int print (int);
int print (term_area*, int); int print (term_area*, int);
FVTerm& print(); FVTerm& print();
protected: protected:
// Enumeration // Enumeration
enum character_type enum character_type
{ {
overlapped_character, overlapped_character,
covered_character covered_character
}; };
// Accessor // Accessor
virtual term_area* getPrintArea(); virtual term_area* getPrintArea();
// Inquiries // Inquiries
bool hasPrintArea() const; bool hasPrintArea() const;
bool hasChildPrintArea() const; bool hasChildPrintArea() const;
bool isChildPrintArea() const; bool isChildPrintArea() const;
bool isVirtualWindow() const; bool isVirtualWindow() const;
// Mutator // Mutator
static void setInsertCursorStyle (bool on); static void setInsertCursorStyle (bool on);
static void setInsertCursorStyle(); static void setInsertCursorStyle();
static void unsetInsertCursorStyle(); static void unsetInsertCursorStyle();
// Methods // Methods
void createArea ( const FRect& void createArea ( const FRect&
, const FPoint& , const FPoint&
, term_area*& ); , term_area*& );
void createArea ( int, int, int, int void createArea ( int, int, int, int
, int, int , int, int
, term_area*& ); , term_area*& );
static void resizeArea ( const FRect& static void resizeArea ( const FRect&
, const FPoint& , const FPoint&
, term_area* );
static void resizeArea ( int, int, int, int
, int, int
, term_area* );
static void removeArea (term_area*&);
static void restoreVTerm (const FRect&);
static void restoreVTerm (int, int, int, int);
static covered_state isCovered ( const FPoint&
, term_area* ); , term_area* );
static void resizeArea ( int, int, int, int static covered_state isCovered ( int, int
, int, int
, term_area* ); , term_area* );
static void removeArea (term_area*&); static void updateVTerm();
static void restoreVTerm (const FRect&); static void updateVTerm (term_area*);
static void restoreVTerm (int, int, int, int); static bool updateVTermCursor (term_area*);
static bool isInsideArea (int, int, term_area*);
static covered_state isCovered ( const FPoint& static void setAreaCursor ( const FPoint&
, term_area* ); , bool, term_area* );
static covered_state isCovered ( int, int static void setAreaCursor ( int, int
, term_area* ); , bool, term_area*);
static void updateVTerm(); static void getArea (const FPoint&, term_area*);
static void updateVTerm (term_area*); static void getArea (int, int, term_area*);
static bool updateVTermCursor (term_area*); static void getArea (const FRect&, term_area*);
static bool isInsideArea (int, int, term_area*); static void getArea (int, int, int, int, term_area*);
static void putArea (const FPoint&, term_area*);
static void putArea (int, int, term_area*);
static void scrollAreaForward (term_area*);
static void scrollAreaReverse (term_area*);
static void clearArea (term_area*, int = ' ');
static void setAreaCursor ( const FPoint& static char_data getCharacter ( character_type
, bool, term_area* ); , const FPoint&
, FVTerm* );
static void setAreaCursor ( int, int static char_data getCharacter ( character_type
, bool, term_area*); , int
, int, FVTerm* );
static void getArea (const FPoint&, term_area*); static char_data getCoveredCharacter (const FPoint&, FVTerm*);
static void getArea (int, int, term_area*); static char_data getCoveredCharacter (int, int, FVTerm*);
static void getArea (const FRect&, term_area*); static char_data getOverlappedCharacter (const FPoint&, FVTerm*);
static void getArea (int, int, int, int, term_area*); static char_data getOverlappedCharacter (int, int, FVTerm*);
static void putArea (const FPoint&, term_area*); static void processTerminalUpdate();
static void putArea (int, int, term_area*); static void startTerminalUpdate();
static void scrollAreaForward (term_area*); static void finishTerminalUpdate();
static void scrollAreaReverse (term_area*); static void flush_out();
static void clearArea (term_area*, int = ' ');
static char_data getCharacter ( character_type // Data Members
, const FPoint& static term_area* vterm; // virtual terminal
, FVTerm* ); static term_area* vdesktop; // virtual desktop
static term_area* active_area; // active area
term_area* print_area; // print area for this object
term_area* child_print_area; // print area for children
term_area* vwin; // virtual window
static char_data getCharacter ( character_type private:
, int // Typedef
, int, FVTerm* ); typedef FTermcap::tcap_map termcap_map;
static char_data getCoveredCharacter (const FPoint&, FVTerm*); // Constants
static char_data getCoveredCharacter (int, int, FVTerm*); static const uInt TERMINAL_OUTPUT_BUFFER_SIZE = 32768;
static char_data getOverlappedCharacter (const FPoint&, FVTerm*); // Buffer size for character output on the terminal
static char_data getOverlappedCharacter (int, int, FVTerm*);
static void processTerminalUpdate();
static void startTerminalUpdate();
static void finishTerminalUpdate();
static void flush_out();
// Data Members // Disable copy constructor
static term_area* vterm; // virtual terminal FVTerm (const FVTerm&);
static term_area* vdesktop; // virtual desktop
static term_area* active_area; // active area
term_area* print_area; // print area for this object
term_area* child_print_area; // print area for children
term_area* vwin; // virtual window
private: // Disable assignment operator (=)
// Typedef FVTerm& operator = (const FVTerm&);
typedef FTermcap::tcap_map termcap_map;
// Constants // Mutators
static const uInt TERMINAL_OUTPUT_BUFFER_SIZE = 32768; void setPrintArea (term_area*);
// Buffer size for character output on the terminal
// Disable copy constructor // Methods
FVTerm (const FVTerm&); void init();
void finish();
static bool clearTerm (int = ' ');
static void updateTerminalLine (uInt);
static bool updateTerminalCursor();
static bool isInsideTerminal (int, int);
static void markAsPrinted (uInt, uInt);
static void markAsPrinted (uInt, uInt, uInt);
static void newFontChanges (char_data*&);
static void charsetChanges (char_data*&);
static void appendCharacter (char_data*&);
static void appendChar (char_data*&);
static void appendAttributes (char_data*&);
static int appendLowerRight (char_data*&);
static void appendOutputBuffer (const std::string&);
static void appendOutputBuffer (const char*&);
static int appendOutputBuffer (int);
// Disable assignment operator (=) // Data Members
FVTerm& operator = (const FVTerm&); static std::queue<int>* output_buffer;
static char_data term_attribute;
// Mutators static char_data next_attribute;
void setPrintArea (term_area*); static FPoint* term_pos; // terminal cursor position
static termcap_map* tcap;
// Methods static bool hidden_cursor;
void init(); static bool terminal_update_complete;
void finish(); static bool terminal_update_pending;
static bool clearTerm (int = ' '); static bool force_terminal_update;
static void updateTerminalLine (uInt); static bool stop_terminal_updates;
static bool updateTerminalCursor(); static int skipped_terminal_update;
static bool isInsideTerminal (int, int);
static void markAsPrinted (uInt, uInt);
static void markAsPrinted (uInt, uInt, uInt);
static void newFontChanges (char_data*&);
static void charsetChanges (char_data*&);
static void appendCharacter (char_data*&);
static void appendChar (char_data*&);
static void appendAttributes (char_data*&);
static int appendLowerRight (char_data*&);
static void appendOutputBuffer (std::string&);
static void appendOutputBuffer (const char* const&);
static int appendOutputBuffer (int);
// Data Members
static std::queue<int>* output_buffer;
static char_data term_attribute;
static char_data next_attribute;
static FPoint* term_pos; // terminal cursor position
static termcap_map* tcap;
static bool hidden_cursor;
static bool terminal_update_complete;
static bool terminal_update_pending;
static bool force_terminal_update;
static bool stop_terminal_updates;
static int skipped_terminal_update;
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -1,6 +1,8 @@
// File: fwidget.cpp // File: fwidget.cpp
// Provides: class FWidget // Provides: class FWidget
#include <vector>
#include "fapplication.h" #include "fapplication.h"
#include "fmenubar.h" #include "fmenubar.h"
#include "fstatusbar.h" #include "fstatusbar.h"
@ -44,19 +46,19 @@ FWidget::FWidget (FWidget* parent, bool disable_alt_screen)
, focus(false) , focus(false)
, focusable(true) , focusable(true)
, visible_cursor(true) , visible_cursor(true)
, widget_cursor_position(-1,-1) , widget_cursor_position(-1, -1)
, size_hints() , size_hints()
, double_flatline_mask() , double_flatline_mask()
, padding() , padding()
, ignore_padding(false) , ignore_padding(false)
, wsize(1,1,1,1) , wsize(1, 1, 1, 1)
, adjust_wsize(1,1,1,1) , adjust_wsize(1, 1, 1, 1)
, adjust_wsize_term() , adjust_wsize_term()
, adjust_wsize_shadow() , adjust_wsize_shadow()
, adjust_wsize_term_shadow() , adjust_wsize_term_shadow()
, offset() , offset()
, client_offset() , client_offset()
, wshadow(0,0) , wshadow(0, 0)
, foreground_color(fc::Default) , foreground_color(fc::Default)
, background_color(fc::Default) , background_color(fc::Default)
, statusbar_message() , statusbar_message()
@ -263,7 +265,6 @@ FPoint FWidget::getPrintPos()
int cy = cur.getY(); int cy = cur.getY();
return FPoint ( cx - offset.getX1() - getX() + 1 return FPoint ( cx - offset.getX1() - getX() + 1
, cy - offset.getY1() - getY() + 1 ); , cy - offset.getY1() - getY() + 1 );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -450,8 +451,8 @@ void FWidget::setPos (int x, int y, bool adjust)
y = 1; y = 1;
} }
wsize.setPos(x,y); wsize.setPos(x, y);
adjust_wsize.setPos(x,y); adjust_wsize.setPos(x, y);
if ( adjust ) if ( adjust )
adjustSize(); adjustSize();
@ -710,7 +711,7 @@ bool FWidget::setCursorPos (register int x, register int y)
{ {
// sets the input cursor position // sets the input cursor position
widget_cursor_position.setPoint(x,y); widget_cursor_position.setPoint(x, y);
if ( (flags & fc::focus) == 0 || isWindowWidget() ) if ( (flags & fc::focus) == 0 || isWindowWidget() )
return false; return false;
@ -857,7 +858,7 @@ FWidget* FWidget::childWidgetAt (FWidget* p, int x, int y)
if ( widget->isEnabled() if ( widget->isEnabled()
&& widget->isVisible() && widget->isVisible()
&& ! widget->isWindowWidget() && ! widget->isWindowWidget()
&& widget->getTermGeometry().contains(x,y) ) && widget->getTermGeometry().contains(x, y) )
{ {
FWidget* child = childWidgetAt(widget, x, y); FWidget* child = childWidgetAt(widget, x, y);
return (child != 0) ? child : widget; return (child != 0) ? child : widget;
@ -1405,8 +1406,8 @@ void FWidget::detectTermSize()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::move (int dx, int dy) void FWidget::move (int dx, int dy)
{ {
wsize.move(dx,dy); wsize.move(dx, dy);
adjust_wsize.move(dx,dy); adjust_wsize.move(dx, dy);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1482,8 +1483,8 @@ void FWidget::drawShadow()
else if ( FWidget* p = getParentWidget() ) else if ( FWidget* p = getParentWidget() )
setColor (wc.shadow_fg, p->getBackgroundColor()); setColor (wc.shadow_fg, p->getBackgroundColor());
block = fc::FullBlock; // █ block = fc::FullBlock; // █
print (fc::LowerHalfBlock); // ▄ print (fc::LowerHalfBlock); // ▄
if ( isWindowWidget() ) if ( isWindowWidget() )
unsetInheritBackground(); unsetInheritBackground();
@ -1491,7 +1492,7 @@ void FWidget::drawShadow()
for (int i = 1; i < getHeight(); i++) for (int i = 1; i < getHeight(); i++)
{ {
setPrintPos (x2 + 1, y1 + i); setPrintPos (x2 + 1, y1 + i);
print (block); // █ print (block); // █
} }
setPrintPos (x1 + 1, y2 + 1); setPrintPos (x1 + 1, y2 + 1);
@ -1500,7 +1501,7 @@ void FWidget::drawShadow()
setInheritBackground(); setInheritBackground();
for (int i = 1; i <= getWidth(); i++) for (int i = 1; i <= getWidth(); i++)
print (fc::UpperHalfBlock); // ▀ print (fc::UpperHalfBlock); // ▀
if ( isWindowWidget() ) if ( isWindowWidget() )
unsetInheritBackground(); unsetInheritBackground();
@ -1542,7 +1543,7 @@ void FWidget::clearShadow()
setPrintPos (x1 + 1, y2 + 1); setPrintPos (x1 + 1, y2 + 1);
for (int i = 1; i <= getWidth(); i++) for (int i = 1; i <= getWidth(); i++)
print (' '); // clear ▀ print (' '); // clear ▀
} }
if ( isWindowWidget() ) if ( isWindowWidget() )
@ -1572,9 +1573,11 @@ void FWidget::drawFlatBorder()
setPrintPos (x1 - 1, y1 + y + 1); setPrintPos (x1 - 1, y1 + y + 1);
if ( double_flatline_mask.left[uLong(y)] ) if ( double_flatline_mask.left[uLong(y)] )
print (fc::NF_rev_border_line_right_and_left); // left+right line (on left side) // left+right line (on left side)
print (fc::NF_rev_border_line_right_and_left);
else else
print (fc::NF_rev_border_line_right); // right line (on left side) // right line (on left side)
print (fc::NF_rev_border_line_right);
} }
setPrintPos (x2, y1 + 1); setPrintPos (x2, y1 + 1);
@ -1582,9 +1585,11 @@ void FWidget::drawFlatBorder()
for (int y = 0; y < getHeight(); y++) for (int y = 0; y < getHeight(); y++)
{ {
if ( double_flatline_mask.right[uLong(y)] ) if ( double_flatline_mask.right[uLong(y)] )
print (fc::NF_rev_border_line_right_and_left); // left+right line (on right side) // left+right line (on right side)
print (fc::NF_rev_border_line_right_and_left);
else else
print (fc::NF_border_line_left); // left line (on right side) // left line (on right side)
print (fc::NF_border_line_left);
setPrintPos (x2, y1 + y + 2); setPrintPos (x2, y1 + y + 2);
} }
@ -1594,9 +1599,11 @@ void FWidget::drawFlatBorder()
for (int x = 0; x < getWidth(); x++) for (int x = 0; x < getWidth(); x++)
{ {
if ( double_flatline_mask.top[uLong(x)] ) if ( double_flatline_mask.top[uLong(x)] )
print (fc::NF_border_line_up_and_down); // top+bottom line (at top) // top+bottom line (at top)
print (fc::NF_border_line_up_and_down);
else else
print (fc::NF_border_line_bottom); // bottom line (at top) // bottom line (at top)
print (fc::NF_border_line_bottom);
} }
setPrintPos (x1, y2); setPrintPos (x1, y2);
@ -1604,9 +1611,11 @@ void FWidget::drawFlatBorder()
for (int x = 0; x < getWidth(); x++) for (int x = 0; x < getWidth(); x++)
{ {
if ( double_flatline_mask.bottom[uLong(x)] ) if ( double_flatline_mask.bottom[uLong(x)] )
print (fc::NF_border_line_up_and_down); // top+bottom line (at bottom) // top+bottom line (at bottom)
print (fc::NF_border_line_up_and_down);
else else
print (fc::NF_border_line_upper); // top line (at bottom) // top line (at bottom)
print (fc::NF_border_line_upper);
} }
} }
@ -1697,61 +1706,61 @@ void FWidget::drawBorder (int x1, int y1, int x2, int y2)
if ( isNewFont() ) if ( isNewFont() )
{ {
setPrintPos (x1, y1); setPrintPos (x1, y1);
print (fc::NF_border_corner_middle_upper_left); // ┌ print (fc::NF_border_corner_middle_upper_left); // ┌
for (int x = x1 + 1; x < x2; x++) for (int x = x1 + 1; x < x2; x++)
print (fc::BoxDrawingsHorizontal); // ─ print (fc::BoxDrawingsHorizontal); // ─
print (fc::NF_border_corner_middle_upper_right); // ┐ print (fc::NF_border_corner_middle_upper_right); // ┐
for (int y = y1 + 1; y <= y2; y++) for (int y = y1 + 1; y <= y2; y++)
{ {
setPrintPos (x1, y); setPrintPos (x1, y);
print (fc::NF_border_line_left); // border left ⎸ print (fc::NF_border_line_left); // border left ⎸
setPrintPos (x2, y); setPrintPos (x2, y);
print (fc::NF_rev_border_line_right); // border right⎹ print (fc::NF_rev_border_line_right); // border right⎹
} }
setPrintPos (x1, y2); setPrintPos (x1, y2);
print (fc::NF_border_corner_middle_lower_left); // └ print (fc::NF_border_corner_middle_lower_left); // └
for (int x = x1 + 1; x < x2; x++) for (int x = x1 + 1; x < x2; x++)
print (fc::BoxDrawingsHorizontal); // ─ print (fc::BoxDrawingsHorizontal); // ─
print (fc::NF_border_corner_middle_lower_right); // ┘ print (fc::NF_border_corner_middle_lower_right); // ┘
} }
else else
{ {
setPrintPos (x1, y1); setPrintPos (x1, y1);
print (fc::BoxDrawingsDownAndRight); // ┌ print (fc::BoxDrawingsDownAndRight); // ┌
for (int x = x1 + 1; x < x2; x++) for (int x = x1 + 1; x < x2; x++)
print (fc::BoxDrawingsHorizontal); // ─ print (fc::BoxDrawingsHorizontal); // ─
print (fc::BoxDrawingsDownAndLeft); // ┐ print (fc::BoxDrawingsDownAndLeft); // ┐
for (int y = y1 + 1; y < y2; y++) for (int y = y1 + 1; y < y2; y++)
{ {
setPrintPos (x1, y); setPrintPos (x1, y);
print (fc::BoxDrawingsVertical); // │ print (fc::BoxDrawingsVertical); // │
setPrintPos (x2, y); setPrintPos (x2, y);
print (fc::BoxDrawingsVertical); // │ print (fc::BoxDrawingsVertical); // │
} }
setPrintPos (x1, y2); setPrintPos (x1, y2);
print (fc::BoxDrawingsUpAndRight); // └ print (fc::BoxDrawingsUpAndRight); // └
for (int x = x1 + 1; x < x2; x++) for (int x = x1 + 1; x < x2; x++)
print (fc::BoxDrawingsHorizontal); // ─ print (fc::BoxDrawingsHorizontal); // ─
print (fc::BoxDrawingsUpAndLeft); // ┘ print (fc::BoxDrawingsUpAndLeft); // ┘
for (int x = x1 + 1; x < x2; x++) for (int x = x1 + 1; x < x2; x++)
{ {
setPrintPos (x, y1); setPrintPos (x, y1);
print (fc::BoxDrawingsHorizontal); // ─ print (fc::BoxDrawingsHorizontal); // ─
setPrintPos (x, y2); setPrintPos (x, y2);
print (fc::BoxDrawingsHorizontal); // ─ print (fc::BoxDrawingsHorizontal); // ─
} }
} }
} }
@ -2431,7 +2440,7 @@ void FWidget::setColorTheme()
wc.tooltip_fg = fc::Black; wc.tooltip_fg = fc::Black;
wc.tooltip_bg = fc::Yellow; wc.tooltip_bg = fc::Yellow;
wc.shadow_fg = fc::Black; wc.shadow_fg = fc::Black;
wc.shadow_bg = fc::LightGray; // only for transparent shadow wc.shadow_bg = fc::LightGray; // only for transparent shadow
wc.current_element_focus_fg = fc::White; wc.current_element_focus_fg = fc::White;
wc.current_element_focus_bg = fc::Blue; wc.current_element_focus_bg = fc::Blue;
wc.current_element_fg = fc::LightGray; wc.current_element_fg = fc::LightGray;
@ -2521,7 +2530,7 @@ void FWidget::setColorTheme()
wc.tooltip_fg = fc::LightGray; wc.tooltip_fg = fc::LightGray;
wc.tooltip_bg = fc::Cyan; wc.tooltip_bg = fc::Cyan;
wc.shadow_fg = fc::Black; wc.shadow_fg = fc::Black;
wc.shadow_bg = fc::LightGray; // only for transparent shadow wc.shadow_bg = fc::LightGray; // only for transparent shadow
wc.current_element_focus_fg = fc::LightGray; wc.current_element_focus_fg = fc::LightGray;
wc.current_element_focus_bg = fc::Red; wc.current_element_focus_bg = fc::Red;
wc.current_element_fg = fc::LightGray; wc.current_element_fg = fc::LightGray;

View File

@ -71,6 +71,8 @@
#ifndef FWIDGET_H #ifndef FWIDGET_H
#define FWIDGET_H #define FWIDGET_H
#include <vector>
#include "fvterm.h" #include "fvterm.h"
@ -95,448 +97,448 @@ class FMenuBar;
class FWidget : public FVTerm class FWidget : public FVTerm
{ {
public: public:
// Using-declaration // Using-declaration
using FVTerm::setColor; using FVTerm::setColor;
struct accelerator struct accelerator
{ {
int key; int key;
FWidget* object; FWidget* object;
}; };
// Typedefs // Typedefs
typedef std::vector<FWidget*> widgetList; typedef std::vector<FWidget*> widgetList;
typedef void* data_ptr; typedef void* data_ptr;
typedef void (*FCallback)(FWidget*, data_ptr); typedef void (*FCallback)(FWidget*, data_ptr);
typedef void (FWidget::*FMemberCallback)(FWidget*, data_ptr); typedef void (FWidget::*FMemberCallback)(FWidget*, data_ptr);
typedef std::vector<accelerator> Accelerators; typedef std::vector<accelerator> Accelerators;
// Constructor // Constructor
explicit FWidget (FWidget* = 0, bool = false); explicit FWidget (FWidget* = 0, bool = false);
// Destructor // Destructor
~FWidget(); ~FWidget();
// Accessors // Accessors
const char* getClassName() const; const char* getClassName() const;
FWidget* getRootWidget() const; FWidget* getRootWidget() const;
FWidget* getParentWidget() const; FWidget* getParentWidget() const;
static FWidget* getMainWidget(); static FWidget* getMainWidget();
virtual FWidget* getFocusWidget() const; virtual FWidget* getFocusWidget() const;
virtual FWidget* getFirstFocusableWidget (FObjectList); virtual FWidget* getFirstFocusableWidget (FObjectList);
virtual FWidget* getLastFocusableWidget (FObjectList); virtual FWidget* getLastFocusableWidget (FObjectList);
static FWidget* getClickedWidget(); static FWidget* getClickedWidget();
static FWidget* getMoveSizeWidget(); static FWidget* getMoveSizeWidget();
static FWidget* getOpenMenu(); static FWidget* getOpenMenu();
static FMenuBar* getMenuBar(); static FMenuBar* getMenuBar();
static FStatusBar* getStatusBar(); static FStatusBar* getStatusBar();
FString getStatusbarMessage() const; FString getStatusbarMessage() const;
short getForegroundColor() const; // get the primary short getForegroundColor() const; // get the primary
short getBackgroundColor() const; // widget colors short getBackgroundColor() const; // widget colors
int getX() const; // positioning int getX() const; // positioning
int getY() const; int getY() const;
const FPoint getPos() const; const FPoint getPos() const;
int getTermX() const; int getTermX() const;
int getTermY() const; int getTermY() const;
const FPoint getTermPos() const; const FPoint getTermPos() const;
int getWidth() const; int getWidth() const;
int getHeight() const; int getHeight() const;
int getTopPadding() const; int getTopPadding() const;
int getLeftPadding() const; int getLeftPadding() const;
int getBottomPadding() const; int getBottomPadding() const;
int getRightPadding() const; int getRightPadding() const;
int getClientWidth() const; int getClientWidth() const;
int getClientHeight() const; int getClientHeight() const;
int getMaxWidth() const; int getMaxWidth() const;
int getMaxHeight() const; int getMaxHeight() const;
const FPoint& getShadow() const; const FPoint& getShadow() const;
const FRect& getGeometry() const; const FRect& getGeometry() const;
const FRect& getGeometryWithShadow(); const FRect& getGeometryWithShadow();
const FRect& getTermGeometry(); const FRect& getTermGeometry();
const FRect& getTermGeometryWithShadow(); const FRect& getTermGeometryWithShadow();
int getFlags() const; int getFlags() const;
FPoint getCursorPos(); FPoint getCursorPos();
FPoint getPrintPos(); FPoint getPrintPos();
std::vector<bool>& doubleFlatLine_ref (fc::sides); std::vector<bool>& doubleFlatLine_ref (fc::sides);
// Mutators // Mutators
static void setMainWidget (FWidget*); static void setMainWidget (FWidget*);
virtual void setFocusWidget (FWidget*); virtual void setFocusWidget (FWidget*);
static void setClickedWidget (FWidget*); static void setClickedWidget (FWidget*);
static void setMoveSizeWidget (FWidget*); static void setMoveSizeWidget (FWidget*);
static void setOpenMenu (FWidget*); static void setOpenMenu (FWidget*);
virtual void setStatusbarMessage (const FString&); virtual void setStatusbarMessage (const FString&);
bool setVisible(); bool setVisible();
virtual bool setEnable (bool); virtual bool setEnable (bool);
virtual bool setEnable(); virtual bool setEnable();
virtual bool unsetEnable(); virtual bool unsetEnable();
virtual bool setDisable(); virtual bool setDisable();
virtual bool setVisibleCursor (bool); // input cursor visibility virtual bool setVisibleCursor (bool); // input cursor visibility
virtual bool setVisibleCursor(); // for the widget virtual bool setVisibleCursor(); // for the widget
virtual bool unsetVisibleCursor(); virtual bool unsetVisibleCursor();
virtual bool setFocus (bool); virtual bool setFocus (bool);
virtual bool setFocus(); virtual bool setFocus();
virtual bool unsetFocus(); virtual bool unsetFocus();
void setFocusable(); void setFocusable();
void unsetFocusable(); void unsetFocusable();
bool ignorePadding (bool); // ignore padding from bool ignorePadding (bool); // ignore padding from
bool ignorePadding(); // the parent widget bool ignorePadding(); // the parent widget
bool acceptPadding(); bool acceptPadding();
void setForegroundColor (short); void setForegroundColor (short);
void setBackgroundColor (short); void setBackgroundColor (short);
void setColor(); void setColor();
virtual void setX (int, bool = true); // positioning virtual void setX (int, bool = true); // positioning
virtual void setY (int, bool = true); virtual void setY (int, bool = true);
virtual void setPos (const FPoint&, bool = true); virtual void setPos (const FPoint&, bool = true);
virtual void setPos (int, int, bool = true); virtual void setPos (int, int, bool = true);
virtual void setWidth (int, bool = true); virtual void setWidth (int, bool = true);
virtual void setHeight (int, bool = true); virtual void setHeight (int, bool = true);
virtual void setSize (int, int, bool = true); virtual void setSize (int, int, bool = true);
void setTopPadding (int, bool = true); void setTopPadding (int, bool = true);
void setLeftPadding (int, bool = true); void setLeftPadding (int, bool = true);
void setBottomPadding (int, bool = true); void setBottomPadding (int, bool = true);
void setRightPadding (int, bool = true); void setRightPadding (int, bool = true);
void setParentOffset(); void setParentOffset();
void setTermOffset(); void setTermOffset();
void setTermOffsetWithPadding(); void setTermOffsetWithPadding();
void setTermSize (int, int); void setTermSize (int, int);
virtual void setGeometry (const FRect&, bool = true); virtual void setGeometry (const FRect&, bool = true);
virtual void setGeometry (int, int, int, int, bool = true); virtual void setGeometry (int, int, int, int, bool = true);
virtual void setShadowSize (int, int); virtual void setShadowSize (int, int);
void setMinimumWidth (int); void setMinimumWidth (int);
void setMinimumHeight (int); void setMinimumHeight (int);
void setMinimumSize (int, int); void setMinimumSize (int, int);
void setMaximumWidth (int); void setMaximumWidth (int);
void setMaximumHeight (int); void setMaximumHeight (int);
void setMaximumSize (int, int); void setMaximumSize (int, int);
void setFixedSize (int, int); void setFixedSize (int, int);
bool setCursorPos (const FPoint&); bool setCursorPos (const FPoint&);
bool setCursorPos (register int, register int); bool setCursorPos (register int, register int);
void unsetCursorPos(); void unsetCursorPos();
void setPrintPos (const FPoint&); void setPrintPos (const FPoint&);
void setPrintPos (register int, register int); void setPrintPos (register int, register int);
void setDoubleFlatLine (fc::sides, bool = true); void setDoubleFlatLine (fc::sides, bool = true);
void unsetDoubleFlatLine (fc::sides); void unsetDoubleFlatLine (fc::sides);
void setDoubleFlatLine (fc::sides, int, bool = true); void setDoubleFlatLine (fc::sides, int, bool = true);
void unsetDoubleFlatLine (fc::sides, int); void unsetDoubleFlatLine (fc::sides, int);
// Inquiries // Inquiries
bool isRootWidget() const; bool isRootWidget() const;
bool isWindowWidget() const; bool isWindowWidget() const;
bool isDialogWidget() const; bool isDialogWidget() const;
bool isMenuWidget() const; bool isMenuWidget() const;
bool isVisible() const; bool isVisible() const;
bool isShown() const; bool isShown() const;
bool isEnabled() const; bool isEnabled() const;
bool hasVisibleCursor() const; bool hasVisibleCursor() const;
bool hasFocus() const; bool hasFocus() const;
bool acceptFocus() const; // is focusable bool acceptFocus() const; // is focusable
bool isPaddingIgnored(); bool isPaddingIgnored();
// Methods // Methods
static FWidget* childWidgetAt (FWidget*, const FPoint&); static FWidget* childWidgetAt (FWidget*, const FPoint&);
static FWidget* childWidgetAt (FWidget*, int, int); static FWidget* childWidgetAt (FWidget*, int, int);
int numOfFocusableChildren(); int numOfFocusableChildren();
virtual bool close(); virtual bool close();
void clearStatusbarMessage(); void clearStatusbarMessage();
void addCallback ( const FString& void addCallback ( const FString&
, FCallback , FCallback
, data_ptr = null ); , data_ptr = null );
void addCallback ( const FString& void addCallback ( const FString&
, FWidget* , FWidget*
, FMemberCallback , FMemberCallback
, data_ptr = null ); , data_ptr = null );
void delCallback (FCallback); void delCallback (FCallback);
void delCallback (FWidget*); void delCallback (FWidget*);
void delCallbacks(); void delCallbacks();
void emitCallback (const FString&); void emitCallback (const FString&);
void addAccelerator (int); void addAccelerator (int);
virtual void addAccelerator (int, FWidget*); virtual void addAccelerator (int, FWidget*);
void delAccelerator (); void delAccelerator ();
virtual void delAccelerator (FWidget*); virtual void delAccelerator (FWidget*);
virtual void redraw(); virtual void redraw();
virtual void resize(); virtual void resize();
virtual void show(); virtual void show();
virtual void hide(); virtual void hide();
virtual bool focusFirstChild(); // widget focusing virtual bool focusFirstChild(); // widget focusing
virtual bool focusLastChild(); virtual bool focusLastChild();
FPoint termToWidgetPos (const FPoint&); FPoint termToWidgetPos (const FPoint&);
void detectTermSize(); void detectTermSize();
virtual void move (const FPoint&); virtual void move (const FPoint&);
virtual void move (int, int); virtual void move (int, int);
void drawShadow(); void drawShadow();
void clearShadow(); void clearShadow();
void drawFlatBorder(); void drawFlatBorder();
void clearFlatBorder(); void clearFlatBorder();
virtual void drawBorder (int, int, int, int); virtual void drawBorder (int, int, int, int);
virtual void drawBorder(); virtual void drawBorder();
static void quit(); static void quit();
// Data Members // Data Members
static widgetList* window_list; static widgetList* window_list;
Accelerators* accelerator_list; Accelerators* accelerator_list;
protected: protected:
struct callback_data struct callback_data
{ {
FString cb_signal; FString cb_signal;
FCallback cb_handler; FCallback cb_handler;
data_ptr data; data_ptr data;
}; };
struct member_callback_data struct member_callback_data
{ {
FString cb_signal; FString cb_signal;
FWidget* cb_instance; FWidget* cb_instance;
FMemberCallback cb_handler; FMemberCallback cb_handler;
data_ptr data; data_ptr data;
}; };
// Typedefs // Typedefs
typedef std::vector<callback_data> CallbackObjects; typedef std::vector<callback_data> CallbackObjects;
typedef std::vector<member_callback_data> MemberCallbackObjects; typedef std::vector<member_callback_data> MemberCallbackObjects;
// Mutators // Mutators
virtual void setStatusBar (FStatusBar*); virtual void setStatusBar (FStatusBar*);
virtual void setMenuBar (FMenuBar*); virtual void setMenuBar (FMenuBar*);
// Methods // Methods
virtual void adjustSize(); virtual void adjustSize();
void adjustSizeGlobal(); void adjustSizeGlobal();
virtual bool focusNextChild(); // Change child virtual bool focusNextChild(); // Change child
virtual bool focusPrevChild(); // focus virtual bool focusPrevChild(); // focus
// Event handlers // Event handlers
bool event (FEvent*); bool event (FEvent*);
virtual void onKeyPress (FKeyEvent*); virtual void onKeyPress (FKeyEvent*);
virtual void onKeyUp (FKeyEvent*); virtual void onKeyUp (FKeyEvent*);
virtual void onKeyDown (FKeyEvent*); virtual void onKeyDown (FKeyEvent*);
virtual void onMouseDown (FMouseEvent*); virtual void onMouseDown (FMouseEvent*);
virtual void onMouseUp (FMouseEvent*); virtual void onMouseUp (FMouseEvent*);
virtual void onMouseDoubleClick (FMouseEvent*); virtual void onMouseDoubleClick (FMouseEvent*);
virtual void onWheel (FWheelEvent*); virtual void onWheel (FWheelEvent*);
virtual void onMouseMove (FMouseEvent*); virtual void onMouseMove (FMouseEvent*);
virtual void onFocusIn (FFocusEvent*); virtual void onFocusIn (FFocusEvent*);
virtual void onFocusOut (FFocusEvent*); virtual void onFocusOut (FFocusEvent*);
virtual void onChildFocusIn (FFocusEvent*); virtual void onChildFocusIn (FFocusEvent*);
virtual void onChildFocusOut (FFocusEvent*); virtual void onChildFocusOut (FFocusEvent*);
virtual void onAccel (FAccelEvent*); virtual void onAccel (FAccelEvent*);
virtual void onResize (FResizeEvent*); virtual void onResize (FResizeEvent*);
virtual void onShow (FShowEvent*); virtual void onShow (FShowEvent*);
virtual void onHide (FHideEvent*); virtual void onHide (FHideEvent*);
virtual void onClose (FCloseEvent*); virtual void onClose (FCloseEvent*);
// Data Members // Data Members
static struct widget_colors static struct widget_colors
{ {
short term_fg; short term_fg;
short term_bg; short term_bg;
short list_fg; short list_fg;
short list_bg; short list_bg;
short selected_list_fg; short selected_list_fg;
short selected_list_bg; short selected_list_bg;
short current_element_focus_fg; short current_element_focus_fg;
short current_element_focus_bg; short current_element_focus_bg;
short current_element_fg; short current_element_fg;
short current_element_bg; short current_element_bg;
short current_inc_search_element_fg; short current_inc_search_element_fg;
short selected_current_element_focus_fg; short selected_current_element_focus_fg;
short selected_current_element_focus_bg; short selected_current_element_focus_bg;
short selected_current_element_fg; short selected_current_element_fg;
short selected_current_element_bg; short selected_current_element_bg;
short label_fg; short label_fg;
short label_bg; short label_bg;
short label_inactive_fg; short label_inactive_fg;
short label_inactive_bg; short label_inactive_bg;
short label_hotkey_fg; short label_hotkey_fg;
short label_hotkey_bg; short label_hotkey_bg;
short label_emphasis_fg; short label_emphasis_fg;
short label_ellipsis_fg; short label_ellipsis_fg;
short inputfield_active_focus_fg; short inputfield_active_focus_fg;
short inputfield_active_focus_bg; short inputfield_active_focus_bg;
short inputfield_active_fg; short inputfield_active_fg;
short inputfield_active_bg; short inputfield_active_bg;
short inputfield_inactive_fg; short inputfield_inactive_fg;
short inputfield_inactive_bg; short inputfield_inactive_bg;
short dialog_fg; short dialog_fg;
short dialog_resize_fg; short dialog_resize_fg;
short dialog_emphasis_fg; short dialog_emphasis_fg;
short dialog_bg; short dialog_bg;
short error_box_fg; short error_box_fg;
short error_box_emphasis_fg; short error_box_emphasis_fg;
short error_box_bg; short error_box_bg;
short tooltip_fg; short tooltip_fg;
short tooltip_bg; short tooltip_bg;
short shadow_fg; short shadow_fg;
short shadow_bg; short shadow_bg;
short toggle_button_active_focus_fg; short toggle_button_active_focus_fg;
short toggle_button_active_focus_bg; short toggle_button_active_focus_bg;
short toggle_button_active_fg; short toggle_button_active_fg;
short toggle_button_active_bg; short toggle_button_active_bg;
short toggle_button_inactive_fg; short toggle_button_inactive_fg;
short toggle_button_inactive_bg; short toggle_button_inactive_bg;
short button_active_focus_fg; short button_active_focus_fg;
short button_active_focus_bg; short button_active_focus_bg;
short button_active_fg; short button_active_fg;
short button_active_bg; short button_active_bg;
short button_inactive_fg; short button_inactive_fg;
short button_inactive_bg; short button_inactive_bg;
short button_hotkey_fg; short button_hotkey_fg;
short titlebar_active_fg; short titlebar_active_fg;
short titlebar_active_bg; short titlebar_active_bg;
short titlebar_inactive_fg; short titlebar_inactive_fg;
short titlebar_inactive_bg; short titlebar_inactive_bg;
short titlebar_button_fg; short titlebar_button_fg;
short titlebar_button_bg; short titlebar_button_bg;
short titlebar_button_focus_fg; short titlebar_button_focus_fg;
short titlebar_button_focus_bg; short titlebar_button_focus_bg;
short menu_active_focus_fg; short menu_active_focus_fg;
short menu_active_focus_bg; short menu_active_focus_bg;
short menu_active_fg; short menu_active_fg;
short menu_active_bg; short menu_active_bg;
short menu_inactive_fg; short menu_inactive_fg;
short menu_inactive_bg; short menu_inactive_bg;
short menu_hotkey_fg; short menu_hotkey_fg;
short menu_hotkey_bg; short menu_hotkey_bg;
short statusbar_fg; short statusbar_fg;
short statusbar_bg; short statusbar_bg;
short statusbar_hotkey_fg; short statusbar_hotkey_fg;
short statusbar_hotkey_bg; short statusbar_hotkey_bg;
short statusbar_separator_fg; short statusbar_separator_fg;
short statusbar_active_fg; short statusbar_active_fg;
short statusbar_active_bg; short statusbar_active_bg;
short statusbar_active_hotkey_fg; short statusbar_active_hotkey_fg;
short statusbar_active_hotkey_bg; short statusbar_active_hotkey_bg;
short scrollbar_fg; short scrollbar_fg;
short scrollbar_bg; short scrollbar_bg;
short scrollbar_button_fg; short scrollbar_button_fg;
short scrollbar_button_bg; short scrollbar_button_bg;
short progressbar_fg; short progressbar_fg;
short progressbar_bg; short progressbar_bg;
} wc; } wc;
// widget_colors wc; // widget_colors wc;
int flags; int flags;
static uInt modal_dialogs; static uInt modal_dialogs;
static widgetList* dialog_list; static widgetList* dialog_list;
static widgetList* always_on_top_list; static widgetList* always_on_top_list;
static widgetList* close_widget; static widgetList* close_widget;
CallbackObjects callback_objects; CallbackObjects callback_objects;
MemberCallbackObjects member_callback_objects; MemberCallbackObjects member_callback_objects;
private: private:
// Disable copy constructor // Disable copy constructor
FWidget (const FWidget&); FWidget (const FWidget&);
// Disable assignment operator (=) // Disable assignment operator (=)
FWidget& operator = (const FWidget&); FWidget& operator = (const FWidget&);
// Methods // Methods
void init(); void init();
void finish(); void finish();
void insufficientSpaceAdjust(); void insufficientSpaceAdjust();
void processDestroy(); void processDestroy();
virtual void draw(); virtual void draw();
static void setColorTheme(); static void setColorTheme();
// Data Members // Data Members
bool enable; bool enable;
bool visible; bool visible;
bool shown; bool shown;
bool focus; bool focus;
bool focusable; bool focusable;
bool visible_cursor; bool visible_cursor;
FPoint widget_cursor_position; FPoint widget_cursor_position;
struct widget_size_hints struct widget_size_hints
{ {
widget_size_hints() widget_size_hints()
: min_width (INT_MIN) : min_width (INT_MIN)
, min_height (INT_MIN) , min_height (INT_MIN)
, max_width (INT_MAX) , max_width (INT_MAX)
, max_height (INT_MAX) , max_height (INT_MAX)
{ } { }
~widget_size_hints() ~widget_size_hints()
{ } { }
void setMinimum (int w, int h) void setMinimum (int w, int h)
{ {
min_width = w; min_width = w;
min_height = h; min_height = h;
} }
void setMaximum (int w, int h) void setMaximum (int w, int h)
{ {
max_width = w; max_width = w;
max_height = h; max_height = h;
} }
int min_width; int min_width;
int min_height; int min_height;
int max_width; int max_width;
int max_height; int max_height;
} size_hints; } size_hints;
struct dbl_line_mask struct dbl_line_mask
{ {
dbl_line_mask() : top(), right(), bottom(), left() dbl_line_mask() : top(), right(), bottom(), left()
{ } { }
~dbl_line_mask() ~dbl_line_mask()
{ } { }
std::vector<bool> top; std::vector<bool> top;
std::vector<bool> right; std::vector<bool> right;
std::vector<bool> bottom; std::vector<bool> bottom;
std::vector<bool> left; std::vector<bool> left;
} double_flatline_mask; } double_flatline_mask;
struct widget_padding struct widget_padding
{ {
widget_padding() : top(0), left(0), bottom(0), right(0) widget_padding() : top(0), left(0), bottom(0), right(0)
{ } { }
~widget_padding() ~widget_padding()
{ } { }
int top; int top;
int left; int left;
int bottom; int bottom;
int right; int right;
} padding; } padding;
bool ignore_padding; bool ignore_padding;
// widget size // widget size
FRect wsize; FRect wsize;
FRect adjust_wsize; FRect adjust_wsize;
FRect adjust_wsize_term; FRect adjust_wsize_term;
FRect adjust_wsize_shadow; FRect adjust_wsize_shadow;
FRect adjust_wsize_term_shadow; FRect adjust_wsize_term_shadow;
// widget offset // widget offset
FRect offset; FRect offset;
// offset of the widget client area // offset of the widget client area
FRect client_offset; FRect client_offset;
// widget shadow size (on the right and bottom side) // widget shadow size (on the right and bottom side)
FPoint wshadow; FPoint wshadow;
// default widget foreground and background color // default widget foreground and background color
short foreground_color; short foreground_color;
short background_color; short background_color;
FString statusbar_message; FString statusbar_message;
static FStatusBar* statusbar; static FStatusBar* statusbar;
static FMenuBar* menubar; static FMenuBar* menubar;
static FWidget* show_root_widget; static FWidget* show_root_widget;
static FWidget* redraw_root_widget; static FWidget* redraw_root_widget;
static bool init_desktop; static bool init_desktop;
static bool hideable; static bool hideable;
// Friend class // Friend class
friend class FToggleButton; friend class FToggleButton;
friend class FScrollView; friend class FScrollView;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -804,7 +806,7 @@ inline bool FWidget::setCursorPos (const FPoint& pos)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FWidget::unsetCursorPos() inline void FWidget::unsetCursorPos()
{ setCursorPos(-1,-1); } { setCursorPos(-1, -1); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FWidget::setPrintPos (const FPoint& pos) inline void FWidget::setPrintPos (const FPoint& pos)

View File

@ -25,7 +25,7 @@ FWindow::FWindow(FWidget* parent)
{ {
setWindowWidget(); setWindowWidget();
FRect geometry = getTermGeometry(); FRect geometry = getTermGeometry();
geometry.move(-1,-1); geometry.move(-1, -1);
createArea (geometry, getShadow(), vwin); createArea (geometry, getShadow(), vwin);
addWindow (this); addWindow (this);
} }
@ -261,12 +261,12 @@ void FWindow::drawBorder()
int y2 = 1 + getHeight() - 1; int y2 = 1 + getHeight() - 1;
setPrintPos (x1, y1); setPrintPos (x1, y1);
print (fc::NF_border_corner_upper_left); // ⎡ print (fc::NF_border_corner_upper_left); // ⎡
for (int x = x1 + 1; x < x2; x++) for (int x = x1 + 1; x < x2; x++)
print (fc::NF_border_line_upper); // ¯ print (fc::NF_border_line_upper); // ¯
print (fc::NF_rev_border_corner_upper_right); // ⎤ print (fc::NF_rev_border_corner_upper_right); // ⎤
for (int y = y1 + 1; y < y2; y++) for (int y = y1 + 1; y < y2; y++)
{ {
@ -282,7 +282,7 @@ void FWindow::drawBorder()
// lower left corner border ⎣ // lower left corner border ⎣
print (fc::NF_border_corner_lower_left); print (fc::NF_border_corner_lower_left);
for (int x = 2; x < getWidth(); x++) // low line _ for (int x = 2; x < getWidth(); x++) // low line _
print (fc::NF_border_line_bottom); print (fc::NF_border_line_bottom);
setPrintPos (x2, y2); setPrintPos (x2, y2);
@ -358,7 +358,7 @@ void FWindow::setWidth (int w, bool adjust)
if ( isVirtualWindow() && getWidth() != old_width ) if ( isVirtualWindow() && getWidth() != old_width )
{ {
FRect geometry = getTermGeometry(); FRect geometry = getTermGeometry();
geometry.move(-1,-1); geometry.move(-1, -1);
resizeArea (geometry, getShadow(), vwin); resizeArea (geometry, getShadow(), vwin);
} }
} }
@ -372,7 +372,7 @@ void FWindow::setHeight (int h, bool adjust)
if ( isVirtualWindow() && getHeight() != old_height ) if ( isVirtualWindow() && getHeight() != old_height )
{ {
FRect geometry = getTermGeometry(); FRect geometry = getTermGeometry();
geometry.move(-1,-1); geometry.move(-1, -1);
resizeArea (geometry, getShadow(), vwin); resizeArea (geometry, getShadow(), vwin);
} }
} }
@ -384,10 +384,11 @@ void FWindow::setSize (int w, int h, bool adjust)
int old_height = getHeight(); int old_height = getHeight();
FWidget::setSize (w, h, adjust); FWidget::setSize (w, h, adjust);
if ( isVirtualWindow() && (getWidth() != old_width || getHeight() != old_height) ) if ( isVirtualWindow()
&& (getWidth() != old_width || getHeight() != old_height) )
{ {
FRect geometry = getTermGeometry(); FRect geometry = getTermGeometry();
geometry.move(-1,-1); geometry.move(-1, -1);
resizeArea (geometry, getShadow(), vwin); resizeArea (geometry, getShadow(), vwin);
} }
} }
@ -413,7 +414,7 @@ void FWindow::setGeometry (int x, int y, int w, int h, bool adjust)
if ( getWidth() != old_width || getHeight() != old_height ) if ( getWidth() != old_width || getHeight() != old_height )
{ {
FRect geometry = getTermGeometry(); FRect geometry = getTermGeometry();
geometry.move(-1,-1); geometry.move(-1, -1);
resizeArea (geometry, getShadow(), vwin); resizeArea (geometry, getShadow(), vwin);
} }
else else
@ -429,7 +430,7 @@ void FWindow::setGeometry (int x, int y, int w, int h, bool adjust)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWindow::move (int dx, int dy) void FWindow::move (int dx, int dy)
{ {
FWidget::move (dx,dy); FWidget::move (dx, dy);
if ( isVirtualWindow() ) if ( isVirtualWindow() )
{ {
@ -456,12 +457,11 @@ FWindow* FWindow::getWindowWidgetAt (int x, int y)
FWindow* w = static_cast<FWindow*>(*iter); FWindow* w = static_cast<FWindow*>(*iter);
if ( ! w->isWindowHidden() if ( ! w->isWindowHidden()
&& w->getTermGeometry().contains(x,y) ) && w->getTermGeometry().contains(x, y) )
return w; return w;
} }
} }
while ( iter != begin ); while ( iter != begin );
} }
return 0; return 0;
@ -779,10 +779,11 @@ void FWindow::setShadowSize (int right, int bottom)
new_right = getShadow().getX(); new_right = getShadow().getX();
new_bottom = getShadow().getY(); new_bottom = getShadow().getY();
if ( isVirtualWindow() && (new_right != old_right || new_bottom != old_bottom) ) if ( isVirtualWindow()
&& (new_right != old_right || new_bottom != old_bottom) )
{ {
FRect geometry = getTermGeometry(); FRect geometry = getTermGeometry();
geometry.move(-1,-1); geometry.move(-1, -1);
resizeArea (geometry, getShadow(), vwin); resizeArea (geometry, getShadow(), vwin);
} }
} }

View File

@ -8,6 +8,7 @@
#include <cmath> #include <cmath>
#include <cstdlib> #include <cstdlib>
#include <limits> #include <limits>
#include <map>
#include <stack> #include <stack>
#include "fapplication.h" #include "fapplication.h"
@ -25,19 +26,19 @@ const lDouble PI = 3.141592653589793238L;
class Button : public FButton class Button : public FButton
{ {
public: public:
// Constructor // Constructor
explicit Button (FWidget* = 0); explicit Button (FWidget* = 0);
// Method // Method
void setChecked(bool); void setChecked(bool);
// Event handler // Event handler
void onKeyPress (FKeyEvent*); void onKeyPress (FKeyEvent*);
private: private:
// Data Member // Data Member
bool checked; bool checked;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -93,93 +94,93 @@ void Button::onKeyPress (FKeyEvent* ev)
class Calc : public FDialog class Calc : public FDialog
{ {
public: public:
// Constructor // Constructor
explicit Calc (FWidget* parent=0); explicit Calc (FWidget* parent=0);
// Destructor // Destructor
~Calc(); ~Calc();
// Event handlers // Event handlers
void onKeyPress (FKeyEvent*); void onKeyPress (FKeyEvent*);
void onAccel (FAccelEvent*); void onAccel (FAccelEvent*);
void onClose (FCloseEvent*); void onClose (FCloseEvent*);
// Callback method // Callback method
void cb_buttonClicked (FWidget*, data_ptr); void cb_buttonClicked (FWidget*, data_ptr);
private: private:
// Methods // Methods
void drawDispay(); void drawDispay();
virtual void draw(); virtual void draw();
bool isDataEntryKey(int); bool isDataEntryKey(int);
bool isOperatorKey(int); bool isOperatorKey(int);
void setDisplay (lDouble); void setDisplay (lDouble);
void setInfixOperator(char); void setInfixOperator(char);
void clearInfixOperator(); void clearInfixOperator();
void calcInfixOperator(); void calcInfixOperator();
void adjustSize(); void adjustSize();
// Data Members // Data Members
bool error; bool error;
bool arcus_mode; bool arcus_mode;
bool hyperbolic_mode; bool hyperbolic_mode;
enum button enum button
{ {
Sine, Sine,
Cosine, Cosine,
Tangent, Tangent,
Reciprocal, Reciprocal,
On, On,
Natural_logarithm, Natural_logarithm,
Powers_of_e, Powers_of_e,
Power, Power,
Square_root, Square_root,
Divide, Divide,
Common_logarithm, Common_logarithm,
Powers_of_ten, Powers_of_ten,
Parenthese_l, Parenthese_l,
Parenthese_r, Parenthese_r,
Multiply, Multiply,
Hyperbolic, Hyperbolic,
Seven, Seven,
Eight, Eight,
Nine, Nine,
Subtract, Subtract,
Arcus, Arcus,
Four, Four,
Five, Five,
Six, Six,
Add, Add,
Pi, Pi,
One, One,
Two, Two,
Three, Three,
Percent, Percent,
Zero, Zero,
Decimal_point, Decimal_point,
Change_sign, Change_sign,
Equals, Equals,
NUM_OF_BUTTONS NUM_OF_BUTTONS
}; };
lDouble a, b; lDouble a, b;
uInt max_char; uInt max_char;
int last_key; int last_key;
char infix_operator; char infix_operator;
char last_infix_operator; char last_infix_operator;
FString input; FString input;
int button_no[Calc::NUM_OF_BUTTONS]; int button_no[Calc::NUM_OF_BUTTONS];
struct stack_data struct stack_data
{ {
lDouble term; lDouble term;
char infix_operator; char infix_operator;
}; };
std::stack<stack_data> bracket_stack; std::stack<stack_data> bracket_stack;
std::map<Calc::button, Button*> calculator_buttons; std::map<Calc::button, Button*> calculator_buttons;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -277,10 +278,9 @@ Calc::Calc (FWidget* parent)
); );
calculator_buttons[button(key)] = btn; calculator_buttons[button(key)] = btn;
} }
calculator_buttons[On]->addAccelerator(fc::Fkey_dc); // del key calculator_buttons[On]->addAccelerator(fc::Fkey_dc); // del key
calculator_buttons[On]->setFocus(); calculator_buttons[On]->setFocus();
calculator_buttons[Pi]->addAccelerator('p'); calculator_buttons[Pi]->addAccelerator('p');
calculator_buttons[Power]->addAccelerator('^'); calculator_buttons[Power]->addAccelerator('^');
@ -329,7 +329,7 @@ void Calc::drawDispay()
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
setPrintPos (3,3); setPrintPos (3, 3);
print(display); print(display);
print(L' '); print(L' ');
setColor(wc.dialog_fg, wc.dialog_bg); setColor(wc.dialog_fg, wc.dialog_bg);
@ -339,16 +339,16 @@ void Calc::drawDispay()
if ( isNewFont() ) if ( isNewFont() )
{ {
FString bottom_line(33, wchar_t(fc::NF_border_line_bottom)); FString bottom_line (33, wchar_t(fc::NF_border_line_bottom));
setPrintPos (3,2); setPrintPos (3, 2);
print (bottom_line); print (bottom_line);
setPrintPos (2,3); setPrintPos (2, 3);
print (wchar_t(fc::NF_rev_border_line_right)); print (wchar_t(fc::NF_rev_border_line_right));
setPrintPos (36,3); setPrintPos (36, 3);
print (wchar_t(fc::NF_border_line_left)); print (wchar_t(fc::NF_border_line_left));
FString top_bottom_line_5(5, wchar_t(fc::NF_border_line_up_and_down)); FString top_bottom_line_5 (5, wchar_t(fc::NF_border_line_up_and_down));
FString top_line_2(2, wchar_t(fc::NF_border_line_upper)); FString top_line_2 (2, wchar_t(fc::NF_border_line_upper));
setPrintPos (3,4); setPrintPos (3, 4);
print ( top_bottom_line_5 + top_line_2 print ( top_bottom_line_5 + top_line_2
+ top_bottom_line_5 + top_line_2 + top_bottom_line_5 + top_line_2
+ top_bottom_line_5 + top_line_2 + top_bottom_line_5 + top_line_2
@ -360,7 +360,7 @@ void Calc::drawDispay()
FString separator = FString(wchar_t(fc::BoxDrawingsVerticalAndRight)) FString separator = FString(wchar_t(fc::BoxDrawingsVerticalAndRight))
+ FString(35, wchar_t(fc::BoxDrawingsHorizontal)) + FString(35, wchar_t(fc::BoxDrawingsHorizontal))
+ FString(wchar_t(fc::BoxDrawingsVerticalAndLeft)); + FString(wchar_t(fc::BoxDrawingsVerticalAndLeft));
setPrintPos (1,4); setPrintPos (1, 4);
print(separator); print(separator);
} }
} }
@ -449,8 +449,6 @@ inline void Calc::clearInfixOperator()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Calc::calcInfixOperator() void Calc::calcInfixOperator()
{ {
using namespace std;
switch ( infix_operator ) switch ( infix_operator )
{ {
case '*': case '*':
@ -576,8 +574,6 @@ void Calc::cb_buttonClicked (FWidget*, data_ptr data)
lDouble* x; lDouble* x;
lDouble infinity = std::numeric_limits<lDouble>::infinity(); lDouble infinity = std::numeric_limits<lDouble>::infinity();
using namespace std;
if ( infix_operator ) if ( infix_operator )
x = &b; x = &b;
else else
@ -597,7 +593,7 @@ void Calc::cb_buttonClicked (FWidget*, data_ptr data)
if ( errno == EDOM || errno == ERANGE ) if ( errno == EDOM || errno == ERANGE )
error = true; error = true;
if ( fabs(*x - infinity) < LDBL_EPSILON ) // x = ∞ if ( std::fabs(*x - infinity) < LDBL_EPSILON ) // x = ∞
error = true; error = true;
} }
else else
@ -633,7 +629,7 @@ void Calc::cb_buttonClicked (FWidget*, data_ptr data)
if ( errno == EDOM || errno == ERANGE ) if ( errno == EDOM || errno == ERANGE )
error = true; error = true;
if ( fabs(*x - infinity) < LDBL_EPSILON ) // x = ∞ if ( std::fabs(*x - infinity) < LDBL_EPSILON ) // x = ∞
error = true; error = true;
} }
else else
@ -775,7 +771,7 @@ void Calc::cb_buttonClicked (FWidget*, data_ptr data)
break; break;
case Powers_of_ten: // 10ˣ case Powers_of_ten: // 10ˣ
*x = std::pow(10,*x); *x = std::pow(10, *x);
if ( errno == EDOM || errno == ERANGE ) if ( errno == EDOM || errno == ERANGE )
error = true; error = true;
@ -972,7 +968,7 @@ void Calc::cb_buttonClicked (FWidget*, data_ptr data)
default: default:
break; break;
} // end of switch } // end of switch
if ( ! input.isEmpty() ) if ( ! input.isEmpty() )
{ {

View File

@ -26,7 +26,7 @@ void cb_quit (FWidget*, FWidget::data_ptr data)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int main (int argc, char* argv[]) int main (int argc, char* argv[])
{ {
int x,y,w,h; int x, y, w, h;
FString label_text = "no OS"; FString label_text = "no OS";
// Create the application object // Create the application object

View File

@ -8,16 +8,16 @@
class keyboard : public FWidget class keyboard : public FWidget
{ {
public: public:
// Constructor // Constructor
explicit keyboard (FWidget* = 0); explicit keyboard (FWidget* = 0);
protected: protected:
// Event handlers // Event handlers
void onKeyPress (FKeyEvent*); void onKeyPress (FKeyEvent*);
void onAccel (FAccelEvent*); void onAccel (FAccelEvent*);
void draw(); void draw();
}; };
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -58,7 +58,7 @@ void keyboard::onAccel (FAccelEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void keyboard::draw() void keyboard::draw()
{ {
setPrintPos (1,1); setPrintPos (1, 1);
print() << "---------------\n" print() << "---------------\n"
<< "Press Q to quit\n" << "Press Q to quit\n"
<< "---------------\n"; << "---------------\n";

View File

@ -1,6 +1,8 @@
// File: listbox.cpp // File: listbox.cpp
#include <iostream> #include <iostream>
#include <list>
#include <map>
#include <fstream> #include <fstream>
#include "fapplication.h" #include "fapplication.h"
@ -49,26 +51,26 @@ FString& mapToString (std::map<FString, FString>::const_iterator iter)
class Listbox : public FDialog class Listbox : public FDialog
{ {
public: public:
// Constructor // Constructor
explicit Listbox (FWidget* = 0); explicit Listbox (FWidget* = 0);
// Destructor // Destructor
~Listbox(); ~Listbox();
private: private:
// Disable copy constructor // Disable copy constructor
Listbox (const Listbox&); Listbox (const Listbox&);
// Disable assignment operator (=) // Disable assignment operator (=)
Listbox& operator = (const Listbox&); Listbox& operator = (const Listbox&);
// Event handlers // Event handlers
void onClose (FCloseEvent*); void onClose (FCloseEvent*);
// Callback method // Callback method
void cb_exitApp (FWidget*, data_ptr); void cb_exitApp (FWidget*, data_ptr);
// Data Member // Data Member
std::list<double>* double_list; std::list<double>* double_list;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -134,7 +136,7 @@ Listbox::Listbox (FWidget* parent)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
Listbox::~Listbox() Listbox::~Listbox() // destructor
{ {
delete temp_str; delete temp_str;
delete double_list; delete double_list;

View File

@ -2,6 +2,8 @@
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <string>
#include <vector>
#include "fapplication.h" #include "fapplication.h"
#include "fdialog.h" #include "fdialog.h"
@ -18,24 +20,24 @@
class Listview : public FDialog class Listview : public FDialog
{ {
public: public:
// Constructor // Constructor
explicit Listview (FWidget* = 0); explicit Listview (FWidget* = 0);
// Destructor // Destructor
~Listview(); ~Listview();
private: private:
// Disable copy constructor // Disable copy constructor
Listview (const Listview&); Listview (const Listview&);
// Disable assignment operator (=) // Disable assignment operator (=)
Listview& operator = (const Listview&); Listview& operator = (const Listview&);
// Event handlers // Event handlers
void onClose (FCloseEvent*); void onClose (FCloseEvent*);
// Callback methods // Callback methods
void cb_exitApp (FWidget*, data_ptr); void cb_exitApp (FWidget*, data_ptr);
void cb_showInMessagebox (FWidget*, data_ptr); void cb_showInMessagebox (FWidget*, data_ptr);
}; };
#pragma pack(pop) #pragma pack(pop)
@ -133,7 +135,7 @@ Listview::Listview (FWidget* parent)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
Listview::~Listview() Listview::~Listview() // destructor
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -13,21 +13,21 @@
class Mandelbrot : public FDialog class Mandelbrot : public FDialog
{ {
public: public:
// Constructor // Constructor
explicit Mandelbrot (FWidget* = 0); explicit Mandelbrot (FWidget* = 0);
// Destructor // Destructor
~Mandelbrot(); ~Mandelbrot();
// Event handlers // Event handlers
void onAccel (FAccelEvent*); void onAccel (FAccelEvent*);
void onClose (FCloseEvent*); void onClose (FCloseEvent*);
private: private:
// Methods // Methods
virtual void draw(); virtual void draw();
void adjustSize(); void adjustSize();
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -20,30 +20,30 @@
class Menu : public FDialog class Menu : public FDialog
{ {
public: public:
// Constructor // Constructor
explicit Menu (FWidget* = 0); explicit Menu (FWidget* = 0);
// Destructor // Destructor
~Menu(); ~Menu();
private: private:
// Disable copy constructor // Disable copy constructor
Menu (const Menu&); Menu (const Menu&);
// Disable assignment operator (=) // Disable assignment operator (=)
Menu& operator = (const Menu&); Menu& operator = (const Menu&);
// Methods // Methods
void defaultCallback (FMenuList*); void defaultCallback (FMenuList*);
void adjustSize(); void adjustSize();
// Event handler // Event handler
void onClose (FCloseEvent*); void onClose (FCloseEvent*);
// Callback methods // Callback methods
void cb_message (FWidget*, data_ptr); void cb_message (FWidget*, data_ptr);
void cb_exitApp (FWidget*, data_ptr); void cb_exitApp (FWidget*, data_ptr);
}; };
#pragma pack(pop) #pragma pack(pop)
@ -68,28 +68,28 @@ Menu::Menu (FWidget* parent)
// "File" menu items // "File" menu items
FMenuItem* New = new FMenuItem ("&New", File); FMenuItem* New = new FMenuItem ("&New", File);
New->addAccelerator (fc::Fckey_n); // Ctrl + N New->addAccelerator (fc::Fckey_n); // Ctrl + N
New->setStatusbarMessage ("Create a new file"); New->setStatusbarMessage ("Create a new file");
FMenuItem* Open = new FMenuItem ("&Open...", File); FMenuItem* Open = new FMenuItem ("&Open...", File);
Open->addAccelerator (fc::Fckey_o); // Ctrl + O Open->addAccelerator (fc::Fckey_o); // Ctrl + O
Open->setStatusbarMessage ("Locate and open a text file"); Open->setStatusbarMessage ("Locate and open a text file");
FMenuItem* Save = new FMenuItem ("&Save", File); FMenuItem* Save = new FMenuItem ("&Save", File);
Save->addAccelerator (fc::Fckey_s); // Ctrl + S Save->addAccelerator (fc::Fckey_s); // Ctrl + S
Save->setStatusbarMessage ("Save the file"); Save->setStatusbarMessage ("Save the file");
FMenuItem* SaveAs = new FMenuItem ("&Save as...", File); FMenuItem* SaveAs = new FMenuItem ("&Save as...", File);
SaveAs->setStatusbarMessage ("Save the current file under a different name"); SaveAs->setStatusbarMessage ("Save the current file under a different name");
FMenuItem* Close = new FMenuItem ("&Close", File); FMenuItem* Close = new FMenuItem ("&Close", File);
Close->addAccelerator (fc::Fckey_w); // Ctrl + W Close->addAccelerator (fc::Fckey_w); // Ctrl + W
Close->setStatusbarMessage ("Close the current file"); Close->setStatusbarMessage ("Close the current file");
FMenuItem* Line1 = new FMenuItem (File); FMenuItem* Line1 = new FMenuItem (File);
Line1->setSeparator(); Line1->setSeparator();
FMenuItem* Print = new FMenuItem ("&Print", File); FMenuItem* Print = new FMenuItem ("&Print", File);
Print->addAccelerator (fc::Fckey_p); // Ctrl + P Print->addAccelerator (fc::Fckey_p); // Ctrl + P
Print->setStatusbarMessage ("Print the current file"); Print->setStatusbarMessage ("Print the current file");
FMenuItem* Line2 = new FMenuItem (File); FMenuItem* Line2 = new FMenuItem (File);
Line2->setSeparator(); Line2->setSeparator();
FMenuItem* Quit = new FMenuItem ("&Quit", File); FMenuItem* Quit = new FMenuItem ("&Quit", File);
Quit->addAccelerator (fc::Fmkey_x); // Meta/Alt + X Quit->addAccelerator (fc::Fmkey_x); // Meta/Alt + X
Quit->setStatusbarMessage ("Exit the program"); Quit->setStatusbarMessage ("Exit the program");
// "Edit" menu items // "Edit" menu items
@ -100,7 +100,8 @@ Menu::Menu (FWidget* parent)
FMenuItem* Line3 = new FMenuItem (Edit); FMenuItem* Line3 = new FMenuItem (Edit);
Line3->setSeparator(); Line3->setSeparator();
FMenuItem* Cut = new FMenuItem (fc::Fckey_x, "Cu&t", Edit); FMenuItem* Cut = new FMenuItem (fc::Fckey_x, "Cu&t", Edit);
Cut->setStatusbarMessage ("Remove the input text and put it in the clipboard"); Cut->setStatusbarMessage ( "Remove the input text "
"and put it in the clipboard" );
FMenuItem* Copy = new FMenuItem (fc::Fckey_c, "&Copy", Edit); FMenuItem* Copy = new FMenuItem (fc::Fckey_c, "&Copy", Edit);
Copy->setStatusbarMessage ("Copy the input text into the clipboad"); Copy->setStatusbarMessage ("Copy the input text into the clipboad");
FMenuItem* Paste = new FMenuItem (fc::Fckey_v, "&Paste", Edit); FMenuItem* Paste = new FMenuItem (fc::Fckey_v, "&Paste", Edit);
@ -184,19 +185,19 @@ Menu::Menu (FWidget* parent)
// Headline labels // Headline labels
FLabel* Headline1 = new FLabel(" Key ", this); FLabel* Headline1 = new FLabel(" Key ", this);
Headline1->ignorePadding(); Headline1->ignorePadding();
Headline1->setGeometry(3,2,5,1); Headline1->setGeometry(3, 2, 5, 1);
Headline1->setEmphasis(); Headline1->setEmphasis();
FLabel* Headline2 = new FLabel(" Function ", this); FLabel* Headline2 = new FLabel(" Function ", this);
Headline2->ignorePadding(); Headline2->ignorePadding();
Headline2->setGeometry(19,2,10,1); Headline2->setGeometry(19, 2, 10, 1);
Headline2->setEmphasis(); Headline2->setEmphasis();
// Info label // Info label
FLabel* Info = new FLabel("<F10> Activate menu bar\n" FLabel* Info = new FLabel("<F10> Activate menu bar\n"
"<Ctrl>+<Space> Activate menu bar\n" "<Ctrl>+<Space> Activate menu bar\n"
"<Meta>+<X> Exit", this); "<Meta>+<X> Exit", this);
Info->setGeometry(2,1,36,3); Info->setGeometry(2, 1, 36, 3);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -15,32 +15,32 @@
class ColorChooser : public FWidget class ColorChooser : public FWidget
{ {
public: public:
// Constructor // Constructor
explicit ColorChooser (FWidget* = 0); explicit ColorChooser (FWidget* = 0);
// Destructor // Destructor
~ColorChooser(); ~ColorChooser();
// Accessors // Accessors
short getForeground(); short getForeground();
short getBackground(); short getBackground();
private: private:
// Disable copy constructor // Disable copy constructor
ColorChooser (const ColorChooser&); ColorChooser (const ColorChooser&);
// Disable assignment operator (=) // Disable assignment operator (=)
ColorChooser& operator = (const ColorChooser&); ColorChooser& operator = (const ColorChooser&);
// Method // Method
void draw(); void draw();
// Event handler // Event handler
void onMouseDown (FMouseEvent*); void onMouseDown (FMouseEvent*);
// Data Members // Data Members
short fg_color; short fg_color;
short bg_color; short bg_color;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -150,36 +150,36 @@ inline short ColorChooser::getBackground()
class Brushes : public FWidget class Brushes : public FWidget
{ {
public: public:
// Constructor // Constructor
explicit Brushes (FWidget* = 0); explicit Brushes (FWidget* = 0);
// Destructor // Destructor
~Brushes(); ~Brushes();
// Accessor // Accessor
wchar_t getBrush(); wchar_t getBrush();
// Mutators // Mutators
void setForeground (short); void setForeground (short);
void setBackground (short); void setBackground (short);
private: private:
// Disable copy constructor // Disable copy constructor
Brushes (const Brushes&); Brushes (const Brushes&);
// Disable assignment operator (=) // Disable assignment operator (=)
Brushes& operator = (const Brushes&); Brushes& operator = (const Brushes&);
// Method // Method
void draw(); void draw();
// Event handler // Event handler
void onMouseDown (FMouseEvent*); void onMouseDown (FMouseEvent*);
// Data Members // Data Members
wchar_t brush; wchar_t brush;
short fg_color; short fg_color;
short bg_color; short bg_color;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -285,46 +285,46 @@ inline void Brushes::setBackground (short color)
class MouseDraw : public FDialog class MouseDraw : public FDialog
{ {
public: public:
// Using-declaration // Using-declaration
using FWidget::setGeometry; using FWidget::setGeometry;
// Constructor // Constructor
explicit MouseDraw (FWidget* = 0); explicit MouseDraw (FWidget* = 0);
// Destructor // Destructor
~MouseDraw(); ~MouseDraw();
// Methods // Methods
void setGeometry (int, int, int, int, bool = true); void setGeometry (int, int, int, int, bool = true);
// Event handlers // Event handlers
void onAccel (FAccelEvent*); void onAccel (FAccelEvent*);
void onClose (FCloseEvent*); void onClose (FCloseEvent*);
private: private:
// Disable copy constructor // Disable copy constructor
MouseDraw (const MouseDraw&); MouseDraw (const MouseDraw&);
// Disable assignment operator (=) // Disable assignment operator (=)
MouseDraw& operator = (const MouseDraw&); MouseDraw& operator = (const MouseDraw&);
// Methods // Methods
virtual void draw(); virtual void draw();
void drawBrush (int, int, bool = false); void drawBrush (int, int, bool = false);
void drawCanvas(); void drawCanvas();
void adjustSize(); void adjustSize();
// Event handler // Event handler
void onMouseDown (FMouseEvent*); void onMouseDown (FMouseEvent*);
void onMouseMove (FMouseEvent*); void onMouseMove (FMouseEvent*);
// Callback methods // Callback methods
void cb_colorChanged (FWidget*, data_ptr); void cb_colorChanged (FWidget*, data_ptr);
// Data Members // Data Members
term_area* canvas; term_area* canvas;
ColorChooser* c_chooser; ColorChooser* c_chooser;
Brushes* brush; Brushes* brush;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -337,7 +337,7 @@ MouseDraw::MouseDraw (FWidget* parent)
{ {
setText ("Drawing with the mouse"); setText ("Drawing with the mouse");
c_chooser = new ColorChooser(this); c_chooser = new ColorChooser(this);
c_chooser->setPos (1,1); c_chooser->setPos (1, 1);
c_chooser->addCallback c_chooser->addCallback
( (
"clicked", "clicked",
@ -345,7 +345,7 @@ MouseDraw::MouseDraw (FWidget* parent)
); );
brush = new Brushes(this); brush = new Brushes(this);
brush->setPos (1,12); brush->setPos (1, 12);
FPoint no_shadow(0,0); FPoint no_shadow(0,0);
FRect scroll_geometry(0, 0, 1, 1); FRect scroll_geometry(0, 0, 1, 1);
@ -459,8 +459,8 @@ void MouseDraw::drawCanvas()
for (int y = 0; y < y_end; y++) // line loop for (int y = 0; y < y_end; y++) // line loop
{ {
char_data* cc; // canvas character char_data* cc; // canvas character
char_data* wc; // window character char_data* wc; // window character
cc = &canvas->text[y * x_end]; cc = &canvas->text[y * x_end];
wc = &print_area->text[(ay + y) * w_line_len + ax]; wc = &print_area->text[(ay + y) * w_line_len + ax];
std::memcpy (wc, cc, sizeof(char_data) * unsigned(x_end)); std::memcpy (wc, cc, sizeof(char_data) * unsigned(x_end));

View File

@ -1,6 +1,8 @@
// File: opti-move.cpp // File: opti-move.cpp
#include <iomanip> #include <iomanip>
#include <string>
#include "fapplication.h" #include "fapplication.h"
#include "fvterm.h" #include "fvterm.h"

View File

@ -16,36 +16,36 @@
class scrollview : public FScrollView class scrollview : public FScrollView
{ {
public: public:
// Constructor // Constructor
explicit scrollview (FWidget* = 0); explicit scrollview (FWidget* = 0);
// Destructor // Destructor
~scrollview (); ~scrollview ();
// Mutator // Mutator
void setScrollSize (int, int); void setScrollSize (int, int);
private: private:
// Disable copy constructor // Disable copy constructor
scrollview (const scrollview&); scrollview (const scrollview&);
// Disable assignment operator (=) // Disable assignment operator (=)
scrollview& operator = (const scrollview&); scrollview& operator = (const scrollview&);
// Method // Method
void draw(); void draw();
// Callback methods // Callback methods
void cb_go_east (FWidget*, data_ptr); void cb_go_east (FWidget*, data_ptr);
void cb_go_south (FWidget*, data_ptr); void cb_go_south (FWidget*, data_ptr);
void cb_go_west (FWidget*, data_ptr); void cb_go_west (FWidget*, data_ptr);
void cb_go_north (FWidget*, data_ptr); void cb_go_north (FWidget*, data_ptr);
// Data Members // Data Members
FButton* go_east; FButton* go_east;
FButton* go_south; FButton* go_south;
FButton* go_west; FButton* go_west;
FButton* go_north; FButton* go_north;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -176,18 +176,18 @@ void scrollview::cb_go_north (FWidget*, data_ptr)
class scrollviewdemo : public FDialog class scrollviewdemo : public FDialog
{ {
public: public:
// Constructor // Constructor
explicit scrollviewdemo (FWidget* = 0); explicit scrollviewdemo (FWidget* = 0);
// Destructor // Destructor
~scrollviewdemo (); ~scrollviewdemo ();
// Event handler // Event handler
void onClose (FCloseEvent*); void onClose (FCloseEvent*);
// Callback method // Callback method
void cb_quit (FWidget* = 0, data_ptr = 0); void cb_quit (FWidget* = 0, data_ptr = 0);
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -1,12 +1,14 @@
// File: string-operations.cpp // File: string-operations.cpp
#include <clocale>
#include <iomanip>
#include <langinfo.h> #include <langinfo.h>
#include <term.h> #include <term.h>
#include <unistd.h> #include <unistd.h>
#include <clocale>
#include <iomanip>
#include <string>
#include <vector>
#include "fstring.h" #include "fstring.h"
@ -70,19 +72,23 @@ int main (int, char**)
std::cout << " add: " << add1 << std::endl; std::cout << " add: " << add1 << std::endl;
// Test: concatenate a FString and a c++ wide string (operator +) // Test: concatenate a FString and a c++ wide string (operator +)
const FString& add2 = FString("FString + ") + std::wstring(L"std::wstring"); const FString& add2 = FString("FString + ")
+ std::wstring(L"std::wstring");
std::cout << " add: " << add2 << std::endl; std::cout << " add: " << add2 << std::endl;
// Test: concatenate a FString and a wide string (operator +) // Test: concatenate a FString and a wide string (operator +)
const FString& add3 = FString("FString + ") + const_cast<wchar_t*>(L"wchar_t*"); const FString& add3 = FString("FString + ")
+ const_cast<wchar_t*>(L"wchar_t*");
std::cout << " add: " << add3 << std::endl; std::cout << " add: " << add3 << std::endl;
// Test: concatenate a FString and a c++ string (operator +) // Test: concatenate a FString and a c++ string (operator +)
const FString& add4 = FString("FString + ") + std::string("std::string"); const FString& add4 = FString("FString + ")
+ std::string("std::string");
std::cout << " add: " << add4 << std::endl; std::cout << " add: " << add4 << std::endl;
// Test: concatenate a FString and a c-string (operator +) // Test: concatenate a FString and a c-string (operator +)
const FString& add5 = FString("FString + ") + const_cast<char*>("char*"); const FString& add5 = FString("FString + ")
+ const_cast<char*>("char*");
std::cout << " add: " << add5 << std::endl; std::cout << " add: " << add5 << std::endl;
// Test: concatenate a FString and a wide character (operator +) // Test: concatenate a FString and a wide character (operator +)
@ -102,19 +108,23 @@ int main (int, char**)
std::cout << " add: " << add9 << std::endl; std::cout << " add: " << add9 << std::endl;
// Test: concatenate a c-string and a FString (operator +) // Test: concatenate a c-string and a FString (operator +)
const FString& add10 = const_cast<char*>("char*") + FString(" + FString"); const FString& add10 = const_cast<char*>("char*")
+ FString(" + FString");
std::cout << " add: " << add10 << std::endl; std::cout << " add: " << add10 << std::endl;
// Test: concatenate a c++ string and a FString (operator +) // Test: concatenate a c++ string and a FString (operator +)
const FString& add11 = std::string("std::string") + FString(" + FString"); const FString& add11 = std::string("std::string")
+ FString(" + FString");
std::cout << " add: " << add11 << std::endl; std::cout << " add: " << add11 << std::endl;
// Test: concatenate a wide string and a FString (operator +) // Test: concatenate a wide string and a FString (operator +)
const FString& add12 = const_cast<wchar_t*>(L"wchar_t*") + FString(" + FString"); const FString& add12 = const_cast<wchar_t*>(L"wchar_t*")
+ FString(" + FString");
std::cout << " add: " << add12 << std::endl; std::cout << " add: " << add12 << std::endl;
// Test: concatenate a c++ wide string and a FString (operator +) // Test: concatenate a c++ wide string and a FString (operator +)
const FString& add13 = std::wstring(L"std::wstring") + FString(" + FString"); const FString& add13 = std::wstring(L"std::wstring")
+ FString(" + FString");
std::cout << " add: " << add13 << std::endl; std::cout << " add: " << add13 << std::endl;
// Test: compare operators ==, <=, <, >=, >, != // Test: compare operators ==, <=, <, >=, >, !=
@ -268,7 +278,7 @@ int main (int, char**)
// Test: extract a substring of 27 characters from position 12 // Test: extract a substring of 27 characters from position 12
std::cout << " mid: \"" std::cout << " mid: \""
<< alphabet.mid(13,27) << "\"" << std::endl; << alphabet.mid(13, 27) << "\"" << std::endl;
// Test: 11 characters from the right of the string // Test: 11 characters from the right of the string
std::cout << " right: \"" std::cout << " right: \""
@ -288,12 +298,12 @@ int main (int, char**)
} }
// Test: get character access at a specified index position // Test: get character access at a specified index position
FString index(5); // string with five characters FString index(5); // string with five characters
index = "index"; index = "index";
try try
{ {
index[0] = L'I'; // write a wide character at position 0 index[0] = L'I'; // write a wide character at position 0
printf ( " index: [0] = %c ; [4] = %c\n" printf ( " index: [0] = %c ; [4] = %c\n"
, char(index[0]) , char(index[0])
, char(index[4]) ); , char(index[4]) );
@ -327,7 +337,7 @@ int main (int, char**)
// Test: remove 2 characters at position 7 // Test: remove 2 characters at position 7
FString remove_std = "A fast remove"; FString remove_std = "A fast remove";
std::cout << " remove: " std::cout << " remove: "
<< remove_std.remove(7,2) << std::endl; << remove_std.remove(7, 2) << std::endl;
// Test: includes a substring (positive test) // Test: includes a substring (positive test)
FString include_std = "string"; FString include_std = "string";

View File

@ -14,38 +14,37 @@
class AttribDlg : public FDialog class AttribDlg : public FDialog
{ {
public: public:
// Constructor // Constructor
explicit AttribDlg (FWidget* = 0); explicit AttribDlg (FWidget* = 0);
// Destructor // Destructor
~AttribDlg(); ~AttribDlg();
// Event handlers // Event handlers
void onAccel (FAccelEvent*); void onAccel (FAccelEvent*);
void onWheel (FWheelEvent*); void onWheel (FWheelEvent*);
void onClose (FCloseEvent*); void onClose (FCloseEvent*);
// Callback methods // Callback methods
void cb_next (FWidget* = 0, data_ptr = 0); void cb_next (FWidget* = 0, data_ptr = 0);
void cb_back (FWidget* = 0, data_ptr = 0); void cb_back (FWidget* = 0, data_ptr = 0);
// Data Members // Data Members
short bgcolor; short bgcolor;
private: private:
// Disable copy constructor // Disable copy constructor
AttribDlg (const AttribDlg&); AttribDlg (const AttribDlg&);
// Disable assignment operator (=) // Disable assignment operator (=)
AttribDlg& operator = (const AttribDlg&); AttribDlg& operator = (const AttribDlg&);
// Method // Method
void adjustSize(); void adjustSize();
// Data Members
FButton* next_button;
FButton* back_button;
// Data Members
FButton* next_button;
FButton* back_button;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -176,38 +175,38 @@ void AttribDlg::adjustSize()
class AttribDemo : public FWidget class AttribDemo : public FWidget
{ {
public: public:
// Constructor // Constructor
explicit AttribDemo (FWidget* = 0); explicit AttribDemo (FWidget* = 0);
// Destructor // Destructor
~AttribDemo() ~AttribDemo()
{ } { }
// Event handler // Event handler
void onWheel (FWheelEvent* ev) void onWheel (FWheelEvent* ev)
{ {
AttribDlg* p = dynamic_cast<AttribDlg*>(getParentWidget()); AttribDlg* p = static_cast<AttribDlg*>(getParentWidget());
if ( p ) if ( p )
p->onWheel(ev); p->onWheel(ev);
} }
private: private:
// Methods // Methods
void printColorLine(); void printColorLine();
void printAltCharset(); void printAltCharset();
void draw(); void draw();
// Data Member // Data Member
int colors; int colors;
}; };
#pragma pack(pop) #pragma pack(pop)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
AttribDemo::AttribDemo (FWidget* parent) AttribDemo::AttribDemo (FWidget* parent)
: FWidget(parent) : FWidget(parent)
, colors(getMaxColor()) , colors(getMaxColor())
{ {
if ( isMonochron() ) if ( isMonochron() )
colors = 1; colors = 1;
@ -402,7 +401,7 @@ int main (int argc, char* argv[])
dialog->setShadow(); dialog->setShadow();
AttribDemo* demo = new AttribDemo(dialog); AttribDemo* demo = new AttribDemo(dialog);
demo->setGeometry (1,1,67,19); demo->setGeometry (1, 1, 67, 19);
app.setMainWidget(dialog); app.setMainWidget(dialog);
dialog->show(); dialog->show();

View File

@ -1,7 +1,9 @@
// File: opti-move.cpp // File: termcap.cpp
#include <iomanip> #include <iomanip>
#include <iostream> #include <iostream>
#include <string>
#include "fapplication.h" #include "fapplication.h"
#include "ftermcap.h" #include "ftermcap.h"
#include "fvterm.h" #include "fvterm.h"

View File

@ -8,17 +8,17 @@
class timer : public FWidget class timer : public FWidget
{ {
public: public:
// Constructor // Constructor
explicit timer (FWidget* = 0); explicit timer (FWidget* = 0);
protected: protected:
// Method // Method
void draw(); void draw();
// Event handlers // Event handlers
void onTimer (FTimerEvent*); void onTimer (FTimerEvent*);
void onAccel (FAccelEvent*); void onAccel (FAccelEvent*);
}; };
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -17,37 +17,37 @@
class Transparent : public FDialog class Transparent : public FDialog
{ {
public: public:
// Typedef and Enumeration // Typedef and Enumeration
typedef enum ttype typedef enum ttype
{ {
transparent = 0, transparent = 0,
shadow = 1, shadow = 1,
inherit_background = 2 inherit_background = 2
} trans_type; } trans_type;
public: public:
// Constructor // Constructor
explicit Transparent (FWidget* = 0, trans_type = transparent); explicit Transparent (FWidget* = 0, trans_type = transparent);
// Destructor // Destructor
~Transparent(); ~Transparent();
private: private:
// Disable copy constructor // Disable copy constructor
Transparent (const Transparent&); Transparent (const Transparent&);
// Disable assignment operator (=) // Disable assignment operator (=)
Transparent& operator = (const Transparent&); Transparent& operator = (const Transparent&);
// Method // Method
void draw(); void draw();
// Event handlers // Event handlers
void onKeyPress (FKeyEvent* ev); void onKeyPress (FKeyEvent* ev);
// Data Members // Data Members
trans_type type; trans_type type;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -134,41 +134,41 @@ void Transparent::onKeyPress (FKeyEvent* ev)
class MainWindow : public FDialog class MainWindow : public FDialog
{ {
private: private:
FString line1; FString line1;
FString line2; FString line2;
private: private:
// Disable copy constructor // Disable copy constructor
MainWindow (const MainWindow&); MainWindow (const MainWindow&);
// Disable assignment operator (=) // Disable assignment operator (=)
MainWindow& operator = (const MainWindow&); MainWindow& operator = (const MainWindow&);
void draw(); void draw();
// Event handlers // Event handlers
void onClose (FCloseEvent*); void onClose (FCloseEvent*);
void onShow (FShowEvent*); void onShow (FShowEvent*);
void onTimer (FTimerEvent*); void onTimer (FTimerEvent*);
void onKeyPress (FKeyEvent* ev) void onKeyPress (FKeyEvent* ev)
{ {
if ( ! ev ) if ( ! ev )
return; return;
if ( ev->key() == 'q' ) if ( ev->key() == 'q' )
{ {
close(); close();
ev->accept(); ev->accept();
} }
else else
FDialog::onKeyPress(ev); FDialog::onKeyPress(ev);
} }
public: public:
// Constructor // Constructor
explicit MainWindow (FWidget* = 0); explicit MainWindow (FWidget* = 0);
// Destructor // Destructor
~MainWindow(); ~MainWindow();
}; };
#pragma pack(pop) #pragma pack(pop)
@ -218,9 +218,9 @@ void MainWindow::draw()
setReverse(true); setReverse(true);
setColor(); setColor();
setPrintPos (2,4); setPrintPos (2, 4);
print(line1); print(line1);
setPrintPos (2,5); setPrintPos (2, 5);
print(line2); print(line2);
if ( isMonochron() ) if ( isMonochron() )

View File

@ -2,6 +2,8 @@
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <string>
#include <vector>
#include "fapplication.h" #include "fapplication.h"
#include "fdialog.h" #include "fdialog.h"
@ -18,23 +20,23 @@
class Treeview : public FDialog class Treeview : public FDialog
{ {
public: public:
// Constructor // Constructor
explicit Treeview (FWidget* = 0); explicit Treeview (FWidget* = 0);
// Destructor // Destructor
~Treeview(); ~Treeview();
private: private:
// Disable copy constructor // Disable copy constructor
Treeview (const Treeview&); Treeview (const Treeview&);
// Disable assignment operator (=) // Disable assignment operator (=)
Treeview& operator = (const Treeview&); Treeview& operator = (const Treeview&);
// Event handlers // Event handlers
void onClose (FCloseEvent*); void onClose (FCloseEvent*);
// Callback methods // Callback methods
void cb_exitApp (FWidget*, data_ptr); void cb_exitApp (FWidget*, data_ptr);
}; };
#pragma pack(pop) #pragma pack(pop)
@ -92,7 +94,7 @@ Treeview::Treeview (FWidget* parent)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
Treeview::~Treeview() Treeview::~Treeview() // destructor
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -1,7 +1,8 @@
// File: ui.cpp // File: ui.cpp
#include <iostream>
#include <fstream> #include <fstream>
#include <iostream>
#include <string>
#include "final.h" #include "final.h"
@ -15,32 +16,32 @@
class ProgressDialog : public FDialog class ProgressDialog : public FDialog
{ {
public: public:
// Constructor // Constructor
explicit ProgressDialog (FWidget* = 0); explicit ProgressDialog (FWidget* = 0);
// Destructor // Destructor
~ProgressDialog(); ~ProgressDialog();
private: private:
// Disable copy constructor // Disable copy constructor
ProgressDialog (const ProgressDialog&); ProgressDialog (const ProgressDialog&);
// Disable assignment operator (=) // Disable assignment operator (=)
ProgressDialog& operator = (const ProgressDialog&); ProgressDialog& operator = (const ProgressDialog&);
// Event handlers // Event handlers
void onShow (FShowEvent*); void onShow (FShowEvent*);
void onTimer (FTimerEvent*); void onTimer (FTimerEvent*);
// Callback methods // Callback methods
void cb_reset_bar (FWidget*, data_ptr); void cb_reset_bar (FWidget*, data_ptr);
void cb_more_bar (FWidget*, data_ptr); void cb_more_bar (FWidget*, data_ptr);
void cb_exit_bar (FWidget*, data_ptr); void cb_exit_bar (FWidget*, data_ptr);
// Data Members // Data Members
FProgressbar* progressBar; FProgressbar* progressBar;
FButton* reset; FButton* reset;
FButton* more; FButton* more;
FButton* quit; FButton* quit;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -97,7 +98,7 @@ ProgressDialog::ProgressDialog (FWidget* parent)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
ProgressDialog::~ProgressDialog() ProgressDialog::~ProgressDialog() // destructor
{ {
delOwnTimer(); delOwnTimer();
delCallback(quit); delCallback(quit);
@ -170,24 +171,24 @@ void ProgressDialog::cb_exit_bar (FWidget*, data_ptr)
class TextWindow : public FDialog class TextWindow : public FDialog
{ {
public: public:
// Constructor // Constructor
explicit TextWindow (FWidget* = 0); explicit TextWindow (FWidget* = 0);
// Destructor // Destructor
~TextWindow(); ~TextWindow();
void append (const FString&); void append (const FString&);
private: private:
// Disable copy constructor // Disable copy constructor
TextWindow (const TextWindow&); TextWindow (const TextWindow&);
// Disable assignment operator (=) // Disable assignment operator (=)
TextWindow& operator = (const TextWindow&); TextWindow& operator = (const TextWindow&);
void adjustSize(); void adjustSize();
// Data Members // Data Members
FTextView* scrollText; FTextView* scrollText;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -212,7 +213,7 @@ TextWindow::TextWindow (FWidget* parent)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
TextWindow::~TextWindow() TextWindow::~TextWindow() // destructor
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -238,46 +239,46 @@ void TextWindow::adjustSize()
class MyDialog : public FDialog class MyDialog : public FDialog
{ {
public: public:
// Constructor // Constructor
explicit MyDialog (FWidget* = 0); explicit MyDialog (FWidget* = 0);
// Destructor // Destructor
~MyDialog(); ~MyDialog();
private: private:
// Disable copy constructor // Disable copy constructor
MyDialog (const MyDialog&); MyDialog (const MyDialog&);
// Disable assignment operator (=) // Disable assignment operator (=)
MyDialog& operator = (const MyDialog&); MyDialog& operator = (const MyDialog&);
// Method // Method
void adjustSize(); void adjustSize();
// Event handlers // Event handlers
void onClose (FCloseEvent*); void onClose (FCloseEvent*);
// Callback methods // Callback methods
void cb_noFunctionMsg (FWidget*, data_ptr); void cb_noFunctionMsg (FWidget*, data_ptr);
void cb_about (FWidget*, data_ptr); void cb_about (FWidget*, data_ptr);
void cb_terminfo (FWidget*, data_ptr); void cb_terminfo (FWidget*, data_ptr);
void cb_drives (FWidget*, data_ptr); void cb_drives (FWidget*, data_ptr);
void cb_cutClipboard (FWidget*, data_ptr); void cb_cutClipboard (FWidget*, data_ptr);
void cb_copyClipboard (FWidget*, data_ptr); void cb_copyClipboard (FWidget*, data_ptr);
void cb_pasteClipboard (FWidget*, data_ptr); void cb_pasteClipboard (FWidget*, data_ptr);
void cb_clearInput (FWidget*, data_ptr); void cb_clearInput (FWidget*, data_ptr);
void cb_input2buttonText (FWidget*, data_ptr); void cb_input2buttonText (FWidget*, data_ptr);
void cb_setTitlebar (FWidget*, data_ptr); void cb_setTitlebar (FWidget*, data_ptr);
void cb_ProgressBar (FWidget*, data_ptr); void cb_ProgressBar (FWidget*, data_ptr);
void cb_updateNumber (FWidget*, data_ptr); void cb_updateNumber (FWidget*, data_ptr);
void cb_activateButton (FWidget*, data_ptr); void cb_activateButton (FWidget*, data_ptr);
void cb_view (FWidget*, data_ptr); void cb_view (FWidget*, data_ptr);
void cb_setInput (FWidget*, data_ptr); void cb_setInput (FWidget*, data_ptr);
void cb_exitApp (FWidget*, data_ptr); void cb_exitApp (FWidget*, data_ptr);
// Data Members // Data Members
FLineEdit* myLineEdit; FLineEdit* myLineEdit;
FListBox* myList; FListBox* myList;
FString clipboard; FString clipboard;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -308,7 +309,7 @@ MyDialog::MyDialog (FWidget* parent)
// "File" menu items // "File" menu items
FMenuItem* Open = new FMenuItem ("&Open...", File); FMenuItem* Open = new FMenuItem ("&Open...", File);
Open->addAccelerator (fc::Fckey_o); // Ctrl + O Open->addAccelerator (fc::Fckey_o); // Ctrl + O
Open->setStatusbarMessage ("Locate and open a text file"); Open->setStatusbarMessage ("Locate and open a text file");
FMenu* Recent = new FMenu ("&System files", File); FMenu* Recent = new FMenu ("&System files", File);
Recent->setStatusbarMessage ("View text file"); Recent->setStatusbarMessage ("View text file");
@ -316,7 +317,7 @@ MyDialog::MyDialog (FWidget* parent)
FMenuItem* Line1 = new FMenuItem (File); FMenuItem* Line1 = new FMenuItem (File);
Line1->setSeparator(); Line1->setSeparator();
FMenuItem* Quit = new FMenuItem ("&Quit", File); FMenuItem* Quit = new FMenuItem ("&Quit", File);
Quit->addAccelerator (fc::Fmkey_x); // Meta/Alt + X Quit->addAccelerator (fc::Fmkey_x); // Meta/Alt + X
Quit->setStatusbarMessage ("Exit the program"); Quit->setStatusbarMessage ("Exit the program");
// "Recent" menu items // "Recent" menu items
@ -332,7 +333,8 @@ MyDialog::MyDialog (FWidget* parent)
FMenuItem* Line2 = new FMenuItem (Edit); FMenuItem* Line2 = new FMenuItem (Edit);
Line2->setSeparator(); Line2->setSeparator();
FMenuItem* Cut = new FMenuItem (fc::Fckey_x, "Cu&t", Edit); FMenuItem* Cut = new FMenuItem (fc::Fckey_x, "Cu&t", Edit);
Cut->setStatusbarMessage ("Remove the input text and put it in the clipboard"); Cut->setStatusbarMessage ( "Remove the input text"
" and put it in the clipboard" );
FMenuItem* Copy = new FMenuItem (fc::Fckey_c, "&Copy", Edit); FMenuItem* Copy = new FMenuItem (fc::Fckey_c, "&Copy", Edit);
Copy->setStatusbarMessage ("Copy the input text into the clipboad"); Copy->setStatusbarMessage ("Copy the input text into the clipboad");
FMenuItem* Paste = new FMenuItem (fc::Fckey_v, "&Paste", Edit); FMenuItem* Paste = new FMenuItem (fc::Fckey_v, "&Paste", Edit);
@ -405,21 +407,21 @@ MyDialog::MyDialog (FWidget* parent)
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_view), F_METHOD_CALLBACK (this, &MyDialog::cb_view),
dynamic_cast<FWidget::data_ptr>(File1) static_cast<FWidget::data_ptr>(File1)
); );
File2->addCallback File2->addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_view), F_METHOD_CALLBACK (this, &MyDialog::cb_view),
dynamic_cast<FWidget::data_ptr>(File2) static_cast<FWidget::data_ptr>(File2)
); );
File3->addCallback File3->addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_view), F_METHOD_CALLBACK (this, &MyDialog::cb_view),
dynamic_cast<FWidget::data_ptr>(File3) static_cast<FWidget::data_ptr>(File3)
); );
// Buttons // Buttons
@ -563,7 +565,7 @@ MyDialog::MyDialog (FWidget* parent)
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_input2buttonText), F_METHOD_CALLBACK (this, &MyDialog::cb_input2buttonText),
dynamic_cast<FWidget::data_ptr>(myLineEdit) static_cast<FWidget::data_ptr>(myLineEdit)
); );
MyButton5->addCallback MyButton5->addCallback
@ -588,21 +590,21 @@ MyDialog::MyDialog (FWidget* parent)
( (
"toggled", "toggled",
F_METHOD_CALLBACK (this, &MyDialog::cb_activateButton), F_METHOD_CALLBACK (this, &MyDialog::cb_activateButton),
dynamic_cast<FWidget::data_ptr>(MyButton5) static_cast<FWidget::data_ptr>(MyButton5)
); );
myList->addCallback myList->addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_setInput), F_METHOD_CALLBACK (this, &MyDialog::cb_setInput),
dynamic_cast<FWidget::data_ptr>(myLineEdit) static_cast<FWidget::data_ptr>(myLineEdit)
); );
myList->addCallback myList->addCallback
( (
"row-selected", "row-selected",
F_METHOD_CALLBACK (this, &MyDialog::cb_updateNumber), F_METHOD_CALLBACK (this, &MyDialog::cb_updateNumber),
dynamic_cast<FWidget::data_ptr>(tagged_count) static_cast<FWidget::data_ptr>(tagged_count)
); );
key_F1->addCallback key_F1->addCallback
@ -625,7 +627,7 @@ MyDialog::MyDialog (FWidget* parent)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
MyDialog::~MyDialog() MyDialog::~MyDialog() // destructor
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -17,42 +17,42 @@
class watch : public FDialog class watch : public FDialog
{ {
public: public:
// Constructor // Constructor
explicit watch (FWidget* = 0); explicit watch (FWidget* = 0);
// Destructor // Destructor
~watch(); ~watch();
// Method // Method
void printTime(); void printTime();
// Event handlers // Event handlers
void onTimer (FTimerEvent*); void onTimer (FTimerEvent*);
void onClose (FCloseEvent*); void onClose (FCloseEvent*);
// Callback methods // Callback methods
void cb_clock (FWidget*, data_ptr); void cb_clock (FWidget*, data_ptr);
void cb_seconds (FWidget*, data_ptr); void cb_seconds (FWidget*, data_ptr);
void cb_exitApp (FWidget*, data_ptr); void cb_exitApp (FWidget*, data_ptr);
protected: protected:
// Method // Method
void adjustSize(); void adjustSize();
private: private:
// Disable copy constructor // Disable copy constructor
watch (const watch&); watch (const watch&);
// Disable assignment operator (=) // Disable assignment operator (=)
watch& operator = (const watch&); watch& operator = (const watch&);
// Data Members // Data Members
bool sec; bool sec;
FLabel* time_label; FLabel* time_label;
FLabel* time_str; FLabel* time_str;
FSwitch* clock_sw; FSwitch* clock_sw;
FSwitch* seconds_sw; FSwitch* seconds_sw;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -119,16 +119,16 @@ watch::~watch()
void watch::printTime() void watch::printTime()
{ {
FString str; FString str;
std::tm* now; std::tm now;
std::time_t t; std::time_t t;
t = std::time(0); // get current time t = std::time(0); // get current time
now = std::localtime(&t); localtime_r(&t, &now);
if ( sec ) if ( sec )
str.sprintf("%02d:%02d:%02d", now->tm_hour, now->tm_min, now->tm_sec); str.sprintf("%02d:%02d:%02d", now.tm_hour, now.tm_min, now.tm_sec);
else else
str.sprintf("%02d:%02d ", now->tm_hour, now->tm_min); str.sprintf("%02d:%02d ", now.tm_hour, now.tm_min);
time_str->setText(str); time_str->setText(str);
time_str->redraw(); time_str->redraw();

View File

@ -1,5 +1,7 @@
// File: windows.cpp // File: windows.cpp
#include <vector>
#include "fapplication.h" #include "fapplication.h"
#include "fdialog.h" #include "fdialog.h"
#include "fdialoglistmenu.h" #include "fdialoglistmenu.h"
@ -19,33 +21,33 @@
class smallWindow : public FDialog class smallWindow : public FDialog
{ {
public: public:
// Constructor // Constructor
explicit smallWindow (FWidget* = 0); explicit smallWindow (FWidget* = 0);
// Destructor // Destructor
~smallWindow(); ~smallWindow();
private: private:
// Disable copy constructor // Disable copy constructor
smallWindow (const smallWindow&); smallWindow (const smallWindow&);
// Disable assignment operator (=) // Disable assignment operator (=)
smallWindow& operator = (const smallWindow&); smallWindow& operator = (const smallWindow&);
// Method // Method
void adjustSize(); void adjustSize();
// Event handlers // Event handlers
void onShow (FShowEvent*); void onShow (FShowEvent*);
void onTimer (FTimerEvent*); void onTimer (FTimerEvent*);
// Data Members // Data Members
FLabel* left_arrow; FLabel* left_arrow;
FLabel* right_arrow; FLabel* right_arrow;
FLabel* top_left_label; FLabel* top_left_label;
FLabel* top_right_label; FLabel* top_right_label;
FLabel* bottom_label; FLabel* bottom_label;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -157,46 +159,46 @@ void smallWindow::onTimer (FTimerEvent*)
class Window : public FDialog class Window : public FDialog
{ {
public: public:
// Constructor // Constructor
explicit Window (FWidget* = 0); explicit Window (FWidget* = 0);
// Destructor // Destructor
~Window(); ~Window();
private: private:
// Typedef // Typedef
typedef struct typedef struct
{ {
bool is_open; bool is_open;
FString* title; FString* title;
FDialog* dgl; FDialog* dgl;
} }
win_data; win_data;
// Disable copy constructor // Disable copy constructor
Window (const Window&); Window (const Window&);
// Disable assignment operator (=) // Disable assignment operator (=)
Window& operator = (const Window&); Window& operator = (const Window&);
// Method // Method
void activateWindow (FDialog*); void activateWindow (FDialog*);
void adjustSize(); void adjustSize();
// Event handlers // Event handlers
void onClose (FCloseEvent*); void onClose (FCloseEvent*);
// Callback methods // Callback methods
void cb_createWindows (FWidget*, data_ptr); void cb_createWindows (FWidget*, data_ptr);
void cb_closeWindows (FWidget*, data_ptr); void cb_closeWindows (FWidget*, data_ptr);
void cb_next (FWidget*, data_ptr); void cb_next (FWidget*, data_ptr);
void cb_previous (FWidget*, data_ptr); void cb_previous (FWidget*, data_ptr);
void cb_exitApp (FWidget*, data_ptr); void cb_exitApp (FWidget*, data_ptr);
void cb_destroyWindow (FWidget*, data_ptr); void cb_destroyWindow (FWidget*, data_ptr);
// Data Members // Data Members
std::vector<win_data*> windows; std::vector<win_data*> windows;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -230,18 +232,18 @@ Window::Window (FWidget* parent)
Line1->setSeparator(); Line1->setSeparator();
FMenuItem* Next = new FMenuItem ("Ne&xt window", File); FMenuItem* Next = new FMenuItem ("Ne&xt window", File);
Next->addAccelerator (fc::Fmkey_npage); // Meta/Alt + PgDn Next->addAccelerator (fc::Fmkey_npage); // Meta/Alt + PgDn
Next->setStatusbarMessage ("Switch to the next window"); Next->setStatusbarMessage ("Switch to the next window");
FMenuItem* Previous = new FMenuItem ("&Previous window", File); FMenuItem* Previous = new FMenuItem ("&Previous window", File);
Previous->addAccelerator (fc::Fmkey_ppage); // Meta/Alt + PgUp Previous->addAccelerator (fc::Fmkey_ppage); // Meta/Alt + PgUp
Previous->setStatusbarMessage ("Switch to the previous window"); Previous->setStatusbarMessage ("Switch to the previous window");
FMenuItem* Line2 = new FMenuItem (File); FMenuItem* Line2 = new FMenuItem (File);
Line2->setSeparator(); Line2->setSeparator();
FMenuItem* Quit = new FMenuItem ("&Quit", File); FMenuItem* Quit = new FMenuItem ("&Quit", File);
Quit->addAccelerator (fc::Fmkey_x); // Meta/Alt + X Quit->addAccelerator (fc::Fmkey_x); // Meta/Alt + X
Quit->setStatusbarMessage ("Exit the program"); Quit->setStatusbarMessage ("Exit the program");
// Statusbar at the bottom // Statusbar at the bottom
@ -353,7 +355,7 @@ void Window::activateWindow (FDialog* win)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Window::adjustSize() void Window::adjustSize()
{ {
int w,h,X,Y,dx,dy; int w, h, X, Y, dx, dy;
std::vector<win_data*>::const_iterator iter, begin; std::vector<win_data*>::const_iterator iter, begin;
w = getRootWidget()->getWidth(); w = getRootWidget()->getWidth();
h = getRootWidget()->getHeight(); h = getRootWidget()->getHeight();
@ -372,7 +374,7 @@ void Window::adjustSize()
{ {
if ( (*iter)->is_open ) if ( (*iter)->is_open )
{ {
int x,y,n; int x, y, n;
n = int(std::distance(begin, iter)); n = int(std::distance(begin, iter));
x = dx + 5 + (n % 3) * 25 + int(n / 3) * 3; x = dx + 5 + (n % 3) * 25 + int(n / 3) * 3;
y = dy + 11 + int(n / 3) * 3; y = dy + 11 + int(n / 3) * 3;
@ -405,7 +407,7 @@ void Window::onClose (FCloseEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Window::cb_createWindows (FWidget*, data_ptr) void Window::cb_createWindows (FWidget*, data_ptr)
{ {
int w,h,dx,dy; int w, h, dx, dy;
std::vector<win_data*>::const_iterator iter, begin; std::vector<win_data*>::const_iterator iter, begin;
iter = begin = windows.begin(); iter = begin = windows.begin();
w = getRootWidget()->getWidth(); w = getRootWidget()->getWidth();