Patch level : 10.0

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :
Slider controls


git-svn-id: svn://10.65.10.50/trunk@16634 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2008-05-20 14:06:05 +00:00
parent da1d0a937b
commit a6f0eea254
7 changed files with 213 additions and 111 deletions

View File

@ -1,6 +1,6 @@
/* STATBAR.H for dynamic custom control for XVT/Design 2.01 /* STATBAR.H for dynamic custom control for XVT/Design 2.01
$Revision: 1.4 $ $Author: guy $ $Date: 2008-04-04 16:04:47 $ $Revision: 1.5 $ $Author: guy $ $Date: 2008-05-20 14:06:05 $
This code was written by Christopher Williamson, This code was written by Christopher Williamson,
May be distributed in object form only when embedded in a May be distributed in object form only when embedded in a
@ -48,9 +48,10 @@ XVTDLL BOOLEAN xvt_toolbar_add_control(WINDOW win, int cid, TOOL_TYPE type, cons
int ico, int cust_width, int idx); int ico, int cust_width, int idx);
XVTDLL WINDOW xvt_toolbar_create(int cid, int left, int top, int right, int bottom, XVTDLL WINDOW xvt_toolbar_create(int cid, int left, int top, int right, int bottom,
long style, WINDOW parent_win); long style, WINDOW parent_win);
XVTDLL void xvt_toolbar_enable_control(WINDOW win, int cid, BOOLEAN on); XVTDLL void xvt_toolbar_enable_control(WINDOW win, int cid, BOOLEAN on);
XVTDLL void xvt_toolbar_realize(WINDOW win); XVTDLL void xvt_toolbar_realize(WINDOW win);
XVTDLL void xvt_toolbar_show_control(WINDOW win, int cid, BOOLEAN on); XVTDLL BOOLEAN xvt_toolbar_set_last_tool(WINDOW win, int cid);
XVTDLL void xvt_toolbar_show_control(WINDOW win, int cid, BOOLEAN on);
#if defined(_cplusplus) || defined(__cplusplus) #if defined(_cplusplus) || defined(__cplusplus)
} /* extern "C" */ } /* extern "C" */

View File

@ -406,7 +406,6 @@ void xvt_app_allow_quit(void)
void xvt_app_create(int argc, char **argv, unsigned long flags, void xvt_app_create(int argc, char **argv, unsigned long flags,
EVENT_HANDLER eh, XVT_CONFIG *config) EVENT_HANDLER eh, XVT_CONFIG *config)
{ {
::wxInitAllImageHandlers();
xvt_fsys_get_default_dir(NULL); // Init Startup Directory xvt_fsys_get_default_dir(NULL); // Init Startup Directory
#ifdef SPEECH_API #ifdef SPEECH_API
@ -2974,9 +2973,11 @@ char* xvt_res_get_str(int rid, char *s, int sz_s)
#define CAST_SCROLL(win, sb) XVT_ASSERT(win != NULL_WIN); wxScrollBar& sb = *(wxScrollBar*)win; #define CAST_SCROLL(win, sb) XVT_ASSERT(win != NULL_WIN); wxScrollBar& sb = *(wxScrollBar*)win;
#define CAST_SCROLL_TYPE(t, dir) const int dir = t == HSCROLL ? wxHORIZONTAL : wxVERTICAL; #define CAST_SCROLL_TYPE(t, dir) const int dir = t == HSCROLL ? wxHORIZONTAL : wxVERTICAL;
#define CAST_GAUGE(win, pb) XVT_ASSERT(win != NULL_WIN); wxGauge& pb = *(wxGauge*)win; #define CAST_GAUGE(win, pb) XVT_ASSERT(win != NULL_WIN); wxGauge& pb = *(wxGauge*)win;
#define CAST_SLIDER(win, sc) XVT_ASSERT(win != NULL_WIN); wxSlider& sc = *(wxSlider*)win;
int xvt_sbar_get_pos(WINDOW win, SCROLL_TYPE t) int xvt_sbar_get_pos(WINDOW win, SCROLL_TYPE t)
{ {
int pos = 0;
switch (t) switch (t)
{ {
case HSCROLL: case HSCROLL:
@ -2984,55 +2985,86 @@ int xvt_sbar_get_pos(WINDOW win, SCROLL_TYPE t)
{ {
CAST_WIN(win, w); CAST_WIN(win, w);
CAST_SCROLL_TYPE(t, dir); CAST_SCROLL_TYPE(t, dir);
return w.GetScrollPos(dir); pos = w.GetScrollPos(dir);
} }
break;
case HVGAUGE: case HVGAUGE:
{ {
CAST_GAUGE(win, g); CAST_GAUGE(win, g);
return g.GetValue(); pos = g.GetValue();
} }
break;
case HVSLIDER:
{
CAST_SLIDER(win, g);
pos = g.GetValue();
}
break;
default: default:
{ {
CAST_SCROLL(win, sb); CAST_SCROLL(win, sb);
return sb.GetThumbPosition(); pos = sb.GetThumbPosition();
} }
break;
} }
return pos;
} }
int xvt_sbar_get_proportion(WINDOW win, SCROLL_TYPE t) int xvt_sbar_get_proportion(WINDOW win, SCROLL_TYPE t)
{ {
if (t == HSCROLL || t == VSCROLL) int p = 1;
{ switch (t)
CAST_WIN(win, w); {
CAST_SCROLL_TYPE(t, dir); case HSCROLL:
return w.GetScrollThumb(dir); case VSCROLL:
} {
CAST_SCROLL(win, sb); CAST_WIN(win, w);
return sb.GetThumbSize(); CAST_SCROLL_TYPE(t, dir);
p = w.GetScrollThumb(dir);
}
break;
case HVSLIDER:
{
CAST_SLIDER(win, sc);
p = sc.GetPageSize();
}
break;
default:
{
CAST_SCROLL(win, sb);
p = sb.GetThumbSize();
}
break;
}
return p;
} }
void xvt_sbar_get_range(WINDOW win, SCROLL_TYPE t, int *minp, int *maxp) void xvt_sbar_get_range(WINDOW win, SCROLL_TYPE t, int *minp, int *maxp)
{ {
*minp = 0; *minp = 0;
if (t == HSCROLL || t == VSCROLL) switch (t)
{ {
CAST_WIN(win, w); case HSCROLL:
CAST_SCROLL_TYPE(t, dir); case VSCROLL:
*maxp = w.GetScrollRange(dir); {
} CAST_WIN(win, w);
else CAST_SCROLL_TYPE(t, dir);
{ *maxp = w.GetScrollRange(dir);
if (t == HVGAUGE) }
break;
case HVGAUGE:
{ {
CAST_GAUGE(win, g); CAST_GAUGE(win, g);
*maxp = g.GetRange(); *maxp = g.GetRange();
} }
else break;
default:
{ {
CAST_SCROLL(win, sb); CAST_SCROLL(win, sb);
*maxp = sb.GetRange(); *maxp = sb.GetRange();
} }
} break;
}
} }
void xvt_sbar_set_pos(WINDOW win, SCROLL_TYPE t, int pos) void xvt_sbar_set_pos(WINDOW win, SCROLL_TYPE t, int pos)
@ -3050,13 +3082,18 @@ void xvt_sbar_set_pos(WINDOW win, SCROLL_TYPE t, int pos)
case HVGAUGE: case HVGAUGE:
{ {
CAST_GAUGE(win, g); CAST_GAUGE(win, g);
if (g.GetRange() <= 1) if (g.GetRange() <= 1)
g.Pulse(); g.Pulse();
else else
g.SetValue(pos); g.SetValue(pos);
} }
break; break;
case HVSLIDER:
{
CAST_SLIDER(win, g);
g.SetValue(pos);
}
break;
default: default:
{ {
CAST_SCROLL(win, sb); CAST_SCROLL(win, sb);
@ -3064,26 +3101,40 @@ void xvt_sbar_set_pos(WINDOW win, SCROLL_TYPE t, int pos)
const int size = sb.GetThumbSize(); const int size = sb.GetThumbSize();
sb.SetScrollbar(pos, size, range, size); sb.SetScrollbar(pos, size, range, size);
} }
break;
} }
} }
void xvt_sbar_set_proportion(WINDOW win, SCROLL_TYPE t, int proportion) void xvt_sbar_set_proportion(WINDOW win, SCROLL_TYPE t, int proportion)
{ {
if (t == HSCROLL || t == VSCROLL) switch (t)
{ {
CAST_WIN(win, w); case HSCROLL:
CAST_SCROLL_TYPE(t, dir); case VSCROLL:
const int pos = w.GetScrollPos(dir); {
const int range = w.GetScrollRange(dir); CAST_WIN(win, w);
w.SetScrollbar(dir, pos, proportion, range); CAST_SCROLL_TYPE(t, dir);
} const int pos = w.GetScrollPos(dir);
else const int range = w.GetScrollRange(dir);
{ w.SetScrollbar(dir, pos, proportion, range);
CAST_SCROLL(win, sb); }
const int pos = sb.GetThumbPosition(); break;
const int range = sb.GetRange(); case HVSLIDER:
sb.SetScrollbar(pos, proportion, range, proportion); {
} CAST_SLIDER(win, sc);
sc.SetPageSize(proportion);
sc.SetTickFreq(sc.GetMax()/proportion, 0);
}
break;
default:
{
CAST_SCROLL(win, sb);
const int pos = sb.GetThumbPosition();
const int range = sb.GetRange();
sb.SetScrollbar(pos, proportion, range, proportion);
}
break;
}
} }
void xvt_sbar_set_range(WINDOW win, SCROLL_TYPE t, int min, int max) void xvt_sbar_set_range(WINDOW win, SCROLL_TYPE t, int min, int max)
@ -3107,6 +3158,12 @@ void xvt_sbar_set_range(WINDOW win, SCROLL_TYPE t, int min, int max)
g.SetRange(max); g.SetRange(max);
} }
break; break;
case HVSLIDER:
{
CAST_SLIDER(win, g);
g.SetRange(min, max);
}
break;
default: default:
{ {
CAST_SCROLL(win, sb); CAST_SCROLL(win, sb);
@ -3784,6 +3841,11 @@ BOOLEAN xvt_fsys_removefile(const char *pathname)
// Timers // Timers
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
struct tm* xvt_time_now()
{
return wxDateTime::GetTmNow();
}
long xvt_timer_create(WINDOW win, long interval) long xvt_timer_create(WINDOW win, long interval)
{ {
CAST_TWIN(win, w); CAST_TWIN(win, w);
@ -3853,18 +3915,20 @@ long xvt_vobj_get_attr(WINDOW win, long data)
xcc[4].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)); xcc[4].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
xcc[5].type = XVT_COLOR_HIGHLIGHT; xcc[5].type = XVT_COLOR_HIGHLIGHT;
xcc[5].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT)); xcc[5].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
xcc[6].type = XVT_COLOR_TROUGH;
xcc[6].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
// AGA components // AGA components
xcc[6].type = XVT_COLOR_CAPTIONLT; xcc[7].type = XVT_COLOR_CAPTIONLT;
xcc[6].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION)); xcc[7].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION));
xcc[7].type = XVT_COLOR_CAPTIONDK; xcc[8].type = XVT_COLOR_CAPTIONDK;
xcc[7].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_INACTIVECAPTION)); xcc[8].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_INACTIVECAPTION));
xcc[8].type = XVT_COLOR_CAPTIONTEXT; xcc[9].type = XVT_COLOR_CAPTIONTEXT;
xcc[8].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT)); xcc[9].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT));
// Last (NULL) component // Last (NULL) component
xcc[9].type = XVT_COLOR_NULL; xcc[10].type = XVT_COLOR_NULL;
xcc[9].color = 0; xcc[10].color = 0;
ret = (long)xcc; ret = (long)xcc;
} }

View File

@ -42,6 +42,7 @@ bool TMainApp::OnInit()
const wxString strApp = strWrk.GetName().Lower(); const wxString strApp = strWrk.GetName().Lower();
m_sic = new wxSingleInstanceChecker(strApp); m_sic = new wxSingleInstanceChecker(strApp);
::wxInitAllImageHandlers();
m_Locale.Init(wxLocale::GetSystemLanguage()); // wxLANGUAGE_ITALIAN m_Locale.Init(wxLocale::GetSystemLanguage()); // wxLANGUAGE_ITALIAN
if (GetComCtl32Version() >= 600 && ::wxDisplayDepth() >= 32) if (GetComCtl32Version() >= 600 && ::wxDisplayDepth() >= 32)

View File

@ -106,6 +106,7 @@ XVTDLL void xvt_dwin_draw_polyline(WINDOW win, const PNT *lpnts, int np
XVTDLL void xvt_dwin_draw_rect(WINDOW win, RCT *rctp); XVTDLL void xvt_dwin_draw_rect(WINDOW win, RCT *rctp);
XVTDLL void xvt_dwin_draw_roundrect(WINDOW win, const RCT *rctp, int oval_width, int oval_height); XVTDLL void xvt_dwin_draw_roundrect(WINDOW win, const RCT *rctp, int oval_width, int oval_height);
XVTDLL void xvt_dwin_draw_dotted_rect(WINDOW win, RCT *rctp); // Added by Guy XVTDLL void xvt_dwin_draw_dotted_rect(WINDOW win, RCT *rctp); // Added by Guy
XVTDLL void xvt_dwin_draw_tool(WINDOW win, int x, int y, int rid, int size); // Added by Guy
XVTDLL void xvt_dwin_draw_set_pos(WINDOW win, PNT pnt); XVTDLL void xvt_dwin_draw_set_pos(WINDOW win, PNT pnt);
XVTDLL void xvt_dwin_draw_text(WINDOW win, int x, int y, const char *s, int len); XVTDLL void xvt_dwin_draw_text(WINDOW win, int x, int y, const char *s, int len);
XVTDLL RCT* xvt_dwin_get_clip(WINDOW win, RCT* rct); XVTDLL RCT* xvt_dwin_get_clip(WINDOW win, RCT* rct);
@ -376,8 +377,11 @@ XVTDLL BOOLEAN xvt_sys_test_network_version();
XVTDLL void xvt_sys_searchenv(const char *filename, const char *varname, char *pathname); XVTDLL void xvt_sys_searchenv(const char *filename, const char *varname, char *pathname);
XVTDLL void xvt_sys_sorry_box(const char* func, const char* file, int line); 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); XVTDLL long xvt_timer_create(WINDOW win, long interval);
XVTDLL void xvt_timer_destroy(long id); XVTDLL void xvt_timer_destroy(long id);
XVTDLL void xvt_vobj_destroy(WINDOW win); XVTDLL void xvt_vobj_destroy(WINDOW win);
XVTDLL long xvt_vobj_get_attr(WINDOW win, long data); XVTDLL long xvt_vobj_get_attr(WINDOW win, long data);
XVTDLL RCT* xvt_vobj_get_client_rect(WINDOW win, RCT *rctp); XVTDLL RCT* xvt_vobj_get_client_rect(WINDOW win, RCT *rctp);

View File

@ -232,6 +232,8 @@ WC_NOTEBK, /* notebook control */
WC_HTML, /* HTML control */ WC_HTML, /* HTML control */
WC_TREE, /* tree view */ WC_TREE, /* tree view */
WC_OUTLOOKBAR, /* Barra di outlook */ WC_OUTLOOKBAR, /* Barra di outlook */
WC_HSLIDER, /* horizontal slider control */
WC_VSLIDER, /* vertical slider control */
} WIN_TYPE; } WIN_TYPE;
typedef enum { typedef enum {
@ -246,7 +248,8 @@ typedef enum { /* type of scrollbar */
HSCROLL, /* horizontal */ HSCROLL, /* horizontal */
VSCROLL, /* vertical */ VSCROLL, /* vertical */
HVSCROLL, /* either */ HVSCROLL, /* either */
HVGAUGE /* progress bar */ HVGAUGE, /* progress bar */
HVSLIDER, /* slider */
} SCROLL_TYPE; } SCROLL_TYPE;
@ -263,7 +266,6 @@ typedef enum e_treeview_node_type {
typedef XVT_CALLCONV_TYPEDEF( BOOLEAN, XVT_TREEVIEW_CALLBACK, typedef XVT_CALLCONV_TYPEDEF( BOOLEAN, XVT_TREEVIEW_CALLBACK,
(WINDOW ctl_win, XVT_TREEVIEW_NODE node) ); (WINDOW ctl_win, XVT_TREEVIEW_NODE node) );
typedef struct s_ctlinfo { typedef struct s_ctlinfo {
WIN_TYPE type; WIN_TYPE type;

View File

@ -42,8 +42,8 @@ const wxBitmap& _GetToolResource(int nIcon, int nDesiredSize)
{ {
static wxHashTable _tool_icons; static wxHashTable _tool_icons;
if (nDesiredSize <= 0) nDesiredSize = 32; else if (nDesiredSize < 16) nDesiredSize = 16; else
if (nDesiredSize > 512) nDesiredSize = 512; if (nDesiredSize > 128) nDesiredSize = 128;
const long nCode = 1000*nIcon + nDesiredSize; const long nCode = 1000*nIcon + nDesiredSize;
wxBitmap* bmp = (wxBitmap*)_tool_icons.Get(nCode); wxBitmap* bmp = (wxBitmap*)_tool_icons.Get(nCode);
if (bmp == NULL) if (bmp == NULL)
@ -58,10 +58,10 @@ const wxBitmap& _GetToolResource(int nIcon, int nDesiredSize)
{ {
const wxIcon ico(strName, wxBITMAP_TYPE_ICO); const wxIcon ico(strName, wxBITMAP_TYPE_ICO);
bmp = new wxBitmap(ico); bmp = new wxBitmap(ico);
} else }
if (strName.EndsWith(".png")) else
{ {
wxImage img(strName, wxBITMAP_TYPE_PNG); wxImage img(strName, wxBITMAP_TYPE_ANY);
img.Rescale(nDesiredSize, nDesiredSize, wxIMAGE_QUALITY_HIGH); img.Rescale(nDesiredSize, nDesiredSize, wxIMAGE_QUALITY_HIGH);
bmp = new wxBitmap(img); bmp = new wxBitmap(img);
} }
@ -188,11 +188,18 @@ WINDOW xvt_ctl_create_def(WIN_DEF *win_def_p, WINDOW parent_win, long app_data)
case WC_VGAUGE: /* vertical progress bar control */ case WC_VGAUGE: /* vertical progress bar control */
{ {
const long style = (win_def_p->wtype == WC_HGAUGE) ? wxGA_HORIZONTAL : wxGA_VERTICAL; const long style = (win_def_p->wtype == WC_HGAUGE) ? wxGA_HORIZONTAL : wxGA_VERTICAL;
wxGauge* pg = new wxGauge(pParent, id, app_data, wxGauge* pg = new wxGauge(pParent, id, app_data, rct.GetPosition(), rct.GetSize(), style);
rct.GetPosition(), rct.GetSize(), style);
win = (WINDOW)pg; win = (WINDOW)pg;
} }
break; break;
case WC_HSLIDER: /* horizontal slider control */
case WC_VSLIDER: /* vertical slider control */
{
const long style = win_def_p->wtype == WC_HSLIDER ? wxSL_HORIZONTAL : wxSL_VERTICAL;
wxSlider* sc = new wxSlider(pParent, id, 0, 0, app_data, rct.GetPosition(), rct.GetSize(), style);
win = (WINDOW)sc;
}
break;
case WC_PUSHBUTTON: /* bottone normale */ case WC_PUSHBUTTON: /* bottone normale */
{ {
wxButton* pb = NULL; wxButton* pb = NULL;
@ -221,7 +228,7 @@ WINDOW xvt_ctl_create_def(WIN_DEF *win_def_p, WINDOW parent_win, long app_data)
case WC_RADIOBUTTON: /* radio button */ case WC_RADIOBUTTON: /* radio button */
{ {
wxRadioButton* rb = new wxRadioButton(pParent, id, win_def_p->text, wxRadioButton* rb = new wxRadioButton(pParent, id, win_def_p->text,
rct.GetPosition(), rct.GetSize()); rct.GetPosition(), rct.GetSize(), wxRB_SINGLE);
win = (WINDOW)rb; win = (WINDOW)rb;
} }
break; break;
@ -337,7 +344,7 @@ BOOLEAN xvt_pane_add(WINDOW win, WINDOW pane, const char* name, int dock, int fl
return done; return done;
} }
static wxAuiPaneInfo* Win2Pane(WINDOW win) static wxAuiPaneInfo* LockPane(WINDOW win)
{ {
wxWindow* pwin = (wxWindow*)win; wxWindow* pwin = (wxWindow*)win;
wxAuiManager* pManager = wxAuiManager::GetManager(pwin); wxAuiManager* pManager = wxAuiManager::GetManager(pwin);
@ -345,29 +352,38 @@ static wxAuiPaneInfo* Win2Pane(WINDOW win)
{ {
wxAuiPaneInfo& pane = pManager->GetPane(pwin); wxAuiPaneInfo& pane = pManager->GetPane(pwin);
if (pane.IsOk()) if (pane.IsOk())
{
pManager->Update();
return &pane; return &pane;
}
} }
return NULL; return NULL;
} }
static void UnlockPane(WINDOW win)
{
wxWindow* pwin = (wxWindow*)win;
wxAuiManager* pManager = wxAuiManager::GetManager(pwin);
if (pManager != NULL)
pManager->Update();
}
BOOLEAN xvt_pane_set_title(WINDOW win, const char* title) BOOLEAN xvt_pane_set_title(WINDOW win, const char* title)
{ {
wxAuiPaneInfo* pane = Win2Pane(win); wxAuiPaneInfo* pane = LockPane(win);
if (pane != NULL) if (pane != NULL)
{
pane->Caption(title); pane->Caption(title);
UnlockPane(win);
}
return pane != NULL; return pane != NULL;
} }
XVTDLL BOOLEAN xvt_pane_change_flags(WINDOW win, int set, int rst) XVTDLL BOOLEAN xvt_pane_change_flags(WINDOW win, int set, int rst)
{ {
wxAuiPaneInfo* pane = Win2Pane(win); wxAuiPaneInfo* pane = LockPane(win);
if (pane != NULL && (set || rst)) if (pane != NULL && (set || rst))
{ {
if (set) pane->SetFlag(set, true); if (set) pane->SetFlag(set, true);
if (rst) pane->SetFlag(rst, false); if (rst) pane->SetFlag(rst, false);
UnlockPane(win);
} }
return pane != NULL; return pane != NULL;
} }
@ -380,7 +396,10 @@ XVTDLL BOOLEAN xvt_pane_detach(WINDOW win)
wxWindow* pwin = (wxWindow*)win; wxWindow* pwin = (wxWindow*)win;
wxAuiManager* pManager = wxAuiManager::GetManager(pwin); wxAuiManager* pManager = wxAuiManager::GetManager(pwin);
if (pManager != NULL) if (pManager != NULL)
{
ok = pManager->DetachPane(pwin); ok = pManager->DetachPane(pwin);
pManager->Update();
}
} }
return ok; return ok;
} }
@ -639,11 +658,7 @@ int TwxTreeCtrl::img2int(XVT_IMAGE xvt_img)
int i = -1; int i = -1;
if (xvt_img != NULL) if (xvt_img != NULL)
{ {
#if wxCHECK_VERSION(2,8,7)
i = m_img[xvt_img] - 1; // Ho memorizzato indice+1 i = m_img[xvt_img] - 1; // Ho memorizzato indice+1
#else
i = (int)m_img.Get((long)xvt_img) - 1;
#endif
if (i < 0) // Immagine sconosciuta if (i < 0) // Immagine sconosciuta
{ {
const wxImage& img = *(wxImage*)xvt_img; const wxImage& img = *(wxImage*)xvt_img;
@ -678,11 +693,7 @@ int TwxTreeCtrl::img2int(XVT_IMAGE xvt_img)
} }
} }
i = il->Add(wxBitmap(img)); i = il->Add(wxBitmap(img));
#if wxCHECK_VERSION(2,8,7)
m_img[xvt_img] = i+1; // Memorizzo indice+1 m_img[xvt_img] = i+1; // Memorizzo indice+1
#else
m_img.Put((long)xvt_img, (wxObject*)(i+1)); // Memorizzo indice+1
#endif
} }
if (i < 0) if (i < 0)
SORRY_BOX(); SORRY_BOX();
@ -711,11 +722,7 @@ void TwxTreeCtrl::SetNodeImages(const wxTreeItemId& id, XVT_IMAGE item_image,
wxFont TwxTreeCtrl::GetFont() const wxFont TwxTreeCtrl::GetFont() const
{ {
#if wxCHECK_VERSION(2,8,7)
return m_font.IsOk() ? m_font : wxTreeCtrl::GetFont(); return m_font.IsOk() ? m_font : wxTreeCtrl::GetFont();
#else
return wxTreeCtrl::GetFont();
#endif
} }
void TwxTreeCtrl::Suspend() void TwxTreeCtrl::Suspend()
@ -833,13 +840,13 @@ BOOLEAN xvt_treeview_expand_node(WINDOW win, XVT_TREEVIEW_NODE node, BOOLEAN rec
if (ok) if (ok)
{ {
CAST_TREEVIEW(win, tv); CAST_TREEVIEW(win, tv);
tv.Suspend();
const wxTreeItemId id(node); const wxTreeItemId id(node);
#if wxCHECK_VERSION(2,8,7)
if (recurse) if (recurse)
tv.ExpandAllChildren(id); tv.ExpandAllChildren(id);
else else
#endif
tv.Expand(id); tv.Expand(id);
tv.Resume();
} }
return ok; return ok;
} }
@ -902,9 +909,15 @@ void xvt_treeview_select_node(WINDOW win, XVT_TREEVIEW_NODE node, BOOLEAN sel)
{ {
CAST_TREEVIEW(win, tv); CAST_TREEVIEW(win, tv);
const wxTreeItemId id(node); const wxTreeItemId id(node);
tv.SelectItem(id, sel != 0);
if (sel) if (sel)
{
tv.Suspend();
tv.SelectItem(id, true);
tv.EnsureVisible(id); tv.EnsureVisible(id);
tv.Resume();
}
else
tv.SelectItem(id, false);
} }
} }
@ -1198,7 +1211,7 @@ void TwxToolBar::OnTool(wxCommandEvent& evt)
EVENT e; memset(&e, 0, sizeof(EVENT)); EVENT e; memset(&e, 0, sizeof(EVENT));
e.type = E_CONTROL; e.type = E_CONTROL;
e.v.ctl.id = evt.GetId(); e.v.ctl.id = evt.GetId();
e.v.ctl.ci.type = WC_PUSHBUTTON; e.v.ctl.ci.type = WC_ICON; // WC_PUSHBUTTON entra in conflitto coi bottoni
e.v.ctl.ci.win = WINDOW(this); e.v.ctl.ci.win = WINDOW(this);
TwxWindow* win = (TwxWindow*)GetParent(); TwxWindow* win = (TwxWindow*)GetParent();
win->DoXvtEvent(e); win->DoXvtEvent(e);
@ -1229,10 +1242,9 @@ BOOLEAN xvt_toolbar_add_control(WINDOW win, int cid, TOOL_TYPE type, const char
{ {
case TOOL_SEPARATOR: case TOOL_SEPARATOR:
if (idx < 0) if (idx < 0)
tb.AddSeparator(); ok = tb.AddSeparator() != NULL;
else else
tb.InsertSeparator(idx); ok = tb.InsertSeparator(idx) != NULL;
ok = TRUE;
break; break;
default: default:
{ {
@ -1255,8 +1267,8 @@ WINDOW xvt_toolbar_create(int cid, int left, int top, int right, int bottom, lon
{ {
const wxPoint ptPos(left, top); const wxPoint ptPos(left, top);
wxSize szSize(right-left, bottom-top); wxSize szSize(right-left, bottom-top);
nStyle |= wxNO_BORDER | wxTB_FLAT | wxTB_NODIVIDER; nStyle |= wxNO_BORDER | wxTB_NODIVIDER; // wxTB_FLAT non disegna il bordo!
int nIcoSize = 16; int nIcoSize = 24;
if (bottom > 0) if (bottom > 0)
{ {
nStyle |= wxTB_HORIZONTAL; nStyle |= wxTB_HORIZONTAL;
@ -1282,13 +1294,34 @@ void xvt_toolbar_enable_control(WINDOW win, int cid, BOOLEAN on)
ptb->EnableTool(cid, on != 0); ptb->EnableTool(cid, on != 0);
} }
BOOLEAN xvt_toolbar_set_last_tool(WINDOW win, int id)
{
BOOLEAN bMoved = FALSE;
wxToolBar* ptb = Win2Bar(win);
if (ptb != NULL) // Is a valid toolbar?
{
const int pos = ptb->GetToolPos(id);
if (pos >= 0)
{
const int nCount = ptb->GetToolsCount();
if (pos < nCount-1)
{
wxToolBarToolBase* tool = ptb->RemoveTool(id);
ptb->InsertTool(nCount-1, tool);
}
bMoved = TRUE;
}
}
return bMoved;
}
void xvt_toolbar_realize(WINDOW win) void xvt_toolbar_realize(WINDOW win)
{ {
wxToolBar* ptb = Win2Bar(win); wxToolBar* ptb = Win2Bar(win);
if (ptb != NULL) // Is a valid toolbar? if (ptb != NULL) // Is a valid toolbar?
{ {
ptb->Realize(); // Update tools ptb->Realize(); // Update tools
wxAuiPaneInfo* pi = Win2Pane(win); wxAuiPaneInfo* pi = LockPane(win);
if (pi != NULL) if (pi != NULL)
{ {
const wxSize szBar = ptb->GetSize(); const wxSize szBar = ptb->GetSize();
@ -1296,7 +1329,7 @@ void xvt_toolbar_realize(WINDOW win)
{ {
pi->MinSize(szBar); pi->MinSize(szBar);
pi->BestSize(szBar); pi->BestSize(szBar);
Win2Pane(win); // calls wxAuiManager::Update() UnlockPane(win);
} }
} }
} }
@ -1308,3 +1341,13 @@ void xvt_toolbar_show_control(WINDOW win, int cid, BOOLEAN on)
if (ptb != NULL && cid > 0) if (ptb != NULL && cid > 0)
ptb->EnableTool(cid, on != 0); // Per ora non so come si faccia ptb->EnableTool(cid, on != 0); // Per ora non so come si faccia
} }
void xvt_dwin_draw_tool(WINDOW win, int x, int y, int rid, int size)
{
const wxBitmap& bmp = _GetToolResource(rid, size);
if (bmp.IsOk())
{
wxDC& dc = GetTDCMapper().GetDC(win);
dc.DrawBitmap(bmp, x, y);
}
}

View File

@ -5,6 +5,7 @@
#include "xvtwin.h" #include "xvtwin.h"
#include "wx/aui/aui.h" #include "wx/aui/aui.h"
#include "wx/dcbuffer.h"
#include "wx/notebook.h" #include "wx/notebook.h"
#include "wx/treectrl.h" #include "wx/treectrl.h"
#include "wx/vlbox.h" #include "wx/vlbox.h"
@ -244,7 +245,8 @@ wxDC& TDC::GetDC(bool bPaint)
if (bPaint) if (bPaint)
{ {
KillDC(); KillDC();
_dc = new wxPaintDC(_owner); //_dc = new wxPaintDC(_owner);
_dc = new wxAutoBufferedPaintDC(_owner);
_dirty = -1; _dirty = -1;
} }
else else
@ -766,14 +768,14 @@ void TwxWindow::OnScroll(wxScrollEvent& evt)
SCROLL_CONTROL sc = ConvertScrollToXVT(evt.GetEventType()); SCROLL_CONTROL sc = ConvertScrollToXVT(evt.GetEventType());
if (sc != SC_NONE) if (sc != SC_NONE)
{ {
const wxScrollBar* sb = (wxScrollBar*)evt.GetEventObject(); wxWindow* ctl = (wxWindow*)evt.GetEventObject();
const wxSize sz = sb->GetSize(); const wxSize sz = ctl->GetSize();
EVENT e; memset(&e, 0, sizeof(EVENT)); EVENT e; memset(&e, 0, sizeof(EVENT));
e.type = E_CONTROL; e.type = E_CONTROL;
e.v.ctl.id = evt.GetId(); e.v.ctl.id = evt.GetId();
e.v.ctl.ci.type = sz.x > sz.y ? WC_HSCROLL : WC_VSCROLL; e.v.ctl.ci.type = sz.x > sz.y ? WC_HSCROLL : WC_VSCROLL;
e.v.ctl.ci.win = (WINDOW)sb; e.v.ctl.ci.win = (WINDOW)ctl;
e.v.ctl.ci.v.scroll.pos = evt.GetPosition(); e.v.ctl.ci.v.scroll.pos = evt.GetPosition();
e.v.ctl.ci.v.scroll.what = sc; e.v.ctl.ci.v.scroll.what = sc;
DoXvtEvent(e); DoXvtEvent(e);
@ -1109,18 +1111,3 @@ TTaskWin::~TTaskWin()
} }
_nice_windows.Delete((WINDOW)this); _nice_windows.Delete((WINDOW)this);
} }
///////////////////////////////////////////////////////////
// Pane interface
///////////////////////////////////////////////////////////
BOOLEAN xvt_win_add_pane(WINDOW win, WINDOW pane, const char* name, int dock, int flags)
{
BOOLEAN done = FALSE;
if (win != NULL_WIN && pane != NULL_WIN && name && *name)
{
done = ((TwxWindow*)win)->AddPane((wxWindow*)pane, name, dock, flags);
}
return done;
}