uint64 EbmlSInteger::UpdateSize(bool bWithDefault, bool bForceRender) { if (!bWithDefault && IsDefaultValue()) return 0; if (Value <= 0x7F && Value >= (-0x80)) { SetSize_(1); } else if (Value <= 0x7FFF && Value >= (-0x8000)) { SetSize_(2); } else if (Value <= 0x7FFFFF && Value >= (-0x800000)) { SetSize_(3); } else if (Value <= 0x7FFFFFFF && Value >= (-0x80000000)) { SetSize_(4); } else if (Value <= EBML_PRETTYLONGINT(0x7FFFFFFFFF) && Value >= EBML_PRETTYLONGINT(-0x8000000000)) { SetSize_(5); } else if (Value <= EBML_PRETTYLONGINT(0x7FFFFFFFFFFF) && Value >= EBML_PRETTYLONGINT(-0x800000000000)) { SetSize_(6); } else if (Value <= EBML_PRETTYLONGINT(0x7FFFFFFFFFFFFF) && Value >= EBML_PRETTYLONGINT(-0x80000000000000)) { SetSize_(7); } else { SetSize_(8); } if (GetDefaultSize() > GetSize()) { SetSize_(GetDefaultSize()); } return GetSize(); }
uint64 EbmlUInteger::UpdateSize(bool bWithDefault, bool /* bForceRender */) { if (!bWithDefault && IsDefaultValue()) return 0; if (Value <= 0xFF) { SetSize_(1); } else if (Value <= 0xFFFF) { SetSize_(2); } else if (Value <= 0xFFFFFF) { SetSize_(3); } else if (Value <= 0xFFFFFFFF) { SetSize_(4); } else if (Value <= EBML_PRETTYLONGINT(0xFFFFFFFFFF)) { SetSize_(5); } else if (Value <= EBML_PRETTYLONGINT(0xFFFFFFFFFFFF)) { SetSize_(6); } else if (Value <= EBML_PRETTYLONGINT(0xFFFFFFFFFFFFFF)) { SetSize_(7); } else { SetSize_(8); } if (GetDefaultSize() > GetSize()) { SetSize_(GetDefaultSize()); } return GetSize(); }
uint64 EbmlString::UpdateSize(bool bWithDefault, bool bForceRender) { if (!bWithDefault && IsDefaultValue()) return 0; if (Value.length() < GetDefaultSize()) { SetSize_(GetDefaultSize()); } else { SetSize_(Value.length()); } return GetSize(); }
wxSize wxButton::DoGetBestSize() const { // the default button in wxGTK is bigger than the other ones because of an // extra border around it, but we don't want to take it into account in // our size calculations (otherwsie the result is visually ugly), so // always return the size of non default button from here const bool isDefault = GTK_WIDGET_HAS_DEFAULT(m_widget); if ( isDefault ) { // temporarily unset default flag GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_DEFAULT ); } wxSize ret( wxControl::DoGetBestSize() ); if ( isDefault ) { // set it back again GTK_WIDGET_SET_FLAGS( m_widget, GTK_CAN_DEFAULT ); } ret.x += 10; // add a few pixels for sloppy (but common) themes if (!HasFlag(wxBU_EXACTFIT)) { wxSize defaultSize = GetDefaultSize(); if (ret.x < defaultSize.x) ret.x = defaultSize.x; if (ret.y < defaultSize.y) ret.y = defaultSize.y; } CacheBestSize(ret); return ret; }
wxSize wxButton::DoGetBestSize() const { // the default button in wxGTK is bigger than the other ones because of an // extra border around it, but we don't want to take it into account in // our size calculations (otherwise the result is visually ugly), so // always return the size of non default button from here const bool isDefault = gtk_widget_has_default(m_widget) != 0; if ( isDefault ) { // temporarily unset default flag gtk_widget_set_can_default(m_widget, FALSE); } wxSize ret( wxAnyButton::DoGetBestSize() ); if ( isDefault ) { // set it back again gtk_widget_set_can_default(m_widget, TRUE); } if (!HasFlag(wxBU_EXACTFIT)) { wxSize defaultSize = GetDefaultSize(); if (ret.x < defaultSize.x) ret.x = defaultSize.x; if (ret.y < defaultSize.y) ret.y = defaultSize.y; } CacheBestSize(ret); return ret; }
RtMainFrame::RtMainFrame(const TGWindow* p) : TGMainFrame(p, 800, 600) { // Create canvas TRootEmbeddedCanvas* eCanvas = new TRootEmbeddedCanvas("Embedded canvas",this,800,600); m_canvas = eCanvas->GetCanvas(); AddFrame(eCanvas, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10, 10, 10, 1)); // ======================================== // Tooltip m_canvas->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", "RtMainFrame", this, "eventHandler(Int_t,Int_t,Int_t,TObject*)"); m_tip = new TGToolTip( gClient->GetDefaultRoot(), eCanvas, "", 0 ); // ======================================== // Buttons TGHorizontalFrame *hframe= new TGHorizontalFrame(this, 200,40); // Exit button hframe->AddFrame( new TGTextButton(hframe, "&Quit", "gApplication->Terminate()") , new TGLayoutHints(kLHintsCenterX,5,5,3,4)); // Save button TGTextButton* buttonPDF = new TGTextButton(hframe, "Save &PDF"); TQObject::Connect(buttonPDF, "Clicked()", "RtMainFrame", this, "savePDF()" ); hframe->AddFrame( buttonPDF , new TGLayoutHints(kLHintsCenterX,5,5,3,4)); AddFrame(hframe,new TGLayoutHints(kLHintsCenterX,2,2,2,2)); // Sets window name and shows the main frame SetWindowName("RT-Biplot"); MapSubwindows(); Resize(GetDefaultSize()); MapWindow(); }
void TextRender::SetExpanse(const Vec2& _expanse, bool _onlyScaleDown) { int len = (int)m_text.length(); int lineCount = 1; int charCount = 0; int charCountMax = 0; for (int i = 0; i < len; i++) { charCount++; if (m_text[i] == '\n') { if (charCountMax < charCount) charCountMax = charCount; charCount = 0; lineCount++; } } //if the text contains no linebreaks if (!charCountMax) charCountMax = charCount; Vec2 captionDim = GetDim(); // in case that the text is to large in any direction scale it down if (!_onlyScaleDown || (captionDim[0] * charCountMax * GetDefaultSize() >= _expanse[0] || captionDim[1] * lineCount >= _expanse[1])) { SetDefaultSize(min((float)(_expanse[0] / (captionDim[0] * charCountMax)), (float)(_expanse[1] / (captionDim[1] * lineCount)))); } }
bool wxTopLevelWindowQt::Create( wxWindow *parent, wxWindowID winId, const wxString &title, const wxPoint &pos, const wxSize &sizeOrig, long style, const wxString &name ) { wxSize size(sizeOrig); if ( !size.IsFullySpecified() ) size.SetDefaults( GetDefaultSize() ); wxTopLevelWindows.Append( this ); if (!CreateBase( parent, winId, pos, size, style, wxDefaultValidator, name )) { wxFAIL_MSG( wxT("wxTopLevelWindowNative creation failed") ); return false; } SetTitle( title ); SetWindowStyleFlag( style ); if (pos != wxDefaultPosition) m_qtWindow->move( pos.x, pos.y ); m_qtWindow->resize( wxQtConvertSize( size ) ); // Prevent automatic deletion of Qt main window on close // (this should be the default, but left just fo enforce it) GetHandle()->setAttribute(Qt::WA_DeleteOnClose, false); // not calling to wxWindow::Create, so do the rest of initialization: if (parent) parent->AddChild( this ); return true; }
bool wxTopLevelWindowDFB::Create(wxWindow *parent, wxWindowID id, const wxString& title, const wxPoint& posOrig, const wxSize& sizeOrig, long style, const wxString &name) { // always create a frame of some reasonable, even if arbitrary, size (at // least for MSW compatibility) wxSize size(sizeOrig); if ( size.x == wxDefaultCoord || size.y == wxDefaultCoord ) { wxSize sizeDefault = GetDefaultSize(); if ( size.x == wxDefaultCoord ) size.x = sizeDefault.x; if ( size.y == wxDefaultCoord ) size.y = sizeDefault.y; } wxPoint pos(posOrig); if ( pos.x == wxDefaultCoord ) pos.x = 0; if ( pos.y == wxDefaultCoord ) pos.y = 0; if ( !wxNonOwnedWindow::Create(parent, id, pos, size, style, name) ) return false; wxTopLevelWindows.Append(this); m_title = title; return true; }
void HTML5VideoFullScreen::VideoSurfaceView::OnMeasure( /* [in] */ Int32 widthMeasureSpec, /* [in] */ Int32 heightMeasureSpec) { Int32 width = GetDefaultSize(mOwner->mVideoWidth, widthMeasureSpec); Int32 height = GetDefaultSize(mOwner->mVideoHeight, heightMeasureSpec); if (mOwner->mVideoWidth > 0 && mOwner->mVideoHeight > 0) { if ( mOwner->mVideoWidth * height > width * mOwner->mVideoHeight ) { height = width * mOwner->mVideoHeight / mOwner->mVideoWidth; } else if ( mOwner->mVideoWidth * height < width * mOwner->mVideoHeight ) { width = height * mOwner->mVideoWidth / mOwner->mVideoHeight; } } SetMeasuredDimension(width, height); }
void wxTopLevelWindowMSW::MSWGetCreateWindowCoords(const wxPoint& pos, const wxSize& size, int& x, int& y, int& w, int& h) const { // let the system position the window if no explicit position was specified if ( pos.x == wxDefaultCoord ) { // if x is set to CW_USEDEFAULT, y parameter is ignored anyhow so we // can just as well set it to CW_USEDEFAULT as well x = y = CW_USEDEFAULT; } else { // OTOH, if x is not set to CW_USEDEFAULT, y shouldn't be set to it // neither because it is not handled as a special value by Windows then // and so we have to choose some default value for it, even if a // completely arbitrary one static const int DEFAULT_Y = 200; x = pos.x; y = pos.y == wxDefaultCoord ? DEFAULT_Y : pos.y; } if ( size.x == wxDefaultCoord || size.y == wxDefaultCoord ) { // We don't use CW_USEDEFAULT here for several reasons: // // 1. It results in huge frames on modern screens (1000*800 is not // uncommon on my 1280*1024 screen) which is way too big for a half // empty frame of most of wxWidgets samples for example) // // 2. It is buggy for frames with wxFRAME_TOOL_WINDOW style for which // the default is for whatever reason 8*8 which breaks client <-> // window size calculations (it would be nice if it didn't, but it // does and the simplest way to fix it seemed to change the broken // default size anyhow) // // 3. There is just no advantage in doing it: with x and y it is // possible that [future versions of] Windows position the new top // level window in some smart way which we can't do, but we can // guess a reasonably good size for a new window just as well // ourselves // wxSize sizeReal = size; sizeReal.SetDefaults(GetDefaultSize()); w = sizeReal.x; h = sizeReal.y; } else { w = size.x; h = size.y; } }
static XtGeometryResult QueryGeometry (Widget gw, XtWidgetGeometry *intended, XtWidgetGeometry *pref) { XmPannerWidget pw = (XmPannerWidget) gw; GetDefaultSize (pw, &pref->width, &pref->height); return(_XmHWQuery(gw, intended, pref)); }
/*! \todo handle exception on errors */ filepos_t EbmlString::RenderData(IOCallback & output, bool /* bForceRender */, bool /* bWithDefault */) { filepos_t Result; output.writeFully(Value.c_str(), Value.length()); Result = Value.length(); if (Result < GetDefaultSize()) { // pad the rest with 0 binary *Pad = new (std::nothrow) binary[GetDefaultSize() - Result]; if (Pad == NULL) { return Result; } memset(Pad, 0x00, GetDefaultSize() - Result); output.writeFully(Pad, GetDefaultSize() - Result); Result = GetDefaultSize(); delete [] Pad; } return Result; }
void gcFrame::setupPositionSave(const char* name, bool saveMax, int defWidth, int defHeight) { if (m_pCVarInfo) return; if (defWidth == -1) defWidth = GetDefaultSize().GetWidth(); if (defHeight == -1) defHeight = GetDefaultSize().GetHeight(); m_pCVarInfo = new CVarInfo(); m_pCVarInfo->setupPositionSave(name, saveMax, defWidth, defHeight); if (saveMax) { //Need to do this as at this stage inheritance may not be full formed and Maximize doesnt work correctly. onFormMaxEvent += guiDelegate(this, &gcFrame::onFormMax); onFormMaxEvent(); } }
filepos_t EbmlCrc32::RenderData(IOCallback & output, bool /* bForceRender */, bool /* bWithDefault */) { filepos_t Result = 4; if (Result != 0) { output.writeFully(&m_crc_final, Result); } if (Result < GetDefaultSize()) { // pad the rest with 0 binary *Pad = new binary[GetDefaultSize() - Result]; if (Pad != NULL) { memset(Pad, 0x00, GetDefaultSize() - Result); output.writeFully(Pad, GetDefaultSize() - Result); Result = GetDefaultSize(); delete [] Pad; } } return Result; }
bool wxTopLevelWindowMGL::Create(wxWindow *parent, wxWindowID id, const wxString& title, const wxPoint& posOrig, const wxSize& sizeOrig, long style, const wxString &name) { // always create a frame of some reasonable, even if arbitrary, size (at // least for MSW compatibility) wxSize size = sizeOrig; if ( size.x == wxDefaultCoord || size.y == wxDefaultCoord ) { wxSize sizeDefault = GetDefaultSize(); if ( size.x == wxDefaultCoord ) size.x = sizeDefault.x; if ( size.y == wxDefaultCoord ) size.y = sizeDefault.y; } // for default positioning, centre the first top level window and // cascade any addtional ones from there. wxPoint pos = posOrig; if ( pos.x == wxDefaultCoord || pos.y == wxDefaultCoord ) { wxSize sizeDisplay = wxGetDisplaySize(); static wxPoint nextPos((sizeDisplay.x - size.x) / 2, (sizeDisplay.y - size.y) / 2); if ( pos.x == wxDefaultCoord ) pos.x = nextPos.x; if ( pos.y == wxDefaultCoord ) pos.y = nextPos.y; if ( pos.x + size.x > sizeDisplay.x || pos.y + size.y > sizeDisplay.y ) pos = wxPoint(); const wxSize cascadeOffset(16, 20); nextPos = pos + cascadeOffset; } wxWindow::Create(NULL, id, pos, size, style, name); SetParent(parent); if ( parent ) parent->AddChild(this); wxTopLevelWindows.Append(this); m_title = title; return true; }
wxSize wxButton::DoGetBestSize() const { wxString rsLabel = wxGetWindowText(GetHWND()); int nWidthButton; int nWidthChar; int nHeightChar; wxFont vFont = (wxFont)GetFont(); GetTextExtent( rsLabel ,&nWidthButton ,NULL ); wxGetCharSize( GetHWND() ,&nWidthChar ,&nHeightChar ,&vFont ); // // Add a margin - the button is wider than just its label // nWidthButton += 3 * nWidthChar; // // The button height is proportional to the height of the font used // int nHeightButton = BUTTON_HEIGHT_FROM_CHAR_HEIGHT(nHeightChar); // // Need a little extra to make it look right // nHeightButton += (int)(nHeightChar/1.5); if (!HasFlag(wxBU_EXACTFIT)) { wxSize vSize = GetDefaultSize(); if (nWidthButton > vSize.x) vSize.x = nWidthButton; if (nHeightButton > vSize.y) vSize.y = nHeightButton; return vSize; } return wxSize( nWidthButton ,nHeightButton ); } // end of wxButton::DoGetBestSize
// Return default size of frame window containing the window when floating. CSize CGenDockablePane::GetFrameSize() { CSize sz = GetDefaultSize(); CWnd* pParent = GetParent(); ASSERT(pParent != NULL && pParent->IsKindOf(RUNTIME_CLASS(CPaneFrameWnd))); if (pParent != NULL) { // If floating add NC area of parent (frame) window CRect wndRect, cliRect; pParent->GetWindowRect(&wndRect); pParent->GetClientRect(&cliRect); sz.cx += wndRect.Width() - cliRect.Width(); sz.cy += wndRect.Height() - cliRect.Height(); } return sz; }
wxSize wxButton::OldGetBestSize() const { Dimension xmargin, ymargin, highlight, shadow, defThickness; XtVaGetValues( (Widget)m_mainWidget, XmNmarginWidth, &xmargin, XmNmarginHeight, &ymargin, XmNhighlightThickness, &highlight, XmNshadowThickness, &shadow, XmNdefaultButtonShadowThickness, &defThickness, NULL ); int x = 0; int y = 0; GetTextExtent( GetLabel(), &x, &y ); int margin = highlight * 2 + ( defThickness ? ( ( shadow + defThickness ) * 4 ) : ( shadow * 2 ) ); wxSize best( x + xmargin * 2 + margin, y + ymargin * 2 + margin ); // all buttons have at least the standard size unless the user explicitly // wants them to be of smaller size and used wxBU_EXACTFIT style when // creating the button if( !HasFlag( wxBU_EXACTFIT ) ) { wxSize def = GetDefaultSize(); int margin = highlight * 2 + ( defThickness ? ( shadow * 4 + defThickness * 4 ) : 0 ); def.x += margin; def.y += margin; if( def.x > best.x ) best.x = def.x; if( def.y > best.y ) best.y = def.y; } return best; }
/*ARGSUSED*/ static void XawSmeBSBInitialize(Widget request, Widget cnew, ArgList args, Cardinal *num_args) { SmeBSBObject entry = (SmeBSBObject)cnew; if (!entry->sme_bsb.font) XtError("Aborting: no font found\n"); if (entry->sme_bsb.label == NULL) entry->sme_bsb.label = XtName(cnew); else entry->sme_bsb.label = XtNewString(entry->sme_bsb.label); GetDefaultSize(cnew, &entry->rectangle.width, &entry->rectangle.height); CreateGCs(cnew); entry->sme_bsb.left_bitmap_width = entry->sme_bsb.left_bitmap_height = 0; entry->sme_bsb.right_bitmap_width = entry->sme_bsb.right_bitmap_height = 0; GetBitmapInfo(cnew, True); /* Left Bitmap Info */ GetBitmapInfo(cnew, False); /* Right Bitmap Info */ }
MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h) : TGMainFrame(p, w, h) { // Create a main frame TString name = "myicon"; ULong_t yellow; gClient->GetColorByName("yellow", yellow); // Create a picture from the XPM data TGPicturePool *picpool = gClient->GetResourcePool()->GetPicturePool(); const TGPicture *iconpic = picpool->GetPicture(name.Data(),icon1); TGIcon *icon = new TGIcon(this, iconpic, 40, 40, kChildFrame, yellow); AddFrame(icon, new TGLayoutHints(kLHintsLeft, 1,15,1,1)); TGTextButton *exit = new TGTextButton(this, "&Exit","gApplication->Terminate(0)"); AddFrame(exit, new TGLayoutHints(kLHintsExpandX,2,0,2,2)); SetWindowName("Icon test"); MapSubwindows(); Resize(GetDefaultSize()); MapWindow(); }
/* ARGSUSED */ static void Initialize (Widget greq, Widget gset, ArgList args, Cardinal *num_args) { XmPannerWidget req = (XmPannerWidget) greq, set = (XmPannerWidget) gset; Dimension defwidth, defheight; #ifdef DEMO _XmInitialIzeConverters(greq); #endif XmPanner_private(set) = (XmPannerPrivateData *)XtCalloc(1, sizeof(XmPannerPrivateData)); ASSIGN_MAX(XmPanner_canvas_width(req), 1); ASSIGN_MAX(XmPanner_canvas_height(req), 1); if (XmPanner_default_scale(req) < 1) XmPanner_default_scale(set) = XmPannerDefaultScale; GetDefaultSize (req, &defwidth, &defheight); if (req->core.width < 1) set->core.width = defwidth; if (req->core.height < 1) set->core.height = defheight; XmPanner_slider_gc(set) = XmPanner_xor_gc(set) = NULL; ResetSliderGC (set); /* foreground */ ResetXorGC (set); /* foreground ^ background */ Rescale(set); /* does a position check */ XmPanner_tmp(set).doing = FALSE; XmPanner_tmp(set).showing = FALSE; }
void CFormulaNode::RecalculateSize( int bRecalc ) { SizeFde sz( 0, 0 ); int i = 0; sz = CFormulaExCalc::RecalculateSize( this ); if( (i = RecalculateGrph( this, regetActiveCalc() )) != 0 ) { sz = CFormulaExCalc::RecalculateSize( this ); i = RecalculateGrph( this, regetActiveCalc() ); } if( isHiddenNDisabled() ) { sz.rwidth() = 0; if( GetParent() && GetParent()->GetSize().height() > 0 ) sz.rheight() = GetParent()->GetSize().height(); else sz.rheight() = GetDefaultSize().height(); } Recalculate_VerticalCenter( sz ); //=== 'mpadded' MathML element if( !isHiddenNDisabled() && getAlignmentType() == FBtnChildPos::MSPACE_Exact_HeightDepth ) { RealFde newValues[ MML_MPADDED_UNITS_LEN ] = { 0.0, 0.0, 0.0, 0.0 }; RealFde childValues[ MML_MPADDED_UNITS_LEN ] = { 0.0, 0.0, 0.0, 0.0 }; int iRet[ MML_MPADDED_UNITS_LEN ] = { -1, -1, -1, -1 }; getChildDimensions_Vertical( childValues ); getChildDimensions_Horizontal( childValues ); getMathMLAttr().parseMPaddedAttr( newValues, childValues, iRet, ::getCurrentFormulatorStyle().getUnit2PX() ); RealFde paddedLSpace = 0.0, paddedRSpace = 0.0; if( iRet[ MML_MPADDED_UNITS_LSPACE ] == 0 ) { paddedLSpace = newValues[ MML_MPADDED_UNITS_LSPACE ]; } if( iRet[ MML_MPADDED_UNITS_WIDTH ] == 0 ) { RealFde width = newValues[ MML_MPADDED_UNITS_WIDTH ]; RealFde delta = width - (paddedLSpace + childValues[ MML_MPADDED_UNITS_WIDTH ]); if( delta >= 0.0 ) paddedRSpace = delta; else { paddedLSpace = width - childValues[ MML_MPADDED_UNITS_WIDTH ]; if( paddedLSpace < 0.0 ) { sz.rwidth() = width; paddedLSpace = 0.0; } } } RealFde paddedTSpace = 0.0, paddedBSpace = 0.0; if( iRet[ MML_MPADDED_UNITS_HEIGHT ] == 0 ) { RealFde height = newValues[ MML_MPADDED_UNITS_HEIGHT ]; RealFde delta = height - childValues[ MML_MPADDED_UNITS_HEIGHT ]; if( delta >= 0 ) paddedTSpace = delta; else { // not feasible } } if( iRet[ MML_MPADDED_UNITS_DEPTH ] == 0 ) { RealFde delta = newValues[ MML_MPADDED_UNITS_DEPTH ] - childValues[ MML_MPADDED_UNITS_DEPTH ]; if( delta >= 0 ) paddedBSpace = delta; else { // not feasible } } if( paddedLSpace || paddedRSpace || paddedTSpace || paddedBSpace ) { CNode *pNode = GetFirstChild(); if( pNode && pNode->GetType() == NODE_FRAME ) { CFrameNode *n1st = (CFrameNode*)pNode; n1st->setLeftIndent( paddedLSpace ); n1st->setRightIndent( paddedRSpace ); n1st->setTopIndent( paddedTSpace ); n1st->setBottomIndent( paddedBSpace ); } } } if( sz != GetSize() || i ) SetSize( sz ); if( bRecalc ) GetParent()->RecalculateSize( bRecalc ); }
//o-------------------------------------------------------------- //| BuffFadeBySlot; Yeahlight, Nov 16, 2008 //o-------------------------------------------------------------- //| Adapted from EQEMU 7.0: Removes the buff in the supplied //| buff slot 'slot' //o-------------------------------------------------------------- void Mob::BuffFadeBySlot(int slot, bool iRecalcBonuses) { bool debugFlag = true; if(slot < 0 || slot > BUFF_COUNT) return; if(!buffs[slot].spell || !buffs[slot].spell->IsValidSpell()) return; if(IsClient()) CastToClient()->MakeBuffFadePacket(buffs[slot].spell, slot); if(debugFlag && this->IsClient() && this->CastToClient()->GetDebugMe()) this->Message(LIGHTEN_BLUE, "Debug: Fading buff %d from slot %d", buffs[slot].spell->GetSpellID(), slot); for(int i = 0; i < EFFECT_COUNT; i++) { if(buffs[slot].spell->IsBlankSpellEffect(i)) continue; switch(buffs[slot].spell->GetSpellEffectID(i)) { case SE_WeaponProc: { SetBonusProcSpell(0); break; } case SE_Illusion: case SE_IllusionCopy: { SendIllusionPacket(GetBaseRace(), GetBaseGender(), GetTexture(), GetHelmTexture()); SendAppearancePacket(this->GetID(), SAT_Size, GetDefaultSize(), true); break; } case SE_Levitate: { SendAppearancePacket(this->GetID(), SAT_Levitate, 0, true); break; } case SE_Invisibility: { SetInvisible(false); break; } case SE_InvisVsUndead: { SetInvisibleUndead(false); break; } case SE_InvisVsAnimals: { SetInvisibleAnimal(false); break; } case SE_Silence: { break; } case SE_DivineAura: { SetInvulnerable(false); break; } case SE_Rune: { break; } case SE_AbsorbMagicAtt: { break; } case SE_Mez: { //Yeahlight: Unfreeze the PC's UI if(IsClient()) SendAppearancePacket(this->GetID(), SAT_Position_Update, SAPP_Sitting_To_Standing, true); this->mesmerized = false; break; } case SE_Charm: { Mob* charmer = entity_list.GetMob(this->GetOwnerID()); if(charmer && charmer->IsClient()) { char npcNameSuffix[] = "_CHARM00"; char npcNamePrefix[100] = ""; strcpy(npcNamePrefix, charmer->GetName()); strcat(npcNamePrefix, npcNameSuffix); Mob* charmPH = entity_list.GetMob(npcNamePrefix); if(charmPH && charmPH->IsNPC()) { charmPH->Depop(); } //Yeahlight: Check for _CHARM01 NPC, too npcNamePrefix[strlen(npcNamePrefix) - 1] = '1'; charmPH = entity_list.GetMob(npcNamePrefix); if(charmPH && charmPH->IsNPC()) { charmPH->Depop(); } //Yeahlight: Generate hate for towards the charmer if the charmer is not FD'ed if(this->IsNPC() && charmer->IsClient() && !charmer->CastToClient()->GetFeigned()) { CastToNPC()->AddToHateList(charmer, 0, GetSpellHate(SE_Charm, this->GetLevel(), false)); } } //Yeahlight: Unfreeze the PC's UI if(IsClient()) { SendAppearancePacket(this->GetID(), SAT_Position_Update, SAPP_Sitting_To_Standing, true); CastToClient()->SetCharmed(false); CastToClient()->charmPositionUpdate_timer->Disable(); } //Yeahlight: Deflag the NPC as charmed else if(IsNPC()) { CastToNPC()->SetCharmed(false); } this->SetOwnerID(0, false); break; } case SE_Root: { break; } case SE_Fear: { //Yeahlight: Unfreeze the PC's UI if(IsClient()) { CastToClient()->SetFeared(false); SendAppearancePacket(this->GetID(), SAT_Position_Update, SAPP_Sitting_To_Standing, true); } else if(IsNPC()) { CastToNPC()->SetFeared(false); CastToNPC()->SetOnFearPath(false); } break; } case SE_SpinTarget: { //Yeahlight: Unfreeze the PC's UI if(IsClient()) SendAppearancePacket(this->GetID(), SAT_Position_Update, SAPP_Sitting_To_Standing, true); break; } case SE_EyeOfZomm: { //Yeahlight: Clear the eye of zomm pointer and depop the eye if(IsClient() && CastToClient()->myEyeOfZomm) { CastToClient()->myEyeOfZomm->Depop(); CastToClient()->myEyeOfZomm = NULL; } break; } case SE_DeathSave: { //Yeahlight: Clear the death save chance if(IsClient()) CastToClient()->SetDeathSave(0); break; } case SE_VoiceGraft: { //Yeahlight: Drop the voice grafting flag from the client if(GetOwner() && GetOwner()->IsClient()) { GetOwner()->CastToClient()->SetVoiceGrafting(false); } break; } case SE_SeeInvis: { //Yeahlight: Mob may no longer see through invis SetCanSeeThroughInvis(false); break; } } } buffs[slot].spell = NULL; if(iRecalcBonuses) CalcBonuses(true, true); }
bool wxTopLevelWindowGTK::Create( wxWindow *parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& sizeOrig, long style, const wxString &name ) { wxSize size(sizeOrig); if (!size.IsFullySpecified()) size.SetDefaults(GetDefaultSize()); wxTopLevelWindows.Append( this ); if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) { wxFAIL_MSG( wxT("wxTopLevelWindowGTK creation failed") ); return false; } m_title = title; // NB: m_widget may be !=NULL if it was created by derived class' Create, // e.g. in wxTaskBarIconAreaGTK if (m_widget == NULL) { m_widget = gtk_window_new(GTK_WINDOW_TOPLEVEL); if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG) { // Tell WM that this is a dialog window and make it center // on parent by default (this is what GtkDialog ctor does): gtk_window_set_type_hint(GTK_WINDOW(m_widget), GDK_WINDOW_TYPE_HINT_DIALOG); gtk_window_set_position(GTK_WINDOW(m_widget), GTK_WIN_POS_CENTER_ON_PARENT); } else { if (style & wxFRAME_TOOL_WINDOW) { gtk_window_set_type_hint(GTK_WINDOW(m_widget), GDK_WINDOW_TYPE_HINT_UTILITY); // On some WMs, like KDE, a TOOL_WINDOW will still show // on the taskbar, but on Gnome a TOOL_WINDOW will not. // For consistency between WMs and with Windows, we // should set the NO_TASKBAR flag which will apply // the set_skip_taskbar_hint if it is available, // ensuring no taskbar entry will appear. style |= wxFRAME_NO_TASKBAR; } } g_object_ref(m_widget); } wxWindow *topParent = wxGetTopLevelParent(m_parent); if (topParent && (((GTK_IS_WINDOW(topParent->m_widget)) && (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG)) || (style & wxFRAME_FLOAT_ON_PARENT))) { gtk_window_set_transient_for( GTK_WINDOW(m_widget), GTK_WINDOW(topParent->m_widget) ); } if (style & wxFRAME_NO_TASKBAR) { gtk_window_set_skip_taskbar_hint(GTK_WINDOW(m_widget), TRUE); } if (style & wxSTAY_ON_TOP) { gtk_window_set_keep_above(GTK_WINDOW(m_widget), TRUE); } if (style & wxMAXIMIZE) gtk_window_maximize(GTK_WINDOW(m_widget)); #if 0 if (!name.empty()) gtk_window_set_role( GTK_WINDOW(m_widget), wxGTK_CONV( name ) ); #endif gtk_window_set_title( GTK_WINDOW(m_widget), wxGTK_CONV( title ) ); gtk_widget_set_can_focus(m_widget, false); g_signal_connect (m_widget, "delete_event", G_CALLBACK (gtk_frame_delete_callback), this); // m_mainWidget is a GtkVBox, holding the bars and client area (m_wxwindow) m_mainWidget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_widget_show( m_mainWidget ); gtk_widget_set_can_focus(m_mainWidget, false); gtk_container_add( GTK_CONTAINER(m_widget), m_mainWidget ); // m_wxwindow is the client area m_wxwindow = wxPizza::New(); gtk_widget_show( m_wxwindow ); gtk_box_pack_start(GTK_BOX(m_mainWidget), m_wxwindow, true, true, 0); // we donm't allow the frame to get the focus as otherwise // the frame will grab it at arbitrary focus changes gtk_widget_set_can_focus(m_wxwindow, false); if (m_parent) m_parent->AddChild( this ); g_signal_connect(m_wxwindow, "size_allocate", G_CALLBACK(size_allocate), this); PostCreation(); #ifndef __WXGTK3__ if (pos != wxDefaultPosition) gtk_widget_set_uposition( m_widget, m_x, m_y ); #endif // for some reported size corrections g_signal_connect (m_widget, "map_event", G_CALLBACK (gtk_frame_map_callback), this); // for iconized state g_signal_connect (m_widget, "window_state_event", G_CALLBACK (gtk_frame_window_state_callback), this); // for wxMoveEvent g_signal_connect (m_widget, "configure_event", G_CALLBACK (gtk_frame_configure_callback), this); // activation g_signal_connect_after (m_widget, "focus_in_event", G_CALLBACK (gtk_frame_focus_in_callback), this); g_signal_connect_after (m_widget, "focus_out_event", G_CALLBACK (gtk_frame_focus_out_callback), this); // We need to customize the default GTK+ logic for key processing to make // it conforming to wxWidgets event processing order. g_signal_connect (m_widget, "key_press_event", G_CALLBACK (wxgtk_tlw_key_press_event), NULL); #ifdef GDK_WINDOWING_X11 #ifdef __WXGTK3__ if (GDK_IS_X11_SCREEN(gtk_window_get_screen(GTK_WINDOW(m_widget)))) #endif { gtk_widget_add_events(m_widget, GDK_PROPERTY_CHANGE_MASK); g_signal_connect(m_widget, "property_notify_event", G_CALLBACK(property_notify_event), this); } #endif // GDK_WINDOWING_X11 // translate wx decorations styles into Motif WM hints (they are recognized // by other WMs as well) // always enable moving the window as we have no separate flag for enabling // it m_gdkFunc = GDK_FUNC_MOVE; if ( style & wxCLOSE_BOX ) m_gdkFunc |= GDK_FUNC_CLOSE; if ( style & wxMINIMIZE_BOX ) m_gdkFunc |= GDK_FUNC_MINIMIZE; if ( style & wxMAXIMIZE_BOX ) m_gdkFunc |= GDK_FUNC_MAXIMIZE; if ( (style & wxSIMPLE_BORDER) || (style & wxNO_BORDER) ) { m_gdkDecor = 0; gtk_window_set_decorated(GTK_WINDOW(m_widget), false); } else // have border { m_gdkDecor = GDK_DECOR_BORDER; if ( style & wxCAPTION ) m_gdkDecor |= GDK_DECOR_TITLE; #if defined(GDK_WINDOWING_WAYLAND) && GTK_CHECK_VERSION(3,10,0) else if ( GDK_IS_WAYLAND_DISPLAY(gtk_widget_get_display(m_widget)) && gtk_check_version(3,10,0) == NULL) { gtk_window_set_titlebar(GTK_WINDOW(m_widget), gtk_header_bar_new()); } #endif if ( style & wxSYSTEM_MENU ) m_gdkDecor |= GDK_DECOR_MENU; if ( style & wxMINIMIZE_BOX ) m_gdkDecor |= GDK_DECOR_MINIMIZE; if ( style & wxMAXIMIZE_BOX ) m_gdkDecor |= GDK_DECOR_MAXIMIZE; if ( style & wxRESIZE_BORDER ) { m_gdkFunc |= GDK_FUNC_RESIZE; m_gdkDecor |= GDK_DECOR_RESIZEH; } } m_decorSize = GetCachedDecorSize(); int w, h; GTKDoGetSize(&w, &h); if (style & wxRESIZE_BORDER) { gtk_window_set_default_size(GTK_WINDOW(m_widget), w, h); #ifndef __WXGTK3__ gtk_window_set_policy(GTK_WINDOW(m_widget), 1, 1, 1); #endif } else { gtk_window_set_resizable(GTK_WINDOW(m_widget), false); // gtk_window_set_default_size() does not work for un-resizable windows, // unless you set the size hints, but that causes Ubuntu's WM to make // the window resizable even though GDK_FUNC_RESIZE is not set. gtk_widget_set_size_request(m_widget, w, h); } return true; }
bool wxTopLevelWindowMSW::Create(wxWindow *parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { wxSize sizeReal = size; if ( !sizeReal.IsFullySpecified() ) { sizeReal.SetDefaults(GetDefaultSize()); } // notice that we should append this window to wxTopLevelWindows list // before calling CreateBase() as it behaves differently for TLW and // non-TLW windows wxTopLevelWindows.Append(this); bool ret = CreateBase(parent, id, pos, sizeReal, style, name); if ( !ret ) return false; if ( parent ) parent->AddChild(this); if ( GetExtraStyle() & wxTOPLEVEL_EX_DIALOG ) { // we have different dialog templates to allows creation of dialogs // with & without captions under MSWindows, resizable or not (but a // resizable dialog always has caption - otherwise it would look too // strange) // we need 3 additional WORDs for dialog menu, class and title (as we // don't use DS_SETFONT we don't need the fourth WORD for the font) static const int dlgsize = sizeof(DLGTEMPLATE) + (sizeof(WORD) * 3); DLGTEMPLATE *dlgTemplate = (DLGTEMPLATE *)malloc(dlgsize); memset(dlgTemplate, 0, dlgsize); // these values are arbitrary, they won't be used normally anyhow dlgTemplate->x = 34; dlgTemplate->y = 22; dlgTemplate->cx = 144; dlgTemplate->cy = 75; // reuse the code in MSWGetStyle() but correct the results slightly for // the dialog // // NB: we need a temporary variable as we can't pass pointer to // dwExtendedStyle directly, it's not aligned correctly for 64 bit // architectures WXDWORD dwExtendedStyle; dlgTemplate->style = MSWGetStyle(style, &dwExtendedStyle); dlgTemplate->dwExtendedStyle = dwExtendedStyle; // all dialogs are popups dlgTemplate->style |= WS_POPUP; #ifndef __WXWINCE__ if ( wxApp::MSWGetDefaultLayout(m_parent) == wxLayout_RightToLeft ) { dlgTemplate->dwExtendedStyle |= WS_EX_LAYOUTRTL; } // force 3D-look if necessary, it looks impossibly ugly otherwise if ( style & (wxRESIZE_BORDER | wxCAPTION) ) dlgTemplate->style |= DS_MODALFRAME; #endif ret = CreateDialog(dlgTemplate, title, pos, sizeReal); free(dlgTemplate); } else // !dialog { ret = CreateFrame(title, pos, sizeReal); } #ifndef __WXWINCE__ if ( ret && !(GetWindowStyleFlag() & wxCLOSE_BOX) ) { EnableCloseButton(false); } #endif // for standard dialogs the dialog manager generates WM_CHANGEUISTATE // itself but for custom windows we have to do it ourselves in order to // make the keyboard indicators (such as underlines for accelerators and // focus rectangles) work under Win2k+ if ( ret ) { MSWUpdateUIState(UIS_INITIALIZE); } // Note: if we include PocketPC in this test, dialogs can fail to show up, // for example the text entry dialog in the dialogs sample. Problem with Maximise()? #if defined(__WXWINCE__) && (defined(__SMARTPHONE__) || defined(__WINCE_STANDARDSDK__)) if ( ( style & wxMAXIMIZE ) || IsAlwaysMaximized() ) { this->Maximize(); } #endif #if defined(__SMARTPHONE__) && defined(__WXWINCE__) SetRightMenu(); // to nothing for initialization #endif return ret; }
KVFileDialog::KVFileDialog(const TGWindow *p, const TGWindow *main, EKVFileDialogMode dlg_type, TGFileInfo *file_info) : TGTransientFrame(p, main, 10, 10, kVerticalFrame) { // Create a file selection dialog. Depending on the dlg_type it can be // used for opening or saving a file or selecting a directory. fDlgMode=dlg_type; SetCleanup(kDeepCleanup); Connect("CloseWindow()", "KVFileDialog", this, "CloseWindow()"); DontCallClose(); int i; if (!p && !main) { MakeZombie(); return; } if (!file_info) { Error("KVFileDialog", "file_info argument not set"); fFileInfo = &gInfo; if (fFileInfo->fIniDir) { delete [] fFileInfo->fIniDir; fFileInfo->fIniDir = 0; } if (fFileInfo->fFilename) { delete [] fFileInfo->fFilename; fFileInfo->fFilename = 0; } fFileInfo->fFileTypeIdx = 0; } else fFileInfo = file_info; if (!fFileInfo->fFileTypes) fFileInfo->fFileTypes = gDefTypes; if (!fFileInfo->fIniDir) fFileInfo->fIniDir = StrDup("."); TGHorizontalFrame *fHtop = new TGHorizontalFrame(this, 10, 10); //--- top toolbar elements TGLabel *fLookin = new TGLabel(fHtop, new TGHotString((dlg_type == kKVFDSave) ? "S&ave in:" : "&Look in:")); fTreeLB = new TGFSComboBox(fHtop, kIDF_FSLB); fTreeLB->Associate(this); fPcdup = fClient->GetPicture("tb_uplevel.xpm"); fPnewf = fClient->GetPicture("tb_newfolder.xpm"); fPlist = fClient->GetPicture("tb_list.xpm"); fPdetails = fClient->GetPicture("tb_details.xpm"); if (!(fPcdup && fPnewf && fPlist && fPdetails)) Error("KVFileDialog", "missing toolbar pixmap(s).\n"); fCdup = new TGPictureButton(fHtop, fPcdup, kIDF_CDUP); fNewf = new TGPictureButton(fHtop, fPnewf, kIDF_NEW_FOLDER); fList = new TGPictureButton(fHtop, fPlist, kIDF_LIST); fDetails = new TGPictureButton(fHtop, fPdetails, kIDF_DETAILS); fCdup->SetStyle(gClient->GetStyle()); fNewf->SetStyle(gClient->GetStyle()); fList->SetStyle(gClient->GetStyle()); fDetails->SetStyle(gClient->GetStyle()); fCdup->SetToolTipText("Up One Level"); fNewf->SetToolTipText("Create New Folder"); fList->SetToolTipText("List"); fDetails->SetToolTipText("Details"); fCdup->Associate(this); fNewf->Associate(this); fList->Associate(this); fDetails->Associate(this); fList->AllowStayDown(kTRUE); fDetails->AllowStayDown(kTRUE); fTreeLB->Resize(200, fTreeLB->GetDefaultHeight()); fHtop->AddFrame(fLookin, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 5, 2, 2)); fHtop->AddFrame(fTreeLB, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 3, 0, 2, 2)); fHtop->AddFrame(fCdup, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 2, 2)); fHtop->AddFrame(fNewf, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 2, 2)); fHtop->AddFrame(fList, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 2, 2)); fHtop->AddFrame(fDetails, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 0, 8, 2, 2)); if (dlg_type == kKVFDSave) { fCheckB = new TGCheckButton(fHtop, "&Overwrite", kIDF_CHECKB); fCheckB->SetToolTipText("Overwrite a file without displaying a message if selected"); } else { fCheckB = new TGCheckButton(fHtop, "&Multiple files", kIDF_CHECKB); fCheckB->SetToolTipText("Allows multiple file selection when SHIFT is pressed"); fCheckB->Connect("Toggled(Bool_t)","TGFileInfo",fFileInfo,"SetMultipleSelection(Bool_t)"); } fHtop->AddFrame(fCheckB, new TGLayoutHints(kLHintsLeft | kLHintsCenterY)); fCheckB->SetOn(fFileInfo->fMultipleSelection); AddFrame(fHtop, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 4, 4, 3, 1)); //--- file view fFv = new TGListView(this, 400, 161); fFc = new TGFileContainer(fFv->GetViewPort(), 10, 10, kHorizontalFrame, fgWhitePixel); fFc->Associate(this); fFv->GetViewPort()->SetBackgroundColor(fgWhitePixel); fFv->SetContainer(fFc); fFv->SetViewMode(kLVList); fFv->SetIncrements(1, 19); // set vertical scroll one line height at a time TGTextButton** buttons = fFv->GetHeaderButtons(); if (buttons) { buttons[0]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByName)"); buttons[1]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByType)"); buttons[2]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortBySize)"); buttons[3]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByOwner)"); buttons[4]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByGroup)"); buttons[5]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByDate)"); } fFc->SetFilter(fFileInfo->fFileTypes[fFileInfo->fFileTypeIdx+1]); fFc->Sort(kSortByName); fFc->ChangeDirectory(fFileInfo->fIniDir); fFc->SetMultipleSelection(fFileInfo->fMultipleSelection); fTreeLB->Update(fFc->GetDirectory()); fList->SetState(kButtonEngaged); AddFrame(fFv, new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsExpandY, 4, 4, 3, 1)); if (dlg_type == kKVFDOpen) { fCheckB->Connect("Toggled(Bool_t)","TGFileContainer",fFc,"SetMultipleSelection(Bool_t)"); fCheckB->Connect("Toggled(Bool_t)","TGFileContainer",fFc,"UnSelectAll()"); } //--- file name and types TGHorizontalFrame *fHf = new TGHorizontalFrame(this, 10, 10); TGVerticalFrame *fVf = new TGVerticalFrame(fHf, 10, 10); TGHorizontalFrame *fHfname = new TGHorizontalFrame(fVf, 10, 10); TGLabel *fLfname = new TGLabel(fHfname, new TGHotString("File &name:")); fTbfname = new TGTextBuffer(1034); fName = new TGTextEntry(fHfname, fTbfname); fName->Resize(230, fName->GetDefaultHeight()); fName->Associate(this); fHfname->AddFrame(fLfname, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 5, 2, 2)); fHfname->AddFrame(fName, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 0, 20, 2, 2)); fVf->AddFrame(fHfname, new TGLayoutHints(kLHintsLeft | kLHintsCenterY | kLHintsExpandX)); TGHorizontalFrame *fHftype = new TGHorizontalFrame(fVf, 10, 10); TGLabel *fLftypes = new TGLabel(fHftype, new TGHotString("Files of &type:")); fTypes = new TGComboBox(fHftype, kIDF_FTYPESLB); fTypes->Associate(this); fTypes->Resize(230, fName->GetDefaultHeight()); TString s; for (i = 0; fFileInfo->fFileTypes[i] != 0; i += 2) { s.Form("%s (%s)", fFileInfo->fFileTypes[i], fFileInfo->fFileTypes[i+1]); fTypes->AddEntry(s.Data(), i); } fTypes->Select(fFileInfo->fFileTypeIdx); // Show all items in combobox without scrollbar //TGDimension fw = fTypes->GetListBox()->GetContainer()->GetDefaultSize(); //fTypes->GetListBox()->Resize(fw.fWidth, fw.fHeight); if (fFileInfo->fFilename && fFileInfo->fFilename[0]) fTbfname->AddText(0, fFileInfo->fFilename); else fTbfname->Clear(); fTypes->GetListBox()->Resize(230, 120); fHftype->AddFrame(fLftypes, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 5, 2, 2)); fHftype->AddFrame(fTypes, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 0, 20, 2, 2)); fVf->AddFrame(fHftype, new TGLayoutHints(kLHintsLeft | kLHintsCenterY | kLHintsExpandX)); fHf->AddFrame(fVf, new TGLayoutHints(kLHintsLeft | kLHintsCenterY | kLHintsExpandX)); //--- Open/Save and Cancel buttons TGVerticalFrame *fVbf = new TGVerticalFrame(fHf, 10, 10, kFixedWidth); fOk = new TGTextButton(fVbf, new TGHotString((dlg_type == kKVFDSave) ? "&Save" : "&Open"), kIDF_OK); fCancel = new TGTextButton(fVbf, new TGHotString("Cancel"), kIDF_CANCEL); fOk->Associate(this); fCancel->Associate(this); fVbf->AddFrame(fOk, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 2, 2)); fVbf->AddFrame(fCancel, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 2, 2)); UInt_t width = TMath::Max(fOk->GetDefaultWidth(), fCancel->GetDefaultWidth()) + 20; fVbf->Resize(width + 20, fVbf->GetDefaultHeight()); fHf->AddFrame(fVbf, new TGLayoutHints(kLHintsLeft | kLHintsCenterY)); AddFrame(fHf, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 4, 4, 3, 1)); SetEditDisabled(kEditDisable); MapSubwindows(); TGDimension size = GetDefaultSize(); Resize(size); //---- position relative to the parent's window CenterOnParent(); //---- make the message box non-resizable SetWMSize(size.fWidth, size.fHeight); SetWMSizeHints(size.fWidth, size.fHeight, 10000, 10000, 1, 1); const char *wname = ((dlg_type == kKVFDSave) ? "Save As..." : (dlg_type==kKVFDOpen) ? "Open" : "Choose directory..."); SetWindowName(wname); SetIconName(wname); SetClassHints("FileDialog", "FileDialog"); SetMWMHints(kMWMDecorAll | kMWMDecorResizeH | kMWMDecorMaximize | kMWMDecorMinimize | kMWMDecorMenu, kMWMFuncAll | kMWMFuncResize | kMWMFuncMaximize | kMWMFuncMinimize, kMWMInputModeless); MapWindow(); fFc->DisplayDirectory(); fClient->WaitFor(this); }
sis3316_flash::sis3316_flash(const TGWindow *p, UInt_t w, UInt_t h, Bool_t *b) : TGMainFrame(p, w, h) { // use hierarchical cleaning SetCleanup(kDeepCleanup); if(b){ fBSetup = b; *fBSetup = kTRUE; } // main window icon and general setup SetWindowName("SIS3316 - Flash Programmer"); SetIconPixmap("sis1.png"); fClient->GetColorByName("green", this->green); fClient->GetColorByName("red", this->red); reboot_prevent_flag = 0; // vertical frame fVert1 = new TGVerticalFrame(this, GetDefaultWidth(), GetDefaultHeight()); AddFrame(fVert1, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY)); // VME FPGA Programming section fGrpVME = new TGGroupFrame(fVert1, "VME FPGA Programming"); // hints, left, right, top, bottom fVert1->AddFrame(fGrpVME, new TGLayoutHints(kLHintsExpandX, 5, 5, 20, 5)); fLblVMEImg = new TGLabel(fGrpVME, "VME FPGA Image"); fGrpVME->AddFrame(fLblVMEImg, new TGLayoutHints(kLHintsNormal, 0, 0, 10, 5)); fHor1 = new TGHorizontalFrame(fGrpVME); fGrpVME->AddFrame(fHor1, new TGLayoutHints(kLHintsExpandX)); fVMEImgPath = new TGTextEntry(fHor1, "test VME Image.bin"); fHor1->AddFrame(fVMEImgPath, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5)); fVMEImgPath->SetWidth(240); fButVMEBrowse = new TGTextButton(fHor1, "...", BTN_VME_BROWSE); fButVMEBrowse->ChangeOptions(fButVMEBrowse->GetOptions() | kFixedWidth); fButVMEBrowse->SetWidth(50); fButVMEBrowse->Associate(this); fHor1->AddFrame(fButVMEBrowse, new TGLayoutHints(kLHintsRight, 5, 5, 5, 5)); fButVMEProg = new TGTextButton(fGrpVME, "Program VME FPGA", BTN_VME_PROG); fButVMEProg->Associate(this); fGrpVME->AddFrame(fButVMEProg, new TGLayoutHints(kLHintsExpandX, 5, 5, 10, 15)); // ADC FPGA Programming section fGrpADC = new TGGroupFrame(fVert1, "ADC FPGA Programming"); //fVert1->AddFrame(fGrpADC, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 5, 5, 10, 5)); fVert1->AddFrame(fGrpADC, new TGLayoutHints(kLHintsExpandX, 5, 5, 20, 5)); // ADC1 fLblADC1Img = new TGLabel(fGrpADC, "ADC FPGA Image"); fGrpADC->AddFrame(fLblADC1Img, new TGLayoutHints(kLHintsNormal, 0, 0, 10, 5)); fHorADC1 = new TGHorizontalFrame(fGrpADC); fGrpADC->AddFrame(fHorADC1, new TGLayoutHints(kLHintsExpandX)); fADC1ImgPath = new TGTextEntry(fHorADC1, "test ADC Image.bin"); fHorADC1->AddFrame(fADC1ImgPath, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5)); fADC1ImgPath->SetWidth(240); fButADC1Browse = new TGTextButton(fHorADC1, "...", BTN_ADC1_BROWSE); fButADC1Browse->ChangeOptions(fButADC1Browse->GetOptions() | kFixedWidth); fButADC1Browse->SetWidth(50); fButADC1Browse->Associate(this); fHorADC1->AddFrame(fButADC1Browse, new TGLayoutHints(kLHintsRight, 5, 5, 5, 5)); fButADCProg = new TGTextButton(fGrpADC, "Program ADC FPGAs", BTN_ADC_PROG); fGrpADC->AddFrame(fButADCProg, new TGLayoutHints(kLHintsExpandX, 5, 5, 10, 15)); fButADCProg->Associate(this); #ifdef NOT_IMPLEMENTED // ADC2 fLblADC2Img = new TGLabel(fGrpADC, "ADC2 FPGA Image"); fGrpADC->AddFrame(fLblADC2Img, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 0)); fHorADC2 = new TGHorizontalFrame(fGrpADC); fGrpADC->AddFrame(fHorADC2, new TGLayoutHints(kLHintsExpandX)); fADC2ImgPath = new TGTextEntry(fHorADC2, "test ADC2 Image.bin"); fHorADC2->AddFrame(fADC2ImgPath, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5)); fADC2ImgPath->SetWidth(187); fButADC2Browse = new TGTextButton(fHorADC2, "...", BTN_ADC2_BROWSE); fButADC2Browse->ChangeOptions(fButADC2Browse->GetOptions() | kFixedWidth); fButADC2Browse->SetWidth(50); fButADC2Browse->Associate(this); fHorADC2->AddFrame(fButADC2Browse, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5)); // ADC3 fLblADC3Img = new TGLabel(fGrpADC, "ADC3 FPGA Image"); fGrpADC->AddFrame(fLblADC3Img, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 0)); fHorADC3 = new TGHorizontalFrame(fGrpADC); fGrpADC->AddFrame(fHorADC3, new TGLayoutHints(kLHintsExpandX)); fADC3ImgPath = new TGTextEntry(fHorADC3, "test ADC2 Image.bin"); fHorADC3->AddFrame(fADC3ImgPath, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5)); fADC3ImgPath->SetWidth(187); fButADC3Browse = new TGTextButton(fHorADC3, "...", BTN_ADC3_BROWSE); fButADC3Browse->ChangeOptions(fButADC3Browse->GetOptions() | kFixedWidth); fButADC3Browse->SetWidth(50); fButADC3Browse->Associate(this); fHorADC3->AddFrame(fButADC3Browse, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5)); // ADC4 fLblADC4Img = new TGLabel(fGrpADC, "ADC4 FPGA Image"); fGrpADC->AddFrame(fLblADC4Img, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 0)); fHorADC4 = new TGHorizontalFrame(fGrpADC); fGrpADC->AddFrame(fHorADC4, new TGLayoutHints(kLHintsExpandX)); fADC4ImgPath = new TGTextEntry(fHorADC4, "test ADC4 Image.bin"); fHorADC4->AddFrame(fADC4ImgPath, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5)); fADC4ImgPath->SetWidth(187); fButADC4Browse = new TGTextButton(fHorADC4, "...", BTN_ADC4_BROWSE); fButADC4Browse->ChangeOptions(fButADC4Browse->GetOptions() | kFixedWidth); fButADC4Browse->SetWidth(50); fButADC4Browse->Associate(this); fHorADC4->AddFrame(fButADC4Browse, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5)); fChkADCImgSelect = new TGCheckButton(fGrpADC, "ADC FPGAs have unique images"); fChkADCImgSelect->SetState(kButtonDown) ; // is ON ! fChkADCImgSelect->SetEnabled(kFALSE); // //fChkADCImgSelect->Associate(this); fGrpADC->AddFrame(fChkADCImgSelect); #endif //fGrpProgram = new TGGroupFrame(fVert1, "Programming"); //fVert1->AddFrame(fGrpProgram, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 10, 10, 0, 0)); fGrpBarProg = new TGGroupFrame(fVert1, "Programming progress"); // hints, left, right, top, bottom fVert1->AddFrame(fGrpBarProg, new TGLayoutHints(kLHintsExpandX, 5, 5, 20, 5)); fBar_prog = new TGHProgressBar(fGrpBarProg); fBar_prog->ShowPosition(kTRUE, kTRUE); fBar_prog->SetBarColor("blue"); fBar_prog->SetForegroundColor(0x000000); fGrpBarProg->AddFrame(fBar_prog, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 10, 10, 20, 10)); // hints, left, right, top, bottom fGrpBarVerify = new TGGroupFrame(fVert1, "Verifying progress"); // hints, left, right, top, bottom fVert1->AddFrame(fGrpBarVerify, new TGLayoutHints(kLHintsExpandX, 5, 5, 20, 5)); fBar_verify = new TGHProgressBar(fGrpBarVerify); fBar_verify->ShowPosition(kTRUE, kTRUE); fBar_verify->SetBarColor("blue"); fBar_verify->SetForegroundColor(0x000000); fGrpBarVerify->AddFrame(fBar_verify, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 10, 10, 20, 20)); // hints, left, right, top, bottom fGrpReboot = new TGGroupFrame(fVert1, "Reboot"); // hints, left, right, top, bottom fVert1->AddFrame(fGrpReboot, new TGLayoutHints(kLHintsExpandX, 5, 5, 20, 5)); fButReboot = new TGTextButton(fGrpReboot, "Reboot SIS3316 FPGAs", BTN_REBOOT); fButReboot->Associate(this); fButReboot->ChangeBackground(this->green); fGrpReboot->AddFrame(fButReboot, new TGLayoutHints(kLHintsExpandX, 5, 5, 10, 15)); fLabel_reboot_note = new TGLabel(fGrpReboot,"Note: the watchdog has to be enabled -> SW80-7 ON "); fLabel_reboot_note->SetTextJustify(kTextLeft + kTextCenterX ); fLabel_reboot_note->SetMargins(0,0,0,0); fLabel_reboot_note->SetWrapLength(-1); fGrpReboot->AddFrame(fLabel_reboot_note, new TGLayoutHints(kLHintsExpandX,2,2,15,2)); // draw everything SetWMSizeHints(w, h, w, h, 1, 1); Resize(GetDefaultSize()); // resize to default size MapSubwindows(); // initially hidden #ifdef NOT_IMPLEMENTED fGrpADC->HideFrame(fHorADC2); fGrpADC->HideFrame(fHorADC3); fGrpADC->HideFrame(fHorADC4); fGrpADC->HideFrame(fLblADC2Img); fGrpADC->HideFrame(fLblADC3Img); fGrpADC->HideFrame(fLblADC4Img); #endif MapWindow(); }
/* ARGSUSED */ static Boolean SetValues (Widget gcur, Widget greq, Widget gset, ArgList args, Cardinal *num_args) { XmPannerWidget cur = (XmPannerWidget) gcur; XmPannerWidget set = (XmPannerWidget) gset; Boolean redisplay = FALSE; if (cur->primitive.foreground != set->primitive.foreground) { ResetSliderGC (set); if (cur->primitive.foreground != cur->core.background_pixel) ResetXorGC (set); redisplay = TRUE; } else if (cur->core.background_pixel != set->core.background_pixel) { ResetXorGC (set); redisplay = TRUE; } if (XmPanner_rubber_band(cur) != XmPanner_rubber_band(set)) { ResetXorGC (set); if (XmPanner_tmp(set).doing) redisplay = TRUE; } if (XmPanner_resize_to_pref(set) && (XmPanner_canvas_width(cur) != XmPanner_canvas_width(set) || XmPanner_canvas_height(cur) != XmPanner_canvas_height(set) || XmPanner_resize_to_pref(cur) != XmPanner_resize_to_pref(set))) { GetDefaultSize (set, &set->core.width, &set->core.height); redisplay = TRUE; } else if (XmPanner_canvas_width(cur) != XmPanner_canvas_width(set) || XmPanner_canvas_height(cur) != XmPanner_canvas_height(set) || XmPanner_internal_border(cur) != XmPanner_internal_border(set)) { Rescale (set); /* does a scale_knob as well */ redisplay = TRUE; } else { Boolean loc = (XmPanner_slider_x(cur) != XmPanner_slider_x(set) || XmPanner_slider_y(cur) != XmPanner_slider_y(set)); Boolean siz = (XmPanner_slider_width(cur) != XmPanner_slider_width(set) || XmPanner_slider_height(cur) != XmPanner_slider_height(set)); if (loc || siz) { /* Fake it as though user has made a page movement; works as long ** as we don't get a callback now with different X and Y values */ /* note! siz does change from the porthole, but if the app changes ** it programmatically, then the value is off */ XmPanner_tmp(set).doing = TRUE; XmPanner_tmp(set).x = XmPanner_knob_x(set) + PANNER_HSCALE (set, XmPanner_slider_x(set) - XmPanner_slider_x(cur)); XmPanner_tmp(set).y = XmPanner_knob_y(set) + PANNER_VSCALE (set, XmPanner_slider_y(set) - XmPanner_slider_y(cur)); ActionNotify((Widget)set, NULL, NULL, 0); XmPanner_tmp(set).doing = FALSE; ScaleKnob(set,loc,siz); redisplay = TRUE; } } return redisplay; }
wxSize wxButton::DoGetBestSize() const { if ( GetId() == wxID_HELP ) return wxSize( 20 , 20 ) ; wxSize sz = GetDefaultSize() ; switch (GetWindowVariant()) { case wxWINDOW_VARIANT_NORMAL: case wxWINDOW_VARIANT_LARGE: sz.y = 20 ; break; case wxWINDOW_VARIANT_SMALL: sz.y = 17 ; break; case wxWINDOW_VARIANT_MINI: sz.y = 15 ; break; default: break; } #if wxOSX_USE_CARBON Rect bestsize = { 0 , 0 , 0 , 0 } ; m_peer->GetBestRect( &bestsize ) ; int wBtn; if ( EmptyRect( &bestsize ) || ( GetWindowStyle() & wxBU_EXACTFIT) ) { Point bounds; ControlFontStyleRec controlFont; OSStatus err = m_peer->GetData<ControlFontStyleRec>( kControlEntireControl, kControlFontStyleTag, &controlFont ); verify_noerr( err ); // GetThemeTextDimensions will cache strings and the documentation // says not to use the NoCopy string creation calls. // This also means that we can't use CFSTR without // -fno-constant-cfstrings if the library might be unloaded, // as GetThemeTextDimensions may cache a pointer to our // unloaded segment. wxCFStringRef str( !m_label.empty() ? m_label : wxString(" "), GetFont().GetEncoding() ); #if wxOSX_USE_ATSU_TEXT SInt16 baseline; if ( m_font.MacGetThemeFontID() != kThemeCurrentPortFont ) { err = GetThemeTextDimensions( (CFStringRef)str, m_font.MacGetThemeFontID(), kThemeStateActive, false, &bounds, &baseline ); verify_noerr( err ); } else #endif { wxClientDC dc(const_cast<wxButton*>(this)); wxCoord width, height ; dc.GetTextExtent( m_label , &width, &height); bounds.h = width; bounds.v = height; } wBtn = bounds.h + sz.y; } else { wBtn = bestsize.right - bestsize.left ; // non 'normal' window variants don't return the correct height // sz.y = bestsize.bottom - bestsize.top ; } if ((wBtn > sz.x) || ( GetWindowStyle() & wxBU_EXACTFIT)) sz.x = wBtn; #endif return sz ; }