import java.util.function.Supplier;
import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Device;
import net.haspamelodica.swt.helper.gcs.GeneralGC;
import net.mograsim.preferences.ColorDefinition;
{
public static void executeWithDifferentForeground(GeneralGC gc, ColorDefinition col, Runnable exec)
{
- executeWithDifferentColor(gc.getDevice(), col, gc::getForeground, gc::setForeground, exec);
+ executeWithDifferentColor(col, gc::getForeground, gc::setForeground, exec);
}
public static void executeWithDifferentBackground(GeneralGC gc, ColorDefinition col, Runnable exec)
{
- executeWithDifferentColor(gc.getDevice(), col, gc::getBackground, gc::setBackground, exec);
+ executeWithDifferentColor(col, gc::getBackground, gc::setBackground, exec);
}
- private static void executeWithDifferentColor(Device device, ColorDefinition col, Supplier<Color> getColor, Consumer<Color> setColor,
- Runnable exec)
+ private static void executeWithDifferentColor(ColorDefinition col, Supplier<Color> getColor, Consumer<Color> setColor, Runnable exec)
{
ColorManager cm = ColorManager.current();
Color oldColor = getColor.get();
- Color newColor = cm.toColor(device, col);
+ Color newColor = cm.toColor(col);
setColor.accept(newColor);
exec.run();
setColor.accept(oldColor);
- cm.dispose(newColor);
}
private ColorHelper()