1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
//////////////////////////////////////////////////////////////////////////
//
// pgAdmin III - PostgreSQL Tools
//
// Copyright (C) 2002 - 2014, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
// ctlMenuToolbar.h - Menu tool bar
//
// This code is essentially stolen (with the authors permission) from
// Paul Nelson (http://www.pnelsoncomposer.com/)
//
//////////////////////////////////////////////////////////////////////////
#ifndef CTLMENUTOOLBAR_H
#define CTLMENUTOOLBAR_H
#include "wx/frame.h"
// ctlMenuButton - Can be used wherever you can use a standard wxBitmapButton
//
// Implements a small pull-down triangle (v), which, when clicked, will display
// a pop-up menu.
class ctlMenuButton : public wxBitmapButton
{
public:
ctlMenuButton(wxToolBar *toolBar, int ID, wxMenu *menu)
{
Create(toolBar, toolBar, ID, menu);
}
void DoProcessLeftClick(wxMouseEvent &event);
wxMenu *m_menu;
void FillMenu();
private:
void Create(wxWindow *window, wxToolBar *toolBar, int ID, wxMenu *menu);
wxToolBar *m_toolBar;
};
// ctlMenuTool - is only used internal to the implementation of ctlMenuToolbar.
//
// You should never have to use it yourself
class ctlMenuTool
{
public:
ctlMenuTool(wxToolBarToolBase *new_tool, int toolId);
wxToolBarToolBase *m_tool;
wxMenu *m_menu;
private:
int m_toolId;
ctlMenuButton *m_button;
};
WX_DECLARE_LIST(ctlMenuTool, ctlMenuToolList);
// *** ctlMenuToolbar - A replacement for wxToolBar which implements menu buttons
// and pull-down buttons
//
// A menu button is a standard looking toolbar tool which, when clicked, pops up a
// menu which can be selected.
//
// A pull-down button presents a small black triangle which, when clicked, pops up
// a menu which can be selected. These buttons are typically used for a list of previous
// actions (for example, previous web pages visited).
class ctlMenuToolbar : public wxToolBar
{
public:
ctlMenuToolbar();
ctlMenuToolbar(wxFrame *parent, wxWindowID id, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, long style = wxTB_HORIZONTAL | wxNO_BORDER, const wxString &name = wxPanelNameStr);
~ctlMenuToolbar();
// NOTE: label, shortHelpString, are not implemented on all platforms and are only
// included for possible future upgrades
ctlMenuButton *AddMenuPulldownTool(int toolId, const wxString &label, const wxString &shortHelpString = wxEmptyString, wxMenu *popupmenu = 0);
void DoProcessLeftClick(wxMouseEvent &event);
private:
wxFrame *m_frame;
ctlMenuToolList *m_menuTools;
};
#endif
|