From b28ce7479c87e41c461395da5f425276748782b5 Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 12 Dec 2007 09:43:46 +0000 Subject: [PATCH] Patch level : 4.0 Files correlati : xvaga.cpp Ricompilazione Demo : [ ] Commento : Spiezzato in due il file xvaga.cpp: ora esiste anche xvtwin.* Nel nuovo file sono confluite tutte le funzioni di creazione/gestione di finestre (top level windows) e controlli (child windows) Aggiunta gestione alberi (wxTreeCtrl) git-svn-id: svn://10.65.10.50/trunk@15858 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- xvaga/xvaga.cpp | 1592 +++++++------------------------------------- xvaga/xvintern.h | 91 --- xvaga/xvt.h | 50 +- xvaga/xvt_env.h | 17 + xvaga/xvt_type.h | 42 +- xvaga/xvtextra.cpp | 3 +- 6 files changed, 361 insertions(+), 1434 deletions(-) delete mode 100755 xvaga/xvintern.h diff --git a/xvaga/xvaga.cpp b/xvaga/xvaga.cpp index a55b80017..ef7ecc92a 100755 --- a/xvaga/xvaga.cpp +++ b/xvaga/xvaga.cpp @@ -9,23 +9,22 @@ #include "wx/fontdlg.h" #include "wx/fs_zip.h" #include "wx/image.h" - +#include "wx/filefn.h" #include #include #include "xvt.h" #include "statbar.h" -#include "xvintern.h" #include "agasys.h" #include "fstrcmp.h" #include "matche.h" #include "xvtpdf.h" +#include "xvtwin.h" #ifdef WIN32 #include "oswin32.h" -#include #else #include #include @@ -34,33 +33,25 @@ #include #endif -#define CAST_WIN(win,w) XVT_ASSERT(win != NULL_WIN); wxWindow& w = *(wxWindow*)win +#define XVT_ASSERT(test) _AssertBox((test), __LINE__, __FILE__ ) +#define CAST_WIN(win,w) wxWindow& w = *(wxWindow*)win; wxASSERT(win != NULL_WIN && w.IsKindOf(CLASSINFO(wxWindow))); #define CAST_TWIN(win,w) XVT_ASSERT(win != NULL_WIN); TwxWindow& w = *(TwxWindow*)win; XVT_ASSERT(_task_win != &w); #define CAST_TDC(win,dc) XVT_ASSERT(win != NULL_WIN); TDC& dc = GetTDCMapper().GetTDC(win); #define CAST_DC(win,dc) XVT_ASSERT(win != NULL_WIN); wxDC& dc = GetTDCMapper().GetDC(win); -// Funzione interna di utilita' -MENU_ITEM* xvt_menu_duplicate_tree(const MENU_ITEM* m); - -wxWindow* _task_win = NULL; wxWindow* _mouse_trapper = NULL; RCT _startup_rect = { 0,0,0,0 }; wxString _startup_dir; wxString _strDefaultStatbarText; wxString _appl_name; -static wxHashTable _nice_windows; static wxHashTable _nice_icons; - -static EVENT_HANDLER _task_win_handler = NULL; static XVT_ERRMSG_HANDLER _error_handler = NULL; -#define XVT_ASSERT(test) assert_box((test), __LINE__, __FILE__ ) - const wxString& _GetAppTitle() { return _appl_name; } -void assert_box(bool test, int line, const char * file) +void _AssertBox(bool test, int line, const char * file) { if (!test) { @@ -74,14 +65,25 @@ void assert_box(bool test, int line, const char * file) } } -void xvt_sys_sorry_box(const char * file,int line) +void xvt_sys_sorry_box(const char* file, int line) { static wxHashTable sorry; if (sorry.Get(line) == NULL) { sorry.Put(line, &sorry); // Dummy const wxString strMessage = wxString::Format("Function in file %s at line %d not implemented", file, line); - ::wxMessageBox(strMessage); + ::wxMessageBox(strMessage, _GetAppTitle(), wxOK|wxICON_WARNING); + } +} + +void xvt_sys_deprecated_box(const char* file, int line) +{ + static wxHashTable deprecated; + if (deprecated.Get(line) == NULL) + { + deprecated.Put(line, &deprecated); // Dummy + const wxString strMessage = wxString::Format("Function in file %s at line %d is deprecated:\nYou can blame Guy for this, if you're bold enough!", file, line); + ::wxMessageBox(strMessage, _GetAppTitle(), wxOK|wxICON_WARNING); } } @@ -98,19 +100,6 @@ static bool RectIntersect(const wxRect &rect1, const wxRect &rect2) return true; } -wxRect NormalizeRCT(const RCT* prct) -{ - wxRect rct; - if (prct != NULL) - { - rct.x = min(prct->left, prct->right); - rct.y = min(prct->top, prct->bottom); - rct.width = abs(prct->right - prct->left); - rct.height = abs(prct->bottom - prct->top); - } - return rct; -} - wxString GetResourceIni() { wxString strName; @@ -121,13 +110,22 @@ wxString GetResourceIni() wxString GetResourceName(const char* type, int rid) { - wxFileConfig ini("", "", GetResourceIni()); - - wxString strName; strName.Printf("/%ss", type); - ini.SetPath(strName); - + wxString strName; strName.Printf("%ss", type); + wxString strKey; strKey.Printf("%d", rid); wxString val; - if (ini.Read(wxString::Format("%d", rid), &val)) + +#ifdef WIN32 + char* buff = val.GetWriteBuf(260); + ::GetPrivateProfileString(strName, strKey, "", buff, 260, GetResourceIni()); + val.UngetWriteBuf(); +#else + wxFileConfig ini("", "", GetResourceIni()); + strName.insert(0, '/'); + ini.SetPath(strName); + ini.Read(strKey, &val); +#endif + + if (!val.IsEmpty()) { strName = _startup_dir; strName += "/custom/"; @@ -144,7 +142,7 @@ wxString GetResourceName(const char* type, int rid) return strName; } -wxIcon* GetIconResource(int rid) +wxIcon* _GetIconResource(int rid) { wxIcon* icon = (wxIcon*)_nice_icons.Get(rid); if (icon == NULL) @@ -164,8 +162,8 @@ wxIcon* GetIconResource(int rid) const wxCursor* GetCursorResource(int rid) { - static wxHashTable cursors; - const wxCursor* cursor = (const wxCursor*)cursors.Get(rid); + static wxHashTable _nice_cursors; + wxCursor* cursor = (wxCursor*)_nice_cursors.Get(rid); if (cursor == NULL) { switch (rid) @@ -194,434 +192,13 @@ const wxCursor* GetCursorResource(int rid) if (cursor == NULL) { XVT_ASSERT(false); - cursor = wxSTANDARD_CURSOR; + cursor = (wxCursor*)wxSTANDARD_CURSOR; } - cursors.Put(rid, (wxCursor*)cursor); + _nice_cursors.Put(rid, cursor); } return cursor; } -/////////////////////////////////////////////////////////// -// Caret emulation -/////////////////////////////////////////////////////////// - -class TwxCaret : private wxTimer -{ - WINDOW _owner; - PNT _pos; - wxSize _size; - bool _visible; - bool _drawn; - -protected: - void Toggle(); - virtual void Notify() { Toggle(); } - -public: - void SetPos(int x, int y); - void SetSize(int x, int y) { _size.x = x; _size.y = y; } - void Show(WINDOW w, bool on = true); - void Hide() { Show(NULL_WIN, false); } - bool IsVisible() const { return _visible; } - WINDOW Owner() const { return _owner; } - void Kill(); - - TwxCaret() : _owner(NULL_WIN), _visible(false) { } - virtual ~TwxCaret() { Kill(); } -} _TheCaret; - -void TwxCaret::Kill() -{ - _owner = NULL_WIN; -} - -void TwxCaret::SetPos(int x, int y) -{ - if (_visible && _drawn) // Lo cancella se necessario - Toggle(); - _pos.h = x; _pos.v = y; -} - -void TwxCaret::Show(WINDOW w, bool on) -{ - if (_visible && _drawn) - Toggle(); // Lo cancella - - _visible = on; - if (on) - { - _owner = w; - Toggle(); - wxTimer::Start(500); // Lampeggia ogni mezzo secondo - } - else - { - if (w == _owner || w == NULL_WIN) - Kill(); - } -} - -void TwxCaret::Toggle() -{ - if (!_visible || _owner == NULL_WIN) - return; - - _drawn = !_drawn; - - DRAW_CTOOLS dct; - xvt_dwin_get_draw_ctools(_owner, &dct); - - CPEN pen; - pen.width = _size.x; - pen.pat = PAT_SOLID; - pen.style = P_SOLID; - pen.color = dct.fore_color; - xvt_dwin_set_draw_mode(_owner, M_NOT_XOR); - - xvt_dwin_set_cpen(_owner, &pen); - xvt_dwin_draw_set_pos(_owner, _pos); - PNT p = _pos; p.v -= _size.y-1; - - xvt_dwin_set_clip(_owner, NULL); // Non si sa mai! - xvt_dwin_draw_line(_owner, p); - xvt_dwin_set_draw_ctools(_owner, &dct); -} - -/////////////////////////////////////////////////////////// -// Generic Display context -/////////////////////////////////////////////////////////// - -#define CAST_COLOR(xc, wc) wxColour wc((xc>>16)&0xFF, (xc>>8)&0xFF, xc&0xFF) -#define MAKE_XVT_COLOR(wc) MAKE_COLOR(wc.Red(), wc.Green(), wc.Blue()) - -TDC::TDC(wxWindow* owner) : _dc(NULL) -{ - _owner = owner; - - memset(&_dct, 0, sizeof(_dct)); - _dct.pen.width = 0; - _dct.pen.pat = PAT_SOLID; - _dct.pen.style = P_SOLID; - _dct.pen.color = COLOR_BLACK; - _dct.brush.pat = PAT_HOLLOW; - _dct.brush.color = COLOR_WHITE; - _dct.mode = M_COPY; - _dct.fore_color = COLOR_BLACK; - _dct.back_color = COLOR_WHITE; - _dct.opaque_text = FALSE; - - _font.SetPointSize(9); // Default font - _deltaf = 0; - - SetClippingBox(NULL); // Reset clip area - - _dirty = -1; // Absolutely force setting -} - -TDC::~TDC() -{ - KillDC(); -} - -void TDC::SetDirty(int d) -{ - if (_dirty >= 0) - _dirty = d; -} - -static int PatternToStyle(PAT_STYLE pat) -{ - int style = wxSOLID; - switch (pat) - { - case PAT_NONE: - case PAT_HOLLOW: style = wxTRANSPARENT; break; - case PAT_SOLID: style = wxSOLID; break; - case PAT_HORZ: style = wxHORIZONTAL_HATCH; break; - case PAT_VERT: style = wxVERTICAL_HATCH; break; - case PAT_FDIAG: style = wxFDIAGONAL_HATCH; break; - case PAT_BDIAG: style = wxBDIAGONAL_HATCH; break; - case PAT_CROSS: style = wxCROSS_HATCH; break; - case PAT_DIAGCROSS: style = wxCROSSDIAG_HATCH; break; - case PAT_RUBBER: - case PAT_SPECIAL: - default: SORRY_BOX(); break; - } - return style; -} - -static int PenStyleToStyle(PEN_STYLE s, PAT_STYLE p) -{ - int style = wxSOLID; - if (p != PAT_HOLLOW) - { - switch (s) - { - case P_DOT : style = wxDOT; break; - case P_DASH: style = wxSHORT_DASH; break; - default: break; - } - } - else - style = wxTRANSPARENT; - - return style; -} - -bool TDC::PenChanged() const -{ - const int diff = memcmp(&_dct.pen, &_real_dct.pen, sizeof(_dct.pen)); - return diff != 0; -} - -bool TDC::BrushChanged() const -{ - const int diff = memcmp(&_dct.brush, &_real_dct.brush, sizeof(_dct.brush)); - return diff != 0; -} - -bool TDC::FontChanged() const -{ - return _font != _real_font; -} - -#ifdef LINUX -bool is_printer_dc(wxDC * dc) -{ - return dc->IsKindOf(CLASSINFO(wxPostScriptDC)); -} -#endif - -wxDC& TDC::GetDC(bool bPaint) -{ - if (bPaint) - { - KillDC(); - _dc = new wxPaintDC(_owner); - _dirty = -1; - } - else - { - if (_dc == NULL) - { - if (_owner == NULL || (unsigned long)_owner == SCREEN_WIN) - _dc = new wxScreenDC(); - else - _dc = new wxClientDC(_owner); - _dirty = -1; - } - } - - if (_dirty) - { - if (_dirty < 0 || PenChanged()) - { - CAST_COLOR(_dct.pen.color, pen_color); - wxPen* pen = wxThePenList->FindOrCreatePen(pen_color, _dct.pen.width, PenStyleToStyle(_dct.pen.style, _dct.pen.pat)); - _dc->SetPen(*pen); - _real_dct.pen = _dct.pen; - } - - if (_dirty < 0 || BrushChanged()) - { - CAST_COLOR(_dct.brush.color, brush_color); - wxBrush* brush = wxTheBrushList->FindOrCreateBrush(brush_color, PatternToStyle(_dct.brush.pat)); - _dc->SetBrush(*brush); - _real_dct.brush = _dct.brush; - } - - if (_dirty < 0 || _dct.mode != _real_dct.mode) - { -#ifdef LINUX - if(!is_printer_dc(_dc)) - { -#endif - switch(_dct.mode) - { - case M_COPY: _dc->SetLogicalFunction(wxCOPY); break; - case M_OR: _dc->SetLogicalFunction(wxOR); break; - case M_XOR: _dc->SetLogicalFunction(wxXOR); break; - case M_CLEAR: _dc->SetLogicalFunction(wxCLEAR); break; - case M_NOT_COPY: _dc->SetLogicalFunction(wxSRC_INVERT); break; - case M_NOT_OR: _dc->SetLogicalFunction(wxNOR); break; - case M_NOT_XOR: _dc->SetLogicalFunction(wxEQUIV); break; - case M_NOT_CLEAR:_dc->SetLogicalFunction(wxSET); break; - default: SORRY_BOX(); - } -#ifdef LINUX - } -#endif - _real_dct.mode = _dct.mode; - } - - if (_dirty < 0 || _dct.fore_color != _real_dct.fore_color) - { - CAST_COLOR(_dct.fore_color, fore_color); - _dc->SetTextForeground(fore_color); - _real_dct.fore_color = _dct.fore_color; - } - - if (_dirty < 0 || _dct.back_color != _real_dct.back_color) - { - CAST_COLOR(_dct.back_color, back_color); - _dc->SetTextBackground(back_color); - _real_dct.back_color = _dct.back_color; - } - - if (_dirty < 0 || _dct.opaque_text != _real_dct.opaque_text) - { - _dc->SetBackgroundMode(_dct.opaque_text ? wxSOLID : wxTRANSPARENT); - _real_dct.opaque_text = _dct.opaque_text; - } - - if (_dirty < 0 || FontChanged()) - { - const wxFont& f = _font.Font(_dc, (WINDOW)_owner); - _dc->SetFont(f); - _real_font = _font; - - int height, desc, lead; - _dc->GetTextExtent("Campo", NULL, &height, &desc, &lead); - _deltaf = height-desc; - } - - _dirty = false; - } - return *_dc; -} - -void TDC::KillDC() -{ - if (_dc != NULL) - { - SetClippingBox(NULL); - delete _dc; - _dc = NULL; - } -} - -void TDC::SetClippingBox(const RCT* pRct) -{ - if (_dc != NULL) - _dc->DestroyClippingRegion(); - if (pRct) - { - const wxRect rct = NormalizeRCT(pRct); - GetDC().SetClippingRegion(rct); - _clip = *pRct; - } - else - { - _clip.left = _clip.top = 0; - _clip.right = _clip.bottom = 32000; - } -} - -bool TDC::GetClippingBox(RCT* pRct) const -{ - *pRct = _clip; - return _clip.right > _clip.left; -} - -WX_DECLARE_HASH_MAP(WINDOW, TDC*, wxIntegerHash, wxIntegerEqual, wxTDCHashMap); - -class TDCMapper : public wxTDCHashMap -{ - WINDOW _pLastOwner; - TDC* _pLastTDC; - -public: - TDC& GetTDC(WINDOW owner); - wxDC& GetDC(WINDOW owner, bool bPaint = false) { return GetTDC(owner).GetDC(bPaint); } - void DestroyDC(WINDOW owner); - void DestroyTDC(WINDOW owner); - bool HasValidDC(WINDOW owner) const; - - TDCMapper() : _pLastOwner(NULL_WIN), _pLastTDC(NULL) { } - virtual ~TDCMapper() { DestroyTDC(NULL_WIN); } -}; - -TDCMapper& GetTDCMapper() -{ - static TDCMapper* _dc_map = NULL; - if (_dc_map == NULL) - _dc_map = new TDCMapper; - return *_dc_map; -} - -void TDCMapper::DestroyDC(WINDOW owner) -{ - if (owner) - { - TDC* pTDC = (*this)[owner]; - if (pTDC) - pTDC->KillDC(); - } - else - { - for (TDCMapper::iterator it = begin(); it != end(); ++it) - { - TDC* pTDC = it->second; - if (pTDC) - pTDC->KillDC(); - } - } -} - -void TDCMapper::DestroyTDC(WINDOW owner) -{ - if (owner != NULL_WIN) - { - TDC* pTDC = (*this)[owner]; - if (pTDC) - delete pTDC; - erase(owner); - } - else - { - TDCMapper::iterator it; - for (it = begin(); it != end(); ++it) - { - TDC* pTDC = it->second; - if (pTDC) - delete pTDC; - } - clear(); - } - _pLastOwner = NULL_WIN; -} - -TDC& TDCMapper::GetTDC(WINDOW owner) -{ - if (owner == _pLastOwner) - return *_pLastTDC; - - TDC* pTDC = (*this)[owner]; - if (pTDC == NULL) - { - if (owner == PRINTER_WIN) - pTDC = new TPrintDC((wxWindow*)owner); - else - pTDC = new TDC((wxWindow*)owner); - (*this)[owner] = pTDC; - } - _pLastOwner = owner; - _pLastTDC = pTDC; - return *pTDC; -} - -bool TDCMapper::HasValidDC(WINDOW owner) const -{ - if (owner == NULL_WIN) - return false; - - if (owner == (WINDOW)_pLastOwner) - return true; - - TDC* pTDC = (*((TDCMapper *) this))[owner]; - return pTDC != NULL; -} - /////////////////////////////////////////////////////////// // Font cache /////////////////////////////////////////////////////////// @@ -651,7 +228,6 @@ void TFontCache::Destroy() } } - wxFont& TFontCache::FindOrCreate(int pointSize, int family, int style, int weight, bool underline, const wxString& face) { @@ -670,657 +246,6 @@ wxFont& TFontCache::FindOrCreate(int pointSize, int family, int style, int weigh return *pFont; } -/////////////////////////////////////////////////////////// -// Generic window class -/////////////////////////////////////////////////////////// - -#define TIMER_ID 1 - -class TwxWindowBase : public wxWindow -{ -#ifdef LINUX -private: - wxString m_strTitle; - virtual void SetTitle(const wxString& title) { wxWindow::SetTitle(m_strTitle = title); } - virtual wxString GetTitle() const { return m_strTitle; } -#endif - -public: - TwxWindowBase() { } - TwxWindowBase(wxWindow *parent, wxWindowID id, const wxString &title, - const wxPoint & pos, const wxSize & size, long style); - - DECLARE_DYNAMIC_CLASS(TwxWindowBase) -}; - -IMPLEMENT_DYNAMIC_CLASS(TwxWindowBase, wxWindow) - -TwxWindowBase::TwxWindowBase(wxWindow *parent, wxWindowID id, const wxString &title, - const wxPoint &pos, const wxSize &size, long style) -{ - // Evita inutili sfarfallamenti in quanto wxWidgets crea le finestre visibili per default - wxWindowBase::Show(false); - Create(parent, id, pos, size, style, title); -#if wxCHECK_VERSION(2,8,0) -#else - SetTitle(title); // Triste necessita', la Create sembra ignorare il titolo -#endif -} - -class TwxWindow : public TwxWindowBase -{ -private: - MENU_ITEM* m_menu; - -protected: - virtual void OnChar(wxKeyEvent& e); - virtual void OnClose(wxCloseEvent& e); - virtual void OnKeyDown(wxKeyEvent& e); - virtual void OnKillFocus(wxFocusEvent& e); - virtual void OnMenu(wxCommandEvent& e); -#if wxCHECK_VERSION(2,8,0) - virtual void OnMouseCaptureLost(wxMouseCaptureLostEvent& e); -#endif - virtual void OnMouseDouble(wxMouseEvent& e); - virtual void OnMouseDown(wxMouseEvent& e); - virtual void OnMouseMove(wxMouseEvent& e); - virtual void OnMouseUp(wxMouseEvent& e); - virtual void OnMouseWheel(wxMouseEvent& e); - virtual void OnScroll(wxScrollEvent& e); - virtual void OnScrollWin(wxScrollWinEvent& e); - virtual void OnSetFocus(wxFocusEvent& e); - virtual void OnSize(wxSizeEvent& e); - virtual void OnTimer(wxTimerEvent& e); - -public: - void DoXvtEvent(EVENT& e); - virtual void OnPaint(wxPaintEvent& e); - -public: - WIN_TYPE _type; - EVENT_HANDLER _eh; - long _app_data; - wxTimer* _timer; - - void SetMenuTree(const MENU_ITEM* menu); - MENU_ITEM* GetMenuTree() const { return m_menu; } - - TwxWindow() : m_menu(NULL), _type(W_DOC), _eh(NULL), _app_data(0L), _timer(NULL) { } - TwxWindow(wxWindow *parent, wxWindowID id, const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = 0); - virtual ~TwxWindow(); - - DECLARE_DYNAMIC_CLASS(TwxWindow); - DECLARE_EVENT_TABLE(); -}; - -class TTaskWin : public wxFrame -{ - MENU_ITEM* m_menu; - - wxMenuBar* m_pOldBar; - wxWindow* m_MenuOwner; - -protected: - virtual void OnClose(wxCloseEvent& e); - virtual void OnMenu(wxCommandEvent& e); - virtual void OnSize(wxSizeEvent& e); - -public: - virtual void OnPaint(wxPaintEvent& e); - -public: - void SetMenuTree(const MENU_ITEM* tree); - const MENU_ITEM* GetMenuTree() const { return m_menu; } - void PushMenuTree(const MENU_ITEM* tree, wxWindow* owner); - void PopMenuTree(); - - TTaskWin() : wxFrame(), m_menu(NULL), m_pOldBar(NULL) { } - TTaskWin(wxWindow *parent, wxWindowID id, const wxString& title, - const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE); - ~TTaskWin(); - - DECLARE_DYNAMIC_CLASS(TTaskWin); - DECLARE_EVENT_TABLE(); -}; - -IMPLEMENT_DYNAMIC_CLASS(TwxWindow, TwxWindowBase) - -BEGIN_EVENT_TABLE(TwxWindow, TwxWindowBase) - EVT_CHAR(TwxWindow::OnChar) - EVT_KEY_DOWN(TwxWindow::OnKeyDown) - EVT_CLOSE(TwxWindow::OnClose) - EVT_KILL_FOCUS(TwxWindow::OnKillFocus) - EVT_LEFT_DCLICK(TwxWindow::OnMouseDouble) - EVT_LEFT_DOWN(TwxWindow::OnMouseDown) - EVT_LEFT_UP(TwxWindow::OnMouseUp) - EVT_MENU_RANGE(1000, 32766, TwxWindow::OnMenu) - EVT_MIDDLE_DOWN(TwxWindow::OnMouseDown) - EVT_MIDDLE_UP(TwxWindow::OnMouseUp) - EVT_MOTION(TwxWindow::OnMouseMove) -#if wxCHECK_VERSION(2,8,0) - EVT_MOUSE_CAPTURE_LOST(TwxWindow::OnMouseCaptureLost) -#endif - EVT_MOUSEWHEEL(TwxWindow::OnMouseWheel) - EVT_PAINT(TwxWindow::OnPaint) - EVT_RIGHT_DOWN(TwxWindow::OnMouseDown) - EVT_RIGHT_UP(TwxWindow::OnMouseUp) - EVT_SCROLL(TwxWindow::OnScroll) - EVT_SCROLLWIN(TwxWindow::OnScrollWin) - EVT_SET_FOCUS(TwxWindow::OnSetFocus) - EVT_SIZE(TwxWindow::OnSize) - EVT_TIMER(TIMER_ID, TwxWindow::OnTimer) -END_EVENT_TABLE() - -void TwxWindow::DoXvtEvent(EVENT& e) -{ - if (this != NULL && _eh != NULL) - _eh((WINDOW)this, &e); -} - -void TwxWindow::OnChar(wxKeyEvent& evt) -{ - static int nSkipNextDotKey = -883; // Valore indefinito - if (nSkipNextDotKey == -883) // Devo stabilire se attivare la gestione o no - { - const char* campoini = xvt_fsys_get_campo_ini(); - char str[2]; - xvt_sys_get_profile_string(campoini, "Main", "Point2Comma", "1", str, sizeof(str)); - nSkipNextDotKey = strchr("1XY", *str) != NULL ? 0 : -1; // Dis/Abilita conversione punto in virgola - } - - EVENT e; memset(&e, 0, sizeof(EVENT)); - e.type = E_CHAR; - int k = evt.GetKeyCode(); - - if (nSkipNextDotKey == 1) - { - nSkipNextDotKey = 0; - if (k == '.') - { - evt.Skip(); - return; - } - } - - switch (k) - { - case WXK_ALT: - case WXK_MENU: - case WXK_NUMPAD0: - case WXK_NUMPAD1: - case WXK_NUMPAD2: - case WXK_NUMPAD3: - case WXK_NUMPAD4: - case WXK_NUMPAD5: - case WXK_NUMPAD6: - case WXK_NUMPAD7: - case WXK_NUMPAD8: - case WXK_NUMPAD9: - evt.Skip(); - return; - case WXK_NUMPAD_DECIMAL: // Arriva solo dalla 3.6.3 in poi - case WXK_DECIMAL: // ??? Arriva sia '.' sia WXK_DECIMAL=340 - if (nSkipNextDotKey == 0) - { - k = ','; // Trasformo il punto in virgola - nSkipNextDotKey = 1; - } - break; - case WXK_NUMPAD_ADD: k = '+';break; - case WXK_DOWN : k = K_DOWN; break; - case WXK_END : k = K_LEND; break; - case WXK_HOME : k = K_LHOME; break; - case WXK_LEFT : k = K_LEFT; break; - case WXK_NEXT : k = K_NEXT; break; - case WXK_PRIOR: k = K_PREV; break; - case WXK_RIGHT: k = K_RIGHT; break; - case WXK_UP : k = K_UP; break; - case WXK_TAB: - if (evt.ShiftDown()) - k = K_BTAB; - break; - default: - if (k >= WXK_F1 && k <= WXK_F24) - k = K_F1 + k - WXK_F1; - break; - } - - e.v.chr.shift = evt.ShiftDown(); - e.v.chr.control = evt.ControlDown(); - if (evt.AltDown()) - { - e.v.chr.control = TRUE; - if (xvt_chr_is_alnum(k)) - k = toupper(k); - else - { - if (strchr("+-", k) == NULL) // Aggiungere qui vari testi eventuali - { - evt.Skip(); - return; - } - } - } - e.v.chr.ch = k; - - DoXvtEvent(e); -} - -void TwxWindow::OnKeyDown(wxKeyEvent& e) -{ -#ifdef WIN32 - // Triste necessita' per gestire corretamente Alt+'+' del tasterino - const int k = e.GetKeyCode(); - if (k == WXK_NUMPAD_ADD) - { - if (e.AltDown()) - { - OnChar(e); - return; - } - } -#else - if (e.AltDown() || e.ControlDown()) - { - OnChar(event); - return; - } -#endif - e.Skip(); -} - -void TwxWindow::OnClose(wxCloseEvent& WXUNUSED(e)) -{ - EVENT e; memset(&e, 0, sizeof(EVENT)); - e.type = E_DESTROY; - DoXvtEvent(e); - Destroy(); -} - -void TwxWindow::OnKillFocus(wxFocusEvent& WXUNUSED(e)) -{ - if (_TheCaret.Owner() == (WINDOW)this) - _TheCaret.Hide(); - - EVENT e; memset(&e, 0, sizeof(EVENT)); - e.type = E_FOCUS; - e.v.active = 0; - DoXvtEvent(e); -} - -void TwxWindow::OnMenu(wxCommandEvent& evt) -{ - EVENT e; memset(&e, 0, sizeof(EVENT)); - e.type = E_COMMAND; - e.v.cmd.control = 0; e.v.cmd.shift = 0; - e.v.cmd.tag = evt.GetId(); - DoXvtEvent(e); -} - -#if wxCHECK_VERSION(2,8,0) -void TwxWindow::OnMouseCaptureLost(wxMouseCaptureLostEvent& WXUNUSED(e)) -{ - xvt_win_release_pointer(); -} -#endif - -void TwxWindow::OnMouseDouble(wxMouseEvent& evt) -{ - EVENT e; memset(&e, 0, sizeof(EVENT)); - e.type = E_MOUSE_DBL; - e.v.mouse.button = (evt.RightDown() ? 1 : 0) + (evt.MiddleDown() ? 2 : 0); - e.v.mouse.control = evt.ControlDown(); - e.v.mouse.shift = evt.ShiftDown(); - e.v.mouse.where.h = evt.GetX(); - e.v.mouse.where.v = evt.GetY(); - DoXvtEvent(e); -} - -void TwxWindow::OnMouseDown(wxMouseEvent& evt) -{ - EVENT e; memset(&e, 0, sizeof(EVENT)); - e.type = E_MOUSE_DOWN; - e.v.mouse.button = (evt.RightDown() ? 1 : 0) + (evt.MiddleDown() ? 2 : 0); - e.v.mouse.control = evt.ControlDown(); - e.v.mouse.shift = evt.ShiftDown(); - e.v.mouse.where.h = evt.GetX(); - e.v.mouse.where.v = evt.GetY(); - DoXvtEvent(e); - SetFocus(); // Triste necessita' -} - -void TwxWindow::OnMouseMove(wxMouseEvent& evt) -{ - EVENT e; memset(&e, 0, sizeof(EVENT)); - e.type = E_MOUSE_MOVE; - e.v.mouse.button = (evt.RightIsDown() ? 1 : 0) + (evt.MiddleIsDown() ? 2 : 0); - e.v.mouse.control = evt.ControlDown(); - e.v.mouse.shift = evt.m_shiftDown; - e.v.mouse.where.h = evt.GetX(); - e.v.mouse.where.v = evt.GetY(); - DoXvtEvent(e); -} - -void TwxWindow::OnMouseUp(wxMouseEvent& evt) -{ - EVENT e; memset(&e, 0, sizeof(EVENT)); - e.type = E_MOUSE_UP; - e.v.mouse.button = (evt.RightUp() ? 1 : 0) + (evt.MiddleUp() ? 2 : 0); - e.v.mouse.control = evt.ControlDown(); - e.v.mouse.shift = evt.ShiftDown(); - e.v.mouse.where.h = evt.GetX(); - e.v.mouse.where.v = evt.GetY(); - DoXvtEvent(e); -} - -void TwxWindow::OnMouseWheel(wxMouseEvent& evt) -{ - const int nRot = evt.GetWheelRotation(); - if (nRot != 0) - { - EVENT e; memset(&e, 0, sizeof(EVENT)); - e.type = E_VSCROLL; - e.v.scroll.pos = evt.GetY(); - e.v.scroll.what = nRot > 0 ? SC_LINE_UP : SC_LINE_DOWN; - DoXvtEvent(e); - } -} - -void TwxWindow::OnPaint(wxPaintEvent& WXUNUSED(evt)) -{ - EVENT e; memset(&e, 0, sizeof(EVENT)); - e.type = E_UPDATE; - - RCT& rct = e.v.update.rct; - - wxRect rctDamaged = GetUpdateRegion().GetBox(); - rct.left = rctDamaged.x; - rct.top = rctDamaged.y; - rct.right = rctDamaged.GetRight()+1; - rct.bottom = rctDamaged.GetBottom()+1; - - TDC& tdc = GetTDCMapper().GetTDC((WINDOW)this); - tdc.GetDC(true); // Forza la creazione di un wxPaintDC - DoXvtEvent(e); - tdc.KillDC(); // Distrugge il wxPaintDC - GetTDCMapper().DestroyDC(NULL_WIN); // Distrugge davvero tutti i wxClientDC residui (risolve molte "porcate" del video) -} - -static SCROLL_CONTROL ConvertScrollToXVT(wxEventType et) -{ - if (et == wxEVT_SCROLL_TOP) - return SC_THUMB; // Meglio di niente - if (et == wxEVT_SCROLL_BOTTOM) - return SC_THUMB; // Meglio di niente - if (et == wxEVT_SCROLL_LINEUP) - return SC_LINE_UP; - if (et == wxEVT_SCROLL_LINEDOWN) - return SC_LINE_DOWN; - if (et == wxEVT_SCROLL_PAGEUP) - return SC_PAGE_UP; - if (et == wxEVT_SCROLL_PAGEDOWN) - return SC_PAGE_DOWN; - if (et == wxEVT_SCROLL_THUMBTRACK) - return SC_THUMBTRACK; - if (et == wxEVT_SCROLL_THUMBRELEASE) - return SC_THUMB; - return SC_NONE; -} - -void TwxWindow::OnScroll(wxScrollEvent& evt) -{ - SCROLL_CONTROL sc = ConvertScrollToXVT(evt.GetEventType()); - if (sc != SC_NONE) - { - EVENT e; memset(&e, 0, sizeof(EVENT)); - - const wxScrollBar* sb = (wxScrollBar*)evt.GetEventObject(); - const wxSize sz = sb->GetSize(); - - e.type = E_CONTROL; - e.v.ctl.id = evt.GetId(); - e.v.ctl.ci.type = sz.x > sz.y ? WC_HSCROLL : WC_VSCROLL; - e.v.ctl.ci.win = (WINDOW)sb; - e.v.ctl.ci.v.scroll.pos = evt.GetPosition(); - e.v.ctl.ci.v.scroll.what = sc; - DoXvtEvent(e); - } -} - -void TwxWindow::OnScrollWin(wxScrollWinEvent& evt) -{ - wxEventType et = evt.GetEventType(); - et -= (wxEVT_SCROLLWIN_TOP - wxEVT_SCROLL_TOP); - const SCROLL_CONTROL sc = ConvertScrollToXVT(et); - if (sc != SC_NONE) - { - EVENT e; memset(&e, 0, sizeof(EVENT)); - e.type = evt.GetOrientation() == wxHORIZONTAL ? E_HSCROLL : E_VSCROLL; - e.v.scroll.pos = evt.GetPosition(); - e.v.scroll.what = sc; - DoXvtEvent(e); - } -} - -void TwxWindow::OnSetFocus(wxFocusEvent& WXUNUSED(e)) -{ - EVENT e; memset(&e, 0, sizeof(EVENT)); - e.type = E_FOCUS; - e.v.active = 1; - DoXvtEvent(e); -} - -void TwxWindow::OnSize(wxSizeEvent& evt) -{ - EVENT e; memset(&e, 0, sizeof(EVENT)); - e.type = E_SIZE; - e.v.size.height = evt.GetSize().x; - e.v.size.width = evt.GetSize().y; - DoXvtEvent(e); -} - -void TwxWindow::OnTimer(wxTimerEvent& WXUNUSED(evt)) -{ - EVENT e; memset(&e, 0, sizeof(EVENT)); - e.type = E_TIMER; - e.v.timer.id = (WINDOW)this; - DoXvtEvent(e); -} - -void TwxWindow::SetMenuTree(const MENU_ITEM* tree) -{ - XVT_ASSERT(tree != NULL); - if (tree != NULL) - { - if (m_menu) - xvt_res_free_menu_tree(m_menu); - m_menu = xvt_menu_duplicate_tree(tree); - ((TTaskWin*)_task_win)->PushMenuTree(tree, this); - } -} - -TwxWindow::TwxWindow(wxWindow *parent, wxWindowID id, const wxString& title, - const wxPoint& pos, const wxSize& size, long style) - : TwxWindowBase(parent, id, title, pos, size, style), - m_menu(NULL), _eh(NULL), _timer(NULL) -{ - _nice_windows.Put((WINDOW)this, this); -} - -TwxWindow::~TwxWindow() -{ - if (_timer) - delete _timer; - if (m_menu) - { - xvt_res_free_menu_tree(m_menu); - ((TTaskWin*)_task_win)->PopMenuTree(); - } - - _nice_windows.Delete((WINDOW)this); -} - - -/////////////////////////////////////////////////////////// -// Main application = TASK_WIN functions -/////////////////////////////////////////////////////////// - -IMPLEMENT_DYNAMIC_CLASS(TTaskWin, wxFrame) - -BEGIN_EVENT_TABLE(TTaskWin, wxFrame) - EVT_CLOSE(TTaskWin::OnClose) - EVT_MENU_RANGE(1000, 32766, TTaskWin::OnMenu) - EVT_PAINT(TTaskWin::OnPaint) - EVT_SIZE(TTaskWin::OnSize) -END_EVENT_TABLE() - -void TTaskWin::OnClose(wxCloseEvent& evt) -{ - if (evt.CanVeto()) - { - EVENT e; memset(&e, 0, sizeof(EVENT)); - e.type = E_CLOSE; - int veto = _task_win_handler((WINDOW)this, &e); - evt.Veto(veto != 0); - } - else - evt.Skip(); -} - -void TTaskWin::OnMenu(wxCommandEvent& evt) -{ - EVENT e; memset(&e, 0, sizeof(EVENT)); - e.type = E_COMMAND; - e.v.cmd.control = 0; e.v.cmd.shift = 0; - e.v.cmd.tag = evt.GetId(); - - if (m_MenuOwner == NULL || m_MenuOwner == this) - _task_win_handler((WINDOW)this, &e); - else - ((TwxWindow*)m_MenuOwner)->_eh((WINDOW)m_MenuOwner, &e); -} - -void TTaskWin::OnPaint(wxPaintEvent& WXUNUSED(evt)) -{ - EVENT e; memset(&e, 0, sizeof(EVENT)); - e.type = E_UPDATE; - RCT& rct = e.v.update.rct; - - wxRect rctDamaged = GetUpdateRegion().GetBox(); - rct.left = rctDamaged.x; - rct.top = rctDamaged.y; - rct.right = rctDamaged.GetRight()+1; - rct.bottom = rctDamaged.GetBottom()+1; - - TDC& dc = GetTDCMapper().GetTDC((WINDOW)this); - dc.GetDC(true); // Forza la creazione di un wxPaintDC - _task_win_handler((WINDOW)this, &e); - dc.KillDC(); -} - -void TTaskWin::OnSize(wxSizeEvent& evt) -{ - EVENT e; memset(&e, 0, sizeof(EVENT)); - e.type = E_SIZE; - e.v.size.height = evt.GetSize().x; - e.v.size.width = evt.GetSize().y; - _task_win_handler((WINDOW)this, &e); -} - -void TTaskWin::SetMenuTree(const MENU_ITEM* tree) -{ - if (m_menu) - xvt_res_free_menu_tree(m_menu); - m_menu = xvt_menu_duplicate_tree(tree); - - wxMenuBar* bar = GetMenuBar(); - for ( ; tree != NULL && tree->tag != 0; tree++) - { - wxMenu* pMenu = new wxMenu; - for (MENU_ITEM* mi = tree->child; mi != NULL && mi->tag != 0; mi++) - { - wxMenuItem* item = NULL; - if (mi->separator) - item = new wxMenuItem(pMenu, wxID_SEPARATOR); - else - item = new wxMenuItem(pMenu, mi->tag, mi->text, wxEmptyString, mi->checkable); - pMenu->Append(item); - } - const int nLast = bar->GetMenuCount()-1; - int m; - for (m = 2; m < nLast; m++) - { - wxMenu* pMenu = bar->GetMenu(m); - if (pMenu->FindItem(tree->child->tag)) - { - bar->Remove(m); -// delete pMenu; - break; - } - } - bar->Insert(m, pMenu, tree->text); - } -} - -void TTaskWin::PushMenuTree(const MENU_ITEM* tree, wxWindow* owner) -{ - if(m_pOldBar != NULL) - PopMenuTree(); - m_pOldBar = GetMenuBar(); - - wxMenuBar* pBar = new wxMenuBar; - for (; tree && tree->tag != 0; tree++) - { - wxMenu* pMenu = new wxMenu; - for (MENU_ITEM* mi = tree->child; mi != NULL && mi->tag != 0; mi++) - { - wxMenuItem* item = NULL; - if (mi->separator) - item = new wxMenuItem(pMenu, wxID_SEPARATOR); - else - item = new wxMenuItem(pMenu, mi->tag, mi->text, wxEmptyString, mi->checkable); - pMenu->Append(item); - } - pBar->Append(pMenu, tree->text); - } - SetMenuBar(pBar); - m_MenuOwner = owner; -} - -void TTaskWin::PopMenuTree() -{ - XVT_ASSERT(m_pOldBar != NULL); - wxMenuBar* pBar = GetMenuBar(); - SetMenuBar(m_pOldBar); - delete pBar; - m_pOldBar = NULL; - m_MenuOwner = NULL; // = this; -} - -TTaskWin::TTaskWin(wxWindow *parent, wxWindowID id, - const wxString& title, const wxPoint& pos, - const wxSize& size, long style) - : wxFrame(parent, id, title, pos, size, style), m_menu(NULL), m_pOldBar(NULL), m_MenuOwner(NULL) -{ - wxIcon* ico = ::GetIconResource(ICON_RSRC); - if (ico) - SetIcon(*ico); - _nice_windows.Put((WINDOW)this, this); -} - -TTaskWin::~TTaskWin() -{ - if (m_menu) - { - xvt_res_free_menu_tree(m_menu); - m_menu = NULL; - } - _nice_windows.Delete((WINDOW)this); -} - /////////////////////////////////////////////////////////// // Speech support /////////////////////////////////////////////////////////// @@ -1559,59 +484,6 @@ BOOLEAN xvt_cb_put_data(CB_FORMAT cbfmt, char *name, long size, PICTURE pic) return ok; } -/////////////////////////////////////////////////////////// -// Controls functions (NOT used) -/////////////////////////////////////////////////////////// - -class TwxScrollBar : public wxScrollBar -{ -protected: - virtual bool AcceptsFocus() const { return false; } // Altrimenti mette il flag wxTAB_TRAVERSAL - -public: - TwxScrollBar(wxWindow *parent, wxWindowID id, - const wxPoint& pos, const wxSize& size, long style) - { Create(parent, id, pos, size, style); } -}; - -WINDOW xvt_ctl_create_def(WIN_DEF *win_def_p, WINDOW parent_win, long app_data) -{ - const wxRect rct = NormalizeRCT(&win_def_p->rct); - wxWindow* pParent = (wxWindow*)parent_win; - - WINDOW win = NULL_WIN; - switch (win_def_p->wtype) - { - case WC_HSCROLL: /* horizontal scrollbar control */ - case WC_VSCROLL: /* vertical scrollbar control */ - { - const long style = win_def_p->wtype == WC_HSCROLL ? wxSB_HORIZONTAL : wxSB_VERTICAL; - TwxScrollBar* sb = new TwxScrollBar(pParent, win_def_p->v.ctl.ctrl_id, - rct.GetPosition(), rct.GetSize(), style); - win = (WINDOW)sb; - } - break; - case WC_HGAUGE: /* horizontal progress bar control */ - case WC_VGAUGE: /* vertical progress bar control */ - { - const long style = win_def_p->wtype == (WC_HGAUGE ? wxGA_HORIZONTAL : wxGA_VERTICAL); - wxGauge* pg = new wxGauge(pParent, win_def_p->v.ctl.ctrl_id, app_data, - rct.GetPosition(), rct.GetSize(), style); - win = (WINDOW)pg; - } - break; - default: - SORRY_BOX(); break; - } - return win; -} - -void xvt_ctl_check_radio_button(WINDOW Win, WINDOW* Wins, int NbrWindows) -{ SORRY_BOX(); } // Ignored - -void xvt_ctl_set_checked(WINDOW Win, BOOLEAN Check) -{ SORRY_BOX(); } // Ignored - /////////////////////////////////////////////////////////// // Debug functions /////////////////////////////////////////////////////////// @@ -1938,15 +810,7 @@ static FL_STATUS xvt_dm_post_file_ask(FILE_SPEC *fsp, const char *msg, int flags wxString selectedname = wxFileSelector(msg, path, name, extension , mask, flags); if (selectedname.IsEmpty()) return FL_CANCEL; - -// wxFileName::SplitPath(selectedname, &path, &name, &extension); -// strcpy(fsp->dir.path, path); -// strcpy(fsp->name, MakeFileName(name, extension)); -// strcpy(fsp->type, extension); - char pathname[_MAX_PATH]; - - xvt_fsys_parse_pathname(selectedname, fsp->dir.path, pathname, fsp->name, fsp->type, NULL); - strcat(fsp->dir.path, pathname); + xvt_fsys_convert_str_to_fspec(selectedname, fsp); return FL_OK; } @@ -2330,19 +1194,25 @@ void xvt_dwin_draw_arc(WINDOW win, const RCT* r, int sx, int sy, int ex, int ey) void xvt_dwin_draw_gradient_circular(WINDOW win, const RCT* r, COLOR col1, COLOR col2, const PNT* center) { -#if wxCHECK_VERSION(2,8,0) - if (r != NULL) + if (win != NULL_WIN && r != NULL) { CAST_DC(win, dc); const wxRect rect = NormalizeRCT(r); CAST_COLOR(col1, color1); CAST_COLOR(col2, color2); +#if wxCHECK_VERSION(2,8,0) if (center != NULL) dc.GradientFillConcentric(rect, color1, color2, wxPoint(center->h, center->v)); else dc.GradientFillConcentric(rect, color1, color2); - } +#else + wxBrush* brush = wxTheBrushList->FindOrCreateBrush(color1, wxSOLID); + wxPen* pen = wxThePenList->FindOrCreatePen(color2, 0, wxSOLID); + dc.SetBrush(*brush); + dc.SetPen(*pen); + dc.DrawEllipse(rect); #endif + } } void xvt_dwin_draw_gradient_linear(WINDOW win, const RCT* r, COLOR col1, COLOR col2, int angle) @@ -2392,7 +1262,7 @@ void xvt_dwin_draw_gradient_linear(WINDOW win, const RCT* r, COLOR col1, COLOR c void xvt_dwin_draw_icon(WINDOW win, int x, int y, int rid) { - wxIcon* ico = ::GetIconResource(rid); + wxIcon* ico = _GetIconResource(rid); if (ico != NULL) { CAST_DC(win, dc); @@ -2733,6 +1603,7 @@ void xvt_dwin_set_clip(WINDOW win, const RCT* rctp) { CAST_TDC(win, dc); dc.SetClippingBox(rctp); + dc.SetDirty(); } void xvt_dwin_set_cpen(WINDOW win, CPEN* cpen) @@ -3047,22 +1918,22 @@ BOOLEAN xvt_fsys_parse_pathname(const char *mbs, char *volname, char *dirname, c wxFileName::SplitPath(mbs, &volume, &path, &file, &ext); if (volname) { - if (mbs[0] == '\\' && mbs[1] == '\\') + if (mbs[0] == mbs[1] && wxIsPathSeparator(mbs[0])) { - volume.insert(0, "\\\\"); - if (path[0] != '\\' && path[0] != '/') - volume << '/'; + volume.insert(size_t(0), size_t(2), wxFILE_SEP_PATH); // Mette due slash all'inizio + if (!wxIsPathSeparator(path[0])) + volume << wxFILE_SEP_PATH; // Accoda uno slash path.insert(0, volume); *volname = '\0'; } else { - strcpy(volname, volume); + wxStrcpy(volname, volume); #ifdef WIN32 - if (volname[0] != '\0' && volname[1] == '\0') - strcat(volname, ":"); + if (volname[0] != '\0' && volname[1] == '\0') + wxStrcat(volname, ":"); #endif - } + } } if (dirname) strcpy(dirname, path); if (leafroot) strcpy(leafroot, file); @@ -3102,19 +1973,12 @@ BOOLEAN xvt_fsys_convert_str_to_fspec(const char *mbs, FILE_SPEC *fs) BOOLEAN ok = FALSE; if (mbs && *mbs && fs != NULL) { - char path[_MAX_PATH]; - - xvt_fsys_parse_pathname(mbs, fs->dir.path, path, fs->name, fs->type, NULL); - strcat(fs->dir.path, path); + char volume[_MAX_DRIVE], path[_MAX_PATH]; + xvt_fsys_parse_pathname(mbs, volume, path, fs->name, fs->type, NULL); + wxStrcpy(fs->dir.path, volume); + wxStrcat(fs->dir.path, path); -// wxString volume, path, file, ext; -// wxFileName::SplitPath(mbs, &volume, &path, &file, &ext); - -// xvt_fsys_convert_str_to_dir(volume+path, &fs->dir); -// wxStrncpy(fs->type, ext, sizeof(fs->type)); -// wxStrncpy(fs->name, file, SZ_FNAME); wxStrcpy(fs->creator, "CAMPO"); -// ok = !file.IsEmpty(); ok = fs->name[0] != '\0'; } return ok; @@ -3134,87 +1998,123 @@ BOOLEAN xvt_fsys_get_dir(DIRECTORY *dirp) return xvt_fsys_convert_str_to_dir(str, dirp); } +static wxString get_disk_root(const char* path) +{ + wxString str; + if (path && *path) + { + str = path; + if (!wxEndsWithPathSeparator(str)) + str << wxFILE_SEP_PATH; + + wxChar drive[_MAX_DRIVE], dir[_MAX_DIR]; + xvt_fsys_parse_pathname(str,drive,dir,NULL,NULL,NULL); + + if (*drive) + str = drive; + else + str = dir; + + if (!wxEndsWithPathSeparator(str)) + str << wxFILE_SEP_PATH; + } + return str; +} + +// Il disco e' un floppy? +BOOLEAN xvt_fsys_is_floppy_drive(const char* path) +{ + BOOLEAN yes = xvt_fsys_is_removable_drive(path); + if (yes) + { + const unsigned long mb = xvt_fsys_get_disk_size(path, 'M'); // Dimensioni in Mb + yes = mb < 4; // E' un vero floppy solo se e' piu' piccolo di 4 Mb + } + return yes; +} + +// Il disco e' rimuovibile? (floppy / memory stick) BOOLEAN xvt_fsys_is_removable_drive(const char* path) { + BOOLEAN yes = FALSE; + + if (path && *path) + { #ifdef WIN32 - if (path != NULL && path[0] == '\\' && path[1] == '\\') - return FALSE; - char drive[_MAX_DRIVE+1]; - xvt_fsys_parse_pathname(path,drive,NULL,NULL,NULL,NULL); - strcat(drive,"\\"); - return GetDriveType(drive) == DRIVE_REMOVABLE; + const wxString strRoot = get_disk_root(path); + yes = GetDriveType(strRoot) == DRIVE_REMOVABLE; #else - char dev[_MAX_PATH]; - - OsLinux_GetFileSys(path, dev, NULL, NULL); - return strncmp(dev, "/dev/fd", 7) == 0; + char dev[_MAX_PATH]; + OsLinux_GetFileSys(path, dev, NULL, NULL); + yes = strncmp(dev, "/dev/fd", 7) == 0; #endif + } + return yes; } BOOLEAN xvt_fsys_is_network_drive(const char* path) { + BOOLEAN yes = FALSE; + if (path && *path) + { + if (wxIsPathSeparator(path[0]) && wxIsPathSeparator(path[1])) + yes = TRUE; + else + { #ifdef WIN32 - if (path != NULL && path[0] == '\\' && path[1] == '\\') - return TRUE; - char drive[_MAX_DRIVE+1]; - xvt_fsys_parse_pathname(path,drive,NULL,NULL,NULL,NULL); - strcat(drive,"\\"); - return GetDriveType(drive) == DRIVE_REMOTE; + const wxString strRoot = get_disk_root(path); + yes = GetDriveType(strRoot) == DRIVE_REMOTE; #else - return OsLinux_IsNetworkDrive(path); + yes = OsLinux_IsNetworkDrive(path); #endif + } + } + return yes; } BOOLEAN xvt_fsys_is_fixed_drive(const char* path) { + BOOLEAN yes = FALSE; + if (path && *path) + { + if (!wxIsPathSeparator(path[0]) || !wxIsPathSeparator(path[1])) + { #ifdef WIN32 - if (path != NULL && path[0] == '\\' && path[1] == '\\') - return FALSE; - char drive[_MAX_DRIVE+1]; - xvt_fsys_parse_pathname(path,drive,NULL,NULL,NULL,NULL); - strcat(drive,"\\"); - return GetDriveType(drive) == DRIVE_FIXED; + const wxString strRoot = get_disk_root(path); + yes = GetDriveType(strRoot) == DRIVE_FIXED; #else - return !(xvt_fsys_is_network_drive(path) || xvt_fsys_is_removable_drive(path)); + yes = !(xvt_fsys_is_network_drive(path) || xvt_fsys_is_removable_drive(path)); #endif + } + } + return yes; } static unsigned long compute_disk_size(const char* path, bool tot, char unit) { -#ifdef WIN32 - char drive[_MAX_DRIVE + 1]; - char pathname[_MAX_PATH]; + long nVal = 0; + if (path && *path) + { + const wxString strRoot = get_disk_root(path); + wxLongLong total = 0, unused = 0; + wxGetDiskSpace(path, &total, &unused); + __int64 nBytes = tot ? total.ToDouble() : unused.ToDouble(); - xvt_fsys_parse_pathname(path, drive, pathname, NULL, NULL, NULL); - if (strlen(drive) > 0) - strcat(drive, "/"); - DWORD nSecPerClust, nBytePerSec, nFreeClust, nTotalClust; - __int64 nBytes = 0; - - if (::GetDiskFreeSpace( *drive ? drive : pathname, &nSecPerClust, &nBytePerSec, &nFreeClust, &nTotalClust) != 0) - { - nBytes = tot ? nTotalClust : nFreeClust; - nBytes *= nSecPerClust; - nBytes *= nBytePerSec; - } - -#else - int64_t nBytes = OsLinux_GetDiskFreeSpace(path); -#endif - - switch (unit) - { - case 'K': nBytes >>= 10; break; // Kilobytes - case 'M': nBytes >>= 20; break; // Megabytes - case 'G': nBytes >>= 30; break; // Gigabytes - case 'T': nBytes >>= 40; break; // Terabytes - default: - break; - } - - const unsigned long nMax = (unsigned long)(~0L); - unsigned long nVal = nBytes > nMax ? nMax : (unsigned long)nBytes; - return nVal; + if (nBytes > 0) + { + switch (unit) + { + case 'K': nBytes >>= 10; break; // Kilobytes + case 'M': nBytes >>= 20; break; // Megabytes + case 'G': nBytes >>= 30; break; // Gigabytes + case 'T': nBytes >>= 40; break; // Terabytes + default : break; + } + const unsigned long nMax = (unsigned long)(~0L); + nVal = nBytes > nMax ? nMax : (unsigned long)nBytes; + } + } + return nVal; } unsigned long xvt_fsys_get_disk_size(const char* path, char unit) @@ -3257,13 +2157,8 @@ long xvt_fsys_file_attr(const char* path, long attr) break; case XVT_FILE_ATTR_SIZE: { - FILE* f = fopen(name, "r"); - if (f != NULL) - { - fseek(f, 0, SEEK_END); - ret = ftell(f); - fclose(f); - } + const wxULongLong sz = wxFileName::GetSize(name); + ret = sz.GetHi() != 0 ? MAXINT : sz.GetLo(); } break; case XVT_FILE_ATTR_MTIME: @@ -3278,7 +2173,7 @@ long xvt_fsys_file_attr(const char* path, long attr) // Original XVT implementation long xvt_fsys_get_file_attr(const FILE_SPEC* fs, long attr) { - char mbs[256]; xvt_fsys_convert_fspec_to_str(fs, mbs, sizeof(mbs)); + char mbs[_MAX_PATH]; xvt_fsys_convert_fspec_to_str(fs, mbs, sizeof(mbs)); return xvt_fsys_file_attr(mbs, attr); } @@ -3361,7 +2256,6 @@ XVT_IMAGE xvt_image_capture(WINDOW win, const RCT* src) return (XVT_IMAGE)i; } - XVT_IMAGE xvt_image_create(XVT_IMAGE_FORMAT format, short width, short height, long reserved) { TXVT_IMAGE* i = new TXVT_IMAGE; @@ -3563,7 +2457,7 @@ DATA_PTR xvt_mem_zalloc(size_t size) // Menu management /////////////////////////////////////////////////////////// -int xvt_menu_count(const MENU_ITEM* m) +static int xvt_menu_count(const MENU_ITEM* m) { int n; @@ -4145,30 +3039,19 @@ WINDOW xvt_scr_get_focus_vobj(void) return xvt_scr_get_focus_topwin(); } -static void AddWinToList(SLIST list, WINDOW win) -{ - if (win != NULL_WIN) - { - CAST_WIN(win, w); - const char* title = w.GetLabel(); - xvt_slist_add_at_elt(list, NULL, title, win); - } -} - SLIST xvt_scr_list_wins() { SLIST list = xvt_slist_create(); _nice_windows.BeginFind(); - -#if wxCHECK_VERSION(2,8,0) for (wxHashTable::Node* node = _nice_windows.Next(); node; node = _nice_windows.Next()) -#else - for (wxNode* node = _nice_windows.Next(); node; node = _nice_windows.Next()) -#endif { - wxObject* pWin = node->GetData(); - AddWinToList(list, (WINDOW)pWin); + wxWindow* pWin = (wxWindow*)node->GetData(); + if (pWin != NULL) + { + const char* title = pWin->GetLabel(); + xvt_slist_add_at_elt(list, NULL, title, (long)pWin); + } } return list; @@ -4323,18 +3206,16 @@ BOOLEAN xvt_str_match(const char* mbs, const char *pat, BOOLEAN case_sensitive) void xvt_str_make_upper(char* str) { -#ifdef WIN32 - _strupr(str); -#else - for (char * s = str; *s; s++) - *s = toupper(*s); -#endif + wxString s(str); + s.MakeUpper(); + strcpy(str, s); } void xvt_str_make_lower(char* str) { - for (char * s = str; *s; s++) - *s = tolower(*s); + wxString s(str); + s.MakeLower(); + strcpy(str, s); } double xvt_str_fuzzy_compare (const char* s1, const char* s2) @@ -4731,7 +3612,6 @@ void xvt_sys_searchenv(const char * filename, const char * varname, char * pathn // BOOLEAN o int? Adso! int xvt_fsys_access(const char *pathname, int mode) { - wxString str = ::wxGetCwd(); return wxAccess(pathname, mode) == -1 ? errno : 0; } @@ -4754,11 +3634,18 @@ BOOLEAN xvt_fsys_rmdir(const char *pathname) return wxRmdir(pathname); } -BOOLEAN xvt_fsys_removefile(const char *pathname) +BOOLEAN xvt_fsys_remove_file(const char *pathname) { return wxRemoveFile(pathname); } +BOOLEAN xvt_fsys_removefile(const char *pathname) +{ + DEPRECATED_BOX(); + return xvt_fsys_remove_file(pathname); +} + + /////////////////////////////////////////////////////////// // Timers /////////////////////////////////////////////////////////// @@ -4793,19 +3680,14 @@ void xvt_timer_destroy(long id) void xvt_vobj_destroy(WINDOW win) { - if (win != PRINTER_WIN) + if (win != PRINTER_WIN && win != TASK_WIN) { - if (_TheCaret.Owner() == win) - _TheCaret.Kill(); + xvt_win_set_caret_visible(win, FALSE); if (_nice_windows.Get(win) != NULL) { - if (win != TASK_WIN) - { - CAST_TWIN(win, w); - w.Close(true); - } - GetTDCMapper().DestroyTDC(win); + CAST_TWIN(win, w); + w.Close(true); } } GetTDCMapper().DestroyTDC(win); @@ -4818,20 +3700,33 @@ long xvt_vobj_get_attr(WINDOW win, long data) { case ATTR_APP_CTL_COLORS: { - XVT_COLOR_COMPONENT* xcc = (XVT_COLOR_COMPONENT*)xvt_mem_zalloc(sizeof(XVT_COLOR_COMPONENT)*6); - + XVT_COLOR_COMPONENT* xcc = (XVT_COLOR_COMPONENT*)xvt_mem_zalloc(sizeof(XVT_COLOR_COMPONENT)*16); + + // XVT components xcc[0].type = XVT_COLOR_FOREGROUND; xcc[0].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT)); xcc[1].type = XVT_COLOR_BACKGROUND; xcc[1].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); - xcc[2].type = XVT_COLOR_CAPTIONLT; - xcc[2].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION)); - xcc[3].type = XVT_COLOR_CAPTIONDK; - xcc[3].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_INACTIVECAPTION)); - xcc[4].type = XVT_COLOR_CAPTIONTEXT; - xcc[4].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT)); - xcc[5].type = XVT_COLOR_NULL; - xcc[5].color = 0; + xcc[2].type = XVT_COLOR_BLEND; + xcc[2].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNHIGHLIGHT)); + xcc[3].type = XVT_COLOR_BORDER; + xcc[3].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW)); + xcc[4].type = XVT_COLOR_SELECT; + xcc[4].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)); + xcc[5].type = XVT_COLOR_HIGHLIGHT; + xcc[5].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT)); + + // AGA components + xcc[6].type = XVT_COLOR_CAPTIONLT; + xcc[6].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION)); + xcc[7].type = XVT_COLOR_CAPTIONDK; + xcc[7].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_INACTIVECAPTION)); + xcc[8].type = XVT_COLOR_CAPTIONTEXT; + xcc[8].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT)); + + // Last (NULL) component + xcc[9].type = XVT_COLOR_NULL; + xcc[9].color = 0; ret = (long)xcc; } @@ -4867,7 +3762,7 @@ long xvt_vobj_get_attr(WINDOW win, long data) ret = wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y); break; case ATTR_DISPLAY_TYPE: - switch (::wxDisplayDepth()) + switch (::wxDisplayDepth()) // Test ormai ridicolo? { case 1: ret = XVT_DISPLAY_MONO; break; case 4: ret = XVT_DISPLAY_COLOR_16; break; @@ -5043,7 +3938,7 @@ void xvt_vobj_minimize(WINDOW win) void xvt_vobj_move(WINDOW win, const RCT* rctp) { CAST_WIN(win, w); - wxRect rct = NormalizeRCT(rctp); + const wxRect rct = NormalizeRCT(rctp); w.Move(rct.x, rct.y); w.SetClientSize(rct.width, rct.height); } @@ -5120,14 +4015,10 @@ void xvt_vobj_translate_points(WINDOW from_win, WINDOW to_win, PNT *pntp, int np WINDOW xvt_win_create(WIN_TYPE wtype, const RCT* rct_p, const char* title, int menu_rid, WINDOW parent, long win_flags, EVENT_MASK mask, EVENT_HANDLER eh, long app_data) { - XVT_ASSERT(rct_p != NULL); - + const wxRect rct = NormalizeRCT(rct_p); const wxString caption = title; - const wxPoint pos(rct_p->left, rct_p->top); - const wxSize size(rct_p->right-rct_p->left, rct_p->bottom-rct_p->top); - - long style = wxCLIP_CHILDREN | wxCLIP_SIBLINGS; + long style = wxCLIP_CHILDREN | wxCLIP_SIBLINGS; if (win_flags & WSF_VSCROLL) style |= wxVSCROLL; if (win_flags & WSF_HSCROLL) @@ -5150,14 +4041,12 @@ WINDOW xvt_win_create(WIN_TYPE wtype, const RCT* rct_p, const char* title, int m } if (parent == SCREEN_WIN) parent = NULL; - w = new TwxWindow((wxWindow*)parent, -1, caption, pos, size, style); + w = new TwxWindow((wxWindow*)parent, -1, caption, rct.GetPosition(), rct.GetSize(), style); w->_type = wtype; w->_app_data = app_data; - w->SetBackgroundStyle(wxBG_STYLE_CUSTOM); // Lo sfondo viene disegnato nella OnPaint - #ifdef WIN32 OsWin32_SetCaptionStyle(w->GetHWND(), wtype == W_DOC); #else @@ -5179,7 +4068,7 @@ WINDOW xvt_win_create(WIN_TYPE wtype, const RCT* rct_p, const char* title, int m if (style & wxVSCROLL) w->SetScrollbar(wxVERTICAL, 0, 1, 100); - //xvt_vobj_move((WINDOW)w, rct_p); // Sembra inutile + // xvt_vobj_move((WINDOW)w, rct_p); // Sembra inutile if (win_flags & WSF_DISABLED) w->Disable(); @@ -5244,21 +4133,6 @@ void xvt_win_release_pointer(void) } } -void xvt_win_set_caret_size(WINDOW win, int width, int height) -{ - _TheCaret.SetSize(width, height); -} - -void xvt_win_set_caret_pos(WINDOW win, PNT p) -{ - _TheCaret.SetPos(p.h, p.v-1); -} - -void xvt_win_set_caret_visible(WINDOW win, BOOLEAN on) -{ - _TheCaret.Show(win, on != 0); -} - void xvt_win_set_cursor(WINDOW win, CURSOR cursor) { CAST_WIN(win, w); @@ -5351,3 +4225,45 @@ WINDOW statbar_create(int cid, int left, int top, int right, int bottom, return (WINDOW)&w; } + +void xvt_btn_set_images(WINDOW win, XVT_IMAGE up, XVT_IMAGE down) +{ + wxBitmapButton* pb = (wxBitmapButton*)win; + XVT_ASSERT(pb != NULL); + + if (up != NULL) + { + XVT_ASSERT(pb->IsKindOf(CLASSINFO(wxBitmapButton))); + wxImage& img = ((TXVT_IMAGE*)up)->Image(); + const int r = img.GetRed(0,0); + const int g = img.GetGreen(0,0); + const int b = img.GetBlue(0,0); + img.SetMask(); + img.SetMaskColour(r, g, b); + + wxBitmap bmpUp(img); + if (bmpUp.Ok()) + { + pb->SetBitmapLabel(bmpUp); + + const wxImage imgGay = img.ConvertToGreyscale(); + wxBitmap bmpGay(imgGay); + pb->SetBitmapDisabled(bmpGay); + } + + if (down != NULL) + { + wxImage& img = ((TXVT_IMAGE*)down)->Image(); + img.SetMask(); + img.SetMaskColour(r, g, b); + wxBitmap bmpDown(img); + if (bmpDown.Ok()) + pb->SetBitmapSelected(bmpDown); + } + else + { + if (bmpUp.Ok()) + pb->SetBitmapSelected(bmpUp); + } + } +} diff --git a/xvaga/xvintern.h b/xvaga/xvintern.h deleted file mode 100755 index 14cf14a78..000000000 --- a/xvaga/xvintern.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef __XVINTERN_H -#define __XVINTERN_H - -class TFontId -{ - wxString m_strFace; - int m_nSize; - XVT_FONT_STYLE_MASK m_wMask; - WINDOW m_win; - -protected: - void Copy(const TFontId& pFont); - bool IsEqual(const TFontId& pFont) const; - -public: - void SetWin(WINDOW w) { m_win = w; } - WINDOW Win() const { return m_win; } - - void SetPointSize(int s) { m_nSize = s; } - int PointSize() const { return m_nSize; } - - void SetMask(XVT_FONT_STYLE_MASK mask) { m_wMask = mask; } - XVT_FONT_STYLE_MASK Mask() const { return m_wMask; } - int Style() const; - bool Underline() const; - int Weight() const; - - void SetFaceName(const char* f) { m_strFace = f; } - const char* FaceName() const; - int Family() const; - - void Copy(const wxFont& rFont); - wxFont& Font(wxDC* dc, WINDOW w) const; - - TFontId& operator=(const TFontId& f) { Copy(f); return *this; } - bool operator==(const TFontId& f) const { return IsEqual(f); } - bool operator!=(const TFontId& f) const { return !IsEqual(f); } - - TFontId() : m_nSize(0), m_wMask(0), m_win(NULL_WIN) { } - TFontId(const TFontId& f) : m_win(NULL_WIN) { Copy(f); } -}; - -class TDC : public wxObject -{ - wxWindow* _owner; - -protected: - wxDC* _dc; - RCT _clip; - int _dirty; // false = 0, true = 1, very_dirty = -1; - int _deltaf; - - DRAW_CTOOLS _real_dct; - TFontId _real_font; - - bool PenChanged() const; - bool BrushChanged() const; - bool FontChanged() const; - -public: - DRAW_CTOOLS _dct; - TFontId _font; - wxPoint _pnt; - - void SetClippingBox(const RCT* pRct); - bool GetClippingBox(RCT* pRct) const; - void SetDirty(int d = 1); - int GetFontDelta() const { return _deltaf; } - - virtual wxDC& GetDC(bool bPaint = false); - virtual void KillDC(); - TDC(wxWindow* owner); - virtual ~TDC(); -}; - -class TPrintDC : public TDC -{ - static bool _page_start; - -public: - static void SetPageStart(); - - virtual wxDC& GetDC(bool); - virtual void KillDC(); - TPrintDC(wxWindow* owner); - virtual ~TPrintDC(); -}; - -const wxString& _GetAppTitle(); - -#endif diff --git a/xvaga/xvt.h b/xvaga/xvt.h index 6feec3903..d942b38f3 100755 --- a/xvaga/xvt.h +++ b/xvaga/xvt.h @@ -173,13 +173,15 @@ XVTDLL long xvt_fsys_get_file_attr(const FILE_SPEC *fs, long attr); // Place // Added by Guy XVTDLL unsigned long xvt_fsys_get_disk_size(const char* path, char unit); XVTDLL unsigned long xvt_fsys_get_disk_free_space(const char* path, char unit); +XVTDLL BOOLEAN xvt_fsys_is_floppy_drive(const char* path); XVTDLL BOOLEAN xvt_fsys_is_removable_drive(const char* path); XVTDLL BOOLEAN xvt_fsys_is_network_drive(const char* path); XVTDLL BOOLEAN xvt_fsys_is_fixed_drive(const char* path); XVTDLL BOOLEAN xvt_fsys_test_disk_free_space(const char* path, unsigned long filesize); XVTDLL BOOLEAN xvt_fsys_mkdir(const char *pathname); XVTDLL BOOLEAN xvt_fsys_rmdir(const char *pathname); -XVTDLL BOOLEAN xvt_fsys_removefile(const char *pathname); +XVTDLL BOOLEAN xvt_fsys_removefile(const char *pathname); // DEPRECATED! +XVTDLL BOOLEAN xvt_fsys_remove_file(const char *pathname); XVTDLL int xvt_fsys_access(const char *pathname, int mode); XVTDLL BOOLEAN xvt_fsys_file_exists(const char *pathname); XVTDLL int xvt_fsys_get_campo_stp_value(const char* name, char* value, int valsize); @@ -219,6 +221,21 @@ XVTDLL void xvt_menu_set_item_enabled(WINDOW win, MENU_TAG tag, BOOLEAN e XVTDLL void xvt_menu_set_item_title(WINDOW win, MENU_TAG tag, const char* text); XVTDLL void xvt_menu_set_tree(WINDOW win, MENU_ITEM* tree); XVTDLL void xvt_menu_update(WINDOW win); +XVTDLL MENU_ITEM* xvt_menu_duplicate_tree(const MENU_ITEM* m); + + +XVTDLL void xvt_notebk_add_page(WINDOW notebk, short tab_no, short page_no, + const char* title, long page_data); +XVTDLL void xvt_notebk_add_tab(WINDOW notebk, short tab_no, const char* title, XVT_IMAGE image); +XVTDLL WINDOW xvt_notebk_create_face(WINDOW notebk, short tab_no, short page_no, + EVENT_MASK mask, EVENT_HANDLER face_eh, long app_data); +XVTDLL WINDOW xvt_notebk_create_face_def(WINDOW notebk, short tab_no, short page_no, + WIN_DEF* win_def_p, EVENT_MASK mask, + EVENT_HANDLER face_eh, long app_data); +XVTDLL WINDOW xvt_notebk_get_face(WINDOW notebk, short tab_no, short page_no); +XVTDLL short xvt_notebk_get_num_tabs(WINDOW notebk); +XVTDLL void xvt_notebk_set_front_page(WINDOW notebk, short tab_no, short page_no); +XVTDLL void xvt_notebk_set_tab_title(WINDOW notebk, short tab_no, const char* title); // Added by Guy typedef const char* TRANSLATE_CALLBACK(const char* ita); @@ -301,6 +318,29 @@ XVTDLL double xvt_str_fuzzy_compare (const char* s1, const char* s2); XVTDLL void xvt_str_make_upper(char* str); XVTDLL void xvt_str_make_lower(char* str); +XVTDLL XVT_TREEVIEW_NODE xvt_treeview_add_child_node(WINDOW win, + XVT_TREEVIEW_NODE parent, XVT_TREEVIEW_NODE_TYPE type, + XVT_IMAGE item_image, XVT_IMAGE collapsed_image, XVT_IMAGE expanded_image, + const char* string, XVT_TREEVIEW_CALLBACK callback, const char* data); +XVTDLL WINDOW xvt_treeview_create(WINDOW parent_win, + RCT * rct_p, char * title, long ctl_flags, long app_data, int ctl_id, + XVT_IMAGE item_image, XVT_IMAGE collapsed_image, XVT_IMAGE expanded_image, + long attrs, int line_height); +XVTDLL void xvt_treeview_destroy_node(WINDOW win, XVT_TREEVIEW_NODE node); +XVTDLL BOOLEAN xvt_treeview_expand_node(WINDOW win, XVT_TREEVIEW_NODE node, BOOLEAN recurse); +XVTDLL XVT_TREEVIEW_NODE xvt_treeview_get_child_node(WINDOW win, XVT_TREEVIEW_NODE parent_node, int position); +XVTDLL const char* xvt_treeview_get_node_data(WINDOW win, XVT_TREEVIEW_NODE node); +XVTDLL XVT_TREEVIEW_NODE xvt_treeview_get_root_node(WINDOW win); +XVTDLL XVT_TREEVIEW_NODE xvt_treeview_get_selected_node(WINDOW win); +XVTDLL BOOLEAN xvt_treeview_remove_child_node(WINDOW win, XVT_TREEVIEW_NODE node); +XVTDLL BOOLEAN xvt_treeview_remove_node_children(WINDOW win, XVT_TREEVIEW_NODE node); +XVTDLL void xvt_treeview_resume(WINDOW win); +XVTDLL void xvt_treeview_select_node(WINDOW win, XVT_TREEVIEW_NODE node, BOOLEAN sel); +XVTDLL void xvt_treeview_set_node_images(WINDOW win, XVT_TREEVIEW_NODE node, + XVT_IMAGE item_image, XVT_IMAGE collapsed_image, XVT_IMAGE expanded_image); +XVTDLL void xvt_treeview_set_node_string(WINDOW win, XVT_TREEVIEW_NODE node, const char* text); +XVTDLL void xvt_treeview_suspend(WINDOW win); + XVTDLL BOOLEAN xvt_chr_is_digit(int c); XVTDLL BOOLEAN xvt_chr_is_alpha(int c); XVTDLL BOOLEAN xvt_chr_is_alnum(int c); @@ -328,6 +368,7 @@ XVTDLL void xvt_sys_sleep(unsigned long msec); XVTDLL BOOLEAN xvt_sys_test_network_version(); XVTDLL void xvt_sys_searchenv(const char *filename, const char *varname, char *pathname); XVTDLL void xvt_sys_sorry_box(const char * file, int line); +XVTDLL void xvt_sys_deprecated_box(const char * file, int line); XVTDLL long xvt_timer_create(WINDOW win, long interval); XVTDLL void xvt_timer_destroy(long id); XVTDLL void xvt_vobj_destroy(WINDOW win); @@ -370,6 +411,7 @@ XVTDLL ULONG xvt_odbc_execute(XVT_ODBC handle, const char* sql, ODBC_CALLBACK cb XVTDLL BOOLEAN xvt_mail_send(const char* to, const char* cc, const char* ccn, const char* subject, const char* msg, const char* attach, BOOLEAN ui); +XVTDLL void xvt_btn_set_images(WINDOW win, XVT_IMAGE up, XVT_IMAGE down); XVTDLL int xvt_net_get_status(); #ifdef __cplusplus @@ -378,4 +420,10 @@ XVTDLL int xvt_net_get_status(); #define SORRY_BOX() xvt_sys_sorry_box(__FILE__, __LINE__) +#ifndef NDEBUG +#define DEPRECATED_BOX() xvt_sys_deprecated_box(__FILE__, __LINE__) +#else +#define DEPRECATED_BOX() +#endif + #endif \ No newline at end of file diff --git a/xvaga/xvt_env.h b/xvaga/xvt_env.h index 0bdb26605..9c12abc95 100755 --- a/xvaga/xvt_env.h +++ b/xvaga/xvt_env.h @@ -1,3 +1,5 @@ +#define XVT_CC_ENUM_END 127 + #define XVT_OS_WIN32 400 #define XVT_OS_LINUX 595 @@ -15,6 +17,7 @@ #define XVT_WS_WIN_2000 412 #define XVT_WS_WIN_XP 413 #define XVT_WS_WIN_SERVER 414 +#define XVT_WS_WIN_VISTA 415 #define XVT_WS_UNKNOWN 0 #define MACWS 100 /* Apple Macintosh */ @@ -53,3 +56,17 @@ #define ATTR_WIN_OPENFILENAME_HOOK (ATTR_WIN_BASE + 13) #define ATTR_WIN_POPUP_DETACHED (ATTR_WIN_BASE + 14) #define main xvt_main + +/**************************************************************************** +* Define Prototyping Information +****************************************************************************/ + +#define XVT_CC_ARGL(al__) ( +#define XVT_CC_ARG(t__,a__) t__ a__, +#define XVT_CC_LARG(t__,a__) t__ a__) +#define XVT_CC_ARGS(al__) al__ +#define XVT_CC_NOARGS() (void) + +/* Default to no linkage conventions in callback typedef */ +#define XVT_CALLCONV_TYPEDEF(ret, func, args) \ + ret (* func) XVT_CC_ARGS(args) diff --git a/xvaga/xvt_type.h b/xvaga/xvt_type.h index 817e99d72..a80eddfd5 100755 --- a/xvaga/xvt_type.h +++ b/xvaga/xvt_type.h @@ -224,10 +224,13 @@ WC_CHECKBUTTON, /* check button control */ WC_LISTEDIT, /* edit with field list */ WC_GROUPBOX, /* group box */ WC_TEXTEDIT, /* text edit object */ -WC_ICON, /* icon control */ -WO_TE, /* text edit */ +WC_ICON, /* icon control */ +WO_TE, /* text edit */ WC_HGAUGE, /* horizontal progress bar */ WC_VGAUGE, /* vertical progress bar */ +WC_NOTEBK, /* notebook control */ +WC_HTML, /* HTML control */ +WC_TREE, /* tree view */ } WIN_TYPE; typedef enum { @@ -246,6 +249,20 @@ HVGAUGE /* progress bar */ } SCROLL_TYPE; +/* Treeview - Types */ + +typedef void * XVT_TREEVIEW_NODE; + +typedef enum e_treeview_node_type { + XVT_TREEVIEW_NODE_TERMINAL, /* leaf - no children */ + XVT_TREEVIEW_NODE_NONTERMINAL, /* branch - may have children */ + XVT_ENUM_DUMMY26 = XVT_CC_ENUM_END +} XVT_TREEVIEW_NODE_TYPE; + +typedef XVT_CALLCONV_TYPEDEF( BOOLEAN, XVT_TREEVIEW_CALLBACK, + (WINDOW ctl_win, XVT_TREEVIEW_NODE node) ); + + typedef struct s_ctlinfo { WIN_TYPE type; @@ -275,6 +292,27 @@ BOOLEAN focus_change; BOOLEAN active; } listedit; +struct s_notebk { + + WINDOW face; + short tab_no; + short page_no; + +} notebk; +struct s_html { + + int reserved; /* Reserved...no usage yet.*/ + +} html; +struct s_treeview { + + XVT_TREEVIEW_NODE node; /* Node */ + BOOLEAN sgl_click; /* Single click */ + BOOLEAN dbl_click; /* Double click */ + BOOLEAN expanded; /* Node was expanded */ + BOOLEAN collapsed; /* Node was collapsed */ + +} treeview; } v; diff --git a/xvaga/xvtextra.cpp b/xvaga/xvtextra.cpp index 0aa845952..27cb7b525 100755 --- a/xvaga/xvtextra.cpp +++ b/xvaga/xvtextra.cpp @@ -15,8 +15,8 @@ #include "incstr.h" #endif -#include "xvintern.h" #include "xvtpdf.h" +#include "xvtwin.h" #pragma pack(4) @@ -368,7 +368,6 @@ TwxPrintOutCache::~TwxPrintOutCache() // Reset(); // Essendo un oggetto statico la delete m_po non funziona! } - /////////////////////////////////////////////////////////// // TPrintDC ///////////////////////////////////////////////////////////