Patch level : 10.0
Files correlati : xvaga.dll Ricompilazione Demo : [ ] Commento : Corretta gestione font in PDF. I file .FON ora vengono correttamente ignorati senza dare errore git-svn-id: svn://10.65.10.50/trunk@18251 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
60c795af20
commit
2130bbc799
@ -18,6 +18,7 @@
|
||||
#include "XFont.h"
|
||||
|
||||
#include <crtdbg.h>
|
||||
#include <shlobj.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@ -223,6 +224,13 @@ BOOL GetFontFile(LPCTSTR lpszFontName,
|
||||
return bResult;
|
||||
}
|
||||
|
||||
BOOL GetFontsFolder(LPTSTR lpszFontPath, int nFontPathSize)
|
||||
{
|
||||
_ASSERTE(nFontPathSize >= _MAX_PATH);
|
||||
*lpszFontPath = '\0';
|
||||
SHGetFolderPath(NULL, CSIDL_FONTS, NULL, 0, lpszFontPath);
|
||||
return *lpszFontPath != '\0';
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
@ -33,4 +33,6 @@ BOOL GetFontFile(LPCTSTR lpszFontName,
|
||||
BOOL GetFontProperties(LPCTSTR lpszFilePath,
|
||||
LPFONT_PROPERTIES lpFontProps);
|
||||
|
||||
BOOL GetFontsFolder(LPTSTR lpszFontPath, int nFontPathSize);
|
||||
|
||||
#endif //XFONT_H
|
||||
|
@ -595,13 +595,10 @@ DRAW_CTOOLS* xvt_app_get_default_ctools(DRAW_CTOOLS *ct)
|
||||
void xvt_app_process_pending_events(void)
|
||||
{
|
||||
wxApp* a = wxTheApp; // Memorizzo il risultato di wxGetInstance
|
||||
if (a != NULL)
|
||||
{
|
||||
while (a->Pending())
|
||||
a->Dispatch();
|
||||
a->ProcessIdle(); // Necessario per wxAUI
|
||||
a->Yield(true); // Non so se serva veramente
|
||||
}
|
||||
while (a->Pending())
|
||||
a->Dispatch();
|
||||
a->ProcessIdle(); // Necessario per wxAUI
|
||||
a->Yield(true); // Non so se serva veramente
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -1288,7 +1285,7 @@ const wxFont& TFontId::Font(wxDC* dc, WINDOW win) const
|
||||
{
|
||||
const int nFontSize = (nMin+nMax)/2;
|
||||
|
||||
wxFont courier(nFontSize, wxFIXED, wxNORMAL, wxNORMAL, FALSE, DEFAULT_FONT_NAME);
|
||||
wxFont courier(nFontSize, wxFIXED, wxNORMAL, wxNORMAL, false, DEFAULT_FONT_NAME);
|
||||
dc->SetFont(courier);
|
||||
int tw; dc->GetTextExtent(str, &tw, NULL);
|
||||
if (tw <= nTarget10)
|
||||
@ -1313,7 +1310,7 @@ const wxFont& TFontId::Font(wxDC* dc, WINDOW win) const
|
||||
for (int i = 15; i > 0; i--)
|
||||
{
|
||||
const int nFontSize = nBest-i;
|
||||
wxFont courier(nFontSize, wxFIXED, wxNORMAL, wxNORMAL, FALSE, DEFAULT_FONT_NAME);
|
||||
wxFont courier(nFontSize, wxFIXED, wxNORMAL, wxNORMAL, false, DEFAULT_FONT_NAME);
|
||||
|
||||
dc->SetFont(courier);
|
||||
int tw, th; dc->GetTextExtent(str, &tw, &th);
|
||||
@ -2710,11 +2707,11 @@ MENU_ITEM* xvt_menu_get_tree(WINDOW win)
|
||||
return m;
|
||||
}
|
||||
|
||||
BOOLEAN xvt_menu_popup(MENU_ITEM *menu_p, WINDOW win, PNT pos,
|
||||
BOOLEAN xvt_menu_popup(const MENU_ITEM *menu_p, WINDOW win, PNT pos,
|
||||
XVT_POPUP_ALIGNMENT /* alignment */, MENU_TAG /* item */)
|
||||
{
|
||||
wxMenu menu;
|
||||
for (MENU_ITEM* mi = menu_p; mi != NULL && mi->tag != 0; mi++)
|
||||
for (const MENU_ITEM* mi = menu_p; mi != NULL && mi->tag != 0; mi++)
|
||||
{
|
||||
if (mi->separator || mi->text == NULL)
|
||||
menu.AppendSeparator();
|
||||
@ -2722,13 +2719,14 @@ BOOLEAN xvt_menu_popup(MENU_ITEM *menu_p, WINDOW win, PNT pos,
|
||||
{
|
||||
wxMenuItem* item = NULL;
|
||||
if (mi->checkable)
|
||||
{
|
||||
item = menu.AppendCheckItem(mi->tag, mi->text);
|
||||
item->Check(mi->checked);
|
||||
}
|
||||
else
|
||||
item = menu.Append(mi->tag, mi->text);
|
||||
// Operazioni fattibili solo dopo la menu.Append(), non prima!
|
||||
item->Enable(mi->enabled);
|
||||
if (mi->checkable)
|
||||
item->Check(mi->checked);
|
||||
item->Enable(mi->enabled);
|
||||
}
|
||||
}
|
||||
|
||||
|
14
xvaga/xvt.h
14
xvaga/xvt.h
@ -212,11 +212,13 @@ XVTDLL void xvt_image_set_ncolors(XVT_IMAGE image, short ncolors);
|
||||
XVTDLL void xvt_image_set_pixel(XVT_IMAGE image, short x, short y, COLOR color);
|
||||
XVTDLL void xvt_image_transfer(XVT_IMAGE dstimage, XVT_IMAGE srcimage, RCT *dstrctp, RCT *srcrctp);
|
||||
|
||||
XVTDLL int xvt_list_add_item(WINDOW win, short icon, const char* text, int flags);
|
||||
XVTDLL BOOLEAN xvt_list_clear(WINDOW win);
|
||||
XVTDLL BOOLEAN xvt_list_get_sel_index(WINDOW win);
|
||||
XVTDLL BOOLEAN xvt_list_set_sel(WINDOW win, int index, BOOLEAN select);
|
||||
XVTDLL int xvt_list_count(WINDOW win);
|
||||
XVTDLL int xvt_list_add_item(WINDOW win, short icon, const char* text, int flags);
|
||||
XVTDLL BOOLEAN xvt_list_add(WINDOW win, int index, const char* text);
|
||||
XVTDLL BOOLEAN xvt_list_clear(WINDOW win);
|
||||
XVTDLL int xvt_list_get_sel_index(WINDOW win);
|
||||
XVTDLL BOOLEAN xvt_list_set_sel(WINDOW win, int index, BOOLEAN select);
|
||||
XVTDLL int xvt_list_count(WINDOW win);
|
||||
XVTDLL MENU_TAG xvt_list_popup(WINDOW parent, const RCT* ownrct, const MENU_ITEM* menu, const XVT_COLOR_COMPONENT* colors, MENU_TAG first);
|
||||
|
||||
XVTDLL DATA_PTR xvt_mem_alloc(size_t size);
|
||||
XVTDLL void xvt_mem_free(DATA_PTR p);
|
||||
@ -225,7 +227,7 @@ XVTDLL DATA_PTR xvt_mem_rep(DATA_PTR dst, DATA_PTR src, unsigned int srclen, lo
|
||||
XVTDLL DATA_PTR xvt_mem_zalloc(size_t size);
|
||||
|
||||
XVTDLL MENU_ITEM* xvt_menu_get_tree(WINDOW win);
|
||||
XVTDLL BOOLEAN xvt_menu_popup(MENU_ITEM *menu_p, WINDOW win, PNT pos, XVT_POPUP_ALIGNMENT alignment, MENU_TAG item);
|
||||
XVTDLL BOOLEAN xvt_menu_popup(const MENU_ITEM *menu_p, WINDOW win, PNT pos, XVT_POPUP_ALIGNMENT alignment, MENU_TAG item);
|
||||
XVTDLL void xvt_menu_set_font_sel(WINDOW win, XVT_FNTID font_id);
|
||||
XVTDLL void xvt_menu_set_item_checked(WINDOW win, MENU_TAG tag, BOOLEAN check);
|
||||
XVTDLL void xvt_menu_set_item_enabled(WINDOW win, MENU_TAG tag, BOOLEAN enable);
|
||||
|
@ -234,6 +234,7 @@ WC_TREE, /* tree view */
|
||||
WC_OUTLOOKBAR, /* Barra di outlook */
|
||||
WC_HSLIDER, /* horizontal slider control */
|
||||
WC_VSLIDER, /* vertical slider control */
|
||||
WC_POPUP /* list of listedit control or popup menu */
|
||||
} WIN_TYPE;
|
||||
|
||||
typedef enum {
|
||||
|
443
xvaga/xvtctl.cpp
443
xvaga/xvtctl.cpp
@ -159,7 +159,6 @@ class TwxOutlookBar : public wxVListBox
|
||||
{
|
||||
enum { MAX_ITEMS = 32 };
|
||||
TwxOutlookItem m_item[MAX_ITEMS];
|
||||
bool m_bCaptured;
|
||||
int m_nHovering;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
@ -169,7 +168,7 @@ protected:
|
||||
virtual void OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const;
|
||||
virtual wxCoord OnMeasureItem(size_t n) const;
|
||||
virtual void OnMouseMove(wxMouseEvent& e);
|
||||
virtual void OnMouseCaptureLost(wxMouseCaptureLostEvent& e);
|
||||
virtual void OnMouseLeave(wxMouseEvent& e);
|
||||
virtual void OnSelected(wxCommandEvent& e);
|
||||
|
||||
public:
|
||||
@ -179,6 +178,32 @@ public:
|
||||
~TwxOutlookBar();
|
||||
};
|
||||
|
||||
class TwxPopUp : public wxVListBox
|
||||
{
|
||||
wxArrayString m_menu;
|
||||
int m_nHovering;
|
||||
wxCoord m_nRowHeight;
|
||||
wxColour m_clrBack, m_clrFore;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
void NotifySelection();
|
||||
|
||||
protected:
|
||||
virtual void OnDrawBackground(wxDC& dc, const wxRect& rect, size_t n) const;
|
||||
virtual void OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const;
|
||||
virtual wxCoord OnMeasureItem(size_t n) const;
|
||||
virtual void OnMouseMove(wxMouseEvent& e);
|
||||
virtual void OnKillFocus(wxFocusEvent& e);
|
||||
virtual void OnSelected(wxCommandEvent& e);
|
||||
virtual void OnKeyDown(wxKeyEvent& e);
|
||||
|
||||
public:
|
||||
int Add(const wxString str);
|
||||
void SetSelectForeColor(const wxColour& rgb) { m_clrFore = rgb; }
|
||||
void SetSelectBackColor(const wxColour& rgb) { m_clrBack= rgb; }
|
||||
TwxPopUp(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size);
|
||||
};
|
||||
|
||||
WINDOW xvt_ctl_create_def(WIN_DEF* win_def_p, WINDOW parent_win, long app_data)
|
||||
{
|
||||
wxASSERT(win_def_p != NULL);
|
||||
@ -239,8 +264,9 @@ WINDOW xvt_ctl_create_def(WIN_DEF* win_def_p, WINDOW parent_win, long app_data)
|
||||
break;
|
||||
case WC_RADIOBUTTON: /* radio button */
|
||||
{
|
||||
long style = wxRB_SINGLE | wxCLIP_SIBLINGS;
|
||||
wxRadioButton* rb = new wxRadioButton(pParent, id, win_def_p->text,
|
||||
rct.GetPosition(), rct.GetSize(), wxRB_SINGLE);
|
||||
rct.GetPosition(), rct.GetSize(), style);
|
||||
win = (WINDOW)rb;
|
||||
}
|
||||
break;
|
||||
@ -256,6 +282,18 @@ WINDOW xvt_ctl_create_def(WIN_DEF* win_def_p, WINDOW parent_win, long app_data)
|
||||
win = (WINDOW)tv;
|
||||
}
|
||||
break;
|
||||
case WC_LBOX:
|
||||
{
|
||||
wxListBox* tlb = new wxListBox(pParent, id, rct.GetPosition(), rct.GetSize());
|
||||
win = (WINDOW)tlb;
|
||||
}
|
||||
break;
|
||||
case WC_POPUP:
|
||||
{
|
||||
TwxPopUp* tpu = new TwxPopUp(pParent, id, rct.GetPosition(), rct.GetSize());
|
||||
win = (WINDOW)tpu;
|
||||
}
|
||||
break;
|
||||
case WC_OUTLOOKBAR:
|
||||
{
|
||||
long style = 0;
|
||||
@ -322,11 +360,21 @@ void xvt_ctl_set_colors(WINDOW win, const XVT_COLOR_COMPONENT* colors, XVT_COLOR
|
||||
CAST_COLOR(colors[i].color, rgb);
|
||||
switch(colors[i].type)
|
||||
{
|
||||
case XVT_COLOR_BACKGROUND:
|
||||
w->SetOwnBackgroundColour(rgb);
|
||||
case XVT_COLOR_BACKGROUND: w->SetOwnBackgroundColour(rgb); break;
|
||||
case XVT_COLOR_FOREGROUND: w->SetOwnForegroundColour(rgb); break;
|
||||
case XVT_COLOR_HIGHLIGHT:
|
||||
{
|
||||
TwxPopUp* tpu = wxDynamicCast(w, TwxPopUp);
|
||||
if (tpu != NULL)
|
||||
tpu->SetSelectForeColor(rgb);
|
||||
}
|
||||
break;
|
||||
case XVT_COLOR_FOREGROUND:
|
||||
w->SetOwnForegroundColour(rgb);
|
||||
case XVT_COLOR_SELECT:
|
||||
{
|
||||
TwxPopUp* tpu = wxDynamicCast(w, TwxPopUp);
|
||||
if (tpu != NULL)
|
||||
tpu->SetSelectBackColor(rgb);
|
||||
}
|
||||
break;
|
||||
case XVT_COLOR_BLEND:
|
||||
if (!w->IsKindOf(CLASSINFO(wxButton)))
|
||||
@ -1002,9 +1050,9 @@ TwxTreeCtrl::TwxTreeCtrl(wxWindow *parent, wxWindowID id,
|
||||
|
||||
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)
|
||||
long app_data, int ctl_id, XVT_IMAGE WXUNUSED(item_image),
|
||||
XVT_IMAGE WXUNUSED(collapsed_image), XVT_IMAGE WXUNUSED(expanded_image),
|
||||
long WXUNUSED(attrs), int WXUNUSED(line_height))
|
||||
{
|
||||
WIN_DEF win_def; memset(&win_def, 0, sizeof(WIN_DEF));
|
||||
win_def.wtype = WC_TREE;
|
||||
@ -1019,7 +1067,7 @@ WINDOW xvt_treeview_create(WINDOW parent_win,
|
||||
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)
|
||||
const char* string, XVT_TREEVIEW_CALLBACK WXUNUSED(callback), const char* data)
|
||||
{
|
||||
XVT_TREEVIEW_NODE node = NULL;
|
||||
if (win != NULL_WIN)
|
||||
@ -1256,7 +1304,7 @@ BEGIN_EVENT_TABLE(TwxOutlookBar, wxVListBox)
|
||||
EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LISTBOX_SELECTED, TwxOutlookBar::OnSelected)
|
||||
EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, TwxOutlookBar::OnSelected)
|
||||
EVT_MOTION(TwxOutlookBar::OnMouseMove)
|
||||
EVT_MOUSE_CAPTURE_LOST(TwxOutlookBar::OnMouseCaptureLost)
|
||||
EVT_LEAVE_WINDOW(TwxOutlookBar::OnMouseLeave)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
static const wxColour ModulateColour(const wxColour& col, int percent)
|
||||
@ -1273,15 +1321,18 @@ static const wxColour ModulateColour(const wxColour& col, int percent)
|
||||
return wxColour(r, g, b);
|
||||
}
|
||||
|
||||
/*
|
||||
static const wxColour MeanColour(const wxColour& c1, const wxColour& c2, int percent = 50)
|
||||
{
|
||||
const double p = percent / 100.0;
|
||||
const double i = 1.0-p;
|
||||
return wxColour(c1.Red()*i+c2.Red()*p, c1.Green()*i+c2.Green()*p, c1.Blue()*i+c2.Blue()*p);
|
||||
}
|
||||
*/
|
||||
|
||||
void TwxOutlookBar::OnDrawBackground(wxDC& dc, const wxRect& rect, size_t n) const
|
||||
void TwxOutlookBar::OnDrawBackground(wxDC& dc, const wxRect& rect, size_t u) const
|
||||
{
|
||||
const int n = u; // Anti warning
|
||||
wxColour color1, color2;
|
||||
if (n == m_nHovering)
|
||||
{
|
||||
@ -1345,10 +1396,10 @@ void TwxOutlookBar::OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const
|
||||
dc.DrawText(oi.m_strText, rect.x+nTextOffset, rect.y+(nSide-szText.y)/2);
|
||||
}
|
||||
|
||||
wxCoord TwxOutlookBar::OnMeasureItem(size_t n) const
|
||||
wxCoord TwxOutlookBar::OnMeasureItem(size_t WXUNUSED(n)) const
|
||||
{
|
||||
const int nItems = GetItemCount();
|
||||
wxCoord nHeight = 36;
|
||||
wxCoord nHeight = 32 + 4; // Icon size + gap
|
||||
if (nItems > 1)
|
||||
{
|
||||
const wxSize sz = GetSize();
|
||||
@ -1359,35 +1410,10 @@ wxCoord TwxOutlookBar::OnMeasureItem(size_t n) const
|
||||
|
||||
void TwxOutlookBar::OnMouseMove(wxMouseEvent& evt)
|
||||
{
|
||||
int nHover = HitTest(evt.GetPosition());
|
||||
if (m_bCaptured && nHover != wxNOT_FOUND)
|
||||
const int nWasHovering = m_nHovering;
|
||||
m_nHovering = HitTest(evt.GetPosition());
|
||||
if (m_nHovering != nWasHovering)
|
||||
{
|
||||
const wxRect rect = GetClientRect();
|
||||
if (!rect.Contains(evt.GetPosition()))
|
||||
nHover = wxNOT_FOUND;
|
||||
}
|
||||
|
||||
if (nHover == wxNOT_FOUND)
|
||||
{
|
||||
if (m_bCaptured)
|
||||
{
|
||||
m_bCaptured = false;
|
||||
ReleaseMouse();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_bCaptured)
|
||||
{
|
||||
m_bCaptured = true;
|
||||
CaptureMouse();
|
||||
}
|
||||
}
|
||||
|
||||
if (nHover != m_nHovering)
|
||||
{
|
||||
const int nWasHovering = m_nHovering;
|
||||
m_nHovering = nHover;
|
||||
if (nWasHovering != wxNOT_FOUND)
|
||||
RefreshLine(nWasHovering);
|
||||
if (m_nHovering != wxNOT_FOUND)
|
||||
@ -1395,9 +1421,8 @@ void TwxOutlookBar::OnMouseMove(wxMouseEvent& evt)
|
||||
}
|
||||
}
|
||||
|
||||
void TwxOutlookBar::OnMouseCaptureLost(wxMouseCaptureLostEvent&)
|
||||
void TwxOutlookBar::OnMouseLeave(wxMouseEvent& WXUNUSED(e))
|
||||
{
|
||||
m_bCaptured = false;
|
||||
if (m_nHovering != wxNOT_FOUND)
|
||||
{
|
||||
const int nWasHovering = m_nHovering;
|
||||
@ -1439,59 +1464,345 @@ int TwxOutlookBar::Add(short nIconId, const wxString strText, int nFlags)
|
||||
|
||||
TwxOutlookBar::TwxOutlookBar(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos, const wxSize& size, long style)
|
||||
: wxVListBox(parent, id, pos, size, style), m_bCaptured(false), m_nHovering(wxNOT_FOUND)
|
||||
: wxVListBox(parent, id, pos, size, style), m_nHovering(wxNOT_FOUND)
|
||||
{
|
||||
SetItemCount(0);
|
||||
}
|
||||
|
||||
TwxOutlookBar::~TwxOutlookBar()
|
||||
{ }
|
||||
|
||||
BOOLEAN xvt_list_add(WINDOW win, int index, const char* text)
|
||||
{
|
||||
if (HasCapture())
|
||||
ReleaseMouse();
|
||||
wxListBox* lb = wxDynamicCast((wxObject*)win, wxListBox);
|
||||
BOOLEAN ok = lb != NULL;
|
||||
if (ok)
|
||||
{
|
||||
const wxString str = text;
|
||||
if (index < 0 || index >= (int)lb->GetCount())
|
||||
lb->AppendString(str);
|
||||
else
|
||||
lb->Insert(str, index);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
int xvt_list_add_item(WINDOW win, short icon, const char* text, int flags)
|
||||
{
|
||||
TwxOutlookBar* olb = wxDynamicCast((wxObject*)win, TwxOutlookBar);
|
||||
const int n = olb != NULL ? olb->Add(icon, text, flags) : -1;
|
||||
int n = -1;
|
||||
if (win != NULL_WIN)
|
||||
{
|
||||
TwxOutlookBar* olb = wxDynamicCast((wxObject*)win, TwxOutlookBar);
|
||||
if (olb != NULL)
|
||||
n = olb->Add(icon, text, flags);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
BOOLEAN xvt_list_clear(WINDOW win)
|
||||
{
|
||||
TwxOutlookBar* olb = wxDynamicCast((wxObject*)win, TwxOutlookBar);
|
||||
if (olb)
|
||||
olb->Clear();
|
||||
return olb != NULL;
|
||||
BOOLEAN ok = win != NULL_WIN;
|
||||
if (ok)
|
||||
{
|
||||
wxVListBox* olb = wxDynamicCast((wxObject*)win, wxVListBox);
|
||||
if (olb != NULL)
|
||||
olb->Clear();
|
||||
else
|
||||
{
|
||||
wxListBox* lb = wxDynamicCast((wxObject*)win, wxListBox);
|
||||
if (lb != NULL)
|
||||
lb->Clear();
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
BOOLEAN xvt_list_get_sel_index(WINDOW win)
|
||||
int xvt_list_get_sel_index(WINDOW win)
|
||||
{
|
||||
TwxOutlookBar* olb = wxDynamicCast((wxObject*)win, TwxOutlookBar);
|
||||
const int sel = olb != NULL ? olb->GetSelection() : -1;
|
||||
int sel = -1;
|
||||
if (win != NULL_WIN)
|
||||
{
|
||||
wxVListBox* olb = wxDynamicCast((wxObject*)win, wxVListBox);
|
||||
if (olb != NULL)
|
||||
sel = olb->GetSelection();
|
||||
else
|
||||
{
|
||||
wxListBox* lb = wxDynamicCast((wxObject*)win, wxListBox);
|
||||
if (lb != NULL)
|
||||
sel = lb->GetSelection();
|
||||
}
|
||||
}
|
||||
return sel;
|
||||
}
|
||||
|
||||
BOOLEAN xvt_list_set_sel(WINDOW win, int index, BOOLEAN select)
|
||||
{
|
||||
TwxOutlookBar* olb = wxDynamicCast((wxObject*)win, TwxOutlookBar);
|
||||
if (olb != NULL)
|
||||
BOOLEAN ok = win != NULL_WIN;
|
||||
if (ok)
|
||||
{
|
||||
if (select)
|
||||
olb->SetSelection(index);
|
||||
wxVListBox* olb = wxDynamicCast((wxObject*)win, wxVListBox);
|
||||
if (olb != NULL)
|
||||
{
|
||||
if (select)
|
||||
olb->SetSelection(index);
|
||||
}
|
||||
else
|
||||
{
|
||||
wxListBox* lb = wxDynamicCast((wxObject*)win, wxListBox);
|
||||
if (lb != NULL)
|
||||
lb->SetSelection(index, select != 0);
|
||||
}
|
||||
}
|
||||
return olb != NULL;
|
||||
return ok;
|
||||
}
|
||||
|
||||
int xvt_list_count(WINDOW win)
|
||||
{
|
||||
int n = 0;
|
||||
TwxOutlookBar* olb = wxDynamicCast((wxObject*)win, TwxOutlookBar);
|
||||
if (olb != NULL)
|
||||
n = olb->GetItemCount();
|
||||
if (win != NULL_WIN)
|
||||
{
|
||||
wxVListBox* olb = wxDynamicCast((wxObject*)win, wxVListBox);
|
||||
if (olb != NULL)
|
||||
n = olb->GetItemCount();
|
||||
else
|
||||
{
|
||||
wxListBox* lb = wxDynamicCast((wxObject*)win, wxListBox);
|
||||
if (lb != NULL)
|
||||
n = lb->GetCount();
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TwxPopUp
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
BEGIN_EVENT_TABLE(TwxPopUp, wxVListBox)
|
||||
EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LISTBOX_SELECTED, TwxPopUp::OnSelected)
|
||||
EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, TwxPopUp::OnSelected)
|
||||
EVT_MOTION(TwxPopUp::OnMouseMove)
|
||||
EVT_KILL_FOCUS(TwxPopUp::OnKillFocus)
|
||||
EVT_KEY_DOWN(TwxPopUp::OnKeyDown)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
void TwxPopUp::OnDrawBackground(wxDC& dc, const wxRect& rect, size_t u) const
|
||||
{
|
||||
const int n = u; // Anti warning
|
||||
if (n == m_nHovering || (m_nHovering == wxNOT_FOUND && IsCurrent(u)))
|
||||
{
|
||||
wxBrush brush(m_clrBack);
|
||||
dc.SetBrush(brush);
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.DrawRectangle(rect);
|
||||
}
|
||||
}
|
||||
|
||||
void TwxPopUp::OnDrawItem(wxDC& dc, const wxRect& rect, size_t u) const
|
||||
{
|
||||
const int n = u; // Anti warning
|
||||
wxColour color;
|
||||
if (n == m_nHovering || (m_nHovering == wxNOT_FOUND && IsCurrent(u)))
|
||||
color = m_clrFore;
|
||||
else
|
||||
color = GetForegroundColour();
|
||||
dc.SetTextForeground(color);
|
||||
dc.SetFont(GetFont());
|
||||
dc.DrawText(m_menu[n], rect.x, rect.y);
|
||||
}
|
||||
|
||||
wxCoord TwxPopUp::OnMeasureItem(size_t WXUNUSED(n)) const
|
||||
{
|
||||
return m_nRowHeight;
|
||||
}
|
||||
|
||||
void TwxPopUp::OnMouseMove(wxMouseEvent& evt)
|
||||
{
|
||||
int nHover = wxNOT_FOUND;
|
||||
|
||||
const wxRect rect = GetClientRect();
|
||||
if (rect.Contains(evt.GetPosition()))
|
||||
nHover = HitTest(evt.GetPosition());
|
||||
|
||||
if (nHover != m_nHovering)
|
||||
{
|
||||
const int nWasHovering = m_nHovering;
|
||||
m_nHovering = nHover;
|
||||
if (nWasHovering != wxNOT_FOUND)
|
||||
RefreshLine(nWasHovering);
|
||||
if (m_nHovering != wxNOT_FOUND)
|
||||
RefreshLine(m_nHovering);
|
||||
}
|
||||
}
|
||||
|
||||
void TwxPopUp::OnKillFocus(wxFocusEvent& WXUNUSED(e))
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
|
||||
void TwxPopUp::NotifySelection()
|
||||
{
|
||||
TwxWindow* win = wxDynamicCast(GetParent(), TwxWindow);
|
||||
if (win != NULL)
|
||||
{
|
||||
EVENT e; memset(&e, 0, sizeof(EVENT));
|
||||
e.type = E_CONTROL;
|
||||
e.v.ctl.id = GetId();
|
||||
e.v.ctl.ci.type = WC_LISTEDIT;
|
||||
e.v.ctl.ci.win = WINDOW(this);
|
||||
e.v.ctl.ci.v.listedit.active = GetSelection();
|
||||
win->DoXvtEvent(e);
|
||||
}
|
||||
Hide();
|
||||
}
|
||||
|
||||
void TwxPopUp::OnSelected(wxCommandEvent& WXUNUSED(evt))
|
||||
{
|
||||
if (m_nHovering >= 0)
|
||||
NotifySelection();
|
||||
}
|
||||
|
||||
int TwxPopUp::Add(const wxString str)
|
||||
{
|
||||
m_menu.Add(str);
|
||||
const int i = m_menu.GetCount();
|
||||
SetItemCount(i);
|
||||
return i;
|
||||
}
|
||||
|
||||
void TwxPopUp::OnKeyDown(wxKeyEvent& evt)
|
||||
{
|
||||
m_nHovering = wxNOT_FOUND; // Evita chiusura involontaria della lista
|
||||
int key = evt.GetKeyCode();
|
||||
switch (key)
|
||||
{
|
||||
case WXK_RETURN:
|
||||
NotifySelection();
|
||||
break;
|
||||
default:
|
||||
if (key > ' ' && key <= 'z')
|
||||
{
|
||||
key = toupper(key);
|
||||
const int curr = max(GetSelection(), 0);
|
||||
const int tot = m_menu.GetCount();
|
||||
int i = curr;
|
||||
for (i = (i+1)%tot; i != curr; i = (i+1)%tot)
|
||||
{
|
||||
if (toupper(m_menu[i][0]) == key)
|
||||
break;
|
||||
}
|
||||
SetSelection(i);
|
||||
}
|
||||
else
|
||||
evt.Skip();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
TwxPopUp::TwxPopUp(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size)
|
||||
: wxVListBox(parent, id, pos, size, wxBORDER|wxPOPUP_WINDOW|wxCLIP_SIBLINGS),
|
||||
m_nHovering(wxNOT_FOUND)
|
||||
{
|
||||
m_clrFore = wxSystemSettings::GetColour(wxSYS_COLOUR_HOTLIGHT);
|
||||
m_clrBack = GetSelectionBackground();
|
||||
|
||||
const wxFont font = parent->GetFont();
|
||||
m_nRowHeight = abs(font.GetPixelSize().y) + 8;
|
||||
}
|
||||
|
||||
static int RoundPopupHeight(int list_h, int row_h)
|
||||
{
|
||||
const int rem = list_h % row_h;
|
||||
if (rem > 0)
|
||||
list_h -= rem;
|
||||
return list_h;
|
||||
}
|
||||
|
||||
MENU_TAG xvt_list_popup(WINDOW parent_win, const RCT* ownrct, const MENU_ITEM* menu,
|
||||
const XVT_COLOR_COMPONENT* colors, MENU_TAG first)
|
||||
{
|
||||
int sel = -1;
|
||||
int items = 0;
|
||||
if (parent_win != NULL_WIN && ownrct != NULL && menu != NULL)
|
||||
{
|
||||
wxWindow* parent = wxStaticCast((wxObject*)parent_win, wxWindow);
|
||||
int width = ownrct->right - ownrct->left;
|
||||
for (items = 0; menu[items].tag != 0; items++) if (menu[items].tag > 0 && menu[items].text)
|
||||
{
|
||||
const wxString str = menu[items].text;
|
||||
int w = 0, h = 0; parent->GetTextExtent(str, &w, &h);
|
||||
w += 24;
|
||||
if (w > width)
|
||||
width = w;
|
||||
}
|
||||
|
||||
const wxFont font = parent->GetFont();
|
||||
const int nRowHeight = abs(font.GetPixelSize().y)+8;
|
||||
const wxRect rctClient = parent->GetClientRect();
|
||||
const int nBottom = rctClient.GetBottom();
|
||||
|
||||
wxPoint pos(ownrct->right-width, ownrct->bottom);
|
||||
wxSize size(width, items*nRowHeight);
|
||||
|
||||
if (pos.y + size.y > nBottom) // La lista deborda di sotto?
|
||||
{
|
||||
if (ownrct->top > nBottom-ownrct->bottom) // Ho piu' spazio sopra che sotto?
|
||||
{
|
||||
pos.y = ownrct->top - size.y; // Sposto la lista sopra al campo di testo
|
||||
if (pos.y < 0)
|
||||
{
|
||||
size.y = RoundPopupHeight(size.y + pos.y, nRowHeight);
|
||||
pos.y = ownrct->top - size.y;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Accorcio la lista in basso
|
||||
size.y = RoundPopupHeight(nBottom-pos.y, nRowHeight);
|
||||
}
|
||||
}
|
||||
if (pos.x < 0)
|
||||
pos.x = 0;
|
||||
|
||||
WIN_DEF wd; memset(&wd, 0, sizeof(wd));
|
||||
wd.ctlcolors = (XVT_COLOR_COMPONENT*)colors;
|
||||
xvt_rect_set(&wd.rct, pos.x, pos.y, pos.x+size.x, pos.y+size.y);
|
||||
wd.v.ctl.ctrl_id = wxID_ANY;
|
||||
wd.v.ctl.flags = CTL_FLAG_INVISIBLE;
|
||||
wd.wtype = WC_POPUP;
|
||||
WINDOW win = xvt_ctl_create_def(&wd, parent_win, 0);
|
||||
|
||||
TwxPopUp* lb = wxDynamicCast((wxObject*)win, TwxPopUp);
|
||||
if (lb != NULL)
|
||||
{
|
||||
for (int i = 0; menu[i].tag != 0; i++)
|
||||
{
|
||||
const MENU_ITEM& mi = menu[i];
|
||||
if (mi.tag > 0)
|
||||
{
|
||||
lb->Add(mi.text);
|
||||
if (mi.tag == first)
|
||||
sel = i;
|
||||
}
|
||||
}
|
||||
if (sel >= 0)
|
||||
lb->SetSelection(sel);
|
||||
lb->Show();
|
||||
lb->SetFocus();
|
||||
while (lb->IsShown())
|
||||
{
|
||||
wxApp* a = wxTheApp; // Memorizzo il risultato di wxGetInstance
|
||||
while (a->Pending())
|
||||
a->Dispatch();
|
||||
}
|
||||
sel = lb->GetSelection();
|
||||
delete lb;
|
||||
}
|
||||
}
|
||||
return sel >= 0 && sel < items ? menu[sel].tag : 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// ToolBar
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -1559,7 +1870,7 @@ static TwxToolBar* Win2Bar(WINDOW win)
|
||||
}
|
||||
|
||||
BOOLEAN xvt_toolbar_add_control(WINDOW win, int cid, TOOL_TYPE type, const char *title,
|
||||
int ico, int cust_width, int idx)
|
||||
int ico, int WXUNUSED(cust_width), int idx)
|
||||
{
|
||||
BOOLEAN ok = FALSE;
|
||||
TwxToolBar* ptb = Win2Bar(win);
|
||||
|
@ -58,13 +58,15 @@ bool TwxPDFDC::StartDoc( const wxString& message )
|
||||
if (m_PDFlib->PDF_begin_document(m_p, m_fileName, 0, "") == -1)
|
||||
{
|
||||
wxLogError( _("Cannot open file for PDF printing!"));
|
||||
m_ok = false;
|
||||
return false;
|
||||
return m_ok = false;
|
||||
}
|
||||
|
||||
PDF_TRY_DL(m_PDFlib, m_p)
|
||||
{
|
||||
const wxString strFontPath = ::wxGetOSDirectory() + "\\Fonts";
|
||||
wxString strFontPath;
|
||||
wxChar* lpszFontPath = strFontPath.GetWriteBuf(_MAX_PATH);
|
||||
GetFontsFolder(lpszFontPath, _MAX_PATH);
|
||||
strFontPath.UngetWriteBuf();
|
||||
m_PDFlib->PDF_set_parameter(m_p, "SearchPath", strFontPath);
|
||||
}
|
||||
PDF_CATCH_DL(m_PDFlib, m_p)
|
||||
@ -74,9 +76,7 @@ bool TwxPDFDC::StartDoc( const wxString& message )
|
||||
}
|
||||
|
||||
m_pageNumber = 0;
|
||||
|
||||
m_ok = true;
|
||||
return true;
|
||||
return m_ok = true;
|
||||
}
|
||||
|
||||
void TwxPDFDC::EndDoc ()
|
||||
@ -103,8 +103,7 @@ void TwxPDFDC::StartPage()
|
||||
if (m_pageopen)
|
||||
return;
|
||||
|
||||
int size_x, size_y;
|
||||
|
||||
int size_x, size_y;
|
||||
DoGetSize (&size_x, &size_y);
|
||||
|
||||
m_pageNumber++;
|
||||
@ -790,13 +789,20 @@ void TwxPDFDC::DoGetTextExtent(const wxString& text,
|
||||
|
||||
//-- Settings ------------------------------------------------------------
|
||||
|
||||
bool TwxPDFDC::IsValidFontFile(const char* szFontFile) const
|
||||
{
|
||||
wxString strFile = szFontFile;
|
||||
strFile.MakeLower();
|
||||
return strFile.EndsWith(".ttf");
|
||||
}
|
||||
|
||||
bool TwxPDFDC::GetFontFamily(const wxFont& font, wxString& file, wxString& family) const
|
||||
{
|
||||
static wxFont m_LastFont;
|
||||
static wxString m_LastFile, m_strFamily;
|
||||
|
||||
if (!m_LastFont.IsOk() ||
|
||||
font.GetPointSize()!= m_LastFont.GetPointSize() ||
|
||||
font.GetPointSize()!= m_LastFont.GetPointSize() || // FAMILY NON DOVREBBE DIPENDERE DA POINTSIZE!
|
||||
font.GetWeight() != m_LastFont.GetWeight() ||
|
||||
font.GetStyle() != m_LastFont.GetStyle() ||
|
||||
font.GetFaceName() != m_LastFont.GetFaceName())
|
||||
@ -807,7 +813,7 @@ bool TwxPDFDC::GetFontFamily(const wxFont& font, wxString& file, wxString& famil
|
||||
|
||||
TCHAR szDisplayName[MAX_PATH], szFontFile[MAX_PATH];
|
||||
bool ok = GetFontFile(m_strFamily + strStyle, szDisplayName, MAX_PATH, szFontFile, MAX_PATH) != 0;
|
||||
if(ok)
|
||||
if (ok)
|
||||
m_strFamily += strStyle;
|
||||
else
|
||||
ok = GetFontFile(m_strFamily, szDisplayName, MAX_PATH, szFontFile, MAX_PATH) != 0;
|
||||
@ -817,6 +823,13 @@ bool TwxPDFDC::GetFontFamily(const wxFont& font, wxString& file, wxString& famil
|
||||
m_LastFile = szFontFile;
|
||||
else
|
||||
m_LastFile = m_strFamily = wxEmptyString;
|
||||
|
||||
if (!IsValidFontFile(szFontFile))
|
||||
{
|
||||
const wxFont swiss(font.GetPointSize(), font.GetFamily(), font.GetStyle(),
|
||||
font.GetWeight(), font.GetUnderlined());
|
||||
return GetFontFamily(swiss, file, family);
|
||||
}
|
||||
}
|
||||
|
||||
file = m_LastFile;
|
||||
@ -843,6 +856,7 @@ void TwxPDFDC::SetFont( const wxFont& font )
|
||||
const wxString strParameter = strFamily + "=" + strFontFile;
|
||||
m_PDFlib->PDF_set_parameter(m_p, "FontOutline", strParameter);
|
||||
m_fontsize = font.GetPointSize();
|
||||
|
||||
// maialata gigante da eliminare data dal fatto che a volte la GetPointSize() scazza
|
||||
// completamente a ritornare la dimensione (problema di wxWindoz) e ritorna un valore
|
||||
// molto molto minore di quello effettivo
|
||||
|
@ -16,6 +16,8 @@ class TwxPDFDC : public wxDC
|
||||
|
||||
protected:
|
||||
TwxPDFDC(); // Dummy constructor for dynamic construction
|
||||
|
||||
bool IsValidFontFile(const char* strFontFile) const;
|
||||
bool GetFontFamily(const wxFont& font, wxString& file, wxString& family) const;
|
||||
|
||||
public:
|
||||
|
Loading…
x
Reference in New Issue
Block a user