@@ -2637,10 +2637,78 @@ void MCCard::drawcardborder(MCDC *dc, const MCRectangle &dirty)
26372637// -----------------------------------------------------------------------------
26382638// Redraw Management
26392639
2640- void MCCard::draw (MCDC *dc, const MCRectangle& dirty, bool p_isolated)
2640+ // IM-2013-09-13: [[ RefactorGraphics ]] Factor out card background drawing to separate method
2641+ void MCCard::drawbackground (MCContext *p_context, const MCRectangle &p_dirty)
26412642{
2643+ if (MCcurtheme != nil && getstack () -> ismetal () && MCcurtheme -> drawmetalbackground (p_context, p_dirty, rect, parent))
2644+ return ;
2645+
2646+ // IM-2013-09-13: [[ RefactorGraphics ]] [[ Bug 11175 ]] Rework card background drawing to handle transparent background patterns
2647+ // transparent backgrounds will now draw on top of the stack background, which in turn draws on top of solid black if transparent
2648+ MCColor color;
2649+ MCPatternRef t_pattern = nil;
2650+ int2 x, y;
2651+
2652+ MCPatternRef t_stack_pattern = nil;
2653+ int16_t t_stack_x, t_stack_y;
2654+
26422655 Window_mode wm = getstack ()->getmode ();
26432656
2657+ Boolean t_hilite;
2658+ t_hilite = MClook == LF_WIN95 && (wm == WM_COMBO || wm == WM_OPTION);
2659+
2660+ bool t_opaque;
2661+ t_opaque = getforecolor (DI_BACK, False, t_hilite, color, t_pattern, x, y, p_context, this ) || MCPatternIsOpaque (t_pattern);
2662+
2663+ // If the card background is a pattern with transparency, then draw the stack background first
2664+ if (!t_opaque)
2665+ {
2666+ t_opaque = parent->getforecolor (DI_BACK, False, t_hilite, color, t_stack_pattern, t_stack_x, t_stack_y, p_context, parent) || MCPatternIsOpaque (t_stack_pattern);
2667+
2668+ // And if the stack background is a pattern with transparency, then fill with black first
2669+ if (!t_opaque)
2670+ {
2671+ p_context->setforeground (p_context->getblack ());
2672+ p_context->setfillstyle (FillSolid, nil, 0 , 0 );
2673+ p_context->fillrect (p_dirty);
2674+ }
2675+
2676+ if (t_stack_pattern != nil)
2677+ p_context->setfillstyle (FillTiled, t_stack_pattern, t_stack_x, t_stack_y);
2678+ else
2679+ {
2680+ p_context->setforeground (color);
2681+ p_context->setfillstyle (FillSolid, nil, 0 , 0 );
2682+ }
2683+
2684+ p_context->fillrect (p_dirty);
2685+ }
2686+
2687+ if (t_pattern != nil)
2688+ p_context->setfillstyle (FillTiled, t_pattern, x, y);
2689+ else
2690+ {
2691+ p_context->setforeground (color);
2692+ p_context->setfillstyle (FillSolid, nil, 0 , 0 );
2693+ }
2694+
2695+ p_context->fillrect (p_dirty);
2696+ }
2697+
2698+ // IM-2013-09-13: [[ RefactorGraphics ]] Factor out card selection rect drawing to separate method
2699+ void MCCard::drawselectionrect (MCContext *p_context)
2700+ {
2701+ p_context->setlineatts (0 , LineDoubleDash, CapButt, JoinBevel);
2702+ p_context->setforeground (p_context->getblack ());
2703+ p_context->setbackground (p_context->getwhite ());
2704+ p_context->setdashes (0 , dashlist, 2 );
2705+ p_context->drawrect (selrect);
2706+ p_context->setlineatts (0 , LineSolid, CapButt, JoinBevel);
2707+ p_context->setbackground (MCzerocolor);
2708+ }
2709+
2710+ void MCCard::draw (MCDC *dc, const MCRectangle& dirty, bool p_isolated)
2711+ {
26442712 bool t_draw_cardborder;
26452713 t_draw_cardborder = true ;
26462714
@@ -2649,12 +2717,8 @@ void MCCard::draw(MCDC *dc, const MCRectangle& dirty, bool p_isolated)
26492717 if (MCcurtheme != nil && getstack () -> menuwindow &&
26502718 MCcurtheme -> drawmenubackground (dc, dirty, getrect (), true ))
26512719 t_draw_cardborder = false ;
2652- else if (MCcurtheme == nil || !getstack () -> ismetal () ||
2653- !MCcurtheme -> drawmetalbackground (dc, dirty, rect, parent))
2654- {
2655- setforeground (dc, DI_BACK, False, MClook == LF_WIN95 && (wm == WM_COMBO || wm == WM_OPTION));
2656- dc -> fillrect (dirty);
2657- }
2720+ else
2721+ drawbackground (dc, dirty);
26582722
26592723 if (objptrs != NULL )
26602724 {
@@ -2675,15 +2739,7 @@ void MCCard::draw(MCDC *dc, const MCRectangle& dirty, bool p_isolated)
26752739 drawcardborder (dc, dirty);
26762740
26772741 if (getstate (CS_SIZE))
2678- {
2679- dc->setlineatts (0 , LineDoubleDash, CapButt, JoinBevel);
2680- dc->setforeground (dc->getblack ());
2681- dc->setbackground (dc->getwhite ());
2682- dc->setdashes (0 , dashlist, 2 );
2683- dc->drawrect (selrect);
2684- dc->setlineatts (0 , LineSolid, CapButt, JoinBevel);
2685- dc->setbackground (MCzerocolor);
2686- }
2742+ drawselectionrect (dc);
26872743}
26882744
26892745// /////////////////////////////////////////////////////////////////////////////
0 commit comments