Set display font family in wxhaskell? - haskell

I'm trying to build a little program to learn some wxHaskell, a haskell library for wxwidgets.
It would be beneficial for this particular one if I could set the font of a text field to monospaced, but I have no idea how to do that if it is possible.
In wxwidgets there seems to be setFamily and wxFONTFAMILY_TELETYPE, but I can't find anything about this being implemented in wxHaskell, nor how to use it if it were.
Is it possible to do this?

Here's an example, in the change the line in the Hello, World program in the wxHaskell Quick Start from:
= do f <- frame [text := "Hello!"]
to
= do f <- frame [text := "Hello!", font := fontFixed]
Found this by digging down in the docs here

Related

AUTOHOTKEY changing WS_EX_CLIENTEDGE color

How can I custom specify, or force, the color of WS_EX_CLIENTEDGE [+E0x200]? I want a much more toned down color for it.
CustomColor := 000055
RequestToDisplay := "I want to change the color of WS_EX_CLIENTEDGE"
RequestTitle := "[REQUEST]"
GUI Request:FONT, s9 w1000 Q5, Verdana
GUI Request:COLOR, %CustomColor%, 000001
GUI Request:Add, EDIT, vMyAddress cFFFFFF r3 w400 xp-11 yp-0 -VScroll Multi WantTab t8 +E0x200 +Left
GUI Request:+LastFound +AlwaysOnTop -Caption -SysMenu
GUI Request:MARGIN, 0, 0
GUI Request:SHOW, x200 y300, %RequestTitle%
ControlSend, Edit1, %RequestToDisplay%, %RequestTitle%
return
ESC::ExitApp
or you might be looking for one of the parameter specified in https://msdn.microsoft.com/en-us/library/windows/desktop/ms724371(v=vs.85).aspx
for instance, see COLOR_ACTIVEBORDER
and for autohotkey SetSysColors dllcall see https://autohotkey.com/board/topic/36724-setsyscolors-set-system-colors/
hope this helps
steph
CP,
to my understanding, WS_EX_CLIENTEDGE is a window style (https://msdn.microsoft.com/en-us/library/windows/desktop/ff700543(v=vs.85).aspx).
to change the color of the edge that this window style produces, is an entire other question.
i would not know how to formulate this precise question.
but looking at your autohotkey code (AUTOHOTKEY changing WS_EX_CLIENTEDGE color), i see that CustomColor := 000055, to me it looks like an hexadecimal color value specified in a decimal way, that is without the 0x prefix (but that would be mandatory in C/C++)
SP.
in my C/C++ understanding one changes window's elements color calling SetSysColors() function see https://msdn.microsoft.com/en-us/library/windows/desktop/ms724940(v=vs.85).aspx for an example.
in that example, COLOR_ACTIVECAPTION is used to specify the window border element's color, it might be the one you are looking for.

What is the right way to render Cairo updates in Gtk2hs?

I'm writing a Haskell program with click-and-drag functionality, so with each mouse movement event an update gets painted to the window. At the moment I'm using
renderWithDrawable myCanvas update
However this is flickering a lot. My understanding is that I need to create a separate drawable (a "surface"?), render to that, and then blit it onto the screen window in a single operation. However I'm confused as to the right way to do this.
I've found drawWindowBeginPaintRegion, which talks about eliminating flicker.
However it is removed in Gtk3 according to the Haddock docs. So I'm not sure if I should use this, as it seems to be deprecated.
I've also found renderWithSimilarSurface in Cairo, which seems to do something similar.
I'm also not sure how these functions relate to renderWithDrawable: do I have to use them inside that function, or what?
What is the right way to do this?
Edit
This seems to be a known thing in Cairo. I'm trying to figure out how to handle this in Haskell.
Explanation and solution in Python
Description of how to handle this issue in raw C
The right way to do this is to make sure all your drawing comes from within expose events, and operates on the draw window provided by the event. You can mark a region as "dirty" and trigger a synthetic expose event using drawWindowInvalidateRect, drawWindowInvalidateRegion, or widgetQueueDraw.
A quick worked example of setting up the drawing pipeline follows. It is excerpted from a custom Viewport type, which does Google-maps style panning with smooth motions on drag-and-release operations, that I built for a side-project some time ago. To support that, it has to redraw on mouse motion events, so it addresses a similar use case to your described problem. I've elided irrelevant stuff with ... to highlight the important bits. I've uploaded the complete project to github just now, so you can browse the repo to see the full details of Viewport. (It's been years though, so there's probably a fair bit of bitrot -- don't expect the project to just build and run with modern GHCs/packages.)
viewportNew :: Viewport -> IO DrawingArea
viewportNew v = do
da <- drawingAreaNew
-- ...
on da exposeEvent $ exposeViewport posRef (draw v)
-- ...
exposeViewport :: IORef Position -> RegionRenderer -> EventM EExpose Bool
exposeViewport posRef draw = do
dw <- eventWindow
region <- eventRegion >>= liftIO . regionGetRectangles
-- ...
liftIO . renderWithDrawable dw $ do
-- Cairo () action goes here
-- can reference region to decide which things to draw
draw region
return True -- see documentation of exposeEvent for what this means
This template should take advantage of gtk's built-in double-buffering and work with both the gtk and gtk3 packages.

Making SVG plots in R; why the need for X11?

I've been looking around for an answer for this. I seem to gather that some sort of X11 (or a virtual frame buffer) is always required for plotting.
However I do not understand why that is needed for SVG graphics, seems like I should even be able to create them manually, so why does R seem to always need the X11?
I imagine that the X11 performs some functionality, like selecting colors from a palette or something like that. Is that the case? if not, how can I avoid the X11 completely.
I'm using ggplot2 to make a plot and gridSVG to extract it as in:
plot <- ggplot(data=data, aes(...)) + ...
print(plot)
mysvg <- grid.export()

Set legend text's HorizontalAlignment to left in octave

I have legend text that in matlab behaves as
set(gcf,'DefaulttextHorizontalAlignment','left');
now I am attempting to replicate this in octave, but for some reason octave seems to ignore the above command.
I am using cygwin Xwin octave and GNUPlot.
(I am not trying to move the text to the other-side of the "line" legend('left'))
Doing some tests, it turns out that I can set the property, but it isn't affecting anything.
LegendHandle = legend( phvec, legendvec, 'Location', 'NorthEastOutside' );
legtxt=findobj(LegendHandle,'type','text');
get(legtxt(1),'HorizontalAlignment') %% returns left
It seems Gnuplot supports the option to change the legend horizontal alignment, but Octave doesn't provide the access to this function in Gnuplot (although it works with FLTK). You simply can't do anything about it, except filing a feature request on the Octave tracker.
Source: http://octave.1599824.n4.nabble.com/set-horizontalalignment-for-legend-text-td2218246.html
So yes, there's currently no solution to left align the legend text using gnuplot, the only thing you can do to remove this awful blank space is, as you said, to use legend('left') to swap the text to the left of the symbols.
I can replicate your problem but only if using gnuplot. It works with other graphics toolkits.
While gnuplot was Octave's default graphics toolkit for a long time, the Octave developers have been slowly replacing it with their own alternative in order to avoid its limitations. I believe recent versions of Octave will already default to fltk but you can change it yourself:
octave-cli-3.8.1> graphics_toolkit fltk
octave-cli-3.8.1> graphics_toolkit # confirm
ans = fltk
octave-cli-3.8.1> x = 0:0.1:10;
octave-cli-3.8.1> figure;
octave-cli-3.8.1> plot (x, [sin(x); cos(x)]);
octave-cli-3.8.1> legend ("long sin", "cos", "Location", "NorthEastOutside");

How can I make a custom layout / change header background color … with Tex, Latex, ConTeXt?

currently I produce dynamically this document with Python Report Labs… to produce pdf documents.
Now, I would like try to produce this document with Tex / Latex / ConTeXt…
I've some questions :
how can I make the layout ?
how can I make header background color ?
how can I define my custom title (with blue box) ?
what is the better choice for my project : Latex or ConTeXt ?
What package I need to use ?
geometry ?
fancyhdr ?
Have you some example ? some resource ?
Yesterday, I've read many many documentation… and I don't found a solution / example for my questions.
Some useful packages apart from the fancyhdr you already mentioned are:
titlesec for more control over your section titles
booktabs for more control over table layout
PGF/TikZ for the graphics in your document, i.e., the page turn effect in the corner and maybe the blue boxes (although that might be considered a bit overkill :))
memoir for more control over your document layout, but the package is more book-oriented than you need probably
koma-script might be a good alternative for memoir but I'm not familiar with it so I don't know about its weaknesses
This is list is not exhaustive and I am not experienced enough in this kind of typesetting meets lay-out stuff to be of much help, but these are packages that come to my mind given your problem :).
Using inputenc there shouldn't be a problem typesetting Russian text.
Maybe the actual process will be easier in ConTeXt, it is more oriented towards control over your typesetting but I'm not familiar with it.
Good luck!
I'd certainly do this kind of think in Context rather than Latex: Context permits grid layout, and allows you to define layers for putting text and other graphics on top of background graphics. But as Pieter says, you could try using TikZ to do this with Latex.
Unicode is no barrier to regular Latex or Context: with either, just specify that you want to use utf-8 as input encoding.
If you do use Latex, don't have headers or footers, and allocate no vertical space for them either.
With Context:
how can I make the layout? — Use grid layout.
how can I make header background color? — Use \setupbackground
how can I define my custom title (with blue box) ? — I don't understand what you want to do here.
Everything you need to do this, except grid mode and how to put graphics in the background, is documented in Context an excursion. Grid mode is explained in the Context manual. Layers are a bit tricky to get to grips with, but Layers in the Context wiki is a good place to start.
With titlesec and color packages use this in LaTeX head (before \begin{document})
\usepackage{titlesec}
\usepackage{color}
% Colors
\definecolor{textcolor}{rgb}{.90,.95,1}
\definecolor{boxcolor}{rgb}{.94,.97,1}
% Header style
\titleformat{\section}
{\color{textcolor}\normalfont\Large\bfseries}
{}{1em}{{\color{boxcolor}\rule{0.35cm}{0.35cm}}\quad}
to make the blue box and change header color, font and remove numbering.

Resources