void FitParmsTable::Append ( const JCharacter* col1, const JCharacter* col2 ) { const JFontManager* fm = GetFontManager(); JSize lineHeight = fm->GetDefaultFont().GetLineHeight(); AppendRows(1, lineHeight + 2); JString* str = jnew JString(col1); itsCol1->Append(str); JSize col1Width = GetColWidth(1); JSize strWidth = fm->GetDefaultFont().GetStringWidth(*str); if (strWidth + 10 > col1Width) { SetColWidth(1, strWidth + 10); } str = jnew JString(col2); itsCol2->Append(str); JSize col2Width = GetColWidth(2); strWidth = fm->GetDefaultFont().GetStringWidth(*str); if (strWidth + 10 > col2Width) { SetColWidth(2, strWidth + 10); } TableRefresh(); }
void CustomGrid::DrawColLabel( wxDC& dc, int col ) { //init dc font and colours dc.SetFont(m_labelFont); if(col == m_gParent->m_pIndex){ dc.SetBrush(wxBrush(m_greenColour, wxBRUSHSTYLE_SOLID)); dc.SetPen(wxPen(m_greenColour, 1)); }else { dc.SetBrush(wxBrush(m_labelBackgroundColour, wxBRUSHSTYLE_SOLID)); dc.SetPen(wxPen(m_labelBackgroundColour, 1)); } //draw retangle wxRect tRect( GetColLeft(col), 1, GetColWidth(col)-2, m_colLabelHeight -2); dc.DrawRectangle(tRect); //draw lines aroud label dc.SetPen(GetDefaultGridLinePen()); dc.DrawLine( GetColLeft(col) -1, 0, GetColRight(col), 0 ); if( col > -1 && (col == 0 || GetColLabelValue( col ).BeforeFirst('-') != GetColLabelValue( col - 1 ).BeforeFirst('-')) ) dc.SetPen(wxPen(*wxBLACK, 4)); dc.DrawLine( GetColLeft(col) -1, 0, GetColLeft(col) - 1, m_colLabelHeight); if( col == m_numCols - 1 ){ dc.SetPen(wxPen(*wxBLACK, 4)); dc.DrawLine( GetColRight(col), 0, GetColRight(col), m_colLabelHeight); } //then draw label dc.DrawLabel(GetColLabelValue(col), tRect, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL); }
static int UpdateOnlyName(openfile* p) { int i; if (p->OnlyName != p->OnlyNameState) { WinMenuCheck(&p->Win,1,OPENFILE_ONLYNAME,p->OnlyName); p->OnlyNameState = p->OnlyName; if (p->OnlyName) { for (i=0;i<4;++i) p->DlgWidth[i] = GetColWidth(p,i); ShowWindow(p->WndList,SW_HIDE); SetColWidth(p,3,0); SetColWidth(p,2,0); SetColWidth(p,1,0); SetColWidth(p,0,300); ShowWindow(p->WndList,SW_SHOWNA); } else { ShowWindow(p->WndList,SW_HIDE); for (i=3;i>=0;--i) SetColWidth(p,i,max(15,p->DlgWidth[i])); ShowWindow(p->WndList,SW_SHOWNA); } } return ERR_NONE; }
void JXTreeListWidget::AdjustColWidths() { if (itsAdjustToTreeTask != NULL) { return; } const JSize colCount = GetColCount(); if (itsMinColWidths->GetElementCount() != colCount) { NeedsAdjustToTree(); return; } for (JIndex i=1; i<=colCount; i++) { SetColWidth(i, itsMinColWidths->GetElement(i)); } if (ColIndexValid(itsElasticColIndex)) { const JCoordinate minReqWidth = itsMinColWidths->GetElement(itsElasticColIndex); if (minReqWidth > 0) { const JCoordinate availWidth = GetApertureWidth() - (GetBoundsWidth() - GetColWidth(itsElasticColIndex)); SetColWidth(itsElasticColIndex, JMax(minReqWidth, availWidth)); } } }
void JXRowHeaderWidget::TablePrepareToDrawCol ( const JIndex colIndex, const JIndex firstRow, const JIndex lastRow ) { itsMaxBcastWidth = GetColWidth(colIndex); }
/* not virtual in wxGrid, so code copied and modified her for painting sorting icons */ void CBOINCGridCtrl::DrawColLabel( wxDC& dc, int col ) { if ( GetColWidth(col) <= 0 || m_colLabelHeight <= 0 ) return; int colLeft = GetColLeft(col); wxRect rect; int colRight = GetColRight(col) - 1; dc.SetPen( wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW),1, wxSOLID) ); dc.DrawLine( colRight, 0, colRight, m_colLabelHeight-1 ); dc.DrawLine( colLeft, 0, colRight, 0 ); dc.DrawLine( colLeft, m_colLabelHeight-1, colRight+1, m_colLabelHeight-1 ); dc.SetPen( *wxWHITE_PEN ); dc.DrawLine( colLeft, 1, colLeft, m_colLabelHeight-1 ); dc.DrawLine( colLeft, 1, colRight, 1 ); dc.SetBackgroundMode( wxTRANSPARENT ); dc.SetTextForeground( GetLabelTextColour() ); dc.SetFont( GetLabelFont() ); int hAlign, vAlign, orient; GetColLabelAlignment( &hAlign, &vAlign ); orient = GetColLabelTextOrientation(); rect.SetX( colLeft + 2 ); rect.SetY( 2 ); rect.SetWidth( GetColWidth(col) - 4 ); rect.SetHeight( m_colLabelHeight - 4 ); DrawTextRectangle( dc, GetColLabelValue( col ), rect, hAlign, vAlign, orient ); //paint sorting indicators, if needed if(col == sortColumn) { int x = rect.GetRight() - ascBitmap.GetWidth() - 2; int y = rect.GetY(); dc.DrawBitmap(this->sortAscending ? descBitmap : ascBitmap,x,y,true); } }
void GLFitParameterTable::AdjustColWidth ( const JSize availabeWidth ) { JCoordinate lineWidth; JColorIndex color; GetColBorderInfo(&lineWidth, &color); JSize usedWidth = 2 * GetColWidth(kFitColIndex) + 2 * lineWidth; if (itsHasStartValues) { usedWidth += GetColWidth(kStartColIndex) + lineWidth; } if (availabeWidth > usedWidth) { SetColWidth(kNameColIndex, availabeWidth - usedWidth); } }
void JXFSBindingTable::UpdateColWidths() { JCoordinate borderWidth; JColorIndex color; GetColBorderInfo(&borderWidth, &color); JCoordinate w = GetApertureWidth(); for (JIndex i=1; i<=kColCount; i++) { if (i != kCommandColumn) { w -= GetColWidth(i) + borderWidth; } } w = JMax(w, kInitColWidth[ kCommandColumn-1 ]); SetColWidth(kCommandColumn, w); }
void GMFilterMBoxTable::AdjustColWidths() { const JSize apWidth = GetApertureWidth(); JCoordinate lineWidth; JColorIndex color; GetColBorderInfo(&lineWidth, &color); const JSize usedWidth = GetColWidth(kCopyColumn) + lineWidth; if (apWidth > usedWidth) { SetColWidth(kMBoxColumn, apWidth - usedWidth); } else { // I'll really need to adjust this relative to the size of the patterns. } }
void THXVarTable::AdjustColWidths() { const JSize apWidth = GetApertureWidth(); JCoordinate lineWidth; JColorIndex color; GetColBorderInfo(&lineWidth, &color); const JSize usedWidth = GetColWidth(kNameColumn) + lineWidth; if (apWidth > usedWidth) { SetColWidth(kFnColumn, apWidth - usedWidth); } else { const JSize nameWidth = apWidth/3; SetColWidth(kNameColumn, nameWidth); SetColWidth(kFnColumn, apWidth - nameWidth - lineWidth); } }
void PIInspectorTable::ResizeFrameBy( SInt16 inWidthDelta, SInt16 inHeightDelta, Boolean inRefresh) { // Validate pointers. ValidateThis_(); // Resize the view. LView::ResizeFrameBy(inWidthDelta, inHeightDelta, inRefresh); // Stretch the value column to fill space. if (inWidthDelta != 0) SetColWidth(GetColWidth(2) + inWidthDelta, 2, 2); }
void CLDisplayClassTable::ResizeFrameBy( SInt16 inWidthDelta, SInt16 inHeightDelta, Boolean inRefresh) { // Validate pointers. ValidateThis_(); // Resize the view. LView::ResizeFrameBy(inWidthDelta, inHeightDelta, inRefresh); // Stretch the class name column to fill space. if (inWidthDelta != 0) SetColWidth(GetColWidth(1) + inWidthDelta, 1, 1); }
void GMAccountList::TableDrawCell ( JPainter& p, const JPoint& cell, const JRect& rect ) { HilightIfSelected(p, cell, rect); JFontStyle fontstyle; if (itsDialog->GetDefaultIndex() == (JIndex)cell.y) { fontstyle.bold = kJTrue; } p.SetFont(JGetDefaultFontName(), kJDefaultFontSize, fontstyle); JString str = itsAccountInfo->NthElement(cell.y)->GetNickname(); // check that column is wide enough const JCoordinate w = p.GetStringWidth(str) + 2*kHMarginWidth; if (w > GetColWidth(1)) { itsMinColWidth = w; } // draw string JRect r = rect; r.left += kHMarginWidth; p.String(r, str, JPainter::kHAlignLeft, JPainter::kVAlignCenter); if (cell.y == JCoordinate(itsAccountInfo->GetElementCount())) { AdjustColWidth(); } }
///////////////////////////////////////////////////////////////////////////// // GetGridWidth // This function is used to determine the total width the grid // requires to show all of its columns. int MyCug::GetGridWidth() { int totalWidth = 0; // get the width of the side heading totalWidth = GetSH_Width(); // get widths of individual columns for ( int xIndex = 0; xIndex < GetNumberCols(); xIndex ++ ) { totalWidth += GetColWidth( xIndex ); } // make sure that the vertical scroll bar is visible CRect rect; m_CUGVScroll->GetClientRect( rect ); if ( rect.Width() > 0 ) { // if it is visible then get its width. totalWidth += GetVS_Width(); } // add one extra pixels to prevent showing of the horizontal scroll bar return totalWidth + 3; }
/*************************************************** OnSetup This function is called just after the grid window is created or attached to a dialog item. It can be used to initially setup the grid ****************************************************/ void CRealTimeGrid::OnSetup(){ int y; int ROWS = 25; int COLS = 6; int iHeight; CUGCell cell; CString strTemp; CDC* pDC; m_pro1Index = AddCellType( &m_pro1 ); m_pro1.SetCanAdjust( FALSE ); m_buttonIndex = AddCellType( &m_button ); pDC = GetDC(); iHeight = -MulDiv( 10, GetDeviceCaps( pDC->m_hDC, LOGPIXELSY), 72 ); m_font1.CreateFont( iHeight,0,0,0,800,0,0,0,0,0,0,0,0, _T( "Arial" ) ); m_font2.CreateFont( iHeight,0,0,0,500,0,0,0,0,0,0,0,0, _T( "Arial" ) ); ReleaseDC( pDC ); SetDefFont(&m_font2); SetUniformRowHeight(TRUE); SetDefRowHeight(25); SetNumberCols(COLS); SetNumberRows(ROWS); SetDoubleBufferMode(1); Set3DHeight( 2 ); SetTH_Height( 0 ); SetSH_Width( 100 ); for( y = 0 ; y < ROWS ; y++ ) { QuickSetCellType(0,y,m_pro1Index); QuickSetAlignment(0,y,UG_ALIGNCENTER|UG_ALIGNVCENTER); QuickSetText( 0, y, _T( "20" ) ); QuickSetTextColor(0,y,RGB(0,0,0)); QuickSetHTextColor(0,y,RGB(0,0,0)); JoinCells(0,y,2,y); QuickSetAlignment(3,y,UG_ALIGNCENTER|UG_ALIGNVCENTER); QuickSetText(3,y,_T( "Normal" ) ); //QuickSetFont(3,y,&m_font2); strTemp.Format( _T( "Sensor %d" ), y ); QuickSetText( -1, y, strTemp ); } GetColDefault( 4, &cell ); cell.SetCellType( m_buttonIndex ); cell.SetText( _T( "Reset" ) ); cell.SetAlignment( UG_ALIGNCENTER | UG_ALIGNVCENTER ); cell.SetBackColor( GetSysColor( COLOR_BTNFACE ) ); SetColDefault( 4, &cell ); GetColDefault( 5, &cell ); cell.SetCellType( UGCT_CHECKBOX ); cell.SetLabelText( _T( "Enabled" ) ); cell.SetBool( TRUE ); cell.SetAlignment( UG_ALIGNVCENTER ); SetColDefault( 5, &cell ); SetColWidth( 5, GetColWidth( 5 ) + 20 ); SetTimer( TIMERID, 100, NULL); }
unsigned long UserWinProcedure(HWND Window,HMSG Message,long Param1,long Param2) { int hlist,i,j; float Midf; switch (Message) { case DIALOGBOXOK: GetPrintPara(); if (PG.Blocks>0) PG.Enable=1; else PG.Enable=0; return(DialogDefaultProcedure(Window, Message, Param1, Param2)); case DIALOGBOXCANCEL: PG.Enable=0; return(DialogDefaultProcedure(Window, Message, Param1, Param2)); case REDRAWMESSAGE: i=DialogDefaultProcedure(Window, Message, Param1, Param2); WaitMessageEmpty(); InitOver=1; InitPrintCut(); CurrentBlock=0; SetPrintPara(); REFLASH; MessageInsert(PrintCutWin[wPAGEADDWIN],WINDOWINIT,0l,0l); ListSetCurrent(WindowList(PrintCutWin[wPAGEADDWIN]),CurrentBlock); REFLASHADD; return i; break; case WINDOWINIT: InitOver=0; i=DialogDefaultProcedure(Window, Message, Param1, Param2); //WaitMessageEmpty(); return i; break; case ADDWIN: GetPrintPara(); if (PG.Blocks<99) PG.Blocks++; CurrentBlock=PG.Blocks-1; if (CurrentBlock>0) CopyBlock(CurrentBlock,CurrentBlock-1); else InitBlock(CurrentBlock); SetPrintPara(); hlist = WindowList(PrintCutWin[wPAGEADDWIN]); MessageGo(PrintCutWin[wPAGEADDWIN],WINDOWINIT,0,0); MessageGo(PrintCutWin[wPAGEADDWIN],WMPAINT,0,ListGetHeight(hlist)*CHARHEIGHT); if (CurrentBlock>=7) ListSetTop(hlist,CurrentBlock-7); else ListSetTop(hlist,0); ListSetCurrent(hlist,CurrentBlock); MessageGo(PrintCutWin[wPAGEADDWIN],REDRAWMESSAGE,0L, MAKELONG(WindowGetWidth(PrintCutWin[wPAGEADDWIN]), WindowGetHeight(PrintCutWin[wPAGEADDWIN])) ); //MessageGo(PrintCutWin[wPAGEADDWIN],KEYDOWN,UP,0l); //MessageGo(PrintCutWin[wPAGEADDWIN],KEYDOWN,DOWN,0l); //ListSetTop(hlist,0); REFLASH; break; case DELETEWIN: GetPrintPara(); for (i=CurrentBlock+1;i<PG.Blocks;i++) CopyBlock1(i-1,i); if (PG.Blocks>0) PG.Blocks--; if (CurrentBlock>=PG.Blocks&&CurrentBlock) CurrentBlock=PG.Blocks-1; SetPrintPara(); hlist = WindowList(PrintCutWin[wPAGEADDWIN]); MessageGo(PrintCutWin[wPAGEADDWIN],WINDOWINIT,0,0); MessageGo(PrintCutWin[wPAGEADDWIN],WMPAINT,0,ListGetHeight(hlist)*CHARHEIGHT); if (CurrentBlock>=7) ListSetTop(hlist,CurrentBlock-7); else ListSetTop(hlist,0); ListSetCurrent(hlist,CurrentBlock); MessageGo(PrintCutWin[wPAGEADDWIN],REDRAWMESSAGE,0L, MAKELONG(WindowGetWidth(PrintCutWin[wPAGEADDWIN]), WindowGetHeight(PrintCutWin[wPAGEADDWIN])) ); REFLASH; break; case DELETETAILWIN: GetPrintPara(); PG.Blocks=CurrentBlock; if (CurrentBlock>=PG.Blocks&&CurrentBlock) CurrentBlock=PG.Blocks-1; SetPrintPara(); hlist = WindowList(PrintCutWin[wPAGEADDWIN]); MessageGo(PrintCutWin[wPAGEADDWIN],WINDOWINIT,0,0); MessageGo(PrintCutWin[wPAGEADDWIN],WMPAINT,0,ListGetHeight(hlist)*CHARHEIGHT); if (CurrentBlock>=7) ListSetTop(hlist,CurrentBlock-7); else ListSetTop(hlist,0); ListSetCurrent(hlist,CurrentBlock); MessageGo(PrintCutWin[wPAGEADDWIN],REDRAWMESSAGE,0L, MAKELONG(WindowGetWidth(PrintCutWin[wPAGEADDWIN]), WindowGetHeight(PrintCutWin[wPAGEADDWIN])) ); REFLASH; break; case COPYWIN: i=GetPrintPara(); if (i<0) switch(i) { case -99: { if (MessageBox("设置打印纸"," 确认您的打印机可使用\n" " 您所定义的纸张大小, \n" " 否则,打印可能出错!" ,2,1)) break; } PaperW=Tmp1; PaperH=Tmp2; if (PaperW<20.0) PaperW=20.0; if (PaperW>1100.0) PaperW=1100.0; if (PaperH<20.0) PaperH=20.0; if (PaperH>1100.0) PaperH=1100.0; printer->xpixel=PaperW*PrinterDPI/25.4; printer->ypixel=PaperH*PrinterDPI/25.4; InitPrintCut(); break; case -5: //Tmp1 = Scale Tmp2=PageH*Tmp4; Tmp1=PageW*Tmp3; if (PG.Blocks) { j=(PG.PageBlock[0].Rotate&1); } else j=0; if (j) { Midf=Tmp2; Tmp2=Tmp1; Tmp1=Midf; } case -1: if (Tmp1>5.0f) { Midf=0.0f; ColLeadNum=0; while (Midf+Tmp1<PaperW) { Midf +=Tmp1; ColLead[ColLeadNum++]=Midf; } } if (Tmp2>5.0f) { Midf=0.0f; RowLeadNum=0; while (Midf+Tmp1<PaperH) { Midf +=Tmp2; RowLead[RowLeadNum++]=Midf; } } break; case -2: ColLeadNum=0; RowLeadNum=0; break; case -3: ColLeadNum=0; break; case -4: RowLeadNum=0; break; case -6: //Auto Scale Fit if (!PG.Blocks) break; PG.Blocks=0; CurrentBlock=0; hlist=PG.PageBlock[0].Rotate; for (i=0;i<RowLeadNum;i++) { for (j=0;j<ColLeadNum;j++) { if (GetColWidth(j)-5.0f>Tmp1+Tmp3&& GetRowHeight(i)-5.0f>Tmp2+Tmp4) { if (hlist&1) { PG.PageBlock[PG.Blocks].Yscale=(GetColWidth(j)-Tmp1-Tmp3)/PageH; PG.PageBlock[PG.Blocks].Xscale=(GetRowHeight(i)-Tmp2-Tmp4)/PageW; } else { PG.PageBlock[PG.Blocks].Xscale=(GetColWidth(j)-Tmp1-Tmp3)/PageW; PG.PageBlock[PG.Blocks].Yscale=(GetRowHeight(i)-Tmp2-Tmp4)/PageH; } PG.PageBlock[PG.Blocks].Xoffset=GetColOffset(j)+Tmp1; PG.PageBlock[PG.Blocks].Yoffset=GetRowOffset(i)+Tmp3; PG.PageBlock[PG.Blocks].PageOffset=0; PG.PageBlock[PG.Blocks++].Rotate=hlist; } if (PG.Blocks>=99) break; } if (PG.Blocks>=99) break; } break; case -7: //Auto Scale Fit if (!PG.Blocks) break; PG.Blocks=0; CurrentBlock=0; hlist=PG.PageBlock[0].Rotate; for (i=0;i<=RowLeadNum;i++) { for (j=0;j<=ColLeadNum;j++) { if (GetColWidth(j)-5.0f>Tmp1+Tmp3&& GetRowHeight(i)-5.0f>Tmp2+Tmp4) { if (hlist&1) { PG.PageBlock[PG.Blocks].Yscale=(GetColWidth(j)-Tmp1-Tmp3)/PageH; PG.PageBlock[PG.Blocks].Xscale=(GetRowHeight(i)-Tmp2-Tmp4)/PageW; } else { PG.PageBlock[PG.Blocks].Xscale=(GetColWidth(j)-Tmp1-Tmp3)/PageW; PG.PageBlock[PG.Blocks].Yscale=(GetRowHeight(i)-Tmp2-Tmp4)/PageH; } PG.PageBlock[PG.Blocks].Xoffset=GetColOffset(j)+Tmp1; PG.PageBlock[PG.Blocks].Yoffset=GetRowOffset(i)+Tmp3; PG.PageBlock[PG.Blocks].PageOffset=0; PG.PageBlock[PG.Blocks++].Rotate=hlist; } if (PG.Blocks>=99) break; } if (PG.Blocks>=99) break; } break; case -8: if (!PG.Blocks) break; PG.Blocks=0; CurrentBlock=0; for (i=0;i<RowLeadNum;i++) { for (j=0;j<ColLeadNum;j++) { if (GetColWidth(j)-5.0f>Tmp1&& GetRowHeight(i)-5.0f>Tmp2) { PG.PageBlock[PG.Blocks].Xoffset=GetColOffset(j)+Tmp1; PG.PageBlock[PG.Blocks].Yoffset=GetRowOffset(i)+Tmp2; PG.PageBlock[PG.Blocks].Xscale=PG.PageBlock[0].Xscale; PG.PageBlock[PG.Blocks].Yscale=PG.PageBlock[0].Yscale; PG.PageBlock[PG.Blocks].PageOffset=0; PG.PageBlock[PG.Blocks++].Rotate=PG.PageBlock[0].Rotate; } if (PG.Blocks>=99) break; } if (PG.Blocks>=99) break; } break; case -9: if (!PG.Blocks) break; PG.Blocks=0; CurrentBlock=0; for (i=0;i<=RowLeadNum;i++) { for (j=0;j<=ColLeadNum;j++) { if (GetColWidth(j)-5.0f>Tmp1&& GetRowHeight(i)-5.0f>Tmp2) { PG.PageBlock[PG.Blocks].Xoffset=GetColOffset(j)+Tmp1; PG.PageBlock[PG.Blocks].Yoffset=GetRowOffset(i)+Tmp2; PG.PageBlock[PG.Blocks].Xscale=PG.PageBlock[0].Xscale; PG.PageBlock[PG.Blocks].Yscale=PG.PageBlock[0].Yscale; PG.PageBlock[PG.Blocks].PageOffset=0; PG.PageBlock[PG.Blocks++].Rotate=PG.PageBlock[0].Rotate; } if (PG.Blocks>=99) break; } if (PG.Blocks>=99) break; } break; } REFLASH; REFLASHADD; break; default: return(DialogDefaultProcedure(Window, Message, Param1, Param2)); } /* return(DialogDefaultProcedure(Window, Message, Param1, Param2)); */ return(TRUE); }