void CCell::initButton( QMainWindow * mWnd ) { Helper * help = Helper::Instance(); button = new QPushButton( QIcon(":/" + help->GetItemNameByState( hextype )), "", mWnd ); button->setFixedWidth( GetButtonWidth() ); button->setFixedHeight( GetButtonHeight() ); button->setIconSize( QSize( GetButtonWidth(), GetButtonHeight() ) ); button->setFlat( true ); button->setCheckable(true); }
void cSettingsDialog::LayoutAndSetWindowSize() { int iX = GetMarginWidth(); int iY = GetMarginHeight(); // Find the widest static text const int widestStaticText = max(max(MeasureStaticTextWidth(historyStaticClearFolders.GetHandle()), MeasureStaticTextWidth(historyStaticClearCache.GetHandle())), MeasureStaticTextWidth(historyStaticCacheSize.GetHandle())); // Find the widest row of controls on the right const int widthRowClearFolders = MeasureButtonWidth(historyStaticClearFolders.GetHandle()); const int widthRowClearCache = MeasureButtonWidth(buttonHistoryClearCache.GetHandle()); const int widthCacheGB = MeasureStaticTextWidth(historyStaticGB.GetHandle()); const int widestRowOnTheRight = max(widthRowClearFolders, widthRowClearCache); const int widthCacheMaximumSize = widestRowOnTheRight - (GetSpacerWidth() + widthCacheGB); const int widthControls = widestStaticText + GetSpacerWidth() + widestRowOnTheRight; const int widthHistoryText = MeasureStaticTextWidth(lineHistory.GetStaticTextHandle()); const int widthHistoryLine = widthControls - (widthHistoryText + GetSpacerWidth()); const int heightHistoryLine = MeasureStaticTextHeight(lineHistory.GetStaticTextHandle(), widthHistoryLine); MoveControl(lineHistory.GetStaticTextHandle(), iX, iY, widthHistoryText, heightHistoryLine); MoveControl(lineHistory.GetLineHandle(), iX + widthHistoryText + GetSpacerWidth(), iY + (heightHistoryLine / 2), widthHistoryLine, 1); iY += heightHistoryLine + GetSpacerHeight(); MoveControlStaticNextToOtherControls(historyStaticClearFolders.GetHandle(), iX, iY, widestStaticText); MoveControl(buttonHistoryClearFolders.GetHandle(), iX + widestStaticText + GetSpacerWidth(), iY, widestRowOnTheRight, GetButtonHeight()); iY += GetButtonHeight() + GetSpacerHeight(); MoveControlStaticNextToOtherControls(historyStaticClearCache.GetHandle(), iX, iY, widestStaticText); MoveControl(buttonHistoryClearCache.GetHandle(), iX + widestStaticText + GetSpacerWidth(), iY, widestRowOnTheRight, GetButtonHeight()); iY += GetButtonHeight() + GetSpacerHeight(); MoveControlStaticNextToOtherControls(historyStaticCacheSize.GetHandle(), iX, iY, widestStaticText); MoveControlInputUpDown(historyCacheMaximumSizeGB, iX + widestStaticText + GetSpacerWidth(), iY, widthCacheMaximumSize); MoveControlStaticNextToOtherControls(historyStaticGB.GetHandle(), iX + widestStaticText + GetSpacerWidth() + widthCacheMaximumSize + GetSpacerWidth(), iY, widthCacheGB); iY += GetInputHeight() + GetSpacerHeight(); const int iWidth = widestStaticText + GetSpacerWidth() + widestRowOnTheRight; MoveControl(horizontalLine.GetLineHandle(), iX, iY, iWidth, 1); iY += 1 + GetSpacerHeight(); const int iDialogWidth = GetMarginWidth() + iWidth + GetMarginWidth(); const int iDialogHeight = iY + GetButtonHeight() + GetMarginHeight(); MoveOkCancelHelp(iDialogWidth, iDialogHeight); // Set our window size now that we know how big it should be SetClientSize(iDialogWidth, iDialogHeight); }
void cMainWindow::OnResize(size_t width, size_t height) { statusBar.Resize(); int iStatusBarWidth = 0; int iStatusBarHeight = 0; GetControlSize(statusBar.GetHandle(), iStatusBarWidth, iStatusBarHeight); int iWindowWidth = int(width); int iWindowHeight = int(height) - iStatusBarHeight; const int iScrollBarWidth = GetScrollBarWidth(); const int iButtonHeight = GetButtonHeight(); const int iButtonWidth = iButtonHeight; const int iButtonsTotalWidth = (2 * (iButtonWidth + GetSpacerWidth())); const int iPathWidth = iWindowWidth - (iButtonsTotalWidth + (2 * GetSpacerWidth())); const int iPathHeight = GetComboBoxHeight(); int x = GetSpacerWidth(); int y = GetSpacerHeight(); MoveControl(comboBoxPath.GetHandle(), x, y, iPathWidth, iPathHeight); x += iPathWidth + GetSpacerWidth(); MoveControl(buttonPathUp.GetHandle(), x, y, iButtonWidth, iButtonHeight); x += iButtonWidth + GetSpacerWidth(); MoveControl(buttonPathShowFolder.GetHandle(), x, y, iButtonWidth, iButtonHeight); x += iButtonWidth + GetSpacerWidth(); y += max(iPathHeight, iButtonHeight) + GetSpacerHeight(); iWindowHeight -= max(iPathHeight, iButtonHeight) + (2 * GetSpacerHeight()); MoveControl(scrollBar.GetHandle(), iWindowWidth - iScrollBarWidth, y, iScrollBarWidth, iWindowHeight); iWindowWidth -= iScrollBarWidth; MoveControl(photoBrowserView.GetHandle(), 0, y, iWindowWidth, iWindowHeight); // Update the scrollbar UpdateScrollBar(); }