1. wxGrid fixes contributed by Gerhard Gruber (client data for cells...)

2. Motif warnings removed
3. Using native msgbox under Motif (ok, it doesn't work, but generic doesn't
   work neither)


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2930 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-06-29 13:13:11 +00:00
parent dfe1eee3bb
commit bf6c2b3505
8 changed files with 278 additions and 242 deletions

View File

@@ -101,12 +101,16 @@ public:
void SetCellTextFont(const wxFont& fnt, int row, int col); void SetCellTextFont(const wxFont& fnt, int row, int col);
wxBitmap *GetCellBitmap(int row, int col) const; wxBitmap *GetCellBitmap(int row, int col) const;
void SetCellBitmap(wxBitmap *bitmap, int row, int col); void SetCellBitmap(wxBitmap *bitmap, int row, int col);
void *SetCellData(void *data, int row, int col);
void *GetCellData(int row, int col);
// Size accessors // Size accessors
void SetColumnWidth(int col, int width); void SetColumnWidth(int col, int width);
int GetColumnWidth(int col) const; int GetColumnWidth(int col) const;
void SetRowHeight(int row, int height); void SetRowHeight(int row, int height);
int GetRowHeight(int row) const; int GetRowHeight(int row) const;
int GetViewHeight() const { return m_viewHeight; }
int GetViewWidth() const { return m_viewWidth; }
// Label accessors // Label accessors
void SetLabelSize(int orientation, int sz); void SetLabelSize(int orientation, int sz);
@@ -266,6 +270,8 @@ protected:
int m_bottomOfSheet; // Calculated from m_rowHeights int m_bottomOfSheet; // Calculated from m_rowHeights
int m_totalGridWidth; // Total 'virtual' size int m_totalGridWidth; // Total 'virtual' size
int m_totalGridHeight; int m_totalGridHeight;
int m_viewHeight; // Number of rows displayed
int m_viewWidth; // Number of columns displayed
int m_cellHeight; // For now, a default int m_cellHeight; // For now, a default
int m_verticalLabelWidth; int m_verticalLabelWidth;
int m_horizontalLabelHeight; int m_horizontalLabelHeight;
@@ -318,7 +324,8 @@ public:
wxColour backgroundColour; wxColour backgroundColour;
wxBrush backgroundBrush; wxBrush backgroundBrush;
wxBitmap* cellBitmap; wxBitmap* cellBitmap;
int alignment; void* cellData; // intended for additional data associated with a cell
int alignment;
wxGridCell(wxGenericGrid *window = (wxGenericGrid *) NULL); wxGridCell(wxGenericGrid *window = (wxGenericGrid *) NULL);
~wxGridCell(); ~wxGridCell();
@@ -337,6 +344,9 @@ public:
void SetAlignment(int align) { alignment = align; } void SetAlignment(int align) { alignment = align; }
wxBitmap *GetCellBitmap() const { return cellBitmap; } wxBitmap *GetCellBitmap() const { return cellBitmap; }
void SetCellBitmap(wxBitmap *bitmap) { cellBitmap = bitmap; } void SetCellBitmap(wxBitmap *bitmap) { cellBitmap = bitmap; }
void *SetCellData(void *data) { void *rc = cellData; cellData = data; return rc; }
void *GetCellData() const { return cellData; }
}; };
class WXDLLEXPORT wxGrid : public wxGenericGrid class WXDLLEXPORT wxGrid : public wxGenericGrid

View File

@@ -4,7 +4,7 @@
#if defined(__WXMSW__) #if defined(__WXMSW__)
#include "wx/msw/msgdlg.h" #include "wx/msw/msgdlg.h"
#elif defined(__WXMOTIF__) #elif defined(__WXMOTIF__)
#include "wx/generic/msgdlgg.h" #include "wx/motif/msgdlg.h"
#elif defined(__WXGTK__) #elif defined(__WXGTK__)
#include "wx/gtk/msgdlg.h" #include "wx/gtk/msgdlg.h"
#elif defined(__WXQT__) #elif defined(__WXQT__)

View File

@@ -5,6 +5,8 @@
// Modified by: Michael Bedward // Modified by: Michael Bedward
// Added edit in place facility, 20 Apr 1999 // Added edit in place facility, 20 Apr 1999
// Added cursor key control, 29 Jun 1999 // Added cursor key control, 29 Jun 1999
// Gerhard Gruber
// Added keyboard navigation, client data, other fixes
// Created: 04/01/98 // Created: 04/01/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem // Copyright: (c) Julian Smart and Markus Holzem
@@ -77,8 +79,10 @@ BEGIN_EVENT_TABLE(wxGenericGrid, wxPanel)
END_EVENT_TABLE() END_EVENT_TABLE()
wxGenericGrid::wxGenericGrid(void) wxGenericGrid::wxGenericGrid()
{ {
m_viewWidth = 0;
m_viewHeight = 0;
m_batchCount = 0; m_batchCount = 0;
m_hScrollBar = (wxScrollBar *) NULL; m_hScrollBar = (wxScrollBar *) NULL;
m_vScrollBar = (wxScrollBar *) NULL; m_vScrollBar = (wxScrollBar *) NULL;
@@ -137,9 +141,15 @@ wxGenericGrid::wxGenericGrid(void)
m_textItem = (wxTextCtrl *) NULL; m_textItem = (wxTextCtrl *) NULL;
} }
bool wxGenericGrid::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, bool wxGenericGrid::Create(wxWindow *parent,
long style, const wxString& name) wxWindowID id,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name)
{ {
m_viewWidth = 0;
m_viewHeight = 0;
m_batchCount = 0; m_batchCount = 0;
m_editingPanel = (wxPanel *) NULL; m_editingPanel = (wxPanel *) NULL;
m_hScrollBar = (wxScrollBar *) NULL; m_hScrollBar = (wxScrollBar *) NULL;
@@ -246,12 +256,12 @@ bool wxGenericGrid::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos,
return TRUE; return TRUE;
} }
wxGenericGrid::~wxGenericGrid(void) wxGenericGrid::~wxGenericGrid()
{ {
ClearGrid(); ClearGrid();
} }
void wxGenericGrid::ClearGrid(void) void wxGenericGrid::ClearGrid()
{ {
int i,j; int i,j;
if (m_gridCells) if (m_gridCells)
@@ -380,7 +390,7 @@ bool wxGenericGrid::CreateGrid(int nRows, int nCols, wxString **cellValues, shor
} }
// Need to determine various dimensions // Need to determine various dimensions
void wxGenericGrid::UpdateDimensions(void) void wxGenericGrid::UpdateDimensions()
{ {
int canvasWidth, canvasHeight; int canvasWidth, canvasHeight;
GetSize(&canvasWidth, &canvasHeight); GetSize(&canvasWidth, &canvasHeight);
@@ -941,7 +951,7 @@ void wxGenericGrid::DrawCellValue(wxDC *dc, wxRect *rect, int row, int col)
} }
} }
void wxGenericGrid::AdjustScrollbars(void) void wxGenericGrid::AdjustScrollbars()
{ {
int cw, ch; int cw, ch;
GetClientSize(&cw, &ch); GetClientSize(&cw, &ch);
@@ -966,56 +976,53 @@ void wxGenericGrid::AdjustScrollbars(void)
int noHorizSteps = 0; int noHorizSteps = 0;
int noVertSteps = 0; int noVertSteps = 0;
if (m_totalGridWidth + vertScrollBarWidth <= cw) if (m_totalGridWidth + vertScrollBarWidth > cw)
noHorizSteps = 0;
else
{ {
noHorizSteps = 0;
int widthCount = 0; int widthCount = 0;
int i; int i;
int nx = 0; int nx = 0;
for (i = m_scrollPosX ; i < m_totalCols; i++) for (i = m_scrollPosX ; i < m_totalCols; i++)
{ {
widthCount += m_colWidths[i]; widthCount += m_colWidths[i];
// A partial bit doesn't count, we still have to scroll to see the // A partial bit doesn't count, we still have to scroll to see the
// rest of it // rest of it
if (widthCount + m_leftOfSheet + m_verticalLabelWidth > (cw-vertScrollBarWidth)) if (widthCount + m_leftOfSheet + m_verticalLabelWidth > (cw-vertScrollBarWidth))
break; break;
else else
nx ++; nx ++;
} }
noHorizSteps += nx; noHorizSteps += nx;
} }
if (m_totalGridHeight + horizScrollBarHeight <= ch) m_viewWidth = noHorizSteps;
noVertSteps = 0;
else if (m_totalGridHeight + horizScrollBarHeight > ch)
{ {
noVertSteps = 0;
int heightCount = 0; int heightCount = 0;
int i; int i;
int ny = 0; int ny = 0;
for (i = m_scrollPosY ; i < m_totalRows; i++) for (i = m_scrollPosY ; i < m_totalRows; i++)
{ {
heightCount += m_rowHeights[i]; heightCount += m_rowHeights[i];
// A partial bit doesn't count, we still have to scroll to see the // A partial bit doesn't count, we still have to scroll to see the
// rest of it // rest of it
if (heightCount + m_topOfSheet + m_horizontalLabelHeight > (ch-horizScrollBarHeight)) if (heightCount + m_topOfSheet + m_horizontalLabelHeight > (ch-horizScrollBarHeight))
break; break;
else else
ny ++; ny ++;
} }
noVertSteps += ny; noVertSteps += ny;
} }
m_viewHeight = noVertSteps;
if (m_totalGridWidth + vertScrollBarWidth <= cw) if (m_totalGridWidth + vertScrollBarWidth <= cw)
{ {
if ( m_hScrollBar ) if ( m_hScrollBar )
m_hScrollBar->Show(FALSE); m_hScrollBar->Show(FALSE);
SetScrollPosX(0); SetScrollPosX(0);
} }
else else
@@ -1479,12 +1486,12 @@ void wxGenericGrid::OnSelectCellImplementation(wxDC *dc, int row, int col)
GetEventHandler()->ProcessEvent(g_evt2); GetEventHandler()->ProcessEvent(g_evt2);
} }
wxGridCell *wxGenericGrid::OnCreateCell(void) wxGridCell *wxGenericGrid::OnCreateCell()
{ {
return new wxGridCell(this); return new wxGridCell(this);
} }
void wxGenericGrid::OnChangeLabels(void) void wxGenericGrid::OnChangeLabels()
{ {
char buf[100]; char buf[100];
int i; int i;
@@ -1510,7 +1517,7 @@ void wxGenericGrid::OnChangeLabels(void)
} }
} }
void wxGenericGrid::OnChangeSelectionLabel(void) void wxGenericGrid::OnChangeSelectionLabel()
{ {
if (!GetEditable()) if (!GetEditable())
return; return;
@@ -1553,7 +1560,7 @@ void wxGenericGrid::HighlightCell(wxDC *dc)
dc->SetLogicalFunction(wxCOPY); dc->SetLogicalFunction(wxCOPY);
} }
void wxGenericGrid::DrawCellText(void) void wxGenericGrid::DrawCellText()
{ {
if (!m_currentRectVisible) if (!m_currentRectVisible)
return; return;
@@ -2510,9 +2517,9 @@ void wxGenericGrid::SetGridCursor(int row, int col)
dc.EndDrawing(); dc.EndDrawing();
} }
/* // ----------------------------------------------------------------------------
* Grid cell // Grid cell
*/ // ----------------------------------------------------------------------------
wxGridCell::wxGridCell(wxGenericGrid *window) wxGridCell::wxGridCell(wxGenericGrid *window)
{ {
@@ -2539,9 +2546,11 @@ wxGridCell::wxGridCell(wxGenericGrid *window)
alignment = window->GetCellAlignment(); alignment = window->GetCellAlignment();
else else
alignment = wxLEFT; alignment = wxLEFT;
cellData = (void *)NULL;
} }
wxGridCell::~wxGridCell(void) wxGridCell::~wxGridCell()
{ {
} }
@@ -2741,4 +2750,25 @@ void wxGenericGrid::_OnLabelRightClick(wxGridEvent& ev)
OnLabelRightClick(ev.m_row, ev.m_col, ev.m_x, ev.m_y, ev.m_control, ev.m_shift); OnLabelRightClick(ev.m_row, ev.m_col, ev.m_x, ev.m_y, ev.m_control, ev.m_shift);
} }
void *wxGenericGrid::SetCellData(void *data, int row, int col)
{
void *rc = NULL;
wxGridCell *cell = GetCell(row, col);
if ( cell )
rc = cell->SetCellData(data);
return rc;
}
void *wxGenericGrid::GetCellData(int row, int col)
{
void *rc = NULL;
wxGridCell *cell = GetCell(row, col);
if ( cell )
rc = cell->GetCellData();
return rc;
}

View File

@@ -118,7 +118,6 @@ libwx_motif_la_SOURCES = \
imaglist.cpp \ imaglist.cpp \
laywin.cpp \ laywin.cpp \
listctrl.cpp \ listctrl.cpp \
msgdlgg.cpp \
panelg.cpp \ panelg.cpp \
printps.cpp \ printps.cpp \
prntdlgg.cpp \ prntdlgg.cpp \
@@ -170,6 +169,7 @@ libwx_motif_la_SOURCES = \
menu.cpp \ menu.cpp \
menuitem.cpp \ menuitem.cpp \
minifram.cpp \ minifram.cpp \
msgdlg.cpp \
notebook.cpp \ notebook.cpp \
palette.cpp \ palette.cpp \
pen.cpp \ pen.cpp \

View File

@@ -6,7 +6,7 @@
// Created: 17/09/98 // Created: 17/09/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@@ -138,7 +138,7 @@ void wxMenu::Append(wxMenuItem *pItem)
m_menuItems.Append(pItem); m_menuItems.Append(pItem);
if (m_menuWidget) if (m_menuWidget)
pItem->CreateItem (m_menuWidget, m_menuBar, m_topLevelMenu); // this is a dynamic Append pItem->CreateItem (m_menuWidget, m_menuBar, m_topLevelMenu); // this is a dynamic Append
m_noItems++; m_noItems++;
} }
@@ -444,8 +444,6 @@ bool wxWindow::PopupMenu(wxMenu *menu, int x, int y)
menu->DestroyMenu(TRUE); menu->DestroyMenu(TRUE);
} }
wxWindow *parent = this;
menu->SetId(1); /* Mark as popped-up */ menu->SetId(1); /* Mark as popped-up */
menu->CreateMenu(NULL, widget, menu); menu->CreateMenu(NULL, widget, menu);
menu->SetInvokingWindow(this); menu->SetInvokingWindow(this);
@@ -1009,7 +1007,7 @@ void wxMenu::DestroyMenu (bool full)
item->SetMenuBar((wxMenuBar*) NULL); item->SetMenuBar((wxMenuBar*) NULL);
item->DestroyItem(full); item->DestroyItem(full);
} // for() }// for()
if (m_buttonWidget) if (m_buttonWidget)
{ {
@@ -1054,7 +1052,7 @@ WXWidget wxMenu::FindMenuItem (int id, wxMenuItem ** it) const
return w; return w;
} }
} }
} // for() }// for()
if (it) if (it)
*it = (wxMenuItem*) NULL; *it = (wxMenuItem*) NULL;

View File

@@ -6,7 +6,7 @@
// Created: 17/09/98 // Created: 17/09/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
/* /*
@@ -71,7 +71,6 @@ wxPaletteRefData::wxPaletteRefData()
wxPaletteRefData::~wxPaletteRefData() wxPaletteRefData::~wxPaletteRefData()
{ {
XColor xcol;
Display *display = (Display*) NULL; Display *display = (Display*) NULL;
wxNode *node, *next; wxNode *node, *next;

View File

@@ -6,7 +6,7 @@
// Created: 04/01/98 // Created: 04/01/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
@@ -36,7 +36,7 @@ END_EVENT_TABLE()
#endif #endif
static void wxToolButtonCallback (Widget w, XtPointer clientData, static void wxToolButtonCallback (Widget w, XtPointer clientData,
XtPointer ptr); XtPointer ptr);
static void wxToolButtonPopupCallback (Widget w, XtPointer client_data, static void wxToolButtonPopupCallback (Widget w, XtPointer client_data,
XEvent *event, Boolean *continue_to_dispatch); XEvent *event, Boolean *continue_to_dispatch);
@@ -161,12 +161,12 @@ bool wxToolBar::CreateTools()
button = XtVaCreateWidget("toggleButton", button = XtVaCreateWidget("toggleButton",
xmToggleButtonWidgetClass, (Widget) m_mainWidget, xmToggleButtonWidgetClass, (Widget) m_mainWidget,
XmNx, currentX, XmNy, currentY, XmNx, currentX, XmNy, currentY,
// XmNpushButtonEnabled, True, // XmNpushButtonEnabled, True,
XmNmultiClick, XmMULTICLICK_KEEP, XmNmultiClick, XmMULTICLICK_KEEP,
XmNlabelType, XmPIXMAP, XmNlabelType, XmPIXMAP,
NULL); NULL);
XtAddCallback ((Widget) button, XmNvalueChangedCallback, (XtCallbackProc) wxToolButtonCallback, XtAddCallback ((Widget) button, XmNvalueChangedCallback, (XtCallbackProc) wxToolButtonCallback,
(XtPointer) this); (XtPointer) this);
XtVaSetValues ((Widget) button, XtVaSetValues ((Widget) button,
XmNselectColor, m_backgroundColour.AllocColour(XtDisplay((Widget) button)), XmNselectColor, m_backgroundColour.AllocColour(XtDisplay((Widget) button)),
@@ -198,7 +198,7 @@ bool wxToolBar::CreateTools()
{ {
int backgroundPixel; int backgroundPixel;
XtVaGetValues(button, XmNbackground, &backgroundPixel, XtVaGetValues(button, XmNbackground, &backgroundPixel,
NULL); NULL);
wxColour col; wxColour col;
@@ -214,10 +214,10 @@ bool wxToolBar::CreateTools()
int backgroundPixel; int backgroundPixel;
if (tool->m_isToggle) if (tool->m_isToggle)
XtVaGetValues(button, XmNselectColor, &backgroundPixel, XtVaGetValues(button, XmNselectColor, &backgroundPixel,
NULL); NULL);
else else
XtVaGetValues(button, XmNarmColor, &backgroundPixel, XtVaGetValues(button, XmNarmColor, &backgroundPixel,
NULL); NULL);
wxColour col; wxColour col;
col.SetPixel(backgroundPixel); col.SetPixel(backgroundPixel);
@@ -235,7 +235,7 @@ bool wxToolBar::CreateTools()
{ {
wxBitmap newBitmap = wxCreateMaskedBitmap(originalBitmap, col); wxBitmap newBitmap = wxCreateMaskedBitmap(originalBitmap, col);
tool->m_bitmap2 = newBitmap; tool->m_bitmap2 = newBitmap;
} }
else else
tool->m_bitmap2 = tool->m_bitmap1; tool->m_bitmap2 = tool->m_bitmap1;
} }
@@ -264,11 +264,11 @@ bool wxToolBar::CreateTools()
} }
XtVaSetValues (button, XtVaSetValues (button,
XmNindicatorOn, False, XmNindicatorOn, False,
XmNshadowThickness, 2, XmNshadowThickness, 2,
// XmNborderWidth, 0, // XmNborderWidth, 0,
// XmNspacing, 0, // XmNspacing, 0,
XmNmarginWidth, 0, XmNmarginWidth, 0,
XmNmarginHeight, 0, XmNmarginHeight, 0,
XmNfillOnSelect, True, XmNfillOnSelect, True,
XmNlabelPixmap, pixmap, XmNlabelPixmap, pixmap,
XmNselectPixmap, pixmap2, XmNselectPixmap, pixmap2,
@@ -303,7 +303,7 @@ bool wxToolBar::CreateTools()
Dimension width, height; Dimension width, height;
XtVaGetValues(button, XmNwidth, & width, XmNheight, & height, XtVaGetValues(button, XmNwidth, & width, XmNheight, & height,
NULL); NULL);
currentX += width + marginX; currentX += width + marginX;
buttonHeight = wxMax(buttonHeight, height); buttonHeight = wxMax(buttonHeight, height);
@@ -471,7 +471,7 @@ WXWidget wxToolBar::GetMainWidget() const
void wxToolButtonCallback (Widget w, XtPointer clientData, void wxToolButtonCallback (Widget w, XtPointer clientData,
XtPointer ptr) XtPointer ptr)
{ {
wxToolBar *toolBar = (wxToolBar *) clientData; wxToolBar *toolBar = (wxToolBar *) clientData;
int index = toolBar->FindIndexForWidget((WXWidget) w); int index = toolBar->FindIndexForWidget((WXWidget) w);
@@ -505,7 +505,6 @@ static void wxToolButtonPopupCallback (Widget w, XtPointer client_data,
wxNode *node = toolBar->GetTools().Find((long)index); wxNode *node = toolBar->GetTools().Find((long)index);
if (!node) if (!node)
return; return;
wxToolBarTool *tool = (wxToolBarTool *)node->Data();
wxString str(toolBar->GetToolShortHelp(index)); wxString str(toolBar->GetToolShortHelp(index));
if (str.IsNull() || str == "") if (str.IsNull() || str == "")
return; return;
@@ -513,8 +512,8 @@ static void wxToolButtonPopupCallback (Widget w, XtPointer client_data,
if (!wxTheToolBarTimer) if (!wxTheToolBarTimer)
wxTheToolBarTimer = new wxToolBarTimer; wxTheToolBarTimer = new wxToolBarTimer;
wxToolBarTimer::buttonWidget = w; wxToolBarTimer::buttonWidget = w;
wxToolBarTimer::helpString = str; wxToolBarTimer::helpString = str;
/************************************************************/ /************************************************************/
@@ -526,7 +525,7 @@ static void wxToolButtonPopupCallback (Widget w, XtPointer client_data,
{ {
XtDestroyWidget (wxToolBarTimer::help_popup); XtDestroyWidget (wxToolBarTimer::help_popup);
XtPopdown (wxToolBarTimer::help_popup); XtPopdown (wxToolBarTimer::help_popup);
} }
wxToolBarTimer::help_popup = (Widget) 0; wxToolBarTimer::help_popup = (Widget) 0;
// One shot // One shot
@@ -544,7 +543,7 @@ static void wxToolButtonPopupCallback (Widget w, XtPointer client_data,
{ {
XtDestroyWidget (wxToolBarTimer::help_popup); XtDestroyWidget (wxToolBarTimer::help_popup);
XtPopdown (wxToolBarTimer::help_popup); XtPopdown (wxToolBarTimer::help_popup);
} }
wxToolBarTimer::help_popup = (Widget) 0; wxToolBarTimer::help_popup = (Widget) 0;
} }
} }

View File

@@ -75,7 +75,7 @@ void wxFlushEvents()
Display *display = (Display*) wxGetDisplay(); Display *display = (Display*) wxGetDisplay();
XSync (display, FALSE); XSync (display, FALSE);
XEvent event;
// XtAppPending returns availability of events AND timers/inputs, which // XtAppPending returns availability of events AND timers/inputs, which
// are processed via callbacks, so XtAppNextEvent will not return if // are processed via callbacks, so XtAppNextEvent will not return if
// there are no events. So added '& XtIMXEvent' - Sergey. // there are no events. So added '& XtIMXEvent' - Sergey.