Change a Popup menu from using a callback to using events. Can't test
it right now but it compiles. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4365 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -37,8 +37,6 @@
|
|||||||
// construct themselves.
|
// construct themselves.
|
||||||
wxExprDatabase *GlobalwxExprDatabase = NULL;
|
wxExprDatabase *GlobalwxExprDatabase = NULL;
|
||||||
|
|
||||||
// Popup menu for editing divisions
|
|
||||||
wxMenu *oglPopupDivisionMenu = NULL;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Division control point
|
* Division control point
|
||||||
@@ -1572,10 +1570,32 @@ bool wxDivisionShape::ResizeAdjoining(int side, double newPos, bool test)
|
|||||||
* Popup menu for editing divisions
|
* Popup menu for editing divisions
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
class OGLPopupDivisionMenu : public wxMenu {
|
||||||
|
public:
|
||||||
|
OGLPopupDivisionMenu() : wxMenu() {
|
||||||
|
Append(DIVISION_MENU_SPLIT_HORIZONTALLY, "Split horizontally");
|
||||||
|
Append(DIVISION_MENU_SPLIT_VERTICALLY, "Split vertically");
|
||||||
|
AppendSeparator();
|
||||||
|
Append(DIVISION_MENU_EDIT_LEFT_EDGE, "Edit left edge");
|
||||||
|
Append(DIVISION_MENU_EDIT_TOP_EDGE, "Edit top edge");
|
||||||
|
}
|
||||||
|
|
||||||
void oglGraphicsDivisionMenuProc(wxMenu& menu, wxCommandEvent& event)
|
void OnMenu(wxCommandEvent& event);
|
||||||
|
|
||||||
|
DECLARE_EVENT_TABLE();
|
||||||
|
};
|
||||||
|
|
||||||
|
BEGIN_EVENT_TABLE(OGLPopupDivisionMenu, wxMenu)
|
||||||
|
EVT_CUSTOM_RANGE(wxEVT_COMMAND_MENU_SELECTED,
|
||||||
|
DIVISION_MENU_SPLIT_HORIZONTALLY,
|
||||||
|
DIVISION_MENU_EDIT_BOTTOM_EDGE,
|
||||||
|
OGLPopupDivisionMenu::OnMenu)
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
|
||||||
|
void OGLPopupDivisionMenu::OnMenu(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
wxDivisionShape *division = (wxDivisionShape *)menu.GetClientData();
|
wxDivisionShape *division = (wxDivisionShape *)GetClientData();
|
||||||
switch (event.GetInt())
|
switch (event.GetInt())
|
||||||
{
|
{
|
||||||
case DIVISION_MENU_SPLIT_HORIZONTALLY:
|
case DIVISION_MENU_SPLIT_HORIZONTALLY:
|
||||||
@@ -1714,6 +1734,8 @@ void wxDivisionShape::EditEdge(int side)
|
|||||||
// Popup menu
|
// Popup menu
|
||||||
void wxDivisionShape::PopupMenu(double x, double y)
|
void wxDivisionShape::PopupMenu(double x, double y)
|
||||||
{
|
{
|
||||||
|
wxMenu* oglPopupDivisionMenu = new OGLPopupDivisionMenu;
|
||||||
|
|
||||||
oglPopupDivisionMenu->SetClientData((void *)this);
|
oglPopupDivisionMenu->SetClientData((void *)this);
|
||||||
if (m_leftSide)
|
if (m_leftSide)
|
||||||
oglPopupDivisionMenu->Enable(DIVISION_MENU_EDIT_LEFT_EDGE, TRUE);
|
oglPopupDivisionMenu->Enable(DIVISION_MENU_EDIT_LEFT_EDGE, TRUE);
|
||||||
@@ -1737,6 +1759,7 @@ void wxDivisionShape::PopupMenu(double x, double y)
|
|||||||
int mouse_y = (int)(dc.LogicalToDeviceY((long)(y - y1*unit_y)));
|
int mouse_y = (int)(dc.LogicalToDeviceY((long)(y - y1*unit_y)));
|
||||||
|
|
||||||
m_canvas->PopupMenu(oglPopupDivisionMenu, mouse_x, mouse_y);
|
m_canvas->PopupMenu(oglPopupDivisionMenu, mouse_x, mouse_y);
|
||||||
|
delete oglPopupDivisionMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDivisionShape::SetLeftSideColour(const wxString& colour)
|
void wxDivisionShape::SetLeftSideColour(const wxString& colour)
|
||||||
|
@@ -225,8 +225,6 @@ class wxDivisionShape: public wxCompositeShape
|
|||||||
wxString m_topSideStyle;
|
wxString m_topSideStyle;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern wxMenu *oglPopupDivisionMenu;
|
|
||||||
extern void oglGraphicsDivisionMenuProc(wxMenu& menu, wxCommandEvent& event);
|
|
||||||
|
|
||||||
#define DIVISION_MENU_SPLIT_HORIZONTALLY 1
|
#define DIVISION_MENU_SPLIT_HORIZONTALLY 1
|
||||||
#define DIVISION_MENU_SPLIT_VERTICALLY 2
|
#define DIVISION_MENU_SPLIT_VERTICALLY 2
|
||||||
|
@@ -55,6 +55,8 @@ char* oglBuffer = NULL;
|
|||||||
|
|
||||||
wxList oglObjectCopyMapping(wxKEY_INTEGER);
|
wxList oglObjectCopyMapping(wxKEY_INTEGER);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void wxOGLInitialize()
|
void wxOGLInitialize()
|
||||||
{
|
{
|
||||||
g_oglBullseyeCursor = new wxCursor(wxCURSOR_BULLSEYE);
|
g_oglBullseyeCursor = new wxCursor(wxCURSOR_BULLSEYE);
|
||||||
@@ -73,15 +75,6 @@ void wxOGLInitialize()
|
|||||||
// Initialize big buffer used when writing images
|
// Initialize big buffer used when writing images
|
||||||
oglBuffer = new char[3000];
|
oglBuffer = new char[3000];
|
||||||
|
|
||||||
if (!oglPopupDivisionMenu)
|
|
||||||
{
|
|
||||||
oglPopupDivisionMenu = new wxMenu("", (wxFunction)oglGraphicsDivisionMenuProc);
|
|
||||||
oglPopupDivisionMenu->Append(DIVISION_MENU_SPLIT_HORIZONTALLY, "Split horizontally");
|
|
||||||
oglPopupDivisionMenu->Append(DIVISION_MENU_SPLIT_VERTICALLY, "Split vertically");
|
|
||||||
oglPopupDivisionMenu->AppendSeparator();
|
|
||||||
oglPopupDivisionMenu->Append(DIVISION_MENU_EDIT_LEFT_EDGE, "Edit left edge");
|
|
||||||
oglPopupDivisionMenu->Append(DIVISION_MENU_EDIT_TOP_EDGE, "Edit top edge");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxOGLCleanUp()
|
void wxOGLCleanUp()
|
||||||
@@ -92,11 +85,6 @@ void wxOGLCleanUp()
|
|||||||
oglBuffer = NULL;
|
oglBuffer = NULL;
|
||||||
}
|
}
|
||||||
oglBuffer = NULL;
|
oglBuffer = NULL;
|
||||||
if (oglPopupDivisionMenu)
|
|
||||||
{
|
|
||||||
delete oglPopupDivisionMenu;
|
|
||||||
oglPopupDivisionMenu = NULL;
|
|
||||||
}
|
|
||||||
if (g_oglBullseyeCursor)
|
if (g_oglBullseyeCursor)
|
||||||
{
|
{
|
||||||
delete g_oglBullseyeCursor;
|
delete g_oglBullseyeCursor;
|
||||||
@@ -190,7 +178,7 @@ int FontSizeDialog(wxFrame *parent, int old_size)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return new_size;
|
return new_size;
|
||||||
/*
|
/*
|
||||||
char *strings[8];
|
char *strings[8];
|
||||||
strings[0] = "4";
|
strings[0] = "4";
|
||||||
strings[1] = "6";
|
strings[1] = "6";
|
||||||
@@ -563,7 +551,7 @@ void oglFindPolylineCentroid(wxList *points, double *x, double *y)
|
|||||||
* Used by functions below.
|
* Used by functions below.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void oglCheckLineIntersection(double x1, double y1, double x2, double y2,
|
void oglCheckLineIntersection(double x1, double y1, double x2, double y2,
|
||||||
double x3, double y3, double x4, double y4,
|
double x3, double y3, double x4, double y4,
|
||||||
double *ratio1, double *ratio2)
|
double *ratio1, double *ratio2)
|
||||||
{
|
{
|
||||||
@@ -583,7 +571,7 @@ void oglCheckLineIntersection(double x1, double y1, double x2, double y2,
|
|||||||
// Check for intersection
|
// Check for intersection
|
||||||
if ((line_constant < 1.0) && (line_constant > 0.0))
|
if ((line_constant < 1.0) && (line_constant > 0.0))
|
||||||
{
|
{
|
||||||
// Now must check that other line hits
|
// Now must check that other line hits
|
||||||
if (((y4 - y3) < 0.005) && ((y4 - y3) > -0.005))
|
if (((y4 - y3) < 0.005) && ((y4 - y3) > -0.005))
|
||||||
k_line = ((x1 - x3) + line_constant*(x2 - x1))/(x4 - x3);
|
k_line = ((x1 - x3) + line_constant*(x2 - x1))/(x4 - x3);
|
||||||
else
|
else
|
||||||
@@ -603,7 +591,7 @@ void oglCheckLineIntersection(double x1, double y1, double x2, double y2,
|
|||||||
* (*x3, *y3) is the point where it hits.
|
* (*x3, *y3) is the point where it hits.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void oglFindEndForPolyline(double n, double xvec[], double yvec[],
|
void oglFindEndForPolyline(double n, double xvec[], double yvec[],
|
||||||
double x1, double y1, double x2, double y2, double *x3, double *y3)
|
double x1, double y1, double x2, double y2, double *x3, double *y3)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -645,7 +633,7 @@ void oglFindEndForPolyline(double n, double xvec[], double yvec[],
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void oglFindEndForBox(double width, double height,
|
void oglFindEndForBox(double width, double height,
|
||||||
double x1, double y1, // Centre of box (possibly)
|
double x1, double y1, // Centre of box (possibly)
|
||||||
double x2, double y2, // other end of line
|
double x2, double y2, // other end of line
|
||||||
double *x3, double *y3) // End on box edge
|
double *x3, double *y3) // End on box edge
|
||||||
@@ -672,7 +660,7 @@ void oglFindEndForBox(double width, double height,
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void oglFindEndForCircle(double radius,
|
void oglFindEndForCircle(double radius,
|
||||||
double x1, double y1, // Centre of circle
|
double x1, double y1, // Centre of circle
|
||||||
double x2, double y2, // Other end of line
|
double x2, double y2, // Other end of line
|
||||||
double *x3, double *y3)
|
double *x3, double *y3)
|
||||||
@@ -729,7 +717,7 @@ void oglGetArrowPoints(double x1, double y1, double x2, double y2,
|
|||||||
* This function assumes that the centre of the ellipse is at x1, y1, and the
|
* This function assumes that the centre of the ellipse is at x1, y1, and the
|
||||||
* ellipse has a width of width1 and a height of height1. It also assumes you are
|
* ellipse has a width of width1 and a height of height1. It also assumes you are
|
||||||
* wanting to draw an arc FROM point x2, y2 TOWARDS point x3, y3.
|
* wanting to draw an arc FROM point x2, y2 TOWARDS point x3, y3.
|
||||||
* This function calculates the x,y coordinates of the intersection point of
|
* This function calculates the x,y coordinates of the intersection point of
|
||||||
* the arc with the ellipse.
|
* the arc with the ellipse.
|
||||||
* Author: Ian Harrison
|
* Author: Ian Harrison
|
||||||
*/
|
*/
|
||||||
@@ -754,7 +742,7 @@ void oglDrawArcToEllipse(double x1, double y1, double width1, double height1, do
|
|||||||
*y4 = (double)(y1 + b1);
|
*y4 = (double)(y1 + b1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
// Check that x2 != x3
|
// Check that x2 != x3
|
||||||
if (fabs(x2 - x3) < 0.05)
|
if (fabs(x2 - x3) < 0.05)
|
||||||
{
|
{
|
||||||
@@ -783,7 +771,7 @@ void oglDrawArcToEllipse(double x1, double y1, double width1, double height1, do
|
|||||||
|
|
||||||
if (K >= 0)
|
if (K >= 0)
|
||||||
// In this case the line intersects the ellipse, so calculate intersection
|
// In this case the line intersects the ellipse, so calculate intersection
|
||||||
{
|
{
|
||||||
if(x2 >= x1)
|
if(x2 >= x1)
|
||||||
{
|
{
|
||||||
ellipse1_x = (double)(((F * -1) + sqrt(K)) / (2 * E));
|
ellipse1_x = (double)(((F * -1) + sqrt(K)) / (2 * E));
|
||||||
@@ -804,7 +792,7 @@ void oglDrawArcToEllipse(double x1, double y1, double width1, double height1, do
|
|||||||
*x4 = ellipse1_x;
|
*x4 = ellipse1_x;
|
||||||
*y4 = ellipse1_y;
|
*y4 = ellipse1_y;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// Draw a little circle (radius = 2) at the end of the arc where it hits
|
// Draw a little circle (radius = 2) at the end of the arc where it hits
|
||||||
// the ellipse .
|
// the ellipse .
|
||||||
|
|
||||||
@@ -848,7 +836,7 @@ static char sg_HexArray[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
|||||||
unsigned int oglHexToDec(char* buf)
|
unsigned int oglHexToDec(char* buf)
|
||||||
{
|
{
|
||||||
int firstDigit, secondDigit;
|
int firstDigit, secondDigit;
|
||||||
|
|
||||||
if (buf[0] >= 'A')
|
if (buf[0] >= 'A')
|
||||||
firstDigit = buf[0] - 'A' + 10;
|
firstDigit = buf[0] - 'A' + 10;
|
||||||
else
|
else
|
||||||
@@ -858,7 +846,7 @@ unsigned int oglHexToDec(char* buf)
|
|||||||
secondDigit = buf[1] - 'A' + 10;
|
secondDigit = buf[1] - 'A' + 10;
|
||||||
else
|
else
|
||||||
secondDigit = buf[1] - '0';
|
secondDigit = buf[1] - '0';
|
||||||
|
|
||||||
return firstDigit * 16 + secondDigit;
|
return firstDigit * 16 + secondDigit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user