void SetPointSize( int size ) { if( GetPointSize() != size ) { m_info.SetPointSize(size); Free(); } }
/* * PlaceAndPaste - find out where the image is to be placed and then paste it there */ void PlaceAndPaste( void ) { HBITMAP hbitmap; WPI_POINT pointsize; img_node *node; WPI_POINT pt; unsigned long format; int bm_width; int bm_height; format = 0; node = GetCurrentNode(); if( node == NULL ) { return; } if( !_wpi_isclipboardformatavailable( Instance, CF_BITMAP, &format ) ) { PrintHintTextByID( WIE_NOBITMAPINCLIPBOARD, NULL ); return; } pointsize = GetPointSize( node->hwnd ); if( fEnableCutCopy ) { RedrawPrevClip( node->hwnd ); PasteImage( NULL, pointsize, node->hwnd ); fEnableCutCopy = FALSE; return; } prevToolType = SetToolType( IMGED_PASTE ); pointCursor = _wpi_loadcursor( Instance, POINT_CUR ); prevCursor = _wpi_setcursor( pointCursor ); _wpi_openclipboard( Instance, HMainWindow ); hbitmap = _wpi_getclipboarddata( Instance, CF_BITMAP ); _wpi_getbitmapdim( hbitmap, &bm_width, &bm_height ); _wpi_closeclipboard( Instance ); dragWidth = (short)(bm_width * pointsize.x); dragHeight = (short)(bm_height * pointsize.y); WriteSetSizeText( WIE_CLIPBOARDBITMAPSIZE, bm_width, bm_height); _wpi_getcursorpos( &pt ); _wpi_screentoclient( node->hwnd, &pt ); pt.x = pt.x / pointsize.x; pt.y = pt.y / pointsize.y; _wpi_setcapture( node->hwnd ); firstTime = true; DragClipBitmap( node->hwnd, &pt, pointsize ); } /* PlaceAndPaste */
/* * RedrawPrevClip - redraw the area if a region has been selected and copied to the * clipboard OR if a region has been selected and then another is * selected (without a cut or copy in between) * - the hwnd parameter indicates which window to draw the clip rect on * - if the hwnd does not match the one associated with clipRect, we return */ void RedrawPrevClip( HWND hwnd ) { WPI_POINT pointsize; int prevROP2; HBRUSH blackbrush; HBRUSH oldbrush; HPEN whitepen; HPEN oldpen; WPI_PRES pres; WPI_RECTDIM left; WPI_RECTDIM top; WPI_RECTDIM right; WPI_RECTDIM bottom; img_node *node; if( !fEnableCutCopy || !_wpi_iswindow( Instance, hwnd ) || clipRect.hwnd != hwnd ) { return; } pointsize = GetPointSize( hwnd ); pres = _wpi_getpres( hwnd ); _wpi_torgbmode( pres ); prevROP2 = _wpi_setrop2( pres, R2_XORPEN ); blackbrush = _wpi_createsolidbrush( BLACK ); oldbrush = _wpi_selectobject( pres, blackbrush ); whitepen = _wpi_createpen( PS_SOLID, 0, WHITE ); oldpen = _wpi_selectobject( pres, whitepen ); _wpi_getrectvalues( clipRect.rect, &left, &top, &right, &bottom ); node = SelectImage( hwnd ); #ifdef __OS2_PM__ _wpi_rectangle( pres, left * pointsize.x + 1, bottom * pointsize.y + 1, right * pointsize.x, top * pointsize.y ); #else _wpi_rectangle( pres, left * pointsize.x, top * pointsize.y, right * pointsize.x, bottom * pointsize.y ); #endif _wpi_selectobject( pres, oldpen ); _wpi_selectobject( pres, oldbrush ); _wpi_setrop2( pres, prevROP2 ); _wpi_releasepres( hwnd, pres ); _wpi_deleteobject( whitepen ); _wpi_deleteobject( blackbrush ); } /* RedrawPrevClip */
/// Initializes a wxFont object using the FontSetting data /// @param font wxFont object to initialize void FontSetting::GetFont(wxFont& font) const { //------Last Checked------// // - Dec 6, 2004 font.SetPointSize(GetPointSize()); font.SetFamily(wxDEFAULT); font.SetStyle(((IsItalic()) ? wxITALIC : wxNORMAL)); if (m_weight <= weightLight) font.SetWeight(wxLIGHT); else if (m_weight < weightBold) font.SetWeight(wxNORMAL); else font.SetWeight(wxBOLD); font.SetUnderlined(IsUnderline()); font.SetFaceName(GetFaceName()); }
void ZDForm::SetPoint(const ZDPoint&zdPoint) { RECT rc; GetWindowRect(m_hwnd,&rc); GetPointSize(rc,m_zdPoint,m_zdSize); m_zdPoint.SetPoint(zdPoint); rc.left = m_zdPoint.GetX(); rc.top = m_zdPoint.GetY(); rc.right = rc.left + m_zdSize.GetWidth(); rc.bottom = rc.top + m_zdSize.GetHeight(); MoveWindow(rc); }
bool wxFontBase::operator==(const wxFont& font) const { // either it is the same font, i.e. they share the same common data or they // have different ref datas but still describe the same font return IsSameAs(font) || ( Ok() == font.Ok() && GetPointSize() == font.GetPointSize() && // in wxGTK1 GetPixelSize() calls GetInternalFont() which uses // operator==() resulting in infinite recursion so we can't use it // in that port #if !defined(__WXGTK__) || defined(__WXGTK20__) GetPixelSize() == font.GetPixelSize() && #endif GetFamily() == font.GetFamily() && GetStyle() == font.GetStyle() && GetWeight() == font.GetWeight() && GetUnderlined() == font.GetUnderlined() && GetFaceName().IsSameAs(font.GetFaceName(), false) && GetEncoding() == font.GetEncoding() ); }
/* * DrawAreaWinProc - window procedure for the drawing area window * - this window is an MDI window */ MRESULT CALLBACK DrawAreaWinProc( HWND hwnd, WPI_MSG msg, WPI_PARAM1 wparam, WPI_PARAM2 lparam ) { static WPI_POINT start_pt = { -1, -1 }; static WPI_POINT end_pt = { -1, -1 }; static WPI_POINT prev_pt = { -1, -1 }; static WPI_POINT new_pt = { -1, -1 }; static WPI_POINT pt1; static BOOL flbuttondown = FALSE; static BOOL frbuttondown = FALSE; static BOOL fdraw_shape = FALSE; static BOOL firsttime; static BOOL wasicon; int mousebutton; WPI_POINT pointsize; WPI_POINT pt2; #ifndef __OS2_PM__ CREATESTRUCT *cs; MDICREATESTRUCT *mdi_cs; MINMAXINFO *minmax; #endif img_node *node; int i; switch ( msg ) { case WM_CREATE: #ifndef __OS2_PM__ cs = (CREATESTRUCT __FAR *)lparam; mdi_cs = (MDICREATESTRUCT __FAR *)cs->lpCreateParams; node = (img_node *)mdi_cs->lParam; for( i = 0; i < node->num_of_images; i++ ) { node[i].hwnd = hwnd; } AddImageNode( node ); CreateUndoStack( node ); setTheCursor( -1, hwnd ); wasicon = FALSE; #endif firsttime = TRUE; i = i; return( 0 ); case WM_MDIACTIVATE: if( IMGED_GET_MDI_FACTIVATE( hwnd, wparam, lparam ) ) { if( _wpi_isiconic( hwnd ) ) { wasicon = TRUE; break; } else { wasicon = FALSE; FocusOnImage( hwnd ); } } return( 0 ); #ifndef __OS2_PM__ case WM_GETMINMAXINFO: node = SelectImage( hwnd ); if( node != NULL ) { minmax = (MINMAXINFO *)lparam; minmax->ptMinTrackSize.x = node->width + 2 * _wpi_getsystemmetrics( SM_CXFRAME ); minmax->ptMinTrackSize.y = node->height + 2 * _wpi_getsystemmetrics( SM_CYFRAME ) + _wpi_getsystemmetrics( SM_CYCAPTION ) - 1; } break; #endif case UM_SHOWVIEWWINDOW: ShowViewWindows( hwnd ); return 0; case WM_SIZE: if ( _imgwpi_issizerestored( wparam ) ) { ResizeChild( lparam, hwnd, firsttime ); firsttime = FALSE; if( wasicon ) { FocusOnImage( hwnd ); wasicon = FALSE; } #ifndef __OS2_PM__ } else if ( _imgwpi_issizeminimized( wparam ) ) { node = SelectImage( hwnd ); HideViewWindow( hwnd ); DeleteActiveImage(); ClearImageText(); SendMessage( ClientWindow, WM_MDINEXT, (WPARAM)(LPVOID)hwnd, 0L ); wasicon = TRUE; #endif } return( 0 ); #ifndef __OS2_PM__ case WM_CHAR: pointsize = GetPointSize( hwnd ); if( LOWORD( wparam ) == ESC_CHAR ) { if( !(lparam & 0x40000000) ) { switch( toolType ) { case IMGED_PASTE: fdraw_shape = FALSE; flbuttondown = FALSE; frbuttondown = FALSE; DontPaste( hwnd, &pt1, pointsize ); break; case IMGED_LINE: case IMGED_RECTO: case IMGED_RECTF: case IMGED_CIRCLEO: case IMGED_CIRCLEF: case IMGED_CLIP: if( !flbuttondown && !frbuttondown ) { break; } fdraw_shape = FALSE; flbuttondown = FALSE; frbuttondown = FALSE; if( toolType == IMGED_LINE ) { OutlineLine( hwnd, &start_pt, &prev_pt, &new_pt, TRUE ); } else if( toolType == IMGED_CLIP ) { OutlineClip( hwnd, &start_pt, &prev_pt, &new_pt, TRUE ); SetRectExists( FALSE ); } else { OutlineRegion( hwnd, &start_pt, &prev_pt, &new_pt, TRUE ); } break; default: break; } } } return( 0 ); #endif case WM_MOUSEMOVE: pointsize = GetPointSize( hwnd ); #ifdef __OS2_PM__ WinSetPointer( HWND_DESKTOP, hCursor[cursorIndex] ); #endif IMGED_MAKEPOINT( wparam, lparam, new_pt ); switch( toolType ) { case IMGED_SNAP: #ifndef __OS2_PM__ OutlineSnap(); #endif break; case IMGED_PASTE: pt1.x = new_pt.x / pointsize.x; pt1.y = new_pt.y / pointsize.y; pt2.x = prev_pt.x / pointsize.x; pt2.y = prev_pt.y / pointsize.y; if( pt1.x != pt2.x || pt1.y != pt2.y ) { DragClipBitmap( hwnd, &pt1, pointsize ); } SetPosInStatus( &new_pt, &pointsize, hwnd ); break; case IMGED_FREEHAND: case IMGED_BRUSH: if( flbuttondown ) { Paint( hwnd, &prev_pt, &new_pt, LMOUSEBUTTON ); } else if( frbuttondown ) { Paint( hwnd, &prev_pt, &new_pt, RMOUSEBUTTON ); } SetPosInStatus( &new_pt, &pointsize, hwnd ); break; case IMGED_LINE: case IMGED_RECTO: case IMGED_RECTF: case IMGED_CIRCLEO: case IMGED_CIRCLEF: case IMGED_CLIP: if( flbuttondown || frbuttondown ) { if( new_pt.x / pointsize.x != end_pt.x / pointsize.x || new_pt.y / pointsize.y != end_pt.y / pointsize.y ) { if( toolType == IMGED_LINE ) { OutlineLine( hwnd, &start_pt, &new_pt, &prev_pt, FALSE ); } else if( toolType == IMGED_CLIP ) { OutlineClip( hwnd, &start_pt, &new_pt, &prev_pt, FALSE ); } else { OutlineRegion( hwnd, &start_pt, &new_pt, &prev_pt, FALSE ); } end_pt = new_pt; SetSizeInStatus( hwnd, &start_pt, &new_pt, &pointsize ); } } else { SetPosInStatus( &new_pt, &pointsize, hwnd ); } break; case IMGED_FILL: SetPosInStatus( &new_pt, &pointsize, hwnd ); break; default: SetPosInStatus( &new_pt, &pointsize, hwnd ); break; } prev_pt = new_pt; return( 0 ); case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: pointsize = GetPointSize( hwnd ); SetCapture( hwnd ); if( msg == WM_LBUTTONDOWN ) { if( frbuttondown ) { break; } #ifdef __OS2_PM__ node = GetCurrentNode(); if( hwnd != node->hwnd ) { break; } #endif flbuttondown = TRUE; mousebutton = LMOUSEBUTTON; } else { if( flbuttondown ) { break; } node = GetCurrentNode(); if( hwnd != node->hwnd ) { break; } frbuttondown = TRUE; mousebutton = RMOUSEBUTTON; } fdraw_shape = TRUE; IMGED_MAKEPOINT( wparam, lparam, start_pt ); IMGED_MAKEPOINT( wparam, lparam, new_pt ); switch( toolType ) { case IMGED_SNAP: #ifndef __OS2_PM__ TransferImage( hwnd ); #endif fdraw_shape = FALSE; flbuttondown = FALSE; frbuttondown = FALSE; break; case IMGED_FREEHAND: case IMGED_BRUSH: BeginFreeHand( hwnd ); DrawSinglePoint( hwnd, &start_pt, mousebutton ); break; case IMGED_LINE: IMGED_MAKEPOINT( wparam, lparam, end_pt ); OutlineLine( hwnd, &start_pt, &new_pt, &prev_pt, TRUE ); break; case IMGED_RECTO: case IMGED_RECTF: case IMGED_CIRCLEO: case IMGED_CIRCLEF: IMGED_MAKEPOINT( wparam, lparam, end_pt ); OutlineRegion( hwnd, &start_pt, &new_pt, &prev_pt, TRUE ); break; case IMGED_CLIP: IMGED_MAKEPOINT( wparam, lparam, end_pt ); RedrawPrevClip( hwnd ); OutlineClip( hwnd, &start_pt, &new_pt, &prev_pt, TRUE ); break; case IMGED_FILL: FillArea( &start_pt, mousebutton ); RecordImage( hwnd ); break; case IMGED_HOTSPOT: SetIsSaved( hwnd, FALSE ); prev_pt.x = start_pt.x / pointsize.x; prev_pt.y = start_pt.y / pointsize.y; SetNewHotSpot( &prev_pt ); break; default: break; } prev_pt = new_pt; return 0; case WM_LBUTTONUP: case WM_RBUTTONUP: pointsize = GetPointSize( hwnd ); IMGED_MAKEPOINT( wparam, lparam, end_pt ); IMGED_MAKEPOINT( wparam, lparam, new_pt ); if( msg == WM_LBUTTONUP ) { mousebutton = LMOUSEBUTTON; } else { mousebutton = RMOUSEBUTTON; } if( fdraw_shape ) { switch( toolType ) { case IMGED_PASTE: PasteImage( &start_pt, pointsize, hwnd ); flbuttondown = FALSE; frbuttondown = FALSE; break; case IMGED_FREEHAND: case IMGED_BRUSH: if( flbuttondown || frbuttondown ) { EndFreeHand( hwnd ); RecordImage( hwnd ); } break; case IMGED_LINE: DrawLine( hwnd, &start_pt, &end_pt, mousebutton ); RecordImage( hwnd ); break; case IMGED_RECTO: case IMGED_RECTF: case IMGED_CIRCLEO: case IMGED_CIRCLEF: DisplayRegion( hwnd, &start_pt, &end_pt, mousebutton ); RecordImage( hwnd ); break; case IMGED_CLIP: SetClipRect( hwnd, &start_pt, &end_pt, pointsize ); break; default: break; } fdraw_shape = FALSE; } ReleaseCapture(); flbuttondown = FALSE; frbuttondown = FALSE; prev_pt = new_pt; return( 0 ); case WM_PAINT: RepaintDrawArea( hwnd ); return( 0 ); case WM_QUERYENDSESSION: case WM_CLOSE: if( lastChanceSave( hwnd ) ) { CloseCurrentImage( hwnd ); return( (MRESULT)1 ); } else { return( (MRESULT)0 ); } #ifndef __OS2_PM__ case WM_DESTROY: SetCursor( LoadCursor( NULL, IDC_ARROW ) ); return( 0 ); #endif default: break; } return( _imgwpi_defMDIchildproc( hwnd, msg, wparam, lparam ) ); } /* DrawAreaWinProc */
wxString wxNativeFontInfo::ToUserString() const { wxString desc; // first put the adjectives, if any - this is English-centric, of course, // but what else can we do? if ( GetUnderlined() ) { desc << _("underlined"); } switch ( GetWeight() ) { default: wxFAIL_MSG( _T("unknown font weight") ); // fall through case wxFONTWEIGHT_NORMAL: break; case wxFONTWEIGHT_LIGHT: desc << _(" light"); break; case wxFONTWEIGHT_BOLD: desc << _(" bold"); break; } switch ( GetStyle() ) { default: wxFAIL_MSG( _T("unknown font style") ); // fall through case wxFONTSTYLE_NORMAL: break; // we don't distinguish between the two for now anyhow... case wxFONTSTYLE_ITALIC: case wxFONTSTYLE_SLANT: desc << _(" italic"); break; } wxString face = GetFaceName(); if ( !face.empty() ) { desc << _T(' ') << face; } int size = GetPointSize(); if ( size != wxNORMAL_FONT->GetPointSize() ) { desc << _T(' ') << size; } #if wxUSE_FONTMAP wxFontEncoding enc = GetEncoding(); if ( enc != wxFONTENCODING_DEFAULT && enc != wxFONTENCODING_SYSTEM ) { desc << _T(' ') << wxFontMapper::GetEncodingName(enc); } #endif // wxUSE_FONTMAP return desc.Strip(wxString::both).MakeLower(); }
wxString wxNativeFontInfo::ToUserString() const { wxString desc; // first put the adjectives, if any - this is English-centric, of course, // but what else can we do? if ( GetUnderlined() ) { desc << _("underlined"); } switch ( GetWeight() ) { default: wxFAIL_MSG( wxT("unknown font weight") ); // fall through case wxFONTWEIGHT_NORMAL: break; case wxFONTWEIGHT_LIGHT: desc << _(" light"); break; case wxFONTWEIGHT_BOLD: desc << _(" bold"); break; } switch ( GetStyle() ) { default: wxFAIL_MSG( wxT("unknown font style") ); // fall through case wxFONTSTYLE_NORMAL: break; // we don't distinguish between the two for now anyhow... case wxFONTSTYLE_ITALIC: case wxFONTSTYLE_SLANT: desc << _(" italic"); break; } wxString face = GetFaceName(); if ( !face.empty() ) { if (face.Contains(' ') || face.Contains(';') || face.Contains(',')) { face.Replace("'", ""); // eventually remove quote characters: most systems do not // allow them in a facename anyway so this usually does nothing // make it possible for FromUserString() function to understand // that the different words which compose this facename are // not different adjectives or other data but rather all parts // of the facename desc << wxT(" '") << face << _("'"); } else desc << wxT(' ') << face; } else // no face name specified { // use the family wxString familyStr; switch ( GetFamily() ) { case wxFONTFAMILY_DECORATIVE: familyStr = "decorative"; break; case wxFONTFAMILY_ROMAN: familyStr = "roman"; break; case wxFONTFAMILY_SCRIPT: familyStr = "script"; break; case wxFONTFAMILY_SWISS: familyStr = "swiss"; break; case wxFONTFAMILY_MODERN: familyStr = "modern"; break; case wxFONTFAMILY_TELETYPE: familyStr = "teletype"; break; case wxFONTFAMILY_DEFAULT: case wxFONTFAMILY_UNKNOWN: break; default: wxFAIL_MSG( "unknown font family" ); } if ( !familyStr.empty() ) desc << " '" << familyStr << " family'"; } int size = GetPointSize(); if ( size != wxNORMAL_FONT->GetPointSize() ) { desc << wxT(' ') << size; } #if wxUSE_FONTMAP wxFontEncoding enc = GetEncoding(); if ( enc != wxFONTENCODING_DEFAULT && enc != wxFONTENCODING_SYSTEM ) { desc << wxT(' ') << wxFontMapper::GetEncodingName(enc); } #endif // wxUSE_FONTMAP return desc.Strip(wxString::both).MakeLower(); }
wxFont& wxFont::Scale(float x) { SetPointSize(int(x*GetPointSize() + 0.5)); return *this; }
void wxFontBase::SetPixelSize( const wxSize& pixelSize ) { wxCHECK_RET( pixelSize.GetWidth() >= 0 && pixelSize.GetHeight() > 0, "Negative values for the pixel size or zero pixel height are not allowed" ); wxScreenDC dc; // NOTE: this algorithm for adjusting the font size is used by all // implementations of wxFont except under wxMSW and wxGTK where // native support to font creation using pixel-size is provided. int largestGood = 0; int smallestBad = 0; bool initialGoodFound = false; bool initialBadFound = false; // NB: this assignment was separated from the variable definition // in order to fix a gcc v3.3.3 compiler crash int currentSize = GetPointSize(); while (currentSize > 0) { dc.SetFont(*static_cast<wxFont*>(this)); // if currentSize (in points) results in a font that is smaller // than required by pixelSize it is considered a good size // NOTE: the pixel size width may be zero if (dc.GetCharHeight() <= pixelSize.GetHeight() && (pixelSize.GetWidth() == 0 || dc.GetCharWidth() <= pixelSize.GetWidth())) { largestGood = currentSize; initialGoodFound = true; } else { smallestBad = currentSize; initialBadFound = true; } if (!initialGoodFound) { currentSize /= 2; } else if (!initialBadFound) { currentSize *= 2; } else { int distance = smallestBad - largestGood; if (distance == 1) break; currentSize = largestGood + distance / 2; } SetPointSize(currentSize); } if (currentSize != largestGood) SetPointSize(largestGood); }