void CPrinterInfo::WriteSettings(void) { WriteProfileInt(ENTRY_FastBitmaps, FastBitmaps(), GetDefaultFastBitmaps()); WriteProfileInt(ENTRY_OutlineGammaValue, GetOutlineGamma(), DEFAULT_OUTLINE_GAMMA); WriteProfileInt(ENTRY_GammaValue, m_Record.m_nBitmapGamma, DEFAULT_BITMAP_GAMMA); WriteProfileInt(ENTRY_FastBitmapGammaValue, m_Record.m_nFastBitmapGamma, DEFAULT_FAST_BITMAP_GAMMA); WriteProfileInt(ENTRY_PostscriptType, GetPostScriptType(), m_nDefaultPostScriptType); WriteProfileInt(ENTRY_EnvelopePosition, GetEnvelopePosition(), GetDefaultEnvelopePosition()); if (m_nOrientationType == PORTRAIT) { WriteProfileFixed(ENTRY_LeftMargin, GetLeftMargin(), m_PhysicalMargins.Left); WriteProfileFixed(ENTRY_TopMargin, GetTopMargin(), m_PhysicalMargins.Top); WriteProfileFixed(ENTRY_RightMargin, GetRightMargin(), m_PhysicalMargins.Right); WriteProfileFixed(ENTRY_BottomMargin, GetBottomMargin(), m_PhysicalMargins.Bottom); WriteProfileFixed(ENTRY_LeftOffset, GetLeftOffset(), MakeFixed(0)); WriteProfileFixed(ENTRY_TopOffset, GetTopOffset(), MakeFixed(0)); } else { WriteProfileFixed(ENTRY_LeftMarginLandscape, GetLeftMargin(), m_PhysicalMargins.Left); WriteProfileFixed(ENTRY_TopMarginLandscape, GetTopMargin(), m_PhysicalMargins.Top); WriteProfileFixed(ENTRY_RightMarginLandscape, GetRightMargin(), m_PhysicalMargins.Right); WriteProfileFixed(ENTRY_BottomMarginLandscape, GetBottomMargin(), m_PhysicalMargins.Bottom); WriteProfileFixed(ENTRY_LeftOffsetLandscape, GetLeftOffset(), MakeFixed(0)); WriteProfileFixed(ENTRY_TopOffsetLandscape, GetTopOffset(), MakeFixed(0)); } WriteProfileInt(ENTRY_UseReverseLandscape, ReverseLandscape(), GetDefaultReverseLandscape()); WriteProfileInt(ENTRY_DoubleSidedType, GetDoubleSidedType(), 0); WriteProfileInt(ENTRY_PrintInstructions, GetPrintInstructions(), DEFAULT_PRINT_INSTRUCTIONS); WriteProfileInt(ENTRY_FlagPrintAsBitmap, GetPrintAsBitmap(), FALSE); }
CRect COXCoolComboBox::GetButtonRect() const { CRect rect(0,0,0,0); BOOL bSimpleCombo=((GetStyle()&0x000f)==CBS_SIMPLE); if(bSimpleCombo) return rect; GetClientRect(&rect); int nRightMargin=GetRightMargin(); int nTopMargin=GetTopMargin(); int nBottomMargin=GetBtmMargin(); int nButtonWidth=GetButtonWidth(); rect.left=rect.right-nRightMargin-::GetSystemMetrics(SM_CXVSCROLL); rect.top+=nTopMargin; rect.right=rect.left+nButtonWidth; rect.bottom-=nBottomMargin; if(rect.left<0) rect.left=0; return rect; }
// Draw all tabs void wxTabView::Draw(wxDC& dc) { // Don't draw anything if there are no tabs. if (GetNumberOfTabs() == 0) return; // Draw top margin area (beneath tabs and above view area) if (GetTabStyle() & wxTAB_STYLE_COLOUR_INTERIOR) { dc.SetPen(*wxTRANSPARENT_PEN); if(GetBackgroundBrush()) dc.SetBrush(*GetBackgroundBrush()); // Add 1 because the pen is transparent. Under Motif, may be different. dc.DrawRectangle( m_tabViewRect.x, (m_tabViewRect.y - m_topMargin), (m_tabViewRect.width + 1), (m_topMargin + 1) ); } // Draw layers in reverse order wxTabLayerList::compatibility_iterator node = m_layers.GetLast(); while (node) { wxTabLayer *layer = (wxTabLayer *)node->GetData(); wxList::compatibility_iterator node2 = layer->GetFirst(); while (node2) { wxTabControl *control = (wxTabControl *)node2->GetData(); control->OnDraw(dc, (!node2->GetNext())); node2 = node2->GetNext(); } node = node->GetPrevious(); } #ifndef wxUSE_NEW_METHOD if (GetTabStyle() & wxTAB_STYLE_DRAW_BOX) { dc.SetPen(* GetShadowPen()); // Draw bottom line dc.DrawLine( (GetViewRect().x + 1), (GetViewRect().y + GetViewRect().height), (GetViewRect().x + GetViewRect().width + 1), (GetViewRect().y + GetViewRect().height) ); // Draw right line dc.DrawLine( (GetViewRect().x + GetViewRect().width), (GetViewRect().y - GetTopMargin() + 1), (GetViewRect().x + GetViewRect().width), (GetViewRect().y + GetViewRect().height) ); dc.SetPen(* wxBLACK_PEN); // Draw bottom line dc.DrawLine( (GetViewRect().x), (GetViewRect().y + GetViewRect().height + 1), #if defined(__WXMOTIF__) (GetViewRect().x + GetViewRect().width + 1), #else (GetViewRect().x + GetViewRect().width + 2), #endif (GetViewRect().y + GetViewRect().height + 1) ); // Draw right line dc.DrawLine( (GetViewRect().x + GetViewRect().width + 1), (GetViewRect().y - GetTopMargin()), (GetViewRect().x + GetViewRect().width + 1), (GetViewRect().y + GetViewRect().height + 1) ); } #endif }
// Layout tabs (optional, e.g. if resizing window) void wxTabView::LayoutTabs(void) { // Make a list of the tab controls, deleting the wxTabLayers. wxList controls; wxTabLayerList::compatibility_iterator layerNode = m_layers.GetFirst(); while (layerNode) { wxTabLayer *layer = (wxTabLayer *)layerNode->GetData(); wxList::compatibility_iterator tabNode = layer->GetFirst(); while (tabNode) { wxTabControl *tab = (wxTabControl *)tabNode->GetData(); controls.Append(tab); wxList::compatibility_iterator next = tabNode->GetNext(); layer->Erase(tabNode); tabNode = next; } wxTabLayerList::compatibility_iterator nextLayerNode = layerNode->GetNext(); delete layer; m_layers.Erase(layerNode); layerNode = nextLayerNode; } wxTabControl *lastTab = NULL; wxTabLayer *currentLayer = new wxTabLayer; m_layers.Append(currentLayer); wxList::compatibility_iterator node = controls.GetFirst(); while (node) { wxTabControl *tabControl = (wxTabControl *)node->GetData(); if (lastTab) { // Start another layer (row). // Tricky choice: can't just check if will be overlapping the edge, because // this happens anyway for 2nd and subsequent rows. // Should check this for 1st row, and then subsequent rows should not exceed 1st // in length. if (((currentLayer == m_layers.GetFirst()->GetData()) && ((lastTab->GetX() + 2*lastTab->GetWidth() + GetHorizontalTabSpacing()) > GetViewRect().width)) || ((currentLayer != m_layers.GetFirst()->GetData()) && (currentLayer->GetCount() == ((wxTabLayer *)m_layers.GetFirst()->GetData())->GetCount()))) { currentLayer = new wxTabLayer; m_layers.Append(currentLayer); lastTab = NULL; } } int layer = m_layers.GetCount() - 1; tabControl->SetRowPosition(currentLayer->GetCount()); tabControl->SetColPosition(layer); // Top of new tab int verticalOffset = (- GetTopMargin()) - ((layer+1)*GetTabHeight()); // Offset from view top-left int horizontalOffset = 0; if (!lastTab) horizontalOffset = layer*GetHorizontalTabOffset(); else horizontalOffset = lastTab->GetX() + GetTabWidth() + GetHorizontalTabSpacing(); tabControl->SetPosition(horizontalOffset, verticalOffset); tabControl->SetSize(GetTabWidth(), GetTabHeight()); currentLayer->Append(tabControl); lastTab = tabControl; node = node->GetNext(); } // Move the selected tab to the bottom wxTabControl *control = FindTabControlForId(m_tabSelection); if (control) MoveSelectionTab(control); }
// Automatically positions tabs // TODO: this should just add the tab to a list, and then // a layout function (e.g. Realize) should be called when all tabs have been added. // The view rect could easily change as the view window is resized. wxTabControl *wxTabView::AddTab(int id, const wxString& label, wxTabControl *existingTab) { // First, find which layer we should be adding to. wxTabLayerList::compatibility_iterator node = m_layers.GetLast(); if (!node) { wxTabLayer *newLayer = new wxTabLayer; node = m_layers.Append(newLayer); } // Check if adding another tab control would go off the // right-hand edge of the layer. wxTabLayer *tabLayer = (wxTabLayer *)node->GetData(); wxList::compatibility_iterator lastTabNode = tabLayer->GetLast(); if (lastTabNode) { wxTabControl *lastTab = (wxTabControl *)lastTabNode->GetData(); // Start another layer (row). // Tricky choice: can't just check if will be overlapping the edge, because // this happens anyway for 2nd and subsequent rows. // Should check this for 1st row, and then subsequent rows should not exceed 1st // in length. if (((tabLayer == m_layers.GetFirst()->GetData()) && ((lastTab->GetX() + 2*lastTab->GetWidth() + GetHorizontalTabSpacing()) > GetViewRect().width)) || ((tabLayer != m_layers.GetFirst()->GetData()) && (tabLayer->GetCount() == ((wxTabLayer *)m_layers.GetFirst()->GetData())->GetCount()))) { tabLayer = new wxTabLayer; m_layers.Append(tabLayer); lastTabNode = wxList::compatibility_iterator(); } } int layer = m_layers.GetCount() - 1; wxTabControl *tabControl = existingTab; if (!existingTab) tabControl = OnCreateTabControl(); tabControl->SetRowPosition(tabLayer->GetCount()); tabControl->SetColPosition(layer); wxTabControl *lastTab = NULL; if (lastTabNode) lastTab = (wxTabControl *)lastTabNode->GetData(); // Top of new tab int verticalOffset = (- GetTopMargin()) - ((layer+1)*GetTabHeight()); // Offset from view top-left int horizontalOffset = 0; if (!lastTab) horizontalOffset = layer*GetHorizontalTabOffset(); else horizontalOffset = lastTab->GetX() + GetTabWidth() + GetHorizontalTabSpacing(); tabControl->SetPosition(horizontalOffset, verticalOffset); tabControl->SetSize(GetTabWidth(), GetTabHeight()); tabControl->SetId(id); tabControl->SetLabel(label); tabControl->SetFont(* GetTabFont()); tabLayer->Append(tabControl); m_noTabs ++; return tabControl; }
void COXCoolComboBox::OnPaint() { if(!IsInCoolState()) { Default(); return; } // set up all the pens we are likely to need HPEN penDefault=(HPEN)GetStockObject(BLACK_PEN); static CPen penHilite(PS_SOLID,1,GetSysColor(COLOR_3DHIGHLIGHT)); static CPen penShadow(PS_SOLID,1,GetSysColor(COLOR_3DSHADOW)); static CPen penFace3D(PS_SOLID,1,GetSysColor(COLOR_3DFACE)); static CPen penDkShad3D(PS_SOLID,1,GetSysColor(COLOR_3DDKSHADOW)); // store margins for future use int nLeftMargin=GetLeftMargin(); int nRightMargin=GetRightMargin(); int nTopMargin=GetTopMargin(); int nBottomMargin=GetBtmMargin(); CRect button_rect=GetButtonRect(); const BOOL bSimpleCombo=((GetStyle()&0x000f)==CBS_SIMPLE); const BOOL bIsEnabled=IsWindowEnabled(); const BOOL bIsHot=IsInHotState() & bIsEnabled; // paint background CPaintDC paintdc(this); CDC* dc=&paintdc; CRect rect, rectClient, rectInternal; // temp rect, client rect, internal rect respectively GetClientRect(rectClient); rectClient.right-=::GetSystemMetrics(SM_CXVSCROLL)-GetButtonWidth(); if(bSimpleCombo) { ASSERT(::IsWindow(m_edit.GetSafeHwnd())); CRect rectEdit; m_edit.GetWindowRect(rectEdit); rectClient.bottom=rectClient.top+rectEdit.Height()+5; } // set up internal rectangle rectInternal=rectClient; rectInternal.left+=nLeftMargin; rectInternal.top+=nTopMargin; rectInternal.right-=nRightMargin; rectInternal.bottom-=nBottomMargin; rect=rectInternal; if(!button_rect.IsRectEmpty()) rect.right=button_rect.left; if(!bIsEnabled) ::FillRect(dc->m_hDC,&rect,GetSysColorBrush(COLOR_3DFACE)); else ::FillRect(dc->m_hDC,&rect,GetSysColorBrush(COLOR_WINDOW)); // do default painting if(!::IsWindow(m_edit.GetSafeHwnd())) { DRAWITEMSTRUCT dis={ sizeof(&dis) }; dis.CtlType=ODT_COMBOBOX; dis.CtlID=GetWindowLongPtr(m_hWnd, GWL_ID); dis.itemID=GetCurSel(); dis.itemAction=ODA_DRAWENTIRE; dis.hwndItem=m_hWnd; dis.hDC=dc->m_hDC; dis.rcItem=CRect(nLeftMargin+1,nTopMargin+1, button_rect.left-1,rectClient.bottom-nBottomMargin-1); dis.itemData=GetItemData(GetCurSel()); dis.itemState=((::GetFocus()==GetSafeHwnd() && !IsDroppedDown()) ? ODS_FOCUS : 0); DrawItem(&dis); } // now do our painting - first borderect... // but first exclude the 'real' client area from the DC dc->SelectClipRgn(NULL); // from drawing background dc->ExcludeClipRect(&rectInternal); // draw border if(!bIsHot) { // now paint background if(bSimpleCombo) FillRect(dc->m_hDC, &rectClient, ::GetSysColorBrush(COLOR_WINDOW)); else FillRect(dc->m_hDC, &rectClient, ::GetSysColorBrush(COLOR_3DFACE)); // fill in small area to the left of edit window in appropriate colour, // to make window look bigger rect=rectClient; rect.top+=nTopMargin; rect.left+=nLeftMargin-1; rect.right=rect.left+1; rect.bottom-=nBottomMargin; if(bIsEnabled) FillRect(dc->m_hDC, &rect, GetSysColorBrush(COLOR_WINDOW)); else FillRect(dc->m_hDC, &rect, GetSysColorBrush(COLOR_3DFACE)); } else { // HOT case - difficult to describe, but reasonably obvious rect=rectClient; rect.left++; rect.right--; rect.top++; rect.bottom-=1+EXTRA_BOTTOM_MARGIN; // paint background FillRect(dc->m_hDC, &rect, GetSysColorBrush(COLOR_3DFACE)); // and border rect=rectClient; SelectObject(dc->m_hDC,penShadow); dc->MoveTo(0,0); dc->LineTo(rect.right,0); dc->MoveTo(0,0); dc->LineTo(0,rect.bottom-1-EXTRA_BOTTOM_MARGIN); SelectObject(dc->m_hDC,penHilite); dc->LineTo(rect.right-1,rect.bottom-1-EXTRA_BOTTOM_MARGIN); dc->LineTo(rect.right-1,rect.top); // and paint extra margin if(EXTRA_BOTTOM_MARGIN) { rect=rectClient; rect.top=rect.bottom-EXTRA_BOTTOM_MARGIN; FillRect(dc->m_hDC, &rect, GetSysColorBrush(COLOR_3DFACE)); } } // unselect the clip region SelectClipRgn(dc->m_hDC, NULL); // now draw highlight border, if disabled if(!bIsEnabled) { SelectObject(dc->m_hDC, GetStockObject(NULL_BRUSH)); SelectObject(dc->m_hDC, penHilite); dc->Rectangle(rectInternal.left-1, rectInternal.top-1, rectInternal.right+1, rectInternal.bottom+1); } // and now for the button BOOL pressed=IsDroppedDown(); rect=button_rect; // do the background if(bIsHot) { rect.bottom--; rect.right++; } if(bIsHot || pressed || !bIsEnabled) { ::FillRect(dc->m_hDC, &rect, GetSysColorBrush(COLOR_3DFACE)); } else { if(bIsEnabled) { // cold and unpressed SelectObject(dc->m_hDC, penHilite); SelectObject(dc->m_hDC, GetSysColorBrush(COLOR_3DFACE)); ::Rectangle(dc->m_hDC, rect.left, rect.top, rect.right, rect.bottom); } } rect=button_rect; // set again if(bIsHot || pressed) { if(pressed) { SelectObject(dc->m_hDC, penShadow); dc->MoveTo(rect.left , rect.top); dc->LineTo(rect.right, rect.top); dc->MoveTo(rect.left , rect.top); dc->LineTo(rect.left , rect.bottom); } else { SelectObject(dc->m_hDC, penHilite); dc->MoveTo(rect.right, rect.top); dc->LineTo(rect.left+1, rect.top); dc->LineTo(rect.left+1, rect.bottom); SelectObject(dc->m_hDC, penFace3D); dc->MoveTo(rect.left, rect.top); dc->LineTo(rect.left, rect.bottom); SelectObject(dc->m_hDC, penShadow); dc->MoveTo(rect.left , rect.bottom - 1); dc->LineTo(rect.right-1, rect.bottom - 1); dc->LineTo(rect.right-1, rect.top); } SelectObject(dc->m_hDC, penDefault); } // now draw shadowy arrow SelectObject(dc->m_hDC, penDkShad3D); SelectObject(dc->m_hDC, ::GetSysColorBrush(COLOR_3DDKSHADOW)); POINT p[3]; p[0].x=rect.left +((rect.right - rect.left) / 3); p[1].x=rect.left +(2 *(rect.right - rect.left) / 3) + 1; p[2].x=(p[0].x + p[1].x) / 2; if(((p[1].x - p[0].x) % 2)) p[1].x--; p[0].y=(rect.top + rect.bottom / 2) -(p[1].x - p[0].x) / 4 - 1; p[1].y=p[0].y; p[2].y=p[0].y +(p[1].x - p[0].x) / 2; if(pressed) // offset by a pixel { p[0].x++; p[0].y++; p[1].x++; p[1].y++; p[2].x++; p[2].y++; } Polygon(dc->m_hDC, p, 3); }
/*---------------------------------------------------------------------------*/ void HTMLBodyDisplay::Format(void) { DisplayManager *manager = GetManager(); if (manager) { PresetWebRect rect(&manager->mViewRect); DISPLAY_INT viewportWidth = rect.Width(); DISPLAY_INT viewportHeight = rect.Height(); WEBC_DEBUG_LOG_TIME_HANDLE(TimeInside) WEBC_DEBUG_LOG_TIME_ENTER(TimeInside,"HTMLBodyDisplay::Format", " ") rect.MoveTo(0, 0); SetParentWidth(viewportWidth, viewportWidth); SetParentHeight(viewportHeight); #if (WEBC_SUPPORT_FRAMES) HTMLBody* bodyElement = (HTMLBody*) mpHtmlElement; HTMLFrameSet* framesetElement = (bodyElement)? bodyElement->GetFrameSet() : 0; mpFrameSet = (HTMLFrameSetDisplay*) ((framesetElement)? framesetElement->GetDisplayElement() : 0); if (mpFrameSet) { // remove all old children while (mpFirstChild) { Remove(mpFirstChild); } // add the frameset mpFrameSet->SetParentWidth(viewportWidth, viewportWidth); mpFrameSet->SetParentHeight(viewportHeight); mpFrameSet->SetXYPosition(0,0); mpFrameSet->SetParentDisplay(this, 0); miContentHeight = viewportHeight; miMaxWidth = viewportWidth; miMinWidth = viewportWidth; mFlowFlags &= ~(FD_FLAG_POS_CHILD_STYLE_MODIFIED| FD_FLAG_FLOW_CHILD_STYLE_MODIFIED| FD_FLAG_LOCAL_STYLE_MODIFIED| FD_FLAG_PARENT_STYLE_MODIFIED); } else #endif // WEBC_SUPPORT_FRAMES { DISPLAY_INT marginLeftValue = GetLeftMargin(); DISPLAY_INT marginRightValue = GetRightMargin(); DISPLAY_INT marginTopValue = GetTopMargin(); DISPLAY_INT paddingLeftValue = mBorder.GetPaddingWidth(CSS_LEFT); DISPLAY_INT paddingRightValue = mBorder.GetPaddingWidth(CSS_RIGHT); DISPLAY_INT paddingTopValue = mBorder.GetPaddingWidth(CSS_TOP); // check to see if we just need to update positioned child formatting if (mFlowFlags & (FD_FLAG_FLOW_CHILD_STYLE_MODIFIED| FD_FLAG_LOCAL_STYLE_MODIFIED| FD_FLAG_PARENT_STYLE_MODIFIED)) { DISPLAY_INT iContentWidth; MarginContext margin (marginLeftValue + paddingLeftValue, viewportWidth - (marginRightValue + paddingRightValue) - 1, this); // Format the flow content miContentHeight = FormatFlowContent (&margin, marginLeftValue + paddingLeftValue, marginTopValue + paddingTopValue, &iContentWidth); // update miContentHeight to include anything in the margins DISPLAY_INT topPad = marginTopValue + paddingTopValue; DISPLAY_INT clearedHeight = margin.ClearAll(topPad + miContentHeight) - topPad; if (clearedHeight > miContentHeight) { miContentHeight = clearedHeight; } // set this element's height UpdateHeight(0, 0); } // Format positioned elements FormatContextFactory childContextFactory; if (mPositionedChildFormatContext) { WebRect oldRect; mPositionedChildFormatContext->getContainingBlock(&oldRect); if (!oldRect.Equals(&rect) || miContentHeight != mPositionedChildFormatContext->getAutoIndentTop()) { mPositionedChildFormatContext->release(); mPositionedChildFormatContext = 0; } } WEBC_BOOL reformatPositionedChildren = (mFlowFlags & FD_FLAG_POS_CHILD_STYLE_MODIFIED) != 0; if (!mPositionedChildFormatContext) { mPositionedChildFormatContext = childContextFactory.newPositioned ( &rect, // containingBlock, WEBC_FALSE, // parentHeightIsAuto, TU_DIR_LTR, // textDirection, 0, // parentBorderLeft, 0, // parentBorderTop, 0, // parentBorderRight, 0, // parentBorderBottom, marginLeftValue, // autoIndentLeft, miContentHeight, // autoIndentTop, marginRightValue // autoIndentRight ); reformatPositionedChildren = (mPositionedChildFormatContext != WEBC_NULL); } if (reformatPositionedChildren) { HTMLFlowDisplayFormatContext formatCtx; BeginFormatPositionedChildren(&formatCtx); FormatPositionedChildren ( mPositionedChildFormatContext, mPositionedChildFormatContext, &childContextFactory ); EndFormatPositionedChildren(&formatCtx); } mFlowFlags &= ~(FD_FLAG_POS_CHILD_STYLE_MODIFIED| FD_FLAG_FLOW_CHILD_STYLE_MODIFIED| FD_FLAG_LOCAL_STYLE_MODIFIED| FD_FLAG_PARENT_STYLE_MODIFIED); } WEBC_ASSERT(!NeedsFormat()); // handles the case where HTMLDocument::ScrollToAnchor is called before the // document's content has been formatted. if (mpHtmlElement) { HTMLDocument* document = mpHtmlElement->GetDocument(); if (document) { document->ScrollToDefaultAnchor(); document->SetQueuedFocus(); } } WEBC_DEBUG_LOG_TIME_EXIT(TimeInside,"HTMLBodyDisplay::Format", " ") } }