Patch level : 10.0

Files correlati     : ba0
Ricompilazione Demo : [ ]
Commento            :
Gestione salvataggio e ripristino del layout dei pannelli


git-svn-id: svn://10.65.10.50/trunk@17279 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2008-09-19 15:34:00 +00:00
parent 1e0c3c8b80
commit 3f66b6a994
6 changed files with 191 additions and 94 deletions

View File

@ -319,12 +319,10 @@ void OsLinux_SetCaptionStyle(wxWindow * w, long style)
int OsLinux_GetSessionId()
{
char s[80];
strcpy(s, getenv("DISPLAY"));
char * p = strchr(s, ':');
char s[256];
wxStrncpy(s, wxGetEnv("DISPLAY"), sizeof(s));
char* p = strchr(s, ':');
if (p == NULL)
p = s;
else

View File

@ -192,14 +192,14 @@ void xvt_sys_sorry_box(const char* func, const char* file, int line)
}
}
void xvt_sys_deprecated_box(const char* file, int line)
void xvt_sys_deprecated_box(const char* func, const char* file, int line)
{
static wxHashTable deprecated;
wxString strKey; strKey << file << ':' << line;
if (deprecated.Get(strKey) == NULL)
{
deprecated.Put(strKey, &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);
const wxString strMessage = wxString::Format("Function %s in file %s at line %d is deprecated:\nYou can blame Guy for this, if you're bold enough!", func, file, line);
_MessageBox(strMessage, wxOK | wxICON_WARNING);
}
}
@ -2591,9 +2591,9 @@ DATA_PTR xvt_mem_zalloc(size_t size)
static int xvt_menu_count(const MENU_ITEM* m)
{
int n;
for (n = 0; m[n].tag != 0; n++);
int n = 0;
if (m != NULL)
for (n = 0; m[n].tag != 0; n++);
return n;
}
@ -2601,7 +2601,7 @@ static int xvt_menu_count(const MENU_ITEM* m)
MENU_ITEM* xvt_menu_duplicate_tree(const MENU_ITEM* m)
{
MENU_ITEM* TheMenu = NULL;
if (m != NULL && m->tag > 0)
if (m != NULL && m->tag != 0)
{
const int n = xvt_menu_count(m)+1;
TheMenu = (MENU_ITEM*)xvt_mem_zalloc(sizeof(MENU_ITEM)*n);
@ -2638,29 +2638,30 @@ BOOLEAN xvt_menu_popup(MENU_ITEM *menu_p, WINDOW win, PNT pos,
wxMenu menu;
for (MENU_ITEM* mi = menu_p; mi != NULL && mi->tag != 0; mi++)
{
wxMenuItem* item = NULL;
if (mi->separator)
menu.AppendSeparator();
else
{
if (mi->checkable)
wxMenuItem* item = NULL;
if (mi->checkable)
item = menu.AppendCheckItem(mi->tag, mi->text);
else
item = menu.Append(mi->tag, mi->text);
}
if (item != NULL) // Non e' un sepatatore
{
item->Enable(mi->enabled); // Fattibile solo dopo l'append
if (mi->checkable)
item->Check(mi->checked);
}
}
CAST_WIN(win, w);
bool ok = w.PopupMenu(&menu, pos.h, pos.v);
return ok;
wxPoint mp = wxDefaultPosition;
if (pos.h >= 0 && pos.v >= 0)
{
mp.x = pos.h;
mp.y = pos.v;
}
CAST_WIN(win, w);
return w.PopupMenu(&menu, mp);
}
static void TranslateMenu(wxMenu* pMenu, TRANSLATE_CALLBACK tc)
@ -3804,12 +3805,28 @@ void xvt_sys_sleep(unsigned long msec)
// XVT system calls (added by Alex)
///////////////////////////////////////////////////////////
XVTDLL BOOLEAN xvt_sys_get_env(const char* varname, char* value, int max_size)
{
const wxString strName(varname);
wxString strValue;
const BOOLEAN ok = wxGetEnv(strName, &strValue);
if (ok)
wxStrncpy(value, strValue, max_size);
return ok;
}
void xvt_sys_searchenv(const char * filename, const char * varname, char * pathname)
{
DEPRECATED_BOX();
xvt_sys_search_env(filename, varname, pathname);
}
void xvt_sys_search_env(const char * filename, const char * varname, char * pathname)
{
#ifdef WIN32
_searchenv(filename, varname, pathname);
#else
const char * value = getenv(varname);
const char * value = wxGetEnv(varname);
if (value)
{
char path_list[4096];
@ -3833,6 +3850,12 @@ void xvt_sys_searchenv(const char * filename, const char * varname, char * pathn
#endif
}
BOOLEAN xvt_sys_set_env(const char* varname, const char* value)
{
const wxString strName(varname);
return value != NULL ? wxSetEnv(strName, value) : wxUnsetEnv(strName);
}
// BOOLEAN o int? Adso!
int xvt_fsys_access(const char *pathname, int mode)
{
@ -3907,13 +3930,24 @@ void xvt_timer_destroy(long id)
// Visual objects
///////////////////////////////////////////////////////////
void xvt_vobj_destroy(WINDOW win)
static wxWindow* SafeCastWin(WINDOW win)
{
wxWindow* w = wxDynamicCast(_nice_windows.Get(win), wxWindow);
if (w != NULL)
{
wxASSERT(win == (WINDOW)w);
const TwxWindow* tw = wxDynamicCast(w, TwxWindow);
if (tw != NULL && tw->InDestroy())
w = NULL;
}
return w;
}
void xvt_vobj_destroy(WINDOW win)
{
wxWindow* w = SafeCastWin(win);
if (w != NULL)
{
xvt_win_set_caret_visible(win, FALSE);
w->Destroy(); // same as delete w
@ -4009,14 +4043,10 @@ long xvt_vobj_get_attr(WINDOW win, long data)
SORRY_BOX(); // Obsoleto e non piu' usato
break;
case ATTR_NATIVE_WINDOW:
if (_nice_windows.Get(win) != NULL)
{
#ifdef WIN32
CAST_WIN(win, w);
ret = (long)w.GetHandle();
#else
ret = win;
#endif
const wxWindow* w = SafeCastWin(win);
if (w != NULL)
ret = (long)w->GetHandle();
}
break;
case ATTR_SCREEN_HEIGHT:
@ -4095,7 +4125,7 @@ RCT* xvt_vobj_get_client_rect(WINDOW win, RCT *rctp)
long xvt_vobj_get_data(WINDOW win)
{
const TwxWindow* w = wxDynamicCast(_nice_windows.Get(win), TwxWindow);
const TwxWindow* w = wxDynamicCast(SafeCastWin(win), TwxWindow);
return w != NULL ? w->_app_data : 0L;
}
@ -4510,7 +4540,7 @@ WINDOW statbar_create(int cid, int left, int top, int right, int bottom,
int parent_rid, long parent_flags, char *parent_class)
{
wxStatusBar* pStatusBar = NULL;
wxFrame* w = wxDynamicCast(_nice_windows.Get(parent_win), wxFrame);
wxFrame* w = wxDynamicCast(SafeCastWin(parent_win), wxFrame);
if (w != NULL)
{
const int nStyle = 0; // not wxST_SIZEGRIP
@ -4518,7 +4548,7 @@ WINDOW statbar_create(int cid, int left, int top, int right, int bottom,
if (pStatusBar != NULL)
{
const wxSize sz = pStatusBar->GetSize();
const int widths[4] = { -1, sz.x/4, sz.x/4, 0 };
const int widths[4] = { -4, -3, -2, 0 };
pStatusBar->SetStatusWidths(3, widths);
}
}

View File

@ -364,6 +364,7 @@ XVTDLL BOOLEAN xvt_sys_get_user_name(char* name, int maxlen);
XVTDLL BOOLEAN xvt_sys_goto_url(const char* url, const char* action);
XVTDLL BOOLEAN xvt_sys_dongle_server_is_running();
XVTDLL BOOLEAN xvt_sys_find_editor(const char* file, char* editor);
XVTDLL BOOLEAN xvt_sys_get_env(const char* varname, char* value, int max_size);
XVTDLL int xvt_sys_get_profile_string(const char* file, const char* paragraph, const char* name,
const char* defval, char* value, int maxsize);
XVTDLL BOOLEAN xvt_sys_set_profile_string(const char* file, const char* paragraph, const char* name,
@ -376,9 +377,11 @@ XVTDLL int xvt_sys_get_version(char* os_version, char* ptk_version, in
XVTDLL unsigned int xvt_sys_load_icon(const char* file);
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_search_env(const char* filename, const char* varname, char* pathname);
XVTDLL void xvt_sys_searchenv(const char * filename, const char * varname, char * pathname); // DEPRECATED!
XVTDLL BOOLEAN xvt_sys_set_env(const char* varname, const char* value);
XVTDLL void xvt_sys_sorry_box(const char* func, const char* file, int line);
XVTDLL void xvt_sys_deprecated_box(const char * file, int line);
XVTDLL void xvt_sys_deprecated_box(const char* file, int line);
XVTDLL struct tm* xvt_time_now();
XVTDLL long xvt_timer_create(WINDOW win, long interval);
@ -425,7 +428,9 @@ XVTDLL void xvt_win_trap_pointer(WINDOW win);
XVTDLL BOOLEAN xvt_pane_add(WINDOW parent, WINDOW pane, const char* name, int dock, int flags);
XVTDLL BOOLEAN xvt_pane_change_flags(WINDOW pane, int set, int reset);
XVTDLL BOOLEAN xvt_pane_detach(WINDOW pane);
XVTDLL BOOLEAN xvt_pane_set_size_range(WINDOW pane, int min_size, int max_size);
XVTDLL BOOLEAN xvt_pane_manager_load_perspective(WINDOW win, const char* str);
XVTDLL int xvt_pane_manager_save_perspective(WINDOW win, char* str, int max_size);
XVTDLL BOOLEAN xvt_pane_set_size_range(WINDOW pane, int min_size, int best_size, int max_size);
XVTDLL BOOLEAN xvt_pane_set_title(WINDOW pane, const char* title);
typedef int ODBC_CALLBACK(void*,int,char**, char**);
@ -445,10 +450,10 @@ XVTDLL int xvt_net_get_status();
#define SORRY_BOX() xvt_sys_sorry_box(__FUNCTION__, __FILE__, __LINE__)
#ifndef NDEBUG
#define DEPRECATED_BOX() xvt_sys_deprecated_box(__FILE__, __LINE__)
#else
#ifdef NDEBUG
#define DEPRECATED_BOX()
#else
#define DEPRECATED_BOX() xvt_sys_deprecated_box(__FUNCTION__, __FILE__, __LINE__)
#endif
#endif

View File

@ -129,6 +129,7 @@ protected:
void OnCollapsed(wxTreeEvent& e); // Called when node is collapsed
void OnSelected(wxTreeEvent& e); // Calls OnClick(e, false)
void OnActivated(wxTreeEvent& e); // Calls OnClick(e, true)
void OnRightDown(wxMouseEvent& e);
public:
void SetNodeImages(const wxTreeItemId& id, XVT_IMAGE item_image,
@ -335,31 +336,34 @@ void xvt_btn_set_images(WINDOW win, XVT_IMAGE up, XVT_IMAGE down)
// Pane interface
///////////////////////////////////////////////////////////
static wxAuiPaneInfo* LockPane(WINDOW win)
static wxAuiManager* FindPaneManager(WINDOW win)
{
wxAuiManager* pManager = NULL;
if (win != NULL_WIN)
{
wxWindow* pwin = wxStaticCast((wxObject*)win, wxWindow);
wxAuiManager* pManager = wxAuiManager::GetManager(pwin);
if (pManager != NULL)
{
wxAuiPaneInfo& pane = pManager->GetPane(pwin);
if (pane.IsOk())
return &pane;
}
pManager = wxAuiManager::GetManager(pwin);
}
return pManager;
}
static wxAuiPaneInfo* LockPane(WINDOW win)
{
wxAuiManager* pManager = FindPaneManager(win);
if (pManager != NULL)
{
wxAuiPaneInfo& pane = pManager->GetPane((wxWindow*)win);
if (pane.IsOk())
return &pane;
}
return NULL;
}
static void UnlockPane(WINDOW win)
{
if (win != NULL_WIN)
{
wxWindow* pwin = wxStaticCast((wxObject*)win, wxWindow);
wxAuiManager* pManager = wxAuiManager::GetManager(pwin);
if (pManager != NULL)
pManager->Update();
}
wxAuiManager* pManager = FindPaneManager(win);
if (pManager != NULL)
pManager->Update();
}
BOOLEAN xvt_pane_add(WINDOW win, WINDOW pane, const char* name, int dock, int flags)
@ -400,20 +404,46 @@ XVTDLL BOOLEAN xvt_pane_change_flags(WINDOW win, int set, int rst)
XVTDLL BOOLEAN xvt_pane_detach(WINDOW win)
{
BOOLEAN ok = FALSE;
if (win != NULL_WIN)
wxAuiManager* pManager = FindPaneManager(win);
if (pManager != NULL)
{
wxWindow* pwin = wxStaticCast((wxObject*)win, wxWindow);
wxAuiManager* pManager = wxAuiManager::GetManager(pwin);
ok = pManager->DetachPane((wxWindow*)win);
pManager->Update();
}
return ok;
}
XVTDLL BOOLEAN xvt_pane_manager_load_perspective(WINDOW win, const char* perspective)
{
BOOLEAN ok = FALSE;
if (perspective && *perspective)
{
wxAuiManager* pManager = FindPaneManager(win);
if (pManager != NULL)
{
ok = pManager->DetachPane(pwin);
pManager->Update();
const wxString str = perspective;
ok = pManager->LoadPerspective(str, true);
}
}
return ok;
}
XVTDLL BOOLEAN xvt_pane_set_size_range(WINDOW win, int min_size, int max_size)
XVTDLL int xvt_pane_manager_save_perspective(WINDOW win, char* perspective, int max_size)
{
int nSize = 0;
wxAuiManager* pManager = FindPaneManager(win);
if (pManager != NULL)
{
const wxString str = pManager->SavePerspective();
nSize = str.Len()+1;
if (perspective != NULL && max_size > 0)
wxStrncpy(perspective, str, max_size);
}
return nSize;
}
XVTDLL BOOLEAN xvt_pane_set_size_range(WINDOW win, int min_size, int best_size, int max_size)
{
BOOLEAN ok = FALSE;
wxAuiPaneInfo* pane = LockPane(win);
@ -421,19 +451,28 @@ XVTDLL BOOLEAN xvt_pane_set_size_range(WINDOW win, int min_size, int max_size)
{
if (min_size > 0 || max_size > 0)
{
wxSize szMin(-1, -1), szMax(-1, -1);
if (best_size <= 0)
{
if (min_size > 0)
best_size = max_size > 0 ? (min_size+max_size) / 2 : min_size;
else
best_size = max_size;
}
wxSize szMin(-1, -1), szBst(-1, -1), szMax(-1, -1);
if (pane->IsTopDockable() || pane->IsBottomDockable())
{
szMin.y = min_size;
szBst.y = best_size;
szMax.y = max_size;
}
else
{
szMin.x = min_size;
szBst.x = best_size;
szMax.x = max_size;
}
pane->MinSize(szMin);
pane->BestSize(szMin);
pane->BestSize(szBst);
pane->MaxSize(szMax);
}
pane->Resizable(min_size != max_size);
@ -679,6 +718,7 @@ BEGIN_EVENT_TABLE(TwxTreeCtrl, wxTreeCtrl)
EVT_TREE_ITEM_COLLAPSED(wxID_ANY, TwxTreeCtrl::OnCollapsed)
EVT_TREE_SEL_CHANGED(wxID_ANY, TwxTreeCtrl::OnSelected)
EVT_TREE_ITEM_ACTIVATED(wxID_ANY, TwxTreeCtrl::OnActivated)
EVT_RIGHT_DOWN(TwxTreeCtrl::OnRightDown)
END_EVENT_TABLE();
#define CAST_TREEVIEW(win, tv) TwxTreeCtrl& tv = *wxStaticCast((wxObject*)win, TwxTreeCtrl);
@ -754,6 +794,22 @@ void TwxTreeCtrl::OnSelected(wxTreeEvent& evt)
void TwxTreeCtrl::OnActivated(wxTreeEvent& evt)
{ OnClick(evt, true); }
void TwxTreeCtrl::OnRightDown(wxMouseEvent& evt)
{
TwxWindow* pParent = wxDynamicCast(GetParent(), TwxWindow);
if (pParent != NULL)
{
EVENT e; memset(&e, 0, sizeof(EVENT));
e.type = E_MOUSE_DOWN;
e.v.mouse.button = 1;
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();
pParent->DoXvtEvent(e);
}
}
int TwxTreeCtrl::img2int(XVT_IMAGE xvt_img)
{
int i = -1;

View File

@ -880,13 +880,15 @@ BOOLEAN TwxWindow::AddPane(wxWindow* wnd, const char* caption, int nDock, int nF
switch (nDock)
{
case 1: // Left
pane.Left().Floatable(true).LeftDockable().RightDockable().MinSize(sz.x/2, -1);
pane.Left().Floatable(true).LeftDockable().RightDockable();
pane.MinSize(sz.x/2, -1).BestSize(sz.x, -1).MaxSize(3*sz.x/2, -1);
break;
case 2: // Top
pane.Top().Floatable(true).TopDockable().BottomDockable().MinSize(-1, sz.y/2);
break;
case 3: // Right
pane.Right().Floatable(true).LeftDockable().RightDockable().MinSize(sz.x/2, -1);
pane.Right().Floatable(true).LeftDockable().RightDockable();
pane.MinSize(sz.x/2, -1).BestSize(sz.x, -1).MaxSize(3*sz.x/2, -1);
break;
case 4: // Bottom
pane.Bottom().Floatable(true).TopDockable().BottomDockable().MinSize(-1, sz.y/2);
@ -928,44 +930,48 @@ TwxWindow::TwxWindow()
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), _app_data(0L), _timer(NULL), m_pManager(NULL)
m_menu(NULL), _eh(NULL), _app_data(0L), _timer(NULL),
m_pManager(NULL), m_bInDestroy(false)
{
_nice_windows.Put((WINDOW)this, this);
}
TwxWindow::~TwxWindow()
{
_nice_windows.Delete((WINDOW)this);
EVENT e; memset(&e, 0, sizeof(EVENT));
e.type = E_DESTROY;
DoXvtEvent(e);
// Rendo praticamente impossibile risalire a questo oggetto d'ora in poi
_eh = NULL;
_app_data = 0L;
if (HasCapture())
if (!m_bInDestroy) // Controllo di non essere RIchiamato dalla gestione di E_DESTROY
{
ReleaseMouse();
xvt_win_release_pointer(); // Paranoid?
}
if (_timer != NULL)
delete _timer;
m_bInDestroy = true;
EVENT e; memset(&e, 0, sizeof(EVENT));
e.type = E_DESTROY;
DoXvtEvent(e);
if (m_pManager != NULL)
{
m_pManager->UnInit(); // Obbligatorio ma, chissa' perche', non gestito dal distruttore!
delete m_pManager;
}
// Rendo praticamente impossibile risalire a questo oggetto d'ora in poi
_nice_windows.Delete((WINDOW)this);
_eh = NULL;
_app_data = 0L;
if (m_menu)
{
xvt_res_free_menu_tree(m_menu);
m_menu = NULL;
((TTaskWin*)_task_win)->PopMenuTree();
}
if (HasCapture())
{
ReleaseMouse();
xvt_win_release_pointer(); // Paranoid?
}
if (_timer != NULL)
delete _timer;
if (m_pManager != NULL)
{
m_pManager->UnInit(); // Obbligatorio ma, chissa' perche', non gestito dal distruttore!
delete m_pManager;
}
if (m_menu)
{
xvt_res_free_menu_tree(m_menu);
m_menu = NULL;
((TTaskWin*)_task_win)->PopMenuTree();
}
}
}
///////////////////////////////////////////////////////////

View File

@ -136,6 +136,7 @@ class TwxWindow : public TwxWindowBase
private:
MENU_ITEM* m_menu;
wxAuiManager* m_pManager;
bool m_bInDestroy;
protected:
virtual void OnChar(wxKeyEvent& e);
@ -161,6 +162,7 @@ protected:
public:
void DoXvtEvent(EVENT& e);
virtual void OnPaint(wxPaintEvent& e);
virtual bool InDestroy() const { return m_bInDestroy; }
public:
WIN_TYPE _type;