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>
* Wrong UTF-8 string length fixed when attaching to FString

View File

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

View File

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

View File

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

View File

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

View File

@ -240,7 +240,8 @@ void FButtonGroup::insert (FToggleButton* button)
// setChecked the first FRadioButton
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) )
first_button->setChecked();
@ -254,8 +255,6 @@ void FButtonGroup::insert (FToggleButton* button)
"toggled",
F_METHOD_CALLBACK (this, &FButtonGroup::cb_buttonToggled)
);
//checkScrollSize (button);
}
//----------------------------------------------------------------------

View File

@ -43,77 +43,77 @@ class FToggleButton;
class FButtonGroup : public FScrollView
{
public:
// Constructors
explicit FButtonGroup (FWidget* = 0);
FButtonGroup (const FString&, FWidget* = 0);
public:
// Constructors
explicit FButtonGroup (FWidget* = 0);
FButtonGroup (const FString&, FWidget* = 0);
// Destructor
virtual ~FButtonGroup();
// Destructor
virtual ~FButtonGroup();
// Accessor
const char* getClassName() const;
FToggleButton* getFirstButton();
FToggleButton* getLastButton();
FToggleButton* getButton (int) const;
uInt getCount() const;
FString& getText();
// Accessor
const char* getClassName() const;
FToggleButton* getFirstButton();
FToggleButton* getLastButton();
FToggleButton* getButton (int) const;
uInt getCount() const;
FString& getText();
// Mutator
bool setEnable(bool);
bool setEnable();
bool unsetEnable();
bool setDisable();
void setText (const FString&);
// Mutator
bool setEnable(bool);
bool setEnable();
bool unsetEnable();
bool setDisable();
void setText (const FString&);
// Inquiries
bool isChecked(int) const;
bool hasFocusedButton() const;
bool hasCheckedButton() const;
// Inquiries
bool isChecked(int) const;
bool hasFocusedButton() const;
bool hasCheckedButton() const;
// Methods
void hide();
void insert (FToggleButton*);
void remove (FToggleButton*);
void checkScrollSize (FToggleButton*);
void checkScrollSize (const FRect&);
// Methods
void hide();
void insert (FToggleButton*);
void remove (FToggleButton*);
void checkScrollSize (FToggleButton*);
void checkScrollSize (const FRect&);
// Event handlers
void onMouseDown (FMouseEvent*);
void onAccel (FAccelEvent*);
void onFocusIn (FFocusEvent*);
// Event handlers
void onMouseDown (FMouseEvent*);
void onAccel (FAccelEvent*);
void onFocusIn (FFocusEvent*);
// Callback method
void cb_buttonToggled (FWidget*, data_ptr);
// Callback method
void cb_buttonToggled (FWidget*, data_ptr);
protected:
// Accessor
uChar getHotkey();
protected:
// Accessor
uChar getHotkey();
// Mutator
void setHotkeyAccelerator();
// Mutator
void setHotkeyAccelerator();
// Methods
virtual void draw();
void drawLabel();
// Methods
virtual void draw();
void drawLabel();
private:
// Disable copy constructor
FButtonGroup (const FButtonGroup&);
private:
// Disable copy constructor
FButtonGroup (const FButtonGroup&);
// Disable assignment operator (=)
FButtonGroup& operator = (const FButtonGroup&);
// Disable assignment operator (=)
FButtonGroup& operator = (const FButtonGroup&);
// Inquiries
bool isRadioButton (FToggleButton*) const;
// Inquiries
bool isRadioButton (FToggleButton*) const;
// Methods
void init();
void directFocus();
// Methods
void init();
void directFocus();
// Data Members
FString text;
FObjectList buttonlist;
// Data Members
FString text;
FObjectList buttonlist;
};
#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] =
{
{fc::vt100_key_rarrow , fc::BlackRightPointingPointer}, // ►
{fc::vt100_key_larrow , fc::BlackLeftPointingPointer}, // ◄
{fc::vt100_key_uarrow , fc::BlackUpPointingTriangle}, // ▲
{fc::vt100_key_darrow , fc::BlackDownPointingTriangle}, // ▼
{fc::vt100_key_block , fc::FullBlock}, // █
{fc::vt100_key_nsup , fc::SuperscriptLatinSmallLetterN}, // ⁿ
{fc::vt100_key_blackrect, fc::BlackVerticalRectangle}, // ▮
{fc::vt100_key_diamond , fc::BlackDiamond}, // ◆
{fc::vt100_key_ckboard , fc::MediumShade}, // ▒
{fc::vt100_key_htab , fc::SymbolForHorizontalTab}, // ␉
{fc::vt100_key_ff , fc::SymbolForFormFeed}, // ␌
{fc::vt100_key_cr , fc::SymbolForCarriageReturn}, // ␍
{fc::vt100_key_lf , fc::SymbolForLineFeed}, // ␊
{fc::vt100_key_degree , fc::Degree}, // °
{fc::vt100_key_plminus , fc::PlusMinus}, // ±
{fc::vt100_key_board , fc::SymbolForNewline}, // ␤
{fc::vt100_key_lantern , fc::SymbolForVerticalTab}, // ␋
{fc::vt100_key_lrcorner , fc::BoxDrawingsUpAndLeft}, // ┘
{fc::vt100_key_urcorner , fc::BoxDrawingsDownAndLeft}, // ┐
{fc::vt100_key_ulcorner , fc::BoxDrawingsDownAndRight}, // ┌
{fc::vt100_key_llcorner , fc::BoxDrawingsUpAndRight}, // └
{fc::vt100_key_plus , fc::BoxDrawingsCross}, // ┼
{fc::vt100_key_s1 , fc::HorizontalScanLine1}, // ⎺
{fc::vt100_key_s3 , fc::HorizontalScanLine3}, // ⎻
{fc::vt100_key_hline , fc::BoxDrawingsHorizontal}, // ─
{fc::vt100_key_s7 , fc::HorizontalScanLine7}, // ⎼
{fc::vt100_key_s9 , fc::HorizontalScanLine9}, // ⎽
{fc::vt100_key_ltee , fc::BoxDrawingsVerticalAndRight}, // ├
{fc::vt100_key_rtee , fc::BoxDrawingsVerticalAndLeft}, // ┤
{fc::vt100_key_btee , fc::BoxDrawingsUpAndHorizontal}, // ┴
{fc::vt100_key_ttee , fc::BoxDrawingsDownAndHorizontal}, // ┬
{fc::vt100_key_vline , fc::BoxDrawingsVertical}, // │
{fc::vt100_key_lequal , fc::LessThanOrEqualTo}, // ≤
{fc::vt100_key_gequal , fc::GreaterThanOrEqualTo}, // ≥
{fc::vt100_key_pi , fc::Pi}, // π
{fc::vt100_key_nequal , fc::NotEqualTo}, // ≠
{fc::vt100_key_sterling , fc::Pound}, // £
{fc::vt100_key_bullet , fc::SmallBullet}, // ·
{fc::vt100_key_diamond , fc::Bullet} // ◆
{fc::vt100_key_rarrow , fc::BlackRightPointingPointer}, // ►
{fc::vt100_key_larrow , fc::BlackLeftPointingPointer}, // ◄
{fc::vt100_key_uarrow , fc::BlackUpPointingTriangle}, // ▲
{fc::vt100_key_darrow , fc::BlackDownPointingTriangle}, // ▼
{fc::vt100_key_block , fc::FullBlock}, // █
{fc::vt100_key_nsup , fc::SuperscriptLatinSmallLetterN}, // ⁿ
{fc::vt100_key_blackrect, fc::BlackVerticalRectangle}, // ▮
{fc::vt100_key_diamond , fc::BlackDiamond}, // ◆
{fc::vt100_key_ckboard , fc::MediumShade}, // ▒
{fc::vt100_key_htab , fc::SymbolForHorizontalTab}, // ␉
{fc::vt100_key_ff , fc::SymbolForFormFeed}, // ␌
{fc::vt100_key_cr , fc::SymbolForCarriageReturn}, // ␍
{fc::vt100_key_lf , fc::SymbolForLineFeed}, // ␊
{fc::vt100_key_degree , fc::Degree}, // °
{fc::vt100_key_plminus , fc::PlusMinus}, // ±
{fc::vt100_key_board , fc::SymbolForNewline}, // ␤
{fc::vt100_key_lantern , fc::SymbolForVerticalTab}, // ␋
{fc::vt100_key_lrcorner , fc::BoxDrawingsUpAndLeft}, // ┘
{fc::vt100_key_urcorner , fc::BoxDrawingsDownAndLeft}, // ┐
{fc::vt100_key_ulcorner , fc::BoxDrawingsDownAndRight}, // ┌
{fc::vt100_key_llcorner , fc::BoxDrawingsUpAndRight}, // └
{fc::vt100_key_plus , fc::BoxDrawingsCross}, // ┼
{fc::vt100_key_s1 , fc::HorizontalScanLine1}, // ⎺
{fc::vt100_key_s3 , fc::HorizontalScanLine3}, // ⎻
{fc::vt100_key_hline , fc::BoxDrawingsHorizontal}, // ─
{fc::vt100_key_s7 , fc::HorizontalScanLine7}, // ⎼
{fc::vt100_key_s9 , fc::HorizontalScanLine9}, // ⎽
{fc::vt100_key_ltee , fc::BoxDrawingsVerticalAndRight}, // ├
{fc::vt100_key_rtee , fc::BoxDrawingsVerticalAndLeft}, // ┤
{fc::vt100_key_btee , fc::BoxDrawingsUpAndHorizontal}, // ┴
{fc::vt100_key_ttee , fc::BoxDrawingsDownAndHorizontal}, // ┬
{fc::vt100_key_vline , fc::BoxDrawingsVertical}, // │
{fc::vt100_key_lequal , fc::LessThanOrEqualTo}, // ≤
{fc::vt100_key_gequal , fc::GreaterThanOrEqualTo}, // ≥
{fc::vt100_key_pi , fc::Pi}, // π
{fc::vt100_key_nequal , fc::NotEqualTo}, // ≠
{fc::vt100_key_sterling , fc::Pound}, // £
{fc::vt100_key_bullet , fc::SmallBullet}, // ·
{fc::vt100_key_diamond , fc::Bullet} // ◆
};
const int lastKeyItem = int ( sizeof(vt100_key_to_utf8)

View File

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

View File

@ -37,9 +37,9 @@ void FCheckMenuItem::init (FWidget* parent)
if ( ! parent )
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 )
menu_ptr->has_checkable_items = true;

View File

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

View File

@ -1187,7 +1187,7 @@ void FDialog::drawBorder()
// lower left corner border ⎣
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);
setPrintPos (x2, y2);
@ -1204,7 +1204,7 @@ void FDialog::drawBorder()
void FDialog::drawTitleBar()
{
static const int menu_btn = 3;
int i,x,length, zoom_btn;
int i, x, length, zoom_btn;
// draw the title button
setPrintPos (1, 1);
@ -1325,7 +1325,7 @@ void FDialog::drawTitleBar()
}
}
}
else // is not zoomed
else // is not zoomed
{
if ( isNewFont() )
{

View File

@ -48,122 +48,122 @@
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 FWindow::setResizeable;
using FWindow::move;
using FWindow::setPos;
using FWidget::drawBorder;
// Enumeration
enum DialogCode
{
Reject = 0,
Accept = 1
};
// Disable copy constructor
FDialog (const FDialog&);
// Constructors
explicit FDialog (FWidget* = 0);
FDialog (const FString&, FWidget* = 0);
// Disable assignment operator (=)
FDialog& operator = (const FDialog&);
// Destructor
virtual ~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*);
// Accessors
virtual const char* getClassName() const;
FString getText() const;
// Callback methods
void cb_move (FWidget*, data_ptr);
void cb_zoom (FWidget*, data_ptr);
void cb_close (FWidget*, data_ptr);
// 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&);
// 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;
// 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 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();
// Friend function from FMenu
friend void FMenu::hideSuperMenus();
};
#pragma pack(pop)

View File

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

View File

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

View File

@ -1,8 +1,11 @@
// File: ffiledialog.cpp
// Provides: class FFileDialog
#include <vector>
#include "ffiledialog.h"
// non-member functions
//----------------------------------------------------------------------
bool sortByName ( const FFileDialog::dir_entry& lhs
@ -230,7 +233,6 @@ void FFileDialog::onKeyPress (FKeyEvent* ev)
default:
break;
}
}
//----------------------------------------------------------------------
@ -268,7 +270,8 @@ int FFileDialog::readDir()
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;
dir_entry entry;
@ -280,7 +283,9 @@ int FFileDialog::readDir()
char resolved_path[MAXPATHLEN] = {};
char symLink[MAXPATHLEN] = {};
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
{
@ -310,7 +315,6 @@ int FFileDialog::readDir()
}
else
break;
} // end while
if ( closedir (directory_stream) != 0 )
@ -326,11 +330,17 @@ int FFileDialog::readDir()
dir_num = numOfDirs();
// 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
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
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
filebrowser->clear();
@ -525,9 +535,9 @@ void FFileDialog::init()
cancel->setGeometry(19, 10, 9, 1);
if ( dlg_type == FFileDialog::Save )
open = new FButton("&Save",this);
open = new FButton("&Save", this);
else
open = new FButton("&Open",this);
open = new FButton("&Open", this);
open->setGeometry(30, 10, 9, 1);
setGeometry (x, y, getWidth(), getHeight());
@ -581,19 +591,18 @@ void FFileDialog::init()
//----------------------------------------------------------------------
char* FFileDialog::getHomeDir()
{
struct passwd* pwd;
pwd = getpwuid( geteuid() );
struct passwd pwd;
struct passwd* pwd_ptr;
char buf[1024];
if ( ! pwd )
if ( getpwuid_r (geteuid(), &pwd, buf, sizeof(buf), &pwd_ptr) )
return const_cast<char*>("");
else
{
pwd = getpwnam(pwd->pw_name);
if ( ! pwd )
if ( getpwnam_r (pwd.pw_name, &pwd, buf, sizeof(buf), &pwd_ptr) )
return const_cast<char*>("");
else
return pwd->pw_dir;
return pwd.pw_dir;
}
}
@ -695,7 +704,8 @@ int FFileDialog::changeDir (const FString& dirname)
{
int i = 1;
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();
end = dir_entries.end();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,6 +2,8 @@
// Provides: class FListBoxItem
// class FListBox
#include <algorithm>
#include "fapplication.h"
#include "flistbox.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
@ -403,7 +405,7 @@ void FListBox::clear()
//----------------------------------------------------------------------
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 current_before = current;
int xoffset_before = xoffset;
@ -1306,8 +1308,8 @@ void FListBox::draw()
for (int y = 2; y < getHeight(); y++)
{
setPrintPos (getWidth(),y);
print (' '); // clear right side of the scrollbar
setPrintPos (getWidth(), y);
print (' '); // clear right side of the scrollbar
}
}
@ -1448,7 +1450,7 @@ void FListBox::drawList()
setColor ( wc.selected_current_element_fg
, wc.selected_current_element_bg );
setCursorPos (3, 2 + int(y)); // first character
setCursorPos (3, 2 + int(y)); // first character
}
else
{
@ -1464,10 +1466,11 @@ void FListBox::drawList()
if ( inc_len > 0 ) // incremental search
{
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
setCursorPos (3 + b, 2 + int(y)); // first character
setCursorPos (3 + b, 2 + int(y)); // first character
}
else
setColor ( wc.current_element_fg
@ -1793,7 +1796,7 @@ void FListBox::cb_VBarChange (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;
int distance = 1;
int xoffset_before = xoffset;

View File

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

View File

@ -2,6 +2,8 @@
// Provides: class FListViewItem
// class FListView
#include <vector>
#include "fapplication.h"
#include "flistview.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++)
{
setPrintPos (getWidth(),y);
setPrintPos (getWidth(), y);
print (' '); // clear right side of the scrollbar
}
}
@ -1233,7 +1235,7 @@ void FListView::drawList()
{
setColor ( wc.current_element_focus_fg
, wc.current_element_focus_bg );
setCursorPos (3, 2 + int(y)); // first character
setCursorPos (3, 2 + int(y)); // first character
}
else
setColor ( wc.current_element_fg

View File

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

View File

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

View File

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

View File

@ -1,6 +1,8 @@
// File: fmenubar.cpp
// Provides: class FMenuBar
#include <vector>
#include "fapplication.h"
#include "fmenubar.h"
#include "fstatusbar.h"
@ -20,7 +22,7 @@ FMenuBar::FMenuBar(FWidget* parent)
}
//----------------------------------------------------------------------
FMenuBar::~FMenuBar()
FMenuBar::~FMenuBar() // destructor
{
setMenuBar(0);
}
@ -428,7 +430,8 @@ void FMenuBar::onMouseMove (FMouseEvent* ev)
}
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
{
public:
// Constructor
explicit FMenuBar (FWidget* = 0);
public:
// Constructor
explicit FMenuBar (FWidget* = 0);
// Destructor
virtual ~FMenuBar();
// Destructor
virtual ~FMenuBar();
// Accessors
virtual const char* getClassName() const;
// Accessors
virtual const char* getClassName() const;
// Methods
void hide();
void resetMenu();
void adjustSize();
// Methods
void hide();
void resetMenu();
void adjustSize();
// Event handlers
void onKeyPress (FKeyEvent*);
void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*);
void onMouseMove (FMouseEvent*);
void onAccel (FAccelEvent*);
// Event handlers
void onKeyPress (FKeyEvent*);
void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*);
void onMouseMove (FMouseEvent*);
void onAccel (FAccelEvent*);
// Callback methods
void cb_item_deactivated (FWidget*, data_ptr);
// Callback methods
void cb_item_deactivated (FWidget*, data_ptr);
private:
// Disable copy constructor
FMenuBar (const FMenuBar&);
private:
// Disable copy constructor
FMenuBar (const FMenuBar&);
// Disable assignment operator (=)
FMenuBar& operator = (const FMenuBar&);
// Disable assignment operator (=)
FMenuBar& operator = (const FMenuBar&);
// Inquiry
bool isMenu (FMenuItem*) const;
// Inquiry
bool isMenu (FMenuItem*) const;
// Methods
void init();
void calculateDimensions();
bool selectNextItem();
bool selectPrevItem();
bool hotkeyMenu (FKeyEvent*&);
int getHotkeyPos (wchar_t*&, wchar_t*&, uInt);
void draw();
void drawItems();
void adjustItems();
void leaveMenuBar();
// Methods
void init();
void calculateDimensions();
bool selectNextItem();
bool selectPrevItem();
bool hotkeyMenu (FKeyEvent*&);
int getHotkeyPos (wchar_t*&, wchar_t*&, uInt);
void draw();
void drawItems();
void adjustItems();
void leaveMenuBar();
// Friend classes
friend class FMenu;
friend class FMenuItem;
// Friend classes
friend class FMenu;
friend class FMenuItem;
// Data Members
bool mouse_down;
bool drop_down;
// Data Members
bool mouse_down;
bool drop_down;
};
#pragma pack(pop)

View File

@ -136,14 +136,14 @@ bool FMenuItem::setFocus (bool on)
if ( isMenuBar(parent) )
{
FMenuBar* menubar_ptr = dynamic_cast<FMenuBar*>(parent);
FMenuBar* menubar_ptr = static_cast<FMenuBar*>(parent);
if ( menubar_ptr )
menubar_ptr->redraw();
}
else if ( isMenu(parent) )
{
FMenu* menu_ptr = dynamic_cast<FMenu*>(parent);
FMenu* menu_ptr = static_cast<FMenu*>(parent);
if ( menu_ptr )
menu_ptr->redraw();
@ -215,7 +215,7 @@ void FMenuItem::addAccelerator (int key, FWidget* obj)
if ( isMenu(super_menu) )
{
FMenu* menu_ptr = dynamic_cast<FMenu*>(super_menu);
FMenu* menu_ptr = static_cast<FMenu*>(super_menu);
if ( menu_ptr )
menu_ptr->calculateDimensions();
@ -248,7 +248,7 @@ void FMenuItem::delAccelerator (FWidget* obj)
if ( isMenu(super_menu) )
{
FMenu* menu_ptr = dynamic_cast<FMenu*>(super_menu);
FMenu* menu_ptr = static_cast<FMenu*>(super_menu);
if ( menu_ptr )
menu_ptr->calculateDimensions();
@ -297,7 +297,7 @@ void FMenuItem::onKeyPress (FKeyEvent* ev)
if ( isMenu(super_menu) )
{
FMenu* smenu = dynamic_cast<FMenu*>(super_menu);
FMenu* smenu = static_cast<FMenu*>(super_menu);
if ( smenu )
smenu->onKeyPress(ev);
@ -305,7 +305,7 @@ void FMenuItem::onKeyPress (FKeyEvent* ev)
if ( isMenuBar(super_menu) )
{
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu);
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( mbar )
{
@ -328,7 +328,7 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
if ( isMenu(super_menu) )
{
FMenu* smenu = dynamic_cast<FMenu*>(super_menu);
FMenu* smenu = static_cast<FMenu*>(super_menu);
if ( smenu )
{
@ -336,20 +336,22 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
try
{
FMouseEvent* _ev = new FMouseEvent (fc::MouseDoubleClick_Event, p2, t, b);
FMouseEvent* _ev = new FMouseEvent ( fc::MouseDoubleClick_Event
, p2, t, b );
smenu->onMouseDoubleClick(_ev);
delete _ev;
}
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) )
{
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu);
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( mbar )
{
@ -357,20 +359,22 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
try
{
FMouseEvent* _ev = new FMouseEvent (fc::MouseDoubleClick_Event, p2, t, b);
FMouseEvent* _ev = new FMouseEvent ( fc::MouseDoubleClick_Event
, p2, t, b );
mbar->onMouseDoubleClick(_ev);
delete _ev;
}
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) )
{
FDialog* dgl = dynamic_cast<FDialog*>(super_menu);
FDialog* dgl = static_cast<FDialog*>(super_menu);
if ( dgl )
{
@ -378,13 +382,15 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
try
{
FMouseEvent* _ev = new FMouseEvent (fc::MouseDoubleClick_Event, p2, t, b);
FMouseEvent* _ev = new FMouseEvent ( fc::MouseDoubleClick_Event
, p2, t, b );
dgl->onMouseDoubleClick(_ev);
delete _ev;
}
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) )
{
FMenu* smenu = dynamic_cast<FMenu*>(super_menu);
FMenu* smenu = static_cast<FMenu*>(super_menu);
if ( smenu )
{
@ -409,20 +415,22 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
try
{
FMouseEvent* _ev = new FMouseEvent (fc::MouseDown_Event, p2, t, b);
FMouseEvent* _ev = new FMouseEvent ( fc::MouseDown_Event
, p2, t, b );
smenu->onMouseDown(_ev);
delete _ev;
}
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) )
{
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu);
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( mbar )
{
@ -430,20 +438,22 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
try
{
FMouseEvent* _ev = new FMouseEvent (fc::MouseDown_Event, p2, t, b);
FMouseEvent* _ev = new FMouseEvent ( fc::MouseDown_Event
, p2, t, b );
mbar->onMouseDown(_ev);
delete _ev;
}
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) )
{
FDialog* dgl = dynamic_cast<FDialog*>(super_menu);
FDialog* dgl = static_cast<FDialog*>(super_menu);
if ( dgl )
{
@ -451,13 +461,15 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
try
{
FMouseEvent* _ev = new FMouseEvent (fc::MouseDown_Event, p2, t, b);
FMouseEvent* _ev = new FMouseEvent ( fc::MouseDown_Event
, p2, t, b );
dgl->onMouseDown(_ev);
delete _ev;
}
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) )
{
FMenu* smenu = dynamic_cast<FMenu*>(super_menu);
FMenu* smenu = static_cast<FMenu*>(super_menu);
if ( smenu )
{
@ -487,7 +499,7 @@ void FMenuItem::onMouseUp (FMouseEvent* ev)
if ( isMenuBar(super_menu) )
{
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu);
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( mbar )
{
@ -500,7 +512,7 @@ void FMenuItem::onMouseUp (FMouseEvent* ev)
if ( isWindowsMenu(super_menu) )
{
FDialog* dgl = dynamic_cast<FDialog*>(super_menu);
FDialog* dgl = static_cast<FDialog*>(super_menu);
if ( dgl )
{
@ -523,7 +535,7 @@ void FMenuItem::onMouseMove (FMouseEvent* ev)
if ( isMenu(super_menu) )
{
FMenu* smenu = dynamic_cast<FMenu*>(super_menu);
FMenu* smenu = static_cast<FMenu*>(super_menu);
if ( smenu )
{
@ -536,7 +548,7 @@ void FMenuItem::onMouseMove (FMouseEvent* ev)
if ( isMenuBar(super_menu) )
{
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu);
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( mbar )
{
@ -549,7 +561,7 @@ void FMenuItem::onMouseMove (FMouseEvent* ev)
if ( isWindowsMenu(super_menu) )
{
FDialog* dgl = dynamic_cast<FDialog*>(super_menu);
FDialog* dgl = static_cast<FDialog*>(super_menu);
if ( dgl )
{
@ -573,7 +585,7 @@ void FMenuItem::onAccel (FAccelEvent* ev)
return;
}
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu);
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( ! mbar )
return;
@ -639,7 +651,7 @@ void FMenuItem::onFocusOut (FFocusEvent*)
if ( super_menu && isMenuBar(super_menu) )
{
FMenuBar* mbar = dynamic_cast<FMenuBar*>(super_menu);
FMenuBar* mbar = static_cast<FMenuBar*>(super_menu);
if ( mbar )
mbar->redraw();
@ -703,16 +715,17 @@ void FMenuItem::init (FWidget* parent)
if ( menu_list )
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 )
{
menubar_ptr->calculateDimensions();
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
@ -721,9 +734,9 @@ void FMenuItem::init (FWidget* parent)
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 )
menu_ptr->calculateDimensions();
@ -781,7 +794,7 @@ void FMenuItem::createDialogList (FMenu* winmenu)
while ( iter != dialog_list->end() && *iter )
{
FDialog* win = dynamic_cast<FDialog*>(*iter);
FDialog* win = static_cast<FDialog*>(*iter);
if ( win )
{
@ -797,18 +810,19 @@ void FMenuItem::createDialogList (FMenu* winmenu)
}
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;
}
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
(
"clicked",
F_METHOD_CALLBACK (win_item, &FMenuItem::cb_switchToDialog),
dynamic_cast<FWidget::data_ptr>(win)
static_cast<FWidget::data_ptr>(win)
);
win->addCallback

View File

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

View File

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

View File

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

View File

@ -1,6 +1,8 @@
// File: fmessagebox.cpp
// Provides: class FMessageBox
#include <algorithm>
#include "fapplication.h"
#include "fmessagebox.h"
@ -426,7 +428,8 @@ void FMessageBox::draw()
int head_offset = 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() )
setReverse(true);

View File

@ -54,96 +54,96 @@
class FMessageBox : public FDialog
{
public:
// Enumeration
enum
{
Reject = 0,
Ok = 1,
Cancel = 2,
Yes = 3,
No = 4,
Abort = 5,
Retry = 6,
Ignore = 7
};
public:
// Enumeration
enum
{
Reject = 0,
Ok = 1,
Cancel = 2,
Yes = 3,
No = 4,
Abort = 5,
Retry = 6,
Ignore = 7
};
// Constructors
explicit FMessageBox (FWidget* = 0);
FMessageBox (const FMessageBox&); // copy constructor
FMessageBox ( const FString&, const FString&
, int, int, int
, FWidget* = 0 );
// Destructor
~FMessageBox();
// Constructors
explicit FMessageBox (FWidget* = 0);
FMessageBox (const FMessageBox&); // copy constructor
FMessageBox ( const FString&, const FString&
, int, int, int
, FWidget* = 0 );
// Destructor
~FMessageBox();
// Assignment operator (=)
FMessageBox& operator = (const FMessageBox&);
// Assignment operator (=)
FMessageBox& operator = (const FMessageBox&);
// Accessor
const char* getClassName() const;
const FString getTitlebarText() const;
const FString getHeadline() const;
const FString getText() const;
// Accessor
const char* getClassName() const;
const FString getTitlebarText() const;
const FString getHeadline() const;
const FString getText() const;
// Mutator
void setTitlebarText (const FString&);
void setHeadline (const FString&);
bool setCenterText(bool);
bool setCenterText();
bool unsetCenterText();
void setText (const FString&);
// Mutator
void setTitlebarText (const FString&);
void setHeadline (const FString&);
bool setCenterText(bool);
bool setCenterText();
bool unsetCenterText();
void setText (const FString&);
// Methods
static int info ( FWidget*
, 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*
// Methods
static int info ( FWidget*
, const FString&
, const FString&
, int = FMessageBox::Ok
, int = 0
, int = 0 );
protected:
// Method
void adjustSize();
// Callback method
void cb_processClick (FWidget*, data_ptr);
static int info ( FWidget*
, const FString&
, int
, int = FMessageBox::Ok
, int = 0
, int = 0 );
private:
// Typedef
typedef std::vector<FString> textLines;
static int error ( FWidget*
, const FString&
, int = FMessageBox::Ok
, int = 0
, int = 0 );
protected:
// Method
void adjustSize();
// Methods
void init (int, int, int);
void calculateDimensions();
virtual void draw();
void resizeButtons();
void adjustButtons();
// Callback method
void cb_processClick (FWidget*, data_ptr);
// 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];
private:
// Typedef
typedef std::vector<FString> textLines;
// Methods
void init (int, int, int);
void calculateDimensions();
virtual void draw();
void resizeButtons();
void adjustButtons();
// 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)

View File

@ -27,7 +27,6 @@ FObject::FObject (FObject* parent)
if ( parent == 0 )
{
timer_modify_lock = false;
if ( ! timer_list )
@ -95,8 +94,6 @@ FObject::~FObject() // destructor
++iter;
}
}
}
// 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
while ( time.tv_usec >= 1000000 )
while ( time->tv_usec >= 1000000 )
{
time.tv_usec -= 1000000;
time.tv_sec++;
time->tv_usec -= 1000000;
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_sec--;
time->tv_usec += 1000000;
time->tv_sec--;
}
else
{
time.tv_usec = 0;
time->tv_usec = 0;
break;
}
}
@ -232,7 +229,7 @@ int FObject::addTimer (int interval)
time_interval.tv_sec = interval / 1000;
time_interval.tv_usec = (interval % 1000) * 1000;
getCurrentTime (currentTime);
getCurrentTime (&currentTime);
timeval timeout = currentTime + time_interval;
timer_data t = { id, time_interval, timeout, this };

View File

@ -12,7 +12,7 @@
#define FOBJECT_H
#include <stdint.h>
#include <sys/time.h> // need for gettimeofday
#include <sys/time.h> // need for gettimeofday
#include <cstdlib>
#include <cstring>
#include <list>
@ -22,24 +22,6 @@
#include "fevent.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
@ -50,76 +32,76 @@ typedef long double lDouble;
class FObject
{
public:
// Typedef
typedef std::list<FObject*> FObjectList;
public:
// Typedef
typedef std::list<FObject*> FObjectList;
// Constructor
explicit FObject (FObject* = 0);
// Constructor
explicit FObject (FObject* = 0);
// Destructor
virtual ~FObject();
// Destructor
virtual ~FObject();
// Accessors
virtual const char* getClassName() const;
FObject* getParent() const;
FObject* getChild (int) const;
const FObjectList& getChildren() const;
int numOfChildren() const;
// Accessors
virtual const char* getClassName() const;
FObject* getParent() const;
FObject* getChild (int) const;
const FObjectList& getChildren() const;
int numOfChildren() const;
// Inquiries
bool hasParent() const;
bool hasChildren() const;
bool isChild (FObject*) const;
bool isDirectChild (FObject*) const;
bool isWidget() const;
bool isInstanceOf (const char*) const;
bool isTimerInUpdating() const;
// Inquiries
bool hasParent() const;
bool hasChildren() const;
bool isChild (FObject*) const;
bool isDirectChild (FObject*) const;
bool isWidget() const;
bool isInstanceOf (const char*) const;
bool isTimerInUpdating() const;
// Methods
void removeParent();
void addChild (FObject*);
void delChild (FObject*);
// Methods
void removeParent();
void addChild (FObject*);
void delChild (FObject*);
// Timer methods
static void getCurrentTime (timeval&);
int addTimer (int);
bool delTimer (int);
bool delOwnTimer();
bool delAllTimer();
// Timer methods
static void getCurrentTime (timeval*);
int addTimer (int);
bool delTimer (int);
bool delOwnTimer();
bool delAllTimer();
protected:
struct timer_data
{
int id;
timeval interval;
timeval timeout;
FObject* object;
};
protected:
struct timer_data
{
int id;
timeval interval;
timeval timeout;
FObject* object;
};
// Typedef
typedef std::vector<timer_data> TimerList;
// Typedef
typedef std::vector<timer_data> TimerList;
// Event handler
virtual bool event (FEvent*);
virtual void onTimer (FTimerEvent*);
// Event handler
virtual bool event (FEvent*);
virtual void onTimer (FTimerEvent*);
// Data Members
static TimerList* timer_list;
bool widget_object;
// Data Members
static TimerList* timer_list;
bool widget_object;
private:
// Disable copy constructor
FObject (const FObject&);
private:
// Disable copy constructor
FObject (const FObject&);
// Disable assignment operator (=)
FObject& operator = (const FObject&);
// Disable assignment operator (=)
FObject& operator = (const FObject&);
// Data Members
FObject* parent_obj;
FObjectList children_list;
bool has_parent;
static bool timer_modify_lock;
// Data Members
FObject* parent_obj;
FObjectList children_list;
bool has_parent;
static bool timer_modify_lock;
};
#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
#define FOPTIATTR_H
#include <algorithm> // need for std::swap
#include <assert.h>
#include <term.h> // need for tparm
#include <algorithm> // need for std::swap
#include "fc.h"
@ -28,244 +28,243 @@
class FOptiAttr
{
public:
// Typedef
typedef struct
{
int code; // character code
short fg_color; // foreground color
short bg_color; // background color
public:
// Typedef
typedef struct
{
int code; // character code
short fg_color; // foreground color
short bg_color; // background color
union attribute
{
struct
{
// Attribute byte #1
uChar bold : 1; // bold
uChar dim : 1; // dim
uChar italic : 1; // italic
uChar underline : 1; // underline
uChar blink : 1; // blink
uChar reverse : 1; // reverse
uChar standout : 1; // standout
uChar invisible : 1; // invisible
// Attribute byte #2
uChar protect : 1; // protect mode
uChar crossed_out : 1; // crossed out
uChar dbl_underline : 1; // double underline
uChar alt_charset : 1; // alternate character set (vt100)
uChar pc_charset : 1; // pc character set (CP437)
uChar transparent : 1; // transparent
uChar trans_shadow : 1; // transparent shadow
uChar inherit_bg : 1; // inherit background
// Attribute byte #3
uChar no_changes : 1; // no changes required
uChar printed : 1; // is printed to VTerm
uChar : 6; // padding bits
} bit;
union attribute
{
struct
{
// Attribute byte #1
uChar bold : 1; // bold
uChar dim : 1; // dim
uChar italic : 1; // italic
uChar underline : 1; // underline
uChar blink : 1; // blink
uChar reverse : 1; // reverse
uChar standout : 1; // standout
uChar invisible : 1; // invisible
// Attribute byte #2
uChar protect : 1; // protect mode
uChar crossed_out : 1; // crossed out
uChar dbl_underline : 1; // double underline
uChar alt_charset : 1; // alternate character set (vt100)
uChar pc_charset : 1; // pc character set (CP437)
uChar transparent : 1; // transparent
uChar trans_shadow : 1; // transparent shadow
uChar inherit_bg : 1; // inherit background
// Attribute byte #3
uChar no_changes : 1; // no changes required
uChar printed : 1; // is printed to VTerm
uChar : 6; // padding bits
} bit;
uChar byte1;
uChar byte2;
uChar byte3;
} attr;
uChar byte1;
uChar byte2;
uChar byte3;
} attr;
} char_data;
} char_data;
// Constructor
explicit FOptiAttr();
// Constructor
explicit FOptiAttr();
// Destructor
~FOptiAttr();
// Destructor
~FOptiAttr();
// Friend operator functions
friend bool operator == (const char_data&, const char_data&);
friend bool operator != (const char_data&, const char_data&);
// Friend operator functions
friend bool operator == (const char_data&, const char_data&);
friend bool operator != (const char_data&, const char_data&);
// Mutators
void setMaxColor (const int&);
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
void setMaxColor (int&);
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
static bool isNormal (char_data*&);
// Inquiry
static bool isNormal (char_data*&);
// Methods
void init();
static short vga2ansi (register short);
char* changeAttribute (char_data*&, char_data*&);
// Methods
void init();
static short vga2ansi (register short);
char* changeAttribute (char_data*&, char_data*&);
private:
// Typedefs and Enumerations
typedef unsigned char uChar;
private:
// Typedefs and Enumerations
typedef unsigned char uChar;
typedef struct
{
char* cap;
bool caused_reset;
} capability;
typedef struct
{
char* cap;
bool caused_reset;
} capability;
enum init_reset_tests
{
no_test = 0x00,
test_ansi_reset = 0x01, // ANSI X3.64 terminal
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
{
no_test = 0x00,
test_ansi_reset = 0x01, // ANSI X3.64 terminal
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 default_color
{
Default = -1,
Black = 0,
LightGray = 7
};
enum default_color
{
Default = -1,
Black = 0,
LightGray = 7
};
// Disable copy constructor
FOptiAttr (const FOptiAttr&);
// Disable copy constructor
FOptiAttr (const FOptiAttr&);
// Disable assignment operator (=)
FOptiAttr& operator = (const FOptiAttr&);
// Disable assignment operator (=)
FOptiAttr& operator = (const FOptiAttr&);
// Mutators
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
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*&);
// Inquiries
static bool hasColor (char_data*&);
static bool hasAttribute (char_data*&);
static bool hasNoAttribute (char_data*&);
// Inquiries
static bool hasColor (char_data*&);
static bool hasAttribute (char_data*&);
static bool hasNoAttribute (char_data*&);
// Methods
bool colorChange (char_data*&, char_data*&);
void resetColor (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
bool colorChange (char_data*&, char_data*&);
void resetColor (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*&);
// Data Members
capability F_enter_bold_mode;
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;
// Data Members
capability F_enter_bold_mode;
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;
char_data off;
char_data on;
char_data off;
int max_color;
int attr_without_color;
bool ansi_default_color;
bool monochron;
bool fake_reverse;
bool cygwin_terminal;
char attr_buf[8192];
char* attr_ptr;
int max_color;
int attr_without_color;
bool ansi_default_color;
bool monochron;
bool fake_reverse;
bool cygwin_terminal;
char attr_buf[8192];
char* attr_ptr;
};
#pragma pack(pop)
@ -288,7 +287,7 @@ inline bool operator != ( const FOptiAttr::char_data& lhs,
{ return ! ( lhs == rhs ); }
//----------------------------------------------------------------------
inline void FOptiAttr::setMaxColor (int& c)
inline void FOptiAttr::setMaxColor (const int& c)
{ max_color = c; }
//----------------------------------------------------------------------

View File

@ -1,8 +1,10 @@
// File: foptimove.cpp
// Provides: class FOptiMove
#include <cstring>
#include "foptimove.h"
#include "string.h"
//----------------------------------------------------------------------
// 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()
{
std::cout << " speed: " << baudrate << " baud\r\n";
std::cout << " char_duration: " << char_duration << " ms\r\n";
std::cout << " cursor_home: " << F_cursor_home.duration << " ms\r\n";
std::cout << " cursor_to_ll: " << F_cursor_to_ll.duration << " ms\r\n";
std::cout << " carriage_return: " << F_carriage_return.duration << " ms\r\n";
std::cout << " tab: " << F_tab.duration << " ms\r\n";
std::cout << " back_tab: " << F_back_tab.duration << " ms\r\n";
std::cout << " cursor_up: " << F_cursor_up.duration << " ms\r\n";
std::cout << " cursor_down: " << 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";
std::cout << " speed: "
<< baudrate << " baud\r\n";
std::cout << " char_duration: "
<< char_duration << " ms\r\n";
std::cout << " cursor_home: "
<< F_cursor_home.duration << " ms\r\n";
std::cout << " cursor_to_ll: "
<< F_cursor_to_ll.duration << " ms\r\n";
std::cout << " carriage_return: "
<< F_carriage_return.duration << " ms\r\n";
std::cout << " tab: "
<< F_tab.duration << " ms\r\n";
std::cout << " back_tab: "
<< F_back_tab.duration << " ms\r\n";
std::cout << " cursor_up: "
<< F_cursor_up.duration << " ms\r\n";
std::cout << " cursor_down: "
<< 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 )
{
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)
/ (baudrate > 0 ? baudrate : 9600); // milliseconds
/ (baudrate > 0 ? baudrate : 9600); // milliseconds
if ( char_duration <= 0 )
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 dst_len;
@ -786,7 +806,7 @@ int FOptiMove::relativeMove ( char*& move
vtime = repeatedAppend (F_cursor_down, num, move);
}
}
else // to_y < from_y
else // to_y < from_y
{
num = from_y - to_y;
@ -874,10 +894,9 @@ int FOptiMove::relativeMove ( char*& move
std::strncpy (hmove, str, sizeof(move_buf) - 1);
htime = htime_r;
}
}
}
else // to_x < from_x
else // to_x < from_x
{
num = from_x - to_x;
@ -924,7 +943,6 @@ int FOptiMove::relativeMove ( char*& move
std::strncpy (hmove, str, sizeof(move_buf) - 1);
htime = htime_l;
}
}
}
@ -947,7 +965,8 @@ int FOptiMove::relativeMove ( char*& move
inline bool FOptiMove::isWideMove ( int xold, int yold
, int xnew, int ynew )
{
return bool ( (xnew > MOVE_LIMIT)
&& (xnew < screen_width - 1 - MOVE_LIMIT)
&& (std::abs(xnew - xold) + std::abs(ynew - yold) > MOVE_LIMIT) );
return bool ( xnew > MOVE_LIMIT
&& xnew < screen_width - 1 - MOVE_LIMIT
&& std::abs(xnew - xold) + std::abs(ynew - yold)
> MOVE_LIMIT );
}

View File

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

View File

@ -20,45 +20,45 @@
class FPoint
{
public:
// Constructors
FPoint ();
FPoint (const FPoint&); // copy constructor
FPoint (int, int);
public:
// Constructors
FPoint ();
FPoint (const FPoint&); // copy constructor
FPoint (int, int);
// Destructor
virtual ~FPoint();
// Destructor
virtual ~FPoint();
// Overloaded operators
FPoint& operator = (const FPoint&);
FPoint& operator += (const FPoint&);
FPoint& operator -= (const FPoint&);
// Overloaded operators
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 FPoint operator + (const FPoint&, const FPoint&);
friend inline FPoint operator - (const FPoint&, const FPoint&);
friend inline FPoint operator - (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&);
// Accessors
virtual const char* getClassName();
int getX() const;
int getY() const;
void setX (int);
void setY (int);
void setPoint (int, int);
// Accessors
virtual const char* getClassName();
int getX() const;
int getY() const;
void setX (int);
void setY (int);
void setPoint (int, int);
// Inquiry
bool isNull() const;
// Inquiry
bool isNull() const;
// Point references
short& x_ref();
short& y_ref();
// Point references
short& x_ref();
short& y_ref();
private:
// Data Members
short xpos;
short ypos;
private:
// Data Members
short xpos;
short ypos;
};
#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
{
setColor (wc.progressbar_fg, wc.progressbar_bg);
print (fc::LeftHalfBlock); // ▌
print (fc::LeftHalfBlock); // ▌
}
i++;

View File

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

View File

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

View File

@ -38,9 +38,9 @@ void FRadioMenuItem::init (FWidget* parent)
if ( ! parent )
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 )
menu_ptr->has_checkable_items = true;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -25,7 +25,7 @@ FWindow::FWindow(FWidget* parent)
{
setWindowWidget();
FRect geometry = getTermGeometry();
geometry.move(-1,-1);
geometry.move(-1, -1);
createArea (geometry, getShadow(), vwin);
addWindow (this);
}
@ -261,12 +261,12 @@ void FWindow::drawBorder()
int y2 = 1 + getHeight() - 1;
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++)
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++)
{
@ -282,7 +282,7 @@ void FWindow::drawBorder()
// lower left corner border ⎣
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);
setPrintPos (x2, y2);
@ -358,7 +358,7 @@ void FWindow::setWidth (int w, bool adjust)
if ( isVirtualWindow() && getWidth() != old_width )
{
FRect geometry = getTermGeometry();
geometry.move(-1,-1);
geometry.move(-1, -1);
resizeArea (geometry, getShadow(), vwin);
}
}
@ -372,7 +372,7 @@ void FWindow::setHeight (int h, bool adjust)
if ( isVirtualWindow() && getHeight() != old_height )
{
FRect geometry = getTermGeometry();
geometry.move(-1,-1);
geometry.move(-1, -1);
resizeArea (geometry, getShadow(), vwin);
}
}
@ -384,10 +384,11 @@ void FWindow::setSize (int w, int h, bool adjust)
int old_height = getHeight();
FWidget::setSize (w, h, adjust);
if ( isVirtualWindow() && (getWidth() != old_width || getHeight() != old_height) )
if ( isVirtualWindow()
&& (getWidth() != old_width || getHeight() != old_height) )
{
FRect geometry = getTermGeometry();
geometry.move(-1,-1);
geometry.move(-1, -1);
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 )
{
FRect geometry = getTermGeometry();
geometry.move(-1,-1);
geometry.move(-1, -1);
resizeArea (geometry, getShadow(), vwin);
}
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)
{
FWidget::move (dx,dy);
FWidget::move (dx, dy);
if ( isVirtualWindow() )
{
@ -456,12 +457,11 @@ FWindow* FWindow::getWindowWidgetAt (int x, int y)
FWindow* w = static_cast<FWindow*>(*iter);
if ( ! w->isWindowHidden()
&& w->getTermGeometry().contains(x,y) )
&& w->getTermGeometry().contains(x, y) )
return w;
}
}
while ( iter != begin );
}
return 0;
@ -779,10 +779,11 @@ void FWindow::setShadowSize (int right, int bottom)
new_right = getShadow().getX();
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();
geometry.move(-1,-1);
geometry.move(-1, -1);
resizeArea (geometry, getShadow(), vwin);
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -20,30 +20,30 @@
class Menu : public FDialog
{
public:
// Constructor
explicit Menu (FWidget* = 0);
public:
// Constructor
explicit Menu (FWidget* = 0);
// Destructor
~Menu();
// Destructor
~Menu();
private:
// Disable copy constructor
Menu (const Menu&);
private:
// Disable copy constructor
Menu (const Menu&);
// Disable assignment operator (=)
Menu& operator = (const Menu&);
// Disable assignment operator (=)
Menu& operator = (const Menu&);
// Methods
void defaultCallback (FMenuList*);
void adjustSize();
// Methods
void defaultCallback (FMenuList*);
void adjustSize();
// Event handler
void onClose (FCloseEvent*);
// Event handler
void onClose (FCloseEvent*);
// Callback methods
void cb_message (FWidget*, data_ptr);
void cb_exitApp (FWidget*, data_ptr);
// Callback methods
void cb_message (FWidget*, data_ptr);
void cb_exitApp (FWidget*, data_ptr);
};
#pragma pack(pop)
@ -68,28 +68,28 @@ Menu::Menu (FWidget* parent)
// "File" menu items
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");
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");
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");
FMenuItem* SaveAs = new FMenuItem ("&Save as...", File);
SaveAs->setStatusbarMessage ("Save the current file under a different name");
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");
FMenuItem* Line1 = new FMenuItem (File);
Line1->setSeparator();
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");
FMenuItem* Line2 = new FMenuItem (File);
Line2->setSeparator();
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");
// "Edit" menu items
@ -100,7 +100,8 @@ Menu::Menu (FWidget* parent)
FMenuItem* Line3 = new FMenuItem (Edit);
Line3->setSeparator();
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);
Copy->setStatusbarMessage ("Copy the input text into the clipboad");
FMenuItem* Paste = new FMenuItem (fc::Fckey_v, "&Paste", Edit);
@ -184,19 +185,19 @@ Menu::Menu (FWidget* parent)
// Headline labels
FLabel* Headline1 = new FLabel(" Key ", this);
Headline1->ignorePadding();
Headline1->setGeometry(3,2,5,1);
Headline1->setGeometry(3, 2, 5, 1);
Headline1->setEmphasis();
FLabel* Headline2 = new FLabel(" Function ", this);
Headline2->ignorePadding();
Headline2->setGeometry(19,2,10,1);
Headline2->setGeometry(19, 2, 10, 1);
Headline2->setEmphasis();
// Info label
FLabel* Info = new FLabel("<F10> Activate menu bar\n"
"<Ctrl>+<Space> Activate menu bar\n"
"<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
{
public:
// Constructor
explicit ColorChooser (FWidget* = 0);
public:
// Constructor
explicit ColorChooser (FWidget* = 0);
// Destructor
~ColorChooser();
// Destructor
~ColorChooser();
// Accessors
short getForeground();
short getBackground();
// Accessors
short getForeground();
short getBackground();
private:
// Disable copy constructor
ColorChooser (const ColorChooser&);
// Disable assignment operator (=)
ColorChooser& operator = (const ColorChooser&);
private:
// Disable copy constructor
ColorChooser (const ColorChooser&);
// Disable assignment operator (=)
ColorChooser& operator = (const ColorChooser&);
// Method
void draw();
// Method
void draw();
// Event handler
void onMouseDown (FMouseEvent*);
// Event handler
void onMouseDown (FMouseEvent*);
// Data Members
short fg_color;
short bg_color;
// Data Members
short fg_color;
short bg_color;
};
#pragma pack(pop)
@ -150,36 +150,36 @@ inline short ColorChooser::getBackground()
class Brushes : public FWidget
{
public:
// Constructor
explicit Brushes (FWidget* = 0);
public:
// Constructor
explicit Brushes (FWidget* = 0);
// Destructor
~Brushes();
// Destructor
~Brushes();
// Accessor
wchar_t getBrush();
// Accessor
wchar_t getBrush();
// Mutators
void setForeground (short);
void setBackground (short);
// Mutators
void setForeground (short);
void setBackground (short);
private:
// Disable copy constructor
Brushes (const Brushes&);
// Disable assignment operator (=)
Brushes& operator = (const Brushes&);
private:
// Disable copy constructor
Brushes (const Brushes&);
// Disable assignment operator (=)
Brushes& operator = (const Brushes&);
// Method
void draw();
// Method
void draw();
// Event handler
void onMouseDown (FMouseEvent*);
// Event handler
void onMouseDown (FMouseEvent*);
// Data Members
wchar_t brush;
short fg_color;
short bg_color;
// Data Members
wchar_t brush;
short fg_color;
short bg_color;
};
#pragma pack(pop)
@ -285,46 +285,46 @@ inline void Brushes::setBackground (short color)
class MouseDraw : public FDialog
{
public:
// Using-declaration
using FWidget::setGeometry;
public:
// Using-declaration
using FWidget::setGeometry;
// Constructor
explicit MouseDraw (FWidget* = 0);
// Constructor
explicit MouseDraw (FWidget* = 0);
// Destructor
~MouseDraw();
// Destructor
~MouseDraw();
// Methods
void setGeometry (int, int, int, int, bool = true);
// Methods
void setGeometry (int, int, int, int, bool = true);
// Event handlers
void onAccel (FAccelEvent*);
void onClose (FCloseEvent*);
// Event handlers
void onAccel (FAccelEvent*);
void onClose (FCloseEvent*);
private:
// Disable copy constructor
MouseDraw (const MouseDraw&);
// Disable assignment operator (=)
MouseDraw& operator = (const MouseDraw&);
private:
// Disable copy constructor
MouseDraw (const MouseDraw&);
// Disable assignment operator (=)
MouseDraw& operator = (const MouseDraw&);
// Methods
virtual void draw();
void drawBrush (int, int, bool = false);
void drawCanvas();
void adjustSize();
// Methods
virtual void draw();
void drawBrush (int, int, bool = false);
void drawCanvas();
void adjustSize();
// Event handler
void onMouseDown (FMouseEvent*);
void onMouseMove (FMouseEvent*);
// Event handler
void onMouseDown (FMouseEvent*);
void onMouseMove (FMouseEvent*);
// Callback methods
void cb_colorChanged (FWidget*, data_ptr);
// Callback methods
void cb_colorChanged (FWidget*, data_ptr);
// Data Members
term_area* canvas;
ColorChooser* c_chooser;
Brushes* brush;
// Data Members
term_area* canvas;
ColorChooser* c_chooser;
Brushes* brush;
};
#pragma pack(pop)
@ -337,7 +337,7 @@ MouseDraw::MouseDraw (FWidget* parent)
{
setText ("Drawing with the mouse");
c_chooser = new ColorChooser(this);
c_chooser->setPos (1,1);
c_chooser->setPos (1, 1);
c_chooser->addCallback
(
"clicked",
@ -345,7 +345,7 @@ MouseDraw::MouseDraw (FWidget* parent)
);
brush = new Brushes(this);
brush->setPos (1,12);
brush->setPos (1, 12);
FPoint no_shadow(0,0);
FRect scroll_geometry(0, 0, 1, 1);
@ -459,8 +459,8 @@ void MouseDraw::drawCanvas()
for (int y = 0; y < y_end; y++) // line loop
{
char_data* cc; // canvas character
char_data* wc; // window character
char_data* cc; // canvas character
char_data* wc; // window character
cc = &canvas->text[y * x_end];
wc = &print_area->text[(ay + y) * w_line_len + ax];
std::memcpy (wc, cc, sizeof(char_data) * unsigned(x_end));

View File

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

View File

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

View File

@ -1,12 +1,14 @@
// File: string-operations.cpp
#include <clocale>
#include <iomanip>
#include <langinfo.h>
#include <term.h>
#include <unistd.h>
#include <clocale>
#include <iomanip>
#include <string>
#include <vector>
#include "fstring.h"
@ -70,19 +72,23 @@ int main (int, char**)
std::cout << " add: " << add1 << std::endl;
// 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;
// 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;
// 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;
// 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;
// Test: concatenate a FString and a wide character (operator +)
@ -102,19 +108,23 @@ int main (int, char**)
std::cout << " add: " << add9 << std::endl;
// 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;
// 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;
// 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;
// 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;
// Test: compare operators ==, <=, <, >=, >, !=
@ -268,7 +278,7 @@ int main (int, char**)
// Test: extract a substring of 27 characters from position 12
std::cout << " mid: \""
<< alphabet.mid(13,27) << "\"" << std::endl;
<< alphabet.mid(13, 27) << "\"" << std::endl;
// Test: 11 characters from the right of the string
std::cout << " right: \""
@ -288,12 +298,12 @@ int main (int, char**)
}
// 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";
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"
, char(index[0])
, char(index[4]) );
@ -327,7 +337,7 @@ int main (int, char**)
// Test: remove 2 characters at position 7
FString remove_std = "A fast remove";
std::cout << " remove: "
<< remove_std.remove(7,2) << std::endl;
<< remove_std.remove(7, 2) << std::endl;
// Test: includes a substring (positive test)
FString include_std = "string";

View File

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

View File

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

View File

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

View File

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

View File

@ -2,6 +2,8 @@
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include "fapplication.h"
#include "fdialog.h"
@ -18,23 +20,23 @@
class Treeview : public FDialog
{
public:
// Constructor
explicit Treeview (FWidget* = 0);
// Destructor
~Treeview();
public:
// Constructor
explicit Treeview (FWidget* = 0);
// Destructor
~Treeview();
private:
// Disable copy constructor
Treeview (const Treeview&);
// Disable assignment operator (=)
Treeview& operator = (const Treeview&);
private:
// Disable copy constructor
Treeview (const Treeview&);
// Disable assignment operator (=)
Treeview& operator = (const Treeview&);
// Event handlers
void onClose (FCloseEvent*);
// Event handlers
void onClose (FCloseEvent*);
// Callback methods
void cb_exitApp (FWidget*, data_ptr);
// Callback methods
void cb_exitApp (FWidget*, data_ptr);
};
#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
#include <iostream>
#include <fstream>
#include <iostream>
#include <string>
#include "final.h"
@ -15,32 +16,32 @@
class ProgressDialog : public FDialog
{
public:
// Constructor
explicit ProgressDialog (FWidget* = 0);
// Destructor
~ProgressDialog();
public:
// Constructor
explicit ProgressDialog (FWidget* = 0);
// Destructor
~ProgressDialog();
private:
// Disable copy constructor
ProgressDialog (const ProgressDialog&);
// Disable assignment operator (=)
ProgressDialog& operator = (const ProgressDialog&);
private:
// Disable copy constructor
ProgressDialog (const ProgressDialog&);
// Disable assignment operator (=)
ProgressDialog& operator = (const ProgressDialog&);
// Event handlers
void onShow (FShowEvent*);
void onTimer (FTimerEvent*);
// Event handlers
void onShow (FShowEvent*);
void onTimer (FTimerEvent*);
// Callback methods
void cb_reset_bar (FWidget*, data_ptr);
void cb_more_bar (FWidget*, data_ptr);
void cb_exit_bar (FWidget*, data_ptr);
// Callback methods
void cb_reset_bar (FWidget*, data_ptr);
void cb_more_bar (FWidget*, data_ptr);
void cb_exit_bar (FWidget*, data_ptr);
// Data Members
FProgressbar* progressBar;
FButton* reset;
FButton* more;
FButton* quit;
// Data Members
FProgressbar* progressBar;
FButton* reset;
FButton* more;
FButton* quit;
};
#pragma pack(pop)
@ -97,7 +98,7 @@ ProgressDialog::ProgressDialog (FWidget* parent)
}
//----------------------------------------------------------------------
ProgressDialog::~ProgressDialog()
ProgressDialog::~ProgressDialog() // destructor
{
delOwnTimer();
delCallback(quit);
@ -170,24 +171,24 @@ void ProgressDialog::cb_exit_bar (FWidget*, data_ptr)
class TextWindow : public FDialog
{
public:
// Constructor
explicit TextWindow (FWidget* = 0);
// Destructor
~TextWindow();
public:
// Constructor
explicit TextWindow (FWidget* = 0);
// Destructor
~TextWindow();
void append (const FString&);
void append (const FString&);
private:
// Disable copy constructor
TextWindow (const TextWindow&);
// Disable assignment operator (=)
TextWindow& operator = (const TextWindow&);
private:
// Disable copy constructor
TextWindow (const TextWindow&);
// Disable assignment operator (=)
TextWindow& operator = (const TextWindow&);
void adjustSize();
void adjustSize();
// Data Members
FTextView* scrollText;
// Data Members
FTextView* scrollText;
};
#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
{
public:
// Constructor
explicit MyDialog (FWidget* = 0);
// Destructor
~MyDialog();
public:
// Constructor
explicit MyDialog (FWidget* = 0);
// Destructor
~MyDialog();
private:
// Disable copy constructor
MyDialog (const MyDialog&);
// Disable assignment operator (=)
MyDialog& operator = (const MyDialog&);
private:
// Disable copy constructor
MyDialog (const MyDialog&);
// Disable assignment operator (=)
MyDialog& operator = (const MyDialog&);
// Method
void adjustSize();
// Method
void adjustSize();
// Event handlers
void onClose (FCloseEvent*);
// Event handlers
void onClose (FCloseEvent*);
// Callback methods
void cb_noFunctionMsg (FWidget*, data_ptr);
void cb_about (FWidget*, data_ptr);
void cb_terminfo (FWidget*, data_ptr);
void cb_drives (FWidget*, data_ptr);
void cb_cutClipboard (FWidget*, data_ptr);
void cb_copyClipboard (FWidget*, data_ptr);
void cb_pasteClipboard (FWidget*, data_ptr);
void cb_clearInput (FWidget*, data_ptr);
void cb_input2buttonText (FWidget*, data_ptr);
void cb_setTitlebar (FWidget*, data_ptr);
void cb_ProgressBar (FWidget*, data_ptr);
void cb_updateNumber (FWidget*, data_ptr);
void cb_activateButton (FWidget*, data_ptr);
void cb_view (FWidget*, data_ptr);
void cb_setInput (FWidget*, data_ptr);
void cb_exitApp (FWidget*, data_ptr);
// Callback methods
void cb_noFunctionMsg (FWidget*, data_ptr);
void cb_about (FWidget*, data_ptr);
void cb_terminfo (FWidget*, data_ptr);
void cb_drives (FWidget*, data_ptr);
void cb_cutClipboard (FWidget*, data_ptr);
void cb_copyClipboard (FWidget*, data_ptr);
void cb_pasteClipboard (FWidget*, data_ptr);
void cb_clearInput (FWidget*, data_ptr);
void cb_input2buttonText (FWidget*, data_ptr);
void cb_setTitlebar (FWidget*, data_ptr);
void cb_ProgressBar (FWidget*, data_ptr);
void cb_updateNumber (FWidget*, data_ptr);
void cb_activateButton (FWidget*, data_ptr);
void cb_view (FWidget*, data_ptr);
void cb_setInput (FWidget*, data_ptr);
void cb_exitApp (FWidget*, data_ptr);
// Data Members
FLineEdit* myLineEdit;
FListBox* myList;
FString clipboard;
// Data Members
FLineEdit* myLineEdit;
FListBox* myList;
FString clipboard;
};
#pragma pack(pop)
@ -308,7 +309,7 @@ MyDialog::MyDialog (FWidget* parent)
// "File" menu items
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");
FMenu* Recent = new FMenu ("&System files", File);
Recent->setStatusbarMessage ("View text file");
@ -316,7 +317,7 @@ MyDialog::MyDialog (FWidget* parent)
FMenuItem* Line1 = new FMenuItem (File);
Line1->setSeparator();
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");
// "Recent" menu items
@ -332,7 +333,8 @@ MyDialog::MyDialog (FWidget* parent)
FMenuItem* Line2 = new FMenuItem (Edit);
Line2->setSeparator();
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);
Copy->setStatusbarMessage ("Copy the input text into the clipboad");
FMenuItem* Paste = new FMenuItem (fc::Fckey_v, "&Paste", Edit);
@ -405,21 +407,21 @@ MyDialog::MyDialog (FWidget* parent)
(
"clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_view),
dynamic_cast<FWidget::data_ptr>(File1)
static_cast<FWidget::data_ptr>(File1)
);
File2->addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_view),
dynamic_cast<FWidget::data_ptr>(File2)
static_cast<FWidget::data_ptr>(File2)
);
File3->addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_view),
dynamic_cast<FWidget::data_ptr>(File3)
static_cast<FWidget::data_ptr>(File3)
);
// Buttons
@ -563,7 +565,7 @@ MyDialog::MyDialog (FWidget* parent)
(
"clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_input2buttonText),
dynamic_cast<FWidget::data_ptr>(myLineEdit)
static_cast<FWidget::data_ptr>(myLineEdit)
);
MyButton5->addCallback
@ -588,21 +590,21 @@ MyDialog::MyDialog (FWidget* parent)
(
"toggled",
F_METHOD_CALLBACK (this, &MyDialog::cb_activateButton),
dynamic_cast<FWidget::data_ptr>(MyButton5)
static_cast<FWidget::data_ptr>(MyButton5)
);
myList->addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_setInput),
dynamic_cast<FWidget::data_ptr>(myLineEdit)
static_cast<FWidget::data_ptr>(myLineEdit)
);
myList->addCallback
(
"row-selected",
F_METHOD_CALLBACK (this, &MyDialog::cb_updateNumber),
dynamic_cast<FWidget::data_ptr>(tagged_count)
static_cast<FWidget::data_ptr>(tagged_count)
);
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
{
public:
// Constructor
explicit watch (FWidget* = 0);
public:
// Constructor
explicit watch (FWidget* = 0);
// Destructor
~watch();
// Destructor
~watch();
// Method
void printTime();
// Method
void printTime();
// Event handlers
void onTimer (FTimerEvent*);
void onClose (FCloseEvent*);
// Event handlers
void onTimer (FTimerEvent*);
void onClose (FCloseEvent*);
// Callback methods
void cb_clock (FWidget*, data_ptr);
void cb_seconds (FWidget*, data_ptr);
void cb_exitApp (FWidget*, data_ptr);
// Callback methods
void cb_clock (FWidget*, data_ptr);
void cb_seconds (FWidget*, data_ptr);
void cb_exitApp (FWidget*, data_ptr);
protected:
// Method
void adjustSize();
protected:
// Method
void adjustSize();
private:
// Disable copy constructor
watch (const watch&);
private:
// Disable copy constructor
watch (const watch&);
// Disable assignment operator (=)
watch& operator = (const watch&);
// Disable assignment operator (=)
watch& operator = (const watch&);
// Data Members
bool sec;
FLabel* time_label;
FLabel* time_str;
FSwitch* clock_sw;
FSwitch* seconds_sw;
// Data Members
bool sec;
FLabel* time_label;
FLabel* time_str;
FSwitch* clock_sw;
FSwitch* seconds_sw;
};
#pragma pack(pop)
@ -119,16 +119,16 @@ watch::~watch()
void watch::printTime()
{
FString str;
std::tm* now;
std::tm now;
std::time_t t;
t = std::time(0); // get current time
now = std::localtime(&t);
localtime_r(&t, &now);
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
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->redraw();

View File

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