Added some standard further identifiers to help with WinCE toolbars

Moved wxID_REPLACE to defs.h
Can now add tools to WinCE toolbar, if using standard identifiers


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22087 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2003-07-18 16:16:14 +00:00
parent 33b3f7c34a
commit bf95a04f16
7 changed files with 133 additions and 55 deletions

View File

@@ -319,6 +319,19 @@ you can use identifiers below wxID\_LOWEST.
#define wxID_FIND 5034 #define wxID_FIND 5034
#define wxID_DUPLICATE 5035 #define wxID_DUPLICATE 5035
#define wxID_SELECTALL 5036 #define wxID_SELECTALL 5036
#define wxID_DELETE 5037
#define wxID_REPLACE 5038
#define wxID_REPLACE_ALL 5039
#define wxID_PROPERTIES 5040
#define wxID_VIEW_DETAILS 5041
#define wxID_VIEW_LARGEICONS 5042
#define wxID_VIEW_SMALLICONS 5043
#define wxID_VIEW_LIST 5044
#define wxID_VIEW_SORTDATE 5045
#define wxID_VIEW_SORTNAME 5046
#define wxID_VIEW_SORTSIZE 5047
#define wxID_VIEW_SORTTYPE 5048
#define wxID_FILE1 5050 #define wxID_FILE1 5050
#define wxID_FILE2 5051 #define wxID_FILE2 5051

View File

@@ -1388,6 +1388,19 @@ enum
wxID_FIND, wxID_FIND,
wxID_DUPLICATE, wxID_DUPLICATE,
wxID_SELECTALL, wxID_SELECTALL,
wxID_DELETE,
wxID_REPLACE,
wxID_REPLACE_ALL,
wxID_PROPERTIES,
wxID_VIEW_DETAILS,
wxID_VIEW_LARGEICONS,
wxID_VIEW_SMALLICONS,
wxID_VIEW_LIST,
wxID_VIEW_SORTDATE,
wxID_VIEW_SORTNAME,
wxID_VIEW_SORTSIZE,
wxID_VIEW_SORTTYPE,
wxID_FILE1 = 5050, wxID_FILE1 = 5050,
wxID_FILE2, wxID_FILE2,

View File

@@ -233,7 +233,12 @@ bool MyApp::OnInit()
// Create the main frame window // Create the main frame window
MyFrame* frame = new MyFrame((wxFrame *) NULL, -1, MyFrame* frame = new MyFrame((wxFrame *) NULL, -1,
_T("wxToolBar Sample"), _T("wxToolBar Sample"),
wxPoint(100, 100), wxSize(550, 300)); #ifdef __WXWINCE__
wxPoint(0, 0), wxDefaultSize, wxNO_BORDER
#else
wxPoint(100, 100), wxSize(550, 300)
#endif
);
frame->Show(TRUE); frame->Show(TRUE);
@@ -246,6 +251,12 @@ bool MyApp::OnInit()
void MyFrame::RecreateToolbar() void MyFrame::RecreateToolbar()
{ {
#ifdef __WXWINCE__
// On Windows CE, we should not delete the
// previous toolbar in case it contains the menubar.
// We'll try to accomodate this usage in due course.
wxToolBar* toolBar = CreateToolBar();
#else
// delete and recreate the toolbar // delete and recreate the toolbar
wxToolBarBase *toolBar = GetToolBar(); wxToolBarBase *toolBar = GetToolBar();
long style = toolBar ? toolBar->GetWindowStyle() : TOOLBAR_STYLE; long style = toolBar ? toolBar->GetWindowStyle() : TOOLBAR_STYLE;
@@ -258,6 +269,7 @@ void MyFrame::RecreateToolbar()
style |= m_horzToolbar ? wxTB_HORIZONTAL : wxTB_VERTICAL; style |= m_horzToolbar ? wxTB_HORIZONTAL : wxTB_VERTICAL;
toolBar = CreateToolBar(style, ID_TOOLBAR); toolBar = CreateToolBar(style, ID_TOOLBAR);
#endif
// Set up toolbar // Set up toolbar
wxBitmap toolBarBitmaps[8]; wxBitmap toolBarBitmaps[8];
@@ -349,8 +361,10 @@ MyFrame::MyFrame(wxFrame* parent,
m_rows = 1; m_rows = 1;
m_nPrint = 1; m_nPrint = 1;
#ifndef __WXWINCE__
// Give it a status line // Give it a status line
CreateStatusBar(); CreateStatusBar();
#endif
// Give it an icon // Give it an icon
SetIcon(wxICON(mondrian)); SetIcon(wxICON(mondrian));

View File

@@ -151,7 +151,7 @@ wxPoint wxFrameBase::GetClientAreaOrigin() const
{ {
wxPoint pt = wxTopLevelWindow::GetClientAreaOrigin(); wxPoint pt = wxTopLevelWindow::GetClientAreaOrigin();
#if wxUSE_TOOLBAR && !defined(__WXUNIVERSAL__) #if wxUSE_TOOLBAR && !defined(__WXUNIVERSAL__) && !defined(__WXWINCE__)
wxToolBar *toolbar = GetToolBar(); wxToolBar *toolbar = GetToolBar();
if ( toolbar && toolbar->IsShown() ) if ( toolbar && toolbar->IsShown() )
{ {

View File

@@ -49,12 +49,6 @@
// constants // constants
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
enum
{
wxID_REPLACE = 5890,
wxID_REPLACE_ALL
};
// ============================================================================ // ============================================================================
// implementation // implementation
// ============================================================================ // ============================================================================

View File

@@ -615,7 +615,10 @@ wxMenuBar::~wxMenuBar()
{ {
// In Windows CE, the menubar is always associated // In Windows CE, the menubar is always associated
// with a toolbar, which destroys the menu implicitly. // with a toolbar, which destroys the menu implicitly.
#ifndef __WXWINCE__ #ifdef __WXWINCE__
if (GetToolBar())
GetToolBar()->SetMenuBar(NULL);
#else
// we should free Windows resources only if Windows doesn't do it for us // we should free Windows resources only if Windows doesn't do it for us
// which happens if we're attached to a frame // which happens if we're attached to a frame
if (m_hMenu && !IsAttached()) if (m_hMenu && !IsAttached())

View File

@@ -285,44 +285,7 @@ bool wxToolBar::MSWCreateToolbar(const wxPoint& pos, const wxSize& size, wxMenuB
if (menuBar) if (menuBar)
menuBar->Create(); menuBar->Create();
#if 0
{
HMENU hMenu = (HMENU)::SendMessage(mbi.hwndMB, SHCMBM_GETMENU, (WPARAM)0, (LPARAM)0);
if (hMenu)
{
TBBUTTON tbButton;
memset(&tbButton, 0, sizeof(TBBUTTON));
tbButton.iBitmap = I_IMAGENONE;
tbButton.fsState = TBSTATE_ENABLED;
tbButton.fsStyle = TBSTYLE_DROPDOWN | TBSTYLE_NO_DROPDOWN_ARROW | TBSTYLE_AUTOSIZE;
size_t i;
for (i = 0; i < menuBar->GetMenuCount(); i++)
{
HMENU hPopupMenu = (HMENU) menuBar->GetMenu(i)->GetHMenu() ;
tbButton.dwData = (DWORD)hPopupMenu;
wxString label = wxStripMenuCodes(menuBar->GetLabelTop(i));
tbButton.iString = (int) label.c_str();
tbButton.idCommand = NewControlId();
if (!::SendMessage((HWND) GetHWND(), TB_INSERTBUTTON, i, (LPARAM)&tbButton))
{
wxLogLastError(wxT("TB_INSERTBUTTON"));
}
}
}
}
#endif
#if 0
CommandBar_AddToolTips( hwndCB, uNumSmallTips,szSmallTips);
CommandBar_AddBitmap(hwndCB, HINST_COMMCTRL, IDB_STD_SMALL_COLOR,
15, 16, 16);
// Add buttons in tbSTDButton to Commandbar
CommandBar_AddButtons(hwndCB, sizeof(tbSTDButton)/sizeof(TBBUTTON),
tbSTDButton);
#endif
return TRUE; return TRUE;
} }
@@ -378,6 +341,9 @@ void wxToolBar::Recreate()
wxToolBar::~wxToolBar() wxToolBar::~wxToolBar()
{ {
if (GetMenuBar())
GetMenuBar()->SetToolBar(NULL);
// we must refresh the frame size when the toolbar is deleted but the frame // we must refresh the frame size when the toolbar is deleted but the frame
// is not - otherwise toolbar leaves a hole in the place it used to occupy // is not - otherwise toolbar leaves a hole in the place it used to occupy
wxFrame *frame = wxDynamicCast(GetParent(), wxFrame); wxFrame *frame = wxDynamicCast(GetParent(), wxFrame);
@@ -548,6 +514,69 @@ bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool)
return TRUE; return TRUE;
} }
struct wxToolBarIdMapping
{
int m_wxwinId;
int m_winceId;
};
static wxToolBarIdMapping sm_ToolBarIdMappingArray[] =
{
{ wxID_COPY, STD_COPY },
{ wxID_CUT, STD_CUT },
{ wxID_FIND, STD_FIND },
{ wxID_PASTE, STD_PASTE },
{ wxID_NEW, STD_FILENEW },
{ wxID_OPEN, STD_FILEOPEN },
{ wxID_SAVE, STD_FILESAVE },
{ wxID_PRINT, STD_PRINT },
{ wxID_PREVIEW, STD_PRINTPRE },
{ wxID_UNDO, STD_UNDO },
{ wxID_REDO, STD_REDOW },
{ wxID_HELP, STD_HELP },
{ wxID_DELETE, STD_DELETE },
{ wxID_REPLACE, STD_REPLACE },
{ wxID_PROPERTIES, STD_PROPERTIES },
{ wxID_VIEW_DETAILS, VIEW_DETAILS },
{ wxID_VIEW_SORTDATE, VIEW_SORTDATE },
{ wxID_VIEW_LARGEICONS, VIEW_LARGEICONS },
{ wxID_VIEW_SORTNAME, VIEW_SORTNAME },
{ wxID_VIEW_LIST, VIEW_LIST },
{ wxID_VIEW_SORTSIZE, VIEW_SORTSIZE },
{ wxID_VIEW_SMALLICONS, VIEW_SMALLICONS },
{ wxID_VIEW_SORTTYPE, VIEW_SORTTYPE },
{ 0, 0},
};
static int wxFindIdForWinceId(int id)
{
int i = 0;
while (TRUE)
{
if (sm_ToolBarIdMappingArray[i].m_winceId == 0)
return -1;
else if (sm_ToolBarIdMappingArray[i].m_winceId == id)
return sm_ToolBarIdMappingArray[i].m_wxwinId;
i ++;
}
return -1;
}
static int wxFindIdForwxWinId(int id)
{
int i = 0;
while (TRUE)
{
if (sm_ToolBarIdMappingArray[i].m_wxwinId == 0)
return -1;
else if (sm_ToolBarIdMappingArray[i].m_wxwinId == id)
return sm_ToolBarIdMappingArray[i].m_winceId;
i ++;
}
return -1;
}
bool wxToolBar::Realize() bool wxToolBar::Realize()
{ {
const size_t nTools = GetToolsCount(); const size_t nTools = GetToolsCount();
@@ -573,6 +602,10 @@ bool wxToolBar::Realize()
// add the buttons and separators // add the buttons and separators
// ------------------------------ // ------------------------------
// Use standard buttons
CommandBar_AddBitmap((HWND) GetHWND(), HINST_COMMCTRL,
IDB_STD_SMALL_COLOR, 0, 16, 16);
TBBUTTON *buttons = new TBBUTTON[nTools]; TBBUTTON *buttons = new TBBUTTON[nTools];
// this array will hold the indices of all controls in the toolbar // this array will hold the indices of all controls in the toolbar
@@ -585,6 +618,8 @@ bool wxToolBar::Realize()
{ {
wxToolBarToolBase *tool = node->GetData(); wxToolBarToolBase *tool = node->GetData();
bool processedThis = TRUE;
TBBUTTON& button = buttons[i]; TBBUTTON& button = buttons[i];
wxZeroMemory(button); wxZeroMemory(button);
@@ -602,10 +637,8 @@ bool wxToolBar::Realize()
break; break;
case wxTOOL_STYLE_BUTTON: case wxTOOL_STYLE_BUTTON:
// TODO // if ( !HasFlag(wxTB_NOICONS) )
#if 0 // button.iBitmap = bitmapId;
if ( !HasFlag(wxTB_NOICONS) )
button.iBitmap = bitmapId;
if ( HasFlag(wxTB_TEXT) ) if ( HasFlag(wxTB_TEXT) )
{ {
@@ -616,7 +649,15 @@ bool wxToolBar::Realize()
} }
} }
button.idCommand = tool->GetId(); int winceId = wxFindIdForwxWinId(tool->GetId());
if (winceId > -1)
{
button.idCommand = tool->GetId();
// if ( !HasFlag(wxTB_NOICONS) )
button.iBitmap = winceId;
}
else
processedThis = FALSE;
if ( tool->IsEnabled() ) if ( tool->IsEnabled() )
button.fsState |= TBSTATE_ENABLED; button.fsState |= TBSTATE_ENABLED;
@@ -653,17 +694,17 @@ bool wxToolBar::Realize()
button.fsStyle = TBSTYLE_BUTTON; button.fsStyle = TBSTYLE_BUTTON;
} }
bitmapId++; // bitmapId++;
#endif
break; break;
} }
lastWasRadio = isRadio; lastWasRadio = isRadio;
i++; if (processedThis)
i++;
} }
// Add buttons in tbSTDButton to Commandbar // Add buttons to Commandbar
if (!CommandBar_AddButtons(GetHwnd(), i, buttons)) if (!CommandBar_AddButtons(GetHwnd(), i, buttons))
{ {
wxLogLastError(wxT("CommandBar_AddButtons")); wxLogLastError(wxT("CommandBar_AddButtons"));