예제 #1
0
void CMuleToolbarCtrl::OnTbnReset(NMHDR* /*pNMHDR*/, LRESULT* /*pResult*/)
{
	// First get rid of old buttons
	// while saving their states
	for (int i = GetButtonCount()-1; i >= 0; i--)
	{
		TBBUTTON Button;
		GetButton(i, &Button);
		for (int j = 0; j < m_buttoncount ; j++)
		{
			if (TBButtons[j].idCommand == Button.idCommand)
			{
				TBButtons[j].fsState = Button.fsState;
				TBButtons[j].fsStyle = Button.fsStyle;
				TBButtons[j].iString = Button.iString;
			}
		}
		DeleteButton(i);
	}

	TBBUTTON sepButton;
	sepButton.idCommand = 0;
	sepButton.fsStyle = TBSTYLE_SEP;
	sepButton.fsState = TBSTATE_ENABLED;
	sepButton.iString = -1;
	sepButton.iBitmap = -1;
	
	// set default configuration 
	CString config = strDefaultToolbar;
	// MORPH START show less controls
	if (thePrefs.IsLessControls())
		config=strDefaultLessControlsToolbar;
	// MORPH END  show less controls

	for (int i = 0; i <config.GetLength(); i += 2)
	{
		int index = _tstoi(config.Mid(i, 2));
		if (index == 99)
		{
			AddButtons(1, &sepButton);
			continue;
		}
		AddButtons(1, &TBButtons[index]);
	}

	// save new (default) configuration 
	thePrefs.SetToolbarSettings(config);

	Localize();		// we have to localize the button-text

	theApp.emuledlg->ShowConnectionState();

	ChangeTextLabelStyle(thePrefs.GetToolbarLabelSettings(), false, true);
	SetAllButtonsWidth();	// then calc and set the button width
	AutoSize();
}
예제 #2
0
/**
 * @function GUI_M_Popup
 * @brief open top layer & launch a popup
 * @param gui_m_popup_e btn xxx: left/middle/right buttons
 * @param gui_img_t img: image of the popup
 * @param const void *usrStr: user message
 * @return int8_t: 0 success, -1 error; in case of error, the top layer is automatically closed
 */
int8_t GUI_M_Popup(gui_m_popup_e btnLeft, gui_m_popup_e btnMiddle, gui_m_popup_e btnRight, gui_img_t img, const void *usrStr) {

  int8_t res = -1;
  rect_st rec;

  /*popup dimension*/
  rec.w = POPUP_W;
  rec.h = POPUP_H;
  rec.x = ((coord_t) P2D_GetLcdWidth() - rec.w) / 2;
  rec.y = ((coord_t) P2D_GetLcdHeight() - rec.h) / 2;

  /*open the top layer*/
  GUI_TopLayerOpen(GUI_M_PopupHandle);

  /*draw the popup background*/
  P2D_SetColors(GetColor(G_COL_BACKGROUND), GetColor(G_COL_BACKGROUND));
  P2D_FillRect(&rec);

  /*create the popup*/
  SetFont(G_FONT_DEFAULT);
  if(AddButtons(&rec, btnLeft, btnMiddle, btnRight) == 0) {

    /*add the user text and display the sprite*/
    if(AddSpriteAndText(&rec, img, usrStr) == 0) res = 0;
  }

  /*in case of error, kill top layer*/
  if(res < 0) {
    GUI_TopLayerClose();
  }

  return res;
}
예제 #3
0
HRESULT CMenuToolbarBase::AddButton(DWORD commandId, LPCWSTR caption, BOOL hasSubMenu, INT iconId, DWORD_PTR buttonData, BOOL last)
{
    TBBUTTON tbb = { 0 };

    tbb.fsState = TBSTATE_ENABLED;
#if !USE_TBSTYLE_EX_VERTICAL
    if (!last && (m_initFlags & SMINIT_VERTICAL))
        tbb.fsState |= TBSTATE_WRAP;
#endif
    tbb.fsStyle = BTNS_CHECKGROUP;

    if (hasSubMenu && (m_initFlags & SMINIT_VERTICAL))
        tbb.fsStyle |= BTNS_DROPDOWN;

    if (!(m_initFlags & SMINIT_VERTICAL))
        tbb.fsStyle |= BTNS_AUTOSIZE;

    tbb.iString = (INT_PTR) caption;
    tbb.idCommand = commandId;

    tbb.iBitmap = iconId;
    tbb.dwData = buttonData;

    m_hasSizes = FALSE;

    if (!AddButtons(1, &tbb))
        return HRESULT_FROM_WIN32(GetLastError());
    return S_OK;
}
예제 #4
0
void CalReviewDialog::CreateControls()
{
    CalReviewDialog* parent = this;
    wxBoxSizer* topVSizer = new wxBoxSizer(wxVERTICAL);
    parent->SetSizer(topVSizer);

    wxNotebook* calibNotebook = new wxNotebook(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP);

    wxPanel* panelMount = new wxPanel(calibNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | wxTAB_TRAVERSAL);
    CreatePanel(panelMount, false);
    panelMount->SetBackgroundColour("BLACK");

    calibNotebook->AddPage(panelMount, _("Mount"));

    // Build the AO panel only if an AO is configured
    if (pSecondaryMount)
    {
        wxPanel* panelAO = new wxPanel(calibNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | wxTAB_TRAVERSAL);
        CreatePanel(panelAO, true);
        panelAO->SetBackgroundColour("BLACK");
        calibNotebook->AddPage(panelAO, _("AO"));
    }

    topVSizer->Add(calibNotebook, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
    AddButtons(this, topVSizer);                              // virtual function
}
예제 #5
0
void CTaskDialog::LayoutControls(void)
{
	// layout controls

	int cx_buttons = 0;
	int cx_width = CalculateDialogWidth(cx_buttons);
	int cy_height = 0;

	int x = cx_margin;
	int y = cy_margin;

	// add content area

	{
		if (config_.pszMainInstruction != 0 || config_.pszMainIcon != 0)
			y += cy_spacing + AddMainInstruction(x, y, cx_width - cx_margin - cx_margin);
		if (config_.pszContent != 0)
			y += cy_spacing + AddContent(x, y, cx_width - cx_margin - cx_margin);
		if (config_.cRadioButtons != 0)
			y += cy_spacing + AddRadioButtons(x, y, cx_width - cx_margin - cx_margin);
		if (HasFlag(TDF_SHOW_PROGRESS_BAR))
			y += cy_spacing + AddProgressBar(x, y, cx_width - cx_margin - cx_margin);

		cy_height = y;
	}

	{
		y  = AddFrame(0, 0, cx_width, cy_height);
		y += AddDividingLine(0, y, cx_width);
		y += cy_spacing;
	}

	// add row of buttons

	{
		y += cy_spacing + AddButtons(cx_margin + cx_width - cx_buttons, y, cx_width);
	}

	// add verification text

	if (config_.pszVerificationText != 0) {
		y += cy_spacing + AddVerificationCheckBox(cx_margin, y, cx_width - cx_margin - cx_margin);
	}

	// add footer area

	if (config_.pszFooter != 0 || config_.pszFooterIcon != 0) {

		y += cy_spacing + AddFooterDividingLine(0, y, cx_width);
		y += cy_spacing + AddFooter(cx_margin, y, cx_width - cx_margin - cy_margin);
	}

	y += cy_margin - cy_spacing;
	y += ::GetSystemMetrics(SM_CYCAPTION);

	// update dialog dimension

	RECT rect = { 0, 0, cx_width, y };
	SetWindowPos(0, &rect, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
}
예제 #6
0
BOOL CDropDownButton::Init(bool bSingleDropDownBtn, bool bWholeDropDown)
{
	DeleteAllButtons();
	m_bSingleDropDownBtn = bSingleDropDownBtn;

	// If a toolbar control was created indirectly via a dialog resource one can not
	// add any buttons without setting an image list before. (?)
	// So, for this to work, we have to attach an image list to the toolbar control!
	// The image list can be empty, and it does not need to be used at all, but it has
	// to be attached.
	CImageList* piml = GetImageList();
	if (piml == NULL || piml->m_hImageList == NULL)
	{
		CImageList iml;
		iml.Create(16, 16, ILC_COLOR, 0, 0);
		SetImageList(&iml);
		iml.Detach();
	}
	if (m_bSingleDropDownBtn)
	{
		TBBUTTON atb[1] = {0};
		atb[0].iBitmap = -1;
		atb[0].idCommand = GetWindowLong(m_hWnd, GWL_ID);
		atb[0].fsState = TBSTATE_ENABLED;
		atb[0].fsStyle = m_bSingleDropDownBtn ? (bWholeDropDown ? BTNS_WHOLEDROPDOWN : BTNS_DROPDOWN) : BTNS_BUTTON;
		atb[0].iString = -1;
		VERIFY( AddButtons(1, atb) );

		ResizeToMaxWidth();
		SetExtendedStyle(TBSTYLE_EX_DRAWDDARROWS);
	}
	return TRUE;
}
예제 #7
0
int CLoginButton::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	ToolData tbBtn = { ToolType_Normal, true, 0, s()->LoginButton()->GetWidth() };
	AddButtons(&tbBtn, 1);
	RefreshAfterAddButtonOrSizeChange();

	return 1;
}
예제 #8
0
		// Добавляет сепаратор, кнопки OK и Cancel.
		void AddOKCancel(int OKMessageId, int CancelMessageId, int ExtraMessageId = -1, bool Separator=true)
		{
			if (Separator)
				AddSeparator();

			int MsgIDs[] = { OKMessageId, CancelMessageId, ExtraMessageId };
			int NumButtons = (ExtraMessageId != -1) ? 3 : (CancelMessageId != -1? 2 : 1);

			AddButtons(NumButtons, MsgIDs, 0, 1);
		}
예제 #9
0
bool TaskToolbar::Create(CWnd* parent, UINT id, bool vertical)
{
	static const int commands[]=
	{
		ID_VIEW,
		ID_TASK_TRANSFER, ID_TASK_COPY, ID_TASK_MOVE, ID_TASK_RENAME, ID_TASK_COPY_TAGGED,
		ID_TASK_RESIZE, ID_TASK_ROTATE, ID_TASK_EDIT_IPTC,
		ID_TASK_GEN_SLIDE_SHOW, ID_TASK_GEN_HTML_ALBUM, ID_BUILD_CATALOG,
		ID_TASK_PRINT, ID_TASK_EXPORT, ID_TASK_HISTOGRAM,
		ID_TASK_TOUCH_UP, ID_SEND_EMAIL, ID_DATE_TIME_ADJ,
		ID_TASK_EXTRACT_JPEG, ID_TASK_DELETE
	};

	if (vertical)
		SetPadding(0, 0);
	else
		SetPadding(0, 4);

	small_icons_ = AfxGetApp()->GetProfileInt(REGISTRY_SECTION_TOOLBAR, REG_ICONS, 0) == 0;

	int bmp_id= small_icons_ ? TOOLBAR_BITMAP_SMALL : TOOLBAR_BITMAP_BIG;

	DWORD tb_style= WS_CHILD | WS_VISIBLE | TBSTYLE_TOOLTIPS | TBSTYLE_FLAT | TBSTYLE_TRANSPARENT |
		/*CCS_TOP |*/ CCS_NORESIZE | CCS_NOPARENTALIGN | CCS_NODIVIDER | TBSTYLE_ALTDRAG | CCS_ADJUSTABLE;

	if (vertical)
		tb_style |= CCS_RIGHT;
	else
		tb_style |= CCS_TOP;

	if (!CToolBarCtrl::Create(tb_style, CRect(0,0,0,0), parent, id))
		return false;

	int w= 0;
	{
		CClientDC dc(parent);
		dc.SelectStockObject(DEFAULT_GUI_FONT);
		w = dc.GetTextExtent(_T("NNNNNNa"), 7).cx;
	}
	// limit button width to make labels wrap
	if (vertical)
		w = w * 13 / 10;
	SendMessage(TB_SETBUTTONWIDTH, 0, MAKELONG(w, w));
	SendMessage(TB_SETDRAWTEXTFLAGS, DT_WORDBREAK, DT_WORDBREAK);
	SendMessage(TB_SETDRAWTEXTFLAGS, DT_SINGLELINE, 0);
	SendMessage(TB_SETMAXTEXTROWS, vertical ? 1 : 2, 0);

	AddButtons("P|PPPPP|PPPPPPPPPPPPPP", commands, bmp_id, IDS_BROWSER_TOOLS, vertical);

	CreateDisabledImageList(bmp_id, saturation, lightness, alpha);

	DeleteButtons();

	return true;
}
예제 #10
0
파일: gui.cpp 프로젝트: VonChenPlus/reactos
    HWND Create(HWND hwndParent)
    {
        static TBBUTTON Buttons [] =
        {   /* iBitmap, idCommand, fsState, fsStyle, bReserved[2], dwData, iString */
            { 0, ID_INSTALL, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, (INT_PTR) szInstallBtn },
            { 1, ID_UNINSTALL, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, (INT_PTR) szUninstallBtn },
            { 2, ID_MODIFY, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, (INT_PTR) szModifyBtn },
            { 5, 0, TBSTATE_ENABLED, BTNS_SEP, { 0 }, 0, 0 },
            { 3, ID_REFRESH, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, 0 },
            { 4, ID_RESETDB,   TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, {0}, 0, 0},
            { 5, 0, TBSTATE_ENABLED, BTNS_SEP, { 0 }, 0, 0 },
            { 5, ID_SETTINGS, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, 0 },
            { 6, ID_EXIT, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, 0 }
        };

        INT NumButtons = sizeof(Buttons) / sizeof(Buttons[0]);
        HIMAGELIST hImageList;

        LoadStringW(hInst, IDS_INSTALL, szInstallBtn, sizeof(szInstallBtn) / sizeof(WCHAR));
        LoadStringW(hInst, IDS_UNINSTALL, szUninstallBtn, sizeof(szUninstallBtn) / sizeof(WCHAR));
        LoadStringW(hInst, IDS_MODIFY, szModifyBtn, sizeof(szModifyBtn) / sizeof(WCHAR));

        m_hWnd = CreateWindowExW(0,
            TOOLBARCLASSNAMEW,
            NULL,
            WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS | TBSTYLE_LIST,
            0, 0, 0, 0,
            hwndParent,
            0,
            hInst,
            NULL);

        if (!m_hWnd)
        {
            /* TODO: Show error message */
            return FALSE;
        }

        SendMessageW(TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_HIDECLIPPEDBUTTONS);
        SetButtonStructSize();

        hImageList = InitImageList();

        if (!hImageList)
        {
            /* TODO: Show error message */
            return FALSE;
        }

        ImageList_Destroy((HIMAGELIST) SetImageList(hImageList));

        AddButtons(NumButtons, Buttons);

        return m_hWnd;
    }
void CBrowserToolbarCtrl::Init()
{
	InitImageList();


    TBButtons[0].idCommand = TB_BACK;
	TBButtons[1].idCommand = TB_FORWARD;
	TBButtons[2].idCommand = TB_STOP;
	TBButtons[3].idCommand = TB_REFRESH;
	TBButtons[4].idCommand = TB_HOME;

	// add button-text:
	TCHAR cButtonStrings[500];
	int lLen, lLen2;
	
	_tcscpy(cButtonStrings, GetResString(IDS_BROWSER_BACK));
	lLen = _tcslen(GetResString(IDS_BROWSER_BACK)) + 1;

	lLen2 = _tcslen(GetResString(IDS_BROWSER_FORWARD)) + 1;
	memcpy(cButtonStrings+lLen, GetResString(IDS_BROWSER_FORWARD), lLen2*sizeof(TCHAR));
	lLen += lLen2;

	lLen2 = _tcslen(GetResString(IDS_BROWSER_STOP)) + 1;
	memcpy(cButtonStrings+lLen, GetResString(IDS_BROWSER_STOP), lLen2*sizeof(TCHAR));
	lLen += lLen2;

	lLen2 = _tcslen(GetResString(IDS_BROWSER_REFRESH)) + 1;
	memcpy(cButtonStrings+lLen, GetResString(IDS_BROWSER_REFRESH), lLen2*sizeof(TCHAR));
	lLen += lLen2;

	lLen2 = _tcslen(GetResString(IDS_BROWSER_VERYCD)) + 1;
	memcpy(cButtonStrings+lLen, GetResString(IDS_BROWSER_VERYCD), lLen2*sizeof(TCHAR));
	lLen += lLen2;

	// terminate
	memcpy(cButtonStrings+lLen, _T("\0"), sizeof(TCHAR));
	
	/*int iRet =*/AddStrings(cButtonStrings);

    
	for( int i = 0; i < NUM_BROWSER_BUTTON; i++ )
	{
		TBButtons[i].iBitmap = i;
		TBButtons[i].fsState = TBSTATE_ENABLED;
		TBButtons[i].fsStyle = TBSTYLE_BUTTON | BTNS_AUTOSIZE;
		TBButtons[i].iString = i;
	}

	AddButtons(NUM_BROWSER_BUTTON, TBButtons);

	Localize();
}
예제 #12
0
/////////////////////////////////////////////////////////////////////////////
// CMainToolBarCtrl message handlers
void CMainToolBarCtrl::Init()
{
	COLORREF crMask = RGB(255, 255, 255);
	
	CSize bitmapSize(32, 32);
	SetBitmapSize(bitmapSize);
	
	CSize buttonSize(40, 40);
	SetButtonSize(buttonSize);

	
	m_normalIL.Create(32, 32, ILC_COLOR24|ILC_MASK, 6, 1);
	UINT nBtnID[] = {IDB_TB_ADD, IDB_TB_START, IDB_TB_CLEAR, IDB_TB_EXPORT, IDB_TB_OPTION, IDB_TB_EXIT};
	COLORREF nCrMask[] = {RGB(255, 255, 255), RGB(255, 0, 255), RGB(255, 0, 255), RGB(255, 255, 255), 
		RGB(255, 255, 255), RGB(255, 255, 255)};
	int i;
	for(i = 0; i < (sizeof(nBtnID)/sizeof(nBtnID[0])); i++)
	{
		CBitmap bm;
		bm.LoadBitmap(nBtnID[i]);
		m_normalIL.Add(&bm, nCrMask[i]);
	}
	SetImageList(&m_normalIL);
	
	int nFirstButtonID = IDC_MAIN_TOOLBAR_BUTTON_FIRST;
	int m_nButtonCount = IDC_MAIN_TOOLBAR_BUTTON_LAST - nFirstButtonID + 1;
	
	int nBitmapIndex[] = {0, 1, 2, 3, 4, 5};
	TBBUTTON tb;
	for (int nIndex = 0; nIndex < m_nButtonCount; nIndex++)
	{
		CString string;
		string.LoadString(nIndex + nFirstButtonID);
		
		// Add second '\0'
		int nStringLength = string.GetLength() + 1;
		TCHAR * pString = string.GetBufferSetLength(nStringLength);
		pString[nStringLength] = 0;
		
		VERIFY((tb.iString = AddStrings(pString)) != -1);
		
		string.ReleaseBuffer();
		
		tb.fsState = TBSTATE_ENABLED;
		tb.fsStyle = TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE;
		tb.dwData = 0;
		tb.iBitmap = nBitmapIndex[nIndex];
		tb.idCommand = nIndex + nFirstButtonID;
		
		AddButtons(1, &tb);
	}
}
예제 #13
0
파일: Globals.cpp 프로젝트: aidush/openmpt
BOOL CModControlBar::AddButton(UINT nID, int iImage, UINT nStyle, UINT nState)
//----------------------------------------------------------------------------
{
    TBBUTTON btn;

    btn.iBitmap = iImage;
    btn.idCommand = nID;
    btn.fsStyle = (uint8_t)nStyle;
    btn.fsState = (uint8_t)nState;
    btn.dwData = 0;
    btn.iString = 0;
    return AddButtons(1, &btn);
}
예제 #14
0
int CDynToolBar::ChangeButtons(UINT* pBtnIDs, UINT Len)
  {
  ASSERT(bButtonsOnce); //AddButtonsOnce should have been called
  CToolBarCtrl& bc = GetToolBarCtrl();
  BOOL Done = bc.DeleteButton(0);
  while (Done)
    Done = bc.DeleteButton(0);
  iLen = 0;
  BtnIDs.SetSize(0);
  BtnStyles.SetSize(0);
  AddButtons(pBtnIDs, Len, ButBitmap);
  if (!DoCreateButtons())
    return -1;
  return 0;
  }
예제 #15
0
int CDynToolBar::AddButtonsOnce(UINT BitmapID, UINT* pBtnIDs, UINT Len)
  {
  ASSERT(!bButtonsOnce); //cannot call this if AddButtonsOnce has been used
  ASSERT(pBits==NULL); //cannot call this if AddButtons has been used
  pTheBitmap = pTBMngr->FindBitmap(BitmapID);
  if (pTheBitmap==NULL)
    return -1;
  bButtonsOnce = 1;
  AddButtons(pBtnIDs, Len, ButBitmap);
  iBitLen = pTheBitmap->iLen;
  const int Size = pTBMngr->BtnSize * iBitLen;
  pBits = new char[Size];
  memcpy(pBits, pTheBitmap->pBits, Size);
  return 0;
  }
예제 #16
0
HRESULT CMenuToolbarBase::AddSeparator(BOOL last)
{
    TBBUTTON tbb = { 0 };

    tbb.fsState = TBSTATE_ENABLED;
#if !USE_TBSTYLE_EX_VERTICAL
    if (!last && (m_initFlags & SMINIT_VERTICAL))
        tbb.fsState |= TBSTATE_WRAP;
#endif
    tbb.fsStyle = BTNS_SEP;
    tbb.iBitmap = 0;

    m_hasSizes = FALSE;

    if (!AddButtons(1, &tbb))
        return HRESULT_FROM_WIN32(GetLastError());

    return S_OK;
}
예제 #17
0
HRESULT CMenuToolbarBase::AddPlaceholder()
{
    TBBUTTON tbb = { 0 };
    WCHAR MenuString[128];
    
    LoadStringW(GetModuleHandle(L"shell32.dll"), IDS_MENU_EMPTY, MenuString, _countof(MenuString));

    tbb.fsState = 0;
    tbb.fsStyle = 0;
    tbb.iString = (INT_PTR) MenuString;
    tbb.iBitmap = -1;

    m_hasSizes = FALSE;

    if (!AddButtons(1, &tbb))
        return HRESULT_FROM_WIN32(GetLastError());

    return S_OK;
}
예제 #18
0
BOOL CPaletteBar::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID )
{
	BOOL bRet = CToolBarCtrl::Create(dwStyle, rect, pParentWnd, nID);

	m_nButtonCount = ID_ELLIPSE - ID_ERASE + 1;

	VERIFY(AddBitmap(m_nButtonCount,IDR_PALETTEBAR) != -1);

	m_pTBButtons = new TBBUTTON[m_nButtonCount];

	int nIndex;
	for (nIndex = 0; nIndex < m_nButtonCount; nIndex++)
	{
		CString string;
		string.LoadString(nIndex + ID_ERASE);

		// Add second '\0'
		int nStringLength = string.GetLength() + 1;
		TCHAR* pString = string.GetBufferSetLength(nStringLength);
		pString[nStringLength] = 0;

		VERIFY((m_pTBButtons[nIndex].iString = AddStrings(pString)) != -1);

		string.ReleaseBuffer();


		m_pTBButtons[nIndex].fsState = TBSTATE_ENABLED;
		m_pTBButtons[nIndex].fsStyle = TBSTYLE_CHECKGROUP;
		m_pTBButtons[nIndex].dwData = 0;
		m_pTBButtons[nIndex].iBitmap = nIndex;
		m_pTBButtons[nIndex].idCommand = nIndex + ID_ERASE;

	}


	for (nIndex = 0; nIndex < m_nButtonCount; nIndex++)
	{
		VERIFY(AddButtons(1,&m_pTBButtons[nIndex]));
	}


	return bRet;
}
예제 #19
0
int CTbcShare::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CToolBarCtrlZ::OnCreate(lpCreateStruct) == -1)
		return -1;

	// TODO:  在此添加您专用的创建代码
	theWndMgr.m_pTbcShare = this;

	int	i = 0;

	InitImageList();

	AddSingleString(GetResString(IDS_OPEN));
	AddSingleString(GetResString(IDS_OPENFOLDER));
	AddSingleString(GetResString(IDS_RENAME));
	AddSingleString(GetResString(IDS_DELETE_FILE));
	AddSingleString(GetResString(IDS_SF_RELOAD));


	TBBUTTON	tbb[BUTTON_COUNT];
	CString		str;

	tbb[0].idCommand = MP_OPEN;
	tbb[1].idCommand = MP_OPENFOLDER;
	tbb[2].idCommand = MP_RENAME;
	tbb[3].idCommand = MP_REMOVE;
	tbb[4].idCommand = MP_REFRESH;

	for (i = 0; i < BUTTON_COUNT; i++)
	{
		tbb[i].iString = i;
		tbb[i].iBitmap = i;
		tbb[i].fsState = 0;
		tbb[i].fsStyle = TBSTYLE_BUTTON | BTNS_AUTOSIZE;
	}
	AddButtons(BUTTON_COUNT, tbb);

	EnableButton(MP_REFRESH);

	Localize();
	return 0;
}
예제 #20
0
int CDynToolBar::AddButtons(UINT BitmapID, UINT* pBtnIDs, UINT Len)
  {
  ASSERT(!bButtonsOnce); //cannot call this if AddButtonsOnce has been used
  CToolBarBitmap* pSrcBitmap = pTBMngr->FindBitmap(BitmapID);
  if (pSrcBitmap==NULL)
    return -1;
  UINT ActLen = AddButtons(pBtnIDs, Len, ButBitmap);
  UINT NewBitLen = iBitLen + ActLen;
  char* pNewBits = new char[pTBMngr->BtnSize * NewBitLen];
  DWORD w1 = NewBitLen * pTBMngr->BtnWidth; //total width of new bit structure
  DWORD w2 = pSrcBitmap->iLen * pTBMngr->BtnWidth; //total width of source bit structure
  if (pBits)
    {//copy old stuff...
    DWORD w = pTBMngr->BtnWidth * iBitLen; //total width of old bit structure
    for (UINT i=0; i<pTBMngr->BtnHeight; i++)
      memcpy(&pNewBits[i*w1], &pBits[i*w], w);
    delete []pBits;
    }
  UINT k = 0;
  for (UINT i=0; i<Len; i++)
    {
    if (pBtnIDs[i]!=ID_SEPARATOR)
      {
      int index = pSrcBitmap->GetBtnIndex(pBtnIDs[i]);
      DWORD o1 = pTBMngr->BtnWidth * (k+iBitLen); //offset
      if (index>=0)
        {
        DWORD o2 = pTBMngr->BtnWidth * index; //offset
        for (UINT j=0; j<pTBMngr->BtnHeight; j++)
          memcpy(&pNewBits[o1+(j*w1)], &(pSrcBitmap->pBits[o2+(j*w2)]), pTBMngr->BtnWidth);
        }
      else
        for (UINT j=0; j<pTBMngr->BtnHeight; j++)
          memset(&pNewBits[o1+j*w1], 0, pTBMngr->BtnWidth);
      k++;
      }
    }
  pBits = pNewBits;
  iBitLen = NewBitLen;
  return 0;
  }
예제 #21
0
CButtonDialog::CButtonDialog(LPCTSTR lpszText, LPCTSTR lpszCaption,
	LPCTSTR lpszButtons, WORD wStyle, DWORD* pHelpIDs ,
	CWnd* pParentWnd) : CCSDialog()
{

	ASSERT(lpszText != NULL);
	ASSERT(lpszCaption != NULL);
	if (HIWORD(lpszText) == NULL)
		VERIFY(m_strText.LoadString(LOWORD((DWORD)(INT_PTR)lpszText)));
	else
		m_strText = lpszText;
	if (HIWORD(lpszCaption) == NULL)
		VERIFY(m_strCaption.LoadString(LOWORD((DWORD)(INT_PTR)lpszCaption)));
	else
		m_strCaption = lpszCaption;
	if (lpszButtons != NULL)
		AddButtons(lpszButtons);

	m_pParentWnd = pParentWnd;
	m_nDefButton = 0;
	m_nCancel = -1;
	m_pButtons = NULL;
	m_wStyle = wStyle;
	m_nBaseID = nFontSize; // don't use IDOK, IDCANCEL, etc
	m_hDlgTmp = NULL;

	LOGFONT lf;
	memcpy(&lf, &theApp.m_lf, sizeof(LOGFONT));
	lf.lfHeight = -nFontSize;
	lf.lfWidth = 0;
	lf.lfWeight = FW_NORMAL;
	VERIFY(m_font.CreateFontIndirect(&lf));

//  m_font.CreateFont(-nFontSize, 0, 0, 0, FW_NORMAL, FALSE, FALSE,
//      FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
//      DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, szFontName);
	m_pHelpIDs = pHelpIDs;
}
예제 #22
0
BOOL COptionSheet::CalcSpacing(CFont &buttonFont)
{
	TEXTMETRIC	txtMetric;
	CRect		rcClient;
	CRect		rcWindow;
	COptionPage *page;
	CRect		rect;
	
	GetClientRect(rcClient);
	GetWindowRect(rcWindow);

	// Get the client area used by the window
	m_XBorder = rcWindow.Width() - rcClient.Width();
	m_YBorder = rcWindow.Height() - rcClient.Height();

	// Get the rect metrics of the font used on the buttons
	CDC *dc = GetDC();
	dc->SelectObject(buttonFont);
	dc->GetTextMetrics(&txtMetric);
	ReleaseDC(dc);

	// Calculate the height of the buttons and the button spacing
	m_ButtonHeight = (txtMetric.tmHeight + txtMetric.tmExternalLeading) + 10;
	m_ButtonYLocOffset = PAGE_SPACING2 + m_ButtonHeight;
	m_ButtonSpacing = m_ButtonHeight + PAGE_SPACING;
	m_ButtonWidth = BUTTON_WIDTH;

	// Adjust the button spacing if in full page wizard mode
	if(m_psh.dwFlags & OSH_WIZARDFULL) {
		m_ButtonSpacing += PAGE_SPACING;
	}

	// Calculate the space needed for the buttons
	m_AllButtonsWidth = 0;

	m_AllButtonsWidth = AddButtons(FALSE);

	// Calculate the sizes of the option pages
	m_MaxChildSize.cx = 0;
	m_MaxChildSize.cy = 0;

	for(int i = 0; i < GetPageCount(); i++) {
		BOOL result;
		CDialogTemplate tmpl;
		SIZE size;

		page = GetPage(i);

		// FIXME
		if(NULL != page->GetTemplateName()) {
			// Create the child dialog and get the rect
			result = tmpl.Load(page->GetTemplateName());
			ASSERT(TRUE == result);

			tmpl.GetSizeInPixels(&size);

			// Calc the size
			if(size.cx > m_MaxChildSize.cx) {
				m_MaxChildSize.cx = size.cx;
			}

			if(size.cy > m_MaxChildSize.cy) {
				m_MaxChildSize.cy = size.cy;
			}
		}
	}

	return TRUE;
}
예제 #23
0
/////////////////////////////////////////////////////////////////////////////
// CMyToolBarCtrl message handlers
void CMyToolBarCtrl::Init()
{
	COLORREF crMask = RGB(255, 0, 255);
	CBitmap tbBitmap;
	tbBitmap.LoadBitmap(IDB_TB_HOT);
	
	BITMAP bmpInfo;
	tbBitmap.GetBitmap(&bmpInfo);
	
	CSize bitmapSize(bmpInfo.bmHeight - 2, bmpInfo.bmHeight);
	SetBitmapSize(bitmapSize);
	
	CSize buttonSize(bmpInfo.bmHeight + 7, bmpInfo.bmHeight + 7);
	SetButtonSize(buttonSize);
	
	m_normalIL.Create(bmpInfo.bmHeight - 2, bmpInfo.bmHeight, ILC_COLOR24|ILC_MASK, 1, 1);
	m_normalIL.Add(&tbBitmap, crMask);
	SetImageList(&m_normalIL);
	tbBitmap.DeleteObject();

	tbBitmap.LoadBitmap(IDB_TB_HOT);
	m_hotIL.Create(bmpInfo.bmHeight - 2, bmpInfo.bmHeight, ILC_COLOR24|ILC_MASK, 1, 1);
	m_hotIL.Add(&tbBitmap, crMask);
	SetHotImageList(&m_hotIL);
	tbBitmap.DeleteObject();

	tbBitmap.LoadBitmap(IDB_TB_HOT);
	m_disableIL.Create(bmpInfo.bmHeight - 2, bmpInfo.bmHeight, ILC_COLOR24|ILC_MASK, 1, 1);
	m_disableIL.Add(&tbBitmap, crMask);
	SetDisabledImageList(&m_disableIL);
	tbBitmap.DeleteObject();

	int nFirstButtonID = FISRT_TOOLBAR_BUTTON_ID;
	int m_nButtonCount = LAST_TOOLBAR_BUTTON_ID - nFirstButtonID + 1;
	
	TBBUTTON tb;
	for (int nIndex = 0; nIndex < m_nButtonCount; nIndex++)
	{
		CString string;
		string.LoadString(nIndex + nFirstButtonID);
		
		// Add second '\0'
		int nStringLength = string.GetLength() + 1;
		TCHAR * pString = string.GetBufferSetLength(nStringLength);
		pString[nStringLength] = 0;
		
		VERIFY((tb.iString = AddStrings(pString)) != -1);
		
		string.ReleaseBuffer();
		
		tb.fsState = TBSTATE_ENABLED;
		tb.fsStyle = TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE;
		tb.dwData = 0;
		tb.iBitmap = nIndex;
		tb.idCommand = nIndex + nFirstButtonID;
		if(tb.idCommand >= TBBTN_DUMMY2)
		{
			tb.fsState = 0;
		}
		
		AddButtons(1, &tb);
	}
}
예제 #24
0
void CDynToolBar::AddSeparator()
  {
  UINT BtnID = ID_SEPARATOR;
  AddButtons(&BtnID, 1, ButSeparator);
  }
예제 #25
0
void CDynToolBar::AddEditButton(UINT BtnID)
  {
  AddButtons(&BtnID, 1, ButEdit);
  iEditLen++;
  }
예제 #26
0
void CDynToolBar::AddComboButton(UINT BtnID)
  {
  AddButtons(&BtnID, 1, ButCombo);
  iComboLen++;
  }
예제 #27
0
void CDynToolBar::AddTextButton(char* pTxt, UINT BtnID)
  {
  AddButtons(&BtnID, 1, ButText);
  iTxtLen++;
  BtnTxts.Add(pTxt);
  }
예제 #28
0
void CMuleToolbarCtrl::Init(void)
{
	m_astrToolbarPaths.RemoveAll();

	// Win98: Explicitly set to Unicode to receive Unicode notifications.
	SendMessage(CCM_SETUNICODEFORMAT, TRUE);

	ModifyStyle(0, TBSTYLE_FLAT | TBSTYLE_ALTDRAG | CCS_ADJUSTABLE | TBSTYLE_TRANSPARENT | TBSTYLE_TOOLTIPS | CCS_NODIVIDER);
	if (thePrefs.GetUseReBarToolbar())
	{
		ModifyStyle(0, CCS_NORESIZE);
		SetExtendedStyle(GetExtendedStyle() | TBSTYLE_EX_HIDECLIPPEDBUTTONS);
	}

	ChangeToolbarBitmap(thePrefs.GetToolbarBitmapSettings(), false);

	// add button-text:
	TCHAR cButtonStrings[2000];
	int lLen, lLen2;
	m_buttoncount = 0;
	
	_tcscpy(cButtonStrings, GetResString(IDS_MAIN_BTN_CONNECT));
	lLen = _tcslen(GetResString(IDS_MAIN_BTN_CONNECT)) + 1;
	++m_buttoncount;

	lLen2 = _tcslen(GetResString(IDS_EM_KADEMLIA)) + 1;
	memcpy(cButtonStrings+lLen, GetResString(IDS_EM_KADEMLIA), lLen2*sizeof(TCHAR));
	lLen += lLen2;
	++m_buttoncount;

	lLen2 = _tcslen(GetResString(IDS_EM_SERVER)) + 1;
	memcpy(cButtonStrings+lLen, GetResString(IDS_EM_SERVER), lLen2*sizeof(TCHAR));
	lLen += lLen2;
	++m_buttoncount;

	lLen2 = _tcslen(GetResString(IDS_EM_TRANS)) + 1;
	memcpy(cButtonStrings+lLen, GetResString(IDS_EM_TRANS), lLen2*sizeof(TCHAR));
	lLen += lLen2;
	++m_buttoncount;

	lLen2 = _tcslen(GetResString(IDS_EM_SEARCH)) + 1;
	memcpy(cButtonStrings+lLen, GetResString(IDS_EM_SEARCH), lLen2*sizeof(TCHAR));
	lLen += lLen2;
	++m_buttoncount;

	lLen2 = _tcslen(GetResString(IDS_EM_FILES)) + 1;
	memcpy(cButtonStrings+lLen, GetResString(IDS_EM_FILES), lLen2*sizeof(TCHAR));
	lLen += lLen2;
	++m_buttoncount;

	lLen2 = _tcslen(GetResString(IDS_EM_MESSAGES)) + 1;
	memcpy(cButtonStrings+lLen, GetResString(IDS_EM_MESSAGES), lLen2*sizeof(TCHAR));
	lLen += lLen2;
	++m_buttoncount;

#ifdef IRC
	lLen2 = _tcslen(GetResString(IDS_IRC)) + 1;
	memcpy(cButtonStrings+lLen, GetResString(IDS_IRC), lLen2*sizeof(TCHAR));
	lLen += lLen2;
	++m_buttoncount;
#endif

	lLen2 = _tcslen(GetResString(IDS_EM_STATISTIC)) + 1;
	memcpy(cButtonStrings+lLen, GetResString(IDS_EM_STATISTIC), lLen2*sizeof(TCHAR));
	lLen += lLen2;
	++m_buttoncount;

	lLen2 = _tcslen(GetResString(IDS_EM_PREFS)) + 1;
	memcpy(cButtonStrings+lLen, GetResString(IDS_EM_PREFS), lLen2*sizeof(TCHAR));
	lLen += lLen2;
	++m_buttoncount;

	lLen2 = _tcslen(GetResString(IDS_TOOLS)) + 1;
	memcpy(cButtonStrings+lLen, GetResString(IDS_TOOLS), lLen2*sizeof(TCHAR));
	lLen += lLen2;
	++m_buttoncount;

	lLen2 = _tcslen(GetResString(IDS_EM_HELP)) + 1;
	memcpy(cButtonStrings+lLen, GetResString(IDS_EM_HELP), lLen2*sizeof(TCHAR));
	lLen += lLen2;
	++m_buttoncount;

#ifdef MOD_SUNYAN
	lLen2 = _tcslen(GetResString(IDS_DMIBOX)) + 1;
	memcpy(cButtonStrings+lLen,GetResString(IDS_DMIBOX), lLen2*sizeof(TCHAR));
	lLen += lLen2;
	++m_buttoncount;
#endif

	// terminate
	memcpy(cButtonStrings+lLen, _T("\0"), sizeof(TCHAR));

	AddStrings(cButtonStrings);

	// initialize buttons:	
	for(int i = 0; i < m_buttoncount; i++)
	{		
		TBButtons[i].fsState	= TBSTATE_ENABLED;
		TBButtons[i].fsStyle	= TBSTYLE_CHECKGROUP;
		TBButtons[i].idCommand	= IDC_TOOLBARBUTTON + i;
		TBButtons[i].iString	= i;

		switch (TBButtons[i].idCommand)
		{
			case TBBTN_CONNECT:
			case TBBTN_OPTIONS:
			case TBBTN_TOOLS:
			case TBBTN_HELP:
				TBButtons[i].fsStyle = TBSTYLE_BUTTON;
				break;
		}
	}

	// set button image indices
	int iBitmap = 0;
	for (int i = 0; i < m_buttoncount; i++)
	{		
		TBButtons[i].iBitmap = iBitmap;
		if (TBButtons[i].idCommand == TBBTN_CONNECT) // 'Connect' button has 3 states
			iBitmap += 3;
		else
			iBitmap += 1;
	}
	
	TBBUTTON sepButton = {0};
	sepButton.idCommand = 0;
	sepButton.fsStyle = TBSTYLE_SEP;
	sepButton.fsState = TBSTATE_ENABLED;
	sepButton.iString = -1;
	sepButton.iBitmap = -1;
	
	CString config = thePrefs.GetToolbarSettings();
	for (int i = 0; i < config.GetLength(); i += 2)
	{
		int index = _tstoi(config.Mid(i, 2));
		if (index == 99)
		{
			AddButtons(1, &sepButton);
			continue;
		}
		AddButtons(1, &TBButtons[index]);
	}

	// recalc toolbar-size
	SetAllButtonsStrings();
	ChangeTextLabelStyle(thePrefs.GetToolbarLabelSettings(), false, true);
	SetAllButtonsWidth();	// then calc and set the button width
	AutoSize();				// and finally call the original (but maybe obsolete) function
	SaveCurHeight();
}
예제 #29
0
BOOL COptionSheet::OnInitDialog() 
{
	BOOL		result;
	CRect		rcClient;
	int			width;
	int			height;

	// Call the default behaviour
	CDialog::OnInitDialog();

	m_CurrentPage = NULL;

	// Create out button font
	if(NULL != m_Font.GetSafeHandle()) {
		m_Font.DeleteObject();
	}

	m_Font.Attach(GetStockObject(DEFAULT_GUI_FONT));

	// Set the icon
	if(m_psh.dwFlags & OSH_USEHICON && NULL != m_psh.hIcon) {
		SetIcon(m_psh.hIcon, FALSE);
	}

	// Calculate spacing needed by all items
	result = CalcSpacing(m_Font);
	if(FALSE == result) {
		ASSERT(0);
		DestroyWindow();
		return TRUE;
	}

	// Adjust our X position to compensate for the biggest child dialog
	width = m_MaxChildSize.cx;
	if(m_psh.dwFlags & OSH_WIZARDFULL) {
		width += (FULLPAGE_SPACING * 2);
	} else {
		width += (PAGE_SPACING * 2);
	}
	if(0 != m_ListWidth) {
		width += m_ListWidth + PAGE_SPACING;
	}

	if(width < m_AllButtonsWidth) {
		width = m_AllButtonsWidth;
	}

	width += m_XBorder;


	// Adjust our X position to compensate for the biggest child dialog
	height = m_YBorder + m_MaxChildSize.cy + m_ButtonSpacing;
	if(!(m_psh.dwFlags & OSH_WIZARDFULL)) {
		height += (PAGE_SPACING * 2);
	}
	
	// Set the new window position
	SetWindowPos(&wndTop,
				 0,
				 0,
				 width, 
				 height,
				 SWP_NOMOVE | SWP_NOZORDER);

	// Set the title
	if(0 != m_strCaption.GetLength()) {
		SetWindowText(m_strCaption);
	}


	// Add the buttons
	AddButtons();

	// IF we are not in wizard mode, select the first root tree item
	// otherwise, display the first page in the list.
	if(FALSE == IsWizardMode()) {
		CRect rect;
		// Select the default item
		BuildList();
		CalcTreeRect(rect);
		GetListControlWnd()->MoveWindow(rect);
	}

	SetActivePage(m_StartPageIndex);

	SetModified(FALSE);

	// We are done!
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
예제 #30
0
bool CTransparentBar::Create(CWnd* parent, UINT id)
{
	int height= GetApp()->IsWhistlerLookAvailable() ? 25 : 23;

	if (!CToolBarCtrl::Create(WS_CHILD | WS_VISIBLE | TBSTYLE_TOOLTIPS | TBSTYLE_FLAT | //TBSTYLE_TRANSPARENT |
		CCS_NOMOVEY | CCS_NORESIZE | CCS_NOPARENTALIGN | CCS_NODIVIDER, CRect(0,0,80,height), parent, id))
	{
		ASSERT(false);
		return false;
	}

	SendMessage(WM_SETFONT, WPARAM(::GetStockObject(DEFAULT_GUI_FONT)));

	// Add toolbar buttons
	//
	SetButtonStructSize(sizeof(TBBUTTON));
	static const int anCommands[]=
	{
		ID_PHOTO_PREV, ID_PHOTO_NEXT, SC_CLOSE
	};
	const int COUNT= array_count(anCommands);		// no of buttons
	CSize btn_size;
	{
		CBitmap Bmp;
		Bmp.LoadBitmap(IDB_TRANSPARENT_BAR);
		BITMAP bmp;
		Bmp.GetBitmap(&bmp);
		btn_size = CSize(bmp.bmWidth / COUNT, bmp.bmHeight);	// determine single button bitmap size
	}
	SetBitmapSize(btn_size);
	SetButtonSize(btn_size + CSize(8, 7));
	AddBitmap(COUNT, IDB_TRANSPARENT_BAR);
//	RString tb(IDS_MAIN_TOOLBAR);
//	tb += "\n";
//	tb.Replace('\n', '\0');
//	int string= AddStrings(tb);
	CSize padding_size= GetApp()->IsWhistlerLookAvailable() ? CSize(5, 9) : CSize(3, 7);
	SendMessage(TB_SETPADDING, 0, MAKELONG(padding_size.cx, padding_size.cy));
	for (int i= 0; i < COUNT; i++)
	{
		TBBUTTON btn;
		if (anCommands[i] == 0)
		{
			btn.iBitmap = 8;
			btn.idCommand = -1;
			btn.fsState = TBSTATE_ENABLED;
			btn.fsStyle = TBSTYLE_SEP;
			btn.data  = 0;
			btn.iString = 0;
			AddButtons(1, &btn);
		}
		btn.iBitmap = i;
		btn.idCommand = anCommands[i];
		btn.fsState = TBSTATE_ENABLED;
		btn.fsStyle = TBSTYLE_BUTTON; // | TBSTYLE_AUTOSIZE;
//		if (anCommands[i] == ID_RECURSIVE || anCommands[i] == ID_EXIF_ONLY)
//			btn.fsStyle |= TBSTYLE_CHECK;
//		else if (anCommands[i] == ID_VIEW_DETAILS || anCommands[i] == ID_VIEW_THUMBNAILS)
//			btn.fsStyle |= TBSTYLE_CHECKGROUP;
//		if (anCommands[i] == ID_FOLDER_LIST)
//			btn.fsStyle |= BTNS_WHOLEDROPDOWN;
//		if (anCommands[i] == ID_BROWSER || anCommands[i] == ID_COMPOSER || anCommands[i] == ID_READ_CAMERA)
//			btn.fsStyle |= BTNS_DROPDOWN;

		btn.data = 0;

//		if (anCommands[i] == ID_BROWSER || anCommands[i] == ID_COMPOSER ||
//			anCommands[i] == ID_READ_CAMERA || anCommands[i] == ID_FOLDER_LIST)
//			btn.iString = string++;
//		else
			btn.iString = -1;

		AddButtons(1, &btn);
	}
//	SetExtendedStyle(TBSTYLE_EX_DRAWDDARROWS);

	return true;
}