How do you use modify the color definitions for a Google Calendar to allow custom colors for events? - api

I'm using the Google Calendar API to create new events. It appears the only method to assign a color to an event is with a colorID (1 to 11) that looks up the specific color from the table.
The default 11 color palette isn't exactly ideal for my needs so I would like to change it but I haven't been able to figure out how. The documentation explains how to obtain these lookup tables and but I can't figure out how to modify them. I assume they can be modified as there is a timestamp in the structure for the last time it was modified.
Anybody know how to modify the colorID table for events?

I know this thread is old, but the answer to the question is that you can't edit the set Event colors. The new custom colors in the new API only correlate with the Calendar color itself, not the Events contained within.
Why Google would only make some of the colors customizable, and not all beats me. Until they realize the desire for more colors it would appear we are stuck with good ol' 1-11.

Added detail from bounty:
I have the same question. I would like to be able to set a custom color for events that I post to the calendar, but don't want to be
limited by the 11 choices. I see in the docs they have added an
additional color setting method
(https://developers.google.com/google-apps/calendar/v3/whats-new#custom_colors_f‌​or_calendars).
But I'm unclear on the concept of how to go about it.
This part of the documentation demonstrates these properties directly: https://developers.google.com/google-apps/calendar/v3/reference/calendarList/insert
Which will let you add and modify your personal calendar as a demo (scroll to the bottom and try out the API Explorer). To do what you are asking on here, set colorRgbFormat=true then add the backgroundColor or foregroundColor properties with the specified color.
You end up with a request which looks like:
POST https://www.googleapis.com/calendar/v3/users/me/calendarList?colorRgbFormat=true&key={YOUR_API_KEY}
Content-Type: application/json
Authorization: Bearer xxxx
X-JavaScript-User-Agent: Google APIs Explorer
{
"id": "SomeCalendarItem",
"backgroundColor": "#444444"
}
Note: I think this answers the bounty question - which is different from what the OP asked, but might be what the OP wanted - #Wescotte, please advise if this solves (or doesn't) your issue as well.

Related

UILables, Text Flow and Layouts

Consider the following, I have paragraph data being sent to a view which needs to be placed over a background image, which has at the top and the bottom, fixed elements (fig1)
Fig1.
My thought was to split this into 4 labels (Fig1.example2) my question here is how I can get the text to flow through labels 1 - 4 given that label 1,2 & 3 ar of fixed height. I assumed here that label 3 should be populated prior to 4 hence the layout in the attached diagram.
Can someone suggest the best way of doing this with maybe an example?
Thanks
Wish I could help more, but I think I can at least point you in the right direction.
First, your idea seems very possible, but would involve lots of calculations of text size that would be ugly and might not produce ideal results. The way I see it working is a binary search of testing portions of your string with sizeWithFont: until you can get the best guess for what the label will fit into that size and still look "right". Then you have to actually break up the string and track it in pieces... just seems wrong.
In iOS 6 (unfortunately doesn't apply to you right now but I'll post it as a potential benefit to others), you could probably use one UILabel and an NSAttributed string. There would be a couple of options to go with here, (I haven't done it so I'm not sure which would be the best) but it seems that if you could format the page with html, you can initialize the attributed string that way.
From the docs:
You can create an attributed string from HTML data using the initialization methods initWithHTML:documentAttributes: and initWithHTML:baseURL:documentAttributes:. The methods return text attributes defined by the HTML as the attributes of the string. They return document-level attributes defined by the HTML, such as paper and margin sizes, by reference to an NSDictionary object, as described in “RTF Files and Attributed Strings.” The methods translate HTML as well as possible into structures of the Cocoa text system, but the Application Kit does not provide complete, true rendering of arbitrary HTML.
An alternative here would be to just use the available attributes, setting line indents and such according to the image size. I haven't worked with attributed strings at this level, so I the best reference would be the developer videos and the programming guide for NSAttributedString. https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/AttributedStrings/AttributedStrings.html#//apple_ref/doc/uid/10000036-BBCCGDBG
For lesser versions of iOS, you'd probably be better off becoming familiar with CoreText. In the end you'll be rewarded with a better looking result, reusability/flexibility, the list goes on. For that, I would start with the CoreText programming guide: https://developer.apple.com/library/mac/#documentation/StringsTextFonts/Conceptual/CoreText_Programming/Introduction/Introduction.html
Maybe someone else can provide some sample code, but I think just looking through the docs will give you less of a headache than trying to calculate 4 labels like that.
EDIT:
I changed the link for CoreText
You have to go with CoreText: create your AttributedString and a CTFramesetter with it.
Then you can get a CTFrame for each of your textboxes and draw it in your graphics context.
https://developer.apple.com/library/mac/#documentation/Carbon/Reference/CTFramesetterRef/Reference/reference.html#//apple_ref/doc/uid/TP40005105
You can also use a UIWebView

Simplest possible way to show two items NSTableView from code?

How I can create a code in XCode 4.2.1 what will create NSTableView and add just couple of items to it?
All what I wanted to do is:
1) Window where is NSTableView
2) I have an array of strings in NSArray which I like to show in that NSTableView
3) All of this should be done in code. So I don't want to learn how to add this action happen when you press button (I know already how to do actions when user click buttons etc), I just want that application launch -> draws the table where is those items from my array. That's it, nothing more.
And yeah I have understood that I do not add items to NSTableView directly. That is not the point in this question. I just mean that I want to show couple of items in that table but I have no and kind of clue WHERE I should add my data from my array.
I have tried to google for example pages for hours (just too many and have not find help) but I will always be stucked in the part when
a) I must do something in the Interface Builder and the images of the interface builder are from version 2.x or 3.x and I have 4.2.1 and it is totally different (new to XCode...). Surely I have drawn my TableView element to UI but I mean delegations etc. Are those necessary at all? Can those be made from source code?
b) Code just does not work anymore because language (Cocoa or Objective-C, I don't know) has changed and I don't know how and what I have to do to make it work on newest version of XCode.
c) There is too much different ways told: "use binding", "you must create new class what is NSTableViewDataSource" etc. I have no any kind of clue what is preferred way, is another way optional or it is "you should use this because another is going deprecated soon" or something.
So please, can somebody give help in step-by-step what I exactly have to do? Should I create some bindings? If so, how and where? Do I have to create DataSource component myself? Are those ways valid any more? If I have to, how I can create it? Create a new class and implement it as a NSTableViewDataSource and then use it? Is that way valid any more and if it is, can sombody show code what is as simple as possible?
I have also checked Apple Documentation page many many times, checked those example codes but there is just too much totally unrelated stuff that I just don't understand at this point so they are totally useless (I mean, I don't know what is required for this task, what are not etc.
I would be very happy if somebody can help short tutorial step-by-step what to do. I mean "step-by-step" like:
1) Create new project
2) Draw NSTableView in project
3) Create new class with this name
4) Write this code: blah blah blah
5) Create another class with this name
6) Write this code
7) Run and see those items from array in NSTableView using (bindings/datasource/whatever is preferred).
Thanks :)
Your tableview needs a datasource. Your datasource is a custom class, it implements the "NSTableViewDataSource" protocol. This protocol contains a few methods that you can use to tell the tableview what data you got.
this includes the objectValue ( the value of the NSCell that is displaying your data on the specified row, and a method that returns the amount of rows the tableview has ( the amount of items in your array ).
Here a tutorial I found by googling:
CocoaDev.com NSTableView tutorial
You can also implement the NSTableViewDelegate protocol which allows some greater control. Like what rows you can select, or some extra configuring of a custom tableview cell.
I must say that back in the day when I started developing desktop applications ( only had experience with web technologies ) that this design pattern confused me as well. Hope you will get your mind round it soon.

Simulate "Slide to Unlock" in MobileSubstrate

There is a way to simulate the Slide To Unlock in the lockscreen? I've been looked for this in SBAwayController, but without any results :( Have anyone an idea?
I believe (if I understand your question correctly) you want to have the lockbar "unlock itself". For something like that you want to look into SBAwayView, not SBAwayController. In that class there are different methods that interact with the different lockbars. You will want to specifically look at the SBAwayLockBar which is a sublcass of TPBottomLockBar (defined in <TelephonyUI/TPBottomLockBar.h>)
You will have to poke around in the headers and see if there is any way to access the lockbar's Knob position.
Hope that helped at least a bit.

Example for custom Range in Gtkmm

I am working on a Potentiometer style widget in Gtkmm and I'd like to use Range as the baseclass.
Does anyone know of a proper example for doing this?
I'm not sure exactly what you're asking for. I know that there is a simple example of using the range widget here. It does handle the creation of the Adjustment object that you'll need. You'll need to define an abstract potentiometer class, then create your vertical and/or horizontal potentiometers separately for flexibility.
The closest thing that I could find to an example of what you'd need to override in order to make your own custom range-like widget is on Old Nabble.
I wish that I could give you more help with this, but I'm rather new to Gtkmm.

Removing Directions markers from the Google Maps API V3

To remove a normal marker from a map, I understand you simply call marker.setMap(null), but when implementing the Google Maps directions services, it automatically adds markers A and B onto the map ( calculating directions from point A to point B ). I do not have control over these markers, so I cannot remove them in the normal way. So how can I remove these markers (I have custom markers on the map instead)?
Set the suppressMarkers option to true when creating your DirectionsRenderer object and then the markers won't show up. You could also change the style or icon of the markers. See the API spec for DirectionsRendererOptions for other properties you can set.
...
directionsDisplay = new google.maps.DirectionsRenderer({suppressMarkers: true});
...
EDIT: It looks like the API changed a little bit since my original answer almost 6 years ago, so the answer from #joni-jones is now the correct way. I tweaked my example above to reflect that.
I had a similar problem. The previous solution did not help me. But I tried this:
var directionsDisplay = new google.maps.DirectionsRenderer({suppressMarkers: true}); And it's work.