How should I print a receipt of a transaction in Objective-C? - objective-c

I've looked up a couple of documents but I was just hoping to get a general idea here.
I want to be able to print off an invoice once a sale has been made. My client will provide me with a specified paper size, also indicating that the paper will have default info on it (ie company name, address, phone number, etc.)
I'm wondering what the best method would be to print off an invoice that could have many items on it - possibly so many that it goes off of the paper my client provides, necessarily onto a new paper.
Now I've looked into NSView, NSPrintOperation, and NSPrintInfo, which I believe I'll definitely be making use of, but is it possible to draw the view behind the scenes? I'm also questioning the best method to store that receipt locally, as possibly a PDF?

You can make use of NSView , NSPrintInfo and NSPrintOperation. and Yes NSView will take care of drawing while printing. (You can differentiate the context i.e either screen or printer).
To save as a PDF, have a look at NSPrintOperation methods (PDFOperationWithView:) which helps to create PDF Data that can be saved to disk.

Related

How to create a list which sorts its self like games with the animation

I am creating a game in flutter in which I want to create my leader board page in which I want to achieve the list like Reorderable widget but in that we drag the tile manually but I need to get it automate ,it should elevate and lower another tiles same animation like Reorderable list but it should be automated
I hope I will find some solution with large community
You can take a look at the AnimatedList in Flutter: https://api.flutter.dev/flutter/widgets/AnimatedList-class.html
When a new value is inserted (or removed), it is automatically animated (and you can of course customize this animation to suit your needs).
I'm not sure how you would handle moving an item from one place to the next in the list, though.
Update
I found this other SO thread which mentions the great_list_view package, in which you can just update your underlying list (with the new score, or sort it again) and it will automatically animate it for you. That sounds like a good option, and the package has recently been updated and has a decent amount of likes on pub.
https://pub.dev/packages/great_list_view

Audio player with predetermined songs, and page transitions. best language

My dad's birthday is coming up. As a child/youth he recorder music of the radio (as many did then) and catalogued them.
I want to create a audio player that displays the songs similar to the way he wrote them ( image linked at bottom).
Has a play all for that page but also has the function to play individual songs.
If possible I would like a page turn animation when switching between pages.
I wold like it to be possible to jump to certain pages e.g page a, page b etc.
I have seen how to create simple media players where you open a file. However I haven't been able to see what I am after.
The layout I am thinking of is the song list top, and Controls at bottom.
My question(s) is which language is best for this and how best to go about doing this?
Any help would be greatly appreciated.
Thought I'd best add that I do not know programming and will be learning what I need for this project as I go. So if possible could you explain your help or indicate which part of it I will need to Google.
UPDATE
Thank you for the replies. I went with VB as suggested and would love some feedback if nobody minds. As I learned more I kept changing my design so it has taken a while to get back to you.
My plan now is to:
*Implement any changes recommended
*Change a little of the gui -
+Change the image of the Insert Tape and Play tape buttons
+Remove the Window media player (Mark not visible) and polish off the control buttons
*Use FormB as the template for the rest of the pages
*Look into compiling the program
+Test on second computer and laptop
+ Possible test on my brothers computer if he is willing to download it
As well as putting the code here I have uploaded the project to Dropbox. There are two version. With music files (62.8 MB and without 5.75 MB. Please note the files are not the copyrighted songs I have substituted them with royalty free alternatives (please see below for attribution). I I changed the file names instead of code to make it easier should I forget to change it back.
Ok the code was too long to add in so uploaded it to GithubGist
FormB vb https://gist.github.com/Phoenix830/6cc03bc9bb54bdd98aaf4641acaef075
FormB.Designer VB https://gist.github.com/Phoenix830/3f347129ebc7c4d5410c9b44a7df9a81
Custom Controls -
Lab_But vb https://gist.github.com/Phoenix830/d7bd00b16e08f116dbf12159e3d464af
Trackbar vb https://gist.github.com/Phoenix830/4e90cf4df9a3ed694e4b9aa3dc60ead6
Zip files
No music https://www.dropbox.com/s/vdjlc1648qi4bpd/Cassette%20Tapes%20-%20No%20Music.rar?dl=0
With Music https://www.dropbox.com/s/i1m5zh0449385zn/Cassette%20Tapes.rar?dl=0
I think that is everything about my current code. This is Attributes and source notes.
Music
Title Kevin MacLeod (incompetech.com)
Licensed under Creative Commons: By Attribution 3.0
http://creativecommons.org/licenses/by/3.0/
01-Barry_Manilow_-_Mandy.mp3 = Arroz Con Pollo.mp3
02-Barry_Manilow-New_York_City_Rhythm = Cheery Monday.mp3
03-Barry_Manilow_-_Looks_Like_We_Made_It = Galway.mp3
04-Barry_Manilow_-_Can't_Smile_Without_You = Glitter Blast
05-Barry_Manilow-Ready_to_Take_a_Chance_Again = Industrious Ferret
06-Barry_Manilow-Tryin'_to_Get_the_Feeling_Again = Le Grand Chase
07-Barry_Manilow-Could_It_Be_Magic = Nouvelle Noel
08-Barry_Manilow_-_Copacabana = Onion Capers
S2-01-Barry_Manilow-It's_a_Miracle = Teddy Bear Waltz
S2-02-Barry_Manilow-All_the_Time = Unholy Knight
S2-03-Barry_Manilow-I_Write_the_Songs = Zazie
This flaged up as an error if I didn't mark it as code
TrackBar
https://www.dropbox.com/s/i1m5zh0449385zn/Cassette%20Tapes.rar?dl=0
I have tried removing some excess code and still have to delete commented out sections that I don't need. I don't understand this enough and can not find enough information online to implement this in my own code using this just as a guide
https://www.youtube.com/watch?v=8Gi_JFAavM4
Getting MP3 info
http://forums.codeguru.com/showthread.php?409651-RESOLVED-How-to-check-the-song-playing-in-Windows-Media-Player
I can not fully remember all the forums, Youtube videos and Microsoft documents I viewed. I will try to add them if I find them as I go over my notes.
These last few links may or may not be overkill but thought worth adding encase they are useful to someone else
Also updated keywords. If they are wrong let me know and I will change them
One of the simplest languages to learn and to easily create an interface i would say is actually Visual Basic in Visual Studio, do download that and google things like "how to play audio file in VB.NET" and "how to add directories to list in VB.NET" and try to use the directories in the list (and when a song reaches it's end) just start on the next one in the list. I would use a ListBox for this. Tell me if you need more help, i would be glad to help you program it, if you need.

Add image or icon set to asset catalog to be used with NSToolbarItem

I have a set of pixel perfect icons which I want to use on toolbar (NSToolbar) of my app. Toolbar is configurable thus I need to provide icons in four sizes: small, standard, small#2x, standard#2x.
I could not find any official information about the size of those icons, but unofficial information (confirmed by my tests) is the following:
small is 24px, normal is 32px.
Thus I need to add four different images: 24x24px, 32x32px, 48x48px, 64x64px to my image set.
As for now I could not find a correct way for that.
I have tried a dozen of different methods but could not find one which preserves pixel perfect quality of all four images.
I believe, I can load right size of the image manually each time it has to be changed, but I am wondering if where is a correct way for that.
Does anyone has a good solution for that?
And yes, I clean build folder before each test.
See the Apple Developer site Human Interface guidelines for formats and sizes. The requirements are different for the different devices, and quite detailed.
For a quick & dirty solution if you're not ready to ship and just want nice looking graphics for testing, I've found that one 512 x 512 pdf, labeled "image#2x" works pretty well. You need to set the
imageScaling = .scaleProportionallyDown
and Cocoa will take care of the rest. But it's definitely not ready for prime-time.
The NSToolbar.sizeModes are enum: small and regular. Small is 24x24 and regular is 32x32; additionally the retina options allow for #2x (48x48 and 64x64) and potentially #3x future-forward.
Apple documentation on these sizes can be found here and here
Make sure to use enum Regular not "Standard", which is undocumented.

Displaying Webpages From RSS Feed in iOS Xcode

Currently, I have an RSS Feed Reader in a UITableView within a Navigation Control. I would like to click on the links and Open up a formatted page (containing all of the information from the website formatted for the iOS screen). I'm not sure if I should do this using the RSS data and a UITextView? I'm currently attempting to use UITextView in hopes that I can separate the information (title, author, body) without anything looking promising. I want to be able to move around the data and format it to my liking in the actual application itself. I read around and noted that you can include HTML and custom CSS. Would this be the way to go? I'm not quite sure how to tackle this. I want the page that opens up to be entirely scrollable (Like the IGN application or Slashgear application). Many apps for websites utilize this (and I am a bit new to this). How do they go about this? I also want to note, at some point I will like to cache the data so it may load what is already loaded without being connected to the internet. Does anyone have any ideas?
Edit:
Ok, I believe I found the correct path to go down from playing around and a lot of googling (nothing directly says what a decent way of doing this is). My particular way as of now is the route of a UIScrollView in general. Now the part I don't understand is how to divide up the long text into 'pages' for scrolling (and I am using the paging feature. This situation has led me into this question: How To Separate Strings For UIScrollView/UITextView based on the size of the frame
Ok, I believe I found the correct path to go down from playing around and a lot of googling (nothing directly says what a decent way of doing this is). My particular way as of now is the route of a UIScrollView in general. Now the part I don't understand is how to divide up the long text into 'pages' for scrolling (and I am using the paging feature. This situation has led me into this question: How To Separate Strings For UIScrollView/UITextView based on the size of the frame

Very confused by a binding issue between a Cocoa app and a Movie Loader patch in Quartz Composer

I've been programming for a while, but just recently decided to start developing for Mac OS X. I feel like I've come to grips with the basics of Objective-C and Cocoa development over the past week. I'm planning on making graphics apps, and as such am currently in the process of learning how to control Quartz compositions through a Cocoa app. I went through the tutorial that apple offers (with the Mac Engravings composition), and was able to create that just fine. In order to make sure that I truly understood what I learned, I decided to create my own composition and link it to a slightly more complicated Cocoa application.
Essentially, I have a composition that loads a movie or image through a Movie Loader patch, at which point it applies various filters to the frames before outputting it. In my Cocoa app, I've written code (or rather copied and pasted from other apple examples) that lets a user pick a file using an NSOpenPanel object. The filepath of the file they pick gets placed in a text-box that I placed in the app's window using Interface Builder. I binded the value of said text-box to the "Movie_Location" key in my composition, which is a published input in the Movie Loader patch that I'm using. However, no matter what I do, movies and images aren't loaded into this composition no matter what I try. The only thing that gets displayed is the default image that I have saved in that input from Quartz Composer (or nothing if I leave it blank before publishing).
I've added a Clear Color patch to the composition and binded that to a colorwell in my UI, and that successfully changes the color in my display, so I know that the composition and my Cocoa app are communicating. I've spent numerous hours at this point trying to figure out what's going on, and I've just about given up. Does the Movie Loader have any weird behaviors that I'm not aware of, or is there something obvious that I seem to be missing? I'd really appreciate any help or advice from anybody.
Thanks for reading through this...
Best,
Sami
There are two things I can think of as reasons why it is doing this:
The file path isn't formatted incorrectly. Try checking backslashes, colons, etc.
The box isn't updating the value. Try literally clicking in the text field and hitting enter.
That's all I can think of without seeing your quartz composition and/or code.
EDIT:
Check the other continuous box, in the general properties.
I figured this out yesterday. spudwaffle's second idea is what was going on. If I were to type a filepath in and hit enter, it would work just fine. I got this to work properly by just removing the bind and instead using the setValue:keyInPath: function that a patch controller offers. That said, is there some way to force a text-box to update? I remember seeing a "continuously update" or something like that button within the bind sub-menu in the inspector, but my code didn't work with that checked either.
Thanks to those of you that tried to help me! I really appreciate it.
Best,
Sami