Skip to content

Commit

Permalink
Add simple gallery items.
Browse files Browse the repository at this point in the history
  • Loading branch information
rhcad committed Nov 3, 2011
1 parent 1078d13 commit 670c039
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 11 deletions.
57 changes: 57 additions & 0 deletions code/pkg_AppUI/Modules/FrameXtp/MainFrm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra,

if (1 == s_nLocker)
{
if (CN_COMMAND == nCode && pInfo && FindGalleryItems(nID))
return TRUE;
if (NotifyCmdMsgEvent(nID, nCode, pExtra, pInfo))
return TRUE;
}
Expand Down Expand Up @@ -393,6 +395,8 @@ CXTPControl* CMainFrame::CreateRibbonComboButton(CXTPRibbonGroup* pGroup,
const Cx_ConfigSection& button)
{
CXTPControlComboBox* pCombo = new CXTPControlComboBox();
CXTPPopupBar* pPopupBarGallery = CXTPControlComboBoxGalleryPopupBar::CreateComboBoxGalleryPopupBar(m_pCommandBars);
CXTPControlGallery* pControlGallery = new CXTPControlGallery();

pGroup->Add(pCombo, buttonID);
if (button->GetString(L"type") == L"combo")
Expand All @@ -401,9 +405,62 @@ CXTPControl* CMainFrame::CreateRibbonComboButton(CXTPRibbonGroup* pGroup,
}
pCombo->SetWidth(button->GetInt32(L"width", 50));

pCombo->SetCommandBar(pPopupBarGallery);

Cx_ConfigSection gallery(button.GetSection(L"gallery"));
UINT galleryID = gallery->GetUInt32(L"id", buttonID);
int showCount = gallery->GetInt32(L"showCount", 10);
CXTPControlGalleryItems* pItems = AddGalleryItems(galleryID);

pControlGallery->SetControlSize(CSize(
gallery->GetInt32(L"width", pCombo->GetWidth()),
16 * min(24, max(2, 1 + showCount))));
pControlGallery->SetResizable(FALSE, gallery->GetBool(L"resizable", TRUE));
pControlGallery->SetItems(pItems);
pPopupBarGallery->GetControls()->Add(pControlGallery, galleryID);

pPopupBarGallery->InternalRelease();

return pCombo;
}

CXTPControlGalleryItems* CMainFrame::AddGalleryItems(UINT id)
{
CXTPControlGalleryItems* pItems = FindGalleryItems(id);

if (!pItems)
{
pItems = CXTPControlGalleryItems::CreateItems(m_pCommandBars, id);
m_mapGallery[id] = pItems;

pItems->SetItemSize(CSize(0, 17));
pItems->AddItem(_T("8"));
pItems->AddItem(_T("9"));
pItems->AddItem(_T("10"));
pItems->AddItem(_T("11"));
pItems->AddItem(_T("12"));
pItems->AddItem(_T("14"));
pItems->AddItem(_T("16"));
pItems->AddItem(_T("18"));
pItems->AddItem(_T("20"));
pItems->AddItem(_T("22"));
pItems->AddItem(_T("24"));
pItems->AddItem(_T("26"));
pItems->AddItem(_T("28"));
pItems->AddItem(_T("36"));
pItems->AddItem(_T("48"));
pItems->AddItem(_T("72"));
}

return pItems;
}

CXTPControlGalleryItems* CMainFrame::FindGalleryItems(UINT id) const
{
std::map<UINT, CXTPControlGalleryItems*>::const_iterator it = m_mapGallery.find(id);
return it != m_mapGallery.end() ? it->second : NULL;
}

void CMainFrame::OnUpdateRibbonTab(CCmdUI* pCmdUI)
{
CXTPRibbonControlTab* pControl = DYNAMIC_DOWNCAST(
Expand Down
3 changes: 3 additions & 0 deletions code/pkg_AppUI/Modules/FrameXtp/MainFrm.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class CMainFrame
UINT buttonID, const Cx_ConfigSection& button);
CXTPControl* CreateRibbonComboButton(CXTPRibbonGroup* pGroup,
UINT buttonID, const Cx_ConfigSection& button);
CXTPControlGalleryItems* AddGalleryItems(UINT id);
CXTPControlGalleryItems* FindGalleryItems(UINT id) const;

UINT GetNodeID(const Cx_ConfigSection& node, LPCWSTR name);
void SetSystemButtonStyle(const CMenu& menu);
Expand All @@ -60,4 +62,5 @@ class CMainFrame
CFrameWnd* m_pMainWnd;
CXTPCommandBars* m_pCommandBars;
std::map<std::wstring, UINT> m_idnames;
std::map<UINT, CXTPControlGalleryItems*> m_mapGallery;
};
21 changes: 12 additions & 9 deletions code/pkg_Example/Modules/HelloFrame/HelloFrame.rc
Original file line number Diff line number Diff line change
Expand Up @@ -227,26 +227,28 @@ STRINGTABLE
BEGIN
ID_GROUP_CLIPBOARD "\n&Clipboard"
ID_GROUP_FONT_OPTION "Show the Font dialog box\nF&ont"
ID_GALLERY_FONTFACE "Font Face"
ID_GALLERY_FONTSIZE "Font Size"
END

STRINGTABLE
BEGIN
ID_GROUP_CLIPBOARD_OPTION "Show the Office clipboard Task Pane\nClipboard"
ID_FONT_GROW "\nGrow Font"
ID_FONT_SHRINK "\nShrink Font"
ID_FONT_CLEAR "\nClear Formatting"
ID_FONT_GROW "Grow font size\nGrow Font"
ID_FONT_SHRINK "Shrink font size\nShrink Font"
ID_FONT_CLEAR "Clear formatting\nClear Formatting"
ID_TEXT_CHANGECASE "Change Case"
END

STRINGTABLE
BEGIN
ID_FORMAT_PAINTER "Copy formatting from one place and apply it to another\nFormat Painter"
ID_FONT_FACE "\nFont Face"
ID_FONT_SIZE "\nFont Size"
ID_FONT_FACE "Select font face\nFont Face"
ID_FONT_SIZE "Select font Size\nFont Size"
ID_CHAR_STRIKETHROUGH "Draw a line through the middle of the selected text\nStrikethrough"
ID_TEXT_SUBSCRIPT "Subscript"
ID_TEXT_SUPERSCRIPT "\nSuperscript"
ID_TEXT_COLOR "\nColor"
ID_TEXT_SUPERSCRIPT "Superscript toggle\nSuperscript"
ID_TEXT_COLOR "Select color\nColor"
END

STRINGTABLE
Expand All @@ -258,7 +260,7 @@ END

STRINGTABLE
BEGIN
ID_TEXT_HIGHLIGHTCOLOR "\nHighlight Color"
ID_TEXT_HIGHLIGHTCOLOR "Highlight Color"
END

STRINGTABLE
Expand Down Expand Up @@ -304,7 +306,8 @@ LANGUAGE 9, 1
#pragma code_page(1252)
#endif //_WIN32
#include "afxres.rc" // Standard components
#endif
#endif

/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

2 changes: 2 additions & 0 deletions code/pkg_Example/Modules/HelloFrame/Resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#define IDR_MAINFRAME 128
#define IDR_SMALLICONS 128
#define IDR_LARGEICONS 129
#define ID_GALLERY_FONTSIZE 2716
#define ID_GALLERY_FONTFACE 2773
#define ID_GROUP_CLIPBOARD_OPTION 2790
#define ID_FONT_GROW 2792
#define ID_FONT_SHRINK 2793
Expand Down
10 changes: 8 additions & 2 deletions code/pkg_Example/Modules/HelloFrame/uifactory.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,14 @@
</group>
<group caption="Ribbon|Font"
optionButtonID="6025 ID_GROUP_FONT_OPTION">
<button id="7618 ID_FONT_FACE" type="combo" width="130"/>
<button id="7619 ID_FONT_SIZE" type="combo" width="45"/>
<button id="7618 ID_FONT_FACE" type="combo" width="130">
<gallery id="2773 ID_GALLERY_FONTFACE"
width="130" showCount="16" resizable="true"/>
</button>
<button id="7619 ID_FONT_SIZE" type="combo" width="45">
<gallery id="2716 ID_GALLERY_FONTSIZE"
width="45" showCount="10" resizable="true"/>
</button>
<button id="2792 ID_FONT_GROW" beginGroup="true"/>
<button id="2793 ID_FONT_SHRINK"/>
<button id="2794 ID_FONT_CLEAR" beginGroup="true"/>
Expand Down

0 comments on commit 670c039

Please sign in to comment.