Appcelerator change app color theme at runtime - appcelerator

I would like to create themes for my App - And by that what I want is that the user would be able to go to the app settings page and choose a different color scheme.
What I've done so far is to create my color "theme" as an object in alloy.js like this:
Alloy.Globals.Theme = {
WindowBackground: "#fafafa",
FontColor: "#383838",
ListItemSelectedColor: "#4ccedc",
.
.
.
};
And where I use colors in my TSS point to this object (which I will populate with the currect colors in runtime).
I have the feeling that this is not the best practice to go with.
And for this to actually change themes, the user would have to close and reopen the app. I've seen many apps where the user just selects the theme and the screen (and all screens that were before that one) immidiatly change the colors acourdingly.
What is the best practice to achive this? I was thinking something in the direction of a theme model but really not sure how to go about it.

Related

How does modifying text highlighting work?

We are all familiar with text highlighting. You hover over any "text" in any application on your Windows OS, your cursor changes into an I-Beam, and you can click and drag across the text to Highlight it. This highlighted text can be copied to the clipboard for later use.
Some applications modify the default highlighting behavior by changing color, opacity, or even shape. Some applications allow for column selection (e.g. Visual Studio "alt-click-drag" creates box like highlighting)
I have scoured the depths of the internet, but I can't seem to find a solid source of information that would explain how one would modify the behavior of text highlighting.
How would I implement column/block text selection, and modifying the appearance of the highlighted text in a compiled application.
Since applications can do this in various custom ways, there is no single solution to change how all of them style text selections.
Many will rely on the current color scheme (using GetSysColor) to determine the highlight colors. So you could modify the scheme and maybe affect the colors used for many applications.
To do this programmatically, you would use SetSysColors to change the COLOR_HIGHLIGHT and COLOR_HIGHLIGHTTEXT values.
Other applications might rely on the current theme (using GetThemeColor). To affect those you'd have to select a different theme that has the colors (and perhaps other styling choices) that you want.
A lot of apps use their own hard-coded color schemes, so you won't be able to programmatically at all.
I'm not sure what you mean with the web application part of your question. A web application is some HTML, JS and CSS that make the browser interact with your system. Any custom selection (coloring) logic that the web application provides, has to be implemented by the browser.
Also you have to realize that "(text) selection" is an rather virtual principle. An application can just render a colored shape (like a blue rectangle) and copy something to the clipboard when it receives a WM_COPY message.
Windows provides in basic substring selection functionality for (rich) edit controls (i.e. start and end position), but for something custom like column selection, custom code is required.
Read more about this in Making a rectangular selection in a RichTextBox with Alt-Left-Mouse sweep?.

How to save Xcode Window Layout and Size

I've got my workspace windows set up like this:
Then I Navigate away from my story board to replace the left window with some code so i Can compare two code documents like this:
When I navigate back to my storyboard, it resets the document outline column to this:
How the frak do I configure window sizing presets? Coming from an Adobe background I'm used to having a preference somewhere that allows me to save interface layouts and sizing presets. The closest thing I can find is "behaviors", but this doesn't seem to control the sizing of columns and windows.
Seems like the best way to handle this is by using "Tabs"
I found this very helpful blog post.

Is there a way to use default "icons" in ckeditor plugins?

I did a plugin that basically allows to create link with some business logic (People enters an id and a link is magically created for them). So I can specify an icon for it no problem there but I love the default "link" icons that comes with the monoo skins...
Is there a way to simply (re)use it ?
Just to make sure it's clear, I'm talking about the icons.png sprite that includes the main "toolbar" icon
Lets say your plugin is called 'newlink'.
You should add to the editor.css of your current skin a css rule like:
a.cke_button .cke_button__newlink_icon{
background : url(icons.png) 0 -1248px no-repeat;
}
(that specific coords are in fact the ones for the link icon of the moono 'icons.png' theme. Other themes may have another, or even another path to the icons file).

MFC colored button with native win7 appearance

I am using MFC to create a dialog project and trying to impart color to the buttons.
I came to know that the only way you can do is to make the button owner draw. OnCtlColor() does not work for buttons.
I am able to color the button overriding OnDrawItem , but the problem is that , in the process the 3D cool look (with slightly rounded corner that you get in Win7) is lost.
Is there any way to retain the native look and color the button on top of that?
This is not a trivial task. As long as you are using themed controls (what you want), you cannot do more than the theme allows.
You would have to re-implement drawing of the button on your own, making use of the theme API as much as possible to retain themed look, yet sneak-in your color.
Though note that you can hardly achieve anything better than, what .NET WinForms do, when you set the Button.BackColor:
See also question how to set Button BackColor?
Disassembling the WinForms ButtonStandardAdapter.PaintWorker will give you some idea and API you need to use. Beware, you need to do lots of coding!
For C++/MFC code check out Vista themed Owner-Drawn and Full-Custom Push/Menu/Image Buttons on CodeProject. Which probably actually does, what you want already (the SetBackgroundColor method), so you might reuse it.

How to add a NSColorPicker to the application's main window?

I'm building an application to generate an array of colors based on a color chosen by the user.
The default on Mac OS X for color selection is to open a NSColorPanel containing multiple NSColorPickers. But, as the color selection process is the main interaction the user will have with the app, it'd be better to avoid the extra clicks and panel-popping in favor of a more straightforward way.
So, is there any way to add a NSColorPicker object to a window?
I know this is an older question, but check out NSColorWell. From the docs:
NSColorWell is an NSControl for selecting and displaying a single color value.
Interresting Question.
I strongly doubt it (but would love to be proven wrong). NSColorPickers are not NSControls (nor NSCells) so there's no clean wrapper to insert into a window.
Even if you were to instanciate an NSColorPanel and get a reference to its contentView and copy it (with all that defines the color picking controls) to your own window... there's no obvious way of obtaining the color value. NSColorPickers are plug-ins so you can't forsee the controls of a colorPicker.
The only other way I can see (and that's a stretch) would be to manually load the NSColorPickers plug-ins directly. I don't know how successfull this would be.
File a bug report and request the feature?

Resources