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

@@ -2,7 +2,7 @@
// Name: gridg.h
// Purpose: wxGenericGrid
// Author: Julian Smart
// Modified by: Michael Bedward
// Modified by: Michael Bedward
// Added edit in place facility, 20 April 1999
// Added cursor key control, 29 Jun 1999
// Created: 01/02/97
@@ -101,12 +101,16 @@ public:
void SetCellTextFont(const wxFont& fnt, int row, int col);
wxBitmap *GetCellBitmap(int row, int col) const;
void SetCellBitmap(wxBitmap *bitmap, int row, int col);
void *SetCellData(void *data, int row, int col);
void *GetCellData(int row, int col);
// Size accessors
void SetColumnWidth(int col, int width);
int GetColumnWidth(int col) const;
void SetRowHeight(int row, int height);
int GetRowHeight(int row) const;
int GetViewHeight() const { return m_viewHeight; }
int GetViewWidth() const { return m_viewWidth; }
// Label accessors
void SetLabelSize(int orientation, int sz);
@@ -266,6 +270,8 @@ protected:
int m_bottomOfSheet; // Calculated from m_rowHeights
int m_totalGridWidth; // Total 'virtual' size
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_verticalLabelWidth;
int m_horizontalLabelHeight;
@@ -318,7 +324,8 @@ public:
wxColour backgroundColour;
wxBrush backgroundBrush;
wxBitmap* cellBitmap;
int alignment;
void* cellData; // intended for additional data associated with a cell
int alignment;
wxGridCell(wxGenericGrid *window = (wxGenericGrid *) NULL);
~wxGridCell();
@@ -337,6 +344,9 @@ public:
void SetAlignment(int align) { alignment = align; }
wxBitmap *GetCellBitmap() const { return cellBitmap; }
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

View File

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

View File

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

View File

@@ -6,7 +6,7 @@
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
@@ -66,7 +66,7 @@ wxMenu::wxMenu(const wxString& title, const wxFunction func)
m_noItems = 0;
m_menuBar = NULL;
m_pInvokingWindow = NULL;
//// Motif-specific members
m_numColumns = 1;
m_menuWidget = (WXWidget) NULL;
@@ -77,7 +77,7 @@ wxMenu::wxMenu(const wxString& title, const wxFunction func)
m_ownedByMenuBar = FALSE;
m_menuParent = (wxMenu*) NULL;
m_clientData = (void*) NULL;
if (m_title != "")
{
Append(ID_SEPARATOR, m_title) ;
@@ -86,7 +86,7 @@ wxMenu::wxMenu(const wxString& title, const wxFunction func)
m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_MENU);
m_foregroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_MENUTEXT);
m_font = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
Callback(func);
}
@@ -100,24 +100,24 @@ wxMenu::~wxMenu()
else
DestroyMenu(FALSE);
}
// Not sure if this is right
if (m_menuParent && m_menuBar)
{
m_menuParent = NULL;
// m_menuBar = NULL;
}
wxNode *node = m_menuItems.First();
while (node)
{
wxMenuItem *item = (wxMenuItem *)node->Data();
/*
if (item->GetSubMenu())
item->DeleteSubMenu();
*/
wxNode *next = node->Next();
delete item;
delete node;
@@ -134,12 +134,12 @@ void wxMenu::Break()
void wxMenu::Append(wxMenuItem *pItem)
{
wxCHECK_RET( pItem != NULL, "can't append NULL item to the menu" );
m_menuItems.Append(pItem);
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++;
}
@@ -154,16 +154,16 @@ void wxMenu::AppendSeparator()
// as well as in m_menuItems, whereas we only store it in
// m_menuItems here. What implications does this have?
void wxMenu::Append(int id, const wxString& label, wxMenu *subMenu,
void wxMenu::Append(int id, const wxString& label, wxMenu *subMenu,
const wxString& helpString)
{
Append(new wxMenuItem(this, id, label, helpString, FALSE, subMenu));
subMenu->m_topLevelMenu = m_topLevelMenu;
}
// Ordinary menu item
void wxMenu::Append(int id, const wxString& label,
void wxMenu::Append(int id, const wxString& label,
const wxString& helpString, bool checkable)
{
// 'checkable' parameter is useless for Windows.
@@ -175,19 +175,19 @@ void wxMenu::Delete(int id)
wxNode *node;
wxMenuItem *item;
int pos;
for (pos = 0, node = m_menuItems.First(); node; node = node->Next(), pos++)
for (pos = 0, node = m_menuItems.First(); node; node = node->Next(), pos++)
{
item = (wxMenuItem *)node->Data();
if (item->GetId() == id)
break;
}
if (!node)
return;
item->DestroyItem(TRUE);
// See also old code - don't know if this is needed (seems redundant).
/*
if (item->GetSubMenu()) {
@@ -196,7 +196,7 @@ void wxMenu::Delete(int id)
children->DeleteObject(item->GetSubMenu());
}
*/
m_menuItems.DeleteNode(node);
delete item;
}
@@ -205,7 +205,7 @@ void wxMenu::Enable(int id, bool flag)
{
wxMenuItem *item = FindItemForId(id);
wxCHECK_RET( item != NULL, "can't enable non-existing menu item" );
item->Enable(flag);
}
@@ -213,7 +213,7 @@ bool wxMenu::Enabled(int Id) const
{
wxMenuItem *item = FindItemForId(Id);
wxCHECK( item != NULL, FALSE );
return item->IsEnabled();
}
@@ -221,7 +221,7 @@ void wxMenu::Check(int Id, bool Flag)
{
wxMenuItem *item = FindItemForId(Id);
wxCHECK_RET( item != NULL, "can't get status of non-existing menu item" );
item->Check(Flag);
}
@@ -229,23 +229,23 @@ bool wxMenu::Checked(int id) const
{
wxMenuItem *item = FindItemForId(id);
wxCHECK( item != NULL, FALSE );
return item->IsChecked();
}
void wxMenu::SetTitle(const wxString& label)
{
m_title = label ;
wxNode *node = m_menuItems.First ();
if (!node)
return;
wxMenuItem *item = (wxMenuItem *) node->Data ();
Widget widget = (Widget) item->GetButtonWidget();
if (!widget)
return;
XmString title_str = XmStringCreateSimple ((char*) (const char*) label);
XtVaSetValues (widget,
XmNlabelString, title_str,
@@ -263,7 +263,7 @@ void wxMenu::SetLabel(int id, const wxString& label)
wxMenuItem *item = FindItemForId(id);
if (item == (wxMenuItem*) NULL)
return;
item->SetLabel(label);
}
@@ -278,7 +278,7 @@ wxString wxMenu::GetLabel(int id) const
XtVaGetValues ((Widget) w,
XmNlabelString, &text,
NULL);
if (XmStringGetLtoR (text, XmSTRING_DEFAULT_CHARSET, &s))
{
wxString str(s);
@@ -301,7 +301,7 @@ int wxMenu::FindItem (const wxString& itemString) const
char buf1[200];
char buf2[200];
wxStripMenuCodes ((char *)(const char *)itemString, buf1);
for (wxNode * node = m_menuItems.First (); node; node = node->Next ())
{
wxMenuItem *item = (wxMenuItem *) node->Data ();
@@ -318,7 +318,7 @@ int wxMenu::FindItem (const wxString& itemString) const
return item->GetId();
}
}
return -1;
}
@@ -329,14 +329,14 @@ wxMenuItem *wxMenu::FindItemForId(int itemId, wxMenu ** itemMenu) const
for (wxNode * node = m_menuItems.First (); node; node = node->Next ())
{
wxMenuItem *item = (wxMenuItem *) node->Data ();
if (item->GetId() == itemId)
{
if (itemMenu)
*itemMenu = (wxMenu *) this;
return item;
}
if (item->GetSubMenu())
{
wxMenuItem *ans = item->GetSubMenu()->FindItemForId (itemId, itemMenu);
@@ -344,7 +344,7 @@ wxMenuItem *wxMenu::FindItemForId(int itemId, wxMenu ** itemMenu) const
return ans;
}
}
if (itemMenu)
*itemMenu = NULL;
return NULL;
@@ -367,14 +367,14 @@ wxString wxMenu::GetHelpString (int itemId) const
void wxMenu::ProcessCommand(wxCommandEvent & event)
{
bool processed = FALSE;
// Try a callback
if (m_callback)
{
(void) (*(m_callback)) (*this, event);
processed = TRUE;
}
// Try the menu's event handler
if ( !processed && GetEventHandler())
{
@@ -429,23 +429,21 @@ void wxMenu::UpdateUI(wxEvtHandler* source)
bool wxWindow::PopupMenu(wxMenu *menu, int x, int y)
{
Widget widget = (Widget) GetMainWidget();
/* The menuId field seems to be usused, so we'll use it to
indicate whether a menu is popped up or not:
0: Not currently created as a popup
-1: Created as a popup, but not active
1: Active popup.
*/
if (menu->GetParent() && (menu->GetId() != -1))
return FALSE;
if (menu->GetMainWidget()) {
menu->DestroyMenu(TRUE);
}
wxWindow *parent = this;
menu->SetId(1); /* Mark as popped-up */
menu->CreateMenu(NULL, widget, menu);
menu->SetInvokingWindow(this);
@@ -454,12 +452,12 @@ bool wxWindow::PopupMenu(wxMenu *menu, int x, int y)
// menu->SetParent(parent);
// parent->children->Append(menu); // Store menu for later deletion
Widget menuWidget = (Widget) menu->GetMainWidget();
int rootX = 0;
int rootY = 0;
int deviceX = x;
int deviceY = y;
/*
@@ -470,27 +468,27 @@ bool wxWindow::PopupMenu(wxMenu *menu, int x, int y)
deviceY = canvas->GetDC ()->LogicalToDeviceY (y);
}
*/
Display *display = XtDisplay (widget);
Window rootWindow = RootWindowOfScreen (XtScreen((Widget)widget));
Window thisWindow = XtWindow (widget);
Window childWindow;
XTranslateCoordinates (display, thisWindow, rootWindow, (int) deviceX, (int) deviceY,
&rootX, &rootY, &childWindow);
XButtonPressedEvent event;
event.type = ButtonPress;
event.button = 1;
event.x = deviceX;
event.y = deviceY;
event.x_root = rootX;
event.y_root = rootY;
XmMenuPosition (menuWidget, &event);
XtManageChild (menuWidget);
return TRUE;
}
@@ -571,10 +569,10 @@ void wxMenuBar::Check(int id, bool flag)
wxMenuItem *item = FindItemForId(id, &itemMenu) ;
if (!item)
return;
if (!item->IsCheckable())
return ;
item->Check(flag);
}
@@ -584,7 +582,7 @@ bool wxMenuBar::Checked(int id) const
wxMenuItem *item = FindItemForId(id, &itemMenu) ;
if (!item)
return FALSE;
return item->IsChecked();
}
@@ -594,7 +592,7 @@ bool wxMenuBar::Enabled(int id) const
wxMenuItem *item = FindItemForId(id, &itemMenu) ;
if (!item)
return FALSE;
return item->IsEnabled();
}
@@ -602,10 +600,10 @@ void wxMenuBar::SetLabel(int id, const wxString& label)
{
wxMenu *itemMenu = NULL;
wxMenuItem *item = FindItemForId(id, &itemMenu) ;
if (!item)
return;
item->SetLabel(label);
}
@@ -613,17 +611,17 @@ wxString wxMenuBar::GetLabel(int id) const
{
wxMenu *itemMenu = NULL;
wxMenuItem *item = FindItemForId(id, &itemMenu) ;
if (!item)
return wxString("");
return item->GetLabel();
}
void wxMenuBar::SetLabelTop(int pos, const wxString& label)
{
wxASSERT( (pos < m_menuCount) );
Widget w = (Widget) m_menus[pos]->GetButtonWidget();
if (w)
{
@@ -638,7 +636,7 @@ void wxMenuBar::SetLabelTop(int pos, const wxString& label)
wxString wxMenuBar::GetLabelTop(int pos) const
{
wxASSERT( (pos < m_menuCount) );
Widget w = (Widget) m_menus[pos]->GetButtonWidget();
if (w)
{
@@ -647,7 +645,7 @@ wxString wxMenuBar::GetLabelTop(int pos) const
XtVaGetValues (w,
XmNlabelString, &text,
NULL);
if (XmStringGetLtoR (text, XmSTRING_DEFAULT_CHARSET, &s))
{
wxString str(s);
@@ -661,7 +659,7 @@ wxString wxMenuBar::GetLabelTop(int pos) const
}
else
return wxEmptyString;
}
bool wxMenuBar::OnDelete(wxMenu *menu, int pos)
@@ -669,7 +667,7 @@ bool wxMenuBar::OnDelete(wxMenu *menu, int pos)
// Only applies to dynamic deletion (when set in frame)
if (!m_menuBarFrame)
return TRUE;
menu->DestroyMenu(TRUE);
return TRUE;
}
@@ -679,18 +677,18 @@ bool wxMenuBar::OnAppend(wxMenu *menu, const char *title)
// Only applies to dynamic append (when set in frame)
if (!m_menuBarFrame)
return TRUE;
// Probably should be an assert here
if (menu->GetParent())
return FALSE;
// Has already been appended
if (menu->GetButtonWidget())
return FALSE;
WXWidget w = menu->CreateMenu(this, GetMainWidget(), menu, title, TRUE);
menu->SetButtonWidget(w);
return TRUE;
}
@@ -698,12 +696,12 @@ void wxMenuBar::Append (wxMenu * menu, const wxString& title)
{
if (!OnAppend(menu, title))
return;
m_menuCount ++;
wxMenu **new_menus = new wxMenu *[m_menuCount];
wxString *new_titles = new wxString[m_menuCount];
int i;
for (i = 0; i < m_menuCount - 1; i++)
{
new_menus[i] = m_menus[i];
@@ -718,10 +716,10 @@ void wxMenuBar::Append (wxMenu * menu, const wxString& title)
}
m_menus = new_menus;
m_titles = new_titles;
m_menus[m_menuCount - 1] = (wxMenu *)menu;
m_titles[m_menuCount - 1] = title;
menu->SetMenuBar(this);
menu->SetParent(this);
}
@@ -730,7 +728,7 @@ void wxMenuBar::Delete(wxMenu * menu, int i)
{
int j;
int ii = (int) i;
if (menu != 0)
{
for (ii = 0; ii < m_menuCount; ii++)
@@ -746,12 +744,12 @@ void wxMenuBar::Delete(wxMenu * menu, int i)
return;
menu = m_menus[ii];
}
if (!OnDelete(menu, ii))
return;
menu->SetParent((wxEvtHandler*) NULL);
-- m_menuCount;
for (j = ii; j < m_menuCount; j++)
{
@@ -781,7 +779,7 @@ wxMenuItem *wxMenuBar::FindItemForId (int id, wxMenu ** itemMenu) const
{
if (itemMenu)
*itemMenu = NULL;
wxMenuItem *item = NULL;
int i;
for (i = 0; i < m_menuCount; i++)
@@ -827,35 +825,35 @@ bool wxMenuBar::CreateMenuBar(wxFrame* parent)
XtMapWidget((Widget) m_mainWidget);
return TRUE;
}
Widget menuBarW = XmCreateMenuBar ((Widget) parent->GetMainWindowWidget(), "MenuBar", NULL, 0);
m_mainWidget = (WXWidget) menuBarW;
int i;
for (i = 0; i < GetMenuCount(); i++)
{
wxMenu *menu = GetMenu(i);
wxString title(m_titles[i]);
menu->SetButtonWidget(menu->CreateMenu (this, menuBarW, menu, title, TRUE));
/*
* COMMENT THIS OUT IF YOU DON'T LIKE A RIGHT-JUSTIFIED HELP MENU
*/
wxStripMenuCodes ((char*) (const char*) title, wxBuffer);
if (strcmp (wxBuffer, "Help") == 0)
XtVaSetValues ((Widget) menuBarW, XmNmenuHelpWidget, (Widget) menu->GetButtonWidget(), NULL);
}
SetBackgroundColour(m_backgroundColour);
SetForegroundColour(m_foregroundColour);
SetFont(m_font);
XtVaSetValues((Widget) parent->GetMainWindowWidget(), XmNmenuBar, (Widget) m_mainWidget, NULL);
XtRealizeWidget ((Widget) menuBarW);
XtManageChild ((Widget) menuBarW);
SetMenuBarFrame(parent);
return TRUE;
}
@@ -867,22 +865,22 @@ bool wxMenuBar::DestroyMenuBar()
SetMenuBarFrame((wxFrame*) NULL);
return FALSE;
}
XtUnmanageChild ((Widget) m_mainWidget);
XtUnrealizeWidget ((Widget) m_mainWidget);
int i;
for (i = 0; i < GetMenuCount(); i++)
{
wxMenu *menu = GetMenu(i);
menu->DestroyMenu(TRUE);
}
XtDestroyWidget((Widget) m_mainWidget);
m_mainWidget = (WXWidget) 0;
SetMenuBarFrame((wxFrame*) NULL);
return TRUE;
}
@@ -900,7 +898,7 @@ int PostDeletionOfMenu( XtPointer* clientData )
{
XtRemoveWorkProc(WorkProcMenuId);
wxMenu *menu = (wxMenu *)clientData;
if (menu->GetMainWidget()) {
if (menu->GetParent())
{
@@ -914,20 +912,20 @@ int PostDeletionOfMenu( XtPointer* clientData )
return TRUE;
}
void
void
wxMenuPopdownCallback(Widget w, XtPointer clientData,
XtPointer ptr)
{
wxMenu *menu = (wxMenu *)clientData;
// Added by JOREL Jean-Charles <jjorel@silr.ireste.fr>
/* Since Callbacks of MenuItems are not yet processed, we put a
* background job which will be done when system will be idle.
* What awful hack!! :(
*/
WorkProcMenuId = XtAppAddWorkProc(
(XtAppContext) wxTheApp->GetAppContext(),
WorkProcMenuId = XtAppAddWorkProc(
(XtAppContext) wxTheApp->GetAppContext(),
(XtWorkProc) PostDeletionOfMenu,
(XtPointer) menu );
// Apparently not found in Motif headers
@@ -947,12 +945,12 @@ WXWidget wxMenu::CreateMenu (wxMenuBar * menuBar, WXWidget parent, wxMenu * topM
Arg args[5];
XtSetArg (args[0], XmNnumColumns, m_numColumns);
XtSetArg (args[1], XmNpacking, XmPACK_COLUMN);
if (!pullDown)
{
menu = XmCreatePopupMenu ((Widget) parent, "popup", args, 2);
XtAddCallback(menu,
XmNunmapCallback,
XmNunmapCallback,
(XtCallbackProc)wxMenuPopdownCallback,
(XtPointer)this);
}
@@ -960,9 +958,9 @@ WXWidget wxMenu::CreateMenu (wxMenuBar * menuBar, WXWidget parent, wxMenu * topM
{
char mnem = wxFindMnemonic (title);
wxStripMenuCodes ((char*) (const char*) title, wxBuffer);
menu = XmCreatePulldownMenu ((Widget) parent, "pulldown", args, 2);
XmString label_str = XmStringCreateSimple (wxBuffer);
buttonWidget = XtVaCreateManagedWidget (wxBuffer,
#if wxUSE_GADGETS
@@ -973,44 +971,44 @@ WXWidget wxMenu::CreateMenu (wxMenuBar * menuBar, WXWidget parent, wxMenu * topM
XmNlabelString, label_str,
XmNsubMenuId, menu,
NULL);
if (mnem != 0)
XtVaSetValues (buttonWidget, XmNmnemonic, mnem, NULL);
XmStringFree (label_str);
}
m_menuWidget = (WXWidget) menu;
m_menuBar = menuBar;
m_topLevelMenu = topMenu;
for (wxNode * node = m_menuItems.First (); node; node = node->Next ())
{
wxMenuItem *item = (wxMenuItem *) node->Data ();
item->CreateItem (menu, menuBar, topMenu);
}
SetBackgroundColour(m_backgroundColour);
SetForegroundColour(m_foregroundColour);
SetFont(m_font);
return buttonWidget;
}
// Destroys the Motif implementation of the menu,
// but maintains the wxWindows data structures so we can
// do a CreateMenu again.
// do a CreateMenu again.
void wxMenu::DestroyMenu (bool full)
{
for (wxNode * node = m_menuItems.First (); node; node = node->Next ())
{
wxMenuItem *item = (wxMenuItem *) node->Data ();
item->SetMenuBar((wxMenuBar*) NULL);
item->DestroyItem(full);
} // for()
}// for()
if (m_buttonWidget)
{
if (full)
@@ -1035,7 +1033,7 @@ WXWidget wxMenu::FindMenuItem (int id, wxMenuItem ** it) const
*it = (wxMenuItem*) NULL;
return m_buttonWidget;
}
for (wxNode * node = m_menuItems.First (); node; node = node->Next ())
{
wxMenuItem *item = (wxMenuItem *) node->Data ();
@@ -1045,7 +1043,7 @@ WXWidget wxMenu::FindMenuItem (int id, wxMenuItem ** it) const
*it = item;
return item->GetButtonWidget();
}
if (item->GetSubMenu())
{
WXWidget w = item->GetSubMenu()->FindMenuItem (id, it);
@@ -1054,8 +1052,8 @@ WXWidget wxMenu::FindMenuItem (int id, wxMenuItem ** it) const
return w;
}
}
} // for()
}// for()
if (it)
*it = (wxMenuItem*) NULL;
return (WXWidget) NULL;
@@ -1068,7 +1066,7 @@ void wxMenu::SetBackgroundColour(const wxColour& col)
wxDoChangeBackgroundColour(m_menuWidget, (wxColour&) col);
if (m_buttonWidget)
wxDoChangeBackgroundColour(m_buttonWidget, (wxColour&) col, TRUE);
wxNode* node = m_menuItems.First();
while (node)
{
@@ -1091,7 +1089,7 @@ void wxMenu::SetForegroundColour(const wxColour& col)
wxDoChangeForegroundColour(m_menuWidget, (wxColour&) col);
if (m_buttonWidget)
wxDoChangeForegroundColour(m_buttonWidget, (wxColour&) col);
wxNode* node = m_menuItems.First();
while (node)
{
@@ -1110,12 +1108,12 @@ void wxMenu::SetForegroundColour(const wxColour& col)
void wxMenu::ChangeFont(bool keepOriginalSize)
{
// lesstif 0.87 hangs when setting XmNfontList
#ifndef LESSTIF_VERSION
#ifndef LESSTIF_VERSION
if (!m_font.Ok() || !m_menuWidget)
return;
XmFontList fontList = (XmFontList) m_font.GetFontList(1.0, XtDisplay((Widget) m_menuWidget));
XtVaSetValues ((Widget) m_menuWidget,
XmNfontList, fontList,
NULL);
@@ -1150,7 +1148,7 @@ void wxMenu::SetFont(const wxFont& font)
void wxMenuBar::SetBackgroundColour(const wxColour& col)
{
m_backgroundColour = col;
if (m_mainWidget)
wxDoChangeBackgroundColour(m_mainWidget, (wxColour&) col);
@@ -1164,7 +1162,7 @@ void wxMenuBar::SetForegroundColour(const wxColour& col)
m_foregroundColour = col;
if (m_mainWidget)
wxDoChangeForegroundColour(m_mainWidget, (wxColour&) col);
int i;
for (i = 0; i < m_menuCount; i++)
m_menus[i]->SetForegroundColour((wxColour&) col);
@@ -1179,7 +1177,7 @@ void wxMenuBar::SetFont(const wxFont& font)
{
m_font = font;
ChangeFont();
int i;
for (i = 0; i < m_menuCount; i++)
m_menus[i]->SetFont(font);

View File

@@ -6,7 +6,7 @@
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/*
@@ -17,7 +17,7 @@
* in Create(). The cells are freed on the next call to Create()
* or when the destructor is called.
*/
/* Wolfram Gloger <u7y22ab@sunmail.lrz-muenchen.de>
I have implemented basic colormap support for the X11 versions of
wxWindows, notably wxPalette::Create(). The way I did it is to
@@ -71,11 +71,10 @@ wxPaletteRefData::wxPaletteRefData()
wxPaletteRefData::~wxPaletteRefData()
{
XColor xcol;
Display *display = (Display*) NULL;
wxNode *node, *next;
for (node = m_palettes.First(); node; node = next) {
wxXPalette *c = (wxXPalette *)node->Data();
unsigned long *pix_array = c->m_pix_array;
@@ -83,7 +82,7 @@ wxPaletteRefData::~wxPaletteRefData()
bool destroyable = c->m_destroyable;
int pix_array_n = c->m_pix_array_n;
display = (Display*) c->m_display;
if (pix_array_n > 0)
{
// XFreeColors(display, cmap, pix_array, pix_array_n, 0);
@@ -96,10 +95,10 @@ wxPaletteRefData::~wxPaletteRefData()
}
delete [] pix_array;
}
if (destroyable)
XFreeColormap(display, cmap);
next = node->Next();
m_palettes.DeleteNode(node);
delete c;
@@ -122,26 +121,26 @@ wxPalette::~wxPalette()
bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue)
{
UnRef();
if (!n) {
return FALSE;
}
m_refData = new wxPaletteRefData;
XColor xcol;
Display* display = (Display*) wxGetDisplay();
unsigned long *pix_array;
Colormap cmap;
int pix_array_n;
cmap = (Colormap) wxTheApp->GetMainColormap(display);
pix_array = new unsigned long[n];
if (!pix_array)
return FALSE;
pix_array_n = n;
xcol.flags = DoRed | DoGreen | DoBlue;
for(int i = 0; i < n; i++) {
@@ -150,16 +149,16 @@ bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *gre
xcol.blue = (unsigned short)blue[i] << 8;
pix_array[i] = (XAllocColor(display, cmap, &xcol) == 0) ? 0 : xcol.pixel;
}
wxXPalette *c = new wxXPalette;
c->m_pix_array_n = pix_array_n;
c->m_pix_array = pix_array;
c->m_cmap = (WXColormap) cmap;
c->m_display = (WXDisplay*) display;
c->m_destroyable = FALSE;
M_PALETTEDATA->m_palettes.Append(c);
return TRUE;
}
@@ -167,7 +166,7 @@ int wxPalette::GetPixel(const unsigned char red, const unsigned char green, cons
{
if ( !m_refData )
return FALSE;
// TODO
return FALSE;
}
@@ -176,10 +175,10 @@ bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsi
{
if ( !m_refData )
return FALSE;
if (index < 0 || index > 255)
return FALSE;
// TODO
return FALSE;
}
@@ -188,7 +187,7 @@ WXColormap wxPalette::GetXColormap(WXDisplay* display) const
{
if (!M_PALETTEDATA || (M_PALETTEDATA->m_palettes.Number() == 0))
return wxTheApp->GetMainColormap(display);
wxNode* node = M_PALETTEDATA->m_palettes.First();
if (!display && node)
{
@@ -200,22 +199,22 @@ WXColormap wxPalette::GetXColormap(WXDisplay* display) const
wxXPalette* p = (wxXPalette*) node->Data();
if (p->m_display == display)
return p->m_cmap;
node = node->Next();
}
/* Make a new one: */
wxXPalette *c = new wxXPalette;
wxXPalette *first = (wxXPalette *)M_PALETTEDATA->m_palettes.First()->Data();
XColor xcol;
int pix_array_n = first->m_pix_array_n;
c->m_pix_array_n = pix_array_n;
c->m_pix_array = new unsigned long[pix_array_n];
c->m_display = display;
c->m_cmap = wxTheApp->GetMainColormap(display);
c->m_destroyable = FALSE;
xcol.flags = DoRed | DoGreen | DoBlue;
int i;
for (i = 0; i < pix_array_n; i++)
@@ -225,11 +224,11 @@ WXColormap wxPalette::GetXColormap(WXDisplay* display) const
c->m_pix_array[i] =
(XAllocColor((Display*) display, (Colormap) c->m_cmap, &xcol) == 0) ? 0 : xcol.pixel;
}
// wxPalette* nonConstThis = (wxPalette*) this;
M_PALETTEDATA->m_palettes.Append(c);
return c->m_cmap;
}
@@ -247,7 +246,7 @@ bool wxPalette::TransferBitmap(void *data, int depth, int size)
*uptr = (unsigned char)pix_array[*uptr];
uptr++;
}
return TRUE;
}
default:
@@ -315,7 +314,7 @@ unsigned long *wxPalette::GetXPixArray(WXDisplay *display, int *n)
if (!M_PALETTEDATA)
return (unsigned long*) 0;
wxNode *node;
for (node = M_PALETTEDATA->m_palettes.First(); node; node = node->Next())
{
wxXPalette *c = (wxXPalette *)node->Data();
@@ -326,7 +325,7 @@ unsigned long *wxPalette::GetXPixArray(WXDisplay *display, int *n)
return c->m_pix_array;
}
}
/* Not found; call GetXColormap, which will create it, then this again */
if (GetXColormap(display))
return GetXPixArray(display, n);
@@ -337,17 +336,17 @@ unsigned long *wxPalette::GetXPixArray(WXDisplay *display, int *n)
void wxPalette::PutXColormap(WXDisplay* display, WXColormap cm, bool dp)
{
UnRef();
m_refData = new wxPaletteRefData;
wxXPalette *c = new wxXPalette;
c->m_pix_array_n = 0;
c->m_pix_array = (unsigned long*) NULL;
c->m_display = display;
c->m_cmap = cm;
c->m_destroyable = dp;
M_PALETTEDATA->m_palettes.Append(c);
}

View File

@@ -6,7 +6,7 @@
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
@@ -36,7 +36,7 @@ END_EVENT_TABLE()
#endif
static void wxToolButtonCallback (Widget w, XtPointer clientData,
XtPointer ptr);
XtPointer ptr);
static void wxToolButtonPopupCallback (Widget w, XtPointer client_data,
XEvent *event, Boolean *continue_to_dispatch);
@@ -71,7 +71,7 @@ bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, cons
{
m_maxWidth = -1;
m_maxHeight = -1;
m_defaultWidth = 24;
m_defaultHeight = 22;
SetName(name);
@@ -113,7 +113,7 @@ bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, cons
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
ChangeBackgroundColour();
return TRUE;
}
@@ -158,15 +158,15 @@ bool wxToolBar::CreateTools()
if (tool->m_isToggle)
{
button = XtVaCreateWidget("toggleButton",
button = XtVaCreateWidget("toggleButton",
xmToggleButtonWidgetClass, (Widget) m_mainWidget,
XmNx, currentX, XmNy, currentY,
// XmNpushButtonEnabled, True,
// XmNpushButtonEnabled, True,
XmNmultiClick, XmMULTICLICK_KEEP,
XmNlabelType, XmPIXMAP,
NULL);
XtAddCallback ((Widget) button, XmNvalueChangedCallback, (XtCallbackProc) wxToolButtonCallback,
(XtPointer) this);
(XtPointer) this);
XtVaSetValues ((Widget) button,
XmNselectColor, m_backgroundColour.AllocColour(XtDisplay((Widget) button)),
@@ -174,7 +174,7 @@ bool wxToolBar::CreateTools()
}
else
{
button = XtVaCreateWidget("button",
button = XtVaCreateWidget("button",
xmPushButtonWidgetClass, (Widget) m_mainWidget,
XmNx, currentX, XmNy, currentY,
XmNpushButtonEnabled, True,
@@ -198,12 +198,12 @@ bool wxToolBar::CreateTools()
{
int backgroundPixel;
XtVaGetValues(button, XmNbackground, &backgroundPixel,
NULL);
NULL);
wxColour col;
col.SetPixel(backgroundPixel);
wxBitmap newBitmap = wxCreateMaskedBitmap(tool->m_bitmap1, col);
tool->m_bitmap1 = newBitmap;
@@ -214,10 +214,10 @@ bool wxToolBar::CreateTools()
int backgroundPixel;
if (tool->m_isToggle)
XtVaGetValues(button, XmNselectColor, &backgroundPixel,
NULL);
NULL);
else
XtVaGetValues(button, XmNarmColor, &backgroundPixel,
NULL);
NULL);
wxColour col;
col.SetPixel(backgroundPixel);
@@ -235,7 +235,7 @@ bool wxToolBar::CreateTools()
{
wxBitmap newBitmap = wxCreateMaskedBitmap(originalBitmap, col);
tool->m_bitmap2 = newBitmap;
}
}
else
tool->m_bitmap2 = tool->m_bitmap1;
}
@@ -264,11 +264,11 @@ bool wxToolBar::CreateTools()
}
XtVaSetValues (button,
XmNindicatorOn, False,
XmNshadowThickness, 2,
// XmNborderWidth, 0,
// XmNspacing, 0,
XmNmarginWidth, 0,
XmNmarginHeight, 0,
XmNshadowThickness, 2,
// XmNborderWidth, 0,
// XmNspacing, 0,
XmNmarginWidth, 0,
XmNmarginHeight, 0,
XmNfillOnSelect, True,
XmNlabelPixmap, pixmap,
XmNselectPixmap, pixmap2,
@@ -303,11 +303,11 @@ bool wxToolBar::CreateTools()
Dimension width, height;
XtVaGetValues(button, XmNwidth, & width, XmNheight, & height,
NULL);
NULL);
currentX += width + marginX;
buttonHeight = wxMax(buttonHeight, height);
XtAddEventHandler (button, EnterWindowMask | LeaveWindowMask,
XtAddEventHandler (button, EnterWindowMask | LeaveWindowMask,
False, wxToolButtonPopupCallback, (XtPointer) this);
m_widgets.Append(tool->m_index, (wxObject*) button);
@@ -471,7 +471,7 @@ WXWidget wxToolBar::GetMainWidget() const
void wxToolButtonCallback (Widget w, XtPointer clientData,
XtPointer ptr)
XtPointer ptr)
{
wxToolBar *toolBar = (wxToolBar *) clientData;
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);
if (!node)
return;
wxToolBarTool *tool = (wxToolBarTool *)node->Data();
wxString str(toolBar->GetToolShortHelp(index));
if (str.IsNull() || str == "")
return;
@@ -513,8 +512,8 @@ static void wxToolButtonPopupCallback (Widget w, XtPointer client_data,
if (!wxTheToolBarTimer)
wxTheToolBarTimer = new wxToolBarTimer;
wxToolBarTimer::buttonWidget = w;
wxToolBarTimer::helpString = str;
wxToolBarTimer::buttonWidget = w;
wxToolBarTimer::helpString = str;
/************************************************************/
@@ -526,7 +525,7 @@ static void wxToolButtonPopupCallback (Widget w, XtPointer client_data,
{
XtDestroyWidget (wxToolBarTimer::help_popup);
XtPopdown (wxToolBarTimer::help_popup);
}
}
wxToolBarTimer::help_popup = (Widget) 0;
// One shot
@@ -544,7 +543,7 @@ static void wxToolButtonPopupCallback (Widget w, XtPointer client_data,
{
XtDestroyWidget (wxToolBarTimer::help_popup);
XtPopdown (wxToolBarTimer::help_popup);
}
}
wxToolBarTimer::help_popup = (Widget) 0;
}
}
@@ -557,16 +556,16 @@ void wxToolBarTimer::Notify()
/************************************************************/
/* Create shell without window decorations */
/************************************************************/
help_popup = XtVaCreatePopupShell ("shell",
overrideShellWidgetClass, (Widget) wxTheApp->GetTopLevelWidget(),
help_popup = XtVaCreatePopupShell ("shell",
overrideShellWidgetClass, (Widget) wxTheApp->GetTopLevelWidget(),
NULL);
/************************************************************/
/* Get absolute position on display of toolbar button */
/************************************************************/
XtTranslateCoords (buttonWidget,
(Position) 0,
(Position) 0,
(Position) 0,
(Position) 0,
&x, &y);
// Move the tooltip more or less above the button
@@ -577,24 +576,24 @@ void wxToolBarTimer::Notify()
/************************************************************/
/* Set the position of the help popup */
/************************************************************/
XtVaSetValues (help_popup,
XmNx, (Position) x,
XmNy, (Position) y,
XtVaSetValues (help_popup,
XmNx, (Position) x,
XmNy, (Position) y,
NULL);
/************************************************************/
/* Create help label */
/************************************************************/
XmString text = XmStringCreateSimple ((char*) (const char*) helpString);
XtVaCreateManagedWidget ("help_label",
xmLabelWidgetClass, help_popup,
XtVaCreateManagedWidget ("help_label",
xmLabelWidgetClass, help_popup,
XmNlabelString, text,
XtVaTypedArg,
XmNforeground, XtRString, "black",
strlen("black")+1,
XtVaTypedArg,
XmNbackground, XtRString, "LightGoldenrod",
strlen("LightGoldenrod")+1,
XtVaTypedArg,
XmNforeground, XtRString, "black",
strlen("black")+1,
XtVaTypedArg,
XmNbackground, XtRString, "LightGoldenrod",
strlen("LightGoldenrod")+1,
NULL);
XmStringFree (text);

View File

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